@jointhedots/gear 1.1.15 → 1.1.17
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/browser-modules/asap-raw.js +1 -1
- package/browser-modules/process.js +1 -1
- package/browser-modules/side-effects.js +211 -2
- package/esm/builder/build-target.js +7 -7
- package/esm/builder/helpers/emit-esmodules.js +14 -7
- package/esm/model/component.js +1 -1
- package/esm/model/helpers/discover-workspace.js +4 -0
- package/esm/model/storage.js +5 -7
- package/package.json +1 -1
- package/schemas/component.schema.json +1 -1
|
@@ -38,7 +38,7 @@ function flush() {
|
|
|
38
38
|
flushing = false;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
var scope = typeof globalThis !== "undefined" ? globalThis : (typeof self !== "undefined" ? self :
|
|
41
|
+
var scope = typeof globalThis !== "undefined" ? globalThis : (typeof self !== "undefined" ? self : globalThis);
|
|
42
42
|
var BrowserMutationObserver = scope.MutationObserver || scope.WebKitMutationObserver;
|
|
43
43
|
|
|
44
44
|
if (typeof BrowserMutationObserver === "function") {
|
|
@@ -4,5 +4,214 @@
|
|
|
4
4
|
import './process.js'
|
|
5
5
|
import './buffer.js'
|
|
6
6
|
|
|
7
|
-
//
|
|
8
|
-
|
|
7
|
+
// Add Node.js-specific API to W3C ReadableStream
|
|
8
|
+
{
|
|
9
|
+
const proto = ReadableStream.prototype
|
|
10
|
+
|
|
11
|
+
// Start consuming the stream, emitting 'data'/'end'/'error'/'close' events
|
|
12
|
+
function _startReading(stream) {
|
|
13
|
+
if (stream._reading) return
|
|
14
|
+
stream._reading = true
|
|
15
|
+
stream._paused = false
|
|
16
|
+
const reader = stream.getReader()
|
|
17
|
+
const pump = () => reader.read().then(({ done, value }) => {
|
|
18
|
+
if (done) {
|
|
19
|
+
stream._reading = false
|
|
20
|
+
stream._emit('end')
|
|
21
|
+
stream._emit('close')
|
|
22
|
+
return
|
|
23
|
+
}
|
|
24
|
+
stream._emit('data', value)
|
|
25
|
+
if (!stream._paused) return pump()
|
|
26
|
+
stream._pump = pump
|
|
27
|
+
}).catch(err => {
|
|
28
|
+
stream._reading = false
|
|
29
|
+
stream._emit('error', err)
|
|
30
|
+
})
|
|
31
|
+
pump()
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
proto._emit = function (event, ...args) {
|
|
35
|
+
this._listeners?.[event]?.slice().forEach(fn => fn(...args))
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
proto.on = proto.addListener = function (event, fn) {
|
|
39
|
+
this._listeners ??= {}
|
|
40
|
+
; (this._listeners[event] ??= []).push(fn)
|
|
41
|
+
if (event === 'data') _startReading(this)
|
|
42
|
+
return this
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
proto.once = function (event, fn) {
|
|
46
|
+
const wrapped = (...args) => { this.off(event, wrapped); fn(...args) }
|
|
47
|
+
return this.on(event, wrapped)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
proto.off = proto.removeListener = function (event, fn) {
|
|
51
|
+
const list = this._listeners?.[event]
|
|
52
|
+
if (list) { const i = list.indexOf(fn); if (i >= 0) list.splice(i, 1) }
|
|
53
|
+
return this
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
proto.pipe = function (dest) {
|
|
57
|
+
this.on('data', chunk => dest.write?.(chunk))
|
|
58
|
+
this.once('end', () => dest.end?.())
|
|
59
|
+
this.once('error', err => dest.destroy?.(err))
|
|
60
|
+
return dest
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
proto.pause = function () {
|
|
64
|
+
this._paused = true
|
|
65
|
+
return this
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
proto.resume = function () {
|
|
69
|
+
this._paused = false
|
|
70
|
+
this._pump?.()
|
|
71
|
+
return this
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
proto.destroy = function (err) {
|
|
75
|
+
if (err) this._emit('error', err)
|
|
76
|
+
this._emit('close')
|
|
77
|
+
this.cancel(err).catch(() => { })
|
|
78
|
+
return this
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
proto.unpipe = function (dest) {
|
|
82
|
+
this._listeners = {}
|
|
83
|
+
return this
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// Add Node.js-specific API to W3C WritableStream
|
|
88
|
+
{
|
|
89
|
+
const proto = WritableStream.prototype
|
|
90
|
+
|
|
91
|
+
proto._emit = function (event, ...args) {
|
|
92
|
+
this._listeners?.[event]?.slice().forEach(fn => fn(...args))
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
proto.on = proto.addListener = function (event, fn) {
|
|
96
|
+
this._listeners ??= {}
|
|
97
|
+
; (this._listeners[event] ??= []).push(fn)
|
|
98
|
+
return this
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
proto.once = function (event, fn) {
|
|
102
|
+
const wrapped = (...args) => { this.off(event, wrapped); fn(...args) }
|
|
103
|
+
return this.on(event, wrapped)
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
proto.off = proto.removeListener = function (event, fn) {
|
|
107
|
+
const list = this._listeners?.[event]
|
|
108
|
+
if (list) { const i = list.indexOf(fn); if (i >= 0) list.splice(i, 1) }
|
|
109
|
+
return this
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
proto._getWriter = function () {
|
|
113
|
+
if (!this._writer) this._writer = this.getWriter()
|
|
114
|
+
return this._writer
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
proto.write = function (chunk, encoding, callback) {
|
|
118
|
+
if (typeof encoding === 'function') { callback = encoding; encoding = undefined }
|
|
119
|
+
const writer = this._getWriter()
|
|
120
|
+
writer.ready.then(() => writer.write(chunk)).then(
|
|
121
|
+
() => { this._emit('drain'); callback?.() },
|
|
122
|
+
err => { this._emit('error', err); callback?.(err) }
|
|
123
|
+
)
|
|
124
|
+
return true
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
proto.end = function (chunk, encoding, callback) {
|
|
128
|
+
if (typeof chunk === 'function') { callback = chunk; chunk = null }
|
|
129
|
+
else if (typeof encoding === 'function') { callback = encoding; encoding = null }
|
|
130
|
+
const writer = this._getWriter()
|
|
131
|
+
const finish = () => writer.close().then(
|
|
132
|
+
() => { this._emit('finish'); this._emit('close'); callback?.() },
|
|
133
|
+
err => { this._emit('error', err); callback?.(err) }
|
|
134
|
+
)
|
|
135
|
+
if (chunk != null) {
|
|
136
|
+
writer.ready.then(() => writer.write(chunk)).then(finish, finish)
|
|
137
|
+
} else {
|
|
138
|
+
finish()
|
|
139
|
+
}
|
|
140
|
+
return this
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
proto.destroy = function (err) {
|
|
144
|
+
const writer = this._getWriter()
|
|
145
|
+
if (err) {
|
|
146
|
+
writer.abort(err).catch(() => { })
|
|
147
|
+
this._emit('error', err)
|
|
148
|
+
} else {
|
|
149
|
+
writer.close().catch(() => { })
|
|
150
|
+
}
|
|
151
|
+
this._emit('close')
|
|
152
|
+
return this
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
proto.cork = function () { this._corked = (this._corked || 0) + 1 }
|
|
156
|
+
proto.uncork = function () { if (this._corked > 0) this._corked-- }
|
|
157
|
+
|
|
158
|
+
proto.setDefaultEncoding = function (encoding) {
|
|
159
|
+
this._defaultEncoding = encoding
|
|
160
|
+
return this
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// Add Node.js-specific API to W3C TransformStream
|
|
165
|
+
{
|
|
166
|
+
const proto = TransformStream.prototype
|
|
167
|
+
|
|
168
|
+
proto._emit = function (event, ...args) {
|
|
169
|
+
this._listeners?.[event]?.slice().forEach(fn => fn(...args))
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
proto.on = proto.addListener = function (event, fn) {
|
|
173
|
+
this._listeners ??= {}
|
|
174
|
+
; (this._listeners[event] ??= []).push(fn)
|
|
175
|
+
if (event === 'data') this.readable.on('data', chunk => this._emit('data', chunk))
|
|
176
|
+
return this
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
proto.once = function (event, fn) {
|
|
180
|
+
const wrapped = (...args) => { this.off(event, wrapped); fn(...args) }
|
|
181
|
+
return this.on(event, wrapped)
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
proto.off = proto.removeListener = function (event, fn) {
|
|
185
|
+
const list = this._listeners?.[event]
|
|
186
|
+
if (list) { const i = list.indexOf(fn); if (i >= 0) list.splice(i, 1) }
|
|
187
|
+
return this
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
proto.write = function (chunk, encoding, callback) {
|
|
191
|
+
return this.writable.write(chunk, encoding, callback)
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
proto.end = function (chunk, encoding, callback) {
|
|
195
|
+
return this.writable.end(chunk, encoding, callback)
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
proto.pipe = function (dest) {
|
|
199
|
+
return this.readable.pipe(dest)
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
proto.pause = function () {
|
|
203
|
+
this.readable.pause()
|
|
204
|
+
return this
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
proto.resume = function () {
|
|
208
|
+
this.readable.resume()
|
|
209
|
+
return this
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
proto.destroy = function (err) {
|
|
213
|
+
this.readable.destroy(err)
|
|
214
|
+
this.writable.destroy(err)
|
|
215
|
+
return this
|
|
216
|
+
}
|
|
217
|
+
}
|
|
@@ -30,9 +30,9 @@ export class BuildTarget {
|
|
|
30
30
|
this.transaction = this.storage.edit();
|
|
31
31
|
return this.transaction;
|
|
32
32
|
}
|
|
33
|
-
store() {
|
|
33
|
+
async store() {
|
|
34
34
|
if (this.transaction) {
|
|
35
|
-
this.transaction.accept();
|
|
35
|
+
await this.transaction.accept();
|
|
36
36
|
this.transaction = null;
|
|
37
37
|
}
|
|
38
38
|
}
|
|
@@ -47,10 +47,10 @@ export class BuildTarget {
|
|
|
47
47
|
publish: undefined,
|
|
48
48
|
entries: undefined,
|
|
49
49
|
};
|
|
50
|
-
if (descriptor.
|
|
51
|
-
manifest.
|
|
52
|
-
for (const name in descriptor.
|
|
53
|
-
manifest.
|
|
50
|
+
if (descriptor.apis) {
|
|
51
|
+
manifest.apis = {};
|
|
52
|
+
for (const name in descriptor.apis) {
|
|
53
|
+
manifest.apis[name] = this.esmodules.add_resource_entry(descriptor.apis[name], baseDir, library);
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
if (descriptor.resources) {
|
|
@@ -90,7 +90,7 @@ export class BuildTarget {
|
|
|
90
90
|
});
|
|
91
91
|
}
|
|
92
92
|
else {
|
|
93
|
-
this.store();
|
|
93
|
+
await this.store();
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
96
|
}
|
|
@@ -21,7 +21,7 @@ function getEsbuildLogLevel(mode) {
|
|
|
21
21
|
return "silent";
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
|
-
|
|
24
|
+
async function create_esbuild_context(task, devmode, onReady) {
|
|
25
25
|
const ws = task.target.workspace;
|
|
26
26
|
// Define modules mapping - using @jspm/core polyfills (same as Vite)
|
|
27
27
|
const jspmPolyfills = Path.resolve(PackageRootDir, "node_modules/@jspm/core/nodelibs/browser");
|
|
@@ -111,7 +111,7 @@ export async function create_esbuild_context(task, devmode) {
|
|
|
111
111
|
ESModuleResolverPlugin(modules_mapping, tsconfig),
|
|
112
112
|
...task.plugins,
|
|
113
113
|
StyleSheetPlugin(task),
|
|
114
|
-
StoragePlugin(task),
|
|
114
|
+
StoragePlugin(task, onReady),
|
|
115
115
|
],
|
|
116
116
|
loader: {
|
|
117
117
|
'.jpg': 'file',
|
|
@@ -255,7 +255,7 @@ function hasTailwindConfig(workspacePath) {
|
|
|
255
255
|
catch { }
|
|
256
256
|
return false;
|
|
257
257
|
}
|
|
258
|
-
export function StoragePlugin(task) {
|
|
258
|
+
export function StoragePlugin(task, onReady) {
|
|
259
259
|
return {
|
|
260
260
|
name: "dipatch-files",
|
|
261
261
|
setup: (build) => {
|
|
@@ -287,10 +287,14 @@ export function StoragePlugin(task) {
|
|
|
287
287
|
throw new Error(`Invalid output file: ${file.path}`);
|
|
288
288
|
}
|
|
289
289
|
}
|
|
290
|
-
task.target.store();
|
|
290
|
+
await task.target.store();
|
|
291
291
|
const storeTime = (Date.now() - storeStart) / 1000;
|
|
292
292
|
const buildTime = (Date.now() - buildStartTime) / 1000;
|
|
293
|
-
task.log.info(`
|
|
293
|
+
task.log.info(`Store ES graph in ${result.outputFiles.length} file(s) (compile: ${buildTime.toFixed(2)}s, store: ${storeTime.toFixed(2)}s)`);
|
|
294
|
+
}
|
|
295
|
+
if (onReady) {
|
|
296
|
+
onReady();
|
|
297
|
+
onReady = null;
|
|
294
298
|
}
|
|
295
299
|
return null;
|
|
296
300
|
});
|
|
@@ -602,11 +606,14 @@ export class ESModulesTask extends BuildTask {
|
|
|
602
606
|
await prev_ctx.dispose();
|
|
603
607
|
}
|
|
604
608
|
const { target } = this;
|
|
605
|
-
this.context = await create_esbuild_context(this, target.devmode);
|
|
606
609
|
if (target.watch) {
|
|
607
|
-
|
|
610
|
+
return new Promise(async (resolve, reject) => {
|
|
611
|
+
this.context = await create_esbuild_context(this, target.devmode, resolve);
|
|
612
|
+
await this.context.watch();
|
|
613
|
+
});
|
|
608
614
|
}
|
|
609
615
|
else {
|
|
616
|
+
this.context = await create_esbuild_context(this, target.devmode);
|
|
610
617
|
await this.context.rebuild();
|
|
611
618
|
await this.context.dispose();
|
|
612
619
|
}
|
package/esm/model/component.js
CHANGED
|
@@ -14,7 +14,7 @@ export function makeComponentPublication(manif) {
|
|
|
14
14
|
type: manif.type,
|
|
15
15
|
icon: manif.icon,
|
|
16
16
|
title: manif.title || manif.name || manif.$id,
|
|
17
|
-
services: manif.
|
|
17
|
+
services: manif.apis ? Object.keys(manif.apis) : [],
|
|
18
18
|
description: manif.description || "",
|
|
19
19
|
keywords: manif.keywords,
|
|
20
20
|
tags: manif.tags,
|
|
@@ -49,6 +49,10 @@ async function discover_component(lib, fpath) {
|
|
|
49
49
|
const err = checkComponentManifest(desc, fpath);
|
|
50
50
|
if (err)
|
|
51
51
|
throw err;
|
|
52
|
+
if (!desc.apis && desc["services"]) {
|
|
53
|
+
desc.apis = desc["services"]; // Migrate renaming 'services' -> 'apis'
|
|
54
|
+
lib.log.warn(`Component '${desc.$id}' manifest shall rename 'services' -> 'apis'`);
|
|
55
|
+
}
|
|
52
56
|
bundle.components.set(fpath, desc);
|
|
53
57
|
lib.log.info(`+ 🧩 component: ${desc.$id} ${desc.type ? `(${desc.type})` : ""}`);
|
|
54
58
|
return true;
|
package/esm/model/storage.js
CHANGED
|
@@ -50,24 +50,22 @@ export class StorageTransaction {
|
|
|
50
50
|
const hash = createContentCID(contentData);
|
|
51
51
|
this.pending.set(fpath, { data: contentData, hash });
|
|
52
52
|
}
|
|
53
|
-
accept() {
|
|
53
|
+
async accept() {
|
|
54
54
|
const { root, scratch, baseDir } = this;
|
|
55
|
-
|
|
55
|
+
await Fsp.mkdir(baseDir, { recursive: true });
|
|
56
56
|
const changes = { added: [], updated: [], changed: false };
|
|
57
|
+
const writes = [];
|
|
57
58
|
for (const [fpath, { data, hash }] of this.pending) {
|
|
58
59
|
const prev = root.cache.get(fpath);
|
|
59
60
|
if (prev !== hash) {
|
|
60
61
|
;
|
|
61
62
|
(prev ? changes.updated : changes.added).push(Path.basename(fpath));
|
|
62
|
-
|
|
63
|
-
Fs.writeFileSync(fpath, data);
|
|
63
|
+
writes.push(Fsp.mkdir(Path.dirname(fpath), { recursive: true }).then(() => Fsp.writeFile(fpath, data)));
|
|
64
64
|
}
|
|
65
65
|
root.cache.set(fpath, hash);
|
|
66
66
|
}
|
|
67
|
+
await Promise.all(writes);
|
|
67
68
|
this.pending.clear();
|
|
68
|
-
/*
|
|
69
|
-
const removed = root.cache.size - newCache.size + changes.added.length
|
|
70
|
-
changes.changed = removed !== 0 || changes.added.length !== 0 || changes.updated.length !== 0*/
|
|
71
69
|
if (changes.updated.length > 0 || changes.added.length > 0) {
|
|
72
70
|
root.on_changes.sendEventsToAll("change", changes);
|
|
73
71
|
}
|
package/package.json
CHANGED