@fxhash/params 0.0.10 → 0.0.11
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-7H32FZ35.js → chunk-B3N473DY.js} +45 -37
- package/dist/chunk-B3N473DY.js.map +1 -0
- package/dist/index.d.ts +249 -3
- package/dist/index.js +100 -5
- package/dist/index.js.map +1 -1
- package/dist/utils-jEvPb5wq.d.ts +141 -0
- package/dist/utils.d.ts +1 -50
- package/dist/utils.js +2 -32
- package/dist/utils.js.map +1 -1
- package/package.json +31 -47
- package/dist/BaseInput.cjs +0 -13
- package/dist/BaseInput.cjs.map +0 -1
- package/dist/BaseInput.css +0 -112
- package/dist/BaseInput.css.map +0 -1
- package/dist/BaseInput.d.ts +0 -12
- package/dist/BaseInput.js +0 -13
- package/dist/BaseInput.js.map +0 -1
- package/dist/Context.cjs +0 -49
- package/dist/Context.cjs.map +0 -1
- package/dist/Context.d.ts +0 -19
- package/dist/Context.js +0 -49
- package/dist/Context.js.map +0 -1
- package/dist/Controller/BigInt.cjs +0 -10
- package/dist/Controller/BigInt.cjs.map +0 -1
- package/dist/Controller/BigInt.css +0 -183
- package/dist/Controller/BigInt.css.map +0 -1
- package/dist/Controller/BigInt.d.ts +0 -8
- package/dist/Controller/BigInt.js +0 -10
- package/dist/Controller/BigInt.js.map +0 -1
- package/dist/Controller/Boolean.cjs +0 -9
- package/dist/Controller/Boolean.cjs.map +0 -1
- package/dist/Controller/Boolean.css +0 -183
- package/dist/Controller/Boolean.css.map +0 -1
- package/dist/Controller/Boolean.d.ts +0 -8
- package/dist/Controller/Boolean.js +0 -9
- package/dist/Controller/Boolean.js.map +0 -1
- package/dist/Controller/Bytes.cjs +0 -9
- package/dist/Controller/Bytes.cjs.map +0 -1
- package/dist/Controller/Bytes.css +0 -191
- package/dist/Controller/Bytes.css.map +0 -1
- package/dist/Controller/Bytes.d.ts +0 -8
- package/dist/Controller/Bytes.js +0 -9
- package/dist/Controller/Bytes.js.map +0 -1
- package/dist/Controller/Color.cjs +0 -10
- package/dist/Controller/Color.cjs.map +0 -1
- package/dist/Controller/Color.css +0 -227
- package/dist/Controller/Color.css.map +0 -1
- package/dist/Controller/Color.d.ts +0 -8
- package/dist/Controller/Color.js +0 -10
- package/dist/Controller/Color.js.map +0 -1
- package/dist/Controller/Controller.cjs +0 -14
- package/dist/Controller/Controller.cjs.map +0 -1
- package/dist/Controller/Controller.css +0 -183
- package/dist/Controller/Controller.css.map +0 -1
- package/dist/Controller/Controller.d.ts +0 -41
- package/dist/Controller/Controller.js +0 -14
- package/dist/Controller/Controller.js.map +0 -1
- package/dist/Controller/Invalid.cjs +0 -7
- package/dist/Controller/Invalid.cjs.map +0 -1
- package/dist/Controller/Invalid.css +0 -48
- package/dist/Controller/Invalid.css.map +0 -1
- package/dist/Controller/Invalid.d.ts +0 -11
- package/dist/Controller/Invalid.js +0 -7
- package/dist/Controller/Invalid.js.map +0 -1
- package/dist/Controller/Number.cjs +0 -9
- package/dist/Controller/Number.cjs.map +0 -1
- package/dist/Controller/Number.css +0 -183
- package/dist/Controller/Number.css.map +0 -1
- package/dist/Controller/Number.d.ts +0 -8
- package/dist/Controller/Number.js +0 -9
- package/dist/Controller/Number.js.map +0 -1
- package/dist/Controller/Param.cjs +0 -21
- package/dist/Controller/Param.cjs.map +0 -1
- package/dist/Controller/Param.css +0 -283
- package/dist/Controller/Param.css.map +0 -1
- package/dist/Controller/Param.d.ts +0 -25
- package/dist/Controller/Param.js +0 -21
- package/dist/Controller/Param.js.map +0 -1
- package/dist/Controller/Select.cjs +0 -9
- package/dist/Controller/Select.cjs.map +0 -1
- package/dist/Controller/Select.css +0 -183
- package/dist/Controller/Select.css.map +0 -1
- package/dist/Controller/Select.d.ts +0 -8
- package/dist/Controller/Select.js +0 -9
- package/dist/Controller/Select.js.map +0 -1
- package/dist/Controller/String.cjs +0 -9
- package/dist/Controller/String.cjs.map +0 -1
- package/dist/Controller/String.css +0 -183
- package/dist/Controller/String.css.map +0 -1
- package/dist/Controller/String.d.ts +0 -8
- package/dist/Controller/String.js +0 -9
- package/dist/Controller/String.js.map +0 -1
- package/dist/Controls.cjs +0 -102
- package/dist/Controls.cjs.map +0 -1
- package/dist/Controls.css +0 -304
- package/dist/Controls.css.map +0 -1
- package/dist/Controls.d.ts +0 -17
- package/dist/Controls.js +0 -102
- package/dist/Controls.js.map +0 -1
- package/dist/LockButton/LockButton.cjs +0 -8
- package/dist/LockButton/LockButton.cjs.map +0 -1
- package/dist/LockButton/LockButton.css +0 -117
- package/dist/LockButton/LockButton.css.map +0 -1
- package/dist/LockButton/LockButton.d.ts +0 -11
- package/dist/LockButton/LockButton.js +0 -8
- package/dist/LockButton/LockButton.js.map +0 -1
- package/dist/ParamsHistory.cjs +0 -89
- package/dist/ParamsHistory.cjs.map +0 -1
- package/dist/ParamsHistory.d.ts +0 -22
- package/dist/ParamsHistory.js +0 -89
- package/dist/ParamsHistory.js.map +0 -1
- package/dist/RuntimeContext.cjs +0 -10
- package/dist/RuntimeContext.cjs.map +0 -1
- package/dist/RuntimeContext.d.ts +0 -44
- package/dist/RuntimeContext.js +0 -10
- package/dist/RuntimeContext.js.map +0 -1
- package/dist/chunk-2SARESCF.js +0 -135
- package/dist/chunk-2SARESCF.js.map +0 -1
- package/dist/chunk-2XWOWIXK.cjs +0 -23
- package/dist/chunk-2XWOWIXK.cjs.map +0 -1
- package/dist/chunk-3OF5LR4Y.cjs +0 -110
- package/dist/chunk-3OF5LR4Y.cjs.map +0 -1
- package/dist/chunk-3QFEC7SK.cjs +0 -39
- package/dist/chunk-3QFEC7SK.cjs.map +0 -1
- package/dist/chunk-4OKETOHR.js +0 -120
- package/dist/chunk-4OKETOHR.js.map +0 -1
- package/dist/chunk-7H32FZ35.js.map +0 -1
- package/dist/chunk-AMJCUB2I.cjs +0 -46
- package/dist/chunk-AMJCUB2I.cjs.map +0 -1
- package/dist/chunk-BEDRMOBJ.js +0 -43
- package/dist/chunk-BEDRMOBJ.js.map +0 -1
- package/dist/chunk-CVLSVTCX.cjs +0 -43
- package/dist/chunk-CVLSVTCX.cjs.map +0 -1
- package/dist/chunk-EACKNC6C.cjs +0 -103
- package/dist/chunk-EACKNC6C.cjs.map +0 -1
- package/dist/chunk-GDSG5VLX.js +0 -67
- package/dist/chunk-GDSG5VLX.js.map +0 -1
- package/dist/chunk-GXCX5YCI.js +0 -46
- package/dist/chunk-GXCX5YCI.js.map +0 -1
- package/dist/chunk-HIC6NEI2.js +0 -39
- package/dist/chunk-HIC6NEI2.js.map +0 -1
- package/dist/chunk-JSFJKANM.js +0 -115
- package/dist/chunk-JSFJKANM.js.map +0 -1
- package/dist/chunk-K22KNCGR.cjs +0 -24
- package/dist/chunk-K22KNCGR.cjs.map +0 -1
- package/dist/chunk-K6UPSPM5.cjs +0 -115
- package/dist/chunk-K6UPSPM5.cjs.map +0 -1
- package/dist/chunk-LTIGECX6.cjs +0 -44
- package/dist/chunk-LTIGECX6.cjs.map +0 -1
- package/dist/chunk-LVN3UGUH.cjs +0 -404
- package/dist/chunk-LVN3UGUH.cjs.map +0 -1
- package/dist/chunk-M7HJ2CKM.cjs +0 -135
- package/dist/chunk-M7HJ2CKM.cjs.map +0 -1
- package/dist/chunk-MWP7SJWC.js +0 -103
- package/dist/chunk-MWP7SJWC.js.map +0 -1
- package/dist/chunk-NBDFYP3Y.js +0 -24
- package/dist/chunk-NBDFYP3Y.js.map +0 -1
- package/dist/chunk-SOEAQVIE.js +0 -34
- package/dist/chunk-SOEAQVIE.js.map +0 -1
- package/dist/chunk-TQGOPELV.cjs +0 -67
- package/dist/chunk-TQGOPELV.cjs.map +0 -1
- package/dist/chunk-WHVPVEYH.cjs +0 -34
- package/dist/chunk-WHVPVEYH.cjs.map +0 -1
- package/dist/chunk-X4GS3I5P.js +0 -110
- package/dist/chunk-X4GS3I5P.js.map +0 -1
- package/dist/chunk-XYWE6TCQ.js +0 -37
- package/dist/chunk-XYWE6TCQ.js.map +0 -1
- package/dist/chunk-YLZI7BR5.cjs +0 -120
- package/dist/chunk-YLZI7BR5.cjs.map +0 -1
- package/dist/chunk-YNPYJVNU.js +0 -44
- package/dist/chunk-YNPYJVNU.js.map +0 -1
- package/dist/chunk-Z5Z6AKH7.cjs +0 -37
- package/dist/chunk-Z5Z6AKH7.cjs.map +0 -1
- package/dist/chunk-ZALRIFOG.js +0 -23
- package/dist/chunk-ZALRIFOG.js.map +0 -1
- package/dist/hooks.cjs +0 -29
- package/dist/hooks.cjs.map +0 -1
- package/dist/hooks.d.ts +0 -6
- package/dist/hooks.js +0 -29
- package/dist/hooks.js.map +0 -1
- package/dist/index.cjs +0 -7
- package/dist/index.cjs.map +0 -1
- package/dist/index.css +0 -112
- package/dist/index.css.map +0 -1
- package/dist/types.cjs +0 -1
- package/dist/types.cjs.map +0 -1
- package/dist/types.d.ts +0 -100
- package/dist/types.js +0 -1
- package/dist/types.js.map +0 -1
- package/dist/utils.cjs +0 -33
- package/dist/utils.cjs.map +0 -1
- package/dist/validation.cjs +0 -9
- package/dist/validation.cjs.map +0 -1
- package/dist/validation.d.ts +0 -241
- package/dist/validation.js +0 -9
- package/dist/validation.js.map +0 -1
package/dist/ParamsHistory.cjs
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 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 _chunkK6UPSPM5cjs = require('./chunk-K6UPSPM5.cjs');
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var _chunkLVN3UGUHcjs = require('./chunk-LVN3UGUH.cjs');
|
|
7
|
-
|
|
8
|
-
// src/ParamsHistory.tsx
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
var _react = require('react');
|
|
16
|
-
|
|
17
|
-
var _lodashdebounce = require('lodash.debounce'); var _lodashdebounce2 = _interopRequireDefault(_lodashdebounce);
|
|
18
|
-
var _jsxruntime = require('react/jsx-runtime');
|
|
19
|
-
var isEqual = (a, b) => _chunkLVN3UGUHcjs.stringifyParamsData.call(void 0, a) === _chunkLVN3UGUHcjs.stringifyParamsData.call(void 0, b);
|
|
20
|
-
var defaultParamsHistoryContext = {
|
|
21
|
-
history: [],
|
|
22
|
-
pushHistory: () => {
|
|
23
|
-
},
|
|
24
|
-
offset: 0,
|
|
25
|
-
setOffset: () => {
|
|
26
|
-
},
|
|
27
|
-
undo: () => {
|
|
28
|
-
},
|
|
29
|
-
redo: () => {
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
var ParamsHistoryContext = _react.createContext.call(void 0, defaultParamsHistoryContext);
|
|
33
|
-
function ParamsHistoryProvider({ children }) {
|
|
34
|
-
const lastActionData = _react.useRef.call(void 0, null);
|
|
35
|
-
const runtime = _react.useContext.call(void 0, _chunkK6UPSPM5cjs.RuntimeContext);
|
|
36
|
-
const [history, setHistory] = _react.useState.call(void 0, []);
|
|
37
|
-
const [offset, setOffset] = _react.useState.call(void 0, 0);
|
|
38
|
-
const historyActions = {
|
|
39
|
-
"params-update": (entry) => {
|
|
40
|
-
runtime.state.update({ params: entry.data });
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
const pushHistory = _react.useCallback.call(void 0,
|
|
44
|
-
_lodashdebounce2.default.call(void 0, (entry) => {
|
|
45
|
-
setHistory((prev) => [entry, ...prev]);
|
|
46
|
-
setOffset(0);
|
|
47
|
-
lastActionData.current = entry.data;
|
|
48
|
-
}, 200),
|
|
49
|
-
[]
|
|
50
|
-
);
|
|
51
|
-
const undo = () => {
|
|
52
|
-
if (offset >= history.length)
|
|
53
|
-
return;
|
|
54
|
-
setOffset(offset + 1);
|
|
55
|
-
};
|
|
56
|
-
const redo = () => {
|
|
57
|
-
if (offset <= 0)
|
|
58
|
-
return;
|
|
59
|
-
setOffset(offset - 1);
|
|
60
|
-
};
|
|
61
|
-
_react.useEffect.call(void 0, () => {
|
|
62
|
-
const currentEntry = _optionalChain([history, 'optionalAccess', _ => _[offset]]);
|
|
63
|
-
_optionalChain([historyActions, 'access', _2 => _2[_optionalChain([currentEntry, 'optionalAccess', _3 => _3.type])], 'optionalCall', _4 => _4(
|
|
64
|
-
currentEntry
|
|
65
|
-
)]);
|
|
66
|
-
lastActionData.current = _optionalChain([currentEntry, 'optionalAccess', _5 => _5.data]);
|
|
67
|
-
}, [offset]);
|
|
68
|
-
_react.useEffect.call(void 0, () => {
|
|
69
|
-
if (isEqual(runtime.state.params, _optionalChain([lastActionData, 'optionalAccess', _6 => _6.current])))
|
|
70
|
-
return;
|
|
71
|
-
if (!runtime.state.params)
|
|
72
|
-
return;
|
|
73
|
-
pushHistory({ type: "params-update", data: runtime.state.params });
|
|
74
|
-
}, [runtime.state.params, lastActionData.current]);
|
|
75
|
-
const context = {
|
|
76
|
-
history,
|
|
77
|
-
pushHistory,
|
|
78
|
-
offset,
|
|
79
|
-
setOffset,
|
|
80
|
-
undo,
|
|
81
|
-
redo
|
|
82
|
-
};
|
|
83
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ParamsHistoryContext.Provider, { value: context, children });
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
exports.ParamsHistoryContext = ParamsHistoryContext; exports.ParamsHistoryProvider = ParamsHistoryProvider;
|
|
89
|
-
//# sourceMappingURL=ParamsHistory.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/ParamsHistory.tsx"],"names":[],"mappings":";;;;;;;;AAAA;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,qBAAqB;AAC9B,OAAO,cAAc;AA+FjB;AA3FJ,IAAM,UAAU,CAAC,GAAQ,MACvB,oBAAoB,CAAC,MAAM,oBAAoB,CAAC;AAoBlD,IAAM,8BAAqD;AAAA,EACzD,SAAS,CAAC;AAAA,EACV,aAAa,MAAM;AAAA,EAAC;AAAA,EACpB,QAAQ;AAAA,EACR,WAAW,MAAM;AAAA,EAAC;AAAA,EAClB,MAAM,MAAM;AAAA,EAAC;AAAA,EACb,MAAM,MAAM;AAAA,EAAC;AACf;AAEO,IAAM,uBAAuB,cAAc,2BAA2B;AAItE,SAAS,sBAAsB,EAAE,SAAS,GAAU;AACzD,QAAM,iBAAiB,OAAO,IAAI;AAClC,QAAM,UAAU,WAAW,cAAc;AACzC,QAAM,CAAC,SAAS,UAAU,IAAI,SAAgC,CAAC,CAAC;AAChE,QAAM,CAAC,QAAQ,SAAS,IAAI,SAAiB,CAAC;AAE9C,QAAM,iBAAuE;AAAA,IAC3E,iBAAiB,CAAC,UAA+B;AAC/C,cAAQ,MAAM,OAAO,EAAE,QAAQ,MAAM,KAAK,CAAC;AAAA,IAC7C;AAAA,EACF;AAEA,QAAM,cAAc;AAAA,IAClB,SAAS,CAAC,UAA+B;AACvC,iBAAW,UAAQ,CAAC,OAAO,GAAG,IAAI,CAAC;AACnC,gBAAU,CAAC;AACX,qBAAe,UAAU,MAAM;AAAA,IACjC,GAAG,GAAG;AAAA,IACN,CAAC;AAAA,EACH;AAEA,QAAM,OAAO,MAAM;AACjB,QAAI,UAAU,QAAQ;AAAQ;AAC9B,cAAU,SAAS,CAAC;AAAA,EACtB;AAEA,QAAM,OAAO,MAAM;AACjB,QAAI,UAAU;AAAG;AACjB,cAAU,SAAS,CAAC;AAAA,EACtB;AAGA,YAAU,MAAM;AACd,UAAM,eAAe,UAAU,MAAM;AACrC,mBAAe,cAAc,IAA+B;AAAA,MAC1D;AAAA,IACF;AACA,mBAAe,UAAU,cAAc;AAAA,EACzC,GAAG,CAAC,MAAM,CAAC;AAGX,YAAU,MAAM;AACd,QAAI,QAAQ,QAAQ,MAAM,QAAQ,gBAAgB,OAAO;AAAG;AAC5D,QAAI,CAAC,QAAQ,MAAM;AAAQ;AAC3B,gBAAY,EAAE,MAAM,iBAAiB,MAAM,QAAQ,MAAM,OAAO,CAAC;AAAA,EACnE,GAAG,CAAC,QAAQ,MAAM,QAAQ,eAAe,OAAO,CAAC;AAEjD,QAAM,UAAiC;AAAA,IACrC;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAEA,SACE,oBAAC,qBAAqB,UAArB,EAA8B,OAAO,SACnC,UACH;AAEJ","sourcesContent":["import {\n PropsWithChildren,\n useContext,\n useEffect,\n useState,\n useCallback,\n useRef,\n} from \"react\"\nimport { createContext } from \"react\"\nimport debounce from \"lodash.debounce\"\nimport { stringifyParamsData } from \"./utils\"\nimport { RuntimeContext } from \"./RuntimeContext\"\n\nconst isEqual = (a: any, b: any) =>\n stringifyParamsData(a) === stringifyParamsData(b)\n\ntype ParamsHistoryActionType = \"params-update\"\n\ninterface IParamsHistoryEntry {\n type: ParamsHistoryActionType\n data: any\n}\n\ntype ParamsHistoryAction = (entry: IParamsHistoryEntry) => void\n\nexport interface IParamsHistoryContext {\n history: IParamsHistoryEntry[]\n pushHistory: (entry: IParamsHistoryEntry) => void\n offset: number\n setOffset: (o: number) => void\n undo: () => void\n redo: () => void\n}\n\nconst defaultParamsHistoryContext: IParamsHistoryContext = {\n history: [],\n pushHistory: () => {},\n offset: 0,\n setOffset: () => {},\n undo: () => {},\n redo: () => {},\n}\n\nexport const ParamsHistoryContext = createContext(defaultParamsHistoryContext)\n\ntype Props = PropsWithChildren<any>\n\nexport function ParamsHistoryProvider({ children }: Props) {\n const lastActionData = useRef(null)\n const runtime = useContext(RuntimeContext)\n const [history, setHistory] = useState<IParamsHistoryEntry[]>([])\n const [offset, setOffset] = useState<number>(0)\n\n const historyActions: Record<ParamsHistoryActionType, ParamsHistoryAction> = {\n \"params-update\": (entry: IParamsHistoryEntry) => {\n runtime.state.update({ params: entry.data })\n },\n }\n\n const pushHistory = useCallback(\n debounce((entry: IParamsHistoryEntry) => {\n setHistory(prev => [entry, ...prev])\n setOffset(0)\n lastActionData.current = entry.data\n }, 200),\n []\n )\n\n const undo = () => {\n if (offset >= history.length) return\n setOffset(offset + 1)\n }\n\n const redo = () => {\n if (offset <= 0) return\n setOffset(offset - 1)\n }\n\n // when offset change apply action based on history entry\n useEffect(() => {\n const currentEntry = history?.[offset]\n historyActions[currentEntry?.type as ParamsHistoryActionType]?.(\n currentEntry\n )\n lastActionData.current = currentEntry?.data\n }, [offset])\n\n // observe data changes and add them to history\n useEffect(() => {\n if (isEqual(runtime.state.params, lastActionData?.current)) return\n if (!runtime.state.params) return\n pushHistory({ type: \"params-update\", data: runtime.state.params })\n }, [runtime.state.params, lastActionData.current])\n\n const context: IParamsHistoryContext = {\n history,\n pushHistory,\n offset,\n setOffset,\n undo,\n redo,\n }\n\n return (\n <ParamsHistoryContext.Provider value={context}>\n {children}\n </ParamsHistoryContext.Provider>\n )\n}\n"]}
|
package/dist/ParamsHistory.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import * as react from 'react';
|
|
3
|
-
import { PropsWithChildren } from 'react';
|
|
4
|
-
|
|
5
|
-
type ParamsHistoryActionType = "params-update";
|
|
6
|
-
interface IParamsHistoryEntry {
|
|
7
|
-
type: ParamsHistoryActionType;
|
|
8
|
-
data: any;
|
|
9
|
-
}
|
|
10
|
-
interface IParamsHistoryContext {
|
|
11
|
-
history: IParamsHistoryEntry[];
|
|
12
|
-
pushHistory: (entry: IParamsHistoryEntry) => void;
|
|
13
|
-
offset: number;
|
|
14
|
-
setOffset: (o: number) => void;
|
|
15
|
-
undo: () => void;
|
|
16
|
-
redo: () => void;
|
|
17
|
-
}
|
|
18
|
-
declare const ParamsHistoryContext: react.Context<IParamsHistoryContext>;
|
|
19
|
-
type Props = PropsWithChildren<any>;
|
|
20
|
-
declare function ParamsHistoryProvider({ children }: Props): react_jsx_runtime.JSX.Element;
|
|
21
|
-
|
|
22
|
-
export { IParamsHistoryContext, ParamsHistoryContext, ParamsHistoryProvider };
|
package/dist/ParamsHistory.js
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
RuntimeContext
|
|
3
|
-
} from "./chunk-JSFJKANM.js";
|
|
4
|
-
import {
|
|
5
|
-
stringifyParamsData
|
|
6
|
-
} from "./chunk-7H32FZ35.js";
|
|
7
|
-
|
|
8
|
-
// src/ParamsHistory.tsx
|
|
9
|
-
import {
|
|
10
|
-
useContext,
|
|
11
|
-
useEffect,
|
|
12
|
-
useState,
|
|
13
|
-
useCallback,
|
|
14
|
-
useRef
|
|
15
|
-
} from "react";
|
|
16
|
-
import { createContext } from "react";
|
|
17
|
-
import debounce from "lodash.debounce";
|
|
18
|
-
import { jsx } from "react/jsx-runtime";
|
|
19
|
-
var isEqual = (a, b) => stringifyParamsData(a) === stringifyParamsData(b);
|
|
20
|
-
var defaultParamsHistoryContext = {
|
|
21
|
-
history: [],
|
|
22
|
-
pushHistory: () => {
|
|
23
|
-
},
|
|
24
|
-
offset: 0,
|
|
25
|
-
setOffset: () => {
|
|
26
|
-
},
|
|
27
|
-
undo: () => {
|
|
28
|
-
},
|
|
29
|
-
redo: () => {
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
var ParamsHistoryContext = createContext(defaultParamsHistoryContext);
|
|
33
|
-
function ParamsHistoryProvider({ children }) {
|
|
34
|
-
const lastActionData = useRef(null);
|
|
35
|
-
const runtime = useContext(RuntimeContext);
|
|
36
|
-
const [history, setHistory] = useState([]);
|
|
37
|
-
const [offset, setOffset] = useState(0);
|
|
38
|
-
const historyActions = {
|
|
39
|
-
"params-update": (entry) => {
|
|
40
|
-
runtime.state.update({ params: entry.data });
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
const pushHistory = useCallback(
|
|
44
|
-
debounce((entry) => {
|
|
45
|
-
setHistory((prev) => [entry, ...prev]);
|
|
46
|
-
setOffset(0);
|
|
47
|
-
lastActionData.current = entry.data;
|
|
48
|
-
}, 200),
|
|
49
|
-
[]
|
|
50
|
-
);
|
|
51
|
-
const undo = () => {
|
|
52
|
-
if (offset >= history.length)
|
|
53
|
-
return;
|
|
54
|
-
setOffset(offset + 1);
|
|
55
|
-
};
|
|
56
|
-
const redo = () => {
|
|
57
|
-
if (offset <= 0)
|
|
58
|
-
return;
|
|
59
|
-
setOffset(offset - 1);
|
|
60
|
-
};
|
|
61
|
-
useEffect(() => {
|
|
62
|
-
const currentEntry = history?.[offset];
|
|
63
|
-
historyActions[currentEntry?.type]?.(
|
|
64
|
-
currentEntry
|
|
65
|
-
);
|
|
66
|
-
lastActionData.current = currentEntry?.data;
|
|
67
|
-
}, [offset]);
|
|
68
|
-
useEffect(() => {
|
|
69
|
-
if (isEqual(runtime.state.params, lastActionData?.current))
|
|
70
|
-
return;
|
|
71
|
-
if (!runtime.state.params)
|
|
72
|
-
return;
|
|
73
|
-
pushHistory({ type: "params-update", data: runtime.state.params });
|
|
74
|
-
}, [runtime.state.params, lastActionData.current]);
|
|
75
|
-
const context = {
|
|
76
|
-
history,
|
|
77
|
-
pushHistory,
|
|
78
|
-
offset,
|
|
79
|
-
setOffset,
|
|
80
|
-
undo,
|
|
81
|
-
redo
|
|
82
|
-
};
|
|
83
|
-
return /* @__PURE__ */ jsx(ParamsHistoryContext.Provider, { value: context, children });
|
|
84
|
-
}
|
|
85
|
-
export {
|
|
86
|
-
ParamsHistoryContext,
|
|
87
|
-
ParamsHistoryProvider
|
|
88
|
-
};
|
|
89
|
-
//# sourceMappingURL=ParamsHistory.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/ParamsHistory.tsx"],"sourcesContent":["import {\n PropsWithChildren,\n useContext,\n useEffect,\n useState,\n useCallback,\n useRef,\n} from \"react\"\nimport { createContext } from \"react\"\nimport debounce from \"lodash.debounce\"\nimport { stringifyParamsData } from \"./utils\"\nimport { RuntimeContext } from \"./RuntimeContext\"\n\nconst isEqual = (a: any, b: any) =>\n stringifyParamsData(a) === stringifyParamsData(b)\n\ntype ParamsHistoryActionType = \"params-update\"\n\ninterface IParamsHistoryEntry {\n type: ParamsHistoryActionType\n data: any\n}\n\ntype ParamsHistoryAction = (entry: IParamsHistoryEntry) => void\n\nexport interface IParamsHistoryContext {\n history: IParamsHistoryEntry[]\n pushHistory: (entry: IParamsHistoryEntry) => void\n offset: number\n setOffset: (o: number) => void\n undo: () => void\n redo: () => void\n}\n\nconst defaultParamsHistoryContext: IParamsHistoryContext = {\n history: [],\n pushHistory: () => {},\n offset: 0,\n setOffset: () => {},\n undo: () => {},\n redo: () => {},\n}\n\nexport const ParamsHistoryContext = createContext(defaultParamsHistoryContext)\n\ntype Props = PropsWithChildren<any>\n\nexport function ParamsHistoryProvider({ children }: Props) {\n const lastActionData = useRef(null)\n const runtime = useContext(RuntimeContext)\n const [history, setHistory] = useState<IParamsHistoryEntry[]>([])\n const [offset, setOffset] = useState<number>(0)\n\n const historyActions: Record<ParamsHistoryActionType, ParamsHistoryAction> = {\n \"params-update\": (entry: IParamsHistoryEntry) => {\n runtime.state.update({ params: entry.data })\n },\n }\n\n const pushHistory = useCallback(\n debounce((entry: IParamsHistoryEntry) => {\n setHistory(prev => [entry, ...prev])\n setOffset(0)\n lastActionData.current = entry.data\n }, 200),\n []\n )\n\n const undo = () => {\n if (offset >= history.length) return\n setOffset(offset + 1)\n }\n\n const redo = () => {\n if (offset <= 0) return\n setOffset(offset - 1)\n }\n\n // when offset change apply action based on history entry\n useEffect(() => {\n const currentEntry = history?.[offset]\n historyActions[currentEntry?.type as ParamsHistoryActionType]?.(\n currentEntry\n )\n lastActionData.current = currentEntry?.data\n }, [offset])\n\n // observe data changes and add them to history\n useEffect(() => {\n if (isEqual(runtime.state.params, lastActionData?.current)) return\n if (!runtime.state.params) return\n pushHistory({ type: \"params-update\", data: runtime.state.params })\n }, [runtime.state.params, lastActionData.current])\n\n const context: IParamsHistoryContext = {\n history,\n pushHistory,\n offset,\n setOffset,\n undo,\n redo,\n }\n\n return (\n <ParamsHistoryContext.Provider value={context}>\n {children}\n </ParamsHistoryContext.Provider>\n )\n}\n"],"mappings":";;;;;;;;AAAA;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,qBAAqB;AAC9B,OAAO,cAAc;AA+FjB;AA3FJ,IAAM,UAAU,CAAC,GAAQ,MACvB,oBAAoB,CAAC,MAAM,oBAAoB,CAAC;AAoBlD,IAAM,8BAAqD;AAAA,EACzD,SAAS,CAAC;AAAA,EACV,aAAa,MAAM;AAAA,EAAC;AAAA,EACpB,QAAQ;AAAA,EACR,WAAW,MAAM;AAAA,EAAC;AAAA,EAClB,MAAM,MAAM;AAAA,EAAC;AAAA,EACb,MAAM,MAAM;AAAA,EAAC;AACf;AAEO,IAAM,uBAAuB,cAAc,2BAA2B;AAItE,SAAS,sBAAsB,EAAE,SAAS,GAAU;AACzD,QAAM,iBAAiB,OAAO,IAAI;AAClC,QAAM,UAAU,WAAW,cAAc;AACzC,QAAM,CAAC,SAAS,UAAU,IAAI,SAAgC,CAAC,CAAC;AAChE,QAAM,CAAC,QAAQ,SAAS,IAAI,SAAiB,CAAC;AAE9C,QAAM,iBAAuE;AAAA,IAC3E,iBAAiB,CAAC,UAA+B;AAC/C,cAAQ,MAAM,OAAO,EAAE,QAAQ,MAAM,KAAK,CAAC;AAAA,IAC7C;AAAA,EACF;AAEA,QAAM,cAAc;AAAA,IAClB,SAAS,CAAC,UAA+B;AACvC,iBAAW,UAAQ,CAAC,OAAO,GAAG,IAAI,CAAC;AACnC,gBAAU,CAAC;AACX,qBAAe,UAAU,MAAM;AAAA,IACjC,GAAG,GAAG;AAAA,IACN,CAAC;AAAA,EACH;AAEA,QAAM,OAAO,MAAM;AACjB,QAAI,UAAU,QAAQ;AAAQ;AAC9B,cAAU,SAAS,CAAC;AAAA,EACtB;AAEA,QAAM,OAAO,MAAM;AACjB,QAAI,UAAU;AAAG;AACjB,cAAU,SAAS,CAAC;AAAA,EACtB;AAGA,YAAU,MAAM;AACd,UAAM,eAAe,UAAU,MAAM;AACrC,mBAAe,cAAc,IAA+B;AAAA,MAC1D;AAAA,IACF;AACA,mBAAe,UAAU,cAAc;AAAA,EACzC,GAAG,CAAC,MAAM,CAAC;AAGX,YAAU,MAAM;AACd,QAAI,QAAQ,QAAQ,MAAM,QAAQ,gBAAgB,OAAO;AAAG;AAC5D,QAAI,CAAC,QAAQ,MAAM;AAAQ;AAC3B,gBAAY,EAAE,MAAM,iBAAiB,MAAM,QAAQ,MAAM,OAAO,CAAC;AAAA,EACnE,GAAG,CAAC,QAAQ,MAAM,QAAQ,eAAe,OAAO,CAAC;AAEjD,QAAM,UAAiC;AAAA,IACrC;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAEA,SACE,oBAAC,qBAAqB,UAArB,EAA8B,OAAO,SACnC,UACH;AAEJ;","names":[]}
|
package/dist/RuntimeContext.cjs
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var _chunkK6UPSPM5cjs = require('./chunk-K6UPSPM5.cjs');
|
|
5
|
-
require('./chunk-LVN3UGUH.cjs');
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
exports.RuntimeContext = _chunkK6UPSPM5cjs.RuntimeContext; exports.RuntimeProvider = _chunkK6UPSPM5cjs.RuntimeProvider;
|
|
10
|
-
//# sourceMappingURL=RuntimeContext.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":""}
|
package/dist/RuntimeContext.d.ts
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import * as react from 'react';
|
|
3
|
-
import { PropsWithChildren } from 'react';
|
|
4
|
-
import { FxParamsData, FxParamDefinition, FxParamType } from './types.js';
|
|
5
|
-
|
|
6
|
-
type TUpdateStateFn<T> = (data: Partial<T>) => void;
|
|
7
|
-
type TUpdateableState<T> = T & {
|
|
8
|
-
update: TUpdateStateFn<T>;
|
|
9
|
-
};
|
|
10
|
-
/**
|
|
11
|
-
* The Runtime Context is responsible for managing the state of a project ran
|
|
12
|
-
* in a frame. It centralizes any source of data to derive the project and
|
|
13
|
-
* facilitate their manipulation from the outside.
|
|
14
|
-
*
|
|
15
|
-
* See comments on IRuntimeContext for more details.
|
|
16
|
-
*/
|
|
17
|
-
type TExecutionContext = "minting" | "standalone" | "capture";
|
|
18
|
-
interface RuntimeState {
|
|
19
|
-
hash: string;
|
|
20
|
-
minter: string;
|
|
21
|
-
params: FxParamsData;
|
|
22
|
-
iteration: number;
|
|
23
|
-
context: TExecutionContext;
|
|
24
|
-
}
|
|
25
|
-
interface RuntimeDefinition {
|
|
26
|
-
params: FxParamDefinition<FxParamType>[] | null;
|
|
27
|
-
version: string | null;
|
|
28
|
-
}
|
|
29
|
-
interface IRuntimeContext {
|
|
30
|
-
state: TUpdateableState<RuntimeState>;
|
|
31
|
-
definition: TUpdateableState<RuntimeDefinition>;
|
|
32
|
-
details: {
|
|
33
|
-
paramsByteSize: number;
|
|
34
|
-
stateHash: {
|
|
35
|
-
soft: string;
|
|
36
|
-
hard: string;
|
|
37
|
-
};
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
declare const RuntimeContext: react.Context<IRuntimeContext>;
|
|
41
|
-
type Props = PropsWithChildren<any>;
|
|
42
|
-
declare function RuntimeProvider({ children }: Props): react_jsx_runtime.JSX.Element;
|
|
43
|
-
|
|
44
|
-
export { IRuntimeContext, RuntimeContext, RuntimeDefinition, RuntimeProvider, RuntimeState, TExecutionContext, TUpdateStateFn, TUpdateableState };
|
package/dist/RuntimeContext.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/chunk-2SARESCF.js
DELETED
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
BaseInput
|
|
3
|
-
} from "./chunk-BEDRMOBJ.js";
|
|
4
|
-
|
|
5
|
-
// src/Controller/Controller.module.scss
|
|
6
|
-
var Controller_module_default = {
|
|
7
|
-
"controller": "_controller_t5850_1",
|
|
8
|
-
"inputContainer": "_inputContainer_t5850_12",
|
|
9
|
-
"default": "_default_t5850_18",
|
|
10
|
-
"invert": "_invert_t5850_34",
|
|
11
|
-
"box": "_box_t5850_50",
|
|
12
|
-
"numberInput": "_numberInput_t5850_67"
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
// src/Controller/Controller.tsx
|
|
16
|
-
import cx from "classnames";
|
|
17
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
18
|
-
function BaseParamsInput(props) {
|
|
19
|
-
const { id } = props;
|
|
20
|
-
return /* @__PURE__ */ jsx(BaseInput, { name: `${id}-params-search`, autoComplete: "off", ...props });
|
|
21
|
-
}
|
|
22
|
-
function Controller(props) {
|
|
23
|
-
const {
|
|
24
|
-
id,
|
|
25
|
-
label,
|
|
26
|
-
layout = "default",
|
|
27
|
-
className,
|
|
28
|
-
inputContainerProps,
|
|
29
|
-
isCodeDriven
|
|
30
|
-
} = props;
|
|
31
|
-
return /* @__PURE__ */ jsxs(
|
|
32
|
-
"div",
|
|
33
|
-
{
|
|
34
|
-
className: cx(Controller_module_default.controller, Controller_module_default[layout], className),
|
|
35
|
-
title: isCodeDriven ? "This parameter is solely code-driven. Controller is just shown for debugging purposes." : "",
|
|
36
|
-
children: [
|
|
37
|
-
id && /* @__PURE__ */ jsx("label", { htmlFor: id, children: label || id }),
|
|
38
|
-
/* @__PURE__ */ jsx("div", { className: Controller_module_default.inputContainer, ...inputContainerProps, children: props.children })
|
|
39
|
-
]
|
|
40
|
-
}
|
|
41
|
-
);
|
|
42
|
-
}
|
|
43
|
-
function HTMLInputController(props) {
|
|
44
|
-
const {
|
|
45
|
-
label,
|
|
46
|
-
id,
|
|
47
|
-
onChange,
|
|
48
|
-
value,
|
|
49
|
-
type,
|
|
50
|
-
className,
|
|
51
|
-
inputProps,
|
|
52
|
-
layout = "default",
|
|
53
|
-
isCodeDriven
|
|
54
|
-
} = props;
|
|
55
|
-
return /* @__PURE__ */ jsx(
|
|
56
|
-
Controller,
|
|
57
|
-
{
|
|
58
|
-
id,
|
|
59
|
-
label,
|
|
60
|
-
layout,
|
|
61
|
-
isCodeDriven,
|
|
62
|
-
children: /* @__PURE__ */ jsx(
|
|
63
|
-
BaseParamsInput,
|
|
64
|
-
{
|
|
65
|
-
className,
|
|
66
|
-
type,
|
|
67
|
-
id,
|
|
68
|
-
onChange,
|
|
69
|
-
value,
|
|
70
|
-
disabled: isCodeDriven,
|
|
71
|
-
...inputProps
|
|
72
|
-
}
|
|
73
|
-
)
|
|
74
|
-
}
|
|
75
|
-
);
|
|
76
|
-
}
|
|
77
|
-
function HTMLInputControllerWithTextInput(props) {
|
|
78
|
-
const {
|
|
79
|
-
label,
|
|
80
|
-
id,
|
|
81
|
-
onChange,
|
|
82
|
-
value,
|
|
83
|
-
type,
|
|
84
|
-
className,
|
|
85
|
-
inputProps = {},
|
|
86
|
-
layout = "default",
|
|
87
|
-
textInputProps,
|
|
88
|
-
isCodeDriven
|
|
89
|
-
} = props;
|
|
90
|
-
return /* @__PURE__ */ jsxs(
|
|
91
|
-
Controller,
|
|
92
|
-
{
|
|
93
|
-
id,
|
|
94
|
-
label,
|
|
95
|
-
layout,
|
|
96
|
-
isCodeDriven,
|
|
97
|
-
children: [
|
|
98
|
-
/* @__PURE__ */ jsx(
|
|
99
|
-
BaseParamsInput,
|
|
100
|
-
{
|
|
101
|
-
className,
|
|
102
|
-
type,
|
|
103
|
-
id,
|
|
104
|
-
onChange,
|
|
105
|
-
value,
|
|
106
|
-
autoComplete: "off",
|
|
107
|
-
disabled: isCodeDriven,
|
|
108
|
-
...inputProps
|
|
109
|
-
}
|
|
110
|
-
),
|
|
111
|
-
/* @__PURE__ */ jsx(
|
|
112
|
-
BaseParamsInput,
|
|
113
|
-
{
|
|
114
|
-
type: "text",
|
|
115
|
-
id: `text-${id}`,
|
|
116
|
-
onChange,
|
|
117
|
-
value,
|
|
118
|
-
autoComplete: "off",
|
|
119
|
-
disabled: isCodeDriven,
|
|
120
|
-
...textInputProps
|
|
121
|
-
}
|
|
122
|
-
)
|
|
123
|
-
]
|
|
124
|
-
}
|
|
125
|
-
);
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
export {
|
|
129
|
-
Controller_module_default,
|
|
130
|
-
BaseParamsInput,
|
|
131
|
-
Controller,
|
|
132
|
-
HTMLInputController,
|
|
133
|
-
HTMLInputControllerWithTextInput
|
|
134
|
-
};
|
|
135
|
-
//# sourceMappingURL=chunk-2SARESCF.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/Controller/Controller.module.scss","../src/Controller/Controller.tsx"],"sourcesContent":["import 'css-chunk:src/Controller/Controller.module.scss';export default {\n \"controller\": \"_controller_t5850_1\",\n \"inputContainer\": \"_inputContainer_t5850_12\",\n \"default\": \"_default_t5850_18\",\n \"invert\": \"_invert_t5850_34\",\n \"box\": \"_box_t5850_50\",\n \"numberInput\": \"_numberInput_t5850_67\"\n};","import {\n HTMLInputTypeAttribute,\n InputHTMLAttributes,\n ReactNode,\n RefObject,\n} from \"react\"\nimport { FxParamOptionsMap, FxParamType } from \"../types\"\nimport classes from \"./Controller.module.scss\"\nimport cx from \"classnames\"\nimport { BaseInput } from \"../BaseInput\"\n\n/*\n * Providing a name starting or ending with `search` prevents\n * 1Password extension to appear in the input fields\n * https://1password.community/discussion/comment/606453/#Comment_606453\n */\nexport function BaseParamsInput(props: InputHTMLAttributes<HTMLInputElement>) {\n const { id } = props\n return (\n <BaseInput name={`${id}-params-search`} autoComplete=\"off\" {...props} />\n )\n}\n\nexport type FxParamInputChangeHandler = (e: any) => void\n\nexport interface ControllerProps {\n label?: string\n id?: string\n children: ReactNode\n layout?: \"default\" | \"invert\" | \"box\"\n className?: string\n inputContainerProps?: {\n ref: RefObject<HTMLDivElement>\n }\n isCodeDriven?: boolean\n}\n\nexport function Controller(props: ControllerProps) {\n const {\n id,\n label,\n layout = \"default\",\n className,\n inputContainerProps,\n isCodeDriven,\n } = props\n return (\n <div\n className={cx(classes.controller, classes[layout], className)}\n title={\n isCodeDriven\n ? \"This parameter is solely code-driven. Controller is just shown for debugging purposes.\"\n : \"\"\n }\n >\n {id && <label htmlFor={id}>{label || id}</label>}\n <div className={classes.inputContainer} {...inputContainerProps}>\n {props.children}\n </div>\n </div>\n )\n}\n\nexport interface HTMLInputControllerProps {\n id: string\n value: string\n onChange: FxParamInputChangeHandler\n type: HTMLInputTypeAttribute\n inputProps?: InputHTMLAttributes<HTMLInputElement | HTMLSelectElement>\n className?: string\n label?: string\n layout?: \"default\" | \"invert\" | \"box\"\n isCodeDriven?: boolean\n}\n\nexport type FxParamControllerProps<Type extends FxParamType> = Omit<\n HTMLInputControllerProps,\n \"type\"\n> & {\n value: any\n options?: FxParamOptionsMap[Type]\n onChange: FxParamInputChangeHandler\n}\n\nexport function HTMLInputController(props: HTMLInputControllerProps) {\n const {\n label,\n id,\n onChange,\n value,\n type,\n className,\n inputProps,\n layout = \"default\",\n isCodeDriven,\n } = props\n return (\n <Controller\n id={id}\n label={label}\n layout={layout}\n isCodeDriven={isCodeDriven}\n >\n <BaseParamsInput\n className={className}\n type={type}\n id={id}\n onChange={onChange}\n value={value}\n disabled={isCodeDriven}\n {...inputProps}\n />\n </Controller>\n )\n}\n\nexport interface HTMLInputControllerWithTextInputProps\n extends HTMLInputControllerProps {\n textInputProps?: InputHTMLAttributes<HTMLInputElement>\n}\n\nexport function HTMLInputControllerWithTextInput(\n props: HTMLInputControllerWithTextInputProps\n) {\n const {\n label,\n id,\n onChange,\n value,\n type,\n className,\n inputProps = {},\n layout = \"default\",\n textInputProps,\n isCodeDriven,\n } = props\n return (\n <Controller\n id={id}\n label={label}\n layout={layout}\n isCodeDriven={isCodeDriven}\n >\n <BaseParamsInput\n className={className}\n type={type}\n id={id}\n onChange={onChange}\n value={value}\n autoComplete=\"off\"\n disabled={isCodeDriven}\n {...inputProps}\n />\n <BaseParamsInput\n type=\"text\"\n id={`text-${id}`}\n onChange={onChange}\n value={value}\n autoComplete=\"off\"\n disabled={isCodeDriven}\n {...textInputProps}\n />\n </Controller>\n )\n}\n"],"mappings":";;;;;AAAyD,IAAO,4BAAQ;AAAA,EACtE,cAAc;AAAA,EACd,kBAAkB;AAAA,EAClB,WAAW;AAAA,EACX,UAAU;AAAA,EACV,OAAO;AAAA,EACP,eAAe;AACjB;;;ACCA,OAAO,QAAQ;AAWX,cA4BA,YA5BA;AAHG,SAAS,gBAAgB,OAA8C;AAC5E,QAAM,EAAE,GAAG,IAAI;AACf,SACE,oBAAC,aAAU,MAAM,GAAG,oBAAoB,cAAa,OAAO,GAAG,OAAO;AAE1E;AAgBO,SAAS,WAAW,OAAwB;AACjD,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA,SAAS;AAAA,IACT;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI;AACJ,SACE;AAAA,IAAC;AAAA;AAAA,MACC,WAAW,GAAG,0BAAQ,YAAY,0BAAQ,MAAM,GAAG,SAAS;AAAA,MAC5D,OACE,eACI,2FACA;AAAA,MAGL;AAAA,cAAM,oBAAC,WAAM,SAAS,IAAK,mBAAS,IAAG;AAAA,QACxC,oBAAC,SAAI,WAAW,0BAAQ,gBAAiB,GAAG,qBACzC,gBAAM,UACT;AAAA;AAAA;AAAA,EACF;AAEJ;AAuBO,SAAS,oBAAoB,OAAiC;AACnE,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,SAAS;AAAA,IACT;AAAA,EACF,IAAI;AACJ,SACE;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MAEA;AAAA,QAAC;AAAA;AAAA,UACC;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA,UAAU;AAAA,UACT,GAAG;AAAA;AAAA,MACN;AAAA;AAAA,EACF;AAEJ;AAOO,SAAS,iCACd,OACA;AACA,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,aAAa,CAAC;AAAA,IACd,SAAS;AAAA,IACT;AAAA,IACA;AAAA,EACF,IAAI;AACJ,SACE;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MAEA;AAAA;AAAA,UAAC;AAAA;AAAA,YACC;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA,cAAa;AAAA,YACb,UAAU;AAAA,YACT,GAAG;AAAA;AAAA,QACN;AAAA,QACA;AAAA,UAAC;AAAA;AAAA,YACC,MAAK;AAAA,YACL,IAAI,QAAQ;AAAA,YACZ;AAAA,YACA;AAAA,YACA,cAAa;AAAA,YACb,UAAU;AAAA,YACT,GAAG;AAAA;AAAA,QACN;AAAA;AAAA;AAAA,EACF;AAEJ;","names":[]}
|
package/dist/chunk-2XWOWIXK.cjs
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
-
|
|
3
|
-
var _chunkM7HJ2CKMcjs = require('./chunk-M7HJ2CKM.cjs');
|
|
4
|
-
|
|
5
|
-
// src/Controller/Boolean.tsx
|
|
6
|
-
var _jsxruntime = require('react/jsx-runtime');
|
|
7
|
-
function BooleanController(props) {
|
|
8
|
-
const { ...rest } = props;
|
|
9
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
10
|
-
_chunkM7HJ2CKMcjs.HTMLInputController,
|
|
11
|
-
{
|
|
12
|
-
type: "checkbox",
|
|
13
|
-
layout: "box",
|
|
14
|
-
inputProps: { checked: props.value },
|
|
15
|
-
...rest
|
|
16
|
-
}
|
|
17
|
-
);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
exports.BooleanController = BooleanController;
|
|
23
|
-
//# sourceMappingURL=chunk-2XWOWIXK.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/Controller/Boolean.tsx"],"names":[],"mappings":";;;;;AAMI;AAHG,SAAS,kBAAkB,OAA0C;AAC1E,QAAM,EAAE,GAAG,KAAK,IAAI;AACpB,SACE;AAAA,IAAC;AAAA;AAAA,MACC,MAAK;AAAA,MACL,QAAO;AAAA,MACP,YAAY,EAAE,SAAS,MAAM,MAAM;AAAA,MAClC,GAAG;AAAA;AAAA,EACN;AAEJ","sourcesContent":["import { FxParamControllerProps, HTMLInputController } from \"./Controller\"\nimport classes from \"./Controller.module.scss\"\n\nexport function BooleanController(props: FxParamControllerProps<\"boolean\">) {\n const { ...rest } = props\n return (\n <HTMLInputController\n type=\"checkbox\"\n layout=\"box\"\n inputProps={{ checked: props.value }}\n {...rest}\n />\n )\n}\n"]}
|
package/dist/chunk-3OF5LR4Y.cjs
DELETED
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
-
|
|
3
|
-
var _chunkLTIGECX6cjs = require('./chunk-LTIGECX6.cjs');
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var _chunkWHVPVEYHcjs = require('./chunk-WHVPVEYH.cjs');
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var _chunkK22KNCGRcjs = require('./chunk-K22KNCGR.cjs');
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var _chunkEACKNC6Ccjs = require('./chunk-EACKNC6C.cjs');
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
var _chunkAMJCUB2Icjs = require('./chunk-AMJCUB2I.cjs');
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
var _chunk2XWOWIXKcjs = require('./chunk-2XWOWIXK.cjs');
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
var _chunk3QFEC7SKcjs = require('./chunk-3QFEC7SK.cjs');
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
var _chunkYLZI7BR5cjs = require('./chunk-YLZI7BR5.cjs');
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
var _chunkTQGOPELVcjs = require('./chunk-TQGOPELV.cjs');
|
|
28
|
-
|
|
29
|
-
// src/Controller/Param.tsx
|
|
30
|
-
var _react = require('react');
|
|
31
|
-
var _jsxruntime = require('react/jsx-runtime');
|
|
32
|
-
var controllerDefinitions = {
|
|
33
|
-
number: {
|
|
34
|
-
type: "number",
|
|
35
|
-
controller: _chunkLTIGECX6cjs.NumberController,
|
|
36
|
-
handler: (e) => Number(e.target.value)
|
|
37
|
-
},
|
|
38
|
-
bigint: {
|
|
39
|
-
type: "bigint",
|
|
40
|
-
controller: _chunkAMJCUB2Icjs.BigIntController,
|
|
41
|
-
handler: (e) => BigInt(e.target.value)
|
|
42
|
-
},
|
|
43
|
-
string: {
|
|
44
|
-
type: "string",
|
|
45
|
-
controller: _chunkK22KNCGRcjs.StringController,
|
|
46
|
-
handler: (e) => e.target.value
|
|
47
|
-
},
|
|
48
|
-
bytes: {
|
|
49
|
-
type: "bytes",
|
|
50
|
-
controller: _chunk3QFEC7SKcjs.BytesController,
|
|
51
|
-
handler: (e) => e.target.value
|
|
52
|
-
},
|
|
53
|
-
boolean: {
|
|
54
|
-
type: "boolean",
|
|
55
|
-
controller: _chunk2XWOWIXKcjs.BooleanController,
|
|
56
|
-
handler: (e) => e.target.checked
|
|
57
|
-
},
|
|
58
|
-
color: {
|
|
59
|
-
type: "color",
|
|
60
|
-
controller: _chunkYLZI7BR5cjs.ColorController,
|
|
61
|
-
handler: (v) => v
|
|
62
|
-
},
|
|
63
|
-
select: {
|
|
64
|
-
type: "select",
|
|
65
|
-
controller: _chunkWHVPVEYHcjs.SelectController,
|
|
66
|
-
handler: (e) => e.target.value
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
function ParameterController(props) {
|
|
70
|
-
const { parameter, onChange, parsed } = props;
|
|
71
|
-
const parsedDefinition = _react.useMemo.call(void 0,
|
|
72
|
-
() => parsed || _chunkEACKNC6Ccjs.validateParameterDefinition.call(void 0, parameter),
|
|
73
|
-
[parameter, parsed]
|
|
74
|
-
);
|
|
75
|
-
const { controller: Controller, handler } = _react.useMemo.call(void 0,
|
|
76
|
-
() => controllerDefinitions[parameter.type],
|
|
77
|
-
[parameter.type]
|
|
78
|
-
);
|
|
79
|
-
const handleChangeParam = (e) => {
|
|
80
|
-
const value = handler(e);
|
|
81
|
-
onChange(parameter.id, value);
|
|
82
|
-
};
|
|
83
|
-
if (parsedDefinition && parsedDefinition.success === false) {
|
|
84
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
85
|
-
_chunkTQGOPELVcjs.ControllerInvalid,
|
|
86
|
-
{
|
|
87
|
-
definition: parameter,
|
|
88
|
-
error: parsedDefinition.error
|
|
89
|
-
}
|
|
90
|
-
);
|
|
91
|
-
}
|
|
92
|
-
const isCodeDriven = parameter.update === "code-driven";
|
|
93
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
94
|
-
Controller,
|
|
95
|
-
{
|
|
96
|
-
id: parameter.id,
|
|
97
|
-
label: parameter.name,
|
|
98
|
-
value: props.value,
|
|
99
|
-
onChange: handleChangeParam,
|
|
100
|
-
options: parameter.options,
|
|
101
|
-
isCodeDriven
|
|
102
|
-
}
|
|
103
|
-
);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
exports.controllerDefinitions = controllerDefinitions; exports.ParameterController = ParameterController;
|
|
110
|
-
//# sourceMappingURL=chunk-3OF5LR4Y.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/Controller/Param.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,eAA6B;AA6FhC;AAlEC,IAAM,wBAAsD;AAAA,EACjE,QAAQ;AAAA,IACN,MAAM;AAAA,IACN,YAAY;AAAA,IACZ,SAAS,OAAK,OAAO,EAAE,OAAO,KAAK;AAAA,EACrC;AAAA,EACA,QAAQ;AAAA,IACN,MAAM;AAAA,IACN,YAAY;AAAA,IACZ,SAAS,OAAK,OAAO,EAAE,OAAO,KAAK;AAAA,EACrC;AAAA,EACA,QAAQ;AAAA,IACN,MAAM;AAAA,IACN,YAAY;AAAA,IACZ,SAAS,OAAK,EAAE,OAAO;AAAA,EACzB;AAAA,EACA,OAAO;AAAA,IACL,MAAM;AAAA,IACN,YAAY;AAAA,IACZ,SAAS,OAAK,EAAE,OAAO;AAAA,EACzB;AAAA,EACA,SAAS;AAAA,IACP,MAAM;AAAA,IACN,YAAY;AAAA,IACZ,SAAS,OAAM,EAA0C,OAAO;AAAA,EAClE;AAAA,EACA,OAAO;AAAA,IACL,MAAM;AAAA,IACN,YAAY;AAAA,IACZ,SAAS,OAAK;AAAA,EAChB;AAAA,EACA,QAAQ;AAAA,IACN,MAAM;AAAA,IACN,YAAY;AAAA,IACZ,SAAS,OAAK,EAAE,OAAO;AAAA,EACzB;AACF;AAWO,SAAS,oBAAoB,OAAiC;AACnE,QAAM,EAAE,WAAW,UAAU,OAAO,IAAI;AAExC,QAAM,mBAAmB;AAAA,IACvB,MAAM,UAAU,4BAA4B,SAAS;AAAA,IACrD,CAAC,WAAW,MAAM;AAAA,EACpB;AACA,QAAM,EAAE,YAAY,YAAY,QAAQ,IAAI;AAAA,IAC1C,MAAM,sBAAsB,UAAU,IAAI;AAAA,IAC1C,CAAC,UAAU,IAAI;AAAA,EACjB;AAEA,QAAM,oBAAoB,CAAC,MAAW;AACpC,UAAM,QAAQ,QAAQ,CAAC;AACvB,aAAS,UAAU,IAAI,KAAK;AAAA,EAC9B;AAEA,MAAI,oBAAoB,iBAAiB,YAAY,OAAO;AAC1D,WACE;AAAA,MAAC;AAAA;AAAA,QACC,YAAY;AAAA,QACZ,OAAO,iBAAiB;AAAA;AAAA,IAC1B;AAAA,EAEJ;AAEA,QAAM,eAAe,UAAU,WAAW;AAE1C,SACE;AAAA,IAAC;AAAA;AAAA,MACC,IAAI,UAAU;AAAA,MACd,OAAO,UAAU;AAAA,MACjB,OAAO,MAAM;AAAA,MACb,UAAU;AAAA,MAEV,SAAS,UAAU;AAAA,MACnB;AAAA;AAAA,EACF;AAEJ","sourcesContent":["import { useMemo, ReactElement } from \"react\"\nimport { FxParamDefinition, FxParamType } from \"../types\"\nimport { FxParamInputChangeHandler, FxParamControllerProps } from \"./Controller\"\nimport { BooleanController } from \"./Boolean\"\nimport { ColorController } from \"./Color\"\nimport { NumberController } from \"./Number\"\nimport { BigIntController } from \"./BigInt\"\nimport { SelectController } from \"./Select\"\nimport { StringController } from \"./String\"\nimport {\n validateParameterDefinition,\n ControllerDefinitionSchemaType,\n} from \"../validation\"\nimport { SafeParseError, SafeParseSuccess, z } from \"zod\"\nimport { ControllerInvalid } from \"./Invalid\"\nimport { BytesController } from \"./Bytes\"\n\ninterface FxParamControllerDefiniton<Type extends FxParamType> {\n type: Type\n controller: (props: FxParamControllerProps<Type>) => ReactElement\n handler: FxParamInputChangeHandler\n}\n\nexport type FxParamControllerDefinitions = {\n [T in FxParamType]: FxParamControllerDefiniton<T>\n}\n\nexport const controllerDefinitions: FxParamControllerDefinitions = {\n number: {\n type: \"number\",\n controller: NumberController,\n handler: e => Number(e.target.value),\n },\n bigint: {\n type: \"bigint\",\n controller: BigIntController,\n handler: e => BigInt(e.target.value),\n },\n string: {\n type: \"string\",\n controller: StringController,\n handler: e => e.target.value,\n },\n bytes: {\n type: \"bytes\",\n controller: BytesController,\n handler: e => e.target.value,\n },\n boolean: {\n type: \"boolean\",\n controller: BooleanController,\n handler: e => (e as React.ChangeEvent<HTMLInputElement>).target.checked,\n },\n color: {\n type: \"color\",\n controller: ColorController,\n handler: v => v,\n },\n select: {\n type: \"select\",\n controller: SelectController,\n handler: e => e.target.value,\n },\n}\n\nexport interface ParameterControllerProps {\n parameter: FxParamDefinition<FxParamType>\n value: any\n onChange: (id: string, value: any) => void\n parsed?:\n | SafeParseError<ControllerDefinitionSchemaType>\n | SafeParseSuccess<ControllerDefinitionSchemaType>\n}\n\nexport function ParameterController(props: ParameterControllerProps) {\n const { parameter, onChange, parsed } = props\n\n const parsedDefinition = useMemo(\n () => parsed || validateParameterDefinition(parameter),\n [parameter, parsed]\n )\n const { controller: Controller, handler } = useMemo(\n () => controllerDefinitions[parameter.type],\n [parameter.type]\n )\n\n const handleChangeParam = (e: any) => {\n const value = handler(e)\n onChange(parameter.id, value)\n }\n\n if (parsedDefinition && parsedDefinition.success === false) {\n return (\n <ControllerInvalid\n definition={parameter}\n error={parsedDefinition.error}\n />\n )\n }\n\n const isCodeDriven = parameter.update === \"code-driven\"\n\n return (\n <Controller\n id={parameter.id}\n label={parameter.name}\n value={props.value}\n onChange={handleChangeParam}\n // TODO: This should be properly casted\n options={parameter.options as any}\n isCodeDriven={isCodeDriven}\n />\n )\n}\n"]}
|
package/dist/chunk-3QFEC7SK.cjs
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
-
|
|
3
|
-
var _chunkM7HJ2CKMcjs = require('./chunk-M7HJ2CKM.cjs');
|
|
4
|
-
|
|
5
|
-
// src/Controller/Bytes.tsx
|
|
6
|
-
var _react = require('react');
|
|
7
|
-
|
|
8
|
-
// src/Controller/Bytes.module.scss
|
|
9
|
-
var Bytes_module_default = {
|
|
10
|
-
"root": "_root_sy7al_1"
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
// src/Controller/Bytes.tsx
|
|
14
|
-
var _jsxruntime = require('react/jsx-runtime');
|
|
15
|
-
function BytesController(props) {
|
|
16
|
-
const { options } = props;
|
|
17
|
-
const hex = _react.useMemo.call(void 0, () => {
|
|
18
|
-
let out = "";
|
|
19
|
-
for (const v of props.value) {
|
|
20
|
-
out += v.toString(16).padStart(2, "0");
|
|
21
|
-
}
|
|
22
|
-
return out;
|
|
23
|
-
}, [props.value]);
|
|
24
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
25
|
-
_chunkM7HJ2CKMcjs.Controller,
|
|
26
|
-
{
|
|
27
|
-
id: props.id,
|
|
28
|
-
label: props.label,
|
|
29
|
-
layout: props.layout,
|
|
30
|
-
isCodeDriven: props.isCodeDriven,
|
|
31
|
-
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: Bytes_module_default.root, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: Bytes_module_default.wrapper, children: hex }) })
|
|
32
|
-
}
|
|
33
|
-
);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
exports.BytesController = BytesController;
|
|
39
|
-
//# sourceMappingURL=chunk-3QFEC7SK.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/Controller/Bytes.tsx","../src/Controller/Bytes.module.scss"],"names":[],"mappings":";;;;;AAAA,SAAS,eAAe;;;ACA4B,IAAO,uBAAQ;AAAA,EACjE,QAAQ;AACV;;;ADyBQ;AAnBD,SAAS,gBAAgB,OAAwC;AACtE,QAAM,EAAE,QAAQ,IAAI;AAEpB,QAAM,MAAM,QAAgB,MAAM;AAChC,QAAI,MAAM;AACV,eAAW,KAAK,MAAM,OAAO;AAC3B,aAAO,EAAE,SAAS,EAAE,EAAE,SAAS,GAAG,GAAG;AAAA,IACvC;AACA,WAAO;AAAA,EACT,GAAG,CAAC,MAAM,KAAK,CAAC;AAEhB,SACE;AAAA,IAAC;AAAA;AAAA,MACC,IAAI,MAAM;AAAA,MACV,OAAO,MAAM;AAAA,MACb,QAAQ,MAAM;AAAA,MACd,cAAc,MAAM;AAAA,MAEpB,8BAAC,SAAI,WAAW,qBAAI,MAClB,8BAAC,SAAI,WAAW,qBAAI,SAAU,eAAI,GACpC;AAAA;AAAA,EACF;AAEJ","sourcesContent":["import { useMemo } from \"react\"\nimport css from \"./Bytes.module.scss\"\nimport {\n Controller,\n FxParamControllerProps,\n HTMLInputController,\n} from \"./Controller\"\n\nexport function BytesController(props: FxParamControllerProps<\"bytes\">) {\n const { options } = props\n\n const hex = useMemo<string>(() => {\n let out = \"\"\n for (const v of props.value) {\n out += v.toString(16).padStart(2, \"0\")\n }\n return out\n }, [props.value])\n\n return (\n <Controller\n id={props.id}\n label={props.label}\n layout={props.layout}\n isCodeDriven={props.isCodeDriven}\n >\n <div className={css.root}>\n <div className={css.wrapper}>{hex}</div>\n </div>\n </Controller>\n )\n}\n","import 'css-chunk:src/Controller/Bytes.module.scss';export default {\n \"root\": \"_root_sy7al_1\"\n};"]}
|