@mmapp/react 0.1.0-alpha.11 → 0.1.0-alpha.13
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/index.d.mts +84 -1
- package/dist/index.d.ts +84 -1
- package/dist/index.js +635 -76
- package/dist/index.mjs +628 -72
- package/package.json +9 -4
package/dist/index.js
CHANGED
|
@@ -33,22 +33,24 @@ __export(index_exports, {
|
|
|
33
33
|
Accordion: () => Accordion,
|
|
34
34
|
AnimatedBox: () => AnimatedBox,
|
|
35
35
|
BUILT_IN_CONSTRAINTS: () => BUILT_IN_CONSTRAINTS,
|
|
36
|
-
Badge: () =>
|
|
36
|
+
Badge: () => Badge2,
|
|
37
37
|
Blueprint: () => Blueprint,
|
|
38
38
|
BrowserPlayer: () => BrowserPlayer,
|
|
39
|
-
Button: () =>
|
|
39
|
+
Button: () => Button2,
|
|
40
40
|
Canvas3D: () => Canvas3D,
|
|
41
|
-
Card: () =>
|
|
41
|
+
Card: () => Card2,
|
|
42
42
|
Chart: () => Chart,
|
|
43
|
-
Column: () =>
|
|
43
|
+
Column: () => Column2,
|
|
44
|
+
ComponentTreeRenderer: () => ComponentTreeRenderer,
|
|
44
45
|
DataGrid: () => DataGrid,
|
|
45
|
-
|
|
46
|
-
|
|
46
|
+
DevPlayer: () => DevPlayer,
|
|
47
|
+
Divider: () => Divider2,
|
|
48
|
+
Each: () => Each2,
|
|
47
49
|
ExperienceWorkflowBridge: () => ExperienceWorkflowBridge,
|
|
48
|
-
Field: () =>
|
|
50
|
+
Field: () => Field2,
|
|
49
51
|
FieldBuilder: () => FieldBuilder,
|
|
50
|
-
Grid: () =>
|
|
51
|
-
Heading: () =>
|
|
52
|
+
Grid: () => Grid2,
|
|
53
|
+
Heading: () => Heading2,
|
|
52
54
|
Icon: () => Icon,
|
|
53
55
|
Image: () => Image,
|
|
54
56
|
Link: () => Link,
|
|
@@ -64,20 +66,20 @@ __export(index_exports, {
|
|
|
64
66
|
RoleGuard: () => RoleGuard,
|
|
65
67
|
Route: () => Route,
|
|
66
68
|
Router: () => Router,
|
|
67
|
-
Row: () =>
|
|
69
|
+
Row: () => Row2,
|
|
68
70
|
RuntimeContext: () => RuntimeContext,
|
|
69
71
|
ScrollArea: () => ScrollArea,
|
|
70
|
-
Section: () =>
|
|
72
|
+
Section: () => Section2,
|
|
71
73
|
Select: () => Select,
|
|
72
74
|
ServerGrid: () => ServerGrid,
|
|
73
|
-
Show: () =>
|
|
75
|
+
Show: () => Show2,
|
|
74
76
|
Slot: () => Slot,
|
|
75
|
-
Spacer: () =>
|
|
76
|
-
Stack: () =>
|
|
77
|
+
Spacer: () => Spacer2,
|
|
78
|
+
Stack: () => Stack2,
|
|
77
79
|
StateBuilder: () => StateBuilder,
|
|
78
80
|
Tabs: () => Tabs,
|
|
79
|
-
Text: () =>
|
|
80
|
-
TextInput: () =>
|
|
81
|
+
Text: () => Text2,
|
|
82
|
+
TextInput: () => TextInput2,
|
|
81
83
|
TransitionBuilder: () => TransitionBuilder,
|
|
82
84
|
TypedTransitionBuilder: () => TypedTransitionBuilder,
|
|
83
85
|
WorkflowProvider: () => WorkflowProvider,
|
|
@@ -90,6 +92,7 @@ __export(index_exports, {
|
|
|
90
92
|
applyMixins: () => applyMixins,
|
|
91
93
|
approval: () => approval,
|
|
92
94
|
assertModelValid: () => assertModelValid,
|
|
95
|
+
builtinAtoms: () => builtinAtoms,
|
|
93
96
|
cedar: () => cedar,
|
|
94
97
|
compose: () => compose,
|
|
95
98
|
computeVisibility: () => computeVisibility,
|
|
@@ -257,7 +260,7 @@ __export(index_exports, {
|
|
|
257
260
|
useVisibility: () => useVisibility,
|
|
258
261
|
useWhileIn: () => useWhileIn,
|
|
259
262
|
useWorkflow: () => useWorkflow,
|
|
260
|
-
useWorkflowState: () =>
|
|
263
|
+
useWorkflowState: () => useState22,
|
|
261
264
|
userAction: () => userAction,
|
|
262
265
|
userChoice: () => userChoice,
|
|
263
266
|
validate: () => validate,
|
|
@@ -3878,6 +3881,559 @@ function useCollection(definition, options = {}) {
|
|
|
3878
3881
|
return handle;
|
|
3879
3882
|
}
|
|
3880
3883
|
|
|
3884
|
+
// src/player/ComponentTreeRenderer.tsx
|
|
3885
|
+
var import_react35 = __toESM(require("react"));
|
|
3886
|
+
|
|
3887
|
+
// src/player/evaluator.ts
|
|
3888
|
+
var EXPR_PATTERN = /\{\{(.+?)\}\}/g;
|
|
3889
|
+
function containsExpression(value) {
|
|
3890
|
+
return typeof value === "string" && EXPR_PATTERN.test(value);
|
|
3891
|
+
}
|
|
3892
|
+
function resolvePath(path, scope) {
|
|
3893
|
+
const parts = path.trim().split(".");
|
|
3894
|
+
let current = scope;
|
|
3895
|
+
for (const part of parts) {
|
|
3896
|
+
if (current == null || typeof current !== "object") return void 0;
|
|
3897
|
+
current = current[part];
|
|
3898
|
+
}
|
|
3899
|
+
return current;
|
|
3900
|
+
}
|
|
3901
|
+
function evaluateExpression(expr2, scopes) {
|
|
3902
|
+
const trimmed = expr2.trim();
|
|
3903
|
+
if (trimmed.startsWith("'") && trimmed.endsWith("'") || trimmed.startsWith('"') && trimmed.endsWith('"')) {
|
|
3904
|
+
return trimmed.slice(1, -1);
|
|
3905
|
+
}
|
|
3906
|
+
if (/^-?\d+(\.\d+)?$/.test(trimmed)) {
|
|
3907
|
+
return Number(trimmed);
|
|
3908
|
+
}
|
|
3909
|
+
if (trimmed === "true") return true;
|
|
3910
|
+
if (trimmed === "false") return false;
|
|
3911
|
+
if (trimmed === "null" || trimmed === "undefined") return void 0;
|
|
3912
|
+
const flatScope = { ...scopes };
|
|
3913
|
+
if (scopes.state_data && typeof scopes.state_data === "object") {
|
|
3914
|
+
Object.assign(flatScope, scopes.state_data);
|
|
3915
|
+
}
|
|
3916
|
+
if (scopes.context && typeof scopes.context === "object") {
|
|
3917
|
+
Object.assign(flatScope, scopes.context);
|
|
3918
|
+
}
|
|
3919
|
+
return resolvePath(trimmed, flatScope);
|
|
3920
|
+
}
|
|
3921
|
+
function evaluateProp(value, scopes) {
|
|
3922
|
+
if (typeof value !== "string") return value;
|
|
3923
|
+
const fullMatch = value.match(/^\{\{(.+)\}\}$/s);
|
|
3924
|
+
if (fullMatch) {
|
|
3925
|
+
return evaluateExpression(fullMatch[1], scopes);
|
|
3926
|
+
}
|
|
3927
|
+
if (containsExpression(value)) {
|
|
3928
|
+
return value.replace(EXPR_PATTERN, (_, expr2) => {
|
|
3929
|
+
const result = evaluateExpression(expr2, scopes);
|
|
3930
|
+
return result == null ? "" : String(result);
|
|
3931
|
+
});
|
|
3932
|
+
}
|
|
3933
|
+
return value;
|
|
3934
|
+
}
|
|
3935
|
+
|
|
3936
|
+
// src/player/ComponentTreeRenderer.tsx
|
|
3937
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
3938
|
+
var UnknownAtom = ({ type, children }) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { border: "1px dashed #e53e3e", borderRadius: 6, padding: "8px 12px", margin: 4, fontSize: 13, color: "#e53e3e", background: "#fff5f5" }, children: [
|
|
3939
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { style: { fontWeight: 600 }, children: [
|
|
3940
|
+
"Unknown: ",
|
|
3941
|
+
type
|
|
3942
|
+
] }),
|
|
3943
|
+
children && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: { marginTop: 4 }, children })
|
|
3944
|
+
] });
|
|
3945
|
+
var RenderNode = ({ node, scopes, atoms, onEvent }) => {
|
|
3946
|
+
if (node.$if) {
|
|
3947
|
+
const condition = evaluateProp(node.$if, scopes);
|
|
3948
|
+
if (!condition) return null;
|
|
3949
|
+
}
|
|
3950
|
+
if (node.$for) {
|
|
3951
|
+
const { each, as, key: keyField } = node.$for;
|
|
3952
|
+
const items = evaluateProp(each, scopes);
|
|
3953
|
+
if (!Array.isArray(items)) return null;
|
|
3954
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_jsx_runtime2.Fragment, { children: items.map((item, index) => {
|
|
3955
|
+
const loopScopes = {
|
|
3956
|
+
...scopes,
|
|
3957
|
+
state_data: {
|
|
3958
|
+
...scopes.state_data ?? {},
|
|
3959
|
+
[as]: item,
|
|
3960
|
+
[`${as}Index`]: index
|
|
3961
|
+
}
|
|
3962
|
+
};
|
|
3963
|
+
const nodeWithoutFor = { ...node, $for: void 0 };
|
|
3964
|
+
const itemKey = keyField ? String(item[keyField] ?? index) : String(index);
|
|
3965
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(RenderNode, { node: nodeWithoutFor, scopes: loopScopes, atoms, onEvent }, itemKey);
|
|
3966
|
+
}) });
|
|
3967
|
+
}
|
|
3968
|
+
const Component = atoms[node.type];
|
|
3969
|
+
if (!Component) {
|
|
3970
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(UnknownAtom, { type: node.type });
|
|
3971
|
+
}
|
|
3972
|
+
const evaluatedProps = {};
|
|
3973
|
+
if (node.props) {
|
|
3974
|
+
for (const [key, value] of Object.entries(node.props)) {
|
|
3975
|
+
if (key.startsWith("on") && typeof value === "string") {
|
|
3976
|
+
evaluatedProps[key] = (...args) => {
|
|
3977
|
+
if (containsExpression(value)) {
|
|
3978
|
+
evaluateExpression(value.replace(/^\{\{|\}\}$/g, ""), scopes);
|
|
3979
|
+
} else {
|
|
3980
|
+
onEvent(value, args[0]);
|
|
3981
|
+
}
|
|
3982
|
+
};
|
|
3983
|
+
} else {
|
|
3984
|
+
evaluatedProps[key] = evaluateProp(value, scopes);
|
|
3985
|
+
}
|
|
3986
|
+
}
|
|
3987
|
+
}
|
|
3988
|
+
let children = null;
|
|
3989
|
+
if (node.children) {
|
|
3990
|
+
if (typeof node.children === "string") {
|
|
3991
|
+
children = evaluateProp(node.children, scopes);
|
|
3992
|
+
} else if (Array.isArray(node.children)) {
|
|
3993
|
+
children = node.children.map((child, index) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(RenderNode, { node: child, scopes, atoms, onEvent }, index));
|
|
3994
|
+
}
|
|
3995
|
+
}
|
|
3996
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Component, { ...evaluatedProps, children });
|
|
3997
|
+
};
|
|
3998
|
+
var CTRErrorBoundary = class extends import_react35.default.Component {
|
|
3999
|
+
constructor(props) {
|
|
4000
|
+
super(props);
|
|
4001
|
+
this.state = { hasError: false };
|
|
4002
|
+
}
|
|
4003
|
+
static getDerivedStateFromError(error) {
|
|
4004
|
+
return { hasError: true, error };
|
|
4005
|
+
}
|
|
4006
|
+
componentDidCatch(error, errorInfo) {
|
|
4007
|
+
console.error("CTR rendering error:", error, errorInfo);
|
|
4008
|
+
}
|
|
4009
|
+
render() {
|
|
4010
|
+
if (this.state.hasError) {
|
|
4011
|
+
return this.props.fallback || /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { padding: 16, background: "#fff5f5", border: "1px solid #fed7d7", borderRadius: 8 }, children: [
|
|
4012
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("strong", { style: { color: "#c53030" }, children: "Rendering Error" }),
|
|
4013
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { style: { color: "#e53e3e", fontSize: 14, marginTop: 4 }, children: this.state.error?.message || "An error occurred while rendering" })
|
|
4014
|
+
] });
|
|
4015
|
+
}
|
|
4016
|
+
return this.props.children;
|
|
4017
|
+
}
|
|
4018
|
+
};
|
|
4019
|
+
var ComponentTreeRenderer = ({
|
|
4020
|
+
tree,
|
|
4021
|
+
scopes,
|
|
4022
|
+
atoms = {},
|
|
4023
|
+
onEvent = () => {
|
|
4024
|
+
},
|
|
4025
|
+
fallback
|
|
4026
|
+
}) => {
|
|
4027
|
+
const allAtoms = (0, import_react35.useMemo)(() => ({ ...atoms }), [atoms]);
|
|
4028
|
+
const handleEvent = (0, import_react35.useCallback)(
|
|
4029
|
+
(eventName, payload) => onEvent(eventName, payload),
|
|
4030
|
+
[onEvent]
|
|
4031
|
+
);
|
|
4032
|
+
const nodes = Array.isArray(tree) ? tree : [tree];
|
|
4033
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(CTRErrorBoundary, { fallback, children: nodes.map((node, index) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(RenderNode, { node, scopes, atoms: allAtoms, onEvent: handleEvent }, index)) });
|
|
4034
|
+
};
|
|
4035
|
+
|
|
4036
|
+
// src/player/DevPlayer.tsx
|
|
4037
|
+
var import_react36 = require("react");
|
|
4038
|
+
|
|
4039
|
+
// src/player/builtin-atoms.tsx
|
|
4040
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
4041
|
+
var Stack = ({ children, gap = 8, style, ...rest }) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: { display: "flex", flexDirection: "column", gap, ...style }, ...rest, children });
|
|
4042
|
+
var Row = ({ children, gap = 8, align, justify, style, ...rest }) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: { display: "flex", flexDirection: "row", gap, alignItems: align, justifyContent: justify, ...style }, ...rest, children });
|
|
4043
|
+
var Column = ({ children, span, style, ...rest }) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: { flex: span ? `0 0 ${Number(span) / 12 * 100}%` : 1, ...style }, ...rest, children });
|
|
4044
|
+
var Grid = ({ children, columns = 2, gap = 8, style, ...rest }) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: { display: "grid", gridTemplateColumns: `repeat(${columns}, 1fr)`, gap, ...style }, ...rest, children });
|
|
4045
|
+
var Divider = ({ style }) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("hr", { style: { border: "none", borderTop: "1px solid #e2e8f0", margin: "8px 0", ...style } });
|
|
4046
|
+
var Spacer = ({ size = 16 }) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: { height: size, flexShrink: 0 } });
|
|
4047
|
+
var Text = ({ children, size, weight, color, style, ...rest }) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { style: { fontSize: size, fontWeight: weight, color, ...style }, ...rest, children });
|
|
4048
|
+
var Heading = ({ children, level = 2, style, ...rest }) => {
|
|
4049
|
+
const lvl = Math.min(Math.max(Number(level), 1), 6);
|
|
4050
|
+
const s = { margin: "0 0 8px", ...style };
|
|
4051
|
+
const c = children;
|
|
4052
|
+
if (lvl === 1) return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("h1", { style: s, ...rest, children: c });
|
|
4053
|
+
if (lvl === 2) return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("h2", { style: s, ...rest, children: c });
|
|
4054
|
+
if (lvl === 3) return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("h3", { style: s, ...rest, children: c });
|
|
4055
|
+
if (lvl === 4) return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("h4", { style: s, ...rest, children: c });
|
|
4056
|
+
if (lvl === 5) return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("h5", { style: s, ...rest, children: c });
|
|
4057
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("h6", { style: s, ...rest, children: c });
|
|
4058
|
+
};
|
|
4059
|
+
var Field = ({ label, value, children, style }) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { style: { marginBottom: 8, ...style }, children: [
|
|
4060
|
+
label ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: { fontSize: 12, color: "#718096", marginBottom: 2 }, children: label }) : null,
|
|
4061
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: { fontSize: 14 }, children: children ?? value ?? "\u2014" })
|
|
4062
|
+
] });
|
|
4063
|
+
var Badge = ({ children, variant = "default", style }) => {
|
|
4064
|
+
const colors = {
|
|
4065
|
+
default: { bg: "#edf2f7", fg: "#4a5568" },
|
|
4066
|
+
success: { bg: "#c6f6d5", fg: "#276749" },
|
|
4067
|
+
warning: { bg: "#fefcbf", fg: "#975a16" },
|
|
4068
|
+
error: { bg: "#fed7d7", fg: "#9b2c2c" },
|
|
4069
|
+
info: { bg: "#bee3f8", fg: "#2a4365" }
|
|
4070
|
+
};
|
|
4071
|
+
const c = colors[variant] ?? colors.default;
|
|
4072
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { style: { display: "inline-block", padding: "2px 8px", borderRadius: 9999, fontSize: 12, fontWeight: 500, background: c.bg, color: c.fg, ...style }, children });
|
|
4073
|
+
};
|
|
4074
|
+
var ImageAtom = ({ src, alt, width, height, style, ...rest }) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("img", { src, alt: alt ?? "", width, height, style: { maxWidth: "100%", ...style }, ...rest });
|
|
4075
|
+
var Button = ({ children, onClick, variant = "primary", disabled, style, ...rest }) => {
|
|
4076
|
+
const styles = {
|
|
4077
|
+
primary: { background: "#3182ce", color: "#fff", border: "none" },
|
|
4078
|
+
secondary: { background: "#edf2f7", color: "#4a5568", border: "1px solid #e2e8f0" },
|
|
4079
|
+
danger: { background: "#e53e3e", color: "#fff", border: "none" },
|
|
4080
|
+
ghost: { background: "transparent", color: "#4a5568", border: "none" }
|
|
4081
|
+
};
|
|
4082
|
+
const base = styles[variant] ?? styles.primary;
|
|
4083
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
4084
|
+
"button",
|
|
4085
|
+
{
|
|
4086
|
+
onClick,
|
|
4087
|
+
disabled,
|
|
4088
|
+
style: { padding: "6px 16px", borderRadius: 6, fontSize: 14, fontWeight: 500, cursor: disabled ? "not-allowed" : "pointer", opacity: disabled ? 0.5 : 1, ...base, ...style },
|
|
4089
|
+
...rest,
|
|
4090
|
+
children
|
|
4091
|
+
}
|
|
4092
|
+
);
|
|
4093
|
+
};
|
|
4094
|
+
var LinkAtom = ({ children, href, style, ...rest }) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("a", { href, style: { color: "#3182ce", textDecoration: "underline", ...style }, ...rest, children });
|
|
4095
|
+
var TextInput = ({ value, onChange, placeholder, label, style, ...rest }) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { style: { marginBottom: 8 }, children: [
|
|
4096
|
+
label ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("label", { style: { display: "block", fontSize: 12, color: "#718096", marginBottom: 2 }, children: label }) : null,
|
|
4097
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
4098
|
+
"input",
|
|
4099
|
+
{
|
|
4100
|
+
type: "text",
|
|
4101
|
+
value: value ?? "",
|
|
4102
|
+
onChange,
|
|
4103
|
+
placeholder,
|
|
4104
|
+
style: { width: "100%", padding: "6px 10px", border: "1px solid #e2e8f0", borderRadius: 6, fontSize: 14, ...style },
|
|
4105
|
+
...rest
|
|
4106
|
+
}
|
|
4107
|
+
)
|
|
4108
|
+
] });
|
|
4109
|
+
var SelectAtom = ({ value, onChange, options, label, placeholder, style }) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { style: { marginBottom: 8 }, children: [
|
|
4110
|
+
label ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("label", { style: { display: "block", fontSize: 12, color: "#718096", marginBottom: 2 }, children: label }) : null,
|
|
4111
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
4112
|
+
"select",
|
|
4113
|
+
{
|
|
4114
|
+
value: value ?? "",
|
|
4115
|
+
onChange,
|
|
4116
|
+
style: { width: "100%", padding: "6px 10px", border: "1px solid #e2e8f0", borderRadius: 6, fontSize: 14, ...style },
|
|
4117
|
+
children: [
|
|
4118
|
+
placeholder ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("option", { value: "", children: placeholder }) : null,
|
|
4119
|
+
Array.isArray(options) && options.map((opt) => {
|
|
4120
|
+
const v = typeof opt === "string" ? opt : opt.value;
|
|
4121
|
+
const l = typeof opt === "string" ? opt : opt.label;
|
|
4122
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("option", { value: v, children: l }, v);
|
|
4123
|
+
})
|
|
4124
|
+
]
|
|
4125
|
+
}
|
|
4126
|
+
)
|
|
4127
|
+
] });
|
|
4128
|
+
var Card = ({ children, title, style, ...rest }) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { style: { border: "1px solid #e2e8f0", borderRadius: 8, padding: 16, background: "#fff", ...style }, ...rest, children: [
|
|
4129
|
+
title ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: { fontWeight: 600, fontSize: 16, marginBottom: 12 }, children: title }) : null,
|
|
4130
|
+
children
|
|
4131
|
+
] });
|
|
4132
|
+
var Section = ({ children, title, style, ...rest }) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("section", { style: { marginBottom: 24, ...style }, ...rest, children: [
|
|
4133
|
+
title ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("h3", { style: { fontSize: 18, fontWeight: 600, marginBottom: 8 }, children: title }) : null,
|
|
4134
|
+
children
|
|
4135
|
+
] });
|
|
4136
|
+
var Show = ({ when: when2, children, fallback }) => when2 ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_jsx_runtime3.Fragment, { children }) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_jsx_runtime3.Fragment, { children: fallback ?? null });
|
|
4137
|
+
var Each = ({ items, children, renderItem }) => {
|
|
4138
|
+
if (!Array.isArray(items)) return null;
|
|
4139
|
+
if (typeof renderItem === "function") return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_jsx_runtime3.Fragment, { children: items.map((item, i) => renderItem(item, i)) });
|
|
4140
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_jsx_runtime3.Fragment, { children });
|
|
4141
|
+
};
|
|
4142
|
+
var builtinAtoms = {
|
|
4143
|
+
Stack,
|
|
4144
|
+
Row,
|
|
4145
|
+
Column,
|
|
4146
|
+
Grid,
|
|
4147
|
+
Divider,
|
|
4148
|
+
Spacer,
|
|
4149
|
+
Text,
|
|
4150
|
+
Heading,
|
|
4151
|
+
Field,
|
|
4152
|
+
Badge,
|
|
4153
|
+
Image: ImageAtom,
|
|
4154
|
+
Button,
|
|
4155
|
+
Link: LinkAtom,
|
|
4156
|
+
TextInput,
|
|
4157
|
+
Select: SelectAtom,
|
|
4158
|
+
Card,
|
|
4159
|
+
Section,
|
|
4160
|
+
Show,
|
|
4161
|
+
Each
|
|
4162
|
+
};
|
|
4163
|
+
|
|
4164
|
+
// src/player/DevPlayer.tsx
|
|
4165
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
4166
|
+
var S = {
|
|
4167
|
+
shell: {
|
|
4168
|
+
display: "flex",
|
|
4169
|
+
flexDirection: "column",
|
|
4170
|
+
height: "100%",
|
|
4171
|
+
minHeight: "100vh",
|
|
4172
|
+
fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',
|
|
4173
|
+
background: "#f7fafc",
|
|
4174
|
+
color: "#1a202c"
|
|
4175
|
+
},
|
|
4176
|
+
toolbar: {
|
|
4177
|
+
display: "flex",
|
|
4178
|
+
alignItems: "center",
|
|
4179
|
+
gap: 12,
|
|
4180
|
+
padding: "8px 16px",
|
|
4181
|
+
background: "#1a202c",
|
|
4182
|
+
color: "#e2e8f0",
|
|
4183
|
+
fontSize: 13,
|
|
4184
|
+
flexShrink: 0
|
|
4185
|
+
},
|
|
4186
|
+
toolbarTitle: { fontWeight: 600, fontSize: 14 },
|
|
4187
|
+
toolbarBadge: {
|
|
4188
|
+
display: "inline-block",
|
|
4189
|
+
padding: "1px 8px",
|
|
4190
|
+
borderRadius: 4,
|
|
4191
|
+
background: "#2d3748",
|
|
4192
|
+
color: "#a0aec0",
|
|
4193
|
+
fontSize: 11,
|
|
4194
|
+
fontFamily: "monospace"
|
|
4195
|
+
},
|
|
4196
|
+
toolbarBtn: {
|
|
4197
|
+
background: "none",
|
|
4198
|
+
border: "1px solid #4a5568",
|
|
4199
|
+
borderRadius: 4,
|
|
4200
|
+
color: "#a0aec0",
|
|
4201
|
+
padding: "2px 10px",
|
|
4202
|
+
fontSize: 12,
|
|
4203
|
+
cursor: "pointer"
|
|
4204
|
+
},
|
|
4205
|
+
toolbarBtnActive: {
|
|
4206
|
+
background: "#2b6cb0",
|
|
4207
|
+
borderColor: "#2b6cb0",
|
|
4208
|
+
color: "#fff"
|
|
4209
|
+
},
|
|
4210
|
+
body: { display: "flex", flex: 1, overflow: "hidden" },
|
|
4211
|
+
preview: { flex: 1, overflow: "auto", padding: 24 },
|
|
4212
|
+
sidebar: {
|
|
4213
|
+
width: 340,
|
|
4214
|
+
flexShrink: 0,
|
|
4215
|
+
borderLeft: "1px solid #e2e8f0",
|
|
4216
|
+
background: "#fff",
|
|
4217
|
+
overflow: "auto",
|
|
4218
|
+
fontSize: 13
|
|
4219
|
+
},
|
|
4220
|
+
sidebarSection: { padding: "12px 16px", borderBottom: "1px solid #f0f0f0" },
|
|
4221
|
+
sidebarHeading: {
|
|
4222
|
+
fontSize: 11,
|
|
4223
|
+
fontWeight: 700,
|
|
4224
|
+
textTransform: "uppercase",
|
|
4225
|
+
color: "#a0aec0",
|
|
4226
|
+
letterSpacing: "0.05em",
|
|
4227
|
+
marginBottom: 8
|
|
4228
|
+
},
|
|
4229
|
+
pre: {
|
|
4230
|
+
background: "#f7fafc",
|
|
4231
|
+
border: "1px solid #e2e8f0",
|
|
4232
|
+
borderRadius: 6,
|
|
4233
|
+
padding: "8px 12px",
|
|
4234
|
+
fontSize: 12,
|
|
4235
|
+
fontFamily: "monospace",
|
|
4236
|
+
whiteSpace: "pre-wrap",
|
|
4237
|
+
wordBreak: "break-word",
|
|
4238
|
+
maxHeight: 260,
|
|
4239
|
+
overflow: "auto"
|
|
4240
|
+
},
|
|
4241
|
+
eventRow: {
|
|
4242
|
+
display: "flex",
|
|
4243
|
+
gap: 8,
|
|
4244
|
+
padding: "4px 0",
|
|
4245
|
+
borderBottom: "1px solid #f7fafc",
|
|
4246
|
+
fontSize: 12,
|
|
4247
|
+
fontFamily: "monospace"
|
|
4248
|
+
},
|
|
4249
|
+
eventTime: { color: "#a0aec0", flexShrink: 0 },
|
|
4250
|
+
eventName: { color: "#3182ce", fontWeight: 500 },
|
|
4251
|
+
dot: (connected) => ({
|
|
4252
|
+
width: 8,
|
|
4253
|
+
height: 8,
|
|
4254
|
+
borderRadius: "50%",
|
|
4255
|
+
background: connected ? "#48bb78" : "#e53e3e",
|
|
4256
|
+
flexShrink: 0
|
|
4257
|
+
})
|
|
4258
|
+
};
|
|
4259
|
+
function useDevSocket(wsUrl, onReload) {
|
|
4260
|
+
const [connected, setConnected] = (0, import_react36.useState)(false);
|
|
4261
|
+
const wsRef = (0, import_react36.useRef)(null);
|
|
4262
|
+
(0, import_react36.useEffect)(() => {
|
|
4263
|
+
if (typeof window === "undefined") return;
|
|
4264
|
+
const url = wsUrl ?? `ws://${window.location.host}/__mm_dev`;
|
|
4265
|
+
let ws;
|
|
4266
|
+
let reconnectTimer;
|
|
4267
|
+
function connect() {
|
|
4268
|
+
try {
|
|
4269
|
+
ws = new WebSocket(url);
|
|
4270
|
+
wsRef.current = ws;
|
|
4271
|
+
ws.onopen = () => setConnected(true);
|
|
4272
|
+
ws.onclose = () => {
|
|
4273
|
+
setConnected(false);
|
|
4274
|
+
reconnectTimer = setTimeout(connect, 3e3);
|
|
4275
|
+
};
|
|
4276
|
+
ws.onmessage = (ev) => {
|
|
4277
|
+
try {
|
|
4278
|
+
const msg = JSON.parse(ev.data);
|
|
4279
|
+
if (msg.type === "workflow:compiled" || msg.type === "workflow:rebuild") {
|
|
4280
|
+
onReload?.();
|
|
4281
|
+
}
|
|
4282
|
+
} catch {
|
|
4283
|
+
}
|
|
4284
|
+
};
|
|
4285
|
+
} catch {
|
|
4286
|
+
reconnectTimer = setTimeout(connect, 3e3);
|
|
4287
|
+
}
|
|
4288
|
+
}
|
|
4289
|
+
connect();
|
|
4290
|
+
return () => {
|
|
4291
|
+
clearTimeout(reconnectTimer);
|
|
4292
|
+
wsRef.current?.close();
|
|
4293
|
+
wsRef.current = null;
|
|
4294
|
+
};
|
|
4295
|
+
}, [wsUrl, onReload]);
|
|
4296
|
+
return connected;
|
|
4297
|
+
}
|
|
4298
|
+
var DevPlayer = ({
|
|
4299
|
+
tree,
|
|
4300
|
+
scopes = {},
|
|
4301
|
+
atoms: userAtoms,
|
|
4302
|
+
title = "DevPlayer",
|
|
4303
|
+
bare = false,
|
|
4304
|
+
wsUrl,
|
|
4305
|
+
onReload,
|
|
4306
|
+
onEvent: externalOnEvent
|
|
4307
|
+
}) => {
|
|
4308
|
+
const [showSidebar, setShowSidebar] = (0, import_react36.useState)(true);
|
|
4309
|
+
const [events, setEvents] = (0, import_react36.useState)([]);
|
|
4310
|
+
const nextId = (0, import_react36.useRef)(0);
|
|
4311
|
+
const connected = useDevSocket(wsUrl, onReload);
|
|
4312
|
+
const mergedAtoms = (0, import_react36.useMemo)(
|
|
4313
|
+
() => ({ ...builtinAtoms, ...userAtoms }),
|
|
4314
|
+
[userAtoms]
|
|
4315
|
+
);
|
|
4316
|
+
const handleEvent = (0, import_react36.useCallback)(
|
|
4317
|
+
(name, payload) => {
|
|
4318
|
+
setEvents((prev) => {
|
|
4319
|
+
const entry = {
|
|
4320
|
+
id: nextId.current++,
|
|
4321
|
+
time: (/* @__PURE__ */ new Date()).toLocaleTimeString("en-US", { hour12: false }),
|
|
4322
|
+
name,
|
|
4323
|
+
payload
|
|
4324
|
+
};
|
|
4325
|
+
const next = [entry, ...prev];
|
|
4326
|
+
return next.length > 100 ? next.slice(0, 100) : next;
|
|
4327
|
+
});
|
|
4328
|
+
externalOnEvent?.(name, payload);
|
|
4329
|
+
},
|
|
4330
|
+
[externalOnEvent]
|
|
4331
|
+
);
|
|
4332
|
+
if (bare) {
|
|
4333
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
4334
|
+
ComponentTreeRenderer,
|
|
4335
|
+
{
|
|
4336
|
+
tree,
|
|
4337
|
+
scopes,
|
|
4338
|
+
atoms: mergedAtoms,
|
|
4339
|
+
onEvent: handleEvent
|
|
4340
|
+
}
|
|
4341
|
+
);
|
|
4342
|
+
}
|
|
4343
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: S.shell, children: [
|
|
4344
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: S.toolbar, children: [
|
|
4345
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: S.dot(connected), title: connected ? "HMR connected" : "HMR disconnected" }),
|
|
4346
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { style: S.toolbarTitle, children: title }),
|
|
4347
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { style: S.toolbarBadge, children: [
|
|
4348
|
+
Array.isArray(tree) ? tree.length : 1,
|
|
4349
|
+
" node",
|
|
4350
|
+
Array.isArray(tree) && tree.length !== 1 ? "s" : ""
|
|
4351
|
+
] }),
|
|
4352
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { style: S.toolbarBadge, children: [
|
|
4353
|
+
Object.keys(mergedAtoms).length,
|
|
4354
|
+
" atoms"
|
|
4355
|
+
] }),
|
|
4356
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: { flex: 1 } }),
|
|
4357
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
4358
|
+
"button",
|
|
4359
|
+
{
|
|
4360
|
+
style: { ...S.toolbarBtn, ...showSidebar ? S.toolbarBtnActive : {} },
|
|
4361
|
+
onClick: () => setShowSidebar((v) => !v),
|
|
4362
|
+
children: "Inspector"
|
|
4363
|
+
}
|
|
4364
|
+
)
|
|
4365
|
+
] }),
|
|
4366
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: S.body, children: [
|
|
4367
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: S.preview, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
4368
|
+
ComponentTreeRenderer,
|
|
4369
|
+
{
|
|
4370
|
+
tree,
|
|
4371
|
+
scopes,
|
|
4372
|
+
atoms: mergedAtoms,
|
|
4373
|
+
onEvent: handleEvent
|
|
4374
|
+
}
|
|
4375
|
+
) }),
|
|
4376
|
+
showSidebar && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: S.sidebar, children: [
|
|
4377
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: S.sidebarSection, children: [
|
|
4378
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: S.sidebarHeading, children: "Scopes" }),
|
|
4379
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("pre", { style: S.pre, children: JSON.stringify(scopes, null, 2) })
|
|
4380
|
+
] }),
|
|
4381
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: S.sidebarSection, children: [
|
|
4382
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: S.sidebarHeading, children: [
|
|
4383
|
+
"Atoms (",
|
|
4384
|
+
Object.keys(mergedAtoms).length,
|
|
4385
|
+
")"
|
|
4386
|
+
] }),
|
|
4387
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: { display: "flex", flexWrap: "wrap", gap: 4 }, children: Object.keys(mergedAtoms).sort().map((name) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
4388
|
+
"span",
|
|
4389
|
+
{
|
|
4390
|
+
style: {
|
|
4391
|
+
display: "inline-block",
|
|
4392
|
+
padding: "1px 6px",
|
|
4393
|
+
borderRadius: 3,
|
|
4394
|
+
background: userAtoms?.[name] ? "#ebf8ff" : "#f7fafc",
|
|
4395
|
+
border: `1px solid ${userAtoms?.[name] ? "#90cdf4" : "#e2e8f0"}`,
|
|
4396
|
+
fontSize: 11,
|
|
4397
|
+
fontFamily: "monospace",
|
|
4398
|
+
color: userAtoms?.[name] ? "#2b6cb0" : "#718096"
|
|
4399
|
+
},
|
|
4400
|
+
children: name
|
|
4401
|
+
},
|
|
4402
|
+
name
|
|
4403
|
+
)) })
|
|
4404
|
+
] }),
|
|
4405
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: S.sidebarSection, children: [
|
|
4406
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { display: "flex", justifyContent: "space-between", alignItems: "center", marginBottom: 8 }, children: [
|
|
4407
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: S.sidebarHeading, children: [
|
|
4408
|
+
"Events (",
|
|
4409
|
+
events.length,
|
|
4410
|
+
")"
|
|
4411
|
+
] }),
|
|
4412
|
+
events.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
4413
|
+
"button",
|
|
4414
|
+
{
|
|
4415
|
+
style: { background: "none", border: "none", color: "#a0aec0", fontSize: 11, cursor: "pointer" },
|
|
4416
|
+
onClick: () => setEvents([]),
|
|
4417
|
+
children: "Clear"
|
|
4418
|
+
}
|
|
4419
|
+
)
|
|
4420
|
+
] }),
|
|
4421
|
+
events.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: { color: "#a0aec0", fontSize: 12, fontStyle: "italic" }, children: "No events yet" }),
|
|
4422
|
+
events.slice(0, 50).map((e) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: S.eventRow, children: [
|
|
4423
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { style: S.eventTime, children: e.time }),
|
|
4424
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { style: S.eventName, children: e.name }),
|
|
4425
|
+
e.payload !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { style: { color: "#718096", overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: JSON.stringify(e.payload) })
|
|
4426
|
+
] }, e.id))
|
|
4427
|
+
] }),
|
|
4428
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: S.sidebarSection, children: [
|
|
4429
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: S.sidebarHeading, children: "Tree (JSON)" }),
|
|
4430
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("pre", { style: { ...S.pre, maxHeight: 400 }, children: JSON.stringify(tree, null, 2) })
|
|
4431
|
+
] })
|
|
4432
|
+
] })
|
|
4433
|
+
] })
|
|
4434
|
+
] });
|
|
4435
|
+
};
|
|
4436
|
+
|
|
3881
4437
|
// src/atoms/index.ts
|
|
3882
4438
|
function stub(displayName) {
|
|
3883
4439
|
const Component = () => {
|
|
@@ -3888,28 +4444,28 @@ function stub(displayName) {
|
|
|
3888
4444
|
Component.displayName = displayName;
|
|
3889
4445
|
return Component;
|
|
3890
4446
|
}
|
|
3891
|
-
var
|
|
3892
|
-
var
|
|
3893
|
-
var
|
|
3894
|
-
var
|
|
3895
|
-
var
|
|
3896
|
-
var
|
|
3897
|
-
var
|
|
3898
|
-
var
|
|
3899
|
-
var
|
|
4447
|
+
var Stack2 = stub("Stack");
|
|
4448
|
+
var Row2 = stub("Row");
|
|
4449
|
+
var Column2 = stub("Column");
|
|
4450
|
+
var Grid2 = stub("Grid");
|
|
4451
|
+
var Divider2 = stub("Divider");
|
|
4452
|
+
var Spacer2 = stub("Spacer");
|
|
4453
|
+
var Text2 = stub("Text");
|
|
4454
|
+
var Heading2 = stub("Heading");
|
|
4455
|
+
var Field2 = stub("Field");
|
|
3900
4456
|
var Image = stub("Image");
|
|
3901
|
-
var
|
|
4457
|
+
var Badge2 = stub("Badge");
|
|
3902
4458
|
var Icon = stub("Icon");
|
|
3903
|
-
var
|
|
4459
|
+
var Button2 = stub("Button");
|
|
3904
4460
|
var Link = stub("Link");
|
|
3905
|
-
var
|
|
3906
|
-
var
|
|
3907
|
-
var
|
|
4461
|
+
var Show2 = stub("Show");
|
|
4462
|
+
var Each2 = stub("Each");
|
|
4463
|
+
var Card2 = stub("Card");
|
|
3908
4464
|
var Tabs = stub("Tabs");
|
|
3909
4465
|
var Accordion = stub("Accordion");
|
|
3910
|
-
var
|
|
4466
|
+
var Section2 = stub("Section");
|
|
3911
4467
|
var Modal = stub("Modal");
|
|
3912
|
-
var
|
|
4468
|
+
var TextInput2 = stub("TextInput");
|
|
3913
4469
|
var Select = stub("Select");
|
|
3914
4470
|
var Markdown = stub("Markdown");
|
|
3915
4471
|
var ScrollArea = stub("ScrollArea");
|
|
@@ -4009,7 +4565,7 @@ function djb2Hash(str) {
|
|
|
4009
4565
|
}
|
|
4010
4566
|
|
|
4011
4567
|
// src/authoring.ts
|
|
4012
|
-
function
|
|
4568
|
+
function useState22(_defaultOrKey) {
|
|
4013
4569
|
return [void 0, () => {
|
|
4014
4570
|
}];
|
|
4015
4571
|
}
|
|
@@ -4020,10 +4576,10 @@ function defineWorkspace(config) {
|
|
|
4020
4576
|
}
|
|
4021
4577
|
|
|
4022
4578
|
// src/hooks/useModule.ts
|
|
4023
|
-
var
|
|
4579
|
+
var import_react37 = require("react");
|
|
4024
4580
|
function useModule(slug, config = {}, options = {}) {
|
|
4025
4581
|
const { enabled = true } = options;
|
|
4026
|
-
return (0,
|
|
4582
|
+
return (0, import_react37.useMemo)(() => ({
|
|
4027
4583
|
slug,
|
|
4028
4584
|
config,
|
|
4029
4585
|
isLoaded: enabled
|
|
@@ -4031,7 +4587,7 @@ function useModule(slug, config = {}, options = {}) {
|
|
|
4031
4587
|
}
|
|
4032
4588
|
|
|
4033
4589
|
// src/hooks/useModuleConfig.ts
|
|
4034
|
-
var
|
|
4590
|
+
var import_react38 = require("react");
|
|
4035
4591
|
var installedModulesStore = [];
|
|
4036
4592
|
var configDefaultsStore = /* @__PURE__ */ new Map();
|
|
4037
4593
|
function setInstalledModules(modules) {
|
|
@@ -4047,7 +4603,7 @@ function getInstalledModules() {
|
|
|
4047
4603
|
return installedModulesStore;
|
|
4048
4604
|
}
|
|
4049
4605
|
function useModuleConfig(moduleSlug) {
|
|
4050
|
-
return (0,
|
|
4606
|
+
return (0, import_react38.useMemo)(() => {
|
|
4051
4607
|
const installed = getInstalledModule(moduleSlug);
|
|
4052
4608
|
const defaults = configDefaultsStore.get(moduleSlug) ?? {};
|
|
4053
4609
|
const persisted = persistedConfigStore.get(moduleSlug) ?? {};
|
|
@@ -4095,8 +4651,8 @@ async function updateDefinitionConfig(values, definitionId) {
|
|
|
4095
4651
|
}
|
|
4096
4652
|
function useModuleConfigWithMutation(moduleSlug) {
|
|
4097
4653
|
const config = useModuleConfig(moduleSlug);
|
|
4098
|
-
const [isSaving, setIsSaving] = (0,
|
|
4099
|
-
const updateConfig = (0,
|
|
4654
|
+
const [isSaving, setIsSaving] = (0, import_react38.useState)(false);
|
|
4655
|
+
const updateConfig = (0, import_react38.useCallback)(async (values) => {
|
|
4100
4656
|
setIsSaving(true);
|
|
4101
4657
|
try {
|
|
4102
4658
|
return await updateDefinitionConfig(values);
|
|
@@ -6299,7 +6855,7 @@ function describeModel(def) {
|
|
|
6299
6855
|
}
|
|
6300
6856
|
|
|
6301
6857
|
// src/hooks/usePlayer.ts
|
|
6302
|
-
var
|
|
6858
|
+
var import_react39 = require("react");
|
|
6303
6859
|
var import_player_core2 = require("@mmapp/player-core");
|
|
6304
6860
|
|
|
6305
6861
|
// src/logger.ts
|
|
@@ -6340,18 +6896,18 @@ function computePlayerState(sm) {
|
|
|
6340
6896
|
};
|
|
6341
6897
|
}
|
|
6342
6898
|
function usePlayer(config) {
|
|
6343
|
-
const configRef = (0,
|
|
6899
|
+
const configRef = (0, import_react39.useRef)(config);
|
|
6344
6900
|
configRef.current = config;
|
|
6345
|
-
(0,
|
|
6901
|
+
(0, import_react39.useEffect)(() => {
|
|
6346
6902
|
if (config.debug) setPlayerDebug(true);
|
|
6347
6903
|
}, [config.debug]);
|
|
6348
|
-
const evaluator = (0,
|
|
6904
|
+
const evaluator = (0, import_react39.useMemo)(() => {
|
|
6349
6905
|
return (0, import_player_core2.createEvaluator)({
|
|
6350
6906
|
functions: config.functions ?? [],
|
|
6351
6907
|
failurePolicy: import_player_core2.WEB_FAILURE_POLICIES.EVENT_REACTION
|
|
6352
6908
|
});
|
|
6353
6909
|
}, [config.definition.id]);
|
|
6354
|
-
const engine = (0,
|
|
6910
|
+
const engine = (0, import_react39.useMemo)(() => {
|
|
6355
6911
|
const actionHandlers = /* @__PURE__ */ new Map();
|
|
6356
6912
|
if (config.actionHandlers) {
|
|
6357
6913
|
for (const [type, handler] of Object.entries(config.actionHandlers)) {
|
|
@@ -6405,8 +6961,8 @@ function usePlayer(config) {
|
|
|
6405
6961
|
return { sm: sm2, eventBus: eventBus2, dispatcher };
|
|
6406
6962
|
}, [config.definition.id, evaluator]);
|
|
6407
6963
|
const { sm, eventBus } = engine;
|
|
6408
|
-
const [playerState, setPlayerState] = (0,
|
|
6409
|
-
(0,
|
|
6964
|
+
const [playerState, setPlayerState] = (0, import_react39.useState)(() => computePlayerState(sm));
|
|
6965
|
+
(0, import_react39.useEffect)(() => {
|
|
6410
6966
|
const stateDef = sm.getCurrentStateDefinition();
|
|
6411
6967
|
if (!stateDef?.on_event?.length) return;
|
|
6412
6968
|
const unsubs = [];
|
|
@@ -6470,7 +7026,7 @@ function usePlayer(config) {
|
|
|
6470
7026
|
for (const unsub of unsubs) unsub();
|
|
6471
7027
|
};
|
|
6472
7028
|
}, [sm, eventBus, evaluator, engine.dispatcher, playerState.currentState]);
|
|
6473
|
-
(0,
|
|
7029
|
+
(0, import_react39.useEffect)(() => {
|
|
6474
7030
|
const unsub = sm.on((event) => {
|
|
6475
7031
|
if (event.type === "transition" || event.type === "state_enter") {
|
|
6476
7032
|
setPlayerState(computePlayerState(sm));
|
|
@@ -6486,7 +7042,7 @@ function usePlayer(config) {
|
|
|
6486
7042
|
});
|
|
6487
7043
|
return unsub;
|
|
6488
7044
|
}, [sm]);
|
|
6489
|
-
const transition2 = (0,
|
|
7045
|
+
const transition2 = (0, import_react39.useCallback)(
|
|
6490
7046
|
async (name, data) => {
|
|
6491
7047
|
playerLog({
|
|
6492
7048
|
level: "info",
|
|
@@ -6513,20 +7069,20 @@ function usePlayer(config) {
|
|
|
6513
7069
|
},
|
|
6514
7070
|
[sm]
|
|
6515
7071
|
);
|
|
6516
|
-
const setField2 = (0,
|
|
7072
|
+
const setField2 = (0, import_react39.useCallback)(
|
|
6517
7073
|
(field2, value) => {
|
|
6518
7074
|
sm.setField(field2, value);
|
|
6519
7075
|
setPlayerState(computePlayerState(sm));
|
|
6520
7076
|
},
|
|
6521
7077
|
[sm]
|
|
6522
7078
|
);
|
|
6523
|
-
const setMemory = (0,
|
|
7079
|
+
const setMemory = (0, import_react39.useCallback)(
|
|
6524
7080
|
(key, value) => {
|
|
6525
7081
|
sm.setMemory(key, value);
|
|
6526
7082
|
},
|
|
6527
7083
|
[sm]
|
|
6528
7084
|
);
|
|
6529
|
-
const publishEvent = (0,
|
|
7085
|
+
const publishEvent = (0, import_react39.useCallback)(
|
|
6530
7086
|
(topic, payload) => {
|
|
6531
7087
|
playerLog({
|
|
6532
7088
|
level: "debug",
|
|
@@ -6552,11 +7108,11 @@ function usePlayer(config) {
|
|
|
6552
7108
|
}
|
|
6553
7109
|
|
|
6554
7110
|
// src/hooks/useDomainSubscription.ts
|
|
6555
|
-
var
|
|
7111
|
+
var import_react40 = require("react");
|
|
6556
7112
|
function useDomainSubscription(eventBus, transport, config) {
|
|
6557
|
-
const configRef = (0,
|
|
7113
|
+
const configRef = (0, import_react40.useRef)(config);
|
|
6558
7114
|
configRef.current = config;
|
|
6559
|
-
(0,
|
|
7115
|
+
(0, import_react40.useEffect)(() => {
|
|
6560
7116
|
if (!transport || config.enabled === false) return;
|
|
6561
7117
|
const unsub = transport.subscribe(
|
|
6562
7118
|
{
|
|
@@ -6609,11 +7165,11 @@ function useDomainSubscription(eventBus, transport, config) {
|
|
|
6609
7165
|
}
|
|
6610
7166
|
|
|
6611
7167
|
// src/hooks/useExperienceState.ts
|
|
6612
|
-
var
|
|
7168
|
+
var import_react41 = require("react");
|
|
6613
7169
|
function useExperienceState(player, selector) {
|
|
6614
|
-
const selectorRef = (0,
|
|
7170
|
+
const selectorRef = (0, import_react41.useRef)(selector);
|
|
6615
7171
|
selectorRef.current = selector;
|
|
6616
|
-
const getSnapshot = (0,
|
|
7172
|
+
const getSnapshot = (0, import_react41.useCallback)(() => {
|
|
6617
7173
|
return selectorRef.current({
|
|
6618
7174
|
currentState: player.currentState,
|
|
6619
7175
|
stateData: player.stateData,
|
|
@@ -6629,20 +7185,20 @@ function useStateField(player, field2, defaultValue) {
|
|
|
6629
7185
|
}
|
|
6630
7186
|
|
|
6631
7187
|
// src/hooks/useComputed.ts
|
|
6632
|
-
var
|
|
7188
|
+
var import_react42 = require("react");
|
|
6633
7189
|
function useComputed(_name, compute, options) {
|
|
6634
7190
|
const mode = options?.mode ?? "read-time";
|
|
6635
7191
|
const deps = options?.deps ?? [];
|
|
6636
|
-
const computeRef = (0,
|
|
7192
|
+
const computeRef = (0, import_react42.useRef)(compute);
|
|
6637
7193
|
computeRef.current = compute;
|
|
6638
7194
|
if (mode === "read-time") {
|
|
6639
|
-
return (0,
|
|
7195
|
+
return (0, import_react42.useMemo)(() => computeRef.current(), [
|
|
6640
7196
|
// We intentionally depend on deps.join to recompute when tracked fields change
|
|
6641
7197
|
// The actual dependency tracking happens at the compiler level
|
|
6642
7198
|
deps.join(",")
|
|
6643
7199
|
]);
|
|
6644
7200
|
}
|
|
6645
|
-
return (0,
|
|
7201
|
+
return (0, import_react42.useMemo)(() => computeRef.current(), [deps.join(",")]);
|
|
6646
7202
|
}
|
|
6647
7203
|
function useComputedWithMeta(name, compute, options) {
|
|
6648
7204
|
const value = useComputed(name, compute, options);
|
|
@@ -6657,26 +7213,26 @@ function useComputedWithMeta(name, compute, options) {
|
|
|
6657
7213
|
}
|
|
6658
7214
|
|
|
6659
7215
|
// src/components/PlayerProvider.tsx
|
|
6660
|
-
var
|
|
6661
|
-
var
|
|
6662
|
-
var PlayerContext = (0,
|
|
7216
|
+
var import_react43 = require("react");
|
|
7217
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
7218
|
+
var PlayerContext = (0, import_react43.createContext)(null);
|
|
6663
7219
|
function PlayerProvider({ player, children }) {
|
|
6664
|
-
return /* @__PURE__ */ (0,
|
|
7220
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(PlayerContext.Provider, { value: player, children });
|
|
6665
7221
|
}
|
|
6666
7222
|
function usePlayerContext() {
|
|
6667
|
-
const ctx = (0,
|
|
7223
|
+
const ctx = (0, import_react43.useContext)(PlayerContext);
|
|
6668
7224
|
if (!ctx) {
|
|
6669
7225
|
throw new Error("usePlayerContext must be used within a <PlayerProvider>");
|
|
6670
7226
|
}
|
|
6671
7227
|
return ctx;
|
|
6672
7228
|
}
|
|
6673
7229
|
function usePlayerContextSafe() {
|
|
6674
|
-
return (0,
|
|
7230
|
+
return (0, import_react43.useContext)(PlayerContext);
|
|
6675
7231
|
}
|
|
6676
7232
|
|
|
6677
7233
|
// src/components/ExperienceWorkflowBridge.tsx
|
|
6678
|
-
var
|
|
6679
|
-
var
|
|
7234
|
+
var import_react44 = require("react");
|
|
7235
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
6680
7236
|
function ExperienceWorkflowBridgeInner({
|
|
6681
7237
|
definition,
|
|
6682
7238
|
initialData,
|
|
@@ -6693,12 +7249,12 @@ function ExperienceWorkflowBridgeInner({
|
|
|
6693
7249
|
actionHandlers,
|
|
6694
7250
|
debug
|
|
6695
7251
|
});
|
|
6696
|
-
const viewConfig = (0,
|
|
7252
|
+
const viewConfig = (0, import_react44.useMemo)(() => {
|
|
6697
7253
|
if (!definition.state_views) return void 0;
|
|
6698
7254
|
return definition.state_views[player.currentState];
|
|
6699
7255
|
}, [definition.state_views, player.currentState]);
|
|
6700
|
-
return /* @__PURE__ */ (0,
|
|
6701
|
-
/* @__PURE__ */ (0,
|
|
7256
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(PlayerProvider, { player, children: [
|
|
7257
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
6702
7258
|
DomainSubscriptionBridge,
|
|
6703
7259
|
{
|
|
6704
7260
|
player,
|
|
@@ -6724,12 +7280,12 @@ function DomainSubscriptionBridge({
|
|
|
6724
7280
|
return null;
|
|
6725
7281
|
}
|
|
6726
7282
|
function ExperienceWorkflowBridge(props) {
|
|
6727
|
-
return /* @__PURE__ */ (0,
|
|
7283
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ExperienceWorkflowBridgeInner, { ...props });
|
|
6728
7284
|
}
|
|
6729
7285
|
|
|
6730
7286
|
// src/components/atoms/index.tsx
|
|
6731
|
-
var
|
|
6732
|
-
var
|
|
7287
|
+
var import_react45 = __toESM(require("react"));
|
|
7288
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
6733
7289
|
|
|
6734
7290
|
// src/loader/experience-workflow-loader.ts
|
|
6735
7291
|
function validateExperienceWorkflow(def) {
|
|
@@ -7790,7 +8346,9 @@ var instance = compileTimeProxy("instance");
|
|
|
7790
8346
|
Card,
|
|
7791
8347
|
Chart,
|
|
7792
8348
|
Column,
|
|
8349
|
+
ComponentTreeRenderer,
|
|
7793
8350
|
DataGrid,
|
|
8351
|
+
DevPlayer,
|
|
7794
8352
|
Divider,
|
|
7795
8353
|
Each,
|
|
7796
8354
|
ExperienceWorkflowBridge,
|
|
@@ -7839,6 +8397,7 @@ var instance = compileTimeProxy("instance");
|
|
|
7839
8397
|
applyMixins,
|
|
7840
8398
|
approval,
|
|
7841
8399
|
assertModelValid,
|
|
8400
|
+
builtinAtoms,
|
|
7842
8401
|
cedar,
|
|
7843
8402
|
compose,
|
|
7844
8403
|
computeVisibility,
|