@valbuild/tanstack-build 0.0.0 → 0.135.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +80 -0
- package/README.md +79 -2
- package/dist/declarations/src/assets.d.ts +34 -0
- package/dist/declarations/src/build.d.ts +260 -0
- package/dist/declarations/src/buildTarget.d.ts +44 -0
- package/dist/declarations/src/contract.d.ts +135 -0
- package/dist/declarations/src/gitTree.d.ts +20 -0
- package/dist/declarations/src/index.d.ts +33 -0
- package/dist/declarations/src/node/cssModules.d.ts +2 -0
- package/dist/declarations/src/node/index.d.ts +18 -0
- package/dist/declarations/src/node/nodeShims.d.ts +74 -0
- package/dist/declarations/src/node/routeSplitter.d.ts +14 -0
- package/dist/declarations/src/node/routes.d.ts +29 -0
- package/dist/declarations/src/node/vendorLayer.d.ts +175 -0
- package/dist/declarations/src/paths.d.ts +4 -0
- package/dist/declarations/src/projectPaths.d.ts +14 -0
- package/dist/declarations/src/routeSplit.d.ts +29 -0
- package/dist/declarations/src/tailwind.d.ts +59 -0
- package/dist/declarations/src/tsconfigPaths.d.ts +34 -0
- package/dist/declarations/src/wire.d.ts +95 -0
- package/dist/slicedToArray-44c37acc.esm.js +303 -0
- package/dist/slicedToArray-7afed0af.cjs.prod.js +310 -0
- package/dist/slicedToArray-80b0ffd7.cjs.dev.js +310 -0
- package/dist/valbuild-tanstack-build.cjs.d.ts +2 -0
- package/dist/valbuild-tanstack-build.cjs.dev.js +3431 -0
- package/dist/valbuild-tanstack-build.cjs.js +7 -0
- package/dist/valbuild-tanstack-build.cjs.prod.js +3431 -0
- package/dist/valbuild-tanstack-build.esm.js +3402 -0
- package/node/dist/valbuild-tanstack-build-node.cjs.d.ts +2 -0
- package/node/dist/valbuild-tanstack-build-node.cjs.dev.js +2204 -0
- package/node/dist/valbuild-tanstack-build-node.cjs.js +7 -0
- package/node/dist/valbuild-tanstack-build-node.cjs.prod.js +2204 -0
- package/node/dist/valbuild-tanstack-build-node.esm.js +2165 -0
- package/node/package.json +4 -0
- package/package.json +63 -6
|
@@ -0,0 +1,3431 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var slicedToArray = require('./slicedToArray-80b0ffd7.cjs.dev.js');
|
|
6
|
+
var browser = require('@rolldown/browser');
|
|
7
|
+
var parseAst = require('@rolldown/browser/parseAst');
|
|
8
|
+
var tailwindcss = require('tailwindcss');
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Paths the platform's contract fixes, in one place.
|
|
12
|
+
*
|
|
13
|
+
* These are not conventions this package chose -- `src/app.tsx` is the module
|
|
14
|
+
* the builder resolves as its entry, and `src/routeTree.gen.ts` is what
|
|
15
|
+
* TanStack's generator is configured to write. They are here so that a change
|
|
16
|
+
* on either side is one edit rather than a search for string literals.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/** The module the builder uses as the project's entry. */
|
|
20
|
+
var ENTRY = "src/app.tsx";
|
|
21
|
+
|
|
22
|
+
/** Where TanStack's generator writes the route tree. */
|
|
23
|
+
var TREE = "src/routeTree.gen.ts";
|
|
24
|
+
|
|
25
|
+
/** Where a file-based project keeps its route files. */
|
|
26
|
+
var ROUTES_DIR = "src/routes";
|
|
27
|
+
|
|
28
|
+
// A minimal posix path resolver. The builder runs in the browser, so node:path
|
|
29
|
+
// is unavailable, and pulling a polyfill in for two functions is not worth it.
|
|
30
|
+
|
|
31
|
+
function dirname(path) {
|
|
32
|
+
var i = path.lastIndexOf("/");
|
|
33
|
+
return i <= 0 ? "" : path.slice(0, i);
|
|
34
|
+
}
|
|
35
|
+
function resolve(from, to) {
|
|
36
|
+
var segments = to.startsWith("/") ? [] : from.split("/").filter(Boolean);
|
|
37
|
+
var _iterator = slicedToArray._createForOfIteratorHelper(to.split("/")),
|
|
38
|
+
_step;
|
|
39
|
+
try {
|
|
40
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
41
|
+
var segment = _step.value;
|
|
42
|
+
if (segment === "" || segment === ".") continue;
|
|
43
|
+
if (segment === "..") segments.pop();else segments.push(segment);
|
|
44
|
+
}
|
|
45
|
+
} catch (err) {
|
|
46
|
+
_iterator.e(err);
|
|
47
|
+
} finally {
|
|
48
|
+
_iterator.f();
|
|
49
|
+
}
|
|
50
|
+
return segments.join("/");
|
|
51
|
+
}
|
|
52
|
+
var EXTENSIONS = ["", ".tsx", ".ts", ".jsx", ".js", "/index.tsx", "/index.ts"];
|
|
53
|
+
|
|
54
|
+
/** Resolve a relative import against the in-memory file set. */
|
|
55
|
+
function resolveInFiles(base, files) {
|
|
56
|
+
var _iterator2 = slicedToArray._createForOfIteratorHelper(EXTENSIONS),
|
|
57
|
+
_step2;
|
|
58
|
+
try {
|
|
59
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
60
|
+
var extension = _step2.value;
|
|
61
|
+
var candidate = base + extension;
|
|
62
|
+
if (candidate in files) return candidate;
|
|
63
|
+
}
|
|
64
|
+
} catch (err) {
|
|
65
|
+
_iterator2.e(err);
|
|
66
|
+
} finally {
|
|
67
|
+
_iterator2.f();
|
|
68
|
+
}
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
var langOf = function langOf(path) {
|
|
73
|
+
return path.endsWith(".tsx") || path.endsWith(".jsx") ? "tsx" : "ts";
|
|
74
|
+
};
|
|
75
|
+
function parse(_x, _x2) {
|
|
76
|
+
return _parse.apply(this, arguments);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** Depth-first walk carrying a parent stack, nearest parent last. */
|
|
80
|
+
function _parse() {
|
|
81
|
+
_parse = slicedToArray._asyncToGenerator(/*#__PURE__*/slicedToArray._regenerator().m(function _callee(path, code) {
|
|
82
|
+
return slicedToArray._regenerator().w(function (_context) {
|
|
83
|
+
while (1) switch (_context.n) {
|
|
84
|
+
case 0:
|
|
85
|
+
_context.n = 1;
|
|
86
|
+
return parseAst.parseAstAsync(code, {
|
|
87
|
+
lang: langOf(path)
|
|
88
|
+
}, path);
|
|
89
|
+
case 1:
|
|
90
|
+
return _context.a(2, _context.v);
|
|
91
|
+
}
|
|
92
|
+
}, _callee);
|
|
93
|
+
}));
|
|
94
|
+
return _parse.apply(this, arguments);
|
|
95
|
+
}
|
|
96
|
+
function walk(node, visit) {
|
|
97
|
+
var stack = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
98
|
+
if (!node || typeof node.type !== "string") return;
|
|
99
|
+
visit(node, stack);
|
|
100
|
+
stack.push(node);
|
|
101
|
+
for (var _i = 0, _Object$keys = Object.keys(node); _i < _Object$keys.length; _i++) {
|
|
102
|
+
var _key = _Object$keys[_i];
|
|
103
|
+
if (_key === "type" || _key === "start" || _key === "end") continue;
|
|
104
|
+
var value = node[_key];
|
|
105
|
+
if (Array.isArray(value)) {
|
|
106
|
+
var _iterator = slicedToArray._createForOfIteratorHelper(value),
|
|
107
|
+
_step;
|
|
108
|
+
try {
|
|
109
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
110
|
+
var item = _step.value;
|
|
111
|
+
if (item && typeof item.type === "string") walk(item, visit, stack);
|
|
112
|
+
}
|
|
113
|
+
} catch (err) {
|
|
114
|
+
_iterator.e(err);
|
|
115
|
+
} finally {
|
|
116
|
+
_iterator.f();
|
|
117
|
+
}
|
|
118
|
+
} else if (value && typeof value.type === "string") {
|
|
119
|
+
walk(value, visit, stack);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
stack.pop();
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/** Applies edits end-first, so earlier offsets stay valid. */
|
|
126
|
+
function applyEdits(code, edits) {
|
|
127
|
+
var ordered = slicedToArray._toConsumableArray(edits).sort(function (a, b) {
|
|
128
|
+
return b.start - a.start || b.end - a.end;
|
|
129
|
+
});
|
|
130
|
+
var out = code;
|
|
131
|
+
var _iterator2 = slicedToArray._createForOfIteratorHelper(ordered),
|
|
132
|
+
_step2;
|
|
133
|
+
try {
|
|
134
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
135
|
+
var edit = _step2.value;
|
|
136
|
+
out = out.slice(0, edit.start) + edit.text + out.slice(edit.end);
|
|
137
|
+
}
|
|
138
|
+
} catch (err) {
|
|
139
|
+
_iterator2.e(err);
|
|
140
|
+
} finally {
|
|
141
|
+
_iterator2.f();
|
|
142
|
+
}
|
|
143
|
+
return out;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Local names imported from a TanStack package.
|
|
148
|
+
*
|
|
149
|
+
* The transforms key on names like `createIsomorphicFn`, and keying on the name
|
|
150
|
+
* alone would rewrite an unrelated local function that happens to share it.
|
|
151
|
+
* Start's compiler tracks imports for the same reason.
|
|
152
|
+
*/
|
|
153
|
+
function tanstackImports(ast) {
|
|
154
|
+
var names = new Set();
|
|
155
|
+
for (var _i2 = 0, _arr = ast.body; _i2 < _arr.length; _i2++) {
|
|
156
|
+
var _value, _statement$source;
|
|
157
|
+
var statement = _arr[_i2];
|
|
158
|
+
if (statement.type !== "ImportDeclaration") continue;
|
|
159
|
+
var source = String((_value = (_statement$source = statement.source) === null || _statement$source === void 0 ? void 0 : _statement$source.value) !== null && _value !== void 0 ? _value : "");
|
|
160
|
+
if (!source.startsWith("@tanstack/")) continue;
|
|
161
|
+
for (var _i3 = 0, _arr2 = (_statement$specifiers = statement.specifiers) !== null && _statement$specifiers !== void 0 ? _statement$specifiers : []; _i3 < _arr2.length; _i3++) {
|
|
162
|
+
var _statement$specifiers, _specifier$local;
|
|
163
|
+
var specifier = _arr2[_i3];
|
|
164
|
+
var local = (_specifier$local = specifier.local) === null || _specifier$local === void 0 ? void 0 : _specifier$local.name;
|
|
165
|
+
if (local) names.add(String(local));
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
return names;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/** Virtual module holding the per-build server-function registry. */
|
|
172
|
+
var REGISTRY_ID = "\0platform:server-fns";
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Populated as each defining module evaluates, read at request time.
|
|
176
|
+
*
|
|
177
|
+
* A mutable module-scoped object rather than something assembled in the entry,
|
|
178
|
+
* because a server function can be declared in any file. Ordering is not a
|
|
179
|
+
* concern: the whole user app is a single chunk (asserted in buildUserApp), so
|
|
180
|
+
* every module has evaluated long before a request arrives.
|
|
181
|
+
*/
|
|
182
|
+
var REGISTRY_SOURCE = "\nexport const __serverFns = {}\nexport function __register(id, fn) { __serverFns[id] = fn }\n";
|
|
183
|
+
|
|
184
|
+
/** Re-exported from the entry so the shell can reach it across the boundary. */
|
|
185
|
+
/** Cheap pre-filter for "does this module define a server function". */
|
|
186
|
+
var hasServerFn = function hasServerFn(code) {
|
|
187
|
+
return code.includes("createServerFn");
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* The entry for the RSC build.
|
|
192
|
+
*
|
|
193
|
+
* NOT the app. Under Start's RSC mode the `rsc` environment is the
|
|
194
|
+
* *server-function provider* -- `createStartHandler` forwards every server
|
|
195
|
+
* function call to it -- and that is the only job the bundle has here, because
|
|
196
|
+
* `renderServerComponent` is not supported yet.
|
|
197
|
+
*
|
|
198
|
+
* Building the app entry instead compiles the whole route tree under the
|
|
199
|
+
* `react-server` condition, where React has no hooks and no `createContext`.
|
|
200
|
+
* That works for a fixture with two components and fails for anything with a
|
|
201
|
+
* router in it: the first symptom is `createContext is not a function`, thrown
|
|
202
|
+
* from inside a vendor chunk, on the first server-function call.
|
|
203
|
+
*
|
|
204
|
+
* So the entry imports only the modules that register server functions. Each
|
|
205
|
+
* one registers itself as a side effect (see the transform below), and whatever
|
|
206
|
+
* they pull in comes with them -- including client components, which are
|
|
207
|
+
* replaced by reference stubs before this build sees them.
|
|
208
|
+
*/
|
|
209
|
+
function rscEntrySource(files) {
|
|
210
|
+
var modules = Object.keys(files).filter(function (path) {
|
|
211
|
+
return /\.(tsx?|jsx?)$/.test(path) && hasServerFn(files[path]);
|
|
212
|
+
}).sort();
|
|
213
|
+
return modules.map(function (path) {
|
|
214
|
+
return "import ".concat(JSON.stringify("./".concat(path)), "\n");
|
|
215
|
+
}).join("") + REGISTRY_REEXPORT;
|
|
216
|
+
}
|
|
217
|
+
var REGISTRY_REEXPORT = "\nexport { __serverFns } from ".concat(JSON.stringify(REGISTRY_ID), "\n");
|
|
218
|
+
var SERVER_RPC = "@tanstack/react-start/server-rpc";
|
|
219
|
+
var CLIENT_RPC = "@tanstack/react-start/client-rpc";
|
|
220
|
+
/**
|
|
221
|
+
* Ids must be identical across the two passes, since one produces the registry
|
|
222
|
+
* key and the other the URL that looks it up. Derived from the module id and
|
|
223
|
+
* the variable name, both of which are pass-independent.
|
|
224
|
+
*
|
|
225
|
+
* Readable rather than hashed, which is a deliberate spike choice: it makes a
|
|
226
|
+
* failed lookup self-explanatory. It also puts source paths in a public URL,
|
|
227
|
+
* so a real implementation should hash this -- the only property the rest of
|
|
228
|
+
* the system depends on is determinism.
|
|
229
|
+
*/
|
|
230
|
+
function makeId(moduleId, variableName, seen) {
|
|
231
|
+
var base = "".concat(moduleId, "--").concat(variableName).replace(/[^A-Za-z0-9_$]+/g, "_").replace(/^_+/, "");
|
|
232
|
+
var id = base;
|
|
233
|
+
var n = 1;
|
|
234
|
+
while (seen.has(id)) id = "".concat(base, "_").concat(++n);
|
|
235
|
+
seen.add(id);
|
|
236
|
+
return id;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* True for `createServerFn(...)` and any chain built on it --
|
|
241
|
+
* `.validator(...)`, `.middleware([...])` and so on.
|
|
242
|
+
*/
|
|
243
|
+
function isCreateServerFnChain(node) {
|
|
244
|
+
var current = node;
|
|
245
|
+
while (current && current.type === "CallExpression") {
|
|
246
|
+
var callee = current.callee;
|
|
247
|
+
if ((callee === null || callee === void 0 ? void 0 : callee.type) === "Identifier" && callee.name === "createServerFn") return true;
|
|
248
|
+
if ((callee === null || callee === void 0 ? void 0 : callee.type) === "MemberExpression") {
|
|
249
|
+
current = callee.object;
|
|
250
|
+
continue;
|
|
251
|
+
}
|
|
252
|
+
return false;
|
|
253
|
+
}
|
|
254
|
+
return false;
|
|
255
|
+
}
|
|
256
|
+
function findSites(ast, moduleId, code, seen) {
|
|
257
|
+
var sites = [];
|
|
258
|
+
var names = new Set();
|
|
259
|
+
walk(ast, function (node, stack) {
|
|
260
|
+
var _callee$property, _node$arguments, _declarator$id;
|
|
261
|
+
if (node.type !== "CallExpression") return;
|
|
262
|
+
var callee = node.callee;
|
|
263
|
+
if ((callee === null || callee === void 0 ? void 0 : callee.type) !== "MemberExpression") return;
|
|
264
|
+
if (((_callee$property = callee.property) === null || _callee$property === void 0 ? void 0 : _callee$property.name) !== "handler") return;
|
|
265
|
+
if (!isCreateServerFnChain(callee.object)) return;
|
|
266
|
+
var arg = (_node$arguments = node.arguments) === null || _node$arguments === void 0 ? void 0 : _node$arguments[0];
|
|
267
|
+
if (!arg) {
|
|
268
|
+
throw new Error("".concat(moduleId, ": createServerFn().handler() must be called with a function."));
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
// The extracted function has to reference the variable to reach
|
|
272
|
+
// __executeServer, so an unassigned call has nothing to hang off. Start
|
|
273
|
+
// enforces the same rule, with the same reasoning.
|
|
274
|
+
var declarator = slicedToArray._toConsumableArray(stack).reverse().find(function (parent) {
|
|
275
|
+
return parent.type === "VariableDeclarator";
|
|
276
|
+
});
|
|
277
|
+
var declarationIndex = stack.map(function (parent) {
|
|
278
|
+
return parent.type;
|
|
279
|
+
}).lastIndexOf("VariableDeclaration");
|
|
280
|
+
if (!declarator || declarationIndex === -1 || ((_declarator$id = declarator.id) === null || _declarator$id === void 0 ? void 0 : _declarator$id.type) !== "Identifier") {
|
|
281
|
+
throw new Error("".concat(moduleId, ": createServerFn() must be assigned to a plain `const` variable ") + "(found ".concat(declarator ? "a destructuring pattern" : "an unassigned call", ")."));
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
// `export const greet = ...` is an ExportNamedDeclaration *wrapping* the
|
|
285
|
+
// VariableDeclaration, so the declaration's own start is after the `export`
|
|
286
|
+
// keyword. Inserting there would put the extracted const between `export`
|
|
287
|
+
// and `const` -- which parses fine, exports the wrong binding, and shows up
|
|
288
|
+
// as "greet is not exported by src/api.ts" two modules away.
|
|
289
|
+
var parent = stack[declarationIndex - 1];
|
|
290
|
+
var statement = (parent === null || parent === void 0 ? void 0 : parent.type) === "ExportNamedDeclaration" ? parent : stack[declarationIndex];
|
|
291
|
+
var variableName = declarator.id.name;
|
|
292
|
+
var handlerName = "".concat(variableName, "_createServerFn_handler");
|
|
293
|
+
while (names.has(handlerName)) handlerName += "_";
|
|
294
|
+
names.add(handlerName);
|
|
295
|
+
sites.push({
|
|
296
|
+
id: makeId(moduleId, variableName, seen),
|
|
297
|
+
variableName: variableName,
|
|
298
|
+
handlerName: handlerName,
|
|
299
|
+
argStart: arg.start,
|
|
300
|
+
argEnd: arg.end,
|
|
301
|
+
declStart: statement.start,
|
|
302
|
+
declEnd: statement.end
|
|
303
|
+
});
|
|
304
|
+
});
|
|
305
|
+
return sites;
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* Rewrites one module for one target. Returns `null` when the module declares
|
|
309
|
+
* no server functions, so the caller can leave it untouched.
|
|
310
|
+
*/
|
|
311
|
+
function transformServerFns(_x, _x2, _x3, _x4) {
|
|
312
|
+
return _transformServerFns.apply(this, arguments);
|
|
313
|
+
}
|
|
314
|
+
function _transformServerFns() {
|
|
315
|
+
_transformServerFns = slicedToArray._asyncToGenerator(/*#__PURE__*/slicedToArray._regenerator().m(function _callee(moduleId, code, target, seen) {
|
|
316
|
+
var ast, sites, edits, _iterator, _step, site, meta, out, prelude;
|
|
317
|
+
return slicedToArray._regenerator().w(function (_context) {
|
|
318
|
+
while (1) switch (_context.n) {
|
|
319
|
+
case 0:
|
|
320
|
+
if (code.includes("createServerFn")) {
|
|
321
|
+
_context.n = 1;
|
|
322
|
+
break;
|
|
323
|
+
}
|
|
324
|
+
return _context.a(2, null);
|
|
325
|
+
case 1:
|
|
326
|
+
_context.n = 2;
|
|
327
|
+
return parse(moduleId, code);
|
|
328
|
+
case 2:
|
|
329
|
+
ast = _context.v;
|
|
330
|
+
sites = findSites(ast, moduleId, code, seen);
|
|
331
|
+
if (!(sites.length === 0)) {
|
|
332
|
+
_context.n = 3;
|
|
333
|
+
break;
|
|
334
|
+
}
|
|
335
|
+
return _context.a(2, null);
|
|
336
|
+
case 3:
|
|
337
|
+
edits = [];
|
|
338
|
+
_iterator = slicedToArray._createForOfIteratorHelper(sites);
|
|
339
|
+
try {
|
|
340
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
341
|
+
site = _step.value;
|
|
342
|
+
if (target === "server") {
|
|
343
|
+
meta = JSON.stringify({
|
|
344
|
+
id: site.id,
|
|
345
|
+
name: site.variableName,
|
|
346
|
+
filename: moduleId
|
|
347
|
+
});
|
|
348
|
+
edits.push({
|
|
349
|
+
start: site.declStart,
|
|
350
|
+
end: site.declStart,
|
|
351
|
+
text: "const ".concat(site.handlerName, " = __platformServerRpc(").concat(meta, ", ") + "(opts) => ".concat(site.variableName, ".__executeServer(opts));\n")
|
|
352
|
+
});
|
|
353
|
+
// Keep the implementation, and pass the extracted fn alongside it.
|
|
354
|
+
edits.push({
|
|
355
|
+
start: site.argStart,
|
|
356
|
+
end: site.argStart,
|
|
357
|
+
text: "".concat(site.handlerName, ", ")
|
|
358
|
+
});
|
|
359
|
+
edits.push({
|
|
360
|
+
start: site.declEnd,
|
|
361
|
+
end: site.declEnd,
|
|
362
|
+
text: "\n__platformRegister(".concat(JSON.stringify(site.id), ", ").concat(site.handlerName, ");")
|
|
363
|
+
});
|
|
364
|
+
} else {
|
|
365
|
+
// Drop the implementation entirely. Whatever it referenced and nothing
|
|
366
|
+
// else does goes with it when rolldown shakes the graph.
|
|
367
|
+
edits.push({
|
|
368
|
+
start: site.argStart,
|
|
369
|
+
end: site.argEnd,
|
|
370
|
+
text: "__platformClientRpc(".concat(JSON.stringify(site.id), ")")
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
} catch (err) {
|
|
375
|
+
_iterator.e(err);
|
|
376
|
+
} finally {
|
|
377
|
+
_iterator.f();
|
|
378
|
+
}
|
|
379
|
+
out = applyEdits(code, edits);
|
|
380
|
+
prelude = target === "server" ? "import { createServerRpc as __platformServerRpc } from ".concat(JSON.stringify(SERVER_RPC), ";\n") + "import { __register as __platformRegister } from ".concat(JSON.stringify(REGISTRY_ID), ";\n") : "import { createClientRpc as __platformClientRpc } from ".concat(JSON.stringify(CLIENT_RPC), ";\n");
|
|
381
|
+
return _context.a(2, {
|
|
382
|
+
code: prelude + out,
|
|
383
|
+
ids: sites.map(function (site) {
|
|
384
|
+
return site.id;
|
|
385
|
+
})
|
|
386
|
+
});
|
|
387
|
+
}
|
|
388
|
+
}, _callee);
|
|
389
|
+
}));
|
|
390
|
+
return _transformServerFns.apply(this, arguments);
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
// One sha256, used by the build hash and by asset content-addressing.
|
|
394
|
+
//
|
|
395
|
+
// `crypto.subtle` rather than node:crypto: the builder runs in a browser tab as
|
|
396
|
+
// well as in Node, and this is the only digest available in both.
|
|
397
|
+
function sha256Hex(_x) {
|
|
398
|
+
return _sha256Hex.apply(this, arguments);
|
|
399
|
+
}
|
|
400
|
+
function _sha256Hex() {
|
|
401
|
+
_sha256Hex = slicedToArray._asyncToGenerator(/*#__PURE__*/slicedToArray._regenerator().m(function _callee(text) {
|
|
402
|
+
var digest;
|
|
403
|
+
return slicedToArray._regenerator().w(function (_context) {
|
|
404
|
+
while (1) switch (_context.n) {
|
|
405
|
+
case 0:
|
|
406
|
+
_context.n = 1;
|
|
407
|
+
return crypto.subtle.digest("SHA-256", new TextEncoder().encode(text));
|
|
408
|
+
case 1:
|
|
409
|
+
digest = _context.v;
|
|
410
|
+
return _context.a(2, slicedToArray._toConsumableArray(new Uint8Array(digest)).map(function (_byte) {
|
|
411
|
+
return _byte.toString(16).padStart(2, "0");
|
|
412
|
+
}).join(""));
|
|
413
|
+
}
|
|
414
|
+
}, _callee);
|
|
415
|
+
}));
|
|
416
|
+
return _sha256Hex.apply(this, arguments);
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
var isCssModule = function isCssModule(path) {
|
|
420
|
+
return /\.module\.css$/.test(path.split("?")[0]);
|
|
421
|
+
};
|
|
422
|
+
|
|
423
|
+
/**
|
|
424
|
+
* Class selectors in a stylesheet.
|
|
425
|
+
*
|
|
426
|
+
* `.foo`, `.foo:hover`, `.a .b`, `.foo.bar` -- but not `.5rem` (a number), and
|
|
427
|
+
* not a class inside an at-rule prelude like `@media`.
|
|
428
|
+
*/
|
|
429
|
+
var CLASS_SELECTOR = /\.(-?[A-Za-z_][\w-]*)/g;
|
|
430
|
+
|
|
431
|
+
/** Directives this cannot honour, so they are reported instead of mis-scoped. */
|
|
432
|
+
var UNSUPPORTED$1 = [[/:global\b/, ":global() is not supported; the class would be scoped anyway"], [/^\s*composes\s*:/m, "composes: is not supported; the composed class is not merged"]];
|
|
433
|
+
/**
|
|
434
|
+
* Strips comments before scanning.
|
|
435
|
+
*
|
|
436
|
+
* A commented-out rule must not contribute a name to the mapping, and a comment
|
|
437
|
+
* is the one place a `.thing` reliably appears without being a selector.
|
|
438
|
+
*/
|
|
439
|
+
var withoutComments = function withoutComments(css) {
|
|
440
|
+
return css.replace(/\/\*[\s\S]*?\*\//g, "");
|
|
441
|
+
};
|
|
442
|
+
|
|
443
|
+
/**
|
|
444
|
+
* Rewrites one CSS module.
|
|
445
|
+
*
|
|
446
|
+
* The suffix comes from the file's path rather than its contents: the same
|
|
447
|
+
* module imported from two places must produce one set of names, and a
|
|
448
|
+
* content hash would also change every emitted class name on every edit.
|
|
449
|
+
*/
|
|
450
|
+
function transformCssModule(_x, _x2) {
|
|
451
|
+
return _transformCssModule.apply(this, arguments);
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
/** The JS module a CSS-module import becomes. */
|
|
455
|
+
function _transformCssModule() {
|
|
456
|
+
_transformCssModule = slicedToArray._asyncToGenerator(/*#__PURE__*/slicedToArray._regenerator().m(function _callee(path, css) {
|
|
457
|
+
var suffix, warnings, _iterator, _step, _step$value, pattern, message, names, scoped;
|
|
458
|
+
return slicedToArray._regenerator().w(function (_context) {
|
|
459
|
+
while (1) switch (_context.n) {
|
|
460
|
+
case 0:
|
|
461
|
+
_context.n = 1;
|
|
462
|
+
return sha256Hex(path);
|
|
463
|
+
case 1:
|
|
464
|
+
suffix = _context.v.slice(0, 8);
|
|
465
|
+
warnings = [];
|
|
466
|
+
_iterator = slicedToArray._createForOfIteratorHelper(UNSUPPORTED$1);
|
|
467
|
+
try {
|
|
468
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
469
|
+
_step$value = slicedToArray._slicedToArray(_step.value, 2), pattern = _step$value[0], message = _step$value[1];
|
|
470
|
+
if (pattern.test(css)) warnings.push("".concat(path, ": ").concat(message, "."));
|
|
471
|
+
}
|
|
472
|
+
} catch (err) {
|
|
473
|
+
_iterator.e(err);
|
|
474
|
+
} finally {
|
|
475
|
+
_iterator.f();
|
|
476
|
+
}
|
|
477
|
+
names = {};
|
|
478
|
+
scoped = withoutComments(css).replace(CLASS_SELECTOR, function (match, name) {
|
|
479
|
+
// A decimal like `.5rem` never reaches here -- the pattern requires a
|
|
480
|
+
// letter or underscore first -- but a property value like `1.5em` would
|
|
481
|
+
// match `.5em` without that guard, which is why it is there.
|
|
482
|
+
names[name] = "".concat(name, "_").concat(suffix);
|
|
483
|
+
return ".".concat(names[name]);
|
|
484
|
+
});
|
|
485
|
+
return _context.a(2, {
|
|
486
|
+
css: scoped,
|
|
487
|
+
names: names,
|
|
488
|
+
warnings: warnings
|
|
489
|
+
});
|
|
490
|
+
}
|
|
491
|
+
}, _callee);
|
|
492
|
+
}));
|
|
493
|
+
return _transformCssModule.apply(this, arguments);
|
|
494
|
+
}
|
|
495
|
+
var cssModuleExports = function cssModuleExports(names) {
|
|
496
|
+
return "export default ".concat(JSON.stringify(names, null, 2), "\n");
|
|
497
|
+
};
|
|
498
|
+
|
|
499
|
+
var CSS_EXTENSIONS = [".css"];
|
|
500
|
+
|
|
501
|
+
/**
|
|
502
|
+
* Vite query suffixes. `./styles.css?url` asks for the URL rather than the
|
|
503
|
+
* contents, but it still means "this stylesheet belongs to the page" -- so the
|
|
504
|
+
* CSS pass has to see through the query, or a project that links its own
|
|
505
|
+
* stylesheet gets an empty one.
|
|
506
|
+
*/
|
|
507
|
+
var withoutQuery = function withoutQuery(path) {
|
|
508
|
+
return path.split("?")[0];
|
|
509
|
+
};
|
|
510
|
+
var isCss = function isCss(path) {
|
|
511
|
+
return CSS_EXTENSIONS.some(function (ext) {
|
|
512
|
+
return withoutQuery(path).endsWith(ext);
|
|
513
|
+
});
|
|
514
|
+
};
|
|
515
|
+
/** Import sources of one module, in the order they appear in the source. */
|
|
516
|
+
function importsOf(_x, _x2) {
|
|
517
|
+
return _importsOf.apply(this, arguments);
|
|
518
|
+
}
|
|
519
|
+
function _importsOf() {
|
|
520
|
+
_importsOf = slicedToArray._asyncToGenerator(/*#__PURE__*/slicedToArray._regenerator().m(function _callee(path, code) {
|
|
521
|
+
var lang, ast, sources, _iterator, _step, statement, source;
|
|
522
|
+
return slicedToArray._regenerator().w(function (_context) {
|
|
523
|
+
while (1) switch (_context.n) {
|
|
524
|
+
case 0:
|
|
525
|
+
lang = path.endsWith(".tsx") || path.endsWith(".jsx") ? "tsx" : "ts";
|
|
526
|
+
_context.n = 1;
|
|
527
|
+
return parseAst.parseAstAsync(code, {
|
|
528
|
+
lang: lang
|
|
529
|
+
}, path);
|
|
530
|
+
case 1:
|
|
531
|
+
ast = _context.v;
|
|
532
|
+
sources = [];
|
|
533
|
+
_iterator = slicedToArray._createForOfIteratorHelper(ast.body);
|
|
534
|
+
try {
|
|
535
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
536
|
+
statement = _step.value;
|
|
537
|
+
// Static imports and re-exports both pull a module into the graph, and
|
|
538
|
+
// both can be the thing that drags a stylesheet in.
|
|
539
|
+
if (statement.type === "ImportDeclaration" || statement.type === "ExportNamedDeclaration" || statement.type === "ExportAllDeclaration") {
|
|
540
|
+
source = statement.source; // A type-only import contributes nothing at runtime, so it contributes
|
|
541
|
+
// no stylesheet either.
|
|
542
|
+
if (source !== null && source !== void 0 && source.value && statement.importKind !== "type" && statement.exportKind !== "type") {
|
|
543
|
+
sources.push(String(source.value));
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
} catch (err) {
|
|
548
|
+
_iterator.e(err);
|
|
549
|
+
} finally {
|
|
550
|
+
_iterator.f();
|
|
551
|
+
}
|
|
552
|
+
return _context.a(2, sources);
|
|
553
|
+
}
|
|
554
|
+
}, _callee);
|
|
555
|
+
}));
|
|
556
|
+
return _importsOf.apply(this, arguments);
|
|
557
|
+
}
|
|
558
|
+
/**
|
|
559
|
+
* Walks the module graph from the entry and concatenates every stylesheet it
|
|
560
|
+
* reaches, dependencies first.
|
|
561
|
+
*
|
|
562
|
+
* Only the user's own files are traversed: a bare specifier is a vendor
|
|
563
|
+
* external, and vendor chunks carry no CSS (the vendor build has no CSS
|
|
564
|
+
* pipeline either). A project that depends on a package shipping its own
|
|
565
|
+
* stylesheet is therefore not covered -- see the README.
|
|
566
|
+
*/
|
|
567
|
+
function collectCss(_x3, _x4) {
|
|
568
|
+
return _collectCss.apply(this, arguments);
|
|
569
|
+
}
|
|
570
|
+
function _collectCss() {
|
|
571
|
+
_collectCss = slicedToArray._asyncToGenerator(/*#__PURE__*/slicedToArray._regenerator().m(function _callee3(files, entry) {
|
|
572
|
+
var dependencyCss,
|
|
573
|
+
aliases,
|
|
574
|
+
visited,
|
|
575
|
+
sheets,
|
|
576
|
+
contributing,
|
|
577
|
+
modules,
|
|
578
|
+
warnings,
|
|
579
|
+
walk,
|
|
580
|
+
_walk,
|
|
581
|
+
_args3 = arguments;
|
|
582
|
+
return slicedToArray._regenerator().w(function (_context3) {
|
|
583
|
+
while (1) switch (_context3.n) {
|
|
584
|
+
case 0:
|
|
585
|
+
_walk = function _walk3() {
|
|
586
|
+
_walk = slicedToArray._asyncToGenerator(/*#__PURE__*/slicedToArray._regenerator().m(function _callee2(path) {
|
|
587
|
+
var _files$bare, bare, text, scoped, code, _iterator2, _step2, source, _aliases$candidates, _bare, aliased, _iterator3, _step3, candidate, hit, resolved, _t, _t2, _t3;
|
|
588
|
+
return slicedToArray._regenerator().w(function (_context2) {
|
|
589
|
+
while (1) switch (_context2.p = _context2.n) {
|
|
590
|
+
case 0:
|
|
591
|
+
if (!visited.has(path)) {
|
|
592
|
+
_context2.n = 1;
|
|
593
|
+
break;
|
|
594
|
+
}
|
|
595
|
+
return _context2.a(2);
|
|
596
|
+
case 1:
|
|
597
|
+
visited.add(path);
|
|
598
|
+
if (!isCss(path)) {
|
|
599
|
+
_context2.n = 5;
|
|
600
|
+
break;
|
|
601
|
+
}
|
|
602
|
+
bare = withoutQuery(path);
|
|
603
|
+
text = (_files$bare = files[bare]) !== null && _files$bare !== void 0 ? _files$bare : "";
|
|
604
|
+
if (!isCssModule(bare)) {
|
|
605
|
+
_context2.n = 3;
|
|
606
|
+
break;
|
|
607
|
+
}
|
|
608
|
+
_context2.n = 2;
|
|
609
|
+
return transformCssModule(bare, text);
|
|
610
|
+
case 2:
|
|
611
|
+
scoped = _context2.v;
|
|
612
|
+
modules[bare] = scoped.names;
|
|
613
|
+
warnings.push.apply(warnings, slicedToArray._toConsumableArray(scoped.warnings));
|
|
614
|
+
sheets.push(scoped.css);
|
|
615
|
+
_context2.n = 4;
|
|
616
|
+
break;
|
|
617
|
+
case 3:
|
|
618
|
+
sheets.push(text);
|
|
619
|
+
case 4:
|
|
620
|
+
contributing.push(bare);
|
|
621
|
+
return _context2.a(2);
|
|
622
|
+
case 5:
|
|
623
|
+
code = files[path];
|
|
624
|
+
if (!(code == null)) {
|
|
625
|
+
_context2.n = 6;
|
|
626
|
+
break;
|
|
627
|
+
}
|
|
628
|
+
return _context2.a(2);
|
|
629
|
+
case 6:
|
|
630
|
+
if (!(!code.includes("import") && !code.includes("export"))) {
|
|
631
|
+
_context2.n = 7;
|
|
632
|
+
break;
|
|
633
|
+
}
|
|
634
|
+
return _context2.a(2);
|
|
635
|
+
case 7:
|
|
636
|
+
_t = slicedToArray._createForOfIteratorHelper;
|
|
637
|
+
_context2.n = 8;
|
|
638
|
+
return importsOf(path, code);
|
|
639
|
+
case 8:
|
|
640
|
+
_iterator2 = _t(_context2.v);
|
|
641
|
+
_context2.p = 9;
|
|
642
|
+
_iterator2.s();
|
|
643
|
+
case 10:
|
|
644
|
+
if ((_step2 = _iterator2.n()).done) {
|
|
645
|
+
_context2.n = 22;
|
|
646
|
+
break;
|
|
647
|
+
}
|
|
648
|
+
source = _step2.value;
|
|
649
|
+
if (source.startsWith(".")) {
|
|
650
|
+
_context2.n = 20;
|
|
651
|
+
break;
|
|
652
|
+
}
|
|
653
|
+
// A bare specifier is a vendor external -- unless it names a
|
|
654
|
+
// stylesheet the layer carried across, in which case it contributes
|
|
655
|
+
// here just like one of the project's own.
|
|
656
|
+
_bare = withoutQuery(source);
|
|
657
|
+
if (!(isCss(_bare) && _bare in dependencyCss && !visited.has(_bare))) {
|
|
658
|
+
_context2.n = 11;
|
|
659
|
+
break;
|
|
660
|
+
}
|
|
661
|
+
visited.add(_bare);
|
|
662
|
+
sheets.push(dependencyCss[_bare]);
|
|
663
|
+
contributing.push(_bare);
|
|
664
|
+
return _context2.a(3, 21);
|
|
665
|
+
case 11:
|
|
666
|
+
// ...or a tsconfig alias, which is a bare specifier that names one of
|
|
667
|
+
// the project's own files.
|
|
668
|
+
aliased = [].concat(slicedToArray._toConsumableArray((_aliases$candidates = aliases === null || aliases === void 0 ? void 0 : aliases.candidates(_bare)) !== null && _aliases$candidates !== void 0 ? _aliases$candidates : []), slicedToArray._toConsumableArray(aliases !== null && aliases !== void 0 && aliases.baseUrlCandidate(_bare) ? [aliases.baseUrlCandidate(_bare)] : []));
|
|
669
|
+
_iterator3 = slicedToArray._createForOfIteratorHelper(aliased);
|
|
670
|
+
_context2.p = 12;
|
|
671
|
+
_iterator3.s();
|
|
672
|
+
case 13:
|
|
673
|
+
if ((_step3 = _iterator3.n()).done) {
|
|
674
|
+
_context2.n = 16;
|
|
675
|
+
break;
|
|
676
|
+
}
|
|
677
|
+
candidate = _step3.value;
|
|
678
|
+
hit = resolveInFiles(candidate, files);
|
|
679
|
+
if (!hit) {
|
|
680
|
+
_context2.n = 15;
|
|
681
|
+
break;
|
|
682
|
+
}
|
|
683
|
+
_context2.n = 14;
|
|
684
|
+
return walk(hit);
|
|
685
|
+
case 14:
|
|
686
|
+
return _context2.a(3, 16);
|
|
687
|
+
case 15:
|
|
688
|
+
_context2.n = 13;
|
|
689
|
+
break;
|
|
690
|
+
case 16:
|
|
691
|
+
_context2.n = 18;
|
|
692
|
+
break;
|
|
693
|
+
case 17:
|
|
694
|
+
_context2.p = 17;
|
|
695
|
+
_t2 = _context2.v;
|
|
696
|
+
_iterator3.e(_t2);
|
|
697
|
+
case 18:
|
|
698
|
+
_context2.p = 18;
|
|
699
|
+
_iterator3.f();
|
|
700
|
+
return _context2.f(18);
|
|
701
|
+
case 19:
|
|
702
|
+
return _context2.a(3, 21);
|
|
703
|
+
case 20:
|
|
704
|
+
// A `?url` import of a stylesheet still contributes it; see withoutQuery.
|
|
705
|
+
resolved = resolveInFiles(resolve(dirname(path), withoutQuery(source)), files);
|
|
706
|
+
if (!resolved) {
|
|
707
|
+
_context2.n = 21;
|
|
708
|
+
break;
|
|
709
|
+
}
|
|
710
|
+
_context2.n = 21;
|
|
711
|
+
return walk(resolved);
|
|
712
|
+
case 21:
|
|
713
|
+
_context2.n = 10;
|
|
714
|
+
break;
|
|
715
|
+
case 22:
|
|
716
|
+
_context2.n = 24;
|
|
717
|
+
break;
|
|
718
|
+
case 23:
|
|
719
|
+
_context2.p = 23;
|
|
720
|
+
_t3 = _context2.v;
|
|
721
|
+
_iterator2.e(_t3);
|
|
722
|
+
case 24:
|
|
723
|
+
_context2.p = 24;
|
|
724
|
+
_iterator2.f();
|
|
725
|
+
return _context2.f(24);
|
|
726
|
+
case 25:
|
|
727
|
+
return _context2.a(2);
|
|
728
|
+
}
|
|
729
|
+
}, _callee2, null, [[12, 17, 18, 19], [9, 23, 24, 25]]);
|
|
730
|
+
}));
|
|
731
|
+
return _walk.apply(this, arguments);
|
|
732
|
+
};
|
|
733
|
+
walk = function _walk2(_x5) {
|
|
734
|
+
return _walk.apply(this, arguments);
|
|
735
|
+
};
|
|
736
|
+
dependencyCss = _args3.length > 2 && _args3[2] !== undefined ? _args3[2] : {};
|
|
737
|
+
aliases = _args3.length > 3 && _args3[3] !== undefined ? _args3[3] : null;
|
|
738
|
+
visited = new Set();
|
|
739
|
+
sheets = [];
|
|
740
|
+
contributing = [];
|
|
741
|
+
modules = {};
|
|
742
|
+
warnings = [];
|
|
743
|
+
_context3.n = 1;
|
|
744
|
+
return walk(entry);
|
|
745
|
+
case 1:
|
|
746
|
+
return _context3.a(2, {
|
|
747
|
+
// A trailing newline per sheet so concatenated files cannot run together
|
|
748
|
+
// when the last rule has no terminator.
|
|
749
|
+
code: sheets.map(function (sheet) {
|
|
750
|
+
return sheet.trim();
|
|
751
|
+
}).filter(Boolean).join("\n"),
|
|
752
|
+
files: contributing,
|
|
753
|
+
modules: modules,
|
|
754
|
+
warnings: warnings
|
|
755
|
+
});
|
|
756
|
+
}
|
|
757
|
+
}, _callee3);
|
|
758
|
+
}));
|
|
759
|
+
return _collectCss.apply(this, arguments);
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
// GENERATED by packages/tanstack-build/scripts/tailwindSources.ts -- do not edit.
|
|
763
|
+
var TAILWIND_SOURCES = {
|
|
764
|
+
index: '@layer theme, base, components, utilities;\n\n@layer theme {\n @theme default {\n --font-sans:\n -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",\n "Noto Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji",\n "Segoe UI Symbol", "Noto Color Emoji";\n --font-serif: ui-serif, Georgia, Cambria, "Times New Roman", Times, serif;\n --font-mono:\n ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",\n "Courier New", monospace;\n\n --color-red-50: oklch(97.1% 0.013 17.38);\n --color-red-100: oklch(93.6% 0.032 17.717);\n --color-red-200: oklch(88.5% 0.062 18.334);\n --color-red-300: oklch(80.8% 0.114 19.571);\n --color-red-400: oklch(70.4% 0.191 22.216);\n --color-red-500: oklch(63.7% 0.237 25.331);\n --color-red-600: oklch(57.7% 0.245 27.325);\n --color-red-700: oklch(50.5% 0.213 27.518);\n --color-red-800: oklch(44.4% 0.177 26.899);\n --color-red-900: oklch(39.6% 0.141 25.723);\n --color-red-950: oklch(25.8% 0.092 26.042);\n\n --color-orange-50: oklch(98% 0.016 73.684);\n --color-orange-100: oklch(95.4% 0.038 75.164);\n --color-orange-200: oklch(90.1% 0.076 70.697);\n --color-orange-300: oklch(83.7% 0.128 66.29);\n --color-orange-400: oklch(75% 0.183 55.934);\n --color-orange-500: oklch(70.5% 0.213 47.604);\n --color-orange-600: oklch(64.6% 0.222 41.116);\n --color-orange-700: oklch(55.3% 0.195 38.402);\n --color-orange-800: oklch(47% 0.157 37.304);\n --color-orange-900: oklch(40.8% 0.123 38.172);\n --color-orange-950: oklch(26.6% 0.079 36.259);\n\n --color-amber-50: oklch(98.7% 0.022 95.277);\n --color-amber-100: oklch(96.2% 0.059 95.617);\n --color-amber-200: oklch(92.4% 0.12 95.746);\n --color-amber-300: oklch(87.9% 0.169 91.605);\n --color-amber-400: oklch(82.8% 0.189 84.429);\n --color-amber-500: oklch(76.9% 0.188 70.08);\n --color-amber-600: oklch(66.6% 0.179 58.318);\n --color-amber-700: oklch(55.5% 0.163 48.998);\n --color-amber-800: oklch(47.3% 0.137 46.201);\n --color-amber-900: oklch(41.4% 0.112 45.904);\n --color-amber-950: oklch(27.9% 0.077 45.635);\n\n --color-yellow-50: oklch(98.7% 0.026 102.212);\n --color-yellow-100: oklch(97.3% 0.071 103.193);\n --color-yellow-200: oklch(94.5% 0.129 101.54);\n --color-yellow-300: oklch(90.5% 0.182 98.111);\n --color-yellow-400: oklch(85.2% 0.199 91.936);\n --color-yellow-500: oklch(79.5% 0.184 86.047);\n --color-yellow-600: oklch(68.1% 0.162 75.834);\n --color-yellow-700: oklch(55.4% 0.135 66.442);\n --color-yellow-800: oklch(47.6% 0.114 61.907);\n --color-yellow-900: oklch(42.1% 0.095 57.708);\n --color-yellow-950: oklch(28.6% 0.066 53.813);\n\n --color-lime-50: oklch(98.6% 0.031 120.757);\n --color-lime-100: oklch(96.7% 0.067 122.328);\n --color-lime-200: oklch(93.8% 0.127 124.321);\n --color-lime-300: oklch(89.7% 0.196 126.665);\n --color-lime-400: oklch(84.1% 0.238 128.85);\n --color-lime-500: oklch(76.8% 0.233 130.85);\n --color-lime-600: oklch(64.8% 0.2 131.684);\n --color-lime-700: oklch(53.2% 0.157 131.589);\n --color-lime-800: oklch(45.3% 0.124 130.933);\n --color-lime-900: oklch(40.5% 0.101 131.063);\n --color-lime-950: oklch(27.4% 0.072 132.109);\n\n --color-green-50: oklch(98.2% 0.018 155.826);\n --color-green-100: oklch(96.2% 0.044 156.743);\n --color-green-200: oklch(92.5% 0.084 155.995);\n --color-green-300: oklch(87.1% 0.15 154.449);\n --color-green-400: oklch(79.2% 0.209 151.711);\n --color-green-500: oklch(72.3% 0.219 149.579);\n --color-green-600: oklch(62.7% 0.194 149.214);\n --color-green-700: oklch(52.7% 0.154 150.069);\n --color-green-800: oklch(44.8% 0.119 151.328);\n --color-green-900: oklch(39.3% 0.095 152.535);\n --color-green-950: oklch(26.6% 0.065 152.934);\n\n --color-emerald-50: oklch(97.9% 0.021 166.113);\n --color-emerald-100: oklch(95% 0.052 163.051);\n --color-emerald-200: oklch(90.5% 0.093 164.15);\n --color-emerald-300: oklch(84.5% 0.143 164.978);\n --color-emerald-400: oklch(76.5% 0.177 163.223);\n --color-emerald-500: oklch(69.6% 0.17 162.48);\n --color-emerald-600: oklch(59.6% 0.145 163.225);\n --color-emerald-700: oklch(50.8% 0.118 165.612);\n --color-emerald-800: oklch(43.2% 0.095 166.913);\n --color-emerald-900: oklch(37.8% 0.077 168.94);\n --color-emerald-950: oklch(26.2% 0.051 172.552);\n\n --color-teal-50: oklch(98.4% 0.014 180.72);\n --color-teal-100: oklch(95.3% 0.051 180.801);\n --color-teal-200: oklch(91% 0.096 180.426);\n --color-teal-300: oklch(85.5% 0.138 181.071);\n --color-teal-400: oklch(77.7% 0.152 181.912);\n --color-teal-500: oklch(70.4% 0.14 182.503);\n --color-teal-600: oklch(60% 0.118 184.704);\n --color-teal-700: oklch(51.1% 0.096 186.391);\n --color-teal-800: oklch(43.7% 0.078 188.216);\n --color-teal-900: oklch(38.6% 0.063 188.416);\n --color-teal-950: oklch(27.7% 0.046 192.524);\n\n --color-cyan-50: oklch(98.4% 0.019 200.873);\n --color-cyan-100: oklch(95.6% 0.045 203.388);\n --color-cyan-200: oklch(91.7% 0.08 205.041);\n --color-cyan-300: oklch(86.5% 0.127 207.078);\n --color-cyan-400: oklch(78.9% 0.154 211.53);\n --color-cyan-500: oklch(71.5% 0.143 215.221);\n --color-cyan-600: oklch(60.9% 0.126 221.723);\n --color-cyan-700: oklch(52% 0.105 223.128);\n --color-cyan-800: oklch(45% 0.085 224.283);\n --color-cyan-900: oklch(39.8% 0.07 227.392);\n --color-cyan-950: oklch(30.2% 0.056 229.695);\n\n --color-sky-50: oklch(97.7% 0.013 236.62);\n --color-sky-100: oklch(95.1% 0.026 236.824);\n --color-sky-200: oklch(90.1% 0.058 230.902);\n --color-sky-300: oklch(82.8% 0.111 230.318);\n --color-sky-400: oklch(74.6% 0.16 232.661);\n --color-sky-500: oklch(68.5% 0.169 237.323);\n --color-sky-600: oklch(58.8% 0.158 241.966);\n --color-sky-700: oklch(50% 0.134 242.749);\n --color-sky-800: oklch(44.3% 0.11 240.79);\n --color-sky-900: oklch(39.1% 0.09 240.876);\n --color-sky-950: oklch(29.3% 0.066 243.157);\n\n --color-blue-50: oklch(97% 0.014 254.604);\n --color-blue-100: oklch(93.2% 0.032 255.585);\n --color-blue-200: oklch(88.2% 0.059 254.128);\n --color-blue-300: oklch(80.9% 0.105 251.813);\n --color-blue-400: oklch(70.7% 0.165 254.624);\n --color-blue-500: oklch(62.3% 0.214 259.815);\n --color-blue-600: oklch(54.6% 0.245 262.881);\n --color-blue-700: oklch(48.8% 0.243 264.376);\n --color-blue-800: oklch(42.4% 0.199 265.638);\n --color-blue-900: oklch(37.9% 0.146 265.522);\n --color-blue-950: oklch(28.2% 0.091 267.935);\n\n --color-indigo-50: oklch(96.2% 0.018 272.314);\n --color-indigo-100: oklch(93% 0.034 272.788);\n --color-indigo-200: oklch(87% 0.065 274.039);\n --color-indigo-300: oklch(78.5% 0.115 274.713);\n --color-indigo-400: oklch(67.3% 0.182 276.935);\n --color-indigo-500: oklch(58.5% 0.233 277.117);\n --color-indigo-600: oklch(51.1% 0.262 276.966);\n --color-indigo-700: oklch(45.7% 0.24 277.023);\n --color-indigo-800: oklch(39.8% 0.195 277.366);\n --color-indigo-900: oklch(35.9% 0.144 278.697);\n --color-indigo-950: oklch(25.7% 0.09 281.288);\n\n --color-violet-50: oklch(96.9% 0.016 293.756);\n --color-violet-100: oklch(94.3% 0.029 294.588);\n --color-violet-200: oklch(89.4% 0.057 293.283);\n --color-violet-300: oklch(81.1% 0.111 293.571);\n --color-violet-400: oklch(70.2% 0.183 293.541);\n --color-violet-500: oklch(60.6% 0.25 292.717);\n --color-violet-600: oklch(54.1% 0.281 293.009);\n --color-violet-700: oklch(49.1% 0.27 292.581);\n --color-violet-800: oklch(43.2% 0.232 292.759);\n --color-violet-900: oklch(38% 0.189 293.745);\n --color-violet-950: oklch(28.3% 0.141 291.089);\n\n --color-purple-50: oklch(97.7% 0.014 308.299);\n --color-purple-100: oklch(94.6% 0.033 307.174);\n --color-purple-200: oklch(90.2% 0.063 306.703);\n --color-purple-300: oklch(82.7% 0.119 306.383);\n --color-purple-400: oklch(71.4% 0.203 305.504);\n --color-purple-500: oklch(62.7% 0.265 303.9);\n --color-purple-600: oklch(55.8% 0.288 302.321);\n --color-purple-700: oklch(49.6% 0.265 301.924);\n --color-purple-800: oklch(43.8% 0.218 303.724);\n --color-purple-900: oklch(38.1% 0.176 304.987);\n --color-purple-950: oklch(29.1% 0.149 302.717);\n\n --color-fuchsia-50: oklch(97.7% 0.017 320.058);\n --color-fuchsia-100: oklch(95.2% 0.037 318.852);\n --color-fuchsia-200: oklch(90.3% 0.076 319.62);\n --color-fuchsia-300: oklch(83.3% 0.145 321.434);\n --color-fuchsia-400: oklch(74% 0.238 322.16);\n --color-fuchsia-500: oklch(66.7% 0.295 322.15);\n --color-fuchsia-600: oklch(59.1% 0.293 322.896);\n --color-fuchsia-700: oklch(51.8% 0.253 323.949);\n --color-fuchsia-800: oklch(45.2% 0.211 324.591);\n --color-fuchsia-900: oklch(40.1% 0.17 325.612);\n --color-fuchsia-950: oklch(29.3% 0.136 325.661);\n\n --color-pink-50: oklch(97.1% 0.014 343.198);\n --color-pink-100: oklch(94.8% 0.028 342.258);\n --color-pink-200: oklch(89.9% 0.061 343.231);\n --color-pink-300: oklch(82.3% 0.12 346.018);\n --color-pink-400: oklch(71.8% 0.202 349.761);\n --color-pink-500: oklch(65.6% 0.241 354.308);\n --color-pink-600: oklch(59.2% 0.249 0.584);\n --color-pink-700: oklch(52.5% 0.223 3.958);\n --color-pink-800: oklch(45.9% 0.187 3.815);\n --color-pink-900: oklch(40.8% 0.153 2.432);\n --color-pink-950: oklch(28.4% 0.109 3.907);\n\n --color-rose-50: oklch(96.9% 0.015 12.422);\n --color-rose-100: oklch(94.1% 0.03 12.58);\n --color-rose-200: oklch(89.2% 0.058 10.001);\n --color-rose-300: oklch(81% 0.117 11.638);\n --color-rose-400: oklch(71.2% 0.194 13.428);\n --color-rose-500: oklch(64.5% 0.246 16.439);\n --color-rose-600: oklch(58.6% 0.253 17.585);\n --color-rose-700: oklch(51.4% 0.222 16.935);\n --color-rose-800: oklch(45.5% 0.188 13.697);\n --color-rose-900: oklch(41% 0.159 10.272);\n --color-rose-950: oklch(27.1% 0.105 12.094);\n\n --color-slate-50: oklch(98.4% 0.003 247.858);\n --color-slate-100: oklch(96.8% 0.007 247.896);\n --color-slate-200: oklch(92.9% 0.013 255.508);\n --color-slate-300: oklch(86.9% 0.022 252.894);\n --color-slate-400: oklch(70.4% 0.04 256.788);\n --color-slate-500: oklch(55.4% 0.046 257.417);\n --color-slate-600: oklch(44.6% 0.043 257.281);\n --color-slate-700: oklch(37.2% 0.044 257.287);\n --color-slate-800: oklch(27.9% 0.041 260.031);\n --color-slate-900: oklch(20.8% 0.042 265.755);\n --color-slate-950: oklch(12.9% 0.042 264.695);\n\n --color-gray-50: oklch(98.5% 0.002 247.839);\n --color-gray-100: oklch(96.7% 0.003 264.542);\n --color-gray-200: oklch(92.8% 0.006 264.531);\n --color-gray-300: oklch(87.2% 0.01 258.338);\n --color-gray-400: oklch(70.7% 0.022 261.325);\n --color-gray-500: oklch(55.1% 0.027 264.364);\n --color-gray-600: oklch(44.6% 0.03 256.802);\n --color-gray-700: oklch(37.3% 0.034 259.733);\n --color-gray-800: oklch(27.8% 0.033 256.848);\n --color-gray-900: oklch(21% 0.034 264.665);\n --color-gray-950: oklch(13% 0.028 261.692);\n\n --color-zinc-50: oklch(98.5% 0 none);\n --color-zinc-100: oklch(96.7% 0.001 286.375);\n --color-zinc-200: oklch(92% 0.004 286.32);\n --color-zinc-300: oklch(87.1% 0.006 286.286);\n --color-zinc-400: oklch(70.5% 0.015 286.067);\n --color-zinc-500: oklch(55.2% 0.016 285.938);\n --color-zinc-600: oklch(44.2% 0.017 285.786);\n --color-zinc-700: oklch(37% 0.013 285.805);\n --color-zinc-800: oklch(27.4% 0.006 286.033);\n --color-zinc-900: oklch(21% 0.006 285.885);\n --color-zinc-950: oklch(14.1% 0.005 285.823);\n\n --color-neutral-50: oklch(98.5% 0 none);\n --color-neutral-100: oklch(97% 0 none);\n --color-neutral-200: oklch(92.2% 0 none);\n --color-neutral-300: oklch(87% 0 none);\n --color-neutral-400: oklch(70.8% 0 none);\n --color-neutral-500: oklch(55.6% 0 none);\n --color-neutral-600: oklch(43.9% 0 none);\n --color-neutral-700: oklch(37.1% 0 none);\n --color-neutral-800: oklch(26.9% 0 none);\n --color-neutral-900: oklch(20.5% 0 none);\n --color-neutral-950: oklch(14.5% 0 none);\n\n --color-stone-50: oklch(98.5% 0.001 106.423);\n --color-stone-100: oklch(97% 0.001 106.424);\n --color-stone-200: oklch(92.3% 0.003 48.717);\n --color-stone-300: oklch(86.9% 0.005 56.366);\n --color-stone-400: oklch(70.9% 0.01 56.259);\n --color-stone-500: oklch(55.3% 0.013 58.071);\n --color-stone-600: oklch(44.4% 0.011 73.639);\n --color-stone-700: oklch(37.4% 0.01 67.558);\n --color-stone-800: oklch(26.8% 0.007 34.298);\n --color-stone-900: oklch(21.6% 0.006 56.043);\n --color-stone-950: oklch(14.7% 0.004 49.25);\n\n --color-mauve-50: oklch(98.5% 0 none);\n --color-mauve-100: oklch(96% 0.003 325.6);\n --color-mauve-200: oklch(92.2% 0.005 325.62);\n --color-mauve-300: oklch(86.5% 0.012 325.68);\n --color-mauve-400: oklch(71.1% 0.019 323.02);\n --color-mauve-500: oklch(54.2% 0.034 322.5);\n --color-mauve-600: oklch(43.5% 0.029 321.78);\n --color-mauve-700: oklch(36.4% 0.029 323.89);\n --color-mauve-800: oklch(26.3% 0.024 320.12);\n --color-mauve-900: oklch(21.2% 0.019 322.12);\n --color-mauve-950: oklch(14.5% 0.008 326);\n\n --color-olive-50: oklch(98.8% 0.003 106.5);\n --color-olive-100: oklch(96.6% 0.005 106.5);\n --color-olive-200: oklch(93% 0.007 106.5);\n --color-olive-300: oklch(88% 0.011 106.6);\n --color-olive-400: oklch(73.7% 0.021 106.9);\n --color-olive-500: oklch(58% 0.031 107.3);\n --color-olive-600: oklch(46.6% 0.025 107.3);\n --color-olive-700: oklch(39.4% 0.023 107.4);\n --color-olive-800: oklch(28.6% 0.016 107.4);\n --color-olive-900: oklch(22.8% 0.013 107.4);\n --color-olive-950: oklch(15.3% 0.006 107.1);\n\n --color-mist-50: oklch(98.7% 0.002 197.1);\n --color-mist-100: oklch(96.3% 0.002 197.1);\n --color-mist-200: oklch(92.5% 0.005 214.3);\n --color-mist-300: oklch(87.2% 0.007 219.6);\n --color-mist-400: oklch(72.3% 0.014 214.4);\n --color-mist-500: oklch(56% 0.021 213.5);\n --color-mist-600: oklch(45% 0.017 213.2);\n --color-mist-700: oklch(37.8% 0.015 216);\n --color-mist-800: oklch(27.5% 0.011 216.9);\n --color-mist-900: oklch(21.8% 0.008 223.9);\n --color-mist-950: oklch(14.8% 0.004 228.8);\n\n --color-taupe-50: oklch(98.6% 0.002 67.8);\n --color-taupe-100: oklch(96% 0.002 17.2);\n --color-taupe-200: oklch(92.2% 0.005 34.3);\n --color-taupe-300: oklch(86.8% 0.007 39.5);\n --color-taupe-400: oklch(71.4% 0.014 41.2);\n --color-taupe-500: oklch(54.7% 0.021 43.1);\n --color-taupe-600: oklch(43.8% 0.017 39.3);\n --color-taupe-700: oklch(36.7% 0.016 35.7);\n --color-taupe-800: oklch(26.8% 0.011 36.5);\n --color-taupe-900: oklch(21.4% 0.009 43.1);\n --color-taupe-950: oklch(14.7% 0.004 49.3);\n\n --color-black: #000;\n --color-white: #fff;\n\n --spacing: 0.25rem;\n\n --breakpoint-sm: 40rem;\n --breakpoint-md: 48rem;\n --breakpoint-lg: 64rem;\n --breakpoint-xl: 80rem;\n --breakpoint-2xl: 96rem;\n\n --container-3xs: 16rem;\n --container-2xs: 18rem;\n --container-xs: 20rem;\n --container-sm: 24rem;\n --container-md: 28rem;\n --container-lg: 32rem;\n --container-xl: 36rem;\n --container-2xl: 42rem;\n --container-3xl: 48rem;\n --container-4xl: 56rem;\n --container-5xl: 64rem;\n --container-6xl: 72rem;\n --container-7xl: 80rem;\n\n --text-xs: 0.75rem;\n --text-xs--line-height: calc(1 / 0.75);\n --text-sm: 0.875rem;\n --text-sm--line-height: calc(1.25 / 0.875);\n --text-base: 1rem;\n --text-base--line-height: calc(1.5 / 1);\n --text-lg: 1.125rem;\n --text-lg--line-height: calc(1.75 / 1.125);\n --text-xl: 1.25rem;\n --text-xl--line-height: calc(1.75 / 1.25);\n --text-2xl: 1.5rem;\n --text-2xl--line-height: calc(2 / 1.5);\n --text-3xl: 1.875rem;\n --text-3xl--line-height: calc(2.25 / 1.875);\n --text-4xl: 2.25rem;\n --text-4xl--line-height: calc(2.5 / 2.25);\n --text-5xl: 3rem;\n --text-5xl--line-height: 1;\n --text-6xl: 3.75rem;\n --text-6xl--line-height: 1;\n --text-7xl: 4.5rem;\n --text-7xl--line-height: 1;\n --text-8xl: 6rem;\n --text-8xl--line-height: 1;\n --text-9xl: 8rem;\n --text-9xl--line-height: 1;\n\n --font-weight-thin: 100;\n --font-weight-extralight: 200;\n --font-weight-light: 300;\n --font-weight-normal: 400;\n --font-weight-medium: 500;\n --font-weight-semibold: 600;\n --font-weight-bold: 700;\n --font-weight-extrabold: 800;\n --font-weight-black: 900;\n\n --tracking-tighter: -0.05em;\n --tracking-tight: -0.025em;\n --tracking-normal: 0em;\n --tracking-wide: 0.025em;\n --tracking-wider: 0.05em;\n --tracking-widest: 0.1em;\n\n --leading-tight: 1.25;\n --leading-snug: 1.375;\n --leading-normal: 1.5;\n --leading-relaxed: 1.625;\n --leading-loose: 2;\n\n --radius-xs: 0.125rem;\n --radius-sm: 0.25rem;\n --radius-md: 0.375rem;\n --radius-lg: 0.5rem;\n --radius-xl: 0.75rem;\n --radius-2xl: 1rem;\n --radius-3xl: 1.5rem;\n --radius-4xl: 2rem;\n\n --shadow-2xs: 0 1px rgb(0 0 0 / 0.05);\n --shadow-xs: 0 1px 2px 0 rgb(0 0 0 / 0.05);\n --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);\n --shadow-md:\n 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);\n --shadow-lg:\n 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);\n --shadow-xl:\n 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);\n --shadow-2xl: 0 25px 50px -12px rgb(0 0 0 / 0.25);\n\n --inset-shadow-2xs: inset 0 1px rgb(0 0 0 / 0.05);\n --inset-shadow-xs: inset 0 1px 1px rgb(0 0 0 / 0.05);\n --inset-shadow-sm: inset 0 2px 4px rgb(0 0 0 / 0.05);\n\n --drop-shadow-xs: 0 1px 1px rgb(0 0 0 / 0.05);\n --drop-shadow-sm: 0 1px 2px rgb(0 0 0 / 0.15);\n --drop-shadow-md: 0 3px 3px rgb(0 0 0 / 0.12);\n --drop-shadow-lg: 0 4px 4px rgb(0 0 0 / 0.15);\n --drop-shadow-xl: 0 9px 7px rgb(0 0 0 / 0.1);\n --drop-shadow-2xl: 0 25px 25px rgb(0 0 0 / 0.15);\n\n --text-shadow-2xs: 0px 1px 0px rgb(0 0 0 / 0.15);\n --text-shadow-xs: 0px 1px 1px rgb(0 0 0 / 0.2);\n --text-shadow-sm:\n 0px 1px 0px rgb(0 0 0 / 0.075), 0px 1px 1px rgb(0 0 0 / 0.075),\n 0px 2px 2px rgb(0 0 0 / 0.075);\n --text-shadow-md:\n 0px 1px 1px rgb(0 0 0 / 0.1), 0px 1px 2px rgb(0 0 0 / 0.1),\n 0px 2px 4px rgb(0 0 0 / 0.1);\n --text-shadow-lg:\n 0px 1px 2px rgb(0 0 0 / 0.1), 0px 3px 2px rgb(0 0 0 / 0.1),\n 0px 4px 8px rgb(0 0 0 / 0.1);\n\n --ease-in: cubic-bezier(0.4, 0, 1, 1);\n --ease-out: cubic-bezier(0, 0, 0.2, 1);\n --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);\n\n --animate-spin: spin 1s linear infinite;\n --animate-ping: ping 1s cubic-bezier(0, 0, 0.2, 1) infinite;\n --animate-pulse: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;\n --animate-bounce: bounce 1s infinite;\n\n @keyframes spin {\n to {\n transform: rotate(360deg);\n }\n }\n\n @keyframes ping {\n 75%,\n 100% {\n transform: scale(2);\n opacity: 0;\n }\n }\n\n @keyframes pulse {\n 50% {\n opacity: 0.5;\n }\n }\n\n @keyframes bounce {\n 0%,\n 100% {\n transform: translateY(-25%);\n animation-timing-function: cubic-bezier(0.8, 0, 1, 1);\n }\n\n 50% {\n transform: none;\n animation-timing-function: cubic-bezier(0, 0, 0.2, 1);\n }\n }\n\n --blur-xs: 4px;\n --blur-sm: 8px;\n --blur-md: 12px;\n --blur-lg: 16px;\n --blur-xl: 24px;\n --blur-2xl: 40px;\n --blur-3xl: 64px;\n\n --perspective-dramatic: 100px;\n --perspective-near: 300px;\n --perspective-normal: 500px;\n --perspective-midrange: 800px;\n --perspective-distant: 1200px;\n\n --aspect-video: 16 / 9;\n\n --default-transition-duration: 150ms;\n --default-transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);\n --default-font-family: --theme(--font-sans, initial);\n --default-font-feature-settings: --theme(\n --font-sans--font-feature-settings,\n initial\n );\n --default-font-variation-settings: --theme(\n --font-sans--font-variation-settings,\n initial\n );\n --default-mono-font-family: --theme(--font-mono, initial);\n --default-mono-font-feature-settings: --theme(\n --font-mono--font-feature-settings,\n initial\n );\n --default-mono-font-variation-settings: --theme(\n --font-mono--font-variation-settings,\n initial\n );\n }\n\n /* Deprecated */\n @theme default inline reference {\n --blur: 8px;\n --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);\n --shadow-inner: inset 0 2px 4px 0 rgb(0 0 0 / 0.05);\n --drop-shadow: 0 1px 2px rgb(0 0 0 / 0.1), 0 1px 1px rgb(0 0 0 / 0.06);\n --radius: 0.25rem;\n --max-width-prose: 65ch;\n }\n}\n\n@layer base {\n /*\n 1. Prevent padding and border from affecting element width. (https://github.com/mozdevs/cssremedy/issues/4)\n 2. Remove default margins and padding\n 3. Reset all borders.\n*/\n\n *,\n ::after,\n ::before,\n ::backdrop,\n ::file-selector-button {\n box-sizing: border-box; /* 1 */\n margin: 0; /* 2 */\n padding: 0; /* 2 */\n border: 0 solid; /* 3 */\n }\n\n /*\n 1. Use a consistent sensible line-height in all browsers.\n 2. Prevent adjustments of font size after orientation changes in iOS.\n 3. Use a more readable tab size.\n 4. Use the user\'s configured `sans` font-family by default.\n 5. Use the user\'s configured `sans` font-feature-settings by default.\n 6. Use the user\'s configured `sans` font-variation-settings by default.\n 7. Disable tap highlights on iOS.\n*/\n\n html,\n :host {\n line-height: 1.5; /* 1 */\n -webkit-text-size-adjust: 100%; /* 2 */\n tab-size: 4; /* 3 */\n font-family: --theme(\n --default-font-family,\n -apple-system,\n BlinkMacSystemFont,\n "Segoe UI",\n Roboto,\n "Helvetica Neue",\n "Noto Sans",\n Arial,\n sans-serif,\n "Apple Color Emoji",\n "Segoe UI Emoji",\n "Segoe UI Symbol",\n "Noto Color Emoji"\n ); /* 4 */\n font-feature-settings: --theme(\n --default-font-feature-settings,\n normal\n ); /* 5 */\n font-variation-settings: --theme(\n --default-font-variation-settings,\n normal\n ); /* 6 */\n -webkit-tap-highlight-color: transparent; /* 7 */\n }\n\n /*\n 1. Add the correct height in Firefox.\n 2. Correct the inheritance of border color in Firefox. (https://bugzilla.mozilla.org/show_bug.cgi?id=190655)\n 3. Reset the default border style to a 1px solid border.\n*/\n\n hr {\n height: 0; /* 1 */\n color: inherit; /* 2 */\n border-top-width: 1px; /* 3 */\n }\n\n /*\n Add the correct text decoration in Chrome, Edge, and Safari.\n*/\n\n abbr:where([title]) {\n -webkit-text-decoration: underline dotted;\n text-decoration: underline dotted;\n }\n\n /*\n Remove the default font size and weight for headings.\n*/\n\n h1,\n h2,\n h3,\n h4,\n h5,\n h6 {\n font-size: inherit;\n font-weight: inherit;\n }\n\n /*\n Reset links to optimize for opt-in styling instead of opt-out.\n*/\n\n a {\n color: inherit;\n -webkit-text-decoration: inherit;\n text-decoration: inherit;\n }\n\n /*\n Add the correct font weight in Edge and Safari.\n*/\n\n b,\n strong {\n font-weight: bolder;\n }\n\n /*\n 1. Use the user\'s configured `mono` font-family by default.\n 2. Use the user\'s configured `mono` font-feature-settings by default.\n 3. Use the user\'s configured `mono` font-variation-settings by default.\n 4. Correct the odd `em` font sizing in all browsers.\n*/\n\n code,\n kbd,\n samp,\n pre {\n font-family: --theme(\n --default-mono-font-family,\n ui-monospace,\n SFMono-Regular,\n Menlo,\n Monaco,\n Consolas,\n "Liberation Mono",\n "Courier New",\n monospace\n ); /* 1 */\n font-feature-settings: --theme(\n --default-mono-font-feature-settings,\n normal\n ); /* 2 */\n font-variation-settings: --theme(\n --default-mono-font-variation-settings,\n normal\n ); /* 3 */\n font-size: 1em; /* 4 */\n }\n\n /*\n Add the correct font size in all browsers.\n*/\n\n small {\n font-size: 80%;\n }\n\n /*\n Prevent `sub` and `sup` elements from affecting the line height in all browsers.\n*/\n\n sub,\n sup {\n font-size: 75%;\n line-height: 0;\n position: relative;\n vertical-align: baseline;\n }\n\n sub {\n bottom: -0.25em;\n }\n\n sup {\n top: -0.5em;\n }\n\n /*\n 1. Remove text indentation from table contents in Chrome and Safari. (https://bugs.chromium.org/p/chromium/issues/detail?id=999088, https://bugs.webkit.org/show_bug.cgi?id=201297)\n 2. Correct table border color inheritance in all Chrome and Safari. (https://bugs.chromium.org/p/chromium/issues/detail?id=935729, https://bugs.webkit.org/show_bug.cgi?id=195016)\n 3. Remove gaps between table borders by default.\n*/\n\n table {\n text-indent: 0; /* 1 */\n border-color: inherit; /* 2 */\n border-collapse: collapse; /* 3 */\n }\n\n /*\n Use the modern Firefox focus style for all focusable elements.\n*/\n\n :-moz-focusring:where(:not(iframe)) {\n outline: auto;\n }\n\n /*\n Add the correct vertical alignment in Chrome and Firefox.\n*/\n\n progress {\n vertical-align: baseline;\n }\n\n /*\n Add the correct display in Chrome and Safari.\n*/\n\n summary {\n display: list-item;\n }\n\n /*\n Make lists unstyled by default.\n*/\n\n ol,\n ul,\n menu {\n list-style: none;\n }\n\n /*\n 1. Make replaced elements `display: block` by default. (https://github.com/mozdevs/cssremedy/issues/14)\n 2. Add `vertical-align: middle` to align replaced elements more sensibly by default. (https://github.com/jensimmons/cssremedy/issues/14#issuecomment-634934210)\n This can trigger a poorly considered lint error in some tools but is included by design.\n*/\n\n img,\n svg,\n video,\n canvas,\n audio,\n iframe,\n embed,\n object {\n display: block; /* 1 */\n vertical-align: middle; /* 2 */\n }\n\n /*\n Constrain images and videos to the parent width and preserve their intrinsic aspect ratio. (https://github.com/mozdevs/cssremedy/issues/14)\n*/\n\n img,\n video {\n max-width: 100%;\n height: auto;\n }\n\n /*\n 1. Inherit font styles in all browsers.\n 2. Remove border radius in all browsers.\n 3. Remove background color in all browsers.\n 4. Ensure consistent opacity for disabled states in all browsers.\n*/\n\n button,\n input,\n select,\n optgroup,\n textarea,\n ::file-selector-button {\n font: inherit; /* 1 */\n font-feature-settings: inherit; /* 1 */\n font-variation-settings: inherit; /* 1 */\n letter-spacing: inherit; /* 1 */\n color: inherit; /* 1 */\n border-radius: 0; /* 2 */\n background-color: transparent; /* 3 */\n opacity: 1; /* 4 */\n }\n\n /*\n Restore default font weight.\n*/\n\n :where(select:is([multiple], [size])) optgroup {\n font-weight: bolder;\n }\n\n /*\n Restore indentation.\n*/\n\n :where(select:is([multiple], [size])) optgroup option {\n padding-inline-start: 20px;\n }\n\n /*\n Restore space after button.\n*/\n\n ::file-selector-button {\n margin-inline-end: 4px;\n }\n\n /*\n Reset the default placeholder opacity in Firefox. (https://github.com/tailwindlabs/tailwindcss/issues/3300)\n*/\n\n ::placeholder {\n opacity: 1;\n }\n\n /*\n Set the default placeholder color to a semi-transparent version of the current text color in browsers that do not\n crash when using `color-mix(…)` with `currentcolor`. (https://github.com/tailwindlabs/tailwindcss/issues/17194)\n*/\n\n @supports (not (-webkit-appearance: -apple-pay-button)) /* Not Safari */ or\n (contain-intrinsic-size: 1px) /* Safari 17+ */ {\n ::placeholder {\n color: color-mix(in oklab, currentcolor 50%, transparent);\n }\n }\n\n /*\n Prevent resizing textareas horizontally by default.\n*/\n\n textarea {\n resize: vertical;\n }\n\n /*\n Remove the inner padding in Chrome and Safari on macOS.\n*/\n\n ::-webkit-search-decoration {\n -webkit-appearance: none;\n }\n\n /*\n 1. Ensure date/time inputs have the same height when empty in iOS Safari.\n 2. Ensure text alignment can be changed on date/time inputs in iOS Safari.\n*/\n\n ::-webkit-date-and-time-value {\n min-height: 1lh; /* 1 */\n text-align: inherit; /* 2 */\n }\n\n /*\n Prevent height from changing on date/time inputs in macOS Safari when the input is set to `display: block`.\n*/\n\n ::-webkit-datetime-edit {\n display: inline-flex;\n }\n\n /*\n Remove excess padding from pseudo-elements in date/time inputs to ensure consistent height across browsers.\n*/\n\n ::-webkit-datetime-edit-fields-wrapper {\n padding: 0;\n }\n\n ::-webkit-datetime-edit,\n ::-webkit-datetime-edit-year-field,\n ::-webkit-datetime-edit-month-field,\n ::-webkit-datetime-edit-day-field,\n ::-webkit-datetime-edit-hour-field,\n ::-webkit-datetime-edit-minute-field,\n ::-webkit-datetime-edit-second-field,\n ::-webkit-datetime-edit-millisecond-field,\n ::-webkit-datetime-edit-meridiem-field {\n padding-block: 0;\n }\n\n /*\n Center dropdown marker shown on inputs with paired `<datalist>`s in Chrome. (https://github.com/tailwindlabs/tailwindcss/issues/18499)\n*/\n\n ::-webkit-calendar-picker-indicator {\n line-height: 1;\n }\n\n /*\n Remove the additional `:invalid` styles in Firefox. (https://github.com/mozilla/gecko-dev/blob/2f9eacd9d3d995c937b4251a5557d95d494c9be1/layout/style/res/forms.css#L728-L737)\n*/\n\n :-moz-ui-invalid {\n box-shadow: none;\n }\n\n /*\n Correct the inability to style the border radius in iOS Safari.\n*/\n\n button,\n input:where([type="button"], [type="reset"], [type="submit"]),\n ::file-selector-button {\n appearance: button;\n }\n\n /*\n Correct the cursor style of increment and decrement buttons in Safari.\n*/\n\n ::-webkit-inner-spin-button,\n ::-webkit-outer-spin-button {\n height: auto;\n }\n\n /*\n Make elements with the HTML hidden attribute stay hidden by default.\n*/\n\n [hidden]:where(:not([hidden="until-found"])) {\n display: none !important;\n }\n}\n\n@layer utilities {\n @tailwind utilities;\n}\n',
|
|
765
|
+
preflight: "/*\n 1. Prevent padding and border from affecting element width. (https://github.com/mozdevs/cssremedy/issues/4)\n 2. Remove default margins and padding\n 3. Reset all borders.\n*/\n\n*,\n::after,\n::before,\n::backdrop,\n::file-selector-button {\n box-sizing: border-box; /* 1 */\n margin: 0; /* 2 */\n padding: 0; /* 2 */\n border: 0 solid; /* 3 */\n}\n\n/*\n 1. Use a consistent sensible line-height in all browsers.\n 2. Prevent adjustments of font size after orientation changes in iOS.\n 3. Use a more readable tab size.\n 4. Use the user's configured `sans` font-family by default.\n 5. Use the user's configured `sans` font-feature-settings by default.\n 6. Use the user's configured `sans` font-variation-settings by default.\n 7. Disable tap highlights on iOS.\n*/\n\nhtml,\n:host {\n line-height: 1.5; /* 1 */\n -webkit-text-size-adjust: 100%; /* 2 */\n tab-size: 4; /* 3 */\n font-family: --theme(\n --default-font-family,\n -apple-system,\n BlinkMacSystemFont,\n 'Segoe UI',\n Roboto,\n 'Helvetica Neue',\n 'Noto Sans',\n Arial,\n sans-serif,\n 'Apple Color Emoji',\n 'Segoe UI Emoji',\n 'Segoe UI Symbol',\n 'Noto Color Emoji'\n ); /* 4 */\n font-feature-settings: --theme(--default-font-feature-settings, normal); /* 5 */\n font-variation-settings: --theme(--default-font-variation-settings, normal); /* 6 */\n -webkit-tap-highlight-color: transparent; /* 7 */\n}\n\n/*\n 1. Add the correct height in Firefox.\n 2. Correct the inheritance of border color in Firefox. (https://bugzilla.mozilla.org/show_bug.cgi?id=190655)\n 3. Reset the default border style to a 1px solid border.\n*/\n\nhr {\n height: 0; /* 1 */\n color: inherit; /* 2 */\n border-top-width: 1px; /* 3 */\n}\n\n/*\n Add the correct text decoration in Chrome, Edge, and Safari.\n*/\n\nabbr:where([title]) {\n -webkit-text-decoration: underline dotted;\n text-decoration: underline dotted;\n}\n\n/*\n Remove the default font size and weight for headings.\n*/\n\nh1,\nh2,\nh3,\nh4,\nh5,\nh6 {\n font-size: inherit;\n font-weight: inherit;\n}\n\n/*\n Reset links to optimize for opt-in styling instead of opt-out.\n*/\n\na {\n color: inherit;\n -webkit-text-decoration: inherit;\n text-decoration: inherit;\n}\n\n/*\n Add the correct font weight in Edge and Safari.\n*/\n\nb,\nstrong {\n font-weight: bolder;\n}\n\n/*\n 1. Use the user's configured `mono` font-family by default.\n 2. Use the user's configured `mono` font-feature-settings by default.\n 3. Use the user's configured `mono` font-variation-settings by default.\n 4. Correct the odd `em` font sizing in all browsers.\n*/\n\ncode,\nkbd,\nsamp,\npre {\n font-family: --theme(\n --default-mono-font-family,\n ui-monospace,\n SFMono-Regular,\n Menlo,\n Monaco,\n Consolas,\n 'Liberation Mono',\n 'Courier New',\n monospace\n ); /* 1 */\n font-feature-settings: --theme(--default-mono-font-feature-settings, normal); /* 2 */\n font-variation-settings: --theme(--default-mono-font-variation-settings, normal); /* 3 */\n font-size: 1em; /* 4 */\n}\n\n/*\n Add the correct font size in all browsers.\n*/\n\nsmall {\n font-size: 80%;\n}\n\n/*\n Prevent `sub` and `sup` elements from affecting the line height in all browsers.\n*/\n\nsub,\nsup {\n font-size: 75%;\n line-height: 0;\n position: relative;\n vertical-align: baseline;\n}\n\nsub {\n bottom: -0.25em;\n}\n\nsup {\n top: -0.5em;\n}\n\n/*\n 1. Remove text indentation from table contents in Chrome and Safari. (https://bugs.chromium.org/p/chromium/issues/detail?id=999088, https://bugs.webkit.org/show_bug.cgi?id=201297)\n 2. Correct table border color inheritance in all Chrome and Safari. (https://bugs.chromium.org/p/chromium/issues/detail?id=935729, https://bugs.webkit.org/show_bug.cgi?id=195016)\n 3. Remove gaps between table borders by default.\n*/\n\ntable {\n text-indent: 0; /* 1 */\n border-color: inherit; /* 2 */\n border-collapse: collapse; /* 3 */\n}\n\n/*\n Use the modern Firefox focus style for all focusable elements.\n*/\n\n:-moz-focusring:where(:not(iframe)) {\n outline: auto;\n}\n\n/*\n Add the correct vertical alignment in Chrome and Firefox.\n*/\n\nprogress {\n vertical-align: baseline;\n}\n\n/*\n Add the correct display in Chrome and Safari.\n*/\n\nsummary {\n display: list-item;\n}\n\n/*\n Make lists unstyled by default.\n*/\n\nol,\nul,\nmenu {\n list-style: none;\n}\n\n/*\n 1. Make replaced elements `display: block` by default. (https://github.com/mozdevs/cssremedy/issues/14)\n 2. Add `vertical-align: middle` to align replaced elements more sensibly by default. (https://github.com/jensimmons/cssremedy/issues/14#issuecomment-634934210)\n This can trigger a poorly considered lint error in some tools but is included by design.\n*/\n\nimg,\nsvg,\nvideo,\ncanvas,\naudio,\niframe,\nembed,\nobject {\n display: block; /* 1 */\n vertical-align: middle; /* 2 */\n}\n\n/*\n Constrain images and videos to the parent width and preserve their intrinsic aspect ratio. (https://github.com/mozdevs/cssremedy/issues/14)\n*/\n\nimg,\nvideo {\n max-width: 100%;\n height: auto;\n}\n\n/*\n 1. Inherit font styles in all browsers.\n 2. Remove border radius in all browsers.\n 3. Remove background color in all browsers.\n 4. Ensure consistent opacity for disabled states in all browsers.\n*/\n\nbutton,\ninput,\nselect,\noptgroup,\ntextarea,\n::file-selector-button {\n font: inherit; /* 1 */\n font-feature-settings: inherit; /* 1 */\n font-variation-settings: inherit; /* 1 */\n letter-spacing: inherit; /* 1 */\n color: inherit; /* 1 */\n border-radius: 0; /* 2 */\n background-color: transparent; /* 3 */\n opacity: 1; /* 4 */\n}\n\n/*\n Restore default font weight.\n*/\n\n:where(select:is([multiple], [size])) optgroup {\n font-weight: bolder;\n}\n\n/*\n Restore indentation.\n*/\n\n:where(select:is([multiple], [size])) optgroup option {\n padding-inline-start: 20px;\n}\n\n/*\n Restore space after button.\n*/\n\n::file-selector-button {\n margin-inline-end: 4px;\n}\n\n/*\n Reset the default placeholder opacity in Firefox. (https://github.com/tailwindlabs/tailwindcss/issues/3300)\n*/\n\n::placeholder {\n opacity: 1;\n}\n\n/*\n Set the default placeholder color to a semi-transparent version of the current text color in browsers that do not\n crash when using `color-mix(…)` with `currentcolor`. (https://github.com/tailwindlabs/tailwindcss/issues/17194)\n*/\n\n@supports (not (-webkit-appearance: -apple-pay-button)) /* Not Safari */ or\n (contain-intrinsic-size: 1px) /* Safari 17+ */ {\n ::placeholder {\n color: color-mix(in oklab, currentcolor 50%, transparent);\n }\n}\n\n/*\n Prevent resizing textareas horizontally by default.\n*/\n\ntextarea {\n resize: vertical;\n}\n\n/*\n Remove the inner padding in Chrome and Safari on macOS.\n*/\n\n::-webkit-search-decoration {\n -webkit-appearance: none;\n}\n\n/*\n 1. Ensure date/time inputs have the same height when empty in iOS Safari.\n 2. Ensure text alignment can be changed on date/time inputs in iOS Safari.\n*/\n\n::-webkit-date-and-time-value {\n min-height: 1lh; /* 1 */\n text-align: inherit; /* 2 */\n}\n\n/*\n Prevent height from changing on date/time inputs in macOS Safari when the input is set to `display: block`.\n*/\n\n::-webkit-datetime-edit {\n display: inline-flex;\n}\n\n/*\n Remove excess padding from pseudo-elements in date/time inputs to ensure consistent height across browsers.\n*/\n\n::-webkit-datetime-edit-fields-wrapper {\n padding: 0;\n}\n\n::-webkit-datetime-edit,\n::-webkit-datetime-edit-year-field,\n::-webkit-datetime-edit-month-field,\n::-webkit-datetime-edit-day-field,\n::-webkit-datetime-edit-hour-field,\n::-webkit-datetime-edit-minute-field,\n::-webkit-datetime-edit-second-field,\n::-webkit-datetime-edit-millisecond-field,\n::-webkit-datetime-edit-meridiem-field {\n padding-block: 0;\n}\n\n/*\n Center dropdown marker shown on inputs with paired `<datalist>`s in Chrome. (https://github.com/tailwindlabs/tailwindcss/issues/18499)\n*/\n\n::-webkit-calendar-picker-indicator {\n line-height: 1;\n}\n\n/*\n Remove the additional `:invalid` styles in Firefox. (https://github.com/mozilla/gecko-dev/blob/2f9eacd9d3d995c937b4251a5557d95d494c9be1/layout/style/res/forms.css#L728-L737)\n*/\n\n:-moz-ui-invalid {\n box-shadow: none;\n}\n\n/*\n Correct the inability to style the border radius in iOS Safari.\n*/\n\nbutton,\ninput:where([type='button'], [type='reset'], [type='submit']),\n::file-selector-button {\n appearance: button;\n}\n\n/*\n Correct the cursor style of increment and decrement buttons in Safari.\n*/\n\n::-webkit-inner-spin-button,\n::-webkit-outer-spin-button {\n height: auto;\n}\n\n/*\n Make elements with the HTML hidden attribute stay hidden by default.\n*/\n\n[hidden]:where(:not([hidden='until-found'])) {\n display: none !important;\n}\n",
|
|
766
|
+
theme: "@theme default {\n --font-sans:\n -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', 'Noto Sans', Arial,\n sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';\n --font-serif: ui-serif, Georgia, Cambria, 'Times New Roman', Times, serif;\n --font-mono:\n ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New',\n monospace;\n\n --color-red-50: oklch(97.1% 0.013 17.38);\n --color-red-100: oklch(93.6% 0.032 17.717);\n --color-red-200: oklch(88.5% 0.062 18.334);\n --color-red-300: oklch(80.8% 0.114 19.571);\n --color-red-400: oklch(70.4% 0.191 22.216);\n --color-red-500: oklch(63.7% 0.237 25.331);\n --color-red-600: oklch(57.7% 0.245 27.325);\n --color-red-700: oklch(50.5% 0.213 27.518);\n --color-red-800: oklch(44.4% 0.177 26.899);\n --color-red-900: oklch(39.6% 0.141 25.723);\n --color-red-950: oklch(25.8% 0.092 26.042);\n\n --color-orange-50: oklch(98% 0.016 73.684);\n --color-orange-100: oklch(95.4% 0.038 75.164);\n --color-orange-200: oklch(90.1% 0.076 70.697);\n --color-orange-300: oklch(83.7% 0.128 66.29);\n --color-orange-400: oklch(75% 0.183 55.934);\n --color-orange-500: oklch(70.5% 0.213 47.604);\n --color-orange-600: oklch(64.6% 0.222 41.116);\n --color-orange-700: oklch(55.3% 0.195 38.402);\n --color-orange-800: oklch(47% 0.157 37.304);\n --color-orange-900: oklch(40.8% 0.123 38.172);\n --color-orange-950: oklch(26.6% 0.079 36.259);\n\n --color-amber-50: oklch(98.7% 0.022 95.277);\n --color-amber-100: oklch(96.2% 0.059 95.617);\n --color-amber-200: oklch(92.4% 0.12 95.746);\n --color-amber-300: oklch(87.9% 0.169 91.605);\n --color-amber-400: oklch(82.8% 0.189 84.429);\n --color-amber-500: oklch(76.9% 0.188 70.08);\n --color-amber-600: oklch(66.6% 0.179 58.318);\n --color-amber-700: oklch(55.5% 0.163 48.998);\n --color-amber-800: oklch(47.3% 0.137 46.201);\n --color-amber-900: oklch(41.4% 0.112 45.904);\n --color-amber-950: oklch(27.9% 0.077 45.635);\n\n --color-yellow-50: oklch(98.7% 0.026 102.212);\n --color-yellow-100: oklch(97.3% 0.071 103.193);\n --color-yellow-200: oklch(94.5% 0.129 101.54);\n --color-yellow-300: oklch(90.5% 0.182 98.111);\n --color-yellow-400: oklch(85.2% 0.199 91.936);\n --color-yellow-500: oklch(79.5% 0.184 86.047);\n --color-yellow-600: oklch(68.1% 0.162 75.834);\n --color-yellow-700: oklch(55.4% 0.135 66.442);\n --color-yellow-800: oklch(47.6% 0.114 61.907);\n --color-yellow-900: oklch(42.1% 0.095 57.708);\n --color-yellow-950: oklch(28.6% 0.066 53.813);\n\n --color-lime-50: oklch(98.6% 0.031 120.757);\n --color-lime-100: oklch(96.7% 0.067 122.328);\n --color-lime-200: oklch(93.8% 0.127 124.321);\n --color-lime-300: oklch(89.7% 0.196 126.665);\n --color-lime-400: oklch(84.1% 0.238 128.85);\n --color-lime-500: oklch(76.8% 0.233 130.85);\n --color-lime-600: oklch(64.8% 0.2 131.684);\n --color-lime-700: oklch(53.2% 0.157 131.589);\n --color-lime-800: oklch(45.3% 0.124 130.933);\n --color-lime-900: oklch(40.5% 0.101 131.063);\n --color-lime-950: oklch(27.4% 0.072 132.109);\n\n --color-green-50: oklch(98.2% 0.018 155.826);\n --color-green-100: oklch(96.2% 0.044 156.743);\n --color-green-200: oklch(92.5% 0.084 155.995);\n --color-green-300: oklch(87.1% 0.15 154.449);\n --color-green-400: oklch(79.2% 0.209 151.711);\n --color-green-500: oklch(72.3% 0.219 149.579);\n --color-green-600: oklch(62.7% 0.194 149.214);\n --color-green-700: oklch(52.7% 0.154 150.069);\n --color-green-800: oklch(44.8% 0.119 151.328);\n --color-green-900: oklch(39.3% 0.095 152.535);\n --color-green-950: oklch(26.6% 0.065 152.934);\n\n --color-emerald-50: oklch(97.9% 0.021 166.113);\n --color-emerald-100: oklch(95% 0.052 163.051);\n --color-emerald-200: oklch(90.5% 0.093 164.15);\n --color-emerald-300: oklch(84.5% 0.143 164.978);\n --color-emerald-400: oklch(76.5% 0.177 163.223);\n --color-emerald-500: oklch(69.6% 0.17 162.48);\n --color-emerald-600: oklch(59.6% 0.145 163.225);\n --color-emerald-700: oklch(50.8% 0.118 165.612);\n --color-emerald-800: oklch(43.2% 0.095 166.913);\n --color-emerald-900: oklch(37.8% 0.077 168.94);\n --color-emerald-950: oklch(26.2% 0.051 172.552);\n\n --color-teal-50: oklch(98.4% 0.014 180.72);\n --color-teal-100: oklch(95.3% 0.051 180.801);\n --color-teal-200: oklch(91% 0.096 180.426);\n --color-teal-300: oklch(85.5% 0.138 181.071);\n --color-teal-400: oklch(77.7% 0.152 181.912);\n --color-teal-500: oklch(70.4% 0.14 182.503);\n --color-teal-600: oklch(60% 0.118 184.704);\n --color-teal-700: oklch(51.1% 0.096 186.391);\n --color-teal-800: oklch(43.7% 0.078 188.216);\n --color-teal-900: oklch(38.6% 0.063 188.416);\n --color-teal-950: oklch(27.7% 0.046 192.524);\n\n --color-cyan-50: oklch(98.4% 0.019 200.873);\n --color-cyan-100: oklch(95.6% 0.045 203.388);\n --color-cyan-200: oklch(91.7% 0.08 205.041);\n --color-cyan-300: oklch(86.5% 0.127 207.078);\n --color-cyan-400: oklch(78.9% 0.154 211.53);\n --color-cyan-500: oklch(71.5% 0.143 215.221);\n --color-cyan-600: oklch(60.9% 0.126 221.723);\n --color-cyan-700: oklch(52% 0.105 223.128);\n --color-cyan-800: oklch(45% 0.085 224.283);\n --color-cyan-900: oklch(39.8% 0.07 227.392);\n --color-cyan-950: oklch(30.2% 0.056 229.695);\n\n --color-sky-50: oklch(97.7% 0.013 236.62);\n --color-sky-100: oklch(95.1% 0.026 236.824);\n --color-sky-200: oklch(90.1% 0.058 230.902);\n --color-sky-300: oklch(82.8% 0.111 230.318);\n --color-sky-400: oklch(74.6% 0.16 232.661);\n --color-sky-500: oklch(68.5% 0.169 237.323);\n --color-sky-600: oklch(58.8% 0.158 241.966);\n --color-sky-700: oklch(50% 0.134 242.749);\n --color-sky-800: oklch(44.3% 0.11 240.79);\n --color-sky-900: oklch(39.1% 0.09 240.876);\n --color-sky-950: oklch(29.3% 0.066 243.157);\n\n --color-blue-50: oklch(97% 0.014 254.604);\n --color-blue-100: oklch(93.2% 0.032 255.585);\n --color-blue-200: oklch(88.2% 0.059 254.128);\n --color-blue-300: oklch(80.9% 0.105 251.813);\n --color-blue-400: oklch(70.7% 0.165 254.624);\n --color-blue-500: oklch(62.3% 0.214 259.815);\n --color-blue-600: oklch(54.6% 0.245 262.881);\n --color-blue-700: oklch(48.8% 0.243 264.376);\n --color-blue-800: oklch(42.4% 0.199 265.638);\n --color-blue-900: oklch(37.9% 0.146 265.522);\n --color-blue-950: oklch(28.2% 0.091 267.935);\n\n --color-indigo-50: oklch(96.2% 0.018 272.314);\n --color-indigo-100: oklch(93% 0.034 272.788);\n --color-indigo-200: oklch(87% 0.065 274.039);\n --color-indigo-300: oklch(78.5% 0.115 274.713);\n --color-indigo-400: oklch(67.3% 0.182 276.935);\n --color-indigo-500: oklch(58.5% 0.233 277.117);\n --color-indigo-600: oklch(51.1% 0.262 276.966);\n --color-indigo-700: oklch(45.7% 0.24 277.023);\n --color-indigo-800: oklch(39.8% 0.195 277.366);\n --color-indigo-900: oklch(35.9% 0.144 278.697);\n --color-indigo-950: oklch(25.7% 0.09 281.288);\n\n --color-violet-50: oklch(96.9% 0.016 293.756);\n --color-violet-100: oklch(94.3% 0.029 294.588);\n --color-violet-200: oklch(89.4% 0.057 293.283);\n --color-violet-300: oklch(81.1% 0.111 293.571);\n --color-violet-400: oklch(70.2% 0.183 293.541);\n --color-violet-500: oklch(60.6% 0.25 292.717);\n --color-violet-600: oklch(54.1% 0.281 293.009);\n --color-violet-700: oklch(49.1% 0.27 292.581);\n --color-violet-800: oklch(43.2% 0.232 292.759);\n --color-violet-900: oklch(38% 0.189 293.745);\n --color-violet-950: oklch(28.3% 0.141 291.089);\n\n --color-purple-50: oklch(97.7% 0.014 308.299);\n --color-purple-100: oklch(94.6% 0.033 307.174);\n --color-purple-200: oklch(90.2% 0.063 306.703);\n --color-purple-300: oklch(82.7% 0.119 306.383);\n --color-purple-400: oklch(71.4% 0.203 305.504);\n --color-purple-500: oklch(62.7% 0.265 303.9);\n --color-purple-600: oklch(55.8% 0.288 302.321);\n --color-purple-700: oklch(49.6% 0.265 301.924);\n --color-purple-800: oklch(43.8% 0.218 303.724);\n --color-purple-900: oklch(38.1% 0.176 304.987);\n --color-purple-950: oklch(29.1% 0.149 302.717);\n\n --color-fuchsia-50: oklch(97.7% 0.017 320.058);\n --color-fuchsia-100: oklch(95.2% 0.037 318.852);\n --color-fuchsia-200: oklch(90.3% 0.076 319.62);\n --color-fuchsia-300: oklch(83.3% 0.145 321.434);\n --color-fuchsia-400: oklch(74% 0.238 322.16);\n --color-fuchsia-500: oklch(66.7% 0.295 322.15);\n --color-fuchsia-600: oklch(59.1% 0.293 322.896);\n --color-fuchsia-700: oklch(51.8% 0.253 323.949);\n --color-fuchsia-800: oklch(45.2% 0.211 324.591);\n --color-fuchsia-900: oklch(40.1% 0.17 325.612);\n --color-fuchsia-950: oklch(29.3% 0.136 325.661);\n\n --color-pink-50: oklch(97.1% 0.014 343.198);\n --color-pink-100: oklch(94.8% 0.028 342.258);\n --color-pink-200: oklch(89.9% 0.061 343.231);\n --color-pink-300: oklch(82.3% 0.12 346.018);\n --color-pink-400: oklch(71.8% 0.202 349.761);\n --color-pink-500: oklch(65.6% 0.241 354.308);\n --color-pink-600: oklch(59.2% 0.249 0.584);\n --color-pink-700: oklch(52.5% 0.223 3.958);\n --color-pink-800: oklch(45.9% 0.187 3.815);\n --color-pink-900: oklch(40.8% 0.153 2.432);\n --color-pink-950: oklch(28.4% 0.109 3.907);\n\n --color-rose-50: oklch(96.9% 0.015 12.422);\n --color-rose-100: oklch(94.1% 0.03 12.58);\n --color-rose-200: oklch(89.2% 0.058 10.001);\n --color-rose-300: oklch(81% 0.117 11.638);\n --color-rose-400: oklch(71.2% 0.194 13.428);\n --color-rose-500: oklch(64.5% 0.246 16.439);\n --color-rose-600: oklch(58.6% 0.253 17.585);\n --color-rose-700: oklch(51.4% 0.222 16.935);\n --color-rose-800: oklch(45.5% 0.188 13.697);\n --color-rose-900: oklch(41% 0.159 10.272);\n --color-rose-950: oklch(27.1% 0.105 12.094);\n\n --color-slate-50: oklch(98.4% 0.003 247.858);\n --color-slate-100: oklch(96.8% 0.007 247.896);\n --color-slate-200: oklch(92.9% 0.013 255.508);\n --color-slate-300: oklch(86.9% 0.022 252.894);\n --color-slate-400: oklch(70.4% 0.04 256.788);\n --color-slate-500: oklch(55.4% 0.046 257.417);\n --color-slate-600: oklch(44.6% 0.043 257.281);\n --color-slate-700: oklch(37.2% 0.044 257.287);\n --color-slate-800: oklch(27.9% 0.041 260.031);\n --color-slate-900: oklch(20.8% 0.042 265.755);\n --color-slate-950: oklch(12.9% 0.042 264.695);\n\n --color-gray-50: oklch(98.5% 0.002 247.839);\n --color-gray-100: oklch(96.7% 0.003 264.542);\n --color-gray-200: oklch(92.8% 0.006 264.531);\n --color-gray-300: oklch(87.2% 0.01 258.338);\n --color-gray-400: oklch(70.7% 0.022 261.325);\n --color-gray-500: oklch(55.1% 0.027 264.364);\n --color-gray-600: oklch(44.6% 0.03 256.802);\n --color-gray-700: oklch(37.3% 0.034 259.733);\n --color-gray-800: oklch(27.8% 0.033 256.848);\n --color-gray-900: oklch(21% 0.034 264.665);\n --color-gray-950: oklch(13% 0.028 261.692);\n\n --color-zinc-50: oklch(98.5% 0 none);\n --color-zinc-100: oklch(96.7% 0.001 286.375);\n --color-zinc-200: oklch(92% 0.004 286.32);\n --color-zinc-300: oklch(87.1% 0.006 286.286);\n --color-zinc-400: oklch(70.5% 0.015 286.067);\n --color-zinc-500: oklch(55.2% 0.016 285.938);\n --color-zinc-600: oklch(44.2% 0.017 285.786);\n --color-zinc-700: oklch(37% 0.013 285.805);\n --color-zinc-800: oklch(27.4% 0.006 286.033);\n --color-zinc-900: oklch(21% 0.006 285.885);\n --color-zinc-950: oklch(14.1% 0.005 285.823);\n\n --color-neutral-50: oklch(98.5% 0 none);\n --color-neutral-100: oklch(97% 0 none);\n --color-neutral-200: oklch(92.2% 0 none);\n --color-neutral-300: oklch(87% 0 none);\n --color-neutral-400: oklch(70.8% 0 none);\n --color-neutral-500: oklch(55.6% 0 none);\n --color-neutral-600: oklch(43.9% 0 none);\n --color-neutral-700: oklch(37.1% 0 none);\n --color-neutral-800: oklch(26.9% 0 none);\n --color-neutral-900: oklch(20.5% 0 none);\n --color-neutral-950: oklch(14.5% 0 none);\n\n --color-stone-50: oklch(98.5% 0.001 106.423);\n --color-stone-100: oklch(97% 0.001 106.424);\n --color-stone-200: oklch(92.3% 0.003 48.717);\n --color-stone-300: oklch(86.9% 0.005 56.366);\n --color-stone-400: oklch(70.9% 0.01 56.259);\n --color-stone-500: oklch(55.3% 0.013 58.071);\n --color-stone-600: oklch(44.4% 0.011 73.639);\n --color-stone-700: oklch(37.4% 0.01 67.558);\n --color-stone-800: oklch(26.8% 0.007 34.298);\n --color-stone-900: oklch(21.6% 0.006 56.043);\n --color-stone-950: oklch(14.7% 0.004 49.25);\n\n --color-mauve-50: oklch(98.5% 0 none);\n --color-mauve-100: oklch(96% 0.003 325.6);\n --color-mauve-200: oklch(92.2% 0.005 325.62);\n --color-mauve-300: oklch(86.5% 0.012 325.68);\n --color-mauve-400: oklch(71.1% 0.019 323.02);\n --color-mauve-500: oklch(54.2% 0.034 322.5);\n --color-mauve-600: oklch(43.5% 0.029 321.78);\n --color-mauve-700: oklch(36.4% 0.029 323.89);\n --color-mauve-800: oklch(26.3% 0.024 320.12);\n --color-mauve-900: oklch(21.2% 0.019 322.12);\n --color-mauve-950: oklch(14.5% 0.008 326);\n\n --color-olive-50: oklch(98.8% 0.003 106.5);\n --color-olive-100: oklch(96.6% 0.005 106.5);\n --color-olive-200: oklch(93% 0.007 106.5);\n --color-olive-300: oklch(88% 0.011 106.6);\n --color-olive-400: oklch(73.7% 0.021 106.9);\n --color-olive-500: oklch(58% 0.031 107.3);\n --color-olive-600: oklch(46.6% 0.025 107.3);\n --color-olive-700: oklch(39.4% 0.023 107.4);\n --color-olive-800: oklch(28.6% 0.016 107.4);\n --color-olive-900: oklch(22.8% 0.013 107.4);\n --color-olive-950: oklch(15.3% 0.006 107.1);\n\n --color-mist-50: oklch(98.7% 0.002 197.1);\n --color-mist-100: oklch(96.3% 0.002 197.1);\n --color-mist-200: oklch(92.5% 0.005 214.3);\n --color-mist-300: oklch(87.2% 0.007 219.6);\n --color-mist-400: oklch(72.3% 0.014 214.4);\n --color-mist-500: oklch(56% 0.021 213.5);\n --color-mist-600: oklch(45% 0.017 213.2);\n --color-mist-700: oklch(37.8% 0.015 216);\n --color-mist-800: oklch(27.5% 0.011 216.9);\n --color-mist-900: oklch(21.8% 0.008 223.9);\n --color-mist-950: oklch(14.8% 0.004 228.8);\n\n --color-taupe-50: oklch(98.6% 0.002 67.8);\n --color-taupe-100: oklch(96% 0.002 17.2);\n --color-taupe-200: oklch(92.2% 0.005 34.3);\n --color-taupe-300: oklch(86.8% 0.007 39.5);\n --color-taupe-400: oklch(71.4% 0.014 41.2);\n --color-taupe-500: oklch(54.7% 0.021 43.1);\n --color-taupe-600: oklch(43.8% 0.017 39.3);\n --color-taupe-700: oklch(36.7% 0.016 35.7);\n --color-taupe-800: oklch(26.8% 0.011 36.5);\n --color-taupe-900: oklch(21.4% 0.009 43.1);\n --color-taupe-950: oklch(14.7% 0.004 49.3);\n\n --color-black: #000;\n --color-white: #fff;\n\n --spacing: 0.25rem;\n\n --breakpoint-sm: 40rem;\n --breakpoint-md: 48rem;\n --breakpoint-lg: 64rem;\n --breakpoint-xl: 80rem;\n --breakpoint-2xl: 96rem;\n\n --container-3xs: 16rem;\n --container-2xs: 18rem;\n --container-xs: 20rem;\n --container-sm: 24rem;\n --container-md: 28rem;\n --container-lg: 32rem;\n --container-xl: 36rem;\n --container-2xl: 42rem;\n --container-3xl: 48rem;\n --container-4xl: 56rem;\n --container-5xl: 64rem;\n --container-6xl: 72rem;\n --container-7xl: 80rem;\n\n --text-xs: 0.75rem;\n --text-xs--line-height: calc(1 / 0.75);\n --text-sm: 0.875rem;\n --text-sm--line-height: calc(1.25 / 0.875);\n --text-base: 1rem;\n --text-base--line-height: calc(1.5 / 1);\n --text-lg: 1.125rem;\n --text-lg--line-height: calc(1.75 / 1.125);\n --text-xl: 1.25rem;\n --text-xl--line-height: calc(1.75 / 1.25);\n --text-2xl: 1.5rem;\n --text-2xl--line-height: calc(2 / 1.5);\n --text-3xl: 1.875rem;\n --text-3xl--line-height: calc(2.25 / 1.875);\n --text-4xl: 2.25rem;\n --text-4xl--line-height: calc(2.5 / 2.25);\n --text-5xl: 3rem;\n --text-5xl--line-height: 1;\n --text-6xl: 3.75rem;\n --text-6xl--line-height: 1;\n --text-7xl: 4.5rem;\n --text-7xl--line-height: 1;\n --text-8xl: 6rem;\n --text-8xl--line-height: 1;\n --text-9xl: 8rem;\n --text-9xl--line-height: 1;\n\n --font-weight-thin: 100;\n --font-weight-extralight: 200;\n --font-weight-light: 300;\n --font-weight-normal: 400;\n --font-weight-medium: 500;\n --font-weight-semibold: 600;\n --font-weight-bold: 700;\n --font-weight-extrabold: 800;\n --font-weight-black: 900;\n\n --tracking-tighter: -0.05em;\n --tracking-tight: -0.025em;\n --tracking-normal: 0em;\n --tracking-wide: 0.025em;\n --tracking-wider: 0.05em;\n --tracking-widest: 0.1em;\n\n --leading-tight: 1.25;\n --leading-snug: 1.375;\n --leading-normal: 1.5;\n --leading-relaxed: 1.625;\n --leading-loose: 2;\n\n --radius-xs: 0.125rem;\n --radius-sm: 0.25rem;\n --radius-md: 0.375rem;\n --radius-lg: 0.5rem;\n --radius-xl: 0.75rem;\n --radius-2xl: 1rem;\n --radius-3xl: 1.5rem;\n --radius-4xl: 2rem;\n\n --shadow-2xs: 0 1px rgb(0 0 0 / 0.05);\n --shadow-xs: 0 1px 2px 0 rgb(0 0 0 / 0.05);\n --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);\n --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);\n --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);\n --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);\n --shadow-2xl: 0 25px 50px -12px rgb(0 0 0 / 0.25);\n\n --inset-shadow-2xs: inset 0 1px rgb(0 0 0 / 0.05);\n --inset-shadow-xs: inset 0 1px 1px rgb(0 0 0 / 0.05);\n --inset-shadow-sm: inset 0 2px 4px rgb(0 0 0 / 0.05);\n\n --drop-shadow-xs: 0 1px 1px rgb(0 0 0 / 0.05);\n --drop-shadow-sm: 0 1px 2px rgb(0 0 0 / 0.15);\n --drop-shadow-md: 0 3px 3px rgb(0 0 0 / 0.12);\n --drop-shadow-lg: 0 4px 4px rgb(0 0 0 / 0.15);\n --drop-shadow-xl: 0 9px 7px rgb(0 0 0 / 0.1);\n --drop-shadow-2xl: 0 25px 25px rgb(0 0 0 / 0.15);\n\n --text-shadow-2xs: 0px 1px 0px rgb(0 0 0 / 0.15);\n --text-shadow-xs: 0px 1px 1px rgb(0 0 0 / 0.2);\n --text-shadow-sm:\n 0px 1px 0px rgb(0 0 0 / 0.075), 0px 1px 1px rgb(0 0 0 / 0.075), 0px 2px 2px rgb(0 0 0 / 0.075);\n --text-shadow-md:\n 0px 1px 1px rgb(0 0 0 / 0.1), 0px 1px 2px rgb(0 0 0 / 0.1), 0px 2px 4px rgb(0 0 0 / 0.1);\n --text-shadow-lg:\n 0px 1px 2px rgb(0 0 0 / 0.1), 0px 3px 2px rgb(0 0 0 / 0.1), 0px 4px 8px rgb(0 0 0 / 0.1);\n\n --ease-in: cubic-bezier(0.4, 0, 1, 1);\n --ease-out: cubic-bezier(0, 0, 0.2, 1);\n --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);\n\n --animate-spin: spin 1s linear infinite;\n --animate-ping: ping 1s cubic-bezier(0, 0, 0.2, 1) infinite;\n --animate-pulse: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;\n --animate-bounce: bounce 1s infinite;\n\n @keyframes spin {\n to {\n transform: rotate(360deg);\n }\n }\n\n @keyframes ping {\n 75%,\n 100% {\n transform: scale(2);\n opacity: 0;\n }\n }\n\n @keyframes pulse {\n 50% {\n opacity: 0.5;\n }\n }\n\n @keyframes bounce {\n 0%,\n 100% {\n transform: translateY(-25%);\n animation-timing-function: cubic-bezier(0.8, 0, 1, 1);\n }\n\n 50% {\n transform: none;\n animation-timing-function: cubic-bezier(0, 0, 0.2, 1);\n }\n }\n\n --blur-xs: 4px;\n --blur-sm: 8px;\n --blur-md: 12px;\n --blur-lg: 16px;\n --blur-xl: 24px;\n --blur-2xl: 40px;\n --blur-3xl: 64px;\n\n --perspective-dramatic: 100px;\n --perspective-near: 300px;\n --perspective-normal: 500px;\n --perspective-midrange: 800px;\n --perspective-distant: 1200px;\n\n --aspect-video: 16 / 9;\n\n --default-transition-duration: 150ms;\n --default-transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);\n --default-font-family: --theme(--font-sans, initial);\n --default-font-feature-settings: --theme(--font-sans--font-feature-settings, initial);\n --default-font-variation-settings: --theme(--font-sans--font-variation-settings, initial);\n --default-mono-font-family: --theme(--font-mono, initial);\n --default-mono-font-feature-settings: --theme(--font-mono--font-feature-settings, initial);\n --default-mono-font-variation-settings: --theme(--font-mono--font-variation-settings, initial);\n}\n\n/* Deprecated */\n@theme default inline reference {\n --blur: 8px;\n --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);\n --shadow-inner: inset 0 2px 4px 0 rgb(0 0 0 / 0.05);\n --drop-shadow: 0 1px 2px rgb(0 0 0 / 0.1), 0 1px 1px rgb(0 0 0 / 0.06);\n --radius: 0.25rem;\n --max-width-prose: 65ch;\n}\n",
|
|
767
|
+
utilities: "@tailwind utilities;\n"
|
|
768
|
+
};
|
|
769
|
+
|
|
770
|
+
/** Does this stylesheet ask for Tailwind at all? */
|
|
771
|
+
var usesTailwind = function usesTailwind(css) {
|
|
772
|
+
return /@import\s+["']tailwindcss/.test(css) || /@tailwind\s+\w/.test(css);
|
|
773
|
+
};
|
|
774
|
+
|
|
775
|
+
/**
|
|
776
|
+
* Directives that need something this build does not have.
|
|
777
|
+
*
|
|
778
|
+
* `@plugin` and `@config` both go through Tailwind's `loadModule`, which means
|
|
779
|
+
* resolving and *executing* a JS module at CSS-compile time. That is a real
|
|
780
|
+
* feature gap rather than a shortcut -- and a solvable one, since a plugin is a
|
|
781
|
+
* dependency the project declares and the vendor layer already builds those --
|
|
782
|
+
* but it is not built, so it fails loudly.
|
|
783
|
+
*
|
|
784
|
+
* `@source` is different: it points the scanner at paths, and candidates here
|
|
785
|
+
* come from the project's files rather than from a glob. Harmless to ignore,
|
|
786
|
+
* worth saying so.
|
|
787
|
+
*/
|
|
788
|
+
var UNSUPPORTED = [["@source", "points the scanner at paths; candidates come from the project files here"]];
|
|
789
|
+
|
|
790
|
+
/**
|
|
791
|
+
* Loads a JS module for `@plugin` / `@config`.
|
|
792
|
+
*
|
|
793
|
+
* Tailwind resolves and *executes* these while compiling CSS, which is the one
|
|
794
|
+
* thing this build cannot do on its own: there is no module resolution here,
|
|
795
|
+
* only a fixed set of externals. So it is a capability the caller supplies --
|
|
796
|
+
* `packages/publish` has a real filesystem and node_modules and passes one; a
|
|
797
|
+
* browser build has neither and does not.
|
|
798
|
+
*
|
|
799
|
+
* Absent, this throws rather than returning an empty plugin. A plugin that
|
|
800
|
+
* silently does nothing leaves a page subtly unstyled, which is much harder to
|
|
801
|
+
* diagnose than a build that stops and names the directive -- and it would make
|
|
802
|
+
* the same project build differently depending on where it was published.
|
|
803
|
+
*/
|
|
804
|
+
|
|
805
|
+
/**
|
|
806
|
+
* Derived from Tailwind's own option rather than restated.
|
|
807
|
+
*
|
|
808
|
+
* It used to be restated -- `(id, base, hint: string) => Promise<{ module:
|
|
809
|
+
* unknown; base: string }>` -- and the restatement was WRONG: Tailwind also
|
|
810
|
+
* wants a `path`, and the loader in the CLI never sent one. Nothing caught it
|
|
811
|
+
* because the package this came from ran under `--experimental-strip-types`,
|
|
812
|
+
* which strips types without checking them, so the mismatch was invisible on
|
|
813
|
+
* both sides of the call.
|
|
814
|
+
*
|
|
815
|
+
* Derived, a Tailwind upgrade that changes the shape is a compile error here
|
|
816
|
+
* -- which is where it can be read -- rather than an `undefined` handed to
|
|
817
|
+
* someone else's code.
|
|
818
|
+
*/
|
|
819
|
+
|
|
820
|
+
/** What a `@plugin` / `@config` module has to be, once it is loaded. */
|
|
821
|
+
|
|
822
|
+
var refuseModule = function refuseModule() {
|
|
823
|
+
return function (id, _base, hint) {
|
|
824
|
+
throw new Error("Tailwind's '@".concat(hint, "' is not supported here: '").concat(id, "' would have to be resolved and ") + "executed while compiling CSS, and this build has no module loader for that. " + "Publishing through the CLI does support it; a browser build does not. " + "Otherwise, remove the directive or express it with @theme/@utility/@custom-variant.");
|
|
825
|
+
};
|
|
826
|
+
};
|
|
827
|
+
|
|
828
|
+
/**
|
|
829
|
+
* Characters that can appear in a Tailwind candidate.
|
|
830
|
+
*
|
|
831
|
+
* Tailwind's real extractor is a Rust state machine over arbitrary text; this
|
|
832
|
+
* is the same idea with a blunter instrument. It over-supplies heavily -- every
|
|
833
|
+
* identifier in the source becomes a candidate -- and that is the safe
|
|
834
|
+
* direction, because `build()` silently drops anything it does not recognise
|
|
835
|
+
* while a missed candidate is a missing style with no error anywhere.
|
|
836
|
+
*
|
|
837
|
+
* Includes `:` for variants (`hover:`, `md:`), `[` `]` and `(` `)` for
|
|
838
|
+
* arbitrary values (`w-[32px]`, `bg-(--brand)`), `/` for opacity (`bg-red-500/50`),
|
|
839
|
+
* `!` and `-` for modifiers.
|
|
840
|
+
*/
|
|
841
|
+
var CANDIDATE = /[A-Za-z0-9_@!.:/%[\]()#&$*+,<>=^~|-]+/g;
|
|
842
|
+
|
|
843
|
+
/** Source extensions worth scanning. Stylesheets are the input, not a source. */
|
|
844
|
+
var SCANNABLE = /\.(tsx?|jsx?|mdx?|html|svelte|vue)$/;
|
|
845
|
+
|
|
846
|
+
/**
|
|
847
|
+
* Candidates for `build()`, extracted from the project's own source.
|
|
848
|
+
*
|
|
849
|
+
* Every string in every module, not just JSX class attributes: a class name can
|
|
850
|
+
* be built anywhere -- a `cn()` helper, a lookup table, a constant in another
|
|
851
|
+
* file -- and Tailwind's own scanner makes the same choice for the same reason.
|
|
852
|
+
*/
|
|
853
|
+
function scanCandidates(files) {
|
|
854
|
+
var found = new Set();
|
|
855
|
+
for (var _i = 0, _Object$entries = Object.entries(files); _i < _Object$entries.length; _i++) {
|
|
856
|
+
var _Object$entries$_i = slicedToArray._slicedToArray(_Object$entries[_i], 2),
|
|
857
|
+
path = _Object$entries$_i[0],
|
|
858
|
+
code = _Object$entries$_i[1];
|
|
859
|
+
if (!SCANNABLE.test(path)) continue;
|
|
860
|
+
var _iterator = slicedToArray._createForOfIteratorHelper(code.matchAll(CANDIDATE)),
|
|
861
|
+
_step;
|
|
862
|
+
try {
|
|
863
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
864
|
+
var match = _step.value;
|
|
865
|
+
found.add(match[0]);
|
|
866
|
+
}
|
|
867
|
+
} catch (err) {
|
|
868
|
+
_iterator.e(err);
|
|
869
|
+
} finally {
|
|
870
|
+
_iterator.f();
|
|
871
|
+
}
|
|
872
|
+
}
|
|
873
|
+
return slicedToArray._toConsumableArray(found);
|
|
874
|
+
}
|
|
875
|
+
/**
|
|
876
|
+
* Resolves `@import "tailwindcss"` and friends from the inlined stylesheets.
|
|
877
|
+
*
|
|
878
|
+
* Tailwind asks for these by package-relative id (`tailwindcss`,
|
|
879
|
+
* `tailwindcss/theme.css`). Anything else is a project stylesheet, which the
|
|
880
|
+
* CSS pass has already inlined by the time this runs -- so an unresolved id
|
|
881
|
+
* here is a genuine error rather than something to paper over.
|
|
882
|
+
*/
|
|
883
|
+
function loadStylesheet(_x) {
|
|
884
|
+
return _loadStylesheet.apply(this, arguments);
|
|
885
|
+
}
|
|
886
|
+
/**
|
|
887
|
+
* Runs the project's stylesheet through Tailwind.
|
|
888
|
+
*
|
|
889
|
+
* The input is the *already concatenated* project CSS, so a project's own rules
|
|
890
|
+
* and its `@import "tailwindcss"` are compiled together and the cascade order
|
|
891
|
+
* the CSS pass worked out is preserved.
|
|
892
|
+
*/
|
|
893
|
+
function _loadStylesheet() {
|
|
894
|
+
_loadStylesheet = slicedToArray._asyncToGenerator(/*#__PURE__*/slicedToArray._regenerator().m(function _callee(id) {
|
|
895
|
+
var name, content;
|
|
896
|
+
return slicedToArray._regenerator().w(function (_context) {
|
|
897
|
+
while (1) switch (_context.n) {
|
|
898
|
+
case 0:
|
|
899
|
+
name = id.replace(/^tailwindcss\/?/, "").replace(/\.css$/, "") || "index";
|
|
900
|
+
content = TAILWIND_SOURCES[name];
|
|
901
|
+
if (!(content === undefined)) {
|
|
902
|
+
_context.n = 1;
|
|
903
|
+
break;
|
|
904
|
+
}
|
|
905
|
+
throw new Error("Tailwind asked for '".concat(id, "', which this build does not carry. ") + "Available: ".concat(Object.keys(TAILWIND_SOURCES).join(", "), "."));
|
|
906
|
+
case 1:
|
|
907
|
+
return _context.a(2, {
|
|
908
|
+
path: "tailwindcss/".concat(name, ".css"),
|
|
909
|
+
base: "/",
|
|
910
|
+
content: content
|
|
911
|
+
});
|
|
912
|
+
}
|
|
913
|
+
}, _callee);
|
|
914
|
+
}));
|
|
915
|
+
return _loadStylesheet.apply(this, arguments);
|
|
916
|
+
}
|
|
917
|
+
function compileTailwind(_x2, _x3, _x4) {
|
|
918
|
+
return _compileTailwind.apply(this, arguments);
|
|
919
|
+
}
|
|
920
|
+
function _compileTailwind() {
|
|
921
|
+
_compileTailwind = slicedToArray._asyncToGenerator(/*#__PURE__*/slicedToArray._regenerator().m(function _callee2(css, files, loadModule) {
|
|
922
|
+
var started, warnings, _iterator2, _step2, _step2$value, directive, why, compiler, candidates;
|
|
923
|
+
return slicedToArray._regenerator().w(function (_context2) {
|
|
924
|
+
while (1) switch (_context2.n) {
|
|
925
|
+
case 0:
|
|
926
|
+
started = performance.now();
|
|
927
|
+
warnings = [];
|
|
928
|
+
_iterator2 = slicedToArray._createForOfIteratorHelper(UNSUPPORTED);
|
|
929
|
+
try {
|
|
930
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
931
|
+
_step2$value = slicedToArray._slicedToArray(_step2.value, 2), directive = _step2$value[0], why = _step2$value[1];
|
|
932
|
+
if (new RegExp("^\\s*".concat(directive, "\\b"), "m").test(css)) {
|
|
933
|
+
warnings.push("'".concat(directive, "' is not supported: it ").concat(why, "."));
|
|
934
|
+
}
|
|
935
|
+
}
|
|
936
|
+
} catch (err) {
|
|
937
|
+
_iterator2.e(err);
|
|
938
|
+
} finally {
|
|
939
|
+
_iterator2.f();
|
|
940
|
+
}
|
|
941
|
+
_context2.n = 1;
|
|
942
|
+
return tailwindcss.compile(css, {
|
|
943
|
+
base: "/",
|
|
944
|
+
loadStylesheet: loadStylesheet,
|
|
945
|
+
loadModule: loadModule !== null && loadModule !== void 0 ? loadModule : refuseModule()
|
|
946
|
+
});
|
|
947
|
+
case 1:
|
|
948
|
+
compiler = _context2.v;
|
|
949
|
+
candidates = scanCandidates(files);
|
|
950
|
+
return _context2.a(2, {
|
|
951
|
+
css: compiler.build(candidates),
|
|
952
|
+
warnings: warnings,
|
|
953
|
+
candidates: candidates.length,
|
|
954
|
+
ms: performance.now() - started
|
|
955
|
+
});
|
|
956
|
+
}
|
|
957
|
+
}, _callee2);
|
|
958
|
+
}));
|
|
959
|
+
return _compileTailwind.apply(this, arguments);
|
|
960
|
+
}
|
|
961
|
+
|
|
962
|
+
/**
|
|
963
|
+
* Extensions treated as assets.
|
|
964
|
+
*
|
|
965
|
+
* Deliberately a list rather than "anything not JS or CSS": an unknown
|
|
966
|
+
* extension should fail as an unresolved import naming the file, not silently
|
|
967
|
+
* become a URL to something the browser cannot use.
|
|
968
|
+
*/
|
|
969
|
+
var ASSET_TYPES = {
|
|
970
|
+
".png": "image/png",
|
|
971
|
+
".jpg": "image/jpeg",
|
|
972
|
+
".jpeg": "image/jpeg",
|
|
973
|
+
".gif": "image/gif",
|
|
974
|
+
".webp": "image/webp",
|
|
975
|
+
".avif": "image/avif",
|
|
976
|
+
".svg": "image/svg+xml",
|
|
977
|
+
".ico": "image/x-icon",
|
|
978
|
+
".woff": "font/woff",
|
|
979
|
+
".woff2": "font/woff2",
|
|
980
|
+
".ttf": "font/ttf",
|
|
981
|
+
".otf": "font/otf",
|
|
982
|
+
".mp4": "video/mp4",
|
|
983
|
+
".webm": "video/webm",
|
|
984
|
+
".mp3": "audio/mpeg",
|
|
985
|
+
".wav": "audio/wav",
|
|
986
|
+
".pdf": "application/pdf",
|
|
987
|
+
".txt": "text/plain"
|
|
988
|
+
};
|
|
989
|
+
var extensionOf = function extensionOf(path) {
|
|
990
|
+
var at = path.lastIndexOf(".");
|
|
991
|
+
return at === -1 ? "" : path.slice(at).toLowerCase();
|
|
992
|
+
};
|
|
993
|
+
var isAsset = function isAsset(path) {
|
|
994
|
+
return extensionOf(path) in ASSET_TYPES;
|
|
995
|
+
};
|
|
996
|
+
var mimeOf = function mimeOf(path) {
|
|
997
|
+
var _ASSET_TYPES$extensio;
|
|
998
|
+
return (_ASSET_TYPES$extensio = ASSET_TYPES[extensionOf(path)]) !== null && _ASSET_TYPES$extensio !== void 0 ? _ASSET_TYPES$extensio : "application/octet-stream";
|
|
999
|
+
};
|
|
1000
|
+
|
|
1001
|
+
/**
|
|
1002
|
+
* Below this many decoded bytes, an asset is inlined as a data URI.
|
|
1003
|
+
*
|
|
1004
|
+
* 4 kB, matching Vite's `assetsInlineLimit` default. The trade is the same one
|
|
1005
|
+
* Vite is making: an extra request costs more than 4 kB of base64 does, and
|
|
1006
|
+
* above that it stops being true.
|
|
1007
|
+
*/
|
|
1008
|
+
var INLINE_LIMIT = 4096;
|
|
1009
|
+
|
|
1010
|
+
/** Decoded byte length of base64, without decoding it. */
|
|
1011
|
+
function base64Bytes(base64) {
|
|
1012
|
+
var clean = base64.replace(/=+$/, "");
|
|
1013
|
+
return Math.floor(clean.length * 3 / 4);
|
|
1014
|
+
}
|
|
1015
|
+
/**
|
|
1016
|
+
* Where an asset import resolves to, for one target.
|
|
1017
|
+
*
|
|
1018
|
+
* Server and client get the *same* URL. An asset is a URL in both, and SSR has
|
|
1019
|
+
* to emit the same `src` the browser will hydrate against -- a server bundle
|
|
1020
|
+
* with a different URL would be a hydration mismatch on every image.
|
|
1021
|
+
*/
|
|
1022
|
+
function resolveAsset(_x, _x2) {
|
|
1023
|
+
return _resolveAsset.apply(this, arguments);
|
|
1024
|
+
}
|
|
1025
|
+
|
|
1026
|
+
/** Where published assets are served from. Matched by the loader. */
|
|
1027
|
+
function _resolveAsset() {
|
|
1028
|
+
_resolveAsset = slicedToArray._asyncToGenerator(/*#__PURE__*/slicedToArray._regenerator().m(function _callee(path, base64) {
|
|
1029
|
+
var hash, name;
|
|
1030
|
+
return slicedToArray._regenerator().w(function (_context) {
|
|
1031
|
+
while (1) switch (_context.n) {
|
|
1032
|
+
case 0:
|
|
1033
|
+
if (!(base64Bytes(base64) <= INLINE_LIMIT)) {
|
|
1034
|
+
_context.n = 1;
|
|
1035
|
+
break;
|
|
1036
|
+
}
|
|
1037
|
+
return _context.a(2, {
|
|
1038
|
+
url: "data:".concat(mimeOf(path), ";base64,").concat(base64)
|
|
1039
|
+
});
|
|
1040
|
+
case 1:
|
|
1041
|
+
_context.n = 2;
|
|
1042
|
+
return sha256Hex(base64);
|
|
1043
|
+
case 2:
|
|
1044
|
+
hash = _context.v.slice(0, 16);
|
|
1045
|
+
name = "".concat(hash).concat(extensionOf(path));
|
|
1046
|
+
return _context.a(2, {
|
|
1047
|
+
url: "".concat(ASSET_BASE).concat(name),
|
|
1048
|
+
file: {
|
|
1049
|
+
name: name,
|
|
1050
|
+
base64: base64
|
|
1051
|
+
}
|
|
1052
|
+
});
|
|
1053
|
+
}
|
|
1054
|
+
}, _callee);
|
|
1055
|
+
}));
|
|
1056
|
+
return _resolveAsset.apply(this, arguments);
|
|
1057
|
+
}
|
|
1058
|
+
var ASSET_BASE = "/_app/a/";
|
|
1059
|
+
|
|
1060
|
+
/** The module a resolved asset import becomes. */
|
|
1061
|
+
var assetModule = function assetModule(url) {
|
|
1062
|
+
return "export default ".concat(JSON.stringify(url), "\n");
|
|
1063
|
+
};
|
|
1064
|
+
|
|
1065
|
+
/** Cheap pre-filter: skip the parse unless one of these appears in the source. */
|
|
1066
|
+
var MARKERS = ["createIsomorphicFn", "createServerOnlyFn", "createClientOnlyFn", "createMiddleware", "ClientOnly"];
|
|
1067
|
+
|
|
1068
|
+
/** Walks a `foo().bar().baz()` chain down to its root callee identifier. */
|
|
1069
|
+
function chainRoot(node) {
|
|
1070
|
+
var current = node;
|
|
1071
|
+
while (current) {
|
|
1072
|
+
if (current.type === "CallExpression") {
|
|
1073
|
+
var callee = current.callee;
|
|
1074
|
+
if ((callee === null || callee === void 0 ? void 0 : callee.type) === "Identifier") return String(callee.name);
|
|
1075
|
+
if ((callee === null || callee === void 0 ? void 0 : callee.type) === "MemberExpression") {
|
|
1076
|
+
current = callee.object;
|
|
1077
|
+
continue;
|
|
1078
|
+
}
|
|
1079
|
+
return null;
|
|
1080
|
+
}
|
|
1081
|
+
return null;
|
|
1082
|
+
}
|
|
1083
|
+
return null;
|
|
1084
|
+
}
|
|
1085
|
+
|
|
1086
|
+
/**
|
|
1087
|
+
* True when this call is the whole chain rather than a link in a longer one.
|
|
1088
|
+
*
|
|
1089
|
+
* Without this, `createIsomorphicFn().client(a).server(b)` matches three times
|
|
1090
|
+
* and the inner replacements land inside text the outer one is about to
|
|
1091
|
+
* replace.
|
|
1092
|
+
*/
|
|
1093
|
+
function isOutermost(node, stack) {
|
|
1094
|
+
var parent = stack[stack.length - 1];
|
|
1095
|
+
var grandparent = stack[stack.length - 2];
|
|
1096
|
+
return !((parent === null || parent === void 0 ? void 0 : parent.type) === "MemberExpression" && parent.object === node && (grandparent === null || grandparent === void 0 ? void 0 : grandparent.type) === "CallExpression");
|
|
1097
|
+
}
|
|
1098
|
+
|
|
1099
|
+
/** Collects `.method(arg)` calls along a chain, nearest-root first. */
|
|
1100
|
+
function methodsOf(node) {
|
|
1101
|
+
var found = new Map();
|
|
1102
|
+
var current = node;
|
|
1103
|
+
while (((_current = current) === null || _current === void 0 ? void 0 : _current.type) === "CallExpression") {
|
|
1104
|
+
var _current, _name, _callee$property, _current$arguments;
|
|
1105
|
+
var callee = current.callee;
|
|
1106
|
+
if ((callee === null || callee === void 0 ? void 0 : callee.type) !== "MemberExpression") break;
|
|
1107
|
+
var name = String((_name = (_callee$property = callee.property) === null || _callee$property === void 0 ? void 0 : _callee$property.name) !== null && _name !== void 0 ? _name : "");
|
|
1108
|
+
// Nearest-to-root wins, so a later duplicate does not shadow the first.
|
|
1109
|
+
found.set(name, {
|
|
1110
|
+
call: current,
|
|
1111
|
+
arg: (_current$arguments = current.arguments) === null || _current$arguments === void 0 ? void 0 : _current$arguments[0],
|
|
1112
|
+
objectEnd: callee.object.end
|
|
1113
|
+
});
|
|
1114
|
+
current = callee.object;
|
|
1115
|
+
}
|
|
1116
|
+
return found;
|
|
1117
|
+
}
|
|
1118
|
+
/**
|
|
1119
|
+
* Rewrites the environment markers in one module for one target.
|
|
1120
|
+
*
|
|
1121
|
+
* Returns `null` when the module contains none, so the caller leaves it alone
|
|
1122
|
+
* and pays no parse.
|
|
1123
|
+
*/
|
|
1124
|
+
function transformEnvMarkers(_x, _x2, _x3) {
|
|
1125
|
+
return _transformEnvMarkers.apply(this, arguments);
|
|
1126
|
+
}
|
|
1127
|
+
function _transformEnvMarkers() {
|
|
1128
|
+
_transformEnvMarkers = slicedToArray._asyncToGenerator(/*#__PURE__*/slicedToArray._regenerator().m(function _callee(moduleId, code, target) {
|
|
1129
|
+
var ast, imported, edits, applied, text;
|
|
1130
|
+
return slicedToArray._regenerator().w(function (_context) {
|
|
1131
|
+
while (1) switch (_context.n) {
|
|
1132
|
+
case 0:
|
|
1133
|
+
if (MARKERS.some(function (marker) {
|
|
1134
|
+
return code.includes(marker);
|
|
1135
|
+
})) {
|
|
1136
|
+
_context.n = 1;
|
|
1137
|
+
break;
|
|
1138
|
+
}
|
|
1139
|
+
return _context.a(2, null);
|
|
1140
|
+
case 1:
|
|
1141
|
+
_context.n = 2;
|
|
1142
|
+
return parse(moduleId, code);
|
|
1143
|
+
case 2:
|
|
1144
|
+
ast = _context.v;
|
|
1145
|
+
imported = tanstackImports(ast);
|
|
1146
|
+
if (!(imported.size === 0)) {
|
|
1147
|
+
_context.n = 3;
|
|
1148
|
+
break;
|
|
1149
|
+
}
|
|
1150
|
+
return _context.a(2, null);
|
|
1151
|
+
case 3:
|
|
1152
|
+
edits = [];
|
|
1153
|
+
applied = [];
|
|
1154
|
+
text = function text(node) {
|
|
1155
|
+
return code.slice(node.start, node.end);
|
|
1156
|
+
};
|
|
1157
|
+
walk(ast, function (node, stack) {
|
|
1158
|
+
// --- handleClientOnlyJSX ---------------------------------------------
|
|
1159
|
+
// On the server the children of <ClientOnly> are dropped and the element
|
|
1160
|
+
// becomes self-closing, so only the fallback renders.
|
|
1161
|
+
if (node.type === "JSXElement" && target === "server") {
|
|
1162
|
+
var _opening$name;
|
|
1163
|
+
var opening = node.openingElement;
|
|
1164
|
+
var name = opening === null || opening === void 0 || (_opening$name = opening.name) === null || _opening$name === void 0 ? void 0 : _opening$name.name;
|
|
1165
|
+
if (name === "ClientOnly" && imported.has("ClientOnly") && !opening.selfClosing) {
|
|
1166
|
+
// From the `>` of the opening tag through the closing tag becomes `/>`.
|
|
1167
|
+
edits.push({
|
|
1168
|
+
start: opening.end - 1,
|
|
1169
|
+
end: node.end,
|
|
1170
|
+
text: " />"
|
|
1171
|
+
});
|
|
1172
|
+
applied.push("ClientOnly");
|
|
1173
|
+
}
|
|
1174
|
+
return;
|
|
1175
|
+
}
|
|
1176
|
+
if (node.type !== "CallExpression") return;
|
|
1177
|
+
|
|
1178
|
+
// --- handleEnvOnly ----------------------------------------------------
|
|
1179
|
+
// createServerOnlyFn(fn) is `fn` on the server and a throwing stub on the
|
|
1180
|
+
// client; createClientOnlyFn the mirror image. A stub rather than a no-op,
|
|
1181
|
+
// because silently doing nothing is how a server-only call in a tab turns
|
|
1182
|
+
// into a confusing downstream failure instead of a clear one.
|
|
1183
|
+
var callee = node.callee;
|
|
1184
|
+
if ((callee === null || callee === void 0 ? void 0 : callee.type) === "Identifier") {
|
|
1185
|
+
var _name2 = String(callee.name);
|
|
1186
|
+
var envOnly = _name2 === "createServerOnlyFn" ? "server" : _name2 === "createClientOnlyFn" ? "client" : null;
|
|
1187
|
+
if (envOnly && imported.has(_name2)) {
|
|
1188
|
+
var _node$arguments;
|
|
1189
|
+
var inner = (_node$arguments = node.arguments) === null || _node$arguments === void 0 ? void 0 : _node$arguments[0];
|
|
1190
|
+
if (!inner) {
|
|
1191
|
+
throw new Error("".concat(moduleId, ": ").concat(_name2, "() must be called with a function."));
|
|
1192
|
+
}
|
|
1193
|
+
edits.push({
|
|
1194
|
+
start: node.start,
|
|
1195
|
+
end: node.end,
|
|
1196
|
+
text: target === envOnly ? text(inner) : "(() => { throw new Error(".concat(JSON.stringify("".concat(_name2, "() functions can only be called on the ").concat(envOnly, "!")), ") })")
|
|
1197
|
+
});
|
|
1198
|
+
applied.push(_name2);
|
|
1199
|
+
}
|
|
1200
|
+
return;
|
|
1201
|
+
}
|
|
1202
|
+
if ((callee === null || callee === void 0 ? void 0 : callee.type) !== "MemberExpression" || !isOutermost(node, stack)) return;
|
|
1203
|
+
var root = chainRoot(node);
|
|
1204
|
+
if (!root || !imported.has(root)) return;
|
|
1205
|
+
|
|
1206
|
+
// --- handleCreateIsomorphicFn ----------------------------------------
|
|
1207
|
+
// The whole chain collapses to this environment's implementation. With no
|
|
1208
|
+
// implementation for this environment, a no-op -- which is what Start does,
|
|
1209
|
+
// and what makes a `.server()`-only isomorphic fn safe to reference in a
|
|
1210
|
+
// browser.
|
|
1211
|
+
if (root === "createIsomorphicFn") {
|
|
1212
|
+
var methods = methodsOf(node);
|
|
1213
|
+
var chosen = methods.get(target);
|
|
1214
|
+
if (chosen && !chosen.arg) {
|
|
1215
|
+
throw new Error("".concat(moduleId, ": createIsomorphicFn().").concat(target, "() must be called with a function."));
|
|
1216
|
+
}
|
|
1217
|
+
edits.push({
|
|
1218
|
+
start: node.start,
|
|
1219
|
+
end: node.end,
|
|
1220
|
+
text: chosen !== null && chosen !== void 0 && chosen.arg ? text(chosen.arg) : "(() => {})"
|
|
1221
|
+
});
|
|
1222
|
+
applied.push("createIsomorphicFn");
|
|
1223
|
+
return;
|
|
1224
|
+
}
|
|
1225
|
+
|
|
1226
|
+
// --- handleCreateMiddleware -------------------------------------------
|
|
1227
|
+
// Client only, and it strips rather than replaces: the middleware object
|
|
1228
|
+
// survives, but its `.server()` body and validators do not reach the
|
|
1229
|
+
// browser. Upstream this pass throws if run on the server, which is the
|
|
1230
|
+
// clearest statement that the server keeps everything.
|
|
1231
|
+
if (root === "createMiddleware" && target === "client") {
|
|
1232
|
+
for (var _i = 0, _arr = ["server", "validator", "inputValidator"]; _i < _arr.length; _i++) {
|
|
1233
|
+
var _name3 = _arr[_i];
|
|
1234
|
+
var method = methodsOf(node).get(_name3);
|
|
1235
|
+
if (!method) continue;
|
|
1236
|
+
if (_name3 !== "server" && !method.arg) {
|
|
1237
|
+
throw new Error("".concat(moduleId, ": createMiddleware().").concat(_name3, "() must be called with a validator."));
|
|
1238
|
+
}
|
|
1239
|
+
// Drop `.name(...)`, leaving the object it was called on.
|
|
1240
|
+
edits.push({
|
|
1241
|
+
start: method.objectEnd,
|
|
1242
|
+
end: method.call.end,
|
|
1243
|
+
text: ""
|
|
1244
|
+
});
|
|
1245
|
+
applied.push("createMiddleware.".concat(_name3));
|
|
1246
|
+
}
|
|
1247
|
+
}
|
|
1248
|
+
});
|
|
1249
|
+
if (!(edits.length === 0)) {
|
|
1250
|
+
_context.n = 4;
|
|
1251
|
+
break;
|
|
1252
|
+
}
|
|
1253
|
+
return _context.a(2, null);
|
|
1254
|
+
case 4:
|
|
1255
|
+
return _context.a(2, {
|
|
1256
|
+
code: applyEdits(code, edits),
|
|
1257
|
+
applied: applied
|
|
1258
|
+
});
|
|
1259
|
+
}
|
|
1260
|
+
}, _callee);
|
|
1261
|
+
}));
|
|
1262
|
+
return _transformEnvMarkers.apply(this, arguments);
|
|
1263
|
+
}
|
|
1264
|
+
|
|
1265
|
+
/**
|
|
1266
|
+
* The names Start deletes from the client build.
|
|
1267
|
+
*
|
|
1268
|
+
* `ssr` and `headers` are server-rendering decisions with no client meaning;
|
|
1269
|
+
* `server` is the route's HTTP handlers. Kept as a literal set rather than
|
|
1270
|
+
* derived, so it can be diffed against Start's when versions move.
|
|
1271
|
+
*/
|
|
1272
|
+
var SERVER_ONLY_OPTIONS = new Set(["ssr", "server", "headers"]);
|
|
1273
|
+
|
|
1274
|
+
/**
|
|
1275
|
+
* The route constructors whose options object this applies to.
|
|
1276
|
+
*
|
|
1277
|
+
* Matches Start's `allCreateRouteFns`. `createLazyFileRoute` is deliberately
|
|
1278
|
+
* absent: a lazy route file carries only the client half, so there is nothing
|
|
1279
|
+
* server-only in it to delete.
|
|
1280
|
+
*/
|
|
1281
|
+
var ROUTE_FNS = new Set(["createFileRoute", "createRootRoute", "createRootRouteWithContext"]);
|
|
1282
|
+
|
|
1283
|
+
/** Cheap pre-filter, so a module with no route call is never parsed. */
|
|
1284
|
+
var shouldRun = function shouldRun(code) {
|
|
1285
|
+
return slicedToArray._toConsumableArray(ROUTE_FNS).some(function (name) {
|
|
1286
|
+
return code.includes(name);
|
|
1287
|
+
}) && slicedToArray._toConsumableArray(SERVER_ONLY_OPTIONS).some(function (name) {
|
|
1288
|
+
return code.includes(name);
|
|
1289
|
+
});
|
|
1290
|
+
};
|
|
1291
|
+
/**
|
|
1292
|
+
* The options object of a route call, in either of its two shapes.
|
|
1293
|
+
*
|
|
1294
|
+
* createRootRoute({ ... }) the argument
|
|
1295
|
+
* createFileRoute('/x')({ ... }) the argument of the *returned* call
|
|
1296
|
+
*/
|
|
1297
|
+
function routeOptionsOf(node, stack) {
|
|
1298
|
+
var _node$arguments;
|
|
1299
|
+
var parent = stack[stack.length - 1];
|
|
1300
|
+
var direct = (_node$arguments = node.arguments) === null || _node$arguments === void 0 ? void 0 : _node$arguments[0];
|
|
1301
|
+
if ((parent === null || parent === void 0 ? void 0 : parent.type) === "CallExpression" && parent.callee === node) {
|
|
1302
|
+
var _parent$arguments;
|
|
1303
|
+
var curried = (_parent$arguments = parent.arguments) === null || _parent$arguments === void 0 ? void 0 : _parent$arguments[0];
|
|
1304
|
+
return (curried === null || curried === void 0 ? void 0 : curried.type) === "ObjectExpression" ? curried : null;
|
|
1305
|
+
}
|
|
1306
|
+
return (direct === null || direct === void 0 ? void 0 : direct.type) === "ObjectExpression" ? direct : null;
|
|
1307
|
+
}
|
|
1308
|
+
|
|
1309
|
+
/** A property's own name, for the plain `key: value` form only. */
|
|
1310
|
+
function propertyName(property) {
|
|
1311
|
+
// Matching Start, which filters on `isObjectProperty`: a shorthand method
|
|
1312
|
+
// (`server() {}`) and a spread are both left alone. A method would be a
|
|
1313
|
+
// strange way to write these options, and a spread cannot be read statically.
|
|
1314
|
+
if (property.type !== "Property" || property.method) return null;
|
|
1315
|
+
var key = property.key;
|
|
1316
|
+
if (!key) return null;
|
|
1317
|
+
if (property.computed) return null;
|
|
1318
|
+
if (key.type === "Identifier") return String(key.name);
|
|
1319
|
+
if (key.type === "Literal") return String(key.value);
|
|
1320
|
+
return null;
|
|
1321
|
+
}
|
|
1322
|
+
|
|
1323
|
+
/**
|
|
1324
|
+
* Edits that delete the flagged properties of one object literal.
|
|
1325
|
+
*
|
|
1326
|
+
* Deleting each property on its own does not work. A property's own range
|
|
1327
|
+
* leaves the comma behind (`{ a: 1, , c: 3 }`, which does not parse), and
|
|
1328
|
+
* extending each one over its neighbouring comma makes *adjacent* deletions
|
|
1329
|
+
* overlap -- two edits claiming the same comma, which corrupts the source
|
|
1330
|
+
* rather than failing.
|
|
1331
|
+
*
|
|
1332
|
+
* So deletions are grouped into runs of consecutive properties, and each run
|
|
1333
|
+
* takes exactly one comma: the one before it when it has a surviving property
|
|
1334
|
+
* to its left, the one after it otherwise.
|
|
1335
|
+
*/
|
|
1336
|
+
function deleteProperties(code, properties, doomed) {
|
|
1337
|
+
var edits = [];
|
|
1338
|
+
for (var i = 0; i < properties.length; i++) {
|
|
1339
|
+
if (!doomed.has(properties[i])) continue;
|
|
1340
|
+
var j = i;
|
|
1341
|
+
while (j + 1 < properties.length && doomed.has(properties[j + 1])) j++;
|
|
1342
|
+
if (i > 0) {
|
|
1343
|
+
// From the end of the property before the run, which takes the comma
|
|
1344
|
+
// separating them.
|
|
1345
|
+
edits.push({
|
|
1346
|
+
start: properties[i - 1].end,
|
|
1347
|
+
end: properties[j].end,
|
|
1348
|
+
text: ""
|
|
1349
|
+
});
|
|
1350
|
+
} else if (j + 1 < properties.length) {
|
|
1351
|
+
// Run starts the object: take the comma that follows it instead.
|
|
1352
|
+
edits.push({
|
|
1353
|
+
start: properties[0].start,
|
|
1354
|
+
end: properties[j + 1].start,
|
|
1355
|
+
text: ""
|
|
1356
|
+
});
|
|
1357
|
+
} else {
|
|
1358
|
+
// The whole object goes. There is no separating comma, but there may be
|
|
1359
|
+
// a trailing one, and `{ , }` does not parse any better than `{ ,`.
|
|
1360
|
+
var end = properties[j].end;
|
|
1361
|
+
var cursor = end;
|
|
1362
|
+
while (cursor < code.length && /\s/.test(code[cursor])) cursor++;
|
|
1363
|
+
if (code[cursor] === ",") end = cursor + 1;
|
|
1364
|
+
edits.push({
|
|
1365
|
+
start: properties[0].start,
|
|
1366
|
+
end: end,
|
|
1367
|
+
text: ""
|
|
1368
|
+
});
|
|
1369
|
+
}
|
|
1370
|
+
i = j;
|
|
1371
|
+
}
|
|
1372
|
+
return edits;
|
|
1373
|
+
}
|
|
1374
|
+
|
|
1375
|
+
/**
|
|
1376
|
+
* Removes server-only route options from one module.
|
|
1377
|
+
*
|
|
1378
|
+
* Returns `null` when there is nothing to do, so the caller pays no parse.
|
|
1379
|
+
* Server and rsc targets always get `null`: they are the ones that need these.
|
|
1380
|
+
*/
|
|
1381
|
+
function transformRouteNodes(_x, _x2, _x3) {
|
|
1382
|
+
return _transformRouteNodes.apply(this, arguments);
|
|
1383
|
+
}
|
|
1384
|
+
function _transformRouteNodes() {
|
|
1385
|
+
_transformRouteNodes = slicedToArray._asyncToGenerator(/*#__PURE__*/slicedToArray._regenerator().m(function _callee(moduleId, code, target) {
|
|
1386
|
+
var ast, imported, edits, removed;
|
|
1387
|
+
return slicedToArray._regenerator().w(function (_context) {
|
|
1388
|
+
while (1) switch (_context.n) {
|
|
1389
|
+
case 0:
|
|
1390
|
+
if (!(target !== "client")) {
|
|
1391
|
+
_context.n = 1;
|
|
1392
|
+
break;
|
|
1393
|
+
}
|
|
1394
|
+
return _context.a(2, null);
|
|
1395
|
+
case 1:
|
|
1396
|
+
if (shouldRun(code)) {
|
|
1397
|
+
_context.n = 2;
|
|
1398
|
+
break;
|
|
1399
|
+
}
|
|
1400
|
+
return _context.a(2, null);
|
|
1401
|
+
case 2:
|
|
1402
|
+
_context.n = 3;
|
|
1403
|
+
return parse(moduleId, code);
|
|
1404
|
+
case 3:
|
|
1405
|
+
ast = _context.v;
|
|
1406
|
+
imported = tanstackImports(ast);
|
|
1407
|
+
if (!(imported.size === 0)) {
|
|
1408
|
+
_context.n = 4;
|
|
1409
|
+
break;
|
|
1410
|
+
}
|
|
1411
|
+
return _context.a(2, null);
|
|
1412
|
+
case 4:
|
|
1413
|
+
edits = [];
|
|
1414
|
+
removed = [];
|
|
1415
|
+
walk(ast, function (node, stack) {
|
|
1416
|
+
var _options$properties;
|
|
1417
|
+
if (node.type !== "CallExpression") return;
|
|
1418
|
+
var callee = node.callee;
|
|
1419
|
+
if ((callee === null || callee === void 0 ? void 0 : callee.type) !== "Identifier") return;
|
|
1420
|
+
var name = String(callee.name);
|
|
1421
|
+
if (!ROUTE_FNS.has(name) || !imported.has(name)) return;
|
|
1422
|
+
var options = routeOptionsOf(node, stack);
|
|
1423
|
+
if (!options) return;
|
|
1424
|
+
var properties = (_options$properties = options.properties) !== null && _options$properties !== void 0 ? _options$properties : [];
|
|
1425
|
+
var doomed = new Set();
|
|
1426
|
+
var _iterator = slicedToArray._createForOfIteratorHelper(properties),
|
|
1427
|
+
_step;
|
|
1428
|
+
try {
|
|
1429
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
1430
|
+
var property = _step.value;
|
|
1431
|
+
var key = propertyName(property);
|
|
1432
|
+
if (!key || !SERVER_ONLY_OPTIONS.has(key)) continue;
|
|
1433
|
+
doomed.add(property);
|
|
1434
|
+
removed.push(key);
|
|
1435
|
+
}
|
|
1436
|
+
} catch (err) {
|
|
1437
|
+
_iterator.e(err);
|
|
1438
|
+
} finally {
|
|
1439
|
+
_iterator.f();
|
|
1440
|
+
}
|
|
1441
|
+
if (doomed.size) edits.push.apply(edits, slicedToArray._toConsumableArray(deleteProperties(code, properties, doomed)));
|
|
1442
|
+
});
|
|
1443
|
+
if (!(edits.length === 0)) {
|
|
1444
|
+
_context.n = 5;
|
|
1445
|
+
break;
|
|
1446
|
+
}
|
|
1447
|
+
return _context.a(2, null);
|
|
1448
|
+
case 5:
|
|
1449
|
+
return _context.a(2, {
|
|
1450
|
+
code: applyEdits(code, edits),
|
|
1451
|
+
removed: removed
|
|
1452
|
+
});
|
|
1453
|
+
}
|
|
1454
|
+
}, _callee);
|
|
1455
|
+
}));
|
|
1456
|
+
return _transformRouteNodes.apply(this, arguments);
|
|
1457
|
+
}
|
|
1458
|
+
|
|
1459
|
+
/**
|
|
1460
|
+
* JSON with comments and trailing commas, which is what tsconfig.json is.
|
|
1461
|
+
*
|
|
1462
|
+
* Written as a scanner rather than a regex on purpose: `"url": "https://x"`
|
|
1463
|
+
* contains `//`, and a regex that strips comments without tracking string state
|
|
1464
|
+
* truncates the file there and throws a parse error pointing at the wrong line.
|
|
1465
|
+
*/
|
|
1466
|
+
function parseJsonc(text) {
|
|
1467
|
+
var out = "";
|
|
1468
|
+
var i = 0;
|
|
1469
|
+
while (i < text.length) {
|
|
1470
|
+
var ch = text[i];
|
|
1471
|
+
if (ch === '"') {
|
|
1472
|
+
// Copy the whole string literal, escapes included, untouched.
|
|
1473
|
+
out += ch;
|
|
1474
|
+
i++;
|
|
1475
|
+
while (i < text.length) {
|
|
1476
|
+
var c = text[i];
|
|
1477
|
+
out += c;
|
|
1478
|
+
i++;
|
|
1479
|
+
if (c === "\\") {
|
|
1480
|
+
if (i < text.length) out += text[i++];
|
|
1481
|
+
continue;
|
|
1482
|
+
}
|
|
1483
|
+
if (c === '"') break;
|
|
1484
|
+
}
|
|
1485
|
+
continue;
|
|
1486
|
+
}
|
|
1487
|
+
if (ch === "/" && text[i + 1] === "/") {
|
|
1488
|
+
while (i < text.length && text[i] !== "\n") i++;
|
|
1489
|
+
continue;
|
|
1490
|
+
}
|
|
1491
|
+
if (ch === "/" && text[i + 1] === "*") {
|
|
1492
|
+
i += 2;
|
|
1493
|
+
while (i < text.length && !(text[i] === "*" && text[i + 1] === "/")) i++;
|
|
1494
|
+
i += 2;
|
|
1495
|
+
continue;
|
|
1496
|
+
}
|
|
1497
|
+
out += ch;
|
|
1498
|
+
i++;
|
|
1499
|
+
}
|
|
1500
|
+
// Trailing commas, now that every remaining comma is structural.
|
|
1501
|
+
return JSON.parse(out.replace(/,(\s*[}\]])/g, "$1"));
|
|
1502
|
+
}
|
|
1503
|
+
|
|
1504
|
+
/** One `paths` entry, pre-split on its wildcard. */
|
|
1505
|
+
|
|
1506
|
+
/**
|
|
1507
|
+
* Reads tsconfig.json out of the file record and builds the matcher.
|
|
1508
|
+
*
|
|
1509
|
+
* Returns null when the project configures no aliases, which is the common
|
|
1510
|
+
* case and costs nothing.
|
|
1511
|
+
*/
|
|
1512
|
+
function aliasMap(files, warn) {
|
|
1513
|
+
var _config$compilerOptio, _config$compilerOptio2;
|
|
1514
|
+
var entry = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "tsconfig.json";
|
|
1515
|
+
var config = readConfig(files, entry, warn, new Set());
|
|
1516
|
+
var paths = config === null || config === void 0 || (_config$compilerOptio = config.compilerOptions) === null || _config$compilerOptio === void 0 ? void 0 : _config$compilerOptio.paths;
|
|
1517
|
+
var baseUrl = config === null || config === void 0 || (_config$compilerOptio2 = config.compilerOptions) === null || _config$compilerOptio2 === void 0 ? void 0 : _config$compilerOptio2.baseUrl;
|
|
1518
|
+
// A project can configure either one without the other, and baseUrl alone is
|
|
1519
|
+
// enough to change how a bare specifier resolves.
|
|
1520
|
+
if ((!paths || Object.keys(paths).length === 0) && baseUrl === undefined) return null;
|
|
1521
|
+
|
|
1522
|
+
// `baseUrl` is relative to the tsconfig that declared it. Since TS 4.1 paths
|
|
1523
|
+
// work without one, resolved against the tsconfig's own directory -- so the
|
|
1524
|
+
// fallback here is the directory, not the project root.
|
|
1525
|
+
var base = resolve(dirname(entry), baseUrl !== null && baseUrl !== void 0 ? baseUrl : ".");
|
|
1526
|
+
var patterns = [];
|
|
1527
|
+
for (var _i = 0, _Object$entries = Object.entries(paths !== null && paths !== void 0 ? paths : {}); _i < _Object$entries.length; _i++) {
|
|
1528
|
+
var _Object$entries$_i = slicedToArray._slicedToArray(_Object$entries[_i], 2),
|
|
1529
|
+
pattern = _Object$entries$_i[0],
|
|
1530
|
+
targets = _Object$entries$_i[1];
|
|
1531
|
+
var star = pattern.indexOf("*");
|
|
1532
|
+
if (star !== pattern.lastIndexOf("*")) {
|
|
1533
|
+
warn("tsconfig paths pattern '".concat(pattern, "' has more than one '*' and is ignored."));
|
|
1534
|
+
continue;
|
|
1535
|
+
}
|
|
1536
|
+
patterns.push({
|
|
1537
|
+
prefix: star === -1 ? pattern : pattern.slice(0, star),
|
|
1538
|
+
suffix: star === -1 ? "" : pattern.slice(star + 1),
|
|
1539
|
+
wildcard: star !== -1,
|
|
1540
|
+
targets: targets.map(function (target) {
|
|
1541
|
+
return resolve(base, target);
|
|
1542
|
+
})
|
|
1543
|
+
});
|
|
1544
|
+
}
|
|
1545
|
+
|
|
1546
|
+
// TypeScript picks the pattern with the longest literal prefix, so `@/ui/*`
|
|
1547
|
+
// beats `@/*` for `@/ui/card` regardless of declaration order.
|
|
1548
|
+
patterns.sort(function (a, b) {
|
|
1549
|
+
return b.prefix.length - a.prefix.length;
|
|
1550
|
+
});
|
|
1551
|
+
return {
|
|
1552
|
+
patterns: Object.keys(paths !== null && paths !== void 0 ? paths : {}),
|
|
1553
|
+
baseUrlCandidate: function baseUrlCandidate(specifier) {
|
|
1554
|
+
return baseUrl === undefined ? null : resolve(base, specifier);
|
|
1555
|
+
},
|
|
1556
|
+
candidates: function candidates(specifier) {
|
|
1557
|
+
var _loop = function _loop() {
|
|
1558
|
+
var pattern = _patterns[_i2];
|
|
1559
|
+
if (!pattern.wildcard) {
|
|
1560
|
+
if (specifier === pattern.prefix) return {
|
|
1561
|
+
v: slicedToArray._toConsumableArray(pattern.targets)
|
|
1562
|
+
};
|
|
1563
|
+
return 0; // continue
|
|
1564
|
+
}
|
|
1565
|
+
if (!specifier.startsWith(pattern.prefix) || !specifier.endsWith(pattern.suffix) || specifier.length < pattern.prefix.length + pattern.suffix.length) {
|
|
1566
|
+
return 0; // continue
|
|
1567
|
+
}
|
|
1568
|
+
var matched = specifier.slice(pattern.prefix.length, specifier.length - pattern.suffix.length);
|
|
1569
|
+
return {
|
|
1570
|
+
v: pattern.targets.map(function (target) {
|
|
1571
|
+
return target.replace("*", matched);
|
|
1572
|
+
})
|
|
1573
|
+
};
|
|
1574
|
+
},
|
|
1575
|
+
_ret;
|
|
1576
|
+
for (var _i2 = 0, _patterns = patterns; _i2 < _patterns.length; _i2++) {
|
|
1577
|
+
_ret = _loop();
|
|
1578
|
+
if (_ret === 0) continue;
|
|
1579
|
+
if (_ret) return _ret.v;
|
|
1580
|
+
}
|
|
1581
|
+
return [];
|
|
1582
|
+
}
|
|
1583
|
+
};
|
|
1584
|
+
}
|
|
1585
|
+
|
|
1586
|
+
/** Follows `extends` through the file record. Package extends cannot be read. */
|
|
1587
|
+
function readConfig(files, path, warn, seen) {
|
|
1588
|
+
var _config, _config$compilerOptio4, _config$compilerOptio5, _parent$compilerOptio;
|
|
1589
|
+
if (seen.has(path)) return null; // a cycle; whatever we have is enough
|
|
1590
|
+
seen.add(path);
|
|
1591
|
+
var text = files[path];
|
|
1592
|
+
if (text === undefined) return null;
|
|
1593
|
+
var config;
|
|
1594
|
+
try {
|
|
1595
|
+
config = parseJsonc(text);
|
|
1596
|
+
} catch (error) {
|
|
1597
|
+
var _message;
|
|
1598
|
+
warn("Could not parse ".concat(path, ": ").concat(String((_message = error === null || error === void 0 ? void 0 : error.message) !== null && _message !== void 0 ? _message : error)));
|
|
1599
|
+
return null;
|
|
1600
|
+
}
|
|
1601
|
+
if (!((_config = config) !== null && _config !== void 0 && _config["extends"])) return config;
|
|
1602
|
+
|
|
1603
|
+
// Only a relative extends can be followed: a package one ("extends":
|
|
1604
|
+
// "@tsconfig/node20/tsconfig.json") lives in node_modules, which a browser
|
|
1605
|
+
// build does not have. Worth saying out loud rather than silently resolving
|
|
1606
|
+
// half the aliases, because the base config is where a monorepo usually puts
|
|
1607
|
+
// them.
|
|
1608
|
+
if (!config["extends"].startsWith(".")) {
|
|
1609
|
+
var _config$compilerOptio3;
|
|
1610
|
+
if (!((_config$compilerOptio3 = config.compilerOptions) !== null && _config$compilerOptio3 !== void 0 && _config$compilerOptio3.paths)) {
|
|
1611
|
+
warn("".concat(path, " extends '").concat(config["extends"], "', which is a package and cannot be read here. ") + "Any 'paths' it declares will not apply -- declare them in ".concat(path, " instead."));
|
|
1612
|
+
}
|
|
1613
|
+
return config;
|
|
1614
|
+
}
|
|
1615
|
+
var parentPath = resolveConfigPath(files, resolve(dirname(path), config["extends"]));
|
|
1616
|
+
var parent = parentPath ? readConfig(files, parentPath, warn, seen) : null;
|
|
1617
|
+
if (!parent) return config;
|
|
1618
|
+
|
|
1619
|
+
// The child wins, and `paths` replaces rather than merges -- which is what
|
|
1620
|
+
// TypeScript does.
|
|
1621
|
+
return {
|
|
1622
|
+
compilerOptions: slicedToArray._objectSpread2(slicedToArray._objectSpread2(slicedToArray._objectSpread2({}, parent.compilerOptions), config.compilerOptions), {}, {
|
|
1623
|
+
// baseUrl in the parent was relative to the *parent*, and readConfig
|
|
1624
|
+
// returns it unresolved, so a parent baseUrl with a child that sets none
|
|
1625
|
+
// is the one case this gets wrong. Rare enough to name rather than model.
|
|
1626
|
+
paths: (_config$compilerOptio4 = (_config$compilerOptio5 = config.compilerOptions) === null || _config$compilerOptio5 === void 0 ? void 0 : _config$compilerOptio5.paths) !== null && _config$compilerOptio4 !== void 0 ? _config$compilerOptio4 : (_parent$compilerOptio = parent.compilerOptions) === null || _parent$compilerOptio === void 0 ? void 0 : _parent$compilerOptio.paths
|
|
1627
|
+
})
|
|
1628
|
+
};
|
|
1629
|
+
}
|
|
1630
|
+
|
|
1631
|
+
/** `extends: './base'` may omit the .json. */
|
|
1632
|
+
function resolveConfigPath(files, path) {
|
|
1633
|
+
for (var _i3 = 0, _arr = [path, "".concat(path, ".json")]; _i3 < _arr.length; _i3++) {
|
|
1634
|
+
var candidate = _arr[_i3];
|
|
1635
|
+
if (candidate in files) return candidate;
|
|
1636
|
+
}
|
|
1637
|
+
return null;
|
|
1638
|
+
}
|
|
1639
|
+
|
|
1640
|
+
// autoCodeSplitting.
|
|
1641
|
+
//
|
|
1642
|
+
// Start splits a route file in two: the *reference* keeps the loader and the
|
|
1643
|
+
// route's critical options and replaces the component with
|
|
1644
|
+
// `lazyRouteComponent(() => import('...?tsr-split=component'))`, and the
|
|
1645
|
+
// *virtual* module holds the component itself. The builder already handles the
|
|
1646
|
+
// resulting dynamic import; what it cannot do is produce the split.
|
|
1647
|
+
//
|
|
1648
|
+
// That split is `@tanstack/router-plugin`'s, built on @babel/core, and it does
|
|
1649
|
+
// not run in a browser. Bundled for the browser target it comes to 1.14 MB and
|
|
1650
|
+
// evaluates as far as `require('@babel/traverse')` -- Babel requires its own
|
|
1651
|
+
// packages by name at module scope, which is the reason @babel/standalone
|
|
1652
|
+
// exists at all. Verified, not assumed: the probe got as far as a real Chromium.
|
|
1653
|
+
//
|
|
1654
|
+
// So this is a capability the caller supplies, like Tailwind's module loader.
|
|
1655
|
+
// `packages/publish` has Node and passes one. A browser build does not split,
|
|
1656
|
+
// and unlike a missing Tailwind plugin that costs *bytes rather than
|
|
1657
|
+
// correctness* -- an unsplit route component renders exactly the same, it just
|
|
1658
|
+
// ships in the entry. That is why this is allowed to differ by environment
|
|
1659
|
+
// where `@plugin` is not.
|
|
1660
|
+
|
|
1661
|
+
/** Query Start's splitter emits, e.g. `?tsr-split=component---errorComponent`. */
|
|
1662
|
+
var SPLIT_QUERY = "tsr-split";
|
|
1663
|
+
|
|
1664
|
+
/** Is this a route file, i.e. one the splitter should look at? */
|
|
1665
|
+
var isRouteFile = function isRouteFile(path) {
|
|
1666
|
+
var routesDir = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "src/routes/";
|
|
1667
|
+
return path.startsWith(routesDir) && /\.(tsx?|jsx?)$/.test(path);
|
|
1668
|
+
};
|
|
1669
|
+
/**
|
|
1670
|
+
* Reads `./posts.tsx?tsr-split=component---errorComponent`.
|
|
1671
|
+
*
|
|
1672
|
+
* Returns null for anything else, including a `?raw` or `?url` query, so the
|
|
1673
|
+
* caller can fall through to its other handling.
|
|
1674
|
+
*/
|
|
1675
|
+
function parseSplitRequest(source) {
|
|
1676
|
+
var _source$split = source.split("?"),
|
|
1677
|
+
_source$split2 = slicedToArray._slicedToArray(_source$split, 2),
|
|
1678
|
+
path = _source$split2[0],
|
|
1679
|
+
query = _source$split2[1];
|
|
1680
|
+
if (!path || !query) return null;
|
|
1681
|
+
var match = new RegExp("(?:^|&)".concat(SPLIT_QUERY, "=([^&]*)")).exec(query);
|
|
1682
|
+
if (!match) return null;
|
|
1683
|
+
return {
|
|
1684
|
+
path: path,
|
|
1685
|
+
targets: match[1].split("---").filter(Boolean)
|
|
1686
|
+
};
|
|
1687
|
+
}
|
|
1688
|
+
|
|
1689
|
+
var DIRECTIVE = /^\s*(['"])use client\1/;
|
|
1690
|
+
|
|
1691
|
+
/** Cheap check before paying for a parse. */
|
|
1692
|
+
var hasUseClient = function hasUseClient(code) {
|
|
1693
|
+
return DIRECTIVE.test(code);
|
|
1694
|
+
};
|
|
1695
|
+
/** Export names of one module, in source order. */
|
|
1696
|
+
function exportsOf(ast) {
|
|
1697
|
+
var names = [];
|
|
1698
|
+
for (var _i = 0, _arr = ast.body; _i < _arr.length; _i++) {
|
|
1699
|
+
var _declaration$id;
|
|
1700
|
+
var statement = _arr[_i];
|
|
1701
|
+
if (statement.type === "ExportDefaultDeclaration") {
|
|
1702
|
+
names.push("default");
|
|
1703
|
+
continue;
|
|
1704
|
+
}
|
|
1705
|
+
if (statement.type !== "ExportNamedDeclaration") continue;
|
|
1706
|
+
|
|
1707
|
+
// `export { a, b as c }`
|
|
1708
|
+
for (var _i2 = 0, _arr2 = (_statement$specifiers = statement.specifiers) !== null && _statement$specifiers !== void 0 ? _statement$specifiers : []; _i2 < _arr2.length; _i2++) {
|
|
1709
|
+
var _statement$specifiers, _specifier$exported;
|
|
1710
|
+
var specifier = _arr2[_i2];
|
|
1711
|
+
var exported = (_specifier$exported = specifier.exported) === null || _specifier$exported === void 0 ? void 0 : _specifier$exported.name;
|
|
1712
|
+
if (exported) names.push(String(exported));
|
|
1713
|
+
}
|
|
1714
|
+
|
|
1715
|
+
// `export const a = ...`, `export function b() {}`
|
|
1716
|
+
var declaration = statement.declaration;
|
|
1717
|
+
if (!declaration) continue;
|
|
1718
|
+
if (declaration.type === "VariableDeclaration") {
|
|
1719
|
+
for (var _i3 = 0, _arr3 = (_declaration$declarat = declaration.declarations) !== null && _declaration$declarat !== void 0 ? _declaration$declarat : []; _i3 < _arr3.length; _i3++) {
|
|
1720
|
+
var _declaration$declarat;
|
|
1721
|
+
var declarator = _arr3[_i3];
|
|
1722
|
+
// A destructured export has no single name to reference; the flight
|
|
1723
|
+
// protocol needs one, so it is not supported rather than silently
|
|
1724
|
+
// producing a reference that cannot resolve.
|
|
1725
|
+
var id = declarator.id;
|
|
1726
|
+
if ((id === null || id === void 0 ? void 0 : id.type) === "Identifier") names.push(String(id.name));
|
|
1727
|
+
}
|
|
1728
|
+
} else if ((_declaration$id = declaration.id) !== null && _declaration$id !== void 0 && _declaration$id.name) {
|
|
1729
|
+
names.push(String(declaration.id.name));
|
|
1730
|
+
}
|
|
1731
|
+
}
|
|
1732
|
+
return slicedToArray._toConsumableArray(new Set(names));
|
|
1733
|
+
}
|
|
1734
|
+
|
|
1735
|
+
/**
|
|
1736
|
+
* Finds every `"use client"` module in the project.
|
|
1737
|
+
*
|
|
1738
|
+
* Ids are assigned by sorted path rather than by discovery order, so the same
|
|
1739
|
+
* project always produces the same ids -- the rsc build writes them into the
|
|
1740
|
+
* flight payload and the ssr build writes them into the lookup map, and those
|
|
1741
|
+
* are separate passes that must agree.
|
|
1742
|
+
*/
|
|
1743
|
+
function collectClientModules(_x) {
|
|
1744
|
+
return _collectClientModules.apply(this, arguments);
|
|
1745
|
+
}
|
|
1746
|
+
|
|
1747
|
+
/**
|
|
1748
|
+
* The rsc-target replacement for a client module.
|
|
1749
|
+
*
|
|
1750
|
+
* `registerClientReference` comes from the flight server, which the rsc vendor
|
|
1751
|
+
* layer already carries. The first argument is the value a server component
|
|
1752
|
+
* would see if it tried to *call* the component -- React replaces it with a
|
|
1753
|
+
* throwing proxy, so the mistake surfaces as "cannot be rendered on the server"
|
|
1754
|
+
* rather than as a confusing render.
|
|
1755
|
+
*/
|
|
1756
|
+
function _collectClientModules() {
|
|
1757
|
+
_collectClientModules = slicedToArray._asyncToGenerator(/*#__PURE__*/slicedToArray._regenerator().m(function _callee(files) {
|
|
1758
|
+
var paths, modules, _iterator2, _step2, _step2$value, index, path, ast, exported, _t;
|
|
1759
|
+
return slicedToArray._regenerator().w(function (_context) {
|
|
1760
|
+
while (1) switch (_context.p = _context.n) {
|
|
1761
|
+
case 0:
|
|
1762
|
+
paths = Object.keys(files).filter(function (path) {
|
|
1763
|
+
return /\.(tsx?|jsx?)$/.test(path) && hasUseClient(files[path]);
|
|
1764
|
+
}).sort();
|
|
1765
|
+
modules = [];
|
|
1766
|
+
_iterator2 = slicedToArray._createForOfIteratorHelper(paths.entries());
|
|
1767
|
+
_context.p = 1;
|
|
1768
|
+
_iterator2.s();
|
|
1769
|
+
case 2:
|
|
1770
|
+
if ((_step2 = _iterator2.n()).done) {
|
|
1771
|
+
_context.n = 6;
|
|
1772
|
+
break;
|
|
1773
|
+
}
|
|
1774
|
+
_step2$value = slicedToArray._slicedToArray(_step2.value, 2), index = _step2$value[0], path = _step2$value[1];
|
|
1775
|
+
_context.n = 3;
|
|
1776
|
+
return parse(path, files[path]);
|
|
1777
|
+
case 3:
|
|
1778
|
+
ast = _context.v;
|
|
1779
|
+
exported = exportsOf(ast);
|
|
1780
|
+
if (!(exported.length === 0)) {
|
|
1781
|
+
_context.n = 4;
|
|
1782
|
+
break;
|
|
1783
|
+
}
|
|
1784
|
+
throw new Error("".concat(path, ": a \"use client\" module must export something. ") + "Its exports are what a server component can reference.");
|
|
1785
|
+
case 4:
|
|
1786
|
+
modules.push({
|
|
1787
|
+
path: path,
|
|
1788
|
+
id: "c".concat(index),
|
|
1789
|
+
exports: exported
|
|
1790
|
+
});
|
|
1791
|
+
case 5:
|
|
1792
|
+
_context.n = 2;
|
|
1793
|
+
break;
|
|
1794
|
+
case 6:
|
|
1795
|
+
_context.n = 8;
|
|
1796
|
+
break;
|
|
1797
|
+
case 7:
|
|
1798
|
+
_context.p = 7;
|
|
1799
|
+
_t = _context.v;
|
|
1800
|
+
_iterator2.e(_t);
|
|
1801
|
+
case 8:
|
|
1802
|
+
_context.p = 8;
|
|
1803
|
+
_iterator2.f();
|
|
1804
|
+
return _context.f(8);
|
|
1805
|
+
case 9:
|
|
1806
|
+
return _context.a(2, modules);
|
|
1807
|
+
}
|
|
1808
|
+
}, _callee, null, [[1, 7, 8, 9]]);
|
|
1809
|
+
}));
|
|
1810
|
+
return _collectClientModules.apply(this, arguments);
|
|
1811
|
+
}
|
|
1812
|
+
function clientReferenceStub(module,
|
|
1813
|
+
/**
|
|
1814
|
+
* Where `registerClientReference` comes from, from the build target.
|
|
1815
|
+
*
|
|
1816
|
+
* A parameter rather than an import for the reason the whole `build-target`
|
|
1817
|
+
* chunk exists: reading it from `@valbuild/vendor/externals` at compile time
|
|
1818
|
+
* is what made this package buildable only inside the platform's own
|
|
1819
|
+
* repository.
|
|
1820
|
+
*/
|
|
1821
|
+
flightServer) {
|
|
1822
|
+
var lines = ["import { registerClientReference as __ref } from ".concat(JSON.stringify(flightServer))];
|
|
1823
|
+
var _iterator = slicedToArray._createForOfIteratorHelper(module.exports),
|
|
1824
|
+
_step;
|
|
1825
|
+
try {
|
|
1826
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
1827
|
+
var name = _step.value;
|
|
1828
|
+
var value = "__ref({}, ".concat(JSON.stringify(module.id), ", ").concat(JSON.stringify(name), ")");
|
|
1829
|
+
lines.push(name === "default" ? "export default ".concat(value) : "export const ".concat(name, " = ").concat(value));
|
|
1830
|
+
}
|
|
1831
|
+
} catch (err) {
|
|
1832
|
+
_iterator.e(err);
|
|
1833
|
+
} finally {
|
|
1834
|
+
_iterator.f();
|
|
1835
|
+
}
|
|
1836
|
+
return lines.join("\n") + "\n";
|
|
1837
|
+
}
|
|
1838
|
+
|
|
1839
|
+
/**
|
|
1840
|
+
* What the ssr and client entries append so the reference map can be built.
|
|
1841
|
+
*
|
|
1842
|
+
* Namespaces rather than lazy importers: the whole app is one chunk, so there
|
|
1843
|
+
* is nothing to defer -- the module is already in memory by the time any
|
|
1844
|
+
* reference is resolved.
|
|
1845
|
+
*/
|
|
1846
|
+
function clientModuleRegistry(modules) {
|
|
1847
|
+
if (modules.length === 0) return "\nexport const __clientModules = {}\n";
|
|
1848
|
+
var imports = modules.map(function (module, index) {
|
|
1849
|
+
return "import * as __c".concat(index, " from ").concat(JSON.stringify(module.path));
|
|
1850
|
+
}).join("\n");
|
|
1851
|
+
var entries = modules.map(function (module, index) {
|
|
1852
|
+
return " ".concat(JSON.stringify(module.id), ": __c").concat(index, ",");
|
|
1853
|
+
}).join("\n");
|
|
1854
|
+
return "\n".concat(imports, "\nexport const __clientModules = {\n").concat(entries, "\n}\n");
|
|
1855
|
+
}
|
|
1856
|
+
|
|
1857
|
+
/**
|
|
1858
|
+
* What a build is targeting, fetched from the platform.
|
|
1859
|
+
*
|
|
1860
|
+
* One implementation, because there used to be two calls and everybody made
|
|
1861
|
+
* them by hand: `/__api/artifacts` for the base revision and `/__api/vendor`
|
|
1862
|
+
* for the project's layer, assembled at eighteen call sites. Two calls to
|
|
1863
|
+
* build one answer is also two chances to assemble a mismatched one -- a base
|
|
1864
|
+
* from after a deploy with a project layer built against the one before it.
|
|
1865
|
+
*
|
|
1866
|
+
* In THIS package, beside the `BuildInput.target` it produces, because the
|
|
1867
|
+
* callers that have to ask are the ones that carry the builder: a CLI on npm
|
|
1868
|
+
* and a Studio in a tab, neither of which can be given the answer at compile
|
|
1869
|
+
* time. `@valbuild/contract` would be the other candidate and is deliberately
|
|
1870
|
+
* types-only -- a user app must not need a runtime import from the platform.
|
|
1871
|
+
*
|
|
1872
|
+
* The route is no longer public. It says what a project depends on, which was
|
|
1873
|
+
* readable by anyone; it now takes the project's own `VAL_API_KEY`, or the
|
|
1874
|
+
* operator token, or nothing at all when the loader is running with
|
|
1875
|
+
* `CONTROL_PLANE_AUTH: open` -- which is how `wrangler dev` runs and why the
|
|
1876
|
+
* suites need no credential.
|
|
1877
|
+
*
|
|
1878
|
+
* NOT a project token, which the loader refuses on every route but
|
|
1879
|
+
* `/__api/publish`. A publisher that holds one asks content's
|
|
1880
|
+
* `GET /v1/build-target` instead, which resolves the project from the token
|
|
1881
|
+
* and asks the loader with the project's api key.
|
|
1882
|
+
*/
|
|
1883
|
+
|
|
1884
|
+
var headersFor = function headersFor(request) {
|
|
1885
|
+
return slicedToArray._objectSpread2({
|
|
1886
|
+
"x-platform-project": request.project
|
|
1887
|
+
}, request.token ? {
|
|
1888
|
+
authorization: "Bearer ".concat(request.token)
|
|
1889
|
+
} : {});
|
|
1890
|
+
};
|
|
1891
|
+
var endpoint = function endpoint(request) {
|
|
1892
|
+
var query = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "";
|
|
1893
|
+
return "".concat(request.loader.replace(/\/+$/, ""), "/__api/build-target").concat(query);
|
|
1894
|
+
};
|
|
1895
|
+
function fetchBuildTarget(_x) {
|
|
1896
|
+
return _fetchBuildTarget.apply(this, arguments);
|
|
1897
|
+
}
|
|
1898
|
+
|
|
1899
|
+
/**
|
|
1900
|
+
* Just this project's layer revision.
|
|
1901
|
+
*
|
|
1902
|
+
* The one question a publisher asks before it has built anything -- must I
|
|
1903
|
+
* send my dependency layer at all -- and the full answer reads the whole layer
|
|
1904
|
+
* out of storage for its specifier map, which is several megabytes to
|
|
1905
|
+
* establish a string comparison.
|
|
1906
|
+
*/
|
|
1907
|
+
function _fetchBuildTarget() {
|
|
1908
|
+
_fetchBuildTarget = slicedToArray._asyncToGenerator(/*#__PURE__*/slicedToArray._regenerator().m(function _callee(request) {
|
|
1909
|
+
var res, _t, _t2, _t3, _t4, _t5;
|
|
1910
|
+
return slicedToArray._regenerator().w(function (_context) {
|
|
1911
|
+
while (1) switch (_context.n) {
|
|
1912
|
+
case 0:
|
|
1913
|
+
_context.n = 1;
|
|
1914
|
+
return fetch(endpoint(request), {
|
|
1915
|
+
headers: headersFor(request)
|
|
1916
|
+
});
|
|
1917
|
+
case 1:
|
|
1918
|
+
res = _context.v;
|
|
1919
|
+
if (res.ok) {
|
|
1920
|
+
_context.n = 3;
|
|
1921
|
+
break;
|
|
1922
|
+
}
|
|
1923
|
+
_t = Error;
|
|
1924
|
+
_t2 = "the platform would not say what to build against: ".concat(res.status, " ");
|
|
1925
|
+
_t3 = "";
|
|
1926
|
+
_context.n = 2;
|
|
1927
|
+
return res.text();
|
|
1928
|
+
case 2:
|
|
1929
|
+
_t4 = _t3.concat.call(_t3, _context.v.slice(0, 200));
|
|
1930
|
+
_t5 = _t2 + _t4;
|
|
1931
|
+
throw new _t(_t5);
|
|
1932
|
+
case 3:
|
|
1933
|
+
_context.n = 4;
|
|
1934
|
+
return res.json();
|
|
1935
|
+
case 4:
|
|
1936
|
+
return _context.a(2, _context.v);
|
|
1937
|
+
}
|
|
1938
|
+
}, _callee);
|
|
1939
|
+
}));
|
|
1940
|
+
return _fetchBuildTarget.apply(this, arguments);
|
|
1941
|
+
}
|
|
1942
|
+
function fetchBuildTargetRev(_x2) {
|
|
1943
|
+
return _fetchBuildTargetRev.apply(this, arguments);
|
|
1944
|
+
}
|
|
1945
|
+
function _fetchBuildTargetRev() {
|
|
1946
|
+
_fetchBuildTargetRev = slicedToArray._asyncToGenerator(/*#__PURE__*/slicedToArray._regenerator().m(function _callee2(request) {
|
|
1947
|
+
var res;
|
|
1948
|
+
return slicedToArray._regenerator().w(function (_context2) {
|
|
1949
|
+
while (1) switch (_context2.n) {
|
|
1950
|
+
case 0:
|
|
1951
|
+
_context2.n = 1;
|
|
1952
|
+
return fetch(endpoint(request, "?only=rev"), {
|
|
1953
|
+
headers: headersFor(request)
|
|
1954
|
+
});
|
|
1955
|
+
case 1:
|
|
1956
|
+
res = _context2.v;
|
|
1957
|
+
if (res.ok) {
|
|
1958
|
+
_context2.n = 2;
|
|
1959
|
+
break;
|
|
1960
|
+
}
|
|
1961
|
+
return _context2.a(2, null);
|
|
1962
|
+
case 2:
|
|
1963
|
+
_context2.n = 3;
|
|
1964
|
+
return res.json();
|
|
1965
|
+
case 3:
|
|
1966
|
+
return _context2.a(2, _context2.v.project.rev);
|
|
1967
|
+
}
|
|
1968
|
+
}, _callee2);
|
|
1969
|
+
}));
|
|
1970
|
+
return _fetchBuildTargetRev.apply(this, arguments);
|
|
1971
|
+
}
|
|
1972
|
+
|
|
1973
|
+
/**
|
|
1974
|
+
* Filename of the entry chunk, in every target.
|
|
1975
|
+
*
|
|
1976
|
+
* Fixed rather than hashed because it is addressed by name from outside the
|
|
1977
|
+
* build: `app.js` in the isolate's module map, `/_app/app.js` from the shell's
|
|
1978
|
+
* client half. Everything the build splits off is content-addressed instead.
|
|
1979
|
+
*/
|
|
1980
|
+
var ENTRY_CHUNK = "app.js";
|
|
1981
|
+
|
|
1982
|
+
/**
|
|
1983
|
+
* The RSC build's entry, which is not the app's.
|
|
1984
|
+
*
|
|
1985
|
+
* See `rscEntrySource`: the rsc environment exists to host server functions,
|
|
1986
|
+
* and compiling the route tree under `react-server` breaks on the first
|
|
1987
|
+
* component that uses a hook or a context.
|
|
1988
|
+
*/
|
|
1989
|
+
var RSC_ENTRY_ID = "\0platform:rsc-entry";
|
|
1990
|
+
|
|
1991
|
+
/** The shared vendor layer, as seen from `rsc/app.js` one directory down. */
|
|
1992
|
+
/**
|
|
1993
|
+
* The platform's externalisation rules, as DATA rather than as an import.
|
|
1994
|
+
*
|
|
1995
|
+
* This module used to read `@valbuild/vendor/externals` at compile time, which
|
|
1996
|
+
* meant a builder could only ever be built in the same repository as the
|
|
1997
|
+
* vendor package it read. It now gets the same facts from the `BuildTarget`
|
|
1998
|
+
* the caller hands it -- `GET /__api/build-target` on the loader, or
|
|
1999
|
+
* `GET /v1/build-target` on content -- which is what makes the builder
|
|
2000
|
+
* movable, and is the whole point of the `build-target` chunk.
|
|
2001
|
+
*
|
|
2002
|
+
* The resolvers are one line each, deliberately: the RULE stays with the side
|
|
2003
|
+
* that owns the chunks (`resolveVendor` in externals.js says the same thing),
|
|
2004
|
+
* and what crosses the wire is the map it reads. A function cannot cross a
|
|
2005
|
+
* wire; a `Record<string, string>` can.
|
|
2006
|
+
*/
|
|
2007
|
+
function vendorRules(target) {
|
|
2008
|
+
var _target$base = target.base,
|
|
2009
|
+
modules = _target$base.modules,
|
|
2010
|
+
rscModules = _target$base.rscModules,
|
|
2011
|
+
paths = _target$base.paths;
|
|
2012
|
+
var chunk = function chunk(map, specifier, base) {
|
|
2013
|
+
return map[specifier] ? "".concat(base).concat(map[specifier], ".js") : null;
|
|
2014
|
+
};
|
|
2015
|
+
return {
|
|
2016
|
+
paths: paths,
|
|
2017
|
+
isBase: function isBase(specifier) {
|
|
2018
|
+
return specifier in modules;
|
|
2019
|
+
},
|
|
2020
|
+
isRsc: function isRsc(specifier) {
|
|
2021
|
+
return specifier in rscModules;
|
|
2022
|
+
},
|
|
2023
|
+
base: function base(specifier, from) {
|
|
2024
|
+
return chunk(modules, specifier, from);
|
|
2025
|
+
},
|
|
2026
|
+
rsc: function rsc(specifier, from) {
|
|
2027
|
+
return chunk(rscModules, specifier, from);
|
|
2028
|
+
},
|
|
2029
|
+
/** Everything externalised, which the build lists as `external`. */
|
|
2030
|
+
specifiers: Object.keys(modules),
|
|
2031
|
+
rscSpecifiers: Object.keys(rscModules)
|
|
2032
|
+
};
|
|
2033
|
+
}
|
|
2034
|
+
var BASE_FROM_RSC = "../vendor/";
|
|
2035
|
+
|
|
2036
|
+
/**
|
|
2037
|
+
* The RSC runtime, as the ssr and client builds see it.
|
|
2038
|
+
*
|
|
2039
|
+
* A module defining a server function that renders a server component imports
|
|
2040
|
+
* the runtime at module scope, and that module is also in the other two graphs
|
|
2041
|
+
* -- the route that calls the server function imports it. Only the rsc build
|
|
2042
|
+
* can supply the real thing, so the others get stubs.
|
|
2043
|
+
*
|
|
2044
|
+
* Throwing rather than no-op: under RSC these are never reached, because Start
|
|
2045
|
+
* routes every server function call to the rsc environment. If one *is*
|
|
2046
|
+
* reached, it means the build was published without `rsc`, and a clear error
|
|
2047
|
+
* beats a silent undefined.
|
|
2048
|
+
*/
|
|
2049
|
+
var RSC_RUNTIME_STUB_ID = "\0platform:rsc-runtime-stub";
|
|
2050
|
+
var RSC_RUNTIME_STUB = "\nconst outsideRsc = (name) => () => {\n throw new Error(\n name + '() needs the React Server Components build. This project was built ' +\n 'without it, so there is no rsc bundle for the server function to run in.',\n )\n}\nexport const renderServerComponent = outsideRsc('renderServerComponent')\nexport const createCompositeComponent = outsideRsc('createCompositeComponent')\nexport const CompositeComponent = outsideRsc('CompositeComponent')\n";
|
|
2051
|
+
|
|
2052
|
+
/**
|
|
2053
|
+
* A stylesheet imported from a dependency, as the *JS* graph sees it.
|
|
2054
|
+
*
|
|
2055
|
+
* It contributes to the page's CSS and nothing to its JavaScript, so the module
|
|
2056
|
+
* is empty -- the same treatment a relative `.css` import gets from
|
|
2057
|
+
* `moduleTypes`, which matches on extension and so does not cover a bare
|
|
2058
|
+
* specifier. Returning an id that still ends in `.css` would make rolldown try
|
|
2059
|
+
* to parse the empty module as CSS.
|
|
2060
|
+
*/
|
|
2061
|
+
var DEPENDENCY_CSS_ID = "\0platform:dependency-css";
|
|
2062
|
+
|
|
2063
|
+
/**
|
|
2064
|
+
* Marks a resolved id as a CSS module's name mapping.
|
|
2065
|
+
*
|
|
2066
|
+
* The id deliberately does NOT end in `.css`. `moduleTypes` picks a module's
|
|
2067
|
+
* type by extension, so `\0platform:css-module:card.module.css` is treated as CSS
|
|
2068
|
+
* and emptied -- the import then yields `undefined` and the component crashes
|
|
2069
|
+
* on `styles.card` at render time, not at build time. An index keeps the
|
|
2070
|
+
* extension out of the id entirely.
|
|
2071
|
+
*/
|
|
2072
|
+
/**
|
|
2073
|
+
* Marks a resolved id as the deferred half of a split route.
|
|
2074
|
+
*
|
|
2075
|
+
* Targets first and the path last, so the id never ends in `.tsx`:
|
|
2076
|
+
* `moduleTypes` picks a module's type by extension and would otherwise decide
|
|
2077
|
+
* what this module is. That trap has cost three bugs in this codebase already.
|
|
2078
|
+
*/
|
|
2079
|
+
var SPLIT_PREFIX = "\0platform:tsr-split:";
|
|
2080
|
+
|
|
2081
|
+
/**
|
|
2082
|
+
* The route and the halves a split id names, or null if it is not one.
|
|
2083
|
+
*
|
|
2084
|
+
* One parse, because two hooks read these ids: `load` builds the deferred half
|
|
2085
|
+
* from the route's source, and `transform` runs the env markers over what
|
|
2086
|
+
* `load` produced. They disagreeing about where the path starts would not fail
|
|
2087
|
+
* — it would quietly hand the markers pass a truncated filename, which only
|
|
2088
|
+
* decides whether it parses as TSX.
|
|
2089
|
+
*/
|
|
2090
|
+
function splitIdOf(id) {
|
|
2091
|
+
if (!id.startsWith(SPLIT_PREFIX)) return null;
|
|
2092
|
+
var rest = id.slice(SPLIT_PREFIX.length);
|
|
2093
|
+
var at = rest.indexOf(":");
|
|
2094
|
+
return {
|
|
2095
|
+
targets: rest.slice(0, at).split("---").filter(Boolean),
|
|
2096
|
+
path: rest.slice(at + 1)
|
|
2097
|
+
};
|
|
2098
|
+
}
|
|
2099
|
+
|
|
2100
|
+
/**
|
|
2101
|
+
* The project file a module id came from.
|
|
2102
|
+
*
|
|
2103
|
+
* A split module's id is virtual, but its *contents* came out of a route file
|
|
2104
|
+
* and its relative imports are written relative to that file. Resolving them
|
|
2105
|
+
* against the virtual id instead gives a path that is not in the project, and
|
|
2106
|
+
* the build fails on every import the deferred half carried with it.
|
|
2107
|
+
*/
|
|
2108
|
+
var sourcePathOf = function sourcePathOf(id) {
|
|
2109
|
+
if (!id) return "";
|
|
2110
|
+
if (!id.startsWith(SPLIT_PREFIX)) return id;
|
|
2111
|
+
var rest = id.slice(SPLIT_PREFIX.length);
|
|
2112
|
+
return rest.slice(rest.indexOf(":") + 1);
|
|
2113
|
+
};
|
|
2114
|
+
var CSS_MODULE_PREFIX = "\0platform:css-module:";
|
|
2115
|
+
|
|
2116
|
+
/** `./a.module.css?inline` -> `./a.module.css`. */
|
|
2117
|
+
var withoutCssQuery = function withoutCssQuery(path) {
|
|
2118
|
+
return path.split("?")[0];
|
|
2119
|
+
};
|
|
2120
|
+
|
|
2121
|
+
/** Marks a resolved id as an asset rather than a source file. */
|
|
2122
|
+
var ASSET_PREFIX = "\0platform:asset:";
|
|
2123
|
+
|
|
2124
|
+
/**
|
|
2125
|
+
* Where `import css from './styles.css?url'` resolves to.
|
|
2126
|
+
*
|
|
2127
|
+
* One URL for the whole project, because the CSS pass concatenates every
|
|
2128
|
+
* stylesheet into one -- so whichever sheet is asked for by URL, the answer is
|
|
2129
|
+
* the same file. The loader serves it, and skips its own <head> injection when
|
|
2130
|
+
* the project links it (see `linksOwnCss` on the build).
|
|
2131
|
+
*/
|
|
2132
|
+
var CSS_URL = "/_app/app.css";
|
|
2133
|
+
var CSS_URL_ID = "\0platform:css-url";
|
|
2134
|
+
|
|
2135
|
+
/**
|
|
2136
|
+
* Env vars whose names start with this are inlined into the *client* bundle as
|
|
2137
|
+
* well as the server one, and are therefore public: anyone can read them from
|
|
2138
|
+
* the served JavaScript. Everything else is inlined only server-side.
|
|
2139
|
+
*
|
|
2140
|
+
* An explicit prefix rather than a separate list, so the exposure of a variable
|
|
2141
|
+
* is visible at every use site in the user's code.
|
|
2142
|
+
*/
|
|
2143
|
+
/**
|
|
2144
|
+
* The project's own source, importable by the app that is made from it.
|
|
2145
|
+
*
|
|
2146
|
+
* `import { FILES } from 'platform:project-source'` -- how a host hands a CMS its
|
|
2147
|
+
* content when there is no filesystem to read it from. Val's in-memory store is
|
|
2148
|
+
* the case this exists for.
|
|
2149
|
+
*
|
|
2150
|
+
* Emitted by the BUILD, from the same record the build is made of, and that is
|
|
2151
|
+
* the whole point. It used to be a chunk of the project's VENDOR LAYER, which
|
|
2152
|
+
* made it dependency-shaped: the layer changes when `package.json` does, so a
|
|
2153
|
+
* publisher reusing a layer by reference -- which is every publish from the
|
|
2154
|
+
* studio tab, because a tab cannot build one -- shipped new code beside a
|
|
2155
|
+
* frozen copy of the source. The symptom was precise and awful: the edit WAS in
|
|
2156
|
+
* the client bundle, so the page hydrated with the new content, while anything
|
|
2157
|
+
* read on the SERVER (`head` metadata, a redirect) still saw the source as it
|
|
2158
|
+
* was at the last CLI publish.
|
|
2159
|
+
*
|
|
2160
|
+
* Server-side only. A client bundle carrying every source file of the project
|
|
2161
|
+
* would be both a leak and, for a real app, enormous.
|
|
2162
|
+
*/
|
|
2163
|
+
var PROJECT_SOURCE = "platform:project-source";
|
|
2164
|
+
var PROJECT_SOURCE_ID = "\0platform:project-source";
|
|
2165
|
+
var PUBLIC_PREFIX = "PUBLIC_";
|
|
2166
|
+
var VALID_KEY = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
2167
|
+
/**
|
|
2168
|
+
* Resolves the user's file tree and hard-externalises everything else.
|
|
2169
|
+
*
|
|
2170
|
+
* There is deliberately no node_modules resolution here. Every dependency is a
|
|
2171
|
+
* vendor external, so the build graph is exactly the user's own files, which is
|
|
2172
|
+
* what keeps this fast enough to run on every publish and why the browser build
|
|
2173
|
+
* needs no virtual filesystem at all.
|
|
2174
|
+
*/
|
|
2175
|
+
function projectPlugin(files, projectSource, splitter, cssModules, aliases, assets, assetUrls, vendorBase, projectVendorBase, projectVendor, vendor, warnings, target, seenIds, clientModules, isRsc) {
|
|
2176
|
+
return {
|
|
2177
|
+
name: "platform:project",
|
|
2178
|
+
resolveId: function resolveId(source, importer) {
|
|
2179
|
+
var _projectVendor$module;
|
|
2180
|
+
if (source === REGISTRY_ID) return REGISTRY_ID;
|
|
2181
|
+
if (source === RSC_ENTRY_ID) return RSC_ENTRY_ID;
|
|
2182
|
+
if (source === PROJECT_SOURCE) {
|
|
2183
|
+
// Refused for the browser rather than emitted and hoped about: this is
|
|
2184
|
+
// every source file of the project, and the mistake it prevents -- a
|
|
2185
|
+
// component importing it "just to read a title" -- is a leak nothing
|
|
2186
|
+
// else would notice.
|
|
2187
|
+
if (target === "client") {
|
|
2188
|
+
warnings.push("'".concat(PROJECT_SOURCE, "' is server-only: it carries the project's entire source. ") + "Import it from a server route handler or a createServerFn handler, not from " + "a component or a loader.");
|
|
2189
|
+
return null;
|
|
2190
|
+
}
|
|
2191
|
+
return PROJECT_SOURCE_ID;
|
|
2192
|
+
}
|
|
2193
|
+
// Before the vendor sets: this is a bare specifier, but it names a
|
|
2194
|
+
// stylesheet rather than a module.
|
|
2195
|
+
if (isCss(source) && projectVendor !== null && projectVendor !== void 0 && projectVendor.css && source in projectVendor.css) {
|
|
2196
|
+
return DEPENDENCY_CSS_ID;
|
|
2197
|
+
}
|
|
2198
|
+
if (source === RSC_RUNTIME_STUB_ID) return RSC_RUNTIME_STUB_ID;
|
|
2199
|
+
|
|
2200
|
+
// The rsc pass has its own vendor set, and the difference is not just
|
|
2201
|
+
// which React: it is narrower on purpose. `react-dom/client` is absent
|
|
2202
|
+
// because the react-server condition refuses it outright, so importing it
|
|
2203
|
+
// from a server component fails here, naming the package, rather than in
|
|
2204
|
+
// a cold isolate that will not boot.
|
|
2205
|
+
if (isRsc) {
|
|
2206
|
+
// The RSC runtime lives in the shell, not in a vendor chunk; see
|
|
2207
|
+
// RSC_RUNTIME_PATH. `rsc/app.js` reaches `rsc/runtime.js` as a sibling.
|
|
2208
|
+
if (source === vendor.paths.rscRuntimeSpecifier) {
|
|
2209
|
+
return {
|
|
2210
|
+
id: vendor.paths.rscRuntimePath,
|
|
2211
|
+
external: true
|
|
2212
|
+
};
|
|
2213
|
+
}
|
|
2214
|
+
// The react-server layer next: whatever a server component renders
|
|
2215
|
+
// with has to come from there, or it gets a React with no hooks.
|
|
2216
|
+
if (vendor.isRsc(source)) {
|
|
2217
|
+
return {
|
|
2218
|
+
id: vendor.rsc(source, vendorBase),
|
|
2219
|
+
external: true
|
|
2220
|
+
};
|
|
2221
|
+
}
|
|
2222
|
+
// Everything else from the *normal* layer. The rsc bundle's other
|
|
2223
|
+
// dependencies -- `createServerFn`, the rpc helpers -- are not
|
|
2224
|
+
// rendering code, and their react-server builds pull React rendering
|
|
2225
|
+
// machinery that fails at module scope. Pointing at the same chunk the
|
|
2226
|
+
// shell uses also keeps it to one instance.
|
|
2227
|
+
var shared = vendor.base(source, BASE_FROM_RSC);
|
|
2228
|
+
if (shared) return {
|
|
2229
|
+
id: shared,
|
|
2230
|
+
external: true
|
|
2231
|
+
};
|
|
2232
|
+
} else {
|
|
2233
|
+
// The ssr and client graphs reach the runtime through the module that
|
|
2234
|
+
// defines the server function; see RSC_RUNTIME_STUB.
|
|
2235
|
+
if (source === vendor.paths.rscRuntimeSpecifier) return RSC_RUNTIME_STUB_ID;
|
|
2236
|
+
if (vendor.isBase(source)) {
|
|
2237
|
+
return {
|
|
2238
|
+
id: vendor.base(source, vendorBase),
|
|
2239
|
+
external: true
|
|
2240
|
+
};
|
|
2241
|
+
}
|
|
2242
|
+
}
|
|
2243
|
+
|
|
2244
|
+
// The project's own layer, resolved exactly like the base one -- an
|
|
2245
|
+
// external pointing at a chunk someone else built. The user's module
|
|
2246
|
+
// graph is still only their own files.
|
|
2247
|
+
var projectChunk = projectVendor === null || projectVendor === void 0 ? void 0 : projectVendor.modules[source];
|
|
2248
|
+
if (projectChunk) {
|
|
2249
|
+
var _projectVendor$worker;
|
|
2250
|
+
// Server-only: the layer has a worker chunk for this and no browser
|
|
2251
|
+
// one. Saying so here, naming the specifier, beats a 404 for a chunk
|
|
2252
|
+
// URL that was never built -- which is what a client bundle importing
|
|
2253
|
+
// it would otherwise produce, at runtime, in a tab.
|
|
2254
|
+
if (target === "client" && projectVendor !== null && projectVendor !== void 0 && (_projectVendor$worker = projectVendor.workerOnly) !== null && _projectVendor$worker !== void 0 && _projectVendor$worker.includes(source)) {
|
|
2255
|
+
warnings.push("'".concat(source, "' is server-only in this project's vendor layer: it could not be built ") + "for the browser. Import it from a server route handler or a createServerFn " + "handler, not from a component or a loader.");
|
|
2256
|
+
return null;
|
|
2257
|
+
}
|
|
2258
|
+
return {
|
|
2259
|
+
id: "".concat(projectVendorBase).concat(projectChunk, ".js"),
|
|
2260
|
+
external: true
|
|
2261
|
+
};
|
|
2262
|
+
}
|
|
2263
|
+
|
|
2264
|
+
// A deferred half of a route file, from the splitter's own rewrite.
|
|
2265
|
+
var split = splitter ? parseSplitRequest(source) : null;
|
|
2266
|
+
if (split) {
|
|
2267
|
+
var path = split.path.startsWith(".") ? resolveInFiles(resolve(dirname(sourcePathOf(importer)), split.path), files) : split.path;
|
|
2268
|
+
if (path && path in files) {
|
|
2269
|
+
return "".concat(SPLIT_PREFIX).concat(split.targets.join("---"), ":").concat(path);
|
|
2270
|
+
}
|
|
2271
|
+
}
|
|
2272
|
+
|
|
2273
|
+
// Everything a project-relative path can turn into, shared by the
|
|
2274
|
+
// relative branch below and the tsconfig-alias one after it -- an alias
|
|
2275
|
+
// can point at a stylesheet or an image just as easily as a module, and
|
|
2276
|
+
// resolving it to a bare file id would skip the asset and CSS-module
|
|
2277
|
+
// passes entirely.
|
|
2278
|
+
var resolveProjectPath = function resolveProjectPath(base) {
|
|
2279
|
+
// Assets are resolved against their own map: they are not text, so they
|
|
2280
|
+
// never entered `files`. Checked first because an asset path would not
|
|
2281
|
+
// resolve there anyway, and the error would name the wrong thing.
|
|
2282
|
+
if (isAsset(base) && base in assets) return ASSET_PREFIX + base;
|
|
2283
|
+
// A CSS module's *import* is its name mapping. The stylesheet half was
|
|
2284
|
+
// produced by the CSS pass; this is the object the module returns.
|
|
2285
|
+
var bareCss = withoutCssQuery(base);
|
|
2286
|
+
if (isCssModule(bareCss) && bareCss in cssModules) {
|
|
2287
|
+
var paths = Object.keys(cssModules);
|
|
2288
|
+
return "".concat(CSS_MODULE_PREFIX).concat(paths.indexOf(bareCss));
|
|
2289
|
+
}
|
|
2290
|
+
return resolveInFiles(base, files);
|
|
2291
|
+
};
|
|
2292
|
+
|
|
2293
|
+
// Vite's `?url` suffix: "give me the URL, not the contents". On a
|
|
2294
|
+
// stylesheet that is how a Start route puts CSS in <head> itself,
|
|
2295
|
+
// rather than relying on a bundler to inject a link -- which is what
|
|
2296
|
+
// the stock __root.tsx does.
|
|
2297
|
+
var _source$split = source.split("?"),
|
|
2298
|
+
_source$split2 = slicedToArray._slicedToArray(_source$split, 2),
|
|
2299
|
+
bare = _source$split2[0],
|
|
2300
|
+
query = _source$split2[1];
|
|
2301
|
+
if (source.startsWith(".")) {
|
|
2302
|
+
if (query === "url" && isCss(bare)) return CSS_URL_ID;
|
|
2303
|
+
var hit = resolveProjectPath(resolve(dirname(sourcePathOf(importer)), source));
|
|
2304
|
+
if (hit) return hit;
|
|
2305
|
+
return null; // let rolldown report the unresolved import with a code frame
|
|
2306
|
+
}
|
|
2307
|
+
if (source in files) return source;
|
|
2308
|
+
|
|
2309
|
+
// tsconfig `paths`. Deliberately *after* the vendor sets: an alias can
|
|
2310
|
+
// never shadow the pinned React, router or start packages, because two
|
|
2311
|
+
// React instances is a broken page rather than a resolution preference.
|
|
2312
|
+
// A pattern that tries is reported rather than silently dropped.
|
|
2313
|
+
if (aliases) {
|
|
2314
|
+
var candidates = aliases.candidates(bare);
|
|
2315
|
+
var _iterator = slicedToArray._createForOfIteratorHelper(candidates),
|
|
2316
|
+
_step;
|
|
2317
|
+
try {
|
|
2318
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
2319
|
+
var candidate = _step.value;
|
|
2320
|
+
if (query === "url" && isCss(candidate)) return CSS_URL_ID;
|
|
2321
|
+
var _hit2 = resolveProjectPath(candidate);
|
|
2322
|
+
if (_hit2) return _hit2;
|
|
2323
|
+
}
|
|
2324
|
+
// A specifier that matched a pattern but resolved to nothing is a typo
|
|
2325
|
+
// or a moved file, not a missing package. Falling through to the
|
|
2326
|
+
// dependency error below would print a list of npm packages and tell
|
|
2327
|
+
// you to install `@/components/Card`, which does not exist and never
|
|
2328
|
+
// will -- so say what was actually tried instead.
|
|
2329
|
+
} catch (err) {
|
|
2330
|
+
_iterator.e(err);
|
|
2331
|
+
} finally {
|
|
2332
|
+
_iterator.f();
|
|
2333
|
+
}
|
|
2334
|
+
if (candidates.length) {
|
|
2335
|
+
warnings.push("'".concat(source, "' matched a tsconfig 'paths' alias but no file was found. ") + "Tried: ".concat(candidates.join(", "), "."));
|
|
2336
|
+
return null;
|
|
2337
|
+
}
|
|
2338
|
+
|
|
2339
|
+
// No pattern matched, so try `baseUrl` on its own. A miss here is not
|
|
2340
|
+
// reported as a broken alias: with a baseUrl set, every unknown npm
|
|
2341
|
+
// package reaches this line, and they are dependency errors.
|
|
2342
|
+
var fromBaseUrl = aliases.baseUrlCandidate(bare);
|
|
2343
|
+
if (fromBaseUrl) {
|
|
2344
|
+
var _hit = resolveProjectPath(fromBaseUrl);
|
|
2345
|
+
if (_hit) return _hit;
|
|
2346
|
+
}
|
|
2347
|
+
}
|
|
2348
|
+
|
|
2349
|
+
// A bare specifier outside the vendor set. Failing here rather than at
|
|
2350
|
+
// runtime is the point: the user gets a build error naming the package
|
|
2351
|
+
// instead of a blank page from a missing module in the isolate.
|
|
2352
|
+
var available = [].concat(slicedToArray._toConsumableArray(isRsc ? [vendor.paths.rscRuntimeSpecifier].concat(slicedToArray._toConsumableArray(vendor.rscSpecifiers), slicedToArray._toConsumableArray(vendor.specifiers)) : vendor.specifiers), slicedToArray._toConsumableArray(Object.keys((_projectVendor$module = projectVendor === null || projectVendor === void 0 ? void 0 : projectVendor.modules) !== null && _projectVendor$module !== void 0 ? _projectVendor$module : {})));
|
|
2353
|
+
warnings.push("'".concat(source, "' is not an available dependency. Available: ").concat(available.join(", "), "."));
|
|
2354
|
+
return null;
|
|
2355
|
+
},
|
|
2356
|
+
load: function load(id) {
|
|
2357
|
+
if (id === REGISTRY_ID) return REGISTRY_SOURCE;
|
|
2358
|
+
if (id === PROJECT_SOURCE_ID) return "export const FILES = ".concat(JSON.stringify(projectSource), "\n");
|
|
2359
|
+
if (id === RSC_ENTRY_ID) return rscEntrySource(files);
|
|
2360
|
+
if (id === RSC_RUNTIME_STUB_ID) return RSC_RUNTIME_STUB;
|
|
2361
|
+
if (id === DEPENDENCY_CSS_ID) return "export {}\n";
|
|
2362
|
+
var split = splitIdOf(id);
|
|
2363
|
+
if (split) {
|
|
2364
|
+
return splitter.virtual(split.path, files[split.path], split.targets).code;
|
|
2365
|
+
}
|
|
2366
|
+
if (id.startsWith(CSS_MODULE_PREFIX)) {
|
|
2367
|
+
var path = Object.keys(cssModules)[Number(id.slice(CSS_MODULE_PREFIX.length))];
|
|
2368
|
+
return cssModuleExports(cssModules[path]);
|
|
2369
|
+
}
|
|
2370
|
+
// Resolved ahead of the build, because `load` cannot be async here and
|
|
2371
|
+
// because the URL has to be identical across targets -- see resolveAsset.
|
|
2372
|
+
if (id === CSS_URL_ID) return assetModule(CSS_URL);
|
|
2373
|
+
if (id.startsWith(ASSET_PREFIX)) {
|
|
2374
|
+
return assetModule(assetUrls.get(id.slice(ASSET_PREFIX.length)));
|
|
2375
|
+
}
|
|
2376
|
+
if (!(id in files)) return null;
|
|
2377
|
+
|
|
2378
|
+
// A "use client" module is a boundary, and which side of it this build is
|
|
2379
|
+
// on decides what the module even is.
|
|
2380
|
+
var clientModule = clientModules.find(function (module) {
|
|
2381
|
+
return module.path === id;
|
|
2382
|
+
});
|
|
2383
|
+
if (clientModule && isRsc) return clientReferenceStub(clientModule, vendor.paths.flightServer);
|
|
2384
|
+
if (id !== ENTRY) return files[id];
|
|
2385
|
+
// The entry carries the registry across the module boundary: the shell
|
|
2386
|
+
// reads `__serverFns` off the user app, not off a module it cannot name.
|
|
2387
|
+
// The rsc build has no use for the registry: it holds references, not
|
|
2388
|
+
// modules.
|
|
2389
|
+
return files[id] + REGISTRY_REEXPORT + (isRsc ? "" : clientModuleRegistry(clientModules));
|
|
2390
|
+
},
|
|
2391
|
+
/**
|
|
2392
|
+
* Runs before rolldown's own oxc pass, so this sees the original TS/JSX.
|
|
2393
|
+
* Modules without a `createServerFn` are returned untouched and never
|
|
2394
|
+
* parsed.
|
|
2395
|
+
*/
|
|
2396
|
+
transform: function transform(code, id) {
|
|
2397
|
+
return slicedToArray._asyncToGenerator(/*#__PURE__*/slicedToArray._regenerator().m(function _callee() {
|
|
2398
|
+
var half, _envMarkers, out, reference, serverFns, envMarkers, routeNodes;
|
|
2399
|
+
return slicedToArray._regenerator().w(function (_context) {
|
|
2400
|
+
while (1) switch (_context.n) {
|
|
2401
|
+
case 0:
|
|
2402
|
+
/*
|
|
2403
|
+
* A split route's DEFERRED half, which would otherwise be skipped whole.
|
|
2404
|
+
*
|
|
2405
|
+
* `load` builds it from `files[path]` -- the original source, before any
|
|
2406
|
+
* of the passes below -- and gives it an id of its own, which is not in
|
|
2407
|
+
* `files`, so the guard after this one returned `null` for it. The
|
|
2408
|
+
* markers live in the component, and the component is exactly what the
|
|
2409
|
+
* splitter moves here: a route using `<ClientOnly>` or
|
|
2410
|
+
* `createIsomorphicFn()` therefore kept TanStack's shipped fallback when
|
|
2411
|
+
* a splitter was supplied and was rewritten when one was not. Splitting
|
|
2412
|
+
* is allowed to cost bytes and is NOT allowed to change behaviour, which
|
|
2413
|
+
* is the whole reason a browser build may skip it.
|
|
2414
|
+
*
|
|
2415
|
+
* The env markers ALONE, and the other two passes are deliberately not
|
|
2416
|
+
* run here: the reference half keeps the route options
|
|
2417
|
+
* (`transformRouteNodes`) and any `createServerFn` (`transformServerFns`),
|
|
2418
|
+
* and re-running the latter would mint a second id for a function that
|
|
2419
|
+
* already has one.
|
|
2420
|
+
*/
|
|
2421
|
+
half = splitIdOf(id);
|
|
2422
|
+
if (!half) {
|
|
2423
|
+
_context.n = 2;
|
|
2424
|
+
break;
|
|
2425
|
+
}
|
|
2426
|
+
_context.n = 1;
|
|
2427
|
+
return transformEnvMarkers(half.path, code, target);
|
|
2428
|
+
case 1:
|
|
2429
|
+
_envMarkers = _context.v;
|
|
2430
|
+
return _context.a(2, _envMarkers ? {
|
|
2431
|
+
code: _envMarkers.code,
|
|
2432
|
+
map: null
|
|
2433
|
+
} : null);
|
|
2434
|
+
case 2:
|
|
2435
|
+
if (!(!(id in files) || isCss(id))) {
|
|
2436
|
+
_context.n = 3;
|
|
2437
|
+
break;
|
|
2438
|
+
}
|
|
2439
|
+
return _context.a(2, null);
|
|
2440
|
+
case 3:
|
|
2441
|
+
// Two passes rather than one shared parse: each bails out on a substring
|
|
2442
|
+
// check before parsing, so a module that uses neither -- which is most of
|
|
2443
|
+
// them -- is never parsed at all.
|
|
2444
|
+
out = code; // First, because it decides what stays in this module at all: the other
|
|
2445
|
+
// passes should see the reference half, not code about to move out of it.
|
|
2446
|
+
if (splitter && isRouteFile(id)) {
|
|
2447
|
+
reference = splitter.reference(id, out);
|
|
2448
|
+
if (reference) out = reference.code;
|
|
2449
|
+
}
|
|
2450
|
+
_context.n = 4;
|
|
2451
|
+
return transformServerFns(id, out, target, seenIds);
|
|
2452
|
+
case 4:
|
|
2453
|
+
serverFns = _context.v;
|
|
2454
|
+
if (serverFns) out = serverFns.code;
|
|
2455
|
+
_context.n = 5;
|
|
2456
|
+
return transformEnvMarkers(id, out, target);
|
|
2457
|
+
case 5:
|
|
2458
|
+
envMarkers = _context.v;
|
|
2459
|
+
if (envMarkers) out = envMarkers.code;
|
|
2460
|
+
// Client only, and last: it deletes whole route options, so running it
|
|
2461
|
+
// before the others would leave them rewriting code about to be removed.
|
|
2462
|
+
_context.n = 6;
|
|
2463
|
+
return transformRouteNodes(id, out, target);
|
|
2464
|
+
case 6:
|
|
2465
|
+
routeNodes = _context.v;
|
|
2466
|
+
if (routeNodes) out = routeNodes.code;
|
|
2467
|
+
return _context.a(2, out === code ? null : {
|
|
2468
|
+
code: out,
|
|
2469
|
+
map: null
|
|
2470
|
+
});
|
|
2471
|
+
}
|
|
2472
|
+
}, _callee);
|
|
2473
|
+
}))();
|
|
2474
|
+
}
|
|
2475
|
+
};
|
|
2476
|
+
}
|
|
2477
|
+
|
|
2478
|
+
/**
|
|
2479
|
+
* Build-time env substitution.
|
|
2480
|
+
*
|
|
2481
|
+
* Values are inlined as literals rather than read at runtime, which is why they
|
|
2482
|
+
* cost nothing to use and why changing one produces a new build hash: the
|
|
2483
|
+
* output genuinely differs.
|
|
2484
|
+
*
|
|
2485
|
+
* Non-public keys resolve to `undefined` in the client bundle rather than being
|
|
2486
|
+
* left alone. An untouched `import.meta.env.SECRET` would throw in the browser,
|
|
2487
|
+
* and a silent `undefined` is both safer and easier to reason about.
|
|
2488
|
+
*/
|
|
2489
|
+
function defineFor(env, target, warnings) {
|
|
2490
|
+
var define = {};
|
|
2491
|
+
var visible = {};
|
|
2492
|
+
for (var _i = 0, _Object$entries = Object.entries(env); _i < _Object$entries.length; _i++) {
|
|
2493
|
+
var _Object$entries$_i = slicedToArray._slicedToArray(_Object$entries[_i], 2),
|
|
2494
|
+
key = _Object$entries$_i[0],
|
|
2495
|
+
value = _Object$entries$_i[1];
|
|
2496
|
+
if (!VALID_KEY.test(key)) {
|
|
2497
|
+
warnings.push("env var '".concat(key, "' is not a valid identifier and was ignored."));
|
|
2498
|
+
continue;
|
|
2499
|
+
}
|
|
2500
|
+
var exposed = target === "server" || key.startsWith(PUBLIC_PREFIX);
|
|
2501
|
+
var literal = exposed ? JSON.stringify(value) : "undefined";
|
|
2502
|
+
define["import.meta.env.".concat(key)] = literal;
|
|
2503
|
+
define["process.env.".concat(key)] = literal;
|
|
2504
|
+
if (exposed) visible[key] = value;
|
|
2505
|
+
}
|
|
2506
|
+
|
|
2507
|
+
// Always defined, even when empty: it makes `import.meta.env` destructuring
|
|
2508
|
+
// work and stops a bare reference from throwing. Specific keys above take
|
|
2509
|
+
// precedence over this object.
|
|
2510
|
+
define["import.meta.env"] = JSON.stringify(visible);
|
|
2511
|
+
return define;
|
|
2512
|
+
}
|
|
2513
|
+
function buildOnce(_x, _x2, _x3, _x4, _x5) {
|
|
2514
|
+
return _buildOnce.apply(this, arguments);
|
|
2515
|
+
}
|
|
2516
|
+
function _buildOnce() {
|
|
2517
|
+
_buildOnce = slicedToArray._asyncToGenerator(/*#__PURE__*/slicedToArray._regenerator().m(function _callee2(input, vendorBase, projectVendorBase, target, warnings) {
|
|
2518
|
+
var _input$projectSource, _input$assets, _input$env;
|
|
2519
|
+
var clientModules,
|
|
2520
|
+
isRsc,
|
|
2521
|
+
assetUrls,
|
|
2522
|
+
cssModules,
|
|
2523
|
+
aliases,
|
|
2524
|
+
vendor,
|
|
2525
|
+
projectVendor,
|
|
2526
|
+
result,
|
|
2527
|
+
chunks,
|
|
2528
|
+
entry,
|
|
2529
|
+
split,
|
|
2530
|
+
_iterator2,
|
|
2531
|
+
_step2,
|
|
2532
|
+
chunk,
|
|
2533
|
+
_args2 = arguments;
|
|
2534
|
+
return slicedToArray._regenerator().w(function (_context2) {
|
|
2535
|
+
while (1) switch (_context2.n) {
|
|
2536
|
+
case 0:
|
|
2537
|
+
clientModules = _args2.length > 5 && _args2[5] !== undefined ? _args2[5] : [];
|
|
2538
|
+
isRsc = _args2.length > 6 && _args2[6] !== undefined ? _args2[6] : false;
|
|
2539
|
+
assetUrls = _args2.length > 7 && _args2[7] !== undefined ? _args2[7] : new Map();
|
|
2540
|
+
cssModules = _args2.length > 8 && _args2[8] !== undefined ? _args2[8] : {};
|
|
2541
|
+
aliases = _args2.length > 9 && _args2[9] !== undefined ? _args2[9] : null;
|
|
2542
|
+
vendor = vendorRules(input.target);
|
|
2543
|
+
/*
|
|
2544
|
+
* The project's own layer, in the shape the plugin already reads.
|
|
2545
|
+
*
|
|
2546
|
+
* `BuildTarget.project` is the wire shape and always present; this is the
|
|
2547
|
+
* "does it have one at all" question the resolver asks, and `null` keeps
|
|
2548
|
+
* that a single check rather than one per field.
|
|
2549
|
+
*/
|
|
2550
|
+
projectVendor = input.target.project.rev === null ? undefined : {
|
|
2551
|
+
rev: input.target.project.rev,
|
|
2552
|
+
modules: input.target.project.modules,
|
|
2553
|
+
css: input.target.project.css,
|
|
2554
|
+
workerOnly: input.target.project.workerOnly
|
|
2555
|
+
}; // The RSC pass is a server build in every respect the transforms care about:
|
|
2556
|
+
// it runs on the server, so server-only code stays and client-only code goes.
|
|
2557
|
+
// Only the vendor layer differs.
|
|
2558
|
+
_context2.n = 1;
|
|
2559
|
+
return browser.build({
|
|
2560
|
+
input: isRsc ? RSC_ENTRY_ID : ENTRY,
|
|
2561
|
+
// Required in the browser. rolldown computes `cwd: inputOptions.cwd ??
|
|
2562
|
+
// process.cwd()` unguarded, so omitting this throws "process is not
|
|
2563
|
+
// defined" from inside the wasm loader -- which surfaces only as a build
|
|
2564
|
+
// error with no stack pointing here. The value is inert for us because the
|
|
2565
|
+
// project plugin resolves every id itself.
|
|
2566
|
+
cwd: "/",
|
|
2567
|
+
// rolldown removed CSS bundling (rolldown/rolldown#4271), so a `.css`
|
|
2568
|
+
// import is a hard build error unless its module type is declared. 'empty'
|
|
2569
|
+
// drops it from the JS graph; the stylesheet itself comes from collectCss.
|
|
2570
|
+
moduleTypes: {
|
|
2571
|
+
".css": "empty"
|
|
2572
|
+
},
|
|
2573
|
+
plugins: [projectPlugin(input.files, (_input$projectSource = input.projectSource) !== null && _input$projectSource !== void 0 ? _input$projectSource : input.files, input.routeSplitter, cssModules, aliases, (_input$assets = input.assets) !== null && _input$assets !== void 0 ? _input$assets : {}, assetUrls, vendorBase, projectVendorBase, projectVendor, vendor, warnings, target, new Set(), clientModules, isRsc)],
|
|
2574
|
+
// oxc handles TS and JSX natively, so there is no separate transform pass
|
|
2575
|
+
// and no type-checking on the publish path. Types are the editor's job.
|
|
2576
|
+
transform: {
|
|
2577
|
+
jsx: {
|
|
2578
|
+
runtime: "automatic",
|
|
2579
|
+
importSource: "react"
|
|
2580
|
+
},
|
|
2581
|
+
define: defineFor((_input$env = input.env) !== null && _input$env !== void 0 ? _input$env : {}, target, warnings)
|
|
2582
|
+
},
|
|
2583
|
+
output: {
|
|
2584
|
+
format: "esm",
|
|
2585
|
+
minify: false,
|
|
2586
|
+
// The entry's name is fixed because both consumers address it by name:
|
|
2587
|
+
// the isolate's module map has an `app.js` key, and the shell's client
|
|
2588
|
+
// half imports `/_app/app.js`. Split chunks are content-addressed, which
|
|
2589
|
+
// is what lets them be served immutable.
|
|
2590
|
+
entryFileNames: ENTRY_CHUNK,
|
|
2591
|
+
chunkFileNames: "c-[hash].js"
|
|
2592
|
+
},
|
|
2593
|
+
write: false
|
|
2594
|
+
});
|
|
2595
|
+
case 1:
|
|
2596
|
+
result = _context2.v;
|
|
2597
|
+
// A type predicate rather than `(chunk: any)`, which is how this read until
|
|
2598
|
+
// the package moved into a repository that type-checks it: an `any`
|
|
2599
|
+
// parameter makes the filter non-narrowing, so every `.code` below was
|
|
2600
|
+
// reaching for a property that an OutputAsset does not have. Nothing was
|
|
2601
|
+
// wrong at runtime -- `type === 'chunk'` was already the check -- but
|
|
2602
|
+
// nothing said so either.
|
|
2603
|
+
chunks = result.output.filter(function (output) {
|
|
2604
|
+
return output.type === "chunk";
|
|
2605
|
+
});
|
|
2606
|
+
entry = chunks.find(function (chunk) {
|
|
2607
|
+
return chunk.fileName === ENTRY_CHUNK;
|
|
2608
|
+
});
|
|
2609
|
+
if (entry) {
|
|
2610
|
+
_context2.n = 2;
|
|
2611
|
+
break;
|
|
2612
|
+
}
|
|
2613
|
+
throw new Error("The build produced no ".concat(ENTRY_CHUNK, ". Chunks: ").concat(chunks.map(function (c) {
|
|
2614
|
+
return c.fileName;
|
|
2615
|
+
}).join(", "), "."));
|
|
2616
|
+
case 2:
|
|
2617
|
+
// Chunk-to-chunk imports come out relative (`./c-abc.js`), which is exactly
|
|
2618
|
+
// what both sides need and why neither gets a base path here: relative to
|
|
2619
|
+
// `app.js` in the module map, relative to `/_app/app.js` as a URL.
|
|
2620
|
+
split = {};
|
|
2621
|
+
_iterator2 = slicedToArray._createForOfIteratorHelper(chunks);
|
|
2622
|
+
try {
|
|
2623
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
2624
|
+
chunk = _step2.value;
|
|
2625
|
+
if (chunk.fileName !== ENTRY_CHUNK) split[chunk.fileName] = chunk.code;
|
|
2626
|
+
}
|
|
2627
|
+
} catch (err) {
|
|
2628
|
+
_iterator2.e(err);
|
|
2629
|
+
} finally {
|
|
2630
|
+
_iterator2.f();
|
|
2631
|
+
}
|
|
2632
|
+
return _context2.a(2, {
|
|
2633
|
+
code: entry.code,
|
|
2634
|
+
chunks: split
|
|
2635
|
+
});
|
|
2636
|
+
}
|
|
2637
|
+
}, _callee2);
|
|
2638
|
+
}));
|
|
2639
|
+
return _buildOnce.apply(this, arguments);
|
|
2640
|
+
}
|
|
2641
|
+
function buildUserApp(_x6) {
|
|
2642
|
+
return _buildUserApp.apply(this, arguments);
|
|
2643
|
+
}
|
|
2644
|
+
|
|
2645
|
+
/**
|
|
2646
|
+
* Exactly what `POST /__api/publish` expects, from a build.
|
|
2647
|
+
*
|
|
2648
|
+
* A function rather than "spread the whole build", because BuildOutput also
|
|
2649
|
+
* carries things the loader has no use for -- timings, warnings, the client
|
|
2650
|
+
* module list -- and rather than a hand-written literal at every call site,
|
|
2651
|
+
* because split chunks were the third output to be added and the third time
|
|
2652
|
+
* every publisher had to be found and edited.
|
|
2653
|
+
*/
|
|
2654
|
+
function _buildUserApp() {
|
|
2655
|
+
_buildUserApp = slicedToArray._asyncToGenerator(/*#__PURE__*/slicedToArray._regenerator().m(function _callee3(input) {
|
|
2656
|
+
var _input$target$project;
|
|
2657
|
+
var warnings, started, rev, clientModules, assetUrls, assetFiles, _i2, _Object$entries2, _input$assets2, _Object$entries2$_i, path, base64, resolved, aliases, css, styles, tailwindMs, compiled, serverStarted, serverBuild, server, clientStarted, clientBuild, client, rscBuild, publicFiles, _i3, _Object$entries3, _input$publicFiles, _Object$entries3$_i, _path, _base, _t, _t2, _t3, _t4, _t5, _t6, _t7, _t8, _t9, _t0, _t1, _t10, _t11, _t12, _t13, _t14, _t15;
|
|
2658
|
+
return slicedToArray._regenerator().w(function (_context3) {
|
|
2659
|
+
while (1) switch (_context3.n) {
|
|
2660
|
+
case 0:
|
|
2661
|
+
warnings = [];
|
|
2662
|
+
started = performance.now(); // Server and client differ in two ways: how vendor imports are addressed
|
|
2663
|
+
// (module-map keys vs asset URLs), and which env vars are visible.
|
|
2664
|
+
// The project layer is addressed differently per target for the same reason
|
|
2665
|
+
// the base layer is: module-map keys inside the isolate, asset URLs in the
|
|
2666
|
+
// browser. The client path carries the layer's revision so it can be cached
|
|
2667
|
+
// immutably.
|
|
2668
|
+
rev = (_input$target$project = input.target.project.rev) !== null && _input$target$project !== void 0 ? _input$target$project : ""; // Found once and used by all three passes, because the ids have to agree:
|
|
2669
|
+
// the rsc build writes them into the flight payload and the others write them
|
|
2670
|
+
// into the lookup map.
|
|
2671
|
+
if (!input.rsc) {
|
|
2672
|
+
_context3.n = 2;
|
|
2673
|
+
break;
|
|
2674
|
+
}
|
|
2675
|
+
_context3.n = 1;
|
|
2676
|
+
return collectClientModules(input.files);
|
|
2677
|
+
case 1:
|
|
2678
|
+
_t = _context3.v;
|
|
2679
|
+
_context3.n = 3;
|
|
2680
|
+
break;
|
|
2681
|
+
case 2:
|
|
2682
|
+
_t = [];
|
|
2683
|
+
case 3:
|
|
2684
|
+
clientModules = _t;
|
|
2685
|
+
// Resolved once, before any target builds, for two reasons: `load` cannot be
|
|
2686
|
+
// async, and every target has to emit the *same* URL -- a server bundle that
|
|
2687
|
+
// disagreed with the client one would be a hydration mismatch on every image.
|
|
2688
|
+
assetUrls = new Map();
|
|
2689
|
+
assetFiles = {};
|
|
2690
|
+
_i2 = 0, _Object$entries2 = Object.entries((_input$assets2 = input.assets) !== null && _input$assets2 !== void 0 ? _input$assets2 : {});
|
|
2691
|
+
case 4:
|
|
2692
|
+
if (!(_i2 < _Object$entries2.length)) {
|
|
2693
|
+
_context3.n = 7;
|
|
2694
|
+
break;
|
|
2695
|
+
}
|
|
2696
|
+
_Object$entries2$_i = slicedToArray._slicedToArray(_Object$entries2[_i2], 2), path = _Object$entries2$_i[0], base64 = _Object$entries2$_i[1];
|
|
2697
|
+
_context3.n = 5;
|
|
2698
|
+
return resolveAsset(path, base64);
|
|
2699
|
+
case 5:
|
|
2700
|
+
resolved = _context3.v;
|
|
2701
|
+
assetUrls.set(path, resolved.url);
|
|
2702
|
+
if (resolved.file) assetFiles[resolved.file.name] = resolved.file.base64;
|
|
2703
|
+
case 6:
|
|
2704
|
+
_i2++;
|
|
2705
|
+
_context3.n = 4;
|
|
2706
|
+
break;
|
|
2707
|
+
case 7:
|
|
2708
|
+
// Collected once rather than per target: the stylesheet is the same either
|
|
2709
|
+
// way, and only the client ever uses it. Whether a build produced one is
|
|
2710
|
+
// recorded in the head pointer at publish time, because the loader -- not the
|
|
2711
|
+
// shell -- injects the link.
|
|
2712
|
+
// Parsed once for the whole build rather than per target or per import:
|
|
2713
|
+
// reading tsconfig.json on every resolveId call would be the hot path in a
|
|
2714
|
+
// build whose whole point is that it takes a second. Both the CSS walk and
|
|
2715
|
+
// the resolver get the same map -- two resolvers disagreeing about what
|
|
2716
|
+
// `@/components/Card` means is how the alias support broke on its first real
|
|
2717
|
+
// use, so they are given it from one place.
|
|
2718
|
+
aliases = aliasMap(input.files, function (message) {
|
|
2719
|
+
return warnings.push(message);
|
|
2720
|
+
});
|
|
2721
|
+
_context3.n = 8;
|
|
2722
|
+
return collectCss(input.files, ENTRY, input.target.project.css, aliases);
|
|
2723
|
+
case 8:
|
|
2724
|
+
css = _context3.v;
|
|
2725
|
+
// Tailwind runs over the *concatenated* stylesheet, so the project's own
|
|
2726
|
+
// rules and its `@import "tailwindcss"` compile together and the cascade
|
|
2727
|
+
// order the CSS pass derived is preserved. Skipped entirely when the project
|
|
2728
|
+
// does not ask for it, which keeps the cost off every other build.
|
|
2729
|
+
styles = css.code;
|
|
2730
|
+
tailwindMs = 0;
|
|
2731
|
+
warnings.push.apply(warnings, slicedToArray._toConsumableArray(css.warnings));
|
|
2732
|
+
if (!usesTailwind(styles)) {
|
|
2733
|
+
_context3.n = 10;
|
|
2734
|
+
break;
|
|
2735
|
+
}
|
|
2736
|
+
_context3.n = 9;
|
|
2737
|
+
return compileTailwind(styles, input.files, input.loadCssModule);
|
|
2738
|
+
case 9:
|
|
2739
|
+
compiled = _context3.v;
|
|
2740
|
+
styles = compiled.css;
|
|
2741
|
+
tailwindMs = compiled.ms;
|
|
2742
|
+
warnings.push.apply(warnings, slicedToArray._toConsumableArray(compiled.warnings));
|
|
2743
|
+
case 10:
|
|
2744
|
+
serverStarted = performance.now();
|
|
2745
|
+
_context3.n = 11;
|
|
2746
|
+
return buildOnce(input, "./vendor/", "./pvendor/", "server", warnings, clientModules, false, assetUrls, css.modules, aliases);
|
|
2747
|
+
case 11:
|
|
2748
|
+
serverBuild = _context3.v;
|
|
2749
|
+
server = performance.now() - serverStarted;
|
|
2750
|
+
clientStarted = performance.now();
|
|
2751
|
+
_context3.n = 12;
|
|
2752
|
+
return buildOnce(input, "/_vendor/", "/_pvendor/".concat(rev, "/"), "client", warnings, clientModules, false, assetUrls, css.modules, aliases);
|
|
2753
|
+
case 12:
|
|
2754
|
+
clientBuild = _context3.v;
|
|
2755
|
+
client = performance.now() - clientStarted; // Paths are relative to `rsc/app.js`, one directory down, so both layers are
|
|
2756
|
+
// addressed with a leading `../`. Getting this wrong does not fail the build;
|
|
2757
|
+
// the cold isolate simply refuses to boot.
|
|
2758
|
+
if (!input.rsc) {
|
|
2759
|
+
_context3.n = 14;
|
|
2760
|
+
break;
|
|
2761
|
+
}
|
|
2762
|
+
_context3.n = 13;
|
|
2763
|
+
return buildOnce(
|
|
2764
|
+
// `../pvendor/`, with no revision segment: the revision belongs in the
|
|
2765
|
+
// browser URL, where it buys immutable caching. Inside the module map
|
|
2766
|
+
// there is exactly one layer and the key is `pvendor/<name>.js`, so a
|
|
2767
|
+
// revision here is a path segment that does not exist -- and the cold
|
|
2768
|
+
// isolate is where you would find that out.
|
|
2769
|
+
input, "../vendor-rsc/", "../pvendor/", "server", warnings, clientModules, true, assetUrls, css.modules, aliases);
|
|
2770
|
+
case 13:
|
|
2771
|
+
_t2 = _context3.v;
|
|
2772
|
+
_context3.n = 15;
|
|
2773
|
+
break;
|
|
2774
|
+
case 14:
|
|
2775
|
+
_t2 = undefined;
|
|
2776
|
+
case 15:
|
|
2777
|
+
rscBuild = _t2;
|
|
2778
|
+
// Stripped of the `public/` prefix here rather than at every consumer: the
|
|
2779
|
+
// prefix is a convention of the project layout, and what the loader needs is
|
|
2780
|
+
// the URL path.
|
|
2781
|
+
publicFiles = {};
|
|
2782
|
+
for (_i3 = 0, _Object$entries3 = Object.entries((_input$publicFiles = input.publicFiles) !== null && _input$publicFiles !== void 0 ? _input$publicFiles : {}); _i3 < _Object$entries3.length; _i3++) {
|
|
2783
|
+
_Object$entries3$_i = slicedToArray._slicedToArray(_Object$entries3[_i3], 2), _path = _Object$entries3$_i[0], _base = _Object$entries3$_i[1];
|
|
2784
|
+
publicFiles[_path.replace(/^public\//, "")] = _base;
|
|
2785
|
+
}
|
|
2786
|
+
_t3 = serverBuild.code;
|
|
2787
|
+
_t4 = clientBuild.code;
|
|
2788
|
+
_t5 = serverBuild.chunks;
|
|
2789
|
+
_t6 = clientBuild.chunks;
|
|
2790
|
+
_t7 = assetFiles;
|
|
2791
|
+
_t8 = publicFiles;
|
|
2792
|
+
_t9 = styles;
|
|
2793
|
+
_t0 = Object.values(input.files).some(function (code) {
|
|
2794
|
+
return /\.css\?url/.test(code);
|
|
2795
|
+
});
|
|
2796
|
+
_t1 = rscBuild === null || rscBuild === void 0 ? void 0 : rscBuild.code;
|
|
2797
|
+
_t10 = rscBuild === null || rscBuild === void 0 ? void 0 : rscBuild.chunks;
|
|
2798
|
+
_t11 = input.rsc ? clientModules : undefined;
|
|
2799
|
+
_t12 = input.target.base.rev;
|
|
2800
|
+
_context3.n = 16;
|
|
2801
|
+
return sha256Hex([input.target.base.rev, rev, styles].concat(slicedToArray._toConsumableArray(Object.entries(assetFiles).flat()), slicedToArray._toConsumableArray(Object.entries(publicFiles).flat()), slicedToArray._toConsumableArray([serverBuild, clientBuild, rscBuild].flatMap(function (built) {
|
|
2802
|
+
return built ? [built.code].concat(slicedToArray._toConsumableArray(Object.entries(built.chunks).flat())) : [];
|
|
2803
|
+
}))).join("\0"));
|
|
2804
|
+
case 16:
|
|
2805
|
+
_t13 = _context3.v.slice(0, 32);
|
|
2806
|
+
_t14 = {
|
|
2807
|
+
server: server,
|
|
2808
|
+
client: client,
|
|
2809
|
+
tailwind: tailwindMs,
|
|
2810
|
+
total: performance.now() - started
|
|
2811
|
+
};
|
|
2812
|
+
_t15 = slicedToArray._toConsumableArray(new Set(warnings));
|
|
2813
|
+
return _context3.a(2, {
|
|
2814
|
+
serverCode: _t3,
|
|
2815
|
+
clientCode: _t4,
|
|
2816
|
+
serverChunks: _t5,
|
|
2817
|
+
clientChunks: _t6,
|
|
2818
|
+
assetFiles: _t7,
|
|
2819
|
+
publicFiles: _t8,
|
|
2820
|
+
cssCode: _t9,
|
|
2821
|
+
linksOwnCss: _t0,
|
|
2822
|
+
rscCode: _t1,
|
|
2823
|
+
rscChunks: _t10,
|
|
2824
|
+
clientModules: _t11,
|
|
2825
|
+
vendorRev: _t12,
|
|
2826
|
+
hash: _t13,
|
|
2827
|
+
timings: _t14,
|
|
2828
|
+
warnings: _t15
|
|
2829
|
+
});
|
|
2830
|
+
}
|
|
2831
|
+
}, _callee3);
|
|
2832
|
+
}));
|
|
2833
|
+
return _buildUserApp.apply(this, arguments);
|
|
2834
|
+
}
|
|
2835
|
+
function publishPayload(build, extra) {
|
|
2836
|
+
return slicedToArray._objectSpread2({
|
|
2837
|
+
serverCode: build.serverCode,
|
|
2838
|
+
clientCode: build.clientCode,
|
|
2839
|
+
serverChunks: build.serverChunks,
|
|
2840
|
+
clientChunks: build.clientChunks,
|
|
2841
|
+
cssCode: build.cssCode,
|
|
2842
|
+
linksOwnCss: build.linksOwnCss,
|
|
2843
|
+
rscCode: build.rscCode,
|
|
2844
|
+
rscChunks: build.rscChunks,
|
|
2845
|
+
assetFiles: build.assetFiles,
|
|
2846
|
+
publicFiles: build.publicFiles,
|
|
2847
|
+
hash: build.hash,
|
|
2848
|
+
vendorRev: build.vendorRev
|
|
2849
|
+
}, extra);
|
|
2850
|
+
}
|
|
2851
|
+
|
|
2852
|
+
/*
|
|
2853
|
+
* The git tree hash of a file record, computed the way git computes it.
|
|
2854
|
+
*
|
|
2855
|
+
* ## Why not any other hash
|
|
2856
|
+
*
|
|
2857
|
+
* The platform compares what a publisher built against what the commit it names
|
|
2858
|
+
* actually holds. That comparison is only useful if two honest publishers of one
|
|
2859
|
+
* commit agree -- and "a hash over the file record" does not give that. CI
|
|
2860
|
+
* hashes a checkout, a browser tab hashes its in-memory record, and they differ
|
|
2861
|
+
* over anything at all: a generated file, a binary the tab skipped,
|
|
2862
|
+
* `val.server.ts` wired at a different moment, line endings. Every instant
|
|
2863
|
+
* publish would then look like a divergence and be replaced by the CI build, and
|
|
2864
|
+
* the pointer would churn after every save.
|
|
2865
|
+
*
|
|
2866
|
+
* The tree hash removes the question rather than tightening the tolerance. It is
|
|
2867
|
+
* what git already stores for the commit, so CI has it for nothing and the
|
|
2868
|
+
* region reads it from the git host along with HEAD. Two honest builds of one
|
|
2869
|
+
* commit then agree BY DEFINITION, because they are both naming the same object.
|
|
2870
|
+
*
|
|
2871
|
+
* ## The format, which is small and unforgiving
|
|
2872
|
+
*
|
|
2873
|
+
* A blob is `blob <byteLength>\0<bytes>`, SHA-1'd. A tree is the concatenation
|
|
2874
|
+
* of `<mode> <name>\0<20 raw sha bytes>` over its entries, SHA-1'd, built
|
|
2875
|
+
* bottom-up. Modes are `100644`, `100755` and `40000` -- a tree's mode has no
|
|
2876
|
+
* leading zero inside an entry, which is the detail that silently produces a
|
|
2877
|
+
* hash git disagrees with.
|
|
2878
|
+
*
|
|
2879
|
+
* Entry order is where a reimplementation usually goes wrong: git sorts by name,
|
|
2880
|
+
* but compares a directory as though its name ended in `/`. So `foo.txt` sorts
|
|
2881
|
+
* BEFORE `foo/` even though `.` is below `/` in ASCII. Get that wrong and the
|
|
2882
|
+
* hash is stable, plausible, and not git's.
|
|
2883
|
+
*/
|
|
2884
|
+
/** SHA-1 over bytes, as the 20 raw bytes git concatenates into a tree. */
|
|
2885
|
+
function sha1(_x) {
|
|
2886
|
+
return _sha.apply(this, arguments);
|
|
2887
|
+
}
|
|
2888
|
+
function _sha() {
|
|
2889
|
+
_sha = slicedToArray._asyncToGenerator(/*#__PURE__*/slicedToArray._regenerator().m(function _callee(bytes) {
|
|
2890
|
+
var digest;
|
|
2891
|
+
return slicedToArray._regenerator().w(function (_context) {
|
|
2892
|
+
while (1) switch (_context.n) {
|
|
2893
|
+
case 0:
|
|
2894
|
+
_context.n = 1;
|
|
2895
|
+
return crypto.subtle.digest("SHA-1", bytes);
|
|
2896
|
+
case 1:
|
|
2897
|
+
digest = _context.v;
|
|
2898
|
+
return _context.a(2, new Uint8Array(digest));
|
|
2899
|
+
}
|
|
2900
|
+
}, _callee);
|
|
2901
|
+
}));
|
|
2902
|
+
return _sha.apply(this, arguments);
|
|
2903
|
+
}
|
|
2904
|
+
var hex = function hex(bytes) {
|
|
2905
|
+
return Array.from(bytes, function (b) {
|
|
2906
|
+
return b.toString(16).padStart(2, "0");
|
|
2907
|
+
}).join("");
|
|
2908
|
+
};
|
|
2909
|
+
function concat(parts) {
|
|
2910
|
+
var total = parts.reduce(function (n, p) {
|
|
2911
|
+
return n + p.length;
|
|
2912
|
+
}, 0);
|
|
2913
|
+
var out = new Uint8Array(total);
|
|
2914
|
+
var at = 0;
|
|
2915
|
+
var _iterator = slicedToArray._createForOfIteratorHelper(parts),
|
|
2916
|
+
_step;
|
|
2917
|
+
try {
|
|
2918
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
2919
|
+
var part = _step.value;
|
|
2920
|
+
out.set(part, at);
|
|
2921
|
+
at += part.length;
|
|
2922
|
+
}
|
|
2923
|
+
} catch (err) {
|
|
2924
|
+
_iterator.e(err);
|
|
2925
|
+
} finally {
|
|
2926
|
+
_iterator.f();
|
|
2927
|
+
}
|
|
2928
|
+
return out;
|
|
2929
|
+
}
|
|
2930
|
+
var utf8 = function utf8(text) {
|
|
2931
|
+
return new TextEncoder().encode(text);
|
|
2932
|
+
};
|
|
2933
|
+
|
|
2934
|
+
/** `blob <length>\0<content>`, hashed. The same value as `git hash-object`. */
|
|
2935
|
+
function blobSha(_x2) {
|
|
2936
|
+
return _blobSha.apply(this, arguments);
|
|
2937
|
+
}
|
|
2938
|
+
function _blobSha() {
|
|
2939
|
+
_blobSha = slicedToArray._asyncToGenerator(/*#__PURE__*/slicedToArray._regenerator().m(function _callee2(content) {
|
|
2940
|
+
var _t;
|
|
2941
|
+
return slicedToArray._regenerator().w(function (_context2) {
|
|
2942
|
+
while (1) switch (_context2.n) {
|
|
2943
|
+
case 0:
|
|
2944
|
+
_t = hex;
|
|
2945
|
+
_context2.n = 1;
|
|
2946
|
+
return sha1(concat([utf8("blob ".concat(content.length, "\0")), content]));
|
|
2947
|
+
case 1:
|
|
2948
|
+
return _context2.a(2, _t(_context2.v));
|
|
2949
|
+
}
|
|
2950
|
+
}, _callee2);
|
|
2951
|
+
}));
|
|
2952
|
+
return _blobSha.apply(this, arguments);
|
|
2953
|
+
}
|
|
2954
|
+
/**
|
|
2955
|
+
* The sort git uses, which is not the sort a reader expects.
|
|
2956
|
+
*
|
|
2957
|
+
* A tree entry compares as though its name had a trailing `/`. `/` is 0x2F and
|
|
2958
|
+
* `.` is 0x2E, so `foo.txt` comes before `foo/` -- the opposite of what plain
|
|
2959
|
+
* name ordering gives, and a difference that changes the hash without changing
|
|
2960
|
+
* anything a human would notice.
|
|
2961
|
+
*/
|
|
2962
|
+
function gitOrder(a, b) {
|
|
2963
|
+
var an = a.mode === "40000" ? "".concat(a.name, "/") : a.name;
|
|
2964
|
+
var bn = b.mode === "40000" ? "".concat(b.name, "/") : b.name;
|
|
2965
|
+
return an < bn ? -1 : an > bn ? 1 : 0;
|
|
2966
|
+
}
|
|
2967
|
+
function hashTree(_x3) {
|
|
2968
|
+
return _hashTree.apply(this, arguments);
|
|
2969
|
+
}
|
|
2970
|
+
/** A file, as this record holds it: its bytes and whether git marks it executable. */
|
|
2971
|
+
function _hashTree() {
|
|
2972
|
+
_hashTree = slicedToArray._asyncToGenerator(/*#__PURE__*/slicedToArray._regenerator().m(function _callee3(entries) {
|
|
2973
|
+
var sorted, body;
|
|
2974
|
+
return slicedToArray._regenerator().w(function (_context3) {
|
|
2975
|
+
while (1) switch (_context3.n) {
|
|
2976
|
+
case 0:
|
|
2977
|
+
sorted = slicedToArray._toConsumableArray(entries).sort(gitOrder);
|
|
2978
|
+
body = concat(sorted.flatMap(function (e) {
|
|
2979
|
+
return [utf8("".concat(e.mode, " ").concat(e.name, "\0")), e.sha];
|
|
2980
|
+
}));
|
|
2981
|
+
return _context3.a(2, sha1(concat([utf8("tree ".concat(body.length, "\0")), body])));
|
|
2982
|
+
}
|
|
2983
|
+
}, _callee3);
|
|
2984
|
+
}));
|
|
2985
|
+
return _hashTree.apply(this, arguments);
|
|
2986
|
+
}
|
|
2987
|
+
/**
|
|
2988
|
+
* The tree hash of a whole file record.
|
|
2989
|
+
*
|
|
2990
|
+
* Paths are `/`-separated and may or may not start with one -- a leading slash
|
|
2991
|
+
* is stripped, because a record keyed `/src/a.ts` and one keyed `src/a.ts` are
|
|
2992
|
+
* the same tree and must not hash differently.
|
|
2993
|
+
*
|
|
2994
|
+
* An empty record hashes to git's empty tree, which is a real object with a
|
|
2995
|
+
* well-known id rather than a special case.
|
|
2996
|
+
*/
|
|
2997
|
+
function treeSha(_x4) {
|
|
2998
|
+
return _treeSha.apply(this, arguments);
|
|
2999
|
+
}
|
|
3000
|
+
|
|
3001
|
+
/** The common case: a record of text files, none executable. */
|
|
3002
|
+
function _treeSha() {
|
|
3003
|
+
_treeSha = slicedToArray._asyncToGenerator(/*#__PURE__*/slicedToArray._regenerator().m(function _callee5(files) {
|
|
3004
|
+
var root, _i, _Object$entries, _Object$entries$_i, rawPath, file, parts, name, at, _iterator2, _step2, dir, next, _build, _t1;
|
|
3005
|
+
return slicedToArray._regenerator().w(function (_context5) {
|
|
3006
|
+
while (1) switch (_context5.n) {
|
|
3007
|
+
case 0:
|
|
3008
|
+
root = {
|
|
3009
|
+
files: new Map(),
|
|
3010
|
+
dirs: new Map()
|
|
3011
|
+
};
|
|
3012
|
+
_i = 0, _Object$entries = Object.entries(files);
|
|
3013
|
+
case 1:
|
|
3014
|
+
if (!(_i < _Object$entries.length)) {
|
|
3015
|
+
_context5.n = 4;
|
|
3016
|
+
break;
|
|
3017
|
+
}
|
|
3018
|
+
_Object$entries$_i = slicedToArray._slicedToArray(_Object$entries[_i], 2), rawPath = _Object$entries$_i[0], file = _Object$entries$_i[1];
|
|
3019
|
+
parts = rawPath.replace(/^\/+/, "").split("/").filter(Boolean);
|
|
3020
|
+
if (!(parts.length === 0)) {
|
|
3021
|
+
_context5.n = 2;
|
|
3022
|
+
break;
|
|
3023
|
+
}
|
|
3024
|
+
return _context5.a(3, 3);
|
|
3025
|
+
case 2:
|
|
3026
|
+
name = parts.pop();
|
|
3027
|
+
at = root;
|
|
3028
|
+
_iterator2 = slicedToArray._createForOfIteratorHelper(parts);
|
|
3029
|
+
try {
|
|
3030
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
3031
|
+
dir = _step2.value;
|
|
3032
|
+
next = at.dirs.get(dir);
|
|
3033
|
+
if (!next) {
|
|
3034
|
+
next = {
|
|
3035
|
+
files: new Map(),
|
|
3036
|
+
dirs: new Map()
|
|
3037
|
+
};
|
|
3038
|
+
at.dirs.set(dir, next);
|
|
3039
|
+
}
|
|
3040
|
+
at = next;
|
|
3041
|
+
}
|
|
3042
|
+
} catch (err) {
|
|
3043
|
+
_iterator2.e(err);
|
|
3044
|
+
} finally {
|
|
3045
|
+
_iterator2.f();
|
|
3046
|
+
}
|
|
3047
|
+
at.files.set(name, file);
|
|
3048
|
+
case 3:
|
|
3049
|
+
_i++;
|
|
3050
|
+
_context5.n = 1;
|
|
3051
|
+
break;
|
|
3052
|
+
case 4:
|
|
3053
|
+
_build = /*#__PURE__*/function () {
|
|
3054
|
+
var _ref3 = slicedToArray._asyncToGenerator(/*#__PURE__*/slicedToArray._regenerator().m(function _callee4(node) {
|
|
3055
|
+
var entries, _iterator3, _step3, _step3$value, _name, _file, _iterator4, _step4, _step4$value, _name2, _dir, _t2, _t3, _t4, _t5, _t6, _t7, _t8, _t9, _t0;
|
|
3056
|
+
return slicedToArray._regenerator().w(function (_context4) {
|
|
3057
|
+
while (1) switch (_context4.p = _context4.n) {
|
|
3058
|
+
case 0:
|
|
3059
|
+
entries = [];
|
|
3060
|
+
_iterator3 = slicedToArray._createForOfIteratorHelper(node.files);
|
|
3061
|
+
_context4.p = 1;
|
|
3062
|
+
_iterator3.s();
|
|
3063
|
+
case 2:
|
|
3064
|
+
if ((_step3 = _iterator3.n()).done) {
|
|
3065
|
+
_context4.n = 5;
|
|
3066
|
+
break;
|
|
3067
|
+
}
|
|
3068
|
+
_step3$value = slicedToArray._slicedToArray(_step3.value, 2), _name = _step3$value[0], _file = _step3$value[1];
|
|
3069
|
+
_t2 = entries;
|
|
3070
|
+
_t3 = _file.executable ? "100755" : "100644";
|
|
3071
|
+
_t4 = _name;
|
|
3072
|
+
_context4.n = 3;
|
|
3073
|
+
return sha1(concat([utf8("blob ".concat(_file.content.length, "\0")), _file.content]));
|
|
3074
|
+
case 3:
|
|
3075
|
+
_t5 = _context4.v;
|
|
3076
|
+
_t2.push.call(_t2, {
|
|
3077
|
+
mode: _t3,
|
|
3078
|
+
name: _t4,
|
|
3079
|
+
sha: _t5
|
|
3080
|
+
});
|
|
3081
|
+
case 4:
|
|
3082
|
+
_context4.n = 2;
|
|
3083
|
+
break;
|
|
3084
|
+
case 5:
|
|
3085
|
+
_context4.n = 7;
|
|
3086
|
+
break;
|
|
3087
|
+
case 6:
|
|
3088
|
+
_context4.p = 6;
|
|
3089
|
+
_t6 = _context4.v;
|
|
3090
|
+
_iterator3.e(_t6);
|
|
3091
|
+
case 7:
|
|
3092
|
+
_context4.p = 7;
|
|
3093
|
+
_iterator3.f();
|
|
3094
|
+
return _context4.f(7);
|
|
3095
|
+
case 8:
|
|
3096
|
+
_iterator4 = slicedToArray._createForOfIteratorHelper(node.dirs);
|
|
3097
|
+
_context4.p = 9;
|
|
3098
|
+
_iterator4.s();
|
|
3099
|
+
case 10:
|
|
3100
|
+
if ((_step4 = _iterator4.n()).done) {
|
|
3101
|
+
_context4.n = 13;
|
|
3102
|
+
break;
|
|
3103
|
+
}
|
|
3104
|
+
_step4$value = slicedToArray._slicedToArray(_step4.value, 2), _name2 = _step4$value[0], _dir = _step4$value[1];
|
|
3105
|
+
_t7 = entries;
|
|
3106
|
+
_t8 = _name2;
|
|
3107
|
+
_context4.n = 11;
|
|
3108
|
+
return _build(_dir);
|
|
3109
|
+
case 11:
|
|
3110
|
+
_t9 = _context4.v;
|
|
3111
|
+
_t7.push.call(_t7, {
|
|
3112
|
+
mode: "40000",
|
|
3113
|
+
name: _t8,
|
|
3114
|
+
sha: _t9
|
|
3115
|
+
});
|
|
3116
|
+
case 12:
|
|
3117
|
+
_context4.n = 10;
|
|
3118
|
+
break;
|
|
3119
|
+
case 13:
|
|
3120
|
+
_context4.n = 15;
|
|
3121
|
+
break;
|
|
3122
|
+
case 14:
|
|
3123
|
+
_context4.p = 14;
|
|
3124
|
+
_t0 = _context4.v;
|
|
3125
|
+
_iterator4.e(_t0);
|
|
3126
|
+
case 15:
|
|
3127
|
+
_context4.p = 15;
|
|
3128
|
+
_iterator4.f();
|
|
3129
|
+
return _context4.f(15);
|
|
3130
|
+
case 16:
|
|
3131
|
+
return _context4.a(2, hashTree(entries));
|
|
3132
|
+
}
|
|
3133
|
+
}, _callee4, null, [[9, 14, 15, 16], [1, 6, 7, 8]]);
|
|
3134
|
+
}));
|
|
3135
|
+
return function build(_x5) {
|
|
3136
|
+
return _ref3.apply(this, arguments);
|
|
3137
|
+
};
|
|
3138
|
+
}();
|
|
3139
|
+
_t1 = hex;
|
|
3140
|
+
_context5.n = 5;
|
|
3141
|
+
return _build(root);
|
|
3142
|
+
case 5:
|
|
3143
|
+
return _context5.a(2, _t1(_context5.v));
|
|
3144
|
+
}
|
|
3145
|
+
}, _callee5);
|
|
3146
|
+
}));
|
|
3147
|
+
return _treeSha.apply(this, arguments);
|
|
3148
|
+
}
|
|
3149
|
+
function treeShaOfText(files) {
|
|
3150
|
+
var encoder = new TextEncoder();
|
|
3151
|
+
return treeSha(Object.fromEntries(Object.entries(files).map(function (_ref) {
|
|
3152
|
+
var _ref2 = slicedToArray._slicedToArray(_ref, 2),
|
|
3153
|
+
path = _ref2[0],
|
|
3154
|
+
text = _ref2[1];
|
|
3155
|
+
return [path, {
|
|
3156
|
+
content: encoder.encode(text)
|
|
3157
|
+
}];
|
|
3158
|
+
})));
|
|
3159
|
+
}
|
|
3160
|
+
|
|
3161
|
+
function _typeof(o) {
|
|
3162
|
+
"@babel/helpers - typeof";
|
|
3163
|
+
|
|
3164
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
|
|
3165
|
+
return typeof o;
|
|
3166
|
+
} : function (o) {
|
|
3167
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
3168
|
+
}, _typeof(o);
|
|
3169
|
+
}
|
|
3170
|
+
|
|
3171
|
+
/**
|
|
3172
|
+
* Where a Val project keeps the module this replaces.
|
|
3173
|
+
*
|
|
3174
|
+
* Exported because a caller has to be able to rewrite JUST this file. The
|
|
3175
|
+
* commit is baked into it (see `BUILT_FROM` in the template), and the files a publish
|
|
3176
|
+
* hands over are the `.val.ts` ones it patched -- this is never among them, so a tab
|
|
3177
|
+
* that merged a save and rebuilt would compile the NEW content against the OLD
|
|
3178
|
+
* commit and read the wrong version of it back.
|
|
3179
|
+
*/
|
|
3180
|
+
var VAL_SERVER_PATH = "src/val/val.server.ts";
|
|
3181
|
+
var VAL_SERVER = VAL_SERVER_PATH;
|
|
3182
|
+
var PROJECT_SOURCE_TYPES = "src/val/project-source.d.ts";
|
|
3183
|
+
|
|
3184
|
+
/**
|
|
3185
|
+
* The sentinel host a wired app reaches its platform at.
|
|
3186
|
+
*
|
|
3187
|
+
* Spelled out here rather than imported from the loader: this package is built
|
|
3188
|
+
* into a browser bundle and the loader's into a Worker. One name in two
|
|
3189
|
+
* spellings is the risk, which is why this is a constant used by both the
|
|
3190
|
+
* template it goes into and the check that reads it back out.
|
|
3191
|
+
*/
|
|
3192
|
+
var CONTROL_HOST = "platform.internal";
|
|
3193
|
+
|
|
3194
|
+
/**
|
|
3195
|
+
* The editing backend, as this platform needs it.
|
|
3196
|
+
*
|
|
3197
|
+
* **This is http mode, and almost nothing here deviates from it.** A published
|
|
3198
|
+
* app reads its content from Val's content service at a commit, relays patches
|
|
3199
|
+
* there, and hands the browser a presigned URL to upload an image to -- exactly
|
|
3200
|
+
* as a Val app deployed anywhere else does. Worth stating because this file used
|
|
3201
|
+
* to do none of it: it put Val in `memory` mode, which sets `patchesAreLocal`,
|
|
3202
|
+
* and that one flag moved pending patches into a store of the platform's own and
|
|
3203
|
+
* buffered every draft image through the isolate. Two behaviours nobody chose,
|
|
3204
|
+
* out of one word.
|
|
3205
|
+
*
|
|
3206
|
+
* Two things differ, and each is load bearing:
|
|
3207
|
+
*
|
|
3208
|
+
* - **`publishOverride`** is the seam, and the only place this platform is
|
|
3209
|
+
* unlike any other host. A publish here commits -- the default, handed over as
|
|
3210
|
+
* `commitToGit` -- AND puts the files it committed where the platform can
|
|
3211
|
+
* reach them, because there is no bundler in the isolate: the studio tab picks
|
|
3212
|
+
* them up, builds, and the result
|
|
3213
|
+
* is served immediately instead of a host noticing the commit and redeploying.
|
|
3214
|
+
* - **no formatter.** A repository passes prettier here so a patch written to
|
|
3215
|
+
* disk comes out formatted like the rest of the code. Prettier's bundle
|
|
3216
|
+
* TDZ-crashes in a Worker isolate ("Cannot access 'y' before
|
|
3217
|
+
* initialization"), and nothing is being written to disk anyway.
|
|
3218
|
+
*
|
|
3219
|
+
* WHAT IT COSTS, said here because the code cannot show it: a project with no
|
|
3220
|
+
* `VAL_API_KEY` and `VAL_SECRET` cannot serve its content at all, where a
|
|
3221
|
+
* memory-mode build could -- its sources were compiled into the bundle, and
|
|
3222
|
+
* these are fetched. Credentials stop being what EDITING needs and become what
|
|
3223
|
+
* running needs.
|
|
3224
|
+
*/
|
|
3225
|
+
var valServerSource = function valServerSource(_ref) {
|
|
3226
|
+
var project = _ref.project,
|
|
3227
|
+
git = _ref.git;
|
|
3228
|
+
return "import {\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 * Hand the files a publish committed back to the platform, to be built.\n *\n * There is no bundler in the isolate, so the commit a publish just made cannot\n * become a running site on its own. This writes what the commit contained, with\n * the commit's own sha, to the platform's pending source, and the studio tab\n * picks that up and builds. The sha is not a receipt: it is what the next build\n * is wired AT, so handing over the wrong one produces a build that reads a\n * different version of its content than it was compiled from.\n *\n * Named for `putPendingSource` in the loader's storage, which is what the\n * other side of this request calls -- along with `getPendingSource` and\n * `clearPendingSource`, which the studio tab uses to pick it up and let it go.\n * One mechanism, one noun, however many processes it crosses.\n */\nasync function putPendingSource(\n patchedSourceFiles: Record<string, string | null>,\n commitSha?: string,\n /**\n * What the commit was built ON, and what it points AT.\n *\n * Both optional, and absent is meaningful rather than lazy: a Val too old to\n * report them sends neither, and the platform has to be able to tell that\n * apart from a commit that genuinely has no parent. It falls back to treating\n * the hand-over as unchained -- correct but conservative -- rather than\n * assuming it is a root commit and concluding the history starts here.\n */\n parentSha?: string,\n treeSha?: string,\n) {\n try {\n /*\n * A name the PLATFORM serves, not a URL on the internet.\n *\n * This used to post to the loader's public address, which works in dev --\n * a different port on loopback -- and cannot work deployed: a Worker may\n * not fetch the hostname it is itself served on, so Cloudflare resolved\n * the subrequest away and answered 404. A save then failed with Val's\n * `HTTPError` and the real cause only in the isolate's log.\n *\n * The platform intercepts this host and answers it from inside, so the\n * door is one it holds rather than one this file knows the address of.\n * `.internal` resolves nowhere, so if interception ever stopped, this\n * fails closed instead of reaching a stranger.\n */\n const res = await fetch(\"https://".concat(CONTROL_HOST, "/__api/source\", {\n method: \"POST\",\n headers: { \"content-type\": \"application/json\" },\n body: JSON.stringify({\n /*\n * The project this isolate is actually SERVING, not the one it was\n * generated for.\n *\n * The platform sets __PLATFORM_PROJECT_ID per request from the id the loader\n * resolved off the hostname. The literal is only a fallback, for a build\n * served by a platform too old to set it -- and it is a bad one: publish\n * the same bundle to two projects and every edit made on either lands\n * under whichever name was baked in here.\n */\n project: projectId(),\n files: patchedSourceFiles,\n commitSha,\n /*\n * Spread, so a Val that did not report them leaves the keys out of the\n * body entirely. `parentSha: undefined` would serialise to nothing\n * anyway, but the platform reads this body with a schema, and an\n * explicitly-absent key is what lets it distinguish \"this build's Val\n * cannot tell me\" from \"there is no parent\".\n */\n ...(parentSha !== undefined ? { parentSha } : {}),\n ...(treeSha !== undefined ? { treeSha } : {}),\n }),\n });\n if (!res.ok) {\n throw new Error(`source endpoint returned ${res.status}`);\n }\n } catch (error) {\n throw new Error(`PENDING_SOURCE_FAILED: ${String(error)}`);\n }\n}\n\n/** The project this isolate is serving. See the note in `putPendingSource`. */\nfunction projectId() {\n return globalThis.__PLATFORM_PROJECT_ID ?? ").concat(JSON.stringify(project), ";\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 * The one thing this platform does differently from any other Val host.\n *\n * A publish in http mode is a git commit, and that stays: `commitToGit` is\n * the default, handed over rather than skipped, and calling it is what makes\n * the content service mark the patches published and the repository carry\n * the change. What is ADDED is the build -- the tab picks the pending\n * source up, compiles it, and the result is served immediately, rather than\n * a host noticing the commit and redeploying minutes later.\n *\n * ORDER: commit, then hand over. The commit is the source of truth, and\n * writing the pending source first would mean a build whose content the\n * content service does not have yet, so every read in it would resolve the\n * previous commit -- the site showing pre-save content with the edits\n * already consumed.\n *\n * A hand-over that fails after a commit that succeeded is NOT reported as a\n * failed publish, which is deliberate: the commit happened, and saying it\n * did not is the more misleading of the two. What is lost is the immediate\n * rebuild, so the site serves its previous build until the next publish --\n * recoverable, and the tab can reload the repository at the new commit to\n * do it.\n */\n publishOverride: async ({ patchedSourceFiles, commitToGit }) => {\n const committed = await commitToGit();\n if (committed.error) {\n return committed;\n }\n try {\n await putPendingSource(\n patchedSourceFiles,\n committed.commit,\n /*\n * Added by @valbuild/server after 0.132.0. An older one has neither\n * field and the platform is told nothing rather than told wrongly --\n * see the note on the parameters.\n */\n committed.parent,\n committed.tree,\n );\n } catch (error) {\n console.error(\n \"Val: the commit landed, but the platform could not be given the \" +\n \"files to build. The site serves its previous build until it is \" +\n \"published again.\",\n error,\n );\n }\n return committed;\n },\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");
|
|
3229
|
+
};
|
|
3230
|
+
|
|
3231
|
+
/**
|
|
3232
|
+
* Types for what the PLATFORM supplies, which is in no package.
|
|
3233
|
+
*
|
|
3234
|
+
* Declared rather than suppressed: an editor open on this project should know
|
|
3235
|
+
* what `FILES` is, and the alternative is a file full of red squiggles that a
|
|
3236
|
+
* developer learns to ignore.
|
|
3237
|
+
*/
|
|
3238
|
+
var PROJECT_SOURCE_DECLARATIONS = "// Generated by the Val studio when this project was wired up to the platform.\n// The build resolves this specifier to the project's own source, shipped into\n// the isolate as a module.\ndeclare module 'platform:project-source' {\n /** Every source file of this project, keyed by its path from the root. */\n export const FILES: Record<string, string>\n}\n\ndeclare global {\n /**\n * The project this isolate is serving, set per request by the platform from\n * the id the loader resolved off the hostname.\n *\n * Absent when server-rendering outside the platform, and in the browser.\n */\n // eslint-disable-next-line no-var\n var __PLATFORM_PROJECT_ID: string | undefined\n /**\n * This project's secrets, handed over per request rather than built in.\n *\n * SERVER ONLY -- set by the platform's Worker entry, which never runs in a\n * browser. Absent outside the platform.\n */\n // eslint-disable-next-line no-var\n var __PLATFORM_SECRETS: Record<string, string> | undefined\n}\nexport {}\n";
|
|
3239
|
+
|
|
3240
|
+
/**
|
|
3241
|
+
* The wired `val.server.ts`, on its own.
|
|
3242
|
+
*
|
|
3243
|
+
* {@link wireUp} does this and eight other things, which is right when a
|
|
3244
|
+
* repository arrives and wrong every time a build is about to run: re-deriving
|
|
3245
|
+
* a package.json and a route entry to change one baked-in sha would be a lot of
|
|
3246
|
+
* machinery to get a one-line difference, and any of it not being idempotent
|
|
3247
|
+
* would be a bug that only shows up on the second publish.
|
|
3248
|
+
*/
|
|
3249
|
+
function wiredValServer(options) {
|
|
3250
|
+
return valServerSource(options);
|
|
3251
|
+
}
|
|
3252
|
+
|
|
3253
|
+
/**
|
|
3254
|
+
* The commit a wired record was last built at, read back out of the file.
|
|
3255
|
+
*
|
|
3256
|
+
* The inverse of `BUILT_FROM` in the template, and it lives here so that one place
|
|
3257
|
+
* knows the format -- a reader elsewhere would go stale the first time the
|
|
3258
|
+
* template's shape changed, and silently, since a failed parse and a build
|
|
3259
|
+
* with no commit look identical.
|
|
3260
|
+
*
|
|
3261
|
+
* There is nowhere else this could come from. A record adopted from the live
|
|
3262
|
+
* build IS the published source, and the commit it was published at is a
|
|
3263
|
+
* literal inside its own `val.server.ts`.
|
|
3264
|
+
*/
|
|
3265
|
+
function bakedGit(files) {
|
|
3266
|
+
var source = files[VAL_SERVER];
|
|
3267
|
+
if (source === undefined) return undefined;
|
|
3268
|
+
/*
|
|
3269
|
+
* `BUILT_FROM`, which is the literal, and now the only place a commit can
|
|
3270
|
+
* come from at all.
|
|
3271
|
+
*
|
|
3272
|
+
* There used to be a `GIT` expression beside it that fell back to a runtime
|
|
3273
|
+
* binding for a SHARED build, which a reader of files alone could not
|
|
3274
|
+
* evaluate. That has gone: the content service owns the commit chain, so a
|
|
3275
|
+
* platform build bakes nothing and binds nothing, and this returns
|
|
3276
|
+
* `undefined` for one -- which is the truth about it.
|
|
3277
|
+
*/
|
|
3278
|
+
var match = /^const BUILT_FROM = (.+);$/m.exec(source);
|
|
3279
|
+
if (!(match !== null && match !== void 0 && match[1]) || match[1] === "null") return undefined;
|
|
3280
|
+
try {
|
|
3281
|
+
var parsed = JSON.parse(match[1]);
|
|
3282
|
+
if (_typeof(parsed) !== "object" || parsed === null) return undefined;
|
|
3283
|
+
var _ref2 = parsed,
|
|
3284
|
+
commit = _ref2.commit,
|
|
3285
|
+
branch = _ref2.branch;
|
|
3286
|
+
if (typeof commit !== "string" || typeof branch !== "string") return undefined;
|
|
3287
|
+
if (commit === "" || branch === "") return undefined;
|
|
3288
|
+
return {
|
|
3289
|
+
commit: commit,
|
|
3290
|
+
branch: branch
|
|
3291
|
+
};
|
|
3292
|
+
} catch (_unused) {
|
|
3293
|
+
return undefined;
|
|
3294
|
+
}
|
|
3295
|
+
}
|
|
3296
|
+
|
|
3297
|
+
/** Is this a Val project at all? */
|
|
3298
|
+
function isValProject(files) {
|
|
3299
|
+
return "val.config.ts" in files && "val.modules.ts" in files;
|
|
3300
|
+
}
|
|
3301
|
+
|
|
3302
|
+
/**
|
|
3303
|
+
* Has this record already been wired up?
|
|
3304
|
+
*
|
|
3305
|
+
* The control host is the marker. It used to be `platform:project-source`,
|
|
3306
|
+
* which the generated file imported while Val was in memory mode and no longer
|
|
3307
|
+
* does -- the project's source stopped being shipped into the isolate when the
|
|
3308
|
+
* content service became what answers for it. The pending-source POST is the
|
|
3309
|
+
* thing that cannot be anything but this platform's: no repository posts to a
|
|
3310
|
+
* host that resolves
|
|
3311
|
+
* nowhere, and every wired file has to, because an isolate cannot build.
|
|
3312
|
+
*/
|
|
3313
|
+
function isWired(files) {
|
|
3314
|
+
var _files$VAL_SERVER$inc, _files$VAL_SERVER;
|
|
3315
|
+
return (_files$VAL_SERVER$inc = (_files$VAL_SERVER = files[VAL_SERVER]) === null || _files$VAL_SERVER === void 0 ? void 0 : _files$VAL_SERVER.includes(CONTROL_HOST)) !== null && _files$VAL_SERVER$inc !== void 0 ? _files$VAL_SERVER$inc : false;
|
|
3316
|
+
}
|
|
3317
|
+
|
|
3318
|
+
/**
|
|
3319
|
+
* Returns the record with the platform's wiring applied, and what it changed.
|
|
3320
|
+
*
|
|
3321
|
+
* Non-destructive, and that matters more than it looks: the caller's record is
|
|
3322
|
+
* what an edit is applied to, and the source that gets published back.
|
|
3323
|
+
*/
|
|
3324
|
+
function wireUp(files, options) {
|
|
3325
|
+
var out = slicedToArray._objectSpread2({}, files);
|
|
3326
|
+
var changes = [];
|
|
3327
|
+
var warnings = [];
|
|
3328
|
+
if (!isValProject(files)) {
|
|
3329
|
+
warnings.push("No val.config.ts or val.modules.ts: this does not look like a Val project, so nothing " + "was wired up. It may still build and serve.");
|
|
3330
|
+
return {
|
|
3331
|
+
files: out,
|
|
3332
|
+
changes: changes,
|
|
3333
|
+
warnings: warnings
|
|
3334
|
+
};
|
|
3335
|
+
}
|
|
3336
|
+
|
|
3337
|
+
// --- the editing backend ----------------------------------------------------
|
|
3338
|
+
|
|
3339
|
+
out[VAL_SERVER] = valServerSource(options);
|
|
3340
|
+
changes.push({
|
|
3341
|
+
what: "".concat(VAL_SERVER, " rewritten for the platform"),
|
|
3342
|
+
why: "Val reads its content over HTTP at this commit, as in any deployment, and a publish " + "also hands the files it committed to the platform so the tab can build them -- nothing " + "else turns a commit into a running site, because there is no bundler in the isolate"
|
|
3343
|
+
});
|
|
3344
|
+
out[PROJECT_SOURCE_TYPES] = PROJECT_SOURCE_DECLARATIONS;
|
|
3345
|
+
changes.push({
|
|
3346
|
+
what: "".concat(PROJECT_SOURCE_TYPES, " added"),
|
|
3347
|
+
why: "the platform sets globals for the project id and its secrets, and the build can " + "supply `platform:project-source`; no package declares either"
|
|
3348
|
+
});
|
|
3349
|
+
|
|
3350
|
+
// --- the Studio's own bundle ------------------------------------------------
|
|
3351
|
+
|
|
3352
|
+
/*
|
|
3353
|
+
* `@valbuild/ui` carries the Studio's UI -- 7.15 MB, base64-embedded into the
|
|
3354
|
+
* package, served by `/api/val/static/...`. A template usually has it only as
|
|
3355
|
+
* a TRANSITIVE dependency, and the vendor layer is built from what a project
|
|
3356
|
+
* DECLARES intersected with what it imports. Undeclared, the Studio loads its
|
|
3357
|
+
* shell and then 404s on its own bundle.
|
|
3358
|
+
*/
|
|
3359
|
+
var manifestRaw = files["package.json"];
|
|
3360
|
+
if (manifestRaw) {
|
|
3361
|
+
try {
|
|
3362
|
+
var _manifest$dependencie;
|
|
3363
|
+
var manifest = JSON.parse(manifestRaw);
|
|
3364
|
+
var deps = (_manifest$dependencie = manifest.dependencies) !== null && _manifest$dependencie !== void 0 ? _manifest$dependencie : {};
|
|
3365
|
+
if (deps["@valbuild/core"] && !deps["@valbuild/ui"]) {
|
|
3366
|
+
deps["@valbuild/ui"] = deps["@valbuild/core"];
|
|
3367
|
+
manifest.dependencies = deps;
|
|
3368
|
+
out["package.json"] = "".concat(JSON.stringify(manifest, null, 2), "\n");
|
|
3369
|
+
changes.push({
|
|
3370
|
+
what: "@valbuild/ui declared as a dependency",
|
|
3371
|
+
why: "it carries the Studio bundle and was only a transitive dependency; the vendor " + "layer is built from what the project declares"
|
|
3372
|
+
});
|
|
3373
|
+
}
|
|
3374
|
+
} catch (_unused2) {
|
|
3375
|
+
warnings.push("package.json could not be parsed, so @valbuild/ui was not declared.");
|
|
3376
|
+
}
|
|
3377
|
+
}
|
|
3378
|
+
|
|
3379
|
+
// --- generated output the repository happens to track -----------------------
|
|
3380
|
+
|
|
3381
|
+
/*
|
|
3382
|
+
* `routeTree.gen.ts` is derived, and this platform generates it per build.
|
|
3383
|
+
* Most projects gitignore it; `valbuild/template-tanstack-starter` tracks it,
|
|
3384
|
+
* so an import carries a stale copy -- which the build would overwrite and
|
|
3385
|
+
* then publish BACK as project source, so the record would slowly fill with
|
|
3386
|
+
* generated files that are never read.
|
|
3387
|
+
*/
|
|
3388
|
+
if (TREE in out) {
|
|
3389
|
+
delete out[TREE];
|
|
3390
|
+
changes.push({
|
|
3391
|
+
what: "".concat(TREE, " dropped"),
|
|
3392
|
+
why: "it is generated per build; a tracked copy would be published back as project source"
|
|
3393
|
+
});
|
|
3394
|
+
}
|
|
3395
|
+
|
|
3396
|
+
// --- what wiring cannot fix -------------------------------------------------
|
|
3397
|
+
|
|
3398
|
+
warnings.push("This wires the SOURCE up. The project still needs a dependency layer built for it, which " + "is a pass over node_modules and cannot happen in a browser.");
|
|
3399
|
+
return {
|
|
3400
|
+
files: out,
|
|
3401
|
+
changes: changes,
|
|
3402
|
+
warnings: warnings
|
|
3403
|
+
};
|
|
3404
|
+
}
|
|
3405
|
+
|
|
3406
|
+
exports.ENTRY = ENTRY;
|
|
3407
|
+
exports.ENTRY_CHUNK = ENTRY_CHUNK;
|
|
3408
|
+
exports.INLINE_LIMIT = INLINE_LIMIT;
|
|
3409
|
+
exports.PROJECT_SOURCE = PROJECT_SOURCE;
|
|
3410
|
+
exports.PUBLIC_PREFIX = PUBLIC_PREFIX;
|
|
3411
|
+
exports.ROUTES_DIR = ROUTES_DIR;
|
|
3412
|
+
exports.TREE = TREE;
|
|
3413
|
+
exports.VAL_SERVER_PATH = VAL_SERVER_PATH;
|
|
3414
|
+
exports.aliasMap = aliasMap;
|
|
3415
|
+
exports.bakedGit = bakedGit;
|
|
3416
|
+
exports.base64Bytes = base64Bytes;
|
|
3417
|
+
exports.blobSha = blobSha;
|
|
3418
|
+
exports.buildUserApp = buildUserApp;
|
|
3419
|
+
exports.fetchBuildTarget = fetchBuildTarget;
|
|
3420
|
+
exports.fetchBuildTargetRev = fetchBuildTargetRev;
|
|
3421
|
+
exports.isAsset = isAsset;
|
|
3422
|
+
exports.isValProject = isValProject;
|
|
3423
|
+
exports.isWired = isWired;
|
|
3424
|
+
exports.publishPayload = publishPayload;
|
|
3425
|
+
exports.resolveInFiles = resolveInFiles;
|
|
3426
|
+
exports.scanCandidates = scanCandidates;
|
|
3427
|
+
exports.treeSha = treeSha;
|
|
3428
|
+
exports.treeShaOfText = treeShaOfText;
|
|
3429
|
+
exports.usesTailwind = usesTailwind;
|
|
3430
|
+
exports.wireUp = wireUp;
|
|
3431
|
+
exports.wiredValServer = wiredValServer;
|