@nimbus-sh/worker 0.5.0 → 0.7.0

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.
Files changed (164) hide show
  1. package/README.md +2 -2
  2. package/dist/_shared/preview-host.d.ts +26 -8
  3. package/dist/_shared/preview-host.d.ts.map +1 -1
  4. package/dist/_shared/preview-host.js +51 -11
  5. package/dist/cirrus-npm-cjs.generated.d.ts +1 -1
  6. package/dist/cirrus-npm-cjs.generated.js +1 -1
  7. package/dist/facets/cirrus-real.d.ts.map +1 -1
  8. package/dist/facets/cirrus-real.js +6 -5
  9. package/dist/facets/compose.d.ts +148 -0
  10. package/dist/facets/compose.d.ts.map +1 -0
  11. package/dist/facets/compose.js +146 -0
  12. package/dist/facets/durable-images.d.ts +18 -5
  13. package/dist/facets/durable-images.d.ts.map +1 -1
  14. package/dist/facets/durable-images.js +36 -7
  15. package/dist/facets/durable-slots.d.ts +1 -1
  16. package/dist/facets/durable-slots.d.ts.map +1 -1
  17. package/dist/facets/durable-slots.js +2 -1
  18. package/dist/facets/esbuild-bundle-pool.d.ts +49 -0
  19. package/dist/facets/esbuild-bundle-pool.d.ts.map +1 -0
  20. package/dist/facets/esbuild-bundle-pool.js +122 -0
  21. package/dist/facets/exec-telemetry.d.ts +8 -0
  22. package/dist/facets/exec-telemetry.d.ts.map +1 -1
  23. package/dist/facets/manager.d.ts +337 -123
  24. package/dist/facets/manager.d.ts.map +1 -1
  25. package/dist/facets/manager.js +1100 -449
  26. package/dist/facets/process.d.ts +20 -16
  27. package/dist/facets/process.d.ts.map +1 -1
  28. package/dist/facets/process.js +59 -28
  29. package/dist/facets/real-vite-fs-shim.js +2 -2
  30. package/dist/facets/resident-identity.d.ts +23 -0
  31. package/dist/facets/resident-identity.d.ts.map +1 -0
  32. package/dist/facets/resident-identity.js +31 -0
  33. package/dist/facets/vite-dev-server.d.ts +25 -47
  34. package/dist/facets/vite-dev-server.d.ts.map +1 -1
  35. package/dist/facets/vite-dev-server.js +185 -219
  36. package/dist/facets/wasm-image-digest.d.ts +25 -0
  37. package/dist/facets/wasm-image-digest.d.ts.map +1 -0
  38. package/dist/facets/wasm-image-digest.js +25 -0
  39. package/dist/facets/wasm-swap-registry.d.ts +51 -92
  40. package/dist/facets/wasm-swap-registry.d.ts.map +1 -1
  41. package/dist/facets/wasm-swap-registry.js +68 -227
  42. package/dist/git/commands.d.ts +0 -1
  43. package/dist/git/commands.d.ts.map +1 -1
  44. package/dist/git/commands.js +0 -3
  45. package/dist/git/network-facet.d.ts.map +1 -1
  46. package/dist/git/network-facet.js +6 -5
  47. package/dist/loaders/child-process/spawn-pool.d.ts +3 -2
  48. package/dist/loaders/child-process/spawn-pool.d.ts.map +1 -1
  49. package/dist/loaders/child-process/spawn-pool.js +3 -2
  50. package/dist/loaders/generated-workers.d.ts +2 -2
  51. package/dist/loaders/generated-workers.d.ts.map +1 -1
  52. package/dist/loaders/generated-workers.js +3 -3
  53. package/dist/loaders/npm-resolve-preamble.d.ts +3 -6
  54. package/dist/loaders/npm-resolve-preamble.d.ts.map +1 -1
  55. package/dist/loaders/npm-resolve-preamble.js +34 -108
  56. package/dist/node-shims-artifact.generated.js +3 -3
  57. package/dist/npm/install-batch-facet.d.ts +3 -2
  58. package/dist/npm/install-batch-facet.d.ts.map +1 -1
  59. package/dist/npm/install-batch-facet.js +45 -15
  60. package/dist/npm/installer.d.ts +22 -17
  61. package/dist/npm/installer.d.ts.map +1 -1
  62. package/dist/npm/installer.js +209 -193
  63. package/dist/npm/pre-bundle-facet.d.ts +1 -1
  64. package/dist/npm/pre-bundle-facet.d.ts.map +1 -1
  65. package/dist/npm/pre-bundle-facet.js +1 -1
  66. package/dist/npm/resolve-facet.d.ts +6 -0
  67. package/dist/npm/resolve-facet.d.ts.map +1 -1
  68. package/dist/npm/resolve-one-facet.d.ts +21 -20
  69. package/dist/npm/resolve-one-facet.d.ts.map +1 -1
  70. package/dist/npm/resolve-one-facet.js +85 -84
  71. package/dist/npm/semver.d.ts +59 -0
  72. package/dist/npm/semver.d.ts.map +1 -0
  73. package/dist/npm/semver.js +226 -0
  74. package/dist/router/index.d.ts.map +1 -1
  75. package/dist/router/index.js +47 -10
  76. package/dist/router/public-directory.d.ts +5 -1
  77. package/dist/router/public-directory.d.ts.map +1 -1
  78. package/dist/router/public-directory.js +9 -2
  79. package/dist/router/remote-api.d.ts +18 -0
  80. package/dist/router/remote-api.d.ts.map +1 -1
  81. package/dist/router/remote-api.js +64 -5
  82. package/dist/runtime/cpython-resident.d.ts.map +1 -1
  83. package/dist/runtime/cpython-resident.js +3 -1
  84. package/dist/runtime/html-entrypoint.d.ts +7 -0
  85. package/dist/runtime/html-entrypoint.d.ts.map +1 -1
  86. package/dist/runtime/html-entrypoint.js +18 -2
  87. package/dist/runtime/node-runner.d.ts +3 -0
  88. package/dist/runtime/node-runner.d.ts.map +1 -1
  89. package/dist/runtime/node-runner.js +7 -0
  90. package/dist/runtime/node-shims.d.ts.map +1 -1
  91. package/dist/runtime/node-shims.js +305 -29
  92. package/dist/runtime/opencode-facet-runner.js +2 -2
  93. package/dist/runtime/package-manager.d.ts +44 -1
  94. package/dist/runtime/package-manager.d.ts.map +1 -1
  95. package/dist/runtime/package-manager.js +168 -3
  96. package/dist/runtime/ruby-resident.d.ts.map +1 -1
  97. package/dist/runtime/ruby-resident.js +2 -0
  98. package/dist/session/agent.d.ts.map +1 -1
  99. package/dist/session/agent.js +28 -1
  100. package/dist/session/helpers.d.ts +38 -0
  101. package/dist/session/helpers.d.ts.map +1 -1
  102. package/dist/session/helpers.js +76 -0
  103. package/dist/session/init-phases.d.ts +1 -1
  104. package/dist/session/init-phases.d.ts.map +1 -1
  105. package/dist/session/init-phases.js +2 -12
  106. package/dist/session/init.d.ts +15 -1
  107. package/dist/session/init.d.ts.map +1 -1
  108. package/dist/session/init.js +91 -603
  109. package/dist/session/keys.d.ts +4 -0
  110. package/dist/session/keys.d.ts.map +1 -1
  111. package/dist/session/keys.js +4 -0
  112. package/dist/session/nimbus-session.d.ts +90 -23
  113. package/dist/session/nimbus-session.d.ts.map +1 -1
  114. package/dist/session/nimbus-session.js +200 -110
  115. package/dist/session/npm-install-port.d.ts +16 -0
  116. package/dist/session/npm-install-port.d.ts.map +1 -0
  117. package/dist/session/npm-install-port.js +37 -0
  118. package/dist/session/port-capability.d.ts +90 -0
  119. package/dist/session/port-capability.d.ts.map +1 -1
  120. package/dist/session/port-capability.js +219 -9
  121. package/dist/session/programmatic.d.ts +125 -5
  122. package/dist/session/programmatic.d.ts.map +1 -1
  123. package/dist/session/programmatic.js +439 -89
  124. package/dist/session/routes.d.ts +39 -17
  125. package/dist/session/routes.d.ts.map +1 -1
  126. package/dist/session/routes.js +67 -131
  127. package/dist/session/rpc.d.ts +39 -16
  128. package/dist/session/rpc.d.ts.map +1 -1
  129. package/dist/session/rpc.js +137 -130
  130. package/dist/session/serving-port.d.ts +27 -0
  131. package/dist/session/serving-port.d.ts.map +1 -0
  132. package/dist/session/serving-port.js +27 -0
  133. package/dist/session/start-real-vite.d.ts +12 -0
  134. package/dist/session/start-real-vite.d.ts.map +1 -1
  135. package/dist/session/start-real-vite.js +4 -4
  136. package/dist/session/supervisor-op.d.ts +41 -4
  137. package/dist/session/supervisor-op.d.ts.map +1 -1
  138. package/dist/session/supervisor-op.js +101 -73
  139. package/dist/session/supervisor-rpc.d.ts +7 -7
  140. package/dist/session/supervisor-rpc.d.ts.map +1 -1
  141. package/dist/session/supervisor-rpc.js +6 -3
  142. package/dist/session/vite-command.d.ts +18 -0
  143. package/dist/session/vite-command.d.ts.map +1 -0
  144. package/dist/session/vite-command.js +609 -0
  145. package/dist/session/ws.d.ts +61 -0
  146. package/dist/session/ws.d.ts.map +1 -1
  147. package/dist/session/ws.js +122 -12
  148. package/dist/shell/npm-bin-entrypoints.d.ts +0 -35
  149. package/dist/shell/npm-bin-entrypoints.d.ts.map +1 -1
  150. package/dist/shell/npm-bin-entrypoints.js +12 -85
  151. package/package.json +24 -4
  152. package/public/_assets/runtime/{node-shims-9e1380d9ee430fcc.js → node-shims-8f8c64edd2a1f0f5.js} +305 -29
  153. package/public/index.html +1 -1
  154. package/scripts/bundle-facet-workers.mjs +1 -1
  155. package/scripts/bundle-npm-cjs.mjs +2 -2
  156. package/dist/facets/on-demand-bundle-gate.d.ts +0 -65
  157. package/dist/facets/on-demand-bundle-gate.d.ts.map +0 -1
  158. package/dist/facets/on-demand-bundle-gate.js +0 -125
  159. package/dist/npm/install-args.d.ts +0 -21
  160. package/dist/npm/install-args.d.ts.map +0 -1
  161. package/dist/npm/install-args.js +0 -70
  162. package/dist/npm/npm-log.d.ts +0 -31
  163. package/dist/npm/npm-log.d.ts.map +0 -1
  164. package/dist/npm/npm-log.js +0 -51
@@ -0,0 +1,226 @@
1
+ /**
2
+ * npm/semver.ts — the one semver implementation the npm resolver picks
3
+ * versions with.
4
+ *
5
+ * The resolver facet (npm/resolve-one-facet.ts) runs inside a dynamic worker
6
+ * whose only module scope is the preamble string in
7
+ * loaders/npm-resolve-preamble.ts. That preamble embeds THESE functions by
8
+ * `fn.toString()`, so the facet's version pick is this module's by
9
+ * construction — there is no second copy to drift, and
10
+ * tests/unit/npm-semver.mjs asserts the embedded functions answer exactly
11
+ * as the exported ones do.
12
+ *
13
+ * Every function here is self-contained on purpose: no closures over module
14
+ * constants, no imports, only calls to the other functions in this file by
15
+ * name. `toString()` reproduces exactly that, and nothing else.
16
+ *
17
+ * What is implemented is the subset of node-semver that npm dependency
18
+ * ranges use: exact versions, `^`, `~`, comparators, hyphen ranges, `||`,
19
+ * X-ranges (`1`, `1.2`, `1.x`, `*`), and — the part the previous helper
20
+ * lacked — prerelease identifiers. Ignoring them meant every `1.0.0-*`
21
+ * compared equal, so `json-server@1.0.0-beta.15` resolved to whichever
22
+ * `1.0.0-*` the packument listed first (`1.0.0-alpha.1`) and
23
+ * `^1.0.0-next.24` picked `1.0.0-next.0`. Measured against the live registry
24
+ * lists before this rewrite.
25
+ */
26
+ /** Parse `v1.2.3-beta.4+build` → `[1, 2, 3, ['beta', 4]]`; null for a non-version. */
27
+ export function parseSemver(v) {
28
+ const m = String(v).trim().replace(/^[v=]+/, '')
29
+ .match(/^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/);
30
+ if (!m)
31
+ return null;
32
+ const prerelease = m[4] === undefined
33
+ ? []
34
+ : m[4].split('.').map((id) => (/^\d+$/.test(id) ? Number(id) : id));
35
+ return [Number(m[1]), Number(m[2]), Number(m[3]), prerelease];
36
+ }
37
+ /**
38
+ * Total order. A release sorts above every prerelease of the same triple;
39
+ * prerelease identifiers compare left to right, numeric before alphanumeric,
40
+ * numeric by value, alphanumeric lexically, and a longer list sorts above
41
+ * its prefix (semver.org §11).
42
+ */
43
+ export function compareSemver(a, b) {
44
+ if (a[0] !== b[0])
45
+ return a[0] - b[0];
46
+ if (a[1] !== b[1])
47
+ return a[1] - b[1];
48
+ if (a[2] !== b[2])
49
+ return a[2] - b[2];
50
+ const ap = a[3] ?? [];
51
+ const bp = b[3] ?? [];
52
+ if (ap.length === 0 && bp.length === 0)
53
+ return 0;
54
+ if (ap.length === 0)
55
+ return 1;
56
+ if (bp.length === 0)
57
+ return -1;
58
+ const n = Math.min(ap.length, bp.length);
59
+ for (let i = 0; i < n; i++) {
60
+ const x = ap[i];
61
+ const y = bp[i];
62
+ if (x === y)
63
+ continue;
64
+ if (typeof x === 'number' && typeof y === 'number')
65
+ return x - y;
66
+ if (typeof x === 'number')
67
+ return -1;
68
+ if (typeof y === 'number')
69
+ return 1;
70
+ return x < y ? -1 : 1;
71
+ }
72
+ return ap.length - bp.length;
73
+ }
74
+ /**
75
+ * One comparator set (the space-separated part of a range) as
76
+ * `>=lower <upper` bounds. Every range shape npm uses normalises to at
77
+ * most two bounds, so a set is a list of `[op, version]` pairs.
78
+ */
79
+ export function semverComparators(part) {
80
+ const comp = part.trim();
81
+ if (comp === '' || comp === '*' || comp === 'x' || comp === 'X' || comp === 'latest')
82
+ return [];
83
+ const m = comp.match(/^(\^|~>?|>=|<=|>|<|=)?\s*v?(\d+|[xX*])(?:\.(\d+|[xX*]))?(?:\.(\d+|[xX*]))?(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/);
84
+ if (!m)
85
+ return null;
86
+ const op = m[1] === '~>' ? '~' : (m[1] ?? '');
87
+ const wild = (s) => s === undefined || s === 'x' || s === 'X' || s === '*';
88
+ const majorWild = wild(m[2]);
89
+ const minorWild = wild(m[3]);
90
+ const patchWild = wild(m[4]);
91
+ const major = majorWild ? 0 : Number(m[2]);
92
+ const minor = minorWild ? 0 : Number(m[3]);
93
+ const patch = patchWild ? 0 : Number(m[4]);
94
+ const pre = m[5] === undefined || patchWild
95
+ ? []
96
+ : m[5].split('.').map((id) => (/^\d+$/.test(id) ? Number(id) : id));
97
+ const lower = [major, minor, patch, pre];
98
+ const ge = () => [['>=', lower]];
99
+ const upto = (u) => [['>=', lower], ['<', u]];
100
+ // X-ranges: `*`, `1`, `1.2`, `1.x`, `1.2.x` — an op in front is applied to
101
+ // the lowest version the X-range names (`>=1.2` is `>=1.2.0`, `<1.x` is `<1.0.0`).
102
+ if (majorWild)
103
+ return [];
104
+ if (minorWild) {
105
+ if (op === '' || op === '^' || op === '~' || op === '=')
106
+ return upto([major + 1, 0, 0, []]);
107
+ return op === '<=' ? [['<', [major + 1, 0, 0, []]]] : [[op, lower]];
108
+ }
109
+ if (patchWild) {
110
+ if (op === '' || op === '~' || op === '=')
111
+ return upto([major, minor + 1, 0, []]);
112
+ if (op === '^')
113
+ return upto(major === 0 ? [0, minor + 1, 0, []] : [major + 1, 0, 0, []]);
114
+ return op === '<=' ? [['<', [major, minor + 1, 0, []]]] : [[op, lower]];
115
+ }
116
+ switch (op) {
117
+ case '^':
118
+ if (major > 0)
119
+ return upto([major + 1, 0, 0, []]);
120
+ if (minor > 0)
121
+ return upto([0, minor + 1, 0, []]);
122
+ return upto([0, 0, patch + 1, []]);
123
+ case '~':
124
+ return upto([major, minor + 1, 0, []]);
125
+ case '':
126
+ case '=':
127
+ return [['=', lower]];
128
+ default:
129
+ return [[op, lower]];
130
+ }
131
+ }
132
+ /**
133
+ * node-semver's prerelease rule: a prerelease version satisfies a comparator
134
+ * set only when some comparator in that set names a prerelease of the same
135
+ * `major.minor.patch`. `^1.0.0-next.24` admits `1.0.0-next.29` and `1.0.0`,
136
+ * never `1.1.0-rc.1`; `^1.0.0` admits no prerelease at all.
137
+ */
138
+ export function satisfiesRange(version, range) {
139
+ const v = parseSemver(version);
140
+ if (!v)
141
+ return false;
142
+ const trimmed = String(range).trim();
143
+ if (trimmed === '' || trimmed === '*' || trimmed === 'x' || trimmed === 'latest')
144
+ return v[3].length === 0;
145
+ for (const orPart of trimmed.split(/\s*\|\|\s*/)) {
146
+ let comparators = [];
147
+ const hyphen = orPart.trim().match(/^(\S+)\s+-\s+(\S+)$/);
148
+ if (hyphen) {
149
+ const lo = semverComparators('>=' + hyphen[1]);
150
+ const hi = semverComparators('<=' + hyphen[2]);
151
+ comparators = lo && hi ? [...lo, ...hi] : null;
152
+ }
153
+ else {
154
+ for (const part of orPart.trim().split(/\s+/)) {
155
+ const c = semverComparators(part);
156
+ if (c === null) {
157
+ comparators = null;
158
+ break;
159
+ }
160
+ comparators.push(...c);
161
+ }
162
+ }
163
+ if (comparators === null)
164
+ continue;
165
+ let ok = true;
166
+ for (const [op, r] of comparators) {
167
+ const cmp = compareSemver(v, r);
168
+ if (op === '>=' ? cmp < 0 : op === '>' ? cmp <= 0 : op === '<=' ? cmp > 0 : op === '<' ? cmp >= 0 : cmp !== 0) {
169
+ ok = false;
170
+ break;
171
+ }
172
+ }
173
+ if (!ok)
174
+ continue;
175
+ if (v[3].length > 0) {
176
+ const admitted = comparators.some(([, r]) => r[3].length > 0 && r[0] === v[0] && r[1] === v[1] && r[2] === v[2]);
177
+ if (!admitted)
178
+ continue;
179
+ }
180
+ return true;
181
+ }
182
+ return false;
183
+ }
184
+ /**
185
+ * Whether `range` is semver-shaped at all — `''`, `*`, `latest`, tags,
186
+ * comparators, hyphen ranges, `||` groups. False for git:, github:,
187
+ * URL, file:, and other non-registry specifiers, where a version pin's
188
+ * presence is all a lockfile can answer.
189
+ */
190
+ export function isSemverRange(range) {
191
+ const trimmed = String(range).trim();
192
+ if (trimmed === '' || trimmed === '*' || trimmed === 'x' || trimmed === 'X' || trimmed === 'latest')
193
+ return true;
194
+ for (const orPart of trimmed.split(/\s*\|\|\s*/)) {
195
+ const hyphen = orPart.trim().match(/^(\S+)\s+-\s+(\S+)$/);
196
+ if (hyphen) {
197
+ const lo = semverComparators('>=' + hyphen[1]);
198
+ const hi = semverComparators('<=' + hyphen[2]);
199
+ if (lo === null || hi === null)
200
+ return false;
201
+ continue;
202
+ }
203
+ for (const part of orPart.trim().split(/\s+/)) {
204
+ if (semverComparators(part) === null)
205
+ return false;
206
+ }
207
+ }
208
+ return true;
209
+ }
210
+ /** The highest version satisfying `range`, or null; `latest`/`*` are the caller's dist-tag lookup. */
211
+ export function resolveVersion(versions, range) {
212
+ const trimmed = String(range ?? '').trim();
213
+ if (trimmed === '' || trimmed === '*' || trimmed === 'x' || trimmed === 'X' || trimmed === 'latest')
214
+ return null;
215
+ let best = null;
216
+ for (const v of versions) {
217
+ if (!satisfiesRange(v, trimmed))
218
+ continue;
219
+ const p = parseSemver(v);
220
+ if (!p)
221
+ continue;
222
+ if (best === null || compareSemver(p, best.p) > 0)
223
+ best = { v, p };
224
+ }
225
+ return best === null ? null : best.v;
226
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/router/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAuCH,OAAO,EAEL,KAAK,qBAAqB,EAC3B,MAAM,iBAAiB,CAAC;AA+BzB,YAAY,EACV,YAAY,IAAI,eAAe,EAC/B,qBAAqB,EACrB,mBAAmB,EACnB,oBAAoB,EACpB,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IAChB;;;;OAIG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED;;;;;;GAMG;AACH,MAAM,MAAM,YAAY,GAAG,CACzB,OAAO,EAAE,OAAO,EAChB,GAAG,EAAE,GAAG,EACR,GAAG,EAAE,gBAAgB,KAClB,QAAQ,GAAG,IAAI,GAAG,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,CAAC;AAEhD,+CAA+C;AAC/C,MAAM,WAAW,0BAA0B;IACzC,oCAAoC;IACpC,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,qDAAqD;IACrD,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,4CAA4C;IAC5C,IAAI,CAAC,EAAE,gBAAgB,CAAC;IACxB,yEAAyE;IACzE,GAAG,CAAC,EAAE,qBAAqB,CAAC;CAC7B;AAED;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B,KAAK,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,gBAAgB,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;CAC7E;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,GAAE,0BAA+B,GACvC,aAAa,CAoWf"}
@@ -50,21 +50,30 @@ const publicTenantCache = new Map();
50
50
  * The tenant segment a public capability URL forwards under. The directory
51
51
  * is consulted first; a deployment without the binding falls back to the
52
52
  * legacy-public DO name, which is where legacy-mode sessions already live.
53
+ * The directory row also carries the port and name the capability was
54
+ * bound with, which is what the `<cap>--<name>--<sid>` form resolves and
55
+ * verifies against.
53
56
  */
54
- async function resolvePublicTenantSegment(capability, env) {
57
+ async function resolvePublicCapability(capability, env, uncached = false) {
55
58
  const cached = publicTenantCache.get(capability);
56
- if (cached !== undefined)
59
+ if (!uncached && cached !== undefined)
57
60
  return cached;
58
61
  const stub = publicDirectoryStub(env);
59
62
  if (stub === null)
60
- return LEGACY_PUBLIC_DO_SEGMENT;
63
+ return { tenantSegment: LEGACY_PUBLIC_DO_SEGMENT, port: null, name: null };
61
64
  const entry = await stub.resolve(capability).catch(() => null);
62
65
  if (entry === null) {
63
66
  // An unresolvable capability 404s: no session DO is named for it.
67
+ publicTenantCache.delete(capability);
64
68
  return null;
65
69
  }
66
- publicTenantCache.set(capability, entry.tenantSegment);
67
- return entry.tenantSegment;
70
+ const resolved = {
71
+ tenantSegment: entry.tenantSegment,
72
+ port: entry.port,
73
+ name: entry.name ?? null,
74
+ };
75
+ publicTenantCache.set(capability, resolved);
76
+ return resolved;
68
77
  }
69
78
  /**
70
79
  * Build a Nimbus default-export handler. The returned object is exactly
@@ -138,16 +147,38 @@ export function createNimbusHandler(options = {}) {
138
147
  // directory — a positive hit is cached for the life of this
139
148
  // isolate, a miss 404s, and a deployment without the binding
140
149
  // falls back to the legacy-public DO name.
141
- const tenantSegment = await resolvePublicTenantSegment(preview.capability, env);
142
- if (tenantSegment === null) {
150
+ let resolved = await resolvePublicCapability(preview.capability, env);
151
+ const matchesHost = (entry) => entry !== null && (preview.name !== undefined
152
+ ? entry.name === preview.name && entry.port !== null
153
+ : entry.port === null || entry.port === preview.port);
154
+ // Rename/rebinding can leave a positive isolate cache entry behind.
155
+ // Verify BOTH host forms, and read through once before refusing.
156
+ if (resolved !== null && !matchesHost(resolved)) {
157
+ resolved = await resolvePublicCapability(preview.capability, env, true);
158
+ }
159
+ if (resolved === null || !matchesHost(resolved)) {
143
160
  return new Response('Not found', { status: 404 });
144
161
  }
162
+ // The name form is resolved by capability like the port form, then
163
+ // the name is verified against the directory row: a capability
164
+ // presented under a name it was not bound with is a 404, never a
165
+ // guess at some other application.
166
+ let port;
167
+ if (preview.name !== undefined) {
168
+ if (resolved.name !== preview.name || resolved.port === null) {
169
+ return new Response('Not found', { status: 404 });
170
+ }
171
+ port = resolved.port;
172
+ }
173
+ else {
174
+ port = preview.port;
175
+ }
145
176
  return forwardToSession(request, {
146
177
  sessionId: preview.sid,
147
- innerPath: `/port/${preview.port}${url.pathname === '/' ? '/' : url.pathname}`,
178
+ innerPath: `/port/${port}${url.pathname === '/' ? '/' : url.pathname}`,
148
179
  basePath: '',
149
180
  }, env, {
150
- tenantSegment,
181
+ tenantSegment: resolved.tenantSegment,
151
182
  extraHeaders: {
152
183
  [PREVIEW_CAPABILITY_HEADER]: preview.capability,
153
184
  [PUBLIC_BEARER_HEADER]: '1',
@@ -172,9 +203,15 @@ export function createNimbusHandler(options = {}) {
172
203
  });
173
204
  if (auth instanceof Response)
174
205
  return auth;
206
+ // The scoped name form is resolved INSIDE the session — the name is
207
+ // a reservation alias only that session's records know — so it is
208
+ // forwarded as `/app/<name>/`, the session's own name-addressed door.
209
+ const scopedInner = preview.name !== undefined
210
+ ? `/app/${preview.name}`
211
+ : `/port/${preview.port}`;
175
212
  return forwardToSession(request, {
176
213
  sessionId: preview.sid,
177
- innerPath: `/port/${preview.port}${url.pathname === '/' ? '/' : url.pathname}`,
214
+ innerPath: `${scopedInner}${url.pathname === '/' ? '/' : url.pathname}`,
178
215
  basePath: '',
179
216
  }, env, { tenantSegment: auth.tenantSegment });
180
217
  }
@@ -14,6 +14,9 @@ export interface PublicDirectoryEntry {
14
14
  readonly tenantSegment: string;
15
15
  readonly sid: string;
16
16
  readonly port: number;
17
+ /** The reservation's name alias, when the capability was bound with one —
18
+ * what the `<cap>--<name>--<sid>` host form is verified against. */
19
+ readonly name?: string;
17
20
  }
18
21
  /** The DO body, usable with any `{ storage }` the tests hand it. */
19
22
  export declare class PublicDirectoryStore {
@@ -29,6 +32,7 @@ export declare class PublicDirectoryStore {
29
32
  tenantSegment: string;
30
33
  sid: string;
31
34
  port: number;
35
+ name?: string;
32
36
  }): Promise<void>;
33
37
  unbind(capability: string): Promise<void>;
34
38
  resolve(capability: string): Promise<PublicDirectoryEntry | null>;
@@ -60,7 +64,7 @@ export declare function bindPublicPortCapability(host: {
60
64
  };
61
65
  tenantSegment?: string;
62
66
  sessionId?: string;
63
- }, capability: string, port: number): Promise<void>;
67
+ }, capability: string, port: number, name?: string): Promise<void>;
64
68
  /** Retire a public port's capability from the routing directory. */
65
69
  export declare function unbindPublicPortCapability(host: {
66
70
  env?: unknown;
@@ -1 +1 @@
1
- {"version":3,"file":"public-directory.d.ts","sourceRoot":"","sources":["../../src/router/public-directory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAMH,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAMD,oEAAoE;AACpE,qBAAa,oBAAoB;IACnB,OAAO,CAAC,GAAG;gBAAH,GAAG,EAAE;QAAE,OAAO,EAAE;YAClC,GAAG,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC;YACtD,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;YAChD,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;SACvC,CAAA;KAAE;IAEG,IAAI,CACR,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE;QAAE,aAAa,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,GAC1D,OAAO,CAAC,IAAI,CAAC;IAgBV,MAAM,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIzC,OAAO,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC;CAKxE;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,OAAO,GAAG;IACjD,IAAI,CAAC,UAAU,EAAE,MAAM,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G,CAAC,EAAE,OAAO,CAAC;IAAC,GAAG,CAAC,EAAE;QAAE,EAAE,CAAC,EAAE;YAAE,IAAI,CAAC,EAAE,OAAO,CAAA;SAAE,CAAA;KAAE,CAAC;IAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,EACtG,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,MAAM,EACZ,IAAI,CAAC,EAAE,MAAM,GACZ,OAAO,CAAC,IAAI,CAAC,CAgBf;AAED,oEAAoE;AACpE,wBAAsB,0BAA0B,CAC9C,IAAI,EAAE;IAAE,GAAG,CAAC,EAAE,OAAO,CAAC;IAAC,GAAG,CAAC,EAAE;QAAE,EAAE,CAAC,EAAE;YAAE,IAAI,CAAC,EAAE,OAAO,CAAA;SAAE,CAAA;KAAE,CAAC;IAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,EACtG,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,IAAI,CAAC,CAOf"}
@@ -31,10 +31,14 @@ export class PublicDirectoryStore {
31
31
  || !Number.isInteger(entry.port) || entry.port < 1 || entry.port > 65535) {
32
32
  throw new Error('NimbusPublicDirectory.bind: entry needs tenantSegment, sid, and a real port');
33
33
  }
34
+ if (entry.name !== undefined && !/^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$/.test(entry.name)) {
35
+ throw new Error('NimbusPublicDirectory.bind: name must be one DNS label');
36
+ }
34
37
  await this.ctx.storage.put(rowKey(capability), {
35
38
  tenantSegment: entry.tenantSegment,
36
39
  sid: entry.sid,
37
40
  port: entry.port,
41
+ ...(entry.name !== undefined ? { name: entry.name } : {}),
38
42
  });
39
43
  }
40
44
  async unbind(capability) {
@@ -87,7 +91,7 @@ function sessionIdentity(host) {
87
91
  * on a non-legacy deployment is a loud error: the exposure would be half-
88
92
  * public — stored as public, unroutable in practice.
89
93
  */
90
- export async function bindPublicPortCapability(host, capability, port) {
94
+ export async function bindPublicPortCapability(host, capability, port, name) {
91
95
  const identity = sessionIdentity(host);
92
96
  if (identity === null)
93
97
  return;
@@ -99,7 +103,10 @@ export async function bindPublicPortCapability(host, capability, port) {
99
103
  + '— without it the capability URL cannot resolve to this session. '
100
104
  + 'Add the binding and the NimbusPublicDirectory migration to wrangler.jsonc.');
101
105
  }
102
- await stub.bind(capability, { tenantSegment: identity.tenantSegment, sid: identity.sid, port });
106
+ await stub.bind(capability, {
107
+ tenantSegment: identity.tenantSegment, sid: identity.sid, port,
108
+ ...(name !== undefined ? { name } : {}),
109
+ });
103
110
  }
104
111
  /** Retire a public port's capability from the routing directory. */
105
112
  export async function unbindPublicPortCapability(host, capability) {
@@ -83,6 +83,7 @@ interface NimbusSessionRpcStub {
83
83
  _rpcListPorts(): Promise<unknown>;
84
84
  _rpcExposePort(port: number, options?: {
85
85
  visibility?: 'scoped' | 'public';
86
+ name?: string;
86
87
  }): Promise<unknown>;
87
88
  _rpcEnsureDurableApp(input: {
88
89
  owner?: string;
@@ -90,9 +91,26 @@ interface NimbusSessionRpcStub {
90
91
  visibility?: 'scoped' | 'public';
91
92
  }): Promise<unknown>;
92
93
  _rpcRemoveDurableApp(owner: string): Promise<unknown>;
94
+ _rpcExposeApp(target: RemoteAppTarget, options?: {
95
+ visibility?: 'scoped' | 'public';
96
+ name?: string;
97
+ }): Promise<unknown>;
98
+ _rpcListApps(): Promise<unknown>;
99
+ _rpcRotateLink(target: RemoteAppTarget): Promise<unknown>;
100
+ _rpcRemoveApp(target: RemoteAppTarget): Promise<unknown>;
93
101
  _rpcUnexposePort(port: number): Promise<unknown>;
94
102
  _rpcDestroy(options?: Record<string, unknown>): Promise<unknown>;
95
103
  }
104
+ /** An app target on the wire: a port, a pid, a name/owner, or the explicit object forms. */
105
+ type RemoteAppTarget = number | string | {
106
+ port: number;
107
+ } | {
108
+ pid: number;
109
+ } | {
110
+ name: string;
111
+ } | {
112
+ owner: string;
113
+ };
96
114
  interface NimbusSessionNamespace {
97
115
  idFromName(name: string): DurableObjectId;
98
116
  get(id: DurableObjectId): NimbusSessionRpcStub;
@@ -1 +1 @@
1
- {"version":3,"file":"remote-api.d.ts","sourceRoot":"","sources":["../../src/router/remote-api.ts"],"names":[],"mappings":"AAIA,OAAO,EAML,KAAK,aAAa,EAEnB,MAAM,kBAAkB,CAAC;AAG1B,MAAM,MAAM,iBAAiB,GACzB,MAAM,GACN,KAAK,GACL,KAAK,GACL,KAAK,GACL,QAAQ,GACR,MAAM,GACN,OAAO,GACP,OAAO,GACP,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;AAElB,MAAM,WAAW,mBAAmB;IAClC,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,iBAAiB,EAAE,CAAC;CAC7B;AAED,MAAM,WAAW,oBAAoB;IACnC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,mBAAmB,CAAC;IAC/B,KAAK,CAAC,EAAE;QACN,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,IAAI,CAAC,EAAE,MAAM,CAAC;KACf,CAAC;IACF,OAAO,CAAC,EAAE;QACR,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,SAAS,CAAC,EAAE,OAAO,CAAC;KACrB,CAAC;CACH;AAED,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,+EAA+E;IAC/E,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC;CAClD;AAED,MAAM,WAAW,qBAAqB;IACpC,kDAAkD;IAClD,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,kDAAkD;IAClD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;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
164
164
  return ctx.stub._rpcRunCode(stringArg(args[0], 'code'), options);
165
165
  }
166
+ // The file plane. Each op's trailing argument is the SDK's file options
167
+ // object; `fileOptions` reads it so a `cred` the client put on the wire
168
+ // is refused loudly rather than dropped — the session-user default is
169
+ // the only identity a remote token can act as.
166
170
  case 'readFile':
171
+ fileOptions(args[1]);
167
172
  return ctx.stub._rpcReadFile(stringArg(args[0], 'path'));
168
173
  case 'readFileBytes':
174
+ fileOptions(args[1]);
169
175
  return ctx.stub._rpcReadFileBytes(stringArg(args[0], 'path'));
170
176
  case 'writeFile':
177
+ fileOptions(args[2]);
171
178
  return ctx.stub._rpcWriteFile(stringArg(args[0], 'path'), fileContentArg(args[1]));
172
179
  case 'stat':
180
+ fileOptions(args[1]);
173
181
  return ctx.stub._rpcStat(stringArg(args[0], 'path'));
174
182
  case 'lstat':
183
+ fileOptions(args[1]);
175
184
  return ctx.stub._rpcLstat(stringArg(args[0], 'path'));
176
185
  case 'rename':
186
+ fileOptions(args[2]);
177
187
  return ctx.stub._rpcRename(stringArg(args[0], 'from'), stringArg(args[1], 'to'));
178
188
  case 'chmod':
189
+ fileOptions(args[2]);
179
190
  return ctx.stub._rpcChmod(stringArg(args[0], 'path'), numberArg(args[1], 'mode'));
180
191
  case 'readRange':
192
+ fileOptions(args[3]);
181
193
  return ctx.stub._rpcFsReadRange(stringArg(args[0], 'path'), numberArg(args[1], 'offset'), numberArg(args[2], 'length'));
182
194
  case 'readdir':
195
+ fileOptions(args[1]);
183
196
  return ctx.stub._rpcReaddir(stringArg(args[0], 'path'));
184
197
  case 'exists':
198
+ fileOptions(args[1]);
185
199
  return ctx.stub._rpcExists(stringArg(args[0], 'path'));
186
200
  case 'mkdir':
201
+ fileOptions(args[1]);
187
202
  return ctx.stub._rpcMkdir(stringArg(args[0], 'path'));
188
203
  case 'deleteFile':
189
- return ctx.stub._rpcDeleteFile(stringArg(args[0], 'path'), objectArg(args[1]));
204
+ return ctx.stub._rpcDeleteFile(stringArg(args[0], 'path'), fileOptions(args[1]));
190
205
  case 'installRuntime': {
191
206
  const spec = stringArg(args[0], 'spec');
192
207
  assertRuntimeAllowed(ctx, spec, 'onDemand');
@@ -223,11 +238,18 @@ async function dispatchRemoteRpc(ctx) {
223
238
  return ctx.stub._rpcListPorts();
224
239
  case 'exposePort': {
225
240
  const options = args[1] === undefined ? undefined : objectArg(args[1]);
226
- return ctx.stub._rpcExposePort(numberArg(args[0], 'port'), options === undefined ? undefined : {
227
- visibility: options.visibility === undefined ? undefined
228
- : options.visibility === 'public' ? 'public' : 'scoped',
229
- });
241
+ return ctx.stub._rpcExposePort(numberArg(args[0], 'port'), options === undefined ? undefined : exposeOptions(options));
242
+ }
243
+ case 'exposeApp': {
244
+ const options = args[1] === undefined ? undefined : objectArg(args[1]);
245
+ return ctx.stub._rpcExposeApp(appTargetArg(args[0]), options === undefined ? undefined : exposeOptions(options));
230
246
  }
247
+ case 'listApps':
248
+ return ctx.stub._rpcListApps();
249
+ case 'rotateLink':
250
+ return ctx.stub._rpcRotateLink(appTargetArg(args[0]));
251
+ case 'removeApp':
252
+ return ctx.stub._rpcRemoveApp(appTargetArg(args[0]));
231
253
  case 'ensureDurableApp': {
232
254
  const input = objectArg(args[0]);
233
255
  return ctx.stub._rpcEnsureDurableApp({
@@ -249,6 +271,28 @@ async function dispatchRemoteRpc(ctx) {
249
271
  throw apiError(`Unknown Nimbus sandbox operation: ${String(op)}`, 'E_REMOTE_OP', 400);
250
272
  }
251
273
  }
274
+ function exposeOptions(options) {
275
+ return {
276
+ ...(options.visibility === undefined ? {} : { visibility: options.visibility === 'public' ? 'public' : 'scoped' }),
277
+ ...(options.name === undefined ? {} : { name: stringArg(options.name, 'name') }),
278
+ };
279
+ }
280
+ function appTargetArg(value) {
281
+ if (typeof value === 'number')
282
+ return numberArg(value, 'target');
283
+ if (typeof value === 'string')
284
+ return stringArg(value, 'target');
285
+ const target = objectArg(value);
286
+ if (target.port !== undefined)
287
+ return { port: numberArg(target.port, 'port') };
288
+ if (target.pid !== undefined)
289
+ return { pid: numberArg(target.pid, 'pid') };
290
+ if (target.name !== undefined)
291
+ return { name: stringArg(target.name, 'name') };
292
+ if (target.owner !== undefined)
293
+ return { owner: stringArg(target.owner, 'owner') };
294
+ throw apiError('Nimbus app target must be a port, a pid, a name, or { port | pid | name | owner }', 'E_ARG_SHAPE', 400);
295
+ }
252
296
  function requireAnyScope(ctx, scopes) {
253
297
  const explicit = ctx.verified?.claims.scopes;
254
298
  if (explicit === undefined)
@@ -272,6 +316,21 @@ function execOptions(ctx, value) {
272
316
  cwd: typeof options.cwd === 'string' ? options.cwd : ctx.root,
273
317
  };
274
318
  }
319
+ /**
320
+ * A file op's options object. The same boundary rule as `execOptions`: the
321
+ * remote token authenticates a SESSION, so a caller does not get to name the
322
+ * uid its file operation acts as. `files.as(cred)` puts `cred` on the wire
323
+ * explicitly so this refusal is the answer the caller gets — never a read
324
+ * that silently ran as somebody else. A colocated embedder holding the DO
325
+ * stub is trusted with `cred` the same way it is trusted with kernel writes.
326
+ */
327
+ function fileOptions(value) {
328
+ const options = value === undefined ? {} : objectArg(value);
329
+ if (options.cred !== undefined) {
330
+ throw apiError('cred is not accepted over the remote API', 'E_ARG_SHAPE', 400);
331
+ }
332
+ return options;
333
+ }
275
334
  function processLogOptions(value) {
276
335
  const options = objectArg(value);
277
336
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"cpython-resident.d.ts","sourceRoot":"","sources":["../../src/runtime/cpython-resident.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,EAGL,KAAK,oBAAoB,EAC1B,MAAM,2CAA2C,CAAC;AACnD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEzD;;;;;;GAMG;AACH,wBAAgB,+BAA+B,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAwDxE;AAeD;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,YAAY,GAAG,oBAAoB,CA8CjF"}
1
+ {"version":3,"file":"cpython-resident.d.ts","sourceRoot":"","sources":["../../src/runtime/cpython-resident.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,EAGL,KAAK,oBAAoB,EAC1B,MAAM,2CAA2C,CAAC;AACnD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEzD;;;;;;GAMG;AACH,wBAAgB,+BAA+B,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAwDxE;AAeD;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,YAAY,GAAG,oBAAoB,CAgDjF"}
@@ -91,6 +91,8 @@ export function cpythonResidentStart(facetMgr) {
91
91
  const command = args.command;
92
92
  const workerCode = buildCPythonSocketProcessWorker(buildCPythonPreamble());
93
93
  const spawned = await facetMgr.spawnWorker(workerCode, command, args.cwd, {
94
+ resident: { argv: args.argv, runtime: 'python' },
95
+ restart: z.object({ NIMBUS_RESTART: z.literal('on-failure') }).safeParse(args.startArgs.userEnv).success ? 'on-failure' : 'never',
94
96
  compatibilityFlags: ['nodejs_compat'],
95
97
  // By path, not by value: the interpreter is 10.6 MiB, more than a single
96
98
  // RPC value may carry, so whichever host runs this process reads it itself.
@@ -106,7 +108,7 @@ export function cpythonResidentStart(facetMgr) {
106
108
  }
107
109
  const data = boot.data;
108
110
  if (data.state === 'listening' && typeof data.port === 'number' && data.port > 0) {
109
- facetMgr.registerPort(spawned.pid, data.port);
111
+ await facetMgr.registerPort(spawned.pid, data.port);
110
112
  const routeable = await facetMgr.waitForRouteablePorts(spawned.pid);
111
113
  const port = routeable.includes(data.port) ? data.port : routeable[0];
112
114
  if (!port) {
@@ -3,5 +3,12 @@ export declare function rewriteViteBuildHtml(html: string, options: {
3
3
  jsFilename: string;
4
4
  cssFilename?: string;
5
5
  removeImportMap?: boolean;
6
+ /**
7
+ * Vite injects `<link rel="stylesheet">` for CSS bundled through the
8
+ * entry when index.html declares none (the create-vite template puts
9
+ * all CSS behind `import './index.css'`). Set true to get that
10
+ * behavior; when false, only an existing stylesheet link is rewritten.
11
+ */
12
+ injectCss?: boolean;
6
13
  }): Promise<string>;
7
14
  //# sourceMappingURL=html-entrypoint.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"html-entrypoint.d.ts","sourceRoot":"","sources":["../../src/runtime/html-entrypoint.ts"],"names":[],"mappings":"AAEA,wBAAsB,wBAAwB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAcxF;AAED,wBAAsB,oBAAoB,CACxC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE;IACP,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B,GACA,OAAO,CAAC,MAAM,CAAC,CA8BjB"}
1
+ {"version":3,"file":"html-entrypoint.d.ts","sourceRoot":"","sources":["../../src/runtime/html-entrypoint.ts"],"names":[],"mappings":"AAEA,wBAAsB,wBAAwB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAcxF;AAED,wBAAsB,oBAAoB,CACxC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE;IACP,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;;;;OAKG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,GACA,OAAO,CAAC,MAAM,CAAC,CAkDjB"}