@valbuild/tanstack-build 0.150.1 → 0.150.9
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/CHANGELOG.md +9 -0
- package/dist/declarations/src/contract.d.ts +46 -0
- package/dist/declarations/src/node/vendorLayer.d.ts +15 -1
- package/dist/valbuild-tanstack-build.cjs.dev.js +1 -1
- package/dist/valbuild-tanstack-build.cjs.prod.js +1 -1
- package/dist/valbuild-tanstack-build.esm.js +1 -1
- package/node/dist/valbuild-tanstack-build-node.cjs.dev.js +304 -16
- package/node/dist/valbuild-tanstack-build-node.cjs.prod.js +304 -16
- package/node/dist/valbuild-tanstack-build-node.esm.js +305 -17
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @valbuild/tanstack-build
|
|
2
2
|
|
|
3
|
+
## 0.150.9
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#971](https://github.com/valbuild/val/pull/971) [`fdb0280`](https://github.com/valbuild/val/commit/fdb02809830355e595127814c8e8676fdb0d5279) Thanks [@freekh](https://github.com/freekh)! - The Studio's files now also ship as plain files, so a host can serve them itself instead of from your app's server.
|
|
8
|
+
|
|
9
|
+
- `@valbuild/ui` includes `static/`: every Studio file, plus a `manifest.json` that says which request path under `/api/val/static` serves which file. Binary files are copied byte for byte. `@valbuild/ui/server` is unchanged, and so is every host that uses it.
|
|
10
|
+
- `@valbuild/tanstack-build` uses it on Val Build's hosting. When the platform says it serves build assets, the site's dependency layer leaves out the Studio copy embedded in `@valbuild/ui/server` and carries the Studio's files as build assets instead. The site's server then loads about 18 MB less JavaScript and uses roughly 80-100 MB less memory. That margin is what kept a Studio from loading on a hosted site: its server ran out of memory and was restarted on almost every request.
|
|
11
|
+
|
|
3
12
|
## 0.150.1
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
|
@@ -119,6 +119,21 @@ export interface BuildTarget {
|
|
|
119
119
|
worker: Record<string, Array<string>>;
|
|
120
120
|
browser: Record<string, Array<string>>;
|
|
121
121
|
};
|
|
122
|
+
/**
|
|
123
|
+
* Whether this platform serves BUILD ASSETS: files a build names by
|
|
124
|
+
* content hash ({@link BuildAssets}), uploaded once and served by the
|
|
125
|
+
* platform itself rather than by the site's server.
|
|
126
|
+
*
|
|
127
|
+
* What a layer build reads it for is the Studio. `@valbuild/ui/server`
|
|
128
|
+
* carries every Studio file base64-embedded, which costs a server that
|
|
129
|
+
* loads it some 80-100 MB of heap -- inside a 128 MB isolate, too much.
|
|
130
|
+
* Where this is true the layer is built without that copy and carries the
|
|
131
|
+
* Studio's files as assets instead.
|
|
132
|
+
*
|
|
133
|
+
* Absent from a platform that predates it, and a layer is then built as
|
|
134
|
+
* it always was: a Studio without its files is worse than a heavy one.
|
|
135
|
+
*/
|
|
136
|
+
buildAssets?: boolean;
|
|
122
137
|
/** Where the chunks live, as seen from each kind of importer. */
|
|
123
138
|
paths: {
|
|
124
139
|
/** The base layer, from a project-layer chunk. */
|
|
@@ -169,3 +184,34 @@ export interface BuildTargetRev {
|
|
|
169
184
|
rev: string | null;
|
|
170
185
|
};
|
|
171
186
|
}
|
|
187
|
+
/**
|
|
188
|
+
* One file a build names, by content: the platform stores it once, under its
|
|
189
|
+
* sha256, and serves it at every path a build maps to it.
|
|
190
|
+
*/
|
|
191
|
+
export interface BuildAsset {
|
|
192
|
+
/** Lower-case hex sha256 of the bytes. Also the file's name in the store. */
|
|
193
|
+
sha256: string;
|
|
194
|
+
contentType: string;
|
|
195
|
+
cacheControl: string;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Files a build has the platform serve for it, by request path, before the
|
|
199
|
+
* request reaches the site's server.
|
|
200
|
+
*
|
|
201
|
+
* GENERIC on purpose. The Studio is the first thing served this way (see
|
|
202
|
+
* {@link BuildTarget}'s `base.buildAssets`), and the platform knows nothing
|
|
203
|
+
* of it: it follows this map. Anything else a build would rather not carry in
|
|
204
|
+
* its server -- a dependency's fonts, a site's own large files -- can be
|
|
205
|
+
* served the same way without the platform learning anything new.
|
|
206
|
+
*/
|
|
207
|
+
export interface BuildAssets {
|
|
208
|
+
/** Request path (`/api/val/static/0.150.8/app`) -> the file served there. */
|
|
209
|
+
paths: Record<string, BuildAsset>;
|
|
210
|
+
/**
|
|
211
|
+
* What a path under `prefix` that is not in {@link paths} is answered with:
|
|
212
|
+
* a single-page app's index page. The longest matching prefix wins.
|
|
213
|
+
*/
|
|
214
|
+
fallbacks: Array<BuildAsset & {
|
|
215
|
+
prefix: string;
|
|
216
|
+
}>;
|
|
217
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BuildTarget } from "../contract.js";
|
|
1
|
+
import type { BuildAssets, BuildTarget } from "../contract.js";
|
|
2
2
|
/**
|
|
3
3
|
* Packages the base layer already provides.
|
|
4
4
|
*
|
|
@@ -128,6 +128,20 @@ export interface VendorLayer {
|
|
|
128
128
|
worker: Record<string, string>;
|
|
129
129
|
/** Browser chunks, served under `/_pvendor/<rev>/`. */
|
|
130
130
|
browser: Record<string, string>;
|
|
131
|
+
/**
|
|
132
|
+
* Files the platform serves for this layer, by request path: the Studio,
|
|
133
|
+
* where the platform serves build assets (`base.buildAssets`) and the
|
|
134
|
+
* project's `@valbuild/ui` ships its files (see `studioAssets.ts`). Absent
|
|
135
|
+
* otherwise.
|
|
136
|
+
*/
|
|
137
|
+
assets?: BuildAssets;
|
|
138
|
+
/**
|
|
139
|
+
* The bytes {@link assets} names, base64, by sha256: for the publisher to
|
|
140
|
+
* upload, and never stored with the layer. The platform keeps each file
|
|
141
|
+
* once, by its hash, so a publisher asks which it is missing and sends
|
|
142
|
+
* only those.
|
|
143
|
+
*/
|
|
144
|
+
assetBytes?: Record<string, string>;
|
|
131
145
|
}
|
|
132
146
|
/**
|
|
133
147
|
* Val's own entry points that are server-only by contract, built for the
|
|
@@ -1185,7 +1185,7 @@ var packageJson = {
|
|
|
1185
1185
|
url: "git+https://github.com/valbuild/val.git"
|
|
1186
1186
|
},
|
|
1187
1187
|
license: "MIT",
|
|
1188
|
-
version: "0.150.
|
|
1188
|
+
version: "0.150.9",
|
|
1189
1189
|
sideEffects: false,
|
|
1190
1190
|
main: "dist/valbuild-tanstack-build.cjs.js",
|
|
1191
1191
|
module: "dist/valbuild-tanstack-build.esm.js",
|
|
@@ -1185,7 +1185,7 @@ var packageJson = {
|
|
|
1185
1185
|
url: "git+https://github.com/valbuild/val.git"
|
|
1186
1186
|
},
|
|
1187
1187
|
license: "MIT",
|
|
1188
|
-
version: "0.150.
|
|
1188
|
+
version: "0.150.9",
|
|
1189
1189
|
sideEffects: false,
|
|
1190
1190
|
main: "dist/valbuild-tanstack-build.cjs.js",
|
|
1191
1191
|
module: "dist/valbuild-tanstack-build.esm.js",
|
|
@@ -1166,7 +1166,7 @@ var packageJson = {
|
|
|
1166
1166
|
url: "git+https://github.com/valbuild/val.git"
|
|
1167
1167
|
},
|
|
1168
1168
|
license: "MIT",
|
|
1169
|
-
version: "0.150.
|
|
1169
|
+
version: "0.150.9",
|
|
1170
1170
|
sideEffects: false,
|
|
1171
1171
|
main: "dist/valbuild-tanstack-build.cjs.js",
|
|
1172
1172
|
module: "dist/valbuild-tanstack-build.esm.js",
|
|
@@ -8,6 +8,7 @@ var node_crypto = require('node:crypto');
|
|
|
8
8
|
var node_module = require('node:module');
|
|
9
9
|
var promises = require('node:fs/promises');
|
|
10
10
|
var node_path = require('node:path');
|
|
11
|
+
var node_fs = require('node:fs');
|
|
11
12
|
var parseAst = require('rolldown/parseAst');
|
|
12
13
|
var esModuleLexer = require('es-module-lexer');
|
|
13
14
|
var node_url = require('node:url');
|
|
@@ -396,6 +397,272 @@ function _nodeShims() {
|
|
|
396
397
|
return _nodeShims.apply(this, arguments);
|
|
397
398
|
}
|
|
398
399
|
|
|
400
|
+
/** What a Val app's server answers Val's API under: `initValServer`'s route. */
|
|
401
|
+
var VAL_API_ROUTE = "/api/val";
|
|
402
|
+
/** Where `@valbuild/ui/server` is mounted under it. */
|
|
403
|
+
var STUDIO_STATIC_ROUTE = "".concat(VAL_API_ROUTE, "/static");
|
|
404
|
+
var UI_SERVER = "@valbuild/ui/server";
|
|
405
|
+
var STUB_ID = "\0platform:studio-served-by-platform";
|
|
406
|
+
|
|
407
|
+
/** `@valbuild/ui`'s `static/manifest.json`, the part read here. */
|
|
408
|
+
|
|
409
|
+
/** The format this reads. A newer one is refused rather than half understood. */
|
|
410
|
+
var MANIFEST_FORMAT = 1;
|
|
411
|
+
|
|
412
|
+
/** The Studio a build used, found while it resolved `@valbuild/ui/server`. */
|
|
413
|
+
|
|
414
|
+
/**
|
|
415
|
+
* Replace `@valbuild/ui/server` with a handler that has no files, when the
|
|
416
|
+
* `@valbuild/ui` being imported ships them as files (`static/manifest.json`),
|
|
417
|
+
* and record which `@valbuild/ui` that was.
|
|
418
|
+
*
|
|
419
|
+
* Resolved first, through everything after this plugin, so the package found
|
|
420
|
+
* is the one the import would have bundled -- under pnpm that is a copy in the
|
|
421
|
+
* store that only the importer can see.
|
|
422
|
+
*/
|
|
423
|
+
function studioServedByPlatform(found) {
|
|
424
|
+
return {
|
|
425
|
+
name: "platform:studio-served-by-platform",
|
|
426
|
+
resolveId: function resolveId(source, importer, extraOptions) {
|
|
427
|
+
var _this = this;
|
|
428
|
+
return regeneratorValues._asyncToGenerator(/*#__PURE__*/regeneratorValues._regenerator().m(function _callee() {
|
|
429
|
+
var resolved;
|
|
430
|
+
return regeneratorValues._regenerator().w(function (_context) {
|
|
431
|
+
while (1) switch (_context.n) {
|
|
432
|
+
case 0:
|
|
433
|
+
if (!(source !== UI_SERVER)) {
|
|
434
|
+
_context.n = 1;
|
|
435
|
+
break;
|
|
436
|
+
}
|
|
437
|
+
return _context.a(2, null);
|
|
438
|
+
case 1:
|
|
439
|
+
_context.n = 2;
|
|
440
|
+
return _this.resolve(source, importer, regeneratorValues._objectSpread2(regeneratorValues._objectSpread2({}, extraOptions), {}, {
|
|
441
|
+
skipSelf: true
|
|
442
|
+
}));
|
|
443
|
+
case 2:
|
|
444
|
+
resolved = _context.v;
|
|
445
|
+
return _context.a(2, replacementFor(found, resolved));
|
|
446
|
+
}
|
|
447
|
+
}, _callee);
|
|
448
|
+
}))();
|
|
449
|
+
},
|
|
450
|
+
load: function load(id) {
|
|
451
|
+
return loadReplacement(id);
|
|
452
|
+
}
|
|
453
|
+
};
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
/**
|
|
457
|
+
* The plugin's decision, given where `@valbuild/ui/server` resolved to: the
|
|
458
|
+
* replacement's id, recording the package in `found`, or null to bundle the
|
|
459
|
+
* module as it is.
|
|
460
|
+
*/
|
|
461
|
+
function replacementFor(found, resolved) {
|
|
462
|
+
if (!resolved || resolved.external) return null;
|
|
463
|
+
var root = packageRootOf(resolved.id);
|
|
464
|
+
if (root === null || !node_fs.existsSync(node_path.join(root, "static", "manifest.json"))) {
|
|
465
|
+
return null;
|
|
466
|
+
}
|
|
467
|
+
if (found.root !== null && found.root !== root) {
|
|
468
|
+
throw new Error("Two copies of @valbuild/ui are bundled into the layer (".concat(found.root, " and ").concat(root, "). ") + "The platform serves one Studio per layer; make the project depend on one version.");
|
|
469
|
+
}
|
|
470
|
+
found.root = root;
|
|
471
|
+
return STUB_ID;
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
/** The replacement's source, for its id; null for any other module. */
|
|
475
|
+
function loadReplacement(id) {
|
|
476
|
+
return id === STUB_ID ? STUB_SOURCE : null;
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
/**
|
|
480
|
+
* What the replaced module exports: the same function, answering every
|
|
481
|
+
* request with what happened and where to look, rather than with a file.
|
|
482
|
+
*
|
|
483
|
+
* Reached only when the platform did NOT answer a Studio file first, which
|
|
484
|
+
* means the layer's assets were not stored or not served -- a platform bug,
|
|
485
|
+
* and one a person should be able to name from the response.
|
|
486
|
+
*/
|
|
487
|
+
var STUB_SOURCE = "export function createUIRequestHandler() {\n return async (path) => ({\n status: 404,\n json: {\n message: \"The Studio's files are served by the platform, and it did not serve this one.\",\n details: \"The site was built without the Studio's files (they are build assets), so \" + JSON.stringify(path) + \" reached the site's server. The platform did not find it among the layer's assets.\",\n },\n });\n}\n";
|
|
488
|
+
|
|
489
|
+
/** The `node_modules/<name>` directory holding `file`, named `@valbuild/ui`. */
|
|
490
|
+
function packageRootOf(file) {
|
|
491
|
+
var dir = node_path.dirname(file);
|
|
492
|
+
for (;;) {
|
|
493
|
+
var manifest = node_path.join(dir, "package.json");
|
|
494
|
+
if (node_fs.existsSync(manifest)) {
|
|
495
|
+
try {
|
|
496
|
+
var _ref = JSON.parse(node_fs.readFileSync(manifest, "utf8")),
|
|
497
|
+
name = _ref.name;
|
|
498
|
+
if (name === "@valbuild/ui") return dir;
|
|
499
|
+
} catch (_unused) {
|
|
500
|
+
// Not a package manifest we can read: keep walking up.
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
var parent = node_path.dirname(dir);
|
|
504
|
+
if (parent === dir) return null;
|
|
505
|
+
dir = parent;
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
/**
|
|
510
|
+
* The Studio as build assets: every route of `@valbuild/ui`'s manifest under
|
|
511
|
+
* {@link STUDIO_STATIC_ROUTE}, and the bytes of every file a route names,
|
|
512
|
+
* base64, by sha256.
|
|
513
|
+
*
|
|
514
|
+
* Each file's hash is checked against the manifest as it is read: what the
|
|
515
|
+
* platform stores under a hash is what anything asking for that hash gets,
|
|
516
|
+
* forever, so a file that does not match is a broken package, not a file.
|
|
517
|
+
*/
|
|
518
|
+
function studioAssetsOf(_x) {
|
|
519
|
+
return _studioAssetsOf.apply(this, arguments);
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
/**
|
|
523
|
+
* A digest of an asset map, for the layer revision.
|
|
524
|
+
*
|
|
525
|
+
* The replaced module is the same text whichever Studio it replaced, so the
|
|
526
|
+
* layer's code alone does not change when only `@valbuild/ui` does -- and a
|
|
527
|
+
* layer that keeps its revision is never sent again, so the new Studio's
|
|
528
|
+
* files would never reach the platform. The map changes, so the map is
|
|
529
|
+
* folded in.
|
|
530
|
+
*/
|
|
531
|
+
function _studioAssetsOf() {
|
|
532
|
+
_studioAssetsOf = regeneratorValues._asyncToGenerator(/*#__PURE__*/regeneratorValues._regenerator().m(function _callee3(root) {
|
|
533
|
+
var manifest, files, assetOf, read, paths, _i, _Object$entries, _Object$entries$_i, route, _Object$entries$_i$, file, cacheControl, asset, fallback, _t;
|
|
534
|
+
return regeneratorValues._regenerator().w(function (_context3) {
|
|
535
|
+
while (1) switch (_context3.n) {
|
|
536
|
+
case 0:
|
|
537
|
+
_t = JSON;
|
|
538
|
+
_context3.n = 1;
|
|
539
|
+
return promises.readFile(node_path.join(root, "static", "manifest.json"), "utf8");
|
|
540
|
+
case 1:
|
|
541
|
+
manifest = _t.parse.call(_t, _context3.v);
|
|
542
|
+
if (!(manifest.format !== MANIFEST_FORMAT)) {
|
|
543
|
+
_context3.n = 2;
|
|
544
|
+
break;
|
|
545
|
+
}
|
|
546
|
+
throw new Error("@valbuild/ui@".concat(manifest.version, " describes its files in format ").concat(manifest.format, ", ") + "and this build reads format ".concat(MANIFEST_FORMAT, ". Update @valbuild/tanstack-build."));
|
|
547
|
+
case 2:
|
|
548
|
+
files = {};
|
|
549
|
+
assetOf = function assetOf(file, cacheControl) {
|
|
550
|
+
var described = manifest.files[file];
|
|
551
|
+
if (!described) {
|
|
552
|
+
throw new Error("@valbuild/ui@".concat(manifest.version, "'s manifest names ").concat(file, ", which it does not list."));
|
|
553
|
+
}
|
|
554
|
+
return {
|
|
555
|
+
sha256: described.sha256,
|
|
556
|
+
contentType: described.contentType,
|
|
557
|
+
cacheControl: cacheControl
|
|
558
|
+
};
|
|
559
|
+
};
|
|
560
|
+
read = /*#__PURE__*/function () {
|
|
561
|
+
var _ref6 = regeneratorValues._asyncToGenerator(/*#__PURE__*/regeneratorValues._regenerator().m(function _callee2(file, sha256) {
|
|
562
|
+
var bytes, actual;
|
|
563
|
+
return regeneratorValues._regenerator().w(function (_context2) {
|
|
564
|
+
while (1) switch (_context2.n) {
|
|
565
|
+
case 0:
|
|
566
|
+
if (!(sha256 in files)) {
|
|
567
|
+
_context2.n = 1;
|
|
568
|
+
break;
|
|
569
|
+
}
|
|
570
|
+
return _context2.a(2);
|
|
571
|
+
case 1:
|
|
572
|
+
_context2.n = 2;
|
|
573
|
+
return promises.readFile(node_path.join(root, "static", "files", file));
|
|
574
|
+
case 2:
|
|
575
|
+
bytes = _context2.v;
|
|
576
|
+
actual = node_crypto.createHash("sha256").update(bytes).digest("hex");
|
|
577
|
+
if (!(actual !== sha256)) {
|
|
578
|
+
_context2.n = 3;
|
|
579
|
+
break;
|
|
580
|
+
}
|
|
581
|
+
throw new Error("@valbuild/ui@".concat(manifest.version, "'s static").concat(file, " does not match its manifest ") + "(sha256 ".concat(actual, ", expected ").concat(sha256, "). The package is corrupt; reinstall it."));
|
|
582
|
+
case 3:
|
|
583
|
+
files[sha256] = bytes.toString("base64");
|
|
584
|
+
case 4:
|
|
585
|
+
return _context2.a(2);
|
|
586
|
+
}
|
|
587
|
+
}, _callee2);
|
|
588
|
+
}));
|
|
589
|
+
return function read(_x2, _x3) {
|
|
590
|
+
return _ref6.apply(this, arguments);
|
|
591
|
+
};
|
|
592
|
+
}();
|
|
593
|
+
paths = {};
|
|
594
|
+
_i = 0, _Object$entries = Object.entries(manifest.routes);
|
|
595
|
+
case 3:
|
|
596
|
+
if (!(_i < _Object$entries.length)) {
|
|
597
|
+
_context3.n = 5;
|
|
598
|
+
break;
|
|
599
|
+
}
|
|
600
|
+
_Object$entries$_i = regeneratorValues._slicedToArray(_Object$entries[_i], 2), route = _Object$entries$_i[0], _Object$entries$_i$ = _Object$entries$_i[1], file = _Object$entries$_i$.file, cacheControl = _Object$entries$_i$.cacheControl;
|
|
601
|
+
asset = assetOf(file, cacheControl);
|
|
602
|
+
paths["".concat(STUDIO_STATIC_ROUTE).concat(route)] = asset;
|
|
603
|
+
_context3.n = 4;
|
|
604
|
+
return read(file, asset.sha256);
|
|
605
|
+
case 4:
|
|
606
|
+
_i++;
|
|
607
|
+
_context3.n = 3;
|
|
608
|
+
break;
|
|
609
|
+
case 5:
|
|
610
|
+
fallback = assetOf(manifest.fallback.file, manifest.fallback.cacheControl);
|
|
611
|
+
_context3.n = 6;
|
|
612
|
+
return read(manifest.fallback.file, fallback.sha256);
|
|
613
|
+
case 6:
|
|
614
|
+
return _context3.a(2, {
|
|
615
|
+
assets: {
|
|
616
|
+
paths: paths,
|
|
617
|
+
fallbacks: [regeneratorValues._objectSpread2({
|
|
618
|
+
prefix: "".concat(STUDIO_STATIC_ROUTE, "/")
|
|
619
|
+
}, fallback)]
|
|
620
|
+
},
|
|
621
|
+
files: files,
|
|
622
|
+
version: manifest.version
|
|
623
|
+
});
|
|
624
|
+
}
|
|
625
|
+
}, _callee3);
|
|
626
|
+
}));
|
|
627
|
+
return _studioAssetsOf.apply(this, arguments);
|
|
628
|
+
}
|
|
629
|
+
function assetsRev(assets) {
|
|
630
|
+
var digest = node_crypto.createHash("sha256");
|
|
631
|
+
var _iterator = regeneratorValues._createForOfIteratorHelper(Object.entries(assets.paths).sort(function (_ref2, _ref3) {
|
|
632
|
+
var _ref4 = regeneratorValues._slicedToArray(_ref2, 1),
|
|
633
|
+
a = _ref4[0];
|
|
634
|
+
var _ref5 = regeneratorValues._slicedToArray(_ref3, 1),
|
|
635
|
+
b = _ref5[0];
|
|
636
|
+
return a < b ? -1 : a > b ? 1 : 0;
|
|
637
|
+
})),
|
|
638
|
+
_step;
|
|
639
|
+
try {
|
|
640
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
641
|
+
var _step$value = regeneratorValues._slicedToArray(_step.value, 2),
|
|
642
|
+
path = _step$value[0],
|
|
643
|
+
asset = _step$value[1];
|
|
644
|
+
digest.update("".concat(path, "\0").concat(asset.sha256, "\0").concat(asset.contentType, "\0").concat(asset.cacheControl, "\n"));
|
|
645
|
+
}
|
|
646
|
+
} catch (err) {
|
|
647
|
+
_iterator.e(err);
|
|
648
|
+
} finally {
|
|
649
|
+
_iterator.f();
|
|
650
|
+
}
|
|
651
|
+
var _iterator2 = regeneratorValues._createForOfIteratorHelper(assets.fallbacks),
|
|
652
|
+
_step2;
|
|
653
|
+
try {
|
|
654
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
655
|
+
var fallback = _step2.value;
|
|
656
|
+
digest.update("fallback\0".concat(fallback.prefix, "\0").concat(fallback.sha256, "\0").concat(fallback.contentType, "\0").concat(fallback.cacheControl, "\n"));
|
|
657
|
+
}
|
|
658
|
+
} catch (err) {
|
|
659
|
+
_iterator2.e(err);
|
|
660
|
+
} finally {
|
|
661
|
+
_iterator2.f();
|
|
662
|
+
}
|
|
663
|
+
return digest.digest("hex").slice(0, 8);
|
|
664
|
+
}
|
|
665
|
+
|
|
399
666
|
/**
|
|
400
667
|
* Packages the base layer already provides.
|
|
401
668
|
*
|
|
@@ -757,7 +1024,7 @@ function buildTargets(_x6, _x7, _x8, _x9, _x0) {
|
|
|
757
1024
|
*/
|
|
758
1025
|
function _buildTargets() {
|
|
759
1026
|
_buildTargets = regeneratorValues._asyncToGenerator(/*#__PURE__*/regeneratorValues._regenerator().m(function _callee6(names, input, outRoot, quiet, platform) {
|
|
760
|
-
var out, digest, packages, serverOnly, unusable, _iterator10, _step10, target, forTarget, dir, stubs, _loop3, _ret, _t4;
|
|
1027
|
+
var out, digest, studio, packages, serverOnly, unusable, _iterator10, _step10, target, forTarget, dir, stubs, _loop3, _ret, _t4;
|
|
761
1028
|
return regeneratorValues._regenerator().w(function (_context7) {
|
|
762
1029
|
while (1) switch (_context7.p = _context7.n) {
|
|
763
1030
|
case 0:
|
|
@@ -766,6 +1033,10 @@ function _buildTargets() {
|
|
|
766
1033
|
browser: {}
|
|
767
1034
|
};
|
|
768
1035
|
digest = node_crypto.createHash("sha256");
|
|
1036
|
+
/** The Studio the worker build replaced, if it replaced one. */
|
|
1037
|
+
studio = {
|
|
1038
|
+
root: null
|
|
1039
|
+
};
|
|
769
1040
|
/** Directory -> the package it belongs to, for the pin check. */
|
|
770
1041
|
packages = new Map();
|
|
771
1042
|
/** Entry -> why it cannot be built for a browser. */
|
|
@@ -825,7 +1096,7 @@ function _buildTargets() {
|
|
|
825
1096
|
return [name, input[name]];
|
|
826
1097
|
})),
|
|
827
1098
|
platform: target.platform,
|
|
828
|
-
plugins: [externaliseBase(target.baseFrom, platform), pinPlatformTanstack(platform), stubStartEntries(), stubServerEntries(target.name === "browser")].concat(regeneratorValues._toConsumableArray(stubs ? [stubUnbundlable(target.name === "browser", stubs)] : []), [
|
|
1099
|
+
plugins: [externaliseBase(target.baseFrom, platform), pinPlatformTanstack(platform), stubStartEntries(), stubServerEntries(target.name === "browser")].concat(regeneratorValues._toConsumableArray(target.name === "worker" && platform.base.buildAssets ? [studioServedByPlatform(studio)] : []), regeneratorValues._toConsumableArray(stubs ? [stubUnbundlable(target.name === "browser", stubs)] : []), [
|
|
829
1100
|
// Worker only: a browser has no Node builtins to bridge to, and a
|
|
830
1101
|
// package reaching for one there is a real error rather than a missing
|
|
831
1102
|
// runtime.
|
|
@@ -1038,6 +1309,7 @@ function _buildTargets() {
|
|
|
1038
1309
|
return _context7.a(2, regeneratorValues._objectSpread2(regeneratorValues._objectSpread2({}, out), {}, {
|
|
1039
1310
|
serverOnly: serverOnly,
|
|
1040
1311
|
unusable: unusable,
|
|
1312
|
+
studioRoot: studio.root,
|
|
1041
1313
|
rev: digest.digest("hex").slice(0, 16)
|
|
1042
1314
|
}));
|
|
1043
1315
|
}
|
|
@@ -2356,7 +2628,7 @@ function buildVendorLayer(_x34, _x35, _x36, _x37) {
|
|
|
2356
2628
|
}
|
|
2357
2629
|
function _buildVendorLayer() {
|
|
2358
2630
|
_buildVendorLayer = regeneratorValues._asyncToGenerator(/*#__PURE__*/regeneratorValues._regenerator().m(function _callee13(dir, deps, css, platform) {
|
|
2359
|
-
var modules, _iterator21, _step21, _loop4, stubs, input, _i6, _Object$entries4, _Object$entries4$_i, specifier, name, file, skipped, workerOnly, workerOnlyReasons, specifierOf, _i7, _Object$keys, _specifier, forBrowser, forgetUncarried, usable, built, _i9, _Object$values, _name2, worked, reasons, serverOnlyByContract, _iterator22, _step22, target, _probe$unusable$_name, probe, unbundlable, _message, _reasons$, _i0, _Object$entries5, _Object$entries5$_i, _specifier3, _name3, _i1, _Object$entries6, _Object$entries6$_i, _specifier4, _name4, reason, _i10, _Object$entries7, _Object$entries7$_i, _specifier5, _name5, _reason, _t19, _t20, _t21;
|
|
2631
|
+
var modules, _iterator21, _step21, _loop4, stubs, input, _i6, _Object$entries4, _Object$entries4$_i, specifier, name, file, skipped, workerOnly, workerOnlyReasons, specifierOf, _i7, _Object$keys, _specifier, forBrowser, forgetUncarried, usable, built, _i9, _Object$values, _name2, worked, reasons, serverOnlyByContract, _iterator22, _step22, target, _probe$unusable$_name, probe, unbundlable, _message, _reasons$, _i0, _Object$entries5, _Object$entries5$_i, _specifier3, _name3, _i1, _Object$entries6, _Object$entries6$_i, _specifier4, _name4, reason, _i10, _Object$entries7, _Object$entries7$_i, _specifier5, _name5, _reason, studio, _t19, _t20, _t21, _t22;
|
|
2360
2632
|
return regeneratorValues._regenerator().w(function (_context15) {
|
|
2361
2633
|
while (1) switch (_context15.p = _context15.n) {
|
|
2362
2634
|
case 0:
|
|
@@ -2730,11 +3002,24 @@ function _buildVendorLayer() {
|
|
|
2730
3002
|
case 48:
|
|
2731
3003
|
forgetUncarried();
|
|
2732
3004
|
|
|
2733
|
-
// The
|
|
2734
|
-
//
|
|
2735
|
-
|
|
2736
|
-
|
|
2737
|
-
|
|
3005
|
+
// The Studio's files, when the worker build replaced the module that
|
|
3006
|
+
// embeds them: see studioAssets.ts.
|
|
3007
|
+
if (!built.studioRoot) {
|
|
3008
|
+
_context15.n = 50;
|
|
3009
|
+
break;
|
|
3010
|
+
}
|
|
3011
|
+
_context15.n = 49;
|
|
3012
|
+
return studioAssetsOf(built.studioRoot);
|
|
3013
|
+
case 49:
|
|
3014
|
+
_t22 = _context15.v;
|
|
3015
|
+
_context15.n = 51;
|
|
3016
|
+
break;
|
|
3017
|
+
case 50:
|
|
3018
|
+
_t22 = null;
|
|
3019
|
+
case 51:
|
|
3020
|
+
studio = _t22;
|
|
3021
|
+
return _context15.a(2, regeneratorValues._objectSpread2({
|
|
3022
|
+
rev: "".concat(built.rev).concat(cssRev(css) ? "-".concat(cssRev(css)) : "") + (studio ? "-a".concat(assetsRev(studio.assets)) : ""),
|
|
2738
3023
|
modules: modules,
|
|
2739
3024
|
worker: built.worker,
|
|
2740
3025
|
browser: built.browser,
|
|
@@ -2742,20 +3027,23 @@ function _buildVendorLayer() {
|
|
|
2742
3027
|
skipped: skipped,
|
|
2743
3028
|
workerOnly: workerOnly,
|
|
2744
3029
|
workerOnlyReasons: workerOnlyReasons
|
|
2745
|
-
}
|
|
2746
|
-
|
|
2747
|
-
|
|
2748
|
-
|
|
3030
|
+
}, studio ? {
|
|
3031
|
+
assets: studio.assets,
|
|
3032
|
+
assetBytes: studio.files
|
|
3033
|
+
} : {}));
|
|
3034
|
+
case 52:
|
|
3035
|
+
_context15.p = 52;
|
|
3036
|
+
_context15.n = 53;
|
|
2749
3037
|
return promises.rm(stubs, {
|
|
2750
3038
|
recursive: true,
|
|
2751
3039
|
force: true
|
|
2752
3040
|
});
|
|
2753
|
-
case
|
|
2754
|
-
return _context15.f(
|
|
2755
|
-
case
|
|
3041
|
+
case 53:
|
|
3042
|
+
return _context15.f(52);
|
|
3043
|
+
case 54:
|
|
2756
3044
|
return _context15.a(2);
|
|
2757
3045
|
}
|
|
2758
|
-
}, _callee13, null, [[24, 26], [22, 30, 31, 32], [11,,
|
|
3046
|
+
}, _callee13, null, [[24, 26], [22, 30, 31, 32], [11,, 52, 54], [3, 7, 8, 9]]);
|
|
2759
3047
|
}));
|
|
2760
3048
|
return _buildVendorLayer.apply(this, arguments);
|
|
2761
3049
|
}
|
|
@@ -8,6 +8,7 @@ var node_crypto = require('node:crypto');
|
|
|
8
8
|
var node_module = require('node:module');
|
|
9
9
|
var promises = require('node:fs/promises');
|
|
10
10
|
var node_path = require('node:path');
|
|
11
|
+
var node_fs = require('node:fs');
|
|
11
12
|
var parseAst = require('rolldown/parseAst');
|
|
12
13
|
var esModuleLexer = require('es-module-lexer');
|
|
13
14
|
var node_url = require('node:url');
|
|
@@ -396,6 +397,272 @@ function _nodeShims() {
|
|
|
396
397
|
return _nodeShims.apply(this, arguments);
|
|
397
398
|
}
|
|
398
399
|
|
|
400
|
+
/** What a Val app's server answers Val's API under: `initValServer`'s route. */
|
|
401
|
+
var VAL_API_ROUTE = "/api/val";
|
|
402
|
+
/** Where `@valbuild/ui/server` is mounted under it. */
|
|
403
|
+
var STUDIO_STATIC_ROUTE = "".concat(VAL_API_ROUTE, "/static");
|
|
404
|
+
var UI_SERVER = "@valbuild/ui/server";
|
|
405
|
+
var STUB_ID = "\0platform:studio-served-by-platform";
|
|
406
|
+
|
|
407
|
+
/** `@valbuild/ui`'s `static/manifest.json`, the part read here. */
|
|
408
|
+
|
|
409
|
+
/** The format this reads. A newer one is refused rather than half understood. */
|
|
410
|
+
var MANIFEST_FORMAT = 1;
|
|
411
|
+
|
|
412
|
+
/** The Studio a build used, found while it resolved `@valbuild/ui/server`. */
|
|
413
|
+
|
|
414
|
+
/**
|
|
415
|
+
* Replace `@valbuild/ui/server` with a handler that has no files, when the
|
|
416
|
+
* `@valbuild/ui` being imported ships them as files (`static/manifest.json`),
|
|
417
|
+
* and record which `@valbuild/ui` that was.
|
|
418
|
+
*
|
|
419
|
+
* Resolved first, through everything after this plugin, so the package found
|
|
420
|
+
* is the one the import would have bundled -- under pnpm that is a copy in the
|
|
421
|
+
* store that only the importer can see.
|
|
422
|
+
*/
|
|
423
|
+
function studioServedByPlatform(found) {
|
|
424
|
+
return {
|
|
425
|
+
name: "platform:studio-served-by-platform",
|
|
426
|
+
resolveId: function resolveId(source, importer, extraOptions) {
|
|
427
|
+
var _this = this;
|
|
428
|
+
return regeneratorValues._asyncToGenerator(/*#__PURE__*/regeneratorValues._regenerator().m(function _callee() {
|
|
429
|
+
var resolved;
|
|
430
|
+
return regeneratorValues._regenerator().w(function (_context) {
|
|
431
|
+
while (1) switch (_context.n) {
|
|
432
|
+
case 0:
|
|
433
|
+
if (!(source !== UI_SERVER)) {
|
|
434
|
+
_context.n = 1;
|
|
435
|
+
break;
|
|
436
|
+
}
|
|
437
|
+
return _context.a(2, null);
|
|
438
|
+
case 1:
|
|
439
|
+
_context.n = 2;
|
|
440
|
+
return _this.resolve(source, importer, regeneratorValues._objectSpread2(regeneratorValues._objectSpread2({}, extraOptions), {}, {
|
|
441
|
+
skipSelf: true
|
|
442
|
+
}));
|
|
443
|
+
case 2:
|
|
444
|
+
resolved = _context.v;
|
|
445
|
+
return _context.a(2, replacementFor(found, resolved));
|
|
446
|
+
}
|
|
447
|
+
}, _callee);
|
|
448
|
+
}))();
|
|
449
|
+
},
|
|
450
|
+
load: function load(id) {
|
|
451
|
+
return loadReplacement(id);
|
|
452
|
+
}
|
|
453
|
+
};
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
/**
|
|
457
|
+
* The plugin's decision, given where `@valbuild/ui/server` resolved to: the
|
|
458
|
+
* replacement's id, recording the package in `found`, or null to bundle the
|
|
459
|
+
* module as it is.
|
|
460
|
+
*/
|
|
461
|
+
function replacementFor(found, resolved) {
|
|
462
|
+
if (!resolved || resolved.external) return null;
|
|
463
|
+
var root = packageRootOf(resolved.id);
|
|
464
|
+
if (root === null || !node_fs.existsSync(node_path.join(root, "static", "manifest.json"))) {
|
|
465
|
+
return null;
|
|
466
|
+
}
|
|
467
|
+
if (found.root !== null && found.root !== root) {
|
|
468
|
+
throw new Error("Two copies of @valbuild/ui are bundled into the layer (".concat(found.root, " and ").concat(root, "). ") + "The platform serves one Studio per layer; make the project depend on one version.");
|
|
469
|
+
}
|
|
470
|
+
found.root = root;
|
|
471
|
+
return STUB_ID;
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
/** The replacement's source, for its id; null for any other module. */
|
|
475
|
+
function loadReplacement(id) {
|
|
476
|
+
return id === STUB_ID ? STUB_SOURCE : null;
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
/**
|
|
480
|
+
* What the replaced module exports: the same function, answering every
|
|
481
|
+
* request with what happened and where to look, rather than with a file.
|
|
482
|
+
*
|
|
483
|
+
* Reached only when the platform did NOT answer a Studio file first, which
|
|
484
|
+
* means the layer's assets were not stored or not served -- a platform bug,
|
|
485
|
+
* and one a person should be able to name from the response.
|
|
486
|
+
*/
|
|
487
|
+
var STUB_SOURCE = "export function createUIRequestHandler() {\n return async (path) => ({\n status: 404,\n json: {\n message: \"The Studio's files are served by the platform, and it did not serve this one.\",\n details: \"The site was built without the Studio's files (they are build assets), so \" + JSON.stringify(path) + \" reached the site's server. The platform did not find it among the layer's assets.\",\n },\n });\n}\n";
|
|
488
|
+
|
|
489
|
+
/** The `node_modules/<name>` directory holding `file`, named `@valbuild/ui`. */
|
|
490
|
+
function packageRootOf(file) {
|
|
491
|
+
var dir = node_path.dirname(file);
|
|
492
|
+
for (;;) {
|
|
493
|
+
var manifest = node_path.join(dir, "package.json");
|
|
494
|
+
if (node_fs.existsSync(manifest)) {
|
|
495
|
+
try {
|
|
496
|
+
var _ref = JSON.parse(node_fs.readFileSync(manifest, "utf8")),
|
|
497
|
+
name = _ref.name;
|
|
498
|
+
if (name === "@valbuild/ui") return dir;
|
|
499
|
+
} catch (_unused) {
|
|
500
|
+
// Not a package manifest we can read: keep walking up.
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
var parent = node_path.dirname(dir);
|
|
504
|
+
if (parent === dir) return null;
|
|
505
|
+
dir = parent;
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
/**
|
|
510
|
+
* The Studio as build assets: every route of `@valbuild/ui`'s manifest under
|
|
511
|
+
* {@link STUDIO_STATIC_ROUTE}, and the bytes of every file a route names,
|
|
512
|
+
* base64, by sha256.
|
|
513
|
+
*
|
|
514
|
+
* Each file's hash is checked against the manifest as it is read: what the
|
|
515
|
+
* platform stores under a hash is what anything asking for that hash gets,
|
|
516
|
+
* forever, so a file that does not match is a broken package, not a file.
|
|
517
|
+
*/
|
|
518
|
+
function studioAssetsOf(_x) {
|
|
519
|
+
return _studioAssetsOf.apply(this, arguments);
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
/**
|
|
523
|
+
* A digest of an asset map, for the layer revision.
|
|
524
|
+
*
|
|
525
|
+
* The replaced module is the same text whichever Studio it replaced, so the
|
|
526
|
+
* layer's code alone does not change when only `@valbuild/ui` does -- and a
|
|
527
|
+
* layer that keeps its revision is never sent again, so the new Studio's
|
|
528
|
+
* files would never reach the platform. The map changes, so the map is
|
|
529
|
+
* folded in.
|
|
530
|
+
*/
|
|
531
|
+
function _studioAssetsOf() {
|
|
532
|
+
_studioAssetsOf = regeneratorValues._asyncToGenerator(/*#__PURE__*/regeneratorValues._regenerator().m(function _callee3(root) {
|
|
533
|
+
var manifest, files, assetOf, read, paths, _i, _Object$entries, _Object$entries$_i, route, _Object$entries$_i$, file, cacheControl, asset, fallback, _t;
|
|
534
|
+
return regeneratorValues._regenerator().w(function (_context3) {
|
|
535
|
+
while (1) switch (_context3.n) {
|
|
536
|
+
case 0:
|
|
537
|
+
_t = JSON;
|
|
538
|
+
_context3.n = 1;
|
|
539
|
+
return promises.readFile(node_path.join(root, "static", "manifest.json"), "utf8");
|
|
540
|
+
case 1:
|
|
541
|
+
manifest = _t.parse.call(_t, _context3.v);
|
|
542
|
+
if (!(manifest.format !== MANIFEST_FORMAT)) {
|
|
543
|
+
_context3.n = 2;
|
|
544
|
+
break;
|
|
545
|
+
}
|
|
546
|
+
throw new Error("@valbuild/ui@".concat(manifest.version, " describes its files in format ").concat(manifest.format, ", ") + "and this build reads format ".concat(MANIFEST_FORMAT, ". Update @valbuild/tanstack-build."));
|
|
547
|
+
case 2:
|
|
548
|
+
files = {};
|
|
549
|
+
assetOf = function assetOf(file, cacheControl) {
|
|
550
|
+
var described = manifest.files[file];
|
|
551
|
+
if (!described) {
|
|
552
|
+
throw new Error("@valbuild/ui@".concat(manifest.version, "'s manifest names ").concat(file, ", which it does not list."));
|
|
553
|
+
}
|
|
554
|
+
return {
|
|
555
|
+
sha256: described.sha256,
|
|
556
|
+
contentType: described.contentType,
|
|
557
|
+
cacheControl: cacheControl
|
|
558
|
+
};
|
|
559
|
+
};
|
|
560
|
+
read = /*#__PURE__*/function () {
|
|
561
|
+
var _ref6 = regeneratorValues._asyncToGenerator(/*#__PURE__*/regeneratorValues._regenerator().m(function _callee2(file, sha256) {
|
|
562
|
+
var bytes, actual;
|
|
563
|
+
return regeneratorValues._regenerator().w(function (_context2) {
|
|
564
|
+
while (1) switch (_context2.n) {
|
|
565
|
+
case 0:
|
|
566
|
+
if (!(sha256 in files)) {
|
|
567
|
+
_context2.n = 1;
|
|
568
|
+
break;
|
|
569
|
+
}
|
|
570
|
+
return _context2.a(2);
|
|
571
|
+
case 1:
|
|
572
|
+
_context2.n = 2;
|
|
573
|
+
return promises.readFile(node_path.join(root, "static", "files", file));
|
|
574
|
+
case 2:
|
|
575
|
+
bytes = _context2.v;
|
|
576
|
+
actual = node_crypto.createHash("sha256").update(bytes).digest("hex");
|
|
577
|
+
if (!(actual !== sha256)) {
|
|
578
|
+
_context2.n = 3;
|
|
579
|
+
break;
|
|
580
|
+
}
|
|
581
|
+
throw new Error("@valbuild/ui@".concat(manifest.version, "'s static").concat(file, " does not match its manifest ") + "(sha256 ".concat(actual, ", expected ").concat(sha256, "). The package is corrupt; reinstall it."));
|
|
582
|
+
case 3:
|
|
583
|
+
files[sha256] = bytes.toString("base64");
|
|
584
|
+
case 4:
|
|
585
|
+
return _context2.a(2);
|
|
586
|
+
}
|
|
587
|
+
}, _callee2);
|
|
588
|
+
}));
|
|
589
|
+
return function read(_x2, _x3) {
|
|
590
|
+
return _ref6.apply(this, arguments);
|
|
591
|
+
};
|
|
592
|
+
}();
|
|
593
|
+
paths = {};
|
|
594
|
+
_i = 0, _Object$entries = Object.entries(manifest.routes);
|
|
595
|
+
case 3:
|
|
596
|
+
if (!(_i < _Object$entries.length)) {
|
|
597
|
+
_context3.n = 5;
|
|
598
|
+
break;
|
|
599
|
+
}
|
|
600
|
+
_Object$entries$_i = regeneratorValues._slicedToArray(_Object$entries[_i], 2), route = _Object$entries$_i[0], _Object$entries$_i$ = _Object$entries$_i[1], file = _Object$entries$_i$.file, cacheControl = _Object$entries$_i$.cacheControl;
|
|
601
|
+
asset = assetOf(file, cacheControl);
|
|
602
|
+
paths["".concat(STUDIO_STATIC_ROUTE).concat(route)] = asset;
|
|
603
|
+
_context3.n = 4;
|
|
604
|
+
return read(file, asset.sha256);
|
|
605
|
+
case 4:
|
|
606
|
+
_i++;
|
|
607
|
+
_context3.n = 3;
|
|
608
|
+
break;
|
|
609
|
+
case 5:
|
|
610
|
+
fallback = assetOf(manifest.fallback.file, manifest.fallback.cacheControl);
|
|
611
|
+
_context3.n = 6;
|
|
612
|
+
return read(manifest.fallback.file, fallback.sha256);
|
|
613
|
+
case 6:
|
|
614
|
+
return _context3.a(2, {
|
|
615
|
+
assets: {
|
|
616
|
+
paths: paths,
|
|
617
|
+
fallbacks: [regeneratorValues._objectSpread2({
|
|
618
|
+
prefix: "".concat(STUDIO_STATIC_ROUTE, "/")
|
|
619
|
+
}, fallback)]
|
|
620
|
+
},
|
|
621
|
+
files: files,
|
|
622
|
+
version: manifest.version
|
|
623
|
+
});
|
|
624
|
+
}
|
|
625
|
+
}, _callee3);
|
|
626
|
+
}));
|
|
627
|
+
return _studioAssetsOf.apply(this, arguments);
|
|
628
|
+
}
|
|
629
|
+
function assetsRev(assets) {
|
|
630
|
+
var digest = node_crypto.createHash("sha256");
|
|
631
|
+
var _iterator = regeneratorValues._createForOfIteratorHelper(Object.entries(assets.paths).sort(function (_ref2, _ref3) {
|
|
632
|
+
var _ref4 = regeneratorValues._slicedToArray(_ref2, 1),
|
|
633
|
+
a = _ref4[0];
|
|
634
|
+
var _ref5 = regeneratorValues._slicedToArray(_ref3, 1),
|
|
635
|
+
b = _ref5[0];
|
|
636
|
+
return a < b ? -1 : a > b ? 1 : 0;
|
|
637
|
+
})),
|
|
638
|
+
_step;
|
|
639
|
+
try {
|
|
640
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
641
|
+
var _step$value = regeneratorValues._slicedToArray(_step.value, 2),
|
|
642
|
+
path = _step$value[0],
|
|
643
|
+
asset = _step$value[1];
|
|
644
|
+
digest.update("".concat(path, "\0").concat(asset.sha256, "\0").concat(asset.contentType, "\0").concat(asset.cacheControl, "\n"));
|
|
645
|
+
}
|
|
646
|
+
} catch (err) {
|
|
647
|
+
_iterator.e(err);
|
|
648
|
+
} finally {
|
|
649
|
+
_iterator.f();
|
|
650
|
+
}
|
|
651
|
+
var _iterator2 = regeneratorValues._createForOfIteratorHelper(assets.fallbacks),
|
|
652
|
+
_step2;
|
|
653
|
+
try {
|
|
654
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
655
|
+
var fallback = _step2.value;
|
|
656
|
+
digest.update("fallback\0".concat(fallback.prefix, "\0").concat(fallback.sha256, "\0").concat(fallback.contentType, "\0").concat(fallback.cacheControl, "\n"));
|
|
657
|
+
}
|
|
658
|
+
} catch (err) {
|
|
659
|
+
_iterator2.e(err);
|
|
660
|
+
} finally {
|
|
661
|
+
_iterator2.f();
|
|
662
|
+
}
|
|
663
|
+
return digest.digest("hex").slice(0, 8);
|
|
664
|
+
}
|
|
665
|
+
|
|
399
666
|
/**
|
|
400
667
|
* Packages the base layer already provides.
|
|
401
668
|
*
|
|
@@ -757,7 +1024,7 @@ function buildTargets(_x6, _x7, _x8, _x9, _x0) {
|
|
|
757
1024
|
*/
|
|
758
1025
|
function _buildTargets() {
|
|
759
1026
|
_buildTargets = regeneratorValues._asyncToGenerator(/*#__PURE__*/regeneratorValues._regenerator().m(function _callee6(names, input, outRoot, quiet, platform) {
|
|
760
|
-
var out, digest, packages, serverOnly, unusable, _iterator10, _step10, target, forTarget, dir, stubs, _loop3, _ret, _t4;
|
|
1027
|
+
var out, digest, studio, packages, serverOnly, unusable, _iterator10, _step10, target, forTarget, dir, stubs, _loop3, _ret, _t4;
|
|
761
1028
|
return regeneratorValues._regenerator().w(function (_context7) {
|
|
762
1029
|
while (1) switch (_context7.p = _context7.n) {
|
|
763
1030
|
case 0:
|
|
@@ -766,6 +1033,10 @@ function _buildTargets() {
|
|
|
766
1033
|
browser: {}
|
|
767
1034
|
};
|
|
768
1035
|
digest = node_crypto.createHash("sha256");
|
|
1036
|
+
/** The Studio the worker build replaced, if it replaced one. */
|
|
1037
|
+
studio = {
|
|
1038
|
+
root: null
|
|
1039
|
+
};
|
|
769
1040
|
/** Directory -> the package it belongs to, for the pin check. */
|
|
770
1041
|
packages = new Map();
|
|
771
1042
|
/** Entry -> why it cannot be built for a browser. */
|
|
@@ -825,7 +1096,7 @@ function _buildTargets() {
|
|
|
825
1096
|
return [name, input[name]];
|
|
826
1097
|
})),
|
|
827
1098
|
platform: target.platform,
|
|
828
|
-
plugins: [externaliseBase(target.baseFrom, platform), pinPlatformTanstack(platform), stubStartEntries(), stubServerEntries(target.name === "browser")].concat(regeneratorValues._toConsumableArray(stubs ? [stubUnbundlable(target.name === "browser", stubs)] : []), [
|
|
1099
|
+
plugins: [externaliseBase(target.baseFrom, platform), pinPlatformTanstack(platform), stubStartEntries(), stubServerEntries(target.name === "browser")].concat(regeneratorValues._toConsumableArray(target.name === "worker" && platform.base.buildAssets ? [studioServedByPlatform(studio)] : []), regeneratorValues._toConsumableArray(stubs ? [stubUnbundlable(target.name === "browser", stubs)] : []), [
|
|
829
1100
|
// Worker only: a browser has no Node builtins to bridge to, and a
|
|
830
1101
|
// package reaching for one there is a real error rather than a missing
|
|
831
1102
|
// runtime.
|
|
@@ -1038,6 +1309,7 @@ function _buildTargets() {
|
|
|
1038
1309
|
return _context7.a(2, regeneratorValues._objectSpread2(regeneratorValues._objectSpread2({}, out), {}, {
|
|
1039
1310
|
serverOnly: serverOnly,
|
|
1040
1311
|
unusable: unusable,
|
|
1312
|
+
studioRoot: studio.root,
|
|
1041
1313
|
rev: digest.digest("hex").slice(0, 16)
|
|
1042
1314
|
}));
|
|
1043
1315
|
}
|
|
@@ -2356,7 +2628,7 @@ function buildVendorLayer(_x34, _x35, _x36, _x37) {
|
|
|
2356
2628
|
}
|
|
2357
2629
|
function _buildVendorLayer() {
|
|
2358
2630
|
_buildVendorLayer = regeneratorValues._asyncToGenerator(/*#__PURE__*/regeneratorValues._regenerator().m(function _callee13(dir, deps, css, platform) {
|
|
2359
|
-
var modules, _iterator21, _step21, _loop4, stubs, input, _i6, _Object$entries4, _Object$entries4$_i, specifier, name, file, skipped, workerOnly, workerOnlyReasons, specifierOf, _i7, _Object$keys, _specifier, forBrowser, forgetUncarried, usable, built, _i9, _Object$values, _name2, worked, reasons, serverOnlyByContract, _iterator22, _step22, target, _probe$unusable$_name, probe, unbundlable, _message, _reasons$, _i0, _Object$entries5, _Object$entries5$_i, _specifier3, _name3, _i1, _Object$entries6, _Object$entries6$_i, _specifier4, _name4, reason, _i10, _Object$entries7, _Object$entries7$_i, _specifier5, _name5, _reason, _t19, _t20, _t21;
|
|
2631
|
+
var modules, _iterator21, _step21, _loop4, stubs, input, _i6, _Object$entries4, _Object$entries4$_i, specifier, name, file, skipped, workerOnly, workerOnlyReasons, specifierOf, _i7, _Object$keys, _specifier, forBrowser, forgetUncarried, usable, built, _i9, _Object$values, _name2, worked, reasons, serverOnlyByContract, _iterator22, _step22, target, _probe$unusable$_name, probe, unbundlable, _message, _reasons$, _i0, _Object$entries5, _Object$entries5$_i, _specifier3, _name3, _i1, _Object$entries6, _Object$entries6$_i, _specifier4, _name4, reason, _i10, _Object$entries7, _Object$entries7$_i, _specifier5, _name5, _reason, studio, _t19, _t20, _t21, _t22;
|
|
2360
2632
|
return regeneratorValues._regenerator().w(function (_context15) {
|
|
2361
2633
|
while (1) switch (_context15.p = _context15.n) {
|
|
2362
2634
|
case 0:
|
|
@@ -2730,11 +3002,24 @@ function _buildVendorLayer() {
|
|
|
2730
3002
|
case 48:
|
|
2731
3003
|
forgetUncarried();
|
|
2732
3004
|
|
|
2733
|
-
// The
|
|
2734
|
-
//
|
|
2735
|
-
|
|
2736
|
-
|
|
2737
|
-
|
|
3005
|
+
// The Studio's files, when the worker build replaced the module that
|
|
3006
|
+
// embeds them: see studioAssets.ts.
|
|
3007
|
+
if (!built.studioRoot) {
|
|
3008
|
+
_context15.n = 50;
|
|
3009
|
+
break;
|
|
3010
|
+
}
|
|
3011
|
+
_context15.n = 49;
|
|
3012
|
+
return studioAssetsOf(built.studioRoot);
|
|
3013
|
+
case 49:
|
|
3014
|
+
_t22 = _context15.v;
|
|
3015
|
+
_context15.n = 51;
|
|
3016
|
+
break;
|
|
3017
|
+
case 50:
|
|
3018
|
+
_t22 = null;
|
|
3019
|
+
case 51:
|
|
3020
|
+
studio = _t22;
|
|
3021
|
+
return _context15.a(2, regeneratorValues._objectSpread2({
|
|
3022
|
+
rev: "".concat(built.rev).concat(cssRev(css) ? "-".concat(cssRev(css)) : "") + (studio ? "-a".concat(assetsRev(studio.assets)) : ""),
|
|
2738
3023
|
modules: modules,
|
|
2739
3024
|
worker: built.worker,
|
|
2740
3025
|
browser: built.browser,
|
|
@@ -2742,20 +3027,23 @@ function _buildVendorLayer() {
|
|
|
2742
3027
|
skipped: skipped,
|
|
2743
3028
|
workerOnly: workerOnly,
|
|
2744
3029
|
workerOnlyReasons: workerOnlyReasons
|
|
2745
|
-
}
|
|
2746
|
-
|
|
2747
|
-
|
|
2748
|
-
|
|
3030
|
+
}, studio ? {
|
|
3031
|
+
assets: studio.assets,
|
|
3032
|
+
assetBytes: studio.files
|
|
3033
|
+
} : {}));
|
|
3034
|
+
case 52:
|
|
3035
|
+
_context15.p = 52;
|
|
3036
|
+
_context15.n = 53;
|
|
2749
3037
|
return promises.rm(stubs, {
|
|
2750
3038
|
recursive: true,
|
|
2751
3039
|
force: true
|
|
2752
3040
|
});
|
|
2753
|
-
case
|
|
2754
|
-
return _context15.f(
|
|
2755
|
-
case
|
|
3041
|
+
case 53:
|
|
3042
|
+
return _context15.f(52);
|
|
3043
|
+
case 54:
|
|
2756
3044
|
return _context15.a(2);
|
|
2757
3045
|
}
|
|
2758
|
-
}, _callee13, null, [[24, 26], [22, 30, 31, 32], [11,,
|
|
3046
|
+
}, _callee13, null, [[24, 26], [22, 30, 31, 32], [11,, 52, 54], [3, 7, 8, 9]]);
|
|
2759
3047
|
}));
|
|
2760
3048
|
return _buildVendorLayer.apply(this, arguments);
|
|
2761
3049
|
}
|
|
@@ -3,7 +3,8 @@ import { build } from 'rolldown';
|
|
|
3
3
|
import { createHash } from 'node:crypto';
|
|
4
4
|
import { createRequire } from 'node:module';
|
|
5
5
|
import { readFile, rm, writeFile, mkdir, readdir, stat } from 'node:fs/promises';
|
|
6
|
-
import { join, resolve, extname,
|
|
6
|
+
import { join, dirname, resolve, extname, isAbsolute } from 'node:path';
|
|
7
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
7
8
|
import { parseAstAsync } from 'rolldown/parseAst';
|
|
8
9
|
import { parse, ImportType, init } from 'es-module-lexer';
|
|
9
10
|
import { pathToFileURL } from 'node:url';
|
|
@@ -374,6 +375,272 @@ function _nodeShims() {
|
|
|
374
375
|
return _nodeShims.apply(this, arguments);
|
|
375
376
|
}
|
|
376
377
|
|
|
378
|
+
/** What a Val app's server answers Val's API under: `initValServer`'s route. */
|
|
379
|
+
var VAL_API_ROUTE = "/api/val";
|
|
380
|
+
/** Where `@valbuild/ui/server` is mounted under it. */
|
|
381
|
+
var STUDIO_STATIC_ROUTE = "".concat(VAL_API_ROUTE, "/static");
|
|
382
|
+
var UI_SERVER = "@valbuild/ui/server";
|
|
383
|
+
var STUB_ID = "\0platform:studio-served-by-platform";
|
|
384
|
+
|
|
385
|
+
/** `@valbuild/ui`'s `static/manifest.json`, the part read here. */
|
|
386
|
+
|
|
387
|
+
/** The format this reads. A newer one is refused rather than half understood. */
|
|
388
|
+
var MANIFEST_FORMAT = 1;
|
|
389
|
+
|
|
390
|
+
/** The Studio a build used, found while it resolved `@valbuild/ui/server`. */
|
|
391
|
+
|
|
392
|
+
/**
|
|
393
|
+
* Replace `@valbuild/ui/server` with a handler that has no files, when the
|
|
394
|
+
* `@valbuild/ui` being imported ships them as files (`static/manifest.json`),
|
|
395
|
+
* and record which `@valbuild/ui` that was.
|
|
396
|
+
*
|
|
397
|
+
* Resolved first, through everything after this plugin, so the package found
|
|
398
|
+
* is the one the import would have bundled -- under pnpm that is a copy in the
|
|
399
|
+
* store that only the importer can see.
|
|
400
|
+
*/
|
|
401
|
+
function studioServedByPlatform(found) {
|
|
402
|
+
return {
|
|
403
|
+
name: "platform:studio-served-by-platform",
|
|
404
|
+
resolveId: function resolveId(source, importer, extraOptions) {
|
|
405
|
+
var _this = this;
|
|
406
|
+
return _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
|
|
407
|
+
var resolved;
|
|
408
|
+
return _regenerator().w(function (_context) {
|
|
409
|
+
while (1) switch (_context.n) {
|
|
410
|
+
case 0:
|
|
411
|
+
if (!(source !== UI_SERVER)) {
|
|
412
|
+
_context.n = 1;
|
|
413
|
+
break;
|
|
414
|
+
}
|
|
415
|
+
return _context.a(2, null);
|
|
416
|
+
case 1:
|
|
417
|
+
_context.n = 2;
|
|
418
|
+
return _this.resolve(source, importer, _objectSpread2(_objectSpread2({}, extraOptions), {}, {
|
|
419
|
+
skipSelf: true
|
|
420
|
+
}));
|
|
421
|
+
case 2:
|
|
422
|
+
resolved = _context.v;
|
|
423
|
+
return _context.a(2, replacementFor(found, resolved));
|
|
424
|
+
}
|
|
425
|
+
}, _callee);
|
|
426
|
+
}))();
|
|
427
|
+
},
|
|
428
|
+
load: function load(id) {
|
|
429
|
+
return loadReplacement(id);
|
|
430
|
+
}
|
|
431
|
+
};
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
/**
|
|
435
|
+
* The plugin's decision, given where `@valbuild/ui/server` resolved to: the
|
|
436
|
+
* replacement's id, recording the package in `found`, or null to bundle the
|
|
437
|
+
* module as it is.
|
|
438
|
+
*/
|
|
439
|
+
function replacementFor(found, resolved) {
|
|
440
|
+
if (!resolved || resolved.external) return null;
|
|
441
|
+
var root = packageRootOf(resolved.id);
|
|
442
|
+
if (root === null || !existsSync(join(root, "static", "manifest.json"))) {
|
|
443
|
+
return null;
|
|
444
|
+
}
|
|
445
|
+
if (found.root !== null && found.root !== root) {
|
|
446
|
+
throw new Error("Two copies of @valbuild/ui are bundled into the layer (".concat(found.root, " and ").concat(root, "). ") + "The platform serves one Studio per layer; make the project depend on one version.");
|
|
447
|
+
}
|
|
448
|
+
found.root = root;
|
|
449
|
+
return STUB_ID;
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
/** The replacement's source, for its id; null for any other module. */
|
|
453
|
+
function loadReplacement(id) {
|
|
454
|
+
return id === STUB_ID ? STUB_SOURCE : null;
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
/**
|
|
458
|
+
* What the replaced module exports: the same function, answering every
|
|
459
|
+
* request with what happened and where to look, rather than with a file.
|
|
460
|
+
*
|
|
461
|
+
* Reached only when the platform did NOT answer a Studio file first, which
|
|
462
|
+
* means the layer's assets were not stored or not served -- a platform bug,
|
|
463
|
+
* and one a person should be able to name from the response.
|
|
464
|
+
*/
|
|
465
|
+
var STUB_SOURCE = "export function createUIRequestHandler() {\n return async (path) => ({\n status: 404,\n json: {\n message: \"The Studio's files are served by the platform, and it did not serve this one.\",\n details: \"The site was built without the Studio's files (they are build assets), so \" + JSON.stringify(path) + \" reached the site's server. The platform did not find it among the layer's assets.\",\n },\n });\n}\n";
|
|
466
|
+
|
|
467
|
+
/** The `node_modules/<name>` directory holding `file`, named `@valbuild/ui`. */
|
|
468
|
+
function packageRootOf(file) {
|
|
469
|
+
var dir = dirname(file);
|
|
470
|
+
for (;;) {
|
|
471
|
+
var manifest = join(dir, "package.json");
|
|
472
|
+
if (existsSync(manifest)) {
|
|
473
|
+
try {
|
|
474
|
+
var _ref = JSON.parse(readFileSync(manifest, "utf8")),
|
|
475
|
+
name = _ref.name;
|
|
476
|
+
if (name === "@valbuild/ui") return dir;
|
|
477
|
+
} catch (_unused) {
|
|
478
|
+
// Not a package manifest we can read: keep walking up.
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
var parent = dirname(dir);
|
|
482
|
+
if (parent === dir) return null;
|
|
483
|
+
dir = parent;
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
/**
|
|
488
|
+
* The Studio as build assets: every route of `@valbuild/ui`'s manifest under
|
|
489
|
+
* {@link STUDIO_STATIC_ROUTE}, and the bytes of every file a route names,
|
|
490
|
+
* base64, by sha256.
|
|
491
|
+
*
|
|
492
|
+
* Each file's hash is checked against the manifest as it is read: what the
|
|
493
|
+
* platform stores under a hash is what anything asking for that hash gets,
|
|
494
|
+
* forever, so a file that does not match is a broken package, not a file.
|
|
495
|
+
*/
|
|
496
|
+
function studioAssetsOf(_x) {
|
|
497
|
+
return _studioAssetsOf.apply(this, arguments);
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
/**
|
|
501
|
+
* A digest of an asset map, for the layer revision.
|
|
502
|
+
*
|
|
503
|
+
* The replaced module is the same text whichever Studio it replaced, so the
|
|
504
|
+
* layer's code alone does not change when only `@valbuild/ui` does -- and a
|
|
505
|
+
* layer that keeps its revision is never sent again, so the new Studio's
|
|
506
|
+
* files would never reach the platform. The map changes, so the map is
|
|
507
|
+
* folded in.
|
|
508
|
+
*/
|
|
509
|
+
function _studioAssetsOf() {
|
|
510
|
+
_studioAssetsOf = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(root) {
|
|
511
|
+
var manifest, files, assetOf, read, paths, _i, _Object$entries, _Object$entries$_i, route, _Object$entries$_i$, file, cacheControl, asset, fallback, _t;
|
|
512
|
+
return _regenerator().w(function (_context3) {
|
|
513
|
+
while (1) switch (_context3.n) {
|
|
514
|
+
case 0:
|
|
515
|
+
_t = JSON;
|
|
516
|
+
_context3.n = 1;
|
|
517
|
+
return readFile(join(root, "static", "manifest.json"), "utf8");
|
|
518
|
+
case 1:
|
|
519
|
+
manifest = _t.parse.call(_t, _context3.v);
|
|
520
|
+
if (!(manifest.format !== MANIFEST_FORMAT)) {
|
|
521
|
+
_context3.n = 2;
|
|
522
|
+
break;
|
|
523
|
+
}
|
|
524
|
+
throw new Error("@valbuild/ui@".concat(manifest.version, " describes its files in format ").concat(manifest.format, ", ") + "and this build reads format ".concat(MANIFEST_FORMAT, ". Update @valbuild/tanstack-build."));
|
|
525
|
+
case 2:
|
|
526
|
+
files = {};
|
|
527
|
+
assetOf = function assetOf(file, cacheControl) {
|
|
528
|
+
var described = manifest.files[file];
|
|
529
|
+
if (!described) {
|
|
530
|
+
throw new Error("@valbuild/ui@".concat(manifest.version, "'s manifest names ").concat(file, ", which it does not list."));
|
|
531
|
+
}
|
|
532
|
+
return {
|
|
533
|
+
sha256: described.sha256,
|
|
534
|
+
contentType: described.contentType,
|
|
535
|
+
cacheControl: cacheControl
|
|
536
|
+
};
|
|
537
|
+
};
|
|
538
|
+
read = /*#__PURE__*/function () {
|
|
539
|
+
var _ref6 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(file, sha256) {
|
|
540
|
+
var bytes, actual;
|
|
541
|
+
return _regenerator().w(function (_context2) {
|
|
542
|
+
while (1) switch (_context2.n) {
|
|
543
|
+
case 0:
|
|
544
|
+
if (!(sha256 in files)) {
|
|
545
|
+
_context2.n = 1;
|
|
546
|
+
break;
|
|
547
|
+
}
|
|
548
|
+
return _context2.a(2);
|
|
549
|
+
case 1:
|
|
550
|
+
_context2.n = 2;
|
|
551
|
+
return readFile(join(root, "static", "files", file));
|
|
552
|
+
case 2:
|
|
553
|
+
bytes = _context2.v;
|
|
554
|
+
actual = createHash("sha256").update(bytes).digest("hex");
|
|
555
|
+
if (!(actual !== sha256)) {
|
|
556
|
+
_context2.n = 3;
|
|
557
|
+
break;
|
|
558
|
+
}
|
|
559
|
+
throw new Error("@valbuild/ui@".concat(manifest.version, "'s static").concat(file, " does not match its manifest ") + "(sha256 ".concat(actual, ", expected ").concat(sha256, "). The package is corrupt; reinstall it."));
|
|
560
|
+
case 3:
|
|
561
|
+
files[sha256] = bytes.toString("base64");
|
|
562
|
+
case 4:
|
|
563
|
+
return _context2.a(2);
|
|
564
|
+
}
|
|
565
|
+
}, _callee2);
|
|
566
|
+
}));
|
|
567
|
+
return function read(_x2, _x3) {
|
|
568
|
+
return _ref6.apply(this, arguments);
|
|
569
|
+
};
|
|
570
|
+
}();
|
|
571
|
+
paths = {};
|
|
572
|
+
_i = 0, _Object$entries = Object.entries(manifest.routes);
|
|
573
|
+
case 3:
|
|
574
|
+
if (!(_i < _Object$entries.length)) {
|
|
575
|
+
_context3.n = 5;
|
|
576
|
+
break;
|
|
577
|
+
}
|
|
578
|
+
_Object$entries$_i = _slicedToArray(_Object$entries[_i], 2), route = _Object$entries$_i[0], _Object$entries$_i$ = _Object$entries$_i[1], file = _Object$entries$_i$.file, cacheControl = _Object$entries$_i$.cacheControl;
|
|
579
|
+
asset = assetOf(file, cacheControl);
|
|
580
|
+
paths["".concat(STUDIO_STATIC_ROUTE).concat(route)] = asset;
|
|
581
|
+
_context3.n = 4;
|
|
582
|
+
return read(file, asset.sha256);
|
|
583
|
+
case 4:
|
|
584
|
+
_i++;
|
|
585
|
+
_context3.n = 3;
|
|
586
|
+
break;
|
|
587
|
+
case 5:
|
|
588
|
+
fallback = assetOf(manifest.fallback.file, manifest.fallback.cacheControl);
|
|
589
|
+
_context3.n = 6;
|
|
590
|
+
return read(manifest.fallback.file, fallback.sha256);
|
|
591
|
+
case 6:
|
|
592
|
+
return _context3.a(2, {
|
|
593
|
+
assets: {
|
|
594
|
+
paths: paths,
|
|
595
|
+
fallbacks: [_objectSpread2({
|
|
596
|
+
prefix: "".concat(STUDIO_STATIC_ROUTE, "/")
|
|
597
|
+
}, fallback)]
|
|
598
|
+
},
|
|
599
|
+
files: files,
|
|
600
|
+
version: manifest.version
|
|
601
|
+
});
|
|
602
|
+
}
|
|
603
|
+
}, _callee3);
|
|
604
|
+
}));
|
|
605
|
+
return _studioAssetsOf.apply(this, arguments);
|
|
606
|
+
}
|
|
607
|
+
function assetsRev(assets) {
|
|
608
|
+
var digest = createHash("sha256");
|
|
609
|
+
var _iterator = _createForOfIteratorHelper(Object.entries(assets.paths).sort(function (_ref2, _ref3) {
|
|
610
|
+
var _ref4 = _slicedToArray(_ref2, 1),
|
|
611
|
+
a = _ref4[0];
|
|
612
|
+
var _ref5 = _slicedToArray(_ref3, 1),
|
|
613
|
+
b = _ref5[0];
|
|
614
|
+
return a < b ? -1 : a > b ? 1 : 0;
|
|
615
|
+
})),
|
|
616
|
+
_step;
|
|
617
|
+
try {
|
|
618
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
619
|
+
var _step$value = _slicedToArray(_step.value, 2),
|
|
620
|
+
path = _step$value[0],
|
|
621
|
+
asset = _step$value[1];
|
|
622
|
+
digest.update("".concat(path, "\0").concat(asset.sha256, "\0").concat(asset.contentType, "\0").concat(asset.cacheControl, "\n"));
|
|
623
|
+
}
|
|
624
|
+
} catch (err) {
|
|
625
|
+
_iterator.e(err);
|
|
626
|
+
} finally {
|
|
627
|
+
_iterator.f();
|
|
628
|
+
}
|
|
629
|
+
var _iterator2 = _createForOfIteratorHelper(assets.fallbacks),
|
|
630
|
+
_step2;
|
|
631
|
+
try {
|
|
632
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
633
|
+
var fallback = _step2.value;
|
|
634
|
+
digest.update("fallback\0".concat(fallback.prefix, "\0").concat(fallback.sha256, "\0").concat(fallback.contentType, "\0").concat(fallback.cacheControl, "\n"));
|
|
635
|
+
}
|
|
636
|
+
} catch (err) {
|
|
637
|
+
_iterator2.e(err);
|
|
638
|
+
} finally {
|
|
639
|
+
_iterator2.f();
|
|
640
|
+
}
|
|
641
|
+
return digest.digest("hex").slice(0, 8);
|
|
642
|
+
}
|
|
643
|
+
|
|
377
644
|
/**
|
|
378
645
|
* Packages the base layer already provides.
|
|
379
646
|
*
|
|
@@ -735,7 +1002,7 @@ function buildTargets(_x6, _x7, _x8, _x9, _x0) {
|
|
|
735
1002
|
*/
|
|
736
1003
|
function _buildTargets() {
|
|
737
1004
|
_buildTargets = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(names, input, outRoot, quiet, platform) {
|
|
738
|
-
var out, digest, packages, serverOnly, unusable, _iterator10, _step10, target, forTarget, dir, stubs, _loop3, _ret, _t4;
|
|
1005
|
+
var out, digest, studio, packages, serverOnly, unusable, _iterator10, _step10, target, forTarget, dir, stubs, _loop3, _ret, _t4;
|
|
739
1006
|
return _regenerator().w(function (_context7) {
|
|
740
1007
|
while (1) switch (_context7.p = _context7.n) {
|
|
741
1008
|
case 0:
|
|
@@ -744,6 +1011,10 @@ function _buildTargets() {
|
|
|
744
1011
|
browser: {}
|
|
745
1012
|
};
|
|
746
1013
|
digest = createHash("sha256");
|
|
1014
|
+
/** The Studio the worker build replaced, if it replaced one. */
|
|
1015
|
+
studio = {
|
|
1016
|
+
root: null
|
|
1017
|
+
};
|
|
747
1018
|
/** Directory -> the package it belongs to, for the pin check. */
|
|
748
1019
|
packages = new Map();
|
|
749
1020
|
/** Entry -> why it cannot be built for a browser. */
|
|
@@ -803,7 +1074,7 @@ function _buildTargets() {
|
|
|
803
1074
|
return [name, input[name]];
|
|
804
1075
|
})),
|
|
805
1076
|
platform: target.platform,
|
|
806
|
-
plugins: [externaliseBase(target.baseFrom, platform), pinPlatformTanstack(platform), stubStartEntries(), stubServerEntries(target.name === "browser")].concat(_toConsumableArray(stubs ? [stubUnbundlable(target.name === "browser", stubs)] : []), [
|
|
1077
|
+
plugins: [externaliseBase(target.baseFrom, platform), pinPlatformTanstack(platform), stubStartEntries(), stubServerEntries(target.name === "browser")].concat(_toConsumableArray(target.name === "worker" && platform.base.buildAssets ? [studioServedByPlatform(studio)] : []), _toConsumableArray(stubs ? [stubUnbundlable(target.name === "browser", stubs)] : []), [
|
|
807
1078
|
// Worker only: a browser has no Node builtins to bridge to, and a
|
|
808
1079
|
// package reaching for one there is a real error rather than a missing
|
|
809
1080
|
// runtime.
|
|
@@ -1016,6 +1287,7 @@ function _buildTargets() {
|
|
|
1016
1287
|
return _context7.a(2, _objectSpread2(_objectSpread2({}, out), {}, {
|
|
1017
1288
|
serverOnly: serverOnly,
|
|
1018
1289
|
unusable: unusable,
|
|
1290
|
+
studioRoot: studio.root,
|
|
1019
1291
|
rev: digest.digest("hex").slice(0, 16)
|
|
1020
1292
|
}));
|
|
1021
1293
|
}
|
|
@@ -2334,7 +2606,7 @@ function buildVendorLayer(_x34, _x35, _x36, _x37) {
|
|
|
2334
2606
|
}
|
|
2335
2607
|
function _buildVendorLayer() {
|
|
2336
2608
|
_buildVendorLayer = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee13(dir, deps, css, platform) {
|
|
2337
|
-
var modules, _iterator21, _step21, _loop4, stubs, input, _i6, _Object$entries4, _Object$entries4$_i, specifier, name, file, skipped, workerOnly, workerOnlyReasons, specifierOf, _i7, _Object$keys, _specifier, forBrowser, forgetUncarried, usable, built, _i9, _Object$values, _name2, worked, reasons, serverOnlyByContract, _iterator22, _step22, target, _probe$unusable$_name, probe, unbundlable, _message, _reasons$, _i0, _Object$entries5, _Object$entries5$_i, _specifier3, _name3, _i1, _Object$entries6, _Object$entries6$_i, _specifier4, _name4, reason, _i10, _Object$entries7, _Object$entries7$_i, _specifier5, _name5, _reason, _t19, _t20, _t21;
|
|
2609
|
+
var modules, _iterator21, _step21, _loop4, stubs, input, _i6, _Object$entries4, _Object$entries4$_i, specifier, name, file, skipped, workerOnly, workerOnlyReasons, specifierOf, _i7, _Object$keys, _specifier, forBrowser, forgetUncarried, usable, built, _i9, _Object$values, _name2, worked, reasons, serverOnlyByContract, _iterator22, _step22, target, _probe$unusable$_name, probe, unbundlable, _message, _reasons$, _i0, _Object$entries5, _Object$entries5$_i, _specifier3, _name3, _i1, _Object$entries6, _Object$entries6$_i, _specifier4, _name4, reason, _i10, _Object$entries7, _Object$entries7$_i, _specifier5, _name5, _reason, studio, _t19, _t20, _t21, _t22;
|
|
2338
2610
|
return _regenerator().w(function (_context15) {
|
|
2339
2611
|
while (1) switch (_context15.p = _context15.n) {
|
|
2340
2612
|
case 0:
|
|
@@ -2708,11 +2980,24 @@ function _buildVendorLayer() {
|
|
|
2708
2980
|
case 48:
|
|
2709
2981
|
forgetUncarried();
|
|
2710
2982
|
|
|
2711
|
-
// The
|
|
2712
|
-
//
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
2983
|
+
// The Studio's files, when the worker build replaced the module that
|
|
2984
|
+
// embeds them: see studioAssets.ts.
|
|
2985
|
+
if (!built.studioRoot) {
|
|
2986
|
+
_context15.n = 50;
|
|
2987
|
+
break;
|
|
2988
|
+
}
|
|
2989
|
+
_context15.n = 49;
|
|
2990
|
+
return studioAssetsOf(built.studioRoot);
|
|
2991
|
+
case 49:
|
|
2992
|
+
_t22 = _context15.v;
|
|
2993
|
+
_context15.n = 51;
|
|
2994
|
+
break;
|
|
2995
|
+
case 50:
|
|
2996
|
+
_t22 = null;
|
|
2997
|
+
case 51:
|
|
2998
|
+
studio = _t22;
|
|
2999
|
+
return _context15.a(2, _objectSpread2({
|
|
3000
|
+
rev: "".concat(built.rev).concat(cssRev(css) ? "-".concat(cssRev(css)) : "") + (studio ? "-a".concat(assetsRev(studio.assets)) : ""),
|
|
2716
3001
|
modules: modules,
|
|
2717
3002
|
worker: built.worker,
|
|
2718
3003
|
browser: built.browser,
|
|
@@ -2720,20 +3005,23 @@ function _buildVendorLayer() {
|
|
|
2720
3005
|
skipped: skipped,
|
|
2721
3006
|
workerOnly: workerOnly,
|
|
2722
3007
|
workerOnlyReasons: workerOnlyReasons
|
|
2723
|
-
}
|
|
2724
|
-
|
|
2725
|
-
|
|
2726
|
-
|
|
3008
|
+
}, studio ? {
|
|
3009
|
+
assets: studio.assets,
|
|
3010
|
+
assetBytes: studio.files
|
|
3011
|
+
} : {}));
|
|
3012
|
+
case 52:
|
|
3013
|
+
_context15.p = 52;
|
|
3014
|
+
_context15.n = 53;
|
|
2727
3015
|
return rm(stubs, {
|
|
2728
3016
|
recursive: true,
|
|
2729
3017
|
force: true
|
|
2730
3018
|
});
|
|
2731
|
-
case
|
|
2732
|
-
return _context15.f(
|
|
2733
|
-
case
|
|
3019
|
+
case 53:
|
|
3020
|
+
return _context15.f(52);
|
|
3021
|
+
case 54:
|
|
2734
3022
|
return _context15.a(2);
|
|
2735
3023
|
}
|
|
2736
|
-
}, _callee13, null, [[24, 26], [22, 30, 31, 32], [11,,
|
|
3024
|
+
}, _callee13, null, [[24, 26], [22, 30, 31, 32], [11,, 52, 54], [3, 7, 8, 9]]);
|
|
2737
3025
|
}));
|
|
2738
3026
|
return _buildVendorLayer.apply(this, arguments);
|
|
2739
3027
|
}
|
package/package.json
CHANGED