@kinotic-ai/spawn 0.1.1 → 0.3.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/dist/index.cjs +4 -2
- package/dist/index.d.cts +9 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +4 -2
- package/dist/spawn-renderer.global.js +5 -3
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -69,7 +69,7 @@ function camelCase(s) {
|
|
|
69
69
|
class SpawnEngine {
|
|
70
70
|
engine;
|
|
71
71
|
constructor() {
|
|
72
|
-
this.engine = new import_liquidjs.Liquid({ cache: true });
|
|
72
|
+
this.engine = new import_liquidjs.Liquid({ cache: true, strictVariables: true });
|
|
73
73
|
this.engine.registerFilter("packageToPath", (v) => v.replaceAll(".", "/"));
|
|
74
74
|
this.engine.registerFilter("encodePackage", (v) => {
|
|
75
75
|
v = v.replaceAll("-", "_");
|
|
@@ -110,6 +110,7 @@ class SpawnEngine {
|
|
|
110
110
|
let context = { ...globals, ...options?.context };
|
|
111
111
|
context = await this.resolveMissingProperties(propertySchemas, context, options?.propertyResolver);
|
|
112
112
|
const files = {};
|
|
113
|
+
const sources = {};
|
|
113
114
|
for (const tree of [...trees].reverse()) {
|
|
114
115
|
for (const source of Object.keys(tree).sort()) {
|
|
115
116
|
const fileName = source.substring(source.lastIndexOf("/") + 1);
|
|
@@ -129,9 +130,10 @@ class SpawnEngine {
|
|
|
129
130
|
content = await this.engine.parseAndRender(content, context);
|
|
130
131
|
}
|
|
131
132
|
files[destination] = content;
|
|
133
|
+
sources[destination] = source;
|
|
132
134
|
}
|
|
133
135
|
}
|
|
134
|
-
return { files, context };
|
|
136
|
+
return { files, sources, context };
|
|
135
137
|
}
|
|
136
138
|
parseConfig(tree) {
|
|
137
139
|
const raw = tree["spawn.json"];
|
package/dist/index.d.cts
CHANGED
|
@@ -71,6 +71,13 @@ interface SpawnRenderResult {
|
|
|
71
71
|
*/
|
|
72
72
|
files: SpawnTree;
|
|
73
73
|
/**
|
|
74
|
+
* The originating spawn path for each rendered file, keyed by the same
|
|
75
|
+
* destination path used in {@link files}. Lets a host trace a rendered file
|
|
76
|
+
* back to its template entry to recover source metadata (e.g. the executable
|
|
77
|
+
* bit) that the destination path alone cannot convey.
|
|
78
|
+
*/
|
|
79
|
+
sources: Record<string, string>;
|
|
80
|
+
/**
|
|
74
81
|
* The full context the templates were rendered with: merged globals,
|
|
75
82
|
* caller-provided values, and any values supplied by the property resolver.
|
|
76
83
|
*/
|
|
@@ -93,6 +100,8 @@ interface SpawnRenderResult {
|
|
|
93
100
|
* {@link PropertyResolver}, or fail the render when no resolver is given
|
|
94
101
|
* - paths containing liquid expressions are rendered; files ending in
|
|
95
102
|
* {@code .liquid} have their content rendered and the suffix stripped
|
|
103
|
+
* - a reference to a variable that is neither in the context nor declared in
|
|
104
|
+
* spawn.json throws rather than rendering empty (strictVariables)
|
|
96
105
|
* - files from derived spawns overwrite same-destination files from inherited
|
|
97
106
|
* spawns
|
|
98
107
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -71,6 +71,13 @@ interface SpawnRenderResult {
|
|
|
71
71
|
*/
|
|
72
72
|
files: SpawnTree;
|
|
73
73
|
/**
|
|
74
|
+
* The originating spawn path for each rendered file, keyed by the same
|
|
75
|
+
* destination path used in {@link files}. Lets a host trace a rendered file
|
|
76
|
+
* back to its template entry to recover source metadata (e.g. the executable
|
|
77
|
+
* bit) that the destination path alone cannot convey.
|
|
78
|
+
*/
|
|
79
|
+
sources: Record<string, string>;
|
|
80
|
+
/**
|
|
74
81
|
* The full context the templates were rendered with: merged globals,
|
|
75
82
|
* caller-provided values, and any values supplied by the property resolver.
|
|
76
83
|
*/
|
|
@@ -93,6 +100,8 @@ interface SpawnRenderResult {
|
|
|
93
100
|
* {@link PropertyResolver}, or fail the render when no resolver is given
|
|
94
101
|
* - paths containing liquid expressions are rendered; files ending in
|
|
95
102
|
* {@code .liquid} have their content rendered and the suffix stripped
|
|
103
|
+
* - a reference to a variable that is neither in the context nor declared in
|
|
104
|
+
* spawn.json throws rather than rendering empty (strictVariables)
|
|
96
105
|
* - files from derived spawns overwrite same-destination files from inherited
|
|
97
106
|
* spawns
|
|
98
107
|
*/
|
package/dist/index.js
CHANGED
|
@@ -23,7 +23,7 @@ function camelCase(s) {
|
|
|
23
23
|
class SpawnEngine {
|
|
24
24
|
engine;
|
|
25
25
|
constructor() {
|
|
26
|
-
this.engine = new Liquid({ cache: true });
|
|
26
|
+
this.engine = new Liquid({ cache: true, strictVariables: true });
|
|
27
27
|
this.engine.registerFilter("packageToPath", (v) => v.replaceAll(".", "/"));
|
|
28
28
|
this.engine.registerFilter("encodePackage", (v) => {
|
|
29
29
|
v = v.replaceAll("-", "_");
|
|
@@ -64,6 +64,7 @@ class SpawnEngine {
|
|
|
64
64
|
let context = { ...globals, ...options?.context };
|
|
65
65
|
context = await this.resolveMissingProperties(propertySchemas, context, options?.propertyResolver);
|
|
66
66
|
const files = {};
|
|
67
|
+
const sources = {};
|
|
67
68
|
for (const tree of [...trees].reverse()) {
|
|
68
69
|
for (const source of Object.keys(tree).sort()) {
|
|
69
70
|
const fileName = source.substring(source.lastIndexOf("/") + 1);
|
|
@@ -83,9 +84,10 @@ class SpawnEngine {
|
|
|
83
84
|
content = await this.engine.parseAndRender(content, context);
|
|
84
85
|
}
|
|
85
86
|
files[destination] = content;
|
|
87
|
+
sources[destination] = source;
|
|
86
88
|
}
|
|
87
89
|
}
|
|
88
|
-
return { files, context };
|
|
90
|
+
return { files, sources, context };
|
|
89
91
|
}
|
|
90
92
|
parseConfig(tree) {
|
|
91
93
|
const raw = tree["spawn.json"];
|
|
@@ -19003,7 +19003,7 @@ From ` + this.originalError.stack;
|
|
|
19003
19003
|
class SpawnEngine {
|
|
19004
19004
|
engine;
|
|
19005
19005
|
constructor() {
|
|
19006
|
-
this.engine = new Liquid({ cache: true });
|
|
19006
|
+
this.engine = new Liquid({ cache: true, strictVariables: true });
|
|
19007
19007
|
this.engine.registerFilter("packageToPath", (v) => v.replaceAll(".", "/"));
|
|
19008
19008
|
this.engine.registerFilter("encodePackage", (v) => {
|
|
19009
19009
|
v = v.replaceAll("-", "_");
|
|
@@ -19044,6 +19044,7 @@ From ` + this.originalError.stack;
|
|
|
19044
19044
|
let context = { ...globals, ...options?.context };
|
|
19045
19045
|
context = await this.resolveMissingProperties(propertySchemas, context, options?.propertyResolver);
|
|
19046
19046
|
const files = {};
|
|
19047
|
+
const sources = {};
|
|
19047
19048
|
for (const tree of [...trees].reverse()) {
|
|
19048
19049
|
for (const source of Object.keys(tree).sort()) {
|
|
19049
19050
|
const fileName = source.substring(source.lastIndexOf("/") + 1);
|
|
@@ -19063,9 +19064,10 @@ From ` + this.originalError.stack;
|
|
|
19063
19064
|
content = await this.engine.parseAndRender(content, context);
|
|
19064
19065
|
}
|
|
19065
19066
|
files[destination] = content;
|
|
19067
|
+
sources[destination] = source;
|
|
19066
19068
|
}
|
|
19067
19069
|
}
|
|
19068
|
-
return { files, context };
|
|
19070
|
+
return { files, sources, context };
|
|
19069
19071
|
}
|
|
19070
19072
|
parseConfig(tree) {
|
|
19071
19073
|
const raw2 = tree["spawn.json"];
|
|
@@ -19104,7 +19106,7 @@ From ` + this.originalError.stack;
|
|
|
19104
19106
|
var engine = new SpawnEngine;
|
|
19105
19107
|
function renderSpawn(inputJson) {
|
|
19106
19108
|
const input = JSON.parse(inputJson);
|
|
19107
|
-
return engine.renderSpawn(input.files, { context: input.context }).then((result) => JSON.stringify(result.files));
|
|
19109
|
+
return engine.renderSpawn(input.files, { context: input.context }).then((result) => JSON.stringify({ files: result.files, sources: result.sources }));
|
|
19108
19110
|
}
|
|
19109
19111
|
globalThis["KinoticSpawn"] = { renderSpawn };
|
|
19110
19112
|
})();
|