@voxgig/model 3.4.0 → 4.0.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/lib/config.d.ts +1 -1
- package/dist/lib/config.js +1 -1
- package/dist/lib/config.js.map +1 -1
- package/dist/lib/watch.d.ts +14 -4
- package/dist/lib/watch.js +79 -47
- package/dist/lib/watch.js.map +1 -1
- package/dist/model.d.ts +1 -1
- package/dist/model.js +2 -1
- package/dist/model.js.map +1 -1
- package/lib/config.ts +1 -1
- package/lib/watch.ts +109 -55
- package/model.ts +4 -2
- package/package.json +3 -3
package/dist/lib/config.d.ts
CHANGED
package/dist/lib/config.js
CHANGED
package/dist/lib/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../lib/config.ts"],"names":[],"mappings":";AAAA,oDAAoD;;;AAKpD,mCAA+B;AAS/B,MAAM,MAAM;IAIV,YAAY,IAAU;QACpB,IAAI,CAAC,KAAK,GAAG;YACX,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,GAAG,EAAE;gBACH,GAAG,CAAC,IAAI,CAAC,GAAG,IAAI,EAAE,CAAC;aACpB;YACD,OAAO,EAAE,IAAI,CAAC,OAAO;SACtB,CAAA;QAED,IAAI,CAAC,KAAK,GAAG,IAAI,aAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IACpC,CAAC;IAED,KAAK,CAAC,GAAG;QACP,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../lib/config.ts"],"names":[],"mappings":";AAAA,oDAAoD;;;AAKpD,mCAA+B;AAS/B,MAAM,MAAM;IAIV,YAAY,IAAU;QACpB,IAAI,CAAC,KAAK,GAAG;YACX,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,GAAG,EAAE;gBACH,GAAG,CAAC,IAAI,CAAC,GAAG,IAAI,EAAE,CAAC;aACpB;YACD,OAAO,EAAE,IAAI,CAAC,OAAO;SACtB,CAAA;QAED,IAAI,CAAC,KAAK,GAAG,IAAI,aAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IACpC,CAAC;IAED,KAAK,CAAC,GAAG;QACP,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,UAAU,CAAC,CAAA;IACzC,CAAC;IAED,KAAK,CAAC,KAAK;QACT,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAA;IAC3B,CAAC;IAED,KAAK,CAAC,IAAI;QACR,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAA;IAC1B,CAAC;CACF;AAGQ,wBAAM"}
|
package/dist/lib/watch.d.ts
CHANGED
|
@@ -11,23 +11,33 @@ type Canon = {
|
|
|
11
11
|
isFolder: boolean;
|
|
12
12
|
when: number;
|
|
13
13
|
};
|
|
14
|
+
type ChangeItem = {
|
|
15
|
+
path: string;
|
|
16
|
+
when: number;
|
|
17
|
+
};
|
|
14
18
|
declare class Watch {
|
|
15
19
|
fsw: FSWatcher;
|
|
16
20
|
spec: any;
|
|
17
21
|
last?: BuildResult;
|
|
18
|
-
|
|
22
|
+
lastChangeTime: number;
|
|
19
23
|
build: Build | undefined;
|
|
20
24
|
runq: Run[];
|
|
21
25
|
doneq: Run[];
|
|
22
26
|
canons: Canon[];
|
|
27
|
+
lastrun: Run | undefined;
|
|
28
|
+
idle: number;
|
|
29
|
+
startTime: number;
|
|
23
30
|
running: boolean;
|
|
31
|
+
lastChange: ChangeItem;
|
|
32
|
+
lastTrigger: ChangeItem;
|
|
24
33
|
constructor(spec: any);
|
|
34
|
+
start(): void;
|
|
35
|
+
canon(path: string): string;
|
|
36
|
+
handleChange(path: string): void;
|
|
25
37
|
drain(): Promise<void>;
|
|
26
38
|
add(path: string): Promise<void>;
|
|
27
|
-
canon(path: string): string;
|
|
28
39
|
update(br: BuildResult): Promise<void>;
|
|
29
|
-
|
|
30
|
-
run(once?: boolean): Promise<BuildResult>;
|
|
40
|
+
run(once?: boolean, trigger?: string): Promise<BuildResult>;
|
|
31
41
|
stop(): Promise<void>;
|
|
32
42
|
handleErrors(br: BuildResult): void;
|
|
33
43
|
descDeps(deps: Record<string, Record<string, {
|
package/dist/lib/watch.js
CHANGED
|
@@ -15,49 +15,92 @@ class Watch {
|
|
|
15
15
|
constructor(spec) {
|
|
16
16
|
this.spec = spec;
|
|
17
17
|
this.fsw = new chokidar_1.FSWatcher();
|
|
18
|
-
this.
|
|
18
|
+
this.lastChangeTime = 0;
|
|
19
19
|
this.runq = [];
|
|
20
20
|
this.doneq = [];
|
|
21
21
|
this.canons = [];
|
|
22
|
+
this.startTime = 0;
|
|
23
|
+
this.lastChange = { path: '', when: 0 };
|
|
24
|
+
this.lastTrigger = { path: '', when: 0 };
|
|
22
25
|
this.running = false;
|
|
23
|
-
|
|
24
|
-
|
|
26
|
+
this.lastrun = undefined;
|
|
27
|
+
this.idle = spec.idle || 111;
|
|
25
28
|
this.fsw.on('change', async (path) => {
|
|
26
|
-
//
|
|
27
|
-
|
|
28
|
-
// Avoid rebuilding when, for example, TS rewrites all files in dist
|
|
29
|
-
// const dorun = 1111 < Date.now() - this.last_change_time
|
|
30
|
-
// console.log('CHANGE', dorun, this.last_change_time, args)
|
|
31
|
-
const canon = this.canon(path);
|
|
32
|
-
const running = this.runq.find((run) => run.canon === canon);
|
|
33
|
-
if (running) {
|
|
34
|
-
// console.log('RUNNING', canon, path)
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
this.runq.push({
|
|
38
|
-
canon,
|
|
39
|
-
path,
|
|
40
|
-
start: Date.now(),
|
|
41
|
-
end: -1,
|
|
42
|
-
});
|
|
43
|
-
// console.log('RUNQ-ADD', this.runq)
|
|
44
|
-
setImmediate(drain);
|
|
29
|
+
// console.log('CHANGE', Date.now() - this.startTime, path)
|
|
30
|
+
this.handleChange(path);
|
|
45
31
|
});
|
|
46
32
|
}
|
|
33
|
+
// Returns first BuildResult
|
|
34
|
+
start() {
|
|
35
|
+
this.startTime = Date.now();
|
|
36
|
+
this.handleChange('<start>');
|
|
37
|
+
// Check if there have been no recent changes, if so, run build.
|
|
38
|
+
setInterval(() => {
|
|
39
|
+
const start = this.startTime;
|
|
40
|
+
const now = Date.now();
|
|
41
|
+
const idleDuration = now - this.lastChange.when;
|
|
42
|
+
// Only trigger a build if there was a actual change
|
|
43
|
+
const trigger = this.lastChange.when !== this.lastTrigger.when &&
|
|
44
|
+
this.lastChange.path !== this.lastTrigger.path;
|
|
45
|
+
// console.log('CHECK-A', {
|
|
46
|
+
// tick: (now - start),
|
|
47
|
+
// idleDuration,
|
|
48
|
+
// trigger,
|
|
49
|
+
// running: this.running,
|
|
50
|
+
// path: this.lastChange.path
|
|
51
|
+
// })
|
|
52
|
+
if (trigger) {
|
|
53
|
+
// Only add to build queue if we've been idle.
|
|
54
|
+
// This allows external compilation outputting multiple files to complete fully.
|
|
55
|
+
// IMPORTANT: always trigger a new build if there were changes *inside* a build period
|
|
56
|
+
if (this.idle < idleDuration) {
|
|
57
|
+
this.lastTrigger.path = this.lastChange.path;
|
|
58
|
+
this.lastTrigger.when = this.lastChange.when;
|
|
59
|
+
const path = this.lastChange.path;
|
|
60
|
+
const canon = this.canon(path);
|
|
61
|
+
this.runq.push({
|
|
62
|
+
canon,
|
|
63
|
+
path,
|
|
64
|
+
start: now,
|
|
65
|
+
end: -1,
|
|
66
|
+
});
|
|
67
|
+
// Defer builds to the event loop to keep idle checking separate.
|
|
68
|
+
setImmediate(this.drain.bind(this));
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}, (this.idle * 1.1 / 2) | 0);
|
|
72
|
+
}
|
|
73
|
+
// If path is inside a watched folder, return folder as canonical reference.
|
|
74
|
+
canon(path) {
|
|
75
|
+
for (const canon of this.canons) {
|
|
76
|
+
if (canon.isFolder && path.startsWith(canon.path)) {
|
|
77
|
+
return canon.path;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return path;
|
|
81
|
+
}
|
|
82
|
+
handleChange(path) {
|
|
83
|
+
// Record most recent (last) changed path and time
|
|
84
|
+
this.lastChange.path = path;
|
|
85
|
+
this.lastChange.when = Date.now();
|
|
86
|
+
}
|
|
47
87
|
async drain() {
|
|
88
|
+
// If already running, all items in queue will be drained from this.runq in the while loop
|
|
48
89
|
if (this.running) {
|
|
49
90
|
return;
|
|
50
91
|
}
|
|
51
92
|
this.running = true;
|
|
52
93
|
let r;
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
94
|
+
// While there are queued runs, run them sequentially
|
|
95
|
+
while (r = this.runq.shift()) {
|
|
96
|
+
// console.log('===DRAIN-RUN', this.runq.length, new Date(), r.start, r.canon)
|
|
97
|
+
// TODO: collect results and errors!!!
|
|
98
|
+
let br = await this.run(false, r.canon);
|
|
56
99
|
// console.log('BR', br)
|
|
57
|
-
this.runq.shift();
|
|
58
100
|
r.end = Date.now();
|
|
59
101
|
this.doneq.push(r);
|
|
60
|
-
|
|
102
|
+
this.lastrun = r;
|
|
103
|
+
// console.log('===DRAIN-DONE', this.runq.length, new Date(), r.start, r.canon)
|
|
61
104
|
}
|
|
62
105
|
this.running = false;
|
|
63
106
|
}
|
|
@@ -79,15 +122,6 @@ class Watch {
|
|
|
79
122
|
this.fsw.add(path);
|
|
80
123
|
// console.log('ADD', canon)
|
|
81
124
|
}
|
|
82
|
-
// If path is inside a watched folder, return folder as canonical reference.
|
|
83
|
-
canon(path) {
|
|
84
|
-
for (const canon of this.canons) {
|
|
85
|
-
if (canon.isFolder && path.startsWith(canon.path)) {
|
|
86
|
-
return canon.path;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
return path;
|
|
90
|
-
}
|
|
91
125
|
async update(br) {
|
|
92
126
|
let build = br.build;
|
|
93
127
|
let files = Object.keys(build.root.deps).reduce((files, target) => {
|
|
@@ -103,15 +137,12 @@ class Watch {
|
|
|
103
137
|
}
|
|
104
138
|
});
|
|
105
139
|
}
|
|
106
|
-
|
|
107
|
-
async start() {
|
|
108
|
-
return await this.run(false);
|
|
109
|
-
}
|
|
110
|
-
async run(once) {
|
|
140
|
+
async run(once, trigger) {
|
|
111
141
|
// console.trace()
|
|
112
142
|
var _a, _b;
|
|
113
|
-
this.
|
|
114
|
-
print('\n@voxgig/model', new Date(this.
|
|
143
|
+
this.lastChangeTime = Date.now();
|
|
144
|
+
print('\n@voxgig/model =================', this.lastChangeTime, new Date(this.lastChangeTime));
|
|
145
|
+
print('TRIGGER:', trigger, '\n');
|
|
115
146
|
// TODO: build spec should not have src!
|
|
116
147
|
let src = (await (0, promises_1.readFile)(this.spec.path)).toString();
|
|
117
148
|
this.spec.src = src;
|
|
@@ -140,12 +171,13 @@ class Watch {
|
|
|
140
171
|
handleErrors(br) {
|
|
141
172
|
if (br.err) {
|
|
142
173
|
for (let be of br.err) {
|
|
143
|
-
if
|
|
174
|
+
// TODO: print stack if not a model error
|
|
175
|
+
if (be.isVal && be.msg) {
|
|
144
176
|
warn(be.msg);
|
|
145
177
|
}
|
|
146
|
-
else if (be.message) {
|
|
147
|
-
|
|
148
|
-
}
|
|
178
|
+
// else if (be.message) {
|
|
179
|
+
// warn(be.message)
|
|
180
|
+
// }
|
|
149
181
|
else {
|
|
150
182
|
warn(be);
|
|
151
183
|
}
|
package/dist/lib/watch.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"watch.js","sourceRoot":"","sources":["../../lib/watch.ts"],"names":[],"mappings":";AAAA,oDAAoD;;;;;;AAEpD,0DAA4B;AAK5B,mCAAmC;AACnC,uCAAoC;AAEpC,0CAA4C;AAG5C,MAAM,KAAK,GAAG,OAAO,CAAC,G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xC,IAAI,CAAC,IAAI,CAAC,IAAI,GAAG,SAAS,CAAC,CAAA;YAC3B,KAAK,IAAI,OAAO,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC;gBACjD,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,CAAA;YAC7B,CAAC;QACH,CAAC;QACD,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACxB,CAAC;CACF;AAIC,sBAAK"}
|
package/dist/model.d.ts
CHANGED
package/dist/model.js
CHANGED
|
@@ -71,7 +71,8 @@ class Model {
|
|
|
71
71
|
}
|
|
72
72
|
async start() {
|
|
73
73
|
this.trigger_model = false;
|
|
74
|
-
const br = await this.config.
|
|
74
|
+
const br = await this.config.run();
|
|
75
|
+
// console.log('MODEL CONFIG START', br.ok)
|
|
75
76
|
return br.ok ? this.watch.start() : br;
|
|
76
77
|
}
|
|
77
78
|
async stop() {
|
package/dist/model.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.js","sourceRoot":"","sources":["../model.ts"],"names":[],"mappings":";AAAA,oDAAoD;;;;;;AAEpD,6BAA6B;AAC7B,4CAAmB;AAMnB,yCAAqC;AACrC,uCAAmC;AAEnC,+CAAmD;AACnD,+CAAmD;AAGnD,MAAM,KAAK;IAQT,YAAY,IAAU;QAHtB,kBAAa,GAAG,KAAK,CAAA;QAInB,MAAM,IAAI,GAAG,IAAI,CAAA;QAEjB,oDAAoD;QACpD,IAAI,CAAC,MAAM,GAAG,UAAU,CAAC,IAAI,EAAE;YAC7B,IAAI,EAAE,GAAG;YACT,KAAK,EAAE,KAAK,UAAU,aAAa,CAAC,KAAY,EAAE,GAAiB;;gBACjE,IAAI,MAAM,KAAK,GAAG,CAAC,IAAI,EAAE,CAAC;oBACxB,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,CAAA;gBACrB,CAAC;gBAED,IAAI,GAAG,CAA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|
+
when: number
|
|
35
|
+
}
|
|
36
|
+
|
|
31
37
|
class Watch {
|
|
32
38
|
fsw: FSWatcher
|
|
33
39
|
spec: any
|
|
34
40
|
last?: BuildResult
|
|
35
|
-
|
|
41
|
+
lastChangeTime: number
|
|
36
42
|
build: Build | undefined
|
|
37
43
|
runq: Run[]
|
|
38
44
|
doneq: Run[]
|
|
39
45
|
canons: Canon[]
|
|
46
|
+
lastrun: Run | undefined
|
|
47
|
+
idle: number
|
|
48
|
+
startTime: number
|
|
40
49
|
running: boolean
|
|
50
|
+
lastChange: ChangeItem
|
|
51
|
+
lastTrigger: ChangeItem
|
|
41
52
|
|
|
42
53
|
constructor(spec: any) {
|
|
43
54
|
this.spec = spec
|
|
44
55
|
this.fsw = new FSWatcher()
|
|
45
|
-
this.
|
|
56
|
+
this.lastChangeTime = 0
|
|
46
57
|
this.runq = []
|
|
47
58
|
this.doneq = []
|
|
48
59
|
this.canons = []
|
|
60
|
+
this.startTime = 0
|
|
61
|
+
this.lastChange = { path: '', when: 0 }
|
|
62
|
+
this.lastTrigger = { path: '', when: 0 }
|
|
49
63
|
this.running = false
|
|
64
|
+
this.lastrun = undefined
|
|
50
65
|
|
|
51
|
-
|
|
52
|
-
const drain = this.drain.bind(this)
|
|
66
|
+
this.idle = spec.idle || 111
|
|
53
67
|
|
|
54
68
|
this.fsw.on('change', async (path: string) => {
|
|
55
|
-
//
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
69
|
+
// console.log('CHANGE', Date.now() - this.startTime, path)
|
|
70
|
+
this.handleChange(path)
|
|
71
|
+
})
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
// Returns first BuildResult
|
|
76
|
+
start() {
|
|
77
|
+
this.startTime = Date.now()
|
|
78
|
+
this.handleChange('<start>')
|
|
79
|
+
|
|
80
|
+
// Check if there have been no recent changes, if so, run build.
|
|
81
|
+
setInterval(() => {
|
|
82
|
+
const start = this.startTime
|
|
83
|
+
const now = Date.now()
|
|
84
|
+
const idleDuration = now - this.lastChange.when
|
|
85
|
+
|
|
86
|
+
// Only trigger a build if there was a actual change
|
|
87
|
+
const trigger = this.lastChange.when !== this.lastTrigger.when &&
|
|
88
|
+
this.lastChange.path !== this.lastTrigger.path
|
|
89
|
+
|
|
90
|
+
// console.log('CHECK-A', {
|
|
91
|
+
// tick: (now - start),
|
|
92
|
+
// idleDuration,
|
|
93
|
+
// trigger,
|
|
94
|
+
// running: this.running,
|
|
95
|
+
// path: this.lastChange.path
|
|
96
|
+
// })
|
|
97
|
+
|
|
98
|
+
if (trigger) {
|
|
99
|
+
|
|
100
|
+
// Only add to build queue if we've been idle.
|
|
101
|
+
// This allows external compilation outputting multiple files to complete fully.
|
|
102
|
+
// IMPORTANT: always trigger a new build if there were changes *inside* a build period
|
|
103
|
+
if (this.idle < idleDuration) {
|
|
104
|
+
this.lastTrigger.path = this.lastChange.path
|
|
105
|
+
this.lastTrigger.when = this.lastChange.when
|
|
106
|
+
|
|
107
|
+
const path = this.lastChange.path
|
|
108
|
+
const canon = this.canon(path)
|
|
109
|
+
|
|
110
|
+
this.runq.push({
|
|
111
|
+
canon,
|
|
112
|
+
path,
|
|
113
|
+
start: now,
|
|
114
|
+
end: -1,
|
|
115
|
+
})
|
|
116
|
+
|
|
117
|
+
// Defer builds to the event loop to keep idle checking separate.
|
|
118
|
+
setImmediate(this.drain.bind(this))
|
|
119
|
+
}
|
|
67
120
|
}
|
|
68
121
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
path,
|
|
72
|
-
start: Date.now(),
|
|
73
|
-
end: -1,
|
|
74
|
-
})
|
|
122
|
+
}, (this.idle * 1.1 / 2) | 0)
|
|
123
|
+
}
|
|
75
124
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
125
|
+
|
|
126
|
+
// If path is inside a watched folder, return folder as canonical reference.
|
|
127
|
+
canon(path: string) {
|
|
128
|
+
for (const canon of this.canons) {
|
|
129
|
+
if (canon.isFolder && path.startsWith(canon.path)) {
|
|
130
|
+
return canon.path
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
return path
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
handleChange(path: string) {
|
|
138
|
+
// Record most recent (last) changed path and time
|
|
139
|
+
this.lastChange.path = path
|
|
140
|
+
this.lastChange.when = Date.now()
|
|
79
141
|
}
|
|
80
142
|
|
|
81
143
|
|
|
82
144
|
async drain() {
|
|
145
|
+
// If already running, all items in queue will be drained from this.runq in the while loop
|
|
83
146
|
if (this.running) {
|
|
84
147
|
return
|
|
85
148
|
}
|
|
86
149
|
|
|
87
150
|
this.running = true
|
|
88
|
-
let r
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
151
|
+
let r: Run | undefined
|
|
152
|
+
|
|
153
|
+
// While there are queued runs, run them sequentially
|
|
154
|
+
while (r = this.runq.shift()) {
|
|
155
|
+
// console.log('===DRAIN-RUN', this.runq.length, new Date(), r.start, r.canon)
|
|
156
|
+
|
|
157
|
+
// TODO: collect results and errors!!!
|
|
158
|
+
let br = await this.run(false, r.canon)
|
|
92
159
|
// console.log('BR', br)
|
|
93
|
-
this.runq.shift()
|
|
94
|
-
r.end = Date.now()
|
|
95
160
|
|
|
161
|
+
r.end = Date.now()
|
|
96
162
|
this.doneq.push(r)
|
|
163
|
+
this.lastrun = r
|
|
97
164
|
|
|
98
|
-
// console.log('
|
|
165
|
+
// console.log('===DRAIN-DONE', this.runq.length, new Date(), r.start, r.canon)
|
|
99
166
|
}
|
|
100
167
|
this.running = false
|
|
101
168
|
}
|
|
@@ -126,17 +193,6 @@ class Watch {
|
|
|
126
193
|
}
|
|
127
194
|
|
|
128
195
|
|
|
129
|
-
// If path is inside a watched folder, return folder as canonical reference.
|
|
130
|
-
canon(path: string) {
|
|
131
|
-
for (const canon of this.canons) {
|
|
132
|
-
if (canon.isFolder && path.startsWith(canon.path)) {
|
|
133
|
-
return canon.path
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
return path
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
|
|
140
196
|
async update(br: BuildResult) {
|
|
141
197
|
let build = (br.build as Build)
|
|
142
198
|
|
|
@@ -160,17 +216,13 @@ class Watch {
|
|
|
160
216
|
}
|
|
161
217
|
|
|
162
218
|
|
|
163
|
-
// Returns first BuildResult
|
|
164
|
-
async start(): Promise<BuildResult> {
|
|
165
|
-
return await this.run(false)
|
|
166
|
-
}
|
|
167
|
-
|
|
168
219
|
|
|
169
|
-
async run(once?: boolean): Promise<BuildResult> {
|
|
220
|
+
async run(once?: boolean, trigger?: string): Promise<BuildResult> {
|
|
170
221
|
// console.trace()
|
|
171
222
|
|
|
172
|
-
this.
|
|
173
|
-
print('\n@voxgig/model', new Date(this.
|
|
223
|
+
this.lastChangeTime = Date.now()
|
|
224
|
+
print('\n@voxgig/model =================', this.lastChangeTime, new Date(this.lastChangeTime))
|
|
225
|
+
print('TRIGGER:', trigger, '\n')
|
|
174
226
|
|
|
175
227
|
// TODO: build spec should not have src!
|
|
176
228
|
let src = (await readFile(this.spec.path)).toString()
|
|
@@ -212,12 +264,14 @@ class Watch {
|
|
|
212
264
|
handleErrors(br: BuildResult) {
|
|
213
265
|
if (br.err) {
|
|
214
266
|
for (let be of br.err) {
|
|
215
|
-
if
|
|
267
|
+
// TODO: print stack if not a model error
|
|
268
|
+
|
|
269
|
+
if (be.isVal && be.msg) {
|
|
216
270
|
warn(be.msg)
|
|
217
271
|
}
|
|
218
|
-
else if (be.message) {
|
|
219
|
-
|
|
220
|
-
}
|
|
272
|
+
// else if (be.message) {
|
|
273
|
+
// warn(be.message)
|
|
274
|
+
// }
|
|
221
275
|
else {
|
|
222
276
|
warn(be)
|
|
223
277
|
}
|
package/model.ts
CHANGED
|
@@ -94,9 +94,11 @@ class Model {
|
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
|
|
97
|
-
async start()
|
|
97
|
+
async start() {
|
|
98
98
|
this.trigger_model = false
|
|
99
|
-
|
|
99
|
+
|
|
100
|
+
const br = await this.config.run()
|
|
101
|
+
// console.log('MODEL CONFIG START', br.ok)
|
|
100
102
|
return br.ok ? this.watch.start() : br
|
|
101
103
|
}
|
|
102
104
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@voxgig/model",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"main": "dist/model.js",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"types": "dist/model.d.ts",
|
|
@@ -50,11 +50,11 @@
|
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@types/jest": "^29.5.13",
|
|
53
|
-
"@types/node": "22.
|
|
53
|
+
"@types/node": "22.7.6",
|
|
54
54
|
"es-jest": "^2.1.0",
|
|
55
55
|
"esbuild": "^0.24.0",
|
|
56
56
|
"esbuild-jest": "^0.5.0",
|
|
57
57
|
"jest": "^29.7.0",
|
|
58
|
-
"typescript": "^5.6.
|
|
58
|
+
"typescript": "^5.6.3"
|
|
59
59
|
}
|
|
60
60
|
}
|