@glomex/integration-web-component 1.1544.1 → 1.1545.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -2
- package/dist/index.d.ts +52 -2805
- package/dist/index.js +73 -1
- package/package.json +8 -11
package/dist/index.js
CHANGED
|
@@ -1 +1,73 @@
|
|
|
1
|
-
|
|
1
|
+
export * from '@turbo-player/integration-web-component';
|
|
2
|
+
import { ComponentName as BaseComponentName, createIntegrationClient } from '@turbo-player/integration-web-component';
|
|
3
|
+
export const ComponentName = {
|
|
4
|
+
...BaseComponentName,
|
|
5
|
+
INTEGRATION: 'glomex-integration'
|
|
6
|
+
};
|
|
7
|
+
const glomexClient = createIntegrationClient({
|
|
8
|
+
moduleUrl: 'https://player.glomex.com/integration/1/integration.js',
|
|
9
|
+
tagName: 'glomex-integration',
|
|
10
|
+
stylesUrl: 'https://player.glomex.com/variant/{id}/variant.css'
|
|
11
|
+
});
|
|
12
|
+
// =============================================================================
|
|
13
|
+
// Public API
|
|
14
|
+
// =============================================================================
|
|
15
|
+
/** Returns the CSS URL for a given integration */
|
|
16
|
+
export function getIntegrationCssUrl(integrationId) {
|
|
17
|
+
return glomexClient.getCssUrl(integrationId);
|
|
18
|
+
}
|
|
19
|
+
/** Returns the custom element name. */
|
|
20
|
+
export function getIntegrationComponentName() {
|
|
21
|
+
return glomexClient.getComponentName();
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Loads the integration custom element by injecting the script into the document.
|
|
25
|
+
* Does nothing if the element is already defined.
|
|
26
|
+
*/
|
|
27
|
+
export function loadIntegrationComponent() {
|
|
28
|
+
glomexClient.loadComponent();
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Loads the variant CSS for the given integration ID by injecting a
|
|
32
|
+
* `<link>` element into the document head. Does nothing if the stylesheet
|
|
33
|
+
* is already loaded.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```ts
|
|
37
|
+
* import { loadIntegrationStyles } from '@glomex/integration-web-component';
|
|
38
|
+
*
|
|
39
|
+
* loadIntegrationStyles('your-integration-id');
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export function loadIntegrationStyles(integrationId, doc) {
|
|
43
|
+
glomexClient.loadStyles(integrationId, doc);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Returns the {@link SharedContext} singleton from the loaded integration.
|
|
47
|
+
*
|
|
48
|
+
* Waits for the integration custom element to be defined, then
|
|
49
|
+
* reads the singleton from its static property — guaranteeing the same
|
|
50
|
+
* instance that the running player uses.
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```ts
|
|
54
|
+
* import { getSharedContext } from '@glomex/integration-web-component';
|
|
55
|
+
*
|
|
56
|
+
* const sharedContext = await getSharedContext();
|
|
57
|
+
* sharedContext.set({
|
|
58
|
+
* appVersion: '2.3.0',
|
|
59
|
+
* providers: {
|
|
60
|
+
* 'my-provider': async () => ({ token: await myAuth.getFreshToken() }),
|
|
61
|
+
* }
|
|
62
|
+
* });
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
export async function getSharedContext() {
|
|
66
|
+
const componentName = glomexClient.getComponentName();
|
|
67
|
+
await customElements.whenDefined(componentName);
|
|
68
|
+
const ctor = customElements.get(componentName);
|
|
69
|
+
if (!ctor?.sharedContext) {
|
|
70
|
+
throw new Error(`sharedContext not available on ${componentName} element`);
|
|
71
|
+
}
|
|
72
|
+
return ctor.sharedContext;
|
|
73
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@glomex/integration-web-component",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1545.1",
|
|
4
4
|
"description": "Web component and types to integrate the glomex player",
|
|
5
5
|
"documentation": "https://docs.glomex.com",
|
|
6
6
|
"homepage": "https://glomex.com",
|
|
@@ -24,24 +24,21 @@
|
|
|
24
24
|
],
|
|
25
25
|
"scripts": {
|
|
26
26
|
"prepack": "npm run build",
|
|
27
|
-
"build": "rm -rf dist &&
|
|
28
|
-
"build:ts": "tsc --build --force",
|
|
29
|
-
"build:rslib": "rslib build",
|
|
27
|
+
"build": "rm -rf dist && tsc --build --force",
|
|
30
28
|
"lint": "tsc --noEmit && biome ci",
|
|
31
|
-
"watch": "
|
|
29
|
+
"watch": "tsc --build --watch"
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"@turbo-player/integration-web-component": "1.1545.1"
|
|
32
33
|
},
|
|
33
34
|
"devDependencies": {
|
|
34
35
|
"@biomejs/biome": "catalog:",
|
|
35
|
-
"@glomex/
|
|
36
|
-
"@glomex/turbo-shared-types": "1.1543.0",
|
|
37
|
-
"@microsoft/api-extractor": "catalog:",
|
|
38
|
-
"@rslib/core": "catalog:",
|
|
39
|
-
"npm-run-all": "catalog:",
|
|
36
|
+
"@glomex/turbo-shared-types": "1.1545.1",
|
|
40
37
|
"typescript": "catalog:"
|
|
41
38
|
},
|
|
42
39
|
"publishConfig": {
|
|
43
40
|
"access": "public"
|
|
44
41
|
},
|
|
45
42
|
"license": "MIT",
|
|
46
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "809a199d4ac2da3879924b43be9df0fa086b206c"
|
|
47
44
|
}
|