@syntrologie/runtime-sdk 2.4.1 → 2.6.0-canary.1
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 +66 -1
- package/dist/SmartCanvasApp.d.ts +5 -3
- package/dist/actions/executors/index.d.ts +1 -2
- package/dist/actions/index.d.ts +2 -2
- package/dist/actions/schema.d.ts +19111 -20709
- package/dist/actions/schema.js +5 -2
- package/dist/actions/types.d.ts +45 -48
- package/dist/anchor/AnchorResolver.d.ts +18 -0
- package/dist/anchor/index.d.ts +2 -0
- package/dist/api.d.ts +3 -8
- package/dist/apps/examples/gamification-app.example.d.ts +8 -8
- package/dist/{chunk-4NYS7GAW.js → chunk-BU4Z6PD7.js} +45 -7
- package/dist/chunk-BU4Z6PD7.js.map +7 -0
- package/dist/{chunk-QGWATS3Z.js → chunk-Q4WGXNKC.js} +2775 -1052
- package/dist/chunk-Q4WGXNKC.js.map +7 -0
- package/dist/{chunk-OGTCFYR3.js → chunk-R5DNAIRI.js} +45 -34
- package/dist/chunk-R5DNAIRI.js.map +7 -0
- package/dist/chunk-XDYJ64IN.js +178 -0
- package/dist/chunk-XDYJ64IN.js.map +7 -0
- package/dist/components/ShadowCanvasOverlay.d.ts +2 -20
- package/dist/components/TileIcon.d.ts +14 -0
- package/dist/config/schema.d.ts +5529 -3620
- package/dist/config/schema.js +21 -61
- package/dist/config/schema.js.map +3 -3
- package/dist/context/schema.d.ts +16 -16
- package/dist/decisions/schema.d.ts +357 -2789
- package/dist/decisions/schema.js +7 -1
- package/dist/decisions/types.d.ts +24 -2
- package/dist/events/registerConfigPredicates.d.ts +7 -10
- package/dist/events/schema.d.ts +12 -12
- package/dist/experiments/adapters/growthbook.d.ts +2 -0
- package/dist/experiments/types.d.ts +7 -0
- package/dist/hooks/useShadowCanvasConfig.d.ts +6 -4
- package/dist/index.d.ts +1 -0
- package/dist/index.js +154 -186
- package/dist/index.js.map +3 -3
- package/dist/overlays/schema.d.ts +70 -70
- package/dist/react.js +4 -3
- package/dist/react.js.map +1 -1
- package/dist/runtime.d.ts +3 -0
- package/dist/smart-canvas.esm.js +123 -84
- package/dist/smart-canvas.esm.js.map +4 -4
- package/dist/smart-canvas.js +3271 -1210
- package/dist/smart-canvas.js.map +4 -4
- package/dist/smart-canvas.min.js +123 -84
- package/dist/smart-canvas.min.js.map +4 -4
- package/dist/surfaces/types.d.ts +2 -1
- package/dist/theme/ThemeProvider.d.ts +11 -16
- package/dist/theme/defaultTheme.d.ts +6 -1
- package/dist/theme/index.d.ts +3 -4
- package/dist/theme/types.d.ts +11 -0
- package/dist/version.d.ts +1 -1
- package/dist/widgets/WidgetRegistry.d.ts +1 -0
- package/package.json +9 -8
- package/schema/canvas-config.schema.json +10583 -1049
- package/scripts/validate-config.mjs +180 -0
- package/dist/actions/executors/tour.d.ts +0 -18
- package/dist/chunk-4NYS7GAW.js.map +0 -7
- package/dist/chunk-OGTCFYR3.js.map +0 -7
- package/dist/chunk-QGWATS3Z.js.map +0 -7
- package/dist/hooks/useHostPatches.d.ts +0 -9
- package/dist/theme/extractHostTheme.d.ts +0 -14
package/dist/decisions/schema.js
CHANGED
|
@@ -3,12 +3,14 @@ import {
|
|
|
3
3
|
AnchorVisibleConditionZ,
|
|
4
4
|
ConditionZ,
|
|
5
5
|
CooldownActiveConditionZ,
|
|
6
|
+
CounterDefZ,
|
|
6
7
|
DecisionStrategyZ,
|
|
7
8
|
DismissedConditionZ,
|
|
8
9
|
EventCountConditionZ,
|
|
9
10
|
EventOccurredConditionZ,
|
|
10
11
|
ExternalStrategyZ,
|
|
11
12
|
FrequencyLimitConditionZ,
|
|
13
|
+
MatchOpZ,
|
|
12
14
|
ModelStrategyZ,
|
|
13
15
|
PageUrlConditionZ,
|
|
14
16
|
RouteConditionZ,
|
|
@@ -18,23 +20,26 @@ import {
|
|
|
18
20
|
ScoreStrategyZ,
|
|
19
21
|
SessionMetricConditionZ,
|
|
20
22
|
StateEqualsConditionZ,
|
|
23
|
+
TriggerWhenZ,
|
|
21
24
|
ViewportConditionZ,
|
|
22
25
|
decisionSchemas,
|
|
23
26
|
validateActivationConfig,
|
|
24
27
|
validateCondition,
|
|
25
28
|
validateStrategy
|
|
26
|
-
} from "../chunk-
|
|
29
|
+
} from "../chunk-BU4Z6PD7.js";
|
|
27
30
|
export {
|
|
28
31
|
ActivationConfigZ,
|
|
29
32
|
AnchorVisibleConditionZ,
|
|
30
33
|
ConditionZ,
|
|
31
34
|
CooldownActiveConditionZ,
|
|
35
|
+
CounterDefZ,
|
|
32
36
|
DecisionStrategyZ,
|
|
33
37
|
DismissedConditionZ,
|
|
34
38
|
EventCountConditionZ,
|
|
35
39
|
EventOccurredConditionZ,
|
|
36
40
|
ExternalStrategyZ,
|
|
37
41
|
FrequencyLimitConditionZ,
|
|
42
|
+
MatchOpZ,
|
|
38
43
|
ModelStrategyZ,
|
|
39
44
|
PageUrlConditionZ,
|
|
40
45
|
RouteConditionZ,
|
|
@@ -44,6 +49,7 @@ export {
|
|
|
44
49
|
ScoreStrategyZ,
|
|
45
50
|
SessionMetricConditionZ,
|
|
46
51
|
StateEqualsConditionZ,
|
|
52
|
+
TriggerWhenZ,
|
|
47
53
|
ViewportConditionZ,
|
|
48
54
|
decisionSchemas,
|
|
49
55
|
validateActivationConfig,
|
|
@@ -110,6 +110,25 @@ export interface FrequencyLimitCondition {
|
|
|
110
110
|
/** Invert the condition (true if limit NOT reached) */
|
|
111
111
|
inverted?: boolean;
|
|
112
112
|
}
|
|
113
|
+
/**
|
|
114
|
+
* Match operator for counter filters.
|
|
115
|
+
* Exactly one of `equals` or `contains` must be specified.
|
|
116
|
+
*/
|
|
117
|
+
export interface MatchOp {
|
|
118
|
+
equals?: string | number | boolean;
|
|
119
|
+
contains?: string;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Defines what events to count for an event_count condition.
|
|
123
|
+
* Registered as an accumulator predicate at config-load time.
|
|
124
|
+
*/
|
|
125
|
+
export interface CounterDef {
|
|
126
|
+
/** Event names to listen for (e.g., ["ui.click"]). ALL other filters AND with this. */
|
|
127
|
+
events: string[];
|
|
128
|
+
/** Prop-based filters. Keys are event prop names OR element-chain fields
|
|
129
|
+
* (tag_name, $el_text, attr__*). All entries AND together. */
|
|
130
|
+
match?: Record<string, MatchOp>;
|
|
131
|
+
}
|
|
113
132
|
/**
|
|
114
133
|
* Condition that checks accumulated event counts.
|
|
115
134
|
* Used for behavior triggers like "visited /pricing 3+ times".
|
|
@@ -125,6 +144,9 @@ export interface EventCountCondition {
|
|
|
125
144
|
count: number;
|
|
126
145
|
/** Only count events within this time window (ms). Omit = session lifetime. */
|
|
127
146
|
withinMs?: number;
|
|
147
|
+
/** Inline counter definition. Defines what events to count.
|
|
148
|
+
* If omitted, predicate is pass-through (counts all events). */
|
|
149
|
+
counter?: CounterDef;
|
|
128
150
|
}
|
|
129
151
|
/**
|
|
130
152
|
* Union of all condition types.
|
|
@@ -234,8 +256,8 @@ export interface RouteFilter {
|
|
|
234
256
|
export interface ActivationConfig {
|
|
235
257
|
/** Route-based filtering */
|
|
236
258
|
routes?: RouteFilter;
|
|
237
|
-
/**
|
|
238
|
-
|
|
259
|
+
/** When true, tile is hidden if none of its props.actions[] have an active triggerWhen. Default: false. */
|
|
260
|
+
onlyIfPopulated?: boolean;
|
|
239
261
|
}
|
|
240
262
|
/**
|
|
241
263
|
* Extended context for strategy evaluation.
|
|
@@ -1,19 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Register accumulator predicates from tile configs at config-load time.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* navigation, the widget never mounts, and clicks go uncounted.
|
|
4
|
+
* Scans all triggerWhen conditions (in tile actions and top-level actions)
|
|
5
|
+
* for event_count conditions with a `counter` definition. For each, builds
|
|
6
|
+
* a predicate and registers it with the accumulator.
|
|
8
7
|
*
|
|
9
|
-
*
|
|
10
|
-
* config is loaded, regardless of canvas state.
|
|
8
|
+
* Safe to call multiple times — accumulator.register() is idempotent.
|
|
11
9
|
*/
|
|
12
10
|
import type { TileConfig } from '../types';
|
|
13
11
|
import type { EventAccumulator } from './EventAccumulator';
|
|
14
12
|
/**
|
|
15
|
-
* Scan tile configs
|
|
16
|
-
* accumulator predicates
|
|
17
|
-
* is idempotent (skips if key already registered).
|
|
13
|
+
* Scan tile configs and top-level actions for event_count conditions
|
|
14
|
+
* and register accumulator predicates from their counter definitions.
|
|
18
15
|
*/
|
|
19
|
-
export declare function registerConfigPredicates(tiles: TileConfig[], accumulator: EventAccumulator): void;
|
|
16
|
+
export declare function registerConfigPredicates(tiles: TileConfig[], accumulator: EventAccumulator, actions?: unknown[]): void;
|
package/dist/events/schema.d.ts
CHANGED
|
@@ -10,15 +10,15 @@ export declare const NormalizedEventZ: z.ZodObject<{
|
|
|
10
10
|
props: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
11
11
|
schemaVersion: z.ZodString;
|
|
12
12
|
}, "strip", z.ZodTypeAny, {
|
|
13
|
-
source: "posthog" | "canvas" | "derived";
|
|
14
|
-
name: string;
|
|
15
13
|
schemaVersion: string;
|
|
14
|
+
source: "canvas" | "posthog" | "derived";
|
|
15
|
+
name: string;
|
|
16
16
|
ts: number;
|
|
17
17
|
props?: Record<string, unknown> | undefined;
|
|
18
18
|
}, {
|
|
19
|
-
source: "posthog" | "canvas" | "derived";
|
|
20
|
-
name: string;
|
|
21
19
|
schemaVersion: string;
|
|
20
|
+
source: "canvas" | "posthog" | "derived";
|
|
21
|
+
name: string;
|
|
22
22
|
ts: number;
|
|
23
23
|
props?: Record<string, unknown> | undefined;
|
|
24
24
|
}>;
|
|
@@ -29,25 +29,25 @@ export declare const EventFilterZ: z.ZodObject<{
|
|
|
29
29
|
}, "strip", z.ZodTypeAny, {
|
|
30
30
|
names?: string[] | undefined;
|
|
31
31
|
patterns?: string[] | undefined;
|
|
32
|
-
sources?: ("
|
|
32
|
+
sources?: ("canvas" | "posthog" | "derived")[] | undefined;
|
|
33
33
|
}, {
|
|
34
34
|
names?: string[] | undefined;
|
|
35
35
|
patterns?: string[] | undefined;
|
|
36
|
-
sources?: ("
|
|
36
|
+
sources?: ("canvas" | "posthog" | "derived")[] | undefined;
|
|
37
37
|
}>;
|
|
38
38
|
/**
|
|
39
39
|
* Validate a NormalizedEvent object.
|
|
40
40
|
*/
|
|
41
41
|
export declare function validateNormalizedEvent(data: unknown): z.SafeParseReturnType<{
|
|
42
|
-
source: "posthog" | "canvas" | "derived";
|
|
43
|
-
name: string;
|
|
44
42
|
schemaVersion: string;
|
|
43
|
+
source: "canvas" | "posthog" | "derived";
|
|
44
|
+
name: string;
|
|
45
45
|
ts: number;
|
|
46
46
|
props?: Record<string, unknown> | undefined;
|
|
47
47
|
}, {
|
|
48
|
-
source: "posthog" | "canvas" | "derived";
|
|
49
|
-
name: string;
|
|
50
48
|
schemaVersion: string;
|
|
49
|
+
source: "canvas" | "posthog" | "derived";
|
|
50
|
+
name: string;
|
|
51
51
|
ts: number;
|
|
52
52
|
props?: Record<string, unknown> | undefined;
|
|
53
53
|
}>;
|
|
@@ -57,11 +57,11 @@ export declare function validateNormalizedEvent(data: unknown): z.SafeParseRetur
|
|
|
57
57
|
export declare function validateEventFilter(data: unknown): z.SafeParseReturnType<{
|
|
58
58
|
names?: string[] | undefined;
|
|
59
59
|
patterns?: string[] | undefined;
|
|
60
|
-
sources?: ("
|
|
60
|
+
sources?: ("canvas" | "posthog" | "derived")[] | undefined;
|
|
61
61
|
}, {
|
|
62
62
|
names?: string[] | undefined;
|
|
63
63
|
patterns?: string[] | undefined;
|
|
64
|
-
sources?: ("
|
|
64
|
+
sources?: ("canvas" | "posthog" | "derived")[] | undefined;
|
|
65
65
|
}>;
|
|
66
66
|
/**
|
|
67
67
|
* Type inference from Zod schema.
|
|
@@ -43,6 +43,7 @@ export interface GrowthBookAdapterOptions extends GrowthBookInitOptions {
|
|
|
43
43
|
*/
|
|
44
44
|
export declare class GrowthBookAdapter implements ExperimentClient {
|
|
45
45
|
private readonly gb;
|
|
46
|
+
private readonly featureListeners;
|
|
46
47
|
constructor(options?: GrowthBookAdapterOptions);
|
|
47
48
|
/**
|
|
48
49
|
* Access to the underlying GrowthBook instance.
|
|
@@ -55,6 +56,7 @@ export declare class GrowthBookAdapter implements ExperimentClient {
|
|
|
55
56
|
getFeatureValue<T>(key: string, fallback: T): T;
|
|
56
57
|
getAllFeatures(): Record<string, unknown>;
|
|
57
58
|
shouldRenderRectangle(_tile: TileConfig): boolean;
|
|
59
|
+
onFeaturesChanged(callback: () => void): () => void;
|
|
58
60
|
}
|
|
59
61
|
/**
|
|
60
62
|
* Create an ExperimentClient backed by GrowthBook.
|
|
@@ -32,6 +32,13 @@ export interface ExperimentClient {
|
|
|
32
32
|
* Returns a map of feature key -> feature value.
|
|
33
33
|
*/
|
|
34
34
|
getAllFeatures?(): Record<string, unknown>;
|
|
35
|
+
/**
|
|
36
|
+
* Subscribe to feature flag value changes.
|
|
37
|
+
* Called when the underlying provider receives updated feature values
|
|
38
|
+
* (e.g., via streaming, webhook, or manual refresh).
|
|
39
|
+
* Returns an unsubscribe function.
|
|
40
|
+
*/
|
|
41
|
+
onFeaturesChanged?(callback: () => void): () => void;
|
|
35
42
|
}
|
|
36
43
|
/**
|
|
37
44
|
* @deprecated Use ExperimentClient instead
|
|
@@ -3,13 +3,15 @@ import type { SmartCanvasRuntime } from '../runtime';
|
|
|
3
3
|
import type { ActionStep, CanvasConfigFetcher, CanvasThemeConfig, LauncherConfig, TileConfig } from '../types';
|
|
4
4
|
export interface UseShadowCanvasConfigOptions {
|
|
5
5
|
fetcher: CanvasConfigFetcher;
|
|
6
|
-
pollIntervalMs?: number;
|
|
7
6
|
/** @deprecated Use runtime instead */
|
|
8
7
|
experiments?: ExperimentClient;
|
|
9
8
|
/** v2 Runtime for activation-based filtering */
|
|
10
9
|
runtime?: SmartCanvasRuntime;
|
|
11
|
-
/** Current
|
|
12
|
-
|
|
10
|
+
/** Current page URL — triggers re-filter when URL changes (route-based activation).
|
|
11
|
+
* Full URL (not just pathname) so hash-based routing also triggers re-filter. */
|
|
12
|
+
pageUrl?: string;
|
|
13
|
+
/** Polling interval in milliseconds. Set to 0 or omit to disable polling. */
|
|
14
|
+
pollIntervalMs?: number;
|
|
13
15
|
}
|
|
14
16
|
export interface ShadowCanvasConfigState {
|
|
15
17
|
tiles: TileConfig[];
|
|
@@ -26,4 +28,4 @@ export interface ShadowCanvasConfigState {
|
|
|
26
28
|
/** Launcher button configuration */
|
|
27
29
|
launcher?: LauncherConfig;
|
|
28
30
|
}
|
|
29
|
-
export declare function useShadowCanvasConfig({ fetcher,
|
|
31
|
+
export declare function useShadowCanvasConfig({ fetcher, experiments, runtime, pageUrl, pollIntervalMs, }: UseShadowCanvasConfigOptions): ShadowCanvasConfigState;
|
package/dist/index.d.ts
CHANGED