@waffle-os/runtime 0.0.153 → 0.0.155
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/net/helper.ts +114 -19
- package/browser/net/ring.ts +18 -6
- package/browser/net/runtime.ts +2 -2
- package/browser/notification-relay.ts +105 -18
- package/browser/notification-wait.ts +45 -4
- package/browser/notification-worker.ts +169 -76
- package/browser/preview.ts +15 -2
- package/core/filesystem.ts +18 -0
- package/core/wasi.ts +75 -4
- package/dist/browser/net/helper.js +83 -18
- package/dist/browser/net/ring.js +6 -5
- package/dist/browser/net/runtime.js +2 -2
- package/dist/browser/notification-relay.js +78 -15
- package/dist/browser/notification-wait.js +37 -5
- package/dist/browser/notification-worker.js +146 -67
- package/dist/core/wasi.js +62 -4
- package/dist/fs/backend.js +7 -0
- package/dist/fs/client.js +75 -17
- package/dist/fs/dirty-admission.js +15 -8
- package/dist/fs/guest-watch.js +267 -94
- package/dist/fs/indexeddb-chunks.js +88 -11
- package/dist/fs/indexeddb.js +366 -110
- package/dist/fs/memory.js +106 -20
- package/dist/fs/multitab-backend.js +291 -74
- package/dist/fs/multitab-protocol.js +1 -0
- package/dist/fs/persistent.js +70 -16
- package/dist/fs/protocol.js +15 -7
- package/dist/fs/publication-attachment.js +9 -7
- package/dist/fs/service.js +62 -9
- package/dist/fs/shared.js +100 -6
- package/dist/fs/storage.js +107 -8
- package/dist/fs/watch-service.js +97 -2
- package/dist/fs/watch-subscriptions.js +121 -8
- package/dist/proc/command-stdio.js +1 -1
- package/dist/proc/intrinsics/core.js +5 -0
- package/dist/proc/intrinsics.js +1 -0
- package/dist/tooling/program/program-transformer.json +1 -1
- package/fs/backend.ts +17 -0
- package/fs/client.ts +99 -16
- package/fs/dirty-admission.ts +22 -7
- package/fs/guest-watch.ts +299 -103
- package/fs/indexeddb-chunks.ts +103 -9
- package/fs/indexeddb.ts +477 -121
- package/fs/memory.ts +120 -19
- package/fs/multitab-backend.ts +440 -95
- package/fs/multitab-protocol.ts +1 -0
- package/fs/persistent.ts +88 -16
- package/fs/protocol.ts +26 -7
- package/fs/publication-attachment.ts +9 -7
- package/fs/service.ts +62 -7
- package/fs/shared.ts +110 -8
- package/fs/storage.ts +128 -10
- package/fs/watch-service.ts +110 -3
- package/fs/watch-subscriptions.ts +115 -7
- package/package.json +1 -1
- package/proc/command-stdio.ts +1 -1
- package/proc/intrinsics/core.ts +7 -0
- package/proc/intrinsics.ts +1 -0
- package/testing/idle-workspace-cancellation-browser.ts +22 -13
- package/testing/indexeddb-storage-browser.ts +564 -1
- package/tooling/program/program-transformer.json +1 -1
package/dist/fs/memory.js
CHANGED
|
@@ -75,6 +75,12 @@ function expandTreeLink(child, path, start, options, expansions, targetEnd) {
|
|
|
75
75
|
targetEnd: target.length + (targetEnd > start ? 1 + targetEnd - start : 0)
|
|
76
76
|
};
|
|
77
77
|
}
|
|
78
|
+
function climbedBase(base, aboveStart) {
|
|
79
|
+
return aboveStart && base === "start" ? "lost" : base;
|
|
80
|
+
}
|
|
81
|
+
function restartedBase(base, options) {
|
|
82
|
+
return options.rooted ? "root" : base;
|
|
83
|
+
}
|
|
78
84
|
export function walkTree(root, path, options) {
|
|
79
85
|
const error = treePathError(path, options.pathUnits, options.pathBytes);
|
|
80
86
|
if (error)
|
|
@@ -83,6 +89,7 @@ export function walkTree(root, path, options) {
|
|
|
83
89
|
const names = [];
|
|
84
90
|
let node = root;
|
|
85
91
|
let parent;
|
|
92
|
+
let base = "start";
|
|
86
93
|
let name = "", terminalDot = false, expansions = 0, targetEnd = 0, start = 0;
|
|
87
94
|
while (start < path.length) {
|
|
88
95
|
let end = path.indexOf("/", start);
|
|
@@ -103,9 +110,11 @@ export function walkTree(root, path, options) {
|
|
|
103
110
|
if (part === ".")
|
|
104
111
|
continue;
|
|
105
112
|
if (part === "..") {
|
|
106
|
-
const
|
|
113
|
+
const popped = dirs.pop();
|
|
114
|
+
const up = popped ?? climbAbove(node, root, options);
|
|
107
115
|
if (typeof up === "number")
|
|
108
116
|
return up;
|
|
117
|
+
base = climbedBase(base, popped === undefined && up !== node);
|
|
109
118
|
node = up;
|
|
110
119
|
names.pop();
|
|
111
120
|
parent = undefined;
|
|
@@ -120,6 +129,7 @@ export function walkTree(root, path, options) {
|
|
|
120
129
|
if (!child)
|
|
121
130
|
return {
|
|
122
131
|
canonicalPath: "/" + names.concat(part).join("/"),
|
|
132
|
+
base,
|
|
123
133
|
parent,
|
|
124
134
|
name,
|
|
125
135
|
node: undefined,
|
|
@@ -132,6 +142,7 @@ export function walkTree(root, path, options) {
|
|
|
132
142
|
if (link?.absolute) {
|
|
133
143
|
dirs.length = 0;
|
|
134
144
|
names.length = 0;
|
|
145
|
+
base = restartedBase(base, options);
|
|
135
146
|
}
|
|
136
147
|
if (link) {
|
|
137
148
|
expansions++;
|
|
@@ -151,7 +162,26 @@ export function walkTree(root, path, options) {
|
|
|
151
162
|
const trailingSlash = path.endsWith("/");
|
|
152
163
|
if (trailingSlash && node.kind !== "dir")
|
|
153
164
|
return 54;
|
|
154
|
-
return {
|
|
165
|
+
return {
|
|
166
|
+
parent,
|
|
167
|
+
name,
|
|
168
|
+
node,
|
|
169
|
+
trailingSlash,
|
|
170
|
+
terminalDot,
|
|
171
|
+
canonicalPath: "/" + names.join("/"),
|
|
172
|
+
base
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
function joinBelow(prefix, below) {
|
|
176
|
+
if (typeof prefix === "number" || below === "/")
|
|
177
|
+
return prefix;
|
|
178
|
+
return (prefix === "/" ? "" : prefix) + below;
|
|
179
|
+
}
|
|
180
|
+
function childName(parent, child) {
|
|
181
|
+
for (const [name, entry] of parent.children)
|
|
182
|
+
if (entry === child)
|
|
183
|
+
return name;
|
|
184
|
+
return;
|
|
155
185
|
}
|
|
156
186
|
function namespacePlan(edits = [], created = [], forgotten = [], links = []) {
|
|
157
187
|
return {
|
|
@@ -204,7 +234,20 @@ export function decode(data) {
|
|
|
204
234
|
export class MemFS {
|
|
205
235
|
root;
|
|
206
236
|
onChange;
|
|
237
|
+
onDirEntryDelta;
|
|
207
238
|
onLinkChange;
|
|
239
|
+
setChild(parent, name, child) {
|
|
240
|
+
const existed = parent.children.has(name);
|
|
241
|
+
parent.children.set(name, child);
|
|
242
|
+
if (!existed)
|
|
243
|
+
this.onDirEntryDelta?.(parent, 64 + name.length * 2);
|
|
244
|
+
}
|
|
245
|
+
deleteChild(parent, name) {
|
|
246
|
+
const deleted = parent.children.delete(name);
|
|
247
|
+
if (deleted)
|
|
248
|
+
this.onDirEntryDelta?.(parent, -(64 + name.length * 2));
|
|
249
|
+
return deleted;
|
|
250
|
+
}
|
|
208
251
|
changed(node) {
|
|
209
252
|
this.onChange?.(node);
|
|
210
253
|
}
|
|
@@ -289,12 +332,18 @@ export class MemFS {
|
|
|
289
332
|
this.handles.delete(handle);
|
|
290
333
|
if (node.kind === "dir") {
|
|
291
334
|
this.removedDirectories.add(node);
|
|
292
|
-
|
|
335
|
+
const trackDelta = this.onDirEntryDelta !== undefined;
|
|
336
|
+
let delta = 0;
|
|
337
|
+
for (const [name, child] of node.children) {
|
|
338
|
+
if (trackDelta)
|
|
339
|
+
delta -= 64 + name.length * 2;
|
|
293
340
|
this.changeLinkCount(child, -1);
|
|
294
341
|
this.forget(child);
|
|
295
342
|
}
|
|
296
343
|
this.directoryPages(node).clear();
|
|
297
344
|
node.children.clear();
|
|
345
|
+
if (delta)
|
|
346
|
+
this.onDirEntryDelta?.(node, delta);
|
|
298
347
|
}
|
|
299
348
|
}
|
|
300
349
|
nodeForHandle(handle) {
|
|
@@ -381,7 +430,21 @@ export class MemFS {
|
|
|
381
430
|
return this.walk(this.handle(this.root), path.replace(/^\/+/, "") || ".", true, followFinal);
|
|
382
431
|
}
|
|
383
432
|
walk(directory, path, clampRoot, followFinal, pathBytes, rooted = false) {
|
|
384
|
-
const resolved =
|
|
433
|
+
const resolved = this.walkNodes(this.directory(directory), path, clampRoot, followFinal, pathBytes, rooted);
|
|
434
|
+
if (typeof resolved === "number")
|
|
435
|
+
return resolved;
|
|
436
|
+
return {
|
|
437
|
+
canonicalPath: resolved.canonicalPath,
|
|
438
|
+
base: resolved.base,
|
|
439
|
+
name: resolved.name,
|
|
440
|
+
trailingSlash: resolved.trailingSlash,
|
|
441
|
+
terminalDot: resolved.terminalDot,
|
|
442
|
+
parent: resolved.parent ? this.handle(resolved.parent) : undefined,
|
|
443
|
+
node: resolved.node ? this.handle(resolved.node) : undefined
|
|
444
|
+
};
|
|
445
|
+
}
|
|
446
|
+
walkNodes(start, path, clampRoot, followFinal, pathBytes, rooted = false) {
|
|
447
|
+
return walkTree(start, path, {
|
|
385
448
|
clampRoot,
|
|
386
449
|
followFinal,
|
|
387
450
|
pathBytes,
|
|
@@ -393,16 +456,39 @@ export class MemFS {
|
|
|
393
456
|
return child;
|
|
394
457
|
}
|
|
395
458
|
});
|
|
459
|
+
}
|
|
460
|
+
realpath(directory, path, rooted = false) {
|
|
461
|
+
if (path.startsWith("/"))
|
|
462
|
+
return 63;
|
|
463
|
+
const start = this.directory(directory);
|
|
464
|
+
const resolved = this.walkNodes(start, path, false, true, undefined, rooted);
|
|
396
465
|
if (typeof resolved === "number")
|
|
397
466
|
return resolved;
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
467
|
+
if (resolved.node === undefined)
|
|
468
|
+
return 44;
|
|
469
|
+
if (!rooted)
|
|
470
|
+
return resolved.canonicalPath.slice(1) || ".";
|
|
471
|
+
if (resolved.base === "root" || resolved.base === "start" && start === this.root)
|
|
472
|
+
return resolved.canonicalPath;
|
|
473
|
+
if (resolved.base === "start")
|
|
474
|
+
return joinBelow(this.pathOf(start), resolved.canonicalPath);
|
|
475
|
+
if (resolved.node.kind === "dir")
|
|
476
|
+
return this.pathOf(resolved.node);
|
|
477
|
+
return joinBelow(this.pathOf(resolved.parent), "/" + resolved.name);
|
|
478
|
+
}
|
|
479
|
+
pathOf(dir) {
|
|
480
|
+
const names = [];
|
|
481
|
+
for (let at = dir;at !== this.root; ) {
|
|
482
|
+
const parent = this.liveParent(at);
|
|
483
|
+
if (typeof parent === "number")
|
|
484
|
+
return parent === 63 ? 44 : parent;
|
|
485
|
+
const name = childName(parent, at);
|
|
486
|
+
if (name === undefined)
|
|
487
|
+
return 44;
|
|
488
|
+
names.push(name);
|
|
489
|
+
at = parent;
|
|
490
|
+
}
|
|
491
|
+
return "/" + names.reverse().join("/");
|
|
406
492
|
}
|
|
407
493
|
symlink(path, target) {
|
|
408
494
|
const prepared = this.planSymlink(path, target, 4);
|
|
@@ -567,7 +653,7 @@ export class MemFS {
|
|
|
567
653
|
const node = kind === "file" ? newFile() : kind === "socket" ? newSocket() : newDir();
|
|
568
654
|
this.directoryPages(parent).reserve(1);
|
|
569
655
|
this.pageEntry(parent, path.name, node);
|
|
570
|
-
|
|
656
|
+
this.setChild(parent, path.name, node);
|
|
571
657
|
this.changeLinkCount(node, 1);
|
|
572
658
|
this.onLinkChange?.(node, 1);
|
|
573
659
|
modified(parent, node.ctime);
|
|
@@ -675,7 +761,7 @@ export class MemFS {
|
|
|
675
761
|
return parent;
|
|
676
762
|
this.directoryPages(parent).reserve(1);
|
|
677
763
|
this.pageEntry(parent, to.name, node);
|
|
678
|
-
|
|
764
|
+
this.setChild(parent, to.name, node);
|
|
679
765
|
this.changeLinkCount(node, 1);
|
|
680
766
|
this.onLinkChange?.(node, 1);
|
|
681
767
|
const time = fileTimeNow();
|
|
@@ -703,7 +789,7 @@ export class MemFS {
|
|
|
703
789
|
if ((parent.mode & 192) !== 192)
|
|
704
790
|
return 2;
|
|
705
791
|
this.pageEntry(parent, path.name, undefined);
|
|
706
|
-
|
|
792
|
+
this.deleteChild(parent, path.name);
|
|
707
793
|
this.changeLinkCount(node, -1);
|
|
708
794
|
this.onLinkChange?.(node, -1);
|
|
709
795
|
const time = fileTimeNow();
|
|
@@ -746,11 +832,11 @@ export class MemFS {
|
|
|
746
832
|
this.directoryPages(parent).reserve(1);
|
|
747
833
|
this.pageEntry(sourceParent, from.name, undefined);
|
|
748
834
|
this.pageEntry(parent, to.name, node);
|
|
749
|
-
|
|
835
|
+
this.deleteChild(sourceParent, from.name);
|
|
750
836
|
const time = fileTimeNow();
|
|
751
837
|
modified(sourceParent, time);
|
|
752
838
|
node.ctime = time;
|
|
753
|
-
|
|
839
|
+
this.setChild(parent, to.name, node);
|
|
754
840
|
if (node.kind === "dir")
|
|
755
841
|
this.directoryParents.set(node, parent);
|
|
756
842
|
if (target) {
|
|
@@ -983,9 +1069,9 @@ export class MemFS {
|
|
|
983
1069
|
if (edge.after)
|
|
984
1070
|
this.changeLinkCount(edge.after, 1);
|
|
985
1071
|
if (edge.after)
|
|
986
|
-
edge.parent
|
|
1072
|
+
this.setChild(edge.parent, edge.name, edge.after);
|
|
987
1073
|
else
|
|
988
|
-
edge.parent
|
|
1074
|
+
this.deleteChild(edge.parent, edge.name);
|
|
989
1075
|
if (edge.after?.kind === "dir")
|
|
990
1076
|
this.directoryParents.set(edge.after, edge.parent);
|
|
991
1077
|
if (edge.after && created.has(edge.after))
|
|
@@ -1079,7 +1165,7 @@ export class MemFS {
|
|
|
1079
1165
|
return false;
|
|
1080
1166
|
const { parent, name, node } = edge;
|
|
1081
1167
|
this.pageEntry(parent, name, undefined);
|
|
1082
|
-
const removed =
|
|
1168
|
+
const removed = this.deleteChild(parent, name);
|
|
1083
1169
|
if (removed) {
|
|
1084
1170
|
this.changeLinkCount(node, -1);
|
|
1085
1171
|
this.onLinkChange?.(node, -1);
|