@blinkk/root 3.3.1 → 3.4.2

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.
@@ -2,11 +2,11 @@ import {
2
2
  BuildAssetMap,
3
3
  ElementGraph,
4
4
  buildPage
5
- } from "./chunk-M3E4RKS7.js";
5
+ } from "./chunk-DLPHCMFV.js";
6
6
  import {
7
7
  loadBundledConfig,
8
8
  loadJson
9
- } from "./chunk-KHO3HMX6.js";
9
+ } from "./chunk-Y4H75NIO.js";
10
10
  import "./chunk-3PWR4F2R.js";
11
11
 
12
12
  // src/cli/build-worker.ts
@@ -14,13 +14,40 @@ var Html = ({ children, ...attrs }) => {
14
14
  return /* @__PURE__ */ jsx(Fragment, { children });
15
15
  };
16
16
 
17
- // src/core/hooks/useI18nContext.ts
18
- import path from "node:path";
17
+ // src/core/hooks/useAssetMap.ts
19
18
  import { createContext as createContext2 } from "preact";
20
19
  import { useContext as useContext2 } from "preact/hooks";
21
- var I18N_CONTEXT = createContext2(null);
20
+ var ASSET_MAP_CONTEXT = createContext2(null);
21
+ function useAssetMap() {
22
+ const assetMap = useContext2(ASSET_MAP_CONTEXT);
23
+ if (!assetMap) {
24
+ throw new Error("ASSET_MAP_CONTEXT not found");
25
+ }
26
+ return assetMap;
27
+ }
28
+ function useAsset(src) {
29
+ const normalizedSrc = src.replace(/^\/+/, "");
30
+ const asset = useAssetMap().get(normalizedSrc);
31
+ if (!asset) {
32
+ throw new Error(`asset not found: ${src}`);
33
+ }
34
+ return asset;
35
+ }
36
+ function useAssetUrl(src) {
37
+ const assetUrl = useAsset(src).assetUrl;
38
+ if (!assetUrl) {
39
+ throw new Error(`asset not found: ${src}`);
40
+ }
41
+ return assetUrl;
42
+ }
43
+
44
+ // src/core/hooks/useI18nContext.ts
45
+ import path from "node:path";
46
+ import { createContext as createContext3 } from "preact";
47
+ import { useContext as useContext3 } from "preact/hooks";
48
+ var I18N_CONTEXT = createContext3(null);
22
49
  function useI18nContext() {
23
- const context = useContext2(I18N_CONTEXT);
50
+ const context = useContext3(I18N_CONTEXT);
24
51
  if (!context) {
25
52
  throw new Error("I18N_CONTEXT not found");
26
53
  }
@@ -43,11 +70,11 @@ function getTranslations(locale) {
43
70
  }
44
71
 
45
72
  // src/core/hooks/useRequestContext.ts
46
- import { createContext as createContext3 } from "preact";
47
- import { useContext as useContext3 } from "preact/hooks";
48
- var REQUEST_CONTEXT = createContext3(null);
73
+ import { createContext as createContext4 } from "preact";
74
+ import { useContext as useContext4 } from "preact/hooks";
75
+ var REQUEST_CONTEXT = createContext4(null);
49
76
  function useRequestContext() {
50
- const context = useContext3(REQUEST_CONTEXT);
77
+ const context = useContext4(REQUEST_CONTEXT);
51
78
  if (!context) {
52
79
  throw new Error("REQUEST_CONTEXT not found");
53
80
  }
@@ -78,6 +105,10 @@ function testPathHasParams(urlPath) {
78
105
  export {
79
106
  HTML_CONTEXT,
80
107
  Html,
108
+ ASSET_MAP_CONTEXT,
109
+ useAssetMap,
110
+ useAsset,
111
+ useAssetUrl,
81
112
  I18N_CONTEXT,
82
113
  useI18nContext,
83
114
  getTranslations,
@@ -86,4 +117,4 @@ export {
86
117
  replaceParams,
87
118
  testPathHasParams
88
119
  };
89
- //# sourceMappingURL=chunk-KW7KTYGC.js.map
120
+ //# sourceMappingURL=chunk-6QWKKJOB.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/core/components/Html.tsx", "../src/core/hooks/useAssetMap.ts", "../src/core/hooks/useI18nContext.ts", "../src/core/hooks/useRequestContext.ts", "../src/utils/url-path-params.ts"],
4
+ "sourcesContent": ["import {ComponentChildren, FunctionalComponent, createContext} from 'preact';\nimport {useContext} from 'preact/hooks';\n\nexport interface HtmlContext {\n htmlAttrs: preact.JSX.HTMLAttributes<HTMLHtmlElement>;\n headAttrs: preact.JSX.HTMLAttributes<HTMLHeadElement>;\n headComponents: ComponentChildren[];\n bodyAttrs: preact.JSX.HTMLAttributes<HTMLBodyElement>;\n scriptDeps: Array<preact.JSX.ScriptHTMLAttributes<HTMLScriptElement>>;\n}\n\nexport const HTML_CONTEXT = createContext<HtmlContext | null>(null);\n\nexport type HtmlProps = preact.JSX.HTMLAttributes<HTMLHtmlElement> & {\n children?: ComponentChildren;\n};\n\n/**\n * The `<Html>` component can be used to update attrs in the `<html>` tag.\n *\n * Usage:\n *\n * ```tsx\n * <Html lang=\"en-US\">\n * <h1>Hello world</h1>\n * </Html>\n * ```\n */\nexport const Html: FunctionalComponent<HtmlProps> = ({children, ...attrs}) => {\n const context = useContext(HTML_CONTEXT);\n if (!context) {\n throw new Error(\n 'HTML_CONTEXT not found, double-check usage of the <Html> component'\n );\n }\n context.htmlAttrs = attrs;\n return <>{children}</>;\n};\n", "import {createContext} from 'preact';\nimport {useContext} from 'preact/hooks';\nimport type {Asset, AssetMap} from '../../render/asset-map/asset-map.js';\n\nexport const ASSET_MAP_CONTEXT = createContext<AssetMap | null>(null);\n\n/**\n * Returns the asset map for the current render.\n */\nexport function useAssetMap(): AssetMap {\n const assetMap = useContext(ASSET_MAP_CONTEXT);\n if (!assetMap) {\n throw new Error('ASSET_MAP_CONTEXT not found');\n }\n return assetMap;\n}\n\n/**\n * Returns an asset from the project's module graph. Paths are relative to the\n * project root and may optionally start with `/`.\n */\nexport function useAsset(src: string): Asset {\n const normalizedSrc = src.replace(/^\\/+/, '');\n const asset = useAssetMap().get(normalizedSrc);\n if (!asset) {\n throw new Error(`asset not found: ${src}`);\n }\n return asset;\n}\n\n/**\n * Returns the serving URL for a file compiled from the project's module graph.\n *\n * Usage:\n *\n * ```tsx\n * const customJs = useAssetUrl('/bundles/foo.ts');\n * return <div data-custom-js={customJs} />;\n * ```\n */\nexport function useAssetUrl(src: string): string {\n const assetUrl = useAsset(src).assetUrl;\n if (!assetUrl) {\n throw new Error(`asset not found: ${src}`);\n }\n return assetUrl;\n}\n", "import path from 'node:path';\nimport {createContext} from 'preact';\nimport {useContext} from 'preact/hooks';\n\nexport const I18N_CONTEXT = createContext<I18nContext | null>(null);\n\nexport interface I18nContext {\n locale: string;\n translations: Record<string, string>;\n}\n\n/**\n * A hook that returns information about the current i18n context, including the\n * locale for the given route and a map of translations for that locale.\n */\nexport function useI18nContext() {\n const context = useContext(I18N_CONTEXT);\n if (!context) {\n throw new Error('I18N_CONTEXT not found');\n }\n return context;\n}\n\nexport function getTranslations(locale: string): Record<string, string> {\n const translations: Record<string, Record<string, string>> = {};\n const translationsFiles = import.meta.glob(['/translations/*.json'], {\n eager: true,\n }) as Record<string, {default?: Record<string, string>}>;\n Object.keys(translationsFiles).forEach((translationPath) => {\n const parts = path.parse(translationPath);\n const locale = parts.name;\n const module = translationsFiles[translationPath];\n if (module && module.default) {\n translations[locale] = module.default;\n }\n });\n return translations[locale] || {};\n}\n", "import {createContext} from 'preact';\nimport {useContext} from 'preact/hooks';\nimport {Route} from '../types.js';\n\nexport interface RequestContext {\n /**\n * The current request path, e.g. `/foo/bar` (default route path) or\n * `/{locale}/foo/bar` (localized route path).\n */\n currentPath: string;\n /** The route file. */\n route: Route;\n /**\n * Route param values. E.g. for a route like `routes/blog/[slug].tsx`,\n * visiting `/blog/foo` will pass {slug: 'foo'} here.\n */\n routeParams: Record<string, string>;\n /** Props passed to the route's server component. */\n props: any;\n /** The current locale. */\n locale: string;\n /** Translations map for the current locale. */\n translations: Record<string, string>;\n /** CSP nonce value. */\n nonce?: string;\n}\n\nexport const REQUEST_CONTEXT = createContext<RequestContext | null>(null);\n\n/**\n * A hook that returns information about the current route.\n *\n * Usage:\n *\n * ```ts\n * const ctx = useRequestContext();\n * ctx.route.src;\n * // => 'routes/index.tsx'\n * ```\n */\nexport function useRequestContext() {\n const context = useContext(REQUEST_CONTEXT);\n if (!context) {\n throw new Error('REQUEST_CONTEXT not found');\n }\n return context;\n}\n", "export function replaceParams(\n urlPathFormat: string,\n params: Record<string, string>\n) {\n const urlPath = urlPathFormat.replaceAll(\n /\\[\\[?(\\.\\.\\.)?([\\w\\-_]*)\\]?\\]/g,\n (match: string, _wildcard: string, key: string) => {\n const val = params[key];\n if (!val) {\n throw new Error(`unreplaced param ${match} in url: ${urlPathFormat}`);\n }\n return val;\n }\n );\n return urlPath;\n}\n\nexport function testPathHasParams(urlPath: string) {\n const segments = urlPath.split('/');\n return segments.some((segment) => {\n return segment.startsWith('[') && segment.includes(']');\n });\n}\n"],
5
+ "mappings": ";AAAA,SAAgD,qBAAoB;AACpE,SAAQ,kBAAiB;AAmChB;AAzBF,IAAM,eAAe,cAAkC,IAAI;AAiB3D,IAAM,OAAuC,CAAC,EAAC,UAAU,GAAG,MAAK,MAAM;AAC5E,QAAM,UAAU,WAAW,YAAY;AACvC,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACA,UAAQ,YAAY;AACpB,SAAO,gCAAG,UAAS;AACrB;;;ACrCA,SAAQ,iBAAAA,sBAAoB;AAC5B,SAAQ,cAAAC,mBAAiB;AAGlB,IAAM,oBAAoBD,eAA+B,IAAI;AAK7D,SAAS,cAAwB;AACtC,QAAM,WAAWC,YAAW,iBAAiB;AAC7C,MAAI,CAAC,UAAU;AACb,UAAM,IAAI,MAAM,6BAA6B;AAAA,EAC/C;AACA,SAAO;AACT;AAMO,SAAS,SAAS,KAAoB;AAC3C,QAAM,gBAAgB,IAAI,QAAQ,QAAQ,EAAE;AAC5C,QAAM,QAAQ,YAAY,EAAE,IAAI,aAAa;AAC7C,MAAI,CAAC,OAAO;AACV,UAAM,IAAI,MAAM,oBAAoB,GAAG,EAAE;AAAA,EAC3C;AACA,SAAO;AACT;AAYO,SAAS,YAAY,KAAqB;AAC/C,QAAM,WAAW,SAAS,GAAG,EAAE;AAC/B,MAAI,CAAC,UAAU;AACb,UAAM,IAAI,MAAM,oBAAoB,GAAG,EAAE;AAAA,EAC3C;AACA,SAAO;AACT;;;AC9CA,OAAO,UAAU;AACjB,SAAQ,iBAAAC,sBAAoB;AAC5B,SAAQ,cAAAC,mB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Q,WAAW,GAAG,KAAK,QAAQ,SAAS,GAAG;AAAA,EACxD,CAAC;AACH;",
6
+ "names": ["createContext", "useContext", "createContext", "useContext", "locale", "createContext", "useContext"]
7
+ }
@@ -4,7 +4,7 @@ import {
4
4
  isJsFile,
5
5
  makeDir,
6
6
  writeFile
7
- } from "./chunk-KHO3HMX6.js";
7
+ } from "./chunk-Y4H75NIO.js";
8
8
  import {
9
9
  isValidTagName,
10
10
  parseTagNames,
@@ -137,7 +137,15 @@ var BuildAssetMap = class _BuildAssetMap {
137
137
  this.rootConfig = rootConfig;
138
138
  this.srcToAsset = /* @__PURE__ */ new Map();
139
139
  }
140
- async get(src) {
140
+ get(src) {
141
+ const asset = this.find(src);
142
+ if (asset) {
143
+ return asset;
144
+ }
145
+ console.log(`could not find build asset: ${src}`);
146
+ return null;
147
+ }
148
+ find(src) {
141
149
  const asset = this.srcToAsset.get(src);
142
150
  if (asset) {
143
151
  return asset;
@@ -149,8 +157,7 @@ var BuildAssetMap = class _BuildAssetMap {
149
157
  return asset2;
150
158
  }
151
159
  }
152
- console.log(`could not find build asset: ${src}`);
153
- return null;
160
+ return void 0;
154
161
  }
155
162
  add(asset) {
156
163
  this.srcToAsset.set(asset.src, asset);
@@ -232,6 +239,9 @@ function realPathRelativeTo(rootDir, src) {
232
239
  const realpath = fs2.realpathSync(path2.resolve(rootDir, src));
233
240
  return path2.relative(rootDir, realpath);
234
241
  }
242
+ function isJsAssetUrl(assetUrl) {
243
+ return assetUrl.endsWith(".js") || assetUrl.endsWith(".mjs");
244
+ }
235
245
  var BuildAsset = class {
236
246
  src;
237
247
  assetUrl;
@@ -259,6 +269,12 @@ var BuildAsset = class {
259
269
  await this.collectJs(this, deps, visited);
260
270
  return Array.from(deps);
261
271
  }
272
+ async getModulePreloadDeps() {
273
+ const visited = /* @__PURE__ */ new Set([this.src]);
274
+ const deps = /* @__PURE__ */ new Set();
275
+ await this.collectModulePreload(this.importedModules, deps, visited);
276
+ return Array.from(deps);
277
+ }
262
278
  async collectJs(asset, urls, visited) {
263
279
  if (!asset) {
264
280
  return;
@@ -280,6 +296,28 @@ var BuildAsset = class {
280
296
  })
281
297
  );
282
298
  }
299
+ /**
300
+ * Walks `srcs` and their transitive imports, collecting the JS chunk URL of
301
+ * every module along the way.
302
+ */
303
+ async collectModulePreload(srcs, urls, visited) {
304
+ await Promise.all(
305
+ srcs.map(async (src) => {
306
+ if (visited.has(src)) {
307
+ return;
308
+ }
309
+ visited.add(src);
310
+ const asset = await this.assetMap.get(src);
311
+ if (!asset || !asset.src) {
312
+ return;
313
+ }
314
+ if (asset.assetUrl && isJsAssetUrl(asset.assetUrl)) {
315
+ urls.add(asset.assetUrl);
316
+ }
317
+ await this.collectModulePreload(asset.importedModules, urls, visited);
318
+ })
319
+ );
320
+ }
283
321
  async collectCss(asset, urls, visited) {
284
322
  if (!asset) {
285
323
  return;
@@ -371,4 +409,4 @@ export {
371
409
  BuildAssetMap,
372
410
  buildPage
373
411
  };
374
- //# sourceMappingURL=chunk-M3E4RKS7.js.map
412
+ //# sourceMappingURL=chunk-DLPHCMFV.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/node/element-graph.ts", "../src/render/asset-map/build-asset-map.ts", "../src/cli/build-page.ts"],
4
+ "sourcesContent": ["import fs from 'node:fs';\nimport path from 'node:path';\nimport glob from 'tiny-glob';\nimport {searchForWorkspaceRoot} from 'vite';\nimport {RootConfig} from '../core/config.js';\nimport {isValidTagName, parseTagNames} from '../utils/elements.js';\nimport {directoryContains, isDirectory, isJsFile} from '../utils/fsutils.js';\nimport type {ResolvedPod} from './pod-collector.js';\n\ninterface ElementSourceFile {\n /** Full file path. */\n filePath: string;\n /** Path relative to the root project directory. */\n relPath: string;\n}\n\n/**\n * Dependency graph for element files to capture which other elements are used\n * by any particular element.\n */\nexport class ElementGraph {\n /**\n * Element tagName => sourceFile.\n */\n readonly sourceFiles: {[tagName: string]: ElementSourceFile} = {};\n\n /**\n * Element tagName => set of element tagName dependencies.\n */\n private deps: Record<string, string[]> = {};\n\n constructor(sourceFiles: {[tagName: string]: ElementSourceFile}) {\n this.sourceFiles = sourceFiles;\n }\n\n toJson() {\n for (const tagName in this.sourceFiles) {\n this.deps[tagName] ??= this.parseDepsFromSource(tagName);\n }\n return {\n sourceFiles: this.sourceFiles,\n deps: this.deps,\n };\n }\n\n static fromJson(data: {deps: any; sourceFiles: any}) {\n const graph = new ElementGraph(data.sourceFiles);\n graph.deps = data.deps;\n return graph;\n }\n\n getDeps(tagName: string, visited?: Set<string>): string[] {\n visited ??= new Set();\n if (visited.has(tagName)) {\n return [];\n }\n\n visited.add(tagName);\n this.deps[tagName] ??= this.parseDepsFromSource(tagName);\n\n const deps = new Set(this.deps[tagName]);\n for (const depTagName of this.deps[tagName]) {\n for (const childDep of this.getDeps(depTagName, visited)) {\n deps.add(childDep);\n }\n }\n return Array.from(deps);\n }\n\n /**\n * Parses an element's source file for usage of other custom elements.\n */\n private parseDepsFromSource(tagName: string): string[] {\n const srcFile = this.sourceFiles[tagName];\n if (!srcFile) {\n throw new Error(`could not find file path for tagName <${tagName}>`);\n }\n const src = fs.readFileSync(srcFile.filePath, 'utf-8');\n const tagNames = parseTagNames(src);\n const deps = new Set<string>();\n for (const depTagName of tagNames) {\n if (depTagName !== tagName && depTagName in this.sourceFiles) {\n deps.add(depTagName);\n }\n }\n return Array.from(deps);\n }\n}\n\n/**\n * Returns a map of all the element file definitions in the project.\n */\nexport async function getElements(\n rootConfig: RootConfig,\n pods?: ResolvedPod[]\n): Promise<ElementGraph> {\n const rootDir = rootConfig.rootDir;\n\n const elementsDirs = getElementsDirs(rootConfig, pods);\n const excludePatterns = rootConfig.elements?.exclude || [];\n const excludeElement = (moduleId: string) => {\n return excludePatterns.some((pattern) => Boolean(moduleId.match(pattern)));\n };\n\n const elementFilePaths: {[tagName: string]: ElementSourceFile} = {};\n for (const dirPath of elementsDirs) {\n if (await isDirectory(dirPath)) {\n const files = await glob('**/*', {cwd: dirPath});\n files.forEach((file) => {\n const parts = path.parse(file);\n if (isJsFile(parts.base) && isValidTagName(parts.name)) {\n const tagName = parts.name;\n const filePath = path.join(dirPath, file);\n const relPath = path.relative(rootDir, filePath);\n if (!excludeElement(relPath)) {\n elementFilePaths[tagName] = {filePath, relPath};\n }\n }\n });\n }\n }\n\n const graph = new ElementGraph(elementFilePaths);\n return graph;\n}\n\n/**\n * Get all element dirs.\n */\nexport function getElementsDirs(rootConfig: RootConfig, pods?: ResolvedPod[]) {\n const rootDir = rootConfig.rootDir;\n const workspaceRoot = searchForWorkspaceRoot(rootDir);\n\n const elementsDirs = [path.join(rootDir, 'elements')];\n const elementsInclude = rootConfig.elements?.include || [];\n\n for (const dirPath of elementsInclude) {\n const elementsDir = path.resolve(rootDir, dirPath);\n if (!directoryContains(rootDir, elementsDir)) {\n throw new Error(\n `the elements dir (${dirPath}) should be within the project's workspace (${workspaceRoot})`\n );\n }\n elementsDirs.push(elementsDir);\n }\n\n // Pod-contributed element dirs bypass the workspace containment check\n // because they are trusted (registered by plugins, not user input).\n if (pods) {\n for (const pod of pods) {\n for (const dir of pod.elementsDirs) {\n elementsDirs.push(dir);\n }\n }\n }\n\n return elementsDirs;\n}\n", "import fs from 'node:fs';\nimport path from 'node:path';\nimport {Manifest} from 'vite';\nimport {RootConfig} from '../../core/config.js';\nimport {ElementGraph} from '../../node/element-graph.js';\nimport {isJsFile} from '../../utils/fsutils.js';\nimport {Asset, AssetMap} from './asset-map.js';\n\nexport type BuildAssetManifest = Record<\n string,\n {\n src: string;\n assetUrl: string;\n importedModules: string[];\n importedCss: string[];\n isElement: boolean;\n }\n>;\n\n/**\n * A pod route, used to alias the route's virtual `pod/<name>/...` src to the\n * real asset built from the route's file. See `fromViteManifest()`.\n */\nexport interface PodRouteAsset {\n /** Virtual src, e.g. `pod/<name>/<relPath>`. */\n src: string;\n /** Absolute path to the pod route file. */\n filePath: string;\n}\n\nexport class BuildAssetMap implements AssetMap {\n private rootConfig: RootConfig;\n private srcToAsset: Map<string, BuildAsset>;\n\n constructor(rootConfig: RootConfig) {\n this.rootConfig = rootConfig;\n this.srcToAsset = new Map();\n }\n\n get(src: string): Asset | null {\n const asset = this.find(src);\n if (asset) {\n return asset;\n }\n console.log(`could not find build asset: ${src}`);\n return null;\n }\n\n private find(src: string): BuildAsset | undefined {\n const asset = this.srcToAsset.get(src);\n if (asset) {\n return asset;\n }\n // Try resolving the realpath of the asset, following symlinks.\n const realSrc = realPathRelativeTo(this.rootConfig.rootDir, src);\n if (realSrc !== src) {\n const asset = this.srcToAsset.get(realSrc);\n if (asset) {\n return asset;\n }\n }\n return undefined;\n }\n\n private add(asset: BuildAsset) {\n this.srcToAsset.set(asset.src, asset);\n }\n\n toJson(): BuildAssetManifest {\n const result: BuildAssetManifest = {};\n for (const src of this.srcToAsset.keys()) {\n result[src] = this.srcToAsset.get(src)!.toJson();\n }\n return result;\n }\n\n static fromViteManifest(\n rootConfig: RootConfig,\n clientManifest: Manifest,\n elementsGraph: ElementGraph,\n podRoutes: PodRouteAsset[] = []\n ) {\n const assetMap = new BuildAssetMap(rootConfig);\n\n const elementFiles = new Set();\n Object.values(elementsGraph.sourceFiles).forEach((elementSource) => {\n elementFiles.add(elementSource.relPath);\n // Vite will resolve symlinks, so we need to follow the src and add the\n // realpath to the element files.\n const realSrc = realPathRelativeTo(\n rootConfig.rootDir,\n elementSource.relPath\n );\n if (realSrc !== elementSource.filePath) {\n elementFiles.add(realSrc);\n }\n });\n\n Object.keys(clientManifest).forEach((manifestKey) => {\n const src = manifestKey;\n const manifestChunk = clientManifest[manifestKey];\n const isElement = elementFiles.has(src);\n // NOTES(stevenle): routes/ files are included in the manifest for\n // their CSS deps, but do not have an asset URL.\n const assetUrl =\n src.startsWith('routes/') && isJsFile(src)\n ? ''\n : `/${manifestChunk.file}`;\n const assetData = {\n src: src,\n assetUrl: assetUrl,\n importedModules: manifestChunk.imports || [],\n importedCss: (manifestChunk.css || []).map((relPath) => `/${relPath}`),\n isElement: isElement,\n };\n assetMap.add(new BuildAsset(assetMap, assetData));\n });\n\n // Pod routes are looked up by their virtual `pod/<name>/...` src at render\n // time, but the manifest keys them by their real file path. Register an\n // alias for each pod route so `get(route.src)` resolves to the built asset\n // (and the route's CSS deps are collected) instead of logging\n // \"could not find build asset\". Like user `routes/`, the alias has no asset\n // URL of its own (the route's client JS is injected via elements/bundles).\n podRoutes.forEach((podRoute) => {\n if (assetMap.srcToAsset.has(podRoute.src)) {\n return;\n }\n const relPath = path\n .relative(rootConfig.rootDir, podRoute.filePath)\n .replace(/\\\\/g, '/');\n // `realPathRelativeTo()` returns a `path.relative()` result with\n // OS-specific separators; normalize to forward slashes to match the\n // manifest keys (and `relPath` above) on Windows/symlinked setups.\n const realPath = realPathRelativeTo(rootConfig.rootDir, relPath).replace(\n /\\\\/g,\n '/'\n );\n const candidateKeys = [relPath, realPath];\n for (const key of candidateKeys) {\n const asset = assetMap.srcToAsset.get(key);\n if (asset) {\n assetMap.add(\n new BuildAsset(assetMap, {\n ...asset.toJson(),\n src: podRoute.src,\n assetUrl: '',\n })\n );\n break;\n }\n }\n });\n\n return assetMap;\n }\n\n static fromRootManifest(\n rootConfig: RootConfig,\n rootManifest: BuildAssetManifest\n ) {\n const assetMap = new BuildAssetMap(rootConfig);\n Object.keys(rootManifest).forEach((moduleId) => {\n const assetData = rootManifest[moduleId];\n assetMap.add(new BuildAsset(assetMap, assetData));\n });\n return assetMap;\n }\n}\n\n/**\n * Returns the realpath of a src file, relative to the rootDir.\n */\nfunction realPathRelativeTo(rootDir: string, src: string) {\n const fullPath = path.resolve(rootDir, src);\n if (!fs.existsSync(fullPath)) {\n return src;\n }\n const realpath = fs.realpathSync(path.resolve(rootDir, src));\n return path.relative(rootDir, realpath);\n}\n\n/**\n * Returns true if a serving URL points to a JS module.\n */\nfunction isJsAssetUrl(assetUrl: string) {\n return assetUrl.endsWith('.js') || assetUrl.endsWith('.mjs');\n}\n\nexport class BuildAsset {\n src: string;\n assetUrl: string;\n private assetMap: BuildAssetMap;\n private importedModules: string[];\n private importedCss: string[];\n isElement: boolean;\n\n constructor(\n assetMap: BuildAssetMap,\n assetData: {\n src: string;\n assetUrl: string;\n importedModules: string[];\n importedCss: string[];\n isElement: boolean;\n }\n ) {\n this.assetMap = assetMap;\n this.src = assetData.src;\n this.assetUrl = assetData.assetUrl;\n this.importedModules = assetData.importedModules;\n this.importedCss = assetData.importedCss;\n this.isElement = assetData.isElement;\n }\n\n async getCssDeps(): Promise<string[]> {\n const visited = new Set<string>();\n const deps = new Set<string>();\n await this.collectCss(this, deps, visited);\n return Array.from(deps);\n }\n\n async getJsDeps(): Promise<string[]> {\n const visited = new Set<string>();\n const deps = new Set<string>();\n await this.collectJs(this, deps, visited);\n return Array.from(deps);\n }\n\n async getModulePreloadDeps(): Promise<string[]> {\n // Seed `visited` with this asset so that the walk starts at the imported\n // modules and this asset's own URL is left out of the results.\n const visited = new Set<string>([this.src]);\n const deps = new Set<string>();\n await this.collectModulePreload(this.importedModules, deps, visited);\n return Array.from(deps);\n }\n\n private async collectJs(\n asset: BuildAsset | null,\n urls: Set<string>,\n visited: Set<string>\n ) {\n if (!asset) {\n return;\n }\n if (!asset.src) {\n return;\n }\n if (visited.has(asset.src)) {\n return;\n }\n visited.add(asset.src);\n if (asset.isElement) {\n urls.add(asset.assetUrl);\n }\n await Promise.all(\n asset.importedModules.map(async (src) => {\n const importedAsset = (await this.assetMap.get(src)) as BuildAsset;\n this.collectJs(importedAsset, urls, visited);\n })\n );\n }\n\n /**\n * Walks `srcs` and their transitive imports, collecting the JS chunk URL of\n * every module along the way.\n */\n private async collectModulePreload(\n srcs: string[],\n urls: Set<string>,\n visited: Set<string>\n ) {\n await Promise.all(\n srcs.map(async (src) => {\n if (visited.has(src)) {\n return;\n }\n visited.add(src);\n const asset = (await this.assetMap.get(src)) as BuildAsset | null;\n if (!asset || !asset.src) {\n return;\n }\n // Route files have no asset URL of their own, and CSS deps are\n // injected as stylesheets rather than preloaded.\n if (asset.assetUrl && isJsAssetUrl(asset.assetUrl)) {\n urls.add(asset.assetUrl);\n }\n await this.collectModulePreload(asset.importedModules, urls, visited);\n })\n );\n }\n\n private async collectCss(\n asset: BuildAsset | null,\n urls: Set<string>,\n visited: Set<string>\n ) {\n if (!asset) {\n return;\n }\n if (!asset.src) {\n return;\n }\n if (visited.has(asset.src)) {\n return;\n }\n visited.add(asset.src);\n if (asset.importedCss) {\n asset.importedCss.forEach((cssUrl) => urls.add(cssUrl));\n }\n await Promise.all(\n asset.importedModules.map(async (moduleId) => {\n const importedAsset = (await this.assetMap.get(moduleId)) as BuildAsset;\n this.collectCss(importedAsset, urls, visited);\n })\n );\n }\n\n toJson() {\n return {\n src: this.src,\n assetUrl: this.assetUrl,\n importedModules: this.importedModules,\n importedCss: this.importedCss,\n isElement: this.isElement,\n };\n }\n}\n", "import path from 'node:path';\n\nimport {RootConfig} from '../core/config.js';\nimport {Route} from '../core/types.js';\nimport {transformHtml} from '../render/html-transform.js';\nimport {makeDir, writeFile} from '../utils/fsutils.js';\n\ntype Renderer = import('../render/render.js').Renderer;\n\n/** A single page to build during the SSG phase of `root build`. */\nexport interface BuildPageTask {\n /** The url path to build, e.g. `/intl/de/about/`. */\n urlPath: string;\n /** Route params used to build the page. */\n params: Record<string, string>;\n /**\n * The route's src file (e.g. `routes/blog/[slug].tsx`). Used by worker\n * threads to disambiguate overlapping routes that match the same url path.\n */\n routeSrc?: string;\n /** The route's locale, used with `routeSrc` to disambiguate routes. */\n locale?: string;\n}\n\n/** The result of building a single page. */\nexport interface BuildPageResult {\n urlPath: string;\n /** Output file path relative to the build dir. Unset when `notFound`. */\n outFilePath?: string;\n notFound?: boolean;\n /** Whether the output was generated via `getStaticContent()`. */\n staticContent?: boolean;\n}\n\n/** Message sent from the build worker to the main thread. */\nexport type BuildWorkerResponse =\n | {type: 'ready'}\n | {type: 'result'; id: number; result: BuildPageResult}\n | {\n type: 'error';\n id: number;\n urlPath: string;\n params: Record<string, string>;\n routeSrc?: string;\n error: string;\n }\n | {type: 'fatal'; error: string};\n\n/** Message sent from the main thread to the build worker. */\nexport type BuildWorkerRequest = {\n type: 'render';\n id: number;\n task: BuildPageTask;\n};\n\n/**\n * Builds a single page (or static content file) to the build dir. Shared by\n * the in-process SSG build loop and the `--threads` build worker.\n */\nexport async function buildPage(\n renderer: Renderer,\n rootConfig: RootConfig,\n buildDir: string,\n route: Route,\n task: BuildPageTask\n): Promise<BuildPageResult> {\n const {urlPath, params} = task;\n const routeModule = route.module;\n if (routeModule.getStaticContent) {\n let props: any;\n if (routeModule.getStaticProps) {\n props = await routeModule.getStaticProps({\n rootConfig,\n params,\n });\n if (props?.notFound) {\n return {urlPath, notFound: true};\n }\n } else {\n props = {rootConfig, params};\n }\n const result = await routeModule.getStaticContent(props);\n let body: string;\n if (typeof result === 'string') {\n body = result;\n } else if (result && typeof result === 'object') {\n body = result.body;\n } else {\n body = '';\n }\n const outFilePath = urlPath.slice(1);\n const outPath = path.join(buildDir, outFilePath);\n await makeDir(path.dirname(outPath));\n await writeFile(outPath, normalizeLineEndings(body));\n return {urlPath, outFilePath, staticContent: true};\n }\n\n const data = await renderer.renderRoute(route, {\n routeParams: params,\n });\n if (data.notFound) {\n return {urlPath, notFound: true};\n }\n\n let outFilePath = path.join(urlPath.slice(1), 'index.html');\n if (outFilePath.endsWith('404/index.html')) {\n outFilePath = outFilePath.replace('404/index.html', '404.html');\n }\n const outPath = path.join(buildDir, outFilePath);\n\n const html = await transformHtml(data.html || '', rootConfig);\n await writeFile(outPath, normalizeLineEndings(html));\n return {urlPath, outFilePath};\n}\n\nexport function normalizeLineEndings(str: string): string {\n return str.replace(/\\r\\n?/g, '\\n');\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;AAAA,OAAO,QAAQ;AACf,OAAO,UAAU;AACjB,OAAO,UAAU;AACjB,SAAQ,8BAA6B;AAiB9B,IAAM,eAAN,MAAM,cAAa;AAAA;AAAA;AAAA;AAAA,EAIf,cAAsD,CAAC;AAAA;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,aAAO;AAAA,IACT,WAAW,UAAU,OAAO,WAAW,UAAU;AAC/C,aAAO,OAAO;AAAA,IAChB,OAAO;AACL,aAAO;AAAA,IACT;AACA,UAAMC,eAAc,QAAQ,MAAM,CAAC;AACnC,UAAMC,WAAUC,MAAK,KAAK,UAAUF,YAAW;AAC/C,UAAM,QAAQE,MAAK,QAAQD,QAAO,CAAC;AACnC,UAAM,UAAUA,UAAS,qBAAqB,IAAI,CAAC;AACnD,WAAO,EAAC,SAAS,aAAAD,cAAa,eAAe,KAAI;AAAA,EACnD;AAEA,QAAM,OAAO,MAAM,SAAS,YAAY,OAAO;AAAA,IAC7C,aAAa;AAAA,EACf,CAAC;AACD,MAAI,KAAK,UAAU;AACjB,WAAO,EAAC,SAAS,UAAU,KAAI;AAAA,EACjC;AAEA,MAAI,cAAcE,MAAK,KAAK,QAAQ,MAAM,CAAC,GAAG,YAAY;AAC1D,MAAI,YAAY,SAAS,gBAAgB,GAAG;AAC1C,kBAAc,YAAY,QAAQ,kBAAkB,UAAU;AAAA,EAChE;AACA,QAAM,UAAUA,MAAK,KAAK,UAAU,WAAW;AAE/C,QAAM,OAAO,MAAM,cAAc,KAAK,QAAQ,IAAI,UAAU;AAC5D,QAAM,UAAU,SAAS,qBAAqB,IAAI,CAAC;AACnD,SAAO,EAAC,SAAS,YAAW;AAC9B;AAEO,SAAS,qBAAqB,KAAqB;AACxD,SAAO,IAAI,QAAQ,UAAU,IAAI;AACnC;",
6
+ "names": ["fs", "path", "asset", "path", "fs", "path", "outFilePath", "outPath", "path"]
7
+ }
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  isDirectory,
3
3
  isJsFile
4
- } from "./chunk-KHO3HMX6.js";
4
+ } from "./chunk-Y4H75NIO.js";
5
5
  import {
6
6
  getVitePlugins
7
7
  } from "./chunk-XSNCF7WU.js";
@@ -565,4 +565,4 @@ export {
565
565
  createViteServer,
566
566
  viteSsrLoadModule
567
567
  };
568
- //# sourceMappingURL=chunk-YU22SAIG.js.map
568
+ //# sourceMappingURL=chunk-QJ4F45DC.js.map
@@ -3,7 +3,7 @@ import {
3
3
  createViteServer,
4
4
  preactToRootJsxPlugin,
5
5
  rootPodsVitePlugin
6
- } from "./chunk-YU22SAIG.js";
6
+ } from "./chunk-QJ4F45DC.js";
7
7
  import {
8
8
  RouteTrie
9
9
  } from "./chunk-I3RCAIW7.js";
@@ -13,13 +13,12 @@ import {
13
13
  buildPage,
14
14
  getElements,
15
15
  getElementsDirs
16
- } from "./chunk-M3E4RKS7.js";
16
+ } from "./chunk-DLPHCMFV.js";
17
17
  import {
18
18
  bundleRootConfig,
19
19
  copyDir,
20
20
  copyGlob,
21
21
  dirExists,
22
- directoryContains,
23
22
  fileExists,
24
23
  flattenPackageDepsFromMonorepo,
25
24
  isDirectory,
@@ -32,7 +31,7 @@ import {
32
31
  rmDir,
33
32
  writeFile,
34
33
  writeJson
35
- } from "./chunk-KHO3HMX6.js";
34
+ } from "./chunk-Y4H75NIO.js";
36
35
  import {
37
36
  configureServerPlugins,
38
37
  getVitePlugins
@@ -1423,7 +1422,7 @@ var DevServerAssetMap = class {
1423
1422
  this.rootConfig = rootConfig;
1424
1423
  this.moduleGraph = moduleGraph;
1425
1424
  }
1426
- async get(src) {
1425
+ get(src) {
1427
1426
  const file = path5.resolve(this.rootConfig.rootDir, src);
1428
1427
  const viteModules = this.moduleGraph.getModulesByFile(file);
1429
1428
  if (viteModules && viteModules.size > 0) {
@@ -1433,23 +1432,25 @@ var DevServerAssetMap = class {
1433
1432
  viteModule
1434
1433
  });
1435
1434
  }
1436
- if (file.startsWith(this.rootConfig.rootDir)) {
1435
+ if (directoryContains(this.rootConfig.rootDir, file)) {
1437
1436
  const assetUrl = file.slice(this.rootConfig.rootDir.length);
1438
1437
  return {
1439
1438
  src,
1440
1439
  assetUrl,
1441
1440
  getCssDeps: async () => [],
1442
- getJsDeps: async () => [assetUrl]
1441
+ getJsDeps: async () => [assetUrl],
1442
+ getModulePreloadDeps: async () => []
1443
1443
  };
1444
1444
  }
1445
1445
  const workspaceRoot = searchForWorkspaceRoot(this.rootConfig.rootDir);
1446
- if (await directoryContains(workspaceRoot, file)) {
1446
+ if (directoryContains(workspaceRoot, file)) {
1447
1447
  const assetUrl = `/@fs/${file}`;
1448
1448
  return {
1449
1449
  src,
1450
1450
  assetUrl,
1451
1451
  getCssDeps: async () => [],
1452
- getJsDeps: async () => [assetUrl]
1452
+ getJsDeps: async () => [assetUrl],
1453
+ getModulePreloadDeps: async () => []
1453
1454
  };
1454
1455
  }
1455
1456
  console.log(`could not find asset in asset map: ${src}`);
@@ -1459,6 +1460,10 @@ var DevServerAssetMap = class {
1459
1460
  return path5.relative(this.rootConfig.rootDir, file);
1460
1461
  }
1461
1462
  };
1463
+ function directoryContains(dir, file) {
1464
+ const relativePath = path5.relative(dir, file);
1465
+ return relativePath !== ".." && !relativePath.startsWith(`..${path5.sep}`);
1466
+ }
1462
1467
  var DevServerAsset = class _DevServerAsset {
1463
1468
  src;
1464
1469
  moduleId;
@@ -1484,6 +1489,14 @@ var DevServerAsset = class _DevServerAsset {
1484
1489
  this.collectJs(this, deps, visited);
1485
1490
  return Array.from(deps);
1486
1491
  }
1492
+ /**
1493
+ * The dev server serves modules unbundled and unhashed, so there are no
1494
+ * shared chunks to preload. Returning an empty list keeps
1495
+ * `<link rel="modulepreload">` tags out of the dev server's HTML.
1496
+ */
1497
+ async getModulePreloadDeps() {
1498
+ return [];
1499
+ }
1487
1500
  getImportedModules() {
1488
1501
  return this.viteModule.importedModules;
1489
1502
  }
@@ -3213,7 +3226,7 @@ function debounce(fn, timeout) {
3213
3226
  // src/cli/gae-deploy.ts
3214
3227
  import { execSync } from "node:child_process";
3215
3228
  import fs7 from "node:fs";
3216
- import yaml from "js-yaml";
3229
+ import { load as loadYaml } from "js-yaml";
3217
3230
  async function gaeDeploy(appDir, options) {
3218
3231
  if (!appDir) {
3219
3232
  throw new Error(
@@ -3229,7 +3242,7 @@ async function gaeDeploy(appDir, options) {
3229
3242
  if (!fs7.existsSync(appYamlPath)) {
3230
3243
  throw new Error(`[gae-deplopy] Missing: ${appYamlPath}`);
3231
3244
  }
3232
- const appYaml = yaml.load(fs7.readFileSync(appYamlPath, "utf8"));
3245
+ const appYaml = loadYaml(fs7.readFileSync(appYamlPath, "utf8"));
3233
3246
  const service = appYaml.service;
3234
3247
  if (!service) {
3235
3248
  throw new Error(
@@ -3775,4 +3788,4 @@ export {
3775
3788
  createProdServer,
3776
3789
  CliRunner
3777
3790
  };
3778
- //# sourceMappingURL=chunk-WGQNQPWG.js.map
3791
+ //# sourceMappingURL=chunk-WRZLI2L2.js.map