@syntrologie/runtime-sdk 2.8.0-canary.30 → 2.8.0-canary.31

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.
@@ -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
- * Validates action steps before execution.
4
+ * Re-exports from validation-core and validation-rules so that existing
5
+ * imports from './validation' continue to work unchanged.
5
6
  */
6
- import type { ActionStep, ValidationResult } from './types';
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';
@@ -0,0 +1,33 @@
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
+ */
8
+ export declare function getEnvVar(name: string): string | undefined;
9
+ /**
10
+ * Load cached segment attributes from localStorage.
11
+ * Returns cached values for instant Phase 1 evaluation.
12
+ */
13
+ export declare function loadCachedSegmentAttributes(): Record<string, boolean>;
14
+ /**
15
+ * Save segment attributes to localStorage for faster future loads.
16
+ */
17
+ export declare function cacheSegmentAttributes(attrs: Record<string, boolean>): void;
18
+ /**
19
+ * Extract segment flags (in_segment_*) from PostHog feature flags.
20
+ */
21
+ export declare function extractSegmentFlags(allFlags: Record<string, boolean | string> | undefined): Record<string, boolean>;
22
+ /**
23
+ * Collect browser metadata for instant GrowthBook targeting.
24
+ * This data is available synchronously from browser APIs — no network call needed.
25
+ * Only non-empty values are included.
26
+ */
27
+ export declare function collectBrowserMetadata(): Record<string, string | string[]>;
28
+ export declare const GEO_DEFAULT_HOST = "https://geo.syntrologie.com";
29
+ /**
30
+ * Fetch geo data from the Cloudflare Worker, with localStorage caching.
31
+ * Returns cached data immediately on subsequent visits. Best-effort — never blocks init.
32
+ */
33
+ 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,90 @@
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
+ export interface SyntroInitResult {
61
+ /**
62
+ * The SmartCanvas handle for controlling the canvas.
63
+ */
64
+ canvas: SmartCanvasHandle;
65
+ /**
66
+ * The unified v2 runtime with all providers.
67
+ * Use this to access telemetry, context, events, and state.
68
+ */
69
+ runtime: SmartCanvasRuntime;
70
+ /**
71
+ * The experiment client, if experiments are configured in the token.
72
+ * @deprecated Access via runtime.telemetry or use DecisionStrategy instead
73
+ */
74
+ experiments?: ExperimentClient;
75
+ /**
76
+ * The telemetry client, if telemetry is configured in the token.
77
+ * @deprecated Access via runtime.telemetry instead
78
+ */
79
+ telemetry?: TelemetryClient;
80
+ /**
81
+ * The session metric tracker, if enableSessionMetrics is true.
82
+ * @deprecated Access via runtime.sessionMetrics instead
83
+ */
84
+ sessionMetrics?: SessionMetricTracker;
85
+ /**
86
+ * App loader for loading external apps from CDN.
87
+ * Exposed for manual app loading if needed.
88
+ */
89
+ appLoader: AppLoader;
90
+ }
@@ -16,94 +16,11 @@
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 { type AppLoader } from './apps/AppLoader';
22
- import type { ExperimentClient } from './experiments/types';
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';
26
21
  import { decodeToken, encodeToken } from './token';
27
- import type { CanvasConfigFetcher } from './types';
28
- export interface SyntroInitOptions {
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[]>;
102
- /**
103
- * Fetch geo data from the Cloudflare Worker, with localStorage caching.
104
- * Returns cached data immediately on subsequent visits. Best-effort — never blocks init.
105
- */
106
- export declare function fetchGeo(geoHost: string): Promise<Record<string, string>>;
22
+ export { collectBrowserMetadata, fetchGeo } from './bootstrap-init';
23
+ export type { SyntroInitOptions, SyntroInitResult } from './bootstrap-types';
107
24
  /**
108
25
  * Initialize the Syntro SDK with a single token.
109
26
  *
@@ -117,7 +34,7 @@ export declare function fetchGeo(geoHost: string): Promise<Record<string, string
117
34
  * @param options - Initialization options
118
35
  * @returns The initialized SDK components
119
36
  */
120
- declare function init(options: SyntroInitOptions): Promise<SyntroInitResult | undefined>;
37
+ declare function init(options: import('./bootstrap-types').SyntroInitOptions): Promise<import('./bootstrap-types').SyntroInitResult | undefined>;
121
38
  /**
122
39
  * The Syntro namespace for single-token initialization.
123
40
  */
@@ -136,4 +53,3 @@ declare global {
136
53
  };
137
54
  }
138
55
  }
139
- export {};