@nimbus-sh/worker 0.1.2 → 0.1.3
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/LICENSE +21 -0
- package/NOTICE.md +6 -0
- package/dist/_shared/cache-stats.d.ts +1 -1
- package/dist/_shared/cache-stats.js +1 -1
- package/dist/_shared/exports-resolver.d.ts +0 -2
- package/dist/_shared/exports-resolver.d.ts.map +1 -1
- package/dist/_shared/exports-resolver.js +0 -2
- package/dist/_shared/session-router.d.ts +0 -1
- package/dist/_shared/session-router.d.ts.map +1 -1
- package/dist/_shared/session-router.js +0 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +0 -1
- package/dist/facets/cirrus-real.d.ts +1 -1
- package/dist/facets/cirrus-real.js +1 -1
- package/dist/facets/manager.d.ts +0 -1
- package/dist/facets/manager.d.ts.map +1 -1
- package/dist/facets/manager.js +3 -15
- package/dist/facets/process.d.ts +2 -2
- package/dist/facets/process.js +2 -2
- package/dist/facets/vite-dev-server.d.ts +3 -3
- package/dist/facets/vite-dev-server.d.ts.map +1 -1
- package/dist/facets/vite-dev-server.js +6 -8
- package/dist/facets/wasm-swap-registry.d.ts +15 -21
- package/dist/facets/wasm-swap-registry.d.ts.map +1 -1
- package/dist/facets/wasm-swap-registry.js +41 -54
- package/dist/facets/ws-terminal.d.ts +4 -5
- package/dist/facets/ws-terminal.d.ts.map +1 -1
- package/dist/facets/ws-terminal.js +7 -8
- package/dist/git/commands.d.ts.map +1 -1
- package/dist/git/commands.js +0 -1
- package/dist/git/network-facet.d.ts.map +1 -1
- package/dist/git/network-facet.js +0 -2
- package/dist/git-bundle.generated.d.ts +2 -3
- package/dist/git-bundle.generated.d.ts.map +1 -1
- package/dist/git-bundle.generated.js +3 -4
- package/dist/loaders/child-process/spawn-facet.d.ts +7 -52
- package/dist/loaders/child-process/spawn-facet.d.ts.map +1 -1
- package/dist/loaders/child-process/spawn-facet.js +7 -49
- package/dist/loaders/child-process/spawn-pool.d.ts +5 -44
- package/dist/loaders/child-process/spawn-pool.d.ts.map +1 -1
- package/dist/loaders/child-process/spawn-pool.js +5 -44
- package/dist/loaders/fanout-pool.d.ts +18 -65
- package/dist/loaders/fanout-pool.d.ts.map +1 -1
- package/dist/loaders/fanout-pool.js +25 -87
- package/dist/loaders/generated-workers.d.ts +1 -2
- package/dist/loaders/generated-workers.d.ts.map +1 -1
- package/dist/loaders/generated-workers.js +5 -6
- package/dist/loaders/loader-pool.d.ts +1 -2
- package/dist/loaders/loader-pool.d.ts.map +1 -1
- package/dist/loaders/loader-pool.js +1 -1
- package/dist/loaders/npm-resolve-preamble.d.ts +4 -5
- package/dist/loaders/npm-resolve-preamble.d.ts.map +1 -1
- package/dist/loaders/npm-resolve-preamble.js +14 -21
- package/dist/loaders/pre-bundle-preamble.d.ts.map +1 -1
- package/dist/loaders/pre-bundle-preamble.js +0 -1
- package/dist/npm/cache.js +1 -1
- package/dist/npm/install-batch-facet.d.ts.map +1 -1
- package/dist/npm/install-batch-facet.js +7 -12
- package/dist/npm/installer.d.ts +5 -7
- package/dist/npm/installer.d.ts.map +1 -1
- package/dist/npm/installer.js +20 -101
- package/dist/npm/r2-cache.d.ts +17 -29
- package/dist/npm/r2-cache.d.ts.map +1 -1
- package/dist/npm/r2-cache.js +16 -27
- package/dist/npm/resolve-facet.d.ts +11 -17
- package/dist/npm/resolve-facet.d.ts.map +1 -1
- package/dist/npm/resolve-facet.js +14 -28
- package/dist/npm/resolve-one-facet.d.ts +10 -13
- package/dist/npm/resolve-one-facet.d.ts.map +1 -1
- package/dist/npm/resolve-one-facet.js +8 -10
- package/dist/npm/resolver.d.ts +0 -2
- package/dist/npm/resolver.d.ts.map +1 -1
- package/dist/npm/resolver.js +0 -12
- package/dist/observability/oom-discriminator.d.ts +0 -2
- package/dist/observability/oom-discriminator.d.ts.map +1 -1
- package/dist/observability/oom-discriminator.js +0 -2
- package/dist/replica/routing.js +1 -1
- package/dist/runtime/barrel-synthesizer.js +1 -1
- package/dist/runtime/clang-runner.d.ts +5 -6
- package/dist/runtime/clang-runner.d.ts.map +1 -1
- package/dist/runtime/clang-runner.js +5 -6
- package/dist/runtime/esbuild-service.d.ts.map +1 -1
- package/dist/runtime/esbuild-service.js +0 -3
- package/dist/runtime/framework-detect.d.ts +0 -1
- package/dist/runtime/framework-detect.d.ts.map +1 -1
- package/dist/runtime/framework-detect.js +0 -1
- package/dist/runtime/node-runner.d.ts +1 -1
- package/dist/runtime/node-runner.js +1 -1
- package/dist/runtime/node-shims.d.ts.map +1 -1
- package/dist/runtime/node-shims.js +0 -22
- package/dist/runtime/package-manager.d.ts +2 -7
- package/dist/runtime/package-manager.d.ts.map +1 -1
- package/dist/runtime/package-manager.js +2 -7
- package/dist/runtime/process-logs-api.js +1 -1
- package/dist/runtime/process-logs.d.ts +0 -1
- package/dist/runtime/process-logs.d.ts.map +1 -1
- package/dist/runtime/process-table.d.ts +2 -2
- package/dist/runtime/process-table.d.ts.map +1 -1
- package/dist/runtime/process-table.js +1 -1
- package/dist/runtime/python-repl.d.ts +0 -1
- package/dist/runtime/python-repl.d.ts.map +1 -1
- package/dist/runtime/python-repl.js +0 -1
- package/dist/runtime/python-runner.d.ts +1 -2
- package/dist/runtime/python-runner.d.ts.map +1 -1
- package/dist/runtime/python-runner.js +1 -3
- package/dist/runtime/repl-session.d.ts +0 -1
- package/dist/runtime/repl-session.d.ts.map +1 -1
- package/dist/runtime/repl-session.js +1 -2
- package/dist/runtime/require-resolver.d.ts.map +1 -1
- package/dist/runtime/require-resolver.js +1 -4
- package/dist/runtime/ruby-runner.d.ts +0 -1
- package/dist/runtime/ruby-runner.d.ts.map +1 -1
- package/dist/runtime/ruby-runner.js +0 -1
- package/dist/runtime/runtime-catalog.d.ts +2 -4
- package/dist/runtime/runtime-catalog.d.ts.map +1 -1
- package/dist/runtime/runtime-catalog.js +2 -4
- package/dist/runtime/runtime-registry.d.ts +1 -1
- package/dist/runtime/runtime-registry.js +1 -1
- package/dist/runtime/streams.d.ts.map +1 -1
- package/dist/runtime/streams.js +0 -1
- package/dist/runtime/wasi-instance.d.ts +35 -45
- package/dist/runtime/wasi-instance.d.ts.map +1 -1
- package/dist/runtime/wasi-instance.js +87 -103
- package/dist/runtime/wasm-runner.d.ts +9 -15
- package/dist/runtime/wasm-runner.d.ts.map +1 -1
- package/dist/runtime/wasm-runner.js +23 -29
- package/dist/session/bindings.d.ts +2 -7
- package/dist/session/bindings.d.ts.map +1 -1
- package/dist/session/bindings.js +3 -8
- package/dist/session/helpers.d.ts +2 -9
- package/dist/session/helpers.d.ts.map +1 -1
- package/dist/session/helpers.js +2 -10
- package/dist/session/init.d.ts +3 -6
- package/dist/session/init.d.ts.map +1 -1
- package/dist/session/init.js +25 -30
- package/dist/session/nimbus-session.d.ts +1 -1
- package/dist/session/nimbus-session.js +5 -5
- package/dist/session/routes.d.ts.map +1 -1
- package/dist/session/routes.js +9 -16
- package/dist/session/rpc.d.ts +2 -2
- package/dist/session/rpc.js +6 -6
- package/dist/session/supervisor-rpc.d.ts +1 -2
- package/dist/session/supervisor-rpc.d.ts.map +1 -1
- package/dist/session/supervisor-rpc.js +1 -5
- package/dist/shell/features.d.ts +5 -5
- package/dist/shell/features.js +6 -6
- package/dist/shell/unix-commands.js +15 -15
- package/dist/vfs/dev-provider.d.ts +1 -1
- package/dist/vfs/dev-provider.js +1 -1
- package/dist/vfs/sqlite-vfs.d.ts +3 -3
- package/dist/vfs/sqlite-vfs.d.ts.map +1 -1
- package/dist/vfs/sqlite-vfs.js +10 -11
- package/package.json +12 -2
- package/public/s/index.html +44 -75
- package/scripts/bundle-facet-workers.mjs +1 -1
- package/scripts/bundle-git.mjs +1 -1
package/dist/vfs/sqlite-vfs.js
CHANGED
|
@@ -96,11 +96,11 @@ export class SqliteVFS {
|
|
|
96
96
|
* (deferWrite/clearPendingWritesForPath/flushPendingWrites/
|
|
97
97
|
* cleanupAfterDelete). Read by getStats() so /api/_diag/memory's
|
|
98
98
|
* `heap.breakdown.vfsInFlightBytes` is no longer a hardcoded 0.
|
|
99
|
-
* (N3,
|
|
99
|
+
* (N3, memory accounting cleanup.)
|
|
100
100
|
*/
|
|
101
101
|
_pendingWriteBytes = 0;
|
|
102
102
|
/**
|
|
103
|
-
* N2 (
|
|
103
|
+
* N2 (memory accounting cleanup). Sum of bytes currently held in the
|
|
104
104
|
* `chunks: []` spool inside writeStream(). Maintained per-chunk so
|
|
105
105
|
* a long-running drain shows live, not the steady-state 0.
|
|
106
106
|
* Reset (or decremented to the drained amount) inside writeStream's
|
|
@@ -481,7 +481,7 @@ export class SqliteVFS {
|
|
|
481
481
|
// ── Deferred batch writes (do86 pattern) ──────────────────────────────
|
|
482
482
|
deferWrite(path, chunkId, data) {
|
|
483
483
|
const key = this.cacheKey(path, chunkId);
|
|
484
|
-
// SINGLE-OWNERSHIP BOUNDARY (H10 audit,
|
|
484
|
+
// SINGLE-OWNERSHIP BOUNDARY (H10 audit, memory accounting cleanup).
|
|
485
485
|
//
|
|
486
486
|
// `data` is one of:
|
|
487
487
|
// - a `subarray` view into the caller's source ArrayBuffer
|
|
@@ -497,7 +497,7 @@ export class SqliteVFS {
|
|
|
497
497
|
// (slice + this) per chunk.
|
|
498
498
|
//
|
|
499
499
|
// _pendingWriteBytes counter is the source-of-truth for N3
|
|
500
|
-
// (
|
|
500
|
+
// (memory accounting cleanup): the `vfsInFlightBytes` heap-estimator
|
|
501
501
|
// contributor reads from it.
|
|
502
502
|
const copy = new Uint8Array(data.length);
|
|
503
503
|
copy.set(data);
|
|
@@ -854,7 +854,7 @@ export class SqliteVFS {
|
|
|
854
854
|
// The deferred write handles persistence; cache entry stays clean
|
|
855
855
|
// to avoid double-writing when the entry is eventually evicted.
|
|
856
856
|
//
|
|
857
|
-
// H10 (
|
|
857
|
+
// H10 (memory accounting cleanup) — `data.slice(...)` here used to
|
|
858
858
|
// allocate a brand-new chunk-sized ArrayBuffer per chunk. Combined
|
|
859
859
|
// with `deferWrite`'s defensive copy at the persistence boundary
|
|
860
860
|
// (sqlite-vfs.ts:_deferWriteCopyForOwnership), the loop transient
|
|
@@ -1050,7 +1050,7 @@ export class SqliteVFS {
|
|
|
1050
1050
|
const inode = this.inodes.get(oldPath);
|
|
1051
1051
|
if (!inode)
|
|
1052
1052
|
throw new Error("ENOENT: " + oldPath);
|
|
1053
|
-
// W-3 (WASI
|
|
1053
|
+
// W-3 (WASI filesystem WASI): if newPath already exists, unlink it first so the
|
|
1054
1054
|
// SQL UPDATE doesn't conflict on inodes.path uniqueness. POSIX rename(2)
|
|
1055
1055
|
// overwrites the destination atomically; clang's atomic-write pattern
|
|
1056
1056
|
// (write tmp + rename → final) depends on this. Without this branch,
|
|
@@ -1171,7 +1171,7 @@ export class SqliteVFS {
|
|
|
1171
1171
|
* heap estimator. We now maintain `_writeStreamSpoolBytes` that
|
|
1172
1172
|
* tracks the live spool contents during the drain; the diag's
|
|
1173
1173
|
* vfsInFlightBytes contributor now sums pendingWriteBytes +
|
|
1174
|
-
* writeStreamSpoolBytes. The N2
|
|
1174
|
+
* writeStreamSpoolBytes. The N2 failing probe asserts on this sum.
|
|
1175
1175
|
*
|
|
1176
1176
|
* Throws on SQLITE_NOMEM (with halve-retry per writeBatch); any
|
|
1177
1177
|
* iterator-source error propagates unchanged. Atomicity guarantee
|
|
@@ -1183,7 +1183,7 @@ export class SqliteVFS {
|
|
|
1183
1183
|
// We build the chunks array fully BEFORE entering transactionSync
|
|
1184
1184
|
// because transactionSync is synchronous (cannot await mid-txn).
|
|
1185
1185
|
//
|
|
1186
|
-
// N2 (
|
|
1186
|
+
// N2 (memory accounting cleanup): track spool bytes so the diag
|
|
1187
1187
|
// estimator's vfsInFlightBytes is no longer a 0 lie. Increment
|
|
1188
1188
|
// per chunk pushed; reset to 0 immediately before delegating to
|
|
1189
1189
|
// writeBatch (the bytes are now `pendingWrites' problem if they
|
|
@@ -1427,7 +1427,6 @@ export class SqliteVFS {
|
|
|
1427
1427
|
// B3: also maintain running counters in sync. For each payload entry,
|
|
1428
1428
|
// compute the delta against any pre-existing inode at that path.
|
|
1429
1429
|
//
|
|
1430
|
-
// W2.5a (audit/sections/W2.5-plan.md): the children-index call is now
|
|
1431
1430
|
// OUTSIDE the `prior === undefined` guard. Pre-W2.5a, ~37 of 46 packages
|
|
1432
1431
|
// per `npm install fastify` accumulated inodes in SQL but never reached
|
|
1433
1432
|
// the in-memory `this.children` index because some path's `prior` was
|
|
@@ -1608,14 +1607,14 @@ export class SqliteVFS {
|
|
|
1608
1607
|
batchWrites: this._batchWrites,
|
|
1609
1608
|
batchWriteRows: this._batchWriteRows,
|
|
1610
1609
|
pendingWrites: this.pendingWrites.size,
|
|
1611
|
-
// N3 (
|
|
1610
|
+
// N3 (memory accounting cleanup): real byte sum of the
|
|
1612
1611
|
// pendingWrites Map. Source-of-truth for the heap-estimator's
|
|
1613
1612
|
// vfsInFlightBytes contributor (was hardcoded 0 at routes.ts:347
|
|
1614
1613
|
// pre-fix). Adding this AS WELL AS the entry count above so
|
|
1615
1614
|
// ops dashboards that already plot the count don't break, while
|
|
1616
1615
|
// memory triage gets the actual byte number.
|
|
1617
1616
|
pendingWriteBytes: this._pendingWriteBytes,
|
|
1618
|
-
// N2 (
|
|
1617
|
+
// N2 (memory accounting cleanup): live byte count inside the
|
|
1619
1618
|
// writeStream() drain spool. Non-zero only during the brief
|
|
1620
1619
|
// window between the first chunk arriving and writeBatch
|
|
1621
1620
|
// returning — bounded by SHARED_RPC_FLUSH_THRESHOLD (4 MiB)
|
package/package.json
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nimbus-sh/worker",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "Nimbus runtime package for Cloudflare Workers, re-exported publicly through @nimbus-sh/sdk/worker.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"cloudflare",
|
|
7
|
+
"workers",
|
|
8
|
+
"durable-objects",
|
|
9
|
+
"webassembly",
|
|
10
|
+
"sandbox",
|
|
11
|
+
"runtime"
|
|
12
|
+
],
|
|
5
13
|
"homepage": "https://github.com/AshishKumar4/Nimbus",
|
|
6
14
|
"repository": {
|
|
7
15
|
"type": "git",
|
|
@@ -38,7 +46,9 @@
|
|
|
38
46
|
"dist",
|
|
39
47
|
"public",
|
|
40
48
|
"scripts",
|
|
41
|
-
"README.md"
|
|
49
|
+
"README.md",
|
|
50
|
+
"LICENSE",
|
|
51
|
+
"NOTICE.md"
|
|
42
52
|
],
|
|
43
53
|
"scripts": {
|
|
44
54
|
"bundle:git": "node scripts/bundle-git.mjs",
|
package/public/s/index.html
CHANGED
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
/* Resize handle */
|
|
85
85
|
.resize-handle { width: 4px; background: #30363d; cursor: col-resize; flex-shrink: 0; }
|
|
86
86
|
.resize-handle:hover { background: #58a6ff; }
|
|
87
|
-
/*
|
|
87
|
+
/* Vertical resize handle for editor (top) ↔
|
|
88
88
|
terminal (bottom) inside the editor-stack column. Hidden outside
|
|
89
89
|
editor mode (rule under .main.editor below). */
|
|
90
90
|
.vresize-handle {
|
|
@@ -119,12 +119,8 @@
|
|
|
119
119
|
.main.preview-only .resize-handle { display: none; }
|
|
120
120
|
.main.preview-only .panel-preview { flex: 1; }
|
|
121
121
|
|
|
122
|
-
/*
|
|
123
|
-
Editor layout mode — 4-pane VSCode-style:
|
|
122
|
+
/* Editor layout mode:
|
|
124
123
|
FILE TREE | editor-stack (editor TOP + terminal BOTTOM) | PREVIEW
|
|
125
|
-
Single mode: 'editor'. Dropped earlier 'editor-split' (editor+preview
|
|
126
|
-
without terminal) per user feedback "I don't need 'edit + preview'
|
|
127
|
-
at all". Renamed 'editor-split-with-term' → 'editor' for clarity.
|
|
128
124
|
|
|
129
125
|
Editor + terminal live INSIDE .panel-left-stack. In 1D modes
|
|
130
126
|
(terminal-only / split / preview-only) the stack is
|
|
@@ -144,7 +140,7 @@
|
|
|
144
140
|
modes (transparent). flex column in editor mode. */
|
|
145
141
|
.panel-left-stack { display: contents; }
|
|
146
142
|
|
|
147
|
-
/*
|
|
143
|
+
/* File-tree sidebar. Lives as a FIRST child of
|
|
148
144
|
.main; visible only in 'editor' mode. ~250px default width,
|
|
149
145
|
resizable via .tree-resize-handle. */
|
|
150
146
|
.panel-tree {
|
|
@@ -232,7 +228,7 @@
|
|
|
232
228
|
font-size: 11px; text-align: center;
|
|
233
229
|
}
|
|
234
230
|
|
|
235
|
-
/* Editor layout
|
|
231
|
+
/* Editor layout: file tree | editor-stack | preview */
|
|
236
232
|
.main.editor .panel-tree { display: flex; }
|
|
237
233
|
.main.editor .tree-resize-handle { display: block; }
|
|
238
234
|
.main.editor .panel-left-stack {
|
|
@@ -298,9 +294,8 @@
|
|
|
298
294
|
<button id="btnTerminal" class="active" title="Terminal">Terminal</button>
|
|
299
295
|
<button id="btnPreview" title="Preview">Preview</button>
|
|
300
296
|
<button id="btnSplit" title="Split view">Split</button>
|
|
301
|
-
<!--
|
|
302
|
-
|
|
303
|
-
Layout: file tree | editor (top) + terminal (bottom) | preview.
|
|
297
|
+
<!-- Single canonical editor mode:
|
|
298
|
+
file tree | editor (top) + terminal (bottom) | preview.
|
|
304
299
|
Lazy-loads Monaco + the tree on first click. -->
|
|
305
300
|
<button id="btnEditor" title="Editor (file tree + Monaco + terminal + preview)">Editor</button>
|
|
306
301
|
<div class="sep"></div>
|
|
@@ -313,7 +308,7 @@
|
|
|
313
308
|
<span class="vite-status" id="viteStatus"></span>
|
|
314
309
|
</div>
|
|
315
310
|
<div class="main" id="mainPanel">
|
|
316
|
-
<!--
|
|
311
|
+
<!-- File-tree sidebar. Visible ONLY
|
|
317
312
|
in editor mode (CSS toggles display:flex on .main.editor).
|
|
318
313
|
The .tree-resize-handle sits between tree and editor stack;
|
|
319
314
|
dragging it adjusts .panel-tree's width inline. -->
|
|
@@ -330,12 +325,11 @@
|
|
|
330
325
|
<div class="tree-body" id="treeBody"></div>
|
|
331
326
|
</div>
|
|
332
327
|
<div class="tree-resize-handle" id="treeResizeHandle"></div>
|
|
333
|
-
<!--
|
|
334
|
-
The .panel-left-stack wrapper is display:contents in 1D modes
|
|
328
|
+
<!-- The .panel-left-stack wrapper is display:contents in 1D modes
|
|
335
329
|
(terminal-only, split, preview-only) — its children act as
|
|
336
|
-
direct flex children of .main. In editor mode
|
|
337
|
-
|
|
338
|
-
|
|
330
|
+
direct flex children of .main. In editor mode, CSS flips it to
|
|
331
|
+
display:flex so editor and terminal stack vertically in the middle
|
|
332
|
+
column. -->
|
|
339
333
|
<div class="panel-left-stack" id="leftStack">
|
|
340
334
|
<div class="panel-editor" id="editorPanel">
|
|
341
335
|
<div class="editor-bar">
|
|
@@ -358,7 +352,7 @@
|
|
|
358
352
|
<span id="editorStatusEnc">UTF-8</span>
|
|
359
353
|
</div>
|
|
360
354
|
</div>
|
|
361
|
-
<!--
|
|
355
|
+
<!-- Vertical resize handle between
|
|
362
356
|
editor (top) and terminal (bottom) inside the editor-stack
|
|
363
357
|
column. Visible only in editor mode (.main.editor). -->
|
|
364
358
|
<div class="vresize-handle" id="editorTerminalResizeHandle"></div>
|
|
@@ -380,9 +374,8 @@
|
|
|
380
374
|
<iframe id="preview-frame" src="about:blank"></iframe>
|
|
381
375
|
</div>
|
|
382
376
|
</div>
|
|
383
|
-
<!--
|
|
384
|
-
|
|
385
|
-
editor session. -->
|
|
377
|
+
<!-- Ctrl+P command palette. Lazy-populated fuzzy file finder; fs-list
|
|
378
|
+
is sent on first open per editor session. -->
|
|
386
379
|
<div class="palette-overlay" id="paletteOverlay">
|
|
387
380
|
<div class="palette-box">
|
|
388
381
|
<input class="palette-input" id="paletteInput" placeholder="Type a file name…" autocomplete="off" spellcheck="false">
|
|
@@ -485,11 +478,8 @@
|
|
|
485
478
|
const mainPanel = document.getElementById('mainPanel');
|
|
486
479
|
const viteStatus = document.getElementById('viteStatus');
|
|
487
480
|
let ws = null, rd = 1000, statsTimer = null;
|
|
488
|
-
//
|
|
489
|
-
//
|
|
490
|
-
// 'editor-split-with-term' (renamed → 'editor'). Layout:
|
|
491
|
-
// file tree | editor (top) + terminal (bottom) | preview
|
|
492
|
-
// Old modes preserved verbatim: 'split', 'terminal-only', 'preview-only'.
|
|
481
|
+
// Current layout modes. Editor mode keeps the file tree, Monaco,
|
|
482
|
+
// terminal, and preview visible together.
|
|
493
483
|
let layout = 'split';
|
|
494
484
|
|
|
495
485
|
// ── Layout controls ──
|
|
@@ -511,7 +501,7 @@
|
|
|
511
501
|
FileTree.ensureLoaded();
|
|
512
502
|
}
|
|
513
503
|
setTimeout(() => {
|
|
514
|
-
//
|
|
504
|
+
// Re-apply persisted pane dims for this layout.
|
|
515
505
|
// PaneResizer uses inline flex which is mode-specific (split vs
|
|
516
506
|
// editor have different pane structures); onLayoutChange picks
|
|
517
507
|
// the right elements for the active mode.
|
|
@@ -532,7 +522,7 @@
|
|
|
532
522
|
document.getElementById('btnRefresh').onclick = () => reloadPreview();
|
|
533
523
|
document.getElementById('btnReloadPreview').onclick = () => reloadPreview();
|
|
534
524
|
|
|
535
|
-
// ──
|
|
525
|
+
// ── Editor module ──
|
|
536
526
|
//
|
|
537
527
|
// Lazy-loads Monaco via cdnjs UMD on first call to ensureLoaded().
|
|
538
528
|
// Cold session (terminal-only flow) never pays the ~5MB download.
|
|
@@ -541,9 +531,7 @@
|
|
|
541
531
|
// All fs operations route through the live WS via fs-read /
|
|
542
532
|
// fs-write / fs-list messages → init.ts handler → SqliteVFS.
|
|
543
533
|
//
|
|
544
|
-
// Perf-invariant:
|
|
545
|
-
// cold terminal-only session (see tests/behavioral/monaco-wave-a/
|
|
546
|
-
// new/monaco-lazy-not-on-cold.mjs).
|
|
534
|
+
// Perf-invariant: Monaco is not loaded on cold terminal-only sessions.
|
|
547
535
|
const Editor = (function() {
|
|
548
536
|
// CDN choice: cdnjs hosts Monaco's UMD AMD-loader (`loader.min.js`)
|
|
549
537
|
// which fetches the remaining vs/* chunks on demand. Total cold
|
|
@@ -589,11 +577,8 @@
|
|
|
589
577
|
// Send a fs-* message; await the paired result. Resolves with the
|
|
590
578
|
// result frame; rejects on error or timeout (15s — generous for
|
|
591
579
|
// big trees, tight enough that a hung session surfaces fast).
|
|
592
|
-
//
|
|
593
|
-
//
|
|
594
|
-
// WS not connected" when clicking Editor before terminal prompt.
|
|
595
|
-
//
|
|
596
|
-
// Race window: connect() runs at page-load and ws is in CONNECTING
|
|
580
|
+
// Queue fs-* frames sent before ws.onopen fires. Race window:
|
|
581
|
+
// connect() runs at page-load and ws is in CONNECTING
|
|
597
582
|
// state (readyState === 0). If the user clicks Editor BEFORE
|
|
598
583
|
// ws.onopen fires, setLayout('editor') invokes Editor.ensureLoaded
|
|
599
584
|
// → eventually fsRequest, which pre-fix rejected synchronously.
|
|
@@ -722,10 +707,7 @@
|
|
|
722
707
|
const ph = document.getElementById('editorPlaceholder');
|
|
723
708
|
if (ph) ph.style.display = 'none';
|
|
724
709
|
|
|
725
|
-
//
|
|
726
|
-
// (per user feedback "current is useless — make it proper, nice").
|
|
727
|
-
// This config mirrors VSCode 1.95+ defaults for a TS/JS file.
|
|
728
|
-
// Verified against actual VSCode source (monaco.IEditorOptions).
|
|
710
|
+
// VS Code-like editor defaults for TS/JS files.
|
|
729
711
|
editor = window.monaco.editor.create(container, {
|
|
730
712
|
value: '',
|
|
731
713
|
language: 'plaintext',
|
|
@@ -843,9 +825,8 @@
|
|
|
843
825
|
|
|
844
826
|
async function openFile(path) {
|
|
845
827
|
if (!path) return;
|
|
846
|
-
//
|
|
847
|
-
//
|
|
848
|
-
// to (a) save first, (b) discard and switch, or (c) cancel.
|
|
828
|
+
// Dirty-prompt before switching files. If the current buffer has
|
|
829
|
+
// unsaved changes, ask the user whether to save or discard.
|
|
849
830
|
// Skip when switching to the SAME file (no-op) or when there
|
|
850
831
|
// is no editor yet.
|
|
851
832
|
if (editor && openPath && openPath !== path) {
|
|
@@ -895,8 +876,7 @@
|
|
|
895
876
|
if (statusLang) statusLang.textContent = lang;
|
|
896
877
|
const statusPos = document.getElementById('editorStatusPos');
|
|
897
878
|
if (statusPos) statusPos.textContent = 'Ln 1, Col 1';
|
|
898
|
-
//
|
|
899
|
-
// palette/Ctrl+P opens highlight the row).
|
|
879
|
+
// Mirror palette/Ctrl+P selection into the file tree.
|
|
900
880
|
if (typeof FileTree !== 'undefined') {
|
|
901
881
|
try { FileTree.setSelected(path); FileTree.markDirty(path, false); } catch {}
|
|
902
882
|
}
|
|
@@ -1038,8 +1018,7 @@
|
|
|
1038
1018
|
}
|
|
1039
1019
|
});
|
|
1040
1020
|
|
|
1041
|
-
//
|
|
1042
|
-
// Cmd+P 5s-TTL palette cache. Called by the fs-watch-event
|
|
1021
|
+
// External invalidation of the Cmd+P 5s-TTL palette cache. Called by the fs-watch-event
|
|
1043
1022
|
// dispatcher in ws.onmessage so a terminal-side write makes
|
|
1044
1023
|
// the next openPalette re-run fs-list instead of serving
|
|
1045
1024
|
// stale results.
|
|
@@ -1051,7 +1030,7 @@
|
|
|
1051
1030
|
return { ensureLoaded, openFile, save, openPalette, tryHandleFsResult, drainFsQueue, invalidateFileListCache };
|
|
1052
1031
|
})();
|
|
1053
1032
|
|
|
1054
|
-
// ──
|
|
1033
|
+
// ── FileTree module ──
|
|
1055
1034
|
//
|
|
1056
1035
|
// VSCode-style left sidebar showing the user VFS (rooted at
|
|
1057
1036
|
// /home/user). Lazy-loads on first editor-mode activation. Tree
|
|
@@ -1109,8 +1088,8 @@
|
|
|
1109
1088
|
const expanded = loadExpandedSet();
|
|
1110
1089
|
expanded.add(ROOT);
|
|
1111
1090
|
|
|
1112
|
-
//
|
|
1113
|
-
//
|
|
1091
|
+
// Outbound queue mirrors Editor.fsRequest for the same websocket
|
|
1092
|
+
// connection race.
|
|
1114
1093
|
const outQueue = [];
|
|
1115
1094
|
function fsRequest(frame, resultType) {
|
|
1116
1095
|
const reqId = nextReqId++;
|
|
@@ -1426,10 +1405,8 @@
|
|
|
1426
1405
|
btnRefresh.addEventListener('click', refreshTree);
|
|
1427
1406
|
searchInput.addEventListener('input', rerender);
|
|
1428
1407
|
|
|
1429
|
-
//
|
|
1430
|
-
//
|
|
1431
|
-
// handles share a single persistence layer. Inline width is
|
|
1432
|
-
// restored from localStorage in PaneResizer.restoreDims().
|
|
1408
|
+
// Tree resize is owned by PaneResizer so all handles share one
|
|
1409
|
+
// persistence layer. Inline width is restored from localStorage.
|
|
1433
1410
|
|
|
1434
1411
|
// Mark a path dirty in the tree (called by Editor when buffer
|
|
1435
1412
|
// diverges from disk).
|
|
@@ -1441,7 +1418,7 @@
|
|
|
1441
1418
|
rerender();
|
|
1442
1419
|
}
|
|
1443
1420
|
|
|
1444
|
-
// ──
|
|
1421
|
+
// ── File-watch subscribe + event apply ─────
|
|
1445
1422
|
//
|
|
1446
1423
|
// Server-side fs-watch protocol (src/session/fs-watch.ts):
|
|
1447
1424
|
//
|
|
@@ -1527,7 +1504,7 @@
|
|
|
1527
1504
|
}, WATCH_COALESCE_MS);
|
|
1528
1505
|
}
|
|
1529
1506
|
|
|
1530
|
-
//
|
|
1507
|
+
// Dispatch an inbound fs-watch-event frame to
|
|
1531
1508
|
// the tree's incremental refresh pipeline. Returns true if the
|
|
1532
1509
|
// frame was consumed (caller short-circuits the rest of its
|
|
1533
1510
|
// onmessage chain), false otherwise.
|
|
@@ -1660,7 +1637,7 @@
|
|
|
1660
1637
|
}
|
|
1661
1638
|
}
|
|
1662
1639
|
|
|
1663
|
-
// ──
|
|
1640
|
+
// ── Pane resize manager ──
|
|
1664
1641
|
//
|
|
1665
1642
|
// Owns the 3 resize handles in editor mode + 1 in split mode:
|
|
1666
1643
|
// H1 tree ↔ editor-stack (col, in editor mode) — TreeResizeHandle in FileTree IIFE
|
|
@@ -1897,17 +1874,12 @@
|
|
|
1897
1874
|
ws.onopen = () => {
|
|
1898
1875
|
setStatus('connected'); rd = 1000;
|
|
1899
1876
|
ws.send(JSON.stringify({type:'resize',cols:term.cols,rows:term.rows}));
|
|
1900
|
-
//
|
|
1901
|
-
//
|
|
1902
|
-
// was a cold session where clicking Editor before the first
|
|
1903
|
-
// ws.onopen produced "fs-list failed: WS not connected".
|
|
1904
|
-
// Drain order doesn't matter — server processes per-reqId.
|
|
1877
|
+
// Drain any fs-* frames that Editor / FileTree queued before WS
|
|
1878
|
+
// opened. Drain order does not matter; the server routes by reqId.
|
|
1905
1879
|
try { if (typeof Editor !== 'undefined') Editor.drainFsQueue(); } catch {}
|
|
1906
1880
|
try { if (typeof FileTree !== 'undefined') FileTree.drainFsQueue(); } catch {}
|
|
1907
|
-
//
|
|
1908
|
-
//
|
|
1909
|
-
// (e.g. `touch foo.c`) appear in the sidebar within ~150 ms
|
|
1910
|
-
// without needing a manual refresh click.
|
|
1881
|
+
// Subscribe the FileTree to server-pushed fs-watch-event frames so
|
|
1882
|
+
// terminal-side writes appear without a manual refresh click.
|
|
1911
1883
|
try { if (typeof FileTree !== 'undefined') FileTree.subscribeOnce(); } catch {}
|
|
1912
1884
|
refreshStats();
|
|
1913
1885
|
if (statsTimer) clearInterval(statsTimer);
|
|
@@ -1924,14 +1896,13 @@
|
|
|
1924
1896
|
ws.onmessage = (e) => {
|
|
1925
1897
|
try {
|
|
1926
1898
|
const msg = JSON.parse(e.data);
|
|
1927
|
-
//
|
|
1928
|
-
//
|
|
1929
|
-
//
|
|
1899
|
+
// fs-*-result frames route to the editor's pending-request
|
|
1900
|
+
// resolver. Return early so shell dispatch does not see them
|
|
1901
|
+
// as unknown types.
|
|
1930
1902
|
if (Editor.tryHandleFsResult(msg)) return;
|
|
1931
|
-
//
|
|
1903
|
+
// FileTree consumes fs-list results too.
|
|
1932
1904
|
if (FileTree.tryHandleFsResult(msg)) return;
|
|
1933
|
-
//
|
|
1934
|
-
// frames (no reqId) route to FileTree.applyWatchEvent which
|
|
1905
|
+
// Server-pushed fs-watch-event frames route to FileTree, which
|
|
1935
1906
|
// coalesces per-parent refreshes on a 100ms window.
|
|
1936
1907
|
if (FileTree.applyWatchEvent(msg)) return;
|
|
1937
1908
|
if (msg.type === 'output') {
|
|
@@ -2367,9 +2338,7 @@
|
|
|
2367
2338
|
// and ProcessTable is populated by then, no arbitrary delay needed.
|
|
2368
2339
|
|
|
2369
2340
|
term.focus();
|
|
2370
|
-
//
|
|
2371
|
-
// Restore any persisted pane dims (tree width, middle/preview ratio,
|
|
2372
|
-
// editor/terminal ratio) BEFORE activating layout so the first paint
|
|
2341
|
+
// Restore persisted pane dims before activating layout so the first paint
|
|
2373
2342
|
// shows the user's prior arrangement.
|
|
2374
2343
|
PaneResizer.restoreDims();
|
|
2375
2344
|
setLayout('editor');
|
|
@@ -47,6 +47,7 @@ async function bundleAsPreamble(entryPath, label) {
|
|
|
47
47
|
format: 'esm',
|
|
48
48
|
target: 'esnext',
|
|
49
49
|
platform: 'neutral',
|
|
50
|
+
absWorkingDir: root,
|
|
50
51
|
write: false,
|
|
51
52
|
logLevel: 'warning',
|
|
52
53
|
legalComments: 'none',
|
|
@@ -106,7 +107,6 @@ async function main() {
|
|
|
106
107
|
' * W7-frame symbols: encodeWriteBatchStream, decodeWriteBatchStream,',
|
|
107
108
|
' * W7_MAGIC, W7_TRAILER.',
|
|
108
109
|
' *',
|
|
109
|
-
` * Generated at: ${new Date().toISOString()}`,
|
|
110
110
|
` * Tar size: ${(tarStripped.length / 1024).toFixed(2)} KiB`,
|
|
111
111
|
` * W7 size: ${(w7Stripped.length / 1024).toFixed(2)} KiB`,
|
|
112
112
|
' */',
|
package/scripts/bundle-git.mjs
CHANGED
|
@@ -47,6 +47,7 @@ async function main() {
|
|
|
47
47
|
format: 'esm',
|
|
48
48
|
target: 'esnext',
|
|
49
49
|
platform: 'browser',
|
|
50
|
+
absWorkingDir: root,
|
|
50
51
|
conditions: ['worker', 'browser', 'import'],
|
|
51
52
|
// Map bare node built-ins → node: prefixed (works with nodejs_compat).
|
|
52
53
|
alias: {
|
|
@@ -87,7 +88,6 @@ async function main() {
|
|
|
87
88
|
' * Consumed by git-network-facet.ts: passed to LOADER.load()\'s',
|
|
88
89
|
' * `modules` record so the facet can `import` isomorphic-git.',
|
|
89
90
|
' *',
|
|
90
|
-
` * Generated at: ${new Date().toISOString()}`,
|
|
91
91
|
` * Size: ${(code.length / 1024).toFixed(1)} KiB`,
|
|
92
92
|
' */',
|
|
93
93
|
'',
|