@syntrologie/runtime-sdk 2.14.0 → 2.15.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 (57) hide show
  1. package/README.md +1 -0
  2. package/dist/SmartCanvasElementLit.d.ts +166 -0
  3. package/dist/actions/schema.js +4 -3
  4. package/dist/actions/types.d.ts +8 -2
  5. package/dist/anchor/AnchorResolver.d.ts +1 -0
  6. package/dist/api-lit.d.ts +84 -0
  7. package/dist/apps/builtinRuntimeModules-lit.d.ts +20 -0
  8. package/dist/bootstrap-types.d.ts +10 -0
  9. package/dist/chunk-2IQ2PTLJ.js +871 -0
  10. package/dist/chunk-2IQ2PTLJ.js.map +7 -0
  11. package/dist/{chunk-YLLWLUQX.js → chunk-4HXPGXUC.js} +1 -16
  12. package/dist/{chunk-YLLWLUQX.js.map → chunk-4HXPGXUC.js.map} +1 -1
  13. package/dist/{chunk-JCDCANR7.js → chunk-CVMZW3II.js} +951 -1040
  14. package/dist/chunk-CVMZW3II.js.map +7 -0
  15. package/dist/{chunk-IR6UOR63.js → chunk-GX7BBYX6.js} +2 -2
  16. package/dist/chunk-JMHRHAEL.js +18 -0
  17. package/dist/chunk-JMHRHAEL.js.map +7 -0
  18. package/dist/{chunk-77TNZ66J.js → chunk-XVRDKBYF.js} +3 -3
  19. package/dist/components/SyntroCanvasOverlay.d.ts +100 -0
  20. package/dist/components/SyntroDrawer.d.ts +110 -0
  21. package/dist/components/SyntroLauncher.d.ts +105 -0
  22. package/dist/components/SyntroTileCard.d.ts +74 -0
  23. package/dist/components/SyntroTileWheel.d.ts +51 -0
  24. package/dist/config/schema.js +3 -2
  25. package/dist/controllers/DecisionController.d.ts +48 -0
  26. package/dist/controllers/NotificationsController.d.ts +59 -0
  27. package/dist/controllers/RuntimeController.d.ts +52 -0
  28. package/dist/controllers/RuntimeEventsController.d.ts +42 -0
  29. package/dist/controllers/ThemeController.d.ts +110 -0
  30. package/dist/controllers/index.d.ts +13 -0
  31. package/dist/decisions/schema.js +2 -1
  32. package/dist/decisions/types.d.ts +4 -0
  33. package/dist/editorLoader.d.ts +5 -0
  34. package/dist/index-lit.d.ts +40 -0
  35. package/dist/index.js +1264 -19
  36. package/dist/index.js.map +4 -4
  37. package/dist/interop/LitInReact.d.ts +27 -0
  38. package/dist/interop/ReactInLit.d.ts +42 -0
  39. package/dist/interop/index.d.ts +7 -0
  40. package/dist/metrics/sessionMetrics.d.ts +4 -0
  41. package/dist/notifications/SyntroToastStack.d.ts +43 -0
  42. package/dist/react-compat.d.ts +114 -0
  43. package/dist/react.js +6 -4
  44. package/dist/react.js.map +1 -1
  45. package/dist/smart-canvas.esm.js +856 -240
  46. package/dist/smart-canvas.esm.js.map +4 -4
  47. package/dist/smart-canvas.js +31411 -40000
  48. package/dist/smart-canvas.js.map +4 -4
  49. package/dist/smart-canvas.min.js +855 -240
  50. package/dist/smart-canvas.min.js.map +4 -4
  51. package/dist/theme/index.js +30 -0
  52. package/dist/theme/index.js.map +7 -0
  53. package/dist/version.d.ts +1 -1
  54. package/package.json +10 -1
  55. package/dist/chunk-JCDCANR7.js.map +0 -7
  56. /package/dist/{chunk-IR6UOR63.js.map → chunk-GX7BBYX6.js.map} +0 -0
  57. /package/dist/{chunk-77TNZ66J.js.map → chunk-XVRDKBYF.js.map} +0 -0
package/README.md CHANGED
@@ -515,3 +515,4 @@ The telemetry client emits:
515
515
  4. Configure the SDK with your API credentials
516
516
  5. Use `runtime.actions` for interventions, `runtime.surfaces` for UI
517
517
  6. For non-React pages, call `window.SmartCanvas.create()` with configuration
518
+
@@ -0,0 +1,166 @@
1
+ /**
2
+ * SmartCanvasElementLit — LitElement shell for the Smart Canvas SDK.
3
+ *
4
+ * This is the Lit equivalent of SmartCanvasElement.tsx (raw HTMLElement + React).
5
+ * It absorbs the logic from SmartCanvasApp.tsx directly into the element class:
6
+ * - Config fetching (useShadowCanvasConfig equivalent)
7
+ * - Action lifecycle (batch handle, revert/apply, version counter)
8
+ * - Theme via ThemeController
9
+ * - Canvas open/close via SmartCanvasController
10
+ * - Runtime context via @lit/context
11
+ *
12
+ * Renders <syntro-canvas-overlay> as its main child (Lit component).
13
+ *
14
+ * Decorator-free: uses `static override properties` (tsconfig has no
15
+ * experimentalDecorators).
16
+ */
17
+ import { LitElement, nothing } from 'lit';
18
+ import type { BatchActionHandle } from './actions/types.js';
19
+ import './components/SyntroCanvasOverlay.js';
20
+ import { type SmartCanvasController } from './controller.js';
21
+ import type { ExperimentClient } from './experiments/types.js';
22
+ import './interop/ReactInLit.js';
23
+ import type { SmartCanvasRuntime } from './runtime.js';
24
+ import type { TelemetryClient } from './telemetry/types.js';
25
+ import type { ActionStep, CanvasConfigFetcher, CanvasThemeConfig, LauncherConfig, TileConfig } from './types.js';
26
+ export declare const runtimeContext: {
27
+ __context__: SmartCanvasRuntime | null;
28
+ };
29
+ /**
30
+ * Props accepted by mountLitApp(). Mirrors SmartCanvasAppProps minus controller
31
+ * (the element owns the controller) and footerSlot/canvasHost (React-only).
32
+ */
33
+ export interface SmartCanvasLitProps {
34
+ fetcher?: CanvasConfigFetcher;
35
+ configUri?: string;
36
+ configUriFeatureKey?: string;
37
+ configFeatureKey?: string;
38
+ fetchCredentials?: RequestCredentials;
39
+ experiments?: ExperimentClient;
40
+ telemetry?: TelemetryClient;
41
+ runtime?: SmartCanvasRuntime;
42
+ launcherLabel?: string;
43
+ initialBatchHandle?: BatchActionHandle | null;
44
+ workspaceTheme?: CanvasThemeConfig;
45
+ }
46
+ export declare class SmartCanvasElementLit extends LitElement {
47
+ #private;
48
+ static shadowRootOptions: ShadowRootInit;
49
+ static styles: import("lit").CSSResult;
50
+ static properties: {
51
+ fetcher: {
52
+ attribute: boolean;
53
+ };
54
+ configUri: {
55
+ type: StringConstructor;
56
+ };
57
+ configUriFeatureKey: {
58
+ type: StringConstructor;
59
+ };
60
+ configFeatureKey: {
61
+ type: StringConstructor;
62
+ };
63
+ fetchCredentials: {
64
+ type: StringConstructor;
65
+ };
66
+ experiments: {
67
+ attribute: boolean;
68
+ };
69
+ telemetry: {
70
+ attribute: boolean;
71
+ };
72
+ runtime: {
73
+ attribute: boolean;
74
+ };
75
+ launcherLabel: {
76
+ type: StringConstructor;
77
+ };
78
+ initialBatchHandle: {
79
+ attribute: boolean;
80
+ };
81
+ workspaceTheme: {
82
+ attribute: boolean;
83
+ };
84
+ _tiles: {
85
+ state: boolean;
86
+ };
87
+ _configActions: {
88
+ state: boolean;
89
+ };
90
+ _isLoading: {
91
+ state: boolean;
92
+ };
93
+ _error: {
94
+ state: boolean;
95
+ };
96
+ _theme: {
97
+ state: boolean;
98
+ };
99
+ _launcher: {
100
+ state: boolean;
101
+ };
102
+ _canvasTitle: {
103
+ state: boolean;
104
+ };
105
+ _displayMode: {
106
+ state: boolean;
107
+ };
108
+ _isOpen: {
109
+ state: boolean;
110
+ };
111
+ _pageUrl: {
112
+ state: boolean;
113
+ };
114
+ };
115
+ fetcher: CanvasConfigFetcher | undefined;
116
+ configUri: string | undefined;
117
+ configUriFeatureKey: string | undefined;
118
+ configFeatureKey: string | undefined;
119
+ fetchCredentials: RequestCredentials;
120
+ experiments: ExperimentClient | undefined;
121
+ telemetry: TelemetryClient | undefined;
122
+ runtime: SmartCanvasRuntime | undefined;
123
+ launcherLabel: string | undefined;
124
+ initialBatchHandle: BatchActionHandle | null;
125
+ workspaceTheme: CanvasThemeConfig | undefined;
126
+ /** @internal */ _tiles: TileConfig[];
127
+ /** @internal */ _configActions: ActionStep[];
128
+ /** @internal */ _isLoading: boolean;
129
+ /** @internal */ _error: string | undefined;
130
+ /** @internal */ _theme: CanvasThemeConfig | undefined;
131
+ /** @internal */ _launcher: LauncherConfig | undefined;
132
+ /** @internal */ _canvasTitle: string | undefined;
133
+ /** @internal */ _displayMode: 'standard' | 'focused';
134
+ /** @internal */ _isOpen: boolean;
135
+ /** @internal */ _pageUrl: string;
136
+ constructor();
137
+ connectedCallback(): void;
138
+ disconnectedCallback(): void;
139
+ updated(changed: Map<string, unknown>): void;
140
+ render(): import("lit-html").TemplateResult<1> | typeof nothing;
141
+ open(): void;
142
+ close(): void;
143
+ toggle(): void;
144
+ setOverrideFetcher(fetcher: CanvasConfigFetcher): void;
145
+ getMountNode(): HTMLElement;
146
+ getController(): SmartCanvasController;
147
+ /** React portal target inside shadow root (launcher, drawer, toasts) */
148
+ getPortalRoot(): HTMLDivElement | null;
149
+ /** Vanilla JS overlay container inside shadow root (tooltips, modals, spotlights) */
150
+ getOverlayContainer(): HTMLDivElement | null;
151
+ /** Direct access to the shadow root (for style injection) */
152
+ getShadowRoot(): ShadowRoot;
153
+ /**
154
+ * Mount the React-based SmartCanvasApp inside this element's shadow root.
155
+ * Uses the ReactBridge interop element. During the transition period, callers
156
+ * can use either mountReactApp() (React) or mountLitApp() (Lit).
157
+ */
158
+ mountReactApp(appProps: Record<string, unknown>): void;
159
+ /**
160
+ * Set properties directly on the element. The Lit property change triggers
161
+ * re-render and re-fetch without React.
162
+ */
163
+ mountLitApp(props: SmartCanvasLitProps): void;
164
+ _loadConfig(): Promise<void>;
165
+ }
166
+ export declare const registerSmartCanvasElement: () => void;
@@ -31,9 +31,10 @@ import {
31
31
  WaitZ,
32
32
  WidgetConfigZ,
33
33
  coreActionStepSchemas
34
- } from "../chunk-77TNZ66J.js";
35
- import "../chunk-IR6UOR63.js";
36
- import "../chunk-YLLWLUQX.js";
34
+ } from "../chunk-XVRDKBYF.js";
35
+ import "../chunk-GX7BBYX6.js";
36
+ import "../chunk-4HXPGXUC.js";
37
+ import "../chunk-JMHRHAEL.js";
37
38
  export {
38
39
  AddClassZ,
39
40
  AnchorIdZ,
@@ -341,6 +341,12 @@ export interface ActionEngineOptions {
341
341
  accumulator?: {
342
342
  subscribe: (cb: () => void) => () => void;
343
343
  };
344
+ sessionMetrics?: {
345
+ subscribe: (cb: () => void) => () => void;
346
+ };
347
+ events?: {
348
+ subscribe: (cb: () => void) => () => void;
349
+ };
344
350
  };
345
351
  }
346
352
  /** The ActionEngine interface */
@@ -353,8 +359,8 @@ export interface ActionEngine {
353
359
  validate: (action: ActionStep) => ValidationResult;
354
360
  /** Get all currently active actions */
355
361
  getActive: () => ActiveAction[];
356
- /** Clean up all active actions and resources */
357
- destroy: () => void;
362
+ /** Clean up all active actions and resources. Awaits async cleanup (animated reverts). */
363
+ destroy: () => Promise<void>;
358
364
  }
359
365
  /** Renderable content types for surfaces */
360
366
  export type RenderableContent = {
@@ -11,6 +11,7 @@ export interface AnchorResolverOptions {
11
11
  export interface AnchorResolver {
12
12
  resolve(selector: string): HTMLElement | null;
13
13
  waitFor(selector: string, timeoutMs?: number): Promise<HTMLElement>;
14
+ /** One-shot: fires callback once when element appears, then auto-removes the watcher. */
14
15
  onAppear(selector: string, cb: (el: HTMLElement) => void): () => void;
15
16
  pendingCount(): number;
16
17
  destroy(): void;
@@ -0,0 +1,84 @@
1
+ /**
2
+ * SmartCanvas API (Lit variant)
3
+ *
4
+ * Entry point for the SmartCanvas SDK using LitElement instead of React.
5
+ * Creates and manages the canvas element, handles configuration, and
6
+ * coordinates between the ActionEngine and UI.
7
+ *
8
+ * The public API (SmartCanvasHandle, SmartCanvasConfig, createSmartCanvas)
9
+ * is identical to api.tsx — only the internal mounting uses mountLitApp()
10
+ * instead of mountReactApp().
11
+ */
12
+ import type { ExperimentClient } from './experiments/types';
13
+ import type { OverlayRecipeFetcher } from './overlays/fetcher';
14
+ import type { ActionHandler, AppearanceConfig, RenderProps } from './render/types';
15
+ import type { SmartCanvasRuntime } from './runtime';
16
+ import { type SmartCanvasElementLit } from './SmartCanvasElementLit';
17
+ import type { TelemetryClient } from './telemetry/types';
18
+ import type { CanvasThemeConfig } from './theme';
19
+ import type { CanvasConfigFetcher, CanvasConfigResponse } from './types';
20
+ export interface SmartCanvasIntegrations {
21
+ experiments?: ExperimentClient;
22
+ telemetry?: TelemetryClient;
23
+ }
24
+ export interface SmartCanvasConfig {
25
+ target?: HTMLElement;
26
+ defaultOpen?: boolean;
27
+ tokens?: Record<string, string>;
28
+ fetcher?: CanvasConfigFetcher;
29
+ configUri?: string;
30
+ configUriFeatureKey?: string;
31
+ fetchCredentials?: RequestCredentials;
32
+ overlayFetcher?: OverlayRecipeFetcher;
33
+ overlayConfigUri?: string;
34
+ overlayConfigFeatureKey?: string;
35
+ overlayFetchCredentials?: RequestCredentials;
36
+ pollIntervalMs?: number;
37
+ integrations?: SmartCanvasIntegrations;
38
+ antiFlicker?: boolean | {
39
+ timeout?: number;
40
+ className?: string;
41
+ };
42
+ editorUrl?: string;
43
+ /**
44
+ * v2 Runtime instance.
45
+ * Required for action execution. If not provided, actions will not be applied.
46
+ */
47
+ runtime?: SmartCanvasRuntime;
48
+ appearance?: AppearanceConfig;
49
+ renderProps?: RenderProps;
50
+ actionHandlers?: ActionHandler;
51
+ /** Workspace-level theme for 3-layer inheritance (defaults → workspace → config) */
52
+ workspaceTheme?: CanvasThemeConfig;
53
+ }
54
+ /**
55
+ * Handle for interacting with a SmartCanvas instance.
56
+ */
57
+ export interface SmartCanvasHandle {
58
+ el: SmartCanvasElementLit;
59
+ open(): void;
60
+ close(): void;
61
+ destroy(): void;
62
+ setTokens(tokens: Record<string, string>): void;
63
+ /**
64
+ * Get the current config.
65
+ */
66
+ getConfig(): Promise<CanvasConfigResponse>;
67
+ /**
68
+ * Enable or disable the canvas.
69
+ * When disabled, all actions are reverted.
70
+ */
71
+ setEnabled(enabled: boolean): Promise<void>;
72
+ setOverrideFetcher(fetcher: CanvasConfigFetcher): void;
73
+ registerTelemetryProperties(properties: Record<string, unknown>): void;
74
+ getSessionId(): string | undefined;
75
+ startSessionRecording(): void;
76
+ /** Track a custom event. Returns true if telemetry is available and event was sent. */
77
+ track(eventName: string, properties?: Record<string, unknown>): boolean;
78
+ /**
79
+ * v2 Runtime instance for context, events, state, and decisions.
80
+ */
81
+ runtime?: SmartCanvasRuntime;
82
+ }
83
+ export declare const createSmartCanvas: (config?: SmartCanvasConfig) => Promise<SmartCanvasHandle>;
84
+ export { getAntiFlickerSnippet } from './antiFlicker';
@@ -0,0 +1,20 @@
1
+ export declare const builtinAdaptiveManifestsLit: {
2
+ id: any;
3
+ version: any;
4
+ name: any;
5
+ description: any;
6
+ runtime: {
7
+ actions: any;
8
+ widgets: any;
9
+ notifyWatchers: any;
10
+ events: any;
11
+ };
12
+ editor: undefined;
13
+ metadata: {
14
+ isBuiltIn: boolean;
15
+ };
16
+ }[];
17
+ export declare function registerBuiltinRuntimeModulesLit(registry: {
18
+ has: (id: string) => boolean;
19
+ register: (manifest: any) => void;
20
+ }): void;
@@ -56,6 +56,16 @@ export interface SyntroInitOptions {
56
56
  * @default false
57
57
  */
58
58
  testMode?: boolean;
59
+ /**
60
+ * App-provided signal values set at init time. Merged into SDK attributes
61
+ * alongside auto-collected browser/geo signals for local flag evaluation.
62
+ *
63
+ * Use this when the host environment (MCP server, agent, etc.) provides
64
+ * signal values that the SDK can't auto-collect from the browser.
65
+ *
66
+ * Tracked as a discrete PostHog event (app_signals_init) on init.
67
+ */
68
+ appSignalsInit?: Record<string, string>;
59
69
  }
60
70
  export interface SyntroInitResult {
61
71
  /**