@pie-players/pie-players-shared 0.3.46 → 0.3.48
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 +30 -0
- package/dist/i18n/simple-i18n.js.map +1 -1
- package/dist/instrumentation/debug-panel-stream.js.map +1 -1
- package/dist/instrumentation/providers/CompositeInstrumentationProvider.js.map +1 -1
- package/dist/instrumentation/providers/DebugPanelInstrumentationProvider.js +2 -1
- package/dist/instrumentation/providers/DebugPanelInstrumentationProvider.js.map +1 -1
- package/dist/loaders/ElementLoader.js +2 -1
- package/dist/loaders/ElementLoader.js.map +1 -1
- package/dist/loaders/element-loader.js +28 -4
- package/dist/loaders/element-loader.js.map +1 -1
- package/dist/loaders/esm-adapter.d.ts +22 -5
- package/dist/loaders/esm-adapter.js +320 -60
- package/dist/loaders/esm-adapter.js.map +1 -1
- package/dist/loaders/iife-adapter.js +1 -2
- package/dist/loaders/iife-adapter.js.map +1 -1
- package/dist/loaders/index.d.ts +1 -1
- package/dist/loaders/index.js.map +1 -1
- package/dist/pie/authoring.js +4 -2
- package/dist/pie/authoring.js.map +1 -1
- package/dist/pie/config.js +4 -1
- package/dist/pie/config.js.map +1 -1
- package/dist/pie/configure-initialization.js.map +1 -1
- package/dist/pie/correct-response-env.js.map +1 -1
- package/dist/pie/index.d.ts +1 -1
- package/dist/pie/index.js +1 -1
- package/dist/pie/index.js.map +1 -1
- package/dist/pie/initialization.js.map +1 -1
- package/dist/pie/instrumentation-event-bridge.js.map +1 -1
- package/dist/pie/instrumentation-event-map.js.map +1 -1
- package/dist/pie/instrumentation-provider-resolution.js.map +1 -1
- package/dist/pie/item-controller-storage.js.map +1 -1
- package/dist/pie/item-controller.d.ts +15 -0
- package/dist/pie/item-controller.js +22 -2
- package/dist/pie/item-controller.js.map +1 -1
- package/dist/pie/item-session-contract.d.ts +1 -0
- package/dist/pie/item-session-contract.js +28 -13
- package/dist/pie/item-session-contract.js.map +1 -1
- package/dist/pie/math-rendering.js.map +1 -1
- package/dist/pie/overrides.js +2 -1
- package/dist/pie/overrides.js.map +1 -1
- package/dist/pie/resource-monitor.js.map +1 -1
- package/dist/pie/stage-tracker.js.map +1 -1
- package/dist/pie/types.d.ts +7 -0
- package/dist/pie/types.js.map +1 -1
- package/dist/pie/updates.d.ts +3 -3
- package/dist/pie/updates.js +39 -18
- package/dist/pie/updates.js.map +1 -1
- package/dist/security/sanitize-item-markup.js.map +1 -1
- package/dist/security/wrap-overwide-images.js +1 -2
- package/dist/security/wrap-overwide-images.js.map +1 -1
- package/dist/security/wrap-overwide-tables.js +1 -2
- package/dist/security/wrap-overwide-tables.js.map +1 -1
- package/dist/server/npm-registry.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -25,6 +25,36 @@ Supported subpaths are declared in `package.json`:
|
|
|
25
25
|
- `@pie-players/pie-players-shared/server/npm-registry`
|
|
26
26
|
- `@pie-players/pie-players-shared/i18n`
|
|
27
27
|
|
|
28
|
+
## Browser ESM Element Contract
|
|
29
|
+
|
|
30
|
+
The canonical producer-side contract lives in
|
|
31
|
+
`pie-elements-ng/docs/PIE_ELEMENT_CONTRACT.md`. The loader assumptions here must
|
|
32
|
+
stay aligned with that document.
|
|
33
|
+
|
|
34
|
+
The ESM element loader consumes static `@pie-element/*` browser entries such as
|
|
35
|
+
`dist/browser/delivery/index.js`; it does not transform element packages through
|
|
36
|
+
CDN `+esm` entry points. Browser ESM elements must publish exact shared runtime
|
|
37
|
+
metadata in `package.json` under `pie.browserSharedDependencies`.
|
|
38
|
+
|
|
39
|
+
jsDelivr is the default npm CDN provider. Hosts can opt into `esm.sh` with
|
|
40
|
+
`loaderOptions.esmCdnProvider = "esm.sh"` and `loaderOptions.esmCdnUrl =
|
|
41
|
+
"https://esm.sh"`. For `esm.sh`, PIE package artifacts are loaded from
|
|
42
|
+
`raw.esm.sh` while shared browser dependencies are loaded from `esm.sh`.
|
|
43
|
+
Provider names are open-ended: custom/internal providers can pass their own name
|
|
44
|
+
when they follow the jsDelivr-compatible package-file URL layout, or pass a
|
|
45
|
+
provider object when package artifacts and shared dependencies need different
|
|
46
|
+
route builders.
|
|
47
|
+
|
|
48
|
+
`dependencies` and `peerDependencies` are not used as fallback runtime contracts.
|
|
49
|
+
If multiple elements request different minor or patch versions of a shared
|
|
50
|
+
singleton such as React, the loader chooses the highest same-major version and
|
|
51
|
+
emits console plus instrumentation warnings. Different major versions fail the
|
|
52
|
+
load and are also reported through console and instrumentation.
|
|
53
|
+
|
|
54
|
+
Preloaded mode means the host has already registered the expected custom element
|
|
55
|
+
tag; it is not a separate package format. IIFE mode remains supported through the
|
|
56
|
+
same package exports and controller compatibility shim used by legacy builders.
|
|
57
|
+
|
|
28
58
|
## Related Documentation
|
|
29
59
|
|
|
30
60
|
- [PIE utilities README](src/pie/README.md)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"simple-i18n.js","sourceRoot":"","sources":["../../src/i18n/simple-i18n.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH;;GAEG;AACH,MAAM,OAAO,UAAU;IACd,MAAM,GAAW,IAAI,CAAC;IACtB,cAAc,GAAW,IAAI,CAAC;IAC9B,SAAS,GAAkB,KAAK,CAAC;IACjC,YAAY,GAAG,IAAI,GAAG,EAA6B,CAAC;IACpD,SAAS,GAAG,IAAI,GAAG,EAAc,CAAC;IAClC,eAAe,GAAG,IAAI,GAAG,EAAyB,CAAC;IACnD,MAAM,CAAa;IAE3B,YAAY,SAAqB,EAAE;QAClC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,cAAc,GAAG,MAAM,CAAC,cAAc,IAAI,IAAI,CAAC;QAEpD,4BAA4B;QAC5B,IAAI,MAAM,CAAC,mBAAmB,EAAE,CAAC;YAChC,KAAK,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,MAAM,CAAC,OAAO,CAC5C,MAAM,CAAC,mBAAmB,CAC1B,EAAE,CAAC;g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AC,MAAM,CAAC,KAAK,CAAC,CAAC;gBACrC,OAAO,QAAmC,CAAC;YAC5C,CAAC;YAAC,MAAM,CAAC;gBACR,+BAA+B;YAChC,CAAC;QACF,CAAC;QAED,2BAA2B;QAC3B,IAAI,KAAK,KAAK,CAAC;YAAE,OAAO,MAAM,CAAC;QAC/B,IAAI,KAAK,KAAK,CAAC;YAAE,OAAO,KAAK,CAAC;QAC9B,OAAO,OAAO,CAAC;IAChB,CAAC;IAEO,mBAAmB;QAC1B,IAAI,OAAO,SAAS,KAAK,WAAW;YAAE,OAAO,IAAI,CAAC;QAElD,MAAM,WAAW,GAChB,SAAS,CAAC,QAAQ;YAClB,CAAC,SAAS,CAAC,SAAS,IAAI,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;YAC/C,IAAI,CAAC;QAEN,OAAO,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IAClC,CAAC;CACD","sourcesContent":["/**\n * Simple I18n Implementation\n *\n * Lightweight i18n without external dependencies.\n * Used for standalone components that don't need the full service architecture.\n */\n\nimport type { I18nConfig, PluralTranslation, TranslationBundle } from \"./types.js\";\n\n/**\n * Simple I18n class for standalone use\n */\nexport class SimpleI18n {\n\tprivate locale: string = \"en\";\n\tprivate fallbackLocale: string = \"en\";\n\tprivate direction: \"ltr\" | \"rtl\" = \"ltr\";\n\tprivate translations = new Map<string, TranslationBundle>();\n\tprivate listeners = new Set<() => void>();\n\tprivate loadingPromises = new Map<string, Promise<void>>();\n\tprivate config: I18nConfig;\n\n\tconstructor(config: I18nConfig = {}) {\n\t\tthis.config = config;\n\t\tthis.fallbackLocale = config.fallbackLocale || \"en\";\n\n\t\t// Load bundled translations\n\t\tif (config.bundledTranslations) {\n\t\t\tfor (const [locale, bundle] of Object.entries(\n\t\t\t\tconfig.bundledTranslations,\n\t\t\t)) {\n\t\t\t\tthis.translations.set(locale, bundle);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Initialize with locale\n\t */\n\tasync initialize(config: I18nConfig): Promise<void> {\n\t\tObject.assign(this.config, config);\n\n\t\tconst locale = config.locale || this.detectBrowserLocale();\n\t\tawait this.setLocale(locale);\n\t}\n\n\t/**\n\t * Translate a key\n\t */\n\tt(key: string, params?: Record<string, any>): string {\n\t\tconst translation = this.getTranslation(key);\n\t\treturn this.interpolate(translation as string, params);\n\t}\n\n\t/**\n\t * Translate with pluralization\n\t */\n\ttn(key: string, count: number, params?: Record<string, any>): string {\n\t\tconst translation = this.getTranslation(key);\n\n\t\tif (typeof translation === \"object\") {\n\t\t\tconst pluralForm = this.selectPluralForm(count, this.locale);\n\t\t\tconst text = translation[pluralForm] || translation.other;\n\t\t\treturn this.interpolate(text, { ...params, count });\n\t\t}\n\n\t\treturn this.interpolate(translation as string, { ...params, count });\n\t}\n\n\t/**\n\t * Get current locale\n\t */\n\tgetLocale(): string {\n\t\treturn this.locale;\n\t}\n\n\t/**\n\t * Change locale\n\t */\n\tasync setLocale(locale: string): Promise<void> {\n\t\t// Check if already loading\n\t\tif (this.loadingPromises.has(locale)) {\n\t\t\tawait this.loadingPromises.get(locale);\n\t\t\treturn;\n\t\t}\n\n\t\t// Check if already loaded\n\t\tif (this.translations.has(locale)) {\n\t\t\tthis.applyLocale(locale);\n\t\t\treturn;\n\t\t}\n\n\t\t// Load translations\n\t\tconst loadingPromise = this.loadTranslationsForLocale(locale);\n\t\tthis.loadingPromises.set(locale, loadingPromise);\n\n\t\ttry {\n\t\t\tawait loadingPromise;\n\t\t\tthis.applyLocale(locale);\n\t\t} finally {\n\t\t\tthis.loadingPromises.delete(locale);\n\t\t}\n\t}\n\n\t/**\n\t * Get current direction\n\t */\n\tgetDirection(): \"ltr\" | \"rtl\" {\n\t\treturn this.direction;\n\t}\n\n\t/**\n\t * Get available locales\n\t */\n\tgetAvailableLocales(): string[] {\n\t\treturn Array.from(this.translations.keys());\n\t}\n\n\t/**\n\t * Check if locale is loaded\n\t */\n\tisLocaleLoaded(locale: string): boolean {\n\t\treturn this.translations.has(locale);\n\t}\n\n\t/**\n\t * Subscribe to changes\n\t */\n\tsubscribe(listener: () => void): () => void {\n\t\tthis.listeners.add(listener);\n\t\treturn () => {\n\t\t\tthis.listeners.delete(listener);\n\t\t};\n\t}\n\n\t/**\n\t * Check if key exists\n\t */\n\thasKey(key: string): boolean {\n\t\tconst bundle = this.translations.get(this.locale);\n\t\treturn !!bundle?.translations[key];\n\t}\n\n\tprivate notifyListeners(): void {\n\t\tfor (const listener of this.listeners) {\n\t\t\tlistener();\n\t\t}\n\t}\n\n\tprivate applyLocale(locale: string): void {\n\t\tconst bundle = this.translations.get(locale);\n\t\tif (!bundle) return;\n\n\t\tthis.locale = locale;\n\t\tthis.direction = bundle.direction;\n\n\t\tthis.applyDOMDirection();\n\t\tthis.notifyListeners();\n\t}\n\n\tprivate applyDOMDirection(): void {\n\t\tif (typeof document === \"undefined\") return;\n\n\t\tdocument.documentElement.setAttribute(\"dir\", this.direction);\n\t\tdocument.documentElement.setAttribute(\"lang\", this.locale);\n\t}\n\n\tprivate async loadTranslationsForLocale(locale: string): Promise<void> {\n\t\tif (!this.config.loadTranslations) {\n\t\t\tthrow new Error(`No translation loader configured for locale: ${locale}`);\n\t\t}\n\n\t\tconst bundle = await this.config.loadTranslations(locale);\n\t\tthis.translations.set(locale, bundle);\n\t}\n\n\tprivate getTranslation(key: string): string | PluralTranslation {\n\t\t// Try current locale\n\t\tconst currentBundle = this.translations.get(this.locale);\n\t\tif (currentBundle?.translations[key]) {\n\t\t\treturn currentBundle.translations[key];\n\t\t}\n\n\t\t// Try fallback locale\n\t\tconst fallbackBundle = this.translations.get(this.fallbackLocale);\n\t\tif (fallbackBundle?.translations[key]) {\n\t\t\treturn fallbackBundle.translations[key];\n\t\t}\n\n\t\t// Missing key\n\t\tif (this.config.onMissingKey) {\n\t\t\tthis.config.onMissingKey(key, this.locale);\n\t\t}\n\n\t\treturn key;\n\t}\n\n\tprivate interpolate(text: string, params?: Record<string, any>): string {\n\t\tif (!params) return text;\n\n\t\treturn text.replace(/\\{(\\w+)\\}/g, (match, key) => {\n\t\t\treturn params[key]?.toString() || match;\n\t\t});\n\t}\n\n\tprivate selectPluralForm(\n\t\tcount: number,\n\t\tlocale: string,\n\t): keyof PluralTranslation {\n\t\t// Use Intl.PluralRules if available\n\t\tif (typeof Intl !== \"undefined\" && Intl.PluralRules) {\n\t\t\ttry {\n\t\t\t\tconst rules = new Intl.PluralRules(locale);\n\t\t\t\tconst category = rules.select(count);\n\t\t\t\treturn category as keyof PluralTranslation;\n\t\t\t} catch {\n\t\t\t\t// Fall through to simple rules\n\t\t\t}\n\t\t}\n\n\t\t// Fallback to simple rules\n\t\tif (count === 0) return \"zero\";\n\t\tif (count === 1) return \"one\";\n\t\treturn \"other\";\n\t}\n\n\tprivate detectBrowserLocale(): string {\n\t\tif (typeof navigator === \"undefined\") return \"en\";\n\n\t\tconst browserLang =\n\t\t\tnavigator.language ||\n\t\t\t(navigator.languages && navigator.languages[0]) ||\n\t\t\t\"en\";\n\n\t\treturn browserLang.split(\"-\")[0];\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"simple-i18n.js","sourceRoot":"","sources":["../../src/i18n/simple-i18n.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAQH;;GAEG;AACH,MAAM,OAAO,UAAU;IACd,MAAM,GAAW,IAAI,CAAC;IACtB,cAAc,GAAW,IAAI,CAAC;IAC9B,SAAS,GAAkB,KAAK,CAAC;IACjC,YAAY,GAAG,IAAI,GAAG,EAA6B,CAAC;IACpD,SAAS,GAAG,IAAI,GAAG,EAAc,CAAC;IAClC,eAAe,GAAG,IAAI,GAAG,EAAyB,CAAC;IACnD,MAAM,CAAa;IAE3B,YAAY,SAAqB,EAAE;QAClC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,cAAc,GAAG,MAAM,CAAC,cAAc,IAAI,IAAI,CAAC;QAEpD,4BAA4B;QAC5B,IAAI,MAA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AC,WAAW,EAAE,CAAC;YACrD,IAAI,CAAC;gBACJ,MAAM,KAAK,GAAG,IAAI,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;gBAC3C,MAAM,QAAQ,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;gBACrC,OAAO,QAAmC,CAAC;YAC5C,CAAC;YAAC,MAAM,CAAC;gBACR,+BAA+B;YAChC,CAAC;QACF,CAAC;QAED,2BAA2B;QAC3B,IAAI,KAAK,KAAK,CAAC;YAAE,OAAO,MAAM,CAAC;QAC/B,IAAI,KAAK,KAAK,CAAC;YAAE,OAAO,KAAK,CAAC;QAC9B,OAAO,OAAO,CAAC;IAChB,CAAC;IAEO,mBAAmB;QAC1B,IAAI,OAAO,SAAS,KAAK,WAAW;YAAE,OAAO,IAAI,CAAC;QAElD,MAAM,WAAW,GAChB,SAAS,CAAC,QAAQ;YAClB,CAAC,SAAS,CAAC,SAAS,IAAI,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;YAC/C,IAAI,CAAC;QAEN,OAAO,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IAClC,CAAC;CACD","sourcesContent":["/**\n * Simple I18n Implementation\n *\n * Lightweight i18n without external dependencies.\n * Used for standalone components that don't need the full service architecture.\n */\n\nimport type {\n\tI18nConfig,\n\tPluralTranslation,\n\tTranslationBundle,\n} from \"./types.js\";\n\n/**\n * Simple I18n class for standalone use\n */\nexport class SimpleI18n {\n\tprivate locale: string = \"en\";\n\tprivate fallbackLocale: string = \"en\";\n\tprivate direction: \"ltr\" | \"rtl\" = \"ltr\";\n\tprivate translations = new Map<string, TranslationBundle>();\n\tprivate listeners = new Set<() => void>();\n\tprivate loadingPromises = new Map<string, Promise<void>>();\n\tprivate config: I18nConfig;\n\n\tconstructor(config: I18nConfig = {}) {\n\t\tthis.config = config;\n\t\tthis.fallbackLocale = config.fallbackLocale || \"en\";\n\n\t\t// Load bundled translations\n\t\tif (config.bundledTranslations) {\n\t\t\tfor (const [locale, bundle] of Object.entries(\n\t\t\t\tconfig.bundledTranslations,\n\t\t\t)) {\n\t\t\t\tthis.translations.set(locale, bundle);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Initialize with locale\n\t */\n\tasync initialize(config: I18nConfig): Promise<void> {\n\t\tObject.assign(this.config, config);\n\n\t\tconst locale = config.locale || this.detectBrowserLocale();\n\t\tawait this.setLocale(locale);\n\t}\n\n\t/**\n\t * Translate a key\n\t */\n\tt(key: string, params?: Record<string, any>): string {\n\t\tconst translation = this.getTranslation(key);\n\t\treturn this.interpolate(translation as string, params);\n\t}\n\n\t/**\n\t * Translate with pluralization\n\t */\n\ttn(key: string, count: number, params?: Record<string, any>): string {\n\t\tconst translation = this.getTranslation(key);\n\n\t\tif (typeof translation === \"object\") {\n\t\t\tconst pluralForm = this.selectPluralForm(count, this.locale);\n\t\t\tconst text = translation[pluralForm] || translation.other;\n\t\t\treturn this.interpolate(text, { ...params, count });\n\t\t}\n\n\t\treturn this.interpolate(translation as string, { ...params, count });\n\t}\n\n\t/**\n\t * Get current locale\n\t */\n\tgetLocale(): string {\n\t\treturn this.locale;\n\t}\n\n\t/**\n\t * Change locale\n\t */\n\tasync setLocale(locale: string): Promise<void> {\n\t\t// Check if already loading\n\t\tif (this.loadingPromises.has(locale)) {\n\t\t\tawait this.loadingPromises.get(locale);\n\t\t\treturn;\n\t\t}\n\n\t\t// Check if already loaded\n\t\tif (this.translations.has(locale)) {\n\t\t\tthis.applyLocale(locale);\n\t\t\treturn;\n\t\t}\n\n\t\t// Load translations\n\t\tconst loadingPromise = this.loadTranslationsForLocale(locale);\n\t\tthis.loadingPromises.set(locale, loadingPromise);\n\n\t\ttry {\n\t\t\tawait loadingPromise;\n\t\t\tthis.applyLocale(locale);\n\t\t} finally {\n\t\t\tthis.loadingPromises.delete(locale);\n\t\t}\n\t}\n\n\t/**\n\t * Get current direction\n\t */\n\tgetDirection(): \"ltr\" | \"rtl\" {\n\t\treturn this.direction;\n\t}\n\n\t/**\n\t * Get available locales\n\t */\n\tgetAvailableLocales(): string[] {\n\t\treturn Array.from(this.translations.keys());\n\t}\n\n\t/**\n\t * Check if locale is loaded\n\t */\n\tisLocaleLoaded(locale: string): boolean {\n\t\treturn this.translations.has(locale);\n\t}\n\n\t/**\n\t * Subscribe to changes\n\t */\n\tsubscribe(listener: () => void): () => void {\n\t\tthis.listeners.add(listener);\n\t\treturn () => {\n\t\t\tthis.listeners.delete(listener);\n\t\t};\n\t}\n\n\t/**\n\t * Check if key exists\n\t */\n\thasKey(key: string): boolean {\n\t\tconst bundle = this.translations.get(this.locale);\n\t\treturn !!bundle?.translations[key];\n\t}\n\n\tprivate notifyListeners(): void {\n\t\tfor (const listener of this.listeners) {\n\t\t\tlistener();\n\t\t}\n\t}\n\n\tprivate applyLocale(locale: string): void {\n\t\tconst bundle = this.translations.get(locale);\n\t\tif (!bundle) return;\n\n\t\tthis.locale = locale;\n\t\tthis.direction = bundle.direction;\n\n\t\tthis.applyDOMDirection();\n\t\tthis.notifyListeners();\n\t}\n\n\tprivate applyDOMDirection(): void {\n\t\tif (typeof document === \"undefined\") return;\n\n\t\tdocument.documentElement.setAttribute(\"dir\", this.direction);\n\t\tdocument.documentElement.setAttribute(\"lang\", this.locale);\n\t}\n\n\tprivate async loadTranslationsForLocale(locale: string): Promise<void> {\n\t\tif (!this.config.loadTranslations) {\n\t\t\tthrow new Error(`No translation loader configured for locale: ${locale}`);\n\t\t}\n\n\t\tconst bundle = await this.config.loadTranslations(locale);\n\t\tthis.translations.set(locale, bundle);\n\t}\n\n\tprivate getTranslation(key: string): string | PluralTranslation {\n\t\t// Try current locale\n\t\tconst currentBundle = this.translations.get(this.locale);\n\t\tif (currentBundle?.translations[key]) {\n\t\t\treturn currentBundle.translations[key];\n\t\t}\n\n\t\t// Try fallback locale\n\t\tconst fallbackBundle = this.translations.get(this.fallbackLocale);\n\t\tif (fallbackBundle?.translations[key]) {\n\t\t\treturn fallbackBundle.translations[key];\n\t\t}\n\n\t\t// Missing key\n\t\tif (this.config.onMissingKey) {\n\t\t\tthis.config.onMissingKey(key, this.locale);\n\t\t}\n\n\t\treturn key;\n\t}\n\n\tprivate interpolate(text: string, params?: Record<string, any>): string {\n\t\tif (!params) return text;\n\n\t\treturn text.replace(/\\{(\\w+)\\}/g, (match, key) => {\n\t\t\treturn params[key]?.toString() || match;\n\t\t});\n\t}\n\n\tprivate selectPluralForm(\n\t\tcount: number,\n\t\tlocale: string,\n\t): keyof PluralTranslation {\n\t\t// Use Intl.PluralRules if available\n\t\tif (typeof Intl !== \"undefined\" && Intl.PluralRules) {\n\t\t\ttry {\n\t\t\t\tconst rules = new Intl.PluralRules(locale);\n\t\t\t\tconst category = rules.select(count);\n\t\t\t\treturn category as keyof PluralTranslation;\n\t\t\t} catch {\n\t\t\t\t// Fall through to simple rules\n\t\t\t}\n\t\t}\n\n\t\t// Fallback to simple rules\n\t\tif (count === 0) return \"zero\";\n\t\tif (count === 1) return \"one\";\n\t\treturn \"other\";\n\t}\n\n\tprivate detectBrowserLocale(): string {\n\t\tif (typeof navigator === \"undefined\") return \"en\";\n\n\t\tconst browserLang =\n\t\t\tnavigator.language ||\n\t\t\t(navigator.languages && navigator.languages[0]) ||\n\t\t\t\"en\";\n\n\t\treturn browserLang.split(\"-\")[0];\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"debug-panel-stream.js","sourceRoot":"","sources":["../../src/instrumentation/debug-panel-stream.ts"],"names":[],"mappings":"AAMA,MAAM,CAAC,MAAM,gCAAgC,GAC5C,kCAAkC,CAAC;AACpC,MAAM,iBAAiB,GAAG,GAAG,CAAC;AAoC9B,SAAS,cAAc;IACtB,IAAI,OAAO,MAAM,KAAK,WAAW;QAAE,OAAO,IAAI,CAAC;IAC/C,OAAO,MAAwB,CAAC;AACjC,CAAC;AAED,SAAS,aAAa,CAAC,WAA2B;IACjD,IAAI,CAAC,WAAW,CAAC,8BAA8B,EAAE,CAAC;QACjD,WAAW,CAAC,8BAA8B,GAAG;YAC5C,MAAM,EAAE,CAAC;YACT,OAAO,EAAE,EAAE;SACX,CAAC;IACH,CAAC;IACD,OAAO,WAAW,CAAC,8BAA8B,CAAC;AACnD,CAAC;AAED,SAAS,WAAW,
|
|
1
|
+
{"version":3,"file":"debug-panel-stream.js","sourceRoot":"","sources":["../../src/instrumentation/debug-panel-stream.ts"],"names":[],"mappings":"AAMA,MAAM,CAAC,MAAM,gCAAgC,GAC5C,kCAAkC,CAAC;AACpC,MAAM,iBAAiB,GAAG,GAAG,CAAC;AAoC9B,SAAS,cAAc;IACtB,IAAI,OAAO,MAAM,KAAK,WAAW;QAAE,OAAO,IAAI,CAAC;IAC/C,OAAO,MAAwB,CAAC;AACjC,CAAC;AAED,SAAS,aAAa,CAAC,WAA2B;IACjD,IAAI,CAAC,WAAW,CAAC,8BAA8B,EAAE,CAAC;QACjD,WAAW,CAAC,8BAA8B,GAAG;YAC5C,MAAM,EAAE,CAAC;YACT,OAAO,EAAE,EAAE;SACX,CAAC;IACH,CAAC;IACD,OAAO,WAAW,CAAC,8BAA8B,CAAC;AACnD,CAAC;AAED,SAAS,WAAW,CACnB,MAAkC;IAElC,OAAO;QACN,GAAG,MAAM;QACT,UAAU,EAAE,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,GAAG,MAAM,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,SAAS;KACpE,CAAC;AACH,CAAC;AAED,MAAM,UAAU,8BAA8B,CAC7C,MAAuC;IAEvC,MAAM,WAAW,GAAG,cAAc,EAAE,CAAC;IACrC,IAAI,CAAC,WAAW;QAAE,OAAO;IACzB,MAAM,KAAK,GAAG,aAAa,CAAC,WAAW,CAAC,CAAC;IACzC,MAAM,UAAU,GAA+B;QAC9C,GAAG,MAAM;QACT,EAAE,EAAE,KAAK,CAAC,MAAM,EAAE;KAClB,CAAC;IACF,KAAK,CAAC,OAAO,CAAC,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AU;QAC3B,YAAY,EAAE,IAAI,CAAC,YAAY;QAC/B,IAAI,EAAE,IAAI,CAAC,UAAU;QACrB,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;QACnC,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,UAAU,EAAE,IAAI,CAAC,UAAU;YAC1B,CAAC,CAAC,EAAE,GAAI,IAAI,CAAC,UAAsC,EAAE;YACrD,CAAC,CAAC,SAAS;KACZ,CAAC;AACH,CAAC","sourcesContent":["import type {\n\tErrorAttributes,\n\tEventAttributes,\n\tMetricAttributes,\n} from \"./types.js\";\n\nexport const INSTRUMENTATION_DEBUG_EVENT_NAME =\n\t\"pie-instrumentation-debug-record\";\nconst MAX_DEBUG_RECORDS = 500;\n\ntype DebugRecordKind =\n\t| \"event\"\n\t| \"error\"\n\t| \"metric\"\n\t| \"user-context\"\n\t| \"global-attributes\";\n\nexport type InstrumentationDebugRecord = {\n\tid: number;\n\tkind: DebugRecordKind;\n\tproviderId: string;\n\tproviderName: string;\n\ttimestamp: string;\n\tname: string;\n\tattributes?: Record<string, unknown>;\n\terrorMessage?: string;\n\terrorStack?: string;\n\tvalue?: number;\n};\n\nexport type InstrumentationDebugRecordInput = Omit<\n\tInstrumentationDebugRecord,\n\t\"id\"\n>;\n\ntype DebugWindowState = {\n\tnextId: number;\n\trecords: InstrumentationDebugRecord[];\n};\n\ntype PieDebugWindow = Window & {\n\t__pieInstrumentationDebugState?: DebugWindowState;\n};\n\nfunction getDebugWindow(): PieDebugWindow | null {\n\tif (typeof window === \"undefined\") return null;\n\treturn window as PieDebugWindow;\n}\n\nfunction getDebugState(debugWindow: PieDebugWindow): DebugWindowState {\n\tif (!debugWindow.__pieInstrumentationDebugState) {\n\t\tdebugWindow.__pieInstrumentationDebugState = {\n\t\t\tnextId: 1,\n\t\t\trecords: [],\n\t\t};\n\t}\n\treturn debugWindow.__pieInstrumentationDebugState;\n}\n\nfunction cloneRecord(\n\trecord: InstrumentationDebugRecord,\n): InstrumentationDebugRecord {\n\treturn {\n\t\t...record,\n\t\tattributes: record.attributes ? { ...record.attributes } : undefined,\n\t};\n}\n\nexport function emitInstrumentationDebugRecord(\n\trecord: InstrumentationDebugRecordInput,\n): void {\n\tconst debugWindow = getDebugWindow();\n\tif (!debugWindow) return;\n\tconst state = getDebugState(debugWindow);\n\tconst nextRecord: InstrumentationDebugRecord = {\n\t\t...record,\n\t\tid: state.nextId++,\n\t};\n\tstate.records.push(nextRecord);\n\tif (state.records.length > MAX_DEBUG_RECORDS) {\n\t\tstate.records.splice(0, state.records.length - MAX_DEBUG_RECORDS);\n\t}\n\tdebugWindow.dispatchEvent(\n\t\tnew CustomEvent<InstrumentationDebugRecord>(\n\t\t\tINSTRUMENTATION_DEBUG_EVENT_NAME,\n\t\t\t{\n\t\t\t\tdetail: cloneRecord(nextRecord),\n\t\t\t},\n\t\t),\n\t);\n}\n\nexport function getBufferedInstrumentationDebugRecords(): InstrumentationDebugRecord[] {\n\tconst debugWindow = getDebugWindow();\n\tif (!debugWindow) return [];\n\tconst state = getDebugState(debugWindow);\n\treturn state.records.map(cloneRecord);\n}\n\nexport function clearBufferedInstrumentationDebugRecords(): void {\n\tconst debugWindow = getDebugWindow();\n\tif (!debugWindow) return;\n\tconst state = getDebugState(debugWindow);\n\tstate.records = [];\n}\n\nexport function subscribeInstrumentationDebugRecords(args: {\n\tlistener: (record: InstrumentationDebugRecord) => void;\n\treplayBuffered?: boolean;\n}): () => void {\n\tconst debugWindow = getDebugWindow();\n\tif (!debugWindow) return () => {};\n\n\tif (args.replayBuffered !== false) {\n\t\tconst records = getBufferedInstrumentationDebugRecords();\n\t\tfor (const record of records) {\n\t\t\targs.listener(record);\n\t\t}\n\t}\n\n\tconst onDebugRecord = (event: Event) => {\n\t\tconst customEvent = event as CustomEvent<InstrumentationDebugRecord>;\n\t\tif (!customEvent.detail) return;\n\t\targs.listener(cloneRecord(customEvent.detail));\n\t};\n\tdebugWindow.addEventListener(INSTRUMENTATION_DEBUG_EVENT_NAME, onDebugRecord);\n\treturn () => {\n\t\tdebugWindow.removeEventListener(\n\t\t\tINSTRUMENTATION_DEBUG_EVENT_NAME,\n\t\t\tonDebugRecord,\n\t\t);\n\t};\n}\n\nexport function createEventDebugRecord(args: {\n\tproviderId: string;\n\tproviderName: string;\n\teventName: string;\n\tattributes: EventAttributes;\n}): InstrumentationDebugRecordInput {\n\treturn {\n\t\tkind: \"event\",\n\t\tproviderId: args.providerId,\n\t\tproviderName: args.providerName,\n\t\tname: args.eventName,\n\t\ttimestamp: new Date().toISOString(),\n\t\tattributes: { ...(args.attributes as Record<string, unknown>) },\n\t};\n}\n\nexport function createErrorDebugRecord(args: {\n\tproviderId: string;\n\tproviderName: string;\n\terror: Error;\n\tattributes: ErrorAttributes;\n}): InstrumentationDebugRecordInput {\n\treturn {\n\t\tkind: \"error\",\n\t\tproviderId: args.providerId,\n\t\tproviderName: args.providerName,\n\t\tname: args.attributes.errorType || \"unknown-error\",\n\t\ttimestamp: new Date().toISOString(),\n\t\tattributes: { ...(args.attributes as Record<string, unknown>) },\n\t\terrorMessage: args.error?.message || \"Unknown error\",\n\t\terrorStack: args.error?.stack,\n\t};\n}\n\nexport function createMetricDebugRecord(args: {\n\tproviderId: string;\n\tproviderName: string;\n\tmetricName: string;\n\tvalue: number;\n\tattributes?: MetricAttributes;\n}): InstrumentationDebugRecordInput {\n\treturn {\n\t\tkind: \"metric\",\n\t\tproviderId: args.providerId,\n\t\tproviderName: args.providerName,\n\t\tname: args.metricName,\n\t\ttimestamp: new Date().toISOString(),\n\t\tvalue: args.value,\n\t\tattributes: args.attributes\n\t\t\t? { ...(args.attributes as Record<string, unknown>) }\n\t\t\t: undefined,\n\t};\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CompositeInstrumentationProvider.js","sourceRoot":"","sources":["../../../src/instrumentation/providers/CompositeInstrumentationProvider.ts"],"names":[],"mappings":"AAQA,MAAM,OAAO,gCAAgC;
|
|
1
|
+
{"version":3,"file":"CompositeInstrumentationProvider.js","sourceRoot":"","sources":["../../../src/instrumentation/providers/CompositeInstrumentationProvider.ts"],"names":[],"mappings":"AAQA,MAAM,OAAO,gCAAgC;IAGnC,UAAU,GAAG,WAAW,CAAC;IACzB,YAAY,GAAG,oBAAoB,CAAC;IAErC,WAAW,GAAG,KAAK,CAAC;IACX,SAAS,CAA4B;IAEtD,YAAY,SAAoC;QAC/C,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAC5C,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,MAA8B;QAC9C,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,UAAU,CACvC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAC7D,CAAC;QACF,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;QACxB,IAAI,MAAM,EAAE,KAAK,EAAE,CAAC;YACnB,KAAK,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,IAAI,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC;gBACjD,IAAI,MAAM,CAAC,MAAM,KAAK,UAAU,EAAE,CAAC;oBAClC,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;oBACvC,OAAO,CAAC,IAAI,CACX,4CAA4C,QAAQ,EAAE,YAAY,IAAI,SAAS,KAAK,QAAQ,EAAE,UAAU,IAAI,SAAS,GAAG,EACxH,MAAM,CAAC,MAAM,CACb,CAAC;gBACH,CAAC;YACF,CAAC;QACF,CAAC;IACF,CAAC;IAED,OAAO;QACN,IAAI,CAAC,IAAI,CAAC,WAAW;YAAE,OAAO,KAAK,CAAC;QACpC,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE;YACvC,IAAI,CAAC;gBACJ,OAAO,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CACjC,QAAQ,CAAC,cAAc,EAAE,CAAC,MAAM,EAAE,UAAU,CAAC,CAC7C,CAAC;IACH,CAAC;IAED,mBAAmB,CAAC,UAA+B;QAClD,IAAI,CAAC,eAAe,CAAC,CAAC,QAAQ,EAAE,EAAE,CACjC,QAAQ,CAAC,mBAAmB,EAAE,CAAC,UAAU,CAAC,CAC1C,CAAC;IACH,CAAC;IAEO,eAAe,CACtB,QAAqD;QAErD,IAAI,CAAC,IAAI,CAAC,WAAW;YAAE,OAAO;QAC9B,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACvC,IAAI,CAAC;gBACJ,QAAQ,CAAC,QAAQ,CAAC,CAAC;YACpB,CAAC;YAAC,MAAM,CAAC;gBACR,uBAAuB;YACxB,CAAC;QACF,CAAC;IACF,CAAC;CACD","sourcesContent":["import type {\n\tErrorAttributes,\n\tEventAttributes,\n\tInstrumentationConfig,\n\tInstrumentationProvider,\n\tMetricAttributes,\n} from \"../types.js\";\n\nexport class CompositeInstrumentationProvider\n\timplements InstrumentationProvider\n{\n\treadonly providerId = \"composite\";\n\treadonly providerName = \"Composite Provider\";\n\n\tprivate initialized = false;\n\tprivate readonly providers: InstrumentationProvider[];\n\n\tconstructor(providers: InstrumentationProvider[]) {\n\t\tthis.providers = providers.filter(Boolean);\n\t}\n\n\tasync initialize(config?: InstrumentationConfig): Promise<void> {\n\t\tconst results = await Promise.allSettled(\n\t\t\tthis.providers.map((provider) => provider.initialize(config)),\n\t\t);\n\t\tthis.initialized = true;\n\t\tif (config?.debug) {\n\t\t\tfor (const [index, result] of results.entries()) {\n\t\t\t\tif (result.status === \"rejected\") {\n\t\t\t\t\tconst provider = this.providers[index];\n\t\t\t\t\tconsole.warn(\n\t\t\t\t\t\t`[CompositeProvider] Failed to initialize ${provider?.providerName || \"unknown\"} (${provider?.providerId || \"unknown\"})`,\n\t\t\t\t\t\tresult.reason,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tisReady(): boolean {\n\t\tif (!this.initialized) return false;\n\t\treturn this.providers.some((provider) => {\n\t\t\ttry {\n\t\t\t\treturn provider.isReady();\n\t\t\t} catch {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t});\n\t}\n\n\tdestroy(): void {\n\t\tthis.initialized = false;\n\t\tfor (const provider of this.providers) {\n\t\t\ttry {\n\t\t\t\tprovider.destroy();\n\t\t\t} catch {\n\t\t\t\t// Best effort: a broken child provider should not block others.\n\t\t\t}\n\t\t}\n\t}\n\n\ttrackError(error: Error, attributes: ErrorAttributes): void {\n\t\tthis.forEachProvider((provider) => provider.trackError(error, attributes));\n\t}\n\n\ttrackEvent(eventName: string, attributes: EventAttributes): void {\n\t\tthis.forEachProvider((provider) =>\n\t\t\tprovider.trackEvent(eventName, attributes),\n\t\t);\n\t}\n\n\ttrackMetric(\n\t\tmetricName: string,\n\t\tvalue: number,\n\t\tattributes?: MetricAttributes,\n\t): void {\n\t\tthis.forEachProvider((provider) => {\n\t\t\tif (provider.trackMetric) {\n\t\t\t\tprovider.trackMetric(metricName, value, attributes);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tprovider.trackEvent(`metric:${metricName}`, {\n\t\t\t\t...(attributes as Record<string, unknown>),\n\t\t\t\tmetricName,\n\t\t\t\tmetricValue: value,\n\t\t\t});\n\t\t});\n\t}\n\n\tsetUserContext(userId: string, attributes?: Record<string, any>): void {\n\t\tthis.forEachProvider((provider) =>\n\t\t\tprovider.setUserContext?.(userId, attributes),\n\t\t);\n\t}\n\n\tsetGlobalAttributes(attributes: Record<string, any>): void {\n\t\tthis.forEachProvider((provider) =>\n\t\t\tprovider.setGlobalAttributes?.(attributes),\n\t\t);\n\t}\n\n\tprivate forEachProvider(\n\t\tcallback: (provider: InstrumentationProvider) => void,\n\t): void {\n\t\tif (!this.initialized) return;\n\t\tfor (const provider of this.providers) {\n\t\t\ttry {\n\t\t\t\tcallback(provider);\n\t\t\t} catch {\n\t\t\t\t// Best effort fan-out.\n\t\t\t}\n\t\t}\n\t}\n}\n"]}
|
|
@@ -32,7 +32,8 @@ export class DebugPanelInstrumentationProvider extends BaseInstrumentationProvid
|
|
|
32
32
|
return;
|
|
33
33
|
}
|
|
34
34
|
const rawMetricValue = attributes.metricValue;
|
|
35
|
-
if (typeof rawMetricValue !== "number" ||
|
|
35
|
+
if (typeof rawMetricValue !== "number" ||
|
|
36
|
+
!Number.isFinite(rawMetricValue)) {
|
|
36
37
|
return;
|
|
37
38
|
}
|
|
38
39
|
const metricName = typeof attributes.metricName === "string" && attributes.metricName
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DebugPanelInstrumentationProvider.js","sourceRoot":"","sources":["../../../src/instrumentation/providers/DebugPanelInstrumentationProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,sBAAsB,EACtB,sBAAsB,EACtB,uBAAuB,EACvB,8BAA8B,GAC9B,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAE/E,MAAM,OAAO,iCAAkC,SAAQ,2BAA2B;IACxE,UAAU,GAAG,aAAa,CAAC;IAC3B,YAAY,GAAG,aAAa,CAAC;IAEtC,KAAK,CAAC,UAAU,CAAC,MAA8B;QAC9C,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;IACzB,CAAC;IAED,OAAO;QACN,OAAO,IAAI,CAAC,WAAW,CAAC;IACzB,CAAC;IAED,OAAO;QACN,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC;IAC1B,CAAC;IAES,YAAY,CAAC,KAAY,EAAE,UAA+B;QACnE,8BAA8B,CAC7B,sBAAsB,CAAC;YACtB,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,YAAY,EAAE,IAAI,CAAC,YAAY;YAC/B,KAAK;YACL,UAAU,EAAE,UAA6B;SACzC,CAAC,CACF,CAAC;IACH,CAAC;IAES,YAAY,CACrB,SAAiB,EACjB,UAA+B;QAE/B,8BAA8B,CAC7B,sBAAsB,CAAC;YACtB,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,YAAY,EAAE,IAAI,CAAC,YAAY;YAC/B,SAAS;YACT,UAAU;SACV,CAAC,CACF,CAAC;QACF,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;YACtC,OAAO;QACR,CAAC;QACD,MAAM,cAAc,GAAG,UAAU,CAAC,WAAW,CAAC;QAC9C,
|
|
1
|
+
{"version":3,"file":"DebugPanelInstrumentationProvider.js","sourceRoot":"","sources":["../../../src/instrumentation/providers/DebugPanelInstrumentationProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,sBAAsB,EACtB,sBAAsB,EACtB,uBAAuB,EACvB,8BAA8B,GAC9B,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAE/E,MAAM,OAAO,iCAAkC,SAAQ,2BAA2B;IACxE,UAAU,GAAG,aAAa,CAAC;IAC3B,YAAY,GAAG,aAAa,CAAC;IAEtC,KAAK,CAAC,UAAU,CAAC,MAA8B;QAC9C,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;IACzB,CAAC;IAED,OAAO;QACN,OAAO,IAAI,CAAC,WAAW,CAAC;IACzB,CAAC;IAED,OAAO;QACN,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC;IAC1B,CAAC;IAES,YAAY,CAAC,KAAY,EAAE,UAA+B;QACnE,8BAA8B,CAC7B,sBAAsB,CAAC;YACtB,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,YAAY,EAAE,IAAI,CAAC,YAAY;YAC/B,KAAK;YACL,UAAU,EAAE,UAA6B;SACzC,CAAC,CACF,CAAC;IACH,CAAC;IAES,YAAY,CACrB,SAAiB,EACjB,UAA+B;QAE/B,8BAA8B,C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IAAI,CAAC,UAAU;YAC3B,YAAY,EAAE,IAAI,CAAC,YAAY;YAC/B,IAAI,EAAE,uBAAuB;YAC7B,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;YACnC,UAAU,EAAE,EAAE,GAAI,UAAsC,EAAE;SAC1D,CAAC,CAAC;IACJ,CAAC;CACD","sourcesContent":["import {\n\tcreateErrorDebugRecord,\n\tcreateEventDebugRecord,\n\tcreateMetricDebugRecord,\n\temitInstrumentationDebugRecord,\n} from \"../debug-panel-stream.js\";\nimport type { ErrorAttributes, InstrumentationConfig } from \"../types.js\";\nimport { BaseInstrumentationProvider } from \"./BaseInstrumentationProvider.js\";\n\nexport class DebugPanelInstrumentationProvider extends BaseInstrumentationProvider {\n\treadonly providerId = \"debug-panel\";\n\treadonly providerName = \"Debug Panel\";\n\n\tasync initialize(config?: InstrumentationConfig): Promise<void> {\n\t\tthis.config = config;\n\t\tthis.initialized = true;\n\t}\n\n\tisReady(): boolean {\n\t\treturn this.initialized;\n\t}\n\n\tdestroy(): void {\n\t\tthis.initialized = false;\n\t}\n\n\tprotected doTrackError(error: Error, attributes: Record<string, any>): void {\n\t\temitInstrumentationDebugRecord(\n\t\t\tcreateErrorDebugRecord({\n\t\t\t\tproviderId: this.providerId,\n\t\t\t\tproviderName: this.providerName,\n\t\t\t\terror,\n\t\t\t\tattributes: attributes as ErrorAttributes,\n\t\t\t}),\n\t\t);\n\t}\n\n\tprotected doTrackEvent(\n\t\teventName: string,\n\t\tattributes: Record<string, any>,\n\t): void {\n\t\temitInstrumentationDebugRecord(\n\t\t\tcreateEventDebugRecord({\n\t\t\t\tproviderId: this.providerId,\n\t\t\t\tproviderName: this.providerName,\n\t\t\t\teventName,\n\t\t\t\tattributes,\n\t\t\t}),\n\t\t);\n\t\tif (!eventName.startsWith(\"metric:\")) {\n\t\t\treturn;\n\t\t}\n\t\tconst rawMetricValue = attributes.metricValue;\n\t\tif (\n\t\t\ttypeof rawMetricValue !== \"number\" ||\n\t\t\t!Number.isFinite(rawMetricValue)\n\t\t) {\n\t\t\treturn;\n\t\t}\n\t\tconst metricName =\n\t\t\ttypeof attributes.metricName === \"string\" && attributes.metricName\n\t\t\t\t? attributes.metricName\n\t\t\t\t: eventName.replace(/^metric:/, \"\");\n\t\temitInstrumentationDebugRecord(\n\t\t\tcreateMetricDebugRecord({\n\t\t\t\tproviderId: this.providerId,\n\t\t\t\tproviderName: this.providerName,\n\t\t\t\tmetricName,\n\t\t\t\tvalue: rawMetricValue,\n\t\t\t\tattributes,\n\t\t\t}),\n\t\t);\n\t}\n\n\tprotected doSetUserContext(\n\t\tuserId: string,\n\t\tattributes?: Record<string, any>,\n\t): void {\n\t\temitInstrumentationDebugRecord({\n\t\t\tkind: \"user-context\",\n\t\t\tproviderId: this.providerId,\n\t\t\tproviderName: this.providerName,\n\t\t\tname: userId,\n\t\t\ttimestamp: new Date().toISOString(),\n\t\t\tattributes: attributes\n\t\t\t\t? { ...(attributes as Record<string, unknown>) }\n\t\t\t\t: undefined,\n\t\t});\n\t}\n\n\tprotected doSetGlobalAttributes(attributes: Record<string, any>): void {\n\t\temitInstrumentationDebugRecord({\n\t\t\tkind: \"global-attributes\",\n\t\t\tproviderId: this.providerId,\n\t\t\tproviderName: this.providerName,\n\t\t\tname: \"set-global-attributes\",\n\t\t\ttimestamp: new Date().toISOString(),\n\t\t\tattributes: { ...(attributes as Record<string, unknown>) },\n\t\t});\n\t}\n}\n"]}
|
|
@@ -58,7 +58,8 @@ export function aggregateElements(items) {
|
|
|
58
58
|
if (!version)
|
|
59
59
|
return tagName;
|
|
60
60
|
const targetEncodedVersion = encodeVersionForTag(version);
|
|
61
|
-
if (!targetEncodedVersion ||
|
|
61
|
+
if (!targetEncodedVersion ||
|
|
62
|
+
existingEncodedVersion === targetEncodedVersion) {
|
|
62
63
|
return tagName;
|
|
63
64
|
}
|
|
64
65
|
return `${baseName}${VERSION_DELIMITER}${targetEncodedVersion}`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ElementLoader.js","sourceRoot":"","sources":["../../src/loaders/ElementLoader.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AASnD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAmB;IACpD,MAAM,UAAU,GAA2B,EAAE,CAAC;IAC9C,MAAM,gBAAgB,GAA2B,EAAE,CAAC;IAEpD,MAAM,iBAAiB,GAAG,YAAY,CAAC;IACvC,MAAM,mBAAmB,GAAG,eAAe,CAAC;IAC5C,MAAM,mBAAmB,GAAG,CAAC,OAAe,EAAU,EAAE,CACvD,OAAO;SACL,IAAI,EAAE;SACN,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC;SACrB,OAAO,CAAC,gBAAgB,EAAE,GAAG,CAAC;SAC9B,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;IAC1B,MAAM,YAAY,GAAG,CACpB,OAAe,EACyC,EAAE;QAC1D,MAAM,YAAY,GAAG,OAAO,CAAC,KAAK,CACjC,IAAI,MAAM,CAAC,GAAG,iBAAiB,IAAI,mBAAmB,IAAI,CAAC,CAC3D,CAAC;QACF,OAAO,YAAY;YAClB,CAAC,CAAC;gBACA,QAAQ,EAAE,OAAO,CAAC,OAAO,CACxB,GAAG,iBAAiB,GAAG,YAAY,CAAC,CAAC,CAAC,EAAE,EACxC,EAAE,CACF;gBACD,sBAAsB,EAAE,YAAY,CAAC,CAAC,CAAC;aACvC;YACF,CAAC,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC;IAC1B,CAAC,CAAC;IACF,MAAM,mBAAmB,GAAG,
|
|
1
|
+
{"version":3,"file":"ElementLoader.js","sourceRoot":"","sources":["../../src/loaders/ElementLoader.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,C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EH,OAAO,UAAU,CAAC;AACnB,CAAC","sourcesContent":["/**\n * Element Loader — element aggregation utilities.\n *\n * The deep `ElementLoader` primitive lives in `./element-loader.ts`. This\n * module owns the shared `ElementMap` type and the `aggregateElements`\n * helper that reduces many items' element declarations into a single\n * deduplicated, version-aware map (used by the section-player to\n * pre-warm in one shot).\n */\n\nimport { parsePackageName } from \"../pie/utils.js\";\nimport type { ItemEntity } from \"../types/index.js\";\n\n/**\n * Map of element tag names to their package versions\n * Example: { \"pie-multiple-choice\": \"@pie-element/multiple-choice@11.0.1\" }\n */\nexport type ElementMap = { [tagName: string]: string };\n\n/**\n * Aggregate unique elements from multiple items\n *\n * Extracts elements from all item configs and deduplicates them.\n * Throws an error if items require different versions of the same element.\n *\n * @param items - Array of items to aggregate elements from\n * @returns Map of unique element tag names to package versions\n * @throws Error if element version conflicts are detected\n *\n * @example\n * ```typescript\n * const items = [\n * { config: { elements: { \"pie-mc\": \"@pie-element/mc@11.0.1\" } } },\n * { config: { elements: { \"pie-mc\": \"@pie-element/mc@11.0.1\" } } },\n * { config: { elements: { \"pie-hotspot\": \"@pie-element/hotspot@9.0.0\" } } }\n * ];\n *\n * const elements = aggregateElements(items);\n * // Result: {\n * // \"pie-mc\": \"@pie-element/mc@11.0.1\",\n * // \"pie-hotspot\": \"@pie-element/hotspot@9.0.0\"\n * // }\n * ```\n */\nexport function aggregateElements(items: ItemEntity[]): ElementMap {\n\tconst elementMap: Record<string, string> = {};\n\tconst seenOriginalTags: Record<string, string> = {};\n\n\tconst VERSION_DELIMITER = \"--version-\";\n\tconst TAG_VERSION_PATTERN = \"[0-9A-Za-z-]+\";\n\tconst encodeVersionForTag = (version: string): string =>\n\t\tversion\n\t\t\t.trim()\n\t\t\t.replace(/[.+]/g, \"-\")\n\t\t\t.replace(/[^0-9A-Za-z-]/g, \"-\")\n\t\t\t.replace(/-{2,}/g, \"-\");\n\tconst parseTagName = (\n\t\ttagName: string,\n\t): { baseName: string; existingEncodedVersion?: string } => {\n\t\tconst versionMatch = tagName.match(\n\t\t\tnew RegExp(`${VERSION_DELIMITER}(${TAG_VERSION_PATTERN})$`),\n\t\t);\n\t\treturn versionMatch\n\t\t\t? {\n\t\t\t\t\tbaseName: tagName.replace(\n\t\t\t\t\t\t`${VERSION_DELIMITER}${versionMatch[1]}`,\n\t\t\t\t\t\t\"\",\n\t\t\t\t\t),\n\t\t\t\t\texistingEncodedVersion: versionMatch[1],\n\t\t\t\t}\n\t\t\t: { baseName: tagName };\n\t};\n\tconst normalizeElementTag = (\n\t\ttagName: string,\n\t\tpackageSpec: string,\n\t): string => {\n\t\tconst { baseName, existingEncodedVersion } = parseTagName(tagName);\n\t\tconst { version } = parsePackageName(packageSpec);\n\t\tif (!version) return tagName;\n\t\tconst targetEncodedVersion = encodeVersionForTag(version);\n\t\tif (\n\t\t\t!targetEncodedVersion ||\n\t\t\texistingEncodedVersion === targetEncodedVersion\n\t\t) {\n\t\t\treturn tagName;\n\t\t}\n\t\treturn `${baseName}${VERSION_DELIMITER}${targetEncodedVersion}`;\n\t};\n\n\titems.forEach((item) => {\n\t\tconst itemElements = item.config?.elements || {};\n\n\t\tObject.entries(itemElements).forEach(([tag, pkg]) => {\n\t\t\tconst packageSpec = String(pkg);\n\t\t\tif (!seenOriginalTags[tag]) {\n\t\t\t\tseenOriginalTags[tag] = packageSpec;\n\t\t\t} else if (seenOriginalTags[tag] !== packageSpec) {\n\t\t\t\t// Preserve existing conflict behavior for repeated original tags.\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Element version conflict: ${tag} requires both ${seenOriginalTags[tag]} and ${packageSpec}. ` +\n\t\t\t\t\t\t`All items in a section must use the same version of each element.`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst normalizedTag = normalizeElementTag(tag, packageSpec);\n\t\t\tif (!elementMap[normalizedTag]) {\n\t\t\t\telementMap[normalizedTag] = packageSpec;\n\t\t\t} else if (elementMap[normalizedTag] !== packageSpec) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Element version conflict: ${normalizedTag} requires both ${elementMap[normalizedTag]} and ${packageSpec}. ` +\n\t\t\t\t\t\t`All items in a section must use the same version of each element.`,\n\t\t\t\t);\n\t\t\t}\n\t\t});\n\t});\n\n\treturn elementMap;\n}\n"]}
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
*/
|
|
21
21
|
import { DEFAULT_IIFE_BUNDLE_RETRY_CONFIG } from "../loader-config.js";
|
|
22
22
|
import { AdapterFailure, } from "./element-loader-types.js";
|
|
23
|
-
import { createEsmBackend
|
|
24
|
-
import { createIifeBackend
|
|
23
|
+
import { createEsmBackend } from "./esm-adapter.js";
|
|
24
|
+
import { createIifeBackend } from "./iife-adapter.js";
|
|
25
25
|
export { AdapterFailure } from "./element-loader-types.js";
|
|
26
26
|
/**
|
|
27
27
|
* Aggregate error thrown by `ensureRegistered` when one or more requested
|
|
@@ -68,6 +68,8 @@ const DEFAULT_LOAD_TIMEOUT_MS = DEFAULT_IIFE_BUNDLE_RETRY_CONFIG.timeoutMs;
|
|
|
68
68
|
// Module-scoped in-flight cache. Key: backend signature + sorted elements.
|
|
69
69
|
// Keeps concurrent identical requests collapsed to one backend call.
|
|
70
70
|
const inFlightRequests = new Map();
|
|
71
|
+
const resolvedEsmBackends = new Map();
|
|
72
|
+
const resolvedBackendOverrides = new Map();
|
|
71
73
|
/**
|
|
72
74
|
* Resolve iff every tag in `elements` is registered with `customElements`.
|
|
73
75
|
* Reject with `ElementLoaderError` otherwise.
|
|
@@ -195,8 +197,18 @@ function resolveBackend(backend) {
|
|
|
195
197
|
if ("kind" in backend) {
|
|
196
198
|
if (backend.kind === "iife")
|
|
197
199
|
return createIifeBackend(backend);
|
|
198
|
-
if (backend.kind === "esm")
|
|
199
|
-
|
|
200
|
+
if (backend.kind === "esm") {
|
|
201
|
+
const backendKey = backendKeyOf(backend);
|
|
202
|
+
const override = resolvedBackendOverrides.get(backendKey);
|
|
203
|
+
if (override)
|
|
204
|
+
return override;
|
|
205
|
+
const existing = resolvedEsmBackends.get(backendKey);
|
|
206
|
+
if (existing)
|
|
207
|
+
return existing;
|
|
208
|
+
const created = createEsmBackend(backend);
|
|
209
|
+
resolvedEsmBackends.set(backendKey, created);
|
|
210
|
+
return created;
|
|
211
|
+
}
|
|
200
212
|
}
|
|
201
213
|
throw new Error("ElementLoader: invalid backend option");
|
|
202
214
|
}
|
|
@@ -250,11 +262,14 @@ function backendKeyOf(backend) {
|
|
|
250
262
|
return `esm#${fingerprintValue({
|
|
251
263
|
kind: "esm",
|
|
252
264
|
cdnBaseUrl: backend.cdnBaseUrl,
|
|
265
|
+
cdnProvider: backend.cdnProvider ?? null,
|
|
253
266
|
moduleResolution: backend.moduleResolution ?? "url",
|
|
254
267
|
view: backend.view ?? "delivery",
|
|
255
268
|
viewConfig: backend.viewConfig ?? null,
|
|
256
269
|
loadControllers: backend.loadControllers ?? true,
|
|
257
270
|
debugEnabled: backend.debugEnabled ?? null,
|
|
271
|
+
trackPageActions: backend.trackPageActions ?? false,
|
|
272
|
+
instrumentationProvider: backend.instrumentationProvider ?? null,
|
|
258
273
|
})}`;
|
|
259
274
|
}
|
|
260
275
|
}
|
|
@@ -380,6 +395,8 @@ function extractAdapterReason(err, tag) {
|
|
|
380
395
|
export const __testing = {
|
|
381
396
|
resetDedupState() {
|
|
382
397
|
inFlightRequests.clear();
|
|
398
|
+
resolvedEsmBackends.clear();
|
|
399
|
+
resolvedBackendOverrides.clear();
|
|
383
400
|
},
|
|
384
401
|
inFlightCount() {
|
|
385
402
|
return inFlightRequests.size;
|
|
@@ -387,5 +404,12 @@ export const __testing = {
|
|
|
387
404
|
dedupKeyFor(elements, backend) {
|
|
388
405
|
return buildDedupKey(backend, elements);
|
|
389
406
|
},
|
|
407
|
+
replaceResolvedBackendForTesting(backend, resolvedBackend) {
|
|
408
|
+
resolvedBackendOverrides.set(backendKeyOf(backend), resolvedBackend);
|
|
409
|
+
},
|
|
410
|
+
restoreResolvedBackendsForTesting() {
|
|
411
|
+
resolvedEsmBackends.clear();
|
|
412
|
+
resolvedBackendOverrides.clear();
|
|
413
|
+
},
|
|
390
414
|
};
|
|
391
415
|
//# sourceMappingURL=element-loader.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"element-loader.js","sourceRoot":"","sources":["../../src/loaders/element-loader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,gCAAgC,EAAE,MAAM,qBAAqB,CAAC;AAEvE,OAAO,EACN,cAAc,GAKd,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACN,gBAAgB,GAEhB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACN,iBAAiB,GAEjB,MAAM,mBAAmB,CAAC;AAS3B,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAI3D;;;GAGG;AACH,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAC1B,IAAI,GAAG,oBAAoB,CAAC;IACrC,gBAAgB,CAAkB;IAClC,OAAO,CAA6C;IAE7D,YACC,OAAe,EACf,gBAAiC,EACjC,OAAmD;QAEnD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;QACzC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACxB,CAAC;CACD;AAED;;;;GAIG;AACH,MAAM,OAAO,qBAAsB,SAAQ,KAAK;IAC7B,IAAI,GAAG,uBAAuB,CAAC;IACxC,YAAY,CAAwB;IACpC,WAAW,CAAwB;IACnC,uBAAuB,CAAwB;IAExD,YACC,QAAsB,EACtB,OAAqB,EACrB,mBAAiC;QAEjC,KAAK,CACJ,qBAAqB,CAAC,QAAQ,EAAE,OAAO,EAAE,mBAAmB,CAAC,CAC7D,CAAC;QACF,IAAI,CAAC,YAAY,GAAG,QAAQ,CAAC;QAC7B,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC;QAC3B,IAAI,CAAC,uBAAuB,GAAG,mB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,GAAG,GAAG,cAEX,CAAC;IACF,IAAI,OAAO,GAAG,CAAC,aAAa,KAAK,UAAU,EAAE,CAAC;QAC7C,IAAI,CAAC;YACJ,OAAO,GAAG,CAAC,aAAa,EAAE,CAAC;QAC5B,CAAC;QAAC,MAAM,CAAC;YACR,OAAO,EAAE,CAAC;QACX,CAAC;IACF,CAAC;IACD,OAAO,EAAE,CAAC;AACX,CAAC;AAED,SAAS,oBAAoB,CAC5B,GAAsB,EACtB,GAAe;IAEf,IAAI,CAAC,GAAG;QAAE,OAAO,SAAS,CAAC;IAC3B,IAAI,GAAG,YAAY,cAAc;QAAE,OAAO,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC/D,OAAO,EAAE,IAAI,EAAE,kBAAkB,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,CAAC,OAAO,EAAE,CAAC;AAC9D,CAAC;AAED,gFAAgF;AAEhF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG;IACxB,eAAe;QACd,gBAAgB,CAAC,KAAK,EAAE,CAAC;IAC1B,CAAC;IACD,aAAa;QACZ,OAAO,gBAAgB,CAAC,IAAI,CAAC;IAC9B,CAAC;IACD,WAAW,CAAC,QAAoB,EAAE,OAAsB;QACvD,OAAO,aAAa,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IACzC,CAAC;CACD,CAAC","sourcesContent":["/**\n * ElementLoader primitive — the one place where \"these tags are registered\n * with customElements\" is decided.\n *\n * Owns the truthful promise contract end-to-end:\n *\n * ensureRegistered(elements, options) resolves iff every requested tag\n * is in `customElements` at the moment of resolution. On partial\n * success it rejects with an `ElementLoaderError` carrying the set of\n * unregistered tags and a per-tag `RegistrationFailureReason` map.\n *\n * The primitive delegates the actual fetch/register work to a backend\n * adapter (IIFE or ESM) but always verifies the outcome via\n * `customElements.whenDefined`. An adapter cannot silently under-register\n * — the primitive will catch it and surface a timeout reason.\n *\n * See packages/players-shared/tests/element-loader-contract.test.ts for\n * the executable specification of every failure mode this primitive is\n * required to catch.\n */\n\nimport { DEFAULT_IIFE_BUNDLE_RETRY_CONFIG } from \"../loader-config.js\";\nimport type { ElementMap } from \"./ElementLoader.js\";\nimport {\n\tAdapterFailure,\n\ttype BackendContext,\n\ttype ElementLoaderBackend,\n\ttype ElementTag,\n\ttype RegistrationFailureReason,\n} from \"./element-loader-types.js\";\nimport {\n\tcreateEsmBackend,\n\ttype EsmBackendConfig,\n} from \"./esm-adapter.js\";\nimport {\n\tcreateIifeBackend,\n\ttype IifeBackendConfig,\n} from \"./iife-adapter.js\";\n\nexport type {\n\tBackendContext,\n\tElementLoaderBackend,\n\tElementMap,\n\tElementTag,\n\tRegistrationFailureReason,\n} from \"./element-loader-types.js\";\nexport { AdapterFailure } from \"./element-loader-types.js\";\nexport type { IifeBackendConfig } from \"./iife-adapter.js\";\nexport type { EsmBackendConfig } from \"./esm-adapter.js\";\n\n/**\n * Aggregate error thrown by `ensureRegistered` when one or more requested\n * tags were not registered by the time verification timed out.\n */\nexport class ElementLoaderError extends Error {\n\toverride readonly name = \"ElementLoaderError\";\n\treadonly unregisteredTags: Set<ElementTag>;\n\treadonly reasons: Map<ElementTag, RegistrationFailureReason>;\n\n\tconstructor(\n\t\tmessage: string,\n\t\tunregisteredTags: Set<ElementTag>,\n\t\treasons: Map<ElementTag, RegistrationFailureReason>,\n\t) {\n\t\tsuper(message);\n\t\tthis.unregisteredTags = unregisteredTags;\n\t\tthis.reasons = reasons;\n\t}\n}\n\n/**\n * Thrown by `assertRegistered` when any requested tag is missing from\n * `customElements`. Carries enough detail for the host to diagnose what\n * pre-registration step was skipped.\n */\nexport class ElementAssertionError extends Error {\n\toverride readonly name = \"ElementAssertionError\";\n\treadonly expectedTags: readonly ElementTag[];\n\treadonly missingTags: readonly ElementTag[];\n\treadonly currentlyRegisteredTags: readonly ElementTag[];\n\n\tconstructor(\n\t\texpected: ElementTag[],\n\t\tmissing: ElementTag[],\n\t\tcurrentlyRegistered: ElementTag[],\n\t) {\n\t\tsuper(\n\t\t\tbuildAssertionMessage(expected, missing, currentlyRegistered),\n\t\t);\n\t\tthis.expectedTags = expected;\n\t\tthis.missingTags = missing;\n\t\tthis.currentlyRegisteredTags = currentlyRegistered;\n\t}\n}\n\nfunction buildAssertionMessage(\n\texpected: ElementTag[],\n\tmissing: ElementTag[],\n\tregistered: ElementTag[],\n): string {\n\tconst expectedStr = expected.join(\", \");\n\tconst missingStr = missing.join(\", \");\n\tconst registeredStr = registered.length\n\t\t? registered.join(\", \")\n\t\t: \"(none enumerable)\";\n\treturn (\n\t\t`ElementLoader.assertRegistered: expected [${expectedStr}], ` +\n\t\t`missing [${missingStr}]. customElements contains: [${registeredStr}].`\n\t);\n}\n\nexport type BackendOption =\n\t| IifeBackendConfig\n\t| EsmBackendConfig\n\t| ElementLoaderBackend;\n\nexport type EnsureRegisteredOptions = {\n\tbackend: BackendOption;\n\tdoc?: Document;\n\twhenDefinedTimeoutMs?: number;\n\t/**\n\t * Outer cumulative deadline for the backend's `load()` call.\n\t *\n\t * Closes the \"promise never settles\" seam for adapters whose underlying\n\t * fetch can stall indefinitely (e.g. ESM `import()` against a frozen\n\t * CDN). When the deadline elapses, the primitive synthesizes an\n\t * `AdapterFailure` with `kind: \"timeout\"` reasons for every requested\n\t * tag — surfacing as a normal `ElementLoaderError` to the caller.\n\t *\n\t * Defaults to `DEFAULT_IIFE_BUNDLE_RETRY_CONFIG.timeoutMs` so\n\t * adapter-internal retry windows (IIFE bundle-build polling) fit\n\t * inside the same overall budget.\n\t */\n\tloadTimeoutMs?: number;\n};\n\nconst DEFAULT_WHEN_DEFINED_TIMEOUT_MS = 5000;\nconst DEFAULT_LOAD_TIMEOUT_MS = DEFAULT_IIFE_BUNDLE_RETRY_CONFIG.timeoutMs;\n\n// Module-scoped in-flight cache. Key: backend signature + sorted elements.\n// Keeps concurrent identical requests collapsed to one backend call.\nconst inFlightRequests = new Map<string, Promise<void>>();\n\n/**\n * Resolve iff every tag in `elements` is registered with `customElements`.\n * Reject with `ElementLoaderError` otherwise.\n *\n * The primitive is the sole authority on registration state:\n * - Empty element map resolves immediately (no backend call).\n * - Already-registered tags resolve immediately (no backend call).\n * - Concurrent identical requests share one backend call.\n * - After the adapter's `load` settles, a post-load verification pass\n * (bounded `customElements.whenDefined`) checks every tag. Any missing\n * tag becomes a rejection.\n */\nexport async function ensureRegistered(\n\telements: ElementMap,\n\toptions: EnsureRegisteredOptions,\n): Promise<void> {\n\tif (!elements || Object.keys(elements).length === 0) return;\n\n\tconst tags = Object.keys(elements);\n\tconst timeoutMs =\n\t\toptions.whenDefinedTimeoutMs ?? DEFAULT_WHEN_DEFINED_TIMEOUT_MS;\n\tconst loadTimeoutMs = options.loadTimeoutMs ?? DEFAULT_LOAD_TIMEOUT_MS;\n\n\t// Fast path: everything already registered. Skip backend and dedup\n\t// bookkeeping entirely.\n\tif (allAlreadyRegistered(tags)) return;\n\n\tconst dedupKey = buildDedupKey(options.backend, elements);\n\tconst existing = inFlightRequests.get(dedupKey);\n\tif (existing) return existing;\n\n\tconst backend = resolveBackend(options.backend);\n\tconst doc = resolveDoc(options.doc);\n\n\tconst promise = runEnsureRegistered(\n\t\telements,\n\t\ttags,\n\t\tbackend,\n\t\t{ doc, whenDefinedTimeoutMs: timeoutMs },\n\t\ttimeoutMs,\n\t\tloadTimeoutMs,\n\t);\n\n\tinFlightRequests.set(dedupKey, promise);\n\ttry {\n\t\tawait promise;\n\t} finally {\n\t\tif (inFlightRequests.get(dedupKey) === promise) {\n\t\t\tinFlightRequests.delete(dedupKey);\n\t\t}\n\t}\n}\n\nasync function runEnsureRegistered(\n\telements: ElementMap,\n\ttags: ElementTag[],\n\tbackend: ElementLoaderBackend,\n\tcontext: BackendContext,\n\ttimeoutMs: number,\n\tloadTimeoutMs: number,\n): Promise<void> {\n\tlet adapterError: Error | undefined;\n\ttry {\n\t\tawait raceWithLoadTimeout(\n\t\t\tbackend.load(elements, context),\n\t\t\ttags,\n\t\t\tloadTimeoutMs,\n\t\t);\n\t} catch (err) {\n\t\tadapterError = err instanceof Error ? err : new Error(String(err));\n\t}\n\n\tconst verification = await Promise.all(\n\t\ttags.map(async (tag) => {\n\t\t\tif (isRegistered(tag)) return { tag, ok: true as const };\n\t\t\ttry {\n\t\t\t\tawait whenDefinedWithTimeout(tag, timeoutMs);\n\t\t\t\treturn { tag, ok: true as const };\n\t\t\t} catch {\n\t\t\t\treturn { tag, ok: false as const };\n\t\t\t}\n\t\t}),\n\t);\n\n\tconst unregistered = new Set<ElementTag>();\n\tconst reasons = new Map<ElementTag, RegistrationFailureReason>();\n\tfor (const v of verification) {\n\t\tif (v.ok) continue;\n\t\tunregistered.add(v.tag);\n\t\tconst adapterReason = extractAdapterReason(adapterError, v.tag);\n\t\treasons.set(\n\t\t\tv.tag,\n\t\t\tadapterReason ?? { kind: \"timeout\", tag: v.tag, timeoutMs },\n\t\t);\n\t}\n\n\tif (unregistered.size > 0) {\n\t\tthrow new ElementLoaderError(\n\t\t\t`Element registration failed; missing tags: ${[...unregistered].join(\", \")}`,\n\t\t\tunregistered,\n\t\t\treasons,\n\t\t);\n\t}\n}\n\n/**\n * Race the backend's `load()` against a cumulative deadline.\n *\n * On timeout, synthesize an `AdapterFailure` whose `reasons` map carries\n * a `kind: \"timeout\"` entry per requested tag. The verification pass in\n * `runEnsureRegistered` will then produce a normal `ElementLoaderError`\n * with structured per-tag reasons — same surface shape as any other\n * adapter rejection.\n */\nasync function raceWithLoadTimeout(\n\tloadPromise: Promise<void>,\n\ttags: ElementTag[],\n\tloadTimeoutMs: number,\n): Promise<void> {\n\tlet timer: ReturnType<typeof setTimeout> | undefined;\n\ttry {\n\t\tawait Promise.race([\n\t\t\tloadPromise,\n\t\t\tnew Promise<void>((_, reject) => {\n\t\t\t\ttimer = setTimeout(() => {\n\t\t\t\t\tconst reasons = new Map<ElementTag, RegistrationFailureReason>();\n\t\t\t\t\tfor (const tag of tags) {\n\t\t\t\t\t\treasons.set(tag, {\n\t\t\t\t\t\t\tkind: \"timeout\",\n\t\t\t\t\t\t\ttag,\n\t\t\t\t\t\t\ttimeoutMs: loadTimeoutMs,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t\treject(new AdapterFailure(reasons));\n\t\t\t\t}, loadTimeoutMs);\n\t\t\t}),\n\t\t]);\n\t} finally {\n\t\tif (timer) clearTimeout(timer);\n\t}\n}\n\n/**\n * Synchronously assert that every tag is already in `customElements`.\n * Throws `ElementAssertionError` with diagnostic detail otherwise.\n *\n * Used by hosts that opt into the \"preloaded\" strategy — they pre-register\n * elements out-of-band and want a loud failure if anything is missing.\n */\nexport function assertRegistered(tags: ElementTag[]): void {\n\tif (!tags || tags.length === 0) return;\n\tconst missing = tags.filter((tag) => !isRegistered(tag));\n\tif (missing.length === 0) return;\n\tthrow new ElementAssertionError(tags, missing, snapshotRegisteredTags());\n}\n\n// ─── Internals ───────────────────────────────────────────────────────────────\n\nfunction resolveBackend(backend: BackendOption): ElementLoaderBackend {\n\tif (isDirectBackend(backend)) return backend;\n\tif (\"kind\" in backend) {\n\t\tif (backend.kind === \"iife\") return createIifeBackend(backend);\n\t\tif (backend.kind === \"esm\") return createEsmBackend(backend);\n\t}\n\tthrow new Error(\"ElementLoader: invalid backend option\");\n}\n\nfunction isDirectBackend(backend: BackendOption): backend is ElementLoaderBackend {\n\treturn (\n\t\ttypeof (backend as { load?: unknown }).load === \"function\" &&\n\t\t!(\"kind\" in backend)\n\t);\n}\n\nfunction resolveDoc(doc: Document | undefined): Document {\n\tif (doc) return doc;\n\tif (typeof document !== \"undefined\") return document;\n\tthrow new Error(\n\t\t\"ElementLoader: no Document available; pass options.doc explicitly\",\n\t);\n}\n\nfunction buildDedupKey(backend: BackendOption, elements: ElementMap): string {\n\tconst backendKey = backendKeyOf(backend);\n\tconst entries = Object.entries(elements).sort(([a], [b]) =>\n\t\ta.localeCompare(b),\n\t);\n\treturn `${backendKey}|${JSON.stringify(entries)}`;\n}\n\nconst backendIds = new WeakMap<ElementLoaderBackend, string>();\nlet nextBackendId = 0;\nconst functionIds = new WeakMap<Function, string>();\nlet nextFunctionId = 0;\nconst opaqueObjectIds = new WeakMap<object, string>();\nlet nextOpaqueObjectId = 0;\n\nfunction backendKeyOf(backend: BackendOption): string {\n\tif (isDirectBackend(backend)) {\n\t\tlet id = backendIds.get(backend);\n\t\tif (!id) {\n\t\t\tid = `b${++nextBackendId}`;\n\t\t\tbackendIds.set(backend, id);\n\t\t}\n\t\treturn `backend#${id}`;\n\t}\n\tif (\"kind\" in backend) {\n\t\tif (backend.kind === \"iife\") {\n\t\t\treturn `iife#${fingerprintValue({\n\t\t\t\tkind: \"iife\",\n\t\t\t\tbundleHost: backend.bundleHost,\n\t\t\t\tbundleType: backend.bundleType ?? \"\",\n\t\t\t\tneedsControllers: backend.needsControllers ?? true,\n\t\t\t\tbundleInfo: backend.bundleInfo ?? null,\n\t\t\t\tdebugEnabled: backend.debugEnabled ?? null,\n\t\t\t\tbundleRetry: backend.bundleRetry ?? null,\n\t\t\t\tonBundleRetryStatus: backend.onBundleRetryStatus ?? null,\n\t\t\t\ttrackPageActions: backend.trackPageActions ?? false,\n\t\t\t\tinstrumentationProvider: backend.instrumentationProvider ?? null,\n\t\t\t})}`;\n\t\t}\n\t\tif (backend.kind === \"esm\") {\n\t\t\treturn `esm#${fingerprintValue({\n\t\t\t\tkind: \"esm\",\n\t\t\t\tcdnBaseUrl: backend.cdnBaseUrl,\n\t\t\t\tmoduleResolution: backend.moduleResolution ?? \"url\",\n\t\t\t\tview: backend.view ?? \"delivery\",\n\t\t\t\tviewConfig: backend.viewConfig ?? null,\n\t\t\t\tloadControllers: backend.loadControllers ?? true,\n\t\t\t\tdebugEnabled: backend.debugEnabled ?? null,\n\t\t\t})}`;\n\t\t}\n\t}\n\treturn \"unknown\";\n}\n\nfunction fingerprintValue(value: unknown): string {\n\treturn JSON.stringify(normalizeForFingerprint(value, new Map()));\n}\n\nfunction normalizeForFingerprint(\n\tvalue: unknown,\n\tseen: Map<object, string>,\n): unknown {\n\tif (value === null || value === undefined) return value;\n\tconst primitiveType = typeof value;\n\tif (\n\t\tprimitiveType === \"string\" ||\n\t\tprimitiveType === \"number\" ||\n\t\tprimitiveType === \"boolean\"\n\t) {\n\t\treturn value;\n\t}\n\tif (primitiveType === \"function\") {\n\t\treturn { __functionRef: getFunctionRefId(value as Function) };\n\t}\n\tif (primitiveType !== \"object\") {\n\t\treturn String(value);\n\t}\n\n\tconst objectValue = value as object;\n\tconst existing = seen.get(objectValue);\n\tif (existing) return { __cycleRef: existing };\n\tconst cycleRefId = `cycle#${seen.size + 1}`;\n\tseen.set(objectValue, cycleRefId);\n\n\tif (Array.isArray(value)) {\n\t\treturn value.map((entry) => normalizeForFingerprint(entry, seen));\n\t}\n\n\tif (!isPlainObject(value)) {\n\t\treturn { __objectRef: getOpaqueObjectRefId(objectValue) };\n\t}\n\n\tconst normalized: Record<string, unknown> = {};\n\tfor (const key of Object.keys(value).sort()) {\n\t\tnormalized[key] = normalizeForFingerprint(\n\t\t\t(value as Record<string, unknown>)[key],\n\t\t\tseen,\n\t\t);\n\t}\n\treturn normalized;\n}\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n\tif (!value || typeof value !== \"object\") return false;\n\tconst prototype = Object.getPrototypeOf(value);\n\treturn prototype === Object.prototype || prototype === null;\n}\n\nfunction getFunctionRefId(fn: Function): string {\n\tlet id = functionIds.get(fn);\n\tif (!id) {\n\t\tid = `fn#${++nextFunctionId}`;\n\t\tfunctionIds.set(fn, id);\n\t}\n\treturn id;\n}\n\nfunction getOpaqueObjectRefId(value: object): string {\n\tlet id = opaqueObjectIds.get(value);\n\tif (!id) {\n\t\tid = `obj#${++nextOpaqueObjectId}`;\n\t\topaqueObjectIds.set(value, id);\n\t}\n\treturn id;\n}\n\nfunction allAlreadyRegistered(tags: ElementTag[]): boolean {\n\treturn tags.every((tag) => isRegistered(tag));\n}\n\nfunction isRegistered(tag: ElementTag): boolean {\n\tif (typeof customElements === \"undefined\") return false;\n\treturn customElements.get(tag) !== undefined;\n}\n\nasync function whenDefinedWithTimeout(\n\ttag: ElementTag,\n\ttimeoutMs: number,\n): Promise<void> {\n\tif (typeof customElements === \"undefined\") {\n\t\tthrow new Error(`no customElements to await ${tag}`);\n\t}\n\tlet timer: ReturnType<typeof setTimeout> | undefined;\n\ttry {\n\t\treturn await Promise.race([\n\t\t\tcustomElements.whenDefined(tag).then(() => undefined),\n\t\t\tnew Promise<void>((_, reject) => {\n\t\t\t\ttimer = setTimeout(\n\t\t\t\t\t() => reject(new Error(`Timeout waiting for ${tag}`)),\n\t\t\t\t\ttimeoutMs,\n\t\t\t\t);\n\t\t\t}),\n\t\t]);\n\t} finally {\n\t\tif (timer) clearTimeout(timer);\n\t}\n}\n\nfunction snapshotRegisteredTags(): ElementTag[] {\n\tif (typeof customElements === \"undefined\") return [];\n\t// Standard `CustomElementRegistry` does not expose iteration. Tests install\n\t// a scripted registry with a `__pieSnapshot` extension to make diagnostic\n\t// messages assertable. Production falls through to an empty list —\n\t// still strictly better than today's \"missing tags: X\" error which leaks\n\t// no registry state at all.\n\tconst reg = customElements as unknown as {\n\t\t__pieSnapshot?: () => ElementTag[];\n\t};\n\tif (typeof reg.__pieSnapshot === \"function\") {\n\t\ttry {\n\t\t\treturn reg.__pieSnapshot();\n\t\t} catch {\n\t\t\treturn [];\n\t\t}\n\t}\n\treturn [];\n}\n\nfunction extractAdapterReason(\n\terr: Error | undefined,\n\ttag: ElementTag,\n): RegistrationFailureReason | undefined {\n\tif (!err) return undefined;\n\tif (err instanceof AdapterFailure) return err.reasons.get(tag);\n\treturn { kind: \"backend-rejected\", tag, cause: err.message };\n}\n\n// ─── Test-only helpers ───────────────────────────────────────────────────────\n\n/**\n * Internal helpers for test harnesses. Not part of the public runtime API;\n * production code should never reach for these.\n *\n * @internal\n */\nexport const __testing = {\n\tresetDedupState(): void {\n\t\tinFlightRequests.clear();\n\t},\n\tinFlightCount(): number {\n\t\treturn inFlightRequests.size;\n\t},\n\tdedupKeyFor(elements: ElementMap, backend: BackendOption): string {\n\t\treturn buildDedupKey(backend, elements);\n\t},\n};\n"]}
|
|
1
|
+
{"version":3,"file":"element-loader.js","sourceRoot":"","sources":["../../src/loaders/element-loader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,gCAAgC,EAAE,MAAM,qBAAqB,CAAC;AAEvE,OAAO,EACN,cAAc,GAKd,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,gBAAgB,EAAyB,MAAM,kBAAkB,CAAC;AAC3E,OAAO,EAAE,iBAAiB,EAA0B,MAAM,mBAAmB,CAAC;AAS9E,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAI3D;;;GAGG;AACH,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAC1B,IAAI,GAAG,oBAAoB,CAAC;IACrC,gBAAgB,CAAkB;IAClC,OAAO,CAA6C;IAE7D,YACC,OAAe,EACf,gBAAiC,EACjC,OAAmD;QAEnD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;QACzC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACxB,CAAC;CACD;AAED;;;;GAIG;AACH,MAAM,OAAO,qBAAsB,SAAQ,KAAK;IAC7B,IAAI,GAAG,uBAAuB,CAAC;IACxC,YAAY,CAAwB;IACpC,WAAW,CAAwB;IACnC,uBAAuB,CAAwB;IAExD,YACC,QAAsB,EACtB,OAAqB,EACrB,mBAAiC;QAEjC,KAAK,CAAC,qBAAqB,CAAC,QAAQ,EAAE,OAAO,EAAE,mBAAmB,CAAC,CAAC,CAAC;QACrE,IAAI,CAAC,YAAY,GAAG,QAAQ,CAAC;QAC7B,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC;QAC3B,IAAI,CAAC,uBAAuB,GAAG,mBAAmB,CAAC;IACpD,CAAC;CACD;AAED,SAAS,qBAAqB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AC,MAAM,SAAS,GAAG;IACxB,eAAe;QACd,gBAAgB,CAAC,KAAK,EAAE,CAAC;QACzB,mBAAmB,CAAC,KAAK,EAAE,CAAC;QAC5B,wBAAwB,CAAC,KAAK,EAAE,CAAC;IAClC,CAAC;IACD,aAAa;QACZ,OAAO,gBAAgB,CAAC,IAAI,CAAC;IAC9B,CAAC;IACD,WAAW,CAAC,QAAoB,EAAE,OAAsB;QACvD,OAAO,aAAa,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IACzC,CAAC;IACD,gCAAgC,CAC/B,OAAsB,EACtB,eAAqC;QAErC,wBAAwB,CAAC,GAAG,CAAC,YAAY,CAAC,OAAO,CAAC,EAAE,eAAe,CAAC,CAAC;IACtE,CAAC;IACD,iCAAiC;QAChC,mBAAmB,CAAC,KAAK,EAAE,CAAC;QAC5B,wBAAwB,CAAC,KAAK,EAAE,CAAC;IAClC,CAAC;CACD,CAAC","sourcesContent":["/**\n * ElementLoader primitive — the one place where \"these tags are registered\n * with customElements\" is decided.\n *\n * Owns the truthful promise contract end-to-end:\n *\n * ensureRegistered(elements, options) resolves iff every requested tag\n * is in `customElements` at the moment of resolution. On partial\n * success it rejects with an `ElementLoaderError` carrying the set of\n * unregistered tags and a per-tag `RegistrationFailureReason` map.\n *\n * The primitive delegates the actual fetch/register work to a backend\n * adapter (IIFE or ESM) but always verifies the outcome via\n * `customElements.whenDefined`. An adapter cannot silently under-register\n * — the primitive will catch it and surface a timeout reason.\n *\n * See packages/players-shared/tests/element-loader-contract.test.ts for\n * the executable specification of every failure mode this primitive is\n * required to catch.\n */\n\nimport { DEFAULT_IIFE_BUNDLE_RETRY_CONFIG } from \"../loader-config.js\";\nimport type { ElementMap } from \"./ElementLoader.js\";\nimport {\n\tAdapterFailure,\n\ttype BackendContext,\n\ttype ElementLoaderBackend,\n\ttype ElementTag,\n\ttype RegistrationFailureReason,\n} from \"./element-loader-types.js\";\nimport { createEsmBackend, type EsmBackendConfig } from \"./esm-adapter.js\";\nimport { createIifeBackend, type IifeBackendConfig } from \"./iife-adapter.js\";\n\nexport type {\n\tBackendContext,\n\tElementLoaderBackend,\n\tElementMap,\n\tElementTag,\n\tRegistrationFailureReason,\n} from \"./element-loader-types.js\";\nexport { AdapterFailure } from \"./element-loader-types.js\";\nexport type { IifeBackendConfig } from \"./iife-adapter.js\";\nexport type { EsmBackendConfig } from \"./esm-adapter.js\";\n\n/**\n * Aggregate error thrown by `ensureRegistered` when one or more requested\n * tags were not registered by the time verification timed out.\n */\nexport class ElementLoaderError extends Error {\n\toverride readonly name = \"ElementLoaderError\";\n\treadonly unregisteredTags: Set<ElementTag>;\n\treadonly reasons: Map<ElementTag, RegistrationFailureReason>;\n\n\tconstructor(\n\t\tmessage: string,\n\t\tunregisteredTags: Set<ElementTag>,\n\t\treasons: Map<ElementTag, RegistrationFailureReason>,\n\t) {\n\t\tsuper(message);\n\t\tthis.unregisteredTags = unregisteredTags;\n\t\tthis.reasons = reasons;\n\t}\n}\n\n/**\n * Thrown by `assertRegistered` when any requested tag is missing from\n * `customElements`. Carries enough detail for the host to diagnose what\n * pre-registration step was skipped.\n */\nexport class ElementAssertionError extends Error {\n\toverride readonly name = \"ElementAssertionError\";\n\treadonly expectedTags: readonly ElementTag[];\n\treadonly missingTags: readonly ElementTag[];\n\treadonly currentlyRegisteredTags: readonly ElementTag[];\n\n\tconstructor(\n\t\texpected: ElementTag[],\n\t\tmissing: ElementTag[],\n\t\tcurrentlyRegistered: ElementTag[],\n\t) {\n\t\tsuper(buildAssertionMessage(expected, missing, currentlyRegistered));\n\t\tthis.expectedTags = expected;\n\t\tthis.missingTags = missing;\n\t\tthis.currentlyRegisteredTags = currentlyRegistered;\n\t}\n}\n\nfunction buildAssertionMessage(\n\texpected: ElementTag[],\n\tmissing: ElementTag[],\n\tregistered: ElementTag[],\n): string {\n\tconst expectedStr = expected.join(\", \");\n\tconst missingStr = missing.join(\", \");\n\tconst registeredStr = registered.length\n\t\t? registered.join(\", \")\n\t\t: \"(none enumerable)\";\n\treturn (\n\t\t`ElementLoader.assertRegistered: expected [${expectedStr}], ` +\n\t\t`missing [${missingStr}]. customElements contains: [${registeredStr}].`\n\t);\n}\n\nexport type BackendOption =\n\t| IifeBackendConfig\n\t| EsmBackendConfig\n\t| ElementLoaderBackend;\n\nexport type EnsureRegisteredOptions = {\n\tbackend: BackendOption;\n\tdoc?: Document;\n\twhenDefinedTimeoutMs?: number;\n\t/**\n\t * Outer cumulative deadline for the backend's `load()` call.\n\t *\n\t * Closes the \"promise never settles\" seam for adapters whose underlying\n\t * fetch can stall indefinitely (e.g. ESM `import()` against a frozen\n\t * CDN). When the deadline elapses, the primitive synthesizes an\n\t * `AdapterFailure` with `kind: \"timeout\"` reasons for every requested\n\t * tag — surfacing as a normal `ElementLoaderError` to the caller.\n\t *\n\t * Defaults to `DEFAULT_IIFE_BUNDLE_RETRY_CONFIG.timeoutMs` so\n\t * adapter-internal retry windows (IIFE bundle-build polling) fit\n\t * inside the same overall budget.\n\t */\n\tloadTimeoutMs?: number;\n};\n\nconst DEFAULT_WHEN_DEFINED_TIMEOUT_MS = 5000;\nconst DEFAULT_LOAD_TIMEOUT_MS = DEFAULT_IIFE_BUNDLE_RETRY_CONFIG.timeoutMs;\n\n// Module-scoped in-flight cache. Key: backend signature + sorted elements.\n// Keeps concurrent identical requests collapsed to one backend call.\nconst inFlightRequests = new Map<string, Promise<void>>();\nconst resolvedEsmBackends = new Map<string, ElementLoaderBackend>();\nconst resolvedBackendOverrides = new Map<string, ElementLoaderBackend>();\n\n/**\n * Resolve iff every tag in `elements` is registered with `customElements`.\n * Reject with `ElementLoaderError` otherwise.\n *\n * The primitive is the sole authority on registration state:\n * - Empty element map resolves immediately (no backend call).\n * - Already-registered tags resolve immediately (no backend call).\n * - Concurrent identical requests share one backend call.\n * - After the adapter's `load` settles, a post-load verification pass\n * (bounded `customElements.whenDefined`) checks every tag. Any missing\n * tag becomes a rejection.\n */\nexport async function ensureRegistered(\n\telements: ElementMap,\n\toptions: EnsureRegisteredOptions,\n): Promise<void> {\n\tif (!elements || Object.keys(elements).length === 0) return;\n\n\tconst tags = Object.keys(elements);\n\tconst timeoutMs =\n\t\toptions.whenDefinedTimeoutMs ?? DEFAULT_WHEN_DEFINED_TIMEOUT_MS;\n\tconst loadTimeoutMs = options.loadTimeoutMs ?? DEFAULT_LOAD_TIMEOUT_MS;\n\n\t// Fast path: everything already registered. Skip backend and dedup\n\t// bookkeeping entirely.\n\tif (allAlreadyRegistered(tags)) return;\n\n\tconst dedupKey = buildDedupKey(options.backend, elements);\n\tconst existing = inFlightRequests.get(dedupKey);\n\tif (existing) return existing;\n\n\tconst backend = resolveBackend(options.backend);\n\tconst doc = resolveDoc(options.doc);\n\n\tconst promise = runEnsureRegistered(\n\t\telements,\n\t\ttags,\n\t\tbackend,\n\t\t{ doc, whenDefinedTimeoutMs: timeoutMs },\n\t\ttimeoutMs,\n\t\tloadTimeoutMs,\n\t);\n\n\tinFlightRequests.set(dedupKey, promise);\n\ttry {\n\t\tawait promise;\n\t} finally {\n\t\tif (inFlightRequests.get(dedupKey) === promise) {\n\t\t\tinFlightRequests.delete(dedupKey);\n\t\t}\n\t}\n}\n\nasync function runEnsureRegistered(\n\telements: ElementMap,\n\ttags: ElementTag[],\n\tbackend: ElementLoaderBackend,\n\tcontext: BackendContext,\n\ttimeoutMs: number,\n\tloadTimeoutMs: number,\n): Promise<void> {\n\tlet adapterError: Error | undefined;\n\ttry {\n\t\tawait raceWithLoadTimeout(\n\t\t\tbackend.load(elements, context),\n\t\t\ttags,\n\t\t\tloadTimeoutMs,\n\t\t);\n\t} catch (err) {\n\t\tadapterError = err instanceof Error ? err : new Error(String(err));\n\t}\n\n\tconst verification = await Promise.all(\n\t\ttags.map(async (tag) => {\n\t\t\tif (isRegistered(tag)) return { tag, ok: true as const };\n\t\t\ttry {\n\t\t\t\tawait whenDefinedWithTimeout(tag, timeoutMs);\n\t\t\t\treturn { tag, ok: true as const };\n\t\t\t} catch {\n\t\t\t\treturn { tag, ok: false as const };\n\t\t\t}\n\t\t}),\n\t);\n\n\tconst unregistered = new Set<ElementTag>();\n\tconst reasons = new Map<ElementTag, RegistrationFailureReason>();\n\tfor (const v of verification) {\n\t\tif (v.ok) continue;\n\t\tunregistered.add(v.tag);\n\t\tconst adapterReason = extractAdapterReason(adapterError, v.tag);\n\t\treasons.set(\n\t\t\tv.tag,\n\t\t\tadapterReason ?? { kind: \"timeout\", tag: v.tag, timeoutMs },\n\t\t);\n\t}\n\n\tif (unregistered.size > 0) {\n\t\tthrow new ElementLoaderError(\n\t\t\t`Element registration failed; missing tags: ${[...unregistered].join(\", \")}`,\n\t\t\tunregistered,\n\t\t\treasons,\n\t\t);\n\t}\n}\n\n/**\n * Race the backend's `load()` against a cumulative deadline.\n *\n * On timeout, synthesize an `AdapterFailure` whose `reasons` map carries\n * a `kind: \"timeout\"` entry per requested tag. The verification pass in\n * `runEnsureRegistered` will then produce a normal `ElementLoaderError`\n * with structured per-tag reasons — same surface shape as any other\n * adapter rejection.\n */\nasync function raceWithLoadTimeout(\n\tloadPromise: Promise<void>,\n\ttags: ElementTag[],\n\tloadTimeoutMs: number,\n): Promise<void> {\n\tlet timer: ReturnType<typeof setTimeout> | undefined;\n\ttry {\n\t\tawait Promise.race([\n\t\t\tloadPromise,\n\t\t\tnew Promise<void>((_, reject) => {\n\t\t\t\ttimer = setTimeout(() => {\n\t\t\t\t\tconst reasons = new Map<ElementTag, RegistrationFailureReason>();\n\t\t\t\t\tfor (const tag of tags) {\n\t\t\t\t\t\treasons.set(tag, {\n\t\t\t\t\t\t\tkind: \"timeout\",\n\t\t\t\t\t\t\ttag,\n\t\t\t\t\t\t\ttimeoutMs: loadTimeoutMs,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t\treject(new AdapterFailure(reasons));\n\t\t\t\t}, loadTimeoutMs);\n\t\t\t}),\n\t\t]);\n\t} finally {\n\t\tif (timer) clearTimeout(timer);\n\t}\n}\n\n/**\n * Synchronously assert that every tag is already in `customElements`.\n * Throws `ElementAssertionError` with diagnostic detail otherwise.\n *\n * Used by hosts that opt into the \"preloaded\" strategy — they pre-register\n * elements out-of-band and want a loud failure if anything is missing.\n */\nexport function assertRegistered(tags: ElementTag[]): void {\n\tif (!tags || tags.length === 0) return;\n\tconst missing = tags.filter((tag) => !isRegistered(tag));\n\tif (missing.length === 0) return;\n\tthrow new ElementAssertionError(tags, missing, snapshotRegisteredTags());\n}\n\n// ─── Internals ───────────────────────────────────────────────────────────────\n\nfunction resolveBackend(backend: BackendOption): ElementLoaderBackend {\n\tif (isDirectBackend(backend)) return backend;\n\tif (\"kind\" in backend) {\n\t\tif (backend.kind === \"iife\") return createIifeBackend(backend);\n\t\tif (backend.kind === \"esm\") {\n\t\t\tconst backendKey = backendKeyOf(backend);\n\t\t\tconst override = resolvedBackendOverrides.get(backendKey);\n\t\t\tif (override) return override;\n\t\t\tconst existing = resolvedEsmBackends.get(backendKey);\n\t\t\tif (existing) return existing;\n\t\t\tconst created = createEsmBackend(backend);\n\t\t\tresolvedEsmBackends.set(backendKey, created);\n\t\t\treturn created;\n\t\t}\n\t}\n\tthrow new Error(\"ElementLoader: invalid backend option\");\n}\n\nfunction isDirectBackend(\n\tbackend: BackendOption,\n): backend is ElementLoaderBackend {\n\treturn (\n\t\ttypeof (backend as { load?: unknown }).load === \"function\" &&\n\t\t!(\"kind\" in backend)\n\t);\n}\n\nfunction resolveDoc(doc: Document | undefined): Document {\n\tif (doc) return doc;\n\tif (typeof document !== \"undefined\") return document;\n\tthrow new Error(\n\t\t\"ElementLoader: no Document available; pass options.doc explicitly\",\n\t);\n}\n\nfunction buildDedupKey(backend: BackendOption, elements: ElementMap): string {\n\tconst backendKey = backendKeyOf(backend);\n\tconst entries = Object.entries(elements).sort(([a], [b]) =>\n\t\ta.localeCompare(b),\n\t);\n\treturn `${backendKey}|${JSON.stringify(entries)}`;\n}\n\nconst backendIds = new WeakMap<ElementLoaderBackend, string>();\nlet nextBackendId = 0;\nconst functionIds = new WeakMap<Function, string>();\nlet nextFunctionId = 0;\nconst opaqueObjectIds = new WeakMap<object, string>();\nlet nextOpaqueObjectId = 0;\n\nfunction backendKeyOf(backend: BackendOption): string {\n\tif (isDirectBackend(backend)) {\n\t\tlet id = backendIds.get(backend);\n\t\tif (!id) {\n\t\t\tid = `b${++nextBackendId}`;\n\t\t\tbackendIds.set(backend, id);\n\t\t}\n\t\treturn `backend#${id}`;\n\t}\n\tif (\"kind\" in backend) {\n\t\tif (backend.kind === \"iife\") {\n\t\t\treturn `iife#${fingerprintValue({\n\t\t\t\tkind: \"iife\",\n\t\t\t\tbundleHost: backend.bundleHost,\n\t\t\t\tbundleType: backend.bundleType ?? \"\",\n\t\t\t\tneedsControllers: backend.needsControllers ?? true,\n\t\t\t\tbundleInfo: backend.bundleInfo ?? null,\n\t\t\t\tdebugEnabled: backend.debugEnabled ?? null,\n\t\t\t\tbundleRetry: backend.bundleRetry ?? null,\n\t\t\t\tonBundleRetryStatus: backend.onBundleRetryStatus ?? null,\n\t\t\t\ttrackPageActions: backend.trackPageActions ?? false,\n\t\t\t\tinstrumentationProvider: backend.instrumentationProvider ?? null,\n\t\t\t})}`;\n\t\t}\n\t\tif (backend.kind === \"esm\") {\n\t\t\treturn `esm#${fingerprintValue({\n\t\t\t\tkind: \"esm\",\n\t\t\t\tcdnBaseUrl: backend.cdnBaseUrl,\n\t\t\t\tcdnProvider: backend.cdnProvider ?? null,\n\t\t\t\tmoduleResolution: backend.moduleResolution ?? \"url\",\n\t\t\t\tview: backend.view ?? \"delivery\",\n\t\t\t\tviewConfig: backend.viewConfig ?? null,\n\t\t\t\tloadControllers: backend.loadControllers ?? true,\n\t\t\t\tdebugEnabled: backend.debugEnabled ?? null,\n\t\t\t\ttrackPageActions: backend.trackPageActions ?? false,\n\t\t\t\tinstrumentationProvider: backend.instrumentationProvider ?? null,\n\t\t\t})}`;\n\t\t}\n\t}\n\treturn \"unknown\";\n}\n\nfunction fingerprintValue(value: unknown): string {\n\treturn JSON.stringify(normalizeForFingerprint(value, new Map()));\n}\n\nfunction normalizeForFingerprint(\n\tvalue: unknown,\n\tseen: Map<object, string>,\n): unknown {\n\tif (value === null || value === undefined) return value;\n\tconst primitiveType = typeof value;\n\tif (\n\t\tprimitiveType === \"string\" ||\n\t\tprimitiveType === \"number\" ||\n\t\tprimitiveType === \"boolean\"\n\t) {\n\t\treturn value;\n\t}\n\tif (primitiveType === \"function\") {\n\t\treturn { __functionRef: getFunctionRefId(value as Function) };\n\t}\n\tif (primitiveType !== \"object\") {\n\t\treturn String(value);\n\t}\n\n\tconst objectValue = value as object;\n\tconst existing = seen.get(objectValue);\n\tif (existing) return { __cycleRef: existing };\n\tconst cycleRefId = `cycle#${seen.size + 1}`;\n\tseen.set(objectValue, cycleRefId);\n\n\tif (Array.isArray(value)) {\n\t\treturn value.map((entry) => normalizeForFingerprint(entry, seen));\n\t}\n\n\tif (!isPlainObject(value)) {\n\t\treturn { __objectRef: getOpaqueObjectRefId(objectValue) };\n\t}\n\n\tconst normalized: Record<string, unknown> = {};\n\tfor (const key of Object.keys(value).sort()) {\n\t\tnormalized[key] = normalizeForFingerprint(\n\t\t\t(value as Record<string, unknown>)[key],\n\t\t\tseen,\n\t\t);\n\t}\n\treturn normalized;\n}\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n\tif (!value || typeof value !== \"object\") return false;\n\tconst prototype = Object.getPrototypeOf(value);\n\treturn prototype === Object.prototype || prototype === null;\n}\n\nfunction getFunctionRefId(fn: Function): string {\n\tlet id = functionIds.get(fn);\n\tif (!id) {\n\t\tid = `fn#${++nextFunctionId}`;\n\t\tfunctionIds.set(fn, id);\n\t}\n\treturn id;\n}\n\nfunction getOpaqueObjectRefId(value: object): string {\n\tlet id = opaqueObjectIds.get(value);\n\tif (!id) {\n\t\tid = `obj#${++nextOpaqueObjectId}`;\n\t\topaqueObjectIds.set(value, id);\n\t}\n\treturn id;\n}\n\nfunction allAlreadyRegistered(tags: ElementTag[]): boolean {\n\treturn tags.every((tag) => isRegistered(tag));\n}\n\nfunction isRegistered(tag: ElementTag): boolean {\n\tif (typeof customElements === \"undefined\") return false;\n\treturn customElements.get(tag) !== undefined;\n}\n\nasync function whenDefinedWithTimeout(\n\ttag: ElementTag,\n\ttimeoutMs: number,\n): Promise<void> {\n\tif (typeof customElements === \"undefined\") {\n\t\tthrow new Error(`no customElements to await ${tag}`);\n\t}\n\tlet timer: ReturnType<typeof setTimeout> | undefined;\n\ttry {\n\t\treturn await Promise.race([\n\t\t\tcustomElements.whenDefined(tag).then(() => undefined),\n\t\t\tnew Promise<void>((_, reject) => {\n\t\t\t\ttimer = setTimeout(\n\t\t\t\t\t() => reject(new Error(`Timeout waiting for ${tag}`)),\n\t\t\t\t\ttimeoutMs,\n\t\t\t\t);\n\t\t\t}),\n\t\t]);\n\t} finally {\n\t\tif (timer) clearTimeout(timer);\n\t}\n}\n\nfunction snapshotRegisteredTags(): ElementTag[] {\n\tif (typeof customElements === \"undefined\") return [];\n\t// Standard `CustomElementRegistry` does not expose iteration. Tests install\n\t// a scripted registry with a `__pieSnapshot` extension to make diagnostic\n\t// messages assertable. Production falls through to an empty list —\n\t// still strictly better than today's \"missing tags: X\" error which leaks\n\t// no registry state at all.\n\tconst reg = customElements as unknown as {\n\t\t__pieSnapshot?: () => ElementTag[];\n\t};\n\tif (typeof reg.__pieSnapshot === \"function\") {\n\t\ttry {\n\t\t\treturn reg.__pieSnapshot();\n\t\t} catch {\n\t\t\treturn [];\n\t\t}\n\t}\n\treturn [];\n}\n\nfunction extractAdapterReason(\n\terr: Error | undefined,\n\ttag: ElementTag,\n): RegistrationFailureReason | undefined {\n\tif (!err) return undefined;\n\tif (err instanceof AdapterFailure) return err.reasons.get(tag);\n\treturn { kind: \"backend-rejected\", tag, cause: err.message };\n}\n\n// ─── Test-only helpers ───────────────────────────────────────────────────────\n\n/**\n * Internal helpers for test harnesses. Not part of the public runtime API;\n * production code should never reach for these.\n *\n * @internal\n */\nexport const __testing = {\n\tresetDedupState(): void {\n\t\tinFlightRequests.clear();\n\t\tresolvedEsmBackends.clear();\n\t\tresolvedBackendOverrides.clear();\n\t},\n\tinFlightCount(): number {\n\t\treturn inFlightRequests.size;\n\t},\n\tdedupKeyFor(elements: ElementMap, backend: BackendOption): string {\n\t\treturn buildDedupKey(backend, elements);\n\t},\n\treplaceResolvedBackendForTesting(\n\t\tbackend: BackendOption,\n\t\tresolvedBackend: ElementLoaderBackend,\n\t): void {\n\t\tresolvedBackendOverrides.set(backendKeyOf(backend), resolvedBackend);\n\t},\n\trestoreResolvedBackendsForTesting(): void {\n\t\tresolvedEsmBackends.clear();\n\t\tresolvedBackendOverrides.clear();\n\t},\n};\n"]}
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* ESM backend adapter for the ElementLoader primitive.
|
|
3
3
|
*
|
|
4
|
-
* Loads PIE elements via dynamic `import()` from
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
4
|
+
* Loads PIE elements via dynamic `import()` from static browser ESM files on a
|
|
5
|
+
* CDN, optionally resolving bare specifiers through an import map injected into
|
|
6
|
+
* the host document. On any per-tag failure (module load, non-constructor
|
|
7
|
+
* element class, define failure), throws `AdapterFailure` with a structured
|
|
8
|
+
* `reasons` map.
|
|
9
9
|
*
|
|
10
10
|
* Like the IIFE adapter, this module does not gate its own promise on
|
|
11
11
|
* `customElements.whenDefined`; the primitive performs that verification
|
|
12
12
|
* uniformly. Here the adapter's job is narrowly to fetch, extract, and
|
|
13
13
|
* call `customElements.define`.
|
|
14
14
|
*/
|
|
15
|
+
import type { InstrumentationProvider } from "../instrumentation/types.js";
|
|
15
16
|
import { type ElementLoaderBackend } from "./element-loader-types.js";
|
|
16
17
|
/** View configuration: how a PIE package's subpath maps to a tag suffix. */
|
|
17
18
|
export type ViewConfig = {
|
|
@@ -20,10 +21,22 @@ export type ViewConfig = {
|
|
|
20
21
|
fallback?: string;
|
|
21
22
|
};
|
|
22
23
|
export declare const BUILT_IN_VIEWS: Record<string, ViewConfig>;
|
|
24
|
+
export type BuiltInEsmCdnProviderName = "jsdelivr" | "esm.sh";
|
|
25
|
+
export type EsmCdnProviderName = BuiltInEsmCdnProviderName | (string & {});
|
|
26
|
+
export type EsmCdnProvider = {
|
|
27
|
+
name: EsmCdnProviderName;
|
|
28
|
+
packageJsonUrl(packageVersion: string): string;
|
|
29
|
+
browserViewUrl(packageVersion: string, view: string): string;
|
|
30
|
+
browserControllerUrl(packageVersion: string): string;
|
|
31
|
+
sharedDependencyUrl(dependencyName: string, version: string, subpath?: string): string;
|
|
32
|
+
};
|
|
33
|
+
export type EsmCdnProviderOption = EsmCdnProviderName | EsmCdnProvider;
|
|
23
34
|
export type EsmBackendConfig = {
|
|
24
35
|
kind: "esm";
|
|
25
36
|
/** Base URL for the ESM CDN (e.g., "https://esm.sh"). */
|
|
26
37
|
cdnBaseUrl: string;
|
|
38
|
+
/** CDN URL strategy. Defaults to jsDelivr, or is inferred from cdnBaseUrl when possible. */
|
|
39
|
+
cdnProvider?: EsmCdnProviderOption;
|
|
27
40
|
/** `"url"` loads via fully-qualified URLs; `"import-map"` uses bare specifiers. */
|
|
28
41
|
moduleResolution?: "url" | "import-map";
|
|
29
42
|
/** View to load (`delivery`, `author`, `print`, or a custom name). */
|
|
@@ -34,6 +47,10 @@ export type EsmBackendConfig = {
|
|
|
34
47
|
loadControllers?: boolean;
|
|
35
48
|
/** Debug flag hook. */
|
|
36
49
|
debugEnabled?: () => boolean;
|
|
50
|
+
/** Whether ESM dependency conflict/failure events should be instrumented. */
|
|
51
|
+
trackPageActions?: boolean;
|
|
52
|
+
/** Instrumentation provider for ESM dependency conflict/failure events. */
|
|
53
|
+
instrumentationProvider?: InstrumentationProvider;
|
|
37
54
|
};
|
|
38
55
|
export type EsmBackend = ElementLoaderBackend & {};
|
|
39
56
|
export declare function createEsmBackend(config: EsmBackendConfig): EsmBackend;
|