@syntrologie/runtime-sdk 2.4.0-canary.18 → 2.4.0-canary.19

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.
Files changed (36) hide show
  1. package/dist/actions/schema.d.ts +7256 -384
  2. package/dist/actions/schema.js +2 -2
  3. package/dist/actions/types.d.ts +7 -0
  4. package/dist/anchor/AnchorResolver.d.ts +18 -0
  5. package/dist/anchor/index.d.ts +2 -0
  6. package/dist/{chunk-LZLDT5DA.js → chunk-LR5AA5SE.js} +2 -2
  7. package/dist/{chunk-NR57IT54.js → chunk-LRN3K2VD.js} +282 -100
  8. package/dist/chunk-LRN3K2VD.js.map +7 -0
  9. package/dist/{chunk-4NYS7GAW.js → chunk-P5G4KT2U.js} +39 -6
  10. package/dist/chunk-P5G4KT2U.js.map +7 -0
  11. package/dist/config/schema.d.ts +448 -40
  12. package/dist/config/schema.js +1 -1
  13. package/dist/context/schema.d.ts +8 -8
  14. package/dist/decisions/schema.d.ts +424 -1408
  15. package/dist/decisions/schema.js +5 -1
  16. package/dist/decisions/types.d.ts +22 -0
  17. package/dist/events/registerConfigPredicates.d.ts +6 -10
  18. package/dist/events/schema.d.ts +8 -8
  19. package/dist/index.d.ts +1 -0
  20. package/dist/index.js +9 -77
  21. package/dist/index.js.map +3 -3
  22. package/dist/overlays/schema.d.ts +22 -22
  23. package/dist/react.js +3 -3
  24. package/dist/runtime.d.ts +3 -0
  25. package/dist/smart-canvas.esm.js +36 -37
  26. package/dist/smart-canvas.esm.js.map +4 -4
  27. package/dist/smart-canvas.js +318 -177
  28. package/dist/smart-canvas.js.map +4 -4
  29. package/dist/smart-canvas.min.js +36 -37
  30. package/dist/smart-canvas.min.js.map +4 -4
  31. package/dist/version.d.ts +1 -1
  32. package/package.json +7 -7
  33. package/schema/canvas-config.schema.json +996 -56
  34. package/dist/chunk-4NYS7GAW.js.map +0 -7
  35. package/dist/chunk-NR57IT54.js.map +0 -7
  36. /package/dist/{chunk-LZLDT5DA.js.map → chunk-LR5AA5SE.js.map} +0 -0
@@ -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,
@@ -23,18 +25,20 @@ import {
23
25
  validateActivationConfig,
24
26
  validateCondition,
25
27
  validateStrategy
26
- } from "../chunk-4NYS7GAW.js";
28
+ } from "../chunk-P5G4KT2U.js";
27
29
  export {
28
30
  ActivationConfigZ,
29
31
  AnchorVisibleConditionZ,
30
32
  ConditionZ,
31
33
  CooldownActiveConditionZ,
34
+ CounterDefZ,
32
35
  DecisionStrategyZ,
33
36
  DismissedConditionZ,
34
37
  EventCountConditionZ,
35
38
  EventOccurredConditionZ,
36
39
  ExternalStrategyZ,
37
40
  FrequencyLimitConditionZ,
41
+ MatchOpZ,
38
42
  ModelStrategyZ,
39
43
  PageUrlConditionZ,
40
44
  RouteConditionZ,
@@ -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.
@@ -1,20 +1,16 @@
1
1
  /**
2
2
  * Register accumulator predicates from tile configs at config-load time.
3
3
  *
4
- * Previously, predicate registration lived inside FAQWidget's useEffect
5
- * meaning predicates were only active when the widget was mounted (canvas open).
6
- * On multi-page apps with `defaultOpen: false`, the canvas stays closed after
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
- * This module extracts that logic so predicates are registered as soon as the
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 for scope + triggerWhen event_count conditions and register
16
- * accumulator predicates. Also scans top-level actions for triggerWhen conditions.
17
- * Safe to call multiple times — accumulator.register() is idempotent (skips if
18
- * key already registered).
13
+ * Scan tile configs and top-level actions for event_count conditions
14
+ * and register accumulator predicates from their counter definitions.
19
15
  */
20
16
  export declare function registerConfigPredicates(tiles: TileConfig[], accumulator: EventAccumulator, actions?: unknown[]): void;
@@ -10,13 +10,13 @@ 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";
13
+ source: "canvas" | "posthog" | "derived";
14
14
  name: string;
15
15
  schemaVersion: string;
16
16
  ts: number;
17
17
  props?: Record<string, unknown> | undefined;
18
18
  }, {
19
- source: "posthog" | "canvas" | "derived";
19
+ source: "canvas" | "posthog" | "derived";
20
20
  name: string;
21
21
  schemaVersion: string;
22
22
  ts: number;
@@ -29,23 +29,23 @@ export declare const EventFilterZ: z.ZodObject<{
29
29
  }, "strip", z.ZodTypeAny, {
30
30
  names?: string[] | undefined;
31
31
  patterns?: string[] | undefined;
32
- sources?: ("posthog" | "canvas" | "derived")[] | undefined;
32
+ sources?: ("canvas" | "posthog" | "derived")[] | undefined;
33
33
  }, {
34
34
  names?: string[] | undefined;
35
35
  patterns?: string[] | undefined;
36
- sources?: ("posthog" | "canvas" | "derived")[] | undefined;
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";
42
+ source: "canvas" | "posthog" | "derived";
43
43
  name: string;
44
44
  schemaVersion: string;
45
45
  ts: number;
46
46
  props?: Record<string, unknown> | undefined;
47
47
  }, {
48
- source: "posthog" | "canvas" | "derived";
48
+ source: "canvas" | "posthog" | "derived";
49
49
  name: string;
50
50
  schemaVersion: string;
51
51
  ts: number;
@@ -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?: ("posthog" | "canvas" | "derived")[] | undefined;
60
+ sources?: ("canvas" | "posthog" | "derived")[] | undefined;
61
61
  }, {
62
62
  names?: string[] | undefined;
63
63
  patterns?: string[] | undefined;
64
- sources?: ("posthog" | "canvas" | "derived")[] | undefined;
64
+ sources?: ("canvas" | "posthog" | "derived")[] | undefined;
65
65
  }>;
66
66
  /**
67
67
  * Type inference from Zod schema.
package/dist/index.d.ts CHANGED
@@ -20,6 +20,7 @@ export * from './telemetry';
20
20
  export * from './types';
21
21
  export * from './version';
22
22
  export * from './actions';
23
+ export * from './anchor';
23
24
  export * from './apps';
24
25
  export * from './context';
25
26
  export * from './decisions';
package/dist/index.js CHANGED
@@ -32,6 +32,7 @@ import {
32
32
  base,
33
33
  cleanupAppContext,
34
34
  createActionEngine,
35
+ createAnchorResolver,
35
36
  createAppContext,
36
37
  createAppLoader,
37
38
  createCanvasConfigFetcher,
@@ -99,7 +100,7 @@ import {
99
100
  validateAction,
100
101
  validateActions,
101
102
  widgetRegistry
102
- } from "./chunk-NR57IT54.js";
103
+ } from "./chunk-LRN3K2VD.js";
103
104
  import {
104
105
  AddClassZ,
105
106
  AnchorIdZ,
@@ -133,18 +134,20 @@ import {
133
134
  WaitZ,
134
135
  WidgetConfigZ,
135
136
  coreActionStepSchemas
136
- } from "./chunk-LZLDT5DA.js";
137
+ } from "./chunk-LR5AA5SE.js";
137
138
  import {
138
139
  ActivationConfigZ,
139
140
  AnchorVisibleConditionZ,
140
141
  ConditionZ,
141
142
  CooldownActiveConditionZ,
143
+ CounterDefZ,
142
144
  DecisionStrategyZ,
143
145
  DismissedConditionZ,
144
146
  EventCountConditionZ,
145
147
  EventOccurredConditionZ,
146
148
  ExternalStrategyZ,
147
149
  FrequencyLimitConditionZ,
150
+ MatchOpZ,
148
151
  ModelStrategyZ,
149
152
  PageUrlConditionZ,
150
153
  RouteConditionZ,
@@ -159,7 +162,7 @@ import {
159
162
  validateActivationConfig,
160
163
  validateCondition,
161
164
  validateStrategy
162
- } from "./chunk-4NYS7GAW.js";
165
+ } from "./chunk-P5G4KT2U.js";
163
166
 
164
167
  // src/index.ts
165
168
  import React4 from "react";
@@ -895,43 +898,6 @@ function FAQWidget({ config, runtime: runtime7, instanceId }) {
895
898
  forceUpdate();
896
899
  });
897
900
  }, [runtime7.accumulator]);
898
- useEffect2(() => {
899
- var _a, _b;
900
- if (!config.scope || !((_a = runtime7.accumulator) == null ? void 0 : _a.register))
901
- return;
902
- const { events: eventNames, urlContains, props: propFilters } = config.scope;
903
- const keys = /* @__PURE__ */ new Set();
904
- for (const action of config.actions) {
905
- if (((_b = action.triggerWhen) == null ? void 0 : _b.type) === "rules") {
906
- for (const rule of action.triggerWhen.rules) {
907
- for (const cond of rule.conditions) {
908
- if (cond.type === "event_count" && cond.key) {
909
- keys.add(cond.key);
910
- }
911
- }
912
- }
913
- }
914
- }
915
- for (const key of keys) {
916
- runtime7.accumulator.register(key, (event) => {
917
- var _a2, _b2, _c;
918
- if (!eventNames.includes(event.name))
919
- return false;
920
- if (urlContains) {
921
- const pathname = String((_b2 = (_a2 = event.props) == null ? void 0 : _a2.pathname) != null ? _b2 : "");
922
- if (!pathname.includes(urlContains))
923
- return false;
924
- }
925
- if (propFilters) {
926
- for (const [k, v] of Object.entries(propFilters)) {
927
- if (((_c = event.props) == null ? void 0 : _c[k]) !== v)
928
- return false;
929
- }
930
- }
931
- return true;
932
- });
933
- }
934
- }, [config.scope, config.actions, runtime7.accumulator]);
935
901
  useEffect2(() => {
936
902
  if (!runtime7.events.subscribe)
937
903
  return;
@@ -1401,43 +1367,6 @@ function NavWidget({ config, runtime: runtime7, instanceId }) {
1401
1367
  forceUpdate();
1402
1368
  });
1403
1369
  }, [runtime7.accumulator]);
1404
- useEffect3(() => {
1405
- var _a, _b;
1406
- if (!config.scope || !((_a = runtime7.accumulator) == null ? void 0 : _a.register))
1407
- return;
1408
- const { events: eventNames, urlContains, props: propFilters } = config.scope;
1409
- const keys = /* @__PURE__ */ new Set();
1410
- for (const action of config.actions) {
1411
- if (((_b = action.triggerWhen) == null ? void 0 : _b.type) === "rules") {
1412
- for (const rule of action.triggerWhen.rules) {
1413
- for (const cond of rule.conditions) {
1414
- if (cond.type === "event_count" && cond.key) {
1415
- keys.add(cond.key);
1416
- }
1417
- }
1418
- }
1419
- }
1420
- }
1421
- for (const key of keys) {
1422
- runtime7.accumulator.register(key, (event) => {
1423
- var _a2, _b2, _c;
1424
- if (!eventNames.includes(event.name))
1425
- return false;
1426
- if (urlContains) {
1427
- const pathname = String((_b2 = (_a2 = event.props) == null ? void 0 : _a2.pathname) != null ? _b2 : "");
1428
- if (!pathname.includes(urlContains))
1429
- return false;
1430
- }
1431
- if (propFilters) {
1432
- for (const [k, v] of Object.entries(propFilters)) {
1433
- if (((_c = event.props) == null ? void 0 : _c[k]) !== v)
1434
- return false;
1435
- }
1436
- }
1437
- return true;
1438
- });
1439
- }
1440
- }, [config.scope, config.actions, runtime7.accumulator]);
1441
1370
  const visibleTips = useMemo2(() => config.actions.filter((tip) => {
1442
1371
  if (!tip.triggerWhen)
1443
1372
  return true;
@@ -2099,6 +2028,7 @@ export {
2099
2028
  ConditionZ,
2100
2029
  ContextManager,
2101
2030
  CooldownActiveConditionZ,
2031
+ CounterDefZ,
2102
2032
  CtaButtonZ,
2103
2033
  DEFAULT_COOLDOWN,
2104
2034
  DEFAULT_TTL,
@@ -2120,6 +2050,7 @@ export {
2120
2050
  InsertHtmlZ,
2121
2051
  InsertPositionZ,
2122
2052
  MAX_VISIBLE_TOASTS,
2053
+ MatchOpZ,
2123
2054
  ModalContentZ,
2124
2055
  ModalZ,
2125
2056
  ModelStrategyZ,
@@ -2188,6 +2119,7 @@ export {
2188
2119
  runtime as contentRuntime,
2189
2120
  coreActionStepSchemas,
2190
2121
  createActionEngine,
2122
+ createAnchorResolver,
2191
2123
  createAppContext,
2192
2124
  createAppLoader,
2193
2125
  createCanvasConfigFetcher,