@valbuild/tanstack-build 0.142.0 → 0.144.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 +20 -0
- package/dist/declarations/src/build.d.ts +7 -0
- package/dist/declarations/src/node/vendorLayer.d.ts +14 -2
- package/dist/{regeneratorValues-637c3146.cjs.prod.js → regeneratorValues-295cad22.cjs.prod.js} +136 -0
- package/dist/{regeneratorValues-78fb2365.cjs.dev.js → regeneratorValues-5b6a1f70.cjs.dev.js} +136 -0
- package/dist/{regeneratorValues-3acdc3fe.esm.js → regeneratorValues-af449040.esm.js} +130 -1
- package/dist/valbuild-tanstack-build.cjs.dev.js +112 -143
- package/dist/valbuild-tanstack-build.cjs.prod.js +112 -143
- package/dist/valbuild-tanstack-build.esm.js +104 -134
- package/node/dist/valbuild-tanstack-build-node.cjs.dev.js +397 -172
- package/node/dist/valbuild-tanstack-build-node.cjs.prod.js +397 -172
- package/node/dist/valbuild-tanstack-build-node.esm.js +398 -173
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @valbuild/tanstack-build
|
|
2
2
|
|
|
3
|
+
## 0.144.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#827](https://github.com/valbuild/val/pull/827) [`1272b14`](https://github.com/valbuild/val/commit/1272b1408cf55fefccdce442352c208a7f69f44b) Thanks [@freekh](https://github.com/freekh)! - Publishing to Val's platform, through `val publish` or the Studio, now handles a stylesheet that imports other stylesheets, and fonts installed as packages:
|
|
8
|
+
|
|
9
|
+
```css
|
|
10
|
+
/* src/styles.css */
|
|
11
|
+
@import "tailwindcss";
|
|
12
|
+
@import "./theme/theme.css";
|
|
13
|
+
|
|
14
|
+
/* src/theme/theme.css */
|
|
15
|
+
@import "@fontsource-variable/inter";
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Before this, the platform's build passed `@import "./theme/theme.css"` on to Tailwind without resolving it, and publishing stopped with `Tailwind asked for './theme/theme.css', which this build does not carry`. A font package such as `@fontsource-variable/inter` was built as code, failed, and was skipped.
|
|
19
|
+
|
|
20
|
+
- A stylesheet's own `@import`s are inlined where they were written, the same way `vite build` handles them. That covers relative files and stylesheets that dependencies ship. `layer()`, `supports()` and media conditions are kept, and a stylesheet imported twice is only included once.
|
|
21
|
+
- The files a dependency's stylesheet points at with `url(...)`, such as a font package's `.woff2` files, are published with the site and served from it.
|
|
22
|
+
|
|
3
23
|
## 0.142.0
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
|
@@ -80,6 +80,13 @@ export interface BuildInput {
|
|
|
80
80
|
* back which it kept.
|
|
81
81
|
*/
|
|
82
82
|
assets?: Record<string, string>;
|
|
83
|
+
/**
|
|
84
|
+
* Files the dependencies' stylesheets point at -- a font package's `.woff2`s
|
|
85
|
+
* -- base64, keyed by the content-addressed name their `url()` was rewritten
|
|
86
|
+
* to. Read in CI by `collectDependencyCss`, and published as they are: the
|
|
87
|
+
* stylesheet already names them, so there is nothing to resolve or inline.
|
|
88
|
+
*/
|
|
89
|
+
dependencyAssets?: Record<string, string>;
|
|
83
90
|
/**
|
|
84
91
|
* What `platform:project-source` resolves to, when the app imports it.
|
|
85
92
|
*
|
|
@@ -136,7 +136,10 @@ interface AuditableImport {
|
|
|
136
136
|
/** Every import and re-export a chunk emits, with the names it takes. */
|
|
137
137
|
export declare function auditableImports(code: string, file: string): Promise<Array<AuditableImport>>;
|
|
138
138
|
export declare function auditableSpecifiers(code: string, file: string): Promise<Array<string>>;
|
|
139
|
-
/**
|
|
139
|
+
/**
|
|
140
|
+
* Bare specifiers that point at a stylesheet rather than a module: a `.css`
|
|
141
|
+
* file a module imports, or anything a stylesheet `@import`s.
|
|
142
|
+
*/
|
|
140
143
|
export declare function cssSpecifiersOf(files: Record<string, string>): string[];
|
|
141
144
|
/** The package a bare specifier belongs to. `@scope/pkg/sub` -> `@scope/pkg`. */
|
|
142
145
|
export declare function packageOf(specifier: string): string;
|
|
@@ -170,6 +173,15 @@ export declare function layerDepsOf(manifest: {
|
|
|
170
173
|
* into the project's stylesheet by the builder's CSS pass. Resolution is the
|
|
171
174
|
* project's own, so the version matches whatever its lockfile pinned.
|
|
172
175
|
*/
|
|
173
|
-
export declare function collectDependencyCss(dir: string, specifiers: Array<string
|
|
176
|
+
export declare function collectDependencyCss(dir: string, specifiers: Array<string>,
|
|
177
|
+
/**
|
|
178
|
+
* Where the files a stylesheet points at with `url(...)` go, base64, keyed
|
|
179
|
+
* by the content-addressed name the rewritten `url()` now uses. Pass it to
|
|
180
|
+
* the build as `dependencyAssets`, which publishes them under `/_app/a/`.
|
|
181
|
+
*
|
|
182
|
+
* Without it the stylesheets are carried as they are, and a relative `url()`
|
|
183
|
+
* in one -- every font package's -- points at nothing once it is served.
|
|
184
|
+
*/
|
|
185
|
+
assets?: Record<string, string>): Promise<Record<string, string>>;
|
|
174
186
|
export declare function buildVendorLayer(dir: string, deps: Array<string>, css: Record<string, string>, platform: VendorPlatform): Promise<VendorLayer | null>;
|
|
175
187
|
export {};
|
package/dist/{regeneratorValues-637c3146.cjs.prod.js → regeneratorValues-295cad22.cjs.prod.js}
RENAMED
|
@@ -302,6 +302,135 @@ function _slicedToArray(r, e) {
|
|
|
302
302
|
return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
|
|
303
303
|
}
|
|
304
304
|
|
|
305
|
+
// One sha256, used by the build hash and by asset content-addressing.
|
|
306
|
+
//
|
|
307
|
+
// `crypto.subtle` rather than node:crypto: the builder runs in a browser tab as
|
|
308
|
+
// well as in Node, and this is the only digest available in both.
|
|
309
|
+
function sha256Hex(_x) {
|
|
310
|
+
return _sha256Hex.apply(this, arguments);
|
|
311
|
+
}
|
|
312
|
+
function _sha256Hex() {
|
|
313
|
+
_sha256Hex = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(text) {
|
|
314
|
+
var digest;
|
|
315
|
+
return _regenerator().w(function (_context) {
|
|
316
|
+
while (1) switch (_context.n) {
|
|
317
|
+
case 0:
|
|
318
|
+
_context.n = 1;
|
|
319
|
+
return crypto.subtle.digest("SHA-256", new TextEncoder().encode(text));
|
|
320
|
+
case 1:
|
|
321
|
+
digest = _context.v;
|
|
322
|
+
return _context.a(2, _toConsumableArray(new Uint8Array(digest)).map(function (_byte) {
|
|
323
|
+
return _byte.toString(16).padStart(2, "0");
|
|
324
|
+
}).join(""));
|
|
325
|
+
}
|
|
326
|
+
}, _callee);
|
|
327
|
+
}));
|
|
328
|
+
return _sha256Hex.apply(this, arguments);
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
* Extensions treated as assets.
|
|
333
|
+
*
|
|
334
|
+
* Deliberately a list rather than "anything not JS or CSS": an unknown
|
|
335
|
+
* extension should fail as an unresolved import naming the file, not silently
|
|
336
|
+
* become a URL to something the browser cannot use.
|
|
337
|
+
*/
|
|
338
|
+
var ASSET_TYPES = {
|
|
339
|
+
".png": "image/png",
|
|
340
|
+
".jpg": "image/jpeg",
|
|
341
|
+
".jpeg": "image/jpeg",
|
|
342
|
+
".gif": "image/gif",
|
|
343
|
+
".webp": "image/webp",
|
|
344
|
+
".avif": "image/avif",
|
|
345
|
+
".svg": "image/svg+xml",
|
|
346
|
+
".ico": "image/x-icon",
|
|
347
|
+
".woff": "font/woff",
|
|
348
|
+
".woff2": "font/woff2",
|
|
349
|
+
".ttf": "font/ttf",
|
|
350
|
+
".otf": "font/otf",
|
|
351
|
+
".mp4": "video/mp4",
|
|
352
|
+
".webm": "video/webm",
|
|
353
|
+
".mp3": "audio/mpeg",
|
|
354
|
+
".wav": "audio/wav",
|
|
355
|
+
".pdf": "application/pdf",
|
|
356
|
+
".txt": "text/plain"
|
|
357
|
+
};
|
|
358
|
+
var extensionOf = function extensionOf(path) {
|
|
359
|
+
var at = path.lastIndexOf(".");
|
|
360
|
+
return at === -1 ? "" : path.slice(at).toLowerCase();
|
|
361
|
+
};
|
|
362
|
+
var isAsset = function isAsset(path) {
|
|
363
|
+
return extensionOf(path) in ASSET_TYPES;
|
|
364
|
+
};
|
|
365
|
+
var mimeOf = function mimeOf(path) {
|
|
366
|
+
var _ASSET_TYPES$extensio;
|
|
367
|
+
return (_ASSET_TYPES$extensio = ASSET_TYPES[extensionOf(path)]) !== null && _ASSET_TYPES$extensio !== void 0 ? _ASSET_TYPES$extensio : "application/octet-stream";
|
|
368
|
+
};
|
|
369
|
+
|
|
370
|
+
/**
|
|
371
|
+
* Below this many decoded bytes, an asset is inlined as a data URI.
|
|
372
|
+
*
|
|
373
|
+
* 4 kB, matching Vite's `assetsInlineLimit` default. The trade is the same one
|
|
374
|
+
* Vite is making: an extra request costs more than 4 kB of base64 does, and
|
|
375
|
+
* above that it stops being true.
|
|
376
|
+
*/
|
|
377
|
+
var INLINE_LIMIT = 4096;
|
|
378
|
+
|
|
379
|
+
/** Decoded byte length of base64, without decoding it. */
|
|
380
|
+
function base64Bytes(base64) {
|
|
381
|
+
var clean = base64.replace(/=+$/, "");
|
|
382
|
+
return Math.floor(clean.length * 3 / 4);
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
385
|
+
* Where an asset import resolves to, for one target.
|
|
386
|
+
*
|
|
387
|
+
* Server and client get the *same* URL. An asset is a URL in both, and SSR has
|
|
388
|
+
* to emit the same `src` the browser will hydrate against -- a server bundle
|
|
389
|
+
* with a different URL would be a hydration mismatch on every image.
|
|
390
|
+
*/
|
|
391
|
+
function resolveAsset(_x, _x2) {
|
|
392
|
+
return _resolveAsset.apply(this, arguments);
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
/** Where published assets are served from. Matched by the loader. */
|
|
396
|
+
function _resolveAsset() {
|
|
397
|
+
_resolveAsset = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(path, base64) {
|
|
398
|
+
var hash, name;
|
|
399
|
+
return _regenerator().w(function (_context) {
|
|
400
|
+
while (1) switch (_context.n) {
|
|
401
|
+
case 0:
|
|
402
|
+
if (!(base64Bytes(base64) <= INLINE_LIMIT)) {
|
|
403
|
+
_context.n = 1;
|
|
404
|
+
break;
|
|
405
|
+
}
|
|
406
|
+
return _context.a(2, {
|
|
407
|
+
url: "data:".concat(mimeOf(path), ";base64,").concat(base64)
|
|
408
|
+
});
|
|
409
|
+
case 1:
|
|
410
|
+
_context.n = 2;
|
|
411
|
+
return sha256Hex(base64);
|
|
412
|
+
case 2:
|
|
413
|
+
hash = _context.v.slice(0, 16);
|
|
414
|
+
name = "".concat(hash).concat(extensionOf(path));
|
|
415
|
+
return _context.a(2, {
|
|
416
|
+
url: "".concat(ASSET_BASE).concat(name),
|
|
417
|
+
file: {
|
|
418
|
+
name: name,
|
|
419
|
+
base64: base64
|
|
420
|
+
}
|
|
421
|
+
});
|
|
422
|
+
}
|
|
423
|
+
}, _callee);
|
|
424
|
+
}));
|
|
425
|
+
return _resolveAsset.apply(this, arguments);
|
|
426
|
+
}
|
|
427
|
+
var ASSET_BASE = "/_app/a/";
|
|
428
|
+
|
|
429
|
+
/** The module a resolved asset import becomes. */
|
|
430
|
+
var assetModule = function assetModule(url) {
|
|
431
|
+
return "export default ".concat(JSON.stringify(url), "\n");
|
|
432
|
+
};
|
|
433
|
+
|
|
305
434
|
function _regeneratorValues(e) {
|
|
306
435
|
if (null != e) {
|
|
307
436
|
var t = e["function" == typeof Symbol && Symbol.iterator || "@@iterator"],
|
|
@@ -320,6 +449,8 @@ function _regeneratorValues(e) {
|
|
|
320
449
|
throw new TypeError(typeof e + " is not iterable");
|
|
321
450
|
}
|
|
322
451
|
|
|
452
|
+
exports.ASSET_BASE = ASSET_BASE;
|
|
453
|
+
exports.INLINE_LIMIT = INLINE_LIMIT;
|
|
323
454
|
exports._asyncToGenerator = _asyncToGenerator;
|
|
324
455
|
exports._createForOfIteratorHelper = _createForOfIteratorHelper;
|
|
325
456
|
exports._defineProperty = _defineProperty;
|
|
@@ -328,3 +459,8 @@ exports._regenerator = _regenerator;
|
|
|
328
459
|
exports._regeneratorValues = _regeneratorValues;
|
|
329
460
|
exports._slicedToArray = _slicedToArray;
|
|
330
461
|
exports._toConsumableArray = _toConsumableArray;
|
|
462
|
+
exports.assetModule = assetModule;
|
|
463
|
+
exports.base64Bytes = base64Bytes;
|
|
464
|
+
exports.isAsset = isAsset;
|
|
465
|
+
exports.resolveAsset = resolveAsset;
|
|
466
|
+
exports.sha256Hex = sha256Hex;
|
package/dist/{regeneratorValues-78fb2365.cjs.dev.js → regeneratorValues-5b6a1f70.cjs.dev.js}
RENAMED
|
@@ -302,6 +302,135 @@ function _slicedToArray(r, e) {
|
|
|
302
302
|
return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
|
|
303
303
|
}
|
|
304
304
|
|
|
305
|
+
// One sha256, used by the build hash and by asset content-addressing.
|
|
306
|
+
//
|
|
307
|
+
// `crypto.subtle` rather than node:crypto: the builder runs in a browser tab as
|
|
308
|
+
// well as in Node, and this is the only digest available in both.
|
|
309
|
+
function sha256Hex(_x) {
|
|
310
|
+
return _sha256Hex.apply(this, arguments);
|
|
311
|
+
}
|
|
312
|
+
function _sha256Hex() {
|
|
313
|
+
_sha256Hex = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(text) {
|
|
314
|
+
var digest;
|
|
315
|
+
return _regenerator().w(function (_context) {
|
|
316
|
+
while (1) switch (_context.n) {
|
|
317
|
+
case 0:
|
|
318
|
+
_context.n = 1;
|
|
319
|
+
return crypto.subtle.digest("SHA-256", new TextEncoder().encode(text));
|
|
320
|
+
case 1:
|
|
321
|
+
digest = _context.v;
|
|
322
|
+
return _context.a(2, _toConsumableArray(new Uint8Array(digest)).map(function (_byte) {
|
|
323
|
+
return _byte.toString(16).padStart(2, "0");
|
|
324
|
+
}).join(""));
|
|
325
|
+
}
|
|
326
|
+
}, _callee);
|
|
327
|
+
}));
|
|
328
|
+
return _sha256Hex.apply(this, arguments);
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
* Extensions treated as assets.
|
|
333
|
+
*
|
|
334
|
+
* Deliberately a list rather than "anything not JS or CSS": an unknown
|
|
335
|
+
* extension should fail as an unresolved import naming the file, not silently
|
|
336
|
+
* become a URL to something the browser cannot use.
|
|
337
|
+
*/
|
|
338
|
+
var ASSET_TYPES = {
|
|
339
|
+
".png": "image/png",
|
|
340
|
+
".jpg": "image/jpeg",
|
|
341
|
+
".jpeg": "image/jpeg",
|
|
342
|
+
".gif": "image/gif",
|
|
343
|
+
".webp": "image/webp",
|
|
344
|
+
".avif": "image/avif",
|
|
345
|
+
".svg": "image/svg+xml",
|
|
346
|
+
".ico": "image/x-icon",
|
|
347
|
+
".woff": "font/woff",
|
|
348
|
+
".woff2": "font/woff2",
|
|
349
|
+
".ttf": "font/ttf",
|
|
350
|
+
".otf": "font/otf",
|
|
351
|
+
".mp4": "video/mp4",
|
|
352
|
+
".webm": "video/webm",
|
|
353
|
+
".mp3": "audio/mpeg",
|
|
354
|
+
".wav": "audio/wav",
|
|
355
|
+
".pdf": "application/pdf",
|
|
356
|
+
".txt": "text/plain"
|
|
357
|
+
};
|
|
358
|
+
var extensionOf = function extensionOf(path) {
|
|
359
|
+
var at = path.lastIndexOf(".");
|
|
360
|
+
return at === -1 ? "" : path.slice(at).toLowerCase();
|
|
361
|
+
};
|
|
362
|
+
var isAsset = function isAsset(path) {
|
|
363
|
+
return extensionOf(path) in ASSET_TYPES;
|
|
364
|
+
};
|
|
365
|
+
var mimeOf = function mimeOf(path) {
|
|
366
|
+
var _ASSET_TYPES$extensio;
|
|
367
|
+
return (_ASSET_TYPES$extensio = ASSET_TYPES[extensionOf(path)]) !== null && _ASSET_TYPES$extensio !== void 0 ? _ASSET_TYPES$extensio : "application/octet-stream";
|
|
368
|
+
};
|
|
369
|
+
|
|
370
|
+
/**
|
|
371
|
+
* Below this many decoded bytes, an asset is inlined as a data URI.
|
|
372
|
+
*
|
|
373
|
+
* 4 kB, matching Vite's `assetsInlineLimit` default. The trade is the same one
|
|
374
|
+
* Vite is making: an extra request costs more than 4 kB of base64 does, and
|
|
375
|
+
* above that it stops being true.
|
|
376
|
+
*/
|
|
377
|
+
var INLINE_LIMIT = 4096;
|
|
378
|
+
|
|
379
|
+
/** Decoded byte length of base64, without decoding it. */
|
|
380
|
+
function base64Bytes(base64) {
|
|
381
|
+
var clean = base64.replace(/=+$/, "");
|
|
382
|
+
return Math.floor(clean.length * 3 / 4);
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
385
|
+
* Where an asset import resolves to, for one target.
|
|
386
|
+
*
|
|
387
|
+
* Server and client get the *same* URL. An asset is a URL in both, and SSR has
|
|
388
|
+
* to emit the same `src` the browser will hydrate against -- a server bundle
|
|
389
|
+
* with a different URL would be a hydration mismatch on every image.
|
|
390
|
+
*/
|
|
391
|
+
function resolveAsset(_x, _x2) {
|
|
392
|
+
return _resolveAsset.apply(this, arguments);
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
/** Where published assets are served from. Matched by the loader. */
|
|
396
|
+
function _resolveAsset() {
|
|
397
|
+
_resolveAsset = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(path, base64) {
|
|
398
|
+
var hash, name;
|
|
399
|
+
return _regenerator().w(function (_context) {
|
|
400
|
+
while (1) switch (_context.n) {
|
|
401
|
+
case 0:
|
|
402
|
+
if (!(base64Bytes(base64) <= INLINE_LIMIT)) {
|
|
403
|
+
_context.n = 1;
|
|
404
|
+
break;
|
|
405
|
+
}
|
|
406
|
+
return _context.a(2, {
|
|
407
|
+
url: "data:".concat(mimeOf(path), ";base64,").concat(base64)
|
|
408
|
+
});
|
|
409
|
+
case 1:
|
|
410
|
+
_context.n = 2;
|
|
411
|
+
return sha256Hex(base64);
|
|
412
|
+
case 2:
|
|
413
|
+
hash = _context.v.slice(0, 16);
|
|
414
|
+
name = "".concat(hash).concat(extensionOf(path));
|
|
415
|
+
return _context.a(2, {
|
|
416
|
+
url: "".concat(ASSET_BASE).concat(name),
|
|
417
|
+
file: {
|
|
418
|
+
name: name,
|
|
419
|
+
base64: base64
|
|
420
|
+
}
|
|
421
|
+
});
|
|
422
|
+
}
|
|
423
|
+
}, _callee);
|
|
424
|
+
}));
|
|
425
|
+
return _resolveAsset.apply(this, arguments);
|
|
426
|
+
}
|
|
427
|
+
var ASSET_BASE = "/_app/a/";
|
|
428
|
+
|
|
429
|
+
/** The module a resolved asset import becomes. */
|
|
430
|
+
var assetModule = function assetModule(url) {
|
|
431
|
+
return "export default ".concat(JSON.stringify(url), "\n");
|
|
432
|
+
};
|
|
433
|
+
|
|
305
434
|
function _regeneratorValues(e) {
|
|
306
435
|
if (null != e) {
|
|
307
436
|
var t = e["function" == typeof Symbol && Symbol.iterator || "@@iterator"],
|
|
@@ -320,6 +449,8 @@ function _regeneratorValues(e) {
|
|
|
320
449
|
throw new TypeError(typeof e + " is not iterable");
|
|
321
450
|
}
|
|
322
451
|
|
|
452
|
+
exports.ASSET_BASE = ASSET_BASE;
|
|
453
|
+
exports.INLINE_LIMIT = INLINE_LIMIT;
|
|
323
454
|
exports._asyncToGenerator = _asyncToGenerator;
|
|
324
455
|
exports._createForOfIteratorHelper = _createForOfIteratorHelper;
|
|
325
456
|
exports._defineProperty = _defineProperty;
|
|
@@ -328,3 +459,8 @@ exports._regenerator = _regenerator;
|
|
|
328
459
|
exports._regeneratorValues = _regeneratorValues;
|
|
329
460
|
exports._slicedToArray = _slicedToArray;
|
|
330
461
|
exports._toConsumableArray = _toConsumableArray;
|
|
462
|
+
exports.assetModule = assetModule;
|
|
463
|
+
exports.base64Bytes = base64Bytes;
|
|
464
|
+
exports.isAsset = isAsset;
|
|
465
|
+
exports.resolveAsset = resolveAsset;
|
|
466
|
+
exports.sha256Hex = sha256Hex;
|
|
@@ -300,6 +300,135 @@ function _slicedToArray(r, e) {
|
|
|
300
300
|
return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
|
|
301
301
|
}
|
|
302
302
|
|
|
303
|
+
// One sha256, used by the build hash and by asset content-addressing.
|
|
304
|
+
//
|
|
305
|
+
// `crypto.subtle` rather than node:crypto: the builder runs in a browser tab as
|
|
306
|
+
// well as in Node, and this is the only digest available in both.
|
|
307
|
+
function sha256Hex(_x) {
|
|
308
|
+
return _sha256Hex.apply(this, arguments);
|
|
309
|
+
}
|
|
310
|
+
function _sha256Hex() {
|
|
311
|
+
_sha256Hex = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(text) {
|
|
312
|
+
var digest;
|
|
313
|
+
return _regenerator().w(function (_context) {
|
|
314
|
+
while (1) switch (_context.n) {
|
|
315
|
+
case 0:
|
|
316
|
+
_context.n = 1;
|
|
317
|
+
return crypto.subtle.digest("SHA-256", new TextEncoder().encode(text));
|
|
318
|
+
case 1:
|
|
319
|
+
digest = _context.v;
|
|
320
|
+
return _context.a(2, _toConsumableArray(new Uint8Array(digest)).map(function (_byte) {
|
|
321
|
+
return _byte.toString(16).padStart(2, "0");
|
|
322
|
+
}).join(""));
|
|
323
|
+
}
|
|
324
|
+
}, _callee);
|
|
325
|
+
}));
|
|
326
|
+
return _sha256Hex.apply(this, arguments);
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* Extensions treated as assets.
|
|
331
|
+
*
|
|
332
|
+
* Deliberately a list rather than "anything not JS or CSS": an unknown
|
|
333
|
+
* extension should fail as an unresolved import naming the file, not silently
|
|
334
|
+
* become a URL to something the browser cannot use.
|
|
335
|
+
*/
|
|
336
|
+
var ASSET_TYPES = {
|
|
337
|
+
".png": "image/png",
|
|
338
|
+
".jpg": "image/jpeg",
|
|
339
|
+
".jpeg": "image/jpeg",
|
|
340
|
+
".gif": "image/gif",
|
|
341
|
+
".webp": "image/webp",
|
|
342
|
+
".avif": "image/avif",
|
|
343
|
+
".svg": "image/svg+xml",
|
|
344
|
+
".ico": "image/x-icon",
|
|
345
|
+
".woff": "font/woff",
|
|
346
|
+
".woff2": "font/woff2",
|
|
347
|
+
".ttf": "font/ttf",
|
|
348
|
+
".otf": "font/otf",
|
|
349
|
+
".mp4": "video/mp4",
|
|
350
|
+
".webm": "video/webm",
|
|
351
|
+
".mp3": "audio/mpeg",
|
|
352
|
+
".wav": "audio/wav",
|
|
353
|
+
".pdf": "application/pdf",
|
|
354
|
+
".txt": "text/plain"
|
|
355
|
+
};
|
|
356
|
+
var extensionOf = function extensionOf(path) {
|
|
357
|
+
var at = path.lastIndexOf(".");
|
|
358
|
+
return at === -1 ? "" : path.slice(at).toLowerCase();
|
|
359
|
+
};
|
|
360
|
+
var isAsset = function isAsset(path) {
|
|
361
|
+
return extensionOf(path) in ASSET_TYPES;
|
|
362
|
+
};
|
|
363
|
+
var mimeOf = function mimeOf(path) {
|
|
364
|
+
var _ASSET_TYPES$extensio;
|
|
365
|
+
return (_ASSET_TYPES$extensio = ASSET_TYPES[extensionOf(path)]) !== null && _ASSET_TYPES$extensio !== void 0 ? _ASSET_TYPES$extensio : "application/octet-stream";
|
|
366
|
+
};
|
|
367
|
+
|
|
368
|
+
/**
|
|
369
|
+
* Below this many decoded bytes, an asset is inlined as a data URI.
|
|
370
|
+
*
|
|
371
|
+
* 4 kB, matching Vite's `assetsInlineLimit` default. The trade is the same one
|
|
372
|
+
* Vite is making: an extra request costs more than 4 kB of base64 does, and
|
|
373
|
+
* above that it stops being true.
|
|
374
|
+
*/
|
|
375
|
+
var INLINE_LIMIT = 4096;
|
|
376
|
+
|
|
377
|
+
/** Decoded byte length of base64, without decoding it. */
|
|
378
|
+
function base64Bytes(base64) {
|
|
379
|
+
var clean = base64.replace(/=+$/, "");
|
|
380
|
+
return Math.floor(clean.length * 3 / 4);
|
|
381
|
+
}
|
|
382
|
+
/**
|
|
383
|
+
* Where an asset import resolves to, for one target.
|
|
384
|
+
*
|
|
385
|
+
* Server and client get the *same* URL. An asset is a URL in both, and SSR has
|
|
386
|
+
* to emit the same `src` the browser will hydrate against -- a server bundle
|
|
387
|
+
* with a different URL would be a hydration mismatch on every image.
|
|
388
|
+
*/
|
|
389
|
+
function resolveAsset(_x, _x2) {
|
|
390
|
+
return _resolveAsset.apply(this, arguments);
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
/** Where published assets are served from. Matched by the loader. */
|
|
394
|
+
function _resolveAsset() {
|
|
395
|
+
_resolveAsset = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(path, base64) {
|
|
396
|
+
var hash, name;
|
|
397
|
+
return _regenerator().w(function (_context) {
|
|
398
|
+
while (1) switch (_context.n) {
|
|
399
|
+
case 0:
|
|
400
|
+
if (!(base64Bytes(base64) <= INLINE_LIMIT)) {
|
|
401
|
+
_context.n = 1;
|
|
402
|
+
break;
|
|
403
|
+
}
|
|
404
|
+
return _context.a(2, {
|
|
405
|
+
url: "data:".concat(mimeOf(path), ";base64,").concat(base64)
|
|
406
|
+
});
|
|
407
|
+
case 1:
|
|
408
|
+
_context.n = 2;
|
|
409
|
+
return sha256Hex(base64);
|
|
410
|
+
case 2:
|
|
411
|
+
hash = _context.v.slice(0, 16);
|
|
412
|
+
name = "".concat(hash).concat(extensionOf(path));
|
|
413
|
+
return _context.a(2, {
|
|
414
|
+
url: "".concat(ASSET_BASE).concat(name),
|
|
415
|
+
file: {
|
|
416
|
+
name: name,
|
|
417
|
+
base64: base64
|
|
418
|
+
}
|
|
419
|
+
});
|
|
420
|
+
}
|
|
421
|
+
}, _callee);
|
|
422
|
+
}));
|
|
423
|
+
return _resolveAsset.apply(this, arguments);
|
|
424
|
+
}
|
|
425
|
+
var ASSET_BASE = "/_app/a/";
|
|
426
|
+
|
|
427
|
+
/** The module a resolved asset import becomes. */
|
|
428
|
+
var assetModule = function assetModule(url) {
|
|
429
|
+
return "export default ".concat(JSON.stringify(url), "\n");
|
|
430
|
+
};
|
|
431
|
+
|
|
303
432
|
function _regeneratorValues(e) {
|
|
304
433
|
if (null != e) {
|
|
305
434
|
var t = e["function" == typeof Symbol && Symbol.iterator || "@@iterator"],
|
|
@@ -318,4 +447,4 @@ function _regeneratorValues(e) {
|
|
|
318
447
|
throw new TypeError(typeof e + " is not iterable");
|
|
319
448
|
}
|
|
320
449
|
|
|
321
|
-
export { _createForOfIteratorHelper as _, _asyncToGenerator as a, _regenerator as b, _toConsumableArray as c, _slicedToArray as d, _regeneratorValues as e, _objectSpread2 as f,
|
|
450
|
+
export { ASSET_BASE as A, INLINE_LIMIT as I, _createForOfIteratorHelper as _, _asyncToGenerator as a, _regenerator as b, _toConsumableArray as c, _slicedToArray as d, _regeneratorValues as e, _objectSpread2 as f, assetModule as g, _defineProperty as h, isAsset as i, base64Bytes as j, resolveAsset as r, sha256Hex as s };
|