@arcanejs/react-toolkit 0.3.2 → 0.4.1
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/chunk-RT2VSMJL.js +13 -0
- package/dist/chunk-TOGR56FN.mjs +13 -0
- package/dist/data.js +11 -2
- package/dist/data.mjs +10 -1
- package/dist/index.js +9 -3
- package/dist/index.mjs +9 -3
- package/dist/logging.d.mts +7 -0
- package/dist/logging.d.ts +7 -0
- package/dist/logging.js +8 -0
- package/dist/logging.mjs +8 -0
- package/package.json +16 -7
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/logging.ts
|
|
2
|
+
var _react = require('react');
|
|
3
|
+
var LoggerContext = _react.createContext.call(void 0, () => {
|
|
4
|
+
throw new Error("LoggerContext not provided");
|
|
5
|
+
});
|
|
6
|
+
var useLogger = () => {
|
|
7
|
+
return _react.useContext.call(void 0, LoggerContext)();
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
exports.LoggerContext = LoggerContext; exports.useLogger = useLogger;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// src/logging.ts
|
|
2
|
+
import { createContext, useContext } from "react";
|
|
3
|
+
var LoggerContext = createContext(() => {
|
|
4
|
+
throw new Error("LoggerContext not provided");
|
|
5
|
+
});
|
|
6
|
+
var useLogger = () => {
|
|
7
|
+
return useContext(LoggerContext)();
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export {
|
|
11
|
+
LoggerContext,
|
|
12
|
+
useLogger
|
|
13
|
+
};
|
package/dist/data.js
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
|
+
|
|
3
|
+
var _chunkRT2VSMJLjs = require('./chunk-RT2VSMJL.js');
|
|
4
|
+
|
|
5
|
+
// src/data.tsx
|
|
2
6
|
var _fs = require('fs');
|
|
3
7
|
|
|
4
8
|
|
|
@@ -29,6 +33,7 @@ function useDataFileCore({
|
|
|
29
33
|
path,
|
|
30
34
|
onPathChange = "defaultValue"
|
|
31
35
|
}) {
|
|
36
|
+
const log = _chunkRT2VSMJLjs.useLogger.call(void 0, );
|
|
32
37
|
const state = _react.useRef.call(void 0, {
|
|
33
38
|
initialized: false,
|
|
34
39
|
path: null,
|
|
@@ -134,10 +139,14 @@ function useDataFileCore({
|
|
|
134
139
|
return;
|
|
135
140
|
}
|
|
136
141
|
if (error.code === "ENOENT") {
|
|
137
|
-
console.log("Creating new file");
|
|
138
142
|
const initialData = onPathChange === "transfer" && state.current.previousData !== void 0 ? state.current.previousData : defaultValue;
|
|
139
143
|
state.current.data = initialData;
|
|
140
144
|
state.current.state = { state: "dirty" };
|
|
145
|
+
_optionalChain([log, 'optionalAccess', _ => _.info, 'call', _2 => _2(
|
|
146
|
+
"Creating a new file at %s with initial data %o",
|
|
147
|
+
path,
|
|
148
|
+
initialData
|
|
149
|
+
)]);
|
|
141
150
|
saveData();
|
|
142
151
|
updateDataFromState();
|
|
143
152
|
return;
|
package/dist/data.mjs
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useLogger
|
|
3
|
+
} from "./chunk-TOGR56FN.mjs";
|
|
4
|
+
|
|
1
5
|
// src/data.tsx
|
|
2
6
|
import { promises as fs } from "fs";
|
|
3
7
|
import {
|
|
@@ -29,6 +33,7 @@ function useDataFileCore({
|
|
|
29
33
|
path,
|
|
30
34
|
onPathChange = "defaultValue"
|
|
31
35
|
}) {
|
|
36
|
+
const log = useLogger();
|
|
32
37
|
const state = useRef({
|
|
33
38
|
initialized: false,
|
|
34
39
|
path: null,
|
|
@@ -134,10 +139,14 @@ function useDataFileCore({
|
|
|
134
139
|
return;
|
|
135
140
|
}
|
|
136
141
|
if (error.code === "ENOENT") {
|
|
137
|
-
console.log("Creating new file");
|
|
138
142
|
const initialData = onPathChange === "transfer" && state.current.previousData !== void 0 ? state.current.previousData : defaultValue;
|
|
139
143
|
state.current.data = initialData;
|
|
140
144
|
state.current.state = { state: "dirty" };
|
|
145
|
+
log?.info(
|
|
146
|
+
"Creating a new file at %s with initial data %o",
|
|
147
|
+
path,
|
|
148
|
+
initialData
|
|
149
|
+
);
|
|
141
150
|
saveData();
|
|
142
151
|
updateDataFromState();
|
|
143
152
|
return;
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
2
|
+
|
|
3
|
+
var _chunkRT2VSMJLjs = require('./chunk-RT2VSMJL.js');
|
|
4
|
+
|
|
5
|
+
// src/index.tsx
|
|
2
6
|
var _reactreconciler = require('react-reconciler'); var _reactreconciler2 = _interopRequireDefault(_reactreconciler);
|
|
3
7
|
var _constants = require('react-reconciler/constants');
|
|
4
8
|
var _toolkit = require('@arcanejs/toolkit'); var ld = _interopRequireWildcard(_toolkit);
|
|
@@ -40,7 +44,8 @@ var Timeline = React.forwardRef(
|
|
|
40
44
|
(props, ref) => React.createElement("timeline", { ...props, ref }, props.children)
|
|
41
45
|
);
|
|
42
46
|
|
|
43
|
-
// src/index.
|
|
47
|
+
// src/index.tsx
|
|
48
|
+
var _jsxruntime = require('react/jsx-runtime');
|
|
44
49
|
var isType = (targetType, type, _props) => targetType === type;
|
|
45
50
|
var canSetProps = (instance) => instance instanceof _base.Base;
|
|
46
51
|
var updateListener = (eventName, property, instance, prevProps, nextProps) => {
|
|
@@ -220,7 +225,8 @@ var reconciler = _reactreconciler2.default.call(void 0, hostConfig);
|
|
|
220
225
|
var ToolkitRenderer = {
|
|
221
226
|
renderGroup: (component, container) => {
|
|
222
227
|
const root = reconciler.createContainer(container, 0, false, null);
|
|
223
|
-
|
|
228
|
+
const componentWithContexts = /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRT2VSMJLjs.LoggerContext.Provider, { value: container.log, children: component });
|
|
229
|
+
reconciler.updateContainer(componentWithContexts, root, null);
|
|
224
230
|
},
|
|
225
231
|
render: (component, container, rootGroupProps) => {
|
|
226
232
|
const group = new ld.Group(rootGroupProps);
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import {
|
|
2
|
+
LoggerContext
|
|
3
|
+
} from "./chunk-TOGR56FN.mjs";
|
|
4
|
+
|
|
5
|
+
// src/index.tsx
|
|
2
6
|
import Reconciler from "react-reconciler";
|
|
3
7
|
import { DefaultEventPriority } from "react-reconciler/constants";
|
|
4
8
|
import * as ld from "@arcanejs/toolkit";
|
|
@@ -40,7 +44,8 @@ var Timeline = React.forwardRef(
|
|
|
40
44
|
(props, ref) => React.createElement("timeline", { ...props, ref }, props.children)
|
|
41
45
|
);
|
|
42
46
|
|
|
43
|
-
// src/index.
|
|
47
|
+
// src/index.tsx
|
|
48
|
+
import { jsx } from "react/jsx-runtime";
|
|
44
49
|
var isType = (targetType, type, _props) => targetType === type;
|
|
45
50
|
var canSetProps = (instance) => instance instanceof Base;
|
|
46
51
|
var updateListener = (eventName, property, instance, prevProps, nextProps) => {
|
|
@@ -220,7 +225,8 @@ var reconciler = Reconciler(hostConfig);
|
|
|
220
225
|
var ToolkitRenderer = {
|
|
221
226
|
renderGroup: (component, container) => {
|
|
222
227
|
const root = reconciler.createContainer(container, 0, false, null);
|
|
223
|
-
|
|
228
|
+
const componentWithContexts = /* @__PURE__ */ jsx(LoggerContext.Provider, { value: container.log, children: component });
|
|
229
|
+
reconciler.updateContainer(componentWithContexts, root, null);
|
|
224
230
|
},
|
|
225
231
|
render: (component, container, rootGroupProps) => {
|
|
226
232
|
const group = new ld.Group(rootGroupProps);
|
package/dist/logging.js
ADDED
package/dist/logging.mjs
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcanejs/react-toolkit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Build web-accessible control interfaces for your long-running Node.js processes",
|
|
6
6
|
"keywords": [
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
},
|
|
21
21
|
"exports": {
|
|
22
22
|
".": {
|
|
23
|
-
"@arcanejs/source": "./src/index.
|
|
23
|
+
"@arcanejs/source": "./src/index.tsx",
|
|
24
24
|
"import": "./dist/index.mjs",
|
|
25
25
|
"require": "./dist/index.js",
|
|
26
26
|
"types": "./dist/index.d.ts"
|
|
@@ -30,7 +30,14 @@
|
|
|
30
30
|
"import": "./dist/data.mjs",
|
|
31
31
|
"require": "./dist/data.js",
|
|
32
32
|
"types": "./dist/data.d.ts"
|
|
33
|
-
}
|
|
33
|
+
},
|
|
34
|
+
"./logging": {
|
|
35
|
+
"@arcanejs/source": "./src/logging.ts",
|
|
36
|
+
"import": "./dist/logging.mjs",
|
|
37
|
+
"require": "./dist/logging.js",
|
|
38
|
+
"types": "./dist/logging.d.ts"
|
|
39
|
+
},
|
|
40
|
+
"./package.json": "./package.json"
|
|
34
41
|
},
|
|
35
42
|
"devDependencies": {
|
|
36
43
|
"@types/eslint": "^8.56.5",
|
|
@@ -38,18 +45,20 @@
|
|
|
38
45
|
"@types/node": "^20.11.24",
|
|
39
46
|
"@types/react": "^18",
|
|
40
47
|
"@types/react-reconciler": "^0.28.8",
|
|
48
|
+
"check-export-map": "^1.3.1",
|
|
41
49
|
"eslint": "^8.57.0",
|
|
42
50
|
"tsup": "^8.1.0",
|
|
43
51
|
"typescript": "^5.3.3",
|
|
44
52
|
"zod": "^3.23.8",
|
|
45
|
-
"@arcanejs/
|
|
46
|
-
"@arcanejs/
|
|
53
|
+
"@arcanejs/typescript-config": "^0.0.0",
|
|
54
|
+
"@arcanejs/eslint-config": "^0.0.0"
|
|
47
55
|
},
|
|
48
56
|
"dependencies": {
|
|
49
57
|
"lodash": "^4.17.21",
|
|
50
58
|
"react": "^18",
|
|
51
59
|
"react-reconciler": "0.28.0",
|
|
52
|
-
"@arcanejs/
|
|
60
|
+
"@arcanejs/protocol": "^0.2.0",
|
|
61
|
+
"@arcanejs/toolkit": "^0.3.0"
|
|
53
62
|
},
|
|
54
63
|
"peerDependencies": {
|
|
55
64
|
"zod": "^3.23.8"
|
|
@@ -67,7 +76,7 @@
|
|
|
67
76
|
},
|
|
68
77
|
"scripts": {
|
|
69
78
|
"lint": "eslint . --max-warnings 0",
|
|
70
|
-
"build": "tsup",
|
|
79
|
+
"build": "rm -rf dist && tsup && check-export-map",
|
|
71
80
|
"dev": "tsup --watch"
|
|
72
81
|
}
|
|
73
82
|
}
|