@voxgig/build 4.15.0 → 4.16.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/util.js +31 -22
- package/dist/util.js.map +1 -1
- package/package.json +2 -2
package/dist/util.js
CHANGED
|
@@ -12,20 +12,18 @@ function indent(text, size) {
|
|
|
12
12
|
const tout = lines.join('');
|
|
13
13
|
return tout;
|
|
14
14
|
}
|
|
15
|
-
// A message definition declares its pattern as a LIST
|
|
16
|
-
//
|
|
17
|
-
//
|
|
18
|
-
//
|
|
19
|
-
// validates the declared shape with (see its producer/msg.ts).
|
|
15
|
+
// A message definition declares its pattern as a LIST, so it is told apart
|
|
16
|
+
// from a chain node - whose values are always maps, the next pattern level or
|
|
17
|
+
// the '$' leaf - even when spelled `pat:`. Same discriminator @voxgig/model
|
|
18
|
+
// validates the declared shape with.
|
|
20
19
|
function ismsgdef(val) {
|
|
21
20
|
return null != val && 'object' === typeof val &&
|
|
22
21
|
!Array.isArray(val) && Array.isArray(val.pat);
|
|
23
22
|
}
|
|
24
|
-
// The pattern of a
|
|
25
|
-
//
|
|
26
|
-
//
|
|
27
|
-
//
|
|
28
|
-
// generator.
|
|
23
|
+
// The pattern of a definition, flattened to the pair sequence [k,v,k,v,...]
|
|
24
|
+
// the chain walk produces. A malformed pair is skipped rather than thrown on:
|
|
25
|
+
// @voxgig/model fails the build on those, so one arriving here came from
|
|
26
|
+
// somewhere else and dropping it degrades better than crashing a generator.
|
|
29
27
|
function msgdefpairs(def) {
|
|
30
28
|
const pairs = [];
|
|
31
29
|
for (const pair of def.pat) {
|
|
@@ -39,16 +37,21 @@ function msgdefpairs(def) {
|
|
|
39
37
|
}
|
|
40
38
|
return pairs;
|
|
41
39
|
}
|
|
42
|
-
// Flatten
|
|
43
|
-
//
|
|
44
|
-
//
|
|
45
|
-
// pattern
|
|
40
|
+
// Flatten main.msg to [path, meta] entries, reading BOTH declaration shapes:
|
|
41
|
+
//
|
|
42
|
+
// the DECLARED shape, a LIST of definitions whose `pat` list IS the pattern;
|
|
43
|
+
// the LEGACY chain, where the nesting is the pattern and '$' carries the
|
|
44
|
+
// metadata.
|
|
45
|
+
//
|
|
46
|
+
// A list rather than a map keyed by message name, because a gateway proxy and
|
|
47
|
+
// the message it forwards to necessarily share their last pattern pair
|
|
48
|
+
// (aim:web,on:todo,save:item proxies aim:todo,save:item), so any key derived
|
|
49
|
+
// from that pair would collide and the two could not both be declared.
|
|
46
50
|
//
|
|
47
51
|
// This is a drop-in for @voxgig/util's dive() over a message tree - same entry
|
|
48
52
|
// shape, same '$' handling, same even-length pair paths that pinify() and the
|
|
49
|
-
// queue-name builders assume
|
|
50
|
-
//
|
|
51
|
-
// metadata and emit one entry per scalar field.
|
|
53
|
+
// queue-name builders assume. dive() cannot be used directly any more: fed a
|
|
54
|
+
// definition it would walk the metadata and emit one entry per scalar field.
|
|
52
55
|
function msgentries(node, depth = 128) {
|
|
53
56
|
const out = [];
|
|
54
57
|
walkmsgs(node, [], depth, out);
|
|
@@ -58,16 +61,22 @@ function walkmsgs(node, prefix, depth, out) {
|
|
|
58
61
|
if (null == node || 'object' !== typeof node) {
|
|
59
62
|
return;
|
|
60
63
|
}
|
|
64
|
+
// The declared shape: each element carries its own pattern.
|
|
65
|
+
if (Array.isArray(node)) {
|
|
66
|
+
for (const def of node) {
|
|
67
|
+
if (ismsgdef(def)) {
|
|
68
|
+
const meta = { ...def };
|
|
69
|
+
delete meta.pat;
|
|
70
|
+
out.push([prefix.concat(msgdefpairs(def)), meta]);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
61
75
|
for (const key of Object.keys(node)) {
|
|
62
76
|
const child = node[key];
|
|
63
77
|
if ('$' === key) {
|
|
64
78
|
out.push([prefix.slice(), child]);
|
|
65
79
|
}
|
|
66
|
-
else if (ismsgdef(child)) {
|
|
67
|
-
const meta = { ...child };
|
|
68
|
-
delete meta.pat;
|
|
69
|
-
out.push([prefix.concat(msgdefpairs(child)), meta]);
|
|
70
|
-
}
|
|
71
80
|
else if (depth <= 1 || null == child || 'object' !== typeof child ||
|
|
72
81
|
0 === Object.keys(child).length) {
|
|
73
82
|
out.push([prefix.concat(key), child]);
|
package/dist/util.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.js","sourceRoot":"","sources":["../util.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"util.js","sourceRoot":"","sources":["../util.ts"],"names":[],"mappings":";;AA8HE,wBAAM;AACN,4BAAQ;AACR,gCAAU;AACV,0BAAO;AACP,4BAAQ;AAhIV,SAAS,MAAM,CAAC,IAAY,EAAE,IAAY;IACxC,IAAI,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;IAC5B,MAAM,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IAC/B,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,GAAG,IAAI,GAAG,IAAI,CAAC,CAAA;IAC/C,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IAC3B,OAAO,IAAI,CAAA;AACb,CAAC;AAGD,2EAA2E;AAC3E,8EAA8E;AAC9E,4EAA4E;AAC5E,qCAAqC;AACrC,SAAS,QAAQ,CAAC,GAAQ;IACxB,OAAO,IAAI,IAAI,GAAG,IAAI,QAAQ,KAAK,OAAO,GAAG;QAC3C,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;AACjD,CAAC;AAGD,4EAA4E;AAC5E,8EAA8E;AAC9E,yEAAyE;AACzE,4EAA4E;AAC5E,SAAS,WAAW,CAAC,GAAQ;IAC3B,MAAM,KAAK,GAAa,EAAE,CAAA;IAE1B,KAAK,MAAM,IAAI,IAAI,GAAG,CAA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,GAAG,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;SAC/D,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAoB,CAAC,CAAA;AACrE,CAAC;AAGD,6EAA6E;AAC7E,8DAA8D;AAC9D,SAAS,QAAQ,CAAC,GAAQ;IACxB,MAAM,KAAK,GAAwB,EAAE,CAAA;IACrC,KAAK,MAAM,KAAK,IAAI,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QACpC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAA;IACtC,CAAC;IACD,OAAO,KAAK,CAAA;AACd,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@voxgig/build",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.16.0",
|
|
4
4
|
"main": "dist/build.js",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"types": "dist/build.d.ts",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@types/js-yaml": "^4.0.9",
|
|
57
57
|
"@types/node": "26.1.2",
|
|
58
|
-
"@voxgig/model": "^
|
|
58
|
+
"@voxgig/model": "^11.0.0",
|
|
59
59
|
"@voxgig/system": "^1.2.0",
|
|
60
60
|
"esbuild": "^0.23.0",
|
|
61
61
|
"typescript": "^5.5.3"
|