|
1328 | 1328 | return parseJSONPointer(fromPointer);
|
1329 | 1329 | }
|
1330 | 1330 |
|
| 1331 | + /** |
| 1332 | + * @module Messaging |
| 1333 | + * @category Libraries |
| 1334 | + * @description |
| 1335 | + * |
| 1336 | + * An abstraction for communications between JavaScript and host platforms. |
| 1337 | + * |
| 1338 | + * 1) First you construct your platform-specific configuration (eg: {@link WebkitMessagingConfig}) |
| 1339 | + * 2) Then use that to get an instance of the Messaging utility which allows |
| 1340 | + * you to send and receive data in a unified way |
| 1341 | + * 3) Each platform implements {@link MessagingTransport} along with its own Configuration |
| 1342 | + * - For example, to learn what configuration is required for Webkit, see: {@link WebkitMessagingConfig} |
| 1343 | + * - Or, to learn about how messages are sent and received in Webkit, see {@link WebkitMessagingTransport} |
| 1344 | + * |
| 1345 | + * ## Links |
| 1346 | + * Please see the following links for examples |
| 1347 | + * |
| 1348 | + * - Windows: {@link WindowsMessagingConfig} |
| 1349 | + * - Webkit: {@link WebkitMessagingConfig} |
| 1350 | + * - Schema: {@link "Messaging Schema"} |
| 1351 | + * |
| 1352 | + */ |
| 1353 | + |
| 1354 | + /** |
| 1355 | + * Common options/config that are *not* transport specific. |
| 1356 | + */ |
| 1357 | + class MessagingContext { |
| 1358 | + /** |
| 1359 | + * @param {object} params |
| 1360 | + * @param {string} params.context |
| 1361 | + * @param {string} params.featureName |
| 1362 | + * @param {"production" | "development"} params.env |
| 1363 | + * @internal |
| 1364 | + */ |
| 1365 | + constructor (params) { |
| 1366 | + this.context = params.context; |
| 1367 | + this.featureName = params.featureName; |
| 1368 | + this.env = params.env; |
| 1369 | + } |
| 1370 | + } |
| 1371 | + |
1331 | 1372 | /**
|
1332 | 1373 | * @typedef {object} AssetConfig
|
1333 | 1374 | * @property {string} regularFontUrl
|
|
1351 | 1392 | #documentOriginIsTracker
|
1352 | 1393 | /** @type {Record<string, unknown> | undefined} */
|
1353 | 1394 | #bundledfeatureSettings
|
| 1395 | + /** @type {MessagingContext} */ |
| 1396 | + #messagingContext |
1354 | 1397 |
|
1355 | 1398 | /** @type {{ debug?: boolean, featureSettings?: Record<string, unknown>, assets?: AssetConfig | undefined, site: Site } | null} */
|
1356 | 1399 | #args
|
|
1405 | 1448 | return this.#bundledConfig
|
1406 | 1449 | }
|
1407 | 1450 |
|
| 1451 | + /** |
| 1452 | + * @returns {MessagingContext} |
| 1453 | + */ |
| 1454 | + get messagingContext () { |
| 1455 | + if (this.#messagingContext) return this.#messagingContext |
| 1456 | + this.#messagingContext = new MessagingContext({ |
| 1457 | + context: 'contentScopeScripts', |
| 1458 | + featureName: this.name, |
| 1459 | + env: this.isDebug ? 'development' : 'production' |
| 1460 | + }); |
| 1461 | + return this.#messagingContext |
| 1462 | + } |
| 1463 | + |
1408 | 1464 | /**
|
1409 | 1465 | * Get the value of a config setting.
|
1410 | 1466 | * If the value is not set, return the default value.
|
|
0 commit comments