json-renderers-run-instructions 0.0.0-stage → 1.2.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/README.md CHANGED
@@ -1,3 +1,14 @@
1
- # Temporary Holding Version
1
+ # json-renderers-run-instructions
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Reusable runtime extracted from `json-renderers-build-table`.
4
+
5
+ ## v1 exports
6
+
7
+ - `runInstructions({ single, double, registry, showLog })` — executes single- and double-target instruction arrays against a caller-provided registry.
8
+ - `renderJsonToDom({ jsonSpec, targetHtmlId, appendPosition, showLog })` — mounts a completed JSON spec using `@keshavsoft/json-to-dom`.
9
+
10
+ This package is generic. It does not import `spec-repo`, understand tables, or construct table definitions. Table-specific spec generation remains in `json-renderers-build-table`.
11
+
12
+ ## Source discipline
13
+
14
+ The public entry point is `src/index.js`; the implementation lives in `src/v1/`.
package/package.json CHANGED
@@ -1,6 +1,21 @@
1
1
  {
2
2
  "name": "json-renderers-run-instructions",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.2.1",
4
+ "description": "Reusable instruction execution and JSON-to-DOM mounting runtime for JSON renderers",
5
+ "type": "module",
6
+ "main": "src/index.js",
7
+ "exports": {
8
+ ".": "./src/index.js"
9
+ },
10
+ "files": [
11
+ "src",
12
+ "README.md"
13
+ ],
14
+ "scripts": {
15
+ "test": "node --test"
16
+ },
17
+ "dependencies": {
18
+ "json-instruction-double": "^1.3.2",
19
+ "json-instruction-single": "^1.5.3"
20
+ }
21
+ }
package/src/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export * from "./v2/index.js";
2
+ export { default } from "./v2/index.js";
@@ -0,0 +1,60 @@
1
+ import runSingleInstructions from "json-instruction-single";
2
+ import runDoubleInstructions from "json-instruction-double";
3
+ import jsonToDom from "@keshavsoft/json-to-dom";
4
+
5
+ /**
6
+ * Executes the single- and double-target instruction lists against a shared registry.
7
+ * This module deliberately knows nothing about tables or table definitions.
8
+ */
9
+ export const runInstructions = ({
10
+ single = [],
11
+ double = [],
12
+ registry = {},
13
+ showLog = false
14
+ } = {}) => {
15
+ if (!Array.isArray(single)) {
16
+ throw new TypeError("single instructions must be an array");
17
+ }
18
+ if (!Array.isArray(double)) {
19
+ throw new TypeError("double instructions must be an array");
20
+ }
21
+ if (!registry || typeof registry !== "object" || Array.isArray(registry)) {
22
+ throw new TypeError("registry must be an object");
23
+ }
24
+
25
+ if (single.length > 0) {
26
+ runSingleInstructions(single, registry, showLog);
27
+ }
28
+ if (double.length > 0) {
29
+ runDoubleInstructions(double, registry);
30
+ }
31
+
32
+ return registry;
33
+ };
34
+
35
+ /**
36
+ * Mounts a generated JSON specification into the DOM.
37
+ * The caller owns spec generation and supplies the completed JSON spec.
38
+ */
39
+ export const renderJsonToDom = ({
40
+ jsonSpec,
41
+ targetHtmlId,
42
+ appendPosition,
43
+ showLog = false
44
+ } = {}) => {
45
+ if (!jsonSpec || typeof jsonSpec !== "object" || Array.isArray(jsonSpec)) {
46
+ throw new TypeError("jsonSpec must be a JSON object");
47
+ }
48
+
49
+ return jsonToDom({
50
+ jsonSpec,
51
+ targetHtmlId,
52
+ appendPosition,
53
+ showLog
54
+ });
55
+ };
56
+
57
+ export default {
58
+ runInstructions,
59
+ renderJsonToDom
60
+ };
@@ -0,0 +1,34 @@
1
+ import runSingleInstructions from "json-instruction-single";
2
+ import runDoubleInstructions from "json-instruction-double";
3
+
4
+ /**
5
+ * Executes the single- and double-target instruction lists against a shared registry.
6
+ * This module deliberately knows nothing about tables or table definitions.
7
+ */
8
+ export const runInstructions = ({
9
+ single = [],
10
+ double = [],
11
+ registry = {},
12
+ showLog = false
13
+ } = {}) => {
14
+ if (!Array.isArray(single)) {
15
+ throw new TypeError("single instructions must be an array");
16
+ }
17
+ if (!Array.isArray(double)) {
18
+ throw new TypeError("double instructions must be an array");
19
+ }
20
+ if (!registry || typeof registry !== "object" || Array.isArray(registry)) {
21
+ throw new TypeError("registry must be an object");
22
+ }
23
+
24
+ if (single.length > 0) {
25
+ runSingleInstructions(single, registry, showLog);
26
+ }
27
+ if (double.length > 0) {
28
+ runDoubleInstructions(double, registry);
29
+ }
30
+
31
+ return registry;
32
+ };
33
+
34
+ export default runInstructions;