@syntrologie/runtime-sdk 2.11.0 → 2.12.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 +176 -117
- package/README.md +2 -0
- package/dist/actions/schema.d.ts +7 -7
- package/dist/actions/schema.js +3 -4
- package/dist/actions/types.d.ts +1 -1
- package/dist/actions/validation-core.d.ts +24 -0
- package/dist/actions/validation-rules.d.ts +74 -0
- package/dist/actions/validation.d.ts +5 -11
- package/dist/bootstrap-init.d.ts +33 -0
- package/dist/bootstrap-runtime.d.ts +7 -0
- package/dist/bootstrap-types.d.ts +90 -0
- package/dist/bootstrap.d.ts +17 -83
- package/dist/{chunk-Q77NT67W.js → chunk-BU4Z6PD7.js} +16 -1
- package/dist/{chunk-Q77NT67W.js.map → chunk-BU4Z6PD7.js.map} +1 -1
- package/dist/{chunk-H3FAYTUV.js → chunk-J2LGX2PV.js} +1216 -394
- package/dist/chunk-J2LGX2PV.js.map +7 -0
- package/dist/{chunk-NBFQGKSV.js → chunk-L6RJMBR2.js} +4 -4
- package/dist/{chunk-NBFQGKSV.js.map → chunk-L6RJMBR2.js.map} +2 -2
- package/dist/{chunk-37TTQRH5.js → chunk-XDYJ64IN.js} +2 -2
- package/dist/config/schema.js +2 -3
- package/dist/decisions/schema.js +1 -2
- package/dist/events/EventBus.d.ts +27 -1
- package/dist/events/history.d.ts +9 -0
- package/dist/events/index.d.ts +3 -0
- package/dist/events/types.d.ts +24 -0
- package/dist/events/validation.d.ts +7 -0
- package/dist/index.d.ts +0 -2
- package/dist/index.js +1131 -2039
- package/dist/index.js.map +4 -4
- package/dist/overlays/runtime/overlay/overlay-runner.d.ts +4 -0
- package/dist/overlays/runtime/overlay/overlay-state.d.ts +21 -0
- package/dist/overlays/types.d.ts +3 -1
- package/dist/react.js +6 -5
- package/dist/react.js.map +2 -2
- package/dist/smart-canvas.esm.js +92 -108
- package/dist/smart-canvas.esm.js.map +4 -4
- package/dist/smart-canvas.js +4649 -4957
- package/dist/smart-canvas.js.map +4 -4
- package/dist/smart-canvas.min.js +92 -108
- package/dist/smart-canvas.min.js.map +4 -4
- package/dist/telemetry/adapters/posthog.d.ts +5 -10
- package/dist/test/setup.d.ts +1 -0
- package/dist/token.d.ts +2 -0
- package/dist/version.d.ts +1 -1
- package/package.json +23 -29
- package/schema/canvas-config.schema.json +1 -1
- package/scripts/syntroReactPlugin.mjs +3 -0
- package/scripts/validate-config.mjs +42 -0
- package/dist/chunk-H3FAYTUV.js.map +0 -7
- package/dist/chunk-JMHRHAEL.js +0 -18
- package/dist/chunk-JMHRHAEL.js.map +0 -7
- package/dist/replayMirror-QZ3GQ527.js +0 -32
- package/dist/replayMirror-QZ3GQ527.js.map +0 -7
- package/dist/telemetry/replayMirror.d.ts +0 -7
- /package/dist/{chunk-37TTQRH5.js.map → chunk-XDYJ64IN.js.map} +0 -0
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { CanvasRecipe, OverlayContext } from '../../types';
|
|
2
|
+
export declare function runOverlays(recipe: CanvasRecipe, ctx: OverlayContext): Promise<() => void>;
|
|
3
|
+
/** Start a tour by ID - clears completion state and begins */
|
|
4
|
+
export declare function startTour(tourId: string): void;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { HighlightStep, ModalStep, TooltipStep } from '../../types';
|
|
2
|
+
export type Step = TooltipStep | HighlightStep | ModalStep;
|
|
3
|
+
export declare const ACTIVE_TOUR_KEY = "syntro_active_tour";
|
|
4
|
+
export interface ActiveTourState {
|
|
5
|
+
tourId: string;
|
|
6
|
+
stepId: string;
|
|
7
|
+
timestamp: number;
|
|
8
|
+
}
|
|
9
|
+
export declare const TOUR_STATE_EXPIRY_MS: number;
|
|
10
|
+
/** Get active tour state from localStorage (returns null if expired) */
|
|
11
|
+
export declare function getActiveTourState(): ActiveTourState | null;
|
|
12
|
+
/** Save active tour state to localStorage with timestamp */
|
|
13
|
+
export declare function setActiveTourState(state: Omit<ActiveTourState, 'timestamp'> | null): void;
|
|
14
|
+
/** Check if a step's route matches the current page */
|
|
15
|
+
export declare function stepRouteMatches(step: Step, path: string): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Watch for route changes in SPAs.
|
|
18
|
+
* Uses NavigationMonitor subscription if available (single patch point),
|
|
19
|
+
* otherwise falls back to direct History API patching (legacy).
|
|
20
|
+
*/
|
|
21
|
+
export declare function watchRouteChanges(callback: (newPath: string) => void, subscribeNavigation?: (cb: (url: string, method: string) => void) => () => void): () => void;
|
package/dist/overlays/types.d.ts
CHANGED
|
@@ -113,8 +113,10 @@ export type CanvasRecipe = {
|
|
|
113
113
|
export type OverlayContext = {
|
|
114
114
|
overlayRoot: HTMLElement;
|
|
115
115
|
resolve: (sel: Selector) => Promise<HTMLElement | null>;
|
|
116
|
-
onEvent: (name: string, payload?:
|
|
116
|
+
onEvent: (name: string, payload?: Record<string, unknown>) => void;
|
|
117
117
|
canvasHost?: HTMLElement | null;
|
|
118
|
+
/** Recipe ID for telemetry attribution */
|
|
119
|
+
recipeId?: string;
|
|
118
120
|
/** Telemetry client for persisting tour state to PostHog */
|
|
119
121
|
telemetry?: {
|
|
120
122
|
setPersonPropertiesOnce?: (props: Record<string, unknown>) => void;
|
package/dist/react.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Syntro
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
5
|
-
import "./chunk-
|
|
6
|
-
import "./chunk-
|
|
7
|
-
import "./chunk-JMHRHAEL.js";
|
|
3
|
+
} from "./chunk-J2LGX2PV.js";
|
|
4
|
+
import "./chunk-L6RJMBR2.js";
|
|
5
|
+
import "./chunk-XDYJ64IN.js";
|
|
6
|
+
import "./chunk-BU4Z6PD7.js";
|
|
8
7
|
|
|
9
8
|
// src/react.tsx
|
|
10
9
|
import { createContext, useContext, useEffect, useRef, useState } from "react";
|
|
@@ -34,6 +33,7 @@ function SyntroProvider({
|
|
|
34
33
|
if (globalInitPromise && globalInitToken === token) {
|
|
35
34
|
globalInitPromise.then((result) => {
|
|
36
35
|
var _a, _b;
|
|
36
|
+
if (!result) return;
|
|
37
37
|
handleRef.current = result.canvas;
|
|
38
38
|
setState({
|
|
39
39
|
canvas: result.canvas,
|
|
@@ -51,6 +51,7 @@ function SyntroProvider({
|
|
|
51
51
|
globalInitPromise = Syntro.init({ token, canvas: canvasOptions, fetcher });
|
|
52
52
|
globalInitPromise.then((result) => {
|
|
53
53
|
var _a, _b;
|
|
54
|
+
if (!result) return;
|
|
54
55
|
handleRef.current = result.canvas;
|
|
55
56
|
setState({
|
|
56
57
|
canvas: result.canvas,
|
package/dist/react.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/react.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * React bindings for the Syntro SDK.\n *\n * Usage:\n * ```tsx\n * import { SyntroProvider, useSyntro } from '@syntrologie/runtime-sdk/react';\n *\n * function App() {\n * return (\n * <SyntroProvider token=\"syn_xxx\">\n * <MyApp />\n * </SyntroProvider>\n * );\n * }\n *\n * function MyComponent() {\n * const { canvas, experiments, telemetry, isReady } = useSyntro();\n * // ...\n * }\n * ```\n */\nimport { createContext, type ReactNode, useContext, useEffect, useRef, useState } from 'react';\n\nimport type { SmartCanvasHandle } from './api';\nimport { Syntro, type SyntroInitOptions, type SyntroInitResult } from './bootstrap';\nimport type { ExperimentClient } from './experiments/types';\nimport type { TelemetryClient } from './telemetry/types';\n\nexport interface SyntroContextValue {\n /** The SmartCanvas handle */\n canvas: SmartCanvasHandle | null;\n /** The experiment client */\n experiments: ExperimentClient | null;\n /** The telemetry client */\n telemetry: TelemetryClient | null;\n /** Whether the SDK has finished initializing */\n isReady: boolean;\n /** Any error that occurred during initialization */\n error: Error | null;\n}\n\nconst SyntroContext = createContext<SyntroContextValue | null>(null);\n\n// Global tracking to handle React Strict Mode double-mounting\nlet globalInitPromise: Promise<SyntroInitResult> | null = null;\nlet globalInitToken: string | null = null;\n\nexport interface SyntroProviderProps {\n /**\n * The Syntro token containing all credentials.\n */\n token: string;\n\n /**\n * Optional canvas configuration overrides.\n */\n canvasOptions?: SyntroInitOptions['canvas'];\n\n /**\n * Custom config fetcher to override the default experiment-based fetcher.\n * Use this for local development or when bypassing the experiment server.\n */\n fetcher?: SyntroInitOptions['fetcher'];\n\n /**\n * Children to render.\n */\n children: ReactNode;\n\n /**\n * Called when initialization completes.\n */\n onReady?: (result: SyntroInitResult) => void;\n\n /**\n * Called when initialization fails.\n */\n onError?: (error: Error) => void;\n}\n\n/**\n * Provider component that initializes the Syntro SDK.\n *\n * Place this at the root of your app or at the top of any subtree\n * that needs access to the SDK.\n */\nexport function SyntroProvider({\n token,\n canvasOptions,\n fetcher,\n children,\n onReady,\n onError,\n}: SyntroProviderProps) {\n const [state, setState] = useState<SyntroContextValue>({\n canvas: null,\n experiments: null,\n telemetry: null,\n isReady: false,\n error: null,\n });\n\n const initRef = useRef(false);\n const handleRef = useRef<SmartCanvasHandle | null>(null);\n\n useEffect(() => {\n if (!token) return;\n\n // Reuse existing init if same token (handles React Strict Mode remounts)\n if (globalInitPromise && globalInitToken === token) {\n globalInitPromise.then((result) => {\n handleRef.current = result.canvas;\n setState({\n canvas: result.canvas,\n experiments: result.experiments ?? null,\n telemetry: result.telemetry ?? null,\n isReady: true,\n error: null,\n });\n });\n return;\n }\n\n // Prevent double init\n if (initRef.current) return;\n initRef.current = true;\n\n globalInitToken = token;\n globalInitPromise = Syntro.init({ token, canvas: canvasOptions, fetcher });\n\n globalInitPromise\n .then((result) => {\n handleRef.current = result.canvas;\n setState({\n canvas: result.canvas,\n experiments: result.experiments ?? null,\n telemetry: result.telemetry ?? null,\n isReady: true,\n error: null,\n });\n onReady?.(result);\n })\n .catch((err) => {\n const error = err instanceof Error ? err : new Error(String(err));\n setState((prev) => ({ ...prev, error, isReady: true }));\n onError?.(error);\n // Clear global state on error so retry is possible\n globalInitPromise = null;\n globalInitToken = null;\n });\n\n // Don't destroy on unmount in dev mode - React Strict Mode will remount\n // The canvas persists and will be reused on remount\n }, [token, canvasOptions, fetcher, onError, onReady]);\n\n return <SyntroContext.Provider value={state}>{children}</SyntroContext.Provider>;\n}\n\n/**\n * Hook to access the Syntro SDK.\n *\n * Must be used within a SyntroProvider.\n *\n * @returns The SDK context containing canvas, experiments, telemetry, and status\n */\nexport function useSyntro(): SyntroContextValue {\n const context = useContext(SyntroContext);\n if (!context) {\n throw new Error('useSyntro must be used within a SyntroProvider');\n }\n return context;\n}\n\n/**\n * Hook to check if the SDK is ready.\n *\n * Shorthand for `useSyntro().isReady`.\n */\nexport function useSyntroReady(): boolean {\n return useSyntro().isReady;\n}\n\n/**\n * Hook to access the experiment client.\n *\n * @returns The experiment client, or null if not configured\n */\nexport function useSyntroExperiments(): ExperimentClient | null {\n return useSyntro().experiments;\n}\n\n/**\n * Hook to access the telemetry client.\n *\n * @returns The telemetry client, or null if not configured\n */\nexport function useSyntroTelemetry(): TelemetryClient | null {\n return useSyntro().telemetry;\n}\n\n/**\n * Hook to access the canvas handle.\n *\n * @returns The canvas handle, or null if not ready\n */\nexport function useSyntroCanvas(): SmartCanvasHandle | null {\n return useSyntro().canvas;\n}\n"],
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["/**\n * React bindings for the Syntro SDK.\n *\n * Usage:\n * ```tsx\n * import { SyntroProvider, useSyntro } from '@syntrologie/runtime-sdk/react';\n *\n * function App() {\n * return (\n * <SyntroProvider token=\"syn_xxx\">\n * <MyApp />\n * </SyntroProvider>\n * );\n * }\n *\n * function MyComponent() {\n * const { canvas, experiments, telemetry, isReady } = useSyntro();\n * // ...\n * }\n * ```\n */\nimport { createContext, type ReactNode, useContext, useEffect, useRef, useState } from 'react';\n\nimport type { SmartCanvasHandle } from './api';\nimport { Syntro, type SyntroInitOptions, type SyntroInitResult } from './bootstrap';\nimport type { ExperimentClient } from './experiments/types';\nimport type { TelemetryClient } from './telemetry/types';\n\nexport interface SyntroContextValue {\n /** The SmartCanvas handle */\n canvas: SmartCanvasHandle | null;\n /** The experiment client */\n experiments: ExperimentClient | null;\n /** The telemetry client */\n telemetry: TelemetryClient | null;\n /** Whether the SDK has finished initializing */\n isReady: boolean;\n /** Any error that occurred during initialization */\n error: Error | null;\n}\n\nconst SyntroContext = createContext<SyntroContextValue | null>(null);\n\n// Global tracking to handle React Strict Mode double-mounting\nlet globalInitPromise: Promise<SyntroInitResult | undefined> | null = null;\nlet globalInitToken: string | null = null;\n\nexport interface SyntroProviderProps {\n /**\n * The Syntro token containing all credentials.\n */\n token: string;\n\n /**\n * Optional canvas configuration overrides.\n */\n canvasOptions?: SyntroInitOptions['canvas'];\n\n /**\n * Custom config fetcher to override the default experiment-based fetcher.\n * Use this for local development or when bypassing the experiment server.\n */\n fetcher?: SyntroInitOptions['fetcher'];\n\n /**\n * Children to render.\n */\n children: ReactNode;\n\n /**\n * Called when initialization completes.\n */\n onReady?: (result: SyntroInitResult) => void;\n\n /**\n * Called when initialization fails.\n */\n onError?: (error: Error) => void;\n}\n\n/**\n * Provider component that initializes the Syntro SDK.\n *\n * Place this at the root of your app or at the top of any subtree\n * that needs access to the SDK.\n */\nexport function SyntroProvider({\n token,\n canvasOptions,\n fetcher,\n children,\n onReady,\n onError,\n}: SyntroProviderProps) {\n const [state, setState] = useState<SyntroContextValue>({\n canvas: null,\n experiments: null,\n telemetry: null,\n isReady: false,\n error: null,\n });\n\n const initRef = useRef(false);\n const handleRef = useRef<SmartCanvasHandle | null>(null);\n\n useEffect(() => {\n if (!token) return;\n\n // Reuse existing init if same token (handles React Strict Mode remounts)\n if (globalInitPromise && globalInitToken === token) {\n globalInitPromise.then((result) => {\n if (!result) return;\n handleRef.current = result.canvas;\n setState({\n canvas: result.canvas,\n experiments: result.experiments ?? null,\n telemetry: result.telemetry ?? null,\n isReady: true,\n error: null,\n });\n });\n return;\n }\n\n // Prevent double init\n if (initRef.current) return;\n initRef.current = true;\n\n globalInitToken = token;\n globalInitPromise = Syntro.init({ token, canvas: canvasOptions, fetcher });\n\n globalInitPromise\n .then((result) => {\n if (!result) return;\n handleRef.current = result.canvas;\n setState({\n canvas: result.canvas,\n experiments: result.experiments ?? null,\n telemetry: result.telemetry ?? null,\n isReady: true,\n error: null,\n });\n onReady?.(result);\n })\n .catch((err) => {\n const error = err instanceof Error ? err : new Error(String(err));\n setState((prev) => ({ ...prev, error, isReady: true }));\n onError?.(error);\n // Clear global state on error so retry is possible\n globalInitPromise = null;\n globalInitToken = null;\n });\n\n // Don't destroy on unmount in dev mode - React Strict Mode will remount\n // The canvas persists and will be reused on remount\n }, [token, canvasOptions, fetcher, onError, onReady]);\n\n return <SyntroContext.Provider value={state}>{children}</SyntroContext.Provider>;\n}\n\n/**\n * Hook to access the Syntro SDK.\n *\n * Must be used within a SyntroProvider.\n *\n * @returns The SDK context containing canvas, experiments, telemetry, and status\n */\nexport function useSyntro(): SyntroContextValue {\n const context = useContext(SyntroContext);\n if (!context) {\n throw new Error('useSyntro must be used within a SyntroProvider');\n }\n return context;\n}\n\n/**\n * Hook to check if the SDK is ready.\n *\n * Shorthand for `useSyntro().isReady`.\n */\nexport function useSyntroReady(): boolean {\n return useSyntro().isReady;\n}\n\n/**\n * Hook to access the experiment client.\n *\n * @returns The experiment client, or null if not configured\n */\nexport function useSyntroExperiments(): ExperimentClient | null {\n return useSyntro().experiments;\n}\n\n/**\n * Hook to access the telemetry client.\n *\n * @returns The telemetry client, or null if not configured\n */\nexport function useSyntroTelemetry(): TelemetryClient | null {\n return useSyntro().telemetry;\n}\n\n/**\n * Hook to access the canvas handle.\n *\n * @returns The canvas handle, or null if not ready\n */\nexport function useSyntroCanvas(): SmartCanvasHandle | null {\n return useSyntro().canvas;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;AAqBA,SAAS,eAA+B,YAAY,WAAW,QAAQ,gBAAgB;AAwI9E;AApHT,IAAM,gBAAgB,cAAyC,IAA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