json-renderers-run-instructions 1.20.1 → 1.22.2

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.
Files changed (41) hide show
  1. package/package.json +13 -16
  2. package/src/index.js +2 -2
  3. package/src/v18/README.md +21 -21
  4. package/src/v18/instructions/executeBuildInstruction.js +53 -53
  5. package/src/v18/instructions/executeWriteBundle.js +21 -21
  6. package/src/v18/instructions/index.js +35 -35
  7. package/src/v18/instructions/resolveSource.js +24 -24
  8. package/src/v18/instructions/writeResult.js +29 -29
  9. package/src/v19/data/definitions.json +149 -149
  10. package/src/v19/data/instructions.json +650 -650
  11. package/src/v19/data/spec.json +1605 -1605
  12. package/src/v19/index.js +54 -54
  13. package/src/v19/instructions/executeBuildInstruction.js +53 -53
  14. package/src/v19/instructions/executeWriteBundle.js +21 -21
  15. package/src/v19/instructions/index.js +35 -35
  16. package/src/v19/instructions/resolveSource.js +24 -24
  17. package/src/v19/instructions/writeResult.js +29 -29
  18. package/src/v19/registerGlobal/index.js +16 -16
  19. package/src/v19/registerGlobal/meta.js +6 -6
  20. package/src/v19/runOptions/index.js +78 -78
  21. package/src/v20/index.js +54 -54
  22. package/src/v20/instructions/executeBuildInstruction.js +53 -53
  23. package/src/v20/instructions/executeWriteBundle.js +21 -21
  24. package/src/v20/instructions/index.js +35 -35
  25. package/src/v20/instructions/resolveSource.js +24 -24
  26. package/src/v20/instructions/writeResult.js +29 -29
  27. package/src/v20/registerGlobal/index.js +16 -16
  28. package/src/v20/registerGlobal/meta.js +6 -6
  29. package/src/v20/runOptions/index.js +36 -36
  30. package/src/v20/runOptions/normalizeOptions.js +28 -28
  31. package/src/v20/runOptions/resolveFeatureKeys.js +43 -43
  32. package/src/v21/index.js +46 -0
  33. package/src/v21/registerGlobal/index.js +16 -0
  34. package/src/v21/registerGlobal/meta.js +6 -0
  35. package/src/v21/runOptions/index.js +28 -0
  36. package/src/v21/runOptions/normalizeOptions.js +28 -0
  37. package/src/v21/runOptions/resolveFeatureKeys.js +55 -0
  38. package/src/v22/index.js +46 -0
  39. package/src/v22/registerGlobal/index.js +16 -0
  40. package/src/v22/registerGlobal/meta.js +6 -0
  41. package/src/v22/runOptions/index.js +59 -0
package/package.json CHANGED
@@ -1,14 +1,11 @@
1
1
  {
2
2
  "name": "json-renderers-run-instructions",
3
- "version": "1.20.1",
3
+ "version": "1.22.2",
4
4
  "description": "Reusable instruction execution and JSON-to-DOM mounting runtime for JSON renderers",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
7
7
  "exports": {
8
- ".": "./src/index.js",
9
- "./v18": "./src/v18/index.js",
10
- "./v19": "./src/v19/index.js",
11
- "./v20": "./src/v20/index.js"
8
+ ".": "./src/index.js"
12
9
  },
13
10
  "files": [
14
11
  "src",
@@ -18,17 +15,17 @@
18
15
  "build": "npx @keshavsoft/build-cli"
19
16
  },
20
17
  "dependencies": {
21
- "declarative-definitions": "^1.3.1",
22
- "declarative-instructions": "^1.2.3",
18
+ "declarative-definitions": "^1.6.1",
19
+ "declarative-instructions-multi": "^1.4.2",
20
+ "declarative-instructions-single": "^1.5.2",
23
21
  "declarative-spec": "^1.4.1",
24
- "json-transformer-funcs-one-dimension": "^1.9.9",
25
- "json-transformer-funcs-primitive": "^1.9.3",
26
- "json-transformer-funcs-two-dimensions": "^1.9.1",
27
- "json-renderers-run-instructions-steps": "^1.8.2",
28
- "json-write-path": "^1.6.1",
29
- "jsonpathly": "^4.0.0"
22
+ "json-renderers-run-instructions-steps": "^1.14.2"
30
23
  },
31
- "devDependencies": {
32
- "spec-repo": "^1.19.2"
24
+ "dependencies1": {
25
+ "declarative-definitions": "file:../declarative-definitions",
26
+ "declarative-instructions-multi": "file:../declarative-instructions-multi",
27
+ "declarative-instructions-single": "file:../declarative-instructions-single",
28
+ "declarative-spec": "^1.4.1",
29
+ "json-renderers-run-instructions-steps": "file:../json-renderers-run-instructions-steps"
33
30
  }
34
- }
31
+ }
package/src/index.js CHANGED
@@ -1,3 +1,3 @@
1
- export * from "./v20/index.js";
1
+ export * from "./v22/index.js";
2
2
 
3
- export { default } from "./v20/index.js";
3
+ export { default } from "./v22/index.js";
package/src/v18/README.md CHANGED
@@ -1,21 +1,21 @@
1
- # v18 instruction sequence experiment
2
-
3
- This version keeps the public options grouped by feature, then resolves enabled
4
- option steps into one ordered instruction sequence.
5
-
6
- 1. Clone the component base spec.
7
- 2. Add the component's normal build instruction keys to the sequence.
8
- 3. Resolve requested option switches into named keys such as `set-search` and
9
- `options-show-button`.
10
- 4. Run each key in order. Object instructions build from data; array
11
- instructions apply writes to the current spec.
12
-
13
- The JSON files in `data/` are local snapshots copied from the declarative
14
- definition, instruction, and spec repositories. The copied table option
15
- definitions are reshaped here as ordered steps with `when` / `whenAny` gates.
16
- This lets the runner be worked on before those repositories adopt the new
17
- option sequence format.
18
-
19
- The stable package entry point continues to use v17. This experiment is
20
- available through the `./v18` package subpath and registers its browser global
21
- at `ks.jsonRenderers.runInstructions.v18`.
1
+ # v18 instruction sequence experiment
2
+
3
+ This version keeps the public options grouped by feature, then resolves enabled
4
+ option steps into one ordered instruction sequence.
5
+
6
+ 1. Clone the component base spec.
7
+ 2. Add the component's normal build instruction keys to the sequence.
8
+ 3. Resolve requested option switches into named keys such as `set-search` and
9
+ `options-show-button`.
10
+ 4. Run each key in order. Object instructions build from data; array
11
+ instructions apply writes to the current spec.
12
+
13
+ The JSON files in `data/` are local snapshots copied from the declarative
14
+ definition, instruction, and spec repositories. The copied table option
15
+ definitions are reshaped here as ordered steps with `when` / `whenAny` gates.
16
+ This lets the runner be worked on before those repositories adopt the new
17
+ option sequence format.
18
+
19
+ The stable package entry point continues to use v17. This experiment is
20
+ available through the `./v18` package subpath and registers its browser global
21
+ at `ks.jsonRenderers.runInstructions.v18`.
@@ -1,53 +1,53 @@
1
- import applyTemplate from "json-transformer-funcs-primitive";
2
- import fromCollection from "json-transformer-funcs-one-dimension";
3
- import { columnOnRow, rowOnColumn } from "json-transformer-funcs-two-dimensions";
4
-
5
- import resolveSource from "./resolveSource.js";
6
- import writeResult from "./writeResult.js";
7
-
8
- const getTemplate = (spec, key) => {
9
- const template = spec[key];
10
- if (template === undefined) {
11
- throw new Error(`Instruction spec not found: ${key}`);
12
- }
13
- return template;
14
- };
15
-
16
- const executeBuildInstruction = ({ key, instruction, state, spec, showLog = false }) => {
17
- const templateKey = instruction.templateKey;
18
- let result;
19
-
20
- switch (instruction.type) {
21
- case "single": {
22
- const source = resolveSource(instruction.sourcePath, state);
23
- const template = getTemplate(spec, templateKey);
24
- result = instruction.func === "fromCollection"
25
- ? fromCollection(source ?? [], template)
26
- : applyTemplate(source, template, showLog);
27
- break;
28
- }
29
- case "rowOnColumn":
30
- result = rowOnColumn({
31
- columns: state.data?.columns,
32
- data: state.data,
33
- columnSpec: getTemplate(spec, templateKey.columnKey),
34
- rowSpec: getTemplate(spec, templateKey.rowKey)
35
- });
36
- break;
37
- case "columnOnRow":
38
- result = columnOnRow({
39
- columns: state.data?.columns,
40
- data: state.data,
41
- columnSpec: getTemplate(spec, templateKey.columnKey),
42
- rowSpec: getTemplate(spec, templateKey.rowKey)
43
- });
44
- break;
45
- default:
46
- throw new Error(`Unsupported instruction type for ${key}: ${instruction.type}`);
47
- }
48
-
49
- writeResult(state, instruction.destinationPath, result, showLog);
50
- if (showLog) console.log(instruction.narration ?? `Ran instruction: ${key}`);
51
- };
52
-
53
- export default executeBuildInstruction;
1
+ import applyTemplate from "json-transformer-funcs-primitive";
2
+ import fromCollection from "json-transformer-funcs-one-dimension";
3
+ import { columnOnRow, rowOnColumn } from "json-transformer-funcs-two-dimensions";
4
+
5
+ import resolveSource from "./resolveSource.js";
6
+ import writeResult from "./writeResult.js";
7
+
8
+ const getTemplate = (spec, key) => {
9
+ const template = spec[key];
10
+ if (template === undefined) {
11
+ throw new Error(`Instruction spec not found: ${key}`);
12
+ }
13
+ return template;
14
+ };
15
+
16
+ const executeBuildInstruction = ({ key, instruction, state, spec, showLog = false }) => {
17
+ const templateKey = instruction.templateKey;
18
+ let result;
19
+
20
+ switch (instruction.type) {
21
+ case "single": {
22
+ const source = resolveSource(instruction.sourcePath, state);
23
+ const template = getTemplate(spec, templateKey);
24
+ result = instruction.func === "fromCollection"
25
+ ? fromCollection(source ?? [], template)
26
+ : applyTemplate(source, template, showLog);
27
+ break;
28
+ }
29
+ case "rowOnColumn":
30
+ result = rowOnColumn({
31
+ columns: state.data?.columns,
32
+ data: state.data,
33
+ columnSpec: getTemplate(spec, templateKey.columnKey),
34
+ rowSpec: getTemplate(spec, templateKey.rowKey)
35
+ });
36
+ break;
37
+ case "columnOnRow":
38
+ result = columnOnRow({
39
+ columns: state.data?.columns,
40
+ data: state.data,
41
+ columnSpec: getTemplate(spec, templateKey.columnKey),
42
+ rowSpec: getTemplate(spec, templateKey.rowKey)
43
+ });
44
+ break;
45
+ default:
46
+ throw new Error(`Unsupported instruction type for ${key}: ${instruction.type}`);
47
+ }
48
+
49
+ writeResult(state, instruction.destinationPath, result, showLog);
50
+ if (showLog) console.log(instruction.narration ?? `Ran instruction: ${key}`);
51
+ };
52
+
53
+ export default executeBuildInstruction;
@@ -1,21 +1,21 @@
1
- import { query } from "jsonpathly";
2
- import writePath from "json-write-path";
3
-
4
- import { hasDestination } from "./writeResult.js";
5
-
6
- const executeWriteBundle = ({ key, steps, state, spec, showLog = false }) => {
7
- for (const step of steps) {
8
- if (step.skipIf && query(state.base, step.skipIf, { returnArray: true }).length > 0) continue;
9
- if (!hasDestination(state, step.destinationPath)) continue;
10
-
11
- const template = spec[step.templateKey];
12
- if (template === undefined) {
13
- throw new Error(`Instruction spec not found: ${step.templateKey} (from ${key})`);
14
- }
15
-
16
- writePath(state, step.destinationPath, structuredClone(template), showLog);
17
- if (showLog) console.log(step.narration ?? `Ran instruction: ${key}`);
18
- }
19
- };
20
-
21
- export default executeWriteBundle;
1
+ import { query } from "jsonpathly";
2
+ import writePath from "json-write-path";
3
+
4
+ import { hasDestination } from "./writeResult.js";
5
+
6
+ const executeWriteBundle = ({ key, steps, state, spec, showLog = false }) => {
7
+ for (const step of steps) {
8
+ if (step.skipIf && query(state.base, step.skipIf, { returnArray: true }).length > 0) continue;
9
+ if (!hasDestination(state, step.destinationPath)) continue;
10
+
11
+ const template = spec[step.templateKey];
12
+ if (template === undefined) {
13
+ throw new Error(`Instruction spec not found: ${step.templateKey} (from ${key})`);
14
+ }
15
+
16
+ writePath(state, step.destinationPath, structuredClone(template), showLog);
17
+ if (showLog) console.log(step.narration ?? `Ran instruction: ${key}`);
18
+ }
19
+ };
20
+
21
+ export default executeWriteBundle;
@@ -1,35 +1,35 @@
1
- import executeBuildInstruction from "./executeBuildInstruction.js";
2
- import executeWriteBundle from "./executeWriteBundle.js";
3
-
4
- const runInstructionSequence = ({
5
- sequence = [],
6
- base,
7
- data,
8
- instructions,
9
- spec,
10
- showLog = false
11
- } = {}) => {
12
- const state = { base, data };
13
-
14
- for (const step of sequence) {
15
- const instructionKey = typeof step === "string" ? step : step.instructionKey;
16
- const instruction = instructions[instructionKey];
17
-
18
- if (!instruction) {
19
- throw new Error(`Instruction not found: ${instructionKey}`);
20
- }
21
-
22
- if (showLog) console.log(`[v18] ${step.key ?? instructionKey}`);
23
-
24
- if (Array.isArray(instruction)) {
25
- executeWriteBundle({ key: instructionKey, steps: instruction, state, spec, showLog });
26
- continue;
27
- }
28
-
29
- executeBuildInstruction({ key: instructionKey, instruction, state, spec, showLog });
30
- }
31
-
32
- return state.base;
33
- };
34
-
35
- export default runInstructionSequence;
1
+ import executeBuildInstruction from "./executeBuildInstruction.js";
2
+ import executeWriteBundle from "./executeWriteBundle.js";
3
+
4
+ const runInstructionSequence = ({
5
+ sequence = [],
6
+ base,
7
+ data,
8
+ instructions,
9
+ spec,
10
+ showLog = false
11
+ } = {}) => {
12
+ const state = { base, data };
13
+
14
+ for (const step of sequence) {
15
+ const instructionKey = typeof step === "string" ? step : step.instructionKey;
16
+ const instruction = instructions[instructionKey];
17
+
18
+ if (!instruction) {
19
+ throw new Error(`Instruction not found: ${instructionKey}`);
20
+ }
21
+
22
+ if (showLog) console.log(`[v18] ${step.key ?? instructionKey}`);
23
+
24
+ if (Array.isArray(instruction)) {
25
+ executeWriteBundle({ key: instructionKey, steps: instruction, state, spec, showLog });
26
+ continue;
27
+ }
28
+
29
+ executeBuildInstruction({ key: instructionKey, instruction, state, spec, showLog });
30
+ }
31
+
32
+ return state.base;
33
+ };
34
+
35
+ export default runInstructionSequence;
@@ -1,24 +1,24 @@
1
- import { query } from "jsonpathly";
2
-
3
- const resolveSource = (sourcePath, state) => {
4
- if (!sourcePath) return null;
5
-
6
- const root = state[sourcePath.fileName];
7
- if (root === undefined) {
8
- throw new Error(`Instruction source not found: ${sourcePath.fileName}`);
9
- }
10
-
11
- if (sourcePath.jsonPath) {
12
- const matches = query(root, sourcePath.jsonPath, { returnArray: true });
13
- if (matches.length === 0) return Array.isArray(root) ? root : [];
14
- return matches.length === 1 ? matches[0] : matches;
15
- }
16
-
17
- if (Array.isArray(sourcePath.filePath) && sourcePath.filePath.length > 0) {
18
- return sourcePath.filePath.reduce((value, key) => value?.[key], root);
19
- }
20
-
21
- return root;
22
- };
23
-
24
- export default resolveSource;
1
+ import { query } from "jsonpathly";
2
+
3
+ const resolveSource = (sourcePath, state) => {
4
+ if (!sourcePath) return null;
5
+
6
+ const root = state[sourcePath.fileName];
7
+ if (root === undefined) {
8
+ throw new Error(`Instruction source not found: ${sourcePath.fileName}`);
9
+ }
10
+
11
+ if (sourcePath.jsonPath) {
12
+ const matches = query(root, sourcePath.jsonPath, { returnArray: true });
13
+ if (matches.length === 0) return Array.isArray(root) ? root : [];
14
+ return matches.length === 1 ? matches[0] : matches;
15
+ }
16
+
17
+ if (Array.isArray(sourcePath.filePath) && sourcePath.filePath.length > 0) {
18
+ return sourcePath.filePath.reduce((value, key) => value?.[key], root);
19
+ }
20
+
21
+ return root;
22
+ };
23
+
24
+ export default resolveSource;
@@ -1,29 +1,29 @@
1
- import writePath from "json-write-path";
2
- import { query } from "jsonpathly";
3
-
4
- const hasDestination = (state, destinationPath) => {
5
- if (!destinationPath?.jsonPath) return true;
6
-
7
- const root = state[destinationPath.fileName];
8
- return root !== undefined && query(root, destinationPath.jsonPath, { returnArray: true }).length > 0;
9
- };
10
-
11
- const writeResult = (state, destinationPath, result, showLog = false) => {
12
- if (!destinationPath) return;
13
- if (!hasDestination(state, destinationPath)) return;
14
-
15
- if (!Array.isArray(destinationPath.filePath) || destinationPath.filePath.length === 0) {
16
- const target = state[destinationPath.fileName];
17
- if (Array.isArray(target)) {
18
- target.push(...(Array.isArray(result) ? result : [result]));
19
- } else {
20
- state[destinationPath.fileName] = result;
21
- }
22
- return;
23
- }
24
-
25
- writePath(state, destinationPath, result, showLog);
26
- };
27
-
28
- export { hasDestination };
29
- export default writeResult;
1
+ import writePath from "json-write-path";
2
+ import { query } from "jsonpathly";
3
+
4
+ const hasDestination = (state, destinationPath) => {
5
+ if (!destinationPath?.jsonPath) return true;
6
+
7
+ const root = state[destinationPath.fileName];
8
+ return root !== undefined && query(root, destinationPath.jsonPath, { returnArray: true }).length > 0;
9
+ };
10
+
11
+ const writeResult = (state, destinationPath, result, showLog = false) => {
12
+ if (!destinationPath) return;
13
+ if (!hasDestination(state, destinationPath)) return;
14
+
15
+ if (!Array.isArray(destinationPath.filePath) || destinationPath.filePath.length === 0) {
16
+ const target = state[destinationPath.fileName];
17
+ if (Array.isArray(target)) {
18
+ target.push(...(Array.isArray(result) ? result : [result]));
19
+ } else {
20
+ state[destinationPath.fileName] = result;
21
+ }
22
+ return;
23
+ }
24
+
25
+ writePath(state, destinationPath, result, showLog);
26
+ };
27
+
28
+ export { hasDestination };
29
+ export default writeResult;