@syntrologie/runtime-sdk 0.2.21 → 1.0.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 +721 -460
- package/README.md +310 -68
- package/dist/RuntimeProvider.d.ts +51 -0
- package/dist/RuntimeProvider.js +113 -0
- package/dist/RuntimeProvider.js.map +1 -0
- package/dist/SmartCanvasApp.d.ts +16 -10
- package/dist/SmartCanvasApp.js +45 -49
- package/dist/SmartCanvasApp.js.map +1 -1
- package/dist/SmartCanvasElement.d.ts +5 -5
- package/dist/SmartCanvasElement.js +24 -14
- 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 +11 -0
- package/dist/actions/ActionEngine.js +274 -0
- package/dist/actions/ActionEngine.js.map +1 -0
- package/dist/actions/executors/index.d.ts +117 -0
- package/dist/actions/executors/index.js +242 -0
- package/dist/actions/executors/index.js.map +1 -0
- package/dist/actions/executors/tour.d.ts +18 -0
- package/dist/actions/executors/tour.js +332 -0
- package/dist/actions/executors/tour.js.map +1 -0
- package/dist/actions/index.d.ts +10 -0
- package/dist/actions/index.js +12 -0
- package/dist/actions/index.js.map +1 -0
- package/dist/actions/types.d.ts +399 -0
- package/dist/actions/types.js +8 -0
- package/dist/actions/types.js.map +1 -0
- package/dist/actions/validation.d.ts +14 -0
- package/dist/actions/validation.js +602 -0
- package/dist/actions/validation.js.map +1 -0
- package/dist/antiFlicker.js +1 -1
- package/dist/api.d.ts +40 -26
- package/dist/api.js +86 -56
- package/dist/api.js.map +1 -1
- package/dist/apps/AppContext.d.ts +31 -0
- package/dist/apps/AppContext.js +93 -0
- package/dist/apps/AppContext.js.map +1 -0
- package/dist/apps/AppLoader.d.ts +84 -0
- package/dist/apps/AppLoader.js +256 -0
- package/dist/apps/AppLoader.js.map +1 -0
- package/dist/apps/AppRegistry.d.ts +102 -0
- package/dist/apps/AppRegistry.js +317 -0
- package/dist/apps/AppRegistry.js.map +1 -0
- 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 +305 -0
- package/dist/apps/examples/gamification-app.example.js +329 -0
- package/dist/apps/examples/gamification-app.example.js.map +1 -0
- package/dist/apps/faq/index.js +11 -0
- package/dist/apps/faq/index.js.map +7 -0
- package/dist/apps/gamification/index.js +2 -0
- package/dist/apps/gamification/index.js.map +7 -0
- package/dist/apps/index.d.ts +15 -0
- package/dist/apps/index.js +17 -0
- package/dist/apps/index.js.map +1 -0
- package/dist/apps/nav/index.js +11 -0
- package/dist/apps/nav/index.js.map +7 -0
- package/dist/apps/types.d.ts +231 -0
- package/dist/apps/types.js +8 -0
- package/dist/apps/types.js.map +1 -0
- 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 +32 -8
- package/dist/bootstrap.js +204 -85
- package/dist/bootstrap.js.map +1 -1
- package/dist/components/ShadowCanvasOverlay.d.ts +6 -6
- package/dist/components/ShadowCanvasOverlay.js +144 -107
- package/dist/components/ShadowCanvasOverlay.js.map +1 -1
- package/dist/components/TileCard.d.ts +5 -5
- package/dist/components/TileCard.js +204 -154
- 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/config-validator.d.ts +49 -0
- package/dist/config-validator.js +173 -0
- package/dist/config-validator.js.map +1 -0
- package/dist/configFetcher.d.ts +2 -2
- package/dist/configFetcher.js +20 -8
- 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 +17 -17
- 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 +97 -97
- 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/earlyPatcher.d.ts +8 -20
- package/dist/earlyPatcher.js +13 -62
- package/dist/earlyPatcher.js.map +1 -1
- package/dist/editorLoader.d.ts +2 -0
- package/dist/editorLoader.js +104 -58
- 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 +25 -1
- package/dist/events/normalizers/posthog.js +35 -27
- package/dist/events/normalizers/posthog.js.map +1 -1
- package/dist/events/schema.d.ts +13 -13
- package/dist/events/schema.js +2 -2
- package/dist/events/types.d.ts +7 -1
- package/dist/events/types.js +29 -21
- package/dist/events/types.js.map +1 -1
- 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 +8 -5
- package/dist/hooks/useCanvasOverlays.js +66 -17
- 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 +5 -9
- package/dist/hooks/useShadowCanvasConfig.js +7 -5
- 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 +34 -27
- package/dist/index.js +36 -24
- package/dist/index.js.map +1 -1
- package/dist/logger.d.ts +29 -0
- package/dist/logger.js +81 -0
- package/dist/logger.js.map +1 -0
- 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.d.ts +146 -146
- 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 +32 -8
- package/dist/runtime.js +87 -13
- package/dist/runtime.js.map +1 -1
- package/dist/smart-canvas.esm.js +155 -78
- package/dist/smart-canvas.esm.js.map +4 -4
- package/dist/smart-canvas.js +38776 -33216
- package/dist/smart-canvas.js.map +4 -4
- package/dist/smart-canvas.min.js +156 -78
- 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.d.ts +1 -0
- package/dist/store/example.js +43 -0
- package/dist/store/example.js.map +1 -0
- package/dist/store/mini-effector.d.ts +46 -0
- package/dist/store/mini-effector.js +88 -0
- package/dist/store/mini-effector.js.map +1 -0
- package/dist/surfaces/Surfaces.d.ts +11 -0
- package/dist/surfaces/Surfaces.js +361 -0
- package/dist/surfaces/Surfaces.js.map +1 -0
- package/dist/surfaces/index.d.ts +9 -0
- package/dist/surfaces/index.js +12 -0
- package/dist/surfaces/index.js.map +1 -0
- package/dist/surfaces/positioning.d.ts +50 -0
- package/dist/surfaces/positioning.js +228 -0
- package/dist/surfaces/positioning.js.map +1 -0
- package/dist/surfaces/types.d.ts +167 -0
- package/dist/surfaces/types.js +23 -0
- package/dist/surfaces/types.js.map +1 -0
- 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 +8 -2
- package/dist/telemetry/adapters/posthog.js +36 -14
- 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.d.ts +2 -0
- package/dist/token.js +3 -6
- package/dist/token.js.map +1 -1
- package/dist/types-only.d.ts +32 -0
- package/dist/types-only.js +11 -0
- package/dist/types-only.js.map +1 -0
- package/dist/types.d.ts +89 -56
- package/dist/types.js +15 -2
- package/dist/types.js.map +1 -1
- package/dist/version.d.ts +13 -0
- package/dist/version.js +14 -0
- package/dist/version.js.map +1 -0
- package/dist/widgets/WidgetRegistry.d.ts +139 -0
- package/dist/widgets/WidgetRegistry.js +182 -0
- package/dist/widgets/WidgetRegistry.js.map +1 -0
- package/dist/widgets/index.d.ts +7 -0
- package/dist/widgets/index.js +7 -0
- package/dist/widgets/index.js.map +1 -0
- package/package.json +26 -10
- package/schema/canvas-config.schema.json +488 -254
- package/schema/runtime-context.schema.json +1 -5
package/README.md
CHANGED
|
@@ -2,19 +2,50 @@
|
|
|
2
2
|
|
|
3
3
|
## Smart Canvas SDK (React + Shadow DOM)
|
|
4
4
|
|
|
5
|
-
The SDK
|
|
5
|
+
The SDK ships a framework-agnostic `<smart-canvas>` custom element with an **open shadow root**. We render everything with React, but the canvas is encapsulated so host Tailwind configs, resets, or stacking contexts can't break the UI.
|
|
6
6
|
|
|
7
|
-
### What
|
|
7
|
+
### What's Included
|
|
8
8
|
|
|
9
9
|
- `SmartCanvasElement` – the custom element that owns the shadow DOM, overlay root, and controller.
|
|
10
10
|
- `SmartCanvasApp` – the React tree (overlay, rectangles, toggle) you portal into the shadow.
|
|
11
11
|
- `SmartCanvasPortal` – helper for React hosts to portal their tree (and context) into the element mount.
|
|
12
12
|
- `createSmartCanvas` – imperative API (`window.SmartCanvas.create`) for non-React hosts.
|
|
13
|
+
- **ActionEngine** – unified execution layer for interventions (highlight, tooltip, badge, DOM modifications)
|
|
14
|
+
- **Surfaces** – managed surface system for rendering UI into named slots
|
|
13
15
|
- GrowthBook/PostHog wrappers, hooks, rectangle components, and wheel remain available.
|
|
14
16
|
|
|
15
|
-
|
|
17
|
+
---
|
|
16
18
|
|
|
17
|
-
|
|
19
|
+
## Quick Start
|
|
20
|
+
|
|
21
|
+
```typescript
|
|
22
|
+
import { Syntro } from '@syntrologie/runtime-sdk';
|
|
23
|
+
|
|
24
|
+
const { runtime } = await Syntro.init({ token: 'syn_...' });
|
|
25
|
+
|
|
26
|
+
// Change a headline
|
|
27
|
+
const handle = await runtime.actions.apply({
|
|
28
|
+
kind: 'set_text',
|
|
29
|
+
anchorId: 'h1.hero-title',
|
|
30
|
+
text: 'Welcome to Our New Experience',
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
// Show a toast notification
|
|
34
|
+
const toast = runtime.surfaces.mount('toast_top', {
|
|
35
|
+
type: 'html',
|
|
36
|
+
content: '<div class="toast">Changes applied!</div>',
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
// Later: revert and cleanup
|
|
40
|
+
await handle.revert();
|
|
41
|
+
toast.unmount();
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## Installation
|
|
47
|
+
|
|
48
|
+
### NPM/Yarn
|
|
18
49
|
|
|
19
50
|
```bash
|
|
20
51
|
npm install @syntrologie/smart-canvas-sdk
|
|
@@ -22,7 +53,7 @@ npm install @syntrologie/smart-canvas-sdk
|
|
|
22
53
|
yarn add @syntrologie/smart-canvas-sdk
|
|
23
54
|
```
|
|
24
55
|
|
|
25
|
-
|
|
56
|
+
### CDN
|
|
26
57
|
|
|
27
58
|
For quick setup without a build process:
|
|
28
59
|
|
|
@@ -39,18 +70,113 @@ For quick setup without a build process:
|
|
|
39
70
|
</script>
|
|
40
71
|
```
|
|
41
72
|
|
|
42
|
-
|
|
73
|
+
### Local Development
|
|
43
74
|
|
|
44
75
|
```bash
|
|
45
|
-
cd tech-core/sdks/
|
|
76
|
+
cd tech-core/sdks/runtime-sdk
|
|
46
77
|
npm run build
|
|
47
|
-
cd ../../tax_landing_page
|
|
48
|
-
npm install @syntrologie/smart-canvas-sdk@file:../tech-core/sdks/shadow-canvas
|
|
49
78
|
```
|
|
50
79
|
|
|
51
|
-
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
## Core Modules
|
|
83
|
+
|
|
84
|
+
### ActionEngine
|
|
85
|
+
|
|
86
|
+
The ActionEngine provides a unified API for applying reversible interventions:
|
|
87
|
+
|
|
88
|
+
```typescript
|
|
89
|
+
// Visual actions
|
|
90
|
+
await runtime.actions.apply({ kind: 'highlight', anchorId: '#cta', style: { color: '#4f46e5' } });
|
|
91
|
+
await runtime.actions.apply({
|
|
92
|
+
kind: 'tooltip',
|
|
93
|
+
anchorId: '#help',
|
|
94
|
+
content: { body: 'Click for help' },
|
|
95
|
+
});
|
|
96
|
+
await runtime.actions.apply({ kind: 'badge', anchorId: '#inbox', content: '3' });
|
|
97
|
+
await runtime.actions.apply({ kind: 'pulse', anchorId: '#notification' });
|
|
98
|
+
|
|
99
|
+
// DOM actions
|
|
100
|
+
await runtime.actions.apply({ kind: 'set_text', anchorId: 'h1', text: 'New headline' });
|
|
101
|
+
await runtime.actions.apply({
|
|
102
|
+
kind: 'insert_html',
|
|
103
|
+
anchorId: '.cta',
|
|
104
|
+
html: '<span>NEW</span>',
|
|
105
|
+
position: 'append',
|
|
106
|
+
});
|
|
107
|
+
await runtime.actions.apply({ kind: 'add_class', anchorId: '.card', className: 'highlighted' });
|
|
108
|
+
await runtime.actions.apply({
|
|
109
|
+
kind: 'set_style',
|
|
110
|
+
anchorId: '.hero',
|
|
111
|
+
styles: { background: '#1e40af' },
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
// Navigation actions
|
|
115
|
+
await runtime.actions.apply({ kind: 'scroll_to', anchorId: '#pricing' });
|
|
116
|
+
await runtime.actions.apply({ kind: 'navigate', url: '/signup' });
|
|
117
|
+
|
|
118
|
+
// Batch with atomic rollback
|
|
119
|
+
const batch = await runtime.actions.applyBatch([
|
|
120
|
+
{ kind: 'set_text', anchorId: 'h1', text: 'New' },
|
|
121
|
+
{ kind: 'highlight', anchorId: 'h1' },
|
|
122
|
+
]);
|
|
123
|
+
await batch.revertAll();
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### Surfaces
|
|
52
127
|
|
|
53
|
-
|
|
128
|
+
The Surfaces system manages UI rendering into named slots:
|
|
129
|
+
|
|
130
|
+
```typescript
|
|
131
|
+
// Static slots
|
|
132
|
+
runtime.surfaces.mount('toast_top', { type: 'html', content: '<div>Saved!</div>' });
|
|
133
|
+
runtime.surfaces.mount('drawer_right', { type: 'html', content: '<div>Settings</div>' });
|
|
134
|
+
runtime.surfaces.mount('overlay_center', { type: 'html', content: '<div>Modal</div>' });
|
|
135
|
+
|
|
136
|
+
// Dynamic slots (positioned relative to anchors)
|
|
137
|
+
runtime.surfaces.mount('inline:product-card', { type: 'html', content: '<span>SALE</span>' });
|
|
138
|
+
runtime.surfaces.mount(
|
|
139
|
+
'adjacent:help-icon',
|
|
140
|
+
{ type: 'html', content: '<div>Help text</div>' },
|
|
141
|
+
{
|
|
142
|
+
position: { placement: 'bottom' },
|
|
143
|
+
}
|
|
144
|
+
);
|
|
145
|
+
|
|
146
|
+
// Priority-based arbitration
|
|
147
|
+
runtime.surfaces.mount('toast_top', content, { priority: 10 }); // Higher priority wins
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
**Available Static Slots:**
|
|
151
|
+
| Slot | Position |
|
|
152
|
+
|------|----------|
|
|
153
|
+
| `drawer_right` | Right edge, full height |
|
|
154
|
+
| `drawer_left` | Left edge, full height |
|
|
155
|
+
| `drawer_bottom` | Bottom edge, full width |
|
|
156
|
+
| `overlay_center` | Centered modal |
|
|
157
|
+
| `overlay_corner_br` | Bottom-right corner |
|
|
158
|
+
| `overlay_corner_bl` | Bottom-left corner |
|
|
159
|
+
| `toast_top` | Top center |
|
|
160
|
+
| `toast_bottom` | Bottom center |
|
|
161
|
+
|
|
162
|
+
### Runtime
|
|
163
|
+
|
|
164
|
+
The runtime provides access to all core providers:
|
|
165
|
+
|
|
166
|
+
```typescript
|
|
167
|
+
const { runtime } = await Syntro.init({ token: 'syn_...' });
|
|
168
|
+
|
|
169
|
+
runtime.telemetry; // Event tracking (PostHog)
|
|
170
|
+
runtime.context; // Page/session/viewport state
|
|
171
|
+
runtime.events; // Normalized event stream
|
|
172
|
+
runtime.state; // Persistent storage
|
|
173
|
+
runtime.actions; // ActionEngine
|
|
174
|
+
runtime.surfaces; // Surfaces
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
---
|
|
178
|
+
|
|
179
|
+
## Using the Custom Element (React Host)
|
|
54
180
|
|
|
55
181
|
```tsx
|
|
56
182
|
import {
|
|
@@ -60,9 +186,11 @@ import {
|
|
|
60
186
|
SmartCanvasPortal,
|
|
61
187
|
registerSmartCanvasElement,
|
|
62
188
|
type SmartCanvasElement,
|
|
63
|
-
} from
|
|
189
|
+
} from '@syntrologie/smart-canvas-sdk';
|
|
64
190
|
|
|
65
|
-
const canvasFetcher = async () => {
|
|
191
|
+
const canvasFetcher = async () => {
|
|
192
|
+
/* return ShadowCanvasConfigResponse */
|
|
193
|
+
};
|
|
66
194
|
|
|
67
195
|
function SmartCanvasBridge() {
|
|
68
196
|
const [element, setElement] = useState<SmartCanvasElement | null>(null);
|
|
@@ -90,7 +218,9 @@ function SmartCanvasBridge() {
|
|
|
90
218
|
}
|
|
91
219
|
```
|
|
92
220
|
|
|
93
|
-
|
|
221
|
+
---
|
|
222
|
+
|
|
223
|
+
## Using the Imperative API (Plain JS Host)
|
|
94
224
|
|
|
95
225
|
When using via CDN, the SDK is available as `window.SyntrologieSDK`:
|
|
96
226
|
|
|
@@ -99,87 +229,199 @@ When using via CDN, the SDK is available as `window.SyntrologieSDK`:
|
|
|
99
229
|
await window.SmartCanvas?.create({
|
|
100
230
|
defaultOpen: true,
|
|
101
231
|
tokens: {
|
|
102
|
-
|
|
103
|
-
|
|
232
|
+
'--sc-surface': '#050814',
|
|
233
|
+
'--sc-fg': '#f8fafc',
|
|
104
234
|
},
|
|
105
235
|
integrations: {
|
|
106
|
-
posthog,
|
|
107
|
-
growthbook,
|
|
236
|
+
posthog, // existing PostHog client
|
|
237
|
+
growthbook, // existing GrowthBook client
|
|
108
238
|
},
|
|
109
239
|
});
|
|
110
240
|
```
|
|
111
241
|
|
|
112
|
-
|
|
242
|
+
---
|
|
113
243
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
244
|
+
## Event System
|
|
245
|
+
|
|
246
|
+
The EventBus provides a unified stream of normalized events:
|
|
247
|
+
|
|
248
|
+
```typescript
|
|
249
|
+
// Subscribe to events
|
|
250
|
+
runtime.events.subscribe({ names: ['ui.click', 'action.applied'] }, (event) => {
|
|
251
|
+
console.log(event.name, event.props);
|
|
252
|
+
});
|
|
119
253
|
|
|
120
|
-
|
|
254
|
+
// Standard events
|
|
255
|
+
// UI: ui.click, ui.scroll, ui.input, ui.submit
|
|
256
|
+
// Navigation: nav.page_view, nav.page_leave
|
|
257
|
+
// Canvas: canvas.opened, canvas.closed, tile.viewed, tile.action
|
|
258
|
+
// Actions: action.applied, action.reverted, action.failed
|
|
259
|
+
// Surfaces: surface.mounted, surface.unmounted
|
|
260
|
+
```
|
|
121
261
|
|
|
122
|
-
|
|
262
|
+
---
|
|
123
263
|
|
|
124
|
-
|
|
125
|
-
| --- | --- |
|
|
126
|
-
| `shadow_canvas_opened` / `shadow_canvas_closed` | Toggle button interactions. |
|
|
127
|
-
| `shadow_canvas_rectangle_viewed` | A rectangle becomes visible (overlay grid & wheel). |
|
|
128
|
-
| `shadow_canvas_action` | CTA click, chatbot send, overlay events (tooltips, dismiss, anchor missing). |
|
|
264
|
+
## State Management
|
|
129
265
|
|
|
130
|
-
|
|
266
|
+
```typescript
|
|
267
|
+
// Dismissals
|
|
268
|
+
runtime.state.dismissals.mark("promo-banner");
|
|
269
|
+
if (runtime.state.dismissals.isDismissed("promo-banner")) { ... }
|
|
131
270
|
|
|
132
|
-
|
|
271
|
+
// Cooldowns
|
|
272
|
+
runtime.state.cooldowns.set("upsell", 86400000); // 24h
|
|
273
|
+
if (runtime.state.cooldowns.isActive("upsell")) { ... }
|
|
133
274
|
|
|
134
|
-
|
|
275
|
+
// Frequency caps
|
|
276
|
+
runtime.state.frequency.increment("tooltip-shown");
|
|
277
|
+
if (runtime.state.frequency.count("tooltip-shown") >= 3) { ... }
|
|
278
|
+
```
|
|
135
279
|
|
|
136
|
-
|
|
137
|
-
|
|
280
|
+
---
|
|
281
|
+
|
|
282
|
+
## Decision Strategies
|
|
283
|
+
|
|
284
|
+
Control when adaptives activate:
|
|
285
|
+
|
|
286
|
+
```typescript
|
|
287
|
+
const result = runtime.evaluateSync({
|
|
288
|
+
type: 'rules',
|
|
289
|
+
rules: [
|
|
290
|
+
{
|
|
291
|
+
conditions: [
|
|
292
|
+
{ type: 'page_url', pattern: '/pricing*' },
|
|
293
|
+
{ type: 'viewport', minWidth: 768 },
|
|
294
|
+
{ type: 'dismissed', key: 'promo', inverted: true },
|
|
295
|
+
],
|
|
296
|
+
value: true,
|
|
297
|
+
},
|
|
298
|
+
],
|
|
299
|
+
default: false,
|
|
300
|
+
});
|
|
138
301
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
302
|
+
if (result.value) {
|
|
303
|
+
// Apply adaptive
|
|
304
|
+
}
|
|
142
305
|
```
|
|
143
306
|
|
|
144
|
-
|
|
307
|
+
---
|
|
145
308
|
|
|
146
|
-
|
|
309
|
+
## Styling & Overlays
|
|
147
310
|
|
|
148
|
-
-
|
|
149
|
-
-
|
|
150
|
-
-
|
|
151
|
-
-
|
|
152
|
-
-
|
|
153
|
-
- `createOverlayRecipeFetcher`, `resolveConfigUri`
|
|
154
|
-
- `runOverlays`, `showTooltip`, `showHighlight`
|
|
155
|
-
- `createAnchorResolver` (works for main DOM + shadow DOM)
|
|
311
|
+
- Fonts, colors, and CSS variables are inherited from the host
|
|
312
|
+
- Tokens can be overridden via `setTokens` or standard CSS:
|
|
313
|
+
- `--syntro-tooltip-bg`, `--syntro-tooltip-fg`, `--syntro-tooltip-radius`
|
|
314
|
+
- `--syntro-ring`, `--syntro-spotlight-backdrop` for highlights
|
|
315
|
+
- A scoped reset is injected via `adoptedStyleSheets`
|
|
156
316
|
|
|
157
|
-
|
|
317
|
+
---
|
|
158
318
|
|
|
159
|
-
|
|
319
|
+
## Schema & Validation
|
|
160
320
|
|
|
161
|
-
-
|
|
162
|
-
-
|
|
163
|
-
- `SmartCanvasController` exposes `open/close` for deterministic tests.
|
|
321
|
+
- JSON schema lives at `schema/canvas-config.schema.json`
|
|
322
|
+
- Validate a config file locally:
|
|
164
323
|
|
|
165
|
-
|
|
324
|
+
```bash
|
|
325
|
+
cd tech-core/sdks/runtime-sdk
|
|
326
|
+
npm run validate-config -- path/to/config.json
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
---
|
|
330
|
+
|
|
331
|
+
## Documentation
|
|
332
|
+
|
|
333
|
+
- **[APPS.md](./APPS.md)** - App architecture: how to build runtime extensions with actions, schemas, and editor modules
|
|
334
|
+
- **[CAPABILITIES.md](./CAPABILITIES.md)** - Complete reference for all actions, surfaces, and config options
|
|
335
|
+
- **[RUNTIME_V2_REFERENCE.md](./RUNTIME_V2_REFERENCE.md)** - Context, Events, State, Decisions modules
|
|
336
|
+
|
|
337
|
+
---
|
|
338
|
+
|
|
339
|
+
## Directory Overview
|
|
166
340
|
|
|
167
341
|
```
|
|
168
|
-
tech-core/sdks/
|
|
342
|
+
tech-core/sdks/runtime-sdk
|
|
169
343
|
├─ src
|
|
170
|
-
│ ├─
|
|
171
|
-
│ ├─
|
|
172
|
-
│ ├─
|
|
173
|
-
│ ├─
|
|
174
|
-
│
|
|
175
|
-
│
|
|
344
|
+
│ ├─ actions/ # ActionEngine (interventions)
|
|
345
|
+
│ │ ├─ types.ts
|
|
346
|
+
│ │ ├─ ActionEngine.ts
|
|
347
|
+
│ │ ├─ validation.ts
|
|
348
|
+
│ │ └─ executors/ # visual, dom, navigation executors
|
|
349
|
+
│ ├─ apps/ # App system (see APPS.md)
|
|
350
|
+
│ │ ├─ AppRegistry.ts # App registration and lifecycle
|
|
351
|
+
│ │ ├─ AppLoader.ts # Dynamic app loading
|
|
352
|
+
│ │ ├─ types.ts # AppManifest, AppContext types
|
|
353
|
+
│ │ └─ built-in/ # Core apps (bundled with runtime)
|
|
354
|
+
│ ├─ surfaces/ # Surfaces (UI rendering)
|
|
355
|
+
│ │ ├─ types.ts
|
|
356
|
+
│ │ ├─ Surfaces.ts
|
|
357
|
+
│ │ └─ positioning.ts
|
|
358
|
+
│ ├─ context/ # Page/session/viewport state
|
|
359
|
+
│ ├─ events/ # EventBus
|
|
360
|
+
│ ├─ state/ # StateStore
|
|
361
|
+
│ ├─ decisions/ # DecisionStrategy evaluation
|
|
362
|
+
│ ├─ runtime.ts # SmartCanvasRuntime factory
|
|
363
|
+
│ ├─ bootstrap.ts # Syntro.init()
|
|
364
|
+
│ ├─ SmartCanvasElement.tsx
|
|
365
|
+
│ ├─ SmartCanvasApp.tsx
|
|
366
|
+
│ └─ SmartCanvasPortal.tsx
|
|
367
|
+
├─ schema/
|
|
368
|
+
│ └─ canvas-config.schema.json
|
|
369
|
+
├─ APPS.md
|
|
370
|
+
├─ CAPABILITIES.md
|
|
371
|
+
├─ RUNTIME_V2_REFERENCE.md
|
|
176
372
|
└─ README.md
|
|
177
373
|
```
|
|
178
374
|
|
|
179
|
-
|
|
375
|
+
---
|
|
376
|
+
|
|
377
|
+
## Development Commands
|
|
378
|
+
|
|
379
|
+
```bash
|
|
380
|
+
# Build TypeScript library
|
|
381
|
+
npm run build:lib
|
|
382
|
+
|
|
383
|
+
# Build CDN bundle
|
|
384
|
+
npm run build:cdn
|
|
385
|
+
|
|
386
|
+
# Full build
|
|
387
|
+
npm run build
|
|
388
|
+
|
|
389
|
+
# Validate a config file
|
|
390
|
+
npm run validate-config -- path/to/config.json
|
|
391
|
+
|
|
392
|
+
# Type check
|
|
393
|
+
npx tsc --noEmit
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
---
|
|
397
|
+
|
|
398
|
+
## Testing
|
|
399
|
+
|
|
400
|
+
- Shadow root is **open**, so Playwright/Cypress can traverse via `.shadow()`
|
|
401
|
+
- Data hooks: `[data-shadow-canvas-id="overlay-launcher"]`, `[data-shadow-canvas-id="rectangle-${id}"]`
|
|
402
|
+
- `SmartCanvasController` exposes `open/close` for deterministic tests
|
|
403
|
+
|
|
404
|
+
---
|
|
405
|
+
|
|
406
|
+
## Analytics Events
|
|
407
|
+
|
|
408
|
+
The telemetry client emits:
|
|
409
|
+
|
|
410
|
+
| Event | Description |
|
|
411
|
+
| ----------------------------------------------- | --------------------------------------- |
|
|
412
|
+
| `shadow_canvas_opened` / `shadow_canvas_closed` | Toggle button interactions |
|
|
413
|
+
| `shadow_canvas_rectangle_viewed` | A rectangle becomes visible |
|
|
414
|
+
| `shadow_canvas_action` | CTA click, chatbot send, overlay events |
|
|
415
|
+
| `action.applied` / `action.reverted` | ActionEngine events |
|
|
416
|
+
| `surface.mounted` / `surface.unmounted` | Surfaces events |
|
|
417
|
+
|
|
418
|
+
---
|
|
419
|
+
|
|
420
|
+
## Quick Checklist
|
|
180
421
|
|
|
181
|
-
1. Call `registerSmartCanvasElement()` once per app
|
|
182
|
-
2. Render `<smart-canvas>` (custom element)
|
|
183
|
-
3. Portal your React tree into the element
|
|
184
|
-
4. Configure the SDK with your API credentials
|
|
185
|
-
5.
|
|
422
|
+
1. Call `registerSmartCanvasElement()` once per app
|
|
423
|
+
2. Render `<smart-canvas>` (custom element)
|
|
424
|
+
3. Portal your React tree into the element's shadow via `SmartCanvasPortal`
|
|
425
|
+
4. Configure the SDK with your API credentials
|
|
426
|
+
5. Use `runtime.actions` for interventions, `runtime.surfaces` for UI
|
|
427
|
+
6. For non-React pages, call `window.SmartCanvas.create()` with configuration
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RuntimeProvider - React context for accessing the v2 Runtime.
|
|
3
|
+
*
|
|
4
|
+
* Provides access to the SmartCanvasRuntime from any component in the tree.
|
|
5
|
+
*/
|
|
6
|
+
import { ReactNode } from 'react';
|
|
7
|
+
import type { SmartCanvasRuntime } from './runtime';
|
|
8
|
+
import type { RuntimeContext } from './context/types';
|
|
9
|
+
export interface RuntimeProviderProps {
|
|
10
|
+
/** The SmartCanvasRuntime instance */
|
|
11
|
+
runtime: SmartCanvasRuntime | null;
|
|
12
|
+
children: ReactNode;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Provider component for the SmartCanvasRuntime.
|
|
16
|
+
*/
|
|
17
|
+
export declare function RuntimeProvider({ runtime, children }: RuntimeProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
18
|
+
/**
|
|
19
|
+
* Hook to access the SmartCanvasRuntime.
|
|
20
|
+
*/
|
|
21
|
+
export declare function useRuntime(): SmartCanvasRuntime | null;
|
|
22
|
+
/**
|
|
23
|
+
* Hook to access the current runtime context (reactive).
|
|
24
|
+
*/
|
|
25
|
+
export declare function useRuntimeContext(): RuntimeContext | null;
|
|
26
|
+
/**
|
|
27
|
+
* Hook to access a specific part of the runtime context.
|
|
28
|
+
*/
|
|
29
|
+
export declare function usePageContext(): import("./context").PageContext | null;
|
|
30
|
+
export declare function useSessionContext(): import("./context").SessionContext | null;
|
|
31
|
+
export declare function useViewportContext(): import("./context").ViewportContext | null;
|
|
32
|
+
/**
|
|
33
|
+
* Hook to subscribe to runtime events.
|
|
34
|
+
*/
|
|
35
|
+
export declare function useRuntimeEvents(filter: {
|
|
36
|
+
names?: string[];
|
|
37
|
+
patterns?: string[];
|
|
38
|
+
sources?: Array<'posthog' | 'canvas' | 'derived'>;
|
|
39
|
+
} | undefined, callback: (event: import('./events/types').NormalizedEvent) => void, deps?: React.DependencyList): void;
|
|
40
|
+
/**
|
|
41
|
+
* Hook to access state helpers.
|
|
42
|
+
*/
|
|
43
|
+
export declare function useRuntimeState(): import("./state").StateStore | null;
|
|
44
|
+
/**
|
|
45
|
+
* Hook to evaluate a decision strategy.
|
|
46
|
+
*/
|
|
47
|
+
export declare function useDecision<T>(strategy: import('./decisions/types').DecisionStrategy<T> | undefined | null, defaultValue: T): {
|
|
48
|
+
value: T;
|
|
49
|
+
isFallback: boolean;
|
|
50
|
+
isLoading: boolean;
|
|
51
|
+
};
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* RuntimeProvider - React context for accessing the v2 Runtime.
|
|
4
|
+
*
|
|
5
|
+
* Provides access to the SmartCanvasRuntime from any component in the tree.
|
|
6
|
+
*/
|
|
7
|
+
import { createContext, useContext, useMemo, useEffect, useState } from 'react';
|
|
8
|
+
const RuntimeReactContext = createContext({
|
|
9
|
+
runtime: null,
|
|
10
|
+
context: null,
|
|
11
|
+
});
|
|
12
|
+
/**
|
|
13
|
+
* Provider component for the SmartCanvasRuntime.
|
|
14
|
+
*/
|
|
15
|
+
export function RuntimeProvider({ runtime, children }) {
|
|
16
|
+
// Subscribe to context changes and re-render when they occur
|
|
17
|
+
const [context, setContext] = useState(runtime ? runtime.context.get() : null);
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
if (!runtime)
|
|
20
|
+
return;
|
|
21
|
+
// Set initial context
|
|
22
|
+
setContext(runtime.context.get());
|
|
23
|
+
// Subscribe to changes
|
|
24
|
+
const unsubscribe = runtime.context.subscribe((ctx) => {
|
|
25
|
+
setContext(ctx);
|
|
26
|
+
});
|
|
27
|
+
return unsubscribe;
|
|
28
|
+
}, [runtime]);
|
|
29
|
+
const value = useMemo(() => ({ runtime, context }), [runtime, context]);
|
|
30
|
+
return _jsx(RuntimeReactContext.Provider, { value: value, children: children });
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Hook to access the SmartCanvasRuntime.
|
|
34
|
+
*/
|
|
35
|
+
export function useRuntime() {
|
|
36
|
+
const { runtime } = useContext(RuntimeReactContext);
|
|
37
|
+
return runtime;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Hook to access the current runtime context (reactive).
|
|
41
|
+
*/
|
|
42
|
+
export function useRuntimeContext() {
|
|
43
|
+
const { context } = useContext(RuntimeReactContext);
|
|
44
|
+
return context;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Hook to access a specific part of the runtime context.
|
|
48
|
+
*/
|
|
49
|
+
export function usePageContext() {
|
|
50
|
+
var _a;
|
|
51
|
+
const context = useRuntimeContext();
|
|
52
|
+
return (_a = context === null || context === void 0 ? void 0 : context.page) !== null && _a !== void 0 ? _a : null;
|
|
53
|
+
}
|
|
54
|
+
export function useSessionContext() {
|
|
55
|
+
var _a;
|
|
56
|
+
const context = useRuntimeContext();
|
|
57
|
+
return (_a = context === null || context === void 0 ? void 0 : context.session) !== null && _a !== void 0 ? _a : null;
|
|
58
|
+
}
|
|
59
|
+
export function useViewportContext() {
|
|
60
|
+
var _a;
|
|
61
|
+
const context = useRuntimeContext();
|
|
62
|
+
return (_a = context === null || context === void 0 ? void 0 : context.viewport) !== null && _a !== void 0 ? _a : null;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Hook to subscribe to runtime events.
|
|
66
|
+
*/
|
|
67
|
+
export function useRuntimeEvents(filter, callback, deps = []) {
|
|
68
|
+
const runtime = useRuntime();
|
|
69
|
+
useEffect(() => {
|
|
70
|
+
if (!runtime)
|
|
71
|
+
return;
|
|
72
|
+
const unsubscribe = filter
|
|
73
|
+
? runtime.events.subscribe(filter, callback)
|
|
74
|
+
: runtime.events.subscribe(callback);
|
|
75
|
+
return unsubscribe;
|
|
76
|
+
}, [runtime, ...deps]);
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Hook to access state helpers.
|
|
80
|
+
*/
|
|
81
|
+
export function useRuntimeState() {
|
|
82
|
+
var _a;
|
|
83
|
+
const runtime = useRuntime();
|
|
84
|
+
return (_a = runtime === null || runtime === void 0 ? void 0 : runtime.state) !== null && _a !== void 0 ? _a : null;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Hook to evaluate a decision strategy.
|
|
88
|
+
*/
|
|
89
|
+
export function useDecision(strategy, defaultValue) {
|
|
90
|
+
const runtime = useRuntime();
|
|
91
|
+
const [result, setResult] = useState({
|
|
92
|
+
value: defaultValue,
|
|
93
|
+
isFallback: true,
|
|
94
|
+
isLoading: true,
|
|
95
|
+
});
|
|
96
|
+
useEffect(() => {
|
|
97
|
+
if (!runtime || !strategy) {
|
|
98
|
+
setResult({ value: defaultValue, isFallback: true, isLoading: false });
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
let cancelled = false;
|
|
102
|
+
runtime.evaluate(strategy).then((res) => {
|
|
103
|
+
if (!cancelled) {
|
|
104
|
+
setResult({ value: res.value, isFallback: res.isFallback, isLoading: false });
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
return () => {
|
|
108
|
+
cancelled = true;
|
|
109
|
+
};
|
|
110
|
+
}, [runtime, strategy, defaultValue]);
|
|
111
|
+
return result;
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=RuntimeProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RuntimeProvider.js","sourceRoot":"","sources":["../src/RuntimeProvider.tsx"],"names":[],"mappings":"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"}
|
package/dist/SmartCanvasApp.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { ReactNode } from
|
|
2
|
-
import { SmartCanvasController } from
|
|
3
|
-
import type { CanvasConfigFetcher } from
|
|
4
|
-
import type { ExperimentClient } from
|
|
5
|
-
import type { TelemetryClient } from
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { SmartCanvasController } from './controller';
|
|
3
|
+
import type { CanvasConfigFetcher } from './types';
|
|
4
|
+
import type { ExperimentClient } from './experiments/types';
|
|
5
|
+
import type { TelemetryClient } from './telemetry/types';
|
|
6
|
+
import { MountableComponent } from './api';
|
|
7
|
+
import { CanvasTheme } from './components/ShadowCanvasOverlay';
|
|
8
|
+
import type { SmartCanvasRuntime } from './runtime';
|
|
9
9
|
export interface SmartCanvasAppProps {
|
|
10
10
|
controller: SmartCanvasController;
|
|
11
11
|
fetcher?: CanvasConfigFetcher;
|
|
@@ -16,9 +16,15 @@ export interface SmartCanvasAppProps {
|
|
|
16
16
|
pollIntervalMs?: number;
|
|
17
17
|
experiments?: ExperimentClient;
|
|
18
18
|
telemetry?: TelemetryClient;
|
|
19
|
-
|
|
19
|
+
/** v2 Runtime instance for context, events, state, and decisions */
|
|
20
|
+
runtime?: SmartCanvasRuntime;
|
|
21
|
+
/** @deprecated Actions replace overlay recipes. Use config.actions instead. */
|
|
22
|
+
overlayFetcher?: () => Promise<unknown>;
|
|
23
|
+
/** @deprecated Actions replace overlay recipes. Use config.actions instead. */
|
|
20
24
|
overlayConfigUri?: string;
|
|
25
|
+
/** @deprecated Actions replace overlay recipes. Use config.actions instead. */
|
|
21
26
|
overlayConfigFeatureKey?: string;
|
|
27
|
+
/** @deprecated Actions replace overlay recipes. Use config.actions instead. */
|
|
22
28
|
overlayFetchCredentials?: RequestCredentials;
|
|
23
29
|
footerSlot?: ReactNode;
|
|
24
30
|
launcherLabel?: string;
|
|
@@ -26,4 +32,4 @@ export interface SmartCanvasAppProps {
|
|
|
26
32
|
customRenderers?: Record<string, MountableComponent>;
|
|
27
33
|
theme?: Partial<CanvasTheme>;
|
|
28
34
|
}
|
|
29
|
-
export declare function SmartCanvasApp({ controller, fetcher, configUri, configUriFeatureKey, configFeatureKey, fetchCredentials, pollIntervalMs, experiments, telemetry, overlayFetcher, overlayConfigUri, overlayConfigFeatureKey, overlayFetchCredentials, footerSlot, launcherLabel, canvasHost, customRenderers, theme, }: SmartCanvasAppProps): import("react/jsx-runtime").JSX.Element
|
|
35
|
+
export declare function SmartCanvasApp({ controller, fetcher, configUri, configUriFeatureKey, configFeatureKey, fetchCredentials, pollIntervalMs, experiments, telemetry, runtime, overlayFetcher, overlayConfigUri, overlayConfigFeatureKey, overlayFetchCredentials, footerSlot, launcherLabel, canvasHost, customRenderers, theme, }: SmartCanvasAppProps): import("react/jsx-runtime").JSX.Element;
|