@pie-players/pie-players-shared 0.2.0
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 +15 -0
- package/dist/config/profile.d.ts.map +1 -0
- package/dist/config/profile.js +27 -0
- package/dist/config/profile.js.map +1 -0
- package/dist/i18n/index.d.ts +13 -0
- package/dist/i18n/index.d.ts.map +1 -0
- package/dist/i18n/index.js +12 -0
- package/dist/i18n/index.js.map +1 -0
- package/dist/i18n/loader.d.ts +36 -0
- package/dist/i18n/loader.d.ts.map +1 -0
- package/dist/i18n/loader.js +133 -0
- package/dist/i18n/loader.js.map +1 -0
- package/dist/i18n/scripts/check-coverage.d.ts +16 -0
- package/dist/i18n/scripts/check-coverage.d.ts.map +1 -0
- package/dist/i18n/scripts/check-coverage.js +262 -0
- package/dist/i18n/scripts/check-coverage.js.map +1 -0
- package/dist/i18n/scripts/scan-hardcoded.d.ts +16 -0
- package/dist/i18n/scripts/scan-hardcoded.d.ts.map +1 -0
- package/dist/i18n/scripts/scan-hardcoded.js +266 -0
- package/dist/i18n/scripts/scan-hardcoded.js.map +1 -0
- package/dist/i18n/simple-i18n.d.ts +69 -0
- package/dist/i18n/simple-i18n.d.ts.map +1 -0
- package/dist/i18n/simple-i18n.js +199 -0
- package/dist/i18n/simple-i18n.js.map +1 -0
- package/dist/i18n/translations/ar/common.json +36 -0
- package/dist/i18n/translations/ar/toolkit.json +48 -0
- package/dist/i18n/translations/ar/tools.json +109 -0
- package/dist/i18n/translations/en/common.json +36 -0
- package/dist/i18n/translations/en/toolkit.json +48 -0
- package/dist/i18n/translations/en/tools.json +109 -0
- package/dist/i18n/translations/es/common.json +36 -0
- package/dist/i18n/translations/es/toolkit.json +48 -0
- package/dist/i18n/translations/es/tools.json +109 -0
- package/dist/i18n/translations/zh/common.json +36 -0
- package/dist/i18n/translations/zh/toolkit.json +48 -0
- package/dist/i18n/translations/zh/tools.json +109 -0
- package/dist/i18n/types.d.ts +58 -0
- package/dist/i18n/types.d.ts.map +1 -0
- package/dist/i18n/types.js +8 -0
- package/dist/i18n/types.js.map +1 -0
- package/dist/i18n/use-i18n-standalone.svelte.d.ts +87 -0
- package/dist/i18n/use-i18n-standalone.svelte.d.ts.map +1 -0
- package/dist/i18n/use-i18n-standalone.svelte.js +151 -0
- package/dist/i18n/use-i18n-standalone.svelte.js.map +1 -0
- package/dist/i18n/use-i18n.svelte.d.ts +67 -0
- package/dist/i18n/use-i18n.svelte.d.ts.map +1 -0
- package/dist/i18n/use-i18n.svelte.js +144 -0
- package/dist/i18n/use-i18n.svelte.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -0
- package/dist/instrumentation/index.d.ts +53 -0
- package/dist/instrumentation/index.d.ts.map +1 -0
- package/dist/instrumentation/index.js +53 -0
- package/dist/instrumentation/index.js.map +1 -0
- package/dist/instrumentation/providers/BaseInstrumentationProvider.d.ts +197 -0
- package/dist/instrumentation/providers/BaseInstrumentationProvider.d.ts.map +1 -0
- package/dist/instrumentation/providers/BaseInstrumentationProvider.js +267 -0
- package/dist/instrumentation/providers/BaseInstrumentationProvider.js.map +1 -0
- package/dist/instrumentation/providers/ConsoleInstrumentationProvider.d.ts +106 -0
- package/dist/instrumentation/providers/ConsoleInstrumentationProvider.d.ts.map +1 -0
- package/dist/instrumentation/providers/ConsoleInstrumentationProvider.js +182 -0
- package/dist/instrumentation/providers/ConsoleInstrumentationProvider.js.map +1 -0
- package/dist/instrumentation/providers/DataDogInstrumentationProvider.d.ts +170 -0
- package/dist/instrumentation/providers/DataDogInstrumentationProvider.d.ts.map +1 -0
- package/dist/instrumentation/providers/DataDogInstrumentationProvider.js +183 -0
- package/dist/instrumentation/providers/DataDogInstrumentationProvider.js.map +1 -0
- package/dist/instrumentation/providers/NewRelicInstrumentationProvider.d.ts +86 -0
- package/dist/instrumentation/providers/NewRelicInstrumentationProvider.d.ts.map +1 -0
- package/dist/instrumentation/providers/NewRelicInstrumentationProvider.js +135 -0
- package/dist/instrumentation/providers/NewRelicInstrumentationProvider.js.map +1 -0
- package/dist/instrumentation/providers/index.d.ts +12 -0
- package/dist/instrumentation/providers/index.d.ts.map +1 -0
- package/dist/instrumentation/providers/index.js +12 -0
- package/dist/instrumentation/providers/index.js.map +1 -0
- package/dist/instrumentation/types.d.ts +348 -0
- package/dist/instrumentation/types.d.ts.map +1 -0
- package/dist/instrumentation/types.js +9 -0
- package/dist/instrumentation/types.js.map +1 -0
- package/dist/loader-config.d.ts +76 -0
- package/dist/loader-config.d.ts.map +1 -0
- package/dist/loader-config.js +12 -0
- package/dist/loader-config.js.map +1 -0
- package/dist/loaders/ElementLoader.d.ts +72 -0
- package/dist/loaders/ElementLoader.d.ts.map +1 -0
- package/dist/loaders/ElementLoader.js +52 -0
- package/dist/loaders/ElementLoader.js.map +1 -0
- package/dist/loaders/EsmElementLoader.d.ts +67 -0
- package/dist/loaders/EsmElementLoader.d.ts.map +1 -0
- package/dist/loaders/EsmElementLoader.js +71 -0
- package/dist/loaders/EsmElementLoader.js.map +1 -0
- package/dist/loaders/IifeElementLoader.d.ts +61 -0
- package/dist/loaders/IifeElementLoader.d.ts.map +1 -0
- package/dist/loaders/IifeElementLoader.js +63 -0
- package/dist/loaders/IifeElementLoader.js.map +1 -0
- package/dist/loaders/index.d.ts +28 -0
- package/dist/loaders/index.d.ts.map +1 -0
- package/dist/loaders/index.js +25 -0
- package/dist/loaders/index.js.map +1 -0
- package/dist/object/index.d.ts +12 -0
- package/dist/object/index.d.ts.map +1 -0
- package/dist/object/index.js +40 -0
- package/dist/object/index.js.map +1 -0
- package/dist/pie/asset-handler.d.ts +64 -0
- package/dist/pie/asset-handler.d.ts.map +1 -0
- package/dist/pie/asset-handler.js +238 -0
- package/dist/pie/asset-handler.js.map +1 -0
- package/dist/pie/component-context.d.ts +22 -0
- package/dist/pie/component-context.d.ts.map +1 -0
- package/dist/pie/component-context.js +30 -0
- package/dist/pie/component-context.js.map +1 -0
- package/dist/pie/config.d.ts +39 -0
- package/dist/pie/config.d.ts.map +1 -0
- package/dist/pie/config.js +174 -0
- package/dist/pie/config.js.map +1 -0
- package/dist/pie/configure-initialization.d.ts +35 -0
- package/dist/pie/configure-initialization.d.ts.map +1 -0
- package/dist/pie/configure-initialization.js +141 -0
- package/dist/pie/configure-initialization.js.map +1 -0
- package/dist/pie/esm-loader.d.ts +93 -0
- package/dist/pie/esm-loader.d.ts.map +1 -0
- package/dist/pie/esm-loader.js +308 -0
- package/dist/pie/esm-loader.js.map +1 -0
- package/dist/pie/iife-loader.d.ts +76 -0
- package/dist/pie/iife-loader.d.ts.map +1 -0
- package/dist/pie/iife-loader.js +303 -0
- package/dist/pie/iife-loader.js.map +1 -0
- package/dist/pie/index.d.ts +31 -0
- package/dist/pie/index.d.ts.map +1 -0
- package/dist/pie/index.js +34 -0
- package/dist/pie/index.js.map +1 -0
- package/dist/pie/initialization.d.ts +40 -0
- package/dist/pie/initialization.d.ts.map +1 -0
- package/dist/pie/initialization.js +349 -0
- package/dist/pie/initialization.js.map +1 -0
- package/dist/pie/logger.d.ts +64 -0
- package/dist/pie/logger.d.ts.map +1 -0
- package/dist/pie/logger.js +45 -0
- package/dist/pie/logger.js.map +1 -0
- package/dist/pie/math-rendering.d.ts +69 -0
- package/dist/pie/math-rendering.d.ts.map +1 -0
- package/dist/pie/math-rendering.js +98 -0
- package/dist/pie/math-rendering.js.map +1 -0
- package/dist/pie/overrides.d.ts +43 -0
- package/dist/pie/overrides.d.ts.map +1 -0
- package/dist/pie/overrides.js +146 -0
- package/dist/pie/overrides.js.map +1 -0
- package/dist/pie/player-initializer.d.ts +55 -0
- package/dist/pie/player-initializer.d.ts.map +1 -0
- package/dist/pie/player-initializer.js +123 -0
- package/dist/pie/player-initializer.js.map +1 -0
- package/dist/pie/registry.d.ts +11 -0
- package/dist/pie/registry.d.ts.map +1 -0
- package/dist/pie/registry.js +21 -0
- package/dist/pie/registry.js.map +1 -0
- package/dist/pie/resource-monitor.d.ts +208 -0
- package/dist/pie/resource-monitor.d.ts.map +1 -0
- package/dist/pie/resource-monitor.js +969 -0
- package/dist/pie/resource-monitor.js.map +1 -0
- package/dist/pie/scoring.d.ts +17 -0
- package/dist/pie/scoring.d.ts.map +1 -0
- package/dist/pie/scoring.js +84 -0
- package/dist/pie/scoring.js.map +1 -0
- package/dist/pie/types.d.ts +136 -0
- package/dist/pie/types.d.ts.map +1 -0
- package/dist/pie/types.js +52 -0
- package/dist/pie/types.js.map +1 -0
- package/dist/pie/updates.d.ts +20 -0
- package/dist/pie/updates.d.ts.map +1 -0
- package/dist/pie/updates.js +175 -0
- package/dist/pie/updates.js.map +1 -0
- package/dist/pie/use-resource-monitor.svelte.d.ts +56 -0
- package/dist/pie/use-resource-monitor.svelte.d.ts.map +1 -0
- package/dist/pie/use-resource-monitor.svelte.js +117 -0
- package/dist/pie/use-resource-monitor.svelte.js.map +1 -0
- package/dist/pie/utils.d.ts +44 -0
- package/dist/pie/utils.d.ts.map +1 -0
- package/dist/pie/utils.js +74 -0
- package/dist/pie/utils.js.map +1 -0
- package/dist/types/custom-elements.d.ts +183 -0
- package/dist/types/custom-elements.d.ts.map +1 -0
- package/dist/types/custom-elements.js +8 -0
- package/dist/types/custom-elements.js.map +1 -0
- package/dist/types/index.d.ts +761 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +120 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/search.d.ts +105 -0
- package/dist/types/search.d.ts.map +1 -0
- package/dist/types/search.js +12 -0
- package/dist/types/search.js.map +1 -0
- package/dist/types/transform.d.ts +48 -0
- package/dist/types/transform.d.ts.map +1 -0
- package/dist/types/transform.js +21 -0
- package/dist/types/transform.js.map +1 -0
- package/dist/ui/focus-trap.d.ts +10 -0
- package/dist/ui/focus-trap.d.ts.map +1 -0
- package/dist/ui/focus-trap.js +30 -0
- package/dist/ui/focus-trap.js.map +1 -0
- package/dist/ui/safe-storage.d.ts +3 -0
- package/dist/ui/safe-storage.d.ts.map +1 -0
- package/dist/ui/safe-storage.js +21 -0
- package/dist/ui/safe-storage.js.map +1 -0
- package/package.json +118 -0
- package/src/components/PieItemPlayer.svelte +604 -0
- package/src/components/PiePreviewLayout.svelte +144 -0
- package/src/components/PiePreviewToggle.svelte +110 -0
- package/src/components/PieSpinner.svelte +85 -0
- package/src/components/ToolSettingsButton.svelte +31 -0
- package/src/components/ToolSettingsPanel.svelte +90 -0
- package/src/components/index.ts +6 -0
- package/src/i18n/README.md +223 -0
- package/src/i18n/index.ts +26 -0
- package/src/i18n/loader.ts +156 -0
- package/src/i18n/scripts/check-coverage.ts +345 -0
- package/src/i18n/scripts/scan-hardcoded.ts +342 -0
- package/src/i18n/simple-i18n.ts +236 -0
- package/src/i18n/translations/ar/common.json +36 -0
- package/src/i18n/translations/ar/toolkit.json +48 -0
- package/src/i18n/translations/ar/tools.json +109 -0
- package/src/i18n/translations/en/common.json +36 -0
- package/src/i18n/translations/en/toolkit.json +48 -0
- package/src/i18n/translations/en/tools.json +109 -0
- package/src/i18n/translations/es/common.json +36 -0
- package/src/i18n/translations/es/toolkit.json +48 -0
- package/src/i18n/translations/es/tools.json +109 -0
- package/src/i18n/translations/zh/common.json +36 -0
- package/src/i18n/translations/zh/toolkit.json +48 -0
- package/src/i18n/translations/zh/tools.json +109 -0
- package/src/i18n/types.ts +66 -0
- package/src/i18n/use-i18n-standalone.svelte.ts +184 -0
- package/src/i18n/use-i18n.svelte.ts +163 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from "./config/profile";
|
|
2
|
+
export * from "./instrumentation";
|
|
3
|
+
export * from "./loader-config";
|
|
4
|
+
export * from "./loaders";
|
|
5
|
+
export * from "./object";
|
|
6
|
+
// Barrel export for PIE runtime utilities
|
|
7
|
+
export * from "./pie";
|
|
8
|
+
export { editorPostFix } from "./types";
|
|
9
|
+
export * from "./ui/focus-trap";
|
|
10
|
+
export * from "./ui/safe-storage";
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,0CAA0C;AAC1C,cAAc,OAAO,CAAC;AAqBtB,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Instrumentation Module
|
|
3
|
+
*
|
|
4
|
+
* Provides pluggable instrumentation for PIE players.
|
|
5
|
+
* Supports multiple providers (New Relic, DataDog, console logging, custom, etc.)
|
|
6
|
+
*
|
|
7
|
+
* @example Using New Relic (default)
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { NewRelicInstrumentationProvider } from '@pie-players/pie-players-shared';
|
|
10
|
+
*
|
|
11
|
+
* const provider = new NewRelicInstrumentationProvider();
|
|
12
|
+
* await provider.initialize();
|
|
13
|
+
*
|
|
14
|
+
* const monitor = new ResourceMonitor({
|
|
15
|
+
* trackPageActions: true,
|
|
16
|
+
* instrumentationProvider: provider
|
|
17
|
+
* });
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* @example Using DataDog
|
|
21
|
+
* ```typescript
|
|
22
|
+
* import { DataDogInstrumentationProvider } from '@pie-players/pie-players-shared';
|
|
23
|
+
*
|
|
24
|
+
* const provider = new DataDogInstrumentationProvider();
|
|
25
|
+
* await provider.initialize({
|
|
26
|
+
* providerSettings: {
|
|
27
|
+
* applicationId: 'abc123',
|
|
28
|
+
* clientToken: 'pub_xyz'
|
|
29
|
+
* }
|
|
30
|
+
* });
|
|
31
|
+
*
|
|
32
|
+
* const monitor = new ResourceMonitor({
|
|
33
|
+
* trackPageActions: true,
|
|
34
|
+
* instrumentationProvider: provider
|
|
35
|
+
* });
|
|
36
|
+
* ```
|
|
37
|
+
*
|
|
38
|
+
* @example Using console logger for development
|
|
39
|
+
* ```typescript
|
|
40
|
+
* import { ConsoleInstrumentationProvider } from '@pie-players/pie-players-shared';
|
|
41
|
+
*
|
|
42
|
+
* const provider = new ConsoleInstrumentationProvider();
|
|
43
|
+
* await provider.initialize({ debug: true });
|
|
44
|
+
*
|
|
45
|
+
* const monitor = new ResourceMonitor({
|
|
46
|
+
* trackPageActions: true,
|
|
47
|
+
* instrumentationProvider: provider
|
|
48
|
+
* });
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
export * from "./providers";
|
|
52
|
+
export type { ErrorAttributes, EventAttributes, InstrumentationConfig, InstrumentationProvider, MetricAttributes, } from "./types";
|
|
53
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/instrumentation/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AAGH,cAAc,aAAa,CAAC;AAE5B,YAAY,EACX,eAAe,EACf,eAAe,EACf,qBAAqB,EACrB,uBAAuB,EACvB,gBAAgB,GAChB,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Instrumentation Module
|
|
3
|
+
*
|
|
4
|
+
* Provides pluggable instrumentation for PIE players.
|
|
5
|
+
* Supports multiple providers (New Relic, DataDog, console logging, custom, etc.)
|
|
6
|
+
*
|
|
7
|
+
* @example Using New Relic (default)
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { NewRelicInstrumentationProvider } from '@pie-players/pie-players-shared';
|
|
10
|
+
*
|
|
11
|
+
* const provider = new NewRelicInstrumentationProvider();
|
|
12
|
+
* await provider.initialize();
|
|
13
|
+
*
|
|
14
|
+
* const monitor = new ResourceMonitor({
|
|
15
|
+
* trackPageActions: true,
|
|
16
|
+
* instrumentationProvider: provider
|
|
17
|
+
* });
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* @example Using DataDog
|
|
21
|
+
* ```typescript
|
|
22
|
+
* import { DataDogInstrumentationProvider } from '@pie-players/pie-players-shared';
|
|
23
|
+
*
|
|
24
|
+
* const provider = new DataDogInstrumentationProvider();
|
|
25
|
+
* await provider.initialize({
|
|
26
|
+
* providerSettings: {
|
|
27
|
+
* applicationId: 'abc123',
|
|
28
|
+
* clientToken: 'pub_xyz'
|
|
29
|
+
* }
|
|
30
|
+
* });
|
|
31
|
+
*
|
|
32
|
+
* const monitor = new ResourceMonitor({
|
|
33
|
+
* trackPageActions: true,
|
|
34
|
+
* instrumentationProvider: provider
|
|
35
|
+
* });
|
|
36
|
+
* ```
|
|
37
|
+
*
|
|
38
|
+
* @example Using console logger for development
|
|
39
|
+
* ```typescript
|
|
40
|
+
* import { ConsoleInstrumentationProvider } from '@pie-players/pie-players-shared';
|
|
41
|
+
*
|
|
42
|
+
* const provider = new ConsoleInstrumentationProvider();
|
|
43
|
+
* await provider.initialize({ debug: true });
|
|
44
|
+
*
|
|
45
|
+
* const monitor = new ResourceMonitor({
|
|
46
|
+
* trackPageActions: true,
|
|
47
|
+
* instrumentationProvider: provider
|
|
48
|
+
* });
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
// Providers
|
|
52
|
+
export * from "./providers";
|
|
53
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/instrumentation/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AAEH,YAAY;AACZ,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base Instrumentation Provider
|
|
3
|
+
*
|
|
4
|
+
* Abstract base class that implements common instrumentation logic for all providers.
|
|
5
|
+
* Provides a template method pattern for tracking errors and events with consistent
|
|
6
|
+
* filtering, transformation, and sampling behavior.
|
|
7
|
+
*
|
|
8
|
+
* Concrete providers only need to implement the actual tracking methods specific
|
|
9
|
+
* to their instrumentation backend (New Relic, DataDog, etc.)
|
|
10
|
+
*/
|
|
11
|
+
import type { ErrorAttributes, EventAttributes, InstrumentationConfig, InstrumentationProvider, MetricAttributes } from "../types";
|
|
12
|
+
/**
|
|
13
|
+
* Abstract base class for instrumentation providers
|
|
14
|
+
*
|
|
15
|
+
* Implements the template method pattern:
|
|
16
|
+
* 1. Checks if provider is ready
|
|
17
|
+
* 2. Applies filters (errorFilter, eventFilter)
|
|
18
|
+
* 3. Applies sampling (sampleRate)
|
|
19
|
+
* 4. Transforms attributes (attributeTransformer)
|
|
20
|
+
* 5. Delegates to concrete provider implementation (doTrackError, doTrackEvent, etc.)
|
|
21
|
+
*/
|
|
22
|
+
export declare abstract class BaseInstrumentationProvider implements InstrumentationProvider {
|
|
23
|
+
abstract readonly providerId: string;
|
|
24
|
+
abstract readonly providerName: string;
|
|
25
|
+
protected initialized: boolean;
|
|
26
|
+
protected config?: InstrumentationConfig;
|
|
27
|
+
/**
|
|
28
|
+
* Initialize the provider with configuration
|
|
29
|
+
*
|
|
30
|
+
* Concrete providers should override this method to perform provider-specific
|
|
31
|
+
* initialization (e.g., loading SDK, checking global objects, etc.)
|
|
32
|
+
*
|
|
33
|
+
* @param config Optional configuration
|
|
34
|
+
*/
|
|
35
|
+
abstract initialize(config?: InstrumentationConfig): Promise<void>;
|
|
36
|
+
/**
|
|
37
|
+
* Check if provider is ready to track events
|
|
38
|
+
*
|
|
39
|
+
* Concrete providers should override this method to check provider-specific
|
|
40
|
+
* readiness (e.g., SDK loaded, global object available, etc.)
|
|
41
|
+
*
|
|
42
|
+
* @returns true if provider is ready
|
|
43
|
+
*/
|
|
44
|
+
abstract isReady(): boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Cleanup provider resources
|
|
47
|
+
*
|
|
48
|
+
* Concrete providers should override this method to perform provider-specific
|
|
49
|
+
* cleanup (e.g., disconnect SDK, clear listeners, etc.)
|
|
50
|
+
*/
|
|
51
|
+
abstract destroy(): void;
|
|
52
|
+
/**
|
|
53
|
+
* Track an error with the instrumentation backend
|
|
54
|
+
*
|
|
55
|
+
* Called by trackError() after all filters and transforms have been applied.
|
|
56
|
+
* Concrete providers should implement the actual error tracking here.
|
|
57
|
+
*
|
|
58
|
+
* @param error The error to track
|
|
59
|
+
* @param attributes Transformed and filtered attributes
|
|
60
|
+
*/
|
|
61
|
+
protected abstract doTrackError(error: Error, attributes: Record<string, any>): void;
|
|
62
|
+
/**
|
|
63
|
+
* Track an event with the instrumentation backend
|
|
64
|
+
*
|
|
65
|
+
* Called by trackEvent() after all filters and transforms have been applied.
|
|
66
|
+
* Concrete providers should implement the actual event tracking here.
|
|
67
|
+
*
|
|
68
|
+
* @param eventName Name of the event
|
|
69
|
+
* @param attributes Transformed and filtered attributes
|
|
70
|
+
*/
|
|
71
|
+
protected abstract doTrackEvent(eventName: string, attributes: Record<string, any>): void;
|
|
72
|
+
/**
|
|
73
|
+
* Set user context in the instrumentation backend
|
|
74
|
+
*
|
|
75
|
+
* Called by setUserContext() after readiness check.
|
|
76
|
+
* Concrete providers should implement the actual user context setting here.
|
|
77
|
+
*
|
|
78
|
+
* @param userId User identifier
|
|
79
|
+
* @param attributes Optional user attributes
|
|
80
|
+
*/
|
|
81
|
+
protected abstract doSetUserContext(userId: string, attributes?: Record<string, any>): void;
|
|
82
|
+
/**
|
|
83
|
+
* Set global attributes in the instrumentation backend
|
|
84
|
+
*
|
|
85
|
+
* Called by setGlobalAttributes() after readiness check.
|
|
86
|
+
* Concrete providers should implement the actual global attribute setting here.
|
|
87
|
+
*
|
|
88
|
+
* @param attributes Attributes to set globally
|
|
89
|
+
*/
|
|
90
|
+
protected abstract doSetGlobalAttributes(attributes: Record<string, any>): void;
|
|
91
|
+
/**
|
|
92
|
+
* Track an error with the instrumentation provider
|
|
93
|
+
*
|
|
94
|
+
* Template method that:
|
|
95
|
+
* 1. Checks if provider is ready
|
|
96
|
+
* 2. Applies error filter if configured
|
|
97
|
+
* 3. Transforms attributes if configured
|
|
98
|
+
* 4. Delegates to concrete provider implementation (doTrackError)
|
|
99
|
+
*
|
|
100
|
+
* @param error The error to track
|
|
101
|
+
* @param attributes Contextual attributes
|
|
102
|
+
*/
|
|
103
|
+
trackError(error: Error, attributes: ErrorAttributes): void;
|
|
104
|
+
/**
|
|
105
|
+
* Track a custom event with the instrumentation provider
|
|
106
|
+
*
|
|
107
|
+
* Template method that:
|
|
108
|
+
* 1. Checks if provider is ready
|
|
109
|
+
* 2. Applies event filter if configured
|
|
110
|
+
* 3. Applies sampling if configured
|
|
111
|
+
* 4. Transforms attributes if configured
|
|
112
|
+
* 5. Adds timestamp if not present
|
|
113
|
+
* 6. Delegates to concrete provider implementation (doTrackEvent)
|
|
114
|
+
*
|
|
115
|
+
* @param eventName Name of the event
|
|
116
|
+
* @param attributes Event attributes
|
|
117
|
+
*/
|
|
118
|
+
trackEvent(eventName: string, attributes: EventAttributes): void;
|
|
119
|
+
/**
|
|
120
|
+
* Track a performance metric
|
|
121
|
+
*
|
|
122
|
+
* Default implementation tracks metrics as events with a `metric:` prefix.
|
|
123
|
+
* Concrete providers can override this method if their backend has a
|
|
124
|
+
* dedicated metric API.
|
|
125
|
+
*
|
|
126
|
+
* @param metricName Name of the metric
|
|
127
|
+
* @param value Numeric value
|
|
128
|
+
* @param attributes Optional metric attributes
|
|
129
|
+
*/
|
|
130
|
+
trackMetric(metricName: string, value: number, attributes?: MetricAttributes): void;
|
|
131
|
+
/**
|
|
132
|
+
* Set user context for session tracking
|
|
133
|
+
*
|
|
134
|
+
* Template method that checks if provider is ready then delegates
|
|
135
|
+
* to concrete provider implementation.
|
|
136
|
+
*
|
|
137
|
+
* @param userId User identifier
|
|
138
|
+
* @param attributes Optional user attributes
|
|
139
|
+
*/
|
|
140
|
+
setUserContext(userId: string, attributes?: Record<string, any>): void;
|
|
141
|
+
/**
|
|
142
|
+
* Set global custom attributes
|
|
143
|
+
*
|
|
144
|
+
* Template method that checks if provider is ready then delegates
|
|
145
|
+
* to concrete provider implementation.
|
|
146
|
+
*
|
|
147
|
+
* @param attributes Attributes to set globally
|
|
148
|
+
*/
|
|
149
|
+
setGlobalAttributes(attributes: Record<string, any>): void;
|
|
150
|
+
/**
|
|
151
|
+
* Guard operation - check if provider is ready
|
|
152
|
+
*
|
|
153
|
+
* Returns false if provider is not ready, logging a warning in debug mode.
|
|
154
|
+
*
|
|
155
|
+
* @param operation Name of the operation for logging
|
|
156
|
+
* @param args Arguments for logging
|
|
157
|
+
* @returns true if provider is ready, false otherwise
|
|
158
|
+
*/
|
|
159
|
+
protected guardedOperation(operation: string, ...args: any[]): boolean;
|
|
160
|
+
/**
|
|
161
|
+
* Apply error filter if configured
|
|
162
|
+
*
|
|
163
|
+
* Returns false if error should be filtered out, logging in debug mode.
|
|
164
|
+
*
|
|
165
|
+
* @param error The error
|
|
166
|
+
* @param attributes Error attributes
|
|
167
|
+
* @returns true if error should be tracked, false if filtered out
|
|
168
|
+
*/
|
|
169
|
+
protected applyErrorFilter(error: Error, attributes: ErrorAttributes): boolean;
|
|
170
|
+
/**
|
|
171
|
+
* Apply event filter if configured
|
|
172
|
+
*
|
|
173
|
+
* Returns false if event should be filtered out, logging in debug mode.
|
|
174
|
+
*
|
|
175
|
+
* @param eventName Event name
|
|
176
|
+
* @param attributes Event attributes
|
|
177
|
+
* @returns true if event should be tracked, false if filtered out
|
|
178
|
+
*/
|
|
179
|
+
protected applyEventFilter(eventName: string, attributes: EventAttributes): boolean;
|
|
180
|
+
/**
|
|
181
|
+
* Apply sampling if configured
|
|
182
|
+
*
|
|
183
|
+
* Returns false if event should be sampled out, logging in debug mode.
|
|
184
|
+
*
|
|
185
|
+
* @param eventName Event name for logging
|
|
186
|
+
* @returns true if event should be tracked, false if sampled out
|
|
187
|
+
*/
|
|
188
|
+
protected applySampling(eventName: string): boolean;
|
|
189
|
+
/**
|
|
190
|
+
* Transform attributes if transformer is configured
|
|
191
|
+
*
|
|
192
|
+
* @param attributes Original attributes
|
|
193
|
+
* @returns Transformed attributes or original if no transformer
|
|
194
|
+
*/
|
|
195
|
+
protected transformAttributes(attributes: Record<string, any>): Record<string, any>;
|
|
196
|
+
}
|
|
197
|
+
//# sourceMappingURL=BaseInstrumentationProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseInstrumentationProvider.d.ts","sourceRoot":"","sources":["../../../src/instrumentation/providers/BaseInstrumentationProvider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EACX,eAAe,EACf,eAAe,EACf,qBAAqB,EACrB,uBAAuB,EACvB,gBAAgB,EAChB,MAAM,UAAU,CAAC;AAElB;;;;;;;;;GASG;AACH,8BAAsB,2BACrB,YAAW,uBAAuB;IAElC,QAAQ,CAAC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IACrC,QAAQ,CAAC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAEvC,SAAS,CAAC,WAAW,UAAS;IAC9B,SAAS,CAAC,MAAM,CAAC,EAAE,qBAAqB,CAAC;IAEzC;;;;;;;OAOG;IACH,QAAQ,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC;IAElE;;;;;;;OAOG;IACH,QAAQ,CAAC,OAAO,IAAI,OAAO;IAE3B;;;;;OAKG;IACH,QAAQ,CAAC,OAAO,IAAI,IAAI;IAMxB;;;;;;;;OAQG;IACH,SAAS,CAAC,QAAQ,CAAC,YAAY,CAC9B,KAAK,EAAE,KAAK,EACZ,UAAU,EAAE,MAAM,CAA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,GACzB,OAAO;IAiBV;;;;;;;;OAQG;IACH,SAAS,CAAC,gBAAgB,CACzB,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,eAAe,GACzB,OAAO;IAiBV;;;;;;;OAOG;IACH,SAAS,CAAC,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO;IAYnD;;;;;OAKG;IACH,SAAS,CAAC,mBAAmB,CAC5B,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAC7B,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;CAMtB"}
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base Instrumentation Provider
|
|
3
|
+
*
|
|
4
|
+
* Abstract base class that implements common instrumentation logic for all providers.
|
|
5
|
+
* Provides a template method pattern for tracking errors and events with consistent
|
|
6
|
+
* filtering, transformation, and sampling behavior.
|
|
7
|
+
*
|
|
8
|
+
* Concrete providers only need to implement the actual tracking methods specific
|
|
9
|
+
* to their instrumentation backend (New Relic, DataDog, etc.)
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Abstract base class for instrumentation providers
|
|
13
|
+
*
|
|
14
|
+
* Implements the template method pattern:
|
|
15
|
+
* 1. Checks if provider is ready
|
|
16
|
+
* 2. Applies filters (errorFilter, eventFilter)
|
|
17
|
+
* 3. Applies sampling (sampleRate)
|
|
18
|
+
* 4. Transforms attributes (attributeTransformer)
|
|
19
|
+
* 5. Delegates to concrete provider implementation (doTrackError, doTrackEvent, etc.)
|
|
20
|
+
*/
|
|
21
|
+
export class BaseInstrumentationProvider {
|
|
22
|
+
initialized = false;
|
|
23
|
+
config;
|
|
24
|
+
// ============================================================================
|
|
25
|
+
// Public API methods (template methods)
|
|
26
|
+
// ============================================================================
|
|
27
|
+
/**
|
|
28
|
+
* Track an error with the instrumentation provider
|
|
29
|
+
*
|
|
30
|
+
* Template method that:
|
|
31
|
+
* 1. Checks if provider is ready
|
|
32
|
+
* 2. Applies error filter if configured
|
|
33
|
+
* 3. Transforms attributes if configured
|
|
34
|
+
* 4. Delegates to concrete provider implementation (doTrackError)
|
|
35
|
+
*
|
|
36
|
+
* @param error The error to track
|
|
37
|
+
* @param attributes Contextual attributes
|
|
38
|
+
*/
|
|
39
|
+
trackError(error, attributes) {
|
|
40
|
+
// Guard: check if provider is ready
|
|
41
|
+
if (!this.guardedOperation("trackError", error, attributes)) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
// Apply error filter
|
|
45
|
+
if (!this.applyErrorFilter(error, attributes)) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
// Transform attributes
|
|
49
|
+
const finalAttributes = this.transformAttributes(attributes);
|
|
50
|
+
// Delegate to concrete provider
|
|
51
|
+
try {
|
|
52
|
+
this.doTrackError(error, finalAttributes);
|
|
53
|
+
if (this.config?.debug) {
|
|
54
|
+
console.log(`[${this.providerName}] Tracked error:`, error, finalAttributes);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
catch (err) {
|
|
58
|
+
console.error(`[${this.providerName}] Error tracking error:`, err);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Track a custom event with the instrumentation provider
|
|
63
|
+
*
|
|
64
|
+
* Template method that:
|
|
65
|
+
* 1. Checks if provider is ready
|
|
66
|
+
* 2. Applies event filter if configured
|
|
67
|
+
* 3. Applies sampling if configured
|
|
68
|
+
* 4. Transforms attributes if configured
|
|
69
|
+
* 5. Adds timestamp if not present
|
|
70
|
+
* 6. Delegates to concrete provider implementation (doTrackEvent)
|
|
71
|
+
*
|
|
72
|
+
* @param eventName Name of the event
|
|
73
|
+
* @param attributes Event attributes
|
|
74
|
+
*/
|
|
75
|
+
trackEvent(eventName, attributes) {
|
|
76
|
+
// Guard: check if provider is ready
|
|
77
|
+
if (!this.guardedOperation("trackEvent", eventName, attributes)) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
// Apply event filter
|
|
81
|
+
if (!this.applyEventFilter(eventName, attributes)) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
// Apply sampling
|
|
85
|
+
if (!this.applySampling(eventName)) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
// Transform attributes
|
|
89
|
+
let finalAttributes = this.transformAttributes(attributes);
|
|
90
|
+
// Add timestamp if not present
|
|
91
|
+
if (!finalAttributes.timestamp) {
|
|
92
|
+
finalAttributes = {
|
|
93
|
+
...finalAttributes,
|
|
94
|
+
timestamp: new Date().toISOString(),
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
// Delegate to concrete provider
|
|
98
|
+
try {
|
|
99
|
+
this.doTrackEvent(eventName, finalAttributes);
|
|
100
|
+
if (this.config?.debug) {
|
|
101
|
+
console.log(`[${this.providerName}] Tracked event:`, eventName, finalAttributes);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
catch (err) {
|
|
105
|
+
console.error(`[${this.providerName}] Error tracking event:`, err);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Track a performance metric
|
|
110
|
+
*
|
|
111
|
+
* Default implementation tracks metrics as events with a `metric:` prefix.
|
|
112
|
+
* Concrete providers can override this method if their backend has a
|
|
113
|
+
* dedicated metric API.
|
|
114
|
+
*
|
|
115
|
+
* @param metricName Name of the metric
|
|
116
|
+
* @param value Numeric value
|
|
117
|
+
* @param attributes Optional metric attributes
|
|
118
|
+
*/
|
|
119
|
+
trackMetric(metricName, value, attributes) {
|
|
120
|
+
// Default implementation: track as event
|
|
121
|
+
this.trackEvent(`metric:${metricName}`, {
|
|
122
|
+
...attributes,
|
|
123
|
+
metricValue: value,
|
|
124
|
+
metricName,
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Set user context for session tracking
|
|
129
|
+
*
|
|
130
|
+
* Template method that checks if provider is ready then delegates
|
|
131
|
+
* to concrete provider implementation.
|
|
132
|
+
*
|
|
133
|
+
* @param userId User identifier
|
|
134
|
+
* @param attributes Optional user attributes
|
|
135
|
+
*/
|
|
136
|
+
setUserContext(userId, attributes) {
|
|
137
|
+
// Guard: check if provider is ready
|
|
138
|
+
if (!this.guardedOperation("setUserContext", userId, attributes)) {
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
// Delegate to concrete provider
|
|
142
|
+
try {
|
|
143
|
+
this.doSetUserContext(userId, attributes);
|
|
144
|
+
if (this.config?.debug) {
|
|
145
|
+
console.log(`[${this.providerName}] Set user context:`, userId, attributes);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
catch (err) {
|
|
149
|
+
console.error(`[${this.providerName}] Error setting user context:`, err);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Set global custom attributes
|
|
154
|
+
*
|
|
155
|
+
* Template method that checks if provider is ready then delegates
|
|
156
|
+
* to concrete provider implementation.
|
|
157
|
+
*
|
|
158
|
+
* @param attributes Attributes to set globally
|
|
159
|
+
*/
|
|
160
|
+
setGlobalAttributes(attributes) {
|
|
161
|
+
// Guard: check if provider is ready
|
|
162
|
+
if (!this.guardedOperation("setGlobalAttributes", attributes)) {
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
// Delegate to concrete provider
|
|
166
|
+
try {
|
|
167
|
+
this.doSetGlobalAttributes(attributes);
|
|
168
|
+
if (this.config?.debug) {
|
|
169
|
+
console.log(`[${this.providerName}] Set global attributes:`, attributes);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
catch (err) {
|
|
173
|
+
console.error(`[${this.providerName}] Error setting global attributes:`, err);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
// ============================================================================
|
|
177
|
+
// Protected utility methods (shared logic)
|
|
178
|
+
// ============================================================================
|
|
179
|
+
/**
|
|
180
|
+
* Guard operation - check if provider is ready
|
|
181
|
+
*
|
|
182
|
+
* Returns false if provider is not ready, logging a warning in debug mode.
|
|
183
|
+
*
|
|
184
|
+
* @param operation Name of the operation for logging
|
|
185
|
+
* @param args Arguments for logging
|
|
186
|
+
* @returns true if provider is ready, false otherwise
|
|
187
|
+
*/
|
|
188
|
+
guardedOperation(operation, ...args) {
|
|
189
|
+
if (!this.isReady()) {
|
|
190
|
+
if (this.config?.debug) {
|
|
191
|
+
console.warn(`[${this.providerName}] Attempted to ${operation} but provider not ready:`, ...args);
|
|
192
|
+
}
|
|
193
|
+
return false;
|
|
194
|
+
}
|
|
195
|
+
return true;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Apply error filter if configured
|
|
199
|
+
*
|
|
200
|
+
* Returns false if error should be filtered out, logging in debug mode.
|
|
201
|
+
*
|
|
202
|
+
* @param error The error
|
|
203
|
+
* @param attributes Error attributes
|
|
204
|
+
* @returns true if error should be tracked, false if filtered out
|
|
205
|
+
*/
|
|
206
|
+
applyErrorFilter(error, attributes) {
|
|
207
|
+
if (this.config?.errorFilter &&
|
|
208
|
+
!this.config.errorFilter(error, attributes)) {
|
|
209
|
+
if (this.config?.debug) {
|
|
210
|
+
console.log(`[${this.providerName}] Error filtered out:`, error, attributes);
|
|
211
|
+
}
|
|
212
|
+
return false;
|
|
213
|
+
}
|
|
214
|
+
return true;
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Apply event filter if configured
|
|
218
|
+
*
|
|
219
|
+
* Returns false if event should be filtered out, logging in debug mode.
|
|
220
|
+
*
|
|
221
|
+
* @param eventName Event name
|
|
222
|
+
* @param attributes Event attributes
|
|
223
|
+
* @returns true if event should be tracked, false if filtered out
|
|
224
|
+
*/
|
|
225
|
+
applyEventFilter(eventName, attributes) {
|
|
226
|
+
if (this.config?.eventFilter &&
|
|
227
|
+
!this.config.eventFilter(eventName, attributes)) {
|
|
228
|
+
if (this.config?.debug) {
|
|
229
|
+
console.log(`[${this.providerName}] Event filtered out:`, eventName, attributes);
|
|
230
|
+
}
|
|
231
|
+
return false;
|
|
232
|
+
}
|
|
233
|
+
return true;
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Apply sampling if configured
|
|
237
|
+
*
|
|
238
|
+
* Returns false if event should be sampled out, logging in debug mode.
|
|
239
|
+
*
|
|
240
|
+
* @param eventName Event name for logging
|
|
241
|
+
* @returns true if event should be tracked, false if sampled out
|
|
242
|
+
*/
|
|
243
|
+
applySampling(eventName) {
|
|
244
|
+
if (this.config?.sampleRate !== undefined && this.config.sampleRate < 1.0) {
|
|
245
|
+
if (Math.random() > this.config.sampleRate) {
|
|
246
|
+
if (this.config?.debug) {
|
|
247
|
+
console.log(`[${this.providerName}] Event sampled out:`, eventName);
|
|
248
|
+
}
|
|
249
|
+
return false;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
return true;
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Transform attributes if transformer is configured
|
|
256
|
+
*
|
|
257
|
+
* @param attributes Original attributes
|
|
258
|
+
* @returns Transformed attributes or original if no transformer
|
|
259
|
+
*/
|
|
260
|
+
transformAttributes(attributes) {
|
|
261
|
+
if (this.config?.attributeTransformer) {
|
|
262
|
+
return this.config.attributeTransformer(attributes);
|
|
263
|
+
}
|
|
264
|
+
return attributes;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
//# sourceMappingURL=BaseInstrumentationProvider.js.map
|
|
@@ -0,0 +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,EAAE,UAA2B;QACnD,oCAAoC;QACpC,IAAI,C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