nitro 3.0.0 → 3.0.1-alpha.1
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/dist/_build/common.mjs +68 -0
- package/dist/_build/common2.mjs +772 -0
- package/dist/_build/rolldown.mjs +206 -0
- package/dist/_build/rollup.mjs +289 -0
- package/dist/_build/vite.build.mjs +56 -0
- package/dist/_build/vite.plugin.mjs +768 -0
- package/dist/_chunks/ANM1K1bE.mjs +304 -0
- package/dist/_chunks/B-D1JOIz.mjs +1355 -0
- package/dist/_chunks/BX9-zVkM.mjs +59 -0
- package/dist/_chunks/Bqks5huO.mjs +31 -0
- package/dist/_chunks/C7CbzoI1.mjs +39 -0
- package/dist/_dev.d.mts +12 -0
- package/dist/_dev.mjs +705 -0
- package/dist/_libs/acorn.mjs +5034 -0
- package/dist/_libs/c12.mjs +2858 -0
- package/dist/_libs/chokidar.mjs +1561 -0
- package/dist/_libs/citty.mjs +333 -0
- package/dist/_libs/commondir.mjs +22 -0
- package/dist/_libs/compatx.mjs +46 -0
- package/dist/_libs/confbox.mjs +2920 -0
- package/dist/_libs/deepmerge.mjs +86 -0
- package/dist/_libs/dot-prop.mjs +138 -0
- package/dist/_libs/duplexer.mjs +71 -0
- package/dist/_libs/escape-string-regexp.mjs +8 -0
- package/dist/_libs/estree-walker.mjs +330 -0
- package/dist/_libs/etag.mjs +80 -0
- package/dist/_libs/fdir.mjs +514 -0
- package/dist/_libs/function-bind.mjs +63 -0
- package/dist/_libs/gen-mapping.mjs +612 -0
- package/dist/_libs/giget.mjs +19289 -0
- package/dist/_libs/gzip-size.mjs +21 -0
- package/dist/_libs/hasown.mjs +14 -0
- package/dist/_libs/httpxy.mjs +410 -0
- package/dist/_libs/is-core-module.mjs +220 -0
- package/dist/_libs/is-module.mjs +13 -0
- package/dist/_libs/is-reference.mjs +32 -0
- package/dist/_libs/js-tokens.mjs +382 -0
- package/dist/_libs/klona.mjs +38 -0
- package/dist/_libs/knitwork.mjs +124 -0
- package/dist/_libs/local-pkg.mjs +1686 -0
- package/dist/_libs/magic-string.mjs +939 -0
- package/dist/_libs/mime.mjs +1391 -0
- package/dist/_libs/node-fetch-native.mjs +173 -0
- package/dist/_libs/path-parse.mjs +47 -0
- package/dist/_libs/pathe.mjs +41 -0
- package/dist/_libs/picomatch.mjs +1673 -0
- package/dist/_libs/plugin-alias.mjs +64 -0
- package/dist/_libs/plugin-commonjs.mjs +1491 -0
- package/dist/_libs/plugin-inject.mjs +135 -0
- package/dist/_libs/plugin-json.mjs +36 -0
- package/dist/_libs/plugin-node-resolve.mjs +1553 -0
- package/dist/_libs/plugin-replace.mjs +104 -0
- package/dist/_libs/pretty-bytes.mjs +116 -0
- package/dist/_libs/remapping.mjs +117 -0
- package/dist/_libs/rou3.mjs +319 -0
- package/dist/_libs/std-env.mjs +158 -0
- package/dist/_libs/strip-literal.mjs +51 -0
- package/dist/_libs/tinyglobby.mjs +292 -0
- package/dist/_libs/tsconfck.mjs +832 -0
- package/dist/_libs/ultrahtml.mjs +138 -0
- package/dist/_libs/unimport.mjs +3520 -0
- package/dist/_libs/untyped.mjs +271 -0
- package/dist/_libs/unwasm.mjs +5836 -0
- package/dist/_libs/vite-plugin-fullstack.mjs +561 -0
- package/dist/_presets.mjs +1752 -0
- package/dist/builder.d.mts +63 -0
- package/dist/builder.mjs +33 -0
- package/dist/cli/_chunks/build.mjs +48 -0
- package/dist/cli/_chunks/common.mjs +15 -0
- package/dist/cli/_chunks/detect-acorn.mjs +12 -0
- package/dist/cli/_chunks/dev.mjs +68 -0
- package/dist/cli/_chunks/dist.mjs +3 -0
- package/dist/cli/_chunks/dist2.mjs +3 -0
- package/dist/cli/_chunks/dist3.mjs +3 -0
- package/dist/cli/_chunks/dist4.mjs +4 -0
- package/dist/cli/_chunks/dist5.mjs +4 -0
- package/dist/cli/_chunks/esm.mjs +3 -0
- package/dist/cli/_chunks/json5.mjs +4 -0
- package/dist/cli/_chunks/jsonc.mjs +4 -0
- package/dist/cli/_chunks/list.mjs +27 -0
- package/dist/cli/_chunks/multipart-parser.mjs +6 -0
- package/dist/cli/_chunks/prepare.mjs +19 -0
- package/dist/cli/_chunks/run.mjs +55 -0
- package/dist/cli/_chunks/task.mjs +16 -0
- package/dist/cli/_chunks/toml.mjs +4 -0
- package/dist/cli/_chunks/yaml.mjs +4 -0
- package/dist/cli/index.d.mts +1 -1
- package/dist/cli/index.mjs +20 -476
- package/dist/node_modules/@poppinss/dumper/build/formatters/html/main.js +1 -1
- package/dist/node_modules/@poppinss/dumper/package.json +1 -1
- package/dist/node_modules/@sindresorhus/is/distribution/index.js +1 -1
- package/dist/node_modules/@sindresorhus/is/package.json +1 -1
- package/dist/node_modules/@speed-highlight/core/dist/index.js +2 -2
- package/dist/node_modules/@speed-highlight/core/dist/terminal.js +2 -2
- package/dist/node_modules/@speed-highlight/core/package.json +7 -3
- package/dist/node_modules/cookie-es/dist/index.mjs +262 -0
- package/dist/node_modules/cookie-es/package.json +37 -0
- package/dist/node_modules/hookable/dist/index.mjs +243 -266
- package/dist/node_modules/hookable/package.json +29 -26
- package/dist/node_modules/rendu/dist/index.mjs +380 -0
- package/dist/node_modules/rendu/package.json +47 -0
- package/dist/node_modules/youch/build/{chunk-VE4LENUR.js → chunk-F4I6KX4R.js} +2 -1
- package/dist/node_modules/youch/build/{chunk-JAN2TFI2.js → chunk-YYEJ3AGB.js} +4 -1
- package/dist/node_modules/youch/build/index.js +16 -8
- package/dist/node_modules/youch/build/public/error_stack/script.js +20 -22
- package/dist/node_modules/youch/build/public/header/script.js +0 -2
- package/dist/node_modules/youch/build/public/layout/script.js +0 -8
- package/dist/node_modules/youch/build/public/layout/style.css +4 -0
- package/dist/node_modules/youch/package.json +16 -17
- package/dist/presets/_nitro/runtime/nitro-dev.d.mts +1 -0
- package/dist/presets/_nitro/runtime/nitro-dev.mjs +48 -42
- package/dist/presets/_nitro/runtime/nitro-prerenderer.d.mts +2 -2
- package/dist/presets/_nitro/runtime/nitro-prerenderer.mjs +10 -14
- package/dist/presets/_nitro/runtime/service-worker.d.mts +1 -0
- package/dist/presets/_nitro/runtime/service-worker.mjs +15 -12
- package/dist/presets/aws-amplify/runtime/aws-amplify.d.mts +1 -0
- package/dist/presets/aws-amplify/runtime/aws-amplify.mjs +7 -6
- package/dist/presets/aws-lambda/runtime/_utils.d.mts +8 -13
- package/dist/presets/aws-lambda/runtime/_utils.mjs +95 -81
- package/dist/presets/aws-lambda/runtime/aws-lambda-streaming.d.mts +1 -2
- package/dist/presets/aws-lambda/runtime/aws-lambda-streaming.mjs +26 -28
- package/dist/presets/aws-lambda/runtime/aws-lambda.mjs +8 -8
- package/dist/presets/azure/runtime/_utils.mjs +43 -43
- package/dist/presets/azure/runtime/azure-swa.d.mts +2 -2
- package/dist/presets/azure/runtime/azure-swa.mjs +24 -22
- package/dist/presets/bun/runtime/bun.d.mts +2 -0
- package/dist/presets/bun/runtime/bun.mjs +34 -21
- package/dist/presets/cloudflare/runtime/_module-handler.d.mts +10 -7
- package/dist/presets/cloudflare/runtime/_module-handler.mjs +80 -88
- package/dist/presets/cloudflare/runtime/cloudflare-durable.d.mts +6 -14
- package/dist/presets/cloudflare/runtime/cloudflare-durable.mjs +60 -63
- package/dist/presets/cloudflare/runtime/cloudflare-module.d.mts +1 -7
- package/dist/presets/cloudflare/runtime/cloudflare-module.mjs +14 -16
- package/dist/presets/cloudflare/runtime/cloudflare-pages.d.mts +12 -12
- package/dist/presets/cloudflare/runtime/cloudflare-pages.mjs +40 -42
- package/dist/presets/cloudflare/runtime/plugin.dev.d.mts +2 -2
- package/dist/presets/cloudflare/runtime/plugin.dev.mjs +89 -82
- package/dist/presets/cloudflare/runtime/shims/workers.dev.mjs +27 -0
- package/dist/presets/deno/runtime/deno-deploy.d.mts +4 -0
- package/dist/presets/deno/runtime/deno-deploy.mjs +15 -12
- package/dist/presets/deno/runtime/deno-server.d.mts +0 -3
- package/dist/presets/deno/runtime/deno-server.mjs +32 -52
- package/dist/presets/netlify/runtime/netlify-edge.d.mts +2 -1
- package/dist/presets/netlify/runtime/netlify-edge.mjs +15 -12
- package/dist/presets/netlify/runtime/netlify.mjs +12 -18
- package/dist/presets/node/runtime/node-cluster.d.mts +3 -1
- package/dist/presets/node/runtime/node-cluster.mjs +50 -54
- package/dist/presets/node/runtime/node-middleware.d.mts +2 -3
- package/dist/presets/node/runtime/node-middleware.mjs +9 -8
- package/dist/presets/node/runtime/node-server.mjs +37 -34
- package/dist/presets/standard/runtime/server.d.mts +1 -3
- package/dist/presets/standard/runtime/server.mjs +2 -4
- package/dist/presets/stormkit/runtime/stormkit.d.mts +13 -13
- package/dist/presets/stormkit/runtime/stormkit.mjs +21 -21
- package/dist/presets/vercel/runtime/vercel.node.d.mts +3 -0
- package/dist/presets/vercel/runtime/vercel.node.mjs +15 -0
- package/dist/presets/vercel/runtime/{vercel.d.mts → vercel.web.d.mts} +3 -3
- package/dist/presets/vercel/runtime/vercel.web.mjs +20 -0
- package/dist/presets/winterjs/runtime/winterjs.d.mts +2 -0
- package/dist/presets/winterjs/runtime/winterjs.mjs +73 -69
- package/dist/presets/zeabur/runtime/zeabur.d.mts +1 -1
- package/dist/presets/zeabur/runtime/zeabur.mjs +1 -1
- package/dist/runtime/app.d.mts +1 -0
- package/dist/runtime/app.mjs +1 -0
- package/dist/runtime/cache.d.mts +1 -0
- package/dist/runtime/cache.mjs +1 -0
- package/dist/runtime/config.d.mts +3 -0
- package/dist/runtime/config.mjs +4 -0
- package/dist/runtime/context.d.mts +1 -0
- package/dist/runtime/context.mjs +1 -0
- package/dist/runtime/database.d.mts +1 -0
- package/dist/runtime/database.mjs +1 -0
- package/dist/runtime/internal/app.d.mts +11 -1
- package/dist/runtime/internal/app.mjs +188 -140
- package/dist/runtime/internal/cache.d.mts +9 -5
- package/dist/runtime/internal/cache.mjs +248 -219
- package/dist/runtime/internal/context.d.mts +9 -9
- package/dist/runtime/internal/context.mjs +17 -10
- package/dist/runtime/internal/database.mjs +8 -10
- package/dist/runtime/internal/error/dev.d.mts +5 -4
- package/dist/runtime/internal/error/dev.mjs +106 -105
- package/dist/runtime/internal/error/hooks.d.mts +1 -0
- package/dist/runtime/internal/error/hooks.mjs +9 -0
- package/dist/runtime/internal/error/prod.d.mts +5 -4
- package/dist/runtime/internal/error/prod.mjs +51 -59
- package/dist/runtime/internal/error/utils.d.mts +4 -4
- package/dist/runtime/internal/error/utils.mjs +1 -1
- package/dist/runtime/internal/meta.d.mts +1 -1
- package/dist/runtime/internal/meta.mjs +1 -1
- package/dist/runtime/internal/plugin.d.mts +2 -2
- package/dist/runtime/internal/plugin.mjs +1 -1
- package/dist/runtime/internal/route-rules.d.mts +8 -8
- package/dist/runtime/internal/route-rules.mjs +54 -52
- package/dist/runtime/internal/routes/dev-tasks.d.mts +1 -2
- package/dist/runtime/internal/routes/dev-tasks.mjs +16 -18
- package/dist/runtime/internal/routes/openapi.d.mts +1 -0
- package/dist/runtime/internal/routes/openapi.mjs +81 -87
- package/dist/runtime/internal/routes/renderer-template.d.mts +1 -1
- package/dist/runtime/internal/routes/renderer-template.dev.d.mts +1 -2
- package/dist/runtime/internal/routes/renderer-template.dev.mjs +15 -17
- package/dist/runtime/internal/routes/renderer-template.mjs +1 -1
- package/dist/runtime/internal/routes/scalar.d.mts +1 -0
- package/dist/runtime/internal/routes/scalar.mjs +22 -23
- package/dist/runtime/internal/routes/swagger.d.mts +1 -0
- package/dist/runtime/internal/routes/swagger.mjs +9 -11
- package/dist/runtime/internal/runtime-config.d.mts +4 -4
- package/dist/runtime/internal/runtime-config.mjs +40 -35
- package/dist/runtime/internal/static.mjs +63 -74
- package/dist/runtime/internal/storage.mjs +2 -2
- package/dist/runtime/internal/task.d.mts +6 -6
- package/dist/runtime/internal/task.mjs +56 -60
- package/dist/runtime/internal/vite/dev-entry.mjs +11 -1
- package/dist/runtime/internal/vite/dev-worker.mjs +9 -57
- package/dist/runtime/internal/vite/ssr-renderer.mjs +3 -1
- package/{lib/runtime-meta.d.mts → dist/runtime/meta.d.mts} +1 -1
- package/dist/runtime/meta.mjs +26 -0
- package/dist/runtime/nitro.d.mts +12 -0
- package/dist/runtime/nitro.mjs +32 -0
- package/dist/runtime/runtime-config.d.mts +1 -0
- package/dist/runtime/runtime-config.mjs +1 -0
- package/dist/runtime/storage.d.mts +1 -0
- package/dist/runtime/storage.mjs +1 -0
- package/dist/runtime/task.d.mts +1 -0
- package/dist/runtime/task.mjs +1 -0
- package/dist/runtime/vite-runtime.d.mts +8 -0
- package/dist/runtime/vite-runtime.mjs +9 -0
- package/dist/types/index.d.mts +2625 -2297
- package/dist/types/index.mjs +1 -1
- package/dist/vite.d.mts +49 -51
- package/dist/vite.mjs +44 -68
- package/lib/tsconfig.json +27 -0
- package/package.json +86 -76
- package/dist/_chunks/app.mjs +0 -19797
- package/dist/_chunks/build.mjs +0 -84
- package/dist/_chunks/build2.mjs +0 -318
- package/dist/_chunks/build3.mjs +0 -6452
- package/dist/_chunks/detect-acorn.mjs +0 -503
- package/dist/_chunks/index.mjs +0 -22242
- package/dist/_chunks/index2.mjs +0 -297
- package/dist/_chunks/index3.mjs +0 -1058
- package/dist/_chunks/index4.mjs +0 -1206
- package/dist/_chunks/info.mjs +0 -11157
- package/dist/_chunks/json5.mjs +0 -68
- package/dist/_chunks/jsonc.mjs +0 -51
- package/dist/_chunks/pathe.M-eThtNZ.mjs +0 -204
- package/dist/_chunks/plugin.mjs +0 -960
- package/dist/_chunks/server.mjs +0 -254
- package/dist/_chunks/snapshot.mjs +0 -284
- package/dist/_chunks/toml.mjs +0 -259
- package/dist/_chunks/yaml.mjs +0 -86
- package/dist/cli/build.mjs +0 -54
- package/dist/cli/common.mjs +0 -13
- package/dist/cli/dev.mjs +0 -95
- package/dist/cli/index2.mjs +0 -17
- package/dist/cli/list.mjs +0 -34
- package/dist/cli/prepare.mjs +0 -24
- package/dist/cli/run.mjs +0 -60
- package/dist/index.d.mts +0 -52
- package/dist/index.mjs +0 -55
- package/dist/node_modules/cookie/dist/index.js +0 -239
- package/dist/node_modules/cookie/package.json +0 -42
- package/dist/node_modules/klona/dist/index.mjs +0 -81
- package/dist/node_modules/klona/full/index.mjs +0 -53
- package/dist/node_modules/klona/package.json +0 -74
- package/dist/node_modules/std-env/dist/index.mjs +0 -1
- package/dist/node_modules/std-env/package.json +0 -46
- package/dist/presets/vercel/runtime/vercel.mjs +0 -17
- package/dist/presets.mjs +0 -2460
- package/dist/runtime/index.d.mts +0 -11
- package/dist/runtime/index.mjs +0 -17
- package/dist/runtime/internal/debug.d.mts +0 -2
- package/dist/runtime/internal/debug.mjs +0 -5
- package/dist/runtime/internal/empty.d.mts +0 -0
- package/dist/runtime/internal/index.d.mts +0 -3
- package/dist/runtime/internal/index.mjs +0 -3
- package/dist/runtime/internal/lib/http-graceful-shutdown.d.mts +0 -16
- package/dist/runtime/internal/lib/http-graceful-shutdown.mjs +0 -213
- package/dist/runtime/internal/renderer.d.mts +0 -3
- package/dist/runtime/internal/renderer.mjs +0 -36
- package/dist/runtime/internal/shutdown.d.mts +0 -9
- package/dist/runtime/internal/shutdown.mjs +0 -34
- package/dist/runtime/internal/utils.d.mts +0 -1
- package/dist/runtime/internal/utils.mjs +0 -15
- package/dist/runtime/internal/vite/dev-entry.d.mts +0 -1
- package/dist/runtime/internal/vite/dev-worker.d.mts +0 -1
- package/dist/runtime/internal/vite/prod-setup.d.mts +0 -4
- package/dist/runtime/internal/vite/prod-setup.mjs +0 -55
- package/dist/runtime/internal/vite/ssr-renderer.d.mts +0 -4
- package/lib/config.d.mts +0 -9
- package/lib/config.mjs +0 -5
- package/lib/meta.d.mts +0 -5
- package/lib/meta.mjs +0 -21
- package/lib/runtime-meta.mjs +0 -38
|
@@ -0,0 +1,561 @@
|
|
|
1
|
+
import { t as MagicString } from "./magic-string.mjs";
|
|
2
|
+
import { t as stripLiteral } from "./strip-literal.mjs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import fs from "node:fs";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
6
|
+
import assert from "node:assert";
|
|
7
|
+
import "srvx/node";
|
|
8
|
+
import { createHash } from "node:crypto";
|
|
9
|
+
import { isCSSRequest, normalizePath } from "vite";
|
|
10
|
+
import assert$1 from "node:assert/strict";
|
|
11
|
+
|
|
12
|
+
//#region node_modules/.pnpm/@pi0+vite-plugin-fullstack@0.0.5-pr-1297_vite@7.2.2_@types+node@24.10.0_jiti@2.6.1_ligh_420de11c17db6dc1bb00fb6cc17e9a42/node_modules/@pi0/vite-plugin-fullstack/dist/index.js
|
|
13
|
+
function parseIdQuery(id) {
|
|
14
|
+
if (!id.includes("?")) return {
|
|
15
|
+
filename: id,
|
|
16
|
+
query: {}
|
|
17
|
+
};
|
|
18
|
+
const [filename, rawQuery] = id.split(`?`, 2);
|
|
19
|
+
return {
|
|
20
|
+
filename,
|
|
21
|
+
query: Object.fromEntries(new URLSearchParams(rawQuery))
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
function toAssetsVirtual(options) {
|
|
25
|
+
return `virtual:fullstack/assets?${new URLSearchParams(options)}&lang.js`;
|
|
26
|
+
}
|
|
27
|
+
function parseAssetsVirtual(id) {
|
|
28
|
+
if (id.startsWith("\0virtual:fullstack/assets?")) return parseIdQuery(id).query;
|
|
29
|
+
}
|
|
30
|
+
function createVirtualPlugin(name, load) {
|
|
31
|
+
name = "virtual:" + name;
|
|
32
|
+
return {
|
|
33
|
+
name: `rsc:virtual-${name}`,
|
|
34
|
+
resolveId: { handler(source, _importer, _options) {
|
|
35
|
+
return source === name ? "\0" + name : void 0;
|
|
36
|
+
} },
|
|
37
|
+
load: { handler(id, options) {
|
|
38
|
+
if (id === "\0" + name) return load.apply(this, [id, options]);
|
|
39
|
+
} }
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
function normalizeRelativePath(s) {
|
|
43
|
+
s = normalizePath(s);
|
|
44
|
+
return s[0] === "." ? s : "./" + s;
|
|
45
|
+
}
|
|
46
|
+
function hashString(v) {
|
|
47
|
+
return createHash("sha256").update(v).digest().toString("hex").slice(0, 12);
|
|
48
|
+
}
|
|
49
|
+
const VALID_ID_PREFIX = `/@id/`;
|
|
50
|
+
const NULL_BYTE_PLACEHOLDER = `__x00__`;
|
|
51
|
+
const FS_PREFIX = `/@fs/`;
|
|
52
|
+
function wrapId(id) {
|
|
53
|
+
return id.startsWith(VALID_ID_PREFIX) ? id : VALID_ID_PREFIX + id.replace("\0", NULL_BYTE_PLACEHOLDER);
|
|
54
|
+
}
|
|
55
|
+
function withTrailingSlash(path$1) {
|
|
56
|
+
if (path$1[path$1.length - 1] !== "/") return `${path$1}/`;
|
|
57
|
+
return path$1;
|
|
58
|
+
}
|
|
59
|
+
const postfixRE = /[?#].*$/;
|
|
60
|
+
function cleanUrl(url) {
|
|
61
|
+
return url.replace(postfixRE, "");
|
|
62
|
+
}
|
|
63
|
+
function splitFileAndPostfix(path$1) {
|
|
64
|
+
const file = cleanUrl(path$1);
|
|
65
|
+
return {
|
|
66
|
+
file,
|
|
67
|
+
postfix: path$1.slice(file.length)
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
const windowsSlashRE = /\\/g;
|
|
71
|
+
function slash(p) {
|
|
72
|
+
return p.replace(windowsSlashRE, "/");
|
|
73
|
+
}
|
|
74
|
+
const isWindows = typeof process !== "undefined" && process.platform === "win32";
|
|
75
|
+
function injectQuery(url, queryToInject) {
|
|
76
|
+
const { file, postfix } = splitFileAndPostfix(url);
|
|
77
|
+
return `${isWindows ? slash(file) : file}?${queryToInject}${postfix[0] === "?" ? `&${postfix.slice(1)}` : postfix}`;
|
|
78
|
+
}
|
|
79
|
+
function normalizeResolvedIdToUrl(environment, url, resolved) {
|
|
80
|
+
const root = environment.config.root;
|
|
81
|
+
const depsOptimizer = environment.depsOptimizer;
|
|
82
|
+
if (resolved.id.startsWith(withTrailingSlash(root))) url = resolved.id.slice(root.length);
|
|
83
|
+
else if (depsOptimizer?.isOptimizedDepFile(resolved.id) || resolved.id !== "/@react-refresh" && path.isAbsolute(resolved.id) && fs.existsSync(cleanUrl(resolved.id))) url = path.posix.join(FS_PREFIX, resolved.id);
|
|
84
|
+
else url = resolved.id;
|
|
85
|
+
if (url[0] !== "." && url[0] !== "/") url = wrapId(resolved.id);
|
|
86
|
+
return url;
|
|
87
|
+
}
|
|
88
|
+
function normalizeViteImportAnalysisUrl(environment, id) {
|
|
89
|
+
let url = normalizeResolvedIdToUrl(environment, id, { id });
|
|
90
|
+
if (environment.config.consumer === "client") {
|
|
91
|
+
const mod = environment.moduleGraph.getModuleById(id);
|
|
92
|
+
if (mod && mod.lastHMRTimestamp > 0) url = injectQuery(url, `t=${mod.lastHMRTimestamp}`);
|
|
93
|
+
}
|
|
94
|
+
return url;
|
|
95
|
+
}
|
|
96
|
+
function evalValue(rawValue) {
|
|
97
|
+
return new Function(`
|
|
98
|
+
var console, exports, global, module, process, require
|
|
99
|
+
return (\n${rawValue}\n)
|
|
100
|
+
`)();
|
|
101
|
+
}
|
|
102
|
+
const directRequestRE = /(\?|&)direct=?(?:&|$)/;
|
|
103
|
+
function assetsPlugin(pluginOpts) {
|
|
104
|
+
let server;
|
|
105
|
+
let resolvedConfig;
|
|
106
|
+
const importAssetsMetaMap = {};
|
|
107
|
+
const bundleMap = {};
|
|
108
|
+
async function processAssetsImport(ctx, id, options) {
|
|
109
|
+
if (ctx.environment.mode === "dev") {
|
|
110
|
+
const result = {
|
|
111
|
+
entry: void 0,
|
|
112
|
+
js: [],
|
|
113
|
+
css: []
|
|
114
|
+
};
|
|
115
|
+
const environment = server.environments[options.environment];
|
|
116
|
+
assert$1(environment, `Unknown environment: ${options.environment}`);
|
|
117
|
+
if (options.environment === "client") result.entry = normalizeViteImportAnalysisUrl(environment, id);
|
|
118
|
+
if (environment.name !== "client") {
|
|
119
|
+
const collected = await collectCss(environment, id, { eager: pluginOpts?.experimental?.devEagerTransform ?? true });
|
|
120
|
+
result.css = collected.hrefs.map((href, i) => ({
|
|
121
|
+
href,
|
|
122
|
+
"data-vite-dev-id": collected.ids[i]
|
|
123
|
+
}));
|
|
124
|
+
}
|
|
125
|
+
return JSON.stringify(result);
|
|
126
|
+
} else {
|
|
127
|
+
const map = importAssetsMetaMap[options.environment] ??= {};
|
|
128
|
+
const meta = {
|
|
129
|
+
id,
|
|
130
|
+
key: path.relative(resolvedConfig.root, id),
|
|
131
|
+
importerEnvironment: ctx.environment.name,
|
|
132
|
+
isEntry: !!(map[id]?.isEntry || options.isEntry)
|
|
133
|
+
};
|
|
134
|
+
map[id] = meta;
|
|
135
|
+
return `__assets_manifest[${JSON.stringify(options.environment)}][${JSON.stringify(meta.key)}]`;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
let writeAssetsManifestCalled = false;
|
|
139
|
+
async function writeAssetsManifest(builder) {
|
|
140
|
+
if (writeAssetsManifestCalled) return;
|
|
141
|
+
writeAssetsManifestCalled = true;
|
|
142
|
+
const manifest = {};
|
|
143
|
+
for (const [environmentName, metas] of Object.entries(importAssetsMetaMap)) {
|
|
144
|
+
const bundle = bundleMap[environmentName];
|
|
145
|
+
const assetDepsMap = collectAssetDeps(bundle);
|
|
146
|
+
for (const [id, meta] of Object.entries(metas)) {
|
|
147
|
+
const found = assetDepsMap[id];
|
|
148
|
+
if (!found) {
|
|
149
|
+
builder.config.logger.error(`[vite-plugin-fullstack] failed to find built chunk for ${meta.id} imported by ${meta.importerEnvironment} environment`);
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
const result = {
|
|
153
|
+
js: [],
|
|
154
|
+
css: []
|
|
155
|
+
};
|
|
156
|
+
const { chunk, deps } = found;
|
|
157
|
+
if (environmentName === "client") {
|
|
158
|
+
result.entry = `/${chunk.fileName}`;
|
|
159
|
+
result.js = deps.js.map((fileName) => ({ href: `/${fileName}` }));
|
|
160
|
+
}
|
|
161
|
+
result.css = deps.css.map((fileName) => ({ href: `/${fileName}` }));
|
|
162
|
+
if (!builder.environments[environmentName].config.build.cssCodeSplit) {
|
|
163
|
+
const singleCss = Object.values(bundle).find((v) => v.type === "asset" && v.originalFileNames.includes("style.css"));
|
|
164
|
+
if (singleCss) result.css.push({ href: `/${singleCss.fileName}` });
|
|
165
|
+
}
|
|
166
|
+
(manifest[environmentName] ??= {})[meta.key] = result;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
const importerEnvironments = new Set(Object.values(importAssetsMetaMap).flatMap((metas) => Object.values(metas)).flatMap((meta) => meta.importerEnvironment));
|
|
170
|
+
for (const environmentName of importerEnvironments) {
|
|
171
|
+
const outDir = builder.environments[environmentName].config.build.outDir;
|
|
172
|
+
fs.writeFileSync(path.join(outDir, BUILD_ASSETS_MANIFEST_NAME), `export default ${JSON.stringify(manifest, null, 2)};`);
|
|
173
|
+
const clientOutDir = builder.environments["client"].config.build.outDir;
|
|
174
|
+
for (const asset of Object.values(bundleMap[environmentName])) if (asset.type === "asset") {
|
|
175
|
+
const srcFile = path.join(outDir, asset.fileName);
|
|
176
|
+
const destFile = path.join(clientOutDir, asset.fileName);
|
|
177
|
+
fs.mkdirSync(path.dirname(destFile), { recursive: true });
|
|
178
|
+
fs.copyFileSync(srcFile, destFile);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
return [
|
|
183
|
+
{
|
|
184
|
+
name: "fullstack:assets",
|
|
185
|
+
sharedDuringBuild: true,
|
|
186
|
+
configureServer(server_) {
|
|
187
|
+
server = server_;
|
|
188
|
+
},
|
|
189
|
+
configResolved(config) {
|
|
190
|
+
resolvedConfig = config;
|
|
191
|
+
},
|
|
192
|
+
configEnvironment(name) {
|
|
193
|
+
if ((pluginOpts?.serverEnvironments ?? ["ssr"]).includes(name)) return { build: { emitAssets: true } };
|
|
194
|
+
},
|
|
195
|
+
transform: { async handler(code, id, _options) {
|
|
196
|
+
if (!code.includes("import.meta.vite.assets")) return;
|
|
197
|
+
const output = new MagicString(code);
|
|
198
|
+
const strippedCode = stripLiteral(code);
|
|
199
|
+
const newImports = /* @__PURE__ */ new Set();
|
|
200
|
+
for (const match of code.matchAll(/import\.meta\.vite\.assets\(([\s\S]*?)\)/dg)) {
|
|
201
|
+
const [start, end] = match.indices[0];
|
|
202
|
+
if (!strippedCode.slice(start, end).includes("import.meta.vite.assets")) continue;
|
|
203
|
+
if (this.environment.name === "client") {
|
|
204
|
+
const replacement$1 = `(${JSON.stringify(EMPTY_ASSETS)})`;
|
|
205
|
+
output.update(start, end, replacement$1);
|
|
206
|
+
continue;
|
|
207
|
+
}
|
|
208
|
+
const argCode = match[1].trim();
|
|
209
|
+
const options = {
|
|
210
|
+
import: id,
|
|
211
|
+
environment: void 0,
|
|
212
|
+
asEntry: false
|
|
213
|
+
};
|
|
214
|
+
if (argCode) {
|
|
215
|
+
const argValue = evalValue(argCode);
|
|
216
|
+
Object.assign(options, argValue);
|
|
217
|
+
}
|
|
218
|
+
const environments = options.environment ? [options.environment] : ["client", this.environment.name];
|
|
219
|
+
const importedNames = [];
|
|
220
|
+
for (const environment of environments) {
|
|
221
|
+
const importSource = toAssetsVirtual({
|
|
222
|
+
import: options.import,
|
|
223
|
+
importer: id,
|
|
224
|
+
environment,
|
|
225
|
+
entry: options.asEntry ? "1" : ""
|
|
226
|
+
});
|
|
227
|
+
const importedName = `__assets_${hashString(importSource)}`;
|
|
228
|
+
newImports.add(`;import ${importedName} from ${JSON.stringify(importSource)};\n`);
|
|
229
|
+
importedNames.push(importedName);
|
|
230
|
+
}
|
|
231
|
+
let replacement = importedNames[0];
|
|
232
|
+
if (importedNames.length > 1) {
|
|
233
|
+
newImports.add(`;import * as __assets_runtime from "virtual:fullstack/runtime";\n`);
|
|
234
|
+
replacement = `__assets_runtime.mergeAssets(${importedNames.join(", ")})`;
|
|
235
|
+
}
|
|
236
|
+
output.update(start, end, `(${replacement})`);
|
|
237
|
+
}
|
|
238
|
+
if (output.hasChanged()) {
|
|
239
|
+
for (const newImport of newImports) output.append(newImport);
|
|
240
|
+
return {
|
|
241
|
+
code: output.toString(),
|
|
242
|
+
map: output.generateMap({ hires: "boundary" })
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
} },
|
|
246
|
+
resolveId: { handler(source) {
|
|
247
|
+
if (source.startsWith("virtual:fullstack/assets?")) return "\0" + source;
|
|
248
|
+
if (source === "virtual:fullstack/assets-manifest") {
|
|
249
|
+
assert$1.notEqual(this.environment.name, "client");
|
|
250
|
+
assert$1.equal(this.environment.mode, "build");
|
|
251
|
+
return {
|
|
252
|
+
id: source,
|
|
253
|
+
external: true
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
if (source === "virtual:fullstack/runtime") return { id: source };
|
|
257
|
+
} },
|
|
258
|
+
load: { async handler(id) {
|
|
259
|
+
if (id === "virtual:fullstack/runtime") return runtimeUtils();
|
|
260
|
+
const parsed = parseAssetsVirtual(id);
|
|
261
|
+
if (!parsed) return;
|
|
262
|
+
assert$1.notEqual(this.environment.name, "client");
|
|
263
|
+
const resolved = await this.resolve(parsed.import, parsed.importer);
|
|
264
|
+
assert$1(resolved, `Failed to resolve: ${parsed.import}`);
|
|
265
|
+
const s = new MagicString("");
|
|
266
|
+
const code = await processAssetsImport(this, resolved.id, {
|
|
267
|
+
environment: parsed.environment,
|
|
268
|
+
isEntry: !!parsed.entry
|
|
269
|
+
});
|
|
270
|
+
s.append(`export default ${code};\n`);
|
|
271
|
+
if (this.environment.mode === "build") s.prepend(`import __assets_manifest from "virtual:fullstack/assets-manifest";\n`);
|
|
272
|
+
return s.toString();
|
|
273
|
+
} },
|
|
274
|
+
renderChunk(code, chunk) {
|
|
275
|
+
if (code.includes("virtual:fullstack/assets-manifest")) {
|
|
276
|
+
const replacement = normalizeRelativePath(path.relative(path.join(chunk.fileName, ".."), BUILD_ASSETS_MANIFEST_NAME));
|
|
277
|
+
code = code.replaceAll("virtual:fullstack/assets-manifest", () => replacement);
|
|
278
|
+
return { code };
|
|
279
|
+
}
|
|
280
|
+
},
|
|
281
|
+
writeBundle(_options, bundle) {
|
|
282
|
+
bundleMap[this.environment.name] = bundle;
|
|
283
|
+
},
|
|
284
|
+
buildStart() {
|
|
285
|
+
if (this.environment.mode == "build" && this.environment.name === "client") {
|
|
286
|
+
if (importAssetsMetaMap["client"]) {
|
|
287
|
+
for (const meta of Object.values(importAssetsMetaMap["client"])) if (meta.isEntry) this.emitFile({
|
|
288
|
+
type: "chunk",
|
|
289
|
+
id: meta.id,
|
|
290
|
+
preserveSignature: "exports-only"
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
},
|
|
295
|
+
buildApp: {
|
|
296
|
+
order: "pre",
|
|
297
|
+
async handler(builder) {
|
|
298
|
+
builder.writeAssetsManifest = async () => {
|
|
299
|
+
await writeAssetsManifest(builder);
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
},
|
|
304
|
+
{
|
|
305
|
+
name: "fullstack:write-assets-manifest-post",
|
|
306
|
+
buildApp: {
|
|
307
|
+
order: "post",
|
|
308
|
+
async handler(builder) {
|
|
309
|
+
await builder.writeAssetsManifest();
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
},
|
|
313
|
+
{
|
|
314
|
+
name: "fullstack:assets-query",
|
|
315
|
+
sharedDuringBuild: true,
|
|
316
|
+
resolveId: {
|
|
317
|
+
order: "pre",
|
|
318
|
+
handler(source) {
|
|
319
|
+
const { query } = parseIdQuery(source);
|
|
320
|
+
if (typeof query["assets"] !== "undefined") {
|
|
321
|
+
if (this.environment.name === "client") return `\0virtual:fullstack/empty-assets`;
|
|
322
|
+
}
|
|
323
|
+
if (source === "virtual:fullstack/runtime") return source;
|
|
324
|
+
}
|
|
325
|
+
},
|
|
326
|
+
load: { async handler(id) {
|
|
327
|
+
if (id === "\0virtual:fullstack/empty-assets") return `export default ${JSON.stringify(EMPTY_ASSETS)}`;
|
|
328
|
+
if (id === "virtual:fullstack/runtime") return runtimeUtils();
|
|
329
|
+
const { filename, query } = parseIdQuery(id);
|
|
330
|
+
const value = query["assets"];
|
|
331
|
+
if (typeof value !== "undefined") {
|
|
332
|
+
const s = new MagicString("");
|
|
333
|
+
const codes = [];
|
|
334
|
+
if (value) {
|
|
335
|
+
const code = await processAssetsImport(this, filename, {
|
|
336
|
+
environment: value,
|
|
337
|
+
isEntry: value === "client"
|
|
338
|
+
});
|
|
339
|
+
codes.push(code);
|
|
340
|
+
} else {
|
|
341
|
+
const code1 = await processAssetsImport(this, filename, {
|
|
342
|
+
environment: "client",
|
|
343
|
+
isEntry: false
|
|
344
|
+
});
|
|
345
|
+
const code2 = await processAssetsImport(this, filename, {
|
|
346
|
+
environment: this.environment.name,
|
|
347
|
+
isEntry: false
|
|
348
|
+
});
|
|
349
|
+
codes.push(code1, code2);
|
|
350
|
+
}
|
|
351
|
+
s.append(`
|
|
352
|
+
import * as __assets_runtime from "virtual:fullstack/runtime";\n
|
|
353
|
+
export default __assets_runtime.mergeAssets(${codes.join(", ")});
|
|
354
|
+
`);
|
|
355
|
+
if (this.environment.mode === "build") s.prepend(`import __assets_manifest from "virtual:fullstack/assets-manifest";\n`);
|
|
356
|
+
return {
|
|
357
|
+
code: s.toString(),
|
|
358
|
+
moduleSideEffects: false
|
|
359
|
+
};
|
|
360
|
+
}
|
|
361
|
+
} },
|
|
362
|
+
hotUpdate(ctx) {
|
|
363
|
+
if (this.environment.name === "rsc") {
|
|
364
|
+
const mods = collectModuleDependents(ctx.modules);
|
|
365
|
+
for (const mod of mods) if (mod.id) {
|
|
366
|
+
const ids = [
|
|
367
|
+
`${mod.id}?assets`,
|
|
368
|
+
`${mod.id}?assets=client`,
|
|
369
|
+
`${mod.id}?assets=${this.environment.name}`
|
|
370
|
+
];
|
|
371
|
+
for (const id of ids) invalidteModuleById(this.environment, id);
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
},
|
|
376
|
+
{
|
|
377
|
+
...createVirtualPlugin("fullstack/client-fallback", () => "export {}"),
|
|
378
|
+
configEnvironment: {
|
|
379
|
+
order: "post",
|
|
380
|
+
handler(name, config, _env) {
|
|
381
|
+
if (name === "client") {
|
|
382
|
+
if ((pluginOpts?.experimental?.clientBuildFallback ?? true) && !config.build?.rollupOptions?.input) return { build: { rollupOptions: { input: { __fallback: "virtual:fullstack/client-fallback" } } } };
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
},
|
|
386
|
+
generateBundle(_optoins, bundle) {
|
|
387
|
+
if (this.environment.name !== "client") return;
|
|
388
|
+
for (const [k, v] of Object.entries(bundle)) if (v.type === "chunk" && v.name === "__fallback") delete bundle[k];
|
|
389
|
+
}
|
|
390
|
+
},
|
|
391
|
+
patchViteClientPlugin(),
|
|
392
|
+
patchVueScopeCssHmr(),
|
|
393
|
+
patchCssLinkSelfAccept()
|
|
394
|
+
];
|
|
395
|
+
}
|
|
396
|
+
const EMPTY_ASSETS = {
|
|
397
|
+
js: [],
|
|
398
|
+
css: []
|
|
399
|
+
};
|
|
400
|
+
const BUILD_ASSETS_MANIFEST_NAME = "__fullstack_assets_manifest.js";
|
|
401
|
+
async function collectCss(environment, entryId, options) {
|
|
402
|
+
const visited = /* @__PURE__ */ new Set();
|
|
403
|
+
const cssIds = /* @__PURE__ */ new Set();
|
|
404
|
+
async function recurse(id) {
|
|
405
|
+
if (visited.has(id) || parseAssetsVirtual(id) || "assets" in parseIdQuery(id).query) return;
|
|
406
|
+
visited.add(id);
|
|
407
|
+
const mod = environment.moduleGraph.getModuleById(id);
|
|
408
|
+
if (!mod) return;
|
|
409
|
+
if (options.eager && !mod?.transformResult) try {
|
|
410
|
+
await environment.transformRequest(id);
|
|
411
|
+
} catch (e) {
|
|
412
|
+
console.error(`[collectCss] Failed to transform '${id}'`, e);
|
|
413
|
+
}
|
|
414
|
+
for (const next of mod?.importedModules ?? []) if (next.id) if (isCSSRequest(next.id)) {
|
|
415
|
+
if (hasSpecialCssQuery(next.id)) continue;
|
|
416
|
+
cssIds.add(next.id);
|
|
417
|
+
} else await recurse(next.id);
|
|
418
|
+
}
|
|
419
|
+
await recurse(entryId);
|
|
420
|
+
const hrefs = [...cssIds].map((id) => normalizeViteImportAnalysisUrl(environment, id));
|
|
421
|
+
return {
|
|
422
|
+
ids: [...cssIds],
|
|
423
|
+
hrefs
|
|
424
|
+
};
|
|
425
|
+
}
|
|
426
|
+
function invalidteModuleById(environment, id) {
|
|
427
|
+
const mod = environment.moduleGraph.getModuleById(id);
|
|
428
|
+
if (mod) environment.moduleGraph.invalidateModule(mod);
|
|
429
|
+
return mod;
|
|
430
|
+
}
|
|
431
|
+
function collectModuleDependents(mods) {
|
|
432
|
+
const visited = /* @__PURE__ */ new Set();
|
|
433
|
+
function recurse(mod) {
|
|
434
|
+
if (visited.has(mod)) return;
|
|
435
|
+
visited.add(mod);
|
|
436
|
+
for (const importer of mod.importers) recurse(importer);
|
|
437
|
+
}
|
|
438
|
+
for (const mod of mods) recurse(mod);
|
|
439
|
+
return [...visited];
|
|
440
|
+
}
|
|
441
|
+
function hasSpecialCssQuery(id) {
|
|
442
|
+
return /[?&](url|inline|raw)(\b|=|&|$)/.test(id);
|
|
443
|
+
}
|
|
444
|
+
function collectAssetDeps(bundle) {
|
|
445
|
+
const chunkToDeps = /* @__PURE__ */ new Map();
|
|
446
|
+
for (const chunk of Object.values(bundle)) if (chunk.type === "chunk") chunkToDeps.set(chunk, collectAssetDepsInner(chunk.fileName, bundle));
|
|
447
|
+
const idToDeps = {};
|
|
448
|
+
for (const [chunk, deps] of chunkToDeps.entries()) for (const id of chunk.moduleIds) idToDeps[id] = {
|
|
449
|
+
chunk,
|
|
450
|
+
deps
|
|
451
|
+
};
|
|
452
|
+
return idToDeps;
|
|
453
|
+
}
|
|
454
|
+
function collectAssetDepsInner(fileName, bundle) {
|
|
455
|
+
const visited = /* @__PURE__ */ new Set();
|
|
456
|
+
const css = [];
|
|
457
|
+
function recurse(k) {
|
|
458
|
+
if (visited.has(k)) return;
|
|
459
|
+
visited.add(k);
|
|
460
|
+
const v = bundle[k];
|
|
461
|
+
assert$1(v, `Not found '${k}' in the bundle`);
|
|
462
|
+
if (v.type === "chunk") {
|
|
463
|
+
css.push(...v.viteMetadata?.importedCss ?? []);
|
|
464
|
+
for (const k2 of v.imports) if (k2 in bundle) recurse(k2);
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
recurse(fileName);
|
|
468
|
+
return {
|
|
469
|
+
js: [...visited],
|
|
470
|
+
css: [...new Set(css)]
|
|
471
|
+
};
|
|
472
|
+
}
|
|
473
|
+
function patchViteClientPlugin() {
|
|
474
|
+
const viteClientPath = normalizePath(fileURLToPath(import.meta.resolve("vite/dist/client/client.mjs")));
|
|
475
|
+
function endIndexOf(code, searchValue) {
|
|
476
|
+
const i = code.lastIndexOf(searchValue);
|
|
477
|
+
return i === -1 ? i : i + searchValue.length;
|
|
478
|
+
}
|
|
479
|
+
return {
|
|
480
|
+
name: "fullstack:patch-vite-client",
|
|
481
|
+
transform: { handler(code, id) {
|
|
482
|
+
if (id === viteClientPath) {
|
|
483
|
+
if (code.includes("linkSheetsMap")) return;
|
|
484
|
+
const s = new MagicString(code);
|
|
485
|
+
s.prependLeft(code.indexOf("const sheetsMap"), `\
|
|
486
|
+
const linkSheetsMap = new Map();
|
|
487
|
+
document
|
|
488
|
+
.querySelectorAll('link[rel="stylesheet"][data-vite-dev-id]')
|
|
489
|
+
.forEach((el) => {
|
|
490
|
+
linkSheetsMap.set(el.getAttribute('data-vite-dev-id'), el)
|
|
491
|
+
});
|
|
492
|
+
`);
|
|
493
|
+
s.appendLeft(endIndexOf(code, `function updateStyle(id, content) {`), `if (linkSheetsMap.has(id)) { return }`);
|
|
494
|
+
s.appendLeft(endIndexOf(code, `function removeStyle(id) {`), `
|
|
495
|
+
const link = linkSheetsMap.get(id);
|
|
496
|
+
if (link) {
|
|
497
|
+
document
|
|
498
|
+
.querySelectorAll(
|
|
499
|
+
'link[rel="stylesheet"][data-vite-dev-id]',
|
|
500
|
+
)
|
|
501
|
+
.forEach((el) => {
|
|
502
|
+
if (el.getAttribute('data-vite-dev-id') === id) {
|
|
503
|
+
el.remove()
|
|
504
|
+
}
|
|
505
|
+
})
|
|
506
|
+
linkSheetsMap.delete(id)
|
|
507
|
+
}
|
|
508
|
+
`);
|
|
509
|
+
return s.toString();
|
|
510
|
+
}
|
|
511
|
+
} }
|
|
512
|
+
};
|
|
513
|
+
}
|
|
514
|
+
function patchVueScopeCssHmr() {
|
|
515
|
+
return {
|
|
516
|
+
name: "fullstack:patch-vue-scoped-css-hmr",
|
|
517
|
+
configureServer(server) {
|
|
518
|
+
server.middlewares.use((req, _res, next) => {
|
|
519
|
+
if (req.headers.accept?.includes("text/css") && req.url?.includes("&lang.css=")) req.url = req.url.replace("&lang.css=", "?lang.css");
|
|
520
|
+
next();
|
|
521
|
+
});
|
|
522
|
+
}
|
|
523
|
+
};
|
|
524
|
+
}
|
|
525
|
+
function patchCssLinkSelfAccept() {
|
|
526
|
+
return {
|
|
527
|
+
name: "fullstack:patch-css-link-self-accept",
|
|
528
|
+
apply: "serve",
|
|
529
|
+
transform: {
|
|
530
|
+
order: "post",
|
|
531
|
+
handler(_code, id, _options) {
|
|
532
|
+
if (this.environment.name === "client" && this.environment.mode === "dev" && isCSSRequest(id) && directRequestRE.test(id)) {
|
|
533
|
+
const mod = this.environment.moduleGraph.getModuleById(id);
|
|
534
|
+
if (mod && !mod.isSelfAccepting) mod.isSelfAccepting = true;
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
};
|
|
539
|
+
}
|
|
540
|
+
function runtimeUtils() {
|
|
541
|
+
return `
|
|
542
|
+
export function mergeAssets(...args) {
|
|
543
|
+
const js = uniqBy(args.flatMap((h) => h.js), (a) => a.href);
|
|
544
|
+
const css = uniqBy(args.flatMap((h) => h.css), (a) => a.href);
|
|
545
|
+
const entry = args.filter((arg) => arg.entry)?.[0]?.entry;
|
|
546
|
+
const raw = { entry, js, css };
|
|
547
|
+
return { ...raw, merge: (...args$1) => mergeAssets(raw, ...args$1) };
|
|
548
|
+
}
|
|
549
|
+
function uniqBy(array, key) {
|
|
550
|
+
const seen = new Set();
|
|
551
|
+
return array.filter((item) => {
|
|
552
|
+
const k = key(item);
|
|
553
|
+
if (seen.has(k)) return false;
|
|
554
|
+
seen.add(k);
|
|
555
|
+
return true;
|
|
556
|
+
});
|
|
557
|
+
}`;
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
//#endregion
|
|
561
|
+
export { assetsPlugin as t };
|