@waffle-os/runtime 0.0.152 → 0.0.154
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/browser/run-command.ts +14 -8
- package/browser/runtime-terminals.ts +26 -0
- package/browser/terminal-output.ts +3 -1
- package/core/filesystem.ts +4 -0
- package/core/wasi.ts +49 -0
- 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/browser/run-command.js +11 -7
- package/dist/browser/runtime-terminals.js +16 -0
- package/dist/browser/terminal-output.js +2 -2
- package/dist/core/wasi.js +40 -0
- package/dist/fs/backend.js +7 -0
- package/dist/fs/client.js +69 -15
- package/dist/fs/dirty-admission.js +15 -8
- package/dist/fs/indexeddb.js +288 -96
- package/dist/fs/memory.js +106 -20
- package/dist/fs/multitab-backend.js +121 -37
- 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 +34 -9
- package/dist/fs/shared.js +96 -6
- package/dist/proc/command-stdio.js +1 -1
- package/dist/proc/start-command.js +4 -0
- package/dist/tooling/program/program-transformer.json +1 -1
- package/fs/backend.ts +11 -0
- package/fs/client.ts +93 -16
- package/fs/dirty-admission.ts +22 -7
- package/fs/guest-watch.ts +1 -1
- package/fs/indexeddb.ts +379 -110
- package/fs/memory.ts +120 -19
- package/fs/multitab-backend.ts +206 -61
- package/fs/multitab-protocol.ts +1 -0
- package/fs/persistent.ts +82 -16
- package/fs/protocol.ts +26 -7
- package/fs/publication-attachment.ts +9 -7
- package/fs/service.ts +35 -7
- package/fs/shared.ts +106 -8
- package/package.json +1 -1
- package/proc/command-stdio.ts +1 -1
- package/proc/start-command.ts +9 -0
- package/testing/idle-workspace-cancellation-browser.ts +22 -13
- package/testing/indexeddb-storage-browser.ts +435 -1
- package/tooling/program/program-transformer.json +1 -1
package/dist/fs/client.js
CHANGED
|
@@ -87,6 +87,8 @@ import {
|
|
|
87
87
|
reapFilesystem,
|
|
88
88
|
unpack,
|
|
89
89
|
wake,
|
|
90
|
+
wakeTransport,
|
|
91
|
+
SIGNAL_TRANSPORT,
|
|
90
92
|
releaseFilesystemReservation
|
|
91
93
|
} from "./protocol.js";
|
|
92
94
|
import {
|
|
@@ -141,6 +143,18 @@ function transferList(payload) {
|
|
|
141
143
|
return { __proto__: null, [symbolIterator]: () => iterator };
|
|
142
144
|
}
|
|
143
145
|
let waitForObservedResolve;
|
|
146
|
+
const PLAIN_REPLIES = new SetConstructor([
|
|
147
|
+
"stat",
|
|
148
|
+
"create",
|
|
149
|
+
"write",
|
|
150
|
+
"append",
|
|
151
|
+
"grow",
|
|
152
|
+
"resize",
|
|
153
|
+
"setTimes",
|
|
154
|
+
"setMode",
|
|
155
|
+
"read",
|
|
156
|
+
"readlink"
|
|
157
|
+
]);
|
|
144
158
|
|
|
145
159
|
export class FilesystemCompletion {
|
|
146
160
|
id;
|
|
@@ -158,6 +172,7 @@ export class FilesystemCompletion {
|
|
|
158
172
|
loading;
|
|
159
173
|
consumed = false;
|
|
160
174
|
released = false;
|
|
175
|
+
retained = true;
|
|
161
176
|
constructor(id, buffer, client, publication) {
|
|
162
177
|
this.id = id;
|
|
163
178
|
this.buffer = buffer;
|
|
@@ -220,7 +235,8 @@ export class FilesystemCompletion {
|
|
|
220
235
|
if (!this.consumed)
|
|
221
236
|
this.cancel();
|
|
222
237
|
else {
|
|
223
|
-
this.
|
|
238
|
+
if (this.retained || atomicsLoad(this.cells, 0) !== State.Complete)
|
|
239
|
+
this.client.connection.port.postMessage({ discard: this.id });
|
|
224
240
|
this.notify();
|
|
225
241
|
}
|
|
226
242
|
mapDelete(this.client.completions, this.id);
|
|
@@ -235,6 +251,7 @@ export class FilesystemCompletion {
|
|
|
235
251
|
}
|
|
236
252
|
arrayAppend(this.backendWaiters, callback);
|
|
237
253
|
this.client.watchRevocation();
|
|
254
|
+
this.client.watchBackendSettlement();
|
|
238
255
|
if (this.backendSettled)
|
|
239
256
|
this.notify();
|
|
240
257
|
}
|
|
@@ -473,6 +490,7 @@ export class FilesystemClient {
|
|
|
473
490
|
capabilities;
|
|
474
491
|
epoch;
|
|
475
492
|
signal;
|
|
493
|
+
transportSignal;
|
|
476
494
|
revoked;
|
|
477
495
|
section;
|
|
478
496
|
shared;
|
|
@@ -489,7 +507,8 @@ export class FilesystemClient {
|
|
|
489
507
|
this.requests = new FilesystemRequestAllocator(connection.requests);
|
|
490
508
|
this.capabilities = new Int32ArrayConstructor(connection.capabilities, 0, CAPABILITY_LENGTH);
|
|
491
509
|
this.epoch = new Int32ArrayConstructor(connection.epoch);
|
|
492
|
-
this.signal = new Int32ArrayConstructor(connection.signal);
|
|
510
|
+
this.signal = new Int32ArrayConstructor(connection.signal, 0, 1);
|
|
511
|
+
this.transportSignal = new Int32ArrayConstructor(connection.signal, SIGNAL_TRANSPORT * 4, 1);
|
|
493
512
|
const revoked = sharedRevoked(connection);
|
|
494
513
|
this.revoked = () => this.disposed || revoked() || !!this.transportError();
|
|
495
514
|
if (connection.residentPublication)
|
|
@@ -505,7 +524,7 @@ export class FilesystemClient {
|
|
|
505
524
|
};
|
|
506
525
|
connection.port.onmessageerror = () => {
|
|
507
526
|
closeRequestMemory(this.requests.memory);
|
|
508
|
-
|
|
527
|
+
wakeTransport(connection);
|
|
509
528
|
mapForEach(this.completions, (completion) => completion.notify());
|
|
510
529
|
connection.port.postMessage({ transportClosed: true });
|
|
511
530
|
connection.port.close();
|
|
@@ -639,26 +658,49 @@ export class FilesystemClient {
|
|
|
639
658
|
this.watchingRevocation = true;
|
|
640
659
|
this.monitorRevocation();
|
|
641
660
|
}
|
|
661
|
+
watchBackendSettlement() {
|
|
662
|
+
this.backendWaiterVersion++;
|
|
663
|
+
if (this.revocationWord === this.transportSignal)
|
|
664
|
+
atomicsNotify(this.transportSignal, 0);
|
|
665
|
+
}
|
|
666
|
+
revocationWord;
|
|
667
|
+
backendWaiterVersion = 0;
|
|
668
|
+
unsettledBackendWaiter() {
|
|
669
|
+
let found = false;
|
|
670
|
+
mapForEach(this.completions, (completion) => {
|
|
671
|
+
if (completion.hasBackendWaiters && !completion.backendSettled)
|
|
672
|
+
found = true;
|
|
673
|
+
});
|
|
674
|
+
return found;
|
|
675
|
+
}
|
|
676
|
+
revocationSignal() {
|
|
677
|
+
return this.connection.publication || this.unsettledBackendWaiter() ? this.signal : this.transportSignal;
|
|
678
|
+
}
|
|
642
679
|
monitorRevocation() {
|
|
643
|
-
const signal = this.signal;
|
|
644
680
|
const stop = () => {
|
|
681
|
+
this.revocationWord = undefined;
|
|
645
682
|
this.watchingRevocation = false;
|
|
646
683
|
};
|
|
647
684
|
const step = () => {
|
|
685
|
+
this.revocationWord = undefined;
|
|
648
686
|
try {
|
|
649
687
|
while (mapSize(this.completions)) {
|
|
688
|
+
const version = this.backendWaiterVersion;
|
|
689
|
+
const signal = this.revocationSignal();
|
|
650
690
|
const observed = atomicsLoad(signal, 0);
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
691
|
+
let waiting = true;
|
|
692
|
+
if (this.revoked())
|
|
693
|
+
waiting = this.sweepRevokedCompletions();
|
|
694
|
+
else
|
|
655
695
|
this.notifySettledBackendWaiters();
|
|
656
|
-
|
|
657
|
-
|
|
696
|
+
if (version !== this.backendWaiterVersion)
|
|
697
|
+
continue;
|
|
698
|
+
if (!waiting || !mapSize(this.completions))
|
|
658
699
|
break;
|
|
659
|
-
const
|
|
660
|
-
if (
|
|
661
|
-
|
|
700
|
+
const parked = atomicsWaitAsync(signal, 0, observed);
|
|
701
|
+
if (parked.async) {
|
|
702
|
+
this.revocationWord = signal;
|
|
703
|
+
afterNativePromise(parked.value, step, stop);
|
|
662
704
|
return;
|
|
663
705
|
}
|
|
664
706
|
}
|
|
@@ -805,14 +847,19 @@ export class FilesystemClient {
|
|
|
805
847
|
throw new FilesystemError(6);
|
|
806
848
|
}
|
|
807
849
|
submitPrepared(operation, args, data, capacity, publication) {
|
|
808
|
-
const input = pack({ operation, args, publication });
|
|
850
|
+
const input = pack(publication ? { operation, args, publication } : { operation, args });
|
|
809
851
|
this.section.enter();
|
|
810
852
|
try {
|
|
811
|
-
|
|
853
|
+
const completion = this.postRequest(input, data, capacity, publication);
|
|
854
|
+
completion.retained = this.retainsReply(operation);
|
|
855
|
+
return completion;
|
|
812
856
|
} finally {
|
|
813
857
|
this.section.exit();
|
|
814
858
|
}
|
|
815
859
|
}
|
|
860
|
+
retainsReply(operation) {
|
|
861
|
+
return !setHas(PLAIN_REPLIES, operation) || this.connection.residentPublication !== undefined || this.shared.publication !== undefined;
|
|
862
|
+
}
|
|
816
863
|
postRequest(input, data, capacity, publication) {
|
|
817
864
|
const inputLength = typedArrayLength(input);
|
|
818
865
|
const total = inputLength + typedArrayLength(data);
|
|
@@ -2047,6 +2094,13 @@ export class FilesystemClient {
|
|
|
2047
2094
|
return errno(error);
|
|
2048
2095
|
}
|
|
2049
2096
|
}
|
|
2097
|
+
realpath(directory, path, rooted = false) {
|
|
2098
|
+
try {
|
|
2099
|
+
return this.call("realpath", [directory, path, rooted]);
|
|
2100
|
+
} catch (error) {
|
|
2101
|
+
return errno(error);
|
|
2102
|
+
}
|
|
2103
|
+
}
|
|
2050
2104
|
readlink(handle) {
|
|
2051
2105
|
this.retain(handle);
|
|
2052
2106
|
try {
|
|
@@ -127,15 +127,22 @@ export class DirtyAdmission {
|
|
|
127
127
|
get revision() {
|
|
128
128
|
return this.values[REVISION];
|
|
129
129
|
}
|
|
130
|
-
|
|
131
|
-
if (!this.enabled ||
|
|
132
|
-
return
|
|
133
|
-
this.values[DIRTY_BYTES] = 0;
|
|
134
|
-
this.values[DIRTY_METADATA] = 0;
|
|
130
|
+
releaseSlot(bytes, metadata) {
|
|
131
|
+
if (!this.enabled || !bytes && !metadata)
|
|
132
|
+
return;
|
|
133
|
+
this.values[DIRTY_BYTES] = Math.max(0, this.values[DIRTY_BYTES] - bytes);
|
|
134
|
+
this.values[DIRTY_METADATA] = Math.max(0, this.values[DIRTY_METADATA] - metadata);
|
|
135
|
+
this.values[REVISION]++;
|
|
136
|
+
this.notify();
|
|
137
|
+
}
|
|
138
|
+
reconcile(namespace, dirtyNamespace, dirtyBytes, dirtyMetadata) {
|
|
139
|
+
if (!this.enabled)
|
|
140
|
+
return;
|
|
141
|
+
this.values[DIRTY_BYTES] = dirtyBytes;
|
|
142
|
+
this.values[DIRTY_METADATA] = dirtyMetadata;
|
|
135
143
|
this.values[NAMESPACE] = namespace;
|
|
136
|
-
this.values[BASE_NAMESPACE] = namespace;
|
|
144
|
+
this.values[BASE_NAMESPACE] = namespace - dirtyNamespace;
|
|
137
145
|
this.notify();
|
|
138
|
-
return true;
|
|
139
146
|
}
|
|
140
147
|
notify() {
|
|
141
148
|
Atomics.add(this.signals, 0, 1);
|
|
@@ -162,7 +169,7 @@ export class DirtyAdmission {
|
|
|
162
169
|
}
|
|
163
170
|
}
|
|
164
171
|
get hasDebt() {
|
|
165
|
-
return this.values[DIRTY_BYTES] > 0 || this.values[DIRTY_METADATA] > 0;
|
|
172
|
+
return this.values[DIRTY_BYTES] > 0 || this.values[DIRTY_METADATA] > 0 || this.values[NAMESPACE] > this.values[BASE_NAMESPACE];
|
|
166
173
|
}
|
|
167
174
|
capacityReleased() {
|
|
168
175
|
if (this.enabled)
|