@analogjs/vite-plugin-nitro 3.0.0-beta.57 → 3.0.0-beta.59
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/migrations/update-nitro-options/update-nitro-options.js +1 -2
- package/package.json +1 -1
- package/src/index.js +2 -3
- package/src/lib/build-server.js +1 -2
- package/src/lib/build-sitemap.js +1 -2
- package/src/lib/build-ssr.js +1 -2
- package/src/lib/hooks/post-rendering-hook.js +1 -2
- package/src/lib/plugins/dev-server-plugin.js +1 -2
- package/src/lib/plugins/dev-server-plugin.js.map +1 -1
- package/src/lib/plugins/page-endpoints.js +1 -2
- package/src/lib/plugins/server-fn-id-plugin.js +1 -2
- package/src/lib/utils/derive-server-fn-id.js +1 -2
- package/src/lib/utils/get-content-files.js +1 -2
- package/src/lib/utils/get-page-handlers.js +1 -2
- package/src/lib/utils/get-server-fn-handlers.js +1 -2
- package/src/lib/utils/i18n-prerender.js +1 -2
- package/src/lib/utils/i18n-workers.js +1 -2
- package/src/lib/utils/inject-server-fn-ids.js +1 -2
- package/src/lib/utils/register-dev-middleware.js +1 -2
- package/src/lib/utils/register-i18n-watcher.js +1 -2
- package/src/lib/utils/renderers.js +1 -2
- package/src/lib/utils/server-fn-endpoints.js +1 -2
- package/src/lib/vite-plugin-nitro.js +4 -5
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as ts from "typescript";
|
|
2
|
-
|
|
2
|
+
// packages/vite-plugin-nitro/migrations/update-nitro-options/update-nitro-options.ts
|
|
3
3
|
var NITRO_PLUGIN_PKG = "@analogjs/vite-plugin-nitro";
|
|
4
4
|
var VITE_CONFIG_EXTENSIONS = [
|
|
5
5
|
".ts",
|
|
@@ -116,7 +116,6 @@ function updateNitroOptions() {
|
|
|
116
116
|
return tree;
|
|
117
117
|
};
|
|
118
118
|
}
|
|
119
|
-
//#endregion
|
|
120
119
|
export { updateNitroOptions as default };
|
|
121
120
|
|
|
122
121
|
//# sourceMappingURL=update-nitro-options.js.map
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
+
import { nitro } from "./lib/vite-plugin-nitro.js";
|
|
1
2
|
import { deriveServerFnId, serverFnFileId } from "./lib/utils/derive-server-fn-id.js";
|
|
2
3
|
import { injectServerFnIds } from "./lib/utils/inject-server-fn-ids.js";
|
|
3
|
-
|
|
4
|
-
//#region packages/vite-plugin-nitro/src/index.ts
|
|
4
|
+
// packages/vite-plugin-nitro/src/index.ts
|
|
5
5
|
var src_default = nitro;
|
|
6
|
-
//#endregion
|
|
7
6
|
export { src_default as default, deriveServerFnId, injectServerFnIds, nitro, serverFnFileId };
|
|
8
7
|
|
|
9
8
|
//# sourceMappingURL=index.js.map
|
package/src/lib/build-server.js
CHANGED
|
@@ -5,7 +5,7 @@ import { build, copyPublicAssets, createNitro, prepare, prerender } from "nitrop
|
|
|
5
5
|
import { dirname, join } from "node:path";
|
|
6
6
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
7
7
|
import { existsSync, mkdirSync, unlinkSync, writeFileSync } from "node:fs";
|
|
8
|
-
|
|
8
|
+
// packages/vite-plugin-nitro/src/lib/build-server.ts
|
|
9
9
|
async function buildServer(options, nitroConfig = {}, routeSourceFiles, i18nWorkers = false) {
|
|
10
10
|
if (i18nWorkers && options?.i18n) {
|
|
11
11
|
validateI18nWorkers(options, nitroConfig);
|
|
@@ -96,7 +96,6 @@ async function buildServer(options, nitroConfig = {}, routeSourceFiles, i18nWork
|
|
|
96
96
|
await nitro.close();
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
|
-
//#endregion
|
|
100
99
|
export { buildServer };
|
|
101
100
|
|
|
102
101
|
//# sourceMappingURL=build-server.js.map
|
package/src/lib/build-sitemap.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { resolve } from "node:path";
|
|
2
2
|
import { writeFileSync } from "node:fs";
|
|
3
3
|
import { create } from "xmlbuilder2";
|
|
4
|
-
|
|
4
|
+
// packages/vite-plugin-nitro/src/lib/build-sitemap.ts
|
|
5
5
|
async function buildSitemap(config, sitemapConfig, routes, outputDir, routeSitemaps, i18nOptions, apiPrefix = "/api") {
|
|
6
6
|
const routeList = (await optionHasRoutes(routes)).filter((route) => !route.startsWith(`${apiPrefix}/_analog/pages/`) && !route.includes("?"));
|
|
7
7
|
if (routeList.length) {
|
|
@@ -92,7 +92,6 @@ async function optionHasRoutes(routes) {
|
|
|
92
92
|
else routeList = [];
|
|
93
93
|
return routeList.filter(Boolean);
|
|
94
94
|
}
|
|
95
|
-
//#endregion
|
|
96
95
|
export { buildSitemap, getHreflangAlternates, stripLocalePrefix };
|
|
97
96
|
|
|
98
97
|
//# sourceMappingURL=build-sitemap.js.map
|
package/src/lib/build-ssr.js
CHANGED
|
@@ -2,7 +2,7 @@ import { I18N_WORKER_SSR_ENTRY } from "./utils/i18n-workers.js";
|
|
|
2
2
|
import * as vite from "vite";
|
|
3
3
|
import { build, mergeConfig } from "vite";
|
|
4
4
|
import { relative, resolve } from "node:path";
|
|
5
|
-
|
|
5
|
+
// packages/vite-plugin-nitro/src/lib/build-ssr.ts
|
|
6
6
|
async function buildSSRApp(config, options, i18nWorkers = false) {
|
|
7
7
|
const workspaceRoot = options?.workspaceRoot ?? process.cwd();
|
|
8
8
|
const sourceRoot = options?.sourceRoot ?? "src";
|
|
@@ -14,7 +14,6 @@ async function buildSSRApp(config, options, i18nWorkers = false) {
|
|
|
14
14
|
} });
|
|
15
15
|
await build(ssrBuildConfig);
|
|
16
16
|
}
|
|
17
|
-
//#endregion
|
|
18
17
|
export { buildSSRApp };
|
|
19
18
|
|
|
20
19
|
//# sourceMappingURL=build-ssr.js.map
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
// packages/vite-plugin-nitro/src/lib/hooks/post-rendering-hook.ts
|
|
2
2
|
function addPostRenderingHooks(nitro, hooks) {
|
|
3
3
|
hooks.forEach((hook) => {
|
|
4
4
|
nitro.hooks.hook("prerender:generate", hook);
|
|
5
5
|
});
|
|
6
6
|
}
|
|
7
|
-
//#endregion
|
|
8
7
|
export { addPostRenderingHooks };
|
|
9
8
|
|
|
10
9
|
//# sourceMappingURL=post-rendering-hook.js.map
|
|
@@ -7,7 +7,7 @@ import { resolve } from "node:path";
|
|
|
7
7
|
import { readFileSync } from "node:fs";
|
|
8
8
|
import { createRouter, toRouteMatcher } from "radix3";
|
|
9
9
|
import { defu } from "defu";
|
|
10
|
-
|
|
10
|
+
// packages/vite-plugin-nitro/src/lib/plugins/dev-server-plugin.ts
|
|
11
11
|
function devServerPlugin(getOptions) {
|
|
12
12
|
let options;
|
|
13
13
|
let sourceRoot;
|
|
@@ -115,7 +115,6 @@ function prepareError(req, error) {
|
|
|
115
115
|
stack: typeof e === "string" ? "" : e.stack
|
|
116
116
|
};
|
|
117
117
|
}
|
|
118
|
-
//#endregion
|
|
119
118
|
export { devServerPlugin };
|
|
120
119
|
|
|
121
120
|
//# sourceMappingURL=dev-server-plugin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dev-server-plugin.js","names":[],"sources":["../../../../src/lib/plugins/dev-server-plugin.ts"],"sourcesContent":["// SSR dev server, middleware and error page source modified from\n// https://github.com/solidjs/solid-start/blob/main/packages/start/dev/server.js\n\nimport {\n Connect,\n Plugin,\n UserConfig,\n ViteDevServer,\n normalizePath,\n} from 'vite';\nimport { resolve } from 'node:path';\nimport { readFileSync } from 'node:fs';\nimport { createEvent, sendWebResponse } from 'h3';\nimport { createRouter as createRadixRouter, toRouteMatcher } from 'radix3';\nimport { defu } from 'defu';\nimport { NitroRouteRules } from 'nitropack';\n\nimport { registerDevServerMiddleware } from '../utils/register-dev-middleware.js';\nimport { registerI18nWatcher } from '../utils/register-i18n-watcher.js';\nimport { Options } from '../options.js';\nimport { detectLocaleFromRoute, setHtmlLang } from '../utils/i18n-prerender.js';\n\ntype ServerOptions = Options & { routeRules?: Record<string, any> | undefined };\n\nexport function devServerPlugin(getOptions: () => ServerOptions): Plugin {\n let options: ServerOptions;\n let sourceRoot: string;\n let index: string;\n let config: UserConfig;\n let root: string;\n let isTest = false;\n\n return {\n name: 'analogjs-dev-ssr-plugin',\n config(userConfig, { mode }) {\n options = getOptions();\n if (!options.ssr) {\n return;\n }\n const workspaceRoot = options.workspaceRoot || process.cwd();\n sourceRoot = options.sourceRoot ?? 'src';\n index = options.index || 'index.html';\n config = userConfig;\n root = normalizePath(resolve(workspaceRoot, config.root || '.') || '.');\n isTest = isTest ? isTest : mode === 'test';\n return {\n resolve: {\n alias: {\n '~analog/entry-server':\n options.entryServer || `${root}/${sourceRoot}/main.server.ts`,\n },\n },\n };\n },\n configureServer(viteServer) {\n if (isTest || !options.ssr) {\n return;\n }\n\n return async () => {\n remove_html_middlewares(viteServer.middlewares);\n registerDevServerMiddleware(root, sourceRoot, viteServer);\n\n if (options.i18n) {\n registerI18nWatcher(viteServer);\n }\n\n viteServer.middlewares.use(async (req, res) => {\n let template = readFileSync(\n resolve(viteServer.config.root, index),\n 'utf-8',\n );\n\n template = await viteServer.transformIndexHtml(\n req.originalUrl as string,\n template,\n );\n\n const _routeRulesMatcher = toRouteMatcher(\n createRadixRouter({ routes: options.routeRules }),\n );\n const _getRouteRules = (path: string) =>\n defu(\n {},\n ..._routeRulesMatcher.matchAll(path).reverse(),\n ) as NitroRouteRules;\n\n try {\n let result: string | Response;\n // Check for route rules explicitly disabling SSR\n if (_getRouteRules(req.originalUrl as string).ssr === false) {\n result = template;\n } else {\n const entryServer = (\n await viteServer.ssrLoadModule('~analog/entry-server')\n )['default'];\n result = await entryServer(req.originalUrl, template, {\n req,\n res,\n });\n }\n\n if (result instanceof Response) {\n sendWebResponse(createEvent(req, res), result);\n return;\n }\n\n // Inject lang attribute when i18n is configured\n let html = typeof result === 'string' ? result : template;\n if (options.i18n) {\n const locale = detectLocaleFromRoute(\n req.originalUrl as string,\n options.i18n,\n );\n html = setHtmlLang(html, locale);\n }\n\n res.setHeader('Content-Type', 'text/html');\n res.end(html);\n } catch (e) {\n viteServer.ssrFixStacktrace(e as Error);\n res.statusCode = 500;\n res.end(`\n <!DOCTYPE html>\n <html lang=\"en\">\n <head>\n <meta charset=\"UTF-8\" />\n <title>Error</title>\n <script type=\"module\">\n import { ErrorOverlay } from '/@vite/client'\n document.body.appendChild(new ErrorOverlay(${JSON.stringify(\n prepareError(req, e),\n ).replace(/</g, '\\\\u003c')}))\n </script>\n </head>\n <body>\n </body>\n </html>\n `);\n }\n });\n };\n },\n };\n}\n\n/**\n * Removes Vite internal middleware\n *\n * @param server\n */\nfunction remove_html_middlewares(server: ViteDevServer['middlewares']) {\n const html_middlewares = [\n 'viteIndexHtmlMiddleware',\n 'vite404Middleware',\n 'viteSpaFallbackMiddleware',\n 'viteHtmlFallbackMiddleware',\n ];\n for (let i = server.stack.length - 1; i > 0; i--) {\n const handler = server.stack[i]?.handle;\n const handlerName =\n typeof handler === 'function' ? handler.name : undefined;\n if (handlerName && html_middlewares.includes(handlerName)) {\n server.stack.splice(i, 1);\n }\n }\n}\n\n/**\n * Formats error for SSR message in error overlay\n * @param req\n * @param error\n * @returns\n */\nfunction prepareError(req: Connect.IncomingMessage, error: unknown) {\n const e = error as Error;\n return {\n message: `An error occured while server rendering ${req.url}:\\n\\n\\t${\n typeof e === 'string' ? e : e.message\n } `,\n stack: typeof e === 'string' ? '' : e.stack,\n };\n}\n"],"mappings":";;;;;;;;;;AAwBA,SAAgB,gBAAgB,YAAyC;CACvE,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI,SAAS;CAEb,OAAO;EACL,MAAM;EACN,OAAO,YAAY,EAAE,QAAQ;GAC3B,UAAU,WAAW;GACrB,IAAI,CAAC,QAAQ,KACX;GAEF,MAAM,gBAAgB,QAAQ,iBAAiB,QAAQ,IAAI;GAC3D,aAAa,QAAQ,cAAc;GACnC,QAAQ,QAAQ,SAAS;GACzB,SAAS;GACT,OAAO,cAAc,QAAQ,eAAe,OAAO,QAAQ,GAAG,KAAK,GAAG;GACtE,SAAS,SAAS,SAAS,SAAS;GACpC,OAAO,EACL,SAAS,EACP,OAAO,EACL,wBACE,QAAQ,eAAe,GAAG,KAAK,GAAG,WAAW,iBACjD,EACF,EACF;EACF;EACA,gBAAgB,YAAY;GAC1B,IAAI,UAAU,CAAC,QAAQ,KACrB;GAGF,OAAO,YAAY;IACjB,wBAAwB,WAAW,WAAW;IAC9C,4BAA4B,MAAM,YAAY,UAAU;IAExD,IAAI,QAAQ,MACV,oBAAoB,UAAU;IAGhC,WAAW,YAAY,IAAI,OAAO,KAAK,QAAQ;KAC7C,IAAI,WAAW,aACb,QAAQ,WAAW,OAAO,MAAM,KAAK,GACrC,OACF;KAEA,WAAW,MAAM,WAAW,mBAC1B,IAAI,aACJ,QACF;KAEA,MAAM,qBAAqB,
|
|
1
|
+
{"version":3,"file":"dev-server-plugin.js","names":["createRadixRouter"],"sources":["../../../../src/lib/plugins/dev-server-plugin.ts"],"sourcesContent":["// SSR dev server, middleware and error page source modified from\n// https://github.com/solidjs/solid-start/blob/main/packages/start/dev/server.js\n\nimport {\n Connect,\n Plugin,\n UserConfig,\n ViteDevServer,\n normalizePath,\n} from 'vite';\nimport { resolve } from 'node:path';\nimport { readFileSync } from 'node:fs';\nimport { createEvent, sendWebResponse } from 'h3';\nimport { createRouter as createRadixRouter, toRouteMatcher } from 'radix3';\nimport { defu } from 'defu';\nimport { NitroRouteRules } from 'nitropack';\n\nimport { registerDevServerMiddleware } from '../utils/register-dev-middleware.js';\nimport { registerI18nWatcher } from '../utils/register-i18n-watcher.js';\nimport { Options } from '../options.js';\nimport { detectLocaleFromRoute, setHtmlLang } from '../utils/i18n-prerender.js';\n\ntype ServerOptions = Options & { routeRules?: Record<string, any> | undefined };\n\nexport function devServerPlugin(getOptions: () => ServerOptions): Plugin {\n let options: ServerOptions;\n let sourceRoot: string;\n let index: string;\n let config: UserConfig;\n let root: string;\n let isTest = false;\n\n return {\n name: 'analogjs-dev-ssr-plugin',\n config(userConfig, { mode }) {\n options = getOptions();\n if (!options.ssr) {\n return;\n }\n const workspaceRoot = options.workspaceRoot || process.cwd();\n sourceRoot = options.sourceRoot ?? 'src';\n index = options.index || 'index.html';\n config = userConfig;\n root = normalizePath(resolve(workspaceRoot, config.root || '.') || '.');\n isTest = isTest ? isTest : mode === 'test';\n return {\n resolve: {\n alias: {\n '~analog/entry-server':\n options.entryServer || `${root}/${sourceRoot}/main.server.ts`,\n },\n },\n };\n },\n configureServer(viteServer) {\n if (isTest || !options.ssr) {\n return;\n }\n\n return async () => {\n remove_html_middlewares(viteServer.middlewares);\n registerDevServerMiddleware(root, sourceRoot, viteServer);\n\n if (options.i18n) {\n registerI18nWatcher(viteServer);\n }\n\n viteServer.middlewares.use(async (req, res) => {\n let template = readFileSync(\n resolve(viteServer.config.root, index),\n 'utf-8',\n );\n\n template = await viteServer.transformIndexHtml(\n req.originalUrl as string,\n template,\n );\n\n const _routeRulesMatcher = toRouteMatcher(\n createRadixRouter({ routes: options.routeRules }),\n );\n const _getRouteRules = (path: string) =>\n defu(\n {},\n ..._routeRulesMatcher.matchAll(path).reverse(),\n ) as NitroRouteRules;\n\n try {\n let result: string | Response;\n // Check for route rules explicitly disabling SSR\n if (_getRouteRules(req.originalUrl as string).ssr === false) {\n result = template;\n } else {\n const entryServer = (\n await viteServer.ssrLoadModule('~analog/entry-server')\n )['default'];\n result = await entryServer(req.originalUrl, template, {\n req,\n res,\n });\n }\n\n if (result instanceof Response) {\n sendWebResponse(createEvent(req, res), result);\n return;\n }\n\n // Inject lang attribute when i18n is configured\n let html = typeof result === 'string' ? result : template;\n if (options.i18n) {\n const locale = detectLocaleFromRoute(\n req.originalUrl as string,\n options.i18n,\n );\n html = setHtmlLang(html, locale);\n }\n\n res.setHeader('Content-Type', 'text/html');\n res.end(html);\n } catch (e) {\n viteServer.ssrFixStacktrace(e as Error);\n res.statusCode = 500;\n res.end(`\n <!DOCTYPE html>\n <html lang=\"en\">\n <head>\n <meta charset=\"UTF-8\" />\n <title>Error</title>\n <script type=\"module\">\n import { ErrorOverlay } from '/@vite/client'\n document.body.appendChild(new ErrorOverlay(${JSON.stringify(\n prepareError(req, e),\n ).replace(/</g, '\\\\u003c')}))\n </script>\n </head>\n <body>\n </body>\n </html>\n `);\n }\n });\n };\n },\n };\n}\n\n/**\n * Removes Vite internal middleware\n *\n * @param server\n */\nfunction remove_html_middlewares(server: ViteDevServer['middlewares']) {\n const html_middlewares = [\n 'viteIndexHtmlMiddleware',\n 'vite404Middleware',\n 'viteSpaFallbackMiddleware',\n 'viteHtmlFallbackMiddleware',\n ];\n for (let i = server.stack.length - 1; i > 0; i--) {\n const handler = server.stack[i]?.handle;\n const handlerName =\n typeof handler === 'function' ? handler.name : undefined;\n if (handlerName && html_middlewares.includes(handlerName)) {\n server.stack.splice(i, 1);\n }\n }\n}\n\n/**\n * Formats error for SSR message in error overlay\n * @param req\n * @param error\n * @returns\n */\nfunction prepareError(req: Connect.IncomingMessage, error: unknown) {\n const e = error as Error;\n return {\n message: `An error occured while server rendering ${req.url}:\\n\\n\\t${\n typeof e === 'string' ? e : e.message\n } `,\n stack: typeof e === 'string' ? '' : e.stack,\n };\n}\n"],"mappings":";;;;;;;;;;AAwBA,SAAgB,gBAAgB,YAAyC;CACvE,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI,SAAS;CAEb,OAAO;EACL,MAAM;EACN,OAAO,YAAY,EAAE,QAAQ;GAC3B,UAAU,WAAW;GACrB,IAAI,CAAC,QAAQ,KACX;GAEF,MAAM,gBAAgB,QAAQ,iBAAiB,QAAQ,IAAI;GAC3D,aAAa,QAAQ,cAAc;GACnC,QAAQ,QAAQ,SAAS;GACzB,SAAS;GACT,OAAO,cAAc,QAAQ,eAAe,OAAO,QAAQ,GAAG,KAAK,GAAG;GACtE,SAAS,SAAS,SAAS,SAAS;GACpC,OAAO,EACL,SAAS,EACP,OAAO,EACL,wBACE,QAAQ,eAAe,GAAG,KAAK,GAAG,WAAW,iBACjD,EACF,EACF;EACF;EACA,gBAAgB,YAAY;GAC1B,IAAI,UAAU,CAAC,QAAQ,KACrB;GAGF,OAAO,YAAY;IACjB,wBAAwB,WAAW,WAAW;IAC9C,4BAA4B,MAAM,YAAY,UAAU;IAExD,IAAI,QAAQ,MACV,oBAAoB,UAAU;IAGhC,WAAW,YAAY,IAAI,OAAO,KAAK,QAAQ;KAC7C,IAAI,WAAW,aACb,QAAQ,WAAW,OAAO,MAAM,KAAK,GACrC,OACF;KAEA,WAAW,MAAM,WAAW,mBAC1B,IAAI,aACJ,QACF;KAEA,MAAM,qBAAqB,eACzBA,aAAkB,EAAE,QAAQ,QAAQ,WAAW,CAAC,CAClD;KACA,MAAM,kBAAkB,SACtB,KACE,CAAC,GACD,GAAG,mBAAmB,SAAS,IAAI,CAAC,CAAC,QAAQ,CAC/C;KAEF,IAAI;MACF,IAAI;MAEJ,IAAI,eAAe,IAAI,WAAqB,CAAC,CAAC,QAAQ,OACpD,SAAS;WACJ;OACL,MAAM,eACJ,MAAM,WAAW,cAAc,sBAAsB,EAAA,CACrD;OACF,SAAS,MAAM,YAAY,IAAI,aAAa,UAAU;QACpD;QACA;OACF,CAAC;MACH;MAEA,IAAI,kBAAkB,UAAU;OAC9B,gBAAgB,YAAY,KAAK,GAAG,GAAG,MAAM;OAC7C;MACF;MAGA,IAAI,OAAO,OAAO,WAAW,WAAW,SAAS;MACjD,IAAI,QAAQ,MAAM;OAChB,MAAM,SAAS,sBACb,IAAI,aACJ,QAAQ,IACV;OACA,OAAO,YAAY,MAAM,MAAM;MACjC;MAEA,IAAI,UAAU,gBAAgB,WAAW;MACzC,IAAI,IAAI,IAAI;KACd,SAAS,GAAG;MACV,WAAW,iBAAiB,CAAU;MACtC,IAAI,aAAa;MACjB,IAAI,IAAI;;;;;;;;iEAQ6C,KAAK,UAChD,aAAa,KAAK,CAAC,CACrB,CAAC,CAAC,QAAQ,MAAM,SAAS,EAAE;;;;;;aAMlC;KACH;IACF,CAAC;GACH;EACF;CACF;AACF;;;;;;AAOA,SAAS,wBAAwB,QAAsC;CACrE,MAAM,mBAAmB;EACvB;EACA;EACA;EACA;CACF;CACA,KAAK,IAAI,IAAI,OAAO,MAAM,SAAS,GAAG,IAAI,GAAG,KAAK;EAChD,MAAM,UAAU,OAAO,MAAM,EAAE,EAAE;EACjC,MAAM,cACJ,OAAO,YAAY,aAAa,QAAQ,OAAO,KAAA;EACjD,IAAI,eAAe,iBAAiB,SAAS,WAAW,GACtD,OAAO,MAAM,OAAO,GAAG,CAAC;CAE5B;AACF;;;;;;;AAQA,SAAS,aAAa,KAA8B,OAAgB;CAClE,MAAM,IAAI;CACV,OAAO;EACL,SAAS,2CAA2C,IAAI,IAAI,SAC1D,OAAO,MAAM,WAAW,IAAI,EAAE,QAC/B;EACD,OAAO,OAAO,MAAM,WAAW,KAAK,EAAE;CACxC;AACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { normalizePath } from "vite";
|
|
2
2
|
import { parseSync } from "oxc-parser";
|
|
3
|
-
|
|
3
|
+
// packages/vite-plugin-nitro/src/lib/plugins/page-endpoints.ts
|
|
4
4
|
function pageEndpointsPlugin() {
|
|
5
5
|
return {
|
|
6
6
|
name: "analogjs-vite-plugin-nitro-rollup-page-endpoint",
|
|
@@ -62,7 +62,6 @@ function pageEndpointsPlugin() {
|
|
|
62
62
|
}
|
|
63
63
|
};
|
|
64
64
|
}
|
|
65
|
-
//#endregion
|
|
66
65
|
export { pageEndpointsPlugin };
|
|
67
66
|
|
|
68
67
|
//# sourceMappingURL=page-endpoints.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { serverFnFileId } from "../utils/derive-server-fn-id.js";
|
|
2
2
|
import { injectServerFnIds } from "../utils/inject-server-fn-ids.js";
|
|
3
|
-
|
|
3
|
+
// packages/vite-plugin-nitro/src/lib/plugins/server-fn-id-plugin.ts
|
|
4
4
|
/**
|
|
5
5
|
* Nitro-build transform that stamps the derived id into each `serverFn` config
|
|
6
6
|
* in a `*.server.ts`, so a function registers under the same opaque route the
|
|
@@ -21,7 +21,6 @@ function serverFnIdPlugin(projectRoot) {
|
|
|
21
21
|
}
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
|
-
//#endregion
|
|
25
24
|
export { serverFnIdPlugin };
|
|
26
25
|
|
|
27
26
|
//# sourceMappingURL=server-fn-id-plugin.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { relative } from "node:path";
|
|
2
2
|
import { createHash } from "node:crypto";
|
|
3
|
-
|
|
3
|
+
// packages/vite-plugin-nitro/src/lib/utils/derive-server-fn-id.ts
|
|
4
4
|
var toPosix = (p) => p.replace(/\\/g, "/");
|
|
5
5
|
/**
|
|
6
6
|
* Server-function ids are derived, never author-chosen, for security:
|
|
@@ -31,7 +31,6 @@ function serverFnFileId(absPath, projectRoot) {
|
|
|
31
31
|
function deriveServerFnId(fileId, exportName) {
|
|
32
32
|
return createHash("sha256").update(`${fileId}#${exportName}`).digest("hex").slice(0, 16);
|
|
33
33
|
}
|
|
34
|
-
//#endregion
|
|
35
34
|
export { deriveServerFnId, serverFnFileId };
|
|
36
35
|
|
|
37
36
|
//# sourceMappingURL=derive-server-fn-id.js.map
|
|
@@ -3,7 +3,7 @@ import { join, relative, resolve } from "node:path";
|
|
|
3
3
|
import { readFileSync } from "node:fs";
|
|
4
4
|
import { globSync } from "tinyglobby";
|
|
5
5
|
import { createRequire } from "node:module";
|
|
6
|
-
|
|
6
|
+
// packages/vite-plugin-nitro/src/lib/utils/get-content-files.ts
|
|
7
7
|
var require = createRequire(import.meta.url);
|
|
8
8
|
/**
|
|
9
9
|
* Discovers content files with front matter and extracts metadata for prerendering.
|
|
@@ -93,7 +93,6 @@ function getMatchingContentFilesWithFrontMatter(workspaceRoot, rootDir, glob, re
|
|
|
93
93
|
};
|
|
94
94
|
});
|
|
95
95
|
}
|
|
96
|
-
//#endregion
|
|
97
96
|
export { getMatchingContentFilesWithFrontMatter };
|
|
98
97
|
|
|
99
98
|
//# sourceMappingURL=get-content-files.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { normalizePath } from "vite";
|
|
2
2
|
import { resolve } from "node:path";
|
|
3
3
|
import { globSync } from "tinyglobby";
|
|
4
|
-
|
|
4
|
+
// packages/vite-plugin-nitro/src/lib/utils/get-page-handlers.ts
|
|
5
5
|
/**
|
|
6
6
|
* Discovers and generates Nitro event handlers for server-side page routes.
|
|
7
7
|
*
|
|
@@ -66,7 +66,6 @@ function getPageHandlers({ workspaceRoot, sourceRoot, rootDir, additionalPagesDi
|
|
|
66
66
|
};
|
|
67
67
|
});
|
|
68
68
|
}
|
|
69
|
-
//#endregion
|
|
70
69
|
export { getPageHandlers };
|
|
71
70
|
|
|
72
71
|
//# sourceMappingURL=get-page-handlers.js.map
|
|
@@ -3,7 +3,7 @@ import { resolve } from "node:path";
|
|
|
3
3
|
import { readFileSync } from "node:fs";
|
|
4
4
|
import { parseSync } from "oxc-parser";
|
|
5
5
|
import { globSync } from "tinyglobby";
|
|
6
|
-
|
|
6
|
+
// packages/vite-plugin-nitro/src/lib/utils/get-server-fn-handlers.ts
|
|
7
7
|
/**
|
|
8
8
|
* `*.server.ts` files that are matched by the glob but are never server-function
|
|
9
9
|
* hosts, so importing them for registration side-effects would be wrong.
|
|
@@ -60,7 +60,6 @@ function definesServerFn(file) {
|
|
|
60
60
|
if (localNames.size === 0) localNames.add("serverFn");
|
|
61
61
|
return program.body.some((node) => node.type === "ExportNamedDeclaration" && node.declaration?.type === "VariableDeclaration" && node.declaration.declarations.some((declarator) => declarator.id?.type === "Identifier" && declarator.init?.type === "CallExpression" && declarator.init.callee?.type === "Identifier" && localNames.has(declarator.init.callee.name)));
|
|
62
62
|
}
|
|
63
|
-
//#endregion
|
|
64
63
|
export { getServerFnHandlers };
|
|
65
64
|
|
|
66
65
|
//# sourceMappingURL=get-server-fn-handlers.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// packages/vite-plugin-nitro/src/lib/utils/i18n-prerender.ts
|
|
2
2
|
/**
|
|
3
3
|
* Expands a list of routes to include locale-prefixed variants.
|
|
4
4
|
*
|
|
@@ -66,7 +66,6 @@ function setHtmlLang(html, locale) {
|
|
|
66
66
|
if (/<html[^>]*\slang\s*=\s*["'][^"']*["']/i.test(html)) return html.replace(/(<html[^>]*\s)lang\s*=\s*["'][^"']*["']/i, `$1lang="${locale}"`);
|
|
67
67
|
return html.replace(/<html/i, `<html lang="${locale}"`);
|
|
68
68
|
}
|
|
69
|
-
//#endregion
|
|
70
69
|
export { createI18nPostRenderingHook, detectLocaleFromRoute, expandRoutesWithLocales, setHtmlLang };
|
|
71
70
|
|
|
72
71
|
//# sourceMappingURL=i18n-prerender.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { dirname, join } from "node:path";
|
|
2
2
|
import { fileURLToPath } from "node:url";
|
|
3
|
-
|
|
3
|
+
// packages/vite-plugin-nitro/src/lib/utils/i18n-workers.ts
|
|
4
4
|
var I18N_WORKER_SSR_ENTRY = "virtual:analog-i18n/main.server";
|
|
5
5
|
function validateI18nWorkers(options, nitro) {
|
|
6
6
|
if (!options.i18n?.loader) throw new Error("i18n.workers requires an i18n.loader module.");
|
|
@@ -49,7 +49,6 @@ export default async function (...args) {
|
|
|
49
49
|
}
|
|
50
50
|
`;
|
|
51
51
|
}
|
|
52
|
-
//#endregion
|
|
53
52
|
export { I18N_WORKER_SSR_ENTRY, i18nWorkerSsrEntry, resolveI18nWorkers, validateI18nWorkers };
|
|
54
53
|
|
|
55
54
|
//# sourceMappingURL=i18n-workers.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { deriveServerFnId } from "./derive-server-fn-id.js";
|
|
2
2
|
import { parseSync } from "oxc-parser";
|
|
3
3
|
import MagicString from "magic-string";
|
|
4
|
-
|
|
4
|
+
// packages/vite-plugin-nitro/src/lib/utils/inject-server-fn-ids.ts
|
|
5
5
|
var SERVER_FN_SOURCE = "@analogjs/router/server";
|
|
6
6
|
/**
|
|
7
7
|
* Server/SSR-build transform: injects the derived `id` into each
|
|
@@ -88,7 +88,6 @@ function collectServerFnLocalNames(body) {
|
|
|
88
88
|
if (names.size === 0) names.add("serverFn");
|
|
89
89
|
return names;
|
|
90
90
|
}
|
|
91
|
-
//#endregion
|
|
92
91
|
export { injectServerFnIds };
|
|
93
92
|
|
|
94
93
|
//# sourceMappingURL=inject-server-fn-ids.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createEvent } from "h3";
|
|
2
2
|
import { globSync } from "tinyglobby";
|
|
3
|
-
|
|
3
|
+
// packages/vite-plugin-nitro/src/lib/utils/register-dev-middleware.ts
|
|
4
4
|
/**
|
|
5
5
|
* Registers development server middleware by discovering and loading middleware files.
|
|
6
6
|
*
|
|
@@ -51,7 +51,6 @@ async function registerDevServerMiddleware(root, sourceRoot, viteServer) {
|
|
|
51
51
|
});
|
|
52
52
|
});
|
|
53
53
|
}
|
|
54
|
-
//#endregion
|
|
55
54
|
export { registerDevServerMiddleware };
|
|
56
55
|
|
|
57
56
|
//# sourceMappingURL=register-dev-middleware.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// packages/vite-plugin-nitro/src/lib/utils/register-i18n-watcher.ts
|
|
2
2
|
/**
|
|
3
3
|
* Registers a file watcher that triggers a full page reload
|
|
4
4
|
* when translation files are added or modified.
|
|
@@ -21,7 +21,6 @@ function registerI18nWatcher(viteServer) {
|
|
|
21
21
|
function isTranslationFile(path) {
|
|
22
22
|
return /i18n.*\.(json|xlf|xmb|arb)$/.test(path);
|
|
23
23
|
}
|
|
24
|
-
//#endregion
|
|
25
24
|
export { isTranslationFile, registerI18nWatcher };
|
|
26
25
|
|
|
27
26
|
//# sourceMappingURL=register-i18n-watcher.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// packages/vite-plugin-nitro/src/lib/utils/renderers.ts
|
|
2
2
|
var ssrRenderer = `
|
|
3
3
|
import { eventHandler, getResponseHeader } from 'h3';
|
|
4
4
|
// @ts-ignore
|
|
@@ -97,7 +97,6 @@ export default eventHandler(async () => {
|
|
|
97
97
|
return template;
|
|
98
98
|
});
|
|
99
99
|
`;
|
|
100
|
-
//#endregion
|
|
101
100
|
export { clientRenderer, createSsrStreamRenderer, ssrRenderer, ssrStreamRenderer };
|
|
102
101
|
|
|
103
102
|
//# sourceMappingURL=renderers.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { normalizePath } from "vite";
|
|
2
2
|
import { join } from "node:path";
|
|
3
3
|
import { createRequire } from "node:module";
|
|
4
|
-
|
|
4
|
+
// packages/vite-plugin-nitro/src/lib/utils/server-fn-endpoints.ts
|
|
5
5
|
/**
|
|
6
6
|
* Nitro virtual-module id for the generated server-function dispatch handler.
|
|
7
7
|
* Referenced from `nitroConfig.handlers` and provided via `nitroConfig.virtual`.
|
|
@@ -64,7 +64,6 @@ function hasZoneJs(root) {
|
|
|
64
64
|
return false;
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
|
-
//#endregion
|
|
68
67
|
export { SERVER_FN_DISPATCH_PREFIX, SERVER_FN_DISPATCH_ROUTE, SERVER_FN_DISPATCH_VIRTUAL, buildServerFnDispatchModule, getServerFnDispatchHandler };
|
|
69
68
|
|
|
70
69
|
//# sourceMappingURL=server-fn-endpoints.js.map
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { I18N_WORKER_SSR_ENTRY, i18nWorkerSsrEntry, resolveI18nWorkers } from "./utils/i18n-workers.js";
|
|
2
|
-
import { clientRenderer, ssrRenderer, ssrStreamRenderer } from "./utils/renderers.js";
|
|
3
1
|
import { buildServer } from "./build-server.js";
|
|
4
2
|
import { buildSSRApp } from "./build-ssr.js";
|
|
3
|
+
import { I18N_WORKER_SSR_ENTRY, i18nWorkerSsrEntry, resolveI18nWorkers } from "./utils/i18n-workers.js";
|
|
5
4
|
import { pageEndpointsPlugin } from "./plugins/page-endpoints.js";
|
|
6
5
|
import { serverFnIdPlugin } from "./plugins/server-fn-id-plugin.js";
|
|
7
6
|
import { getPageHandlers } from "./utils/get-page-handlers.js";
|
|
8
7
|
import { getServerFnHandlers } from "./utils/get-server-fn-handlers.js";
|
|
9
8
|
import { SERVER_FN_DISPATCH_VIRTUAL, buildServerFnDispatchModule, getServerFnDispatchHandler } from "./utils/server-fn-endpoints.js";
|
|
10
9
|
import { buildSitemap } from "./build-sitemap.js";
|
|
11
|
-
import { createI18nPostRenderingHook, expandRoutesWithLocales } from "./utils/i18n-prerender.js";
|
|
12
10
|
import { devServerPlugin } from "./plugins/dev-server-plugin.js";
|
|
13
11
|
import { getMatchingContentFilesWithFrontMatter } from "./utils/get-content-files.js";
|
|
12
|
+
import { clientRenderer, ssrRenderer, ssrStreamRenderer } from "./utils/renderers.js";
|
|
13
|
+
import { createI18nPostRenderingHook, expandRoutesWithLocales } from "./utils/i18n-prerender.js";
|
|
14
14
|
import { build, createDevServer, createNitro, loadOptions } from "nitropack";
|
|
15
15
|
import { toNodeListener } from "h3";
|
|
16
16
|
import { mergeConfig, normalizePath } from "vite";
|
|
@@ -18,7 +18,7 @@ import { dirname, relative, resolve } from "node:path";
|
|
|
18
18
|
import { platform } from "node:os";
|
|
19
19
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
20
20
|
import { existsSync, readFileSync } from "node:fs";
|
|
21
|
-
|
|
21
|
+
// packages/vite-plugin-nitro/src/lib/vite-plugin-nitro.ts
|
|
22
22
|
var isWindows = platform() === "win32";
|
|
23
23
|
var filePrefix = isWindows ? "file:///" : "";
|
|
24
24
|
var clientOutputPath = "";
|
|
@@ -421,7 +421,6 @@ function withAnalogRouteRuleHeaders(nitroOptions) {
|
|
|
421
421
|
routeRules
|
|
422
422
|
};
|
|
423
423
|
}
|
|
424
|
-
//#endregion
|
|
425
424
|
export { nitro };
|
|
426
425
|
|
|
427
426
|
//# sourceMappingURL=vite-plugin-nitro.js.map
|