@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.
Files changed (324) hide show
  1. package/CAPABILITIES.md +944 -440
  2. package/README.md +395 -66
  3. package/dist/RuntimeProvider.d.ts +51 -0
  4. package/dist/RuntimeProvider.js +113 -0
  5. package/dist/RuntimeProvider.js.map +1 -0
  6. package/dist/SmartCanvasApp.d.ts +16 -10
  7. package/dist/SmartCanvasApp.js +47 -51
  8. package/dist/SmartCanvasApp.js.map +1 -1
  9. package/dist/SmartCanvasElement.d.ts +5 -5
  10. package/dist/SmartCanvasElement.js +24 -14
  11. package/dist/SmartCanvasElement.js.map +1 -1
  12. package/dist/SmartCanvasPortal.d.ts +2 -2
  13. package/dist/SmartCanvasPortal.js +2 -2
  14. package/dist/SmartCanvasPortal.js.map +1 -1
  15. package/dist/actions/ActionEngine.d.ts +11 -0
  16. package/dist/actions/ActionEngine.js +272 -0
  17. package/dist/actions/ActionEngine.js.map +1 -0
  18. package/dist/actions/executors/index.d.ts +116 -0
  19. package/dist/actions/executors/index.js +240 -0
  20. package/dist/actions/executors/index.js.map +1 -0
  21. package/dist/actions/executors/tour.d.ts +18 -0
  22. package/dist/actions/executors/tour.js +332 -0
  23. package/dist/actions/executors/tour.js.map +1 -0
  24. package/dist/actions/index.d.ts +10 -0
  25. package/dist/actions/index.js +12 -0
  26. package/dist/actions/index.js.map +1 -0
  27. package/dist/actions/types.d.ts +399 -0
  28. package/dist/actions/types.js +8 -0
  29. package/dist/actions/types.js.map +1 -0
  30. package/dist/actions/validation.d.ts +14 -0
  31. package/dist/actions/validation.js +577 -0
  32. package/dist/actions/validation.js.map +1 -0
  33. package/dist/adaptives/adaptive-chatbot/index.js +9 -0
  34. package/dist/adaptives/adaptive-chatbot/index.js.map +7 -0
  35. package/dist/adaptives/adaptive-content/index.js +2 -0
  36. package/dist/adaptives/adaptive-content/index.js.map +7 -0
  37. package/dist/adaptives/adaptive-faq/index.js +11 -0
  38. package/dist/adaptives/adaptive-faq/index.js.map +7 -0
  39. package/dist/adaptives/adaptive-gamification/index.js +2 -0
  40. package/dist/adaptives/adaptive-gamification/index.js.map +7 -0
  41. package/dist/adaptives/adaptive-nav/index.js +11 -0
  42. package/dist/adaptives/adaptive-nav/index.js.map +7 -0
  43. package/dist/adaptives/adaptive-overlays/index.js +91 -0
  44. package/dist/adaptives/adaptive-overlays/index.js.map +7 -0
  45. package/dist/antiFlicker.js +1 -1
  46. package/dist/api.d.ts +40 -26
  47. package/dist/api.js +87 -60
  48. package/dist/api.js.map +1 -1
  49. package/dist/apps/AppContext.d.ts +31 -0
  50. package/dist/apps/AppContext.js +91 -0
  51. package/dist/apps/AppContext.js.map +1 -0
  52. package/dist/apps/AppLoader.d.ts +85 -0
  53. package/dist/apps/AppLoader.js +282 -0
  54. package/dist/apps/AppLoader.js.map +1 -0
  55. package/dist/apps/AppRegistry.d.ts +102 -0
  56. package/dist/apps/AppRegistry.js +317 -0
  57. package/dist/apps/AppRegistry.js.map +1 -0
  58. package/dist/apps/examples/gamification-app.example.d.ts +305 -0
  59. package/dist/apps/examples/gamification-app.example.js +329 -0
  60. package/dist/apps/examples/gamification-app.example.js.map +1 -0
  61. package/dist/apps/index.d.ts +14 -0
  62. package/dist/apps/index.js +16 -0
  63. package/dist/apps/index.js.map +1 -0
  64. package/dist/apps/types.d.ts +231 -0
  65. package/dist/apps/types.js +8 -0
  66. package/dist/apps/types.js.map +1 -0
  67. package/dist/blocks/data/ComparisonBlock.d.ts +1 -1
  68. package/dist/blocks/data/ComparisonBlock.js +40 -40
  69. package/dist/blocks/data/ComparisonBlock.js.map +1 -1
  70. package/dist/blocks/data/StatsBlock.d.ts +1 -1
  71. package/dist/blocks/data/StatsBlock.js +42 -44
  72. package/dist/blocks/data/StatsBlock.js.map +1 -1
  73. package/dist/blocks/data/index.d.ts +2 -2
  74. package/dist/blocks/data/index.js +2 -2
  75. package/dist/blocks/index.d.ts +5 -5
  76. package/dist/blocks/index.js +29 -30
  77. package/dist/blocks/index.js.map +1 -1
  78. package/dist/blocks/interactive/ChecklistBlock.d.ts +1 -1
  79. package/dist/blocks/interactive/ChecklistBlock.js +60 -60
  80. package/dist/blocks/interactive/ChecklistBlock.js.map +1 -1
  81. package/dist/blocks/interactive/RatingBlock.d.ts +1 -1
  82. package/dist/blocks/interactive/RatingBlock.js +73 -65
  83. package/dist/blocks/interactive/RatingBlock.js.map +1 -1
  84. package/dist/blocks/interactive/index.d.ts +2 -2
  85. package/dist/blocks/interactive/index.js +2 -2
  86. package/dist/blocks/notification/NotificationBlock.d.ts +2 -2
  87. package/dist/blocks/notification/NotificationBlock.js +68 -64
  88. package/dist/blocks/notification/NotificationBlock.js.map +1 -1
  89. package/dist/blocks/notification/index.d.ts +1 -1
  90. package/dist/blocks/notification/index.js +1 -1
  91. package/dist/bootstrap.d.ts +32 -8
  92. package/dist/bootstrap.js +218 -102
  93. package/dist/bootstrap.js.map +1 -1
  94. package/dist/components/ShadowCanvasOverlay.d.ts +6 -6
  95. package/dist/components/ShadowCanvasOverlay.js +156 -118
  96. package/dist/components/ShadowCanvasOverlay.js.map +1 -1
  97. package/dist/components/TileCard.d.ts +5 -5
  98. package/dist/components/TileCard.js +205 -154
  99. package/dist/components/TileCard.js.map +1 -1
  100. package/dist/components/TileWheel.d.ts +3 -3
  101. package/dist/components/TileWheel.js +29 -7
  102. package/dist/components/TileWheel.js.map +1 -1
  103. package/dist/config-validator.d.ts +49 -0
  104. package/dist/config-validator.js +173 -0
  105. package/dist/config-validator.js.map +1 -0
  106. package/dist/configFetcher.d.ts +7 -3
  107. package/dist/configFetcher.js +70 -29
  108. package/dist/configFetcher.js.map +1 -1
  109. package/dist/context/ContextManager.d.ts +3 -3
  110. package/dist/context/ContextManager.js +19 -18
  111. package/dist/context/ContextManager.js.map +1 -1
  112. package/dist/context/index.d.ts +4 -4
  113. package/dist/context/index.js +3 -3
  114. package/dist/context/schema.d.ts +9 -9
  115. package/dist/context/schema.js +2 -2
  116. package/dist/context/schema.js.map +1 -1
  117. package/dist/decisions/engine.d.ts +5 -5
  118. package/dist/decisions/engine.js +13 -13
  119. package/dist/decisions/engine.js.map +1 -1
  120. package/dist/decisions/index.d.ts +6 -6
  121. package/dist/decisions/index.js +5 -5
  122. package/dist/decisions/schema.d.ts +131 -131
  123. package/dist/decisions/schema.js +21 -21
  124. package/dist/decisions/schema.js.map +1 -1
  125. package/dist/decisions/strategies/rules.d.ts +1 -1
  126. package/dist/decisions/strategies/rules.js +24 -24
  127. package/dist/decisions/strategies/rules.js.map +1 -1
  128. package/dist/decisions/strategies/score.d.ts +1 -1
  129. package/dist/decisions/strategies/score.js +3 -3
  130. package/dist/decisions/types.d.ts +19 -19
  131. package/dist/earlyPatcher.d.ts +8 -20
  132. package/dist/earlyPatcher.js +13 -62
  133. package/dist/earlyPatcher.js.map +1 -1
  134. package/dist/editorLoader.d.ts +19 -7
  135. package/dist/editorLoader.js +154 -97
  136. package/dist/editorLoader.js.map +1 -1
  137. package/dist/events/EventBus.d.ts +3 -3
  138. package/dist/events/EventBus.js +5 -7
  139. package/dist/events/EventBus.js.map +1 -1
  140. package/dist/events/index.d.ts +6 -6
  141. package/dist/events/index.js +5 -5
  142. package/dist/events/normalizers/canvas.d.ts +2 -2
  143. package/dist/events/normalizers/canvas.js +3 -3
  144. package/dist/events/normalizers/canvas.js.map +1 -1
  145. package/dist/events/normalizers/posthog.d.ts +25 -1
  146. package/dist/events/normalizers/posthog.js +35 -27
  147. package/dist/events/normalizers/posthog.js.map +1 -1
  148. package/dist/events/schema.d.ts +13 -13
  149. package/dist/events/schema.js +3 -3
  150. package/dist/events/schema.js.map +1 -1
  151. package/dist/events/types.d.ts +7 -1
  152. package/dist/events/types.js +29 -21
  153. package/dist/events/types.js.map +1 -1
  154. package/dist/experiments/adapters/growthbook.d.ts +5 -4
  155. package/dist/experiments/adapters/growthbook.js +14 -6
  156. package/dist/experiments/adapters/growthbook.js.map +1 -1
  157. package/dist/experiments/index.d.ts +3 -3
  158. package/dist/experiments/index.js +1 -1
  159. package/dist/experiments/registry.d.ts +2 -2
  160. package/dist/experiments/registry.js +2 -2
  161. package/dist/experiments/types.d.ts +10 -1
  162. package/dist/fetchers/cdnFetcher.d.ts +1 -1
  163. package/dist/fetchers/cdnFetcher.js +4 -8
  164. package/dist/fetchers/cdnFetcher.js.map +1 -1
  165. package/dist/fetchers/experimentsFetcher.d.ts +25 -3
  166. package/dist/fetchers/experimentsFetcher.js +55 -8
  167. package/dist/fetchers/experimentsFetcher.js.map +1 -1
  168. package/dist/fetchers/index.d.ts +3 -3
  169. package/dist/fetchers/index.js +2 -2
  170. package/dist/fetchers/index.js.map +1 -1
  171. package/dist/fetchers/mergeConfigs.d.ts +29 -0
  172. package/dist/fetchers/mergeConfigs.js +38 -0
  173. package/dist/fetchers/mergeConfigs.js.map +1 -0
  174. package/dist/fetchers/registry.d.ts +1 -1
  175. package/dist/fetchers/registry.js +4 -4
  176. package/dist/fetchers/types.d.ts +1 -1
  177. package/dist/hooks/useCanvasOverlays.d.ts +8 -5
  178. package/dist/hooks/useCanvasOverlays.js +66 -17
  179. package/dist/hooks/useCanvasOverlays.js.map +1 -1
  180. package/dist/hooks/useHostPatches.d.ts +2 -2
  181. package/dist/hooks/useHostPatches.js +8 -8
  182. package/dist/hooks/useHostPatches.js.map +1 -1
  183. package/dist/hooks/useShadowCanvasConfig.d.ts +5 -9
  184. package/dist/hooks/useShadowCanvasConfig.js +7 -5
  185. package/dist/hooks/useShadowCanvasConfig.js.map +1 -1
  186. package/dist/hostPatcher/core/patcher.d.ts +1 -1
  187. package/dist/hostPatcher/core/patcher.js +18 -9
  188. package/dist/hostPatcher/core/patcher.js.map +1 -1
  189. package/dist/hostPatcher/core/sanitizer.js +24 -3
  190. package/dist/hostPatcher/core/sanitizer.js.map +1 -1
  191. package/dist/hostPatcher/policy/defaultPolicy.js +15 -5
  192. package/dist/hostPatcher/policy/defaultPolicy.js.map +1 -1
  193. package/dist/hostPatcher/utils/anchors.js +4 -6
  194. package/dist/hostPatcher/utils/anchors.js.map +1 -1
  195. package/dist/index.d.ts +34 -27
  196. package/dist/index.js +51 -24
  197. package/dist/index.js.map +1 -1
  198. package/dist/logger.d.ts +29 -0
  199. package/dist/logger.js +81 -0
  200. package/dist/logger.js.map +1 -0
  201. package/dist/metrics/index.d.ts +1 -1
  202. package/dist/metrics/index.js +1 -1
  203. package/dist/metrics/sessionMetrics.d.ts +1 -1
  204. package/dist/metrics/sessionMetrics.js +6 -6
  205. package/dist/overlays/fetcher.d.ts +2 -2
  206. package/dist/overlays/fetcher.js +13 -15
  207. package/dist/overlays/fetcher.js.map +1 -1
  208. package/dist/overlays/recipeRegistry.js +2 -2
  209. package/dist/overlays/recipeRegistry.js.map +1 -1
  210. package/dist/overlays/runtime/anchor/resolve.js +1 -1
  211. package/dist/overlays/runtime/anchor/resolve.js.map +1 -1
  212. package/dist/overlays/runtime/index.d.ts +7 -7
  213. package/dist/overlays/runtime/index.js +7 -7
  214. package/dist/overlays/runtime/overlay/highlight.js +39 -39
  215. package/dist/overlays/runtime/overlay/highlight.js.map +1 -1
  216. package/dist/overlays/runtime/overlay/modal.js +5 -5
  217. package/dist/overlays/runtime/overlay/modal.js.map +1 -1
  218. package/dist/overlays/runtime/overlay/root.js +1 -1
  219. package/dist/overlays/runtime/overlay/runner.js +88 -28
  220. package/dist/overlays/runtime/overlay/runner.js.map +1 -1
  221. package/dist/overlays/runtime/overlay/tooltip.d.ts +1 -1
  222. package/dist/overlays/runtime/overlay/tooltip.js +13 -15
  223. package/dist/overlays/runtime/overlay/tooltip.js.map +1 -1
  224. package/dist/overlays/runtime/utils/dom.js +4 -1
  225. package/dist/overlays/runtime/utils/dom.js.map +1 -1
  226. package/dist/overlays/schema.d.ts +146 -146
  227. package/dist/overlays/schema.js +12 -8
  228. package/dist/overlays/schema.js.map +1 -1
  229. package/dist/react.d.ts +7 -7
  230. package/dist/react.js +4 -4
  231. package/dist/react.js.map +1 -1
  232. package/dist/render/RenderContext.d.ts +2 -2
  233. package/dist/render/RenderContext.js +5 -5
  234. package/dist/render/RenderContext.js.map +1 -1
  235. package/dist/render/index.d.ts +3 -3
  236. package/dist/render/index.js +1 -1
  237. package/dist/render/types.d.ts +4 -4
  238. package/dist/runtime.d.ts +32 -8
  239. package/dist/runtime.js +109 -13
  240. package/dist/runtime.js.map +1 -1
  241. package/dist/smart-canvas.esm.js +144 -55
  242. package/dist/smart-canvas.esm.js.map +4 -4
  243. package/dist/smart-canvas.js +14688 -11455
  244. package/dist/smart-canvas.js.map +4 -4
  245. package/dist/smart-canvas.min.js +145 -55
  246. package/dist/smart-canvas.min.js.map +4 -4
  247. package/dist/state/StateStore.d.ts +1 -7
  248. package/dist/state/StateStore.js +15 -9
  249. package/dist/state/StateStore.js.map +1 -1
  250. package/dist/state/helpers/cooldowns.d.ts +1 -1
  251. package/dist/state/helpers/cooldowns.js +1 -1
  252. package/dist/state/helpers/dismissals.d.ts +1 -1
  253. package/dist/state/helpers/dismissals.js +1 -1
  254. package/dist/state/helpers/frequency.d.ts +1 -1
  255. package/dist/state/helpers/frequency.js +1 -1
  256. package/dist/state/index.d.ts +4 -4
  257. package/dist/state/index.js +3 -3
  258. package/dist/state/schema.d.ts +1 -1
  259. package/dist/state/schema.js +1 -1
  260. package/dist/store/example.d.ts +1 -0
  261. package/dist/store/example.js +43 -0
  262. package/dist/store/example.js.map +1 -0
  263. package/dist/store/mini-effector.d.ts +46 -0
  264. package/dist/store/mini-effector.js +88 -0
  265. package/dist/store/mini-effector.js.map +1 -0
  266. package/dist/surfaces/Surfaces.d.ts +11 -0
  267. package/dist/surfaces/Surfaces.js +361 -0
  268. package/dist/surfaces/Surfaces.js.map +1 -0
  269. package/dist/surfaces/index.d.ts +9 -0
  270. package/dist/surfaces/index.js +12 -0
  271. package/dist/surfaces/index.js.map +1 -0
  272. package/dist/surfaces/positioning.d.ts +50 -0
  273. package/dist/surfaces/positioning.js +228 -0
  274. package/dist/surfaces/positioning.js.map +1 -0
  275. package/dist/surfaces/types.d.ts +167 -0
  276. package/dist/surfaces/types.js +23 -0
  277. package/dist/surfaces/types.js.map +1 -0
  278. package/dist/telemetry/adapters/noop.d.ts +12 -0
  279. package/dist/telemetry/adapters/noop.js +42 -0
  280. package/dist/telemetry/adapters/noop.js.map +1 -0
  281. package/dist/telemetry/adapters/posthog.d.ts +8 -2
  282. package/dist/telemetry/adapters/posthog.js +36 -14
  283. package/dist/telemetry/adapters/posthog.js.map +1 -1
  284. package/dist/telemetry/index.d.ts +4 -3
  285. package/dist/telemetry/index.js +3 -2
  286. package/dist/telemetry/index.js.map +1 -1
  287. package/dist/telemetry/registry.d.ts +2 -9
  288. package/dist/telemetry/registry.js +4 -2
  289. package/dist/telemetry/registry.js.map +1 -1
  290. package/dist/telemetry/types.d.ts +1 -1
  291. package/dist/theme/ThemeProvider.d.ts +2 -2
  292. package/dist/theme/ThemeProvider.js +21 -21
  293. package/dist/theme/ThemeProvider.js.map +1 -1
  294. package/dist/theme/defaultTheme.d.ts +4 -5
  295. package/dist/theme/defaultTheme.js +127 -118
  296. package/dist/theme/defaultTheme.js.map +1 -1
  297. package/dist/theme/extractHostTheme.d.ts +1 -1
  298. package/dist/theme/extractHostTheme.js +43 -45
  299. package/dist/theme/extractHostTheme.js.map +1 -1
  300. package/dist/theme/index.d.ts +5 -5
  301. package/dist/theme/index.js +3 -3
  302. package/dist/theme/index.js.map +1 -1
  303. package/dist/theme/types.d.ts +2 -2
  304. package/dist/token.d.ts +2 -0
  305. package/dist/token.js +3 -6
  306. package/dist/token.js.map +1 -1
  307. package/dist/types-only.d.ts +32 -0
  308. package/dist/types-only.js +11 -0
  309. package/dist/types-only.js.map +1 -0
  310. package/dist/types.d.ts +89 -56
  311. package/dist/types.js +14 -2
  312. package/dist/types.js.map +1 -1
  313. package/dist/version.d.ts +13 -0
  314. package/dist/version.js +14 -0
  315. package/dist/version.js.map +1 -0
  316. package/dist/widgets/WidgetRegistry.d.ts +145 -0
  317. package/dist/widgets/WidgetRegistry.js +191 -0
  318. package/dist/widgets/WidgetRegistry.js.map +1 -0
  319. package/dist/widgets/index.d.ts +7 -0
  320. package/dist/widgets/index.js +7 -0
  321. package/dist/widgets/index.js.map +1 -0
  322. package/package.json +35 -15
  323. package/schema/canvas-config.schema.json +488 -254
  324. 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 now ships a framework-agnostic `<smart-canvas>` custom element with an **open shadow root**. We still render everything with React, but the canvas is encapsulated so host Tailwind configs, resets, or stacking contexts cant break the UI.
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
- ### Whats Included
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
- ### Installation
17
+ ---
16
18
 
17
- #### NPM/Yarn
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
- #### CDN
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
- #### Local Development
73
+ ### Local Development
43
74
 
44
75
  ```bash
45
- cd tech-core/sdks/shadow-canvas
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
- Rebuild and reinstall whenever the SDK changes.
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
- ### Using the Custom Element (React Host)
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 "@syntrologie/smart-canvas-sdk";
189
+ } from '@syntrologie/smart-canvas-sdk';
64
190
 
65
- const canvasFetcher = async () => {/* return ShadowCanvasConfigResponse */};
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
- ### Using the Imperative API (Plain JS Host)
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
- "--sc-surface": "#050814",
103
- "--sc-fg": "#f8fafc",
232
+ '--sc-surface': '#050814',
233
+ '--sc-fg': '#f8fafc',
104
234
  },
105
235
  integrations: {
106
- posthog, // existing PostHog client
107
- growthbook, // existing GrowthBook client
236
+ posthog, // existing PostHog client
237
+ growthbook, // existing GrowthBook client
108
238
  },
109
239
  });
110
240
  ```
111
241
 
112
- ### Styling & Overlays
242
+ ---
113
243
 
114
- - Fonts, colors, and CSS variables (`--sc-surface`, `--sc-fg`, etc.) are inherited from the host. Tokens can be overridden via `setTokens` or standard CSS:
115
- - `--syntro-tooltip-bg`, `--syntro-tooltip-fg`, `--syntro-tooltip-radius`, `--syntro-tooltip-shadow`
116
- - `--syntro-ring`, `--syntro-spotlight-backdrop` for highlights
117
- - A scoped reset is injected via `adoptedStyleSheets` (fallbacks to `<style>`).
118
- - Tooltips/popovers should use the Popover API or Floating UI with the exposed overlay root (`element.getOverlayRoot()`).
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
- ### Analytics Events
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
- The `createSyntroTelemetry` client emits:
307
+ ---
123
308
 
124
- | Event | Description |
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
- ### Rectangle Config (unchanged)
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
- The experimentation service still returns the same payload (`rectangles`, `style`, `content`, optional `experiment` metadata). Top-level fields now include optional `canvasTitle` so host teams can rename the overlay without code changes. See `src/types.ts` for the exact contract.
317
+ ---
133
318
 
134
- ### Schema & Validation Tool
319
+ ## Schema & Validation
135
320
 
136
- - JSON schema lives at `schema/canvas-config.schema.json` (published with the package).
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/shadow-canvas
141
- npm run validate-config -- ../../tax_landing_page/public/smart-canvas-demo.json
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
- The script evaluates structure/required fields without third-party dependencies so CI and content authors can catch issues early.
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
- ### Overlays (Tooltips & Highlights)
408
+ `GITHUB_TOKEN` is auto-provided. npm auth is OIDC — no `NPM_TOKEN` needed.
147
409
 
148
- - Recipes use the schema in `src/overlays/schema.ts` (roughly `{ id, version, steps[] }`).
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
- Telemetry for overlays uses `telemetry.trackAction("syntro_overlay_*", stepId, "overlay")`.
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
- ### Testing
416
+ ---
160
417
 
161
- - Shadow root is **open**, so Playwright/Cypress can traverse via `.shadow()`.
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
- ### Directory Overview
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/shadow-canvas
429
+ tech-core/sdks/runtime-sdk
169
430
  ├─ src
170
- │ ├─ SmartCanvasElement.tsx // custom element + controller glue
171
- │ ├─ SmartCanvasApp.tsx // React UI
172
- │ ├─ SmartCanvasPortal.tsx // portal helper
173
- │ ├─ api.tsx // window.SmartCanvas + imperative API
174
- ├─ analytics/, experiments/, hooks/, components/
175
- └─ controller.ts
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
- ### Quick Checklist
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 elements shadow via `SmartCanvasPortal`.
184
- 4. Configure the SDK with your API credentials.
185
- 5. For non-React pages, call `window.SmartCanvas.create()` with configuration.
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
+ };