@syntrologie/runtime-sdk 2.8.0-canary.4 → 2.8.0-canary.41
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 +44 -0
- package/dist/actions/schema.d.ts +1 -1
- package/dist/actions/schema.js +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-R5DNAIRI.js → chunk-TN5BLBPU.js} +1 -1
- package/dist/{chunk-R5DNAIRI.js.map → chunk-TN5BLBPU.js.map} +1 -1
- package/dist/{chunk-5GTCL2IH.js → chunk-X2XEU6KD.js} +1506 -599
- package/dist/chunk-X2XEU6KD.js.map +7 -0
- package/dist/components/TileIcon.d.ts +2 -2
- package/dist/components/emojiToIcon.d.ts +24 -0
- 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/normalizers/posthog.d.ts +4 -50
- package/dist/events/types.d.ts +30 -23
- package/dist/events/validation.d.ts +7 -0
- package/dist/index.d.ts +0 -2
- package/dist/index.js +1523 -182
- 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 +4 -2
- package/dist/react.js.map +2 -2
- package/dist/smart-canvas.esm.js +123 -54
- package/dist/smart-canvas.esm.js.map +4 -4
- package/dist/smart-canvas.js +5650 -2964
- package/dist/smart-canvas.js.map +4 -4
- package/dist/smart-canvas.min.js +123 -54
- package/dist/smart-canvas.min.js.map +4 -4
- package/dist/telemetry/adapters/posthog.d.ts +30 -4
- 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 -28
- package/schema/canvas-config.schema.json +100 -2
- package/scripts/syntroReactPlugin.mjs +3 -0
- package/scripts/validate-config.mjs +42 -0
- package/dist/chunk-5GTCL2IH.js.map +0 -7
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* TileIcon — maps emoji identifiers to Lucide icons.
|
|
3
3
|
*
|
|
4
|
-
* Uses the
|
|
5
|
-
*
|
|
4
|
+
* Uses the shared emoji-to-icon mapping so tiles render the same
|
|
5
|
+
* icons as the editor sidebar, nav tips, and notifications.
|
|
6
6
|
*/
|
|
7
7
|
import type { ReactElement } from 'react';
|
|
8
8
|
interface TileIconProps {
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared emoji → Lucide icon mapping.
|
|
3
|
+
*
|
|
4
|
+
* Used by TileIcon, NavWidget, and NotificationToastStack to render
|
|
5
|
+
* Lucide SVG icons in place of emoji strings. This keeps icon rendering
|
|
6
|
+
* consistent and styleable across all surfaces.
|
|
7
|
+
*
|
|
8
|
+
* To add a new mapping, add the emoji key and Lucide component here.
|
|
9
|
+
*/
|
|
10
|
+
import type { ReactElement } from 'react';
|
|
11
|
+
interface EmojiIconProps {
|
|
12
|
+
emoji: string;
|
|
13
|
+
size?: number;
|
|
14
|
+
color?: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Render a Lucide icon for a known emoji, or fall back to the raw string.
|
|
18
|
+
*/
|
|
19
|
+
export declare function EmojiIcon({ emoji, size, color, }: EmojiIconProps): ReactElement;
|
|
20
|
+
/**
|
|
21
|
+
* Check if an emoji string has a Lucide mapping.
|
|
22
|
+
*/
|
|
23
|
+
export declare function hasIconMapping(emoji: string): boolean;
|
|
24
|
+
export {};
|
|
@@ -6,10 +6,19 @@
|
|
|
6
6
|
* - Event history for recent event lookups
|
|
7
7
|
* - Filtering by name, pattern, or source
|
|
8
8
|
*/
|
|
9
|
-
import type {
|
|
9
|
+
import type { EventHistory } from './history';
|
|
10
|
+
import type { EmitResult, EventCallback, EventFilter, EventUnsubscribe, NormalizedEvent } from './types';
|
|
10
11
|
export interface EventBusOptions {
|
|
11
12
|
/** Maximum number of events to keep in history */
|
|
12
13
|
maxHistorySize?: number;
|
|
14
|
+
/** Enable debug mode — emit() returns EmitResult and logs to console */
|
|
15
|
+
debug?: boolean;
|
|
16
|
+
/** EventHistory instance for recording emitted events (debug/test) */
|
|
17
|
+
history?: EventHistory;
|
|
18
|
+
/** PostHog capture function for forwarding custom events */
|
|
19
|
+
posthogCapture?: (name: string, props?: Record<string, unknown>) => void;
|
|
20
|
+
/** When true, skip PostHog forwarding (for tests) */
|
|
21
|
+
testMode?: boolean;
|
|
13
22
|
}
|
|
14
23
|
/**
|
|
15
24
|
* EventBus class for managing normalized events.
|
|
@@ -18,6 +27,10 @@ export declare class EventBus {
|
|
|
18
27
|
private subscriptions;
|
|
19
28
|
private history;
|
|
20
29
|
private maxHistorySize;
|
|
30
|
+
private debug;
|
|
31
|
+
private emitHistory;
|
|
32
|
+
private posthogCapture;
|
|
33
|
+
private testMode;
|
|
21
34
|
constructor(options?: EventBusOptions);
|
|
22
35
|
/**
|
|
23
36
|
* Subscribe to events matching an optional filter.
|
|
@@ -32,6 +45,19 @@ export declare class EventBus {
|
|
|
32
45
|
* Publish a pre-constructed NormalizedEvent.
|
|
33
46
|
*/
|
|
34
47
|
publishEvent(event: NormalizedEvent): void;
|
|
48
|
+
/**
|
|
49
|
+
* Emit a validated custom event from the host application.
|
|
50
|
+
*
|
|
51
|
+
* Custom events must use the `app:` prefix (e.g. `app:cart:abandoned`).
|
|
52
|
+
* In debug mode, returns an EmitResult with delivery details.
|
|
53
|
+
* In production mode, returns undefined.
|
|
54
|
+
*/
|
|
55
|
+
emit(name: string, props?: Record<string, unknown>): EmitResult | undefined;
|
|
56
|
+
/**
|
|
57
|
+
* Set the PostHog capture function after construction.
|
|
58
|
+
* Used by bootstrap to wire PostHog after the EventBus is created.
|
|
59
|
+
*/
|
|
60
|
+
setPosthogCapture(fn: (name: string, props?: Record<string, unknown>) => void): void;
|
|
35
61
|
/**
|
|
36
62
|
* Get recent events matching an optional filter.
|
|
37
63
|
*/
|
package/dist/events/index.d.ts
CHANGED
|
@@ -5,8 +5,11 @@ export type { EventAccumulator, EventAccumulatorOptions } from './EventAccumulat
|
|
|
5
5
|
export { createEventAccumulator } from './EventAccumulator';
|
|
6
6
|
export type { EventBusOptions } from './EventBus';
|
|
7
7
|
export { createEventBus, EventBus } from './EventBus';
|
|
8
|
+
export { EventHistory } from './history';
|
|
8
9
|
export { CanvasEvents } from './normalizers/canvas';
|
|
9
10
|
export { createPostHogNormalizer, normalizePostHogEvent, shouldNormalizeEvent, } from './normalizers/posthog';
|
|
10
11
|
export { registerConfigPredicates } from './registerConfigPredicates';
|
|
11
12
|
export * from './schema';
|
|
12
13
|
export * from './types';
|
|
14
|
+
export type { ValidationResult as EventValidationResult } from './validation';
|
|
15
|
+
export { validateEventName, validateProps } from './validation';
|
|
@@ -1,53 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* PostHog Event Normalizer
|
|
2
|
+
* PostHog Event Normalizer — re-exported from @syntrologie/event-processor.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* This module is automatically wired up during `Syntro.init()` when PostHog
|
|
7
|
-
* credentials are provided in the token. The flow is:
|
|
8
|
-
*
|
|
9
|
-
* 1. PostHog captures user interactions (clicks, scrolls, navigation, etc.)
|
|
10
|
-
* 2. PostHog's `eventCaptured` callback fires
|
|
11
|
-
* 3. `createPostHogNormalizer()` transforms the event to a NormalizedEvent
|
|
12
|
-
* 4. The normalized event is published to the EventBus
|
|
13
|
-
*
|
|
14
|
-
* This allows canvas components and decision strategies to react to user
|
|
15
|
-
* interactions with the main webapp, not just canvas-specific events.
|
|
16
|
-
*
|
|
17
|
-
* @example
|
|
18
|
-
* ```typescript
|
|
19
|
-
* // In bootstrap.ts (already wired up automatically)
|
|
20
|
-
* const normalizer = createPostHogNormalizer((event) => {
|
|
21
|
-
* eventBus.publishEvent(event);
|
|
22
|
-
* });
|
|
23
|
-
*
|
|
24
|
-
* // PostHog adapter calls normalizer on each capture
|
|
25
|
-
* posthog.on('eventCaptured', normalizer);
|
|
26
|
-
* ```
|
|
27
|
-
*
|
|
28
|
-
* @see RUNTIME_V2_REFERENCE.md for the full event mapping table
|
|
29
|
-
*/
|
|
30
|
-
import type { NormalizedEvent } from '../types';
|
|
31
|
-
/**
|
|
32
|
-
* PostHog event structure (simplified).
|
|
33
|
-
*/
|
|
34
|
-
interface PostHogEvent {
|
|
35
|
-
event: string;
|
|
36
|
-
properties?: Record<string, unknown>;
|
|
37
|
-
timestamp?: string | number;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Normalize a PostHog event into a NormalizedEvent.
|
|
41
|
-
*/
|
|
42
|
-
export declare function normalizePostHogEvent(phEvent: PostHogEvent): NormalizedEvent;
|
|
43
|
-
/**
|
|
44
|
-
* Check if a PostHog event should be normalized.
|
|
45
|
-
* Filters out internal/system events that aren't useful for adaptives.
|
|
46
|
-
*/
|
|
47
|
-
export declare function shouldNormalizeEvent(phEvent: PostHogEvent): boolean;
|
|
48
|
-
/**
|
|
49
|
-
* Create a function that hooks into PostHog's onCapture callback
|
|
50
|
-
* and normalizes events into the EventBus.
|
|
4
|
+
* The canonical implementation now lives in the event-processor package
|
|
5
|
+
* so it can be shared between runtime-sdk (browser) and the data pipeline.
|
|
51
6
|
*/
|
|
52
|
-
export
|
|
53
|
-
export {};
|
|
7
|
+
export { createPostHogNormalizer, normalizePostHogEvent, shouldNormalizeEvent, } from '@syntrologie/event-processor/normalizers/posthog';
|
package/dist/events/types.d.ts
CHANGED
|
@@ -4,25 +4,8 @@
|
|
|
4
4
|
* The EventBus provides a normalized event stream that unifies events from
|
|
5
5
|
* PostHog autocapture, Canvas events, and derived behavioral signals.
|
|
6
6
|
*/
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
*/
|
|
10
|
-
export type EventSource = 'posthog' | 'canvas' | 'derived';
|
|
11
|
-
/**
|
|
12
|
-
* Normalized event structure for the event bus.
|
|
13
|
-
*/
|
|
14
|
-
export interface NormalizedEvent {
|
|
15
|
-
/** Event timestamp (milliseconds since epoch) */
|
|
16
|
-
ts: number;
|
|
17
|
-
/** Normalized event name (e.g., "ui.click", "canvas.opened") */
|
|
18
|
-
name: string;
|
|
19
|
-
/** Event source */
|
|
20
|
-
source: EventSource;
|
|
21
|
-
/** Event properties/payload */
|
|
22
|
-
props?: Record<string, unknown>;
|
|
23
|
-
/** Schema version for forward compatibility */
|
|
24
|
-
schemaVersion: string;
|
|
25
|
-
}
|
|
7
|
+
export type { EventSource, NormalizedEvent } from '@syntrologie/event-processor';
|
|
8
|
+
export { EVENT_SCHEMA_VERSION } from '@syntrologie/event-processor';
|
|
26
9
|
/**
|
|
27
10
|
* Event filter for subscriptions.
|
|
28
11
|
*/
|
|
@@ -32,18 +15,22 @@ export interface EventFilter {
|
|
|
32
15
|
/** Filter by event name patterns (regex) */
|
|
33
16
|
patterns?: string[];
|
|
34
17
|
/** Filter by sources */
|
|
35
|
-
sources?: EventSource[];
|
|
18
|
+
sources?: import('@syntrologie/event-processor').EventSource[];
|
|
36
19
|
}
|
|
37
20
|
/**
|
|
38
21
|
* Callback for event subscriptions.
|
|
39
22
|
*/
|
|
40
|
-
export type EventCallback = (event: NormalizedEvent) => void;
|
|
23
|
+
export type EventCallback = (event: import('@syntrologie/event-processor').NormalizedEvent) => void;
|
|
41
24
|
/**
|
|
42
25
|
* Unsubscribe function returned by subscribe().
|
|
43
26
|
*/
|
|
44
27
|
export type EventUnsubscribe = () => void;
|
|
45
28
|
/**
|
|
46
29
|
* Standard event names used by the runtime.
|
|
30
|
+
*
|
|
31
|
+
* This is a superset of event-processor's StandardEvents, adding
|
|
32
|
+
* canvas, overlay, action, notification, and surface events that
|
|
33
|
+
* are specific to the runtime SDK.
|
|
47
34
|
*/
|
|
48
35
|
export declare const StandardEvents: {
|
|
49
36
|
readonly UI_CLICK: "ui.click";
|
|
@@ -78,6 +65,26 @@ export declare const StandardEvents: {
|
|
|
78
65
|
readonly SURFACE_UNMOUNTED: "surface.unmounted";
|
|
79
66
|
};
|
|
80
67
|
/**
|
|
81
|
-
*
|
|
68
|
+
* Result returned from emit() in debug mode.
|
|
69
|
+
* In production mode, emit() returns undefined.
|
|
70
|
+
*/
|
|
71
|
+
export interface EmitResult {
|
|
72
|
+
delivered: boolean;
|
|
73
|
+
matchedRules: Array<{
|
|
74
|
+
tileId: string;
|
|
75
|
+
ruleIndex: number;
|
|
76
|
+
title: string;
|
|
77
|
+
}>;
|
|
78
|
+
posthogCaptured: boolean;
|
|
79
|
+
listenersNotified: number;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Entry in the debug/test event history.
|
|
82
83
|
*/
|
|
83
|
-
export
|
|
84
|
+
export interface EmitHistoryEntry {
|
|
85
|
+
name: string;
|
|
86
|
+
props?: Record<string, unknown>;
|
|
87
|
+
source: 'custom';
|
|
88
|
+
timestamp: number;
|
|
89
|
+
matchedRules: EmitResult['matchedRules'];
|
|
90
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export interface ValidationResult {
|
|
2
|
+
valid: boolean;
|
|
3
|
+
reason?: string;
|
|
4
|
+
stripped?: string[];
|
|
5
|
+
}
|
|
6
|
+
export declare function validateEventName(name: string): ValidationResult;
|
|
7
|
+
export declare function validateProps(props: Record<string, unknown> | undefined): ValidationResult;
|
package/dist/index.d.ts
CHANGED
|
@@ -25,7 +25,6 @@ export * from './apps';
|
|
|
25
25
|
export * from './context';
|
|
26
26
|
export * from './decisions';
|
|
27
27
|
export * from './events';
|
|
28
|
-
export * from './events';
|
|
29
28
|
export type { NavigationDiagnostics, NavigationListener } from './navigation/NavigationMonitor';
|
|
30
29
|
export { NavigationMonitor } from './navigation/NavigationMonitor';
|
|
31
30
|
export * from './notifications';
|
|
@@ -33,7 +32,6 @@ export { RuntimeProvider, useDecision, usePageContext, useRuntime, useRuntimeCon
|
|
|
33
32
|
export type { RuntimeMode, SmartCanvasRuntime, SmartCanvasRuntimeOptions } from './runtime';
|
|
34
33
|
export { createSmartCanvasRuntime, RUNTIME_VERSION } from './runtime';
|
|
35
34
|
export * from './state';
|
|
36
|
-
export * from './state';
|
|
37
35
|
export * from './surfaces';
|
|
38
36
|
export * from './widgets';
|
|
39
37
|
export type { SyntroInitOptions, SyntroInitResult } from './bootstrap';
|