@waffle-os/runtime 0.0.156 → 0.0.157
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/filesystem-backend.ts +11 -1
- package/browser/preview-protocol.ts +2 -0
- package/browser/preview.ts +128 -18
- package/browser/runtime-terminals.ts +65 -24
- package/browser/shared-fs.ts +141 -14
- package/browser/worker.ts +73 -6
- package/core/descriptors.ts +19 -2
- package/core/devices.ts +237 -2
- package/core/fd-reopen.ts +105 -20
- package/core/filesystem.ts +71 -0
- package/core/index.ts +4 -0
- package/core/open-file.ts +212 -18
- package/core/wasi.ts +397 -46
- package/dist/browser/filesystem-backend.js +4 -2
- package/dist/browser/preview.js +120 -17
- package/dist/browser/runtime-terminals.js +53 -10
- package/dist/browser/shared-fs.js +124 -11
- package/dist/browser/worker.js +59 -6
- package/dist/core/descriptors.js +9 -1
- package/dist/core/devices.js +211 -1
- package/dist/core/fd-reopen.js +79 -18
- package/dist/core/filesystem.js +13 -0
- package/dist/core/open-file.js +166 -13
- package/dist/core/wasi.js +353 -27
- package/dist/fs/backend.js +29 -2
- package/dist/fs/client.js +199 -6
- package/dist/fs/index.js +21 -1
- package/dist/fs/indexeddb.js +30 -2
- package/dist/fs/locks.js +1112 -0
- package/dist/fs/memory.js +109 -1
- package/dist/fs/multitab-backend.js +315 -195
- package/dist/fs/multitab-protocol.js +1 -0
- package/dist/fs/persistent.js +13 -6
- package/dist/fs/protocol.js +9 -3
- package/dist/fs/service.js +386 -22
- package/dist/fs/shared.js +54 -1
- package/dist/fs/storage-geometry.js +2 -0
- package/dist/interrupt/rewriter-internal.js +4 -1
- package/dist/proc/abi.js +80 -6
- package/dist/proc/errors.js +1 -0
- package/dist/proc/filesystem-codec.js +40 -9
- package/dist/proc/index.js +10 -1
- package/dist/proc/pty.js +193 -0
- package/dist/proc/worker-client.js +11 -2
- package/dist/proc/worker-pipes.js +51 -0
- package/dist/runtime.js +11 -2
- package/dist/search/engine.js +53 -0
- package/dist/tooling/program/program-transformer.json +1 -1
- package/fs/backend.ts +33 -1
- package/fs/client.ts +225 -6
- package/fs/index.ts +22 -1
- package/fs/indexeddb.ts +36 -2
- package/fs/locks.ts +1406 -0
- package/fs/memory.ts +114 -1
- package/fs/multitab-backend.ts +561 -303
- package/fs/multitab-protocol.ts +1 -0
- package/fs/persistent.ts +14 -3
- package/fs/protocol.ts +17 -5
- package/fs/service.ts +468 -23
- package/fs/shared.ts +60 -2
- package/fs/storage-geometry.ts +3 -0
- package/index.ts +2 -0
- package/interrupt/rewriter-internal.ts +4 -1
- package/package.json +2 -2
- package/proc/abi.ts +79 -6
- package/proc/errors.ts +1 -0
- package/proc/filesystem-codec.ts +39 -9
- package/proc/index.ts +11 -0
- package/proc/pty.ts +227 -0
- package/proc/worker-client.ts +28 -6
- package/proc/worker-pipes.ts +57 -0
- package/runtime.ts +12 -2
- package/search/engine.ts +49 -0
- package/testing/indexeddb-storage-browser.ts +173 -2
- package/tooling/program/program-transformer.json +1 -1
package/fs/multitab-protocol.ts
CHANGED
package/fs/persistent.ts
CHANGED
|
@@ -103,8 +103,9 @@ export class PersistentBackend extends MemoryBackend {
|
|
|
103
103
|
private readonly dirtyLimits: Partial<DirtyLimits> | false = {},
|
|
104
104
|
startupRoot?: MemoryBudget,
|
|
105
105
|
sharedRoot?: MemoryBackendSharedRoot,
|
|
106
|
+
machineId?: string,
|
|
106
107
|
) {
|
|
107
|
-
super(fs, reservation, startupRoot, undefined, sharedRoot);
|
|
108
|
+
super(fs, reservation, startupRoot, undefined, sharedRoot, machineId);
|
|
108
109
|
this.initialWorkspaceId = reservation.workspace;
|
|
109
110
|
this.initialEra = reservation.era;
|
|
110
111
|
this.loadedIndex = index !== undefined;
|
|
@@ -180,7 +181,10 @@ export class PersistentBackend extends MemoryBackend {
|
|
|
180
181
|
return this.storage.terminalFailureReason?.();
|
|
181
182
|
}
|
|
182
183
|
setTerminalFailureListener(listener: (reason: unknown) => void): void {
|
|
183
|
-
this.storage.setTerminalFailureListener?.(
|
|
184
|
+
this.storage.setTerminalFailureListener?.((reason) => {
|
|
185
|
+
this.cancelTimer();
|
|
186
|
+
listener(reason);
|
|
187
|
+
});
|
|
184
188
|
}
|
|
185
189
|
private hasPendingChanges(): boolean {
|
|
186
190
|
if (this.dirty.size > 0 || this.removed.size > 0 || this.shared.publication) return true;
|
|
@@ -192,7 +196,11 @@ export class PersistentBackend extends MemoryBackend {
|
|
|
192
196
|
private startTimer(intervalMs: number): void {
|
|
193
197
|
if (intervalMs > 0)
|
|
194
198
|
this.timer = setInterval(() => {
|
|
195
|
-
if (
|
|
199
|
+
if (this.stopped || this.isTerminallyFailed()) {
|
|
200
|
+
this.cancelTimer();
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
if (!this.pendingCheckpoints && this.hasPendingChanges())
|
|
196
204
|
void this.checkpoint().catch(() => {});
|
|
197
205
|
}, intervalMs);
|
|
198
206
|
}
|
|
@@ -204,6 +212,7 @@ export class PersistentBackend extends MemoryBackend {
|
|
|
204
212
|
dirtyLimits?: Partial<DirtyLimits> | false;
|
|
205
213
|
startupRoot?: MemoryBudget;
|
|
206
214
|
sharedRoot?: MemoryBackendSharedRoot;
|
|
215
|
+
machineId?: string;
|
|
207
216
|
signal?: AbortSignal;
|
|
208
217
|
} = {},
|
|
209
218
|
): Promise<PersistentBackend> {
|
|
@@ -225,6 +234,7 @@ export class PersistentBackend extends MemoryBackend {
|
|
|
225
234
|
options.dirtyLimits,
|
|
226
235
|
options.startupRoot,
|
|
227
236
|
options.sharedRoot,
|
|
237
|
+
options.machineId,
|
|
228
238
|
);
|
|
229
239
|
const fs = restoreTree(index);
|
|
230
240
|
const root = fs.root;
|
|
@@ -239,6 +249,7 @@ export class PersistentBackend extends MemoryBackend {
|
|
|
239
249
|
options.dirtyLimits,
|
|
240
250
|
options.startupRoot,
|
|
241
251
|
options.sharedRoot,
|
|
252
|
+
options.machineId,
|
|
242
253
|
);
|
|
243
254
|
try {
|
|
244
255
|
if (!index.nodes[0]?.identity) {
|
package/fs/protocol.ts
CHANGED
|
@@ -134,6 +134,8 @@ export interface FilesystemConnection {
|
|
|
134
134
|
sections: SharedArrayBuffer;
|
|
135
135
|
/** Nonzero lock owner token; service clears it when this identity is reaped. */
|
|
136
136
|
owner: number;
|
|
137
|
+
/** Optional logical-process POSIX lock owner token (shared by exec successors and thread members). */
|
|
138
|
+
posixOwner?: number;
|
|
137
139
|
maxBytes: number;
|
|
138
140
|
/** Service revocation in word 0, then per-owner liveness for independent process identities. */
|
|
139
141
|
ownerStates: SharedArrayBuffer;
|
|
@@ -149,6 +151,8 @@ export interface FilesystemReservation {
|
|
|
149
151
|
targetOwner: number;
|
|
150
152
|
/** Closed once; transfer state: 0 pending, 1 adopted, 2 cancelled. */
|
|
151
153
|
state: SharedArrayBuffer;
|
|
154
|
+
/** Shared open-file control block when transferring a file or directory description. */
|
|
155
|
+
ofd?: SharedArrayBuffer;
|
|
152
156
|
}
|
|
153
157
|
export type FilesystemIdentity = Omit<FilesystemConnection, "port" | "requests">;
|
|
154
158
|
export interface FilesystemOwnerConstruction {
|
|
@@ -278,15 +282,20 @@ function identityPublication(
|
|
|
278
282
|
return domain;
|
|
279
283
|
}
|
|
280
284
|
/** Processes share storage, not the lifetime of the process that spawned them. */
|
|
281
|
-
export function createProcessFilesystemIdentity(
|
|
285
|
+
export function createProcessFilesystemIdentity(
|
|
286
|
+
parent: FilesystemIdentity,
|
|
287
|
+
posixOwner?: number,
|
|
288
|
+
): FilesystemIdentity {
|
|
282
289
|
const identity = createFilesystemIdentity(parent);
|
|
283
290
|
identity.revocations = identity.revocations.slice(0, 1);
|
|
291
|
+
if (posixOwner !== undefined) identity.posixOwner = posixOwner;
|
|
284
292
|
return identity;
|
|
285
293
|
}
|
|
286
|
-
/** Idempotent across the controller and guest copies of a transferred description.
|
|
287
|
-
|
|
294
|
+
/** Idempotent across the controller and guest copies of a transferred description.
|
|
295
|
+
* Returns true for the single call that transitioned the reservation to closed. */
|
|
296
|
+
export function releaseFilesystemReservation(reservation: FilesystemReservation): boolean {
|
|
288
297
|
const state = new Int32Array(reservation.state);
|
|
289
|
-
if (Atomics.exchange(state, 0, 1)) return;
|
|
298
|
+
if (Atomics.exchange(state, 0, 1)) return false;
|
|
290
299
|
const target = new Int32ArrayConstructor(reservation.target, 0, CAPABILITY_LENGTH);
|
|
291
300
|
for (;;) {
|
|
292
301
|
const count = Atomics.load(target, reservation.targetKey + 1);
|
|
@@ -296,12 +305,15 @@ export function releaseFilesystemReservation(reservation: FilesystemReservation)
|
|
|
296
305
|
)
|
|
297
306
|
break;
|
|
298
307
|
}
|
|
299
|
-
if (Atomics.compareExchange(state, 1, 0, 2) === 0)
|
|
308
|
+
if (Atomics.compareExchange(state, 1, 0, 2) === 0) {
|
|
309
|
+
if (reservation.ofd) Atomics.sub(new Int32ArrayConstructor(reservation.ofd), 6, 1);
|
|
300
310
|
Atomics.sub(
|
|
301
311
|
new Int32ArrayConstructor(reservation.source, 0, CAPABILITY_LENGTH),
|
|
302
312
|
reservation.sourceKey + 2,
|
|
303
313
|
1,
|
|
304
314
|
);
|
|
315
|
+
}
|
|
316
|
+
return true;
|
|
305
317
|
}
|
|
306
318
|
export function reserveIdentityCapability(
|
|
307
319
|
source: FilesystemIdentity,
|