@jigs.design/compiler 0.3.3 → 0.3.5
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/compile.d.ts +13 -0
- package/dist/compile.js +17 -3
- package/package.json +3 -3
package/dist/compile.d.ts
CHANGED
|
@@ -116,6 +116,12 @@ export interface CompiledDefine {
|
|
|
116
116
|
procedures: ReadonlyArray<ProcedureUse>;
|
|
117
117
|
props: Array<DefineProp>;
|
|
118
118
|
statements: Array<Statement>;
|
|
119
|
+
/**
|
|
120
|
+
* The tags a library jig's body draws: components and the jigs it
|
|
121
|
+
* calls. Empty for a document's own define: those are on the
|
|
122
|
+
* document's result.
|
|
123
|
+
*/
|
|
124
|
+
tags: ReadonlySet<string>;
|
|
119
125
|
}
|
|
120
126
|
/** One component the document actually renders, and how often it is written. */
|
|
121
127
|
interface DefineUse {
|
|
@@ -168,6 +174,13 @@ export interface CompileResult {
|
|
|
168
174
|
* source with the fixes applied. It names every tag the program draws.
|
|
169
175
|
*/
|
|
170
176
|
source: string;
|
|
177
|
+
/**
|
|
178
|
+
* The tags the program draws, from its tree and its own defines'
|
|
179
|
+
* bodies, fixes included: each component and each jig it calls, not
|
|
180
|
+
* the tags those jigs draw (on the library's defines). Nothing in prose
|
|
181
|
+
* or in string literals counts.
|
|
182
|
+
*/
|
|
183
|
+
tags: ReadonlySet<string>;
|
|
171
184
|
}
|
|
172
185
|
/**
|
|
173
186
|
* Compiles `jigs` against `catalog`, in order: a jig may use the ones
|
package/dist/compile.js
CHANGED
|
@@ -196,7 +196,8 @@ function readDefine(node, findings, libraryNames, components) {
|
|
|
196
196
|
origin: "doc",
|
|
197
197
|
procedures: [],
|
|
198
198
|
props,
|
|
199
|
-
statements: []
|
|
199
|
+
statements: [],
|
|
200
|
+
tags: /* @__PURE__ */ new Set()
|
|
200
201
|
};
|
|
201
202
|
}
|
|
202
203
|
function lookupHint(name, candidates) {
|
|
@@ -707,6 +708,14 @@ function describeNumber(spec) {
|
|
|
707
708
|
if (spec.kind === "number" && spec.min !== void 0 && spec.max !== void 0) return `a number from ${spec.min} to ${spec.max}`;
|
|
708
709
|
return `a ${spec.kind} value`;
|
|
709
710
|
}
|
|
711
|
+
/** Each component `nodes` draw and each jig they call, by name, added to `into`. */
|
|
712
|
+
function collectTags(nodes, into) {
|
|
713
|
+
for (const node of nodes) {
|
|
714
|
+
if (node.type === "element") into.add(node.component);
|
|
715
|
+
else if (node.type === "call") into.add(node.name);
|
|
716
|
+
if (node.type === "call" || node.type === "each" || node.type === "element" || node.type === "if") collectTags(node.children, into);
|
|
717
|
+
}
|
|
718
|
+
}
|
|
710
719
|
function visitRender(nodes, visit) {
|
|
711
720
|
for (const node of nodes) if (node.type === "call") {
|
|
712
721
|
visit(node);
|
|
@@ -848,6 +857,9 @@ function compileDocument(source, library, components) {
|
|
|
848
857
|
findings.push(...generated.findings);
|
|
849
858
|
for (const finding of findings) if (finding.start !== void 0) finding.line = lineAt(source, finding.start);
|
|
850
859
|
findings.sort((a, b) => a.line - b.line);
|
|
860
|
+
const drawn = /* @__PURE__ */ new Set();
|
|
861
|
+
collectTags(tree, drawn);
|
|
862
|
+
for (const def of docDefines) collectTags(def.body, drawn);
|
|
851
863
|
return {
|
|
852
864
|
defines: docDefines,
|
|
853
865
|
fields: uses.fields,
|
|
@@ -861,7 +873,8 @@ function compileDocument(source, library, components) {
|
|
|
861
873
|
tree
|
|
862
874
|
},
|
|
863
875
|
reads: uses.reads,
|
|
864
|
-
source
|
|
876
|
+
source,
|
|
877
|
+
tags: drawn
|
|
865
878
|
};
|
|
866
879
|
}
|
|
867
880
|
function buildLibrary(list, components) {
|
|
@@ -877,7 +890,8 @@ function buildLibrary(list, components) {
|
|
|
877
890
|
built.set(def.name, {
|
|
878
891
|
...def,
|
|
879
892
|
origin: "library",
|
|
880
|
-
procedures: result.procedures
|
|
893
|
+
procedures: result.procedures,
|
|
894
|
+
tags: result.tags
|
|
881
895
|
});
|
|
882
896
|
}
|
|
883
897
|
return built;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jigs.design/compiler",
|
|
3
|
-
"version": "0.3.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.3.5",
|
|
4
|
+
"description": "The Jigs compiler: parser, checker against a catalog, code generator, jig libraries, and the edit helpers. It evolves in place, behind the server API.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -26,6 +26,6 @@
|
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"acorn": "8.19.0",
|
|
29
|
-
"@jigs.design/protocol": "0.3.
|
|
29
|
+
"@jigs.design/protocol": "0.3.5"
|
|
30
30
|
}
|
|
31
31
|
}
|