@syntrologie/runtime-sdk 2.0.0 → 2.0.1-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 +232 -138
- package/README.md +76 -57
- package/dist/RuntimeProvider.d.ts +6 -6
- package/dist/RuntimeProvider.js +2 -3
- package/dist/RuntimeProvider.js.map +1 -1
- package/dist/SmartCanvasApp.d.ts +8 -8
- package/dist/SmartCanvasApp.js +16 -18
- package/dist/SmartCanvasApp.js.map +1 -1
- package/dist/SmartCanvasElement.d.ts +5 -5
- package/dist/SmartCanvasElement.js +13 -13
- package/dist/SmartCanvasElement.js.map +1 -1
- package/dist/SmartCanvasPortal.d.ts +2 -2
- package/dist/SmartCanvasPortal.js +2 -2
- package/dist/actions/ActionEngine.d.ts +1 -1
- package/dist/actions/ActionEngine.js +24 -24
- package/dist/actions/ActionEngine.js.map +1 -1
- package/dist/actions/executors/index.d.ts +6 -6
- package/dist/actions/executors/index.js +22 -22
- package/dist/actions/executors/index.js.map +1 -1
- package/dist/actions/executors/tour.d.ts +1 -1
- package/dist/actions/executors/tour.js +19 -19
- package/dist/actions/executors/tour.js.map +1 -1
- package/dist/actions/index.d.ts +5 -5
- package/dist/actions/index.js +3 -3
- package/dist/actions/index.js.map +1 -1
- package/dist/actions/types.d.ts +37 -37
- package/dist/actions/validation.d.ts +1 -1
- package/dist/actions/validation.js +195 -196
- package/dist/actions/validation.js.map +1 -1
- package/dist/antiFlicker.js +1 -1
- package/dist/api.d.ts +10 -10
- package/dist/api.js +11 -11
- package/dist/api.js.map +1 -1
- package/dist/apps/AppContext.d.ts +2 -2
- package/dist/apps/AppContext.js +1 -1
- package/dist/apps/AppContext.js.map +1 -1
- package/dist/apps/AppLoader.d.ts +2 -2
- package/dist/apps/AppLoader.js +24 -24
- package/dist/apps/AppLoader.js.map +1 -1
- package/dist/apps/AppRegistry.d.ts +2 -2
- package/dist/apps/AppRegistry.js +28 -28
- package/dist/apps/AppRegistry.js.map +1 -1
- package/dist/apps/adaptive-chatbot/index.js +7 -0
- package/dist/apps/adaptive-chatbot/index.js.map +7 -0
- package/dist/apps/examples/gamification-app.example.d.ts +3 -3
- package/dist/apps/examples/gamification-app.example.js +94 -94
- package/dist/apps/examples/gamification-app.example.js.map +1 -1
- package/dist/apps/faq/index.js.map +3 -3
- package/dist/apps/gamification/index.js.map +3 -3
- package/dist/apps/index.d.ts +10 -10
- package/dist/apps/index.js +6 -6
- package/dist/apps/nav/index.js.map +3 -3
- package/dist/apps/types.d.ts +10 -10
- package/dist/blocks/data/ComparisonBlock.d.ts +1 -1
- package/dist/blocks/data/ComparisonBlock.js +40 -40
- package/dist/blocks/data/ComparisonBlock.js.map +1 -1
- package/dist/blocks/data/StatsBlock.d.ts +1 -1
- package/dist/blocks/data/StatsBlock.js +41 -41
- package/dist/blocks/data/StatsBlock.js.map +1 -1
- package/dist/blocks/data/index.d.ts +2 -2
- package/dist/blocks/data/index.js +2 -2
- package/dist/blocks/index.d.ts +5 -5
- package/dist/blocks/index.js +29 -29
- package/dist/blocks/index.js.map +1 -1
- package/dist/blocks/interactive/ChecklistBlock.d.ts +1 -1
- package/dist/blocks/interactive/ChecklistBlock.js +60 -60
- package/dist/blocks/interactive/ChecklistBlock.js.map +1 -1
- package/dist/blocks/interactive/RatingBlock.d.ts +1 -1
- package/dist/blocks/interactive/RatingBlock.js +75 -65
- package/dist/blocks/interactive/RatingBlock.js.map +1 -1
- package/dist/blocks/interactive/index.d.ts +2 -2
- package/dist/blocks/interactive/index.js +2 -2
- package/dist/blocks/notification/NotificationBlock.d.ts +2 -2
- package/dist/blocks/notification/NotificationBlock.js +67 -63
- package/dist/blocks/notification/NotificationBlock.js.map +1 -1
- package/dist/blocks/notification/index.d.ts +1 -1
- package/dist/blocks/notification/index.js +1 -1
- package/dist/bootstrap.d.ts +10 -10
- package/dist/bootstrap.js +54 -40
- package/dist/bootstrap.js.map +1 -1
- package/dist/components/ShadowCanvasOverlay.d.ts +6 -6
- package/dist/components/ShadowCanvasOverlay.js +117 -107
- package/dist/components/ShadowCanvasOverlay.js.map +1 -1
- package/dist/components/TileCard.d.ts +5 -5
- package/dist/components/TileCard.js +174 -143
- package/dist/components/TileCard.js.map +1 -1
- package/dist/components/TileWheel.d.ts +3 -3
- package/dist/components/TileWheel.js +7 -7
- package/dist/components/TileWheel.js.map +1 -1
- package/dist/configFetcher.d.ts +2 -2
- package/dist/configFetcher.js +10 -7
- package/dist/configFetcher.js.map +1 -1
- package/dist/context/ContextManager.d.ts +3 -3
- package/dist/context/ContextManager.js +15 -15
- package/dist/context/ContextManager.js.map +1 -1
- package/dist/context/index.d.ts +4 -4
- package/dist/context/index.js +3 -3
- package/dist/context/schema.d.ts +1 -1
- package/dist/context/schema.js +1 -1
- package/dist/decisions/engine.d.ts +5 -5
- package/dist/decisions/engine.js +13 -13
- package/dist/decisions/index.d.ts +6 -6
- package/dist/decisions/index.js +5 -5
- package/dist/decisions/schema.d.ts +1 -1
- package/dist/decisions/schema.js +20 -20
- package/dist/decisions/strategies/rules.d.ts +1 -1
- package/dist/decisions/strategies/rules.js +24 -24
- package/dist/decisions/strategies/rules.js.map +1 -1
- package/dist/decisions/strategies/score.d.ts +1 -1
- package/dist/decisions/strategies/score.js +3 -3
- package/dist/decisions/types.d.ts +19 -19
- package/dist/editorLoader.js +20 -20
- package/dist/editorLoader.js.map +1 -1
- package/dist/events/EventBus.d.ts +3 -3
- package/dist/events/EventBus.js +5 -7
- package/dist/events/EventBus.js.map +1 -1
- package/dist/events/index.d.ts +6 -6
- package/dist/events/index.js +5 -5
- package/dist/events/normalizers/canvas.d.ts +2 -2
- package/dist/events/normalizers/canvas.js +3 -3
- package/dist/events/normalizers/canvas.js.map +1 -1
- package/dist/events/normalizers/posthog.d.ts +1 -1
- package/dist/events/normalizers/posthog.js +35 -27
- package/dist/events/normalizers/posthog.js.map +1 -1
- package/dist/events/schema.d.ts +1 -1
- package/dist/events/schema.js +2 -2
- package/dist/events/types.d.ts +1 -1
- package/dist/events/types.js +27 -27
- package/dist/experiments/adapters/growthbook.d.ts +4 -4
- package/dist/experiments/adapters/growthbook.js +5 -5
- package/dist/experiments/adapters/growthbook.js.map +1 -1
- package/dist/experiments/index.d.ts +3 -3
- package/dist/experiments/index.js +1 -1
- package/dist/experiments/registry.d.ts +2 -2
- package/dist/experiments/registry.js +2 -2
- package/dist/experiments/types.d.ts +5 -1
- package/dist/fetchers/cdnFetcher.d.ts +1 -1
- package/dist/fetchers/cdnFetcher.js +4 -8
- package/dist/fetchers/cdnFetcher.js.map +1 -1
- package/dist/fetchers/experimentsFetcher.d.ts +2 -2
- package/dist/fetchers/experimentsFetcher.js +7 -7
- package/dist/fetchers/experimentsFetcher.js.map +1 -1
- package/dist/fetchers/index.d.ts +3 -3
- package/dist/fetchers/index.js +2 -2
- package/dist/fetchers/index.js.map +1 -1
- package/dist/fetchers/registry.d.ts +1 -1
- package/dist/fetchers/registry.js +4 -4
- package/dist/fetchers/types.d.ts +1 -1
- package/dist/hooks/useCanvasOverlays.d.ts +5 -5
- package/dist/hooks/useCanvasOverlays.js +15 -13
- package/dist/hooks/useCanvasOverlays.js.map +1 -1
- package/dist/hooks/useHostPatches.d.ts +2 -2
- package/dist/hooks/useHostPatches.js +8 -8
- package/dist/hooks/useHostPatches.js.map +1 -1
- package/dist/hooks/useShadowCanvasConfig.d.ts +3 -3
- package/dist/hooks/useShadowCanvasConfig.js +5 -2
- package/dist/hooks/useShadowCanvasConfig.js.map +1 -1
- package/dist/hostPatcher/core/patcher.d.ts +1 -1
- package/dist/hostPatcher/core/patcher.js +18 -9
- package/dist/hostPatcher/core/patcher.js.map +1 -1
- package/dist/hostPatcher/core/sanitizer.js +24 -3
- package/dist/hostPatcher/core/sanitizer.js.map +1 -1
- package/dist/hostPatcher/policy/defaultPolicy.js +15 -5
- package/dist/hostPatcher/policy/defaultPolicy.js.map +1 -1
- package/dist/hostPatcher/utils/anchors.js +4 -6
- package/dist/hostPatcher/utils/anchors.js.map +1 -1
- package/dist/index.d.ts +32 -32
- package/dist/index.js +29 -29
- package/dist/index.js.map +1 -1
- package/dist/metrics/index.d.ts +1 -1
- package/dist/metrics/index.js +1 -1
- package/dist/metrics/sessionMetrics.d.ts +1 -1
- package/dist/metrics/sessionMetrics.js +6 -6
- package/dist/overlays/fetcher.d.ts +2 -2
- package/dist/overlays/fetcher.js +4 -4
- package/dist/overlays/recipeRegistry.js +2 -2
- package/dist/overlays/recipeRegistry.js.map +1 -1
- package/dist/overlays/runtime/anchor/resolve.js +1 -1
- package/dist/overlays/runtime/anchor/resolve.js.map +1 -1
- package/dist/overlays/runtime/index.d.ts +7 -7
- package/dist/overlays/runtime/index.js +7 -7
- package/dist/overlays/runtime/overlay/highlight.js +39 -39
- package/dist/overlays/runtime/overlay/highlight.js.map +1 -1
- package/dist/overlays/runtime/overlay/modal.js +5 -5
- package/dist/overlays/runtime/overlay/modal.js.map +1 -1
- package/dist/overlays/runtime/overlay/root.js +1 -1
- package/dist/overlays/runtime/overlay/runner.js +70 -23
- package/dist/overlays/runtime/overlay/runner.js.map +1 -1
- package/dist/overlays/runtime/overlay/tooltip.d.ts +1 -1
- package/dist/overlays/runtime/overlay/tooltip.js +10 -10
- package/dist/overlays/runtime/overlay/tooltip.js.map +1 -1
- package/dist/overlays/runtime/utils/dom.js +4 -1
- package/dist/overlays/runtime/utils/dom.js.map +1 -1
- package/dist/overlays/schema.js +12 -8
- package/dist/overlays/schema.js.map +1 -1
- package/dist/react.d.ts +7 -7
- package/dist/react.js +4 -4
- package/dist/react.js.map +1 -1
- package/dist/render/RenderContext.d.ts +2 -2
- package/dist/render/RenderContext.js +5 -5
- package/dist/render/RenderContext.js.map +1 -1
- package/dist/render/index.d.ts +3 -3
- package/dist/render/index.js +1 -1
- package/dist/render/types.d.ts +4 -4
- package/dist/runtime.d.ts +12 -12
- package/dist/runtime.js +20 -20
- package/dist/runtime.js.map +1 -1
- package/dist/smart-canvas.esm.js +16 -16
- package/dist/smart-canvas.esm.js.map +4 -4
- package/dist/smart-canvas.js +644 -491
- package/dist/smart-canvas.js.map +4 -4
- package/dist/smart-canvas.min.js +15 -15
- package/dist/smart-canvas.min.js.map +4 -4
- package/dist/state/StateStore.d.ts +1 -1
- package/dist/state/StateStore.js +9 -9
- package/dist/state/StateStore.js.map +1 -1
- package/dist/state/helpers/cooldowns.d.ts +1 -1
- package/dist/state/helpers/cooldowns.js +1 -1
- package/dist/state/helpers/dismissals.d.ts +1 -1
- package/dist/state/helpers/dismissals.js +1 -1
- package/dist/state/helpers/frequency.d.ts +1 -1
- package/dist/state/helpers/frequency.js +1 -1
- package/dist/state/index.d.ts +4 -4
- package/dist/state/index.js +3 -3
- package/dist/state/schema.d.ts +1 -1
- package/dist/state/schema.js +1 -1
- package/dist/store/example.js +13 -13
- package/dist/store/example.js.map +1 -1
- package/dist/store/mini-effector.js +6 -8
- package/dist/store/mini-effector.js.map +1 -1
- package/dist/surfaces/Surfaces.d.ts +1 -1
- package/dist/surfaces/Surfaces.js +25 -25
- package/dist/surfaces/Surfaces.js.map +1 -1
- package/dist/surfaces/index.d.ts +4 -4
- package/dist/surfaces/index.js +3 -3
- package/dist/surfaces/positioning.d.ts +2 -2
- package/dist/surfaces/positioning.js +74 -77
- package/dist/surfaces/positioning.js.map +1 -1
- package/dist/surfaces/types.d.ts +9 -9
- package/dist/surfaces/types.js +7 -7
- package/dist/surfaces/types.js.map +1 -1
- package/dist/telemetry/adapters/noop.d.ts +12 -0
- package/dist/telemetry/adapters/noop.js +42 -0
- package/dist/telemetry/adapters/noop.js.map +1 -0
- package/dist/telemetry/adapters/posthog.d.ts +2 -2
- package/dist/telemetry/adapters/posthog.js +29 -16
- package/dist/telemetry/adapters/posthog.js.map +1 -1
- package/dist/telemetry/index.d.ts +4 -3
- package/dist/telemetry/index.js +3 -2
- package/dist/telemetry/index.js.map +1 -1
- package/dist/telemetry/registry.d.ts +2 -2
- package/dist/telemetry/registry.js +4 -2
- package/dist/telemetry/registry.js.map +1 -1
- package/dist/telemetry/types.d.ts +1 -1
- package/dist/theme/ThemeProvider.d.ts +2 -2
- package/dist/theme/ThemeProvider.js +21 -21
- package/dist/theme/ThemeProvider.js.map +1 -1
- package/dist/theme/defaultTheme.d.ts +2 -2
- package/dist/theme/defaultTheme.js +111 -111
- package/dist/theme/defaultTheme.js.map +1 -1
- package/dist/theme/extractHostTheme.d.ts +1 -1
- package/dist/theme/extractHostTheme.js +42 -44
- package/dist/theme/extractHostTheme.js.map +1 -1
- package/dist/theme/index.d.ts +5 -5
- package/dist/theme/index.js +3 -3
- package/dist/theme/index.js.map +1 -1
- package/dist/theme/types.d.ts +2 -2
- package/dist/token.js +3 -6
- package/dist/token.js.map +1 -1
- package/dist/types-only.d.ts +1 -1
- package/dist/types.d.ts +43 -43
- package/dist/widgets/WidgetRegistry.d.ts +2 -2
- package/dist/widgets/WidgetRegistry.js +11 -11
- package/dist/widgets/WidgetRegistry.js.map +1 -1
- package/dist/widgets/index.d.ts +2 -2
- package/dist/widgets/index.js +1 -1
- package/dist/widgets/index.js.map +1 -1
- package/package.json +4 -2
- package/schema/canvas-config.schema.json +51 -7
- package/schema/runtime-context.schema.json +1 -5
package/dist/configFetcher.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { debug } from './logger';
|
|
1
2
|
/**
|
|
2
3
|
* Allowed hosts for fetching config.
|
|
3
4
|
* Only config from these hosts will be fetched.
|
|
@@ -6,7 +7,7 @@ const ALLOWED_CONFIG_HOSTS = [
|
|
|
6
7
|
'api.syntrologie.com',
|
|
7
8
|
'cdn.syntrologie.com',
|
|
8
9
|
'localhost',
|
|
9
|
-
'127.0.0.1'
|
|
10
|
+
'127.0.0.1',
|
|
10
11
|
];
|
|
11
12
|
/**
|
|
12
13
|
* Validates that a config URI is from an allowed host.
|
|
@@ -22,7 +23,7 @@ function validateConfigUri(uri) {
|
|
|
22
23
|
return false;
|
|
23
24
|
}
|
|
24
25
|
// Check against allowlist
|
|
25
|
-
const isAllowed = ALLOWED_CONFIG_HOSTS.some(host => parsed.hostname === host);
|
|
26
|
+
const isAllowed = ALLOWED_CONFIG_HOSTS.some((host) => parsed.hostname === host);
|
|
26
27
|
if (!isAllowed) {
|
|
27
28
|
console.warn('[SmartCanvas] Config URI host not in allowlist:', parsed.hostname);
|
|
28
29
|
return false;
|
|
@@ -48,7 +49,7 @@ function isSameOrigin(uri) {
|
|
|
48
49
|
return false;
|
|
49
50
|
}
|
|
50
51
|
}
|
|
51
|
-
export const resolveConfigUri = ({ configUri, experiments, featureKey =
|
|
52
|
+
export const resolveConfigUri = ({ configUri, experiments, featureKey = 'smart-canvas-config-uri', }) => {
|
|
52
53
|
var _a;
|
|
53
54
|
if (configUri)
|
|
54
55
|
return configUri;
|
|
@@ -57,21 +58,21 @@ export const resolveConfigUri = ({ configUri, experiments, featureKey = "smart-c
|
|
|
57
58
|
return fromFeature;
|
|
58
59
|
return undefined;
|
|
59
60
|
};
|
|
60
|
-
export const createCanvasConfigFetcher = ({ configUri, experiments, featureKey, credentials, configFeatureKey =
|
|
61
|
+
export const createCanvasConfigFetcher = ({ configUri, experiments, featureKey, credentials, configFeatureKey = 'smart-canvas-config', }) => {
|
|
61
62
|
return async () => {
|
|
62
63
|
var _a;
|
|
63
64
|
// First check if we have a direct config object from experiment platform
|
|
64
65
|
if (experiments && configFeatureKey) {
|
|
65
66
|
const directConfig = (_a = experiments.getFeatureValue) === null || _a === void 0 ? void 0 : _a.call(experiments, configFeatureKey, null);
|
|
66
67
|
if (directConfig && typeof directConfig === 'object') {
|
|
67
|
-
|
|
68
|
+
debug('SmartCanvas Config', 'Resolved config directly from feature flag', directConfig);
|
|
68
69
|
return directConfig;
|
|
69
70
|
}
|
|
70
71
|
}
|
|
71
72
|
// Fall back to URI-based fetching
|
|
72
73
|
const uri = resolveConfigUri({ configUri, experiments, featureKey });
|
|
73
74
|
if (!uri) {
|
|
74
|
-
|
|
75
|
+
debug('SmartCanvas Config', 'No config available — returning empty config');
|
|
75
76
|
return { tiles: [], overlays: [] };
|
|
76
77
|
}
|
|
77
78
|
// Security: Validate URI against allowlist
|
|
@@ -85,7 +86,9 @@ export const createCanvasConfigFetcher = ({ configUri, experiments, featureKey,
|
|
|
85
86
|
if (!response.ok) {
|
|
86
87
|
throw new Error(`SmartCanvas: failed to fetch config (${response.status})`);
|
|
87
88
|
}
|
|
88
|
-
|
|
89
|
+
const config = await response.json();
|
|
90
|
+
debug('SmartCanvas Config', 'Fetched config from URI', config);
|
|
91
|
+
return config;
|
|
89
92
|
};
|
|
90
93
|
};
|
|
91
94
|
//# sourceMappingURL=configFetcher.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configFetcher.js","sourceRoot":"","sources":["../src/configFetcher.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"configFetcher.js","sourceRoot":"","sources":["../src/configFetcher.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAEjC;;;GAGG;AACH,MAAM,oBAAoB,GAAG;IAC3B,qBAAqB;IACrB,qBAAqB;IACrB,WAAW;IACX,WAAW;CACZ,CAAC;AAEF;;;GAGG;AACH,SAAS,iBAAiB,CAAC,GAAW;IACpC,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;QAC5B,MAAM,WAAW,GAAG,4BAA4B,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAEvE,kCAAkC;QAClC,IAAI,MAAM,CAAC,QAAQ,KAAK,QAAQ,IAAI,CAAC,WAAW,EAAE,CAAC;YACjD,OAAO,CAAC,IAAI,CAAC,0CAA0C,EAAE,GAAG,CAAC,CAAC;YAC9D,OAAO,KAAK,CAAC;QACf,CAAC;QAED,0BAA0B;QAC1B,MAAM,SAAS,GAAG,oBAAoB,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,QAAQ,KAAK,I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C;QAC/D,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
* - Notifying subscribers when context changes
|
|
7
7
|
* - Providing the current context snapshot
|
|
8
8
|
*/
|
|
9
|
-
import type { RuntimeContext, AnchorState, ContextChangeCallback, Unsubscribe, PageHistoryEntry } from
|
|
10
|
-
import type { TelemetryClient } from
|
|
11
|
-
import type { RoutesConfig } from
|
|
9
|
+
import type { RuntimeContext, AnchorState, ContextChangeCallback, Unsubscribe, PageHistoryEntry } from './types';
|
|
10
|
+
import type { TelemetryClient } from '../telemetry/types';
|
|
11
|
+
import type { RoutesConfig } from '../types';
|
|
12
12
|
export interface ContextManagerOptions {
|
|
13
13
|
/** Telemetry client for session ID */
|
|
14
14
|
telemetry?: TelemetryClient;
|
|
@@ -5,17 +5,17 @@ function createDefaultContext() {
|
|
|
5
5
|
const now = Date.now();
|
|
6
6
|
return {
|
|
7
7
|
page: {
|
|
8
|
-
url: typeof window !==
|
|
9
|
-
title: typeof document !==
|
|
8
|
+
url: typeof window !== 'undefined' ? window.location.href : '',
|
|
9
|
+
title: typeof document !== 'undefined' ? document.title : undefined,
|
|
10
10
|
},
|
|
11
11
|
session: {
|
|
12
|
-
sessionId:
|
|
12
|
+
sessionId: '',
|
|
13
13
|
startTs: now,
|
|
14
14
|
pageHistory: [],
|
|
15
15
|
},
|
|
16
16
|
viewport: {
|
|
17
|
-
width: typeof window !==
|
|
18
|
-
height: typeof window !==
|
|
17
|
+
width: typeof window !== 'undefined' ? window.innerWidth : 0,
|
|
18
|
+
height: typeof window !== 'undefined' ? window.innerHeight : 0,
|
|
19
19
|
},
|
|
20
20
|
};
|
|
21
21
|
}
|
|
@@ -62,15 +62,15 @@ function matchRoute(url, routes) {
|
|
|
62
62
|
*/
|
|
63
63
|
function matchPattern(pathname, pattern) {
|
|
64
64
|
// Normalize paths
|
|
65
|
-
const normalizedPath = pathname.replace(/\/$/,
|
|
66
|
-
const normalizedPattern = pattern.replace(/\/$/,
|
|
65
|
+
const normalizedPath = pathname.replace(/\/$/, '') || '/';
|
|
66
|
+
const normalizedPattern = pattern.replace(/\/$/, '') || '/';
|
|
67
67
|
// Exact match
|
|
68
68
|
if (normalizedPath === normalizedPattern)
|
|
69
69
|
return true;
|
|
70
70
|
// Convert pattern to regex
|
|
71
71
|
const regexPattern = normalizedPattern
|
|
72
|
-
.replace(/:[^/]+/g,
|
|
73
|
-
.replace(/\*/g,
|
|
72
|
+
.replace(/:[^/]+/g, '[^/]+') // :param -> [^/]+
|
|
73
|
+
.replace(/\*/g, '.*'); // * -> .*
|
|
74
74
|
const regex = new RegExp(`^${regexPattern}$`);
|
|
75
75
|
return regex.test(normalizedPath);
|
|
76
76
|
}
|
|
@@ -104,7 +104,7 @@ export class ContextManager {
|
|
|
104
104
|
// Add current page to history
|
|
105
105
|
this.addPageToHistory(this.context.page.url);
|
|
106
106
|
// Setup browser event listeners
|
|
107
|
-
if (typeof window !==
|
|
107
|
+
if (typeof window !== 'undefined') {
|
|
108
108
|
this.setupBrowserListeners();
|
|
109
109
|
}
|
|
110
110
|
}
|
|
@@ -171,14 +171,14 @@ export class ContextManager {
|
|
|
171
171
|
this.updateViewport();
|
|
172
172
|
}, 100);
|
|
173
173
|
};
|
|
174
|
-
window.addEventListener(
|
|
175
|
-
this.cleanupFns.push(() => window.removeEventListener(
|
|
174
|
+
window.addEventListener('resize', handleResize);
|
|
175
|
+
this.cleanupFns.push(() => window.removeEventListener('resize', handleResize));
|
|
176
176
|
// Navigation listener (popstate for back/forward)
|
|
177
177
|
const handlePopState = () => {
|
|
178
178
|
this.updatePage();
|
|
179
179
|
};
|
|
180
|
-
window.addEventListener(
|
|
181
|
-
this.cleanupFns.push(() => window.removeEventListener(
|
|
180
|
+
window.addEventListener('popstate', handlePopState);
|
|
181
|
+
this.cleanupFns.push(() => window.removeEventListener('popstate', handlePopState));
|
|
182
182
|
// History pushState/replaceState interception
|
|
183
183
|
const originalPushState = history.pushState.bind(history);
|
|
184
184
|
const originalReplaceState = history.replaceState.bind(history);
|
|
@@ -254,7 +254,7 @@ export class ContextManager {
|
|
|
254
254
|
callback(this.context, this.previousContext);
|
|
255
255
|
}
|
|
256
256
|
catch (err) {
|
|
257
|
-
console.error(
|
|
257
|
+
console.error('[ContextManager] Listener error:', err);
|
|
258
258
|
}
|
|
259
259
|
}
|
|
260
260
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContextManager.js","sourceRoot":"","sources":["../../src/context/ContextManager.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ContextManager.js","sourceRoot":"","sources":["../../src/context/ContextManager.ts"],"names":[],"mappings":"AA6BA;;GAEG;AACH,SAAS,oBAAoB;IAC3B,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IACvB,OAAO;QACL,IAAI,EAAE;YACJ,GAAG,EAAE,OAAO,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE;YAC9D,KAAK,EAAE,OAAO,QAAQ,KAAK,WAAW,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS;SACpE;QACD,OAAO,EAAE;YACP,SAAS,EAAE,EAAE;YACb,OAAO,EAAE,GAAG;YACZ,WAAW,EAAE,EAAE;SAChB;QACD,QAAQ,EAAE;YACR,KAAK,EAAE,OAAO,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;YAC5D,MAAM,EAAE,OAAO,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;SAC/D;KACF,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,SAAS,UAAU,CAAC,GAAW,EAAE,MAAqB;IACpD,IAAI,CAAC,MAAM;QAAE,OAAO,SA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,CAAC;gBACH,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,eAAe,CAAC,CAAC;YAC/C,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,OAAO,CAAC,KAAK,CAAC,kCAAkC,EAAE,GAAG,CAAC,CAAC;YACzD,CAAC;QACH,CAAC;IACH,CAAC;CACF;AAED;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAAC,UAAiC,EAAE;IACtE,OAAO,IAAI,cAAc,CAAC,OAAO,CAAC,CAAC;AACrC,CAAC"}
|
package/dist/context/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Context module exports.
|
|
3
3
|
*/
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
6
|
-
export { ContextManager, createContextManager } from
|
|
7
|
-
export type { ContextManagerOptions } from
|
|
4
|
+
export * from './types';
|
|
5
|
+
export * from './schema';
|
|
6
|
+
export { ContextManager, createContextManager } from './ContextManager';
|
|
7
|
+
export type { ContextManagerOptions } from './ContextManager';
|
package/dist/context/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Context module exports.
|
|
3
3
|
*/
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
6
|
-
export { ContextManager, createContextManager } from
|
|
4
|
+
export * from './types';
|
|
5
|
+
export * from './schema';
|
|
6
|
+
export { ContextManager, createContextManager } from './ContextManager';
|
|
7
7
|
//# sourceMappingURL=index.js.map
|
package/dist/context/schema.d.ts
CHANGED
package/dist/context/schema.js
CHANGED
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
* The central evaluation engine for DecisionStrategy objects.
|
|
5
5
|
* Routes strategies to their appropriate evaluators.
|
|
6
6
|
*/
|
|
7
|
-
import type { DecisionStrategy, DecisionResult } from
|
|
8
|
-
import type { RuntimeContext } from
|
|
9
|
-
import type { StateStore } from
|
|
10
|
-
import type { EventBus } from
|
|
11
|
-
import type { SessionMetricTracker } from
|
|
7
|
+
import type { DecisionStrategy, DecisionResult } from './types';
|
|
8
|
+
import type { RuntimeContext } from '../context/types';
|
|
9
|
+
import type { StateStore } from '../state/StateStore';
|
|
10
|
+
import type { EventBus } from '../events/EventBus';
|
|
11
|
+
import type { SessionMetricTracker } from '../metrics/sessionMetrics';
|
|
12
12
|
/**
|
|
13
13
|
* Options for the decision engine evaluate function.
|
|
14
14
|
*/
|
package/dist/decisions/engine.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { evaluateRuleStrategy } from
|
|
2
|
-
import { evaluateScoreStrategy } from
|
|
1
|
+
import { evaluateRuleStrategy } from './strategies/rules';
|
|
2
|
+
import { evaluateScoreStrategy } from './strategies/score';
|
|
3
3
|
/**
|
|
4
4
|
* Create an EvaluationContext from runtime components.
|
|
5
5
|
*/
|
|
@@ -33,33 +33,33 @@ function createEvaluationContext(context, options) {
|
|
|
33
33
|
export async function evaluate(strategy, context, options = {}) {
|
|
34
34
|
const evalContext = createEvaluationContext(context, options);
|
|
35
35
|
switch (strategy.type) {
|
|
36
|
-
case
|
|
36
|
+
case 'rules':
|
|
37
37
|
return evaluateRuleStrategy(strategy, evalContext);
|
|
38
|
-
case
|
|
38
|
+
case 'score':
|
|
39
39
|
return evaluateScoreStrategy(strategy, evalContext);
|
|
40
|
-
case
|
|
40
|
+
case 'model':
|
|
41
41
|
// Phase 3: Model-based strategy
|
|
42
42
|
// For now, return default
|
|
43
43
|
return {
|
|
44
44
|
value: strategy.default,
|
|
45
45
|
isFallback: true,
|
|
46
46
|
matchInfo: {
|
|
47
|
-
strategyType:
|
|
47
|
+
strategyType: 'model',
|
|
48
48
|
},
|
|
49
49
|
};
|
|
50
|
-
case
|
|
50
|
+
case 'external':
|
|
51
51
|
// Phase 3: External strategy
|
|
52
52
|
// For now, return default
|
|
53
53
|
return {
|
|
54
54
|
value: strategy.default,
|
|
55
55
|
isFallback: true,
|
|
56
56
|
matchInfo: {
|
|
57
|
-
strategyType:
|
|
57
|
+
strategyType: 'external',
|
|
58
58
|
},
|
|
59
59
|
};
|
|
60
60
|
default:
|
|
61
61
|
// Unknown strategy type
|
|
62
|
-
console.warn(
|
|
62
|
+
console.warn('[DecisionEngine] Unknown strategy type:', strategy.type);
|
|
63
63
|
return {
|
|
64
64
|
value: undefined,
|
|
65
65
|
isFallback: true,
|
|
@@ -76,12 +76,12 @@ export async function evaluate(strategy, context, options = {}) {
|
|
|
76
76
|
export function evaluateSync(strategy, context, options = {}) {
|
|
77
77
|
const evalContext = createEvaluationContext(context, options);
|
|
78
78
|
switch (strategy.type) {
|
|
79
|
-
case
|
|
79
|
+
case 'rules':
|
|
80
80
|
return evaluateRuleStrategy(strategy, evalContext);
|
|
81
|
-
case
|
|
81
|
+
case 'score':
|
|
82
82
|
return evaluateScoreStrategy(strategy, evalContext);
|
|
83
|
-
case
|
|
84
|
-
case
|
|
83
|
+
case 'model':
|
|
84
|
+
case 'external':
|
|
85
85
|
// These require async, return default
|
|
86
86
|
return {
|
|
87
87
|
value: strategy.default,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Decisions module exports.
|
|
3
3
|
*/
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
6
|
-
export { evaluate, evaluateSync, createDecisionEngine } from
|
|
7
|
-
export type { EvaluateOptions } from
|
|
8
|
-
export { evaluateCondition, evaluateRule, evaluateRuleStrategy } from
|
|
9
|
-
export { evaluateScoreStrategy } from
|
|
4
|
+
export * from './types';
|
|
5
|
+
export * from './schema';
|
|
6
|
+
export { evaluate, evaluateSync, createDecisionEngine } from './engine';
|
|
7
|
+
export type { EvaluateOptions } from './engine';
|
|
8
|
+
export { evaluateCondition, evaluateRule, evaluateRuleStrategy } from './strategies/rules';
|
|
9
|
+
export { evaluateScoreStrategy } from './strategies/score';
|
package/dist/decisions/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Decisions module exports.
|
|
3
3
|
*/
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
6
|
-
export { evaluate, evaluateSync, createDecisionEngine } from
|
|
4
|
+
export * from './types';
|
|
5
|
+
export * from './schema';
|
|
6
|
+
export { evaluate, evaluateSync, createDecisionEngine } from './engine';
|
|
7
7
|
// Strategy evaluators (for advanced use)
|
|
8
|
-
export { evaluateCondition, evaluateRule, evaluateRuleStrategy } from
|
|
9
|
-
export { evaluateScoreStrategy } from
|
|
8
|
+
export { evaluateCondition, evaluateRule, evaluateRuleStrategy } from './strategies/rules';
|
|
9
|
+
export { evaluateScoreStrategy } from './strategies/score';
|
|
10
10
|
//# sourceMappingURL=index.js.map
|
package/dist/decisions/schema.js
CHANGED
|
@@ -1,63 +1,63 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Zod schemas for decision strategy validation.
|
|
3
3
|
*/
|
|
4
|
-
import { z } from
|
|
4
|
+
import { z } from 'zod';
|
|
5
5
|
// =============================================================================
|
|
6
6
|
// CONDITION SCHEMAS
|
|
7
7
|
// =============================================================================
|
|
8
8
|
export const PageUrlConditionZ = z.object({
|
|
9
|
-
type: z.literal(
|
|
9
|
+
type: z.literal('page_url'),
|
|
10
10
|
url: z.string(),
|
|
11
11
|
});
|
|
12
12
|
export const RouteConditionZ = z.object({
|
|
13
|
-
type: z.literal(
|
|
13
|
+
type: z.literal('route'),
|
|
14
14
|
routeId: z.string(),
|
|
15
15
|
});
|
|
16
16
|
export const AnchorVisibleConditionZ = z.object({
|
|
17
|
-
type: z.literal(
|
|
17
|
+
type: z.literal('anchor_visible'),
|
|
18
18
|
anchorId: z.string(),
|
|
19
|
-
state: z.enum([
|
|
19
|
+
state: z.enum(['visible', 'present', 'absent']),
|
|
20
20
|
});
|
|
21
21
|
export const EventOccurredConditionZ = z.object({
|
|
22
|
-
type: z.literal(
|
|
22
|
+
type: z.literal('event_occurred'),
|
|
23
23
|
eventName: z.string(),
|
|
24
24
|
withinMs: z.number().optional(),
|
|
25
25
|
});
|
|
26
26
|
export const StateEqualsConditionZ = z.object({
|
|
27
|
-
type: z.literal(
|
|
27
|
+
type: z.literal('state_equals'),
|
|
28
28
|
key: z.string(),
|
|
29
29
|
value: z.unknown(),
|
|
30
30
|
});
|
|
31
31
|
export const ViewportConditionZ = z.object({
|
|
32
|
-
type: z.literal(
|
|
32
|
+
type: z.literal('viewport'),
|
|
33
33
|
minWidth: z.number().optional(),
|
|
34
34
|
maxWidth: z.number().optional(),
|
|
35
35
|
minHeight: z.number().optional(),
|
|
36
36
|
maxHeight: z.number().optional(),
|
|
37
37
|
});
|
|
38
38
|
export const SessionMetricConditionZ = z.object({
|
|
39
|
-
type: z.literal(
|
|
39
|
+
type: z.literal('session_metric'),
|
|
40
40
|
key: z.string(),
|
|
41
|
-
operator: z.enum([
|
|
41
|
+
operator: z.enum(['gte', 'lte', 'eq', 'gt', 'lt']),
|
|
42
42
|
threshold: z.number(),
|
|
43
43
|
});
|
|
44
44
|
export const DismissedConditionZ = z.object({
|
|
45
|
-
type: z.literal(
|
|
45
|
+
type: z.literal('dismissed'),
|
|
46
46
|
key: z.string(),
|
|
47
47
|
inverted: z.boolean().optional(),
|
|
48
48
|
});
|
|
49
49
|
export const CooldownActiveConditionZ = z.object({
|
|
50
|
-
type: z.literal(
|
|
50
|
+
type: z.literal('cooldown_active'),
|
|
51
51
|
key: z.string(),
|
|
52
52
|
inverted: z.boolean().optional(),
|
|
53
53
|
});
|
|
54
54
|
export const FrequencyLimitConditionZ = z.object({
|
|
55
|
-
type: z.literal(
|
|
55
|
+
type: z.literal('frequency_limit'),
|
|
56
56
|
key: z.string(),
|
|
57
57
|
limit: z.number(),
|
|
58
58
|
inverted: z.boolean().optional(),
|
|
59
59
|
});
|
|
60
|
-
export const ConditionZ = z.discriminatedUnion(
|
|
60
|
+
export const ConditionZ = z.discriminatedUnion('type', [
|
|
61
61
|
PageUrlConditionZ,
|
|
62
62
|
RouteConditionZ,
|
|
63
63
|
AnchorVisibleConditionZ,
|
|
@@ -77,32 +77,32 @@ export const RuleZ = z.object({
|
|
|
77
77
|
value: z.unknown(),
|
|
78
78
|
});
|
|
79
79
|
export const RuleStrategyZ = z.object({
|
|
80
|
-
type: z.literal(
|
|
80
|
+
type: z.literal('rules'),
|
|
81
81
|
rules: z.array(RuleZ),
|
|
82
82
|
default: z.unknown(),
|
|
83
83
|
});
|
|
84
84
|
export const ScoreStrategyZ = z.object({
|
|
85
|
-
type: z.literal(
|
|
85
|
+
type: z.literal('score'),
|
|
86
86
|
field: z.string(),
|
|
87
87
|
threshold: z.number(),
|
|
88
88
|
above: z.unknown(),
|
|
89
89
|
below: z.unknown(),
|
|
90
90
|
});
|
|
91
91
|
export const ModelStrategyZ = z.object({
|
|
92
|
-
type: z.literal(
|
|
92
|
+
type: z.literal('model'),
|
|
93
93
|
modelId: z.string(),
|
|
94
94
|
inputs: z.array(z.string()),
|
|
95
95
|
outputMapping: z.record(z.unknown()),
|
|
96
96
|
default: z.unknown(),
|
|
97
97
|
});
|
|
98
98
|
export const ExternalStrategyZ = z.object({
|
|
99
|
-
type: z.literal(
|
|
99
|
+
type: z.literal('external'),
|
|
100
100
|
endpoint: z.string(),
|
|
101
|
-
method: z.enum([
|
|
101
|
+
method: z.enum(['GET', 'POST']).optional(),
|
|
102
102
|
default: z.unknown(),
|
|
103
103
|
timeoutMs: z.number().optional(),
|
|
104
104
|
});
|
|
105
|
-
export const DecisionStrategyZ = z.discriminatedUnion(
|
|
105
|
+
export const DecisionStrategyZ = z.discriminatedUnion('type', [
|
|
106
106
|
RuleStrategyZ,
|
|
107
107
|
ScoreStrategyZ,
|
|
108
108
|
ModelStrategyZ,
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Evaluates rules in order and returns the value of the first matching rule.
|
|
5
5
|
*/
|
|
6
|
-
import type { RuleStrategy, Rule, Condition, DecisionResult, EvaluationContext } from
|
|
6
|
+
import type { RuleStrategy, Rule, Condition, DecisionResult, EvaluationContext } from '../types';
|
|
7
7
|
/**
|
|
8
8
|
* Evaluate a single condition against the evaluation context.
|
|
9
9
|
*/
|