@process.co/ui 0.0.14 → 0.0.16
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/css/ui.css +154 -182
- package/css/ui.d.ts +4 -0
- package/dist/components/dev/index.cjs +273 -460
- package/dist/components/dev/index.cjs.map +1 -1
- package/dist/components/dev/index.js +268 -454
- package/dist/components/dev/index.js.map +1 -1
- package/dist/components/fields/index.cjs +8429 -4917
- package/dist/components/fields/index.cjs.map +1 -1
- package/dist/components/fields/index.d.cts +4 -1
- package/dist/components/fields/index.d.ts +4 -1
- package/dist/components/fields/index.js +8403 -4897
- package/dist/components/fields/index.js.map +1 -1
- package/dist/{index-pApzdjfp.d.cts → index-19C2gVyr.d.cts} +213 -150
- package/dist/{index-pApzdjfp.d.ts → index-19C2gVyr.d.ts} +213 -150
- package/dist/index.cjs +10104 -5309
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -12
- package/dist/index.d.ts +5 -12
- package/dist/index.js +10070 -5276
- package/dist/index.js.map +1 -1
- package/package.json +7 -2
|
@@ -1,474 +1,288 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import React2, { createContext, useContext, useCallback, useState, useEffect, useMemo } from 'react';
|
|
2
|
+
|
|
3
|
+
// src/components/dev/DevProvider.tsx
|
|
4
|
+
var DevContext = createContext(null);
|
|
5
|
+
function useDevContext() {
|
|
6
|
+
return useContext(DevContext);
|
|
5
7
|
}
|
|
6
|
-
function
|
|
7
|
-
|
|
8
|
+
function useNodeProperty(fieldName) {
|
|
9
|
+
const devCtx = useDevContext();
|
|
10
|
+
if (devCtx) {
|
|
11
|
+
const value = devCtx.getProperty(fieldName);
|
|
12
|
+
const setValue = useCallback((newValue) => {
|
|
13
|
+
devCtx.setProperty(fieldName, newValue);
|
|
14
|
+
}, [devCtx, fieldName]);
|
|
15
|
+
return [value, setValue];
|
|
16
|
+
}
|
|
17
|
+
console.warn(`useNodeProperty('${fieldName}') called outside of DevProvider - returning undefined`);
|
|
18
|
+
const [localValue, setLocalValue] = useState(void 0);
|
|
19
|
+
return [localValue, setLocalValue];
|
|
8
20
|
}
|
|
9
|
-
function
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
return obj;
|
|
21
|
+
function useInferredTypes() {
|
|
22
|
+
const devCtx = useDevContext();
|
|
23
|
+
if (devCtx) {
|
|
24
|
+
return {
|
|
25
|
+
inferredTypes: devCtx.inferredTypes,
|
|
26
|
+
setInferredType: devCtx.setInferredType,
|
|
27
|
+
getInferredType: devCtx.getInferredType
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
return null;
|
|
21
31
|
}
|
|
22
|
-
function
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
_d = true;
|
|
36
|
-
_e = err;
|
|
37
|
-
} finally{
|
|
38
|
-
try {
|
|
39
|
-
if (!_n && _i["return"] != null) _i["return"]();
|
|
40
|
-
} finally{
|
|
41
|
-
if (_d) throw _e;
|
|
32
|
+
function DevProvider({
|
|
33
|
+
children,
|
|
34
|
+
storageKey = "process-dev",
|
|
35
|
+
initialData = {},
|
|
36
|
+
persist = true,
|
|
37
|
+
nodeId = "dev-node-1"
|
|
38
|
+
}) {
|
|
39
|
+
const [data, setData] = useState(() => {
|
|
40
|
+
if (persist && typeof window !== "undefined") {
|
|
41
|
+
try {
|
|
42
|
+
const stored = localStorage.getItem(`${storageKey}:data`);
|
|
43
|
+
if (stored) {
|
|
44
|
+
return { ...initialData, ...JSON.parse(stored) };
|
|
42
45
|
}
|
|
46
|
+
} catch (e) {
|
|
47
|
+
console.warn("DevProvider: Failed to load from localStorage", e);
|
|
48
|
+
}
|
|
43
49
|
}
|
|
44
|
-
return
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
var ownKeys = Object.keys(source);
|
|
53
|
-
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
54
|
-
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
55
|
-
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
56
|
-
}));
|
|
50
|
+
return initialData;
|
|
51
|
+
});
|
|
52
|
+
const [inferredTypes, setInferredTypesState] = useState(() => {
|
|
53
|
+
if (persist && typeof window !== "undefined") {
|
|
54
|
+
try {
|
|
55
|
+
const stored = localStorage.getItem(`${storageKey}:inferredTypes`);
|
|
56
|
+
if (stored) {
|
|
57
|
+
return JSON.parse(stored);
|
|
57
58
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
59
|
+
} catch (e) {
|
|
60
|
+
console.warn("DevProvider: Failed to load inferredTypes from localStorage", e);
|
|
61
|
+
}
|
|
61
62
|
}
|
|
62
|
-
return
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
keys.push.apply(keys, symbols);
|
|
63
|
+
return {};
|
|
64
|
+
});
|
|
65
|
+
useEffect(() => {
|
|
66
|
+
if (persist && typeof window !== "undefined") {
|
|
67
|
+
try {
|
|
68
|
+
localStorage.setItem(`${storageKey}:data`, JSON.stringify(data));
|
|
69
|
+
} catch (e) {
|
|
70
|
+
console.warn("DevProvider: Failed to save data to localStorage", e);
|
|
71
|
+
}
|
|
74
72
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
84
|
-
});
|
|
73
|
+
}, [data, storageKey, persist]);
|
|
74
|
+
useEffect(() => {
|
|
75
|
+
if (persist && typeof window !== "undefined") {
|
|
76
|
+
try {
|
|
77
|
+
localStorage.setItem(`${storageKey}:inferredTypes`, JSON.stringify(inferredTypes));
|
|
78
|
+
} catch (e) {
|
|
79
|
+
console.warn("DevProvider: Failed to save inferredTypes to localStorage", e);
|
|
80
|
+
}
|
|
85
81
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
82
|
+
}, [inferredTypes, storageKey, persist]);
|
|
83
|
+
const setProperty = useCallback((key, value2) => {
|
|
84
|
+
setData((prev) => ({ ...prev, [key]: value2 }));
|
|
85
|
+
}, []);
|
|
86
|
+
const getProperty = useCallback((key) => {
|
|
87
|
+
return data[key];
|
|
88
|
+
}, [data]);
|
|
89
|
+
const setInferredType = useCallback((fieldName, type) => {
|
|
90
|
+
setInferredTypesState((prev) => ({ ...prev, [fieldName]: type }));
|
|
91
|
+
}, []);
|
|
92
|
+
const getInferredType = useCallback((fieldName) => {
|
|
93
|
+
return inferredTypes[fieldName];
|
|
94
|
+
}, [inferredTypes]);
|
|
95
|
+
const clearInferredType = useCallback((fieldName) => {
|
|
96
|
+
setInferredTypesState((prev) => {
|
|
97
|
+
const { [fieldName]: _, ...rest } = prev;
|
|
98
|
+
return rest;
|
|
99
|
+
});
|
|
100
|
+
}, []);
|
|
101
|
+
const clearAllInferredTypes = useCallback(() => {
|
|
102
|
+
setInferredTypesState({});
|
|
103
|
+
}, []);
|
|
104
|
+
const clearAll = useCallback(() => {
|
|
105
|
+
setData({});
|
|
106
|
+
setInferredTypesState({});
|
|
107
|
+
if (persist && typeof window !== "undefined") {
|
|
108
|
+
localStorage.removeItem(`${storageKey}:data`);
|
|
109
|
+
localStorage.removeItem(`${storageKey}:inferredTypes`);
|
|
100
110
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
111
|
+
}, [storageKey, persist]);
|
|
112
|
+
const exportData = useCallback(() => {
|
|
113
|
+
return JSON.stringify({ data, inferredTypes }, null, 2);
|
|
114
|
+
}, [data, inferredTypes]);
|
|
115
|
+
const importData = useCallback((json) => {
|
|
116
|
+
try {
|
|
117
|
+
const parsed = JSON.parse(json);
|
|
118
|
+
if (parsed.data) setData(parsed.data);
|
|
119
|
+
if (parsed.inferredTypes) setInferredTypesState(parsed.inferredTypes);
|
|
120
|
+
} catch (e) {
|
|
121
|
+
console.error("DevProvider: Failed to import data", e);
|
|
112
122
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
123
|
+
}, []);
|
|
124
|
+
const value = useMemo(() => ({
|
|
125
|
+
data,
|
|
126
|
+
setProperty,
|
|
127
|
+
getProperty,
|
|
128
|
+
inferredTypes,
|
|
129
|
+
setInferredType,
|
|
130
|
+
getInferredType,
|
|
131
|
+
clearInferredType,
|
|
132
|
+
clearAllInferredTypes,
|
|
133
|
+
nodeId,
|
|
134
|
+
clearAll,
|
|
135
|
+
exportData,
|
|
136
|
+
importData
|
|
137
|
+
}), [data, setProperty, getProperty, inferredTypes, setInferredType, getInferredType, clearInferredType, clearAllInferredTypes, nodeId, clearAll, exportData, importData]);
|
|
138
|
+
return /* @__PURE__ */ React2.createElement(DevContext.Provider, { value }, children);
|
|
117
139
|
}
|
|
118
|
-
function
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
140
|
+
function DevToolbar({ className }) {
|
|
141
|
+
const devCtx = useDevContext();
|
|
142
|
+
const [showData, setShowData] = useState(false);
|
|
143
|
+
const [showTypeEditor, setShowTypeEditor] = useState(false);
|
|
144
|
+
const [newTypeKey, setNewTypeKey] = useState("");
|
|
145
|
+
const [newTypeValue, setNewTypeValue] = useState("");
|
|
146
|
+
if (!devCtx) {
|
|
147
|
+
return /* @__PURE__ */ React2.createElement("div", { className }, "DevToolbar: Not inside DevProvider");
|
|
148
|
+
}
|
|
149
|
+
const handleAddType = () => {
|
|
150
|
+
if (newTypeKey.trim() && newTypeValue.trim()) {
|
|
151
|
+
devCtx.setInferredType(newTypeKey.trim(), newTypeValue.trim());
|
|
152
|
+
setNewTypeKey("");
|
|
153
|
+
setNewTypeValue("");
|
|
125
154
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
"@swc/helpers - typeof";
|
|
134
|
-
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
135
|
-
}
|
|
136
|
-
function _unsupported_iterable_to_array(o, minLen) {
|
|
137
|
-
if (!o) return;
|
|
138
|
-
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
139
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
140
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
141
|
-
if (n === "Map" || n === "Set") return Array.from(n);
|
|
142
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
143
|
-
}
|
|
144
|
-
import React2, { createContext, useContext, useCallback, useState, useEffect, useMemo } from 'react';
|
|
145
|
-
// src/components/dev/DevProvider.tsx
|
|
146
|
-
var DevContext = createContext(null);
|
|
147
|
-
function useDevContext() {
|
|
148
|
-
return useContext(DevContext);
|
|
149
|
-
}
|
|
150
|
-
function useNodeProperty(fieldName) {
|
|
151
|
-
var devCtx = useDevContext();
|
|
152
|
-
if (devCtx) {
|
|
153
|
-
var value = devCtx.getProperty(fieldName);
|
|
154
|
-
var setValue = useCallback(function(newValue) {
|
|
155
|
-
devCtx.setProperty(fieldName, newValue);
|
|
156
|
-
}, [
|
|
157
|
-
devCtx,
|
|
158
|
-
fieldName
|
|
159
|
-
]);
|
|
160
|
-
return [
|
|
161
|
-
value,
|
|
162
|
-
setValue
|
|
163
|
-
];
|
|
155
|
+
};
|
|
156
|
+
const handleRemoveType = (key) => {
|
|
157
|
+
devCtx.clearInferredType(key);
|
|
158
|
+
};
|
|
159
|
+
const handleClearAllTypes = () => {
|
|
160
|
+
if (confirm("Clear all inferred types?")) {
|
|
161
|
+
devCtx.clearAllInferredTypes();
|
|
164
162
|
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
163
|
+
};
|
|
164
|
+
return /* @__PURE__ */ React2.createElement("div", { className: `${className || ""} uii:border uii:rounded-lg uii:p-4 uii:bg-gray-50 dark:uii:bg-gray-900` }, /* @__PURE__ */ React2.createElement("div", { className: "uii:flex uii:items-center uii:gap-4 uii:mb-2 uii:flex-wrap" }, /* @__PURE__ */ React2.createElement("span", { className: "uii:font-semibold uii:text-sm" }, "\u{1F6E0}\uFE0F Dev Mode"), /* @__PURE__ */ React2.createElement("span", { className: "uii:text-xs uii:text-gray-500" }, "Node: ", devCtx.nodeId), /* @__PURE__ */ React2.createElement(
|
|
165
|
+
"button",
|
|
166
|
+
{
|
|
167
|
+
onClick: () => setShowData(!showData),
|
|
168
|
+
className: "uii:text-xs uii:px-2 uii:py-1 uii:bg-blue-100 dark:uii:bg-blue-900 uii:rounded hover:uii:bg-blue-200"
|
|
169
|
+
},
|
|
170
|
+
showData ? "Hide" : "Show",
|
|
171
|
+
" Data"
|
|
172
|
+
), /* @__PURE__ */ React2.createElement(
|
|
173
|
+
"button",
|
|
174
|
+
{
|
|
175
|
+
onClick: () => setShowTypeEditor(!showTypeEditor),
|
|
176
|
+
className: "uii:text-xs uii:px-2 uii:py-1 uii:bg-purple-100 dark:uii:bg-purple-900 uii:rounded hover:uii:bg-purple-200"
|
|
177
|
+
},
|
|
178
|
+
showTypeEditor ? "Hide" : "Spoof",
|
|
179
|
+
" Types"
|
|
180
|
+
), /* @__PURE__ */ React2.createElement(
|
|
181
|
+
"button",
|
|
182
|
+
{
|
|
183
|
+
onClick: () => {
|
|
184
|
+
const json = devCtx.exportData();
|
|
185
|
+
navigator.clipboard.writeText(json);
|
|
186
|
+
alert("Data copied to clipboard!");
|
|
187
|
+
},
|
|
188
|
+
className: "uii:text-xs uii:px-2 uii:py-1 uii:bg-green-100 dark:uii:bg-green-900 uii:rounded hover:uii:bg-green-200"
|
|
189
|
+
},
|
|
190
|
+
"Export"
|
|
191
|
+
), /* @__PURE__ */ React2.createElement(
|
|
192
|
+
"button",
|
|
193
|
+
{
|
|
194
|
+
onClick: () => {
|
|
195
|
+
const json = prompt("Paste JSON data:");
|
|
196
|
+
if (json) devCtx.importData(json);
|
|
197
|
+
},
|
|
198
|
+
className: "uii:text-xs uii:px-2 uii:py-1 uii:bg-yellow-100 dark:uii:bg-yellow-900 uii:rounded hover:uii:bg-yellow-200"
|
|
199
|
+
},
|
|
200
|
+
"Import"
|
|
201
|
+
), /* @__PURE__ */ React2.createElement(
|
|
202
|
+
"button",
|
|
203
|
+
{
|
|
204
|
+
onClick: () => {
|
|
205
|
+
if (confirm("Clear all data?")) devCtx.clearAll();
|
|
206
|
+
},
|
|
207
|
+
className: "uii:text-xs uii:px-2 uii:py-1 uii:bg-red-100 dark:uii:bg-red-900 uii:rounded hover:uii:bg-red-200"
|
|
208
|
+
},
|
|
209
|
+
"Clear"
|
|
210
|
+
)), showTypeEditor && /* @__PURE__ */ React2.createElement("div", { className: "uii:mt-3 uii:p-3 uii:bg-purple-50 dark:uii:bg-purple-950 uii:rounded-lg uii:border uii:border-purple-200 dark:uii:border-purple-800" }, /* @__PURE__ */ React2.createElement("div", { className: "uii:text-xs uii:font-medium uii:mb-2 uii:text-purple-700 dark:uii:text-purple-300" }, "Spoof Inferred Types (simulate external field types)"), /* @__PURE__ */ React2.createElement("div", { className: "uii:flex uii:gap-2 uii:mb-2 uii:flex-wrap" }, /* @__PURE__ */ React2.createElement(
|
|
211
|
+
"input",
|
|
212
|
+
{
|
|
213
|
+
type: "text",
|
|
214
|
+
placeholder: "Field name (e.g., switchExpression)",
|
|
215
|
+
value: newTypeKey,
|
|
216
|
+
onChange: (e) => setNewTypeKey(e.target.value),
|
|
217
|
+
className: "uii:text-xs uii:px-2 uii:py-1 uii:border uii:rounded uii:flex-1 uii:min-w-[150px] uii:bg-white dark:uii:bg-gray-800"
|
|
180
218
|
}
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
return _object_spread({}, initialData, JSON.parse(stored));
|
|
191
|
-
}
|
|
192
|
-
} catch (e) {
|
|
193
|
-
console.warn("DevProvider: Failed to load from localStorage", e);
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
return initialData;
|
|
197
|
-
}), 2), data = _useState[0], setData = _useState[1];
|
|
198
|
-
var _useState1 = _sliced_to_array(useState(function() {
|
|
199
|
-
if (persist && typeof window !== "undefined") {
|
|
200
|
-
try {
|
|
201
|
-
var stored = localStorage.getItem("".concat(storageKey, ":inferredTypes"));
|
|
202
|
-
if (stored) {
|
|
203
|
-
return JSON.parse(stored);
|
|
204
|
-
}
|
|
205
|
-
} catch (e) {
|
|
206
|
-
console.warn("DevProvider: Failed to load inferredTypes from localStorage", e);
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
return {};
|
|
210
|
-
}), 2), inferredTypes = _useState1[0], setInferredTypesState = _useState1[1];
|
|
211
|
-
useEffect(function() {
|
|
212
|
-
if (persist && typeof window !== "undefined") {
|
|
213
|
-
try {
|
|
214
|
-
localStorage.setItem("".concat(storageKey, ":data"), JSON.stringify(data));
|
|
215
|
-
} catch (e) {
|
|
216
|
-
console.warn("DevProvider: Failed to save data to localStorage", e);
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
}, [
|
|
220
|
-
data,
|
|
221
|
-
storageKey,
|
|
222
|
-
persist
|
|
223
|
-
]);
|
|
224
|
-
useEffect(function() {
|
|
225
|
-
if (persist && typeof window !== "undefined") {
|
|
226
|
-
try {
|
|
227
|
-
localStorage.setItem("".concat(storageKey, ":inferredTypes"), JSON.stringify(inferredTypes));
|
|
228
|
-
} catch (e) {
|
|
229
|
-
console.warn("DevProvider: Failed to save inferredTypes to localStorage", e);
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
}, [
|
|
233
|
-
inferredTypes,
|
|
234
|
-
storageKey,
|
|
235
|
-
persist
|
|
236
|
-
]);
|
|
237
|
-
var setProperty = useCallback(function(key, value2) {
|
|
238
|
-
setData(function(prev) {
|
|
239
|
-
return _object_spread_props(_object_spread({}, prev), _define_property({}, key, value2));
|
|
240
|
-
});
|
|
241
|
-
}, []);
|
|
242
|
-
var getProperty = useCallback(function(key) {
|
|
243
|
-
return data[key];
|
|
244
|
-
}, [
|
|
245
|
-
data
|
|
246
|
-
]);
|
|
247
|
-
var setInferredType = useCallback(function(fieldName, type) {
|
|
248
|
-
setInferredTypesState(function(prev) {
|
|
249
|
-
return _object_spread_props(_object_spread({}, prev), _define_property({}, fieldName, type));
|
|
250
|
-
});
|
|
251
|
-
}, []);
|
|
252
|
-
var getInferredType = useCallback(function(fieldName) {
|
|
253
|
-
return inferredTypes[fieldName];
|
|
254
|
-
}, [
|
|
255
|
-
inferredTypes
|
|
256
|
-
]);
|
|
257
|
-
var clearInferredType = useCallback(function(fieldName) {
|
|
258
|
-
setInferredTypesState(function(prev) {
|
|
259
|
-
var _ = prev[fieldName], rest = _object_without_properties(prev, [
|
|
260
|
-
fieldName
|
|
261
|
-
].map(_to_property_key));
|
|
262
|
-
return rest;
|
|
263
|
-
});
|
|
264
|
-
}, []);
|
|
265
|
-
var clearAllInferredTypes = useCallback(function() {
|
|
266
|
-
setInferredTypesState({});
|
|
267
|
-
}, []);
|
|
268
|
-
var clearAll = useCallback(function() {
|
|
269
|
-
setData({});
|
|
270
|
-
setInferredTypesState({});
|
|
271
|
-
if (persist && typeof window !== "undefined") {
|
|
272
|
-
localStorage.removeItem("".concat(storageKey, ":data"));
|
|
273
|
-
localStorage.removeItem("".concat(storageKey, ":inferredTypes"));
|
|
274
|
-
}
|
|
275
|
-
}, [
|
|
276
|
-
storageKey,
|
|
277
|
-
persist
|
|
278
|
-
]);
|
|
279
|
-
var exportData = useCallback(function() {
|
|
280
|
-
return JSON.stringify({
|
|
281
|
-
data: data,
|
|
282
|
-
inferredTypes: inferredTypes
|
|
283
|
-
}, null, 2);
|
|
284
|
-
}, [
|
|
285
|
-
data,
|
|
286
|
-
inferredTypes
|
|
287
|
-
]);
|
|
288
|
-
var importData = useCallback(function(json) {
|
|
289
|
-
try {
|
|
290
|
-
var parsed = JSON.parse(json);
|
|
291
|
-
if (parsed.data) setData(parsed.data);
|
|
292
|
-
if (parsed.inferredTypes) setInferredTypesState(parsed.inferredTypes);
|
|
293
|
-
} catch (e) {
|
|
294
|
-
console.error("DevProvider: Failed to import data", e);
|
|
295
|
-
}
|
|
296
|
-
}, []);
|
|
297
|
-
var value = useMemo(function() {
|
|
298
|
-
return {
|
|
299
|
-
data: data,
|
|
300
|
-
setProperty: setProperty,
|
|
301
|
-
getProperty: getProperty,
|
|
302
|
-
inferredTypes: inferredTypes,
|
|
303
|
-
setInferredType: setInferredType,
|
|
304
|
-
getInferredType: getInferredType,
|
|
305
|
-
clearInferredType: clearInferredType,
|
|
306
|
-
clearAllInferredTypes: clearAllInferredTypes,
|
|
307
|
-
nodeId: nodeId,
|
|
308
|
-
clearAll: clearAll,
|
|
309
|
-
exportData: exportData,
|
|
310
|
-
importData: importData
|
|
311
|
-
};
|
|
312
|
-
}, [
|
|
313
|
-
data,
|
|
314
|
-
setProperty,
|
|
315
|
-
getProperty,
|
|
316
|
-
inferredTypes,
|
|
317
|
-
setInferredType,
|
|
318
|
-
getInferredType,
|
|
319
|
-
clearInferredType,
|
|
320
|
-
clearAllInferredTypes,
|
|
321
|
-
nodeId,
|
|
322
|
-
clearAll,
|
|
323
|
-
exportData,
|
|
324
|
-
importData
|
|
325
|
-
]);
|
|
326
|
-
return /* @__PURE__ */ React2.createElement(DevContext.Provider, {
|
|
327
|
-
value: value
|
|
328
|
-
}, children);
|
|
329
|
-
}
|
|
330
|
-
function DevToolbar(param) {
|
|
331
|
-
var className = param.className;
|
|
332
|
-
var devCtx = useDevContext();
|
|
333
|
-
var _useState = _sliced_to_array(useState(false), 2), showData = _useState[0], setShowData = _useState[1];
|
|
334
|
-
var _useState1 = _sliced_to_array(useState(false), 2), showTypeEditor = _useState1[0], setShowTypeEditor = _useState1[1];
|
|
335
|
-
var _useState2 = _sliced_to_array(useState(""), 2), newTypeKey = _useState2[0], setNewTypeKey = _useState2[1];
|
|
336
|
-
var _useState3 = _sliced_to_array(useState(""), 2), newTypeValue = _useState3[0], setNewTypeValue = _useState3[1];
|
|
337
|
-
if (!devCtx) {
|
|
338
|
-
return /* @__PURE__ */ React2.createElement("div", {
|
|
339
|
-
className: className
|
|
340
|
-
}, "DevToolbar: Not inside DevProvider");
|
|
219
|
+
), /* @__PURE__ */ React2.createElement(
|
|
220
|
+
"input",
|
|
221
|
+
{
|
|
222
|
+
type: "text",
|
|
223
|
+
placeholder: "Type (e.g., string | number)",
|
|
224
|
+
value: newTypeValue,
|
|
225
|
+
onChange: (e) => setNewTypeValue(e.target.value),
|
|
226
|
+
onKeyDown: (e) => e.key === "Enter" && handleAddType(),
|
|
227
|
+
className: "uii:text-xs uii:px-2 uii:py-1 uii:border uii:rounded uii:flex-1 uii:min-w-[200px] uii:bg-white dark:uii:bg-gray-800"
|
|
341
228
|
}
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
onClick:
|
|
367
|
-
|
|
368
|
-
},
|
|
369
|
-
className: "uii:text-xs uii:px-2 uii:py-1 uii:bg-blue-100 dark:uii:bg-blue-900 uii:rounded hover:uii:bg-blue-200"
|
|
370
|
-
}, showData ? "Hide" : "Show", " Data"), /* @__PURE__ */ React2.createElement("button", {
|
|
371
|
-
onClick: function() {
|
|
372
|
-
return setShowTypeEditor(!showTypeEditor);
|
|
373
|
-
},
|
|
374
|
-
className: "uii:text-xs uii:px-2 uii:py-1 uii:bg-purple-100 dark:uii:bg-purple-900 uii:rounded hover:uii:bg-purple-200"
|
|
375
|
-
}, showTypeEditor ? "Hide" : "Spoof", " Types"), /* @__PURE__ */ React2.createElement("button", {
|
|
376
|
-
onClick: function() {
|
|
377
|
-
var json = devCtx.exportData();
|
|
378
|
-
navigator.clipboard.writeText(json);
|
|
379
|
-
alert("Data copied to clipboard!");
|
|
380
|
-
},
|
|
381
|
-
className: "uii:text-xs uii:px-2 uii:py-1 uii:bg-green-100 dark:uii:bg-green-900 uii:rounded hover:uii:bg-green-200"
|
|
382
|
-
}, "Export"), /* @__PURE__ */ React2.createElement("button", {
|
|
383
|
-
onClick: function() {
|
|
384
|
-
var json = prompt("Paste JSON data:");
|
|
385
|
-
if (json) devCtx.importData(json);
|
|
386
|
-
},
|
|
387
|
-
className: "uii:text-xs uii:px-2 uii:py-1 uii:bg-yellow-100 dark:uii:bg-yellow-900 uii:rounded hover:uii:bg-yellow-200"
|
|
388
|
-
}, "Import"), /* @__PURE__ */ React2.createElement("button", {
|
|
389
|
-
onClick: function() {
|
|
390
|
-
if (confirm("Clear all data?")) devCtx.clearAll();
|
|
391
|
-
},
|
|
392
|
-
className: "uii:text-xs uii:px-2 uii:py-1 uii:bg-red-100 dark:uii:bg-red-900 uii:rounded hover:uii:bg-red-200"
|
|
393
|
-
}, "Clear")), showTypeEditor && /* @__PURE__ */ React2.createElement("div", {
|
|
394
|
-
className: "uii:mt-3 uii:p-3 uii:bg-purple-50 dark:uii:bg-purple-950 uii:rounded-lg uii:border uii:border-purple-200 dark:uii:border-purple-800"
|
|
395
|
-
}, /* @__PURE__ */ React2.createElement("div", {
|
|
396
|
-
className: "uii:text-xs uii:font-medium uii:mb-2 uii:text-purple-700 dark:uii:text-purple-300"
|
|
397
|
-
}, "Spoof Inferred Types (simulate external field types)"), /* @__PURE__ */ React2.createElement("div", {
|
|
398
|
-
className: "uii:flex uii:gap-2 uii:mb-2 uii:flex-wrap"
|
|
399
|
-
}, /* @__PURE__ */ React2.createElement("input", {
|
|
400
|
-
type: "text",
|
|
401
|
-
placeholder: "Field name (e.g., switchExpression)",
|
|
402
|
-
value: newTypeKey,
|
|
403
|
-
onChange: function(e) {
|
|
404
|
-
return setNewTypeKey(e.target.value);
|
|
405
|
-
},
|
|
406
|
-
className: "uii:text-xs uii:px-2 uii:py-1 uii:border uii:rounded uii:flex-1 uii:min-w-[150px] uii:bg-white dark:uii:bg-gray-800"
|
|
407
|
-
}), /* @__PURE__ */ React2.createElement("input", {
|
|
408
|
-
type: "text",
|
|
409
|
-
placeholder: "Type (e.g., string | number)",
|
|
410
|
-
value: newTypeValue,
|
|
411
|
-
onChange: function(e) {
|
|
412
|
-
return setNewTypeValue(e.target.value);
|
|
229
|
+
), /* @__PURE__ */ React2.createElement(
|
|
230
|
+
"button",
|
|
231
|
+
{
|
|
232
|
+
onClick: handleAddType,
|
|
233
|
+
disabled: !newTypeKey.trim() || !newTypeValue.trim(),
|
|
234
|
+
className: "uii:text-xs uii:px-3 uii:py-1 uii:bg-purple-500 uii:text-white uii:rounded hover:uii:bg-purple-600 disabled:uii:opacity-50 disabled:uii:cursor-not-allowed"
|
|
235
|
+
},
|
|
236
|
+
"Add"
|
|
237
|
+
)), Object.keys(devCtx.inferredTypes).length > 0 && /* @__PURE__ */ React2.createElement("div", { className: "uii:mt-2" }, /* @__PURE__ */ React2.createElement("div", { className: "uii:flex uii:items-center uii:justify-between uii:mb-1" }, /* @__PURE__ */ React2.createElement("span", { className: "uii:text-xs uii:text-gray-500" }, "Current inferred types:"), /* @__PURE__ */ React2.createElement(
|
|
238
|
+
"button",
|
|
239
|
+
{
|
|
240
|
+
onClick: handleClearAllTypes,
|
|
241
|
+
className: "uii:text-xs uii:px-2 uii:py-0.5 uii:bg-red-100 dark:uii:bg-red-900 uii:text-red-700 dark:uii:text-red-300 uii:rounded hover:uii:bg-red-200"
|
|
242
|
+
},
|
|
243
|
+
"Clear All"
|
|
244
|
+
)), /* @__PURE__ */ React2.createElement("div", { className: "uii:space-y-1" }, Object.entries(devCtx.inferredTypes).map(([key, value]) => value && /* @__PURE__ */ React2.createElement(
|
|
245
|
+
"div",
|
|
246
|
+
{
|
|
247
|
+
key,
|
|
248
|
+
className: "uii:flex uii:items-center uii:gap-2 uii:text-xs uii:bg-white dark:uii:bg-gray-800 uii:px-2 uii:py-1 uii:rounded"
|
|
249
|
+
},
|
|
250
|
+
/* @__PURE__ */ React2.createElement(
|
|
251
|
+
"button",
|
|
252
|
+
{
|
|
253
|
+
onClick: () => {
|
|
254
|
+
navigator.clipboard.writeText(key);
|
|
413
255
|
},
|
|
414
|
-
|
|
415
|
-
|
|
256
|
+
className: "uii:text-gray-400 hover:uii:text-purple-600 uii:text-xs",
|
|
257
|
+
title: "Copy field name"
|
|
258
|
+
},
|
|
259
|
+
"\u{1F4CB}"
|
|
260
|
+
),
|
|
261
|
+
/* @__PURE__ */ React2.createElement(
|
|
262
|
+
"span",
|
|
263
|
+
{
|
|
264
|
+
className: "uii:font-mono uii:text-purple-600 dark:uii:text-purple-400 uii:cursor-pointer uii:truncate uii:max-w-[300px]",
|
|
265
|
+
onClick: () => {
|
|
266
|
+
navigator.clipboard.writeText(key);
|
|
416
267
|
},
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
className: "uii:text-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
}, Object.entries(devCtx.inferredTypes).map(function(param) {
|
|
434
|
-
var _param = _sliced_to_array(param, 2), key = _param[0], value = _param[1];
|
|
435
|
-
return value && /* @__PURE__ */ React2.createElement("div", {
|
|
436
|
-
key: key,
|
|
437
|
-
className: "uii:flex uii:items-center uii:gap-2 uii:text-xs uii:bg-white dark:uii:bg-gray-800 uii:px-2 uii:py-1 uii:rounded"
|
|
438
|
-
}, /* @__PURE__ */ React2.createElement("button", {
|
|
439
|
-
onClick: function() {
|
|
440
|
-
navigator.clipboard.writeText(key);
|
|
441
|
-
},
|
|
442
|
-
className: "uii:text-gray-400 hover:uii:text-purple-600 uii:text-xs",
|
|
443
|
-
title: "Copy field name"
|
|
444
|
-
}, "\uD83D\uDCCB"), /* @__PURE__ */ React2.createElement("span", {
|
|
445
|
-
className: "uii:font-mono uii:text-purple-600 dark:uii:text-purple-400 uii:cursor-pointer uii:truncate uii:max-w-[300px]",
|
|
446
|
-
onClick: function() {
|
|
447
|
-
navigator.clipboard.writeText(key);
|
|
448
|
-
},
|
|
449
|
-
title: key
|
|
450
|
-
}, key), /* @__PURE__ */ React2.createElement("span", {
|
|
451
|
-
className: "uii:text-gray-400"
|
|
452
|
-
}, "\u2192"), /* @__PURE__ */ React2.createElement("span", {
|
|
453
|
-
className: "uii:font-mono uii:text-gray-600 dark:uii:text-gray-300 uii:flex-1 uii:truncate"
|
|
454
|
-
}, value), /* @__PURE__ */ React2.createElement("button", {
|
|
455
|
-
onClick: function() {
|
|
456
|
-
return handleRemoveType(key);
|
|
457
|
-
},
|
|
458
|
-
className: "uii:text-red-500 hover:uii:text-red-700 uii:text-xs",
|
|
459
|
-
title: "Remove"
|
|
460
|
-
}, "\u2715"));
|
|
461
|
-
})))), showData && /* @__PURE__ */ React2.createElement("div", {
|
|
462
|
-
className: "uii:mt-2"
|
|
463
|
-
}, /* @__PURE__ */ React2.createElement("div", {
|
|
464
|
-
className: "uii:text-xs uii:mb-1 uii:font-medium"
|
|
465
|
-
}, "Data:"), /* @__PURE__ */ React2.createElement("pre", {
|
|
466
|
-
className: "uii:text-xs uii:bg-gray-100 dark:uii:bg-gray-800 uii:p-2 uii:rounded uii:overflow-auto uii:max-h-48"
|
|
467
|
-
}, JSON.stringify(devCtx.data, null, 2)), /* @__PURE__ */ React2.createElement("div", {
|
|
468
|
-
className: "uii:text-xs uii:mb-1 uii:mt-2 uii:font-medium"
|
|
469
|
-
}, "Inferred Types:"), /* @__PURE__ */ React2.createElement("pre", {
|
|
470
|
-
className: "uii:text-xs uii:bg-gray-100 dark:uii:bg-gray-800 uii:p-2 uii:rounded uii:overflow-auto uii:max-h-24"
|
|
471
|
-
}, JSON.stringify(devCtx.inferredTypes, null, 2))));
|
|
268
|
+
title: key
|
|
269
|
+
},
|
|
270
|
+
key
|
|
271
|
+
),
|
|
272
|
+
/* @__PURE__ */ React2.createElement("span", { className: "uii:text-gray-400" }, "\u2192"),
|
|
273
|
+
/* @__PURE__ */ React2.createElement("span", { className: "uii:font-mono uii:text-gray-600 dark:uii:text-gray-300 uii:flex-1 uii:truncate" }, value),
|
|
274
|
+
/* @__PURE__ */ React2.createElement(
|
|
275
|
+
"button",
|
|
276
|
+
{
|
|
277
|
+
onClick: () => handleRemoveType(key),
|
|
278
|
+
className: "uii:text-red-500 hover:uii:text-red-700 uii:text-xs",
|
|
279
|
+
title: "Remove"
|
|
280
|
+
},
|
|
281
|
+
"\u2715"
|
|
282
|
+
)
|
|
283
|
+
))))), showData && /* @__PURE__ */ React2.createElement("div", { className: "uii:mt-2" }, /* @__PURE__ */ React2.createElement("div", { className: "uii:text-xs uii:mb-1 uii:font-medium" }, "Data:"), /* @__PURE__ */ React2.createElement("pre", { className: "uii:text-xs uii:bg-gray-100 dark:uii:bg-gray-800 uii:p-2 uii:rounded uii:overflow-auto uii:max-h-48" }, JSON.stringify(devCtx.data, null, 2)), /* @__PURE__ */ React2.createElement("div", { className: "uii:text-xs uii:mb-1 uii:mt-2 uii:font-medium" }, "Inferred Types:"), /* @__PURE__ */ React2.createElement("pre", { className: "uii:text-xs uii:bg-gray-100 dark:uii:bg-gray-800 uii:p-2 uii:rounded uii:overflow-auto uii:max-h-24" }, JSON.stringify(devCtx.inferredTypes, null, 2))));
|
|
472
284
|
}
|
|
473
|
-
|
|
285
|
+
|
|
286
|
+
export { DevContext, DevProvider, DevToolbar, useDevContext, useInferredTypes, useNodeProperty };
|
|
287
|
+
//# sourceMappingURL=index.js.map
|
|
474
288
|
//# sourceMappingURL=index.js.map
|