@syntrologie/runtime-sdk 0.2.21 → 1.0.0
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 +944 -440
- package/README.md +395 -66
- 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 +47 -51
- 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/SmartCanvasPortal.js.map +1 -1
- package/dist/actions/ActionEngine.d.ts +11 -0
- package/dist/actions/ActionEngine.js +272 -0
- package/dist/actions/ActionEngine.js.map +1 -0
- package/dist/actions/executors/index.d.ts +116 -0
- package/dist/actions/executors/index.js +240 -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 +577 -0
- package/dist/actions/validation.js.map +1 -0
- package/dist/adaptives/adaptive-chatbot/index.js +9 -0
- package/dist/adaptives/adaptive-chatbot/index.js.map +7 -0
- package/dist/adaptives/adaptive-content/index.js +2 -0
- package/dist/adaptives/adaptive-content/index.js.map +7 -0
- package/dist/adaptives/adaptive-faq/index.js +11 -0
- package/dist/adaptives/adaptive-faq/index.js.map +7 -0
- package/dist/adaptives/adaptive-gamification/index.js +2 -0
- package/dist/adaptives/adaptive-gamification/index.js.map +7 -0
- package/dist/adaptives/adaptive-nav/index.js +11 -0
- package/dist/adaptives/adaptive-nav/index.js.map +7 -0
- package/dist/adaptives/adaptive-overlays/index.js +91 -0
- package/dist/adaptives/adaptive-overlays/index.js.map +7 -0
- package/dist/antiFlicker.js +1 -1
- package/dist/api.d.ts +40 -26
- package/dist/api.js +87 -60
- package/dist/api.js.map +1 -1
- package/dist/apps/AppContext.d.ts +31 -0
- package/dist/apps/AppContext.js +91 -0
- package/dist/apps/AppContext.js.map +1 -0
- package/dist/apps/AppLoader.d.ts +85 -0
- package/dist/apps/AppLoader.js +282 -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/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/index.d.ts +14 -0
- package/dist/apps/index.js +16 -0
- package/dist/apps/index.js.map +1 -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 +42 -44
- 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 -30
- 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 +73 -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 +68 -64
- 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 +218 -102
- package/dist/bootstrap.js.map +1 -1
- package/dist/components/ShadowCanvasOverlay.d.ts +6 -6
- package/dist/components/ShadowCanvasOverlay.js +156 -118
- package/dist/components/ShadowCanvasOverlay.js.map +1 -1
- package/dist/components/TileCard.d.ts +5 -5
- package/dist/components/TileCard.js +205 -154
- package/dist/components/TileCard.js.map +1 -1
- package/dist/components/TileWheel.d.ts +3 -3
- package/dist/components/TileWheel.js +29 -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 +7 -3
- package/dist/configFetcher.js +70 -29
- package/dist/configFetcher.js.map +1 -1
- package/dist/context/ContextManager.d.ts +3 -3
- package/dist/context/ContextManager.js +19 -18
- 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 +9 -9
- package/dist/context/schema.js +2 -2
- package/dist/context/schema.js.map +1 -1
- package/dist/decisions/engine.d.ts +5 -5
- package/dist/decisions/engine.js +13 -13
- package/dist/decisions/engine.js.map +1 -1
- package/dist/decisions/index.d.ts +6 -6
- package/dist/decisions/index.js +5 -5
- package/dist/decisions/schema.d.ts +131 -131
- package/dist/decisions/schema.js +21 -21
- package/dist/decisions/schema.js.map +1 -1
- 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 +19 -7
- package/dist/editorLoader.js +154 -97
- 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 +3 -3
- package/dist/events/schema.js.map +1 -1
- 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 +5 -4
- package/dist/experiments/adapters/growthbook.js +14 -6
- 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 +10 -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 +25 -3
- package/dist/fetchers/experimentsFetcher.js +55 -8
- 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/mergeConfigs.d.ts +29 -0
- package/dist/fetchers/mergeConfigs.js +38 -0
- package/dist/fetchers/mergeConfigs.js.map +1 -0
- 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 +51 -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 +13 -15
- package/dist/overlays/fetcher.js.map +1 -1
- 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 +88 -28
- 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 +13 -15
- 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 +109 -13
- package/dist/runtime.js.map +1 -1
- package/dist/smart-canvas.esm.js +144 -55
- package/dist/smart-canvas.esm.js.map +4 -4
- package/dist/smart-canvas.js +14688 -11455
- package/dist/smart-canvas.js.map +4 -4
- package/dist/smart-canvas.min.js +145 -55
- package/dist/smart-canvas.min.js.map +4 -4
- package/dist/state/StateStore.d.ts +1 -7
- package/dist/state/StateStore.js +15 -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 -9
- 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 +4 -5
- package/dist/theme/defaultTheme.js +127 -118
- package/dist/theme/defaultTheme.js.map +1 -1
- package/dist/theme/extractHostTheme.d.ts +1 -1
- package/dist/theme/extractHostTheme.js +43 -45
- 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 +14 -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 +145 -0
- package/dist/widgets/WidgetRegistry.js +191 -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 +35 -15
- 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
|
|
127
|
+
|
|
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
|
+
---
|
|
52
178
|
|
|
53
|
-
|
|
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,286 @@ 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
|
+
```
|
|
261
|
+
|
|
262
|
+
---
|
|
263
|
+
|
|
264
|
+
## State Management
|
|
265
|
+
|
|
266
|
+
```typescript
|
|
267
|
+
// Dismissals
|
|
268
|
+
runtime.state.dismissals.mark("promo-banner");
|
|
269
|
+
if (runtime.state.dismissals.isDismissed("promo-banner")) { ... }
|
|
270
|
+
|
|
271
|
+
// Cooldowns
|
|
272
|
+
runtime.state.cooldowns.set("upsell", 86400000); // 24h
|
|
273
|
+
if (runtime.state.cooldowns.isActive("upsell")) { ... }
|
|
274
|
+
|
|
275
|
+
// Frequency caps
|
|
276
|
+
runtime.state.frequency.increment("tooltip-shown");
|
|
277
|
+
if (runtime.state.frequency.count("tooltip-shown") >= 3) { ... }
|
|
278
|
+
```
|
|
279
|
+
|
|
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
|
+
});
|
|
301
|
+
|
|
302
|
+
if (result.value) {
|
|
303
|
+
// Apply adaptive
|
|
304
|
+
}
|
|
305
|
+
```
|
|
121
306
|
|
|
122
|
-
|
|
307
|
+
---
|
|
123
308
|
|
|
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). |
|
|
309
|
+
## Styling & Overlays
|
|
129
310
|
|
|
130
|
-
|
|
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`
|
|
131
316
|
|
|
132
|
-
|
|
317
|
+
---
|
|
133
318
|
|
|
134
|
-
|
|
319
|
+
## Schema & Validation
|
|
135
320
|
|
|
136
|
-
- JSON schema lives at `schema/canvas-config.schema.json`
|
|
321
|
+
- JSON schema lives at `schema/canvas-config.schema.json`
|
|
137
322
|
- Validate a config file locally:
|
|
138
323
|
|
|
139
324
|
```bash
|
|
140
|
-
cd tech-core/sdks/
|
|
141
|
-
npm run validate-config --
|
|
325
|
+
cd tech-core/sdks/runtime-sdk
|
|
326
|
+
npm run validate-config -- path/to/config.json
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
---
|
|
330
|
+
|
|
331
|
+
## Releasing
|
|
332
|
+
|
|
333
|
+
The SDK uses [semantic-release](https://github.com/semantic-release/semantic-release) with conventional commits. Versions are never bumped manually.
|
|
334
|
+
|
|
335
|
+
### Channels
|
|
336
|
+
|
|
337
|
+
| Channel | Trigger | npm dist-tag | CDN path |
|
|
338
|
+
| ---------- | ---------------------------------------------- | ------------ | ----------------------------- |
|
|
339
|
+
| **Canary** | Push to `develop` touching `tech-core/sdks/**` | `develop` | `/v2/canary/` |
|
|
340
|
+
| **Stable** | Manual workflow dispatch from `main` | `latest` | `/v2/latest/` + `/{VERSION}/` |
|
|
341
|
+
|
|
342
|
+
### Commit Messages → Version Bumps
|
|
343
|
+
|
|
344
|
+
| Prefix | Bump | Example |
|
|
345
|
+
| ----------------- | --------------------- | ---------------- |
|
|
346
|
+
| `fix(sdk): ...` | Patch (2.0.0 → 2.0.1) | Bug fixes |
|
|
347
|
+
| `feat(sdk): ...` | Minor (2.0.0 → 2.1.0) | New features |
|
|
348
|
+
| `feat(sdk)!: ...` | Major (2.0.0 → 3.0.0) | Breaking changes |
|
|
349
|
+
|
|
350
|
+
Commits with `chore`, `docs`, `ci`, or `refactor` prefixes (without `!`) do not trigger a release.
|
|
351
|
+
|
|
352
|
+
### What the Pipeline Does
|
|
353
|
+
|
|
354
|
+
1. Builds all adaptives + runtime-sdk (lint, format check, tests)
|
|
355
|
+
2. Analyzes commits since last tag → determines version
|
|
356
|
+
3. Syncs version to all adaptive `package.json` files + `SDK_VERSION` constant
|
|
357
|
+
4. Publishes `runtime-sdk` to npm via OIDC trusted publishing
|
|
358
|
+
5. Publishes all `adapt-*` packages to npm via OIDC
|
|
359
|
+
6. Deploys CDN bundles to Cloudflare R2
|
|
360
|
+
7. Creates GitHub release with changelog
|
|
361
|
+
|
|
362
|
+
### npm Auth — OIDC Trusted Publishing
|
|
363
|
+
|
|
364
|
+
No npm tokens are needed. GitHub Actions exchanges a short-lived OIDC token with npm for auth. Each `@syntrologie/*` package has a trusted publisher configured on [npmjs.com](https://www.npmjs.com) pointing to:
|
|
365
|
+
|
|
366
|
+
- **Org:** `SyntropyForge`
|
|
367
|
+
- **Repo:** `amazing-demos`
|
|
368
|
+
- **Workflow:** `sdk-release.yaml`
|
|
369
|
+
|
|
370
|
+
When adding a new package, you must configure its trusted publisher on npmjs.com before the pipeline can publish it. The first publish of a new package requires a manual `npm publish` with a token (OIDC requires the package to already exist).
|
|
371
|
+
|
|
372
|
+
### Published Packages
|
|
373
|
+
|
|
374
|
+
| Package | Description |
|
|
375
|
+
| --------------------------------- | --------------------------------------------- |
|
|
376
|
+
| `@syntrologie/runtime-sdk` | Core runtime |
|
|
377
|
+
| `@syntrologie/adapt-content` | Text, attributes, styles, HTML insertion |
|
|
378
|
+
| `@syntrologie/adapt-overlays` | Highlights, tooltips, badges, pulse, modals |
|
|
379
|
+
| `@syntrologie/adapt-nav` | Navigation widget + scrollTo/navigate actions |
|
|
380
|
+
| `@syntrologie/adapt-gamification` | Badges, points, leaderboards |
|
|
381
|
+
| `@syntrologie/adapt-faq` | FAQ accordion widget |
|
|
382
|
+
| `@syntrologie/adapt-chatbot` | Chatbot widget |
|
|
383
|
+
|
|
384
|
+
### CDN URLs
|
|
385
|
+
|
|
386
|
+
```
|
|
387
|
+
# Stable (latest)
|
|
388
|
+
https://cdn.syntrologie.com/runtime-sdk/v2/latest/smart-canvas.min.js
|
|
389
|
+
|
|
390
|
+
# Canary (develop)
|
|
391
|
+
https://cdn.syntrologie.com/runtime-sdk/v2/canary/smart-canvas.min.js
|
|
392
|
+
|
|
393
|
+
# Pinned version
|
|
394
|
+
https://cdn.syntrologie.com/runtime-sdk/{VERSION}/smart-canvas.min.js
|
|
395
|
+
|
|
396
|
+
# Lazy adaptive bundles
|
|
397
|
+
https://cdn.syntrologie.com/runtime-sdk/v2/latest/adaptives/{appId}/index.js
|
|
142
398
|
```
|
|
143
399
|
|
|
144
|
-
|
|
400
|
+
### Required GitHub Secrets
|
|
401
|
+
|
|
402
|
+
| Secret | Purpose |
|
|
403
|
+
| ---------------------- | ------------------------ |
|
|
404
|
+
| `R2_ACCESS_KEY_ID` | Cloudflare R2 CDN deploy |
|
|
405
|
+
| `R2_SECRET_ACCESS_KEY` | Cloudflare R2 CDN deploy |
|
|
406
|
+
| `R2_ENDPOINT` | Cloudflare R2 endpoint |
|
|
145
407
|
|
|
146
|
-
|
|
408
|
+
`GITHUB_TOKEN` is auto-provided. npm auth is OIDC — no `NPM_TOKEN` needed.
|
|
147
409
|
|
|
148
|
-
|
|
149
|
-
- Provide a recipe URI via `overlayConfigUri` or let GrowthBook supply `smart-canvas-overlay-uri`.
|
|
150
|
-
- Overlays render in `#syntro-overlays` (fixed, pointer-events: none) and use Floating UI for tethering.
|
|
151
|
-
- The Canvas runtime dynamically imports the overlay chunk only when a recipe resolves.
|
|
152
|
-
- Exposed helpers:
|
|
153
|
-
- `createOverlayRecipeFetcher`, `resolveConfigUri`
|
|
154
|
-
- `runOverlays`, `showTooltip`, `showHighlight`
|
|
155
|
-
- `createAnchorResolver` (works for main DOM + shadow DOM)
|
|
410
|
+
### Troubleshooting
|
|
156
411
|
|
|
157
|
-
|
|
412
|
+
- **"No new version is released"** — 0 relevant commits since last tag. Push a `fix:` or `feat:` commit touching SDK paths.
|
|
413
|
+
- **npm 404 / auth error** — package missing trusted publisher config on npmjs.com.
|
|
414
|
+
- **Format check fails** — run `npx prettier --write <file>` locally before pushing.
|
|
158
415
|
|
|
159
|
-
|
|
416
|
+
---
|
|
160
417
|
|
|
161
|
-
|
|
162
|
-
- Data hooks: `[data-shadow-canvas-id="overlay-launcher"]`, `[data-shadow-canvas-id="rectangle-${id}"]`, etc.
|
|
163
|
-
- `SmartCanvasController` exposes `open/close` for deterministic tests.
|
|
418
|
+
## Documentation
|
|
164
419
|
|
|
165
|
-
|
|
420
|
+
- **[APPS.md](./APPS.md)** - App architecture: how to build runtime extensions with actions, schemas, and editor modules
|
|
421
|
+
- **[CAPABILITIES.md](./CAPABILITIES.md)** - Complete reference for all actions, surfaces, and config options
|
|
422
|
+
- **[RUNTIME_V2_REFERENCE.md](./RUNTIME_V2_REFERENCE.md)** - Context, Events, State, Decisions modules
|
|
423
|
+
|
|
424
|
+
---
|
|
425
|
+
|
|
426
|
+
## Directory Overview
|
|
166
427
|
|
|
167
428
|
```
|
|
168
|
-
tech-core/sdks/
|
|
429
|
+
tech-core/sdks/runtime-sdk
|
|
169
430
|
├─ src
|
|
170
|
-
│ ├─
|
|
171
|
-
│ ├─
|
|
172
|
-
│ ├─
|
|
173
|
-
│ ├─
|
|
174
|
-
│
|
|
175
|
-
│
|
|
431
|
+
│ ├─ actions/ # ActionEngine (interventions)
|
|
432
|
+
│ │ ├─ types.ts
|
|
433
|
+
│ │ ├─ ActionEngine.ts
|
|
434
|
+
│ │ ├─ validation.ts
|
|
435
|
+
│ │ └─ executors/ # visual, dom, navigation executors
|
|
436
|
+
│ ├─ apps/ # App system (see APPS.md)
|
|
437
|
+
│ │ ├─ AppRegistry.ts # App registration and lifecycle
|
|
438
|
+
│ │ ├─ AppLoader.ts # Dynamic app loading
|
|
439
|
+
│ │ ├─ types.ts # AppManifest, AppContext types
|
|
440
|
+
│ │ └─ built-in/ # Core apps (bundled with runtime)
|
|
441
|
+
│ ├─ surfaces/ # Surfaces (UI rendering)
|
|
442
|
+
│ │ ├─ types.ts
|
|
443
|
+
│ │ ├─ Surfaces.ts
|
|
444
|
+
│ │ └─ positioning.ts
|
|
445
|
+
│ ├─ context/ # Page/session/viewport state
|
|
446
|
+
│ ├─ events/ # EventBus
|
|
447
|
+
│ ├─ state/ # StateStore
|
|
448
|
+
│ ├─ decisions/ # DecisionStrategy evaluation
|
|
449
|
+
│ ├─ runtime.ts # SmartCanvasRuntime factory
|
|
450
|
+
│ ├─ bootstrap.ts # Syntro.init()
|
|
451
|
+
│ ├─ SmartCanvasElement.tsx
|
|
452
|
+
│ ├─ SmartCanvasApp.tsx
|
|
453
|
+
│ └─ SmartCanvasPortal.tsx
|
|
454
|
+
├─ schema/
|
|
455
|
+
│ └─ canvas-config.schema.json
|
|
456
|
+
├─ APPS.md
|
|
457
|
+
├─ CAPABILITIES.md
|
|
458
|
+
├─ RUNTIME_V2_REFERENCE.md
|
|
176
459
|
└─ README.md
|
|
177
460
|
```
|
|
178
461
|
|
|
179
|
-
|
|
462
|
+
---
|
|
463
|
+
|
|
464
|
+
## Development Commands
|
|
465
|
+
|
|
466
|
+
```bash
|
|
467
|
+
# Build TypeScript library
|
|
468
|
+
npm run build:lib
|
|
469
|
+
|
|
470
|
+
# Build CDN bundle
|
|
471
|
+
npm run build:cdn
|
|
472
|
+
|
|
473
|
+
# Full build
|
|
474
|
+
npm run build
|
|
475
|
+
|
|
476
|
+
# Validate a config file
|
|
477
|
+
npm run validate-config -- path/to/config.json
|
|
478
|
+
|
|
479
|
+
# Type check
|
|
480
|
+
npx tsc --noEmit
|
|
481
|
+
```
|
|
482
|
+
|
|
483
|
+
---
|
|
484
|
+
|
|
485
|
+
## Testing
|
|
486
|
+
|
|
487
|
+
- Shadow root is **open**, so Playwright/Cypress can traverse via `.shadow()`
|
|
488
|
+
- Data hooks: `[data-shadow-canvas-id="overlay-launcher"]`, `[data-shadow-canvas-id="rectangle-${id}"]`
|
|
489
|
+
- `SmartCanvasController` exposes `open/close` for deterministic tests
|
|
490
|
+
|
|
491
|
+
---
|
|
492
|
+
|
|
493
|
+
## Analytics Events
|
|
494
|
+
|
|
495
|
+
The telemetry client emits:
|
|
496
|
+
|
|
497
|
+
| Event | Description |
|
|
498
|
+
| ----------------------------------------------- | --------------------------------------- |
|
|
499
|
+
| `shadow_canvas_opened` / `shadow_canvas_closed` | Toggle button interactions |
|
|
500
|
+
| `shadow_canvas_rectangle_viewed` | A rectangle becomes visible |
|
|
501
|
+
| `shadow_canvas_action` | CTA click, chatbot send, overlay events |
|
|
502
|
+
| `action.applied` / `action.reverted` | ActionEngine events |
|
|
503
|
+
| `surface.mounted` / `surface.unmounted` | Surfaces events |
|
|
504
|
+
|
|
505
|
+
---
|
|
506
|
+
|
|
507
|
+
## Quick Checklist
|
|
180
508
|
|
|
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.
|
|
509
|
+
1. Call `registerSmartCanvasElement()` once per app
|
|
510
|
+
2. Render `<smart-canvas>` (custom element)
|
|
511
|
+
3. Portal your React tree into the element's shadow via `SmartCanvasPortal`
|
|
512
|
+
4. Configure the SDK with your API credentials
|
|
513
|
+
5. Use `runtime.actions` for interventions, `runtime.surfaces` for UI
|
|
514
|
+
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 { RuntimeContext } from './context/types';
|
|
8
|
+
import type { SmartCanvasRuntime } from './runtime';
|
|
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
|
+
};
|