@voxgig/model 11.1.1 → 12.0.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/bin/voxgig-model +7 -5
- package/dist/build.js +0 -7
- package/dist/build.js.map +1 -1
- package/dist/config.d.ts +14 -2
- package/dist/config.js +179 -3
- package/dist/config.js.map +1 -1
- package/dist/init.js +4 -4
- package/dist/init.js.map +1 -1
- package/dist/model.js +24 -85
- package/dist/model.js.map +1 -1
- package/dist/producer/local.js +0 -5
- package/dist/producer/local.js.map +1 -1
- package/dist/producer/model.js +0 -14
- package/dist/producer/model.js.map +1 -1
- package/dist/producer/msg.js +0 -63
- package/dist/producer/msg.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/watch.js +4 -6
- package/dist/watch.js.map +1 -1
- package/model/{sys.aon → sys.aontu} +3 -51
- package/package.json +8 -8
- package/src/build.ts +0 -7
- package/src/config.ts +220 -3
- package/src/init.ts +4 -4
- package/src/model.ts +26 -52
- package/src/producer/local.ts +0 -5
- package/src/producer/model.ts +0 -14
- package/src/producer/msg.ts +0 -63
- package/src/types.ts +0 -3
- package/src/watch.ts +4 -6
- /package/model/.model-config/{model-config.aon → model-config.aontu} +0 -0
package/src/producer/msg.ts
CHANGED
|
@@ -3,39 +3,6 @@
|
|
|
3
3
|
import type { Build, Producer, BuildContext, ProducerResult } from '../types'
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
// Message declarations live in `main.msg` and come in two shapes.
|
|
7
|
-
//
|
|
8
|
-
// The legacy shape nests the pattern pairs, so the pattern is the path down
|
|
9
|
-
// to the definition, and the definition sits at whatever depth that reaches:
|
|
10
|
-
//
|
|
11
|
-
// aim: web: { on: todo: { save: item: { '$': { file: './web_save_item' } } } }
|
|
12
|
-
//
|
|
13
|
-
// The declared shape is a LIST of definitions, each carrying its pattern as
|
|
14
|
-
// data - an ordered list of single-pair maps:
|
|
15
|
-
//
|
|
16
|
-
// main: msg: [
|
|
17
|
-
// { pat: [ {aim: todo}, {save: item} ] }
|
|
18
|
-
// { pat: [ {aim: web}, {on: todo}, {save: item} ], file: "./web_save_item" }
|
|
19
|
-
// ]
|
|
20
|
-
//
|
|
21
|
-
// A LIST, NOT A MAP KEYED BY MESSAGE NAME. The obvious flat shape - one entry
|
|
22
|
-
// per message, keyed by name - cannot express a gateway proxy. A proxy and the
|
|
23
|
-
// message it forwards to necessarily share their last pattern pair
|
|
24
|
-
// (aim:web,on:todo,save:item proxies aim:todo,save:item), and a key derived
|
|
25
|
-
// from that pair therefore collides. Keyed by name, the two above would both
|
|
26
|
-
// demand `save_item`, and aontu would merge them and fail trying to unify
|
|
27
|
-
// `todo` with `web`. A list has no key, so the question never arises.
|
|
28
|
-
//
|
|
29
|
-
// The action file still comes from the LAST pattern pair (save:item ->
|
|
30
|
-
// save_item), with `file` overriding it for a custom name - unchanged, and
|
|
31
|
-
// exactly what a proxy uses. That convention lives in the consumers
|
|
32
|
-
// (@voxgig/system's actpath, @voxgig/build's actfile), not here.
|
|
33
|
-
//
|
|
34
|
-
// The two shapes are told apart by main.msg being an array. Both may appear
|
|
35
|
-
// in one model only in the sense that a model picks one; a chain model that
|
|
36
|
-
// happens to contain a definition is a mistake this reports, because the
|
|
37
|
-
// nested walk would read the definition's metadata as pattern pairs and
|
|
38
|
-
// silently produce garbage patterns.
|
|
39
6
|
|
|
40
7
|
|
|
41
8
|
// Report a problem against the definition it belongs to.
|
|
@@ -55,10 +22,6 @@ function isMsgDef(val: any): boolean {
|
|
|
55
22
|
}
|
|
56
23
|
|
|
57
24
|
|
|
58
|
-
// Sort in UTF-8 byte order, matching Go's sort.Strings, so both
|
|
59
|
-
// implementations report the same problems in the same order. The default JS
|
|
60
|
-
// string sort compares UTF-16 code units, which disagrees for astral-plane
|
|
61
|
-
// names (see the model producer's jsonify, which sorts keys the same way).
|
|
62
25
|
function sortNames(names: string[]): string[] {
|
|
63
26
|
return names.sort((a, b) => Buffer.compare(Buffer.from(a), Buffer.from(b)))
|
|
64
27
|
}
|
|
@@ -109,17 +72,6 @@ function checkMsgList(msg: any[]): string[] {
|
|
|
109
72
|
continue
|
|
110
73
|
}
|
|
111
74
|
|
|
112
|
-
// Reduce the pattern to its pairs, stopping at the first malformed one -
|
|
113
|
-
// the rest of the checks read the pairs, so there is nothing further to
|
|
114
|
-
// say about this message until its pattern is well-formed.
|
|
115
|
-
//
|
|
116
|
-
// Two renderings: `pairs` reads well in a message, and `canon` identifies
|
|
117
|
-
// the pattern. They cannot be the same string, because `key:value` joined
|
|
118
|
-
// by commas is ambiguous once a key or value contains a delimiter -
|
|
119
|
-
// [{a: "b,c:d"}] and [{a: b}, {c: d}] would both render `a:b,c:d` and the
|
|
120
|
-
// second would be rejected as a duplicate of the first. Quoting each part
|
|
121
|
-
// removes the ambiguity: a delimiter inside a part is escaped, so only
|
|
122
|
-
// genuinely equal patterns produce equal keys.
|
|
123
75
|
const pairs: string[] = []
|
|
124
76
|
const canon: string[] = []
|
|
125
77
|
let wellFormed = true
|
|
@@ -173,11 +125,6 @@ function checkMsgList(msg: any[]): string[] {
|
|
|
173
125
|
}
|
|
174
126
|
|
|
175
127
|
|
|
176
|
-
// The legacy chain. Nothing to validate in the chain itself - it has been
|
|
177
|
-
// valid by construction since before this producer existed - but a definition
|
|
178
|
-
// found among its nodes is reported rather than walked: the nested walk reads
|
|
179
|
-
// two levels at a time, so it would take the definition's metadata keys for
|
|
180
|
-
// pattern pairs and emit patterns nobody declared.
|
|
181
128
|
function checkMsgChain(msg: any): string[] {
|
|
182
129
|
const problems: string[] = []
|
|
183
130
|
|
|
@@ -193,16 +140,6 @@ function checkMsgChain(msg: any): string[] {
|
|
|
193
140
|
}
|
|
194
141
|
|
|
195
142
|
|
|
196
|
-
// Checks the message declarations before anything is written.
|
|
197
|
-
//
|
|
198
|
-
// This runs in BOTH phases, and must: a `pre` action can rewrite model source
|
|
199
|
-
// and request a reload, and the build re-resolves the model AFTER the pre
|
|
200
|
-
// phase has finished (see BuildImpl.run). A pre-only check would then have
|
|
201
|
-
// validated a model that no longer exists, and the model producer would write
|
|
202
|
-
// the regenerated one unchecked. Checking again in post closes that window -
|
|
203
|
-
// this producer is first in the pipeline, so it still runs ahead of the model
|
|
204
|
-
// producer, and a build whose model went bad during a reload fails with
|
|
205
|
-
// nothing written.
|
|
206
143
|
const msg_producer: Producer = async (build: Build, ctx: BuildContext) => {
|
|
207
144
|
const pr: ProducerResult = {
|
|
208
145
|
ok: true,
|
package/src/types.ts
CHANGED
|
@@ -131,9 +131,6 @@ interface ModelSpec {
|
|
|
131
131
|
dryrun?: boolean
|
|
132
132
|
buildargs?: any
|
|
133
133
|
fs?: any
|
|
134
|
-
// Resolve a .model-config/model-config.aon (auto-created when missing)
|
|
135
|
-
// that declares the build actions and their order. Defaults to true; set
|
|
136
|
-
// false to skip the config entirely and run the model on its own.
|
|
137
134
|
config?: boolean
|
|
138
135
|
watch?: {
|
|
139
136
|
mod?: boolean // file modification
|
package/src/watch.ts
CHANGED
|
@@ -17,6 +17,7 @@ import type {
|
|
|
17
17
|
import { makeBuild } from './build'
|
|
18
18
|
import { FSWatcher } from 'chokidar'
|
|
19
19
|
|
|
20
|
+
import { existsSync } from 'node:fs'
|
|
20
21
|
import { stat } from 'fs/promises'
|
|
21
22
|
|
|
22
23
|
|
|
@@ -108,7 +109,6 @@ class Watch {
|
|
|
108
109
|
|
|
109
110
|
// Check if there have been no recent changes, if so, run build.
|
|
110
111
|
this.intervalId = setInterval(() => {
|
|
111
|
-
// const start = this.startTime
|
|
112
112
|
const now = Date.now()
|
|
113
113
|
const idleDuration = now - this.lastChange.when
|
|
114
114
|
|
|
@@ -117,9 +117,6 @@ class Watch {
|
|
|
117
117
|
// this.lastChange.path !== this.lastTrigger.path
|
|
118
118
|
|
|
119
119
|
if (trigger) {
|
|
120
|
-
// Only add to build queue if we've been idle.
|
|
121
|
-
// This allows external compilation outputting multiple files to complete fully.
|
|
122
|
-
// IMPORTANT: always trigger a new build if there were changes *inside* a build period
|
|
123
120
|
if (this.idle < idleDuration) {
|
|
124
121
|
this.lastTrigger.path = this.lastChange.path
|
|
125
122
|
this.lastTrigger.when = this.lastChange.when
|
|
@@ -216,9 +213,10 @@ class Watch {
|
|
|
216
213
|
files.push(...Object.keys(build.deps[target]))
|
|
217
214
|
}
|
|
218
215
|
|
|
219
|
-
// TODO: remove deleted files
|
|
220
216
|
for (const file of files) {
|
|
221
|
-
|
|
217
|
+
// A dry run's in-memory config is not on disk to be watched.
|
|
218
|
+
if ('string' === typeof file && '' !== file && build.opts.base !== file &&
|
|
219
|
+
existsSync(file)) {
|
|
222
220
|
await this.add(file)
|
|
223
221
|
}
|
|
224
222
|
}
|
|
File without changes
|