@syntrologie/runtime-sdk 2.8.0-canary.13 → 2.8.0-canary.130
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/CAPABILITIES.md +321 -173
- package/README.md +3 -0
- package/dist/SmartCanvasApp.d.ts +4 -1
- package/dist/SmartCanvasElementLit.d.ts +166 -0
- package/dist/actions/schema.d.ts +783 -783
- package/dist/actions/schema.js +3 -3
- package/dist/actions/types.d.ts +9 -3
- package/dist/actions/validation-core.d.ts +24 -0
- package/dist/actions/validation-rules.d.ts +74 -0
- package/dist/actions/validation.d.ts +5 -11
- package/dist/anchor/AnchorResolver.d.ts +1 -0
- package/dist/api-lit.d.ts +84 -0
- package/dist/api.d.ts +3 -0
- package/dist/apps/builtinRuntimeModules-lit.d.ts +20 -0
- package/dist/bootstrap-init.d.ts +35 -0
- package/dist/bootstrap-runtime.d.ts +7 -0
- package/dist/bootstrap-types.d.ts +100 -0
- package/dist/bootstrap.d.ts +19 -83
- package/dist/chunk-2IQ2PTLJ.js +871 -0
- package/dist/chunk-2IQ2PTLJ.js.map +7 -0
- package/dist/chunk-4HXPGXUC.js +226 -0
- package/dist/chunk-4HXPGXUC.js.map +7 -0
- package/dist/{chunk-37TTQRH5.js → chunk-GX7BBYX6.js} +4 -4
- package/dist/chunk-GX7BBYX6.js.map +7 -0
- package/dist/{chunk-G4PH7C7H.js → chunk-SC5B3YCG.js} +2702 -1442
- package/dist/chunk-SC5B3YCG.js.map +7 -0
- package/dist/{chunk-NBFQGKSV.js → chunk-XVRDKBYF.js} +4 -4
- package/dist/{chunk-NBFQGKSV.js.map → chunk-XVRDKBYF.js.map} +2 -2
- package/dist/components/ShadowCanvasOverlay.d.ts +1 -2
- package/dist/components/SyntroCanvasOverlay.d.ts +100 -0
- package/dist/components/SyntroDrawer.d.ts +110 -0
- package/dist/components/SyntroLauncher.d.ts +105 -0
- package/dist/components/SyntroTileCard.d.ts +74 -0
- package/dist/components/SyntroTileWheel.d.ts +51 -0
- package/dist/config/schema.d.ts +147 -136
- package/dist/config/schema.js +2 -2
- package/dist/controllers/DecisionController.d.ts +48 -0
- package/dist/controllers/NotificationsController.d.ts +59 -0
- package/dist/controllers/RuntimeController.d.ts +52 -0
- package/dist/controllers/RuntimeEventsController.d.ts +42 -0
- package/dist/controllers/ThemeController.d.ts +110 -0
- package/dist/controllers/index.d.ts +13 -0
- package/dist/decisions/schema.d.ts +47 -47
- package/dist/decisions/schema.js +1 -1
- package/dist/decisions/types.d.ts +4 -0
- package/dist/editorLoader.d.ts +5 -0
- package/dist/events/EventBus.d.ts +27 -1
- package/dist/events/history.d.ts +9 -0
- package/dist/events/index.d.ts +3 -0
- package/dist/events/types.d.ts +24 -0
- package/dist/events/validation.d.ts +7 -0
- package/dist/fetchers/experimentsFetcher.d.ts +3 -3
- package/dist/fetchers/mergeConfigs.d.ts +7 -7
- package/dist/index-lit.d.ts +40 -0
- package/dist/index.d.ts +1 -2
- package/dist/index.js +2435 -2022
- package/dist/index.js.map +4 -4
- package/dist/interop/LitInReact.d.ts +27 -0
- package/dist/interop/ReactInLit.d.ts +42 -0
- package/dist/interop/index.d.ts +7 -0
- package/dist/metrics/sessionMetrics.d.ts +4 -0
- package/dist/notifications/SyntroToastStack.d.ts +43 -0
- package/dist/overlays/runtime/overlay/overlay-runner.d.ts +4 -0
- package/dist/overlays/runtime/overlay/overlay-state.d.ts +21 -0
- package/dist/overlays/types.d.ts +3 -1
- package/dist/platform/PlatformAdapter.d.ts +46 -0
- package/dist/platform/ShopifyAdapter.d.ts +36 -0
- package/dist/platform/ShopifyAnchorResolver.d.ts +31 -0
- package/dist/platform/ShopifyAntiFlicker.d.ts +21 -0
- package/dist/platform/ShopifyPixelBridge.d.ts +37 -0
- package/dist/platform/detect.d.ts +9 -0
- package/dist/platform/index.d.ts +10 -0
- package/dist/platform/shopify-cookie-contract.d.ts +39 -0
- package/dist/react-compat.d.ts +114 -0
- package/dist/react.js +7 -4
- package/dist/react.js.map +2 -2
- package/dist/shopify-pixel-entry.d.ts +68 -0
- package/dist/shopify-pixel.js +77 -0
- package/dist/shopify-pixel.js.map +7 -0
- package/dist/shopify-pixel.min.js +2 -0
- package/dist/shopify-pixel.min.js.map +7 -0
- package/dist/smart-canvas.esm.js +858 -258
- package/dist/smart-canvas.esm.js.map +4 -4
- package/dist/smart-canvas.js +28024 -36411
- package/dist/smart-canvas.js.map +4 -4
- package/dist/smart-canvas.min.js +857 -258
- package/dist/smart-canvas.min.js.map +4 -4
- package/dist/telemetry/InterventionTracker.d.ts +23 -0
- package/dist/telemetry/adapters/posthog.d.ts +5 -10
- package/dist/telemetry/index.d.ts +1 -0
- package/dist/test/setup.d.ts +1 -0
- package/dist/theme/index.js +30 -0
- package/dist/theme/index.js.map +7 -0
- package/dist/token.d.ts +2 -0
- package/dist/version.d.ts +1 -1
- package/package.json +32 -29
- package/schema/canvas-config.schema.json +2345 -11394
- package/scripts/syntroReactPlugin.mjs +3 -0
- package/scripts/validate-config.mjs +42 -0
- package/dist/chunk-37TTQRH5.js.map +0 -7
- package/dist/chunk-G4PH7C7H.js.map +0 -7
- package/dist/chunk-Q77NT67W.js +0 -203
- package/dist/chunk-Q77NT67W.js.map +0 -7
- package/dist/replayMirror-QZ3GQ527.js +0 -32
- package/dist/replayMirror-QZ3GQ527.js.map +0 -7
- package/dist/telemetry/replayMirror.d.ts +0 -7
package/dist/actions/schema.js
CHANGED
|
@@ -31,9 +31,9 @@ import {
|
|
|
31
31
|
WaitZ,
|
|
32
32
|
WidgetConfigZ,
|
|
33
33
|
coreActionStepSchemas
|
|
34
|
-
} from "../chunk-
|
|
35
|
-
import "../chunk-
|
|
36
|
-
import "../chunk-
|
|
34
|
+
} from "../chunk-XVRDKBYF.js";
|
|
35
|
+
import "../chunk-GX7BBYX6.js";
|
|
36
|
+
import "../chunk-4HXPGXUC.js";
|
|
37
37
|
import "../chunk-JMHRHAEL.js";
|
|
38
38
|
export {
|
|
39
39
|
AddClassZ,
|
package/dist/actions/types.d.ts
CHANGED
|
@@ -181,7 +181,7 @@ export interface TourStep {
|
|
|
181
181
|
}
|
|
182
182
|
/** Orchestrate sequential steps with cross-page state */
|
|
183
183
|
export interface TourAction extends BaseAction {
|
|
184
|
-
kind: '
|
|
184
|
+
kind: 'overlays:tour';
|
|
185
185
|
tourId: string;
|
|
186
186
|
steps: TourStep[];
|
|
187
187
|
startStep?: string;
|
|
@@ -341,6 +341,12 @@ export interface ActionEngineOptions {
|
|
|
341
341
|
accumulator?: {
|
|
342
342
|
subscribe: (cb: () => void) => () => void;
|
|
343
343
|
};
|
|
344
|
+
sessionMetrics?: {
|
|
345
|
+
subscribe: (cb: () => void) => () => void;
|
|
346
|
+
};
|
|
347
|
+
events?: {
|
|
348
|
+
subscribe: (cb: () => void) => () => void;
|
|
349
|
+
};
|
|
344
350
|
};
|
|
345
351
|
}
|
|
346
352
|
/** The ActionEngine interface */
|
|
@@ -353,8 +359,8 @@ export interface ActionEngine {
|
|
|
353
359
|
validate: (action: ActionStep) => ValidationResult;
|
|
354
360
|
/** Get all currently active actions */
|
|
355
361
|
getActive: () => ActiveAction[];
|
|
356
|
-
/** Clean up all active actions and resources */
|
|
357
|
-
destroy: () => void
|
|
362
|
+
/** Clean up all active actions and resources. Awaits async cleanup (animated reverts). */
|
|
363
|
+
destroy: () => Promise<void>;
|
|
358
364
|
}
|
|
359
365
|
/** Renderable content types for surfaces */
|
|
360
366
|
export type RenderableContent = {
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Action Validation — Core
|
|
3
|
+
*
|
|
4
|
+
* Main validate dispatch function, anchor validation, dangerous attrs constants,
|
|
5
|
+
* and common validation helpers.
|
|
6
|
+
*/
|
|
7
|
+
import type { ActionStep, AnchorId, ValidationError, ValidationResult, ValidationWarning } from './types';
|
|
8
|
+
/** Dangerous attribute names that should not be set */
|
|
9
|
+
export declare const DANGEROUS_ATTRS: Set<string>;
|
|
10
|
+
/** Maximum HTML content length */
|
|
11
|
+
export declare const MAX_HTML_LENGTH = 50000;
|
|
12
|
+
/** Maximum style count */
|
|
13
|
+
export declare const MAX_STYLE_COUNT = 50;
|
|
14
|
+
/**
|
|
15
|
+
* Validate an action step.
|
|
16
|
+
*/
|
|
17
|
+
export declare function validateAction(action: ActionStep): ValidationResult;
|
|
18
|
+
export declare function validateAnchorAction(action: {
|
|
19
|
+
anchorId: AnchorId;
|
|
20
|
+
}, errors: ValidationError[], warnings: ValidationWarning[]): void;
|
|
21
|
+
/**
|
|
22
|
+
* Validate a batch of actions.
|
|
23
|
+
*/
|
|
24
|
+
export declare function validateActions(actions: ActionStep[]): ValidationResult;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Action Validation — Rules
|
|
3
|
+
*
|
|
4
|
+
* Specific validators by action kind: badge, tooltip, modal, content
|
|
5
|
+
* (text/attrs/classes/styles/HTML), tour, sequence, parallel, wait,
|
|
6
|
+
* navigate, mountWidget, and warning detection.
|
|
7
|
+
*/
|
|
8
|
+
import type { ActionStep, ValidationError, ValidationWarning } from './types';
|
|
9
|
+
export declare function validateBadgeAction(action: {
|
|
10
|
+
content: string;
|
|
11
|
+
}, errors: ValidationError[], warnings: ValidationWarning[]): void;
|
|
12
|
+
export declare function validateTooltipAction(action: {
|
|
13
|
+
content: {
|
|
14
|
+
title?: string;
|
|
15
|
+
body: string;
|
|
16
|
+
};
|
|
17
|
+
}, errors: ValidationError[], _warnings: ValidationWarning[]): void;
|
|
18
|
+
export declare function validateInsertHtmlAction(action: {
|
|
19
|
+
html: string;
|
|
20
|
+
position: string;
|
|
21
|
+
}, errors: ValidationError[], _warnings: ValidationWarning[]): void;
|
|
22
|
+
export declare function validateSetTextAction(action: {
|
|
23
|
+
text: string;
|
|
24
|
+
}, errors: ValidationError[], _warnings: ValidationWarning[]): void;
|
|
25
|
+
export declare function validateSetAttrAction(action: {
|
|
26
|
+
attr: string;
|
|
27
|
+
value: string;
|
|
28
|
+
}, errors: ValidationError[], _warnings: ValidationWarning[]): void;
|
|
29
|
+
export declare function validateClassAction(action: {
|
|
30
|
+
className: string;
|
|
31
|
+
}, errors: ValidationError[], warnings: ValidationWarning[]): void;
|
|
32
|
+
export declare function validateSetStyleAction(action: {
|
|
33
|
+
styles: Record<string, string>;
|
|
34
|
+
}, errors: ValidationError[], _warnings: ValidationWarning[]): void;
|
|
35
|
+
export declare function validateMountWidgetAction(action: {
|
|
36
|
+
slot: string;
|
|
37
|
+
widget: {
|
|
38
|
+
widgetId: string;
|
|
39
|
+
};
|
|
40
|
+
}, errors: ValidationError[], _warnings: ValidationWarning[]): void;
|
|
41
|
+
export declare function validateWaitAction(action: {
|
|
42
|
+
durationMs?: number;
|
|
43
|
+
event?: string;
|
|
44
|
+
}, errors: ValidationError[], _warnings: ValidationWarning[]): void;
|
|
45
|
+
export declare function validateSequenceAction(action: {
|
|
46
|
+
actions: ActionStep[];
|
|
47
|
+
}, errors: ValidationError[], warnings: ValidationWarning[]): void;
|
|
48
|
+
export declare function validateParallelAction(action: {
|
|
49
|
+
actions: ActionStep[];
|
|
50
|
+
waitFor?: string;
|
|
51
|
+
}, errors: ValidationError[], warnings: ValidationWarning[]): void;
|
|
52
|
+
export declare function validateNavigateAction(action: {
|
|
53
|
+
url: string;
|
|
54
|
+
}, errors: ValidationError[], warnings: ValidationWarning[]): void;
|
|
55
|
+
export declare function validateModalAction(action: {
|
|
56
|
+
content: {
|
|
57
|
+
title?: string;
|
|
58
|
+
body: string;
|
|
59
|
+
};
|
|
60
|
+
size?: string;
|
|
61
|
+
ctaButtons?: {
|
|
62
|
+
label: string;
|
|
63
|
+
actionId: string;
|
|
64
|
+
}[];
|
|
65
|
+
}, errors: ValidationError[], _warnings: ValidationWarning[]): void;
|
|
66
|
+
export declare function validateTourAction(action: {
|
|
67
|
+
tourId: string;
|
|
68
|
+
steps: {
|
|
69
|
+
id: string;
|
|
70
|
+
action: ActionStep;
|
|
71
|
+
route?: string;
|
|
72
|
+
onAction?: Record<string, string>;
|
|
73
|
+
}[];
|
|
74
|
+
}, errors: ValidationError[], warnings: ValidationWarning[]): void;
|
|
@@ -1,14 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Action Validation
|
|
2
|
+
* Action Validation — Barrel re-export
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* Re-exports from validation-core and validation-rules so that existing
|
|
5
|
+
* imports from './validation' continue to work unchanged.
|
|
5
6
|
*/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
* Validate an action step.
|
|
9
|
-
*/
|
|
10
|
-
export declare function validateAction(action: ActionStep): ValidationResult;
|
|
11
|
-
/**
|
|
12
|
-
* Validate a batch of actions.
|
|
13
|
-
*/
|
|
14
|
-
export declare function validateActions(actions: ActionStep[]): ValidationResult;
|
|
7
|
+
export { DANGEROUS_ATTRS, MAX_HTML_LENGTH, MAX_STYLE_COUNT, validateAction, validateActions, validateAnchorAction, } from './validation-core';
|
|
8
|
+
export { validateBadgeAction, validateClassAction, validateInsertHtmlAction, validateModalAction, validateMountWidgetAction, validateNavigateAction, validateParallelAction, validateSequenceAction, validateSetAttrAction, validateSetStyleAction, validateSetTextAction, validateTooltipAction, validateTourAction, validateWaitAction, } from './validation-rules';
|
|
@@ -11,6 +11,7 @@ export interface AnchorResolverOptions {
|
|
|
11
11
|
export interface AnchorResolver {
|
|
12
12
|
resolve(selector: string): HTMLElement | null;
|
|
13
13
|
waitFor(selector: string, timeoutMs?: number): Promise<HTMLElement>;
|
|
14
|
+
/** One-shot: fires callback once when element appears, then auto-removes the watcher. */
|
|
14
15
|
onAppear(selector: string, cb: (el: HTMLElement) => void): () => void;
|
|
15
16
|
pendingCount(): number;
|
|
16
17
|
destroy(): void;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SmartCanvas API (Lit variant)
|
|
3
|
+
*
|
|
4
|
+
* Entry point for the SmartCanvas SDK using LitElement instead of React.
|
|
5
|
+
* Creates and manages the canvas element, handles configuration, and
|
|
6
|
+
* coordinates between the ActionEngine and UI.
|
|
7
|
+
*
|
|
8
|
+
* The public API (SmartCanvasHandle, SmartCanvasConfig, createSmartCanvas)
|
|
9
|
+
* is identical to api.tsx — only the internal mounting uses mountLitApp()
|
|
10
|
+
* instead of mountReactApp().
|
|
11
|
+
*/
|
|
12
|
+
import type { ExperimentClient } from './experiments/types';
|
|
13
|
+
import type { OverlayRecipeFetcher } from './overlays/fetcher';
|
|
14
|
+
import type { ActionHandler, AppearanceConfig, RenderProps } from './render/types';
|
|
15
|
+
import type { SmartCanvasRuntime } from './runtime';
|
|
16
|
+
import { type SmartCanvasElementLit } from './SmartCanvasElementLit';
|
|
17
|
+
import type { TelemetryClient } from './telemetry/types';
|
|
18
|
+
import type { CanvasThemeConfig } from './theme';
|
|
19
|
+
import type { CanvasConfigFetcher, CanvasConfigResponse } from './types';
|
|
20
|
+
export interface SmartCanvasIntegrations {
|
|
21
|
+
experiments?: ExperimentClient;
|
|
22
|
+
telemetry?: TelemetryClient;
|
|
23
|
+
}
|
|
24
|
+
export interface SmartCanvasConfig {
|
|
25
|
+
target?: HTMLElement;
|
|
26
|
+
defaultOpen?: boolean;
|
|
27
|
+
tokens?: Record<string, string>;
|
|
28
|
+
fetcher?: CanvasConfigFetcher;
|
|
29
|
+
configUri?: string;
|
|
30
|
+
configUriFeatureKey?: string;
|
|
31
|
+
fetchCredentials?: RequestCredentials;
|
|
32
|
+
overlayFetcher?: OverlayRecipeFetcher;
|
|
33
|
+
overlayConfigUri?: string;
|
|
34
|
+
overlayConfigFeatureKey?: string;
|
|
35
|
+
overlayFetchCredentials?: RequestCredentials;
|
|
36
|
+
pollIntervalMs?: number;
|
|
37
|
+
integrations?: SmartCanvasIntegrations;
|
|
38
|
+
antiFlicker?: boolean | {
|
|
39
|
+
timeout?: number;
|
|
40
|
+
className?: string;
|
|
41
|
+
};
|
|
42
|
+
editorUrl?: string;
|
|
43
|
+
/**
|
|
44
|
+
* v2 Runtime instance.
|
|
45
|
+
* Required for action execution. If not provided, actions will not be applied.
|
|
46
|
+
*/
|
|
47
|
+
runtime?: SmartCanvasRuntime;
|
|
48
|
+
appearance?: AppearanceConfig;
|
|
49
|
+
renderProps?: RenderProps;
|
|
50
|
+
actionHandlers?: ActionHandler;
|
|
51
|
+
/** Workspace-level theme for 3-layer inheritance (defaults → workspace → config) */
|
|
52
|
+
workspaceTheme?: CanvasThemeConfig;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Handle for interacting with a SmartCanvas instance.
|
|
56
|
+
*/
|
|
57
|
+
export interface SmartCanvasHandle {
|
|
58
|
+
el: SmartCanvasElementLit;
|
|
59
|
+
open(): void;
|
|
60
|
+
close(): void;
|
|
61
|
+
destroy(): void;
|
|
62
|
+
setTokens(tokens: Record<string, string>): void;
|
|
63
|
+
/**
|
|
64
|
+
* Get the current config.
|
|
65
|
+
*/
|
|
66
|
+
getConfig(): Promise<CanvasConfigResponse>;
|
|
67
|
+
/**
|
|
68
|
+
* Enable or disable the canvas.
|
|
69
|
+
* When disabled, all actions are reverted.
|
|
70
|
+
*/
|
|
71
|
+
setEnabled(enabled: boolean): Promise<void>;
|
|
72
|
+
setOverrideFetcher(fetcher: CanvasConfigFetcher): void;
|
|
73
|
+
registerTelemetryProperties(properties: Record<string, unknown>): void;
|
|
74
|
+
getSessionId(): string | undefined;
|
|
75
|
+
startSessionRecording(): void;
|
|
76
|
+
/** Track a custom event. Returns true if telemetry is available and event was sent. */
|
|
77
|
+
track(eventName: string, properties?: Record<string, unknown>): boolean;
|
|
78
|
+
/**
|
|
79
|
+
* v2 Runtime instance for context, events, state, and decisions.
|
|
80
|
+
*/
|
|
81
|
+
runtime?: SmartCanvasRuntime;
|
|
82
|
+
}
|
|
83
|
+
export declare const createSmartCanvas: (config?: SmartCanvasConfig) => Promise<SmartCanvasHandle>;
|
|
84
|
+
export { getAntiFlickerSnippet } from './antiFlicker';
|
package/dist/api.d.ts
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import type { ExperimentClient } from './experiments/types';
|
|
8
8
|
import type { OverlayRecipeFetcher } from './overlays/fetcher';
|
|
9
|
+
import type { PlatformAdapter } from './platform/PlatformAdapter';
|
|
9
10
|
import type { ActionHandler, AppearanceConfig, RenderProps } from './render/types';
|
|
10
11
|
import type { SmartCanvasRuntime } from './runtime';
|
|
11
12
|
import { type SmartCanvasElement } from './SmartCanvasElement';
|
|
@@ -45,6 +46,8 @@ export interface SmartCanvasConfig {
|
|
|
45
46
|
actionHandlers?: ActionHandler;
|
|
46
47
|
/** Workspace-level theme for 3-layer inheritance (defaults → workspace → config) */
|
|
47
48
|
workspaceTheme?: CanvasThemeConfig;
|
|
49
|
+
/** Platform adapter for host-platform-specific integrations (Shopify, WordPress, etc.) */
|
|
50
|
+
platformAdapter?: PlatformAdapter;
|
|
48
51
|
}
|
|
49
52
|
/**
|
|
50
53
|
* Handle for interacting with a SmartCanvas instance.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export declare const builtinAdaptiveManifestsLit: {
|
|
2
|
+
id: any;
|
|
3
|
+
version: any;
|
|
4
|
+
name: any;
|
|
5
|
+
description: any;
|
|
6
|
+
runtime: {
|
|
7
|
+
actions: any;
|
|
8
|
+
widgets: any;
|
|
9
|
+
notifyWatchers: any;
|
|
10
|
+
events: any;
|
|
11
|
+
};
|
|
12
|
+
editor: undefined;
|
|
13
|
+
metadata: {
|
|
14
|
+
isBuiltIn: boolean;
|
|
15
|
+
};
|
|
16
|
+
}[];
|
|
17
|
+
export declare function registerBuiltinRuntimeModulesLit(registry: {
|
|
18
|
+
has: (id: string) => boolean;
|
|
19
|
+
register: (manifest: any) => void;
|
|
20
|
+
}): void;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bootstrap init helpers — token decode, host resolution, browser metadata
|
|
3
|
+
* collection, env var resolution, segment cache, and geo data fetching.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Get environment variable, supporting both Vite and Next.js patterns.
|
|
7
|
+
* CSP-safe: no eval() is used. Vite env access is resolved at build time
|
|
8
|
+
* via the __VITE_IMPORT_META_ENV__ define.
|
|
9
|
+
*/
|
|
10
|
+
export declare function getEnvVar(name: string): string | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* Load cached segment attributes from localStorage.
|
|
13
|
+
* Returns cached values for instant Phase 1 evaluation.
|
|
14
|
+
*/
|
|
15
|
+
export declare function loadCachedSegmentAttributes(): Record<string, boolean>;
|
|
16
|
+
/**
|
|
17
|
+
* Save segment attributes to localStorage for faster future loads.
|
|
18
|
+
*/
|
|
19
|
+
export declare function cacheSegmentAttributes(attrs: Record<string, boolean>): void;
|
|
20
|
+
/**
|
|
21
|
+
* Extract segment flags (in_segment_*) from PostHog feature flags.
|
|
22
|
+
*/
|
|
23
|
+
export declare function extractSegmentFlags(allFlags: Record<string, boolean | string> | undefined): Record<string, boolean>;
|
|
24
|
+
/**
|
|
25
|
+
* Collect browser metadata for instant GrowthBook targeting.
|
|
26
|
+
* This data is available synchronously from browser APIs — no network call needed.
|
|
27
|
+
* Only non-empty values are included.
|
|
28
|
+
*/
|
|
29
|
+
export declare function collectBrowserMetadata(): Record<string, string | string[]>;
|
|
30
|
+
export declare const GEO_DEFAULT_HOST = "https://geo.syntrologie.com";
|
|
31
|
+
/**
|
|
32
|
+
* Fetch geo data from the Cloudflare Worker, with localStorage caching.
|
|
33
|
+
* Returns cached data immediately on subsequent visits. Best-effort — never blocks init.
|
|
34
|
+
*/
|
|
35
|
+
export declare function fetchGeo(geoHost: string): Promise<Record<string, string>>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bootstrap runtime phase — EventBus creation, event processor, experiment client,
|
|
3
|
+
* telemetry, runtime factory, canvas initialization, app loader, and cleanup.
|
|
4
|
+
*/
|
|
5
|
+
import type { SyntroInitOptions, SyntroInitResult } from './bootstrap-types';
|
|
6
|
+
/** Internal init implementation — all errors propagate to the outer init() try/catch. */
|
|
7
|
+
export declare function _initCore(options: SyntroInitOptions): Promise<SyntroInitResult>;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bootstrap type definitions — interfaces, enums, and type exports
|
|
3
|
+
* for the Syntro SDK initialization flow.
|
|
4
|
+
*/
|
|
5
|
+
import type { SmartCanvasConfig, SmartCanvasHandle } from './api';
|
|
6
|
+
import type { AppLoader } from './apps/AppLoader';
|
|
7
|
+
import type { ExperimentClient } from './experiments/types';
|
|
8
|
+
import type { SessionMetricTracker } from './metrics';
|
|
9
|
+
import type { SmartCanvasRuntime } from './runtime';
|
|
10
|
+
import type { TelemetryClient } from './telemetry/types';
|
|
11
|
+
import type { CanvasConfigFetcher } from './types';
|
|
12
|
+
export interface SyntroInitOptions {
|
|
13
|
+
/**
|
|
14
|
+
* The Syntro token containing all credentials.
|
|
15
|
+
* Generated from your admin dashboard.
|
|
16
|
+
*
|
|
17
|
+
* Optional in editor mode (when editor_token is present in URL params).
|
|
18
|
+
*/
|
|
19
|
+
token?: string;
|
|
20
|
+
/**
|
|
21
|
+
* Optional canvas configuration overrides.
|
|
22
|
+
*/
|
|
23
|
+
canvas?: Partial<Omit<SmartCanvasConfig, 'integrations' | 'fetcher'>>;
|
|
24
|
+
/**
|
|
25
|
+
* Custom config fetcher to override the default experiment-based fetcher.
|
|
26
|
+
* Use this for local development or when bypassing the experiment server.
|
|
27
|
+
*
|
|
28
|
+
* When provided, this fetcher is used instead of the experiments-based config lookup.
|
|
29
|
+
* The token's telemetry credentials (t field) are still used if present.
|
|
30
|
+
*/
|
|
31
|
+
fetcher?: CanvasConfigFetcher;
|
|
32
|
+
/**
|
|
33
|
+
* @deprecated Session metrics are always enabled. This flag has no effect.
|
|
34
|
+
*/
|
|
35
|
+
enableSessionMetrics?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* CDN base URL for loading adaptive bundles.
|
|
38
|
+
* Adaptives are loaded from: {cdnBase}/adaptives/{appId}/index.js
|
|
39
|
+
*
|
|
40
|
+
* @default "https://cdn.syntrologie.com"
|
|
41
|
+
*/
|
|
42
|
+
cdnBase?: string;
|
|
43
|
+
/**
|
|
44
|
+
* @deprecated Core app executors are now registered synchronously.
|
|
45
|
+
* This option has no effect and will be removed in a future version.
|
|
46
|
+
*/
|
|
47
|
+
registerBuiltInApps?: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Enable debug mode. emit() returns EmitResult, all events logged to console.
|
|
50
|
+
* @default false
|
|
51
|
+
*/
|
|
52
|
+
debug?: boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Enable test mode. PostHog capture skipped, toasts not rendered,
|
|
55
|
+
* full event history retained (uncapped).
|
|
56
|
+
* @default false
|
|
57
|
+
*/
|
|
58
|
+
testMode?: boolean;
|
|
59
|
+
/**
|
|
60
|
+
* App-provided signal values set at init time. Merged into SDK attributes
|
|
61
|
+
* alongside auto-collected browser/geo signals for local flag evaluation.
|
|
62
|
+
*
|
|
63
|
+
* Use this when the host environment (MCP server, agent, etc.) provides
|
|
64
|
+
* signal values that the SDK can't auto-collect from the browser.
|
|
65
|
+
*
|
|
66
|
+
* Tracked as a discrete PostHog event (app_signals_init) on init.
|
|
67
|
+
*/
|
|
68
|
+
appSignalsInit?: Record<string, string>;
|
|
69
|
+
}
|
|
70
|
+
export interface SyntroInitResult {
|
|
71
|
+
/**
|
|
72
|
+
* The SmartCanvas handle for controlling the canvas.
|
|
73
|
+
*/
|
|
74
|
+
canvas: SmartCanvasHandle;
|
|
75
|
+
/**
|
|
76
|
+
* The unified v2 runtime with all providers.
|
|
77
|
+
* Use this to access telemetry, context, events, and state.
|
|
78
|
+
*/
|
|
79
|
+
runtime: SmartCanvasRuntime;
|
|
80
|
+
/**
|
|
81
|
+
* The experiment client, if experiments are configured in the token.
|
|
82
|
+
* @deprecated Access via runtime.telemetry or use DecisionStrategy instead
|
|
83
|
+
*/
|
|
84
|
+
experiments?: ExperimentClient;
|
|
85
|
+
/**
|
|
86
|
+
* The telemetry client, if telemetry is configured in the token.
|
|
87
|
+
* @deprecated Access via runtime.telemetry instead
|
|
88
|
+
*/
|
|
89
|
+
telemetry?: TelemetryClient;
|
|
90
|
+
/**
|
|
91
|
+
* The session metric tracker, if enableSessionMetrics is true.
|
|
92
|
+
* @deprecated Access via runtime.sessionMetrics instead
|
|
93
|
+
*/
|
|
94
|
+
sessionMetrics?: SessionMetricTracker;
|
|
95
|
+
/**
|
|
96
|
+
* App loader for loading external apps from CDN.
|
|
97
|
+
* Exposed for manual app loading if needed.
|
|
98
|
+
*/
|
|
99
|
+
appLoader: AppLoader;
|
|
100
|
+
}
|
package/dist/bootstrap.d.ts
CHANGED
|
@@ -16,89 +16,12 @@
|
|
|
16
16
|
* runtime.state.dismissals.mark('my-tile');
|
|
17
17
|
* ```
|
|
18
18
|
*/
|
|
19
|
-
import { type SmartCanvasConfig, type SmartCanvasHandle } from './api';
|
|
20
19
|
import type { appRegistry } from './apps';
|
|
21
|
-
import {
|
|
22
|
-
import type {
|
|
23
|
-
import { type SessionMetricTracker } from './metrics';
|
|
24
|
-
import { type SmartCanvasRuntime } from './runtime';
|
|
25
|
-
import type { TelemetryClient } from './telemetry/types';
|
|
20
|
+
import type { SmartCanvasRuntime } from './runtime';
|
|
21
|
+
import type { InterventionTracker } from './telemetry/InterventionTracker';
|
|
26
22
|
import { decodeToken, encodeToken } from './token';
|
|
27
|
-
|
|
28
|
-
export
|
|
29
|
-
/**
|
|
30
|
-
* The Syntro token containing all credentials.
|
|
31
|
-
* Generated from your admin dashboard.
|
|
32
|
-
*
|
|
33
|
-
* Optional in editor mode (when editor_token is present in URL params).
|
|
34
|
-
*/
|
|
35
|
-
token?: string;
|
|
36
|
-
/**
|
|
37
|
-
* Optional canvas configuration overrides.
|
|
38
|
-
*/
|
|
39
|
-
canvas?: Partial<Omit<SmartCanvasConfig, 'integrations' | 'fetcher'>>;
|
|
40
|
-
/**
|
|
41
|
-
* Custom config fetcher to override the default experiment-based fetcher.
|
|
42
|
-
* Use this for local development or when bypassing the experiment server.
|
|
43
|
-
*
|
|
44
|
-
* When provided, this fetcher is used instead of the experiments-based config lookup.
|
|
45
|
-
* The token's telemetry credentials (t field) are still used if present.
|
|
46
|
-
*/
|
|
47
|
-
fetcher?: CanvasConfigFetcher;
|
|
48
|
-
/**
|
|
49
|
-
* @deprecated Session metrics are always enabled. This flag has no effect.
|
|
50
|
-
*/
|
|
51
|
-
enableSessionMetrics?: boolean;
|
|
52
|
-
/**
|
|
53
|
-
* CDN base URL for loading adaptive bundles.
|
|
54
|
-
* Adaptives are loaded from: {cdnBase}/adaptives/{appId}/index.js
|
|
55
|
-
*
|
|
56
|
-
* @default "https://cdn.syntrologie.com"
|
|
57
|
-
*/
|
|
58
|
-
cdnBase?: string;
|
|
59
|
-
/**
|
|
60
|
-
* @deprecated Core app executors are now registered synchronously.
|
|
61
|
-
* This option has no effect and will be removed in a future version.
|
|
62
|
-
*/
|
|
63
|
-
registerBuiltInApps?: boolean;
|
|
64
|
-
}
|
|
65
|
-
export interface SyntroInitResult {
|
|
66
|
-
/**
|
|
67
|
-
* The SmartCanvas handle for controlling the canvas.
|
|
68
|
-
*/
|
|
69
|
-
canvas: SmartCanvasHandle;
|
|
70
|
-
/**
|
|
71
|
-
* The unified v2 runtime with all providers.
|
|
72
|
-
* Use this to access telemetry, context, events, and state.
|
|
73
|
-
*/
|
|
74
|
-
runtime: SmartCanvasRuntime;
|
|
75
|
-
/**
|
|
76
|
-
* The experiment client, if experiments are configured in the token.
|
|
77
|
-
* @deprecated Access via runtime.telemetry or use DecisionStrategy instead
|
|
78
|
-
*/
|
|
79
|
-
experiments?: ExperimentClient;
|
|
80
|
-
/**
|
|
81
|
-
* The telemetry client, if telemetry is configured in the token.
|
|
82
|
-
* @deprecated Access via runtime.telemetry instead
|
|
83
|
-
*/
|
|
84
|
-
telemetry?: TelemetryClient;
|
|
85
|
-
/**
|
|
86
|
-
* The session metric tracker, if enableSessionMetrics is true.
|
|
87
|
-
* @deprecated Access via runtime.sessionMetrics instead
|
|
88
|
-
*/
|
|
89
|
-
sessionMetrics?: SessionMetricTracker;
|
|
90
|
-
/**
|
|
91
|
-
* App loader for loading external apps from CDN.
|
|
92
|
-
* Exposed for manual app loading if needed.
|
|
93
|
-
*/
|
|
94
|
-
appLoader: AppLoader;
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* Collect browser metadata for instant GrowthBook targeting.
|
|
98
|
-
* This data is available synchronously from browser APIs — no network call needed.
|
|
99
|
-
* Only non-empty values are included.
|
|
100
|
-
*/
|
|
101
|
-
export declare function collectBrowserMetadata(): Record<string, string | string[]>;
|
|
23
|
+
export { collectBrowserMetadata, fetchGeo } from './bootstrap-init';
|
|
24
|
+
export type { SyntroInitOptions, SyntroInitResult } from './bootstrap-types';
|
|
102
25
|
/**
|
|
103
26
|
* Initialize the Syntro SDK with a single token.
|
|
104
27
|
*
|
|
@@ -112,7 +35,17 @@ export declare function collectBrowserMetadata(): Record<string, string | string
|
|
|
112
35
|
* @param options - Initialization options
|
|
113
36
|
* @returns The initialized SDK components
|
|
114
37
|
*/
|
|
115
|
-
declare function init(options: SyntroInitOptions): Promise<SyntroInitResult>;
|
|
38
|
+
declare function init(options: import('./bootstrap-types').SyntroInitOptions): Promise<import('./bootstrap-types').SyntroInitResult | undefined>;
|
|
39
|
+
/**
|
|
40
|
+
* Emit a custom event through the SDK.
|
|
41
|
+
*
|
|
42
|
+
* Events flow through the EventBus (tile notification rule matching)
|
|
43
|
+
* and PostHog (analytics). Event names must use the `app:` prefix.
|
|
44
|
+
*
|
|
45
|
+
* @param eventName - Event name (e.g., 'app:setup:sdk_connected')
|
|
46
|
+
* @param props - Optional event properties
|
|
47
|
+
*/
|
|
48
|
+
declare function emit(eventName: string, props?: Record<string, unknown>): void;
|
|
116
49
|
/**
|
|
117
50
|
* The Syntro namespace for single-token initialization.
|
|
118
51
|
*/
|
|
@@ -120,6 +53,9 @@ export declare const Syntro: {
|
|
|
120
53
|
init: typeof init;
|
|
121
54
|
encodeToken: typeof encodeToken;
|
|
122
55
|
decodeToken: typeof decodeToken;
|
|
56
|
+
events: {
|
|
57
|
+
emit: typeof emit;
|
|
58
|
+
};
|
|
123
59
|
};
|
|
124
60
|
declare global {
|
|
125
61
|
interface Window {
|
|
@@ -128,7 +64,7 @@ declare global {
|
|
|
128
64
|
appRegistry: typeof appRegistry;
|
|
129
65
|
runtime: SmartCanvasRuntime;
|
|
130
66
|
version: string;
|
|
67
|
+
interventionTracker?: InterventionTracker;
|
|
131
68
|
};
|
|
132
69
|
}
|
|
133
70
|
}
|
|
134
|
-
export {};
|