@valbuild/tanstack-build 0.136.1 → 0.136.10
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 +19 -0
- package/dist/{slicedToArray-d71360f4.esm.js → regeneratorValues-3acdc3fe.esm.js} +19 -1
- package/dist/{slicedToArray-12869836.cjs.dev.js → regeneratorValues-637c3146.cjs.prod.js} +19 -0
- package/dist/{slicedToArray-149a2518.cjs.prod.js → regeneratorValues-78fb2365.cjs.dev.js} +19 -0
- package/dist/valbuild-tanstack-build.cjs.dev.js +659 -133
- package/dist/valbuild-tanstack-build.cjs.prod.js +659 -133
- package/dist/valbuild-tanstack-build.esm.js +553 -27
- package/node/dist/valbuild-tanstack-build-node.cjs.dev.js +75 -93
- package/node/dist/valbuild-tanstack-build-node.cjs.prod.js +75 -93
- package/node/dist/valbuild-tanstack-build-node.esm.js +1 -19
- package/package.json +1 -1
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var regeneratorValues = require('./regeneratorValues-78fb2365.cjs.dev.js');
|
|
6
6
|
var browser = require('@rolldown/browser');
|
|
7
7
|
var projectPaths = require('./projectPaths-f222255a.cjs.dev.js');
|
|
8
8
|
var parseAst = require('@rolldown/browser/parseAst');
|
|
@@ -18,7 +18,7 @@ function dirname(path) {
|
|
|
18
18
|
}
|
|
19
19
|
function resolve(from, to) {
|
|
20
20
|
var segments = to.startsWith("/") ? [] : from.split("/").filter(Boolean);
|
|
21
|
-
var _iterator =
|
|
21
|
+
var _iterator = regeneratorValues._createForOfIteratorHelper(to.split("/")),
|
|
22
22
|
_step;
|
|
23
23
|
try {
|
|
24
24
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
@@ -37,7 +37,7 @@ var EXTENSIONS = ["", ".tsx", ".ts", ".jsx", ".js", "/index.tsx", "/index.ts"];
|
|
|
37
37
|
|
|
38
38
|
/** Resolve a relative import against the in-memory file set. */
|
|
39
39
|
function resolveInFiles(base, files) {
|
|
40
|
-
var _iterator2 =
|
|
40
|
+
var _iterator2 = regeneratorValues._createForOfIteratorHelper(EXTENSIONS),
|
|
41
41
|
_step2;
|
|
42
42
|
try {
|
|
43
43
|
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
@@ -62,8 +62,8 @@ function parse(_x, _x2) {
|
|
|
62
62
|
|
|
63
63
|
/** Depth-first walk carrying a parent stack, nearest parent last. */
|
|
64
64
|
function _parse() {
|
|
65
|
-
_parse =
|
|
66
|
-
return
|
|
65
|
+
_parse = regeneratorValues._asyncToGenerator(/*#__PURE__*/regeneratorValues._regenerator().m(function _callee(path, code) {
|
|
66
|
+
return regeneratorValues._regenerator().w(function (_context) {
|
|
67
67
|
while (1) switch (_context.n) {
|
|
68
68
|
case 0:
|
|
69
69
|
_context.n = 1;
|
|
@@ -87,7 +87,7 @@ function walk(node, visit) {
|
|
|
87
87
|
if (_key === "type" || _key === "start" || _key === "end") continue;
|
|
88
88
|
var value = node[_key];
|
|
89
89
|
if (Array.isArray(value)) {
|
|
90
|
-
var _iterator =
|
|
90
|
+
var _iterator = regeneratorValues._createForOfIteratorHelper(value),
|
|
91
91
|
_step;
|
|
92
92
|
try {
|
|
93
93
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
@@ -108,11 +108,11 @@ function walk(node, visit) {
|
|
|
108
108
|
|
|
109
109
|
/** Applies edits end-first, so earlier offsets stay valid. */
|
|
110
110
|
function applyEdits(code, edits) {
|
|
111
|
-
var ordered =
|
|
111
|
+
var ordered = regeneratorValues._toConsumableArray(edits).sort(function (a, b) {
|
|
112
112
|
return b.start - a.start || b.end - a.end;
|
|
113
113
|
});
|
|
114
114
|
var out = code;
|
|
115
|
-
var _iterator2 =
|
|
115
|
+
var _iterator2 = regeneratorValues._createForOfIteratorHelper(ordered),
|
|
116
116
|
_step2;
|
|
117
117
|
try {
|
|
118
118
|
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
@@ -255,7 +255,7 @@ function findSites(ast, moduleId, code, seen) {
|
|
|
255
255
|
// The extracted function has to reference the variable to reach
|
|
256
256
|
// __executeServer, so an unassigned call has nothing to hang off. Start
|
|
257
257
|
// enforces the same rule, with the same reasoning.
|
|
258
|
-
var declarator =
|
|
258
|
+
var declarator = regeneratorValues._toConsumableArray(stack).reverse().find(function (parent) {
|
|
259
259
|
return parent.type === "VariableDeclarator";
|
|
260
260
|
});
|
|
261
261
|
var declarationIndex = stack.map(function (parent) {
|
|
@@ -296,9 +296,9 @@ function transformServerFns(_x, _x2, _x3, _x4) {
|
|
|
296
296
|
return _transformServerFns.apply(this, arguments);
|
|
297
297
|
}
|
|
298
298
|
function _transformServerFns() {
|
|
299
|
-
_transformServerFns =
|
|
299
|
+
_transformServerFns = regeneratorValues._asyncToGenerator(/*#__PURE__*/regeneratorValues._regenerator().m(function _callee(moduleId, code, target, seen) {
|
|
300
300
|
var ast, sites, edits, _iterator, _step, site, meta, out, prelude;
|
|
301
|
-
return
|
|
301
|
+
return regeneratorValues._regenerator().w(function (_context) {
|
|
302
302
|
while (1) switch (_context.n) {
|
|
303
303
|
case 0:
|
|
304
304
|
if (code.includes("createServerFn")) {
|
|
@@ -319,7 +319,7 @@ function _transformServerFns() {
|
|
|
319
319
|
return _context.a(2, null);
|
|
320
320
|
case 3:
|
|
321
321
|
edits = [];
|
|
322
|
-
_iterator =
|
|
322
|
+
_iterator = regeneratorValues._createForOfIteratorHelper(sites);
|
|
323
323
|
try {
|
|
324
324
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
325
325
|
site = _step.value;
|
|
@@ -382,16 +382,16 @@ function sha256Hex(_x) {
|
|
|
382
382
|
return _sha256Hex.apply(this, arguments);
|
|
383
383
|
}
|
|
384
384
|
function _sha256Hex() {
|
|
385
|
-
_sha256Hex =
|
|
385
|
+
_sha256Hex = regeneratorValues._asyncToGenerator(/*#__PURE__*/regeneratorValues._regenerator().m(function _callee(text) {
|
|
386
386
|
var digest;
|
|
387
|
-
return
|
|
387
|
+
return regeneratorValues._regenerator().w(function (_context) {
|
|
388
388
|
while (1) switch (_context.n) {
|
|
389
389
|
case 0:
|
|
390
390
|
_context.n = 1;
|
|
391
391
|
return crypto.subtle.digest("SHA-256", new TextEncoder().encode(text));
|
|
392
392
|
case 1:
|
|
393
393
|
digest = _context.v;
|
|
394
|
-
return _context.a(2,
|
|
394
|
+
return _context.a(2, regeneratorValues._toConsumableArray(new Uint8Array(digest)).map(function (_byte) {
|
|
395
395
|
return _byte.toString(16).padStart(2, "0");
|
|
396
396
|
}).join(""));
|
|
397
397
|
}
|
|
@@ -437,9 +437,9 @@ function transformCssModule(_x, _x2) {
|
|
|
437
437
|
|
|
438
438
|
/** The JS module a CSS-module import becomes. */
|
|
439
439
|
function _transformCssModule() {
|
|
440
|
-
_transformCssModule =
|
|
440
|
+
_transformCssModule = regeneratorValues._asyncToGenerator(/*#__PURE__*/regeneratorValues._regenerator().m(function _callee(path, css) {
|
|
441
441
|
var suffix, warnings, _iterator, _step, _step$value, pattern, message, names, scoped;
|
|
442
|
-
return
|
|
442
|
+
return regeneratorValues._regenerator().w(function (_context) {
|
|
443
443
|
while (1) switch (_context.n) {
|
|
444
444
|
case 0:
|
|
445
445
|
_context.n = 1;
|
|
@@ -447,10 +447,10 @@ function _transformCssModule() {
|
|
|
447
447
|
case 1:
|
|
448
448
|
suffix = _context.v.slice(0, 8);
|
|
449
449
|
warnings = [];
|
|
450
|
-
_iterator =
|
|
450
|
+
_iterator = regeneratorValues._createForOfIteratorHelper(UNSUPPORTED$1);
|
|
451
451
|
try {
|
|
452
452
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
453
|
-
_step$value =
|
|
453
|
+
_step$value = regeneratorValues._slicedToArray(_step.value, 2), pattern = _step$value[0], message = _step$value[1];
|
|
454
454
|
if (pattern.test(css)) warnings.push("".concat(path, ": ").concat(message, "."));
|
|
455
455
|
}
|
|
456
456
|
} catch (err) {
|
|
@@ -501,9 +501,9 @@ function importsOf(_x, _x2) {
|
|
|
501
501
|
return _importsOf.apply(this, arguments);
|
|
502
502
|
}
|
|
503
503
|
function _importsOf() {
|
|
504
|
-
_importsOf =
|
|
504
|
+
_importsOf = regeneratorValues._asyncToGenerator(/*#__PURE__*/regeneratorValues._regenerator().m(function _callee(path, code) {
|
|
505
505
|
var lang, ast, sources, _iterator, _step, statement, source;
|
|
506
|
-
return
|
|
506
|
+
return regeneratorValues._regenerator().w(function (_context) {
|
|
507
507
|
while (1) switch (_context.n) {
|
|
508
508
|
case 0:
|
|
509
509
|
lang = path.endsWith(".tsx") || path.endsWith(".jsx") ? "tsx" : "ts";
|
|
@@ -514,7 +514,7 @@ function _importsOf() {
|
|
|
514
514
|
case 1:
|
|
515
515
|
ast = _context.v;
|
|
516
516
|
sources = [];
|
|
517
|
-
_iterator =
|
|
517
|
+
_iterator = regeneratorValues._createForOfIteratorHelper(ast.body);
|
|
518
518
|
try {
|
|
519
519
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
520
520
|
statement = _step.value;
|
|
@@ -552,7 +552,7 @@ function collectCss(_x3, _x4) {
|
|
|
552
552
|
return _collectCss.apply(this, arguments);
|
|
553
553
|
}
|
|
554
554
|
function _collectCss() {
|
|
555
|
-
_collectCss =
|
|
555
|
+
_collectCss = regeneratorValues._asyncToGenerator(/*#__PURE__*/regeneratorValues._regenerator().m(function _callee3(files, entry) {
|
|
556
556
|
var dependencyCss,
|
|
557
557
|
aliases,
|
|
558
558
|
visited,
|
|
@@ -563,13 +563,13 @@ function _collectCss() {
|
|
|
563
563
|
walk,
|
|
564
564
|
_walk,
|
|
565
565
|
_args3 = arguments;
|
|
566
|
-
return
|
|
566
|
+
return regeneratorValues._regenerator().w(function (_context3) {
|
|
567
567
|
while (1) switch (_context3.n) {
|
|
568
568
|
case 0:
|
|
569
569
|
_walk = function _walk3() {
|
|
570
|
-
_walk =
|
|
570
|
+
_walk = regeneratorValues._asyncToGenerator(/*#__PURE__*/regeneratorValues._regenerator().m(function _callee2(path) {
|
|
571
571
|
var _files$bare, bare, text, scoped, code, _iterator2, _step2, source, _aliases$candidates, _bare, aliased, _iterator3, _step3, candidate, hit, resolved, _t, _t2, _t3;
|
|
572
|
-
return
|
|
572
|
+
return regeneratorValues._regenerator().w(function (_context2) {
|
|
573
573
|
while (1) switch (_context2.p = _context2.n) {
|
|
574
574
|
case 0:
|
|
575
575
|
if (!visited.has(path)) {
|
|
@@ -594,7 +594,7 @@ function _collectCss() {
|
|
|
594
594
|
case 2:
|
|
595
595
|
scoped = _context2.v;
|
|
596
596
|
modules[bare] = scoped.names;
|
|
597
|
-
warnings.push.apply(warnings,
|
|
597
|
+
warnings.push.apply(warnings, regeneratorValues._toConsumableArray(scoped.warnings));
|
|
598
598
|
sheets.push(scoped.css);
|
|
599
599
|
_context2.n = 4;
|
|
600
600
|
break;
|
|
@@ -617,7 +617,7 @@ function _collectCss() {
|
|
|
617
617
|
}
|
|
618
618
|
return _context2.a(2);
|
|
619
619
|
case 7:
|
|
620
|
-
_t =
|
|
620
|
+
_t = regeneratorValues._createForOfIteratorHelper;
|
|
621
621
|
_context2.n = 8;
|
|
622
622
|
return importsOf(path, code);
|
|
623
623
|
case 8:
|
|
@@ -649,8 +649,8 @@ function _collectCss() {
|
|
|
649
649
|
case 11:
|
|
650
650
|
// ...or a tsconfig alias, which is a bare specifier that names one of
|
|
651
651
|
// the project's own files.
|
|
652
|
-
aliased = [].concat(
|
|
653
|
-
_iterator3 =
|
|
652
|
+
aliased = [].concat(regeneratorValues._toConsumableArray((_aliases$candidates = aliases === null || aliases === void 0 ? void 0 : aliases.candidates(_bare)) !== null && _aliases$candidates !== void 0 ? _aliases$candidates : []), regeneratorValues._toConsumableArray(aliases !== null && aliases !== void 0 && aliases.baseUrlCandidate(_bare) ? [aliases.baseUrlCandidate(_bare)] : []));
|
|
653
|
+
_iterator3 = regeneratorValues._createForOfIteratorHelper(aliased);
|
|
654
654
|
_context2.p = 12;
|
|
655
655
|
_iterator3.s();
|
|
656
656
|
case 13:
|
|
@@ -837,11 +837,11 @@ var SCANNABLE = /\.(tsx?|jsx?|mdx?|html|svelte|vue)$/;
|
|
|
837
837
|
function scanCandidates(files) {
|
|
838
838
|
var found = new Set();
|
|
839
839
|
for (var _i = 0, _Object$entries = Object.entries(files); _i < _Object$entries.length; _i++) {
|
|
840
|
-
var _Object$entries$_i =
|
|
840
|
+
var _Object$entries$_i = regeneratorValues._slicedToArray(_Object$entries[_i], 2),
|
|
841
841
|
path = _Object$entries$_i[0],
|
|
842
842
|
code = _Object$entries$_i[1];
|
|
843
843
|
if (!SCANNABLE.test(path)) continue;
|
|
844
|
-
var _iterator =
|
|
844
|
+
var _iterator = regeneratorValues._createForOfIteratorHelper(code.matchAll(CANDIDATE)),
|
|
845
845
|
_step;
|
|
846
846
|
try {
|
|
847
847
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
@@ -854,7 +854,7 @@ function scanCandidates(files) {
|
|
|
854
854
|
_iterator.f();
|
|
855
855
|
}
|
|
856
856
|
}
|
|
857
|
-
return
|
|
857
|
+
return regeneratorValues._toConsumableArray(found);
|
|
858
858
|
}
|
|
859
859
|
/**
|
|
860
860
|
* Resolves `@import "tailwindcss"` and friends from the inlined stylesheets.
|
|
@@ -875,9 +875,9 @@ function loadStylesheet(_x) {
|
|
|
875
875
|
* the CSS pass worked out is preserved.
|
|
876
876
|
*/
|
|
877
877
|
function _loadStylesheet() {
|
|
878
|
-
_loadStylesheet =
|
|
878
|
+
_loadStylesheet = regeneratorValues._asyncToGenerator(/*#__PURE__*/regeneratorValues._regenerator().m(function _callee(id) {
|
|
879
879
|
var name, content;
|
|
880
|
-
return
|
|
880
|
+
return regeneratorValues._regenerator().w(function (_context) {
|
|
881
881
|
while (1) switch (_context.n) {
|
|
882
882
|
case 0:
|
|
883
883
|
name = id.replace(/^tailwindcss\/?/, "").replace(/\.css$/, "") || "index";
|
|
@@ -902,17 +902,17 @@ function compileTailwind(_x2, _x3, _x4) {
|
|
|
902
902
|
return _compileTailwind.apply(this, arguments);
|
|
903
903
|
}
|
|
904
904
|
function _compileTailwind() {
|
|
905
|
-
_compileTailwind =
|
|
905
|
+
_compileTailwind = regeneratorValues._asyncToGenerator(/*#__PURE__*/regeneratorValues._regenerator().m(function _callee2(css, files, loadModule) {
|
|
906
906
|
var started, warnings, _iterator2, _step2, _step2$value, directive, why, compiler, candidates;
|
|
907
|
-
return
|
|
907
|
+
return regeneratorValues._regenerator().w(function (_context2) {
|
|
908
908
|
while (1) switch (_context2.n) {
|
|
909
909
|
case 0:
|
|
910
910
|
started = performance.now();
|
|
911
911
|
warnings = [];
|
|
912
|
-
_iterator2 =
|
|
912
|
+
_iterator2 = regeneratorValues._createForOfIteratorHelper(UNSUPPORTED);
|
|
913
913
|
try {
|
|
914
914
|
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
915
|
-
_step2$value =
|
|
915
|
+
_step2$value = regeneratorValues._slicedToArray(_step2.value, 2), directive = _step2$value[0], why = _step2$value[1];
|
|
916
916
|
if (new RegExp("^\\s*".concat(directive, "\\b"), "m").test(css)) {
|
|
917
917
|
warnings.push("'".concat(directive, "' is not supported: it ").concat(why, "."));
|
|
918
918
|
}
|
|
@@ -1009,9 +1009,9 @@ function resolveAsset(_x, _x2) {
|
|
|
1009
1009
|
|
|
1010
1010
|
/** Where published assets are served from. Matched by the loader. */
|
|
1011
1011
|
function _resolveAsset() {
|
|
1012
|
-
_resolveAsset =
|
|
1012
|
+
_resolveAsset = regeneratorValues._asyncToGenerator(/*#__PURE__*/regeneratorValues._regenerator().m(function _callee(path, base64) {
|
|
1013
1013
|
var hash, name;
|
|
1014
|
-
return
|
|
1014
|
+
return regeneratorValues._regenerator().w(function (_context) {
|
|
1015
1015
|
while (1) switch (_context.n) {
|
|
1016
1016
|
case 0:
|
|
1017
1017
|
if (!(base64Bytes(base64) <= INLINE_LIMIT)) {
|
|
@@ -1109,9 +1109,9 @@ function transformEnvMarkers(_x, _x2, _x3) {
|
|
|
1109
1109
|
return _transformEnvMarkers.apply(this, arguments);
|
|
1110
1110
|
}
|
|
1111
1111
|
function _transformEnvMarkers() {
|
|
1112
|
-
_transformEnvMarkers =
|
|
1112
|
+
_transformEnvMarkers = regeneratorValues._asyncToGenerator(/*#__PURE__*/regeneratorValues._regenerator().m(function _callee(moduleId, code, target) {
|
|
1113
1113
|
var ast, imported, edits, applied, text;
|
|
1114
|
-
return
|
|
1114
|
+
return regeneratorValues._regenerator().w(function (_context) {
|
|
1115
1115
|
while (1) switch (_context.n) {
|
|
1116
1116
|
case 0:
|
|
1117
1117
|
if (MARKERS.some(function (marker) {
|
|
@@ -1246,6 +1246,490 @@ function _transformEnvMarkers() {
|
|
|
1246
1246
|
return _transformEnvMarkers.apply(this, arguments);
|
|
1247
1247
|
}
|
|
1248
1248
|
|
|
1249
|
+
/** `TANSTACK_DEVTOOLS_PACKAGES` upstream. Exact specifiers, not prefixes. */
|
|
1250
|
+
var TANSTACK_DEVTOOLS_PACKAGES = ["@tanstack/react-devtools", "@tanstack/preact-devtools", "@tanstack/solid-devtools", "@tanstack/vue-devtools", "@tanstack/svelte-devtools", "@tanstack/angular-devtools", "@tanstack/devtools"];
|
|
1251
|
+
var isDevtoolsImport = function isDevtoolsImport(source) {
|
|
1252
|
+
return typeof source === "string" && TANSTACK_DEVTOOLS_PACKAGES.includes(source);
|
|
1253
|
+
};
|
|
1254
|
+
|
|
1255
|
+
/** Through the newline after `node`, so a removed statement leaves no blank line. */
|
|
1256
|
+
var endOfLine = function endOfLine(code, node) {
|
|
1257
|
+
return code[node.end] === "\n" ? node.end + 1 : node.end;
|
|
1258
|
+
};
|
|
1259
|
+
|
|
1260
|
+
/** The element name a `render` value renders: `<X />`, `() => <X />`, `X`, `X()`. */
|
|
1261
|
+
function renderedName(value) {
|
|
1262
|
+
if (!value) return null;
|
|
1263
|
+
var elementName = function elementName(element) {
|
|
1264
|
+
return (element === null || element === void 0 ? void 0 : element.type) === "JSXElement" && element.openingElement.name.type === "JSXIdentifier" ? String(element.openingElement.name.name) : null;
|
|
1265
|
+
};
|
|
1266
|
+
if (value.type === "JSXElement") return elementName(value);
|
|
1267
|
+
if (value.type === "ArrowFunctionExpression" || value.type === "FunctionExpression") return elementName(value.body);
|
|
1268
|
+
if (value.type === "Identifier") return String(value.name);
|
|
1269
|
+
if (value.type === "CallExpression" && value.callee.type === "Identifier") return String(value.callee.name);
|
|
1270
|
+
return null;
|
|
1271
|
+
}
|
|
1272
|
+
|
|
1273
|
+
/** `getPluginReferences` upstream: the panels a devtools element's `plugins` renders. */
|
|
1274
|
+
function pluginReferences(opening) {
|
|
1275
|
+
var refs = [];
|
|
1276
|
+
for (var _i = 0, _arr = opening.attributes; _i < _arr.length; _i++) {
|
|
1277
|
+
var _attr$value, _attr$value2;
|
|
1278
|
+
var attr = _arr[_i];
|
|
1279
|
+
if (attr.type !== "JSXAttribute") continue;
|
|
1280
|
+
if (attr.name.type !== "JSXIdentifier" || attr.name.name !== "plugins") continue;
|
|
1281
|
+
var expression = (_attr$value = attr.value) === null || _attr$value === void 0 ? void 0 : _attr$value.expression;
|
|
1282
|
+
if (((_attr$value2 = attr.value) === null || _attr$value2 === void 0 ? void 0 : _attr$value2.type) !== "JSXExpressionContainer" || (expression === null || expression === void 0 ? void 0 : expression.type) !== "ArrayExpression") continue;
|
|
1283
|
+
for (var _i2 = 0, _arr2 = expression.elements; _i2 < _arr2.length; _i2++) {
|
|
1284
|
+
var element = _arr2[_i2];
|
|
1285
|
+
if ((element === null || element === void 0 ? void 0 : element.type) !== "ObjectExpression") continue;
|
|
1286
|
+
for (var _i3 = 0, _arr3 = element.properties; _i3 < _arr3.length; _i3++) {
|
|
1287
|
+
var prop = _arr3[_i3];
|
|
1288
|
+
if (prop.type !== "Property" || prop.key.type !== "Identifier") continue;
|
|
1289
|
+
if (prop.key.name !== "render") continue;
|
|
1290
|
+
var name = renderedName(prop.value);
|
|
1291
|
+
if (name) refs.push(name);
|
|
1292
|
+
}
|
|
1293
|
+
}
|
|
1294
|
+
}
|
|
1295
|
+
return refs;
|
|
1296
|
+
}
|
|
1297
|
+
|
|
1298
|
+
/** Every name a binding pattern declares: `a`, `{ a, b: c }`, `[a, ...b]`, `a = 1`. */
|
|
1299
|
+
function patternNames(pattern, into) {
|
|
1300
|
+
if (!pattern) return;
|
|
1301
|
+
switch (pattern.type) {
|
|
1302
|
+
case "Identifier":
|
|
1303
|
+
into.add(String(pattern.name));
|
|
1304
|
+
return;
|
|
1305
|
+
case "ObjectPattern":
|
|
1306
|
+
for (var _i4 = 0, _arr4 = pattern.properties; _i4 < _arr4.length; _i4++) {
|
|
1307
|
+
var prop = _arr4[_i4];
|
|
1308
|
+
patternNames(prop.type === "RestElement" ? prop.argument : prop.value, into);
|
|
1309
|
+
}
|
|
1310
|
+
return;
|
|
1311
|
+
case "ArrayPattern":
|
|
1312
|
+
for (var _i5 = 0, _arr5 = pattern.elements; _i5 < _arr5.length; _i5++) {
|
|
1313
|
+
var element = _arr5[_i5];
|
|
1314
|
+
patternNames(element, into);
|
|
1315
|
+
}
|
|
1316
|
+
return;
|
|
1317
|
+
case "AssignmentPattern":
|
|
1318
|
+
patternNames(pattern.left, into);
|
|
1319
|
+
return;
|
|
1320
|
+
case "RestElement":
|
|
1321
|
+
patternNames(pattern.argument, into);
|
|
1322
|
+
return;
|
|
1323
|
+
case "TSParameterProperty":
|
|
1324
|
+
patternNames(pattern.parameter, into);
|
|
1325
|
+
return;
|
|
1326
|
+
}
|
|
1327
|
+
}
|
|
1328
|
+
|
|
1329
|
+
/** The names declared by the statements directly in a block's body. */
|
|
1330
|
+
function blockNames(statements, into) {
|
|
1331
|
+
var _iterator = regeneratorValues._createForOfIteratorHelper(statements),
|
|
1332
|
+
_step;
|
|
1333
|
+
try {
|
|
1334
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
1335
|
+
var statement = _step.value;
|
|
1336
|
+
var declaration = statement.type === "ExportNamedDeclaration" ? statement.declaration : statement;
|
|
1337
|
+
if (!declaration) continue;
|
|
1338
|
+
if (declaration.type === "VariableDeclaration") for (var _i6 = 0, _arr6 = declaration.declarations; _i6 < _arr6.length; _i6++) {
|
|
1339
|
+
var declarator = _arr6[_i6];
|
|
1340
|
+
patternNames(declarator.id, into);
|
|
1341
|
+
} else if ((declaration.type === "FunctionDeclaration" || declaration.type === "ClassDeclaration") && declaration.id) into.add(String(declaration.id.name));
|
|
1342
|
+
}
|
|
1343
|
+
} catch (err) {
|
|
1344
|
+
_iterator.e(err);
|
|
1345
|
+
} finally {
|
|
1346
|
+
_iterator.f();
|
|
1347
|
+
}
|
|
1348
|
+
}
|
|
1349
|
+
|
|
1350
|
+
/**
|
|
1351
|
+
* Whether some scope between `stack`'s root and here declares `name`, so a
|
|
1352
|
+
* read of it here is NOT the import.
|
|
1353
|
+
*
|
|
1354
|
+
* The module scope itself is skipped: a top-level declaration sharing an
|
|
1355
|
+
* import's name is a redeclaration error, not a shadow. What this does not
|
|
1356
|
+
* see is a `var` hoisted out of a nested block into its function -- which
|
|
1357
|
+
* errs toward keeping an element, never toward removing a user's own one.
|
|
1358
|
+
*/
|
|
1359
|
+
function isShadowed(name, stack) {
|
|
1360
|
+
var _scope$init, _scope$left;
|
|
1361
|
+
var _iterator2 = regeneratorValues._createForOfIteratorHelper(stack),
|
|
1362
|
+
_step2;
|
|
1363
|
+
try {
|
|
1364
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
1365
|
+
var scope = _step2.value;
|
|
1366
|
+
var declared = new Set();
|
|
1367
|
+
switch (scope.type) {
|
|
1368
|
+
case "FunctionDeclaration":
|
|
1369
|
+
case "FunctionExpression":
|
|
1370
|
+
case "ArrowFunctionExpression":
|
|
1371
|
+
for (var _i7 = 0, _arr7 = scope.params; _i7 < _arr7.length; _i7++) {
|
|
1372
|
+
var param = _arr7[_i7];
|
|
1373
|
+
patternNames(param, declared);
|
|
1374
|
+
}
|
|
1375
|
+
// A function expression's own name is in scope inside it.
|
|
1376
|
+
if (scope.type === "FunctionExpression" && scope.id) declared.add(String(scope.id.name));
|
|
1377
|
+
break;
|
|
1378
|
+
case "BlockStatement":
|
|
1379
|
+
case "StaticBlock":
|
|
1380
|
+
blockNames(scope.body, declared);
|
|
1381
|
+
break;
|
|
1382
|
+
case "SwitchStatement":
|
|
1383
|
+
for (var _i8 = 0, _arr8 = scope.cases; _i8 < _arr8.length; _i8++) {
|
|
1384
|
+
var branch = _arr8[_i8];
|
|
1385
|
+
blockNames(branch.consequent, declared);
|
|
1386
|
+
}
|
|
1387
|
+
break;
|
|
1388
|
+
case "ForStatement":
|
|
1389
|
+
if (((_scope$init = scope.init) === null || _scope$init === void 0 ? void 0 : _scope$init.type) === "VariableDeclaration") blockNames([scope.init], declared);
|
|
1390
|
+
break;
|
|
1391
|
+
case "ForInStatement":
|
|
1392
|
+
case "ForOfStatement":
|
|
1393
|
+
if (((_scope$left = scope.left) === null || _scope$left === void 0 ? void 0 : _scope$left.type) === "VariableDeclaration") blockNames([scope.left], declared);
|
|
1394
|
+
break;
|
|
1395
|
+
case "CatchClause":
|
|
1396
|
+
patternNames(scope.param, declared);
|
|
1397
|
+
break;
|
|
1398
|
+
case "ClassExpression":
|
|
1399
|
+
if (scope.id) declared.add(String(scope.id.name));
|
|
1400
|
+
break;
|
|
1401
|
+
}
|
|
1402
|
+
if (declared.has(name)) return true;
|
|
1403
|
+
}
|
|
1404
|
+
} catch (err) {
|
|
1405
|
+
_iterator2.e(err);
|
|
1406
|
+
} finally {
|
|
1407
|
+
_iterator2.f();
|
|
1408
|
+
}
|
|
1409
|
+
return false;
|
|
1410
|
+
}
|
|
1411
|
+
|
|
1412
|
+
/**
|
|
1413
|
+
* Whether this element is one of the imported devtools components.
|
|
1414
|
+
*
|
|
1415
|
+
* By binding, not by spelling: a lower-case name is an intrinsic element
|
|
1416
|
+
* whatever is in scope (`import { TanStackDevtools as div }` does not make
|
|
1417
|
+
* `<div>` a devtools), and a name some enclosing scope redeclares is that
|
|
1418
|
+
* scope's, not the import's.
|
|
1419
|
+
*/
|
|
1420
|
+
function isDevtoolsElement(opening, names, stack) {
|
|
1421
|
+
var name = opening.name;
|
|
1422
|
+
var root = name.type === "JSXIdentifier" ? String(name.name) : name.type === "JSXMemberExpression" && name.object.type === "JSXIdentifier" ? String(name.object.name) : null;
|
|
1423
|
+
if (root === null || !names.has(root)) return false;
|
|
1424
|
+
// Only a bare name is subject to the intrinsic rule: `<d.Panel>` is a member
|
|
1425
|
+
// read of `d` whatever its case.
|
|
1426
|
+
if (name.type === "JSXIdentifier" && /^[a-z]/.test(root)) return false;
|
|
1427
|
+
return !isShadowed(root, stack);
|
|
1428
|
+
}
|
|
1429
|
+
|
|
1430
|
+
/**
|
|
1431
|
+
* Edits whose range sits inside another edit's are dropped.
|
|
1432
|
+
*
|
|
1433
|
+
* MagicString, which upstream splices with, tolerates overlapping removals;
|
|
1434
|
+
* `applyEdits` does not, and a devtools element nested inside another one --
|
|
1435
|
+
* or inside a panel being removed -- would otherwise splice twice.
|
|
1436
|
+
*/
|
|
1437
|
+
function outermost(edits) {
|
|
1438
|
+
return edits.filter(function (edit) {
|
|
1439
|
+
return !edits.some(function (other) {
|
|
1440
|
+
return other !== edit && other.start <= edit.start && other.end >= edit.end && (other.start < edit.start || other.end > edit.end);
|
|
1441
|
+
});
|
|
1442
|
+
});
|
|
1443
|
+
}
|
|
1444
|
+
|
|
1445
|
+
/**
|
|
1446
|
+
* Whether `node` -- an identifier named like a binding -- is a READ of it,
|
|
1447
|
+
* rather than a name in some other role: a non-computed property or key, a JSX
|
|
1448
|
+
* attribute name, the right half of `<A.B>`.
|
|
1449
|
+
*/
|
|
1450
|
+
function isReference(node, parent) {
|
|
1451
|
+
if (!parent) return true;
|
|
1452
|
+
switch (parent.type) {
|
|
1453
|
+
case "MemberExpression":
|
|
1454
|
+
return parent.object === node || parent.computed;
|
|
1455
|
+
case "JSXMemberExpression":
|
|
1456
|
+
return parent.object === node;
|
|
1457
|
+
case "Property":
|
|
1458
|
+
case "MethodDefinition":
|
|
1459
|
+
case "PropertyDefinition":
|
|
1460
|
+
// A shorthand `{ X }` has its own value node, which is the read.
|
|
1461
|
+
return parent.key !== node || parent.computed;
|
|
1462
|
+
case "JSXAttribute":
|
|
1463
|
+
return parent.name !== node;
|
|
1464
|
+
case "JSXOpeningElement":
|
|
1465
|
+
case "JSXClosingElement":
|
|
1466
|
+
// `<div>` is an intrinsic element, never a read of a binding named div.
|
|
1467
|
+
return !/^[a-z]/.test(String(node.name));
|
|
1468
|
+
default:
|
|
1469
|
+
return true;
|
|
1470
|
+
}
|
|
1471
|
+
}
|
|
1472
|
+
|
|
1473
|
+
/**
|
|
1474
|
+
* The local names in `names` read anywhere outside `removed`.
|
|
1475
|
+
*
|
|
1476
|
+
* Import declarations are not walked: a specifier is a binding, not a read, and
|
|
1477
|
+
* every one of them is either being removed or being kept anyway.
|
|
1478
|
+
*/
|
|
1479
|
+
function readOutside(ast, names, removed) {
|
|
1480
|
+
var found = new Set();
|
|
1481
|
+
var inRemoved = function inRemoved(node) {
|
|
1482
|
+
return removed.some(function (edit) {
|
|
1483
|
+
return edit.start <= node.start && node.end <= edit.end;
|
|
1484
|
+
});
|
|
1485
|
+
};
|
|
1486
|
+
for (var _i9 = 0, _arr9 = ast.body; _i9 < _arr9.length; _i9++) {
|
|
1487
|
+
var statement = _arr9[_i9];
|
|
1488
|
+
if (statement.type === "ImportDeclaration") continue;
|
|
1489
|
+
walk(statement, function (node, stack) {
|
|
1490
|
+
if (node.type !== "Identifier" && node.type !== "JSXIdentifier") return;
|
|
1491
|
+
var name = String(node.name);
|
|
1492
|
+
if (!names.has(name) || found.has(name)) return;
|
|
1493
|
+
if (!isReference(node, stack[stack.length - 1])) return;
|
|
1494
|
+
// A read of some inner scope's binding of the same name is not a read
|
|
1495
|
+
// of the import, and must not turn its removal into a stub.
|
|
1496
|
+
if (isShadowed(name, stack)) return;
|
|
1497
|
+
if (!inRemoved(node)) found.add(name);
|
|
1498
|
+
});
|
|
1499
|
+
}
|
|
1500
|
+
return found;
|
|
1501
|
+
}
|
|
1502
|
+
|
|
1503
|
+
/**
|
|
1504
|
+
* What a devtools binding becomes when something besides a removed element
|
|
1505
|
+
* still reads it: a component that renders nothing, or a namespace of them.
|
|
1506
|
+
*/
|
|
1507
|
+
function stubFor(specifier) {
|
|
1508
|
+
var local = String(specifier.local.name);
|
|
1509
|
+
return specifier.type === "ImportNamespaceSpecifier" ? "const ".concat(local, " = new Proxy({}, { get: () => () => null });") : "const ".concat(local, " = () => null;");
|
|
1510
|
+
}
|
|
1511
|
+
|
|
1512
|
+
/**
|
|
1513
|
+
* Strips TanStack Devtools from one module.
|
|
1514
|
+
*
|
|
1515
|
+
* Both targets, as upstream does: the plugin applies to the client and the SSR
|
|
1516
|
+
* build alike. Returns `null` when there is nothing to remove, so the caller
|
|
1517
|
+
* leaves the module alone and pays no parse.
|
|
1518
|
+
*/
|
|
1519
|
+
function transformRemoveDevtools(_x, _x2) {
|
|
1520
|
+
return _transformRemoveDevtools.apply(this, arguments);
|
|
1521
|
+
}
|
|
1522
|
+
function _transformRemoveDevtools() {
|
|
1523
|
+
_transformRemoveDevtools = regeneratorValues._asyncToGenerator(/*#__PURE__*/regeneratorValues._regenerator().m(function _callee(moduleId, code) {
|
|
1524
|
+
var ast, devtoolsImports, devtoolsNames, _iterator3, _step3, statement, _i1, _arr1, _statement$specifiers2, specifier, elements, panels, removed, stillRead, edits, _iterator5, _step5, _statement$specifiers3, _statement, stubs, _loop, _ret, _i0, _arr0;
|
|
1525
|
+
return regeneratorValues._regenerator().w(function (_context2) {
|
|
1526
|
+
while (1) switch (_context2.p = _context2.n) {
|
|
1527
|
+
case 0:
|
|
1528
|
+
if (TANSTACK_DEVTOOLS_PACKAGES.some(function (pkg) {
|
|
1529
|
+
return code.includes(pkg);
|
|
1530
|
+
})) {
|
|
1531
|
+
_context2.n = 1;
|
|
1532
|
+
break;
|
|
1533
|
+
}
|
|
1534
|
+
return _context2.a(2, null);
|
|
1535
|
+
case 1:
|
|
1536
|
+
_context2.p = 1;
|
|
1537
|
+
_context2.n = 2;
|
|
1538
|
+
return parse(moduleId, code);
|
|
1539
|
+
case 2:
|
|
1540
|
+
ast = _context2.v;
|
|
1541
|
+
_context2.n = 4;
|
|
1542
|
+
break;
|
|
1543
|
+
case 3:
|
|
1544
|
+
_context2.p = 3;
|
|
1545
|
+
_context2.v;
|
|
1546
|
+
return _context2.a(2, null);
|
|
1547
|
+
case 4:
|
|
1548
|
+
devtoolsImports = ast.body.filter(function (statement) {
|
|
1549
|
+
var _statement$source;
|
|
1550
|
+
return statement.type === "ImportDeclaration" && isDevtoolsImport((_statement$source = statement.source) === null || _statement$source === void 0 ? void 0 : _statement$source.value);
|
|
1551
|
+
});
|
|
1552
|
+
if (!(devtoolsImports.length === 0)) {
|
|
1553
|
+
_context2.n = 5;
|
|
1554
|
+
break;
|
|
1555
|
+
}
|
|
1556
|
+
return _context2.a(2, null);
|
|
1557
|
+
case 5:
|
|
1558
|
+
devtoolsNames = new Set();
|
|
1559
|
+
_iterator3 = regeneratorValues._createForOfIteratorHelper(devtoolsImports);
|
|
1560
|
+
try {
|
|
1561
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
1562
|
+
statement = _step3.value;
|
|
1563
|
+
for (_i1 = 0, _arr1 = (_statement$specifiers2 = statement.specifiers) !== null && _statement$specifiers2 !== void 0 ? _statement$specifiers2 : []; _i1 < _arr1.length; _i1++) {
|
|
1564
|
+
specifier = _arr1[_i1];
|
|
1565
|
+
devtoolsNames.add(String(specifier.local.name));
|
|
1566
|
+
}
|
|
1567
|
+
}
|
|
1568
|
+
|
|
1569
|
+
// The elements first: whether an import can simply go depends on whether
|
|
1570
|
+
// anything outside them still reads its names.
|
|
1571
|
+
} catch (err) {
|
|
1572
|
+
_iterator3.e(err);
|
|
1573
|
+
} finally {
|
|
1574
|
+
_iterator3.f();
|
|
1575
|
+
}
|
|
1576
|
+
elements = [];
|
|
1577
|
+
panels = new Set();
|
|
1578
|
+
if (devtoolsNames.size > 0) {
|
|
1579
|
+
walk(ast, function (node, stack) {
|
|
1580
|
+
if (node.type !== "JSXElement") return;
|
|
1581
|
+
var opening = node.openingElement;
|
|
1582
|
+
if (!isDevtoolsElement(opening, devtoolsNames, stack)) return;
|
|
1583
|
+
var _iterator4 = regeneratorValues._createForOfIteratorHelper(pluginReferences(opening)),
|
|
1584
|
+
_step4;
|
|
1585
|
+
try {
|
|
1586
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
1587
|
+
var panel = _step4.value;
|
|
1588
|
+
panels.add(panel);
|
|
1589
|
+
}
|
|
1590
|
+
} catch (err) {
|
|
1591
|
+
_iterator4.e(err);
|
|
1592
|
+
} finally {
|
|
1593
|
+
_iterator4.f();
|
|
1594
|
+
}
|
|
1595
|
+
var parent = stack[stack.length - 1];
|
|
1596
|
+
// Only a JSX child can simply vanish, and take its line with it.
|
|
1597
|
+
// Anywhere else -- a return, a `&&`, an initialiser -- the element is an
|
|
1598
|
+
// expression and needs a stand-in, which must end where the element
|
|
1599
|
+
// did: the newline after it may be the only thing ending the statement.
|
|
1600
|
+
var inJsx = (parent === null || parent === void 0 ? void 0 : parent.type) === "JSXElement" || (parent === null || parent === void 0 ? void 0 : parent.type) === "JSXFragment";
|
|
1601
|
+
elements.push(inJsx ? {
|
|
1602
|
+
start: node.start,
|
|
1603
|
+
end: endOfLine(code, node),
|
|
1604
|
+
text: ""
|
|
1605
|
+
} : {
|
|
1606
|
+
start: node.start,
|
|
1607
|
+
end: node.end,
|
|
1608
|
+
text: "null"
|
|
1609
|
+
});
|
|
1610
|
+
});
|
|
1611
|
+
}
|
|
1612
|
+
removed = outermost(elements);
|
|
1613
|
+
stillRead = readOutside(ast, new Set([].concat(regeneratorValues._toConsumableArray(devtoolsNames), regeneratorValues._toConsumableArray(panels))), removed);
|
|
1614
|
+
edits = regeneratorValues._toConsumableArray(removed);
|
|
1615
|
+
_iterator5 = regeneratorValues._createForOfIteratorHelper(devtoolsImports);
|
|
1616
|
+
try {
|
|
1617
|
+
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
1618
|
+
_statement = _step5.value;
|
|
1619
|
+
stubs = ((_statement$specifiers3 = _statement.specifiers) !== null && _statement$specifiers3 !== void 0 ? _statement$specifiers3 : []).filter(function (specifier) {
|
|
1620
|
+
return stillRead.has(String(specifier.local.name));
|
|
1621
|
+
}).map(stubFor);
|
|
1622
|
+
edits.push(stubs.length > 0 ? {
|
|
1623
|
+
start: _statement.start,
|
|
1624
|
+
end: _statement.end,
|
|
1625
|
+
text: stubs.join(" ")
|
|
1626
|
+
} : {
|
|
1627
|
+
start: _statement.start,
|
|
1628
|
+
end: endOfLine(code, _statement),
|
|
1629
|
+
text: ""
|
|
1630
|
+
});
|
|
1631
|
+
}
|
|
1632
|
+
} catch (err) {
|
|
1633
|
+
_iterator5.e(err);
|
|
1634
|
+
} finally {
|
|
1635
|
+
_iterator5.f();
|
|
1636
|
+
}
|
|
1637
|
+
if (!(panels.size > 0)) {
|
|
1638
|
+
_context2.n = 9;
|
|
1639
|
+
break;
|
|
1640
|
+
}
|
|
1641
|
+
_loop = /*#__PURE__*/regeneratorValues._regenerator().m(function _loop() {
|
|
1642
|
+
var _statement$source2, _statement$specifiers;
|
|
1643
|
+
var statement, specifiers, dropped, remaining, text, defaults, named, clause;
|
|
1644
|
+
return regeneratorValues._regenerator().w(function (_context) {
|
|
1645
|
+
while (1) switch (_context.n) {
|
|
1646
|
+
case 0:
|
|
1647
|
+
statement = _arr0[_i0];
|
|
1648
|
+
if (!(statement.type !== "ImportDeclaration")) {
|
|
1649
|
+
_context.n = 1;
|
|
1650
|
+
break;
|
|
1651
|
+
}
|
|
1652
|
+
return _context.a(2, 0);
|
|
1653
|
+
case 1:
|
|
1654
|
+
if (!isDevtoolsImport((_statement$source2 = statement.source) === null || _statement$source2 === void 0 ? void 0 : _statement$source2.value)) {
|
|
1655
|
+
_context.n = 2;
|
|
1656
|
+
break;
|
|
1657
|
+
}
|
|
1658
|
+
return _context.a(2, 0);
|
|
1659
|
+
case 2:
|
|
1660
|
+
specifiers = (_statement$specifiers = statement.specifiers) !== null && _statement$specifiers !== void 0 ? _statement$specifiers : [];
|
|
1661
|
+
dropped = specifiers.filter(function (specifier) {
|
|
1662
|
+
var local = String(specifier.local.name);
|
|
1663
|
+
return specifier.type !== "ImportNamespaceSpecifier" && panels.has(local) && !stillRead.has(local);
|
|
1664
|
+
});
|
|
1665
|
+
if (!(dropped.length === 0)) {
|
|
1666
|
+
_context.n = 3;
|
|
1667
|
+
break;
|
|
1668
|
+
}
|
|
1669
|
+
return _context.a(2, 0);
|
|
1670
|
+
case 3:
|
|
1671
|
+
remaining = specifiers.filter(function (s) {
|
|
1672
|
+
return !dropped.includes(s);
|
|
1673
|
+
});
|
|
1674
|
+
if (!(remaining.length === 0)) {
|
|
1675
|
+
_context.n = 4;
|
|
1676
|
+
break;
|
|
1677
|
+
}
|
|
1678
|
+
edits.push({
|
|
1679
|
+
start: statement.start,
|
|
1680
|
+
end: endOfLine(code, statement),
|
|
1681
|
+
text: ""
|
|
1682
|
+
});
|
|
1683
|
+
return _context.a(2, 0);
|
|
1684
|
+
case 4:
|
|
1685
|
+
text = function text(node) {
|
|
1686
|
+
return code.slice(node.start, node.end);
|
|
1687
|
+
};
|
|
1688
|
+
defaults = remaining.filter(function (s) {
|
|
1689
|
+
return s.type !== "ImportSpecifier";
|
|
1690
|
+
}).map(text);
|
|
1691
|
+
named = remaining.filter(function (s) {
|
|
1692
|
+
return s.type === "ImportSpecifier";
|
|
1693
|
+
}).map(text);
|
|
1694
|
+
clause = [].concat(regeneratorValues._toConsumableArray(defaults), regeneratorValues._toConsumableArray(named.length > 0 ? ["{ ".concat(named.join(", "), " }")] : [])).join(", ");
|
|
1695
|
+
edits.push({
|
|
1696
|
+
start: statement.start,
|
|
1697
|
+
end: statement.end,
|
|
1698
|
+
text: "import ".concat(clause, " from ").concat(text(statement.source), ";")
|
|
1699
|
+
});
|
|
1700
|
+
case 5:
|
|
1701
|
+
return _context.a(2);
|
|
1702
|
+
}
|
|
1703
|
+
}, _loop);
|
|
1704
|
+
});
|
|
1705
|
+
_i0 = 0, _arr0 = ast.body;
|
|
1706
|
+
case 6:
|
|
1707
|
+
if (!(_i0 < _arr0.length)) {
|
|
1708
|
+
_context2.n = 9;
|
|
1709
|
+
break;
|
|
1710
|
+
}
|
|
1711
|
+
return _context2.d(regeneratorValues._regeneratorValues(_loop()), 7);
|
|
1712
|
+
case 7:
|
|
1713
|
+
_ret = _context2.v;
|
|
1714
|
+
if (!(_ret === 0)) {
|
|
1715
|
+
_context2.n = 8;
|
|
1716
|
+
break;
|
|
1717
|
+
}
|
|
1718
|
+
return _context2.a(3, 8);
|
|
1719
|
+
case 8:
|
|
1720
|
+
_i0++;
|
|
1721
|
+
_context2.n = 6;
|
|
1722
|
+
break;
|
|
1723
|
+
case 9:
|
|
1724
|
+
return _context2.a(2, {
|
|
1725
|
+
code: applyEdits(code, edits)
|
|
1726
|
+
});
|
|
1727
|
+
}
|
|
1728
|
+
}, _callee, null, [[1, 3]]);
|
|
1729
|
+
}));
|
|
1730
|
+
return _transformRemoveDevtools.apply(this, arguments);
|
|
1731
|
+
}
|
|
1732
|
+
|
|
1249
1733
|
/**
|
|
1250
1734
|
* The names Start deletes from the client build.
|
|
1251
1735
|
*
|
|
@@ -1266,9 +1750,9 @@ var ROUTE_FNS = new Set(["createFileRoute", "createRootRoute", "createRootRouteW
|
|
|
1266
1750
|
|
|
1267
1751
|
/** Cheap pre-filter, so a module with no route call is never parsed. */
|
|
1268
1752
|
var shouldRun = function shouldRun(code) {
|
|
1269
|
-
return
|
|
1753
|
+
return regeneratorValues._toConsumableArray(ROUTE_FNS).some(function (name) {
|
|
1270
1754
|
return code.includes(name);
|
|
1271
|
-
}) &&
|
|
1755
|
+
}) && regeneratorValues._toConsumableArray(SERVER_ONLY_OPTIONS).some(function (name) {
|
|
1272
1756
|
return code.includes(name);
|
|
1273
1757
|
});
|
|
1274
1758
|
};
|
|
@@ -1366,9 +1850,9 @@ function transformRouteNodes(_x, _x2, _x3) {
|
|
|
1366
1850
|
return _transformRouteNodes.apply(this, arguments);
|
|
1367
1851
|
}
|
|
1368
1852
|
function _transformRouteNodes() {
|
|
1369
|
-
_transformRouteNodes =
|
|
1853
|
+
_transformRouteNodes = regeneratorValues._asyncToGenerator(/*#__PURE__*/regeneratorValues._regenerator().m(function _callee(moduleId, code, target) {
|
|
1370
1854
|
var ast, imported, edits, removed;
|
|
1371
|
-
return
|
|
1855
|
+
return regeneratorValues._regenerator().w(function (_context) {
|
|
1372
1856
|
while (1) switch (_context.n) {
|
|
1373
1857
|
case 0:
|
|
1374
1858
|
if (!(target !== "client")) {
|
|
@@ -1407,7 +1891,7 @@ function _transformRouteNodes() {
|
|
|
1407
1891
|
if (!options) return;
|
|
1408
1892
|
var properties = (_options$properties = options.properties) !== null && _options$properties !== void 0 ? _options$properties : [];
|
|
1409
1893
|
var doomed = new Set();
|
|
1410
|
-
var _iterator =
|
|
1894
|
+
var _iterator = regeneratorValues._createForOfIteratorHelper(properties),
|
|
1411
1895
|
_step;
|
|
1412
1896
|
try {
|
|
1413
1897
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
@@ -1422,7 +1906,7 @@ function _transformRouteNodes() {
|
|
|
1422
1906
|
} finally {
|
|
1423
1907
|
_iterator.f();
|
|
1424
1908
|
}
|
|
1425
|
-
if (doomed.size) edits.push.apply(edits,
|
|
1909
|
+
if (doomed.size) edits.push.apply(edits, regeneratorValues._toConsumableArray(deleteProperties(code, properties, doomed)));
|
|
1426
1910
|
});
|
|
1427
1911
|
if (!(edits.length === 0)) {
|
|
1428
1912
|
_context.n = 5;
|
|
@@ -1509,7 +1993,7 @@ function aliasMap(files, warn) {
|
|
|
1509
1993
|
var base = resolve(dirname(entry), baseUrl !== null && baseUrl !== void 0 ? baseUrl : ".");
|
|
1510
1994
|
var patterns = [];
|
|
1511
1995
|
for (var _i = 0, _Object$entries = Object.entries(paths !== null && paths !== void 0 ? paths : {}); _i < _Object$entries.length; _i++) {
|
|
1512
|
-
var _Object$entries$_i =
|
|
1996
|
+
var _Object$entries$_i = regeneratorValues._slicedToArray(_Object$entries[_i], 2),
|
|
1513
1997
|
pattern = _Object$entries$_i[0],
|
|
1514
1998
|
targets = _Object$entries$_i[1];
|
|
1515
1999
|
var star = pattern.indexOf("*");
|
|
@@ -1542,7 +2026,7 @@ function aliasMap(files, warn) {
|
|
|
1542
2026
|
var pattern = _patterns[_i2];
|
|
1543
2027
|
if (!pattern.wildcard) {
|
|
1544
2028
|
if (specifier === pattern.prefix) return {
|
|
1545
|
-
v:
|
|
2029
|
+
v: regeneratorValues._toConsumableArray(pattern.targets)
|
|
1546
2030
|
};
|
|
1547
2031
|
return 0; // continue
|
|
1548
2032
|
}
|
|
@@ -1603,7 +2087,7 @@ function readConfig(files, path, warn, seen) {
|
|
|
1603
2087
|
// The child wins, and `paths` replaces rather than merges -- which is what
|
|
1604
2088
|
// TypeScript does.
|
|
1605
2089
|
return {
|
|
1606
|
-
compilerOptions:
|
|
2090
|
+
compilerOptions: regeneratorValues._objectSpread2(regeneratorValues._objectSpread2(regeneratorValues._objectSpread2({}, parent.compilerOptions), config.compilerOptions), {}, {
|
|
1607
2091
|
// baseUrl in the parent was relative to the *parent*, and readConfig
|
|
1608
2092
|
// returns it unresolved, so a parent baseUrl with a child that sets none
|
|
1609
2093
|
// is the one case this gets wrong. Rare enough to name rather than model.
|
|
@@ -1658,7 +2142,7 @@ var isRouteFile = function isRouteFile(path) {
|
|
|
1658
2142
|
*/
|
|
1659
2143
|
function parseSplitRequest(source) {
|
|
1660
2144
|
var _source$split = source.split("?"),
|
|
1661
|
-
_source$split2 =
|
|
2145
|
+
_source$split2 = regeneratorValues._slicedToArray(_source$split, 2),
|
|
1662
2146
|
path = _source$split2[0],
|
|
1663
2147
|
query = _source$split2[1];
|
|
1664
2148
|
if (!path || !query) return null;
|
|
@@ -1713,7 +2197,7 @@ function exportsOf(ast) {
|
|
|
1713
2197
|
names.push(String(declaration.id.name));
|
|
1714
2198
|
}
|
|
1715
2199
|
}
|
|
1716
|
-
return
|
|
2200
|
+
return regeneratorValues._toConsumableArray(new Set(names));
|
|
1717
2201
|
}
|
|
1718
2202
|
|
|
1719
2203
|
/**
|
|
@@ -1738,16 +2222,16 @@ function collectClientModules(_x) {
|
|
|
1738
2222
|
* rather than as a confusing render.
|
|
1739
2223
|
*/
|
|
1740
2224
|
function _collectClientModules() {
|
|
1741
|
-
_collectClientModules =
|
|
2225
|
+
_collectClientModules = regeneratorValues._asyncToGenerator(/*#__PURE__*/regeneratorValues._regenerator().m(function _callee(files) {
|
|
1742
2226
|
var paths, modules, _iterator2, _step2, _step2$value, index, path, ast, exported, _t;
|
|
1743
|
-
return
|
|
2227
|
+
return regeneratorValues._regenerator().w(function (_context) {
|
|
1744
2228
|
while (1) switch (_context.p = _context.n) {
|
|
1745
2229
|
case 0:
|
|
1746
2230
|
paths = Object.keys(files).filter(function (path) {
|
|
1747
2231
|
return /\.(tsx?|jsx?)$/.test(path) && hasUseClient(files[path]);
|
|
1748
2232
|
}).sort();
|
|
1749
2233
|
modules = [];
|
|
1750
|
-
_iterator2 =
|
|
2234
|
+
_iterator2 = regeneratorValues._createForOfIteratorHelper(paths.entries());
|
|
1751
2235
|
_context.p = 1;
|
|
1752
2236
|
_iterator2.s();
|
|
1753
2237
|
case 2:
|
|
@@ -1755,7 +2239,7 @@ function _collectClientModules() {
|
|
|
1755
2239
|
_context.n = 6;
|
|
1756
2240
|
break;
|
|
1757
2241
|
}
|
|
1758
|
-
_step2$value =
|
|
2242
|
+
_step2$value = regeneratorValues._slicedToArray(_step2.value, 2), index = _step2$value[0], path = _step2$value[1];
|
|
1759
2243
|
_context.n = 3;
|
|
1760
2244
|
return parse(path, files[path]);
|
|
1761
2245
|
case 3:
|
|
@@ -1804,7 +2288,7 @@ function clientReferenceStub(module,
|
|
|
1804
2288
|
*/
|
|
1805
2289
|
flightServer) {
|
|
1806
2290
|
var lines = ["import { registerClientReference as __ref } from ".concat(JSON.stringify(flightServer))];
|
|
1807
|
-
var _iterator =
|
|
2291
|
+
var _iterator = regeneratorValues._createForOfIteratorHelper(module.exports),
|
|
1808
2292
|
_step;
|
|
1809
2293
|
try {
|
|
1810
2294
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
@@ -1866,7 +2350,7 @@ function clientModuleRegistry(modules) {
|
|
|
1866
2350
|
*/
|
|
1867
2351
|
|
|
1868
2352
|
var headersFor = function headersFor(request) {
|
|
1869
|
-
return
|
|
2353
|
+
return regeneratorValues._objectSpread2({
|
|
1870
2354
|
"x-platform-project": request.project
|
|
1871
2355
|
}, request.token ? {
|
|
1872
2356
|
authorization: "Bearer ".concat(request.token)
|
|
@@ -1889,9 +2373,9 @@ function fetchBuildTarget(_x) {
|
|
|
1889
2373
|
* establish a string comparison.
|
|
1890
2374
|
*/
|
|
1891
2375
|
function _fetchBuildTarget() {
|
|
1892
|
-
_fetchBuildTarget =
|
|
2376
|
+
_fetchBuildTarget = regeneratorValues._asyncToGenerator(/*#__PURE__*/regeneratorValues._regenerator().m(function _callee(request) {
|
|
1893
2377
|
var res, _t, _t2, _t3, _t4, _t5;
|
|
1894
|
-
return
|
|
2378
|
+
return regeneratorValues._regenerator().w(function (_context) {
|
|
1895
2379
|
while (1) switch (_context.n) {
|
|
1896
2380
|
case 0:
|
|
1897
2381
|
_context.n = 1;
|
|
@@ -1927,9 +2411,9 @@ function fetchBuildTargetRev(_x2) {
|
|
|
1927
2411
|
return _fetchBuildTargetRev.apply(this, arguments);
|
|
1928
2412
|
}
|
|
1929
2413
|
function _fetchBuildTargetRev() {
|
|
1930
|
-
_fetchBuildTargetRev =
|
|
2414
|
+
_fetchBuildTargetRev = regeneratorValues._asyncToGenerator(/*#__PURE__*/regeneratorValues._regenerator().m(function _callee2(request) {
|
|
1931
2415
|
var res;
|
|
1932
|
-
return
|
|
2416
|
+
return regeneratorValues._regenerator().w(function (_context2) {
|
|
1933
2417
|
while (1) switch (_context2.n) {
|
|
1934
2418
|
case 0:
|
|
1935
2419
|
_context2.n = 1;
|
|
@@ -2279,7 +2763,7 @@ function projectPlugin(files, projectSource, splitter, cssModules, aliases, asse
|
|
|
2279
2763
|
// rather than relying on a bundler to inject a link -- which is what
|
|
2280
2764
|
// the stock __root.tsx does.
|
|
2281
2765
|
var _source$split = source.split("?"),
|
|
2282
|
-
_source$split2 =
|
|
2766
|
+
_source$split2 = regeneratorValues._slicedToArray(_source$split, 2),
|
|
2283
2767
|
bare = _source$split2[0],
|
|
2284
2768
|
query = _source$split2[1];
|
|
2285
2769
|
if (source.startsWith(".")) {
|
|
@@ -2296,7 +2780,7 @@ function projectPlugin(files, projectSource, splitter, cssModules, aliases, asse
|
|
|
2296
2780
|
// A pattern that tries is reported rather than silently dropped.
|
|
2297
2781
|
if (aliases) {
|
|
2298
2782
|
var candidates = aliases.candidates(bare);
|
|
2299
|
-
var _iterator =
|
|
2783
|
+
var _iterator = regeneratorValues._createForOfIteratorHelper(candidates),
|
|
2300
2784
|
_step;
|
|
2301
2785
|
try {
|
|
2302
2786
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
@@ -2333,7 +2817,7 @@ function projectPlugin(files, projectSource, splitter, cssModules, aliases, asse
|
|
|
2333
2817
|
// A bare specifier outside the vendor set. Failing here rather than at
|
|
2334
2818
|
// runtime is the point: the user gets a build error naming the package
|
|
2335
2819
|
// instead of a blank page from a missing module in the isolate.
|
|
2336
|
-
var available = [].concat(
|
|
2820
|
+
var available = [].concat(regeneratorValues._toConsumableArray(isRsc ? [vendor.paths.rscRuntimeSpecifier].concat(regeneratorValues._toConsumableArray(vendor.rscSpecifiers), regeneratorValues._toConsumableArray(vendor.specifiers)) : vendor.specifiers), regeneratorValues._toConsumableArray(Object.keys((_projectVendor$module = projectVendor === null || projectVendor === void 0 ? void 0 : projectVendor.modules) !== null && _projectVendor$module !== void 0 ? _projectVendor$module : {})));
|
|
2337
2821
|
warnings.push("'".concat(source, "' is not an available dependency. Available: ").concat(available.join(", "), "."));
|
|
2338
2822
|
return null;
|
|
2339
2823
|
},
|
|
@@ -2378,9 +2862,9 @@ function projectPlugin(files, projectSource, splitter, cssModules, aliases, asse
|
|
|
2378
2862
|
* parsed.
|
|
2379
2863
|
*/
|
|
2380
2864
|
transform: function transform(code, id) {
|
|
2381
|
-
return
|
|
2382
|
-
var half, _envMarkers, out, reference, serverFns, envMarkers, routeNodes;
|
|
2383
|
-
return
|
|
2865
|
+
return regeneratorValues._asyncToGenerator(/*#__PURE__*/regeneratorValues._regenerator().m(function _callee() {
|
|
2866
|
+
var half, _out, _devtools, _envMarkers, out, devtools, reference, serverFns, envMarkers, routeNodes;
|
|
2867
|
+
return regeneratorValues._regenerator().w(function (_context) {
|
|
2384
2868
|
while (1) switch (_context.n) {
|
|
2385
2869
|
case 0:
|
|
2386
2870
|
/*
|
|
@@ -2404,48 +2888,66 @@ function projectPlugin(files, projectSource, splitter, cssModules, aliases, asse
|
|
|
2404
2888
|
*/
|
|
2405
2889
|
half = splitIdOf(id);
|
|
2406
2890
|
if (!half) {
|
|
2407
|
-
_context.n =
|
|
2891
|
+
_context.n = 3;
|
|
2408
2892
|
break;
|
|
2409
2893
|
}
|
|
2894
|
+
// Devtools too, for the same reason: `<TanStackDevtools>` sits in a
|
|
2895
|
+
// layout's component, which is what moves into this half.
|
|
2896
|
+
_out = code;
|
|
2410
2897
|
_context.n = 1;
|
|
2411
|
-
return
|
|
2898
|
+
return transformRemoveDevtools(half.path, _out);
|
|
2412
2899
|
case 1:
|
|
2900
|
+
_devtools = _context.v;
|
|
2901
|
+
if (_devtools) _out = _devtools.code;
|
|
2902
|
+
_context.n = 2;
|
|
2903
|
+
return transformEnvMarkers(half.path, _out, target);
|
|
2904
|
+
case 2:
|
|
2413
2905
|
_envMarkers = _context.v;
|
|
2414
|
-
|
|
2415
|
-
|
|
2906
|
+
if (_envMarkers) _out = _envMarkers.code;
|
|
2907
|
+
return _context.a(2, _out === code ? null : {
|
|
2908
|
+
code: _out,
|
|
2416
2909
|
map: null
|
|
2417
|
-
}
|
|
2418
|
-
case
|
|
2910
|
+
});
|
|
2911
|
+
case 3:
|
|
2419
2912
|
if (!(!(id in files) || isCss(id))) {
|
|
2420
|
-
_context.n =
|
|
2913
|
+
_context.n = 4;
|
|
2421
2914
|
break;
|
|
2422
2915
|
}
|
|
2423
2916
|
return _context.a(2, null);
|
|
2424
|
-
case
|
|
2917
|
+
case 4:
|
|
2425
2918
|
// Two passes rather than one shared parse: each bails out on a substring
|
|
2426
2919
|
// check before parsing, so a module that uses neither -- which is most of
|
|
2427
2920
|
// them -- is never parsed at all.
|
|
2428
|
-
out = code; //
|
|
2429
|
-
//
|
|
2921
|
+
out = code; // Before the split, as `@tanstack/devtools-vite` runs (`enforce: "pre"`):
|
|
2922
|
+
// the reference half then carries no devtools import. The deferred half
|
|
2923
|
+
// is built from the original source, so it runs again above.
|
|
2924
|
+
_context.n = 5;
|
|
2925
|
+
return transformRemoveDevtools(id, out);
|
|
2926
|
+
case 5:
|
|
2927
|
+
devtools = _context.v;
|
|
2928
|
+
if (devtools) out = devtools.code;
|
|
2929
|
+
// Then the split, because it decides what stays in this module at all:
|
|
2930
|
+
// the other passes should see the reference half, not code about to move
|
|
2931
|
+
// out of it.
|
|
2430
2932
|
if (splitter && isRouteFile(id)) {
|
|
2431
2933
|
reference = splitter.reference(id, out);
|
|
2432
2934
|
if (reference) out = reference.code;
|
|
2433
2935
|
}
|
|
2434
|
-
_context.n =
|
|
2936
|
+
_context.n = 6;
|
|
2435
2937
|
return transformServerFns(id, out, target, seenIds);
|
|
2436
|
-
case
|
|
2938
|
+
case 6:
|
|
2437
2939
|
serverFns = _context.v;
|
|
2438
2940
|
if (serverFns) out = serverFns.code;
|
|
2439
|
-
_context.n =
|
|
2941
|
+
_context.n = 7;
|
|
2440
2942
|
return transformEnvMarkers(id, out, target);
|
|
2441
|
-
case
|
|
2943
|
+
case 7:
|
|
2442
2944
|
envMarkers = _context.v;
|
|
2443
2945
|
if (envMarkers) out = envMarkers.code;
|
|
2444
2946
|
// Client only, and last: it deletes whole route options, so running it
|
|
2445
2947
|
// before the others would leave them rewriting code about to be removed.
|
|
2446
|
-
_context.n =
|
|
2948
|
+
_context.n = 8;
|
|
2447
2949
|
return transformRouteNodes(id, out, target);
|
|
2448
|
-
case
|
|
2950
|
+
case 8:
|
|
2449
2951
|
routeNodes = _context.v;
|
|
2450
2952
|
if (routeNodes) out = routeNodes.code;
|
|
2451
2953
|
return _context.a(2, out === code ? null : {
|
|
@@ -2474,7 +2976,7 @@ function defineFor(env, target, warnings) {
|
|
|
2474
2976
|
var define = {};
|
|
2475
2977
|
var visible = {};
|
|
2476
2978
|
for (var _i = 0, _Object$entries = Object.entries(env); _i < _Object$entries.length; _i++) {
|
|
2477
|
-
var _Object$entries$_i =
|
|
2979
|
+
var _Object$entries$_i = regeneratorValues._slicedToArray(_Object$entries[_i], 2),
|
|
2478
2980
|
key = _Object$entries$_i[0],
|
|
2479
2981
|
value = _Object$entries$_i[1];
|
|
2480
2982
|
if (!VALID_KEY.test(key)) {
|
|
@@ -2488,17 +2990,41 @@ function defineFor(env, target, warnings) {
|
|
|
2488
2990
|
if (exposed) visible[key] = value;
|
|
2489
2991
|
}
|
|
2490
2992
|
|
|
2993
|
+
// Vite's built-ins, and they win over a project env var of the same name as
|
|
2994
|
+
// they do in Vite. Every build here is a production build -- it is what gets
|
|
2995
|
+
// published -- so these say what `vite build` would. Without them
|
|
2996
|
+
// `import.meta.env.PROD` read `undefined`, and `!import.meta.env.PROD &&
|
|
2997
|
+
// <Debug />` rendered on a published site while `vite build` dropped it.
|
|
2998
|
+
var builtins = {
|
|
2999
|
+
MODE: "production",
|
|
3000
|
+
DEV: false,
|
|
3001
|
+
PROD: true,
|
|
3002
|
+
SSR: target === "server",
|
|
3003
|
+
BASE_URL: "/"
|
|
3004
|
+
};
|
|
3005
|
+
for (var _i2 = 0, _Object$entries2 = Object.entries(builtins); _i2 < _Object$entries2.length; _i2++) {
|
|
3006
|
+
var _Object$entries2$_i = regeneratorValues._slicedToArray(_Object$entries2[_i2], 2),
|
|
3007
|
+
_key = _Object$entries2$_i[0],
|
|
3008
|
+
_value = _Object$entries2$_i[1];
|
|
3009
|
+
define["import.meta.env.".concat(_key)] = JSON.stringify(_value);
|
|
3010
|
+
}
|
|
3011
|
+
// What Vite substitutes, and what the vendor layer already bakes into every
|
|
3012
|
+
// dependency (vendorLayer.ts). The project's own source was the one place
|
|
3013
|
+
// nobody set it, and rolldown's own default filled the gap with
|
|
3014
|
+
// "development" -- so a published site's code was told it was in dev.
|
|
3015
|
+
define["process.env.NODE_ENV"] = JSON.stringify("production");
|
|
3016
|
+
|
|
2491
3017
|
// Always defined, even when empty: it makes `import.meta.env` destructuring
|
|
2492
3018
|
// work and stops a bare reference from throwing. Specific keys above take
|
|
2493
3019
|
// precedence over this object.
|
|
2494
|
-
define["import.meta.env"] = JSON.stringify(visible);
|
|
3020
|
+
define["import.meta.env"] = JSON.stringify(regeneratorValues._objectSpread2(regeneratorValues._objectSpread2({}, visible), builtins));
|
|
2495
3021
|
return define;
|
|
2496
3022
|
}
|
|
2497
3023
|
function buildOnce(_x, _x2, _x3, _x4, _x5) {
|
|
2498
3024
|
return _buildOnce.apply(this, arguments);
|
|
2499
3025
|
}
|
|
2500
3026
|
function _buildOnce() {
|
|
2501
|
-
_buildOnce =
|
|
3027
|
+
_buildOnce = regeneratorValues._asyncToGenerator(/*#__PURE__*/regeneratorValues._regenerator().m(function _callee2(input, vendorBase, projectVendorBase, target, warnings) {
|
|
2502
3028
|
var _input$projectSource, _input$assets, _input$env;
|
|
2503
3029
|
var clientModules,
|
|
2504
3030
|
isRsc,
|
|
@@ -2515,7 +3041,7 @@ function _buildOnce() {
|
|
|
2515
3041
|
_step2,
|
|
2516
3042
|
chunk,
|
|
2517
3043
|
_args2 = arguments;
|
|
2518
|
-
return
|
|
3044
|
+
return regeneratorValues._regenerator().w(function (_context2) {
|
|
2519
3045
|
while (1) switch (_context2.n) {
|
|
2520
3046
|
case 0:
|
|
2521
3047
|
clientModules = _args2.length > 5 && _args2[5] !== undefined ? _args2[5] : [];
|
|
@@ -2602,7 +3128,7 @@ function _buildOnce() {
|
|
|
2602
3128
|
// what both sides need and why neither gets a base path here: relative to
|
|
2603
3129
|
// `app.js` in the module map, relative to `/_app/app.js` as a URL.
|
|
2604
3130
|
split = {};
|
|
2605
|
-
_iterator2 =
|
|
3131
|
+
_iterator2 = regeneratorValues._createForOfIteratorHelper(chunks);
|
|
2606
3132
|
try {
|
|
2607
3133
|
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
2608
3134
|
chunk = _step2.value;
|
|
@@ -2636,10 +3162,10 @@ function buildUserApp(_x6) {
|
|
|
2636
3162
|
* every publisher had to be found and edited.
|
|
2637
3163
|
*/
|
|
2638
3164
|
function _buildUserApp() {
|
|
2639
|
-
_buildUserApp =
|
|
3165
|
+
_buildUserApp = regeneratorValues._asyncToGenerator(/*#__PURE__*/regeneratorValues._regenerator().m(function _callee3(input) {
|
|
2640
3166
|
var _input$target$project;
|
|
2641
|
-
var warnings, started, rev, clientModules, assetUrls, assetFiles,
|
|
2642
|
-
return
|
|
3167
|
+
var warnings, started, rev, clientModules, assetUrls, assetFiles, _i3, _Object$entries3, _input$assets2, _Object$entries3$_i, path, base64, resolved, aliases, css, styles, tailwindMs, compiled, serverStarted, serverBuild, server, clientStarted, clientBuild, client, rscBuild, publicFiles, _i4, _Object$entries4, _input$publicFiles, _Object$entries4$_i, _path, _base, _t, _t2, _t3, _t4, _t5, _t6, _t7, _t8, _t9, _t0, _t1, _t10, _t11, _t12, _t13, _t14, _t15;
|
|
3168
|
+
return regeneratorValues._regenerator().w(function (_context3) {
|
|
2643
3169
|
while (1) switch (_context3.n) {
|
|
2644
3170
|
case 0:
|
|
2645
3171
|
warnings = [];
|
|
@@ -2671,13 +3197,13 @@ function _buildUserApp() {
|
|
|
2671
3197
|
// disagreed with the client one would be a hydration mismatch on every image.
|
|
2672
3198
|
assetUrls = new Map();
|
|
2673
3199
|
assetFiles = {};
|
|
2674
|
-
|
|
3200
|
+
_i3 = 0, _Object$entries3 = Object.entries((_input$assets2 = input.assets) !== null && _input$assets2 !== void 0 ? _input$assets2 : {});
|
|
2675
3201
|
case 4:
|
|
2676
|
-
if (!(
|
|
3202
|
+
if (!(_i3 < _Object$entries3.length)) {
|
|
2677
3203
|
_context3.n = 7;
|
|
2678
3204
|
break;
|
|
2679
3205
|
}
|
|
2680
|
-
_Object$
|
|
3206
|
+
_Object$entries3$_i = regeneratorValues._slicedToArray(_Object$entries3[_i3], 2), path = _Object$entries3$_i[0], base64 = _Object$entries3$_i[1];
|
|
2681
3207
|
_context3.n = 5;
|
|
2682
3208
|
return resolveAsset(path, base64);
|
|
2683
3209
|
case 5:
|
|
@@ -2685,7 +3211,7 @@ function _buildUserApp() {
|
|
|
2685
3211
|
assetUrls.set(path, resolved.url);
|
|
2686
3212
|
if (resolved.file) assetFiles[resolved.file.name] = resolved.file.base64;
|
|
2687
3213
|
case 6:
|
|
2688
|
-
|
|
3214
|
+
_i3++;
|
|
2689
3215
|
_context3.n = 4;
|
|
2690
3216
|
break;
|
|
2691
3217
|
case 7:
|
|
@@ -2712,7 +3238,7 @@ function _buildUserApp() {
|
|
|
2712
3238
|
// does not ask for it, which keeps the cost off every other build.
|
|
2713
3239
|
styles = css.code;
|
|
2714
3240
|
tailwindMs = 0;
|
|
2715
|
-
warnings.push.apply(warnings,
|
|
3241
|
+
warnings.push.apply(warnings, regeneratorValues._toConsumableArray(css.warnings));
|
|
2716
3242
|
if (!usesTailwind(styles)) {
|
|
2717
3243
|
_context3.n = 10;
|
|
2718
3244
|
break;
|
|
@@ -2723,7 +3249,7 @@ function _buildUserApp() {
|
|
|
2723
3249
|
compiled = _context3.v;
|
|
2724
3250
|
styles = compiled.css;
|
|
2725
3251
|
tailwindMs = compiled.ms;
|
|
2726
|
-
warnings.push.apply(warnings,
|
|
3252
|
+
warnings.push.apply(warnings, regeneratorValues._toConsumableArray(compiled.warnings));
|
|
2727
3253
|
case 10:
|
|
2728
3254
|
serverStarted = performance.now();
|
|
2729
3255
|
_context3.n = 11;
|
|
@@ -2763,8 +3289,8 @@ function _buildUserApp() {
|
|
|
2763
3289
|
// prefix is a convention of the project layout, and what the loader needs is
|
|
2764
3290
|
// the URL path.
|
|
2765
3291
|
publicFiles = {};
|
|
2766
|
-
for (
|
|
2767
|
-
_Object$
|
|
3292
|
+
for (_i4 = 0, _Object$entries4 = Object.entries((_input$publicFiles = input.publicFiles) !== null && _input$publicFiles !== void 0 ? _input$publicFiles : {}); _i4 < _Object$entries4.length; _i4++) {
|
|
3293
|
+
_Object$entries4$_i = regeneratorValues._slicedToArray(_Object$entries4[_i4], 2), _path = _Object$entries4$_i[0], _base = _Object$entries4$_i[1];
|
|
2768
3294
|
publicFiles[_path.replace(/^public\//, "")] = _base;
|
|
2769
3295
|
}
|
|
2770
3296
|
_t3 = serverBuild.code;
|
|
@@ -2782,8 +3308,8 @@ function _buildUserApp() {
|
|
|
2782
3308
|
_t11 = input.rsc ? clientModules : undefined;
|
|
2783
3309
|
_t12 = input.target.base.rev;
|
|
2784
3310
|
_context3.n = 16;
|
|
2785
|
-
return sha256Hex([input.target.base.rev, rev, styles].concat(
|
|
2786
|
-
return built ? [built.code].concat(
|
|
3311
|
+
return sha256Hex([input.target.base.rev, rev, styles].concat(regeneratorValues._toConsumableArray(Object.entries(assetFiles).flat()), regeneratorValues._toConsumableArray(Object.entries(publicFiles).flat()), regeneratorValues._toConsumableArray([serverBuild, clientBuild, rscBuild].flatMap(function (built) {
|
|
3312
|
+
return built ? [built.code].concat(regeneratorValues._toConsumableArray(Object.entries(built.chunks).flat())) : [];
|
|
2787
3313
|
}))).join("\0"));
|
|
2788
3314
|
case 16:
|
|
2789
3315
|
_t13 = _context3.v.slice(0, 32);
|
|
@@ -2793,7 +3319,7 @@ function _buildUserApp() {
|
|
|
2793
3319
|
tailwind: tailwindMs,
|
|
2794
3320
|
total: performance.now() - started
|
|
2795
3321
|
};
|
|
2796
|
-
_t15 =
|
|
3322
|
+
_t15 = regeneratorValues._toConsumableArray(new Set(warnings));
|
|
2797
3323
|
return _context3.a(2, {
|
|
2798
3324
|
serverCode: _t3,
|
|
2799
3325
|
clientCode: _t4,
|
|
@@ -2817,7 +3343,7 @@ function _buildUserApp() {
|
|
|
2817
3343
|
return _buildUserApp.apply(this, arguments);
|
|
2818
3344
|
}
|
|
2819
3345
|
function publishPayload(build, extra) {
|
|
2820
|
-
return
|
|
3346
|
+
return regeneratorValues._objectSpread2({
|
|
2821
3347
|
serverCode: build.serverCode,
|
|
2822
3348
|
clientCode: build.clientCode,
|
|
2823
3349
|
serverChunks: build.serverChunks,
|
|
@@ -2849,14 +3375,14 @@ function publishArtifacts(_x) {
|
|
|
2849
3375
|
return _publishArtifacts.apply(this, arguments);
|
|
2850
3376
|
}
|
|
2851
3377
|
function _publishArtifacts() {
|
|
2852
|
-
_publishArtifacts =
|
|
3378
|
+
_publishArtifacts = regeneratorValues._asyncToGenerator(/*#__PURE__*/regeneratorValues._regenerator().m(function _callee2(build) {
|
|
2853
3379
|
var options,
|
|
2854
3380
|
encoder,
|
|
2855
3381
|
out,
|
|
2856
3382
|
single,
|
|
2857
3383
|
group,
|
|
2858
3384
|
_args2 = arguments;
|
|
2859
|
-
return
|
|
3385
|
+
return regeneratorValues._regenerator().w(function (_context2) {
|
|
2860
3386
|
while (1) switch (_context2.n) {
|
|
2861
3387
|
case 0:
|
|
2862
3388
|
options = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : {};
|
|
@@ -2878,7 +3404,7 @@ function _publishArtifacts() {
|
|
|
2878
3404
|
}
|
|
2879
3405
|
group = function group(prefix, record) {
|
|
2880
3406
|
for (var _i = 0, _Object$entries = Object.entries(record !== null && record !== void 0 ? record : {}); _i < _Object$entries.length; _i++) {
|
|
2881
|
-
var _Object$entries$_i =
|
|
3407
|
+
var _Object$entries$_i = regeneratorValues._slicedToArray(_Object$entries[_i], 2),
|
|
2882
3408
|
name = _Object$entries$_i[0],
|
|
2883
3409
|
body = _Object$entries$_i[1];
|
|
2884
3410
|
/*
|
|
@@ -2900,9 +3426,9 @@ function _publishArtifacts() {
|
|
|
2900
3426
|
group(artifactKeys.ARTIFACT_PREFIXES.assetFiles, build.assetFiles);
|
|
2901
3427
|
group(artifactKeys.ARTIFACT_PREFIXES.publicFiles, build.publicFiles);
|
|
2902
3428
|
return _context2.a(2, Promise.all(out.map(/*#__PURE__*/function () {
|
|
2903
|
-
var _ref2 =
|
|
3429
|
+
var _ref2 = regeneratorValues._asyncToGenerator(/*#__PURE__*/regeneratorValues._regenerator().m(function _callee(_ref) {
|
|
2904
3430
|
var key, body, _t, _t2, _t3, _t4;
|
|
2905
|
-
return
|
|
3431
|
+
return regeneratorValues._regenerator().w(function (_context) {
|
|
2906
3432
|
while (1) switch (_context.n) {
|
|
2907
3433
|
case 0:
|
|
2908
3434
|
key = _ref.key, body = _ref.body;
|
|
@@ -2969,9 +3495,9 @@ function sha1(_x) {
|
|
|
2969
3495
|
return _sha.apply(this, arguments);
|
|
2970
3496
|
}
|
|
2971
3497
|
function _sha() {
|
|
2972
|
-
_sha =
|
|
3498
|
+
_sha = regeneratorValues._asyncToGenerator(/*#__PURE__*/regeneratorValues._regenerator().m(function _callee(bytes) {
|
|
2973
3499
|
var digest;
|
|
2974
|
-
return
|
|
3500
|
+
return regeneratorValues._regenerator().w(function (_context) {
|
|
2975
3501
|
while (1) switch (_context.n) {
|
|
2976
3502
|
case 0:
|
|
2977
3503
|
_context.n = 1;
|
|
@@ -2995,7 +3521,7 @@ function concat(parts) {
|
|
|
2995
3521
|
}, 0);
|
|
2996
3522
|
var out = new Uint8Array(total);
|
|
2997
3523
|
var at = 0;
|
|
2998
|
-
var _iterator =
|
|
3524
|
+
var _iterator = regeneratorValues._createForOfIteratorHelper(parts),
|
|
2999
3525
|
_step;
|
|
3000
3526
|
try {
|
|
3001
3527
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
@@ -3019,9 +3545,9 @@ function blobSha(_x2) {
|
|
|
3019
3545
|
return _blobSha.apply(this, arguments);
|
|
3020
3546
|
}
|
|
3021
3547
|
function _blobSha() {
|
|
3022
|
-
_blobSha =
|
|
3548
|
+
_blobSha = regeneratorValues._asyncToGenerator(/*#__PURE__*/regeneratorValues._regenerator().m(function _callee2(content) {
|
|
3023
3549
|
var _t;
|
|
3024
|
-
return
|
|
3550
|
+
return regeneratorValues._regenerator().w(function (_context2) {
|
|
3025
3551
|
while (1) switch (_context2.n) {
|
|
3026
3552
|
case 0:
|
|
3027
3553
|
_t = hex;
|
|
@@ -3052,12 +3578,12 @@ function hashTree(_x3) {
|
|
|
3052
3578
|
}
|
|
3053
3579
|
/** A file, as this record holds it: its bytes and whether git marks it executable. */
|
|
3054
3580
|
function _hashTree() {
|
|
3055
|
-
_hashTree =
|
|
3581
|
+
_hashTree = regeneratorValues._asyncToGenerator(/*#__PURE__*/regeneratorValues._regenerator().m(function _callee3(entries) {
|
|
3056
3582
|
var sorted, body;
|
|
3057
|
-
return
|
|
3583
|
+
return regeneratorValues._regenerator().w(function (_context3) {
|
|
3058
3584
|
while (1) switch (_context3.n) {
|
|
3059
3585
|
case 0:
|
|
3060
|
-
sorted =
|
|
3586
|
+
sorted = regeneratorValues._toConsumableArray(entries).sort(gitOrder);
|
|
3061
3587
|
body = concat(sorted.flatMap(function (e) {
|
|
3062
3588
|
return [utf8("".concat(e.mode, " ").concat(e.name, "\0")), e.sha];
|
|
3063
3589
|
}));
|
|
@@ -3083,9 +3609,9 @@ function treeSha(_x4) {
|
|
|
3083
3609
|
|
|
3084
3610
|
/** The common case: a record of text files, none executable. */
|
|
3085
3611
|
function _treeSha() {
|
|
3086
|
-
_treeSha =
|
|
3612
|
+
_treeSha = regeneratorValues._asyncToGenerator(/*#__PURE__*/regeneratorValues._regenerator().m(function _callee5(files) {
|
|
3087
3613
|
var root, _i, _Object$entries, _Object$entries$_i, rawPath, file, parts, name, at, _iterator2, _step2, dir, next, _build, _t1;
|
|
3088
|
-
return
|
|
3614
|
+
return regeneratorValues._regenerator().w(function (_context5) {
|
|
3089
3615
|
while (1) switch (_context5.n) {
|
|
3090
3616
|
case 0:
|
|
3091
3617
|
root = {
|
|
@@ -3098,7 +3624,7 @@ function _treeSha() {
|
|
|
3098
3624
|
_context5.n = 4;
|
|
3099
3625
|
break;
|
|
3100
3626
|
}
|
|
3101
|
-
_Object$entries$_i =
|
|
3627
|
+
_Object$entries$_i = regeneratorValues._slicedToArray(_Object$entries[_i], 2), rawPath = _Object$entries$_i[0], file = _Object$entries$_i[1];
|
|
3102
3628
|
parts = rawPath.replace(/^\/+/, "").split("/").filter(Boolean);
|
|
3103
3629
|
if (!(parts.length === 0)) {
|
|
3104
3630
|
_context5.n = 2;
|
|
@@ -3108,7 +3634,7 @@ function _treeSha() {
|
|
|
3108
3634
|
case 2:
|
|
3109
3635
|
name = parts.pop();
|
|
3110
3636
|
at = root;
|
|
3111
|
-
_iterator2 =
|
|
3637
|
+
_iterator2 = regeneratorValues._createForOfIteratorHelper(parts);
|
|
3112
3638
|
try {
|
|
3113
3639
|
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
3114
3640
|
dir = _step2.value;
|
|
@@ -3134,13 +3660,13 @@ function _treeSha() {
|
|
|
3134
3660
|
break;
|
|
3135
3661
|
case 4:
|
|
3136
3662
|
_build = /*#__PURE__*/function () {
|
|
3137
|
-
var _ref3 =
|
|
3663
|
+
var _ref3 = regeneratorValues._asyncToGenerator(/*#__PURE__*/regeneratorValues._regenerator().m(function _callee4(node) {
|
|
3138
3664
|
var entries, _iterator3, _step3, _step3$value, _name, _file, _iterator4, _step4, _step4$value, _name2, _dir, _t2, _t3, _t4, _t5, _t6, _t7, _t8, _t9, _t0;
|
|
3139
|
-
return
|
|
3665
|
+
return regeneratorValues._regenerator().w(function (_context4) {
|
|
3140
3666
|
while (1) switch (_context4.p = _context4.n) {
|
|
3141
3667
|
case 0:
|
|
3142
3668
|
entries = [];
|
|
3143
|
-
_iterator3 =
|
|
3669
|
+
_iterator3 = regeneratorValues._createForOfIteratorHelper(node.files);
|
|
3144
3670
|
_context4.p = 1;
|
|
3145
3671
|
_iterator3.s();
|
|
3146
3672
|
case 2:
|
|
@@ -3148,7 +3674,7 @@ function _treeSha() {
|
|
|
3148
3674
|
_context4.n = 5;
|
|
3149
3675
|
break;
|
|
3150
3676
|
}
|
|
3151
|
-
_step3$value =
|
|
3677
|
+
_step3$value = regeneratorValues._slicedToArray(_step3.value, 2), _name = _step3$value[0], _file = _step3$value[1];
|
|
3152
3678
|
_t2 = entries;
|
|
3153
3679
|
_t3 = _file.executable ? "100755" : "100644";
|
|
3154
3680
|
_t4 = _name;
|
|
@@ -3176,7 +3702,7 @@ function _treeSha() {
|
|
|
3176
3702
|
_iterator3.f();
|
|
3177
3703
|
return _context4.f(7);
|
|
3178
3704
|
case 8:
|
|
3179
|
-
_iterator4 =
|
|
3705
|
+
_iterator4 = regeneratorValues._createForOfIteratorHelper(node.dirs);
|
|
3180
3706
|
_context4.p = 9;
|
|
3181
3707
|
_iterator4.s();
|
|
3182
3708
|
case 10:
|
|
@@ -3184,7 +3710,7 @@ function _treeSha() {
|
|
|
3184
3710
|
_context4.n = 13;
|
|
3185
3711
|
break;
|
|
3186
3712
|
}
|
|
3187
|
-
_step4$value =
|
|
3713
|
+
_step4$value = regeneratorValues._slicedToArray(_step4.value, 2), _name2 = _step4$value[0], _dir = _step4$value[1];
|
|
3188
3714
|
_t7 = entries;
|
|
3189
3715
|
_t8 = _name2;
|
|
3190
3716
|
_context4.n = 11;
|
|
@@ -3232,7 +3758,7 @@ function _treeSha() {
|
|
|
3232
3758
|
function treeShaOfText(files) {
|
|
3233
3759
|
var encoder = new TextEncoder();
|
|
3234
3760
|
return treeSha(Object.fromEntries(Object.entries(files).map(function (_ref) {
|
|
3235
|
-
var _ref2 =
|
|
3761
|
+
var _ref2 = regeneratorValues._slicedToArray(_ref, 2),
|
|
3236
3762
|
path = _ref2[0],
|
|
3237
3763
|
text = _ref2[1];
|
|
3238
3764
|
return [path, {
|
|
@@ -3311,7 +3837,7 @@ var LEGACY_CONTROL_HOST = "platform.internal";
|
|
|
3311
3837
|
*/
|
|
3312
3838
|
var valServerSource = function valServerSource(_ref) {
|
|
3313
3839
|
var git = _ref.git;
|
|
3314
|
-
return "".concat(WIRED_MARKER, "\nimport {\n initValContent,\n initValServer,\n} from \"@valbuild/tanstack/server\";\nimport { config } from \"../../val.config\";\nimport valModules from \"../../val.modules\";\n\n/**\n * A secret, as the platform hands it over at RUNTIME.\n *\n * Preferred over `process.env`, which the builder inlines as a literal into\n * this bundle: that puts the value in storage inside the code, copies it into\n * every isolate that loads it, and makes rotating it a republish.\n *\n * Falls back to the build-time value, so an app published before secrets\n * existed keeps working.\n */\nfunction secret(name: string): string | undefined {\n return (globalThis.__PLATFORM_SECRETS ?? {})[name] ?? process.env[name];\n}\n\n/**\n * The commit this build was made from, and the branch it commits to.\n *\n * Baked in rather than handed over at runtime, unlike a secret, because it is\n * not configuration -- it is a property OF THIS BUILD. Every read of a\n * `.val.ts` in http mode fetches that path from the content service at this\n * sha, so a build served with somebody else's commit renders and edits a\n * version of its files it was not compiled from. A secret can be rotated under\n * a running build; this cannot, and publishing again is how it changes.\n *\n * WHAT THIS IS NOT. It is not every read: a committed render reads the source\n * bundled into this build and asks the content service nothing. It is the\n * PUBLISH path -- turning pending patches into new `.val.ts` text means\n * fetching the current text to patch, and that is the read that happens at\n * this sha. The docblock used to say \"every read\", which sent readers looking\n * for a content call on the serving path that is not there.\n *\n * `null` when the source came from no commit -- a record assembled in a tab,\n * a fixture, or ANY build this platform makes, which is the common case rather\n * than the exception. Such a build has no repository to mirror commits into,\n * and does not need one: the content service is the store of record for\n * content and mints its own commit shas. Val is in http mode on credentials\n * alone.\n */\nconst BUILT_FROM = ").concat(git ? JSON.stringify(git) : "null", ";\n\n/**\n * What puts Val in http mode: its content service owns the content.\n *\n * The same three things any deployed Val app is configured with. Note what is\n * NOT here: no `sourceFiles`, so patches are relayed to the content service\n * instead of being kept by this platform, and the browser uploads an image\n * straight there on a presigned URL instead of streaming it through here.\n *\n * `undefined` when a credential or the commit is missing, and deliberately not\n * a throw at module scope: that would take the isolate down with it, page\n * renders included. Val is left to refuse the request and name what it wanted\n * -- `VAL_ENV=app` is set on this build precisely so that a missing credential\n * is an error instead of a fall-through to `fs` mode, looking for a working\n * tree that is not in here.\n */\nconst apiKey = secret(\"VAL_API_KEY\");\nconst valSecret = secret(\"VAL_SECRET\");\n/*\n * Which content service, for a project that is not pointed at the real one.\n *\n * A secret rather than a baked literal, because unlike the commit this IS\n * configuration: the same build should be servable against a stand-in and\n * against production. It is what makes the editing path testable at all --\n * Val's own `e2e/mock-content-host` implements this wire protocol with no git\n * repository behind it -- and without it a build could only ever talk to\n * content.val.build.\n *\n * It does NOT redirect everything, and the gap is in Val rather than here:\n * `getSettings`, which remote FILES use, reads `process.env.VAL_CONTENT_URL`\n * at module scope inside @valbuild/server. This platform bundles its\n * dependencies separately from the app, so nothing it sets reaches that read --\n * the same reason `apiKey` has to be passed in rather than found. So patches,\n * commits and source reads go where this says, and remote file uploads still\n * address the real host.\n */\nconst valContentUrl = secret(\"VAL_CONTENT_URL\");\n/*\n * WHICH project's content this is, at the content service.\n *\n * Val's own name for the project (`org/name`), which is not the platform's\n * project id and cannot be derived from it. A repository that is deployed\n * anywhere else puts it in `val.config.ts`; one imported here need not have,\n * so it is configuration the platform can supply -- and it goes through\n * `secret` rather than `--env` for a second reason: a build-time literal\n * would have to be baked into the shared dependency layer, where\n * @valbuild/server reads `process.env.VAL_PROJECT`, and that layer is reused\n * by every project with the same dependencies.\n *\n * What the app configured wins over nothing at all, so a repository that does\n * name its project keeps working with no secret set.\n */\nconst valProject = secret(\"VAL_PROJECT\");\nconst valConfig = {\n ...config,\n ...(valProject !== undefined ? { project: valProject } : {}),\n};\n/*\n * CREDENTIALS ALONE. A commit is not part of what puts Val in http mode.\n *\n * It used to be: `GIT !== null` was in this condition, and a build with no\n * commit fell through to `undefined` -- which meant every site this platform\n * seeded was silently unable to edit, because a shared build cannot know a\n * commit. The binding that worked around it (`VAL_GIT_COMMIT` /\n * `VAL_GIT_BRANCH` out of the project's secrets) is gone with it: it named a\n * commit in the TEMPLATE's repository, which was true only for as long as\n * seeding and repository creation shared a template, and it was one more thing\n * in KV that could go stale.\n *\n * The commit is optional NOW, and it is still sent where there is one -- see\n * the note at the spread below. What is gone is the binding that supplied one\n * from KV, so there is one source per environment and no precedence rule\n * between a baked value and a bound one.\n */\nconst http =\n apiKey !== undefined && valSecret !== undefined\n ? {\n apiKey,\n valSecret,\n /*\n * BOTH SPELLINGS OF THE COMMIT, because the APP decides which one is\n * read and this file cannot know which app it is being written into.\n *\n * `ValHttpMode` has been renamed in both directions. Up to 0.132 it\n * took `gitCommit`/`gitBranch`; 0.133.0 replaced that pair with a\n * nested `git`; the version this package ships beside flattens it\n * back again. The generated file is compiled against whatever\n * `@valbuild/tanstack` the PROJECT installed -- the starter pins\n * 0.133.0 -- and a platform writing this file has no say in that. So\n * this is not one rename behind or ahead: it is on both sides of one at\n * once, and will be until every app it publishes has moved.\n *\n * Sending only the wrong one is SILENT, which is why this is belt and\n * braces rather than a version check. An unknown key on the options\n * object is ignored, so the commit is simply dropped and a build wired\n * FROM A COMMIT runs as though it had none -- which means a publish\n * produces no mirrored `.val.ts`, so a save commits and hands over\n * nothing, and the site keeps serving its old content with the patches\n * already consumed. Nothing reports it. valbuild/home's loop is the one\n * thing that sees it, and it was bisected there: 25/25 with the key the\n * installed version reads, 21/23 without, failing at exactly \"the save\n * left the file it rewrote pending\".\n *\n * Whichever version is installed reads its own key and ignores the\n * other two. Drop this to one spelling when every app this platform\n * publishes is past the rename -- not before, and not on the say-so of\n * a compiler in the Val repository, which is looking at a different\n * version of `@valbuild/tanstack` than the app is.\n */\n ...(BUILT_FROM !== null\n ? {\n git: BUILT_FROM,\n gitCommit: BUILT_FROM.commit,\n gitBranch: BUILT_FROM.branch,\n }\n : {}),\n ...(valContentUrl !== undefined ? { valContentUrl } : {}),\n }\n : undefined;\n\nconst { valApiHandler, draftMode } = initValServer(\n valModules,\n valConfig,\n {\n ...(http ? { http } : {}),\n },\n);\n\nconst {\n fetchValStega: fetchVal,\n fetchValKeyStega: fetchValKey,\n fetchValRouteStega: fetchValRoute,\n fetchValRouteUrl,\n} = initValContent(valConfig, valModules, {\n draftMode,\n /*\n * The SAME object the API got.\n *\n * These readers resolve content through a Val server of their own rather than\n * by calling the API over HTTP, so the mode question is put to them\n * separately -- configuring only `initValServer` left them inferring `fs`\n * mode, looking for a working tree that is not in here. `gitCommit` is the\n * field that would be silently wrong rather than loudly missing: two\n * different shas means the API edits one version of a file while the page\n * renders another.\n */\n ...(http ? { http } : {}),\n});\n\n/**\n * A build that is MEANT to edit and cannot, refusing instead of pretending to.\n *\n * `BUILT_FROM` being non-null says this build came from a commit, so it was\n * made to edit against a content service. If the credentials for that service are not\n * here, the configuration is broken -- and the failure that was reaching people\n * was not an error at all. Val picks its storage mode by inference, so an\n * isolate with no api key lands in a mode that ACCEPTS the write and keeps it\n * in the isolate. Cloudflare starts an isolate per concurrent request, so the\n * save answers 200 and the next request, served by a different isolate, has\n * never heard of it. The edit is simply gone, and nothing anywhere said so.\n *\n * That is the worst available outcome: a person is told their work is saved\n * when it is not. Refusing is strictly better, and naming the missing secret\n * turns an evening of reading logs into one line in a response body.\n *\n * WHY HERE rather than relying on `VAL_ENV=app`: that is a build-time\n * substitution into the shared dependency layer, so whether a build fails\n * loudly depends on which layer it happens to be pinned to. This file is\n * written on every build, by the platform, and cannot be missing from one.\n *\n * Only the editing API. Page renders do not come through here, and a site whose\n * content cannot be edited should still serve the content it has.\n */\nconst editingApiHandler =\n http === undefined\n ? async () => {\n const missing = [\n apiKey === undefined ? \"VAL_API_KEY\" : null,\n valSecret === undefined ? \"VAL_SECRET\" : null,\n /*\n * A build from no commit is listed the same way, because from the\n * outside the two are one state. It is not a secret somebody can set\n * -- a commit is a property OF THE BUILD, and the only cure is\n * publishing this project's own repository over whatever is serving\n * it. Named anyway, because \"it was built from no commit\" is the\n * sentence that ends the search.\n */\n BUILT_FROM === null ? \"a commit (this build was made from none)\" : null,\n ].filter(Boolean);\n return Response.json(\n {\n error:\n \"This site cannot be edited. Its content lives in a content service, and \" +\n missing.join(\", \") +\n \" \" +\n (missing.length > 1 ? \"are\" : \"is\") +\n \" missing, so there is nothing to edit against. Editing is refused rather \" +\n \"than kept in this isolate's memory, where it would be lost without being \" +\n \"reported.\" +\n (BUILT_FROM === null\n ? \" A build made from no commit is usually one SEEDED from a template: \" +\n \"publish this project's own repository to replace it.\"\n : \" This build was made from commit \" + BUILT_FROM.commit.slice(0, 8) + \".\"),\n missing,\n },\n { status: 503 },\n );\n }\n : valApiHandler;\n\nexport {\n editingApiHandler as valApiHandler,\n draftMode,\n fetchVal,\n fetchValKey,\n fetchValRoute,\n fetchValRouteUrl,\n};\n");
|
|
3840
|
+
return "".concat(WIRED_MARKER, "\nimport {\n initValContent,\n initValServer,\n} from \"@valbuild/tanstack/server\";\nimport { config } from \"../../val.config\";\nimport valModules from \"../../val.modules\";\n/*\n * This build's own source, which a publish patches. A project with no\n * repository has no other copy of its `.val.ts` text: content keeps its\n * content as data. Ignored by a @valbuild/tanstack that predates it.\n */\nimport { FILES } from \"platform:project-source\";\n\n/**\n * A secret, as the platform hands it over at RUNTIME.\n *\n * Preferred over `process.env`, which the builder inlines as a literal into\n * this bundle: that puts the value in storage inside the code, copies it into\n * every isolate that loads it, and makes rotating it a republish.\n *\n * Falls back to the build-time value, so an app published before secrets\n * existed keeps working.\n */\nfunction secret(name: string): string | undefined {\n return (globalThis.__PLATFORM_SECRETS ?? {})[name] ?? process.env[name];\n}\n\n/**\n * The commit this build was made from, and the branch it commits to.\n *\n * Baked in rather than handed over at runtime, unlike a secret, because it is\n * not configuration -- it is a property OF THIS BUILD. Every read of a\n * `.val.ts` in http mode fetches that path from the content service at this\n * sha, so a build served with somebody else's commit renders and edits a\n * version of its files it was not compiled from. A secret can be rotated under\n * a running build; this cannot, and publishing again is how it changes.\n *\n * WHAT THIS IS NOT. It is not every read: a committed render reads the source\n * bundled into this build and asks the content service nothing. It is the\n * PUBLISH path -- turning pending patches into new `.val.ts` text means\n * fetching the current text to patch, and that is the read that happens at\n * this sha. The docblock used to say \"every read\", which sent readers looking\n * for a content call on the serving path that is not there.\n *\n * `null` when the source came from no commit -- a record assembled in a tab,\n * a fixture, or ANY build this platform makes, which is the common case rather\n * than the exception. Such a build has no repository to mirror commits into,\n * and does not need one: the content service is the store of record for\n * content and mints its own commit shas. Val is in http mode on credentials\n * alone.\n */\nconst BUILT_FROM = ").concat(git ? JSON.stringify(git) : "null", ";\n\n/**\n * What puts Val in http mode: its content service owns the content.\n *\n * The same three things any deployed Val app is configured with. Note what is\n * NOT here: no `sourceFiles`, so patches are relayed to the content service\n * instead of being kept by this platform, and the browser uploads an image\n * straight there on a presigned URL instead of streaming it through here.\n *\n * `undefined` when a credential or the commit is missing, and deliberately not\n * a throw at module scope: that would take the isolate down with it, page\n * renders included. Val is left to refuse the request and name what it wanted\n * -- `VAL_ENV=app` is set on this build precisely so that a missing credential\n * is an error instead of a fall-through to `fs` mode, looking for a working\n * tree that is not in here.\n */\nconst apiKey = secret(\"VAL_API_KEY\");\nconst valSecret = secret(\"VAL_SECRET\");\n/*\n * Which content service, for a project that is not pointed at the real one.\n *\n * A secret rather than a baked literal, because unlike the commit this IS\n * configuration: the same build should be servable against a stand-in and\n * against production. It is what makes the editing path testable at all --\n * Val's own `e2e/mock-content-host` implements this wire protocol with no git\n * repository behind it -- and without it a build could only ever talk to\n * content.val.build.\n *\n * It does NOT redirect everything, and the gap is in Val rather than here:\n * `getSettings`, which remote FILES use, reads `process.env.VAL_CONTENT_URL`\n * at module scope inside @valbuild/server. This platform bundles its\n * dependencies separately from the app, so nothing it sets reaches that read --\n * the same reason `apiKey` has to be passed in rather than found. So patches,\n * commits and source reads go where this says, and remote file uploads still\n * address the real host.\n */\nconst valContentUrl = secret(\"VAL_CONTENT_URL\");\n/*\n * WHICH project's content this is, at the content service.\n *\n * Val's own name for the project (`org/name`), which is not the platform's\n * project id and cannot be derived from it. A repository that is deployed\n * anywhere else puts it in `val.config.ts`; one imported here need not have,\n * so it is configuration the platform can supply -- and it goes through\n * `secret` rather than `--env` for a second reason: a build-time literal\n * would have to be baked into the shared dependency layer, where\n * @valbuild/server reads `process.env.VAL_PROJECT`, and that layer is reused\n * by every project with the same dependencies.\n *\n * What the app configured wins over nothing at all, so a repository that does\n * name its project keeps working with no secret set.\n */\nconst valProject = secret(\"VAL_PROJECT\");\nconst valConfig = {\n ...config,\n ...(valProject !== undefined ? { project: valProject } : {}),\n};\n/*\n * CREDENTIALS ALONE. A commit is not part of what puts Val in http mode.\n *\n * It used to be: `GIT !== null` was in this condition, and a build with no\n * commit fell through to `undefined` -- which meant every site this platform\n * seeded was silently unable to edit, because a shared build cannot know a\n * commit. The binding that worked around it (`VAL_GIT_COMMIT` /\n * `VAL_GIT_BRANCH` out of the project's secrets) is gone with it: it named a\n * commit in the TEMPLATE's repository, which was true only for as long as\n * seeding and repository creation shared a template, and it was one more thing\n * in KV that could go stale.\n *\n * The commit is optional NOW, and it is still sent where there is one -- see\n * the note at the spread below. What is gone is the binding that supplied one\n * from KV, so there is one source per environment and no precedence rule\n * between a baked value and a bound one.\n */\nconst http =\n apiKey !== undefined && valSecret !== undefined\n ? {\n apiKey,\n valSecret,\n /*\n * BOTH SPELLINGS OF THE COMMIT, because the APP decides which one is\n * read and this file cannot know which app it is being written into.\n *\n * `ValHttpMode` has been renamed in both directions. Up to 0.132 it\n * took `gitCommit`/`gitBranch`; 0.133.0 replaced that pair with a\n * nested `git`; the version this package ships beside flattens it\n * back again. The generated file is compiled against whatever\n * `@valbuild/tanstack` the PROJECT installed -- the starter pins\n * 0.133.0 -- and a platform writing this file has no say in that. So\n * this is not one rename behind or ahead: it is on both sides of one at\n * once, and will be until every app it publishes has moved.\n *\n * Sending only the wrong one is SILENT, which is why this is belt and\n * braces rather than a version check. An unknown key on the options\n * object is ignored, so the commit is simply dropped and a build wired\n * FROM A COMMIT runs as though it had none -- which means a publish\n * produces no mirrored `.val.ts`, so a save commits and hands over\n * nothing, and the site keeps serving its old content with the patches\n * already consumed. Nothing reports it. valbuild/home's loop is the one\n * thing that sees it, and it was bisected there: 25/25 with the key the\n * installed version reads, 21/23 without, failing at exactly \"the save\n * left the file it rewrote pending\".\n *\n * Whichever version is installed reads its own key and ignores the\n * other two. Drop this to one spelling when every app this platform\n * publishes is past the rename -- not before, and not on the say-so of\n * a compiler in the Val repository, which is looking at a different\n * version of `@valbuild/tanstack` than the app is.\n */\n ...(BUILT_FROM !== null\n ? {\n git: BUILT_FROM,\n gitCommit: BUILT_FROM.commit,\n gitBranch: BUILT_FROM.branch,\n }\n : {}),\n ...(valContentUrl !== undefined ? { valContentUrl } : {}),\n projectSource: FILES,\n }\n : undefined;\n\nconst { valApiHandler, draftMode } = initValServer(\n valModules,\n valConfig,\n {\n ...(http ? { http } : {}),\n },\n);\n\nconst {\n fetchValStega: fetchVal,\n fetchValKeyStega: fetchValKey,\n fetchValRouteStega: fetchValRoute,\n fetchValRouteUrl,\n} = initValContent(valConfig, valModules, {\n draftMode,\n /*\n * The SAME object the API got.\n *\n * These readers resolve content through a Val server of their own rather than\n * by calling the API over HTTP, so the mode question is put to them\n * separately -- configuring only `initValServer` left them inferring `fs`\n * mode, looking for a working tree that is not in here. `gitCommit` is the\n * field that would be silently wrong rather than loudly missing: two\n * different shas means the API edits one version of a file while the page\n * renders another.\n */\n ...(http ? { http } : {}),\n});\n\n/**\n * A build that is MEANT to edit and cannot, refusing instead of pretending to.\n *\n * `BUILT_FROM` being non-null says this build came from a commit, so it was\n * made to edit against a content service. If the credentials for that service are not\n * here, the configuration is broken -- and the failure that was reaching people\n * was not an error at all. Val picks its storage mode by inference, so an\n * isolate with no api key lands in a mode that ACCEPTS the write and keeps it\n * in the isolate. Cloudflare starts an isolate per concurrent request, so the\n * save answers 200 and the next request, served by a different isolate, has\n * never heard of it. The edit is simply gone, and nothing anywhere said so.\n *\n * That is the worst available outcome: a person is told their work is saved\n * when it is not. Refusing is strictly better, and naming the missing secret\n * turns an evening of reading logs into one line in a response body.\n *\n * WHY HERE rather than relying on `VAL_ENV=app`: that is a build-time\n * substitution into the shared dependency layer, so whether a build fails\n * loudly depends on which layer it happens to be pinned to. This file is\n * written on every build, by the platform, and cannot be missing from one.\n *\n * Only the editing API. Page renders do not come through here, and a site whose\n * content cannot be edited should still serve the content it has.\n */\nconst editingApiHandler =\n http === undefined\n ? async () => {\n const missing = [\n apiKey === undefined ? \"VAL_API_KEY\" : null,\n valSecret === undefined ? \"VAL_SECRET\" : null,\n /*\n * A build from no commit is listed the same way, because from the\n * outside the two are one state. It is not a secret somebody can set\n * -- a commit is a property OF THE BUILD, and the only cure is\n * publishing this project's own repository over whatever is serving\n * it. Named anyway, because \"it was built from no commit\" is the\n * sentence that ends the search.\n */\n BUILT_FROM === null ? \"a commit (this build was made from none)\" : null,\n ].filter(Boolean);\n return Response.json(\n {\n error:\n \"This site cannot be edited. Its content lives in a content service, and \" +\n missing.join(\", \") +\n \" \" +\n (missing.length > 1 ? \"are\" : \"is\") +\n \" missing, so there is nothing to edit against. Editing is refused rather \" +\n \"than kept in this isolate's memory, where it would be lost without being \" +\n \"reported.\" +\n (BUILT_FROM === null\n ? \" A build made from no commit is usually one SEEDED from a template: \" +\n \"publish this project's own repository to replace it.\"\n : \" This build was made from commit \" + BUILT_FROM.commit.slice(0, 8) + \".\"),\n missing,\n },\n { status: 503 },\n );\n }\n : valApiHandler;\n\nexport {\n editingApiHandler as valApiHandler,\n draftMode,\n fetchVal,\n fetchValKey,\n fetchValRoute,\n fetchValRouteUrl,\n};\n");
|
|
3315
3841
|
};
|
|
3316
3842
|
|
|
3317
3843
|
/**
|
|
@@ -3414,7 +3940,7 @@ function rebakeGit(files, git) {
|
|
|
3414
3940
|
var source = files[VAL_SERVER];
|
|
3415
3941
|
if (source === undefined) return files;
|
|
3416
3942
|
if (!BUILT_FROM_LINE.test(source)) return files;
|
|
3417
|
-
return
|
|
3943
|
+
return regeneratorValues._objectSpread2(regeneratorValues._objectSpread2({}, files), {}, regeneratorValues._defineProperty({}, VAL_SERVER, source.replace(BUILT_FROM_LINE, "const BUILT_FROM = ".concat(git === null ? "null" : JSON.stringify(git), ";"))));
|
|
3418
3944
|
}
|
|
3419
3945
|
|
|
3420
3946
|
/** Is this a Val project at all? */
|
|
@@ -3443,7 +3969,7 @@ function isWired(files) {
|
|
|
3443
3969
|
* what an edit is applied to, and the source that gets published back.
|
|
3444
3970
|
*/
|
|
3445
3971
|
function wireUp(files, options) {
|
|
3446
|
-
var out =
|
|
3972
|
+
var out = regeneratorValues._objectSpread2({}, files);
|
|
3447
3973
|
var changes = [];
|
|
3448
3974
|
var warnings = [];
|
|
3449
3975
|
if (!isValProject(files)) {
|