@pie-players/pie-players-shared 0.3.43 → 0.3.44
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/dist/config/profile.d.ts +0 -1
- package/dist/config/profile.js.map +1 -1
- package/dist/i18n/index.d.ts +0 -3
- package/dist/i18n/index.js +0 -2
- package/dist/i18n/index.js.map +1 -1
- package/dist/i18n/loader.d.ts +0 -1
- package/dist/i18n/loader.js.map +1 -1
- package/dist/i18n/simple-i18n.d.ts +0 -1
- package/dist/i18n/simple-i18n.js.map +1 -1
- package/dist/i18n/types.d.ts +0 -1
- package/dist/i18n/types.js.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -4
- package/dist/index.js.map +1 -1
- package/dist/instrumentation/debug-panel-stream.d.ts +0 -1
- package/dist/instrumentation/debug-panel-stream.js.map +1 -1
- package/dist/instrumentation/index.d.ts +0 -1
- package/dist/instrumentation/index.js.map +1 -1
- package/dist/instrumentation/provider-guards.d.ts +0 -1
- package/dist/instrumentation/provider-guards.js.map +1 -1
- package/dist/instrumentation/providers/BaseInstrumentationProvider.d.ts +0 -1
- package/dist/instrumentation/providers/BaseInstrumentationProvider.js.map +1 -1
- package/dist/instrumentation/providers/CompositeInstrumentationProvider.d.ts +0 -1
- package/dist/instrumentation/providers/CompositeInstrumentationProvider.js.map +1 -1
- package/dist/instrumentation/providers/ConsoleInstrumentationProvider.d.ts +0 -1
- package/dist/instrumentation/providers/ConsoleInstrumentationProvider.js.map +1 -1
- package/dist/instrumentation/providers/DebugPanelInstrumentationProvider.d.ts +0 -1
- package/dist/instrumentation/providers/DebugPanelInstrumentationProvider.js.map +1 -1
- package/dist/instrumentation/providers/NewRelicInstrumentationProvider.d.ts +0 -1
- package/dist/instrumentation/providers/NewRelicInstrumentationProvider.js.map +1 -1
- package/dist/instrumentation/providers/index.d.ts +0 -1
- package/dist/instrumentation/providers/index.js.map +1 -1
- package/dist/instrumentation/types.d.ts +0 -1
- package/dist/instrumentation/types.js.map +1 -1
- package/dist/loader-config.d.ts +0 -1
- package/dist/loader-config.js.map +1 -1
- package/dist/loaders/ElementLoader.d.ts +0 -1
- package/dist/loaders/ElementLoader.js.map +1 -1
- package/dist/loaders/element-loader-types.d.ts +0 -1
- package/dist/loaders/element-loader-types.js.map +1 -1
- package/dist/loaders/element-loader.d.ts +0 -1
- package/dist/loaders/element-loader.js.map +1 -1
- package/dist/loaders/esm-adapter.d.ts +0 -1
- package/dist/loaders/esm-adapter.js.map +1 -1
- package/dist/loaders/iife-adapter.d.ts +0 -1
- package/dist/loaders/iife-adapter.js.map +1 -1
- package/dist/loaders/index.d.ts +0 -1
- package/dist/loaders/index.js.map +1 -1
- package/dist/object/index.d.ts +0 -1
- package/dist/object/index.js.map +1 -1
- package/dist/pie/asset-handler.d.ts +0 -1
- package/dist/pie/asset-handler.js.map +1 -1
- package/dist/pie/authoring.d.ts +0 -1
- package/dist/pie/authoring.js.map +1 -1
- package/dist/pie/component-context.d.ts +0 -1
- package/dist/pie/component-context.js.map +1 -1
- package/dist/pie/config.d.ts +0 -1
- package/dist/pie/config.js.map +1 -1
- package/dist/pie/configure-initialization.d.ts +0 -1
- package/dist/pie/configure-initialization.js.map +1 -1
- package/dist/pie/correct-response-env.d.ts +0 -1
- package/dist/pie/correct-response-env.js.map +1 -1
- package/dist/pie/custom-element-define.d.ts +0 -1
- package/dist/pie/custom-element-define.js.map +1 -1
- package/dist/pie/index.d.ts +4 -9
- package/dist/pie/index.js +4 -8
- package/dist/pie/index.js.map +1 -1
- package/dist/pie/initialization.d.ts +0 -1
- package/dist/pie/initialization.js.map +1 -1
- package/dist/pie/instrumentation-event-bridge.d.ts +0 -1
- package/dist/pie/instrumentation-event-bridge.js.map +1 -1
- package/dist/pie/instrumentation-event-map.d.ts +0 -1
- package/dist/pie/instrumentation-event-map.js.map +1 -1
- package/dist/pie/instrumentation-provider-resolution.d.ts +0 -1
- package/dist/pie/instrumentation-provider-resolution.js.map +1 -1
- package/dist/pie/item-controller-storage.d.ts +0 -1
- package/dist/pie/item-controller-storage.js.map +1 -1
- package/dist/pie/item-controller.d.ts +0 -1
- package/dist/pie/item-controller.js.map +1 -1
- package/dist/pie/item-session-contract.d.ts +0 -1
- package/dist/pie/item-session-contract.js.map +1 -1
- package/dist/pie/logger.d.ts +0 -1
- package/dist/pie/logger.js.map +1 -1
- package/dist/pie/math-rendering.d.ts +0 -1
- package/dist/pie/math-rendering.js.map +1 -1
- package/dist/pie/overrides.d.ts +0 -1
- package/dist/pie/overrides.js.map +1 -1
- package/dist/pie/player-initializer.d.ts +0 -1
- package/dist/pie/player-initializer.js.map +1 -1
- package/dist/pie/registry.d.ts +0 -1
- package/dist/pie/registry.js.map +1 -1
- package/dist/pie/resource-monitor.d.ts +0 -1
- package/dist/pie/resource-monitor.js.map +1 -1
- package/dist/pie/scoring.d.ts +0 -1
- package/dist/pie/scoring.js.map +1 -1
- package/dist/pie/stage-tracker.d.ts +0 -1
- package/dist/pie/stage-tracker.js.map +1 -1
- package/dist/pie/stages.d.ts +0 -1
- package/dist/pie/stages.js.map +1 -1
- package/dist/pie/tag-names.d.ts +0 -1
- package/dist/pie/tag-names.js.map +1 -1
- package/dist/pie/types.d.ts +0 -1
- package/dist/pie/types.js.map +1 -1
- package/dist/pie/updates.d.ts +0 -1
- package/dist/pie/updates.js.map +1 -1
- package/dist/pie/utils.d.ts +0 -1
- package/dist/pie/utils.js.map +1 -1
- package/dist/player-strategy.d.ts +0 -1
- package/dist/player-strategy.js.map +1 -1
- package/dist/security/index.d.ts +0 -1
- package/dist/security/index.js.map +1 -1
- package/dist/security/sanitize-item-markup.d.ts +0 -1
- package/dist/security/sanitize-item-markup.js.map +1 -1
- package/dist/security/sanitize-svg-icon.d.ts +0 -1
- package/dist/security/sanitize-svg-icon.js.map +1 -1
- package/dist/security/validate-style-url.d.ts +0 -1
- package/dist/security/validate-style-url.js.map +1 -1
- package/dist/security/wrap-overwide-images.d.ts +0 -1
- package/dist/security/wrap-overwide-images.js.map +1 -1
- package/dist/server/npm-registry.d.ts +0 -1
- package/dist/server/npm-registry.js.map +1 -1
- package/dist/types/index.d.ts +0 -1
- package/dist/types/index.js.map +1 -1
- package/dist/ui/debug-panel-persistence.d.ts +0 -1
- package/dist/ui/debug-panel-persistence.js.map +1 -1
- package/dist/ui/first-focusable.d.ts +0 -1
- package/dist/ui/first-focusable.js.map +1 -1
- package/dist/ui/focus-trap.d.ts +0 -1
- package/dist/ui/focus-trap.js.map +1 -1
- package/dist/ui/safe-storage.d.ts +0 -1
- package/dist/ui/safe-storage.js.map +1 -1
- package/package.json +6 -64
- package/dist/components/PieItemPlayer.svelte +0 -951
- package/dist/components/PiePreviewLayout.svelte +0 -154
- package/dist/components/PiePreviewToggle.svelte +0 -110
- package/dist/components/PieSpinner.svelte +0 -85
- package/dist/components/ToolSettingsButton.svelte +0 -62
- package/dist/components/ToolSettingsPanel.svelte +0 -104
- package/dist/components/index.ts +0 -6
- package/dist/config/profile.d.ts.map +0 -1
- package/dist/i18n/index.d.ts.map +0 -1
- package/dist/i18n/loader.d.ts.map +0 -1
- package/dist/i18n/simple-i18n.d.ts.map +0 -1
- package/dist/i18n/types.d.ts.map +0 -1
- package/dist/i18n/use-i18n-standalone.svelte.ts +0 -185
- package/dist/i18n/use-i18n.svelte.ts +0 -164
- package/dist/index.d.ts.map +0 -1
- package/dist/instrumentation/debug-panel-stream.d.ts.map +0 -1
- package/dist/instrumentation/index.d.ts.map +0 -1
- package/dist/instrumentation/provider-guards.d.ts.map +0 -1
- package/dist/instrumentation/providers/BaseInstrumentationProvider.d.ts.map +0 -1
- package/dist/instrumentation/providers/CompositeInstrumentationProvider.d.ts.map +0 -1
- package/dist/instrumentation/providers/ConsoleInstrumentationProvider.d.ts.map +0 -1
- package/dist/instrumentation/providers/DebugPanelInstrumentationProvider.d.ts.map +0 -1
- package/dist/instrumentation/providers/NewRelicInstrumentationProvider.d.ts.map +0 -1
- package/dist/instrumentation/providers/index.d.ts.map +0 -1
- package/dist/instrumentation/types.d.ts.map +0 -1
- package/dist/loader-config.d.ts.map +0 -1
- package/dist/loaders/ElementLoader.d.ts.map +0 -1
- package/dist/loaders/element-loader-types.d.ts.map +0 -1
- package/dist/loaders/element-loader.d.ts.map +0 -1
- package/dist/loaders/esm-adapter.d.ts.map +0 -1
- package/dist/loaders/iife-adapter.d.ts.map +0 -1
- package/dist/loaders/index.d.ts.map +0 -1
- package/dist/object/index.d.ts.map +0 -1
- package/dist/pie/asset-handler.d.ts.map +0 -1
- package/dist/pie/authoring.d.ts.map +0 -1
- package/dist/pie/component-context.d.ts.map +0 -1
- package/dist/pie/config.d.ts.map +0 -1
- package/dist/pie/configure-initialization.d.ts.map +0 -1
- package/dist/pie/correct-response-env.d.ts.map +0 -1
- package/dist/pie/custom-element-define.d.ts.map +0 -1
- package/dist/pie/index.d.ts.map +0 -1
- package/dist/pie/initialization.d.ts.map +0 -1
- package/dist/pie/instrumentation-event-bridge.d.ts.map +0 -1
- package/dist/pie/instrumentation-event-map.d.ts.map +0 -1
- package/dist/pie/instrumentation-provider-resolution.d.ts.map +0 -1
- package/dist/pie/item-controller-storage.d.ts.map +0 -1
- package/dist/pie/item-controller.d.ts.map +0 -1
- package/dist/pie/item-session-contract.d.ts.map +0 -1
- package/dist/pie/logger.d.ts.map +0 -1
- package/dist/pie/math-rendering.d.ts.map +0 -1
- package/dist/pie/overrides.d.ts.map +0 -1
- package/dist/pie/player-initializer.d.ts.map +0 -1
- package/dist/pie/registry.d.ts.map +0 -1
- package/dist/pie/resource-monitor.d.ts.map +0 -1
- package/dist/pie/scoring.d.ts.map +0 -1
- package/dist/pie/stage-tracker.d.ts.map +0 -1
- package/dist/pie/stages.d.ts.map +0 -1
- package/dist/pie/tag-names.d.ts.map +0 -1
- package/dist/pie/types.d.ts.map +0 -1
- package/dist/pie/updates.d.ts.map +0 -1
- package/dist/pie/use-resource-monitor.svelte.d.ts +0 -56
- package/dist/pie/use-resource-monitor.svelte.d.ts.map +0 -1
- package/dist/pie/use-resource-monitor.svelte.js +0 -176
- package/dist/pie/use-resource-monitor.svelte.js.map +0 -1
- package/dist/pie/utils.d.ts.map +0 -1
- package/dist/player-strategy.d.ts.map +0 -1
- package/dist/security/index.d.ts.map +0 -1
- package/dist/security/sanitize-item-markup.d.ts.map +0 -1
- package/dist/security/sanitize-svg-icon.d.ts.map +0 -1
- package/dist/security/validate-style-url.d.ts.map +0 -1
- package/dist/security/wrap-overwide-images.d.ts.map +0 -1
- package/dist/server/npm-registry.d.ts.map +0 -1
- package/dist/types/index.d.ts.map +0 -1
- package/dist/ui/debug-panel-persistence.d.ts.map +0 -1
- package/dist/ui/first-focusable.d.ts.map +0 -1
- package/dist/ui/focus-trap.d.ts.map +0 -1
- package/dist/ui/safe-storage.d.ts.map +0 -1
- package/dist/ui/use-promise.svelte.ts +0 -109
package/dist/config/profile.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profile.js","sourceRoot":"","sources":["../../src/config/profile.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,8EAA8E;AAC9E,4EAA4E;AAC5E,MAAM,0BAA0B,GAAG,2BAA2B,CAAC;AAC/D,MAAM,0BAA0B,GAAG,GAAG,0BAA0B,WAAW,CAAC;AAS5E,SAAS,aAAa,CAAC,GAAW;IACjC,IAAI,CAAC;QACJ,sBAAsB;QACtB,MAAM,CAAC,GAAI,MAAM,CAAC,IAAY,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC;QAC3C,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC;YAAE,OAAO,CAAC,CAAC;IACrD,CAAC;IAAC,MAAM,CAAC,CAAA,CAAC;IACV,OAAO,SAAS,CAAC;AAClB,CAAC;AAED,MAAM,CAAC,MAAM,kBAAkB,GAC9B,CAAC,OAAO,MAAM,KAAK,WAAW,IAAI,MAAM,CAAC,sBAAsB,CAAC;IAChE,aAAa,CAAC,2BAA2B,CAAC;IAC1C,0BAA0B,CAAC;AAE5B,MAAM,CAAC,MAAM,kBAAkB,GAC9B,CAAC,OAAO,MAAM,KAAK,WAAW,IAAI,MAAM,CAAC,sBAAsB,CAAC;IAChE,aAAa,CAAC,2BAA2B,CAAC;IAC1C,0BAA0B,CAAC"}
|
|
1
|
+
{"version":3,"file":"profile.js","sourceRoot":"","sources":["../../src/config/profile.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,8EAA8E;AAC9E,4EAA4E;AAC5E,MAAM,0BAA0B,GAAG,2BAA2B,CAAC;AAC/D,MAAM,0BAA0B,GAAG,GAAG,0BAA0B,WAAW,CAAC;AAS5E,SAAS,aAAa,CAAC,GAAW;IACjC,IAAI,CAAC;QACJ,sBAAsB;QACtB,MAAM,CAAC,GAAI,MAAM,CAAC,IAAY,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC;QAC3C,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC;YAAE,OAAO,CAAC,CAAC;IACrD,CAAC;IAAC,MAAM,CAAC,CAAA,CAAC;IACV,OAAO,SAAS,CAAC;AAClB,CAAC;AAED,MAAM,CAAC,MAAM,kBAAkB,GAC9B,CAAC,OAAO,MAAM,KAAK,WAAW,IAAI,MAAM,CAAC,sBAAsB,CAAC;IAChE,aAAa,CAAC,2BAA2B,CAAC;IAC1C,0BAA0B,CAAC;AAE5B,MAAM,CAAC,MAAM,kBAAkB,GAC9B,CAAC,OAAO,MAAM,KAAK,WAAW,IAAI,MAAM,CAAC,sBAAsB,CAAC;IAChE,aAAa,CAAC,2BAA2B,CAAC;IAC1C,0BAA0B,CAAC","sourcesContent":["/**\n * Minimal, frontend-safe defaults for PIE build service URLs.\n *\n * In PIEOneer, these come from `$env/dynamic/public`. In `pie-players` we avoid\n * SvelteKit env dependencies so this can be consumed by any bundler.\n */\n\n// Default public bundle host. Keep this aligned with the IIFE loader default.\n// (We prefer the proxy endpoint, which is stable/cached for browser usage.)\nconst DEFAULT_BUILDER_ORIGIN_URL = \"https://proxy.pie-api.com\";\nconst DEFAULT_BUILDER_BUNDLE_URL = `${DEFAULT_BUILDER_ORIGIN_URL}/bundles/`;\n\ndeclare global {\n\tinterface Window {\n\t\tPIE_BUILDER_ORIGIN_URL?: string;\n\t\tPIE_BUILDER_BUNDLE_URL?: string;\n\t}\n}\n\nfunction readPublicEnv(key: string): string | undefined {\n\ttry {\n\t\t// Vite/SvelteKit-like\n\t\tconst v = (import.meta as any)?.env?.[key];\n\t\tif (typeof v === \"string\" && v.length > 0) return v;\n\t} catch {}\n\treturn undefined;\n}\n\nexport const BUILDER_ORIGIN_URL =\n\t(typeof window !== \"undefined\" && window.PIE_BUILDER_ORIGIN_URL) ||\n\treadPublicEnv(\"PUBLIC_BUILDER_ORIGIN_URL\") ||\n\tDEFAULT_BUILDER_ORIGIN_URL;\n\nexport const BUILDER_BUNDLE_URL =\n\t(typeof window !== \"undefined\" && window.PIE_BUILDER_BUNDLE_URL) ||\n\treadPublicEnv(\"PUBLIC_BUILDER_BUNDLE_URL\") ||\n\tDEFAULT_BUILDER_BUNDLE_URL;\n"]}
|
package/dist/i18n/index.d.ts
CHANGED
|
@@ -8,6 +8,3 @@
|
|
|
8
8
|
export { BUNDLED_TRANSLATIONS, getAvailableLocales, isRTLLocale, loadTranslations, } from "./loader.js";
|
|
9
9
|
export { SimpleI18n } from "./simple-i18n.js";
|
|
10
10
|
export type { I18nConfig, I18nServiceApi, PluralTranslation, TranslationBundle, } from "./types.js";
|
|
11
|
-
export { useI18n } from "./use-i18n.svelte.js";
|
|
12
|
-
export { type UseI18nStandaloneConfig, useI18nStandalone, } from "./use-i18n-standalone.svelte.js";
|
|
13
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/i18n/index.js
CHANGED
|
@@ -7,6 +7,4 @@
|
|
|
7
7
|
*/
|
|
8
8
|
export { BUNDLED_TRANSLATIONS, getAvailableLocales, isRTLLocale, loadTranslations, } from "./loader.js";
|
|
9
9
|
export { SimpleI18n } from "./simple-i18n.js";
|
|
10
|
-
export { useI18n } from "./use-i18n.svelte.js";
|
|
11
|
-
export { useI18nStandalone, } from "./use-i18n-standalone.svelte.js";
|
|
12
10
|
//# sourceMappingURL=index.js.map
|
package/dist/i18n/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/i18n/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACN,oBAAoB,EACpB,mBAAmB,EACnB,WAAW,EACX,gBAAgB,GAChB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/i18n/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACN,oBAAoB,EACpB,mBAAmB,EACnB,WAAW,EACX,gBAAgB,GAChB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC","sourcesContent":["/**\n * I18n Module\n *\n * Internationalization system for PIE Players.\n *\n * @module @pie-players/pie-players-shared/i18n\n */\n\nexport {\n\tBUNDLED_TRANSLATIONS,\n\tgetAvailableLocales,\n\tisRTLLocale,\n\tloadTranslations,\n} from \"./loader.js\";\nexport { SimpleI18n } from \"./simple-i18n.js\";\nexport type {\n\tI18nConfig,\n\tI18nServiceApi,\n\tPluralTranslation,\n\tTranslationBundle,\n} from \"./types.js\";\n"]}
|
package/dist/i18n/loader.d.ts
CHANGED
package/dist/i18n/loader.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loader.js","sourceRoot":"","sources":["../../src/i18n/loader.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,wCAAwC;AACxC,OAAO,QAAQ,MAAM,+BAA+B,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE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CAAC;YACP,uBAAuB;YACvB,MAAM,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC;QACxB,CAAC;IACF,CAAC;IAED,OAAO,MAAM,CAAC;AACf,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,mBAAmB;IAClC,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;AACjC,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CAAC,MAAc;IACzC,OAAO,WAAW,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;AACrC,CAAC","sourcesContent":["/**\n * Translation Loader\n *\n * Implements hybrid loading strategy:\n * - English bundled with application\n * - Other languages loaded on demand\n *\n * Part of PIE Players i18n system.\n */\n\n// Import English translations (bundled)\nimport enCommon from \"./translations/en/common.json\" with { type: \"json\" };\nimport enToolkit from \"./translations/en/toolkit.json\" with { type: \"json\" };\nimport enTools from \"./translations/en/tools.json\" with { type: \"json\" };\nimport type { TranslationBundle } from \"./types.js\";\n\n// RTL locales\nconst RTL_LOCALES = [\"ar\", \"he\", \"fa\", \"ur\"];\n\n/**\n * Bundled English translations\n * Available immediately without network request\n */\nexport const BUNDLED_TRANSLATIONS: Record<string, TranslationBundle> = {\n\ten: {\n\t\tlocale: \"en\",\n\t\tdirection: \"ltr\",\n\t\ttranslations: {\n\t\t\t...flattenTranslations(enCommon),\n\t\t\t...flattenTranslations(enToolkit),\n\t\t\t...flattenTranslations(enTools),\n\t\t},\n\t},\n};\n\nconst LOCALE_IMPORTS: Record<string, () => Promise<[any, any, any]>> = {\n\tes: () =>\n\t\tPromise.all([\n\t\t\timport(\"./translations/es/common.json\"),\n\t\t\timport(\"./translations/es/toolkit.json\"),\n\t\t\timport(\"./translations/es/tools.json\"),\n\t\t]),\n\tzh: () =>\n\t\tPromise.all([\n\t\t\timport(\"./translations/zh/common.json\"),\n\t\t\timport(\"./translations/zh/toolkit.json\"),\n\t\t\timport(\"./translations/zh/tools.json\"),\n\t\t]),\n\tar: () =>\n\t\tPromise.all([\n\t\t\timport(\"./translations/ar/common.json\"),\n\t\t\timport(\"./translations/ar/toolkit.json\"),\n\t\t\timport(\"./translations/ar/tools.json\"),\n\t\t]),\n};\n\n/**\n * Load translations for a locale\n *\n * @param locale Locale code (e.g., 'en', 'es', 'zh', 'ar')\n * @returns Translation bundle with flattened keys\n */\nexport async function loadTranslations(\n\tlocale: string,\n): Promise<TranslationBundle> {\n\t// Return bundled English immediately\n\tif (locale === \"en\") {\n\t\treturn BUNDLED_TRANSLATIONS.en;\n\t}\n\n\tconst importer = LOCALE_IMPORTS[locale];\n\tif (!importer) {\n\t\tthrow new Error(\n\t\t\t`Translation files not found for locale: ${locale}. Ensure translation files exist in packages/players-shared/src/i18n/translations/${locale}/`,\n\t\t);\n\t}\n\n\t// Lazy load other locales\n\ttry {\n\t\tconst [common, toolkit, tools] = await importer();\n\n\t\treturn {\n\t\t\tlocale,\n\t\t\tdirection: RTL_LOCALES.includes(locale) ? \"rtl\" : \"ltr\",\n\t\t\ttranslations: {\n\t\t\t\t...flattenTranslations(common.default || common),\n\t\t\t\t...flattenTranslations(toolkit.default || toolkit),\n\t\t\t\t...flattenTranslations(tools.default || tools),\n\t\t\t},\n\t\t};\n\t} catch (error) {\n\t\tconsole.error(`Failed to load translations for locale: ${locale}`, error);\n\t\tthrow new Error(\n\t\t\t`Translation files not found for locale: ${locale}. Ensure translation files exist in packages/players-shared/src/i18n/translations/${locale}/`,\n\t\t);\n\t}\n}\n\n/**\n * Flatten nested JSON to dot notation\n *\n * Converts:\n * { \"common\": { \"save\": \"Save\" } }\n *\n * To:\n * { \"common.save\": \"Save\" }\n *\n * @param obj Nested translation object\n * @param prefix Current key prefix\n * @param result Accumulated result\n * @returns Flattened translation object\n */\nfunction flattenTranslations(\n\tobj: any,\n\tprefix = \"\",\n\tresult: Record<string, any> = {},\n): Record<string, any> {\n\tfor (const [key, value] of Object.entries(obj)) {\n\t\tconst newKey = prefix ? `${prefix}.${key}` : key;\n\n\t\tif (value && typeof value === \"object\" && !Array.isArray(value)) {\n\t\t\t// Check if it's a plural form (has 'one' or 'other' keys)\n\t\t\tif (\"one\" in value || \"other\" in value) {\n\t\t\t\t// This is a plural translation, keep it as an object\n\t\t\t\tresult[newKey] = value;\n\t\t\t} else {\n\t\t\t\t// This is a nested object, flatten recursively\n\t\t\t\tflattenTranslations(value, newKey, result);\n\t\t\t}\n\t\t} else {\n\t\t\t// This is a leaf value\n\t\t\tresult[newKey] = value;\n\t\t}\n\t}\n\n\treturn result;\n}\n\n/**\n * Get available locales\n *\n * @returns Array of locale codes\n */\nexport function getAvailableLocales(): string[] {\n\treturn [\"en\", \"es\", \"zh\", \"ar\"];\n}\n\n/**\n * Check if locale is RTL\n *\n * @param locale Locale code\n * @returns True if locale is right-to-left\n */\nexport function isRTLLocale(locale: string): boolean {\n\treturn RTL_LOCALES.includes(locale);\n}\n"]}
|
|
@@ -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,OAA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;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 { 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"]}
|
package/dist/i18n/types.d.ts
CHANGED
package/dist/i18n/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/i18n/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/i18n/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG","sourcesContent":["/**\n * I18n Type Definitions\n *\n * Shared types for internationalization system.\n * Defined in players-shared to avoid circular dependencies.\n */\n\n/**\n * Plural translation forms\n * Follows ICU MessageFormat plural rules\n */\nexport interface PluralTranslation {\n\tzero?: string;\n\tone: string;\n\tfew?: string;\n\tmany?: string;\n\tother: string;\n}\n\n/**\n * Translation bundle structure\n */\nexport interface TranslationBundle {\n\tlocale: string;\n\ttranslations: Record<string, string | PluralTranslation>;\n\tdirection: \"ltr\" | \"rtl\";\n}\n\n/**\n * I18n configuration\n */\nexport interface I18nConfig {\n\t/** Initial locale (default: browser language) */\n\tlocale?: string;\n\n\t/** Fallback locale (default: 'en') */\n\tfallbackLocale?: string;\n\n\t/** Translation loader function */\n\tloadTranslations?: (locale: string) => Promise<TranslationBundle>;\n\n\t/** Bundled translations (for hybrid loading) */\n\tbundledTranslations?: Record<string, TranslationBundle>;\n\n\t/** Missing key handler */\n\tonMissingKey?: (key: string, locale: string) => void;\n\n\t/** Debug mode */\n\tdebug?: boolean;\n}\n\n/**\n * I18nService API contract\n */\nexport interface I18nServiceApi {\n\tinitialize(config: I18nConfig): Promise<void>;\n\tt(key: string, params?: Record<string, any>): string;\n\ttn(key: string, count: number, params?: Record<string, any>): string;\n\tgetLocale(): string;\n\tsetLocale(locale: string): Promise<void>;\n\tgetDirection(): \"ltr\" | \"rtl\";\n\tgetAvailableLocales(): string[];\n\tisLocaleLoaded(locale: string): boolean;\n\tsubscribe(listener: () => void): () => void;\n\thasKey(key: string): boolean;\n}\n"]}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -12,8 +12,4 @@ export * from "./ui/focus-trap.js";
|
|
|
12
12
|
export * from "./ui/first-focusable.js";
|
|
13
13
|
export * from "./ui/debug-panel-persistence.js";
|
|
14
14
|
export * from "./ui/safe-storage.js";
|
|
15
|
-
// use-promise is a Svelte 5 runes module and is shipped as raw source via
|
|
16
|
-
// the `./ui/use-promise` subpath export. It is not re-exported here because
|
|
17
|
-
// tsc cannot compile `.svelte.ts` runes correctly; the consumer's Svelte
|
|
18
|
-
// plugin processes it at consume time.
|
|
19
15
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,0CAA0C;AAC1C,cAAc,gBAAgB,CAAC;AAmB/B,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC;AACxC,cAAc,iCAAiC,CAAC;AAChD,cAAc,sBAAsB,CAAC
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,0CAA0C;AAC1C,cAAc,gBAAgB,CAAC;AAmB/B,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC;AACxC,cAAc,iCAAiC,CAAC;AAChD,cAAc,sBAAsB,CAAC","sourcesContent":["export * from \"./config/profile.js\";\nexport * from \"./instrumentation/index.js\";\nexport * from \"./loader-config.js\";\nexport * from \"./player-strategy.js\";\nexport * from \"./security/index.js\";\nexport * from \"./loaders/index.js\";\nexport * from \"./object/index.js\";\n// Barrel export for PIE runtime utilities\nexport * from \"./pie/index.js\";\nexport type {\n\tAssessmentEntity,\n\tAssessmentItemRef,\n\tAssessmentSection,\n\tConfigEntity,\n\tEnv,\n\tItemConfig,\n\tItemEntity,\n\tLegacyAssessmentSection,\n\tOutcomeResponse,\n\tPassageEntity,\n\tPieController,\n\tPieModel,\n\tQuestionEntity,\n\tRubricBlock,\n\tSectionQuestionRef,\n\tTestPart,\n} from \"./types/index.js\";\nexport { editorPostFix } from \"./types/index.js\";\nexport * from \"./ui/focus-trap.js\";\nexport * from \"./ui/first-focusable.js\";\nexport * from \"./ui/debug-panel-persistence.js\";\nexport * from \"./ui/safe-storage.js\";\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,CAAC,MAAkC;IACtD,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,MAA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QACN,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE,IAAI,CAAC,UAAU;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"}
|
|
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,CAAC,MAAkC;IACtD,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,KA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,UAAU,EAAE,IAAI,CAAC,KAAK,EAAE,KAAK;KAC7B,CAAC;AACH,CAAC;AAED,MAAM,UAAU,uBAAuB,CAAC,IAMvC;IACA,OAAO;QACN,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE,IAAI,CAAC,UAAU;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(record: InstrumentationDebugRecord): 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>(INSTRUMENTATION_DEBUG_EVENT_NAME, {\n\t\t\tdetail: cloneRecord(nextRecord),\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"]}
|
|
@@ -34,4 +34,3 @@ export { isInstrumentationProvider } from "./provider-guards.js";
|
|
|
34
34
|
export { clearBufferedInstrumentationDebugRecords, getBufferedInstrumentationDebugRecords, INSTRUMENTATION_DEBUG_EVENT_NAME, subscribeInstrumentationDebugRecords, } from "./debug-panel-stream.js";
|
|
35
35
|
export type { InstrumentationDebugRecord } from "./debug-panel-stream.js";
|
|
36
36
|
export type { ErrorAttributes, EventAttributes, InstrumentationConfig, InstrumentationProvider, MetricAttributes, } from "./types.js";
|
|
37
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/instrumentation/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,YAAY;AACZ,cAAc,sBAAsB,CAAC;AACrC,OAAO,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,EACN,wCAAwC,EACxC,sCAAsC,EACtC,gCAAgC,EAChC,oCAAoC,GACpC,MAAM,yBAAyB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/instrumentation/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,YAAY;AACZ,cAAc,sBAAsB,CAAC;AACrC,OAAO,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,EACN,wCAAwC,EACxC,sCAAsC,EACtC,gCAAgC,EAChC,oCAAoC,GACpC,MAAM,yBAAyB,CAAC","sourcesContent":["/**\n * Instrumentation Module\n *\n * Provides pluggable instrumentation for PIE players.\n * Supports multiple providers (New Relic, console logging, custom, etc.)\n *\n * @example Using New Relic (default)\n * ```typescript\n * import { NewRelicInstrumentationProvider } from '@pie-players/pie-players-shared';\n *\n * const provider = new NewRelicInstrumentationProvider();\n * await provider.initialize();\n *\n * const monitor = new ResourceMonitor({\n * trackPageActions: true,\n * instrumentationProvider: provider\n * });\n * ```\n * @example Using console logger for development\n * ```typescript\n * import { ConsoleInstrumentationProvider } from '@pie-players/pie-players-shared';\n *\n * const provider = new ConsoleInstrumentationProvider();\n * await provider.initialize({ debug: true });\n *\n * const monitor = new ResourceMonitor({\n * trackPageActions: true,\n * instrumentationProvider: provider\n * });\n * ```\n */\n\n// Providers\nexport * from \"./providers/index.js\";\nexport { isInstrumentationProvider } from \"./provider-guards.js\";\nexport {\n\tclearBufferedInstrumentationDebugRecords,\n\tgetBufferedInstrumentationDebugRecords,\n\tINSTRUMENTATION_DEBUG_EVENT_NAME,\n\tsubscribeInstrumentationDebugRecords,\n} from \"./debug-panel-stream.js\";\nexport type { InstrumentationDebugRecord } from \"./debug-panel-stream.js\";\n// Core types\nexport type {\n\tErrorAttributes,\n\tEventAttributes,\n\tInstrumentationConfig,\n\tInstrumentationProvider,\n\tMetricAttributes,\n} from \"./types.js\";\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider-guards.js","sourceRoot":"","sources":["../../src/instrumentation/provider-guards.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,yBAAyB,CACxC,KAAc;IAEd,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IACtD,MAAM,SAAS,GAAG,KAAgC,CAAC;IACnD,OAAO,CACN,OAAO,SAAS,CAAC,UAAU,KAAK,QAAQ;QACxC,OAAO,SAAS,CAAC,YAAY,KAAK,QAAQ;QAC1C,OAAO,SAAS,CAAC,UAAU,KAAK,UAAU;QAC1C,OAAO,SAAS,CAAC,UAAU,KAAK,UAAU;QAC1C,OAAO,SAAS,CAAC,UAAU,KAAK,UAAU;QAC1C,OAAO,SAAS,CAAC,OAAO,KAAK,UAAU;QACvC,OAAO,SAAS,CAAC,OAAO,KAAK,UAAU,CACvC,CAAC;AACH,CAAC"}
|
|
1
|
+
{"version":3,"file":"provider-guards.js","sourceRoot":"","sources":["../../src/instrumentation/provider-guards.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,yBAAyB,CACxC,KAAc;IAEd,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IACtD,MAAM,SAAS,GAAG,KAAgC,CAAC;IACnD,OAAO,CACN,OAAO,SAAS,CAAC,UAAU,KAAK,QAAQ;QACxC,OAAO,SAAS,CAAC,YAAY,KAAK,QAAQ;QAC1C,OAAO,SAAS,CAAC,UAAU,KAAK,UAAU;QAC1C,OAAO,SAAS,CAAC,UAAU,KAAK,UAAU;QAC1C,OAAO,SAAS,CAAC,UAAU,KAAK,UAAU;QAC1C,OAAO,SAAS,CAAC,OAAO,KAAK,UAAU;QACvC,OAAO,SAAS,CAAC,OAAO,KAAK,UAAU,CACvC,CAAC;AACH,CAAC","sourcesContent":["import type { InstrumentationProvider } from \"./types.js\";\n\nexport function isInstrumentationProvider(\n\tvalue: unknown,\n): value is InstrumentationProvider {\n\tif (!value || typeof value !== \"object\") return false;\n\tconst candidate = value as Record<string, unknown>;\n\treturn (\n\t\ttypeof candidate.providerId === \"string\" &&\n\t\ttypeof candidate.providerName === \"string\" &&\n\t\ttypeof candidate.initialize === \"function\" &&\n\t\ttypeof candidate.trackError === \"function\" &&\n\t\ttypeof candidate.trackEvent === \"function\" &&\n\t\ttypeof candidate.destroy === \"function\" &&\n\t\ttypeof candidate.isReady === \"function\"\n\t);\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseInstrumentationProvider.js","sourceRoot":"","sources":["../../../src/instrumentation/providers/BaseInstrumentationProvider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAUH;;;;;;;;;GASG;AACH,MAAM,OAAgB,2BAA2B;IAMtC,WAAW,GAAG,KAAK,CAAC;IACpB,MAAM,CAAyB;IAwFzC,+EAA+E;IAC/E,wCAAwC;IACxC,+EAA+E;IAE/E;;;;;;;;;;;OAWG;IACH,UAAU,CAAC,KAAY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AAmB,CAC5B,UAA+B;QAE/B,IAAI,IAAI,CAAC,MAAM,EAAE,oBAAoB,EAAE,CAAC;YACvC,OAAO,IAAI,CAAC,MAAM,CAAC,oBAAoB,CAAC,UAAU,CAAC,CAAC;QACrD,CAAC;QACD,OAAO,UAAiC,CAAC;IAC1C,CAAC;CACD"}
|
|
1
|
+
{"version":3,"file":"BaseInstrumentationProvider.js","sourceRoot":"","sources":["../../../src/instrumentation/providers/BaseInstrumentationProvider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAUH;;;;;;;;;GASG;AACH,MAAM,OAAgB,2BAA2B;IAMtC,WAAW,GAAG,KAAK,CAAC;IACpB,MAAM,CAAyB;IAwFzC,+EAA+E;IAC/E,wCAAwC;IACxC,+EAA+E;IAE/E;;;;;;;;;;;OAWG;IACH,UAAU,CAAC,KAAY,EAAE,UAA2B;QACnD,oCAAoC;QACpC,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,YAAY,EAAE,KAAK,EAAE,UAAU,CAAC,EAAE,CAAC;YAC7D,OAAO;QACR,CAAC;QAED,qBAAqB;QACrB,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,KAAK,EAAE,UAAU,CAAC,EAAE,CAAC;YAC/C,OAAO;QACR,CAAC;QAED,uBAAuB;QACvB,MAAM,eAAe,GAAG,IAAI,CAAC,mBAAmB,CAAC,UAAU,CAAC,CAAC;QAE7D,gCAAgC;QAChC,IAAI,CAAC;YACJ,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,eAAe,CAAC,CAAC;YAE1C,IAAI,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,CAAC;gBACxB,OAAO,CAAC,GAAG,CACV,IAAI,IAAI,CAAC,YAAY,kBAAkB,EACvC,KAAK,EACL,eAAe,CACf,CAAC;YACH,CAAC;QACF,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACd,OAAO,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,YAAY,yBAAyB,EAAE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AAI,CAAC;IACb,CAAC;IAED;;;;;;;OAOG;IACO,aAAa,CAAC,SAAiB;QACxC,IAAI,IAAI,CAAC,MAAM,EAAE,UAAU,KAAK,SAAS,IAAI,IAAI,CAAC,MAAM,CAAC,UAAU,GAAG,GAAG,EAAE,CAAC;YAC3E,IAAI,IAAI,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;gBAC5C,IAAI,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,CAAC;oBACxB,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,YAAY,sBAAsB,EAAE,SAAS,CAAC,CAAC;gBACrE,CAAC;gBACD,OAAO,KAAK,CAAC;YACd,CAAC;QACF,CAAC;QACD,OAAO,IAAI,CAAC;IACb,CAAC;IAED;;;;;OAKG;IACO,mBAAmB,CAC5B,UAA+B;QAE/B,IAAI,IAAI,CAAC,MAAM,EAAE,oBAAoB,EAAE,CAAC;YACvC,OAAO,IAAI,CAAC,MAAM,CAAC,oBAAoB,CAAC,UAAU,CAAC,CAAC;QACrD,CAAC;QACD,OAAO,UAAiC,CAAC;IAC1C,CAAC;CACD","sourcesContent":["/**\n * Base Instrumentation Provider\n *\n * Abstract base class that implements common instrumentation logic for all providers.\n * Provides a template method pattern for tracking errors and events with consistent\n * filtering, transformation, and sampling behavior.\n *\n * Concrete providers only need to implement the actual tracking methods specific\n * to their instrumentation backend (New Relic, DataDog, etc.)\n */\n\nimport type {\n\tErrorAttributes,\n\tEventAttributes,\n\tInstrumentationConfig,\n\tInstrumentationProvider,\n\tMetricAttributes,\n} from \"../types.js\";\n\n/**\n * Abstract base class for instrumentation providers\n *\n * Implements the template method pattern:\n * 1. Checks if provider is ready\n * 2. Applies filters (errorFilter, eventFilter)\n * 3. Applies sampling (sampleRate)\n * 4. Transforms attributes (attributeTransformer)\n * 5. Delegates to concrete provider implementation (doTrackError, doTrackEvent, etc.)\n */\nexport abstract class BaseInstrumentationProvider\n\timplements InstrumentationProvider\n{\n\tabstract readonly providerId: string;\n\tabstract readonly providerName: string;\n\n\tprotected initialized = false;\n\tprotected config?: InstrumentationConfig;\n\n\t/**\n\t * Initialize the provider with configuration\n\t *\n\t * Concrete providers should override this method to perform provider-specific\n\t * initialization (e.g., loading SDK, checking global objects, etc.)\n\t *\n\t * @param config Optional configuration\n\t */\n\tabstract initialize(config?: InstrumentationConfig): Promise<void>;\n\n\t/**\n\t * Check if provider is ready to track events\n\t *\n\t * Concrete providers should override this method to check provider-specific\n\t * readiness (e.g., SDK loaded, global object available, etc.)\n\t *\n\t * @returns true if provider is ready\n\t */\n\tabstract isReady(): boolean;\n\n\t/**\n\t * Cleanup provider resources\n\t *\n\t * Concrete providers should override this method to perform provider-specific\n\t * cleanup (e.g., disconnect SDK, clear listeners, etc.)\n\t */\n\tabstract destroy(): void;\n\n\t// ============================================================================\n\t// Abstract methods that concrete providers MUST implement\n\t// ============================================================================\n\n\t/**\n\t * Track an error with the instrumentation backend\n\t *\n\t * Called by trackError() after all filters and transforms have been applied.\n\t * Concrete providers should implement the actual error tracking here.\n\t *\n\t * @param error The error to track\n\t * @param attributes Transformed and filtered attributes\n\t */\n\tprotected abstract doTrackError(\n\t\terror: Error,\n\t\tattributes: Record<string, any>,\n\t): void;\n\n\t/**\n\t * Track an event with the instrumentation backend\n\t *\n\t * Called by trackEvent() after all filters and transforms have been applied.\n\t * Concrete providers should implement the actual event tracking here.\n\t *\n\t * @param eventName Name of the event\n\t * @param attributes Transformed and filtered attributes\n\t */\n\tprotected abstract doTrackEvent(\n\t\teventName: string,\n\t\tattributes: Record<string, any>,\n\t): void;\n\n\t/**\n\t * Set user context in the instrumentation backend\n\t *\n\t * Called by setUserContext() after readiness check.\n\t * Concrete providers should implement the actual user context setting here.\n\t *\n\t * @param userId User identifier\n\t * @param attributes Optional user attributes\n\t */\n\tprotected abstract doSetUserContext(\n\t\tuserId: string,\n\t\tattributes?: Record<string, any>,\n\t): void;\n\n\t/**\n\t * Set global attributes in the instrumentation backend\n\t *\n\t * Called by setGlobalAttributes() after readiness check.\n\t * Concrete providers should implement the actual global attribute setting here.\n\t *\n\t * @param attributes Attributes to set globally\n\t */\n\tprotected abstract doSetGlobalAttributes(\n\t\tattributes: Record<string, any>,\n\t): void;\n\n\t// ============================================================================\n\t// Public API methods (template methods)\n\t// ============================================================================\n\n\t/**\n\t * Track an error with the instrumentation provider\n\t *\n\t * Template method that:\n\t * 1. Checks if provider is ready\n\t * 2. Applies error filter if configured\n\t * 3. Transforms attributes if configured\n\t * 4. Delegates to concrete provider implementation (doTrackError)\n\t *\n\t * @param error The error to track\n\t * @param attributes Contextual attributes\n\t */\n\ttrackError(error: Error, attributes: ErrorAttributes): void {\n\t\t// Guard: check if provider is ready\n\t\tif (!this.guardedOperation(\"trackError\", error, attributes)) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Apply error filter\n\t\tif (!this.applyErrorFilter(error, attributes)) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Transform attributes\n\t\tconst finalAttributes = this.transformAttributes(attributes);\n\n\t\t// Delegate to concrete provider\n\t\ttry {\n\t\t\tthis.doTrackError(error, finalAttributes);\n\n\t\t\tif (this.config?.debug) {\n\t\t\t\tconsole.log(\n\t\t\t\t\t`[${this.providerName}] Tracked error:`,\n\t\t\t\t\terror,\n\t\t\t\t\tfinalAttributes,\n\t\t\t\t);\n\t\t\t}\n\t\t} catch (err) {\n\t\t\tconsole.error(`[${this.providerName}] Error tracking error:`, err);\n\t\t}\n\t}\n\n\t/**\n\t * Track a custom event with the instrumentation provider\n\t *\n\t * Template method that:\n\t * 1. Checks if provider is ready\n\t * 2. Applies event filter if configured\n\t * 3. Applies sampling if configured\n\t * 4. Transforms attributes if configured\n\t * 5. Adds timestamp if not present\n\t * 6. Delegates to concrete provider implementation (doTrackEvent)\n\t *\n\t * @param eventName Name of the event\n\t * @param attributes Event attributes\n\t */\n\ttrackEvent(eventName: string, attributes: EventAttributes): void {\n\t\t// Guard: check if provider is ready\n\t\tif (!this.guardedOperation(\"trackEvent\", eventName, attributes)) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Apply event filter\n\t\tif (!this.applyEventFilter(eventName, attributes)) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Apply sampling\n\t\tif (!this.applySampling(eventName)) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Transform attributes\n\t\tlet finalAttributes = this.transformAttributes(attributes);\n\n\t\t// Add timestamp if not present\n\t\tif (!finalAttributes.timestamp) {\n\t\t\tfinalAttributes = {\n\t\t\t\t...finalAttributes,\n\t\t\t\ttimestamp: new Date().toISOString(),\n\t\t\t};\n\t\t}\n\n\t\t// Delegate to concrete provider\n\t\ttry {\n\t\t\tthis.doTrackEvent(eventName, finalAttributes);\n\n\t\t\tif (this.config?.debug) {\n\t\t\t\tconsole.log(\n\t\t\t\t\t`[${this.providerName}] Tracked event:`,\n\t\t\t\t\teventName,\n\t\t\t\t\tfinalAttributes,\n\t\t\t\t);\n\t\t\t}\n\t\t} catch (err) {\n\t\t\tconsole.error(`[${this.providerName}] Error tracking event:`, err);\n\t\t}\n\t}\n\n\t/**\n\t * Track a performance metric\n\t *\n\t * Default implementation tracks metrics as events with a `metric:` prefix.\n\t * Concrete providers can override this method if their backend has a\n\t * dedicated metric API.\n\t *\n\t * @param metricName Name of the metric\n\t * @param value Numeric value\n\t * @param attributes Optional metric attributes\n\t */\n\ttrackMetric(\n\t\tmetricName: string,\n\t\tvalue: number,\n\t\tattributes?: MetricAttributes,\n\t): void {\n\t\t// Default implementation: track as event\n\t\tthis.trackEvent(`metric:${metricName}`, {\n\t\t\t...attributes,\n\t\t\tmetricValue: value,\n\t\t\tmetricName,\n\t\t});\n\t}\n\n\t/**\n\t * Set user context for session tracking\n\t *\n\t * Template method that checks if provider is ready then delegates\n\t * to concrete provider implementation.\n\t *\n\t * @param userId User identifier\n\t * @param attributes Optional user attributes\n\t */\n\tsetUserContext(userId: string, attributes?: Record<string, any>): void {\n\t\t// Guard: check if provider is ready\n\t\tif (!this.guardedOperation(\"setUserContext\", userId, attributes)) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Delegate to concrete provider\n\t\ttry {\n\t\t\tthis.doSetUserContext(userId, attributes);\n\n\t\t\tif (this.config?.debug) {\n\t\t\t\tconsole.log(\n\t\t\t\t\t`[${this.providerName}] Set user context:`,\n\t\t\t\t\tuserId,\n\t\t\t\t\tattributes,\n\t\t\t\t);\n\t\t\t}\n\t\t} catch (err) {\n\t\t\tconsole.error(`[${this.providerName}] Error setting user context:`, err);\n\t\t}\n\t}\n\n\t/**\n\t * Set global custom attributes\n\t *\n\t * Template method that checks if provider is ready then delegates\n\t * to concrete provider implementation.\n\t *\n\t * @param attributes Attributes to set globally\n\t */\n\tsetGlobalAttributes(attributes: Record<string, any>): void {\n\t\t// Guard: check if provider is ready\n\t\tif (!this.guardedOperation(\"setGlobalAttributes\", attributes)) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Delegate to concrete provider\n\t\ttry {\n\t\t\tthis.doSetGlobalAttributes(attributes);\n\n\t\t\tif (this.config?.debug) {\n\t\t\t\tconsole.log(\n\t\t\t\t\t`[${this.providerName}] Set global attributes:`,\n\t\t\t\t\tattributes,\n\t\t\t\t);\n\t\t\t}\n\t\t} catch (err) {\n\t\t\tconsole.error(\n\t\t\t\t`[${this.providerName}] Error setting global attributes:`,\n\t\t\t\terr,\n\t\t\t);\n\t\t}\n\t}\n\n\t// ============================================================================\n\t// Protected utility methods (shared logic)\n\t// ============================================================================\n\n\t/**\n\t * Guard operation - check if provider is ready\n\t *\n\t * Returns false if provider is not ready, logging a warning in debug mode.\n\t *\n\t * @param operation Name of the operation for logging\n\t * @param args Arguments for logging\n\t * @returns true if provider is ready, false otherwise\n\t */\n\tprotected guardedOperation(operation: string, ...args: any[]): boolean {\n\t\tif (!this.isReady()) {\n\t\t\tif (this.config?.debug) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t`[${this.providerName}] Attempted to ${operation} but provider not ready:`,\n\t\t\t\t\t...args,\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn false;\n\t\t}\n\t\treturn true;\n\t}\n\n\t/**\n\t * Apply error filter if configured\n\t *\n\t * Returns false if error should be filtered out, logging in debug mode.\n\t *\n\t * @param error The error\n\t * @param attributes Error attributes\n\t * @returns true if error should be tracked, false if filtered out\n\t */\n\tprotected applyErrorFilter(\n\t\terror: Error,\n\t\tattributes: ErrorAttributes,\n\t): boolean {\n\t\tif (\n\t\t\tthis.config?.errorFilter &&\n\t\t\t!this.config.errorFilter(error, attributes)\n\t\t) {\n\t\t\tif (this.config?.debug) {\n\t\t\t\tconsole.log(\n\t\t\t\t\t`[${this.providerName}] Error filtered out:`,\n\t\t\t\t\terror,\n\t\t\t\t\tattributes,\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn false;\n\t\t}\n\t\treturn true;\n\t}\n\n\t/**\n\t * Apply event filter if configured\n\t *\n\t * Returns false if event should be filtered out, logging in debug mode.\n\t *\n\t * @param eventName Event name\n\t * @param attributes Event attributes\n\t * @returns true if event should be tracked, false if filtered out\n\t */\n\tprotected applyEventFilter(\n\t\teventName: string,\n\t\tattributes: EventAttributes,\n\t): boolean {\n\t\tif (\n\t\t\tthis.config?.eventFilter &&\n\t\t\t!this.config.eventFilter(eventName, attributes)\n\t\t) {\n\t\t\tif (this.config?.debug) {\n\t\t\t\tconsole.log(\n\t\t\t\t\t`[${this.providerName}] Event filtered out:`,\n\t\t\t\t\teventName,\n\t\t\t\t\tattributes,\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn false;\n\t\t}\n\t\treturn true;\n\t}\n\n\t/**\n\t * Apply sampling if configured\n\t *\n\t * Returns false if event should be sampled out, logging in debug mode.\n\t *\n\t * @param eventName Event name for logging\n\t * @returns true if event should be tracked, false if sampled out\n\t */\n\tprotected applySampling(eventName: string): boolean {\n\t\tif (this.config?.sampleRate !== undefined && this.config.sampleRate < 1.0) {\n\t\t\tif (Math.random() > this.config.sampleRate) {\n\t\t\t\tif (this.config?.debug) {\n\t\t\t\t\tconsole.log(`[${this.providerName}] Event sampled out:`, eventName);\n\t\t\t\t}\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n\n\t/**\n\t * Transform attributes if transformer is configured\n\t *\n\t * @param attributes Original attributes\n\t * @returns Transformed attributes or original if no transformer\n\t */\n\tprotected transformAttributes(\n\t\tattributes: Record<string, any>,\n\t): Record<string, any> {\n\t\tif (this.config?.attributeTransformer) {\n\t\t\treturn this.config.attributeTransformer(attributes);\n\t\t}\n\t\treturn attributes as Record<string, any>;\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;IACnC,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,IAA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;YACjC,IAAI,QAAQ,CAAC,WAAW,EAAE,CAAC;gBAC1B,QAAQ,CAAC,WAAW,CAAC,UAAU,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC;gBACpD,OAAO;YACR,CAAC;YACD,QAAQ,CAAC,UAAU,CAAC,UAAU,UAAU,EAAE,EAAE;gBAC3C,GAAI,UAAsC;gBAC1C,UAAU;gBACV,WAAW,EAAE,KAAK;aAClB,CAAC,CAAC;QACJ,CAAC,CAAC,CAAC;IACJ,CAAC;IAED,cAAc,CAAC,MAAc,EAAE,UAAgC;QAC9D,IAAI,CAAC,eAAe,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,cAAc,EAAE,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC;IACnF,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"}
|
|
1
|
+
{"version":3,"file":"CompositeInstrumentationProvider.js","sourceRoot":"","sources":["../../../src/instrumentation/providers/CompositeInstrumentationProvider.ts"],"names":[],"mappings":"AAQA,MAAM,OAAO,gCAAgC;IACnC,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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W;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 implements InstrumentationProvider {\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) => provider.setUserContext?.(userId, attributes));\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"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConsoleInstrumentationProvider.js","sourceRoot":"","sources":["../../../src/instrumentation/providers/ConsoleInstrumentationProvider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAGH,OAAO,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAyB/E,MAAM,OAAO,8BAA+B,SAAQ,2BAA2B;IACrE,UAAU,GA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AC,kCAAkC;YACpC,CAAC,CAAC,EAAE,CAAC;QACN,OAAO,CAAC,GAAG,CAAC,2CAA2C,EAAE,KAAK,CAAC,CAAC;QAChE,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,UAAU,CAAC,CAAC;IACxC,CAAC;CACD","sourcesContent":["/**\n * Console Instrumentation Provider\n *\n * Development provider that logs instrumentation events to the console.\n * Useful for debugging and testing without requiring external instrumentation services.\n *\n * @example\n * ```typescript\n * const provider = new ConsoleInstrumentationProvider();\n * await provider.initialize({ debug: true });\n *\n * provider.trackError(new Error('Test error'), {\n * component: 'test-component',\n * errorType: 'TestError'\n * });\n * // Outputs: [Instrumentation Error] test-component: TestError\n * // Error: Test error\n * // { component: 'test-component', errorType: 'TestError' }\n * ```\n */\n\nimport type { InstrumentationConfig, MetricAttributes } from \"../types.js\";\nimport { BaseInstrumentationProvider } from \"./BaseInstrumentationProvider.js\";\n\nexport interface ConsoleProviderConfig {\n\t/**\n\t * Use colored output in console\n\t *\n\t * @default true\n\t */\n\tuseColors?: boolean;\n\n\t/**\n\t * Include stack traces with errors\n\t *\n\t * @default true\n\t */\n\tincludeStackTrace?: boolean;\n\n\t/**\n\t * Group related logs together\n\t *\n\t * @default false\n\t */\n\tuseGroups?: boolean;\n}\n\nexport class ConsoleInstrumentationProvider extends BaseInstrumentationProvider {\n\treadonly providerId = \"console\";\n\treadonly providerName = \"Console Logger\";\n\n\tprivate providerConfig: ConsoleProviderConfig;\n\n\tconstructor(providerConfig: ConsoleProviderConfig = {}) {\n\t\tsuper();\n\t\tthis.providerConfig = {\n\t\t\tuseColors: providerConfig.useColors !== false,\n\t\t\tincludeStackTrace: providerConfig.includeStackTrace !== false,\n\t\t\tuseGroups: providerConfig.useGroups === true,\n\t\t};\n\t}\n\n\t/**\n\t * Initialize the console provider\n\t *\n\t * @param config Optional configuration\n\t */\n\tasync initialize(config?: InstrumentationConfig): Promise<void> {\n\t\tthis.config = config;\n\t\tthis.initialized = true;\n\n\t\t// Merge provider-specific config if provided\n\t\tif (config?.providerSettings) {\n\t\t\tthis.providerConfig = {\n\t\t\t\t...this.providerConfig,\n\t\t\t\t...config.providerSettings,\n\t\t\t};\n\t\t}\n\n\t\tconsole.log(\n\t\t\t\"%c[ConsoleProvider] Initialized\",\n\t\t\tthis.providerConfig.useColors ? \"color: green; font-weight: bold\" : \"\",\n\t\t);\n\t}\n\n\t/**\n\t * Check if provider is ready\n\t *\n\t * @returns true if initialized\n\t */\n\tisReady(): boolean {\n\t\treturn this.initialized;\n\t}\n\n\t/**\n\t * Cleanup provider resources\n\t */\n\tdestroy(): void {\n\t\tthis.initialized = false;\n\t\tconsole.log(\n\t\t\t\"%c[ConsoleProvider] Destroyed\",\n\t\t\tthis.providerConfig.useColors ? \"color: gray\" : \"\",\n\t\t);\n\t}\n\n\t/**\n\t * Track an error to console\n\t *\n\t * @param error The error to track\n\t * @param attributes Transformed attributes (already filtered and transformed by base class)\n\t */\n\tprotected doTrackError(error: Error, attributes: Record<string, any>): void {\n\t\tconst style = this.providerConfig.useColors\n\t\t\t? \"color: red; font-weight: bold\"\n\t\t\t: \"\";\n\t\tconst timestamp = new Date().toISOString();\n\n\t\tif (this.providerConfig.useGroups) {\n\t\t\tconsole.groupCollapsed(\n\t\t\t\t`%c[Instrumentation Error] ${attributes.component}: ${attributes.errorType}`,\n\t\t\t\tstyle,\n\t\t\t);\n\t\t\tconsole.error(\"Error:\", error.message);\n\t\t\tif (this.providerConfig.includeStackTrace && error.stack) {\n\t\t\t\tconsole.error(\"Stack:\", error.stack);\n\t\t\t}\n\t\t\tconsole.log(\"Attributes:\", attributes);\n\t\t\tconsole.log(\"Timestamp:\", timestamp);\n\t\t\tconsole.groupEnd();\n\t\t} else {\n\t\t\tconsole.error(\n\t\t\t\t`%c[Instrumentation Error] ${attributes.component}: ${attributes.errorType}`,\n\t\t\t\tstyle,\n\t\t\t);\n\t\t\tconsole.error(\"Error:\", error.message);\n\t\t\tif (this.providerConfig.includeStackTrace && error.stack) {\n\t\t\t\tconsole.error(\"Stack:\", error.stack);\n\t\t\t}\n\t\t\tconsole.error(\"Attributes:\", attributes);\n\t\t\tconsole.error(\"Timestamp:\", timestamp);\n\t\t}\n\t}\n\n\t/**\n\t * Track an event to console\n\t *\n\t * @param eventName Name of the event\n\t * @param attributes Transformed attributes (already filtered and transformed by base class)\n\t */\n\tprotected doTrackEvent(\n\t\teventName: string,\n\t\tattributes: Record<string, any>,\n\t): void {\n\t\tconst style = this.providerConfig.useColors ? \"color: blue\" : \"\";\n\t\tconst timestamp = new Date().toISOString();\n\n\t\tif (this.providerConfig.useGroups) {\n\t\t\tconsole.groupCollapsed(`%c[Instrumentation Event] ${eventName}`, style);\n\t\t\tconsole.log(\"Attributes:\", attributes);\n\t\t\tconsole.log(\"Timestamp:\", timestamp);\n\t\t\tconsole.groupEnd();\n\t\t} else {\n\t\t\tconsole.log(`%c[Instrumentation Event] ${eventName}`, style);\n\t\t\tconsole.log(\"Attributes:\", attributes);\n\t\t\tconsole.log(\"Timestamp:\", timestamp);\n\t\t}\n\t}\n\n\t/**\n\t * Track a metric to console\n\t *\n\t * Overrides base class to provide custom formatting.\n\t *\n\t * @param metricName Name of the metric\n\t * @param value Numeric value\n\t * @param attributes Optional metric attributes\n\t */\n\ttrackMetric(\n\t\tmetricName: string,\n\t\tvalue: number,\n\t\tattributes?: MetricAttributes,\n\t): void {\n\t\tif (!this.isReady()) return;\n\n\t\tconst style = this.providerConfig.useColors ? \"color: green\" : \"\";\n\t\tconst timestamp = new Date().toISOString();\n\t\tconst unit = attributes?.unit || \"\";\n\t\tconst displayValue = unit ? `${value} ${unit}` : value;\n\n\t\tif (this.providerConfig.useGroups) {\n\t\t\tconsole.groupCollapsed(\n\t\t\t\t`%c[Instrumentation Metric] ${metricName}: ${displayValue}`,\n\t\t\t\tstyle,\n\t\t\t);\n\t\t\tif (attributes) {\n\t\t\t\tconsole.log(\"Attributes:\", attributes);\n\t\t\t}\n\t\t\tconsole.log(\"Timestamp:\", timestamp);\n\t\t\tconsole.groupEnd();\n\t\t} else {\n\t\t\tconsole.log(\n\t\t\t\t`%c[Instrumentation Metric] ${metricName}:`,\n\t\t\t\tstyle,\n\t\t\t\tdisplayValue,\n\t\t\t);\n\t\t\tif (attributes) {\n\t\t\t\tconsole.log(\"Attributes:\", attributes);\n\t\t\t}\n\t\t\tconsole.log(\"Timestamp:\", timestamp);\n\t\t}\n\t}\n\n\t/**\n\t * Set user context\n\t *\n\t * Logs user context to console.\n\t *\n\t * @param userId User identifier\n\t * @param attributes Optional user attributes\n\t */\n\tprotected doSetUserContext(\n\t\tuserId: string,\n\t\tattributes?: Record<string, any>,\n\t): void {\n\t\tconst style = this.providerConfig.useColors\n\t\t\t? \"color: purple; font-weight: bold\"\n\t\t\t: \"\";\n\t\tconsole.log(`%c[Instrumentation] Set User Context: ${userId}`, style);\n\t\tif (attributes) {\n\t\t\tconsole.log(\"User Attributes:\", attributes);\n\t\t}\n\t}\n\n\t/**\n\t * Set global attributes\n\t *\n\t * Logs global attributes to console.\n\t *\n\t * @param attributes Attributes to set globally\n\t */\n\tprotected doSetGlobalAttributes(attributes: Record<string, any>): void {\n\t\tconst style = this.providerConfig.useColors\n\t\t\t? \"color: orange; font-weight: bold\"\n\t\t\t: \"\";\n\t\tconsole.log(\"%c[Instrumentation] Set Global Attributes\", style);\n\t\tconsole.log(\"Attributes:\", attributes);\n\t}\n}\n"]}
|
|
@@ -11,4 +11,3 @@ export declare class DebugPanelInstrumentationProvider extends BaseInstrumentati
|
|
|
11
11
|
protected doSetUserContext(userId: string, attributes?: Record<string, any>): void;
|
|
12
12
|
protected doSetGlobalAttributes(attributes: Record<string, any>): void;
|
|
13
13
|
}
|
|
14
|
-
//# sourceMappingURL=DebugPanelInstrumentationProvider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DebugPanelInstrumentationProvider.js","sourceRoot":"","sources":["../../../src/instrumentation/providers/DebugPanelInstrumentationProvider.ts"],"names":[],"mappings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AK,QAAQ,IAAI,UAAU,CAAC,UAAU;YACjE,CAAC,CAAC,UAAU,CAAC,UAAU;YACvB,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;QACtC,8BAA8B,CAC7B,uBAAuB,CAAC;YACvB,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,YAAY,EAAE,IAAI,CAAC,YAAY;YAC/B,UAAU;YACV,KAAK,EAAE,cAAc;YACrB,UAAU;SACV,CAAC,CACF,CAAC;IACH,CAAC;IAES,gBAAgB,CACzB,MAAc,EACd,UAAgC;QAEhC,8BAA8B,CAAC;YAC9B,IAAI,EAAE,cAAc;YACpB,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,YAAY,EAAE,IAAI,CAAC,YAAY;YAC/B,IAAI,EAAE,MAAM;YACZ,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;YACnC,UAAU,EAAE,UAAU;gBACrB,CAAC,CAAC,EAAE,GAAI,UAAsC,EAAE;gBAChD,CAAC,CAAC,SAAS;SACZ,CAAC,CAAC;IACJ,CAAC;IAES,qBAAqB,CAAC,UAA+B;QAC9D,8BAA8B,CAAC;YAC9B,IAAI,EAAE,mBAAmB;YACzB,UAAU,EAAE,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"}
|
|
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,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C,UAAU,EAAE,EAAE,CAAC,CAAC;QACtC,8BAA8B,CAC7B,uBAAuB,CAAC;YACvB,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,YAAY,EAAE,IAAI,CAAC,YAAY;YAC/B,UAAU;YACV,KAAK,EAAE,cAAc;YACrB,UAAU;SACV,CAAC,CACF,CAAC;IACH,CAAC;IAES,gBAAgB,CACzB,MAAc,EACd,UAAgC;QAEhC,8BAA8B,CAAC;YAC9B,IAAI,EAAE,cAAc;YACpB,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,YAAY,EAAE,IAAI,CAAC,YAAY;YAC/B,IAAI,EAAE,MAAM;YACZ,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;YACnC,UAAU,EAAE,UAAU;gBACrB,CAAC,CAAC,EAAE,GAAI,UAAsC,EAAE;gBAChD,CAAC,CAAC,SAAS;SACZ,CAAC,CAAC;IACJ,CAAC;IAES,qBAAqB,CAAC,UAA+B;QAC9D,8BAA8B,CAAC;YAC9B,IAAI,EAAE,mBAAmB;YACzB,UAAU,EAAE,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 (typeof rawMetricValue !== \"number\" || !Number.isFinite(rawMetricValue)) {\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"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NewRelicInstrumentationProvider.js","sourceRoot":"","sources":["../../../src/instrumentation/providers/NewRelicInstrumentationProvider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAGH,OAAO,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAE/E,MAAM,OAAO,+BAAgC,SAAQ,2BAA2B;IACtE,UAAU,GAAG,UAAU,CAAC;IACxB,YAAY,GAAG,WAAW,CAAC;IAEpC;;;;;;;OAOG;IACH,KAAK,CAAC,UAAU,CAAC,MAA8B;QAC9C,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QAErB,kCAAkC;QAClC,IAAI,OAAO,MAAM,KAAK,WAAW,IAAK,MAAc,CAAC,QAAQ,EAAE,CAAC;YAC/D,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;YACxB,IAAI,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,CAAC;gBACxB,OAAO,CAAC,GAAG,CAAC,6CAA6C,CAAC,CAAC;YAC5D,CAAC;QACF,CAAC;aAAM,CAAC;YACP,IAAI,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,CAAC;gBACxB,OAAO,CAAC,IAAI,CACX,wEAAwE,CACxE,CAAC;YACH,CAAC;YACD,2CAA2C;YAC3C,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC;QAC1B,CAAC;IACF,CAAC;IAED;;;;OAIG;IACH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AA+B;QAC9D,MAAM,QAAQ,GAAI,MAAc,CAAC,QAAQ,CAAC;QAE1C,IAAI,QAAQ,CAAC,kBAAkB,EAAE,CAAC;YACjC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;gBACvD,QAAQ,CAAC,kBAAkB,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;YACzC,CAAC;QACF,CAAC;IACF,CAAC;CACD"}
|
|
1
|
+
{"version":3,"file":"NewRelicInstrumentationProvider.js","sourceRoot":"","sources":["../../../src/instrumentation/providers/NewRelicInstrumentationProvider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAGH,OAAO,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAE/E,MAAM,OAAO,+BAAgC,SAAQ,2BAA2B;IACtE,UAAU,GAAG,UAAU,CAAC;IACxB,YAAY,GAAG,WAAW,CAAC;IAEpC;;;;;;;OAOG;IACH,KAAK,CAAC,UAAU,CAAC,MAA8B;QAC9C,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QAErB,kCAAkC;QAClC,IAAI,OAAO,MAAM,KAAK,WAAW,IAAK,MAAc,CAAC,QAAQ,EAAE,CAAC;YAC/D,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;YACxB,IAAI,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,CAAC;gBACxB,OAAO,CAAC,GAAG,CAAC,6CAA6C,CAAC,CAAC;YAC5D,CAAC;QACF,CAAC;aAAM,CAAC;YACP,IAAI,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,CAAC;gBACxB,OAAO,CAAC,IAAI,CACX,wEAAwE,CACxE,CAAC;YACH,CAAC;YACD,2CAA2C;YAC3C,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC;QAC1B,CAAC;IACF,CAAC;IAED;;;;OAIG;IACH,OAAO;QACN,OAAO,CACN,IAA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GAAI,MAAc,CAAC,QAAQ,CAAC;QAE1C,IAAI,QAAQ,CAAC,kBAAkB,EAAE,CAAC;YACjC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;gBACvD,QAAQ,CAAC,kBAAkB,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;YACzC,CAAC;QACF,CAAC;IACF,CAAC;CACD","sourcesContent":["/**\n * New Relic Instrumentation Provider\n *\n * Default provider that maintains backwards compatibility with existing\n * New Relic instrumentation.\n *\n * This provider wraps the global `window.newrelic` object provided by\n * the New Relic Browser Agent.\n *\n * @example\n * ```typescript\n * const provider = new NewRelicInstrumentationProvider();\n * await provider.initialize();\n *\n * if (provider.isReady()) {\n * provider.trackError(new Error('Something went wrong'), {\n * component: 'my-component',\n * errorType: 'ValidationError'\n * });\n * }\n * ```\n */\n\nimport type { InstrumentationConfig } from \"../types.js\";\nimport { BaseInstrumentationProvider } from \"./BaseInstrumentationProvider.js\";\n\nexport class NewRelicInstrumentationProvider extends BaseInstrumentationProvider {\n\treadonly providerId = \"newrelic\";\n\treadonly providerName = \"New Relic\";\n\n\t/**\n\t * Initialize the New Relic provider\n\t *\n\t * Checks if the New Relic Browser Agent is available via `window.newrelic`.\n\t * If not available, initialization succeeds but `isReady()` will return false.\n\t *\n\t * @param config Optional configuration\n\t */\n\tasync initialize(config?: InstrumentationConfig): Promise<void> {\n\t\tthis.config = config;\n\n\t\t// Check if New Relic is available\n\t\tif (typeof window !== \"undefined\" && (window as any).newrelic) {\n\t\t\tthis.initialized = true;\n\t\t\tif (this.config?.debug) {\n\t\t\t\tconsole.log(\"[NewRelicProvider] Initialized successfully\");\n\t\t\t}\n\t\t} else {\n\t\t\tif (this.config?.debug) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t\"[NewRelicProvider] New Relic not available (window.newrelic not found)\",\n\t\t\t\t);\n\t\t\t}\n\t\t\t// Don't throw - allow graceful degradation\n\t\t\tthis.initialized = false;\n\t\t}\n\t}\n\n\t/**\n\t * Check if provider is ready\n\t *\n\t * @returns true if New Relic is available and initialized\n\t */\n\tisReady(): boolean {\n\t\treturn (\n\t\t\tthis.initialized &&\n\t\t\ttypeof window !== \"undefined\" &&\n\t\t\t!!(window as any).newrelic\n\t\t);\n\t}\n\n\t/**\n\t * Cleanup provider resources\n\t *\n\t * Marks provider as uninitialized. The global `window.newrelic` object\n\t * is not modified.\n\t */\n\tdestroy(): void {\n\t\tthis.initialized = false;\n\t\tif (this.config?.debug) {\n\t\t\tconsole.log(\"[NewRelicProvider] Destroyed\");\n\t\t}\n\t}\n\n\t/**\n\t * Track an error with New Relic\n\t *\n\t * Calls `newrelic.noticeError(error, attributes)`\n\t *\n\t * @param error The error to track\n\t * @param attributes Transformed attributes (already filtered and transformed by base class)\n\t */\n\tprotected doTrackError(error: Error, attributes: Record<string, any>): void {\n\t\tconst newrelic = (window as any).newrelic;\n\t\tnewrelic.noticeError(error, attributes);\n\t}\n\n\t/**\n\t * Track a custom event/page action with New Relic\n\t *\n\t * Calls `newrelic.addPageAction(eventName, attributes)`\n\t *\n\t * @param eventName Name of the event\n\t * @param attributes Transformed attributes (already filtered and transformed by base class)\n\t */\n\tprotected doTrackEvent(\n\t\teventName: string,\n\t\tattributes: Record<string, any>,\n\t): void {\n\t\tconst newrelic = (window as any).newrelic;\n\t\tnewrelic.addPageAction(eventName, attributes);\n\t}\n\n\t/**\n\t * Set user context for session tracking\n\t *\n\t * Calls `newrelic.setUserId()` and `newrelic.setCustomAttribute()` for user attributes.\n\t *\n\t * @param userId User identifier\n\t * @param attributes Optional user attributes\n\t */\n\tprotected doSetUserContext(\n\t\tuserId: string,\n\t\tattributes?: Record<string, any>,\n\t): void {\n\t\tconst newrelic = (window as any).newrelic;\n\n\t\t// Set user ID if method exists\n\t\tif (newrelic.setUserId) {\n\t\t\tnewrelic.setUserId(userId);\n\t\t}\n\n\t\t// Set custom attributes for user\n\t\tif (attributes && newrelic.setCustomAttribute) {\n\t\t\tfor (const [key, value] of Object.entries(attributes)) {\n\t\t\t\tnewrelic.setCustomAttribute(key, value);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Set global custom attributes\n\t *\n\t * Calls `newrelic.setCustomAttribute()` for each attribute.\n\t *\n\t * @param attributes Attributes to set globally\n\t */\n\tprotected doSetGlobalAttributes(attributes: Record<string, any>): void {\n\t\tconst newrelic = (window as any).newrelic;\n\n\t\tif (newrelic.setCustomAttribute) {\n\t\t\tfor (const [key, value] of Object.entries(attributes)) {\n\t\t\t\tnewrelic.setCustomAttribute(key, value);\n\t\t\t}\n\t\t}\n\t}\n}\n"]}
|
|
@@ -9,4 +9,3 @@ export { CompositeInstrumentationProvider } from "./CompositeInstrumentationProv
|
|
|
9
9
|
export { ConsoleInstrumentationProvider } from "./ConsoleInstrumentationProvider.js";
|
|
10
10
|
export { DebugPanelInstrumentationProvider } from "./DebugPanelInstrumentationProvider.js";
|
|
11
11
|
export { NewRelicInstrumentationProvider } from "./NewRelicInstrumentationProvider.js";
|
|
12
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/instrumentation/providers/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,2CAA2C;AAC3C,OAAO,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAE/E,qBAAqB;AACrB,OAAO,EAAE,gCAAgC,EAAE,MAAM,uCAAuC,CAAC;AACzF,OAAO,EAAE,8BAA8B,EAAE,MAAM,qCAAqC,CAAC;AACrF,OAAO,EAAE,iCAAiC,EAAE,MAAM,wCAAwC,CAAC;AAC3F,OAAO,EAAE,+BAA+B,EAAE,MAAM,sCAAsC,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/instrumentation/providers/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,2CAA2C;AAC3C,OAAO,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAE/E,qBAAqB;AACrB,OAAO,EAAE,gCAAgC,EAAE,MAAM,uCAAuC,CAAC;AACzF,OAAO,EAAE,8BAA8B,EAAE,MAAM,qCAAqC,CAAC;AACrF,OAAO,EAAE,iCAAiC,EAAE,MAAM,wCAAwC,CAAC;AAC3F,OAAO,EAAE,+BAA+B,EAAE,MAAM,sCAAsC,CAAC","sourcesContent":["/**\n * Instrumentation Providers\n *\n * This module exports all available instrumentation providers.\n */\n\n// Base class for creating custom providers\nexport { BaseInstrumentationProvider } from \"./BaseInstrumentationProvider.js\";\nexport type { ConsoleProviderConfig } from \"./ConsoleInstrumentationProvider.js\";\n// Built-in providers\nexport { CompositeInstrumentationProvider } from \"./CompositeInstrumentationProvider.js\";\nexport { ConsoleInstrumentationProvider } from \"./ConsoleInstrumentationProvider.js\";\nexport { DebugPanelInstrumentationProvider } from \"./DebugPanelInstrumentationProvider.js\";\nexport { NewRelicInstrumentationProvider } from \"./NewRelicInstrumentationProvider.js\";\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/instrumentation/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/instrumentation/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG","sourcesContent":["/**\n * Instrumentation Types\n *\n * Core interfaces and types for pluggable instrumentation system.\n * Abstracts vendor-specific APIs (New Relic and custom providers)\n * to enable clients to use any instrumentation provider.\n */\n\n/**\n * Pluggable instrumentation provider interface\n *\n * All instrumentation providers must implement this interface.\n * Provides methods for tracking errors, events, and metrics.\n *\n * @example\n * ```typescript\n * class CustomProvider implements InstrumentationProvider {\n * readonly providerId = 'custom';\n * readonly providerName = 'Custom Analytics';\n *\n * async initialize(config?: InstrumentationConfig): Promise<void> {\n * // Initialize your analytics SDK\n * }\n *\n * trackError(error: Error, attributes: ErrorAttributes): void {\n * // Send error to your analytics backend\n * }\n *\n * trackEvent(eventName: string, attributes: EventAttributes): void {\n * // Send event to your analytics backend\n * }\n *\n * isReady(): boolean {\n * return true;\n * }\n *\n * destroy(): void {\n * // Cleanup\n * }\n * }\n * ```\n */\nexport interface InstrumentationProvider {\n\t/**\n\t * Unique identifier for the provider (e.g., 'newrelic', 'console')\n\t */\n\treadonly providerId: string;\n\n\t/**\n\t * Human-readable provider name (e.g., 'New Relic')\n\t */\n\treadonly providerName: string;\n\n\t/**\n\t * Initialize the provider (load SDKs, configure clients, etc.)\n\t *\n\t * @param config Optional configuration for the provider\n\t */\n\tinitialize(config?: InstrumentationConfig): Promise<void>;\n\n\t/**\n\t * Track an error with contextual attributes\n\t *\n\t * @param error The error to track\n\t * @param attributes Contextual attributes about the error\n\t */\n\ttrackError(error: Error, attributes: ErrorAttributes): void;\n\n\t/**\n\t * Track a custom event/page action\n\t *\n\t * @param eventName Name of the event (e.g., 'pie-resource-load', 'pie-resource-retry')\n\t * @param attributes Contextual attributes about the event\n\t */\n\ttrackEvent(eventName: string, attributes: EventAttributes): void;\n\n\t/**\n\t * Track a performance metric\n\t *\n\t * Optional - not all providers support direct metrics.\n\t * For providers without metric support, consider tracking as custom events instead.\n\t *\n\t * @param metricName Name of the metric\n\t * @param value Numeric value of the metric\n\t * @param attributes Optional attributes about the metric\n\t */\n\ttrackMetric?(\n\t\tmetricName: string,\n\t\tvalue: number,\n\t\tattributes?: MetricAttributes,\n\t): void;\n\n\t/**\n\t * Set user context for session tracking\n\t *\n\t * Optional - associates user information with subsequent events/errors.\n\t *\n\t * @param userId User identifier\n\t * @param attributes Optional user attributes\n\t */\n\tsetUserContext?(userId: string, attributes?: Record<string, any>): void;\n\n\t/**\n\t * Set custom attributes that apply to all subsequent events\n\t *\n\t * Optional - useful for setting context like environment, version, etc.\n\t *\n\t * @param attributes Attributes to set globally\n\t */\n\tsetGlobalAttributes?(attributes: Record<string, any>): void;\n\n\t/**\n\t * Cleanup provider resources\n\t *\n\t * Called when the provider is being destroyed or replaced.\n\t */\n\tdestroy(): void;\n\n\t/**\n\t * Check if provider is ready to track events\n\t *\n\t * @returns true if provider is initialized and ready, false otherwise\n\t */\n\tisReady(): boolean;\n}\n\n/**\n * Configuration for instrumentation providers\n */\nexport interface InstrumentationConfig {\n\t/**\n\t * Enable/disable instrumentation\n\t *\n\t * @default true\n\t */\n\tenabled?: boolean;\n\n\t/**\n\t * Enable debug logging\n\t *\n\t * @default false\n\t */\n\tdebug?: boolean;\n\n\t/**\n\t * Sample rate for events (0.0 to 1.0)\n\t *\n\t * 1.0 = 100% of events tracked\n\t * 0.5 = 50% of events tracked\n\t * 0.1 = 10% of events tracked\n\t *\n\t * @default 1.0\n\t */\n\tsampleRate?: number;\n\n\t/**\n\t * Provider-specific settings\n\t *\n\t * Each provider can define its own configuration structure.\n\t *\n\t * @example New Relic\n\t * ```typescript\n\t * providerSettings: {\n\t * // New Relic doesn't need additional config (uses global newrelic object)\n\t * }\n\t * ```\n\t *\n\t * @example Console provider\n\t * ```typescript\n\t * providerSettings: {\n\t * useColors: true\n\t * }\n\t * ```\n\t */\n\tproviderSettings?: Record<string, any>;\n\n\t/**\n\t * Filter function for errors\n\t *\n\t * Return false to skip tracking the error.\n\t *\n\t * @param error The error being tracked\n\t * @param attributes The error attributes\n\t * @returns true to track, false to skip\n\t */\n\terrorFilter?: (error: Error, attributes: ErrorAttributes) => boolean;\n\n\t/**\n\t * Filter function for events\n\t *\n\t * Return false to skip tracking the event.\n\t *\n\t * @param eventName The event name\n\t * @param attributes The event attributes\n\t * @returns true to track, false to skip\n\t */\n\teventFilter?: (eventName: string, attributes: EventAttributes) => boolean;\n\n\t/**\n\t * Transform function for attributes\n\t *\n\t * Allows modifying or enriching attributes before they're sent to the provider.\n\t *\n\t * @param attributes The original attributes\n\t * @returns The transformed attributes\n\t */\n\tattributeTransformer?: (\n\t\tattributes: Record<string, any>,\n\t) => Record<string, any>;\n}\n\n/**\n * Common error attributes\n *\n * These attributes are sent with error tracking calls.\n * All providers should support these base attributes.\n */\nexport interface ErrorAttributes {\n\t/**\n\t * Component that generated the error\n\t *\n\t * Examples: 'pie-item-player', 'pie-resource-monitor'\n\t */\n\tcomponent: string;\n\n\t/**\n\t * Type/category of error\n\t *\n\t * Examples: 'InvalidConfig', 'ConfigParseError', 'EsmLoadingError',\n\t * 'IifeLoadingError', 'ResourceLoadError'\n\t */\n\terrorType: string;\n\n\t// Contextual data (all optional, depends on error type)\n\n\t/**\n\t * Single item ID (if error relates to a specific item)\n\t */\n\titemId?: string;\n\n\t/**\n\t * Multiple item IDs (if error relates to multiple items)\n\t */\n\titemIds?: string[];\n\n\t/**\n\t * PIE element type (if error relates to a specific element)\n\t *\n\t * Examples: '@pie-element/inline-choice', '@pie-element/match'\n\t */\n\telementType?: string;\n\n\t/**\n\t * CDN base URL (for ESM loading errors)\n\t */\n\tcdnBaseUrl?: string;\n\n\t/**\n\t * Bundle host URL (for IIFE loading errors)\n\t */\n\tbundleHost?: string;\n\n\t/**\n\t * Resource URL (for resource loading errors)\n\t */\n\tresourceUrl?: string;\n\n\t/**\n\t * Resource type (for resource loading errors)\n\t *\n\t * Examples: 'img', 'audio', 'video', 'link', 'source'\n\t */\n\tresourceType?: string;\n\n\t/**\n\t * Duration in milliseconds (for timing-related errors)\n\t */\n\tduration?: number;\n\n\t/**\n\t * Retry count (for retry-related errors)\n\t */\n\tretryCount?: number;\n\n\t/**\n\t * Whether retry was attempted (for resource errors)\n\t */\n\twasRetried?: boolean;\n\n\t/**\n\t * Extensible for additional context-specific attributes\n\t */\n\t[key: string]: any;\n}\n\n/**\n * Common event attributes\n *\n * These attributes are sent with event tracking calls.\n */\nexport interface EventAttributes {\n\t/**\n\t * Component that generated the event\n\t *\n\t * Optional - some events may be component-agnostic\n\t */\n\tcomponent?: string;\n\n\t/**\n\t * Timestamp of the event\n\t *\n\t * ISO 8601 format string\n\t */\n\ttimestamp?: string;\n\n\t// Resource loading events\n\n\t/**\n\t * Resource URL\n\t */\n\turl?: string;\n\n\t/**\n\t * Load duration in milliseconds\n\t */\n\tduration?: number;\n\n\t/**\n\t * Transfer size in bytes\n\t */\n\tsize?: number;\n\n\t/**\n\t * Resource type\n\t *\n\t * Examples: 'img', 'audio', 'video', 'link', 'script', 'stylesheet'\n\t */\n\ttype?: string;\n\n\t/**\n\t * Whether the resource load failed\n\t */\n\tfailed?: boolean;\n\n\t/**\n\t * Whether retry was attempted\n\t */\n\twasRetried?: boolean;\n\n\t/**\n\t * Retry count\n\t */\n\tretryCount?: number;\n\n\t/**\n\t * Retry attempt number\n\t */\n\tattempt?: number;\n\n\t/**\n\t * Delay before retry in milliseconds\n\t */\n\tdelay?: number;\n\n\t/**\n\t * Extensible for additional event-specific attributes\n\t */\n\t[key: string]: any;\n}\n\n/**\n * Metric attributes\n *\n * These attributes are sent with metric tracking calls.\n */\nexport interface MetricAttributes {\n\t/**\n\t * Unit of measurement\n\t *\n\t * Examples: 'ms', 'bytes', 'count', 'percent'\n\t */\n\tunit?: string;\n\n\t/**\n\t * Category of metric\n\t *\n\t * Examples: 'performance', 'resource', 'error', 'user-action'\n\t */\n\tcategory?: string;\n\n\t/**\n\t * Extensible for additional metric-specific attributes\n\t */\n\t[key: string]: any;\n}\n"]}
|
package/dist/loader-config.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loader-config.js","sourceRoot":"","sources":["../src/loader-config.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAwEH,MAAM,CAAC,MAAM,gCAAgC,GAAG;IAC/C,YAAY,EAAE,IAAI;IAClB,SAAS,EAAE,MAAM;CACR,CAAC;AAEX,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACpC,gBAAgB,EAAE,KAAK;IACvB,uBAAuB,EAAE,SAAS;IAClC,kBAAkB,EAAE,CAAC;IACrB,kBAAkB,EAAE,GAAG;IACvB,eAAe,EAAE,gCAAgC;CACxC,CAAC"}
|
|
1
|
+
{"version":3,"file":"loader-config.js","sourceRoot":"","sources":["../src/loader-config.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAwEH,MAAM,CAAC,MAAM,gCAAgC,GAAG;IAC/C,YAAY,EAAE,IAAI;IAClB,SAAS,EAAE,MAAM;CACR,CAAC;AAEX,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACpC,gBAAgB,EAAE,KAAK;IACvB,uBAAuB,EAAE,SAAS;IAClC,kBAAkB,EAAE,CAAC;IACrB,kBAAkB,EAAE,GAAG;IACvB,eAAe,EAAE,gCAAgC;CACxC,CAAC","sourcesContent":["/**\n * Shared loader configuration for PIE custom elements.\n *\n * Mirrors the `LoaderConfig` used by PIEOneer's custom element tags.\n */\n\nimport type { InstrumentationProvider } from \"./instrumentation/types.js\";\n\nexport type IifeBundleRetryConfig = {\n\t/**\n\t * Delay in ms between IIFE bundle retry attempts.\n\t */\n\tretryDelayMs?: number;\n\n\t/**\n\t * Total timeout in ms before IIFE bundle load retries fail permanently.\n\t */\n\ttimeoutMs?: number;\n};\n\nexport type LoaderConfig = {\n\t/**\n\t * Enable tracking page actions/events.\n\t *\n\t * When true, instrumentation events will be sent to the instrumentation provider.\n\t */\n\ttrackPageActions?: boolean;\n\n\t/**\n\t * Instrumentation provider for tracking events and errors.\n\t *\n\t * Optional. If not provided, defaults to NewRelicInstrumentationProvider.\n\t * The provider handles instrumentation gracefully - if New Relic (or the configured\n\t * backend) is not available, it will simply not track events (no errors thrown).\n\t *\n\t * @example Using New Relic (default - no configuration needed)\n\t * ```typescript\n\t * // Just enable tracking - will use New Relic if window.newrelic is available\n\t * const loaderConfig = {\n\t * trackPageActions: true\n\t * };\n\t * ```\n\t * @example Using Console provider (for development/debugging)\n\t * ```typescript\n\t * import { ConsoleInstrumentationProvider } from '@pie-players/pie-players-shared';\n\t *\n\t * const provider = new ConsoleInstrumentationProvider({ useColors: true });\n\t * await provider.initialize({ debug: true });\n\t *\n\t * const loaderConfig = {\n\t * trackPageActions: true,\n\t * instrumentationProvider: provider\n\t * };\n\t * ```\n\t */\n\tinstrumentationProvider?: InstrumentationProvider;\n\n\t/**\n\t * Maximum number of retry attempts for failed resources (images/audio/video).\n\t */\n\tmaxResourceRetries?: number;\n\n\t/**\n\t * Initial delay in ms before first resource retry attempt (exponential backoff).\n\t */\n\tresourceRetryDelay?: number;\n\n\t/**\n\t * Retry policy for IIFE bundle loads.\n\t *\n\t * Kept separate from resource retry settings so bundle-build polling can be tuned\n\t * independently from media/resource retries.\n\t */\n\tiifeBundleRetry?: IifeBundleRetryConfig;\n};\n\nexport const DEFAULT_IIFE_BUNDLE_RETRY_CONFIG = {\n\tretryDelayMs: 3000,\n\ttimeoutMs: 120000,\n} as const;\n\nexport const DEFAULT_LOADER_CONFIG = {\n\ttrackPageActions: false,\n\tinstrumentationProvider: undefined,\n\tmaxResourceRetries: 3,\n\tresourceRetryDelay: 500,\n\tiifeBundleRetry: DEFAULT_IIFE_BUNDLE_RETRY_CONFIG,\n} as const;\n"]}
|
|
@@ -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,QA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QACtB,MAAM,YAAY,GAAG,IAAI,CAAC,MAAM,EAAE,QAAQ,IAAI,EAAE,CAAC;QAEjD,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,EAAE;YACnD,MAAM,WAAW,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;YAChC,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,EAAE,CAAC;gBAC5B,gBAAgB,CAAC,GAAG,CAAC,GAAG,WAAW,CAAC;YACrC,CAAC;iBAAM,IAAI,gBAAgB,CAAC,GAAG,CAAC,KAAK,WAAW,EAAE,CAAC;gBAClD,kEAAkE;gBAClE,MAAM,IAAI,KAAK,CACd,6BAA6B,GAAG,kBAAkB,gBAAgB,CAAC,GAAG,CAAC,QAAQ,WAAW,IAAI;oBAC7F,mEAAmE,CACpE,CAAC;YACH,CAAC;YAED,MAAM,aAAa,GAAG,mBAAmB,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC;YAC5D,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,EAAE,CAAC;gBAChC,UAAU,CAAC,aAAa,CAAC,GAAG,WAAW,CAAC;YACzC,CAAC;iBAAM,IAAI,UAAU,CAAC,aAAa,CAAC,KAAK,WAAW,EAAE,CAAC;gBACtD,MAAM,IAAI,KAAK,CACd,6BAA6B,aAAa,kBAAkB,UAAU,CAAC,aAAa,CAAC,QAAQ,WAAW,IAAI;oBAC3G,mEAAmE,CACpE,CAAC;YACH,CAAC;QACF,CAAC,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,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 = (tagName: string, packageSpec: string): 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 (!targetEncodedVersion || existingEncodedVersion === targetEncodedVersion) {\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"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"element-loader-types.js","sourceRoot":"","sources":["../../src/loaders/element-loader-types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAuCH;;;;;;;;GAQG;AACH,MAAM,OAAO,cAAe,SAAQ,KAAK;IACtB,IAAI,GAAG,gBAAgB,CAAC;IACjC,OAAO,CAA6C;IAE7D,YAAY,OAAmD;QAC9D,MAAM,IAAI,GAAG,CAAC,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;QACjC,KAAK,CACJ,+BAA+B,OAAO,CAAC,IAAI,YAAY,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CACxE,CAAC;QACF,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACxB,CAAC;CACD"}
|
|
1
|
+
{"version":3,"file":"element-loader-types.js","sourceRoot":"","sources":["../../src/loaders/element-loader-types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAuCH;;;;;;;;GAQG;AACH,MAAM,OAAO,cAAe,SAAQ,KAAK;IACtB,IAAI,GAAG,gBAAgB,CAAC;IACjC,OAAO,CAA6C;IAE7D,YAAY,OAAmD;QAC9D,MAAM,IAAI,GAAG,CAAC,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;QACjC,KAAK,CACJ,+BAA+B,OAAO,CAAC,IAAI,YAAY,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CACxE,CAAC;QACF,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACxB,CAAC;CACD","sourcesContent":["/**\n * Shared types for the ElementLoader primitive and its backend adapters.\n *\n * Keeping types in their own module breaks the import cycle that would\n * otherwise form between the primitive (which dispatches to adapters) and\n * the adapters (which implement the backend interface).\n */\n\nimport type { ElementMap } from \"./ElementLoader.js\";\n\nexport type ElementTag = string;\n\nexport type { ElementMap };\n\n/**\n * Structured reason for why a specific tag failed to register.\n *\n * The primitive prefers adapter-supplied reasons (rich, diagnostic) over the\n * generic `timeout` reason it synthesizes from its own verification pass.\n */\nexport type RegistrationFailureReason =\n\t| { kind: \"timeout\"; tag: ElementTag; timeoutMs: number }\n\t| { kind: \"not-a-constructor\"; tag: ElementTag; packageName?: string }\n\t| {\n\t\t\tkind: \"package-not-in-bundle\";\n\t\t\ttag: ElementTag;\n\t\t\tpackageName: string;\n\t\t\tavailablePackages: string[];\n\t }\n\t| {\n\t\t\tkind: \"module-load-failed\";\n\t\t\ttag: ElementTag;\n\t\t\tspecifier: string;\n\t\t\tcause: string;\n\t }\n\t| {\n\t\t\tkind: \"bundle-load-failed\";\n\t\t\ttag: ElementTag;\n\t\t\turl: string;\n\t\t\tcause: string;\n\t }\n\t| { kind: \"define-failed\"; tag: ElementTag; cause: string }\n\t| { kind: \"backend-rejected\"; tag: ElementTag; cause: string }\n\t| { kind: \"no-element-class\"; tag: ElementTag; packageName: string };\n\n/**\n * Thrown by an adapter when it has structured, per-tag knowledge of which\n * registrations failed and why. The primitive unpacks the `reasons` map\n * and merges it into its own `ElementLoaderError.reasons`.\n *\n * Generic `Error` thrown from an adapter is treated as catastrophic: the\n * primitive assigns a blanket `backend-rejected` reason to every requested\n * tag that is still missing after verification.\n */\nexport class AdapterFailure extends Error {\n\toverride readonly name = \"AdapterFailure\";\n\treadonly reasons: Map<ElementTag, RegistrationFailureReason>;\n\n\tconstructor(reasons: Map<ElementTag, RegistrationFailureReason>) {\n\t\tconst tags = [...reasons.keys()];\n\t\tsuper(\n\t\t\t`Backend adapter failure for ${reasons.size} tag(s): ${tags.join(\", \")}`,\n\t\t);\n\t\tthis.reasons = reasons;\n\t}\n}\n\n/**\n * Context the primitive hands to the adapter for each load.\n *\n * The adapter is free to use `whenDefinedTimeoutMs` for its own internal\n * waits, but the primitive always enforces an independent\n * `customElements.whenDefined` verification after the adapter returns — so\n * an adapter cannot silently under-register tags even if it ignores this\n * context.\n */\nexport type BackendContext = {\n\tdoc: Document;\n\twhenDefinedTimeoutMs: number;\n};\n\n/**\n * Backend adapter contract.\n *\n * Resolve only if every requested tag was attempted and the adapter\n * believes every tag is registered. On partial failure, throw\n * `AdapterFailure` with a `reasons` map. On catastrophic failure, throw a\n * generic Error.\n */\nexport type ElementLoaderBackend = {\n\tload(elements: ElementMap, context: BackendContext): Promise<void>;\n};\n"]}
|
|
@@ -89,4 +89,3 @@ export declare function ensureRegistered(elements: ElementMap, options: EnsureRe
|
|
|
89
89
|
* elements out-of-band and want a loud failure if anything is missing.
|
|
90
90
|
*/
|
|
91
91
|
export declare function assertRegistered(tags: ElementTag[]): void;
|
|
92
|
-
//# sourceMappingURL=element-loader.d.ts.map
|