@arcanejs/react-toolkit 0.12.5 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +273 -193
- package/dist/{chunk-Q54JXYCV.js → chunk-EJVUDIQP.js} +94 -38
- package/dist/{chunk-CAHNLXTY.mjs → chunk-TP2BI3OM.mjs} +93 -37
- package/dist/colors.js +7 -7
- package/dist/colors.mjs +1 -1
- package/dist/data.d.mts +12 -2
- package/dist/data.d.ts +12 -2
- package/dist/data.js +49 -12
- package/dist/data.mjs +47 -10
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/index.mjs +1 -1
- package/package.json +8 -8
package/dist/data.js
CHANGED
|
@@ -27,11 +27,20 @@ function useDataFileContext(dataFile) {
|
|
|
27
27
|
function useDataFile(dataFile, usage) {
|
|
28
28
|
return dataFile.useDataFile(usage);
|
|
29
29
|
}
|
|
30
|
+
var ArcaneDataFileError = class extends Error {
|
|
31
|
+
constructor(message, operation, path, cause) {
|
|
32
|
+
super(message, { cause });
|
|
33
|
+
this.operation = operation;
|
|
34
|
+
this.path = path;
|
|
35
|
+
this.name = `ArcaneDataFileError(${operation})`;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
30
38
|
function useDataFileCore({
|
|
31
39
|
schema,
|
|
32
40
|
defaultValue,
|
|
33
41
|
path,
|
|
34
|
-
onPathChange = "defaultValue"
|
|
42
|
+
onPathChange = "defaultValue",
|
|
43
|
+
onError
|
|
35
44
|
}) {
|
|
36
45
|
const log = _chunkRT2VSMJLjs.useLogger.call(void 0, );
|
|
37
46
|
const state = _react.useRef.call(void 0, {
|
|
@@ -48,9 +57,13 @@ function useDataFileCore({
|
|
|
48
57
|
if (!state.current.initialized) {
|
|
49
58
|
state.current.initialized = true;
|
|
50
59
|
} else {
|
|
51
|
-
|
|
52
|
-
"Cannot change schema or defaultValue after initialization"
|
|
60
|
+
const error = new ArcaneDataFileError(
|
|
61
|
+
"Cannot change schema or defaultValue after initialization",
|
|
62
|
+
"usage",
|
|
63
|
+
null
|
|
53
64
|
);
|
|
65
|
+
_optionalChain([onError, 'optionalCall', _ => _(error)]);
|
|
66
|
+
throw error;
|
|
54
67
|
}
|
|
55
68
|
}, [schema, defaultValue]);
|
|
56
69
|
const [data, setData] = _react.useState.call(void 0, {
|
|
@@ -104,7 +117,14 @@ function useDataFileCore({
|
|
|
104
117
|
if (state.current.path === currentPath && state.current.data === currentData) {
|
|
105
118
|
state.current.state = { state: "saved" };
|
|
106
119
|
}
|
|
107
|
-
} catch (
|
|
120
|
+
} catch (cause) {
|
|
121
|
+
const error = new ArcaneDataFileError(
|
|
122
|
+
`Error saving data file to path: ${currentPath}`,
|
|
123
|
+
"save",
|
|
124
|
+
currentPath,
|
|
125
|
+
cause
|
|
126
|
+
);
|
|
127
|
+
_optionalChain([onError, 'optionalCall', _2 => _2(error)]);
|
|
108
128
|
if (state.current.path === currentPath && state.current.data === currentData) {
|
|
109
129
|
state.current.state = { state: "error", error };
|
|
110
130
|
updateDataFromState();
|
|
@@ -140,16 +160,16 @@ function useDataFileCore({
|
|
|
140
160
|
state.current.state = { state: "saved" };
|
|
141
161
|
updateDataFromState();
|
|
142
162
|
}
|
|
143
|
-
}).catch((
|
|
163
|
+
}).catch((err) => {
|
|
144
164
|
if (state.current.path !== path) {
|
|
145
165
|
return;
|
|
146
166
|
}
|
|
147
|
-
if (
|
|
167
|
+
if (err.code === "ENOENT") {
|
|
148
168
|
const initialData = onPathChange === "transfer" && state.current.previousData !== void 0 ? state.current.previousData : defaultValue;
|
|
149
169
|
state.current.data = initialData;
|
|
150
170
|
state.current.lastUpdatedMillis = Date.now();
|
|
151
171
|
state.current.state = { state: "dirty" };
|
|
152
|
-
_optionalChain([log, 'optionalAccess',
|
|
172
|
+
_optionalChain([log, 'optionalAccess', _3 => _3.info, 'call', _4 => _4(
|
|
153
173
|
"Creating a new file at %s with initial data %o",
|
|
154
174
|
path,
|
|
155
175
|
initialData
|
|
@@ -158,6 +178,14 @@ function useDataFileCore({
|
|
|
158
178
|
updateDataFromState();
|
|
159
179
|
return;
|
|
160
180
|
}
|
|
181
|
+
const error = new ArcaneDataFileError(
|
|
182
|
+
`Error loading data file at path: ${path}`,
|
|
183
|
+
"load",
|
|
184
|
+
path,
|
|
185
|
+
err
|
|
186
|
+
);
|
|
187
|
+
_optionalChain([onError, 'optionalCall', _5 => _5(error)]);
|
|
188
|
+
_optionalChain([log, 'optionalAccess', _6 => _6.error, 'call', _7 => _7(error)]);
|
|
161
189
|
state.current.state = { state: "error", error };
|
|
162
190
|
updateDataFromState();
|
|
163
191
|
});
|
|
@@ -202,17 +230,25 @@ function createDataFileDefinition({
|
|
|
202
230
|
});
|
|
203
231
|
const useDataFile2 = ({
|
|
204
232
|
path,
|
|
205
|
-
onPathChange
|
|
233
|
+
onPathChange,
|
|
234
|
+
onError
|
|
206
235
|
}) => useDataFileCore({
|
|
207
236
|
schema,
|
|
208
237
|
defaultValue,
|
|
209
238
|
path,
|
|
210
|
-
onPathChange
|
|
239
|
+
onPathChange,
|
|
240
|
+
onError
|
|
211
241
|
});
|
|
212
|
-
const Provider = ({
|
|
242
|
+
const Provider = ({
|
|
243
|
+
path,
|
|
244
|
+
onPathChange,
|
|
245
|
+
onError,
|
|
246
|
+
children
|
|
247
|
+
}) => {
|
|
213
248
|
const { data, updateData, saveData } = useDataFile2({
|
|
214
249
|
path,
|
|
215
|
-
onPathChange
|
|
250
|
+
onPathChange,
|
|
251
|
+
onError
|
|
216
252
|
});
|
|
217
253
|
const providedContext = _react.useMemo.call(void 0,
|
|
218
254
|
() => ({
|
|
@@ -243,4 +279,5 @@ function createDataFileDefinition({
|
|
|
243
279
|
|
|
244
280
|
|
|
245
281
|
|
|
246
|
-
|
|
282
|
+
|
|
283
|
+
exports.ArcaneDataFileError = ArcaneDataFileError; exports.createDataFileDefinition = createDataFileDefinition; exports.useDataFile = useDataFile; exports.useDataFileContext = useDataFileContext; exports.useDataFileCore = useDataFileCore; exports.useDataFileData = useDataFileData; exports.useDataFileUpdater = useDataFileUpdater;
|
package/dist/data.mjs
CHANGED
|
@@ -27,11 +27,20 @@ function useDataFileContext(dataFile) {
|
|
|
27
27
|
function useDataFile(dataFile, usage) {
|
|
28
28
|
return dataFile.useDataFile(usage);
|
|
29
29
|
}
|
|
30
|
+
var ArcaneDataFileError = class extends Error {
|
|
31
|
+
constructor(message, operation, path, cause) {
|
|
32
|
+
super(message, { cause });
|
|
33
|
+
this.operation = operation;
|
|
34
|
+
this.path = path;
|
|
35
|
+
this.name = `ArcaneDataFileError(${operation})`;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
30
38
|
function useDataFileCore({
|
|
31
39
|
schema,
|
|
32
40
|
defaultValue,
|
|
33
41
|
path,
|
|
34
|
-
onPathChange = "defaultValue"
|
|
42
|
+
onPathChange = "defaultValue",
|
|
43
|
+
onError
|
|
35
44
|
}) {
|
|
36
45
|
const log = useLogger();
|
|
37
46
|
const state = useRef({
|
|
@@ -48,9 +57,13 @@ function useDataFileCore({
|
|
|
48
57
|
if (!state.current.initialized) {
|
|
49
58
|
state.current.initialized = true;
|
|
50
59
|
} else {
|
|
51
|
-
|
|
52
|
-
"Cannot change schema or defaultValue after initialization"
|
|
60
|
+
const error = new ArcaneDataFileError(
|
|
61
|
+
"Cannot change schema or defaultValue after initialization",
|
|
62
|
+
"usage",
|
|
63
|
+
null
|
|
53
64
|
);
|
|
65
|
+
onError?.(error);
|
|
66
|
+
throw error;
|
|
54
67
|
}
|
|
55
68
|
}, [schema, defaultValue]);
|
|
56
69
|
const [data, setData] = useState({
|
|
@@ -104,7 +117,14 @@ function useDataFileCore({
|
|
|
104
117
|
if (state.current.path === currentPath && state.current.data === currentData) {
|
|
105
118
|
state.current.state = { state: "saved" };
|
|
106
119
|
}
|
|
107
|
-
} catch (
|
|
120
|
+
} catch (cause) {
|
|
121
|
+
const error = new ArcaneDataFileError(
|
|
122
|
+
`Error saving data file to path: ${currentPath}`,
|
|
123
|
+
"save",
|
|
124
|
+
currentPath,
|
|
125
|
+
cause
|
|
126
|
+
);
|
|
127
|
+
onError?.(error);
|
|
108
128
|
if (state.current.path === currentPath && state.current.data === currentData) {
|
|
109
129
|
state.current.state = { state: "error", error };
|
|
110
130
|
updateDataFromState();
|
|
@@ -140,11 +160,11 @@ function useDataFileCore({
|
|
|
140
160
|
state.current.state = { state: "saved" };
|
|
141
161
|
updateDataFromState();
|
|
142
162
|
}
|
|
143
|
-
}).catch((
|
|
163
|
+
}).catch((err) => {
|
|
144
164
|
if (state.current.path !== path) {
|
|
145
165
|
return;
|
|
146
166
|
}
|
|
147
|
-
if (
|
|
167
|
+
if (err.code === "ENOENT") {
|
|
148
168
|
const initialData = onPathChange === "transfer" && state.current.previousData !== void 0 ? state.current.previousData : defaultValue;
|
|
149
169
|
state.current.data = initialData;
|
|
150
170
|
state.current.lastUpdatedMillis = Date.now();
|
|
@@ -158,6 +178,14 @@ function useDataFileCore({
|
|
|
158
178
|
updateDataFromState();
|
|
159
179
|
return;
|
|
160
180
|
}
|
|
181
|
+
const error = new ArcaneDataFileError(
|
|
182
|
+
`Error loading data file at path: ${path}`,
|
|
183
|
+
"load",
|
|
184
|
+
path,
|
|
185
|
+
err
|
|
186
|
+
);
|
|
187
|
+
onError?.(error);
|
|
188
|
+
log?.error(error);
|
|
161
189
|
state.current.state = { state: "error", error };
|
|
162
190
|
updateDataFromState();
|
|
163
191
|
});
|
|
@@ -202,17 +230,25 @@ function createDataFileDefinition({
|
|
|
202
230
|
});
|
|
203
231
|
const useDataFile2 = ({
|
|
204
232
|
path,
|
|
205
|
-
onPathChange
|
|
233
|
+
onPathChange,
|
|
234
|
+
onError
|
|
206
235
|
}) => useDataFileCore({
|
|
207
236
|
schema,
|
|
208
237
|
defaultValue,
|
|
209
238
|
path,
|
|
210
|
-
onPathChange
|
|
239
|
+
onPathChange,
|
|
240
|
+
onError
|
|
211
241
|
});
|
|
212
|
-
const Provider = ({
|
|
242
|
+
const Provider = ({
|
|
243
|
+
path,
|
|
244
|
+
onPathChange,
|
|
245
|
+
onError,
|
|
246
|
+
children
|
|
247
|
+
}) => {
|
|
213
248
|
const { data, updateData, saveData } = useDataFile2({
|
|
214
249
|
path,
|
|
215
|
-
onPathChange
|
|
250
|
+
onPathChange,
|
|
251
|
+
onError
|
|
216
252
|
});
|
|
217
253
|
const providedContext = useMemo(
|
|
218
254
|
() => ({
|
|
@@ -237,6 +273,7 @@ function createDataFileDefinition({
|
|
|
237
273
|
};
|
|
238
274
|
}
|
|
239
275
|
export {
|
|
276
|
+
ArcaneDataFileError,
|
|
240
277
|
createDataFileDefinition,
|
|
241
278
|
useDataFile,
|
|
242
279
|
useDataFileContext,
|
package/dist/index.d.mts
CHANGED
|
@@ -51,8 +51,8 @@ type ReactToolkitConfig = {
|
|
|
51
51
|
componentNamespaces: Array<PreparedComponents<any>>;
|
|
52
52
|
};
|
|
53
53
|
declare const ToolkitRenderer: {
|
|
54
|
-
renderGroup: (component:
|
|
55
|
-
render: (component:
|
|
54
|
+
renderGroup: (component: React__default.ReactElement, container: ld.Group, config?: ReactToolkitConfig) => void;
|
|
55
|
+
render: (component: React__default.ReactElement, container: ld.Toolkit, rootGroupProps?: Props, config?: ReactToolkitConfig) => void;
|
|
56
56
|
};
|
|
57
57
|
|
|
58
58
|
declare const Button: React__default.ForwardRefExoticComponent<Partial<Partial<_arcanejs_toolkit_components_button.InternalProps>> & React__default.RefAttributes<ld.Button>>;
|
package/dist/index.d.ts
CHANGED
|
@@ -51,8 +51,8 @@ type ReactToolkitConfig = {
|
|
|
51
51
|
componentNamespaces: Array<PreparedComponents<any>>;
|
|
52
52
|
};
|
|
53
53
|
declare const ToolkitRenderer: {
|
|
54
|
-
renderGroup: (component:
|
|
55
|
-
render: (component:
|
|
54
|
+
renderGroup: (component: React__default.ReactElement, container: ld.Group, config?: ReactToolkitConfig) => void;
|
|
55
|
+
render: (component: React__default.ReactElement, container: ld.Toolkit, rootGroupProps?: Props, config?: ReactToolkitConfig) => void;
|
|
56
56
|
};
|
|
57
57
|
|
|
58
58
|
declare const Button: React__default.ForwardRefExoticComponent<Partial<Partial<_arcanejs_toolkit_components_button.InternalProps>> & React__default.RefAttributes<ld.Button>>;
|
package/dist/index.js
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
|
|
16
|
-
var
|
|
16
|
+
var _chunkEJVUDIQPjs = require('./chunk-EJVUDIQP.js');
|
|
17
17
|
require('./chunk-RT2VSMJL.js');
|
|
18
18
|
|
|
19
19
|
|
|
@@ -30,4 +30,4 @@ require('./chunk-RT2VSMJL.js');
|
|
|
30
30
|
|
|
31
31
|
|
|
32
32
|
|
|
33
|
-
exports.Button =
|
|
33
|
+
exports.Button = _chunkEJVUDIQPjs.Button; exports.CoreComponents = _chunkEJVUDIQPjs.CoreComponents; exports.Group = _chunkEJVUDIQPjs.Group; exports.GroupHeader = _chunkEJVUDIQPjs.GroupHeader; exports.Label = _chunkEJVUDIQPjs.Label; exports.Rect = _chunkEJVUDIQPjs.Rect; exports.SliderButton = _chunkEJVUDIQPjs.SliderButton; exports.Switch = _chunkEJVUDIQPjs.Switch; exports.Tab = _chunkEJVUDIQPjs.Tab; exports.Tabs = _chunkEJVUDIQPjs.Tabs; exports.TextInput = _chunkEJVUDIQPjs.TextInput; exports.Timeline = _chunkEJVUDIQPjs.Timeline; exports.ToolkitRenderer = _chunkEJVUDIQPjs.ToolkitRenderer; exports.prepareComponents = _chunkEJVUDIQPjs.prepareComponents;
|
package/dist/index.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcanejs/react-toolkit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Build web-accessible control interfaces for your long-running Node.js processes",
|
|
6
6
|
"keywords": [
|
|
@@ -55,8 +55,8 @@
|
|
|
55
55
|
"@types/eslint": "^8.56.5",
|
|
56
56
|
"@types/lodash": "^4.17.10",
|
|
57
57
|
"@types/node": "^20.11.24",
|
|
58
|
-
"@types/react": "^
|
|
59
|
-
"@types/react-reconciler": "^0.
|
|
58
|
+
"@types/react": "^19.2.2",
|
|
59
|
+
"@types/react-reconciler": "^0.32.2",
|
|
60
60
|
"check-export-map": "^1.3.1",
|
|
61
61
|
"eslint": "^8.57.0",
|
|
62
62
|
"tsup": "^8.1.0",
|
|
@@ -66,11 +66,11 @@
|
|
|
66
66
|
"@arcanejs/typescript-config": "^0.0.0"
|
|
67
67
|
},
|
|
68
68
|
"dependencies": {
|
|
69
|
-
"lodash": "^4.17.
|
|
70
|
-
"react": "^
|
|
71
|
-
"react-reconciler": "0.
|
|
72
|
-
"@arcanejs/
|
|
73
|
-
"@arcanejs/
|
|
69
|
+
"lodash": "^4.17.23",
|
|
70
|
+
"react": "^19.2.0",
|
|
71
|
+
"react-reconciler": "0.33.0",
|
|
72
|
+
"@arcanejs/protocol": "^0.8.0",
|
|
73
|
+
"@arcanejs/toolkit": "^7.0.0"
|
|
74
74
|
},
|
|
75
75
|
"peerDependencies": {
|
|
76
76
|
"zod": "^3.23.8"
|