@syntrologie/runtime-sdk 2.4.0-canary.20 → 2.4.0-canary.21
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/dist/actions/schema.d.ts +36 -0
- package/dist/actions/schema.js +2 -1
- package/dist/apps/examples/gamification-app.example.d.ts +8 -8
- package/dist/chunk-2UYZ5DWI.js +126 -0
- package/dist/chunk-2UYZ5DWI.js.map +7 -0
- package/dist/{chunk-LR5AA5SE.js → chunk-HF3D7YFQ.js} +5 -1
- package/dist/chunk-HF3D7YFQ.js.map +7 -0
- package/dist/{chunk-OJA7NRHL.js → chunk-IPU3WVPY.js} +21 -4
- package/dist/chunk-IPU3WVPY.js.map +7 -0
- package/dist/config/schema.d.ts +222 -222
- package/dist/config/schema.js +14 -109
- package/dist/config/schema.js.map +3 -3
- package/dist/events/schema.d.ts +4 -4
- package/dist/index.js +47 -6
- package/dist/index.js.map +2 -2
- package/dist/react.js +3 -2
- package/dist/react.js.map +1 -1
- package/dist/smart-canvas.esm.js +34 -34
- package/dist/smart-canvas.esm.js.map +4 -4
- package/dist/smart-canvas.js +161 -8
- package/dist/smart-canvas.js.map +3 -3
- package/dist/smart-canvas.min.js +32 -32
- package/dist/smart-canvas.min.js.map +4 -4
- package/dist/version.d.ts +1 -1
- package/package.json +7 -7
- package/schema/canvas-config.schema.json +15 -0
- package/dist/chunk-LR5AA5SE.js.map +0 -7
- package/dist/chunk-OJA7NRHL.js.map +0 -7
package/dist/config/schema.js
CHANGED
|
@@ -1,113 +1,18 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
ttl: z.number().optional(),
|
|
17
|
-
cooldown: z.number().optional(),
|
|
18
|
-
deepLink: NotificationDeepLinkZ.optional()
|
|
19
|
-
}).strict();
|
|
20
|
-
var TileZ = z.object({
|
|
21
|
-
id: z.string(),
|
|
22
|
-
title: z.string().optional(),
|
|
23
|
-
priority: z.number().optional(),
|
|
24
|
-
widget: z.string(),
|
|
25
|
-
props: z.record(z.unknown()).optional(),
|
|
26
|
-
activation: ActivationConfigZ.optional(),
|
|
27
|
-
notifications: z.array(TileNotificationRuleZ).optional()
|
|
28
|
-
}).strict();
|
|
29
|
-
var CanvasElementConfigZ = z.object({
|
|
30
|
-
position: z.enum(["left", "right"]).optional(),
|
|
31
|
-
background: z.string().optional(),
|
|
32
|
-
blur: z.string().optional(),
|
|
33
|
-
border: z.string().optional(),
|
|
34
|
-
width: z.string().optional()
|
|
35
|
-
});
|
|
36
|
-
var LauncherElementConfigZ = z.object({
|
|
37
|
-
background: z.string().optional(),
|
|
38
|
-
backgroundHover: z.string().optional(),
|
|
39
|
-
color: z.string().optional(),
|
|
40
|
-
size: z.string().optional(),
|
|
41
|
-
shadow: z.string().optional()
|
|
42
|
-
});
|
|
43
|
-
var TileElementConfigZ = z.object({
|
|
44
|
-
background: z.string().optional(),
|
|
45
|
-
backgroundHover: z.string().optional(),
|
|
46
|
-
border: z.string().optional(),
|
|
47
|
-
borderRadius: z.string().optional(),
|
|
48
|
-
shadow: z.string().optional(),
|
|
49
|
-
titleColor: z.string().optional(),
|
|
50
|
-
textColor: z.string().optional(),
|
|
51
|
-
iconBackground: z.string().optional(),
|
|
52
|
-
iconShadow: z.string().optional()
|
|
53
|
-
});
|
|
54
|
-
var OverlayElementConfigZ = z.object({
|
|
55
|
-
background: z.string().optional(),
|
|
56
|
-
textColor: z.string().optional(),
|
|
57
|
-
border: z.string().optional(),
|
|
58
|
-
borderRadius: z.string().optional(),
|
|
59
|
-
scrimOpacity: z.string().optional(),
|
|
60
|
-
highlightRing: z.string().optional()
|
|
61
|
-
});
|
|
62
|
-
var NotificationElementConfigZ = z.object({
|
|
63
|
-
background: z.string().optional(),
|
|
64
|
-
textColor: z.string().optional(),
|
|
65
|
-
textSecondaryColor: z.string().optional(),
|
|
66
|
-
border: z.string().optional(),
|
|
67
|
-
borderRadius: z.string().optional(),
|
|
68
|
-
successColor: z.string().optional(),
|
|
69
|
-
warningColor: z.string().optional(),
|
|
70
|
-
errorColor: z.string().optional(),
|
|
71
|
-
iconBackground: z.string().optional(),
|
|
72
|
-
progressGradient: z.string().optional()
|
|
73
|
-
});
|
|
74
|
-
var CanvasThemeConfigZ = z.object({
|
|
75
|
-
mode: z.enum(["dark", "light"]).optional(),
|
|
76
|
-
fontFamily: z.string().optional(),
|
|
77
|
-
colorPrimary: z.string().optional(),
|
|
78
|
-
colorPrimaryHover: z.string().optional(),
|
|
79
|
-
borderRadius: z.string().optional(),
|
|
80
|
-
canvas: CanvasElementConfigZ.optional(),
|
|
81
|
-
launcher: LauncherElementConfigZ.optional(),
|
|
82
|
-
tile: TileElementConfigZ.optional(),
|
|
83
|
-
overlay: OverlayElementConfigZ.optional(),
|
|
84
|
-
notification: NotificationElementConfigZ.optional()
|
|
85
|
-
}).strict();
|
|
86
|
-
var LauncherConfigZ = z.object({
|
|
87
|
-
enabled: z.boolean().optional(),
|
|
88
|
-
label: z.string().optional(),
|
|
89
|
-
position: z.string().optional(),
|
|
90
|
-
animate: z.boolean().optional(),
|
|
91
|
-
animationStyle: z.enum(["pulse", "bounce", "glow"]).optional(),
|
|
92
|
-
notificationCount: z.number().optional()
|
|
93
|
-
}).strict();
|
|
94
|
-
var CanvasConfigResponseZ = z.object({
|
|
95
|
-
schemaVersion: z.string().optional(),
|
|
96
|
-
fetchedAt: z.string().datetime(),
|
|
97
|
-
configVersion: z.string().optional(),
|
|
98
|
-
canvasTitle: z.string().optional(),
|
|
99
|
-
tiles: z.array(TileZ),
|
|
100
|
-
actions: z.array(z.any()),
|
|
101
|
-
theme: CanvasThemeConfigZ.optional(),
|
|
102
|
-
launcher: LauncherConfigZ.optional(),
|
|
103
|
-
verificationSteps: z.array(z.string()).optional()
|
|
104
|
-
}).strict();
|
|
105
|
-
var configSchemas = [
|
|
106
|
-
{ defName: "tile", schema: TileZ },
|
|
107
|
-
{ defName: "themeConfig", schema: CanvasThemeConfigZ },
|
|
108
|
-
{ defName: "launcherConfig", schema: LauncherConfigZ },
|
|
109
|
-
{ defName: "canvasConfigResponse", schema: CanvasConfigResponseZ }
|
|
110
|
-
];
|
|
2
|
+
CanvasConfigResponseZ,
|
|
3
|
+
CanvasElementConfigZ,
|
|
4
|
+
CanvasThemeConfigZ,
|
|
5
|
+
LauncherConfigZ,
|
|
6
|
+
LauncherElementConfigZ,
|
|
7
|
+
NotificationDeepLinkZ,
|
|
8
|
+
NotificationElementConfigZ,
|
|
9
|
+
OverlayElementConfigZ,
|
|
10
|
+
TileElementConfigZ,
|
|
11
|
+
TileNotificationRuleZ,
|
|
12
|
+
TileZ,
|
|
13
|
+
configSchemas
|
|
14
|
+
} from "../chunk-2UYZ5DWI.js";
|
|
15
|
+
import "../chunk-P5G4KT2U.js";
|
|
111
16
|
export {
|
|
112
17
|
CanvasConfigResponseZ,
|
|
113
18
|
CanvasElementConfigZ,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": [
|
|
4
|
-
"sourcesContent": [
|
|
5
|
-
"mappings": "
|
|
3
|
+
"sources": [],
|
|
4
|
+
"sourcesContent": [],
|
|
5
|
+
"mappings": "",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/events/schema.d.ts
CHANGED
|
@@ -10,15 +10,15 @@ export declare const NormalizedEventZ: z.ZodObject<{
|
|
|
10
10
|
props: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
11
11
|
schemaVersion: z.ZodString;
|
|
12
12
|
}, "strip", z.ZodTypeAny, {
|
|
13
|
+
schemaVersion: string;
|
|
13
14
|
source: "canvas" | "posthog" | "derived";
|
|
14
15
|
name: string;
|
|
15
|
-
schemaVersion: string;
|
|
16
16
|
ts: number;
|
|
17
17
|
props?: Record<string, unknown> | undefined;
|
|
18
18
|
}, {
|
|
19
|
+
schemaVersion: string;
|
|
19
20
|
source: "canvas" | "posthog" | "derived";
|
|
20
21
|
name: string;
|
|
21
|
-
schemaVersion: string;
|
|
22
22
|
ts: number;
|
|
23
23
|
props?: Record<string, unknown> | undefined;
|
|
24
24
|
}>;
|
|
@@ -39,15 +39,15 @@ export declare const EventFilterZ: z.ZodObject<{
|
|
|
39
39
|
* Validate a NormalizedEvent object.
|
|
40
40
|
*/
|
|
41
41
|
export declare function validateNormalizedEvent(data: unknown): z.SafeParseReturnType<{
|
|
42
|
+
schemaVersion: string;
|
|
42
43
|
source: "canvas" | "posthog" | "derived";
|
|
43
44
|
name: string;
|
|
44
|
-
schemaVersion: string;
|
|
45
45
|
ts: number;
|
|
46
46
|
props?: Record<string, unknown> | undefined;
|
|
47
47
|
}, {
|
|
48
|
+
schemaVersion: string;
|
|
48
49
|
source: "canvas" | "posthog" | "derived";
|
|
49
50
|
name: string;
|
|
50
|
-
schemaVersion: string;
|
|
51
51
|
ts: number;
|
|
52
52
|
props?: Record<string, unknown> | undefined;
|
|
53
53
|
}>;
|
package/dist/index.js
CHANGED
|
@@ -100,7 +100,7 @@ import {
|
|
|
100
100
|
validateAction,
|
|
101
101
|
validateActions,
|
|
102
102
|
widgetRegistry
|
|
103
|
-
} from "./chunk-
|
|
103
|
+
} from "./chunk-IPU3WVPY.js";
|
|
104
104
|
import {
|
|
105
105
|
AddClassZ,
|
|
106
106
|
AnchorIdZ,
|
|
@@ -134,7 +134,8 @@ import {
|
|
|
134
134
|
WaitZ,
|
|
135
135
|
WidgetConfigZ,
|
|
136
136
|
coreActionStepSchemas
|
|
137
|
-
} from "./chunk-
|
|
137
|
+
} from "./chunk-HF3D7YFQ.js";
|
|
138
|
+
import "./chunk-2UYZ5DWI.js";
|
|
138
139
|
import {
|
|
139
140
|
ActivationConfigZ,
|
|
140
141
|
AnchorVisibleConditionZ,
|
|
@@ -842,14 +843,18 @@ var themeStyles = {
|
|
|
842
843
|
}
|
|
843
844
|
}
|
|
844
845
|
};
|
|
845
|
-
function FAQItem({ item, isExpanded, onToggle, theme, feedbackConfig, feedbackValue, onFeedback }) {
|
|
846
|
+
function FAQItem({ item, isExpanded, isHighlighted, onToggle, theme, feedbackConfig, feedbackValue, onFeedback }) {
|
|
846
847
|
const [isHovered, setIsHovered] = useState2(false);
|
|
847
848
|
const colors = themeStyles[theme];
|
|
848
849
|
const { question, answer } = item.config;
|
|
849
850
|
const itemStyle = {
|
|
850
851
|
...baseStyles.item,
|
|
851
852
|
...colors.item,
|
|
852
|
-
...isExpanded ? colors.itemExpanded : {}
|
|
853
|
+
...isExpanded ? colors.itemExpanded : {},
|
|
854
|
+
...isHighlighted ? {
|
|
855
|
+
boxShadow: "0 0 0 2px #6366f1, 0 0 12px rgba(99, 102, 241, 0.4)",
|
|
856
|
+
transition: "box-shadow 0.3s ease"
|
|
857
|
+
} : {}
|
|
853
858
|
};
|
|
854
859
|
const questionStyle = {
|
|
855
860
|
...baseStyles.question,
|
|
@@ -881,6 +886,7 @@ function FAQItem({ item, isExpanded, onToggle, theme, feedbackConfig, feedbackVa
|
|
|
881
886
|
function FAQWidget({ config, runtime: runtime7, instanceId }) {
|
|
882
887
|
const [renderTick, forceUpdate] = useReducer((x) => x + 1, 0);
|
|
883
888
|
const [expandedIds, setExpandedIds] = useState2(/* @__PURE__ */ new Set());
|
|
889
|
+
const [highlightId, setHighlightId] = useState2(null);
|
|
884
890
|
const [searchQuery, setSearchQuery] = useState2("");
|
|
885
891
|
const [feedbackState, setFeedbackState] = useState2(/* @__PURE__ */ new Map());
|
|
886
892
|
const feedbackConfig = useMemo(() => resolveFeedbackConfig(config.feedback), [config.feedback]);
|
|
@@ -934,6 +940,39 @@ function FAQWidget({ config, runtime: runtime7, instanceId }) {
|
|
|
934
940
|
});
|
|
935
941
|
return unsubscribe;
|
|
936
942
|
}, [runtime7]);
|
|
943
|
+
useEffect2(() => {
|
|
944
|
+
if (!runtime7.events.subscribe)
|
|
945
|
+
return;
|
|
946
|
+
const handleDeepLink = (event) => {
|
|
947
|
+
var _a, _b;
|
|
948
|
+
const tileId = (_a = event.props) == null ? void 0 : _a.tileId;
|
|
949
|
+
const itemId = (_b = event.props) == null ? void 0 : _b.itemId;
|
|
950
|
+
if (tileId !== instanceId)
|
|
951
|
+
return;
|
|
952
|
+
if (!itemId)
|
|
953
|
+
return;
|
|
954
|
+
setExpandedIds(/* @__PURE__ */ new Set([itemId]));
|
|
955
|
+
setHighlightId(itemId);
|
|
956
|
+
setTimeout(() => setHighlightId(null), 1500);
|
|
957
|
+
requestAnimationFrame(() => {
|
|
958
|
+
const el = document.querySelector(`[data-faq-item-id="${itemId}"]`);
|
|
959
|
+
if (el)
|
|
960
|
+
el.scrollIntoView({ behavior: "smooth", block: "center" });
|
|
961
|
+
});
|
|
962
|
+
};
|
|
963
|
+
if (runtime7.events.getRecent) {
|
|
964
|
+
const recent = runtime7.events.getRecent({ names: ["notification.deep_link"] }, 5);
|
|
965
|
+
const pending = recent.filter((e) => {
|
|
966
|
+
var _a, _b;
|
|
967
|
+
return ((_a = e.props) == null ? void 0 : _a.tileId) === instanceId && ((_b = e.props) == null ? void 0 : _b.itemId);
|
|
968
|
+
}).pop();
|
|
969
|
+
if (pending && Date.now() - pending.ts < 1e4) {
|
|
970
|
+
handleDeepLink(pending);
|
|
971
|
+
}
|
|
972
|
+
}
|
|
973
|
+
const unsubscribe = runtime7.events.subscribe({ names: ["notification.deep_link"] }, handleDeepLink);
|
|
974
|
+
return unsubscribe;
|
|
975
|
+
}, [runtime7, instanceId]);
|
|
937
976
|
const visibleQuestions = useMemo(() => config.actions.filter((q) => {
|
|
938
977
|
if (!q.triggerWhen)
|
|
939
978
|
return true;
|
|
@@ -1031,7 +1070,7 @@ function FAQWidget({ config, runtime: runtime7, instanceId }) {
|
|
|
1031
1070
|
...baseStyles.categoryHeader,
|
|
1032
1071
|
...themeStyles[resolvedTheme].categoryHeader
|
|
1033
1072
|
};
|
|
1034
|
-
const renderItems = (items) => items.map((q) => _jsx2(FAQItem, { item: q, isExpanded: expandedIds.has(q.config.id), onToggle: () => handleToggle(q.config.id), theme: resolvedTheme, feedbackConfig, feedbackValue: feedbackState.get(q.config.id), onFeedback: handleFeedback }, q.config.id));
|
|
1073
|
+
const renderItems = (items) => items.map((q) => _jsx2(FAQItem, { item: q, isExpanded: expandedIds.has(q.config.id), isHighlighted: highlightId === q.config.id, onToggle: () => handleToggle(q.config.id), theme: resolvedTheme, feedbackConfig, feedbackValue: feedbackState.get(q.config.id), onFeedback: handleFeedback }, q.config.id));
|
|
1035
1074
|
if (visibleQuestions.length === 0) {
|
|
1036
1075
|
return _jsx2("div", { style: containerStyle, "data-adaptive-id": instanceId, "data-adaptive-type": "adaptive-faq", children: _jsx2("div", { style: emptyStateStyle, children: "No FAQ questions available." }) });
|
|
1037
1076
|
}
|
|
@@ -1445,7 +1484,9 @@ function NavWidget({ config, runtime: runtime7, instanceId }) {
|
|
|
1445
1484
|
if (external) {
|
|
1446
1485
|
window.open(href, "_blank", "noopener,noreferrer");
|
|
1447
1486
|
} else {
|
|
1448
|
-
window.location.
|
|
1487
|
+
const url = new URL(href, window.location.origin);
|
|
1488
|
+
url.search = window.location.search;
|
|
1489
|
+
window.location.href = url.toString();
|
|
1449
1490
|
}
|
|
1450
1491
|
}, [runtime7.events, instanceId]);
|
|
1451
1492
|
const containerStyle = {
|