@valbuild/tanstack-build 0.136.3 → 0.138.4
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 +17 -0
- package/dist/declarations/src/wire.d.ts +8 -1
- 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 +711 -136
- package/dist/valbuild-tanstack-build.cjs.prod.js +711 -136
- package/dist/valbuild-tanstack-build.esm.js +606 -32
- 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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as _createForOfIteratorHelper, a as _asyncToGenerator, b as _regenerator, c as _toConsumableArray, d as _slicedToArray, e as
|
|
1
|
+
import { _ as _createForOfIteratorHelper, a as _asyncToGenerator, b as _regenerator, c as _toConsumableArray, d as _slicedToArray, e as _regeneratorValues, f as _objectSpread2, g as _defineProperty } from './regeneratorValues-3acdc3fe.esm.js';
|
|
2
2
|
import { build } from '@rolldown/browser';
|
|
3
3
|
import { E as ENTRY, T as TREE } from './projectPaths-5e4defea.esm.js';
|
|
4
4
|
export { E as ENTRY, R as ROUTES_DIR, T as TREE } from './projectPaths-5e4defea.esm.js';
|
|
@@ -1244,6 +1244,490 @@ function _transformEnvMarkers() {
|
|
|
1244
1244
|
return _transformEnvMarkers.apply(this, arguments);
|
|
1245
1245
|
}
|
|
1246
1246
|
|
|
1247
|
+
/** `TANSTACK_DEVTOOLS_PACKAGES` upstream. Exact specifiers, not prefixes. */
|
|
1248
|
+
var TANSTACK_DEVTOOLS_PACKAGES = ["@tanstack/react-devtools", "@tanstack/preact-devtools", "@tanstack/solid-devtools", "@tanstack/vue-devtools", "@tanstack/svelte-devtools", "@tanstack/angular-devtools", "@tanstack/devtools"];
|
|
1249
|
+
var isDevtoolsImport = function isDevtoolsImport(source) {
|
|
1250
|
+
return typeof source === "string" && TANSTACK_DEVTOOLS_PACKAGES.includes(source);
|
|
1251
|
+
};
|
|
1252
|
+
|
|
1253
|
+
/** Through the newline after `node`, so a removed statement leaves no blank line. */
|
|
1254
|
+
var endOfLine = function endOfLine(code, node) {
|
|
1255
|
+
return code[node.end] === "\n" ? node.end + 1 : node.end;
|
|
1256
|
+
};
|
|
1257
|
+
|
|
1258
|
+
/** The element name a `render` value renders: `<X />`, `() => <X />`, `X`, `X()`. */
|
|
1259
|
+
function renderedName(value) {
|
|
1260
|
+
if (!value) return null;
|
|
1261
|
+
var elementName = function elementName(element) {
|
|
1262
|
+
return (element === null || element === void 0 ? void 0 : element.type) === "JSXElement" && element.openingElement.name.type === "JSXIdentifier" ? String(element.openingElement.name.name) : null;
|
|
1263
|
+
};
|
|
1264
|
+
if (value.type === "JSXElement") return elementName(value);
|
|
1265
|
+
if (value.type === "ArrowFunctionExpression" || value.type === "FunctionExpression") return elementName(value.body);
|
|
1266
|
+
if (value.type === "Identifier") return String(value.name);
|
|
1267
|
+
if (value.type === "CallExpression" && value.callee.type === "Identifier") return String(value.callee.name);
|
|
1268
|
+
return null;
|
|
1269
|
+
}
|
|
1270
|
+
|
|
1271
|
+
/** `getPluginReferences` upstream: the panels a devtools element's `plugins` renders. */
|
|
1272
|
+
function pluginReferences(opening) {
|
|
1273
|
+
var refs = [];
|
|
1274
|
+
for (var _i = 0, _arr = opening.attributes; _i < _arr.length; _i++) {
|
|
1275
|
+
var _attr$value, _attr$value2;
|
|
1276
|
+
var attr = _arr[_i];
|
|
1277
|
+
if (attr.type !== "JSXAttribute") continue;
|
|
1278
|
+
if (attr.name.type !== "JSXIdentifier" || attr.name.name !== "plugins") continue;
|
|
1279
|
+
var expression = (_attr$value = attr.value) === null || _attr$value === void 0 ? void 0 : _attr$value.expression;
|
|
1280
|
+
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;
|
|
1281
|
+
for (var _i2 = 0, _arr2 = expression.elements; _i2 < _arr2.length; _i2++) {
|
|
1282
|
+
var element = _arr2[_i2];
|
|
1283
|
+
if ((element === null || element === void 0 ? void 0 : element.type) !== "ObjectExpression") continue;
|
|
1284
|
+
for (var _i3 = 0, _arr3 = element.properties; _i3 < _arr3.length; _i3++) {
|
|
1285
|
+
var prop = _arr3[_i3];
|
|
1286
|
+
if (prop.type !== "Property" || prop.key.type !== "Identifier") continue;
|
|
1287
|
+
if (prop.key.name !== "render") continue;
|
|
1288
|
+
var name = renderedName(prop.value);
|
|
1289
|
+
if (name) refs.push(name);
|
|
1290
|
+
}
|
|
1291
|
+
}
|
|
1292
|
+
}
|
|
1293
|
+
return refs;
|
|
1294
|
+
}
|
|
1295
|
+
|
|
1296
|
+
/** Every name a binding pattern declares: `a`, `{ a, b: c }`, `[a, ...b]`, `a = 1`. */
|
|
1297
|
+
function patternNames(pattern, into) {
|
|
1298
|
+
if (!pattern) return;
|
|
1299
|
+
switch (pattern.type) {
|
|
1300
|
+
case "Identifier":
|
|
1301
|
+
into.add(String(pattern.name));
|
|
1302
|
+
return;
|
|
1303
|
+
case "ObjectPattern":
|
|
1304
|
+
for (var _i4 = 0, _arr4 = pattern.properties; _i4 < _arr4.length; _i4++) {
|
|
1305
|
+
var prop = _arr4[_i4];
|
|
1306
|
+
patternNames(prop.type === "RestElement" ? prop.argument : prop.value, into);
|
|
1307
|
+
}
|
|
1308
|
+
return;
|
|
1309
|
+
case "ArrayPattern":
|
|
1310
|
+
for (var _i5 = 0, _arr5 = pattern.elements; _i5 < _arr5.length; _i5++) {
|
|
1311
|
+
var element = _arr5[_i5];
|
|
1312
|
+
patternNames(element, into);
|
|
1313
|
+
}
|
|
1314
|
+
return;
|
|
1315
|
+
case "AssignmentPattern":
|
|
1316
|
+
patternNames(pattern.left, into);
|
|
1317
|
+
return;
|
|
1318
|
+
case "RestElement":
|
|
1319
|
+
patternNames(pattern.argument, into);
|
|
1320
|
+
return;
|
|
1321
|
+
case "TSParameterProperty":
|
|
1322
|
+
patternNames(pattern.parameter, into);
|
|
1323
|
+
return;
|
|
1324
|
+
}
|
|
1325
|
+
}
|
|
1326
|
+
|
|
1327
|
+
/** The names declared by the statements directly in a block's body. */
|
|
1328
|
+
function blockNames(statements, into) {
|
|
1329
|
+
var _iterator = _createForOfIteratorHelper(statements),
|
|
1330
|
+
_step;
|
|
1331
|
+
try {
|
|
1332
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
1333
|
+
var statement = _step.value;
|
|
1334
|
+
var declaration = statement.type === "ExportNamedDeclaration" ? statement.declaration : statement;
|
|
1335
|
+
if (!declaration) continue;
|
|
1336
|
+
if (declaration.type === "VariableDeclaration") for (var _i6 = 0, _arr6 = declaration.declarations; _i6 < _arr6.length; _i6++) {
|
|
1337
|
+
var declarator = _arr6[_i6];
|
|
1338
|
+
patternNames(declarator.id, into);
|
|
1339
|
+
} else if ((declaration.type === "FunctionDeclaration" || declaration.type === "ClassDeclaration") && declaration.id) into.add(String(declaration.id.name));
|
|
1340
|
+
}
|
|
1341
|
+
} catch (err) {
|
|
1342
|
+
_iterator.e(err);
|
|
1343
|
+
} finally {
|
|
1344
|
+
_iterator.f();
|
|
1345
|
+
}
|
|
1346
|
+
}
|
|
1347
|
+
|
|
1348
|
+
/**
|
|
1349
|
+
* Whether some scope between `stack`'s root and here declares `name`, so a
|
|
1350
|
+
* read of it here is NOT the import.
|
|
1351
|
+
*
|
|
1352
|
+
* The module scope itself is skipped: a top-level declaration sharing an
|
|
1353
|
+
* import's name is a redeclaration error, not a shadow. What this does not
|
|
1354
|
+
* see is a `var` hoisted out of a nested block into its function -- which
|
|
1355
|
+
* errs toward keeping an element, never toward removing a user's own one.
|
|
1356
|
+
*/
|
|
1357
|
+
function isShadowed(name, stack) {
|
|
1358
|
+
var _scope$init, _scope$left;
|
|
1359
|
+
var _iterator2 = _createForOfIteratorHelper(stack),
|
|
1360
|
+
_step2;
|
|
1361
|
+
try {
|
|
1362
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
1363
|
+
var scope = _step2.value;
|
|
1364
|
+
var declared = new Set();
|
|
1365
|
+
switch (scope.type) {
|
|
1366
|
+
case "FunctionDeclaration":
|
|
1367
|
+
case "FunctionExpression":
|
|
1368
|
+
case "ArrowFunctionExpression":
|
|
1369
|
+
for (var _i7 = 0, _arr7 = scope.params; _i7 < _arr7.length; _i7++) {
|
|
1370
|
+
var param = _arr7[_i7];
|
|
1371
|
+
patternNames(param, declared);
|
|
1372
|
+
}
|
|
1373
|
+
// A function expression's own name is in scope inside it.
|
|
1374
|
+
if (scope.type === "FunctionExpression" && scope.id) declared.add(String(scope.id.name));
|
|
1375
|
+
break;
|
|
1376
|
+
case "BlockStatement":
|
|
1377
|
+
case "StaticBlock":
|
|
1378
|
+
blockNames(scope.body, declared);
|
|
1379
|
+
break;
|
|
1380
|
+
case "SwitchStatement":
|
|
1381
|
+
for (var _i8 = 0, _arr8 = scope.cases; _i8 < _arr8.length; _i8++) {
|
|
1382
|
+
var branch = _arr8[_i8];
|
|
1383
|
+
blockNames(branch.consequent, declared);
|
|
1384
|
+
}
|
|
1385
|
+
break;
|
|
1386
|
+
case "ForStatement":
|
|
1387
|
+
if (((_scope$init = scope.init) === null || _scope$init === void 0 ? void 0 : _scope$init.type) === "VariableDeclaration") blockNames([scope.init], declared);
|
|
1388
|
+
break;
|
|
1389
|
+
case "ForInStatement":
|
|
1390
|
+
case "ForOfStatement":
|
|
1391
|
+
if (((_scope$left = scope.left) === null || _scope$left === void 0 ? void 0 : _scope$left.type) === "VariableDeclaration") blockNames([scope.left], declared);
|
|
1392
|
+
break;
|
|
1393
|
+
case "CatchClause":
|
|
1394
|
+
patternNames(scope.param, declared);
|
|
1395
|
+
break;
|
|
1396
|
+
case "ClassExpression":
|
|
1397
|
+
if (scope.id) declared.add(String(scope.id.name));
|
|
1398
|
+
break;
|
|
1399
|
+
}
|
|
1400
|
+
if (declared.has(name)) return true;
|
|
1401
|
+
}
|
|
1402
|
+
} catch (err) {
|
|
1403
|
+
_iterator2.e(err);
|
|
1404
|
+
} finally {
|
|
1405
|
+
_iterator2.f();
|
|
1406
|
+
}
|
|
1407
|
+
return false;
|
|
1408
|
+
}
|
|
1409
|
+
|
|
1410
|
+
/**
|
|
1411
|
+
* Whether this element is one of the imported devtools components.
|
|
1412
|
+
*
|
|
1413
|
+
* By binding, not by spelling: a lower-case name is an intrinsic element
|
|
1414
|
+
* whatever is in scope (`import { TanStackDevtools as div }` does not make
|
|
1415
|
+
* `<div>` a devtools), and a name some enclosing scope redeclares is that
|
|
1416
|
+
* scope's, not the import's.
|
|
1417
|
+
*/
|
|
1418
|
+
function isDevtoolsElement(opening, names, stack) {
|
|
1419
|
+
var name = opening.name;
|
|
1420
|
+
var root = name.type === "JSXIdentifier" ? String(name.name) : name.type === "JSXMemberExpression" && name.object.type === "JSXIdentifier" ? String(name.object.name) : null;
|
|
1421
|
+
if (root === null || !names.has(root)) return false;
|
|
1422
|
+
// Only a bare name is subject to the intrinsic rule: `<d.Panel>` is a member
|
|
1423
|
+
// read of `d` whatever its case.
|
|
1424
|
+
if (name.type === "JSXIdentifier" && /^[a-z]/.test(root)) return false;
|
|
1425
|
+
return !isShadowed(root, stack);
|
|
1426
|
+
}
|
|
1427
|
+
|
|
1428
|
+
/**
|
|
1429
|
+
* Edits whose range sits inside another edit's are dropped.
|
|
1430
|
+
*
|
|
1431
|
+
* MagicString, which upstream splices with, tolerates overlapping removals;
|
|
1432
|
+
* `applyEdits` does not, and a devtools element nested inside another one --
|
|
1433
|
+
* or inside a panel being removed -- would otherwise splice twice.
|
|
1434
|
+
*/
|
|
1435
|
+
function outermost(edits) {
|
|
1436
|
+
return edits.filter(function (edit) {
|
|
1437
|
+
return !edits.some(function (other) {
|
|
1438
|
+
return other !== edit && other.start <= edit.start && other.end >= edit.end && (other.start < edit.start || other.end > edit.end);
|
|
1439
|
+
});
|
|
1440
|
+
});
|
|
1441
|
+
}
|
|
1442
|
+
|
|
1443
|
+
/**
|
|
1444
|
+
* Whether `node` -- an identifier named like a binding -- is a READ of it,
|
|
1445
|
+
* rather than a name in some other role: a non-computed property or key, a JSX
|
|
1446
|
+
* attribute name, the right half of `<A.B>`.
|
|
1447
|
+
*/
|
|
1448
|
+
function isReference(node, parent) {
|
|
1449
|
+
if (!parent) return true;
|
|
1450
|
+
switch (parent.type) {
|
|
1451
|
+
case "MemberExpression":
|
|
1452
|
+
return parent.object === node || parent.computed;
|
|
1453
|
+
case "JSXMemberExpression":
|
|
1454
|
+
return parent.object === node;
|
|
1455
|
+
case "Property":
|
|
1456
|
+
case "MethodDefinition":
|
|
1457
|
+
case "PropertyDefinition":
|
|
1458
|
+
// A shorthand `{ X }` has its own value node, which is the read.
|
|
1459
|
+
return parent.key !== node || parent.computed;
|
|
1460
|
+
case "JSXAttribute":
|
|
1461
|
+
return parent.name !== node;
|
|
1462
|
+
case "JSXOpeningElement":
|
|
1463
|
+
case "JSXClosingElement":
|
|
1464
|
+
// `<div>` is an intrinsic element, never a read of a binding named div.
|
|
1465
|
+
return !/^[a-z]/.test(String(node.name));
|
|
1466
|
+
default:
|
|
1467
|
+
return true;
|
|
1468
|
+
}
|
|
1469
|
+
}
|
|
1470
|
+
|
|
1471
|
+
/**
|
|
1472
|
+
* The local names in `names` read anywhere outside `removed`.
|
|
1473
|
+
*
|
|
1474
|
+
* Import declarations are not walked: a specifier is a binding, not a read, and
|
|
1475
|
+
* every one of them is either being removed or being kept anyway.
|
|
1476
|
+
*/
|
|
1477
|
+
function readOutside(ast, names, removed) {
|
|
1478
|
+
var found = new Set();
|
|
1479
|
+
var inRemoved = function inRemoved(node) {
|
|
1480
|
+
return removed.some(function (edit) {
|
|
1481
|
+
return edit.start <= node.start && node.end <= edit.end;
|
|
1482
|
+
});
|
|
1483
|
+
};
|
|
1484
|
+
for (var _i9 = 0, _arr9 = ast.body; _i9 < _arr9.length; _i9++) {
|
|
1485
|
+
var statement = _arr9[_i9];
|
|
1486
|
+
if (statement.type === "ImportDeclaration") continue;
|
|
1487
|
+
walk(statement, function (node, stack) {
|
|
1488
|
+
if (node.type !== "Identifier" && node.type !== "JSXIdentifier") return;
|
|
1489
|
+
var name = String(node.name);
|
|
1490
|
+
if (!names.has(name) || found.has(name)) return;
|
|
1491
|
+
if (!isReference(node, stack[stack.length - 1])) return;
|
|
1492
|
+
// A read of some inner scope's binding of the same name is not a read
|
|
1493
|
+
// of the import, and must not turn its removal into a stub.
|
|
1494
|
+
if (isShadowed(name, stack)) return;
|
|
1495
|
+
if (!inRemoved(node)) found.add(name);
|
|
1496
|
+
});
|
|
1497
|
+
}
|
|
1498
|
+
return found;
|
|
1499
|
+
}
|
|
1500
|
+
|
|
1501
|
+
/**
|
|
1502
|
+
* What a devtools binding becomes when something besides a removed element
|
|
1503
|
+
* still reads it: a component that renders nothing, or a namespace of them.
|
|
1504
|
+
*/
|
|
1505
|
+
function stubFor(specifier) {
|
|
1506
|
+
var local = String(specifier.local.name);
|
|
1507
|
+
return specifier.type === "ImportNamespaceSpecifier" ? "const ".concat(local, " = new Proxy({}, { get: () => () => null });") : "const ".concat(local, " = () => null;");
|
|
1508
|
+
}
|
|
1509
|
+
|
|
1510
|
+
/**
|
|
1511
|
+
* Strips TanStack Devtools from one module.
|
|
1512
|
+
*
|
|
1513
|
+
* Both targets, as upstream does: the plugin applies to the client and the SSR
|
|
1514
|
+
* build alike. Returns `null` when there is nothing to remove, so the caller
|
|
1515
|
+
* leaves the module alone and pays no parse.
|
|
1516
|
+
*/
|
|
1517
|
+
function transformRemoveDevtools(_x, _x2) {
|
|
1518
|
+
return _transformRemoveDevtools.apply(this, arguments);
|
|
1519
|
+
}
|
|
1520
|
+
function _transformRemoveDevtools() {
|
|
1521
|
+
_transformRemoveDevtools = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(moduleId, code) {
|
|
1522
|
+
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;
|
|
1523
|
+
return _regenerator().w(function (_context2) {
|
|
1524
|
+
while (1) switch (_context2.p = _context2.n) {
|
|
1525
|
+
case 0:
|
|
1526
|
+
if (TANSTACK_DEVTOOLS_PACKAGES.some(function (pkg) {
|
|
1527
|
+
return code.includes(pkg);
|
|
1528
|
+
})) {
|
|
1529
|
+
_context2.n = 1;
|
|
1530
|
+
break;
|
|
1531
|
+
}
|
|
1532
|
+
return _context2.a(2, null);
|
|
1533
|
+
case 1:
|
|
1534
|
+
_context2.p = 1;
|
|
1535
|
+
_context2.n = 2;
|
|
1536
|
+
return parse(moduleId, code);
|
|
1537
|
+
case 2:
|
|
1538
|
+
ast = _context2.v;
|
|
1539
|
+
_context2.n = 4;
|
|
1540
|
+
break;
|
|
1541
|
+
case 3:
|
|
1542
|
+
_context2.p = 3;
|
|
1543
|
+
_context2.v;
|
|
1544
|
+
return _context2.a(2, null);
|
|
1545
|
+
case 4:
|
|
1546
|
+
devtoolsImports = ast.body.filter(function (statement) {
|
|
1547
|
+
var _statement$source;
|
|
1548
|
+
return statement.type === "ImportDeclaration" && isDevtoolsImport((_statement$source = statement.source) === null || _statement$source === void 0 ? void 0 : _statement$source.value);
|
|
1549
|
+
});
|
|
1550
|
+
if (!(devtoolsImports.length === 0)) {
|
|
1551
|
+
_context2.n = 5;
|
|
1552
|
+
break;
|
|
1553
|
+
}
|
|
1554
|
+
return _context2.a(2, null);
|
|
1555
|
+
case 5:
|
|
1556
|
+
devtoolsNames = new Set();
|
|
1557
|
+
_iterator3 = _createForOfIteratorHelper(devtoolsImports);
|
|
1558
|
+
try {
|
|
1559
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
1560
|
+
statement = _step3.value;
|
|
1561
|
+
for (_i1 = 0, _arr1 = (_statement$specifiers2 = statement.specifiers) !== null && _statement$specifiers2 !== void 0 ? _statement$specifiers2 : []; _i1 < _arr1.length; _i1++) {
|
|
1562
|
+
specifier = _arr1[_i1];
|
|
1563
|
+
devtoolsNames.add(String(specifier.local.name));
|
|
1564
|
+
}
|
|
1565
|
+
}
|
|
1566
|
+
|
|
1567
|
+
// The elements first: whether an import can simply go depends on whether
|
|
1568
|
+
// anything outside them still reads its names.
|
|
1569
|
+
} catch (err) {
|
|
1570
|
+
_iterator3.e(err);
|
|
1571
|
+
} finally {
|
|
1572
|
+
_iterator3.f();
|
|
1573
|
+
}
|
|
1574
|
+
elements = [];
|
|
1575
|
+
panels = new Set();
|
|
1576
|
+
if (devtoolsNames.size > 0) {
|
|
1577
|
+
walk(ast, function (node, stack) {
|
|
1578
|
+
if (node.type !== "JSXElement") return;
|
|
1579
|
+
var opening = node.openingElement;
|
|
1580
|
+
if (!isDevtoolsElement(opening, devtoolsNames, stack)) return;
|
|
1581
|
+
var _iterator4 = _createForOfIteratorHelper(pluginReferences(opening)),
|
|
1582
|
+
_step4;
|
|
1583
|
+
try {
|
|
1584
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
1585
|
+
var panel = _step4.value;
|
|
1586
|
+
panels.add(panel);
|
|
1587
|
+
}
|
|
1588
|
+
} catch (err) {
|
|
1589
|
+
_iterator4.e(err);
|
|
1590
|
+
} finally {
|
|
1591
|
+
_iterator4.f();
|
|
1592
|
+
}
|
|
1593
|
+
var parent = stack[stack.length - 1];
|
|
1594
|
+
// Only a JSX child can simply vanish, and take its line with it.
|
|
1595
|
+
// Anywhere else -- a return, a `&&`, an initialiser -- the element is an
|
|
1596
|
+
// expression and needs a stand-in, which must end where the element
|
|
1597
|
+
// did: the newline after it may be the only thing ending the statement.
|
|
1598
|
+
var inJsx = (parent === null || parent === void 0 ? void 0 : parent.type) === "JSXElement" || (parent === null || parent === void 0 ? void 0 : parent.type) === "JSXFragment";
|
|
1599
|
+
elements.push(inJsx ? {
|
|
1600
|
+
start: node.start,
|
|
1601
|
+
end: endOfLine(code, node),
|
|
1602
|
+
text: ""
|
|
1603
|
+
} : {
|
|
1604
|
+
start: node.start,
|
|
1605
|
+
end: node.end,
|
|
1606
|
+
text: "null"
|
|
1607
|
+
});
|
|
1608
|
+
});
|
|
1609
|
+
}
|
|
1610
|
+
removed = outermost(elements);
|
|
1611
|
+
stillRead = readOutside(ast, new Set([].concat(_toConsumableArray(devtoolsNames), _toConsumableArray(panels))), removed);
|
|
1612
|
+
edits = _toConsumableArray(removed);
|
|
1613
|
+
_iterator5 = _createForOfIteratorHelper(devtoolsImports);
|
|
1614
|
+
try {
|
|
1615
|
+
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
1616
|
+
_statement = _step5.value;
|
|
1617
|
+
stubs = ((_statement$specifiers3 = _statement.specifiers) !== null && _statement$specifiers3 !== void 0 ? _statement$specifiers3 : []).filter(function (specifier) {
|
|
1618
|
+
return stillRead.has(String(specifier.local.name));
|
|
1619
|
+
}).map(stubFor);
|
|
1620
|
+
edits.push(stubs.length > 0 ? {
|
|
1621
|
+
start: _statement.start,
|
|
1622
|
+
end: _statement.end,
|
|
1623
|
+
text: stubs.join(" ")
|
|
1624
|
+
} : {
|
|
1625
|
+
start: _statement.start,
|
|
1626
|
+
end: endOfLine(code, _statement),
|
|
1627
|
+
text: ""
|
|
1628
|
+
});
|
|
1629
|
+
}
|
|
1630
|
+
} catch (err) {
|
|
1631
|
+
_iterator5.e(err);
|
|
1632
|
+
} finally {
|
|
1633
|
+
_iterator5.f();
|
|
1634
|
+
}
|
|
1635
|
+
if (!(panels.size > 0)) {
|
|
1636
|
+
_context2.n = 9;
|
|
1637
|
+
break;
|
|
1638
|
+
}
|
|
1639
|
+
_loop = /*#__PURE__*/_regenerator().m(function _loop() {
|
|
1640
|
+
var _statement$source2, _statement$specifiers;
|
|
1641
|
+
var statement, specifiers, dropped, remaining, text, defaults, named, clause;
|
|
1642
|
+
return _regenerator().w(function (_context) {
|
|
1643
|
+
while (1) switch (_context.n) {
|
|
1644
|
+
case 0:
|
|
1645
|
+
statement = _arr0[_i0];
|
|
1646
|
+
if (!(statement.type !== "ImportDeclaration")) {
|
|
1647
|
+
_context.n = 1;
|
|
1648
|
+
break;
|
|
1649
|
+
}
|
|
1650
|
+
return _context.a(2, 0);
|
|
1651
|
+
case 1:
|
|
1652
|
+
if (!isDevtoolsImport((_statement$source2 = statement.source) === null || _statement$source2 === void 0 ? void 0 : _statement$source2.value)) {
|
|
1653
|
+
_context.n = 2;
|
|
1654
|
+
break;
|
|
1655
|
+
}
|
|
1656
|
+
return _context.a(2, 0);
|
|
1657
|
+
case 2:
|
|
1658
|
+
specifiers = (_statement$specifiers = statement.specifiers) !== null && _statement$specifiers !== void 0 ? _statement$specifiers : [];
|
|
1659
|
+
dropped = specifiers.filter(function (specifier) {
|
|
1660
|
+
var local = String(specifier.local.name);
|
|
1661
|
+
return specifier.type !== "ImportNamespaceSpecifier" && panels.has(local) && !stillRead.has(local);
|
|
1662
|
+
});
|
|
1663
|
+
if (!(dropped.length === 0)) {
|
|
1664
|
+
_context.n = 3;
|
|
1665
|
+
break;
|
|
1666
|
+
}
|
|
1667
|
+
return _context.a(2, 0);
|
|
1668
|
+
case 3:
|
|
1669
|
+
remaining = specifiers.filter(function (s) {
|
|
1670
|
+
return !dropped.includes(s);
|
|
1671
|
+
});
|
|
1672
|
+
if (!(remaining.length === 0)) {
|
|
1673
|
+
_context.n = 4;
|
|
1674
|
+
break;
|
|
1675
|
+
}
|
|
1676
|
+
edits.push({
|
|
1677
|
+
start: statement.start,
|
|
1678
|
+
end: endOfLine(code, statement),
|
|
1679
|
+
text: ""
|
|
1680
|
+
});
|
|
1681
|
+
return _context.a(2, 0);
|
|
1682
|
+
case 4:
|
|
1683
|
+
text = function text(node) {
|
|
1684
|
+
return code.slice(node.start, node.end);
|
|
1685
|
+
};
|
|
1686
|
+
defaults = remaining.filter(function (s) {
|
|
1687
|
+
return s.type !== "ImportSpecifier";
|
|
1688
|
+
}).map(text);
|
|
1689
|
+
named = remaining.filter(function (s) {
|
|
1690
|
+
return s.type === "ImportSpecifier";
|
|
1691
|
+
}).map(text);
|
|
1692
|
+
clause = [].concat(_toConsumableArray(defaults), _toConsumableArray(named.length > 0 ? ["{ ".concat(named.join(", "), " }")] : [])).join(", ");
|
|
1693
|
+
edits.push({
|
|
1694
|
+
start: statement.start,
|
|
1695
|
+
end: statement.end,
|
|
1696
|
+
text: "import ".concat(clause, " from ").concat(text(statement.source), ";")
|
|
1697
|
+
});
|
|
1698
|
+
case 5:
|
|
1699
|
+
return _context.a(2);
|
|
1700
|
+
}
|
|
1701
|
+
}, _loop);
|
|
1702
|
+
});
|
|
1703
|
+
_i0 = 0, _arr0 = ast.body;
|
|
1704
|
+
case 6:
|
|
1705
|
+
if (!(_i0 < _arr0.length)) {
|
|
1706
|
+
_context2.n = 9;
|
|
1707
|
+
break;
|
|
1708
|
+
}
|
|
1709
|
+
return _context2.d(_regeneratorValues(_loop()), 7);
|
|
1710
|
+
case 7:
|
|
1711
|
+
_ret = _context2.v;
|
|
1712
|
+
if (!(_ret === 0)) {
|
|
1713
|
+
_context2.n = 8;
|
|
1714
|
+
break;
|
|
1715
|
+
}
|
|
1716
|
+
return _context2.a(3, 8);
|
|
1717
|
+
case 8:
|
|
1718
|
+
_i0++;
|
|
1719
|
+
_context2.n = 6;
|
|
1720
|
+
break;
|
|
1721
|
+
case 9:
|
|
1722
|
+
return _context2.a(2, {
|
|
1723
|
+
code: applyEdits(code, edits)
|
|
1724
|
+
});
|
|
1725
|
+
}
|
|
1726
|
+
}, _callee, null, [[1, 3]]);
|
|
1727
|
+
}));
|
|
1728
|
+
return _transformRemoveDevtools.apply(this, arguments);
|
|
1729
|
+
}
|
|
1730
|
+
|
|
1247
1731
|
/**
|
|
1248
1732
|
* The names Start deletes from the client build.
|
|
1249
1733
|
*
|
|
@@ -2377,7 +2861,7 @@ function projectPlugin(files, projectSource, splitter, cssModules, aliases, asse
|
|
|
2377
2861
|
*/
|
|
2378
2862
|
transform: function transform(code, id) {
|
|
2379
2863
|
return _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
|
|
2380
|
-
var half, _envMarkers, out, reference, serverFns, envMarkers, routeNodes;
|
|
2864
|
+
var half, _out, _devtools, _envMarkers, out, devtools, reference, serverFns, envMarkers, routeNodes;
|
|
2381
2865
|
return _regenerator().w(function (_context) {
|
|
2382
2866
|
while (1) switch (_context.n) {
|
|
2383
2867
|
case 0:
|
|
@@ -2402,48 +2886,66 @@ function projectPlugin(files, projectSource, splitter, cssModules, aliases, asse
|
|
|
2402
2886
|
*/
|
|
2403
2887
|
half = splitIdOf(id);
|
|
2404
2888
|
if (!half) {
|
|
2405
|
-
_context.n =
|
|
2889
|
+
_context.n = 3;
|
|
2406
2890
|
break;
|
|
2407
2891
|
}
|
|
2892
|
+
// Devtools too, for the same reason: `<TanStackDevtools>` sits in a
|
|
2893
|
+
// layout's component, which is what moves into this half.
|
|
2894
|
+
_out = code;
|
|
2408
2895
|
_context.n = 1;
|
|
2409
|
-
return
|
|
2896
|
+
return transformRemoveDevtools(half.path, _out);
|
|
2410
2897
|
case 1:
|
|
2898
|
+
_devtools = _context.v;
|
|
2899
|
+
if (_devtools) _out = _devtools.code;
|
|
2900
|
+
_context.n = 2;
|
|
2901
|
+
return transformEnvMarkers(half.path, _out, target);
|
|
2902
|
+
case 2:
|
|
2411
2903
|
_envMarkers = _context.v;
|
|
2412
|
-
|
|
2413
|
-
|
|
2904
|
+
if (_envMarkers) _out = _envMarkers.code;
|
|
2905
|
+
return _context.a(2, _out === code ? null : {
|
|
2906
|
+
code: _out,
|
|
2414
2907
|
map: null
|
|
2415
|
-
}
|
|
2416
|
-
case
|
|
2908
|
+
});
|
|
2909
|
+
case 3:
|
|
2417
2910
|
if (!(!(id in files) || isCss(id))) {
|
|
2418
|
-
_context.n =
|
|
2911
|
+
_context.n = 4;
|
|
2419
2912
|
break;
|
|
2420
2913
|
}
|
|
2421
2914
|
return _context.a(2, null);
|
|
2422
|
-
case
|
|
2915
|
+
case 4:
|
|
2423
2916
|
// Two passes rather than one shared parse: each bails out on a substring
|
|
2424
2917
|
// check before parsing, so a module that uses neither -- which is most of
|
|
2425
2918
|
// them -- is never parsed at all.
|
|
2426
|
-
out = code; //
|
|
2427
|
-
//
|
|
2919
|
+
out = code; // Before the split, as `@tanstack/devtools-vite` runs (`enforce: "pre"`):
|
|
2920
|
+
// the reference half then carries no devtools import. The deferred half
|
|
2921
|
+
// is built from the original source, so it runs again above.
|
|
2922
|
+
_context.n = 5;
|
|
2923
|
+
return transformRemoveDevtools(id, out);
|
|
2924
|
+
case 5:
|
|
2925
|
+
devtools = _context.v;
|
|
2926
|
+
if (devtools) out = devtools.code;
|
|
2927
|
+
// Then the split, because it decides what stays in this module at all:
|
|
2928
|
+
// the other passes should see the reference half, not code about to move
|
|
2929
|
+
// out of it.
|
|
2428
2930
|
if (splitter && isRouteFile(id)) {
|
|
2429
2931
|
reference = splitter.reference(id, out);
|
|
2430
2932
|
if (reference) out = reference.code;
|
|
2431
2933
|
}
|
|
2432
|
-
_context.n =
|
|
2934
|
+
_context.n = 6;
|
|
2433
2935
|
return transformServerFns(id, out, target, seenIds);
|
|
2434
|
-
case
|
|
2936
|
+
case 6:
|
|
2435
2937
|
serverFns = _context.v;
|
|
2436
2938
|
if (serverFns) out = serverFns.code;
|
|
2437
|
-
_context.n =
|
|
2939
|
+
_context.n = 7;
|
|
2438
2940
|
return transformEnvMarkers(id, out, target);
|
|
2439
|
-
case
|
|
2941
|
+
case 7:
|
|
2440
2942
|
envMarkers = _context.v;
|
|
2441
2943
|
if (envMarkers) out = envMarkers.code;
|
|
2442
2944
|
// Client only, and last: it deletes whole route options, so running it
|
|
2443
2945
|
// before the others would leave them rewriting code about to be removed.
|
|
2444
|
-
_context.n =
|
|
2946
|
+
_context.n = 8;
|
|
2445
2947
|
return transformRouteNodes(id, out, target);
|
|
2446
|
-
case
|
|
2948
|
+
case 8:
|
|
2447
2949
|
routeNodes = _context.v;
|
|
2448
2950
|
if (routeNodes) out = routeNodes.code;
|
|
2449
2951
|
return _context.a(2, out === code ? null : {
|
|
@@ -2486,10 +2988,34 @@ function defineFor(env, target, warnings) {
|
|
|
2486
2988
|
if (exposed) visible[key] = value;
|
|
2487
2989
|
}
|
|
2488
2990
|
|
|
2991
|
+
// Vite's built-ins, and they win over a project env var of the same name as
|
|
2992
|
+
// they do in Vite. Every build here is a production build -- it is what gets
|
|
2993
|
+
// published -- so these say what `vite build` would. Without them
|
|
2994
|
+
// `import.meta.env.PROD` read `undefined`, and `!import.meta.env.PROD &&
|
|
2995
|
+
// <Debug />` rendered on a published site while `vite build` dropped it.
|
|
2996
|
+
var builtins = {
|
|
2997
|
+
MODE: "production",
|
|
2998
|
+
DEV: false,
|
|
2999
|
+
PROD: true,
|
|
3000
|
+
SSR: target === "server",
|
|
3001
|
+
BASE_URL: "/"
|
|
3002
|
+
};
|
|
3003
|
+
for (var _i2 = 0, _Object$entries2 = Object.entries(builtins); _i2 < _Object$entries2.length; _i2++) {
|
|
3004
|
+
var _Object$entries2$_i = _slicedToArray(_Object$entries2[_i2], 2),
|
|
3005
|
+
_key = _Object$entries2$_i[0],
|
|
3006
|
+
_value = _Object$entries2$_i[1];
|
|
3007
|
+
define["import.meta.env.".concat(_key)] = JSON.stringify(_value);
|
|
3008
|
+
}
|
|
3009
|
+
// What Vite substitutes, and what the vendor layer already bakes into every
|
|
3010
|
+
// dependency (vendorLayer.ts). The project's own source was the one place
|
|
3011
|
+
// nobody set it, and rolldown's own default filled the gap with
|
|
3012
|
+
// "development" -- so a published site's code was told it was in dev.
|
|
3013
|
+
define["process.env.NODE_ENV"] = JSON.stringify("production");
|
|
3014
|
+
|
|
2489
3015
|
// Always defined, even when empty: it makes `import.meta.env` destructuring
|
|
2490
3016
|
// work and stops a bare reference from throwing. Specific keys above take
|
|
2491
3017
|
// precedence over this object.
|
|
2492
|
-
define["import.meta.env"] = JSON.stringify(visible);
|
|
3018
|
+
define["import.meta.env"] = JSON.stringify(_objectSpread2(_objectSpread2({}, visible), builtins));
|
|
2493
3019
|
return define;
|
|
2494
3020
|
}
|
|
2495
3021
|
function buildOnce(_x, _x2, _x3, _x4, _x5) {
|
|
@@ -2636,7 +3162,7 @@ function buildUserApp(_x6) {
|
|
|
2636
3162
|
function _buildUserApp() {
|
|
2637
3163
|
_buildUserApp = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(input) {
|
|
2638
3164
|
var _input$target$project;
|
|
2639
|
-
var warnings, started, rev, clientModules, assetUrls, assetFiles,
|
|
3165
|
+
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;
|
|
2640
3166
|
return _regenerator().w(function (_context3) {
|
|
2641
3167
|
while (1) switch (_context3.n) {
|
|
2642
3168
|
case 0:
|
|
@@ -2669,13 +3195,13 @@ function _buildUserApp() {
|
|
|
2669
3195
|
// disagreed with the client one would be a hydration mismatch on every image.
|
|
2670
3196
|
assetUrls = new Map();
|
|
2671
3197
|
assetFiles = {};
|
|
2672
|
-
|
|
3198
|
+
_i3 = 0, _Object$entries3 = Object.entries((_input$assets2 = input.assets) !== null && _input$assets2 !== void 0 ? _input$assets2 : {});
|
|
2673
3199
|
case 4:
|
|
2674
|
-
if (!(
|
|
3200
|
+
if (!(_i3 < _Object$entries3.length)) {
|
|
2675
3201
|
_context3.n = 7;
|
|
2676
3202
|
break;
|
|
2677
3203
|
}
|
|
2678
|
-
_Object$
|
|
3204
|
+
_Object$entries3$_i = _slicedToArray(_Object$entries3[_i3], 2), path = _Object$entries3$_i[0], base64 = _Object$entries3$_i[1];
|
|
2679
3205
|
_context3.n = 5;
|
|
2680
3206
|
return resolveAsset(path, base64);
|
|
2681
3207
|
case 5:
|
|
@@ -2683,7 +3209,7 @@ function _buildUserApp() {
|
|
|
2683
3209
|
assetUrls.set(path, resolved.url);
|
|
2684
3210
|
if (resolved.file) assetFiles[resolved.file.name] = resolved.file.base64;
|
|
2685
3211
|
case 6:
|
|
2686
|
-
|
|
3212
|
+
_i3++;
|
|
2687
3213
|
_context3.n = 4;
|
|
2688
3214
|
break;
|
|
2689
3215
|
case 7:
|
|
@@ -2761,8 +3287,8 @@ function _buildUserApp() {
|
|
|
2761
3287
|
// prefix is a convention of the project layout, and what the loader needs is
|
|
2762
3288
|
// the URL path.
|
|
2763
3289
|
publicFiles = {};
|
|
2764
|
-
for (
|
|
2765
|
-
_Object$
|
|
3290
|
+
for (_i4 = 0, _Object$entries4 = Object.entries((_input$publicFiles = input.publicFiles) !== null && _input$publicFiles !== void 0 ? _input$publicFiles : {}); _i4 < _Object$entries4.length; _i4++) {
|
|
3291
|
+
_Object$entries4$_i = _slicedToArray(_Object$entries4[_i4], 2), _path = _Object$entries4$_i[0], _base = _Object$entries4$_i[1];
|
|
2766
3292
|
publicFiles[_path.replace(/^public\//, "")] = _base;
|
|
2767
3293
|
}
|
|
2768
3294
|
_t3 = serverBuild.code;
|
|
@@ -3309,7 +3835,7 @@ var LEGACY_CONTROL_HOST = "platform.internal";
|
|
|
3309
3835
|
*/
|
|
3310
3836
|
var valServerSource = function valServerSource(_ref) {
|
|
3311
3837
|
var git = _ref.git;
|
|
3312
|
-
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");
|
|
3838
|
+
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 * The publish job this build was made for, when a Studio built it in a tab.\n *\n * A tab's build has no commit to bake -- the job's is minted at the seal, after\n * the build -- so this is how it says where it sits in the content service's\n * chain. Without it the service places it at whatever build is live, which is\n * a different build for a request this one is still serving when the pointer\n * moves. Set by the Studio (`rebakeGit`), `null` for any other build.\n */\nconst BUILT_FOR_JOB = 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 ...(BUILT_FOR_JOB !== null ? { publishJob: BUILT_FOR_JOB } : {}),\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");
|
|
3313
3839
|
};
|
|
3314
3840
|
|
|
3315
3841
|
/**
|
|
@@ -3354,6 +3880,48 @@ function wiredValServer(options) {
|
|
|
3354
3880
|
* and a build made from no commit are the same answer.
|
|
3355
3881
|
*/
|
|
3356
3882
|
var BUILT_FROM_LINE = /^const BUILT_FROM = (.+);$/m;
|
|
3883
|
+
|
|
3884
|
+
/** The line that carries the publish job, as {@link BUILT_FROM_LINE} the commit. */
|
|
3885
|
+
var BUILT_FOR_JOB_LINE = /^const BUILT_FOR_JOB = (.+);$/m;
|
|
3886
|
+
|
|
3887
|
+
/**
|
|
3888
|
+
* Where a file generated before {@link BUILT_FOR_JOB_LINE} existed hands
|
|
3889
|
+
* `http` its last option, which is where the job goes in one.
|
|
3890
|
+
*/
|
|
3891
|
+
var PROJECT_SOURCE_OPTION = " projectSource: FILES,\n";
|
|
3892
|
+
var PUBLISH_JOB_OPTION = " ...(BUILT_FOR_JOB !== null ? { publishJob: BUILT_FOR_JOB } : {}),\n";
|
|
3893
|
+
|
|
3894
|
+
/** The publish job a record is wired for: see `BUILT_FOR_JOB` in the template. */
|
|
3895
|
+
function bakedJob(files) {
|
|
3896
|
+
var source = files[VAL_SERVER];
|
|
3897
|
+
var match = source === undefined ? null : BUILT_FOR_JOB_LINE.exec(source);
|
|
3898
|
+
if (!(match !== null && match !== void 0 && match[1]) || match[1] === "null") return undefined;
|
|
3899
|
+
try {
|
|
3900
|
+
var parsed = JSON.parse(match[1]);
|
|
3901
|
+
return typeof parsed === "string" && parsed !== "" ? parsed : undefined;
|
|
3902
|
+
} catch (_unused) {
|
|
3903
|
+
return undefined;
|
|
3904
|
+
}
|
|
3905
|
+
}
|
|
3906
|
+
|
|
3907
|
+
/** `source` with its job set, or `source` itself when it cannot carry one. */
|
|
3908
|
+
function rebakeJob(source, job) {
|
|
3909
|
+
var line = "const BUILT_FOR_JOB = ".concat(job === null ? "null" : JSON.stringify(job), ";");
|
|
3910
|
+
if (BUILT_FOR_JOB_LINE.test(source)) return source.replace(BUILT_FOR_JOB_LINE, line);
|
|
3911
|
+
if (job === null) return source;
|
|
3912
|
+
/*
|
|
3913
|
+
* A file wired before the job existed: the line goes in under `BUILT_FROM`,
|
|
3914
|
+
* and the option beside `projectSource`. Only where both are exactly as
|
|
3915
|
+
* generated -- a file somebody edited is left as it is, and its build is
|
|
3916
|
+
* placed at the live build, which is what it was before.
|
|
3917
|
+
*/
|
|
3918
|
+
var at = source.indexOf(PROJECT_SOURCE_OPTION);
|
|
3919
|
+
if (at === -1 || source.indexOf(PROJECT_SOURCE_OPTION, at + 1) !== -1) return source;
|
|
3920
|
+
var withOption = source.slice(0, at + PROJECT_SOURCE_OPTION.length) + PUBLISH_JOB_OPTION + source.slice(at + PROJECT_SOURCE_OPTION.length);
|
|
3921
|
+
return withOption.replace(BUILT_FROM_LINE, function (built) {
|
|
3922
|
+
return "".concat(built, "\n").concat(line);
|
|
3923
|
+
});
|
|
3924
|
+
}
|
|
3357
3925
|
function bakedGit(files) {
|
|
3358
3926
|
var source = files[VAL_SERVER];
|
|
3359
3927
|
if (source === undefined) return undefined;
|
|
@@ -3381,7 +3949,7 @@ function bakedGit(files) {
|
|
|
3381
3949
|
commit: commit,
|
|
3382
3950
|
branch: branch
|
|
3383
3951
|
};
|
|
3384
|
-
} catch (
|
|
3952
|
+
} catch (_unused2) {
|
|
3385
3953
|
return undefined;
|
|
3386
3954
|
}
|
|
3387
3955
|
}
|
|
@@ -3408,11 +3976,17 @@ function bakedGit(files) {
|
|
|
3408
3976
|
* Non-destructive, like {@link wireUp}: the caller's record is what gets
|
|
3409
3977
|
* published back as source.
|
|
3410
3978
|
*/
|
|
3411
|
-
function rebakeGit(files, git
|
|
3979
|
+
function rebakeGit(files, git,
|
|
3980
|
+
/**
|
|
3981
|
+
* The publish job a tab is building this for, or `null`. A Studio that
|
|
3982
|
+
* predates jobs leaves it out, and the file keeps what it had.
|
|
3983
|
+
*/
|
|
3984
|
+
job) {
|
|
3412
3985
|
var source = files[VAL_SERVER];
|
|
3413
3986
|
if (source === undefined) return files;
|
|
3414
3987
|
if (!BUILT_FROM_LINE.test(source)) return files;
|
|
3415
|
-
|
|
3988
|
+
var withGit = source.replace(BUILT_FROM_LINE, "const BUILT_FROM = ".concat(git === null ? "null" : JSON.stringify(git), ";"));
|
|
3989
|
+
return _objectSpread2(_objectSpread2({}, files), {}, _defineProperty({}, VAL_SERVER, job === undefined ? withGit : rebakeJob(withGit, job)));
|
|
3416
3990
|
}
|
|
3417
3991
|
|
|
3418
3992
|
/** Is this a Val project at all? */
|
|
@@ -3490,7 +4064,7 @@ function wireUp(files, options) {
|
|
|
3490
4064
|
why: "it carries the Studio bundle and was only a transitive dependency; the vendor " + "layer is built from what the project declares"
|
|
3491
4065
|
});
|
|
3492
4066
|
}
|
|
3493
|
-
} catch (
|
|
4067
|
+
} catch (_unused3) {
|
|
3494
4068
|
warnings.push("package.json could not be parsed, so @valbuild/ui was not declared.");
|
|
3495
4069
|
}
|
|
3496
4070
|
}
|
|
@@ -3522,4 +4096,4 @@ function wireUp(files, options) {
|
|
|
3522
4096
|
};
|
|
3523
4097
|
}
|
|
3524
4098
|
|
|
3525
|
-
export { ENTRY_CHUNK, INLINE_LIMIT, PROJECT_SOURCE, PUBLIC_PREFIX, VAL_SERVER_PATH, aliasMap, bakedGit, base64Bytes, blobSha, buildUserApp, fetchBuildTarget, fetchBuildTargetRev, isAsset, isValProject, isWired, publishArtifacts, publishPayload, rebakeGit, resolveInFiles, scanCandidates, treeSha, treeShaOfText, usesTailwind, wireUp, wiredValServer };
|
|
4099
|
+
export { ENTRY_CHUNK, INLINE_LIMIT, PROJECT_SOURCE, PUBLIC_PREFIX, VAL_SERVER_PATH, aliasMap, bakedGit, bakedJob, base64Bytes, blobSha, buildUserApp, fetchBuildTarget, fetchBuildTargetRev, isAsset, isValProject, isWired, publishArtifacts, publishPayload, rebakeGit, resolveInFiles, scanCandidates, treeSha, treeShaOfText, usesTailwind, wireUp, wiredValServer };
|