@vite-hub/workspace 0.4.1 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. package/README.md +62 -19
  2. package/dist/blob-database/postgres.d.ts +424 -0
  3. package/dist/blob-database/postgres.js +2 -0
  4. package/dist/blob-database-sources-DDZ1wV9w.js +9 -0
  5. package/dist/blob-database.d.ts +33 -447
  6. package/dist/blob-database.js +637 -208
  7. package/dist/checkout.js +1 -1
  8. package/dist/cloudflare.d.ts +1 -1
  9. package/dist/cloudflare.js +1 -1
  10. package/dist/{config-D1QENneP.js → config-DiyPi3Ff.js} +7 -7
  11. package/dist/{config-CDeGd0RB.d.ts → config-hxABr_Gg.d.ts} +1 -1
  12. package/dist/durability.d.ts +11 -2
  13. package/dist/durability.js +46 -4
  14. package/dist/{error-diagnostics-CQ4BUqRe.js → error-diagnostics-C0KyI408.js} +5 -1
  15. package/dist/{error-diagnostics-B5s9kNEA.js → error-diagnostics-Cth97txN.js} +10 -2
  16. package/dist/{path-uxLkzrZm.d.ts → errors-DXCZjdUU.d.ts} +0 -1
  17. package/dist/{file-CqG9zqiF.js → file-C1DYoGz3.js} +1 -1
  18. package/dist/{target-Dm9dHAVJ.js → file-metadata-Dv2JZwal.js} +1 -29
  19. package/dist/{files-B6wpAhEx.js → files-iHyik8jj.js} +2 -2
  20. package/dist/files.d.ts +13 -5
  21. package/dist/files.js +6 -5
  22. package/dist/{github-DKAlO0Vh.js → github-CFHl6RI0.js} +4 -4
  23. package/dist/{glob-BOqSKzSg.js → glob-BitxqDhb.js} +7 -7
  24. package/dist/{glob-Cjxms1t7.js → glob-Buxfvmyy.js} +1 -1
  25. package/dist/history-schema-BBWbpDk4.d.ts +436 -0
  26. package/dist/history-schema-postgres-U_ueRvmO.js +41 -0
  27. package/dist/{host-Bf1a2uo_.js → host-Dmr2Ctem.js} +150 -16
  28. package/dist/{hosted-zG7HJaE4.js → hosted-BktlvkF2.js} +20 -11
  29. package/dist/{hosted-vercel-blob-AbXG8fvR.js → hosted-vercel-blob-D0IPAjb1.js} +5 -5
  30. package/dist/hosted-vercel-blob.d.ts +1 -1
  31. package/dist/hosted-vercel-blob.js +1 -1
  32. package/dist/hosted.d.ts +1 -1
  33. package/dist/hosted.js +1 -1
  34. package/dist/index.d.ts +11 -23
  35. package/dist/index.js +28 -106
  36. package/dist/internal/workspace.d.ts +14 -0
  37. package/dist/internal/workspace.js +86 -0
  38. package/dist/{lifecycle-D8FdpBod.js → lifecycle-D6WN2dd_.js} +11 -8
  39. package/dist/loader.d.ts +1 -1
  40. package/dist/loader.js +2 -2
  41. package/dist/{mcp-resources-DntxtmDU.js → mcp-resources-TtxLNSL6.js} +1 -1
  42. package/dist/{memory-D5jq9HZW.js → memory-DjzwSng2.js} +16 -8
  43. package/dist/{metadata-target-DDoOQNp1.js → metadata-target-CR0aDtvS.js} +205 -60
  44. package/dist/{operation-definition-nmRu_O3V.d.ts → operation-definition-CI2PJGqu.d.ts} +8 -2
  45. package/dist/{operations-D8uCpzhM.js → operations-Cib30_dt.js} +5 -5
  46. package/dist/{operations-DsY2MQnG.js → operations-dtcU5LkD.js} +22 -7
  47. package/dist/operations.d.ts +2 -2
  48. package/dist/operations.js +1 -1
  49. package/dist/{path--wrT_Azm.js → path-BlIBpI7U.js} +1 -16
  50. package/dist/{plugins-CsrXCA1Q.d.ts → plugins-DKCBrH31.d.ts} +1 -1
  51. package/dist/{provider-sm9uzkLg.js → provider-Fc3M6bEx.js} +23 -10
  52. package/dist/providers/github/store.d.ts +1 -1
  53. package/dist/providers/github/store.js +1 -1
  54. package/dist/{registry-CwryP59t.d.ts → registry-CLL0TY0L.d.ts} +5 -3
  55. package/dist/{registry-DmVfUe4K.js → registry-CedQvQxW.js} +8 -3
  56. package/dist/{registry-CFl1Htyc.d.ts → registry-DpB5PBA4.d.ts} +5 -4
  57. package/dist/{request-scope-Dw5n8bMC.js → request-scope-Bcv2kD8h.js} +2 -1
  58. package/dist/rule-keys-Bsz6jTTF.js +19 -0
  59. package/dist/rules-OHaPFopX.js +269 -0
  60. package/dist/runtime/assets.d.ts +1 -1
  61. package/dist/runtime/assets.js +3 -3
  62. package/dist/runtime/empty-assets-registry.d.ts +1 -1
  63. package/dist/runtime/empty-registry.d.ts +2 -2
  64. package/dist/runtime/registry.d.ts +2 -2
  65. package/dist/runtime/request.js +1 -1
  66. package/dist/runtime/state.d.ts +5 -4
  67. package/dist/runtime/state.js +18 -6
  68. package/dist/runtime/workspace.d.ts +1 -1
  69. package/dist/runtime/workspace.js +1 -1
  70. package/dist/runtime.d.ts +9 -8
  71. package/dist/runtime.js +23 -16
  72. package/dist/{search-C_RfoM2j.js → search-BqNV9LnO.js} +1 -1
  73. package/dist/{server-Cd4-iCh5.js → server-CFtrOPk6.js} +5 -5
  74. package/dist/server.d.ts +2 -2
  75. package/dist/server.js +1 -1
  76. package/dist/{shared-ovXVSV3-.js → shared-BgDjxY3J.js} +14 -3
  77. package/dist/source-metadata.d.ts +2 -2
  78. package/dist/source-metadata.js +3 -3
  79. package/dist/{state-C-YtsaiJ.d.ts → state-DBV6VHS6.d.ts} +13 -21
  80. package/dist/{store-NZoRto-Y.js → store-BRMdD8Ft.js} +37 -36
  81. package/dist/{sync-CrT8zjwc.js → sync-BezGVzrW.js} +4 -4
  82. package/dist/test.d.ts +1 -1
  83. package/dist/test.js +1 -1
  84. package/dist/{types-1Z-tKK3g.d.ts → types-9DMtFjaa.d.ts} +52 -4
  85. package/dist/{use-B0o5HoBl.js → use-Dm2tbI5F.js} +15 -15
  86. package/dist/{use-CjbF8EO9.d.ts → use-Dv973swc.d.ts} +20 -28
  87. package/dist/{state-Cb_hIyAw.js → use-tools-C1qvhzme.js} +4 -17
  88. package/dist/use-tools-CMUthOdy.d.ts +12 -0
  89. package/dist/{utils-Dw-WULEZ.js → utils-C0Au2R16.js} +77 -268
  90. package/dist/vite.d.ts +32 -3
  91. package/dist/vite.js +990 -1286
  92. package/dist/vitehub-grants-C8IAl5-M.js +38 -0
  93. package/dist/{workspace-DvKu5PRa.js → workspace-CFrwWhEm.js} +18 -17
  94. package/dist/{workspace-CIXgHeyX.d.ts → workspace-Cw4ycIW-.d.ts} +1 -1
  95. package/package.json +22 -12
package/dist/vite.js CHANGED
@@ -1,24 +1,25 @@
1
1
  import { n as __exportAll$1, r as __toESM, t as __commonJSMin } from "./rolldown-runtime-rQ84J-ij.js";
2
- import { t as createMemoryWorkspaceStore } from "./memory-D5jq9HZW.js";
2
+ import { t as createMemoryWorkspaceStore } from "./memory-DjzwSng2.js";
3
3
  import { t as normalizeSafeWorkspacePath } from "./path-DrSIenjj.js";
4
- import { t as workspaceErrorDiagnostics } from "./error-diagnostics-B5s9kNEA.js";
4
+ import { t as workspaceErrorDiagnostics } from "./error-diagnostics-Cth97txN.js";
5
5
  import { assertNoSymlinks, checkoutFailure, conflictMarkerPatterns, folderOf, formatWorkspaceStatus, ignoredName, localCheckoutStatus, pullWorkspaces, pushWorkspaces, resolveWorkspaceConflicts, workspaceLockFile, workspaceStatus } from "./checkout.js";
6
6
  import { n as isRecordOrFunction, t as isRecord$1 } from "./object-Da1zyPCR.js";
7
- import { t as internalErrorDiagnostics } from "./error-diagnostics-CQ4BUqRe.js";
8
- import { n as isWorkspaceStore, r as normalizeWorkspaceStoreOptions } from "./provider-sm9uzkLg.js";
9
- import { i as installHostedWorkspaceRuntime } from "./hosted-zG7HJaE4.js";
10
- import { a as normalizeWorkspaceSources, n as createSourceContext } from "./config-D1QENneP.js";
11
- import { s as workspaceRegistryLoadError, t as normalizeWorkspaceDefinition } from "./registry-DmVfUe4K.js";
12
- import { n as installHostedVercelBlobWorkspaceRuntime } from "./hosted-vercel-blob-AbXG8fvR.js";
13
- import { S as resolve$1, _ as redactInspectionText, a as createNoExternalAddition, b as isAbsolute$1, c as isProductionBuild, d as resolveViteHubProjectRoot, f as shouldSkipViteProviderBuild, g as requireViteHubDevServerUrl, h as readViteHubDevTargetOption, i as createNativePackageLoading, l as isServerEnvironment, m as fetchViteHubDevEndpoint, n as callOperationFromCli, o as createViteHubEnvImportAliases, p as discoverViteHubDevServer, s as generatedViteHubWatchIgnoredAddition, t as workspaceOperations, u as publishViteHubDevServer, v as relativeDefinitionFile, x as relative$1, y as dirname$1 } from "./operations-DsY2MQnG.js";
14
- import { a as refreshWorkspaceDevToken, c as workspaceDevHeader, d as workspaceDevTokenHeader, f as workspaceDevTokenServerId, n as ensureWorkspaceDevToken, o as runWorkspaceDevCommand, p as isViteHubSecretEqual, r as readWorkspaceDevToken, s as validateWorkspaceDevToken, u as workspaceDevRoute } from "./server-Cd4-iCh5.js";
15
- import { n as syncWorkspaceDefinition } from "./lifecycle-D8FdpBod.js";
7
+ import { t as internalErrorDiagnostics } from "./error-diagnostics-C0KyI408.js";
8
+ import { n as isWorkspaceStore, r as normalizeWorkspaceStoreOptions } from "./provider-Fc3M6bEx.js";
9
+ import { i as installHostedWorkspaceRuntime } from "./hosted-BktlvkF2.js";
10
+ import { a as normalizeWorkspaceSources, n as createSourceContext } from "./config-DiyPi3Ff.js";
11
+ import { c as workspaceRegistryLoadError, n as normalizeWorkspaceDefinition } from "./registry-CedQvQxW.js";
12
+ import { n as installHostedVercelBlobWorkspaceRuntime } from "./hosted-vercel-blob-D0IPAjb1.js";
13
+ import { S as resolve$1, _ as redactInspectionText, a as createNoExternalAddition, b as isAbsolute$1, c as isProductionBuild, d as resolveViteHubProjectRoot, f as shouldSkipViteProviderBuild, g as requireViteHubDevServerUrl, h as readViteHubDevTargetOption, i as createNativePackageLoading, l as isServerEnvironment, m as fetchViteHubDevEndpoint, n as callOperationFromCli, o as createViteHubEnvImportAliases, p as discoverViteHubDevServer, s as generatedViteHubWatchIgnoredAddition, t as workspaceOperations, u as publishViteHubDevServer, v as relativeDefinitionFile, x as relative$1, y as dirname$1 } from "./operations-dtcU5LkD.js";
14
+ import { a as refreshWorkspaceDevToken, c as workspaceDevHeader, d as workspaceDevTokenHeader, f as workspaceDevTokenServerId, n as ensureWorkspaceDevToken, o as runWorkspaceDevCommand, p as isViteHubSecretEqual, r as readWorkspaceDevToken, s as validateWorkspaceDevToken, u as workspaceDevRoute } from "./server-CFtrOPk6.js";
15
+ import { n as syncWorkspaceDefinition } from "./lifecycle-D6WN2dd_.js";
16
16
  import { createRequire, isBuiltin } from "node:module";
17
17
  import { formatRuntimeDiagnosticError } from "@vite-hub/runtime";
18
18
  import { basename, dirname, extname, isAbsolute, join, relative, resolve, sep } from "node:path";
19
19
  import { createHash } from "node:crypto";
20
+ import { Minimatch } from "minimatch";
20
21
  import { defineDiagnostics } from "nostics";
21
- import { existsSync, mkdirSync, readFileSync, readdirSync, realpathSync, renameSync, rmSync, statSync, writeFileSync } from "node:fs";
22
+ import { existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, realpathSync, renameSync, rmSync, statSync, writeFileSync } from "node:fs";
22
23
  import { access, chmod, copyFile, cp, mkdir, mkdtemp, readFile, readdir, realpath, rename, rm, rmdir, stat, writeFile } from "node:fs/promises";
23
24
  import { tmpdir } from "node:os";
24
25
  import { fileURLToPath, pathToFileURL } from "node:url";
@@ -798,6 +799,24 @@ function createExternalMatcher(patterns) {
798
799
  });
799
800
  return (id) => matchers.some((matches) => matches(id));
800
801
  }
802
+ /** Returns the modules of the chunks that no chunk loaded from the entry chunk imports. */
803
+ function findUnusedChunkModules(chunks) {
804
+ const used = new Set(chunks.filter((chunk) => chunk.isEntry));
805
+ for (const chunk of used) for (const other of chunks) if (!used.has(other) && chunk.code.includes(other.fileName)) used.add(other);
806
+ return new Set(chunks.filter((chunk) => !used.has(chunk)).flatMap((chunk) => chunk.moduleIds));
807
+ }
808
+ function createEmptyModulesPlugin(ids) {
809
+ return {
810
+ name: "vitehub-empty-unused-chunks",
811
+ load(id) {
812
+ if (ids.has(id)) return {
813
+ code: "",
814
+ moduleSideEffects: false,
815
+ moduleType: "js"
816
+ };
817
+ }
818
+ };
819
+ }
801
820
  async function bundleEsmEntry(entryFile, outfile, options = {}) {
802
821
  const { rolldown } = await importRolldown();
803
822
  options.signal?.throwIfAborted();
@@ -828,7 +847,7 @@ async function bundleEsmEntry(entryFile, outfile, options = {}) {
828
847
  " globalThis.__dirname = globalThis.process.getBuiltinModule(\"node:path\").dirname(globalThis.__filename);",
829
848
  "}"
830
849
  ] : []].filter(Boolean).join("\n");
831
- const bundle = await rolldown({
850
+ const build = (extraPlugins = [], shimMissingExports = false) => rolldown({
832
851
  cwd: workingDir,
833
852
  external: isExternal ? (id) => isExternal(id) : void 0,
834
853
  input: entryFile,
@@ -837,35 +856,49 @@ async function bundleEsmEntry(entryFile, outfile, options = {}) {
837
856
  },
838
857
  moduleTypes: platform === "node" ? { ".wasm": "binary" } : void 0,
839
858
  platform,
840
- plugins,
859
+ plugins: [...extraPlugins, ...plugins],
841
860
  resolve: {
842
861
  conditionNames: options.conditions ?? (platform === "node" ? ["node"] : void 0),
843
862
  extensions: options.extensions,
844
863
  mainFields: options.mainFields ?? (platform === "neutral" ? ["module", "main"] : void 0),
845
864
  symlinks: !options.preserveSymlinks
846
865
  },
866
+ shimMissingExports,
847
867
  transform: {
848
868
  define: options.define,
849
869
  target: "es2022"
850
870
  },
851
871
  tsconfig: options.tsconfig ?? true
852
872
  });
873
+ const generate = async (bundle, codeSplitting) => (await bundle.generate({
874
+ banner: banner || void 0,
875
+ chunkFileNames: codeSplitting ? "chunk-[hash].js" : void 0,
876
+ codeSplitting,
877
+ format,
878
+ keepNames: options.keepNames ?? Boolean(options.minifySyntax || options.minifyIdentifiers),
879
+ minify,
880
+ polyfillRequire: !(format === "esm" && platform === "node"),
881
+ sourcemap: false
882
+ })).output;
883
+ let bundle = await build();
853
884
  let output;
854
885
  try {
855
- output = (await bundle.generate({
856
- banner: banner || void 0,
857
- codeSplitting: false,
858
- format,
859
- keepNames: options.keepNames ?? Boolean(options.minifySyntax || options.minifyIdentifiers),
860
- minify,
861
- polyfillRequire: !(format === "esm" && platform === "node"),
862
- sourcemap: false
863
- })).output;
886
+ output = await generate(bundle, true);
887
+ const chunks = output.filter((file) => file.type === "chunk");
888
+ if (chunks.length > 1 || chunks.some((chunk) => chunk.dynamicImports.includes(chunk.fileName))) {
889
+ options.signal?.throwIfAborted();
890
+ const unusedModules = findUnusedChunkModules(chunks);
891
+ if (unusedModules.size) {
892
+ await bundle.close();
893
+ bundle = await build([createEmptyModulesPlugin(unusedModules)], true);
894
+ }
895
+ output = await generate(bundle, false);
896
+ }
864
897
  } finally {
865
898
  await bundle.close();
866
899
  }
867
900
  options.signal?.throwIfAborted();
868
- const chunk = output.find((file) => file.type === "chunk");
901
+ const chunk = output.find((file) => file.type === "chunk" && file.isEntry);
869
902
  await mkdir(dirname(outfile), { recursive: true });
870
903
  await writeFile(outfile, chunk.code, { signal: options.signal });
871
904
  options.signal?.throwIfAborted();
@@ -912,6 +945,166 @@ function realpathIfExists(path) {
912
945
  }
913
946
  }
914
947
  //#endregion
948
+ //#region ../internal/src/build/runtime-package-files.ts
949
+ const alwaysPublishedFile = /^(?:package\.json|(?:readme|copying|licen[cs]e)(?:\..*[^~$])?)$/i;
950
+ const rootExcluded = /* @__PURE__ */ new Set([
951
+ "package-lock.json",
952
+ "yarn.lock",
953
+ "pnpm-lock.yaml",
954
+ "bun.lockb",
955
+ ".lock-wscript",
956
+ "build/config.gypi"
957
+ ]);
958
+ const excludedEntry = /^(?:node_modules|\.git|\.hg|\.svn|CVS|\.npmrc|\.npmignore|\.gitignore|\.DS_Store|npm-debug\.log|\._.*|.*\.orig|\..*\.swp)$/i;
959
+ function hasNodeModulesSegment$1(path) {
960
+ return path.split(/[\\/]/).includes("node_modules");
961
+ }
962
+ function isNestedPath(path) {
963
+ return Boolean(path) && path !== ".." && !path.startsWith(`..${sep}`) && !isAbsolute(path);
964
+ }
965
+ /** Runs a filesystem read, and returns `undefined` when the path is gone. */
966
+ async function unlessGone(read) {
967
+ try {
968
+ return await read();
969
+ } catch (error) {
970
+ const { code } = error;
971
+ if (code === "ENOENT" || code === "ENOTDIR") return void 0;
972
+ throw error;
973
+ }
974
+ }
975
+ function readIfPresent(read) {
976
+ try {
977
+ return read();
978
+ } catch (error) {
979
+ if (error.code === "ENOENT") return void 0;
980
+ throw error;
981
+ }
982
+ }
983
+ function packageRule(entry) {
984
+ const include = !entry.startsWith("!");
985
+ const pattern = (include ? entry : entry.slice(1)).replace(/^\.\//, "/").replace(/\/$/, "") || "**";
986
+ const matcher = new Minimatch(pattern, {
987
+ dot: true,
988
+ matchBase: true,
989
+ nocase: true,
990
+ nocomment: true,
991
+ nonegate: true
992
+ });
993
+ return {
994
+ include,
995
+ matches: (path, partial = false) => matcher.match(path, partial) || matcher.match(`/${path}`, partial)
996
+ };
997
+ }
998
+ /** Files selected for a linked package's publish list; `undefined` keeps the whole package. */
999
+ function publishedPackagePaths(packageDir) {
1000
+ let manifest;
1001
+ const contents = readIfPresent(() => readFileSync(join(packageDir, "package.json"), "utf8"));
1002
+ if (contents === void 0) return void 0;
1003
+ try {
1004
+ manifest = JSON.parse(contents);
1005
+ } catch {
1006
+ return;
1007
+ }
1008
+ if (!manifest || typeof manifest !== "object" || !("files" in manifest) || !Array.isArray(manifest.files)) return void 0;
1009
+ const rules = [];
1010
+ const required = /* @__PURE__ */ new Set();
1011
+ const requiredAncestors = /* @__PURE__ */ new Set();
1012
+ const requirePath = (entry) => {
1013
+ const path = relative(packageDir, join(packageDir, entry));
1014
+ if (!isNestedPath(path)) return;
1015
+ required.add(path);
1016
+ for (let parent = dirname(path); parent !== "."; parent = dirname(parent)) requiredAncestors.add(parent);
1017
+ };
1018
+ for (const entry of manifest.files) {
1019
+ if (typeof entry !== "string" || !entry) continue;
1020
+ const candidate = join(packageDir, entry);
1021
+ if (!entry.startsWith("!") && isNestedPath(relative(packageDir, candidate)) && readIfPresent(() => lstatSync(candidate))?.isFile()) requirePath(entry);
1022
+ else rules.push(packageRule(entry.endsWith("/*") ? `${entry}*` : entry));
1023
+ }
1024
+ if ("main" in manifest && typeof manifest.main === "string") requirePath(manifest.main);
1025
+ if ("browser" in manifest && typeof manifest.browser === "string") requirePath(manifest.browser);
1026
+ if ("bin" in manifest) {
1027
+ const bin = manifest.bin;
1028
+ if (typeof bin === "string") requirePath(bin);
1029
+ else if (bin && typeof bin === "object") {
1030
+ for (const file of Object.values(bin)) if (typeof file === "string") requirePath(file);
1031
+ }
1032
+ }
1033
+ const files = /* @__PURE__ */ new Set();
1034
+ const entries = /* @__PURE__ */ new Set([""]);
1035
+ const visit = (directory, ancestors, inheritedIgnores) => {
1036
+ const children = readIfPresent(() => readdirSync(join(packageDir, directory)));
1037
+ if (!children) return;
1038
+ let ignores = inheritedIgnores;
1039
+ if (directory) {
1040
+ const ignore = readIfPresent(() => readFileSync(join(packageDir, directory, ".npmignore"), "utf8")) ?? readIfPresent(() => readFileSync(join(packageDir, directory, ".gitignore"), "utf8"));
1041
+ if (ignore) {
1042
+ const localRules = ignore.split(/\r?\n/).map((line) => line.trim()).filter((line) => line && !line.startsWith("#")).map(packageRule);
1043
+ ignores = [...ignores, (paths, included) => {
1044
+ for (const rule of localRules) if (paths.slice(ancestors.length).some((path) => rule.matches(path.slice(directory.length + 1)))) included = !rule.include;
1045
+ return included;
1046
+ }];
1047
+ }
1048
+ }
1049
+ for (const child of children) {
1050
+ const path = join(directory, child);
1051
+ const portablePath = path.replaceAll(sep, "/");
1052
+ if (excludedEntry.test(child) || rootExcluded.has(portablePath) || child.includes("*")) continue;
1053
+ const prefixes = [...ancestors, portablePath];
1054
+ let included = false;
1055
+ for (const rule of rules) if (prefixes.some((prefix) => rule.matches(prefix))) included = rule.include;
1056
+ const includeFile = included && ignores.every((ignore) => ignore(prefixes, true)) || required.has(path) || !directory && alwaysPublishedFile.test(child);
1057
+ const includeDirectory = included || requiredAncestors.has(path) || rules.some((rule) => rule.include && rule.matches(portablePath, true));
1058
+ if (!includeFile && !includeDirectory) continue;
1059
+ const info = readIfPresent(() => lstatSync(join(packageDir, path)));
1060
+ if (info?.isDirectory() && includeDirectory) visit(path, prefixes, ignores);
1061
+ else if (info?.isFile() && includeFile) {
1062
+ files.add(path);
1063
+ for (let entry = path; entry !== "." && !entries.has(entry); entry = dirname(entry)) entries.add(entry);
1064
+ }
1065
+ }
1066
+ };
1067
+ visit("", [], []);
1068
+ return {
1069
+ files,
1070
+ entries
1071
+ };
1072
+ }
1073
+ /** Copies a file or folder and follows links. `node_modules` folders and paths that disappear during the copy are skipped. */
1074
+ async function copyTree(source, target) {
1075
+ const info = await unlessGone(() => stat(source));
1076
+ if (!info) return;
1077
+ if (!info.isDirectory()) {
1078
+ await unlessGone(() => copyFile(source, target));
1079
+ return;
1080
+ }
1081
+ const entries = await unlessGone(() => readdir(source));
1082
+ if (!entries) return;
1083
+ await mkdir(target, { recursive: true });
1084
+ for (const entry of entries) if (entry !== "node_modules") await copyTree(join(source, entry), join(target, entry));
1085
+ }
1086
+ /**
1087
+ * Copies one runtime package into deployment output, without its `node_modules`.
1088
+ *
1089
+ * An installed package only holds its published files. A linked workspace package, such as a `link:` or `workspace:`
1090
+ * dependency, is a whole source folder with tests and fixtures, so only the files that `npm publish` would ship are
1091
+ * copied. A path that disappears during the copy, such as a temporary test folder that another process removes, is
1092
+ * skipped instead of failing the build.
1093
+ */
1094
+ async function copyRuntimePackageFiles(packageDir, targetDir) {
1095
+ const paths = hasNodeModulesSegment$1(packageDir) ? void 0 : publishedPackagePaths(packageDir);
1096
+ if (!paths) {
1097
+ await copyTree(packageDir, targetDir);
1098
+ return;
1099
+ }
1100
+ await mkdir(targetDir, { recursive: true });
1101
+ for (const path of paths.files) {
1102
+ const target = join(targetDir, path);
1103
+ await mkdir(dirname(target), { recursive: true });
1104
+ await unlessGone(() => copyFile(join(packageDir, path), target));
1105
+ }
1106
+ }
1107
+ //#endregion
915
1108
  //#region ../internal/src/build/provider-output-sources.ts
916
1109
  /** Removes retained provider output after readers release it, tolerating transient filesystem contention. */
917
1110
  async function removeProviderOutputArtifactDir(path) {
@@ -924,6 +1117,9 @@ async function removeProviderOutputArtifactDir(path) {
924
1117
  }
925
1118
  //#endregion
926
1119
  //#region ../internal/src/build/vercel-config.ts
1120
+ function createDefaultVercelOutputRoot(rootDir) {
1121
+ return resolve(rootDir, ".vercel", "output");
1122
+ }
927
1123
  function createVercelConfigJson() {
928
1124
  return {
929
1125
  routes: [{ handle: "filesystem" }, {
@@ -933,15 +1129,320 @@ function createVercelConfigJson() {
933
1129
  version: 3
934
1130
  };
935
1131
  }
936
- function createNodeFunctionConfig(extra = {}) {
937
- return {
938
- handler: "index.mjs",
939
- launcherType: "Nodejs",
940
- runtime: "nodejs24.x",
941
- shouldAddHelpers: false,
942
- supportsResponseStreaming: true,
943
- ...extra
944
- };
1132
+ function createNodeFunctionConfig(extra = {}) {
1133
+ return {
1134
+ handler: "index.mjs",
1135
+ launcherType: "Nodejs",
1136
+ runtime: "nodejs24.x",
1137
+ shouldAddHelpers: false,
1138
+ supportsResponseStreaming: true,
1139
+ ...extra
1140
+ };
1141
+ }
1142
+ //#endregion
1143
+ //#region ../internal/src/build/runtime-package-resolution.ts
1144
+ /** Locates package metadata through exports, an entry's ancestors, or the project's dependency roots. */
1145
+ function createRuntimePackageResolver(readPackageName) {
1146
+ return async (name, resolver, fromDir) => {
1147
+ try {
1148
+ return resolver.resolve(`${name}/package.json`);
1149
+ } catch (error) {
1150
+ if (!isPackageResolutionMiss(error)) throw error;
1151
+ }
1152
+ try {
1153
+ let current = dirname(resolver.resolve(name));
1154
+ while (current !== dirname(current)) {
1155
+ const candidate = join(current, "package.json");
1156
+ try {
1157
+ await access(candidate);
1158
+ if (readPackageName(await readFile(candidate, "utf8"), candidate) === name) return candidate;
1159
+ } catch (error) {
1160
+ if (error.code !== "ENOENT") throw error;
1161
+ }
1162
+ current = dirname(current);
1163
+ }
1164
+ } catch (error) {
1165
+ if (!isPackageResolutionMiss(error)) throw error;
1166
+ }
1167
+ let current = fromDir;
1168
+ while (current !== dirname(current)) {
1169
+ const candidate = join(current, "node_modules", ...name.split("/"), "package.json");
1170
+ try {
1171
+ await access(candidate);
1172
+ return candidate;
1173
+ } catch (error) {
1174
+ if (error.code !== "ENOENT") throw error;
1175
+ }
1176
+ current = dirname(current);
1177
+ }
1178
+ };
1179
+ }
1180
+ function isPackageResolutionMiss(error) {
1181
+ const code = error?.code;
1182
+ return code === "MODULE_NOT_FOUND" || code === "ERR_MODULE_NOT_FOUND" || code === "ERR_PACKAGE_PATH_NOT_EXPORTED";
1183
+ }
1184
+ //#endregion
1185
+ //#region ../internal/src/build/runtime-package-directory.ts
1186
+ /** Update a staged copy, then publish it with rollback on failure or cancellation. */
1187
+ async function updateRuntimePackageDirectory(options) {
1188
+ const stagingRoot = await mkdtemp(join(dirname(options.directory), ".vitehub-runtime-packages-"));
1189
+ const stagedDirectory = join(stagingRoot, "node_modules");
1190
+ const previousDirectory = join(stagingRoot, "previous-node_modules");
1191
+ let movedPreviousOutput = false;
1192
+ let installedReplacement = false;
1193
+ let cleanupStagingRoot = true;
1194
+ try {
1195
+ try {
1196
+ await cp(options.directory, stagedDirectory, { recursive: true });
1197
+ } catch (error) {
1198
+ if (error.code !== "ENOENT") throw error;
1199
+ }
1200
+ await mkdir(stagedDirectory, { recursive: true });
1201
+ await options.update(stagedDirectory);
1202
+ options.signal?.throwIfAborted();
1203
+ try {
1204
+ await rename(options.directory, previousDirectory);
1205
+ movedPreviousOutput = true;
1206
+ cleanupStagingRoot = false;
1207
+ } catch (error) {
1208
+ if (error.code !== "ENOENT") throw error;
1209
+ }
1210
+ try {
1211
+ options.signal?.throwIfAborted();
1212
+ await rename(stagedDirectory, options.directory);
1213
+ installedReplacement = true;
1214
+ options.signal?.throwIfAborted();
1215
+ cleanupStagingRoot = true;
1216
+ } catch (error) {
1217
+ if (installedReplacement) await rm(options.directory, {
1218
+ force: true,
1219
+ recursive: true
1220
+ });
1221
+ if (movedPreviousOutput) await rename(previousDirectory, options.directory);
1222
+ cleanupStagingRoot = true;
1223
+ throw error;
1224
+ }
1225
+ } finally {
1226
+ if (cleanupStagingRoot) await rm(stagingRoot, {
1227
+ force: true,
1228
+ recursive: true
1229
+ });
1230
+ }
1231
+ }
1232
+ //#endregion
1233
+ //#region ../internal/src/build/vercel-runtime-packages.ts
1234
+ const runtimeExportConditions = /* @__PURE__ */ new Set([
1235
+ "default",
1236
+ "import",
1237
+ "module",
1238
+ "node",
1239
+ "node-addons",
1240
+ "require"
1241
+ ]);
1242
+ const resolvePackageJson = createRuntimePackageResolver((source, path) => parsePackageJson(JSON.parse(source), path).name);
1243
+ let nodeFileTracePromise;
1244
+ /** Collects the runtime packages that features add to Vercel functions, then traces and copies them once per function. */
1245
+ function createVercelFunctionRuntimePackagesPass(beforeWrite) {
1246
+ const requests = [];
1247
+ return {
1248
+ add(request) {
1249
+ requests.push(request);
1250
+ },
1251
+ async copy(signal) {
1252
+ const functions = /* @__PURE__ */ new Map();
1253
+ for (const request of requests.splice(0)) {
1254
+ const outputRoot = request.outputRoot ?? createDefaultVercelOutputRoot(request.rootDir);
1255
+ const serverDir = resolve(outputRoot, "functions", request.serverFunctionName ?? "__server.func");
1256
+ const entry = functions.get(serverDir) ?? {
1257
+ requests: [],
1258
+ rootDir: request.rootDir
1259
+ };
1260
+ entry.requests.push(request);
1261
+ functions.set(serverDir, entry);
1262
+ }
1263
+ for (const [serverDir, entry] of functions) await copyFunctionRuntimePackages(serverDir, entry.rootDir, entry.requests, signal, beforeWrite);
1264
+ }
1265
+ };
1266
+ }
1267
+ async function copyFunctionRuntimePackages(serverDir, rootDir, requests, signal, beforeWrite) {
1268
+ try {
1269
+ await access(serverDir);
1270
+ } catch (error) {
1271
+ if (error.code === "ENOENT") return;
1272
+ throw error;
1273
+ }
1274
+ const groups = [];
1275
+ for (const request of requests) {
1276
+ const requested = Array.isArray(request.packages) ? request.packages : await request.packages();
1277
+ if (requested.length) groups.push(requested.map((runtimePackage) => ({
1278
+ ...runtimePackage,
1279
+ resolveFrom: runtimePackage.resolveFrom ?? join(request.rootDir, "package.json")
1280
+ })));
1281
+ }
1282
+ if (!groups.length) return;
1283
+ const directory = resolve(serverDir, "node_modules");
1284
+ await beforeWrite?.(directory);
1285
+ await updateRuntimePackageDirectory({
1286
+ directory,
1287
+ signal,
1288
+ update: (outputNodeModules) => copyNodeRuntimePackageGroups(outputNodeModules, rootDir, groups)
1289
+ });
1290
+ }
1291
+ async function copyNodeRuntimePackageGroups(outputNodeModules, rootDir, groups) {
1292
+ const selected = /* @__PURE__ */ new Map();
1293
+ const requested = /* @__PURE__ */ new Map();
1294
+ for (const packages of groups) {
1295
+ const visited = /* @__PURE__ */ new Set();
1296
+ const expanded = /* @__PURE__ */ new Set();
1297
+ for (const runtimePackage of packages) {
1298
+ const resolveFrom = runtimePackage.resolveFrom ?? join(rootDir, "package.json");
1299
+ const resolver = createRequire(resolveFrom);
1300
+ const packageJsonPath = await selectRuntimePackage(runtimePackage.name, resolver, dirname(resolveFrom), selected, visited, expanded, runtimePackage);
1301
+ if (!packageJsonPath) continue;
1302
+ const previous = requested.get(runtimePackage.name);
1303
+ if (previous && previous !== packageJsonPath) throw internalErrorDiagnostics.INTERNAL_RUNTIME_PACKAGE_VERSION_CONFLICT({
1304
+ first: dirname(previous),
1305
+ name: runtimePackage.name,
1306
+ second: dirname(packageJsonPath)
1307
+ });
1308
+ requested.set(runtimePackage.name, packageJsonPath);
1309
+ }
1310
+ }
1311
+ for (const [name, { packageJson, packageJsonPath, resolver }] of selected) {
1312
+ const packageDir = dirname(packageJsonPath);
1313
+ const targetDir = join(outputNodeModules, ...name.split("/"));
1314
+ await rm(targetDir, {
1315
+ force: true,
1316
+ recursive: true
1317
+ });
1318
+ if (!await copyTracedPackageFiles(name, resolver, packageDir, packageJsonPath, packageJson, targetDir)) await copyRuntimePackageFiles(packageDir, targetDir);
1319
+ }
1320
+ }
1321
+ async function selectRuntimePackage(name, resolver, fromDir, selected, visited, expanded, options = { name }) {
1322
+ const packageJsonPath = await resolvePackageJson(name, resolver, fromDir);
1323
+ if (!packageJsonPath) {
1324
+ if (options.optional) return void 0;
1325
+ throw internalErrorDiagnostics.INTERNAL_B0046({ message: `Could not resolve package.json for ${name}.` });
1326
+ }
1327
+ const resolvedPackageJsonPath = await realpath(packageJsonPath);
1328
+ const packageDir = dirname(resolvedPackageJsonPath);
1329
+ const packageJson = parsePackageJson(JSON.parse(await readFile(resolvedPackageJsonPath, "utf8")), resolvedPackageJsonPath);
1330
+ const packageKey = `${name}\0${resolvedPackageJsonPath}`;
1331
+ if (!visited.has(packageKey)) {
1332
+ visited.add(packageKey);
1333
+ selected.set(name, {
1334
+ packageJson,
1335
+ packageJsonPath: resolvedPackageJsonPath,
1336
+ resolver
1337
+ });
1338
+ }
1339
+ const expansionKey = `${packageKey}\0${options.includePeerDependencies ? "peers" : "dependencies"}`;
1340
+ if (expanded.has(expansionKey)) return resolvedPackageJsonPath;
1341
+ expanded.add(expansionKey);
1342
+ const packageRequire = createRequire(resolvedPackageJsonPath);
1343
+ const dependencyNames = new Set(Object.keys(packageJson.dependencies || {}));
1344
+ const optionalDependencyNames = new Set(Object.keys(packageJson.optionalDependencies || {}));
1345
+ for (const dependencyName of optionalDependencyNames) dependencyNames.add(dependencyName);
1346
+ const requiredPeerDependencyNames = /* @__PURE__ */ new Set();
1347
+ if (options.includePeerDependencies) {
1348
+ for (const dependencyName of Object.keys(packageJson.peerDependencies || {})) if (!packageJson.peerDependenciesMeta?.[dependencyName]?.optional) {
1349
+ dependencyNames.add(dependencyName);
1350
+ requiredPeerDependencyNames.add(dependencyName);
1351
+ }
1352
+ }
1353
+ for (const dependencyName of dependencyNames) await selectRuntimePackage(dependencyName, packageRequire, packageDir, selected, visited, expanded, {
1354
+ includePeerDependencies: options.includePeerDependencies,
1355
+ name: dependencyName,
1356
+ optional: optionalDependencyNames.has(dependencyName) && !requiredPeerDependencyNames.has(dependencyName)
1357
+ });
1358
+ return resolvedPackageJsonPath;
1359
+ }
1360
+ async function copyTracedPackageFiles(name, resolver, packageDir, packageJsonPath, packageJson, targetDir) {
1361
+ const entries = await resolvePackageTraceEntries(name, resolver, packageDir, packageJson);
1362
+ if (!entries) return false;
1363
+ const { fileList } = await (await loadNodeFileTrace())([...entries], {
1364
+ base: packageDir,
1365
+ conditions: ["node"],
1366
+ exportsOnly: true,
1367
+ processCwd: packageDir
1368
+ });
1369
+ fileList.add(relative(packageDir, packageJsonPath));
1370
+ for (const file of fileList) {
1371
+ const source = resolve(packageDir, file);
1372
+ if (!isInsideDirectory(packageDir, source) || hasNodeModulesSegment(file)) continue;
1373
+ if (!(await stat(source)).isFile()) continue;
1374
+ const target = resolve(targetDir, file);
1375
+ await mkdir(dirname(target), { recursive: true });
1376
+ await copyFile(source, target);
1377
+ }
1378
+ return true;
1379
+ }
1380
+ async function loadNodeFileTrace() {
1381
+ nodeFileTracePromise ??= import("@vercel/nft").then(({ nodeFileTrace }) => nodeFileTrace);
1382
+ return nodeFileTracePromise;
1383
+ }
1384
+ async function resolvePackageTraceEntries(name, resolver, packageDir, packageJson) {
1385
+ const entryCandidates = /* @__PURE__ */ new Set();
1386
+ if (packageJson.exports) {
1387
+ const exportedTargets = collectRuntimeExportTargets(packageJson.exports);
1388
+ if (!exportedTargets) return void 0;
1389
+ for (const target of exportedTargets) entryCandidates.add(resolve(packageDir, target));
1390
+ } else {
1391
+ try {
1392
+ entryCandidates.add(resolver.resolve(name));
1393
+ } catch (error) {
1394
+ if (!isPackageResolutionMiss(error)) throw error;
1395
+ }
1396
+ if (packageJson.main) entryCandidates.add(resolve(packageDir, packageJson.main));
1397
+ if (packageJson.module) entryCandidates.add(resolve(packageDir, packageJson.module));
1398
+ entryCandidates.add(resolve(packageDir, "index.js"));
1399
+ }
1400
+ const entries = [];
1401
+ for (const candidate of entryCandidates) try {
1402
+ const candidateStat = await stat(candidate);
1403
+ if (candidateStat.isFile()) entries.push(candidate);
1404
+ else if (candidateStat.isDirectory()) return void 0;
1405
+ } catch (error) {
1406
+ if (error.code !== "ENOENT") throw error;
1407
+ }
1408
+ return entries.length ? entries : void 0;
1409
+ }
1410
+ function collectRuntimeExportTargets(exportsValue, condition) {
1411
+ if (typeof exportsValue === "string") {
1412
+ if (condition === "types") return /* @__PURE__ */ new Set();
1413
+ if (exportsValue.includes("*")) return void 0;
1414
+ return exportsValue.startsWith("./") ? /* @__PURE__ */ new Set([exportsValue]) : /* @__PURE__ */ new Set();
1415
+ }
1416
+ if (Array.isArray(exportsValue)) {
1417
+ const targets = /* @__PURE__ */ new Set();
1418
+ for (const entry of exportsValue) {
1419
+ const entryTargets = collectRuntimeExportTargets(entry, condition);
1420
+ if (!entryTargets) return void 0;
1421
+ for (const target of entryTargets) targets.add(target);
1422
+ }
1423
+ return targets;
1424
+ }
1425
+ if (typeof exportsValue !== "object" || exportsValue === null) return /* @__PURE__ */ new Set();
1426
+ const targets = /* @__PURE__ */ new Set();
1427
+ for (const [key, value] of Object.entries(exportsValue)) {
1428
+ if (key === "types") continue;
1429
+ if (!key.startsWith(".") && !runtimeExportConditions.has(key)) continue;
1430
+ const entryTargets = collectRuntimeExportTargets(value, key);
1431
+ if (!entryTargets) return void 0;
1432
+ for (const target of entryTargets) targets.add(target);
1433
+ }
1434
+ return targets;
1435
+ }
1436
+ function hasNodeModulesSegment(path) {
1437
+ return path.split(/[\\/]/).includes("node_modules");
1438
+ }
1439
+ function isInsideDirectory(parent, child) {
1440
+ const childRelativePath = relative(parent, child);
1441
+ return childRelativePath === "" || !childRelativePath.startsWith(`..${sep}`) && childRelativePath !== ".." && !isAbsolute(childRelativePath);
1442
+ }
1443
+ function parsePackageJson(value, path) {
1444
+ if (typeof value !== "object" || value === null || Array.isArray(value)) throw internalErrorDiagnostics.INTERNAL_B0047({ message: `Expected ${path} to contain a JSON object.` });
1445
+ return value;
945
1446
  }
946
1447
  //#endregion
947
1448
  //#region ../internal/src/build/provider-output-catalog.ts
@@ -1264,9 +1765,6 @@ async function writeProviderOutputOwnershipFiles(outputRoot, ownership, files) {
1264
1765
  await writeFile(file, `${JSON.stringify(values, null, 2)}\n`, "utf8");
1265
1766
  }));
1266
1767
  }
1267
- function createDefaultVercelOutputRoot(rootDir) {
1268
- return resolve(rootDir, ".vercel", "output");
1269
- }
1270
1768
  function createDefaultNetlifyOutputRoot(rootDir) {
1271
1769
  return resolve(rootDir, ".netlify", "v1");
1272
1770
  }
@@ -2107,9 +2605,11 @@ async function finalizeProviderDeploymentOutputs(catalog, options = {}) {
2107
2605
  const write = withProviderDeploymentOutputRootLock(rootDir, async () => {
2108
2606
  await withProviderDeploymentOutputRootTransaction(rootDir, async (transaction) => {
2109
2607
  try {
2608
+ const vercelRuntimePackages = createVercelFunctionRuntimePackagesPass((nodeModules) => transaction.snapshot([nodeModules]));
2110
2609
  for (const contribution of rootContributions) {
2111
2610
  throwIfProviderOutputAborted(controller.signal);
2112
2611
  await contribution.write({
2612
+ addVercelRuntimePackages: (request) => vercelRuntimePackages.add(request),
2113
2613
  readCloudflareState: async (options) => await readCloudflareProviderDeploymentOutputState(rootDir, options),
2114
2614
  signal: controller.signal,
2115
2615
  write: async (writeOptions) => {
@@ -2125,6 +2625,8 @@ async function finalizeProviderDeploymentOutputs(catalog, options = {}) {
2125
2625
  });
2126
2626
  throwIfProviderOutputAborted(controller.signal);
2127
2627
  }
2628
+ await vercelRuntimePackages.copy(controller.signal);
2629
+ throwIfProviderOutputAborted(controller.signal);
2128
2630
  ready();
2129
2631
  const rollback = await rootDecision;
2130
2632
  if (rollback !== void 0) throw rollback;
@@ -2300,305 +2802,37 @@ function scanSuffixDefinitions(feature, source) {
2300
2802
  if (!name) continue;
2301
2803
  registerDefinition(definitions, createDefinition(source, file, name), feature);
2302
2804
  }
2303
- return sortDefinitions(definitions);
2304
- }
2305
- function scanDirectoryDefinitions(feature, source) {
2306
- const definitions = /* @__PURE__ */ new Map();
2307
- for (const scanDir of source.scanDirs) {
2308
- const directory = resolve$1(scanDir, source.subdir);
2309
- for (const file of listSourceFiles(directory, { includeHidden: source.includeHidden })) {
2310
- const name = source.normalizeName ? source.normalizeName(directory, file) : normalizePathDefinitionName(directory, file);
2311
- if (!name) continue;
2312
- registerDefinition(definitions, createDefinition(source, file, name), feature);
2313
- }
2314
- }
2315
- return sortDefinitions(definitions);
2316
- }
2317
- function discoverDefinitions$1(feature, sources) {
2318
- return mergeDefinitions(feature, ...sources.map((source) => source.kind === "suffix" ? scanSuffixDefinitions(feature, source) : scanDirectoryDefinitions(feature, source)));
2319
- }
2320
- /**
2321
- * Writes generated output only when its bytes change. A running dev server watches these files, so an identical
2322
- * rewrite, for example from a CLI command that loads the project, would rebuild it for nothing.
2323
- */
2324
- function writeFileIfChangedSync(file, contents) {
2325
- if (existsSync(file) && readFileSync(file, "utf8") === contents) return;
2326
- mkdirSync(resolve$1(file, ".."), { recursive: true });
2327
- writeFileSync(file, contents, "utf8");
2328
- }
2329
- /** `writeFileIfChangedSync` for async callers. */
2330
- async function writeFileIfChanged(file, contents) {
2331
- if (await readFile(file, "utf8").catch(() => void 0) === contents) return;
2332
- await mkdir(resolve$1(file, ".."), { recursive: true });
2333
- await writeFile(file, contents, "utf8");
2334
- }
2335
- //#endregion
2336
- //#region ../internal/src/build/runtime-package-resolution.ts
2337
- /** Locates package metadata through exports, an entry's ancestors, or the project's dependency roots. */
2338
- function createRuntimePackageResolver(readPackageName) {
2339
- return async (name, resolver, fromDir) => {
2340
- try {
2341
- return resolver.resolve(`${name}/package.json`);
2342
- } catch (error) {
2343
- if (!isPackageResolutionMiss(error)) throw error;
2344
- }
2345
- try {
2346
- let current = dirname(resolver.resolve(name));
2347
- while (current !== dirname(current)) {
2348
- const candidate = join(current, "package.json");
2349
- try {
2350
- await access(candidate);
2351
- if (readPackageName(await readFile(candidate, "utf8"), candidate) === name) return candidate;
2352
- } catch (error) {
2353
- if (error.code !== "ENOENT") throw error;
2354
- }
2355
- current = dirname(current);
2356
- }
2357
- } catch (error) {
2358
- if (!isPackageResolutionMiss(error)) throw error;
2359
- }
2360
- let current = fromDir;
2361
- while (current !== dirname(current)) {
2362
- const candidate = join(current, "node_modules", ...name.split("/"), "package.json");
2363
- try {
2364
- await access(candidate);
2365
- return candidate;
2366
- } catch (error) {
2367
- if (error.code !== "ENOENT") throw error;
2368
- }
2369
- current = dirname(current);
2370
- }
2371
- };
2372
- }
2373
- function isPackageResolutionMiss(error) {
2374
- const code = error?.code;
2375
- return code === "MODULE_NOT_FOUND" || code === "ERR_MODULE_NOT_FOUND" || code === "ERR_PACKAGE_PATH_NOT_EXPORTED";
2376
- }
2377
- //#endregion
2378
- //#region ../internal/src/build/runtime-package-directory.ts
2379
- /** Update a staged copy, then publish it with rollback on failure or cancellation. */
2380
- async function updateRuntimePackageDirectory(options) {
2381
- const stagingRoot = await mkdtemp(join(dirname(options.directory), ".vitehub-runtime-packages-"));
2382
- const stagedDirectory = join(stagingRoot, "node_modules");
2383
- const previousDirectory = join(stagingRoot, "previous-node_modules");
2384
- let movedPreviousOutput = false;
2385
- let installedReplacement = false;
2386
- let cleanupStagingRoot = true;
2387
- try {
2388
- try {
2389
- await cp(options.directory, stagedDirectory, { recursive: true });
2390
- } catch (error) {
2391
- if (error.code !== "ENOENT") throw error;
2392
- }
2393
- await mkdir(stagedDirectory, { recursive: true });
2394
- await options.update(stagedDirectory);
2395
- options.signal?.throwIfAborted();
2396
- try {
2397
- await rename(options.directory, previousDirectory);
2398
- movedPreviousOutput = true;
2399
- cleanupStagingRoot = false;
2400
- } catch (error) {
2401
- if (error.code !== "ENOENT") throw error;
2402
- }
2403
- try {
2404
- options.signal?.throwIfAborted();
2405
- await rename(stagedDirectory, options.directory);
2406
- installedReplacement = true;
2407
- options.signal?.throwIfAborted();
2408
- cleanupStagingRoot = true;
2409
- } catch (error) {
2410
- if (installedReplacement) await rm(options.directory, {
2411
- force: true,
2412
- recursive: true
2413
- });
2414
- if (movedPreviousOutput) await rename(previousDirectory, options.directory);
2415
- cleanupStagingRoot = true;
2416
- throw error;
2417
- }
2418
- } finally {
2419
- if (cleanupStagingRoot) await rm(stagingRoot, {
2420
- force: true,
2421
- recursive: true
2422
- });
2423
- }
2424
- }
2425
- //#endregion
2426
- //#region ../internal/src/build/vercel-runtime-packages.ts
2427
- const runtimeExportConditions = /* @__PURE__ */ new Set([
2428
- "default",
2429
- "import",
2430
- "module",
2431
- "node",
2432
- "node-addons",
2433
- "require"
2434
- ]);
2435
- const resolvePackageJson = createRuntimePackageResolver((source, path) => parsePackageJson(JSON.parse(source), path).name);
2436
- let nodeFileTracePromise;
2437
- async function copyVercelFunctionRuntimePackages(options) {
2438
- const outputRoot = options.outputRoot ?? createDefaultVercelOutputRoot(options.rootDir);
2439
- const serverFunctionName = options.serverFunctionName ?? "__server.func";
2440
- const serverDir = resolve(outputRoot, "functions", serverFunctionName);
2441
- try {
2442
- await access(serverDir);
2443
- } catch (error) {
2444
- if (error.code === "ENOENT") return;
2445
- throw error;
2446
- }
2447
- const packages = Array.isArray(options.packages) ? options.packages : await options.packages();
2448
- if (!packages.length) return;
2449
- await updateRuntimePackageDirectory({
2450
- directory: resolve(serverDir, "node_modules"),
2451
- signal: options.signal,
2452
- update: (outputNodeModules) => copyNodeRuntimePackages({
2453
- outputNodeModules,
2454
- packages,
2455
- rootDir: options.rootDir
2456
- })
2457
- });
2458
- }
2459
- async function copyNodeRuntimePackages(options) {
2460
- if (!options.packages.length) return;
2461
- const copied = /* @__PURE__ */ new Set();
2462
- const expanded = /* @__PURE__ */ new Set();
2463
- for (const runtimePackage of options.packages) {
2464
- const resolveFrom = runtimePackage.resolveFrom ?? join(options.rootDir, "package.json");
2465
- const resolver = createRequire(resolveFrom);
2466
- await copyPackageToNodeModules(runtimePackage.name, resolver, dirname(resolveFrom), options.outputNodeModules, copied, expanded, runtimePackage);
2467
- }
2468
- }
2469
- async function copyPackageToNodeModules(name, resolver, fromDir, outputNodeModules, copied, expanded, options = { name }) {
2470
- const packageJsonPath = await resolvePackageJson(name, resolver, fromDir);
2471
- if (!packageJsonPath) {
2472
- if (options.optional) return;
2473
- throw internalErrorDiagnostics.INTERNAL_B0046({ message: `Could not resolve package.json for ${name}.` });
2474
- }
2475
- const resolvedPackageJsonPath = await realpath(packageJsonPath);
2476
- const packageDir = dirname(resolvedPackageJsonPath);
2477
- const packageJson = parsePackageJson(JSON.parse(await readFile(resolvedPackageJsonPath, "utf8")), resolvedPackageJsonPath);
2478
- const packageKey = `${name}\0${resolvedPackageJsonPath}`;
2479
- if (!copied.has(packageKey)) {
2480
- copied.add(packageKey);
2481
- const targetDir = join(outputNodeModules, ...name.split("/"));
2482
- await rm(targetDir, {
2483
- force: true,
2484
- recursive: true
2485
- });
2486
- if (!await copyTracedPackageFiles(name, resolver, packageDir, resolvedPackageJsonPath, packageJson, targetDir)) await copyPackageDirectory(packageDir, targetDir);
2487
- }
2488
- const expansionKey = `${packageKey}\0${options.includePeerDependencies ? "peers" : "dependencies"}`;
2489
- if (expanded.has(expansionKey)) return;
2490
- expanded.add(expansionKey);
2491
- const packageRequire = createRequire(resolvedPackageJsonPath);
2492
- const dependencyNames = new Set(Object.keys(packageJson.dependencies || {}));
2493
- const optionalDependencyNames = new Set(Object.keys(packageJson.optionalDependencies || {}));
2494
- for (const dependencyName of optionalDependencyNames) dependencyNames.add(dependencyName);
2495
- const requiredPeerDependencyNames = /* @__PURE__ */ new Set();
2496
- if (options.includePeerDependencies) {
2497
- for (const dependencyName of Object.keys(packageJson.peerDependencies || {})) if (!packageJson.peerDependenciesMeta?.[dependencyName]?.optional) {
2498
- dependencyNames.add(dependencyName);
2499
- requiredPeerDependencyNames.add(dependencyName);
2500
- }
2501
- }
2502
- for (const dependencyName of dependencyNames) await copyPackageToNodeModules(dependencyName, packageRequire, packageDir, outputNodeModules, copied, expanded, {
2503
- includePeerDependencies: options.includePeerDependencies,
2504
- name: dependencyName,
2505
- optional: optionalDependencyNames.has(dependencyName) && !requiredPeerDependencyNames.has(dependencyName)
2506
- });
2507
- }
2508
- async function copyTracedPackageFiles(name, resolver, packageDir, packageJsonPath, packageJson, targetDir) {
2509
- const entries = await resolvePackageTraceEntries(name, resolver, packageDir, packageJson);
2510
- if (!entries) return false;
2511
- const { fileList } = await (await loadNodeFileTrace())([...entries], {
2512
- base: packageDir,
2513
- conditions: ["node"],
2514
- exportsOnly: true,
2515
- processCwd: packageDir
2516
- });
2517
- fileList.add(relative(packageDir, packageJsonPath));
2518
- for (const file of fileList) {
2519
- const source = resolve(packageDir, file);
2520
- if (!isInsideDirectory(packageDir, source) || hasNodeModulesSegment(file)) continue;
2521
- if (!(await stat(source)).isFile()) continue;
2522
- const target = resolve(targetDir, file);
2523
- await mkdir(dirname(target), { recursive: true });
2524
- await copyFile(source, target);
2525
- }
2526
- return true;
2527
- }
2528
- async function copyPackageDirectory(packageDir, targetDir) {
2529
- await mkdir(dirname(targetDir), { recursive: true });
2530
- await cp(packageDir, targetDir, {
2531
- dereference: true,
2532
- filter: (source) => !hasNodeModulesSegment(relative(packageDir, source)),
2533
- recursive: true
2534
- });
2535
- }
2536
- async function loadNodeFileTrace() {
2537
- nodeFileTracePromise ??= import("@vercel/nft").then(({ nodeFileTrace }) => nodeFileTrace);
2538
- return nodeFileTracePromise;
2539
- }
2540
- async function resolvePackageTraceEntries(name, resolver, packageDir, packageJson) {
2541
- const entryCandidates = /* @__PURE__ */ new Set();
2542
- if (packageJson.exports) {
2543
- const exportedTargets = collectRuntimeExportTargets(packageJson.exports);
2544
- if (!exportedTargets) return void 0;
2545
- for (const target of exportedTargets) entryCandidates.add(resolve(packageDir, target));
2546
- } else {
2547
- try {
2548
- entryCandidates.add(resolver.resolve(name));
2549
- } catch (error) {
2550
- if (!isPackageResolutionMiss(error)) throw error;
2551
- }
2552
- if (packageJson.main) entryCandidates.add(resolve(packageDir, packageJson.main));
2553
- if (packageJson.module) entryCandidates.add(resolve(packageDir, packageJson.module));
2554
- entryCandidates.add(resolve(packageDir, "index.js"));
2555
- }
2556
- const entries = [];
2557
- for (const candidate of entryCandidates) try {
2558
- const candidateStat = await stat(candidate);
2559
- if (candidateStat.isFile()) entries.push(candidate);
2560
- else if (candidateStat.isDirectory()) return void 0;
2561
- } catch (error) {
2562
- if (error.code !== "ENOENT") throw error;
2563
- }
2564
- return entries.length ? entries : void 0;
2805
+ return sortDefinitions(definitions);
2565
2806
  }
2566
- function collectRuntimeExportTargets(exportsValue, condition) {
2567
- if (typeof exportsValue === "string") {
2568
- if (condition === "types") return /* @__PURE__ */ new Set();
2569
- if (exportsValue.includes("*")) return void 0;
2570
- return exportsValue.startsWith("./") ? /* @__PURE__ */ new Set([exportsValue]) : /* @__PURE__ */ new Set();
2571
- }
2572
- if (Array.isArray(exportsValue)) {
2573
- const targets = /* @__PURE__ */ new Set();
2574
- for (const entry of exportsValue) {
2575
- const entryTargets = collectRuntimeExportTargets(entry, condition);
2576
- if (!entryTargets) return void 0;
2577
- for (const target of entryTargets) targets.add(target);
2807
+ function scanDirectoryDefinitions(feature, source) {
2808
+ const definitions = /* @__PURE__ */ new Map();
2809
+ for (const scanDir of source.scanDirs) {
2810
+ const directory = resolve$1(scanDir, source.subdir);
2811
+ for (const file of listSourceFiles(directory, { includeHidden: source.includeHidden })) {
2812
+ const name = source.normalizeName ? source.normalizeName(directory, file) : normalizePathDefinitionName(directory, file);
2813
+ if (!name) continue;
2814
+ registerDefinition(definitions, createDefinition(source, file, name), feature);
2578
2815
  }
2579
- return targets;
2580
- }
2581
- if (typeof exportsValue !== "object" || exportsValue === null) return /* @__PURE__ */ new Set();
2582
- const targets = /* @__PURE__ */ new Set();
2583
- for (const [key, value] of Object.entries(exportsValue)) {
2584
- if (key === "types") continue;
2585
- if (!key.startsWith(".") && !runtimeExportConditions.has(key)) continue;
2586
- const entryTargets = collectRuntimeExportTargets(value, key);
2587
- if (!entryTargets) return void 0;
2588
- for (const target of entryTargets) targets.add(target);
2589
2816
  }
2590
- return targets;
2817
+ return sortDefinitions(definitions);
2591
2818
  }
2592
- function hasNodeModulesSegment(path) {
2593
- return path.split(/[\\/]/).includes("node_modules");
2819
+ function discoverDefinitions$1(feature, sources) {
2820
+ return mergeDefinitions(feature, ...sources.map((source) => source.kind === "suffix" ? scanSuffixDefinitions(feature, source) : scanDirectoryDefinitions(feature, source)));
2594
2821
  }
2595
- function isInsideDirectory(parent, child) {
2596
- const childRelativePath = relative(parent, child);
2597
- return childRelativePath === "" || !childRelativePath.startsWith(`..${sep}`) && childRelativePath !== ".." && !isAbsolute(childRelativePath);
2822
+ /**
2823
+ * Writes generated output only when its bytes change. A running dev server watches these files, so an identical
2824
+ * rewrite, for example from a CLI command that loads the project, would rebuild it for nothing.
2825
+ */
2826
+ function writeFileIfChangedSync(file, contents) {
2827
+ if (existsSync(file) && readFileSync(file, "utf8") === contents) return;
2828
+ mkdirSync(resolve$1(file, ".."), { recursive: true });
2829
+ writeFileSync(file, contents, "utf8");
2598
2830
  }
2599
- function parsePackageJson(value, path) {
2600
- if (typeof value !== "object" || value === null || Array.isArray(value)) throw internalErrorDiagnostics.INTERNAL_B0047({ message: `Expected ${path} to contain a JSON object.` });
2601
- return value;
2831
+ /** `writeFileIfChangedSync` for async callers. */
2832
+ async function writeFileIfChanged(file, contents) {
2833
+ if (await readFile(file, "utf8").catch(() => void 0) === contents) return;
2834
+ await mkdir(resolve$1(file, ".."), { recursive: true });
2835
+ await writeFile(file, contents, "utf8");
2602
2836
  }
2603
2837
  //#endregion
2604
2838
  //#region ../internal/src/dev-endpoint.ts
@@ -2793,8 +3027,8 @@ function registerViteHubDevEndpoint(server, options) {
2793
3027
  });
2794
3028
  });
2795
3029
  }
2796
- //#endregion
2797
- //#region ../internal/src/nitro-kit.ts
3030
+ Object.freeze({ vitehubAuthAccess: "handler" });
3031
+ Object.freeze({ vitehubOwnAccess: true });
2798
3032
  function cloneArray(value) {
2799
3033
  return Array.isArray(value) ? [...value] : [];
2800
3034
  }
@@ -15824,7 +16058,7 @@ function fromNumericReference(value) {
15824
16058
  if (value === 0 || value > 1114111 || value >= 55296 && value <= 57343) return "�";
15825
16059
  return String.fromCodePoint(C1[value] ?? value);
15826
16060
  }
15827
- function decodeHTMLAttribute$1(input) {
16061
+ function decodeHTMLAttribute(input) {
15828
16062
  let amp = input.indexOf("&");
15829
16063
  if (amp === -1) return input;
15830
16064
  let out = "";
@@ -15984,7 +16218,7 @@ function parseHtmlInline(content) {
15984
16218
  };
15985
16219
  }
15986
16220
  function decodeAttributeValue(value) {
15987
- return value.includes("&") ? decodeHTMLAttribute$1(value) : value;
16221
+ return value.includes("&") ? decodeHTMLAttribute(value) : value;
15988
16222
  }
15989
16223
  function parseHtmlAttributes(attrsStr) {
15990
16224
  const attrs = {};
@@ -16880,334 +17114,68 @@ function createMarkdownParser$1(options = {}) {
16880
17114
  state.tree = {
16881
17115
  frontmatter: frontmatterText || !isStartsWithLastInput ? frontmatterData : prevOutput?.frontmatter ?? frontmatterData,
16882
17116
  meta: {},
16883
- nodes: [...state.reusableNodes, ...nodes]
16884
- };
16885
- lastOutput = state.tree;
16886
- lastInput = markdown;
16887
- } else {
16888
- state.tree = {
16889
- frontmatter: frontmatterData,
16890
- meta: {},
16891
- nodes
16892
- };
16893
- lastOutput = null;
16894
- lastInput = null;
16895
- }
16896
- for (const plugin of plugins) {
16897
- if (!plugin.post) continue;
16898
- await withSpan(tracer, `comark:post:${plugin.name}`, () => plugin.post(state));
16899
- }
16900
- return state.tree;
16901
- });
16902
- };
16903
- return parseFn;
16904
- }
16905
- //#endregion
16906
- //#region ../../node_modules/.pnpm/comark@0.9.0_katex@0.19.1_shiki@4.5.0/node_modules/comark/dist/index.js
16907
- let warnedLinkifyOption = false;
16908
- function resolveParserOptions(options) {
16909
- const { autoClose = true, tracer = noopTracer, linkify: linkifyOption, ...rest } = options;
16910
- const userPlugins = options.plugins ?? [];
16911
- if (linkifyOption !== void 0 && !warnedLinkifyOption) {
16912
- warnedLinkifyOption = true;
16913
- console.warn("[comark] `ParserOptions.linkify` is deprecated and will be removed in a future major version. Use `registerDefaultPlugins: false` and register `linkify()` from `comark/plugins/linkify` only when needed.");
16914
- }
16915
- const registerDefaults = options.registerDefaultPlugins !== false;
16916
- const plugins = dedupePlugins([...linkifyOption ?? registerDefaults ? [linkify_default()] : [], ...registerDefaults ? [
16917
- frontmatter_default(),
16918
- html_default(),
16919
- alert_default(),
16920
- task_list_default(),
16921
- components_default(),
16922
- attributes_default()
16923
- ] : []], userPlugins);
16924
- const hasPlugin = (name) => plugins.some((plugin) => plugin.name === name);
16925
- const pluginAutoClose = Object.assign({}, ...plugins.map((p) => p.autoClose));
16926
- return {
16927
- ...rest,
16928
- plugins,
16929
- tracer,
16930
- autoClose: autoClose === true ? (markdown, streaming) => autoCloseMarkdown(markdown, {
16931
- ...pluginAutoClose,
16932
- frontmatter: hasPlugin("frontmatter") && streaming,
16933
- syntax: hasPlugin("components"),
16934
- attributes: hasPlugin("components") || hasPlugin("attributes"),
16935
- math: hasPlugin("math"),
16936
- dropTrailingOpeners: streaming === true
16937
- }) : autoClose || void 0
16938
- };
16939
- }
16940
- function createMarkdownParser(options = {}) {
16941
- return createMarkdownParser$1(resolveParserOptions(options));
16942
- }
16943
- async function parseMarkdown(markdown, options = {}) {
16944
- return await createMarkdownParser(options)(markdown);
16945
- }
16946
- //#endregion
16947
- //#region ../../node_modules/.pnpm/comark@0.9.0_katex@0.19.1_shiki@4.5.0/node_modules/comark/dist/plugins/binding.js
16948
- const markdownItInlineBinding = (md, options = {}) => {
16949
- const tag = options.tag || "binding";
16950
- md.inline.ruler.after("entity", "mdc_inline_binding", (state, silent) => {
16951
- const start = state.pos;
16952
- if (state.src[start] !== "{" || state.src[start + 1] !== "{") return false;
16953
- let end = start + 2;
16954
- while (end < state.posMax - 1) {
16955
- if (state.src[end] === "}" && state.src[end + 1] === "}") break;
16956
- end += 1;
16957
- }
16958
- if (end >= state.posMax - 1) return false;
16959
- const inner = state.src.slice(start + 2, end).trim();
16960
- if (!inner) return false;
16961
- const separator = inner.indexOf("||");
16962
- const value = separator === -1 ? inner : inner.slice(0, separator).trim();
16963
- const defaultValue = separator === -1 ? "" : inner.slice(separator + 2).trim();
16964
- if (!value) return false;
16965
- state.pos = end + 2;
16966
- if (silent) return true;
16967
- const token = state.push("mdc_inline_component", tag, 0);
16968
- token.attrSet(":value", value);
16969
- if (defaultValue) token.attrSet("defaultValue", defaultValue);
16970
- return true;
16971
- });
16972
- };
16973
- var binding_default = defineComarkPlugin((opts = {}) => {
16974
- return {
16975
- name: "binding",
16976
- markdownItPlugins: [((md) => markdownItInlineBinding(md, opts))]
16977
- };
16978
- });
16979
- //#endregion
16980
- //#region ../markdown-template/dist/prepare-BUVd_uB_.js
16981
- const dynamicError = { why: ({ message }) => message === void 0 ? "" : String(message) };
16982
- const markdownTemplateErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
16983
- docsBase: "https://vitehub.dev/docs/markdown-template/diagnostics",
16984
- codes: {
16985
- MARKDOWN_TEMPLATE_R0002: {
16986
- ...dynamicError,
16987
- fix: "Bind the condition to a `data.<path>` path that the template may read, or to a JSON literal, such as `:condition=\"data.ready\"`."
16988
- },
16989
- MARKDOWN_TEMPLATE_B0001: {
16990
- ...dynamicError,
16991
- fix: "Pass a path that starts with `./`, ends with `.template.md`, and uses `/` between folders, such as `./review/PULL_REQUEST.template.md`."
16992
- },
16993
- MARKDOWN_TEMPLATE_B0002: {
16994
- ...dynamicError,
16995
- fix: "Remove the empty, `.`, and `..` folders from the path, such as `./review/PULL_REQUEST.template.md` in place of `./review/../PULL_REQUEST.template.md`."
16996
- },
16997
- MARKDOWN_TEMPLATE_R0011: {
16998
- ...dynamicError,
16999
- fix: "Pass a link value in the template data that is a safe URL, such as an `https:` or relative URL without spaces at the ends, control characters, backslashes, or HTML character references."
17000
- },
17001
- MARKDOWN_TEMPLATE_R0012: {
17002
- ...dynamicError,
17003
- fix: "Pass a link value in the template data that is a safe URL, such as an `https:` or relative URL without spaces at the ends, control characters, backslashes, or HTML character references."
17004
- },
17005
- MARKDOWN_TEMPLATE_R0013: {
17006
- ...dynamicError,
17007
- fix: "Pass a link value in the template data that is a safe URL, such as an `https:` or relative URL without spaces at the ends, control characters, backslashes, or HTML character references."
17008
- },
17009
- MARKDOWN_TEMPLATE_R0014: {
17010
- ...dynamicError,
17011
- fix: "Pass the template text as a string to `renderMarkdownTemplate()`, or use `renderMarkdownFile()` with the path of a template file."
17012
- },
17013
- MARKDOWN_TEMPLATE_R0015: {
17014
- ...dynamicError,
17015
- fix: "Write `::else-if` and `::else` blocks only inside the `::if` block that they follow, as in `::if{:condition=\"data.ready\"}` ... `::else` ... `::`."
17016
- },
17017
- MARKDOWN_TEMPLATE_R0017: {
17018
- ...dynamicError,
17019
- fix: "Add the value that the message names to the `data` that you pass to the renderer, or remove its binding from the template."
17020
- },
17021
- MARKDOWN_TEMPLATE_R0018: {
17022
- ...dynamicError,
17023
- fix: "Bind the value that the message names to a string, number, or boolean in `data`, or use `:insert{:markdown=\"data.<path>\"}` for a Markdown fragment."
17024
- },
17025
- MARKDOWN_TEMPLATE_R0020: {
17026
- ...dynamicError,
17027
- fix: "Give each `:insert` a bound `:markdown` prop with an allowed `data.<path>` that holds a Markdown string, such as `:insert{:markdown=\"data.summary\"}`."
17028
- },
17029
- MARKDOWN_TEMPLATE_R0021: {
17030
- ...dynamicError,
17031
- fix: "Put the `:insert` on its own line with blank lines around it, or pass a fragment that is one paragraph."
17032
- },
17033
- MARKDOWN_TEMPLATE_R0022: {
17034
- ...dynamicError,
17035
- fix: "Remove the condition from the `::else` block, or use `::else-if{:condition=\"data.<path>\"}` for a branch with a condition."
17036
- },
17037
- MARKDOWN_TEMPLATE_R0023: {
17038
- ...dynamicError,
17039
- fix: "Put `::else` last in its `::if` block, and move each `::else-if` before it."
17040
- },
17041
- MARKDOWN_TEMPLATE_R0024: {
17042
- ...dynamicError,
17043
- fix: "Give `::if` and `::else-if` a bound `:condition` or `:value` prop, such as `::if{:condition=\"data.ready\"}`, and use only the `eq`, `neq`, `gt`, `gte`, `lt`, and `lte` props next to it."
17044
- },
17045
- MARKDOWN_TEMPLATE_R0025: {
17046
- ...dynamicError,
17047
- fix: "Write `::else-if` and `::else` blocks only inside the `::if` block that they follow, as in `::if{:condition=\"data.ready\"}` ... `::else` ... `::`."
17048
- },
17049
- MARKDOWN_TEMPLATE_R0026: {
17050
- ...dynamicError,
17051
- fix: "Put `::else` last in its `::if` block, and move each `::else-if` before it."
17052
- },
17053
- MARKDOWN_TEMPLATE_R0027: {
17054
- ...dynamicError,
17055
- fix: "Remove the condition from the `::else` block, or use `::else-if{:condition=\"data.<path>\"}` for a branch with a condition."
17056
- },
17057
- MARKDOWN_TEMPLATE_R0029: {
17058
- ...dynamicError,
17059
- fix: "Add a closing `::` line for each `::if`, `::else-if`, and `::else` block of the template."
17060
- },
17061
- MARKDOWN_TEMPLATE_R0030: {
17062
- ...dynamicError,
17063
- fix: "Remove the `:srcdoc` binding from the template, and write the iframe content as static markup."
17064
- },
17065
- MARKDOWN_TEMPLATE_R0031: {
17066
- ...dynamicError,
17067
- fix: "Remove the binding of the HTML event-handler attribute, such as `:onclick`, from the template."
17068
- },
17069
- MARKDOWN_TEMPLATE_R0032: {
17070
- ...dynamicError,
17071
- fix: "Remove the `:style` binding from the template, and use a static `style` attribute or a class."
17072
- },
17073
- MARKDOWN_TEMPLATE_R0033: {
17074
- ...dynamicError,
17075
- fix: "Write the link as `[label](){:href=\"data.<path>\"}` in place of `{{ }}` in the link destination."
17076
- }
17077
- }
17078
- });
17079
- const openTag = /^(\s*<\s*[A-Za-z][\w:-]*)(\s+[\s\S]*?)?(\s*\/?>\s*)$/;
17080
- const attribute = /([:\w.-]+)(\s*=\s*)?(?:"([^"]*)"|'([^']*)'|([^\s"'=<>`]+))?/g;
17081
- /**
17082
- * Comark 0.8 decodes HTML attribute values with the body decoder, so `&copy=2` becomes `©=2`.
17083
- * Browsers leave that reference alone inside attributes. Escape `&` before Comark decodes,
17084
- * so the template receives the authored value and applies attribute decoding itself.
17085
- */
17086
- const rawHtmlAttributes = defineComarkPlugin(() => ({
17087
- name: "vitehub-raw-html-attributes",
17088
- markdownItPost(state) {
17089
- const visit = (tokens) => {
17090
- for (const token of tokens) {
17091
- if (token.type === "html_inline") token.content = escapeAttributeValues(token.content);
17092
- if (token.children) visit(token.children);
17117
+ nodes: [...state.reusableNodes, ...nodes]
17118
+ };
17119
+ lastOutput = state.tree;
17120
+ lastInput = markdown;
17121
+ } else {
17122
+ state.tree = {
17123
+ frontmatter: frontmatterData,
17124
+ meta: {},
17125
+ nodes
17126
+ };
17127
+ lastOutput = null;
17128
+ lastInput = null;
17093
17129
  }
17094
- };
17095
- visit(state.tokens);
17096
- }
17097
- }));
17098
- function escapeAttributeValues(tag) {
17099
- const match = tag.match(openTag);
17100
- if (!match?.[2]?.includes("&")) return tag;
17101
- const attributes = match[2].replace(attribute, (source, name, equals, double, single, bare) => {
17102
- if (!equals) return source;
17103
- const escape = (value) => value.replaceAll("&", "&amp;");
17104
- if (double !== void 0) return `${name}${equals}"${escape(double)}"`;
17105
- if (single !== void 0) return `${name}${equals}'${escape(single)}'`;
17106
- return bare === void 0 ? source : `${name}${equals}${escape(bare)}`;
17107
- });
17108
- return `${match[1]}${attributes}${match[3]}`;
17130
+ for (const plugin of plugins) {
17131
+ if (!plugin.post) continue;
17132
+ await withSpan(tracer, `comark:post:${plugin.name}`, () => plugin.post(state));
17133
+ }
17134
+ return state.tree;
17135
+ });
17136
+ };
17137
+ return parseFn;
17109
17138
  }
17110
- const comarkHtml = html_default({ markdown: false });
17111
- /** Plugins that keep authored HTML blocks raw and their attributes undecoded, as the template renderer expects. */
17112
- const htmlPlugins = [{
17113
- ...comarkHtml,
17114
- markdownItPost(state) {
17115
- for (const [index, token] of state.tokens.entries()) {
17116
- const first = token.children?.[0];
17117
- if (token.type !== "inline" || state.tokens[index - 1]?.type !== "paragraph_open" || first?.type !== "html_inline") continue;
17118
- token.children.unshift(Object.assign(Object.create(Object.getPrototypeOf(first)), first, {
17119
- type: "text",
17120
- content: ""
17121
- }));
17122
- }
17123
- comarkHtml.markdownItPost?.(state);
17139
+ //#endregion
17140
+ //#region ../../node_modules/.pnpm/comark@0.9.0_katex@0.19.1_shiki@4.5.0/node_modules/comark/dist/index.js
17141
+ let warnedLinkifyOption = false;
17142
+ function resolveParserOptions(options) {
17143
+ const { autoClose = true, tracer = noopTracer, linkify: linkifyOption, ...rest } = options;
17144
+ const userPlugins = options.plugins ?? [];
17145
+ if (linkifyOption !== void 0 && !warnedLinkifyOption) {
17146
+ warnedLinkifyOption = true;
17147
+ console.warn("[comark] `ParserOptions.linkify` is deprecated and will be removed in a future major version. Use `registerDefaultPlugins: false` and register `linkify()` from `comark/plugins/linkify` only when needed.");
17124
17148
  }
17125
- }, rawHtmlAttributes()];
17126
- const parserOptions = {
17127
- autoClose: false,
17128
- autoUnwrap: false,
17129
- linkify: false,
17130
- plugins: [...htmlPlugins, binding_default()]
17131
- };
17132
- const literalHtmlTags$1 = /* @__PURE__ */ new Set([
17133
- "code",
17134
- "pre",
17135
- "script",
17136
- "style",
17137
- "textarea",
17138
- "kbd",
17139
- "samp",
17140
- "var"
17141
- ]);
17142
- /** Whether authored HTML children are reparsed as Markdown by the template renderer. */
17143
- function hasMarkdownHtmlChildren([tag, attrs, ...children]) {
17144
- return attrs.$?.html === 1 && attrs.$?.block === 1 && tag !== "a" && tag !== "img" && !literalHtmlTags$1.has(tag) && children.every((child) => typeof child === "string");
17145
- }
17146
- const literalHtmlTags = /* @__PURE__ */ new Set([
17147
- "code",
17148
- "pre",
17149
- "script",
17150
- "style",
17151
- "textarea",
17152
- "kbd",
17153
- "samp",
17154
- "var"
17155
- ]);
17156
- async function prepareTemplate(source) {
17157
- const prefix = `VITEHUBCODE${crypto.randomUUID().replaceAll("-", "")}`;
17158
- const lines = [];
17159
- const masked = source.replace(/^([\t ]*)(:[^\r\n]*)$/gm, (_match, indent, line) => `${indent}${prefix}${lines.push(line) - 1}END`);
17160
- const pattern = new RegExp(`${prefix}(\\d+)END`, "g");
17161
- const inCode = /* @__PURE__ */ new Set();
17162
- const visit = (nodes, literal = false) => {
17163
- for (const node of nodes) if (typeof node === "string") {
17164
- if (literal) for (const match of node.matchAll(pattern)) inCode.add(Number(match[1]));
17165
- } else visit(node.slice(2), literal || node[0] !== null && literalHtmlTags.has(node[0]));
17166
- };
17167
- if (lines.length) visit((await parseMarkdown(masked, {
17168
- autoClose: false,
17169
- autoUnwrap: false,
17170
- linkify: false,
17171
- plugins: htmlPlugins
17172
- })).nodes);
17173
- const template = masked.replace(pattern, (token, index) => inCode.has(Number(index)) ? token : lines[Number(index)]);
17174
- validateBranches(template);
17149
+ const registerDefaults = options.registerDefaultPlugins !== false;
17150
+ const plugins = dedupePlugins([...linkifyOption ?? registerDefaults ? [linkify_default()] : [], ...registerDefaults ? [
17151
+ frontmatter_default(),
17152
+ html_default(),
17153
+ alert_default(),
17154
+ task_list_default(),
17155
+ components_default(),
17156
+ attributes_default()
17157
+ ] : []], userPlugins);
17158
+ const hasPlugin = (name) => plugins.some((plugin) => plugin.name === name);
17159
+ const pluginAutoClose = Object.assign({}, ...plugins.map((p) => p.autoClose));
17175
17160
  return {
17176
- template,
17177
- restore: (rendered) => rendered.replace(pattern, (_token, index) => lines[Number(index)])
17161
+ ...rest,
17162
+ plugins,
17163
+ tracer,
17164
+ autoClose: autoClose === true ? (markdown, streaming) => autoCloseMarkdown(markdown, {
17165
+ ...pluginAutoClose,
17166
+ frontmatter: hasPlugin("frontmatter") && streaming,
17167
+ syntax: hasPlugin("components"),
17168
+ attributes: hasPlugin("components") || hasPlugin("attributes"),
17169
+ math: hasPlugin("math"),
17170
+ dropTrailingOpeners: streaming === true
17171
+ }) : autoClose || void 0
17178
17172
  };
17179
17173
  }
17180
- function validateBranches(template) {
17181
- const stack = [];
17182
- for (const line of template.split(/\r?\n/)) {
17183
- if (/^\s*::\s*$/.test(line)) {
17184
- stack.pop();
17185
- continue;
17186
- }
17187
- const match = line.match(/^\s*::([\w-]+)(?:\{(.*)\})?\s*$/);
17188
- if (!match) continue;
17189
- const tag = match[1];
17190
- if (tag !== "else" && tag !== "else-if") {
17191
- stack.push({
17192
- tag,
17193
- sawElse: false
17194
- });
17195
- continue;
17196
- }
17197
- const current = stack.at(-1);
17198
- if (current?.tag === "else") throw markdownTemplateErrorDiagnostics.MARKDOWN_TEMPLATE_R0026({ message: `[vitehub] Markdown template ${tag} block cannot follow else.` });
17199
- if (current?.tag !== "if" && current?.tag !== "else-if") throw markdownTemplateErrorDiagnostics.MARKDOWN_TEMPLATE_R0025({ message: `[vitehub] Markdown template ${tag} block must follow an if block.` });
17200
- if (current.sawElse) throw markdownTemplateErrorDiagnostics.MARKDOWN_TEMPLATE_R0026({ message: `[vitehub] Markdown template ${tag} block cannot follow else.` });
17201
- if (tag === "else") {
17202
- if (match[2]?.trim()) throw markdownTemplateErrorDiagnostics.MARKDOWN_TEMPLATE_R0027({ message: "[vitehub] Markdown template else block does not accept a condition." });
17203
- current.sawElse = true;
17204
- }
17205
- stack.push({
17206
- tag,
17207
- sawElse: false
17208
- });
17209
- }
17210
- if (stack.some((entry) => entry.tag === "if" || entry.tag === "else-if" || entry.tag === "else")) throw markdownTemplateErrorDiagnostics.MARKDOWN_TEMPLATE_R0029({ message: "[vitehub] Markdown template if block is missing a closing :: line." });
17174
+ function createMarkdownParser(options = {}) {
17175
+ return createMarkdownParser$1(resolveParserOptions(options));
17176
+ }
17177
+ async function parseMarkdown(markdown, options = {}) {
17178
+ return await createMarkdownParser(options)(markdown);
17211
17179
  }
17212
17180
  //#endregion
17213
17181
  //#region ../../node_modules/.pnpm/comark@0.9.0_katex@0.19.1_shiki@4.5.0/node_modules/comark/dist/internal/stringify/state.js
@@ -18156,587 +18124,146 @@ async function renderMarkdown(document, options) {
18156
18124
  return renderFrontmatter(document.frontmatter || {}, content, options?.frontmatterOptions);
18157
18125
  }
18158
18126
  //#endregion
18159
- //#region ../../node_modules/.pnpm/entities@8.1.0/node_modules/entities/dist/decode-codepoint.js
18160
- /**
18161
- * C1 Unicode control character reference replacements (code points 128–159).
18162
- * Index i gives the replacement for code point 128+i; 0 means "no replacement".
18163
- */
18164
- const c1 = [
18165
- 8364,
18166
- 0,
18167
- 8218,
18168
- 402,
18169
- 8222,
18170
- 8230,
18171
- 8224,
18172
- 8225,
18173
- 710,
18174
- 8240,
18175
- 352,
18176
- 8249,
18177
- 338,
18178
- 0,
18179
- 381,
18180
- 0,
18181
- 0,
18182
- 8216,
18183
- 8217,
18184
- 8220,
18185
- 8221,
18186
- 8226,
18187
- 8211,
18188
- 8212,
18189
- 732,
18190
- 8482,
18191
- 353,
18192
- 8250,
18193
- 339,
18194
- 0,
18195
- 382,
18196
- 376
18197
- ];
18198
- /**
18199
- * True for NUL, UTF-16 surrogates, and values past U+10FFFF.
18200
- * @param codePoint Unicode code point to check.
18201
- */
18202
- function isInvalidCodePoint(codePoint) {
18203
- return codePoint === 0 || codePoint >= 55296 && codePoint <= 57343 || codePoint > 1114111;
18204
- }
18205
- /**
18206
- * Replace the given code point with U+FFFD if it is NUL (0), a surrogate, or
18207
- * outside the valid Unicode range. Code points in the C1 controls range
18208
- * (128–159) are remapped to their Windows-1252 equivalents, following the
18209
- * HTML spec. All other code points are returned unchanged.
18210
- * @param codePoint Unicode code point to convert.
18211
- */
18212
- function replaceCodePoint(codePoint) {
18213
- if (isInvalidCodePoint(codePoint)) return 65533;
18214
- if (codePoint >= 128 && codePoint <= 159) return c1[codePoint - 128] || codePoint;
18215
- return codePoint;
18216
- }
18217
- /**
18218
- * Convert the code point of a decoded numeric entity to a string, replacing
18219
- * invalid values.
18220
- *
18221
- * Fast path for plain BMP code points: [1..0x7F] and [0xA0..0xD7FF] pass
18222
- * `replaceCodePoint` unchanged (no NUL, C1 remap, surrogate, or out-of-range
18223
- * handling) and fit a single charCode. 0xd760 = 0xD800 (the first surrogate)
18224
- * - 0xA0.
18225
- * @param codePoint Unicode code point to convert.
18226
- */
18227
- function codePointToString(codePoint) {
18228
- return codePoint - 1 >>> 0 < 127 || codePoint - 160 >>> 0 < 55136 ? String.fromCharCode(codePoint) : String.fromCodePoint(replaceCodePoint(codePoint));
18229
- }
18230
- //#endregion
18231
- //#region ../../node_modules/.pnpm/entities@8.1.0/node_modules/entities/dist/internal/decode-shared.js
18232
- const BASE91_INVERSE = /* #__PURE__ */ (() => {
18233
- const table = /* @__PURE__ */ new Uint8Array(127);
18234
- let code = 0;
18235
- for (let char = 33; char <= 126; char++) if (char !== 34 && char !== 36 && char !== 92) table[char] = code++;
18236
- return table;
18237
- })();
18238
- /**
18239
- * Decode a dictionary-encoded trie string back into its Uint16Array.
18240
- *
18241
- * Stream layout (consumed in this order):
18242
- * 1. dict1 atoms — `dict1AtomCount` uint16 values, delta+RLE encoded.
18243
- * 2. dict2 atoms — `atomCount - dict1AtomCount` values, delta+RLE.
18244
- * 3. dict2 ngrams — `ngramCount - (dictSize - dict1AtomCount)` entries,
18245
- * each a pair of slot codes that resolve to earlier slots.
18246
- * 4. dict1 ngrams — `dictSize - dict1AtomCount` entries, same shape.
18247
- * 5. data — slot codes, each expanding to one or more uint16 values.
18248
- *
18249
- * Codes use a 91-char base (printable ASCII minus `"`, `$`, `\`):
18250
- * - char1 < dictSize → 1-char code, slot = char1
18251
- * - char1 ≥ dictSize → 2-char code, slot = dictSize + (char1 - dictSize)*91 + char2
18252
- *
18253
- * Slot index → token kind:
18254
- * [0, A) dict1 atoms (1-char codes)
18255
- * [A, dictSize) dict1 ngrams (1-char codes)
18256
- * [dictSize, dictSize+D) dict2 atoms (2-char codes)
18257
- * [dictSize+D, end) dict2 ngrams (2-char codes)
18258
- *
18259
- * Both atom dicts decode before any ngram, and dict2 ngrams decode before
18260
- * dict1 ngrams. So every ngram entry references slots whose contents are
18261
- * already filled — no forward references to handle.
18262
- *
18263
- * This runs on library import. Flat typed arrays store each slot as either
18264
- * a plain value (`single`, covering every atom) or a range in a shared
18265
- * `pool` (ngrams).
18266
- * @param input Packed trie string.
18267
- * @param resultLength Expected number of uint16 values in the output.
18268
- * @param atomCount Total number of distinct uint16 values in the trie.
18269
- * @param dict1AtomCount Atoms in the 1-char range (`A` above).
18270
- * @param ngramCount Total number of ngram entries (dict1 + dict2).
18271
- * @param dictSize Number of 1-char code slots; the rest of `BASE - dictSize`
18272
- * first-byte values are 2-char codes.
18273
- */
18274
- function decodeTrieDict(input, resultLength, atomCount, dict1AtomCount, ngramCount, dictSize) {
18275
- const base = 91;
18276
- const inputLength = input.length;
18277
- const twoCharBias = dictSize * 90;
18278
- let pos = 0;
18279
- /** Read one slot code at `pos` and return its slot index, advancing pos. */
18280
- const readSlotCode = () => {
18281
- const c1 = BASE91_INVERSE[input.charCodeAt(pos++)];
18282
- return c1 < dictSize ? c1 : c1 * base - twoCharBias + BASE91_INVERSE[input.charCodeAt(pos++)];
18283
- };
18284
- const dict2AtomCount = atomCount - dict1AtomCount;
18285
- const slotCount = atomCount + ngramCount;
18286
- const single = new Int32Array(slotCount);
18287
- single.fill(-1, dict1AtomCount, dictSize);
18288
- single.fill(-1, dictSize + dict2AtomCount, slotCount);
18289
- const start = new Int32Array(slotCount);
18290
- const length = new Int32Array(slotCount);
18291
- /**
18292
- * Decode `count` ascending uint16 values from a delta+RLE stream into
18293
- * `single[off..off+count)`.
18294
- *
18295
- * code < 89 → delta = code
18296
- * code == 89 → run-length: next char encodes runLength-2; emit `runLength` consecutive +1 values
18297
- * code == 90, next < 90 → escape: delta = 89 + next * BASE + after-next
18298
- * code == 90, next == 90 → double-escape: extra char for very large deltas
18299
- * @param count
18300
- * @param off
18301
- */
18302
- function decodeDelta(count, off) {
18303
- let previous = 0;
18304
- let slot = off;
18305
- const end = off + count;
18306
- while (slot < end) {
18307
- const code = BASE91_INVERSE[input.charCodeAt(pos++)];
18308
- if (code < 89) {
18309
- previous += code;
18310
- single[slot++] = previous;
18311
- } else if (code === 89) {
18312
- let runLength = BASE91_INVERSE[input.charCodeAt(pos++)] + 2;
18313
- while (runLength--) single[slot++] = ++previous;
18314
- } else {
18315
- const next = BASE91_INVERSE[input.charCodeAt(pos++)];
18316
- previous += 89 + (next < 90 ? next * base + BASE91_INVERSE[input.charCodeAt(pos++)] : BASE91_INVERSE[input.charCodeAt(pos++)] * 8281 + BASE91_INVERSE[input.charCodeAt(pos++)] * base + BASE91_INVERSE[input.charCodeAt(pos++)]);
18317
- single[slot++] = previous;
18318
- }
18319
- }
18320
- }
18321
- decodeDelta(dict1AtomCount, 0);
18322
- decodeDelta(dict2AtomCount, dictSize);
18323
- const references = new Int32Array(ngramCount * 2);
18324
- let poolSize = 0;
18325
- let ngramIndex = 0;
18326
- /**
18327
- * Read `count` ngram entries (each = 2 slot-code references) for the slots
18328
- * starting at `startSlot`, recording references and assigning pool ranges.
18329
- * @param count
18330
- * @param startSlot
18331
- */
18332
- function readNgramReferences(count, startSlot) {
18333
- for (let index = 0; index < count; index++) {
18334
- const slot = startSlot + index;
18335
- const a = readSlotCode();
18336
- const b = readSlotCode();
18337
- references[ngramIndex * 2] = a;
18338
- references[ngramIndex * 2 + 1] = b;
18339
- ngramIndex += 1;
18340
- start[slot] = poolSize;
18341
- const entryLength = (single[a] < 0 ? length[a] : 1) + (single[b] < 0 ? length[b] : 1);
18342
- length[slot] = entryLength;
18343
- poolSize += entryLength;
18344
- }
18345
- }
18346
- readNgramReferences(ngramCount - dictSize + dict1AtomCount, dictSize + dict2AtomCount);
18347
- readNgramReferences(dictSize - dict1AtomCount, dict1AtomCount);
18348
- const pool = new Uint16Array(poolSize);
18349
- let write = 0;
18350
- for (let index = 0; index < ngramIndex; index++) for (let half = 0; half < 2; half++) {
18351
- const source = references[index * 2 + half];
18352
- const value = single[source];
18353
- if (value < 0) {
18354
- let read = start[source];
18355
- const readEnd = read + length[source];
18356
- while (read < readEnd) pool[write++] = pool[read++];
18357
- } else pool[write++] = value;
18358
- }
18359
- const out = new Uint16Array(resultLength);
18360
- let outIndex = 0;
18361
- while (pos < inputLength) {
18362
- let slot = BASE91_INVERSE[input.charCodeAt(pos++)];
18363
- if (slot >= dictSize) slot = slot * base - twoCharBias + BASE91_INVERSE[input.charCodeAt(pos++)];
18364
- const value = single[slot];
18365
- if (value < 0) {
18366
- let read = start[slot];
18367
- const readEnd = read + length[slot];
18368
- while (read < readEnd) out[outIndex++] = pool[read++];
18369
- } else out[outIndex++] = value;
18370
- }
18371
- return out;
18372
- }
18373
- //#endregion
18374
- //#region ../../node_modules/.pnpm/entities@8.1.0/node_modules/entities/dist/generated/decode-data-html.js
18375
- /** Packed HTML decode trie data. */
18376
- const htmlDecodeTree = /* #__PURE__ */ decodeTrieDict("!}.&u%}'&}*'~!6*)%&,~!J~!J~%L~y<~!R,~~%Lu~~#GD~~#|)1#%}^%}2%+#.##%##%}&%##%'#%##&%#%#'%#&#%#&#'#%%#&#%##%#)%''%&%#%#'%#%%#%%}%%%#%#&(23#%%#&-%0%('1#(##%#'##+%'*.:1}#%#6-+(%'%%#%%%}#L'2351&('%}&/N'(0(/*-%(%%}#'+&T%7.2}#&%&#%#36/5##%&%%#&#%%#))2%%##%&&'0~!#*+&'%1~!%).'3q?&%'1~!.##%6(~!+%%%(Gw'rT~!E#<nA%#jZ~!H%(~!42##~!*31&~!G%U~#)5~#`3~!J~!Z~%]~%Y~%C~!q~!u~#kz~%#~!6'~!D~!U~!?~#T~!c%~!G#'~%7|~!G~!J~!G&~#pb~(Df}#%}*&}#%##%##%##&#-}&'#'&%#.++}%mI,#,@&(}*%}*'%&##&#%##%}&0}#.},U},%}+%}&%}#%##&}B%(}(%}+%)})%##%#&}&%##%&}<%}>%#%&}*%}(%}9%}/%})%}*%}*%}?&}&%}3%}&*#%})%#%#)}#&#-#+*%E%%'%'#%}#*V##&##I}#&&##%&%#&&Qf%%))w/0+&%#(#.%-''''++++7}>%4'',##1,#%#&%##&#'##&#*#9)%&%}#*}%,#+P(%A&%#'&##wSD',9E00#y#@}(+}&%&>~!#~!X}#*}(&&}(&}(,%}%&#+&}#&}I%#%}%)#(},'%#*}4%%#%}(''}#/##(##),%-##%%)#&}(.}&%#&}%%}*&#%},&&}&%}#%*'#%})%}D&}&%}-&}6&#&}-,%}#%})-(~+`~,=?~I9'9%~!,#%})%})%}@%}?%}(~!?~#<~#pP~#BG~#=1#%K+~#?#~%;)~#A~#mF1~#A'~'X%'~#lR~#N~'N~#r~#m#-~#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5Abb|L~@:RhK9:4E|0@52B5G|#C::aY?C2F|-:2<BaY?C2F|.5Jvk!a)javYrquJu3x4ia#T)2@SmYM?C2F|HAxPhH(!a#U#`a*-5Abb|4~@:RhJ9:4E|R@52B5G|F:2<BaY?C2F|Sc^#Xa2j=Qq5CJvB!-g<v{z;hhM?C2F|Zi[vrv{z;hiM?C2F|XKsA>!a)-g<v{z;h[eb?C2F|]i[vrv{z;h]eb?C2F|^iZu.vix,hZq3ah!.(?C2F|QOu!5ShXM:2<BaY?C2F|P", 13494, 2713, 49, 25, 61);
18377
- //#endregion
18378
- //#region ../../node_modules/.pnpm/entities@8.1.0/node_modules/entities/dist/internal/bin-trie-flags.js
18379
- /**
18380
- * Bit flags & masks for the binary trie encoding used for entity decoding.
18381
- *
18382
- * The trie is a flat `Uint16Array`. Every node starts with one header word:
18383
- *
18384
- * 15..14 VALUE_LENGTH Number of words the value occupies, +1.
18385
- * 0 = no value; 1 = value inline in bits 12..0;
18386
- * 2/3 = value in the 1/2 words after the header.
18387
- * 13 FLAG13 If VALUE_LENGTH > 0: semicolon required ("strict"
18388
- * entity; `;` is never stored as a branch).
18389
- * If VALUE_LENGTH == 0: this node is a compact run.
18390
- * 12..7 BRANCH_LENGTH Number of branches (or run length for runs).
18391
- * 6..0 JUMP_TABLE Jump-table offset / single-branch char / first
18392
- * run char (see below).
18393
- *
18394
- * Branch data follows the header and any value words. Its shape is selected
18395
- * by (JUMP_TABLE, BRANCH_LENGTH) in the header:
18396
- *
18397
- * Single branch JUMP_TABLE = the only child's char, BRANCH_LENGTH = 0.
18398
- * No branch words; the child node follows immediately.
18399
- * Jump table JUMP_TABLE = first covered char (> 0), BRANCH_LENGTH =
18400
- * table length. One word per covered char: 0 = no branch,
18401
- * otherwise the child's offset from the END of the table,
18402
- * +1 (so 0 stays the no-branch sentinel).
18403
- * Dictionary JUMP_TABLE = 0, BRANCH_LENGTH = number of branches.
18404
- * ceil(n/2) words of sorted keys packed two per word
18405
- * (low byte first), then n pointer words storing the
18406
- * child's offset from the END of the branch data.
18407
- * Compact run VALUE_LENGTH = 0, FLAG13 set. BRANCH_LENGTH = run
18408
- * length (3..63), JUMP_TABLE = first char; remaining run
18409
- * chars packed two per word after the header. The target
18410
- * node follows the packed words immediately.
18411
- *
18412
- * Pointers are end-relative (rather than relative to the pointer's own
18413
- * position) because that makes the common "child encoded right after the
18414
- * branch data" case a small constant, which compresses far better. Offsets
18415
- * to already-encoded (shared) nodes wrap via uint16 modulo arithmetic; the
18416
- * decoder masks navigation results with `& 0xff_ff` to match.
18417
- */
18418
- var BinTrieFlags;
18419
- (function(BinTrieFlags) {
18420
- BinTrieFlags[BinTrieFlags["VALUE_LENGTH"] = 49152] = "VALUE_LENGTH";
18421
- BinTrieFlags[BinTrieFlags["FLAG13"] = 8192] = "FLAG13";
18422
- BinTrieFlags[BinTrieFlags["BRANCH_LENGTH"] = 8064] = "BRANCH_LENGTH";
18423
- BinTrieFlags[BinTrieFlags["JUMP_TABLE"] = 127] = "JUMP_TABLE";
18424
- /** Bits 12..0: the inline value of a VALUE_LENGTH = 1 header word. */
18425
- BinTrieFlags[BinTrieFlags["VALUE_MASK"] = 8191] = "VALUE_MASK";
18426
- })(BinTrieFlags || (BinTrieFlags = {}));
18427
- //#endregion
18428
- //#region ../../node_modules/.pnpm/entities@8.1.0/node_modules/entities/dist/decode.js
18429
- var CharCodes;
18430
- (function(CharCodes) {
18431
- CharCodes[CharCodes["AMP"] = 38] = "AMP";
18432
- CharCodes[CharCodes["NUM"] = 35] = "NUM";
18433
- CharCodes[CharCodes["SEMI"] = 59] = "SEMI";
18434
- CharCodes[CharCodes["EQUALS"] = 61] = "EQUALS";
18435
- CharCodes[CharCodes["ZERO"] = 48] = "ZERO";
18436
- CharCodes[CharCodes["NINE"] = 57] = "NINE";
18437
- CharCodes[CharCodes["LOWER_A"] = 97] = "LOWER_A";
18438
- CharCodes[CharCodes["LOWER_X"] = 120] = "LOWER_X";
18439
- })(CharCodes || (CharCodes = {}));
18440
- /** Bit that needs to be set to convert an upper case ASCII character to lower case */
18441
- const TO_LOWER_BIT = 32;
18442
- const CONSUMED_SHIFT = 21;
18443
- const CODE_POINT_MASK = 2097151;
18444
- /**
18445
- * Reserved consumed field for counts of at least 2047 characters after `&`.
18446
- * The true count is in `longNumericConsumed`.
18447
- */
18448
- const CONSUMED_OVERFLOW = 2047;
18449
- /**
18450
- * Side channel for numeric entities of at least 2048 characters including
18451
- * `&`. Set by `parseNumericEntity` when its consumed count reaches the
18452
- * reserved value `CONSUMED_OVERFLOW`; callers read the true count from here.
18453
- * A module-level slot avoids a tuple allocation on the hot path.
18454
- */
18455
- let longNumericConsumed = 0;
18456
- /**
18457
- * Extract the consumed count from a `parseNumericEntity` packed result,
18458
- * recovering the true length from `longNumericConsumed` when the packed
18459
- * field contains the sentinel. Read it before the next `parseNumericEntity`
18460
- * call, which may overwrite the side channel. This helper owns that protocol.
18461
- * @param packed Packed result of `parseNumericEntity`.
18462
- */
18463
- function unpackConsumed(packed) {
18464
- const consumed = packed >>> CONSUMED_SHIFT;
18465
- return consumed === CONSUMED_OVERFLOW ? longNumericConsumed : consumed;
18466
- }
18467
- /**
18468
- * Unsigned subtraction trick: (code - lo) >>> 0 wraps negatives to large
18469
- * values, so a single `<=` covers the entire [lo..hi] range check.
18470
- * @param code Code point to check.
18471
- */
18472
- function isNumber(code) {
18473
- return code - CharCodes.ZERO >>> 0 <= 9;
18474
- }
18475
- function isHexadecimalCharacter(code) {
18476
- return (code | TO_LOWER_BIT) - CharCodes.LOWER_A >>> 0 <= 5;
18477
- }
18478
- function isAlpha(code) {
18479
- return (code | TO_LOWER_BIT) - CharCodes.LOWER_A >>> 0 <= 25;
18480
- }
18481
- /**
18482
- * Checks if the given character is a valid end character for an entity in an attribute.
18483
- *
18484
- * Attribute values that aren't terminated properly aren't parsed, and shouldn't lead to a parser error.
18485
- * See the example in https://html.spec.whatwg.org/multipage/parsing.html#named-character-reference-state
18486
- * @param code Code point to check.
18487
- */
18488
- function isEntityInAttributeInvalidEnd(code) {
18489
- return code === CharCodes.EQUALS || isAlpha(code) || isNumber(code);
18490
- }
18491
- var EntityDecoderState;
18492
- (function(EntityDecoderState) {
18493
- EntityDecoderState[EntityDecoderState["EntityStart"] = 0] = "EntityStart";
18494
- EntityDecoderState[EntityDecoderState["NumericStart"] = 1] = "NumericStart";
18495
- EntityDecoderState[EntityDecoderState["NumericDecimal"] = 2] = "NumericDecimal";
18496
- EntityDecoderState[EntityDecoderState["NumericHex"] = 3] = "NumericHex";
18497
- EntityDecoderState[EntityDecoderState["NamedEntity"] = 4] = "NamedEntity";
18498
- })(EntityDecoderState || (EntityDecoderState = {}));
18499
- /**
18500
- * Decoding mode for named entities.
18501
- */
18502
- var DecodingMode;
18503
- (function(DecodingMode) {
18504
- /** Entities in text nodes that can end with any character. */
18505
- DecodingMode[DecodingMode["Legacy"] = 0] = "Legacy";
18506
- /** Only allow entities terminated with a semicolon. */
18507
- DecodingMode[DecodingMode["Strict"] = 1] = "Strict";
18508
- /** Entities in attributes have limitations on ending characters. */
18509
- DecodingMode[DecodingMode["Attribute"] = 2] = "Attribute";
18510
- })(DecodingMode || (DecodingMode = {}));
18511
- /**
18512
- * Determines the branch of the current node that is taken given the current
18513
- * character. This function is used to traverse the trie.
18514
- *
18515
- * See `BinTrieFlags` for the branch-data layouts handled here.
18516
- * @param decodeTree The trie.
18517
- * @param current The current node's header word.
18518
- * @param nodeIndex Index of the node's first branch-data word (the header
18519
- * plus any value words have been skipped by the caller).
18520
- * @param char The current character.
18521
- * @returns The index of the next node, or -1 if no branch is taken.
18522
- */
18523
- function determineBranch(decodeTree, current, nodeIndex, char) {
18524
- const branchCount = (current & BinTrieFlags.BRANCH_LENGTH) >> 7;
18525
- const jumpOffset = current & BinTrieFlags.JUMP_TABLE;
18526
- if (jumpOffset) {
18527
- if (branchCount === 0) return char === jumpOffset ? nodeIndex : -1;
18528
- const slot = char - jumpOffset;
18529
- if (slot >>> 0 >= branchCount) return -1;
18530
- const stored = decodeTree[nodeIndex + slot];
18531
- return stored === 0 ? -1 : nodeIndex + branchCount + stored - 1 & 65535;
18532
- }
18533
- if (branchCount === 0) return -1;
18534
- const packedKeySlots = branchCount + 1 >> 1;
18535
- const branchEnd = nodeIndex + packedKeySlots + branchCount;
18536
- for (let index = 0; index < branchCount; index++) {
18537
- const key = decodeTree[nodeIndex + (index >> 1)] >> ((index & 1) << 3) & 255;
18538
- if (key === char) return branchEnd + decodeTree[nodeIndex + packedKeySlots + index] & 65535;
18539
- if (key > char) return -1;
18540
- }
18541
- return -1;
18542
- }
18543
- /**
18544
- * Read the decoded value from a trie node.
18545
- * @param decodeTree The trie.
18546
- * @param nodeIndex The index of the node.
18547
- * @param valueLength The length of the value (1, 2, or 3).
18548
- * @returns The decoded string.
18549
- */
18550
- function readTrieValue(decodeTree, nodeIndex, valueLength) {
18551
- if (valueLength === 1) return String.fromCharCode(decodeTree[nodeIndex] & BinTrieFlags.VALUE_MASK);
18552
- if (valueLength === 2) return String.fromCharCode(decodeTree[nodeIndex + 1]);
18553
- return String.fromCharCode(decodeTree[nodeIndex + 1], decodeTree[nodeIndex + 2]);
18554
- }
18555
- /**
18556
- * Parse a numeric entity (`&#DDD;` or `&#xHHH;`).
18557
- *
18558
- * Encodes the result as `(consumed << CONSUMED_SHIFT) | codepoint` (see
18559
- * the packing comment at the top of the file; overlong entities spill
18560
- * their length into `longNumericConsumed`). Returns 0 when no digits were
18561
- * found.
18562
- *
18563
- * This is the sync counterpart of the streaming
18564
- * `EntityDecoder#stateNumericDecimal` / `#stateNumericHex`. Digit parsing
18565
- * matches those methods; only this packed result needs a value clamp.
18566
- * @param input The input string.
18567
- * @param numberStart Index of the `#` character.
18568
- * @param inputLength Cached `input.length`.
18569
- */
18570
- function parseNumericEntity(input, numberStart, inputLength) {
18571
- let offset = numberStart + 1;
18572
- let cp = 0;
18573
- let digitStart = offset;
18574
- if (offset < inputLength && (input.charCodeAt(offset) | TO_LOWER_BIT) === CharCodes.LOWER_X) {
18575
- offset += 1;
18576
- digitStart = offset;
18577
- while (offset < inputLength) {
18578
- const char = input.charCodeAt(offset);
18579
- if (isNumber(char)) cp = cp * 16 + (char - CharCodes.ZERO);
18580
- else if (isHexadecimalCharacter(char)) cp = cp * 16 + ((char | TO_LOWER_BIT) - CharCodes.LOWER_A + 10);
18581
- else break;
18582
- offset += 1;
18583
- }
18584
- } else while (offset < inputLength) {
18585
- const digit = input.charCodeAt(offset) - CharCodes.ZERO;
18586
- if (digit >>> 0 > 9) break;
18587
- cp = cp * 10 + digit;
18588
- offset += 1;
18589
- }
18590
- if (offset === digitStart) return 0;
18591
- if (offset < inputLength && input.charCodeAt(offset) === CharCodes.SEMI) offset += 1;
18592
- if (cp > 1114111) cp = 1114112;
18593
- let consumed = offset - numberStart;
18594
- if (consumed >= CONSUMED_OVERFLOW) {
18595
- longNumericConsumed = consumed;
18596
- consumed = CONSUMED_OVERFLOW;
18597
- }
18598
- return consumed << CONSUMED_SHIFT | cp;
18599
- }
18600
- /**
18601
- * Decode all entities in `input` using the HTML trie.
18602
- *
18603
- * Hard-wired to `htmlDecodeTree`: the inline root navigation below assumes
18604
- * the HTML root's jump-table shape, so this must not be generalized to
18605
- * other tries (the XML trie's dictionary root would silently match no
18606
- * entities — `decodeXML` has its own hand-coded fast path instead).
18607
- * @param input The string to decode.
18608
- * @param isStrict Only match semicolon-terminated entities.
18609
- * @param isAttribute Whether to apply attribute-specific parsing rules (disallowing certain non-semicolon terminators).
18610
- * @returns The decoded string.
18611
- */
18612
- function decodeWithTrie(input, isStrict, isAttribute) {
18613
- const decodeTree = htmlDecodeTree;
18614
- let offset = input.indexOf("&");
18615
- if (offset < 0) return input;
18616
- const inputLength = input.length;
18617
- let chunkStart = 0;
18618
- let result = "";
18619
- const root = decodeTree[0];
18620
- const rootJumpOffset = root & BinTrieFlags.JUMP_TABLE;
18621
- const rootBranchCount = (root & BinTrieFlags.BRANCH_LENGTH) >> 7;
18622
- do {
18623
- const entityStart = offset + 1;
18624
- const firstChar = input.charCodeAt(entityStart);
18625
- let consumed;
18626
- let value;
18627
- if (firstChar === CharCodes.NUM) {
18628
- const packed = parseNumericEntity(input, entityStart, inputLength);
18629
- consumed = unpackConsumed(packed);
18630
- if (isStrict && consumed > 0 && input.charCodeAt(entityStart + consumed - 1) !== CharCodes.SEMI) consumed = 0;
18631
- value = consumed === 0 ? "" : codePointToString(packed & CODE_POINT_MASK);
18632
- } else if (isAlpha(firstChar)) {
18633
- consumed = 0;
18634
- value = "";
18635
- const rootSlotIndex = firstChar - rootJumpOffset;
18636
- let nodeIndex;
18637
- if (rootSlotIndex >>> 0 < rootBranchCount) {
18638
- const stored = decodeTree[1 + rootSlotIndex];
18639
- nodeIndex = stored === 0 ? -1 : rootBranchCount + stored & 65535;
18640
- } else nodeIndex = -1;
18641
- let bestNodeIndex = 0;
18642
- let bestValueLength = 0;
18643
- let current = nodeIndex < 0 ? 0 : decodeTree[nodeIndex];
18644
- let index = entityStart + 1;
18645
- trie: while (index < inputLength) {
18646
- while ((current & (BinTrieFlags.VALUE_LENGTH | BinTrieFlags.FLAG13)) === 0 && (current & BinTrieFlags.JUMP_TABLE) !== 0) {
18647
- const jumpOffset = current & BinTrieFlags.JUMP_TABLE;
18648
- const branchCount = (current & BinTrieFlags.BRANCH_LENGTH) >> 7;
18649
- if (branchCount === 0) {
18650
- if (input.charCodeAt(index) !== jumpOffset) break trie;
18651
- nodeIndex += 1;
18652
- } else {
18653
- const slot = input.charCodeAt(index) - jumpOffset;
18654
- if (slot >>> 0 >= branchCount) break trie;
18655
- const stored = decodeTree[nodeIndex + 1 + slot];
18656
- if (stored === 0) break trie;
18657
- nodeIndex = nodeIndex + branchCount + stored & 65535;
18658
- }
18659
- current = decodeTree[nodeIndex];
18660
- index += 1;
18661
- if (index >= inputLength) break trie;
18662
- }
18663
- if ((current & (BinTrieFlags.VALUE_LENGTH | BinTrieFlags.FLAG13)) === BinTrieFlags.FLAG13) {
18664
- const runLength = (current & BinTrieFlags.BRANCH_LENGTH) >> 7;
18665
- if (input.charCodeAt(index) !== (current & BinTrieFlags.JUMP_TABLE)) break;
18666
- index += 1;
18667
- const remaining = runLength - 1;
18668
- let wordIndex = nodeIndex + 1;
18669
- let charIndexInPacked = 0;
18670
- for (; charIndexInPacked + 1 < remaining; charIndexInPacked += 2) {
18671
- const packed = decodeTree[wordIndex];
18672
- if (input.charCodeAt(index) !== (packed & 255)) break trie;
18673
- index += 1;
18674
- if (input.charCodeAt(index) !== (packed >> 8 & 255)) break trie;
18675
- index += 1;
18676
- wordIndex += 1;
18677
- }
18678
- if (charIndexInPacked < remaining) {
18679
- if (input.charCodeAt(index) !== (decodeTree[wordIndex] & 255)) break;
18680
- index += 1;
18681
- }
18682
- nodeIndex += 1 + (runLength >> 1);
18683
- current = decodeTree[nodeIndex];
18684
- continue;
18685
- }
18686
- const valueLength = current >>> 14;
18687
- const char = input.charCodeAt(index);
18688
- if (valueLength !== 0) {
18689
- if (char === CharCodes.SEMI) {
18690
- consumed = index - entityStart + 1;
18691
- value = valueLength === 1 ? String.fromCharCode(current & BinTrieFlags.VALUE_MASK) : readTrieValue(decodeTree, nodeIndex, valueLength);
18692
- break;
18693
- }
18694
- if (!isStrict && (current & BinTrieFlags.FLAG13) === 0) {
18695
- consumed = index - entityStart;
18696
- bestNodeIndex = nodeIndex;
18697
- bestValueLength = valueLength;
18698
- }
18699
- if (valueLength === 1) break;
18700
- }
18701
- const next = determineBranch(decodeTree, current, nodeIndex + (valueLength || 1), char);
18702
- if (next < 0) break;
18703
- nodeIndex = next;
18704
- current = decodeTree[nodeIndex];
18705
- index += 1;
18706
- }
18707
- if (value === "") {
18708
- const finalVL = current >>> 14;
18709
- if (finalVL !== 0 && !isStrict && (current & BinTrieFlags.FLAG13) === 0) {
18710
- consumed = index - entityStart;
18711
- bestNodeIndex = nodeIndex;
18712
- bestValueLength = finalVL;
18713
- }
18714
- if (consumed > 0) value = readTrieValue(decodeTree, bestNodeIndex, bestValueLength);
18715
- }
18716
- } else {
18717
- consumed = 0;
18718
- value = "";
18719
- }
18720
- if (consumed === 0 || isAttribute && firstChar !== CharCodes.NUM && input.charCodeAt(entityStart + consumed - 1) !== CharCodes.SEMI && entityStart + consumed < inputLength && isEntityInAttributeInvalidEnd(input.charCodeAt(entityStart + consumed))) offset = entityStart;
18721
- else {
18722
- if (chunkStart < offset) result += input.slice(chunkStart, offset);
18723
- result += value;
18724
- offset = chunkStart = entityStart + consumed;
18127
+ //#region ../../node_modules/.pnpm/comark@0.9.0_katex@0.19.1_shiki@4.5.0/node_modules/comark/dist/plugins/binding.js
18128
+ const markdownItInlineBinding = (md, options = {}) => {
18129
+ const tag = options.tag || "binding";
18130
+ md.inline.ruler.after("entity", "mdc_inline_binding", (state, silent) => {
18131
+ const start = state.pos;
18132
+ if (state.src[start] !== "{" || state.src[start + 1] !== "{") return false;
18133
+ let end = start + 2;
18134
+ while (end < state.posMax - 1) {
18135
+ if (state.src[end] === "}" && state.src[end + 1] === "}") break;
18136
+ end += 1;
18725
18137
  }
18726
- if (input.charCodeAt(offset) !== CharCodes.AMP) offset = input.indexOf("&", offset);
18727
- } while (offset >= 0);
18728
- return result + input.slice(chunkStart);
18729
- }
18730
- /**
18731
- * Decodes an HTML string in an attribute.
18732
- * @param htmlAttribute The string to decode.
18733
- * @returns The decoded string.
18734
- */
18735
- function decodeHTMLAttribute(htmlAttribute) {
18736
- return decodeWithTrie(htmlAttribute, false, true);
18737
- }
18138
+ if (end >= state.posMax - 1) return false;
18139
+ const inner = state.src.slice(start + 2, end).trim();
18140
+ if (!inner) return false;
18141
+ const separator = inner.indexOf("||");
18142
+ const value = separator === -1 ? inner : inner.slice(0, separator).trim();
18143
+ const defaultValue = separator === -1 ? "" : inner.slice(separator + 2).trim();
18144
+ if (!value) return false;
18145
+ state.pos = end + 2;
18146
+ if (silent) return true;
18147
+ const token = state.push("mdc_inline_component", tag, 0);
18148
+ token.attrSet(":value", value);
18149
+ if (defaultValue) token.attrSet("defaultValue", defaultValue);
18150
+ return true;
18151
+ });
18152
+ };
18153
+ var binding_default = defineComarkPlugin((opts = {}) => {
18154
+ return {
18155
+ name: "binding",
18156
+ markdownItPlugins: [((md) => markdownItInlineBinding(md, opts))]
18157
+ };
18158
+ });
18738
18159
  //#endregion
18739
- //#region ../markdown-template/dist/render-CpaRdP2V.js
18160
+ //#region ../markdown-template/dist/prepare-B9amb4_J.js
18161
+ const dynamicError = { why: ({ message }) => message === void 0 ? "" : String(message) };
18162
+ const markdownTemplateErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
18163
+ docsBase: "https://vitehub.dev/docs/markdown-template/diagnostics",
18164
+ codes: {
18165
+ MARKDOWN_TEMPLATE_R0002: {
18166
+ ...dynamicError,
18167
+ fix: "Bind the condition to a `data.<path>` path that the template may read, or to a JSON literal, such as `:condition=\"data.ready\"`."
18168
+ },
18169
+ MARKDOWN_TEMPLATE_B0001: {
18170
+ ...dynamicError,
18171
+ fix: "Pass a path that starts with `./`, ends with `.template.md`, and uses `/` between folders, such as `./review/PULL_REQUEST.template.md`."
18172
+ },
18173
+ MARKDOWN_TEMPLATE_B0002: {
18174
+ ...dynamicError,
18175
+ fix: "Remove the empty, `.`, and `..` folders from the path, such as `./review/PULL_REQUEST.template.md` in place of `./review/../PULL_REQUEST.template.md`."
18176
+ },
18177
+ MARKDOWN_TEMPLATE_BINDING_IN_CODE: {
18178
+ why: ({ path }) => `The binding "{{ ${path} }}" is inside inline code or a code block, so the template shows it as text and does not fill it.`,
18179
+ fix: "Move the binding out of the code, such as `**{{ data.repository }}**` in place of `` `{{ data.repository }}` ``. To show a value as code, put the Markdown in `data`, such as `` `vitejs/vite` ``, and insert it with `:insert{:markdown=\"data.<path>\"}`."
18180
+ },
18181
+ MARKDOWN_TEMPLATE_BINDING_OUTSIDE_DATA: {
18182
+ why: ({ path }) => `The binding "${path}" does not start with \`data.\`. A template reads each value from \`data\`, so "${path}" is never defined.`,
18183
+ fix: "Start each binding with `data.`: write `{{ data.name }}` in place of `{{ name }}`, and `:href=\"data.url\"` in place of `:href=\"url\"`. Pass the same values in `data`."
18184
+ },
18185
+ MARKDOWN_TEMPLATE_R0011: {
18186
+ ...dynamicError,
18187
+ fix: "Pass a link value in the template data that is a safe URL, such as an `https:` or relative URL without spaces at the ends, control characters, backslashes, or HTML character references."
18188
+ },
18189
+ MARKDOWN_TEMPLATE_R0012: {
18190
+ ...dynamicError,
18191
+ fix: "Pass a link value in the template data that is a safe URL, such as an `https:` or relative URL without spaces at the ends, control characters, backslashes, or HTML character references."
18192
+ },
18193
+ MARKDOWN_TEMPLATE_R0013: {
18194
+ ...dynamicError,
18195
+ fix: "Pass a link value in the template data that is a safe URL, such as an `https:` or relative URL without spaces at the ends, control characters, backslashes, or HTML character references."
18196
+ },
18197
+ MARKDOWN_TEMPLATE_R0014: {
18198
+ ...dynamicError,
18199
+ fix: "Pass the template text as a string to `renderMarkdownTemplate()`, or use `renderMarkdownFile()` with the path of a template file."
18200
+ },
18201
+ MARKDOWN_TEMPLATE_R0015: {
18202
+ ...dynamicError,
18203
+ fix: "Write `::else-if` and `::else` blocks only inside the `::if` block that they follow, as in `::if{:condition=\"data.ready\"}` ... `::else` ... `::`."
18204
+ },
18205
+ MARKDOWN_TEMPLATE_R0017: {
18206
+ ...dynamicError,
18207
+ fix: "Add the value that the message names to the `data` that you pass to the renderer, or remove its binding from the template."
18208
+ },
18209
+ MARKDOWN_TEMPLATE_R0018: {
18210
+ ...dynamicError,
18211
+ fix: "Bind the value that the message names to a string, number, or boolean in `data`, or use `:insert{:markdown=\"data.<path>\"}` for a Markdown fragment."
18212
+ },
18213
+ MARKDOWN_TEMPLATE_R0020: {
18214
+ ...dynamicError,
18215
+ fix: "Give each `:insert` a bound `:markdown` prop with an allowed `data.<path>` that holds a Markdown string, such as `:insert{:markdown=\"data.summary\"}`."
18216
+ },
18217
+ MARKDOWN_TEMPLATE_R0021: {
18218
+ ...dynamicError,
18219
+ fix: "Put the `:insert` on its own line with blank lines around it, or pass a fragment that is one paragraph."
18220
+ },
18221
+ MARKDOWN_TEMPLATE_R0022: {
18222
+ ...dynamicError,
18223
+ fix: "Remove the condition from the `::else` block, or use `::else-if{:condition=\"data.<path>\"}` for a branch with a condition."
18224
+ },
18225
+ MARKDOWN_TEMPLATE_R0023: {
18226
+ ...dynamicError,
18227
+ fix: "Put `::else` last in its `::if` block, and move each `::else-if` before it."
18228
+ },
18229
+ MARKDOWN_TEMPLATE_R0024: {
18230
+ ...dynamicError,
18231
+ fix: "Give `::if` and `::else-if` a bound `:condition` or `:value` prop, such as `::if{:condition=\"data.ready\"}`, and use only the `eq`, `neq`, `gt`, `gte`, `lt`, and `lte` props next to it."
18232
+ },
18233
+ MARKDOWN_TEMPLATE_R0025: {
18234
+ ...dynamicError,
18235
+ fix: "Write `::else-if` and `::else` blocks only inside the `::if` block that they follow, as in `::if{:condition=\"data.ready\"}` ... `::else` ... `::`."
18236
+ },
18237
+ MARKDOWN_TEMPLATE_R0026: {
18238
+ ...dynamicError,
18239
+ fix: "Put `::else` last in its `::if` block, and move each `::else-if` before it."
18240
+ },
18241
+ MARKDOWN_TEMPLATE_R0027: {
18242
+ ...dynamicError,
18243
+ fix: "Remove the condition from the `::else` block, or use `::else-if{:condition=\"data.<path>\"}` for a branch with a condition."
18244
+ },
18245
+ MARKDOWN_TEMPLATE_R0029: {
18246
+ ...dynamicError,
18247
+ fix: "Add a closing `::` line for each `::if`, `::else-if`, and `::else` block of the template."
18248
+ },
18249
+ MARKDOWN_TEMPLATE_R0030: {
18250
+ ...dynamicError,
18251
+ fix: "Remove the `:srcdoc` binding from the template, and write the iframe content as static markup."
18252
+ },
18253
+ MARKDOWN_TEMPLATE_R0031: {
18254
+ ...dynamicError,
18255
+ fix: "Remove the binding of the HTML event-handler attribute, such as `:onclick`, from the template."
18256
+ },
18257
+ MARKDOWN_TEMPLATE_R0032: {
18258
+ ...dynamicError,
18259
+ fix: "Remove the `:style` binding from the template, and use a static `style` attribute or a class."
18260
+ },
18261
+ MARKDOWN_TEMPLATE_R0033: {
18262
+ ...dynamicError,
18263
+ fix: "Write the link as `[label](){:href=\"data.<path>\"}` in place of `{{ }}` in the link destination."
18264
+ }
18265
+ }
18266
+ });
18740
18267
  function pathValue(value, parts) {
18741
18268
  if (!parts.length) return { value };
18742
18269
  if (value === null || typeof value !== "object" && typeof value !== "function") return void 0;
@@ -18747,15 +18274,35 @@ function pathValue(value, parts) {
18747
18274
  if (resolved !== void 0) return resolved;
18748
18275
  }
18749
18276
  }
18277
+ function isJsonLiteral(value) {
18278
+ try {
18279
+ JSON.parse(value);
18280
+ return true;
18281
+ } catch {
18282
+ return false;
18283
+ }
18284
+ }
18285
+ function bindingRoot(value) {
18286
+ return isJsonLiteral(value) ? void 0 : value.split(".", 1)[0];
18287
+ }
18288
+ const bindingRoots = /* @__PURE__ */ new Set([
18289
+ "data",
18290
+ "frontmatter",
18291
+ "meta",
18292
+ "props"
18293
+ ]);
18294
+ /** Rejects a bound path that starts with no known name, such as `{{ name }}` from templates before `data.` paths. */
18295
+ function assertBindingRoot(value) {
18296
+ const root = bindingRoot(value);
18297
+ if (root !== void 0 && !bindingRoots.has(root)) throw markdownTemplateErrorDiagnostics.MARKDOWN_TEMPLATE_BINDING_OUTSIDE_DATA({ path: value });
18298
+ }
18750
18299
  function resolveTemplateAttributes(attributes, renderData) {
18751
18300
  const values = Object.create(null);
18752
18301
  const rewritten = { ...attributes };
18753
18302
  for (const [key, value] of Object.entries(attributes)) {
18754
18303
  if (!key.startsWith(":") || typeof value !== "string") continue;
18755
- try {
18756
- JSON.parse(value);
18757
- continue;
18758
- } catch {}
18304
+ if (isJsonLiteral(value)) continue;
18305
+ assertBindingRoot(value);
18759
18306
  const alias = `binding${Object.keys(values).length}`;
18760
18307
  values[alias] = pathValue(renderData, value.split("."))?.value;
18761
18308
  rewritten[key] = `props.${alias}`;
@@ -18809,6 +18356,124 @@ function snapshotTemplateData(value, seen = /* @__PURE__ */ new WeakMap()) {
18809
18356
  }
18810
18357
  return copy;
18811
18358
  }
18359
+ const comarkHtml = html_default({ markdown: false });
18360
+ /** Plugins that keep authored HTML blocks raw, as the template renderer expects. */
18361
+ const htmlPlugins = [{
18362
+ ...comarkHtml,
18363
+ markdownItPost(state) {
18364
+ for (const [index, token] of state.tokens.entries()) {
18365
+ const first = token.children?.[0];
18366
+ if (token.type !== "inline" || state.tokens[index - 1]?.type !== "paragraph_open" || first?.type !== "html_inline") continue;
18367
+ token.children.unshift(Object.assign(Object.create(Object.getPrototypeOf(first)), first, {
18368
+ type: "text",
18369
+ content: ""
18370
+ }));
18371
+ }
18372
+ comarkHtml.markdownItPost?.(state);
18373
+ }
18374
+ }];
18375
+ const defaultPlugins = [
18376
+ frontmatter_default,
18377
+ alert_default,
18378
+ task_list_default,
18379
+ components_default,
18380
+ attributes_default
18381
+ ];
18382
+ /**
18383
+ * Comark's default plugins without linkify, so plain URLs stay text, then `plugins`.
18384
+ * A plugin in `plugins` replaces the default plugin with the same name, as Comark does.
18385
+ */
18386
+ function templatePlugins(...plugins) {
18387
+ const names = new Set(plugins.map((plugin) => plugin.name));
18388
+ return [...defaultPlugins.map((plugin) => plugin()).filter((plugin) => !names.has(plugin.name)), ...plugins];
18389
+ }
18390
+ const bindingPlugin = binding_default();
18391
+ const parserOptions = {
18392
+ autoClose: false,
18393
+ autoUnwrap: false,
18394
+ registerDefaultPlugins: false,
18395
+ plugins: templatePlugins(...htmlPlugins, bindingPlugin)
18396
+ };
18397
+ /** Parser options for one render, with the caller's extra plugins. */
18398
+ function templateParserOptions(plugins = []) {
18399
+ return {
18400
+ ...parserOptions,
18401
+ plugins: templatePlugins(...htmlPlugins, bindingPlugin, ...plugins)
18402
+ };
18403
+ }
18404
+ /** HTML tags whose text the renderer keeps as written. */
18405
+ const literalHtmlTags = /* @__PURE__ */ new Set([
18406
+ "code",
18407
+ "pre",
18408
+ "script",
18409
+ "style",
18410
+ "textarea",
18411
+ "kbd",
18412
+ "samp",
18413
+ "var"
18414
+ ]);
18415
+ /** Whether authored HTML children are reparsed as Markdown by the template renderer. */
18416
+ function hasMarkdownHtmlChildren([tag, attrs, ...children]) {
18417
+ return attrs.$?.html === 1 && attrs.$?.block === 1 && tag !== "a" && tag !== "img" && !literalHtmlTags.has(tag) && children.every((child) => typeof child === "string");
18418
+ }
18419
+ async function prepareTemplate(source) {
18420
+ const prefix = `VITEHUBCODE${crypto.randomUUID().replaceAll("-", "")}`;
18421
+ const lines = [];
18422
+ const masked = source.replace(/^([\t ]*)(:[^\r\n]*)$/gm, (_match, indent, line) => `${indent}${prefix}${lines.push(line) - 1}END`);
18423
+ const pattern = new RegExp(`${prefix}(\\d+)END`, "g");
18424
+ const inCode = /* @__PURE__ */ new Set();
18425
+ const visit = (nodes, literal = false) => {
18426
+ for (const node of nodes) if (typeof node === "string") {
18427
+ if (literal) for (const match of node.matchAll(pattern)) inCode.add(Number(match[1]));
18428
+ } else visit(node.slice(2), literal || node[0] !== null && literalHtmlTags.has(node[0]));
18429
+ };
18430
+ if (lines.length) visit((await parseMarkdown(masked, {
18431
+ autoClose: false,
18432
+ autoUnwrap: false,
18433
+ registerDefaultPlugins: false,
18434
+ plugins: templatePlugins(...htmlPlugins)
18435
+ })).nodes);
18436
+ const template = masked.replace(pattern, (token, index) => inCode.has(Number(index)) ? token : lines[Number(index)]);
18437
+ validateBranches(template);
18438
+ return {
18439
+ template,
18440
+ restore: (rendered) => rendered.replace(pattern, (_token, index) => lines[Number(index)])
18441
+ };
18442
+ }
18443
+ function validateBranches(template) {
18444
+ const stack = [];
18445
+ for (const line of template.split(/\r\n|[\r\n]/)) {
18446
+ if (/^\s*::\s*$/.test(line)) {
18447
+ stack.pop();
18448
+ continue;
18449
+ }
18450
+ const match = line.match(/^\s*::([\w-]+)(?:\{(.*)\})?\s*$/);
18451
+ if (!match) continue;
18452
+ const tag = match[1];
18453
+ if (tag !== "else" && tag !== "else-if") {
18454
+ stack.push({
18455
+ tag,
18456
+ sawElse: false
18457
+ });
18458
+ continue;
18459
+ }
18460
+ const current = stack.at(-1);
18461
+ if (current?.tag === "else") throw markdownTemplateErrorDiagnostics.MARKDOWN_TEMPLATE_R0026({ message: `[vitehub] Markdown template ${tag} block cannot follow else.` });
18462
+ if (current?.tag !== "if" && current?.tag !== "else-if") throw markdownTemplateErrorDiagnostics.MARKDOWN_TEMPLATE_R0025({ message: `[vitehub] Markdown template ${tag} block must follow an if block.` });
18463
+ if (current.sawElse) throw markdownTemplateErrorDiagnostics.MARKDOWN_TEMPLATE_R0026({ message: `[vitehub] Markdown template ${tag} block cannot follow else.` });
18464
+ if (tag === "else") {
18465
+ if (match[2]?.trim()) throw markdownTemplateErrorDiagnostics.MARKDOWN_TEMPLATE_R0027({ message: "[vitehub] Markdown template else block does not accept a condition." });
18466
+ current.sawElse = true;
18467
+ }
18468
+ stack.push({
18469
+ tag,
18470
+ sawElse: false
18471
+ });
18472
+ }
18473
+ if (stack.some((entry) => entry.tag === "if" || entry.tag === "else-if" || entry.tag === "else")) throw markdownTemplateErrorDiagnostics.MARKDOWN_TEMPLATE_R0029({ message: "[vitehub] Markdown template if block is missing a closing :: line." });
18474
+ }
18475
+ //#endregion
18476
+ //#region ../markdown-template/dist/render-BJDteOoz.js
18812
18477
  const ordered = (compare) => (value, expected) => (typeof value === "number" && typeof expected === "number" || typeof value === "string" && typeof expected === "string") && compare(value, expected);
18813
18478
  const comparisons = {
18814
18479
  eq: (value, expected) => value === expected,
@@ -18829,12 +18494,7 @@ function matchesCondition(attributes, renderData, validatePath) {
18829
18494
  if (!allowedProps.has(key.replace(/^:/, ""))) throw markdownTemplateErrorDiagnostics.MARKDOWN_TEMPLATE_R0024({ message: `[vitehub] Unsupported Markdown template condition prop "${key}". Use Comark-bound condition or value props.` });
18830
18495
  if (key === "condition" || key === "value") throw markdownTemplateErrorDiagnostics.MARKDOWN_TEMPLATE_R0024({ message: `[vitehub] Markdown template ${key} prop must be bound. Write :${key}="data.path" instead of ${key}="${String(value)}".` });
18831
18496
  if (validatePath && key.startsWith(":") && typeof value === "string") {
18832
- let literal = false;
18833
- try {
18834
- JSON.parse(value);
18835
- literal = true;
18836
- } catch {}
18837
- if (!literal && (!value.startsWith("data.") || !validatePath(value.slice(5)))) throw markdownTemplateErrorDiagnostics.MARKDOWN_TEMPLATE_R0002({ message: `[vitehub] Unsafe Markdown template condition "${value}".` });
18497
+ if (!isJsonLiteral(value) && (!value.startsWith("data.") || !validatePath(value.slice(5)))) throw markdownTemplateErrorDiagnostics.MARKDOWN_TEMPLATE_R0002({ message: `[vitehub] Unsafe Markdown template condition "${value}".` });
18838
18498
  }
18839
18499
  }
18840
18500
  const isCondition = (key) => key === "condition" || key === ":condition";
@@ -18852,19 +18512,18 @@ function matchesCondition(attributes, renderData, validatePath) {
18852
18512
  }
18853
18513
  const legacyHtmlReferences = new Set(characterEntitiesLegacy);
18854
18514
  async function safeLinkDestination(value, path, options = {}) {
18855
- const decodedValue = options.decodeHtmlEntities ? decodeHTMLAttribute(value) : value;
18856
- const suffixIndex = decodedValue.search(/[?#]/);
18857
- const scheme = decodedValue.match(/^([a-z][a-z\d+.-]*):/i);
18858
- const hasPathBackslash = (!scheme || /^(?:file|ftp|https?|wss?)$/i.test(scheme[1])) && decodedValue.slice(0, suffixIndex < 0 ? void 0 : suffixIndex).includes("\\");
18859
- const hasHtmlReferencePrefix = !options.decodeHtmlEntities && (/&#(?:\d+|x[\dA-F]+)/i.test(value) || [...value.matchAll(/&([A-Za-z][A-Za-z\d]*)(?=[^=A-Za-z\d]|$)/g)].some((match) => legacyHtmlReferences.has(match[1])));
18860
- const hasBracketedAuthority = /^(?:[a-z][a-z\d+.-]*:)?\/{2,}(?:[^/?#]*@)?\[/i.test(decodedValue) || /^(?:file|ftp|https?|wss?):\/*(?:[^/?#]*@)?\[/i.test(decodedValue);
18861
- if (decodedValue.startsWith(" ") || decodedValue.endsWith(" ") || /%(?![\dA-F]{2})/i.test(decodedValue) || hasPathBackslash || hasHtmlReferencePrefix || hasBracketedAuthority || [...decodedValue].some((character) => {
18515
+ const suffixIndex = value.search(/[?#]/);
18516
+ const scheme = value.match(/^([a-z][a-z\d+.-]*):/i);
18517
+ const hasPathBackslash = (!scheme || /^(?:file|ftp|https?|wss?)$/i.test(scheme[1])) && value.slice(0, suffixIndex < 0 ? void 0 : suffixIndex).includes("\\");
18518
+ const hasHtmlReferencePrefix = !options.decoded && (/&#(?:\d+|x[\dA-F]+)/i.test(value) || [...value.matchAll(/&([A-Za-z][A-Za-z\d]*)(?=[^=A-Za-z\d]|$)/g)].some((match) => legacyHtmlReferences.has(match[1])));
18519
+ const hasBracketedAuthority = /^(?:[a-z][a-z\d+.-]*:)?\/{2,}(?:[^/?#]*@)?\[/i.test(value) || /^(?:file|ftp|https?|wss?):\/*(?:[^/?#]*@)?\[/i.test(value);
18520
+ if (value.startsWith(" ") || value.endsWith(" ") || /%(?![\dA-F]{2})/i.test(value) || hasPathBackslash || hasHtmlReferencePrefix || hasBracketedAuthority || [...value].some((character) => {
18862
18521
  const codePoint = character.codePointAt(0);
18863
18522
  return codePoint < 32 || codePoint === 127;
18864
18523
  })) throw markdownTemplateErrorDiagnostics.MARKDOWN_TEMPLATE_R0011({ message: `[vitehub] Markdown template link binding "{{ ${path} }}" must resolve to a safe destination.` });
18865
18524
  let encoded;
18866
18525
  try {
18867
- encoded = encodeURI(decodedValue);
18526
+ encoded = encodeURI(value);
18868
18527
  encoded = encoded.replace(/%25([\dA-F]{2})/gi, "%$1").replace(/[()]/g, (character) => `%${character.codePointAt(0).toString(16).toUpperCase()}`);
18869
18528
  } catch {
18870
18529
  throw markdownTemplateErrorDiagnostics.MARKDOWN_TEMPLATE_R0012({ message: `[vitehub] Markdown template link binding "{{ ${path} }}" must resolve to a safe destination.` });
@@ -18914,11 +18573,9 @@ async function renderMarkdownTemplate(template, options = {}) {
18914
18573
  async function renderMarkdownTemplateInternal(template, options = {}) {
18915
18574
  if (typeof template !== "string") throw markdownTemplateErrorDiagnostics.MARKDOWN_TEMPLATE_R0014({ message: "[vitehub] Markdown template must be a string." });
18916
18575
  const prepared = await prepareTemplate(template);
18917
- const parseOptions = {
18918
- ...parserOptions,
18919
- plugins: [...parserOptions.plugins, ...options.plugins ?? []]
18920
- };
18576
+ const parseOptions = templateParserOptions(options.plugins);
18921
18577
  const tree = await parseMarkdown(prepared.template, parseOptions);
18578
+ const bindingPositions = /* @__PURE__ */ new WeakMap();
18922
18579
  const data = snapshotTemplateData(options.data ?? {});
18923
18580
  const renderData = (state) => ({
18924
18581
  ...state.renderData,
@@ -18927,7 +18584,7 @@ async function renderMarkdownTemplateInternal(template, options = {}) {
18927
18584
  const renderAuthoredHtml = async (node, state, parent, childPolicy) => {
18928
18585
  const [tag, attrs, ...children] = node;
18929
18586
  const sanitized = await sanitizeUrlAttributes(tag, resolveScalarTemplateAttributes(attrs, renderData(state)), attrs, state.context.svg === true);
18930
- const escaped = Object.fromEntries(Object.entries(sanitized).map(([key, value]) => [key, typeof value === "string" ? escapeHtml$1(value) : value]));
18587
+ const escaped = Object.fromEntries(Object.entries(sanitized).map(([key, value]) => [key, typeof value === "string" ? value.replaceAll("&", "&amp;") : value]));
18931
18588
  const content = childPolicy === "markdown" && hasMarkdownHtmlChildren(node) ? (await parseMarkdown(children.join(""), parseOptions)).nodes : rawBlockTags.has(tag) && attrs.$?.block === 1 && typeof children[0] === "string" ? [children[0].replace(/^\r?\n/, ""), ...children.slice(1)] : children;
18932
18589
  const revert = state.applyContext({ svg: tag.toLowerCase() === "svg" || state.context.svg === true && tag.toLowerCase() !== "foreignobject" });
18933
18590
  try {
@@ -18945,7 +18602,8 @@ async function renderMarkdownTemplateInternal(template, options = {}) {
18945
18602
  };
18946
18603
  return prepared.restore((await renderMarkdown(tree, { components: {
18947
18604
  Binding: async (node, state, parent) => {
18948
- rejectLinkDestinationBinding(node, parent);
18605
+ if (typeof node[1][":value"] === "string") assertBindingRoot(node[1][":value"]);
18606
+ rejectLinkDestinationBinding(node, parent, bindingPositions);
18949
18607
  return state.one(resolveScalarTemplateBinding(node[1], renderData(state)), state, parent, true);
18950
18608
  },
18951
18609
  If: async (node, state, parent) => {
@@ -18962,7 +18620,7 @@ async function renderMarkdownTemplateInternal(template, options = {}) {
18962
18620
  if (typeof value !== "string") throw markdownTemplateErrorDiagnostics.MARKDOWN_TEMPLATE_R0020({ message: `[vitehub] Markdown template Insert markdown prop "${String(path ?? "markdown")}" must resolve to a string.` });
18963
18621
  const fragment = await parseMarkdown(value, {
18964
18622
  ...parseOptions,
18965
- plugins: [...htmlPlugins, ...options.plugins ?? []]
18623
+ plugins: templatePlugins(...htmlPlugins, ...options.plugins ?? [])
18966
18624
  });
18967
18625
  if (parent && (parent[0] === "p" || state.context.inline)) {
18968
18626
  if (!fragment.nodes.length) return "";
@@ -18999,26 +18657,30 @@ async function renderMarkdownTemplateInternal(template, options = {}) {
18999
18657
  }
19000
18658
  } })).trim());
19001
18659
  }
19002
- /**
19003
- * Comark does not parse `[label]({{ data.url }})` as a link. It keeps the brackets as text around the binding, and the
19004
- * output shows the escaped brackets and a bare URL. Reject that form and name the attribute syntax.
19005
- */
19006
- function rejectLinkDestinationBinding(node, parent) {
19007
- if (!parent) return;
19008
- const siblings = parent.slice(2);
19009
- const index = siblings.indexOf(node);
19010
- const before = siblings[index - 1];
19011
- const after = siblings[index + 1];
19012
- if (index < 1 || typeof before !== "string" || typeof after !== "string") return;
18660
+ function rejectLinkDestinationBinding(node, parent, positions) {
18661
+ if (!parent || parent.length < 5) return;
18662
+ let indexes = positions.get(parent);
18663
+ if (!indexes) {
18664
+ indexes = /* @__PURE__ */ new Map();
18665
+ for (let index = 2; index < parent.length; index++) {
18666
+ const child = parent[index];
18667
+ if (Array.isArray(child) && child[0] !== null && !indexes.has(child)) indexes.set(child, index);
18668
+ }
18669
+ positions.set(parent, indexes);
18670
+ }
18671
+ const index = indexes.get(node);
18672
+ if (index === void 0 || index < 3) return;
18673
+ const before = parent[index - 1];
18674
+ const after = parent[index + 1];
18675
+ if (typeof before !== "string" || typeof after !== "string") return;
19013
18676
  const destination = before.match(/\]\(\s*$/);
19014
18677
  if (!destination || !/^(?:\s+(?:"[\s\S]*"|'[\s\S]*'|\([\s\S]*\)))?\s*\)/.test(after)) return;
19015
- const text = siblings.slice(0, index).map((sibling) => typeof sibling === "string" ? sibling : "x").join("");
18678
+ const text = parent.slice(2, index).map((sibling) => typeof sibling === "string" ? sibling : "x").join("");
19016
18679
  const label = labelStart(text.slice(0, text.length - destination[0].length + 1));
19017
18680
  if (label === void 0 || text[label - 1] === "!") return;
19018
18681
  const path = String(node[1][":value"]);
19019
18682
  throw markdownTemplateErrorDiagnostics.MARKDOWN_TEMPLATE_R0033({ message: `[vitehub] Markdown template binding "{{ ${path} }}" cannot be a Markdown link destination. Use [label](){:href="${path}"}.` });
19020
18683
  }
19021
- /** Returns the matching unescaped opening `[` in the label text. */
19022
18684
  function labelStart(text) {
19023
18685
  let depth = 0;
19024
18686
  for (let index = text.length - 1; index >= 0; index--) {
@@ -19057,7 +18719,7 @@ async function sanitizeUrlAttributes(tag, props, source, svgContext = false) {
19057
18719
  const isUrl = urlAttributesByTag.get(tag.toLowerCase())?.has(attribute) || (attribute === "href" || attribute === "xlink:href") && (svgUrlAttributes.has(tag.toLowerCase()) || tag.toLowerCase() === "img" && svgContext);
19058
18720
  if (typeof value !== "string" || !isUrl) continue;
19059
18721
  const binding = source[`:${key}`];
19060
- sanitized[key] = await safeLinkDestination(value, String(binding ?? key), { decodeHtmlEntities: binding === void 0 });
18722
+ sanitized[key] = await safeLinkDestination(value, String(binding ?? key), { decoded: binding === void 0 });
19061
18723
  }
19062
18724
  return sanitized;
19063
18725
  }
@@ -19103,8 +18765,11 @@ function conditionalBranches(node) {
19103
18765
  after
19104
18766
  };
19105
18767
  }
19106
- //#endregion
19107
- //#region ../markdown-template/dist/vite-BGJ4jHJz.js
18768
+ [.../* @__PURE__ */ new Set([
18769
+ "if",
18770
+ "else-if",
18771
+ "else"
18772
+ ])];
19108
18773
  function parseMarkdownTemplateRequest(id) {
19109
18774
  if (id.includes("#")) return;
19110
18775
  const queryIndex = id.indexOf("?");
@@ -19152,6 +18817,10 @@ async function collectContributions(plugins, options) {
19152
18817
  const candidates = [];
19153
18818
  await flattenPlugins(plugins ?? [], candidates, /* @__PURE__ */ new Set());
19154
18819
  const collected = /* @__PURE__ */ new Map();
18820
+ const context = {
18821
+ ...options.context,
18822
+ plugins: candidates
18823
+ };
19155
18824
  for (const plugin of candidates) {
19156
18825
  if (!Object.hasOwn(plugin, "vitehub")) continue;
19157
18826
  const metadata = Reflect.get(plugin, "vitehub");
@@ -19163,7 +18832,7 @@ async function collectContributions(plugins, options) {
19163
18832
  throw options.invalid(`[vitehub] Plugin ${JSON.stringify(contributor)} contributed an invalid ${options.kind}: ${reason}`);
19164
18833
  };
19165
18834
  const callable = typeof source === "function";
19166
- const entries = callable ? await Reflect.apply(source, void 0, [options.context]) : source;
18835
+ const entries = callable ? await Reflect.apply(source, void 0, [context]) : source;
19167
18836
  if (entries === void 0 && callable) continue;
19168
18837
  if (!Array.isArray(entries)) fail(`\`vitehub.${options.key}\` must be an array or a function that returns one.`);
19169
18838
  const list = entries;
@@ -20680,6 +20349,8 @@ const WORKSPACE_LOAD_ID_PATTERN = /(?:^\0#vitehub(?:-workspace-registry$|\/works
20680
20349
  const generatedNitroWorkspacePlugin = ".vitehub/nitro/workspace/plugin.ts";
20681
20350
  const generatedNitroWorkspaceRegistry = ".vitehub/nitro/workspace/registry.js";
20682
20351
  const generatedNitroWorkspaceDurabilityRegistry = ".vitehub/nitro/workspace/durability-registry.js";
20352
+ const generatedNitroWorkspaceDurabilityFallback = ".vitehub/nitro/workspace/durability-fallback.js";
20353
+ const generatedNitroWorkspaceDurabilityLoader = ".vitehub/nitro/workspace/durability-loader.js";
20683
20354
  const cloudflareArtifactsBindingsFileName = ".vitehub-workspace-artifacts-bindings.json";
20684
20355
  const noExternalAddition = createNoExternalAddition(WORKSPACE_PACKAGE_NAME);
20685
20356
  const workspacesDirSegment = /[\\/](?:server[\\/])?workspaces(?:[\\/]|$)/;
@@ -21079,7 +20750,32 @@ function shouldInstallNitroWorkspacePlugin(config, options, normalized, definiti
21079
20750
  }
21080
20751
  function mergeNitroWorkspaceConfig(value, root, dev) {
21081
20752
  const kit = createNitroServerKit(isRecord(value) ? { ...value } : {});
21082
- kit.addPlugin(resolve(root, generatedNitroWorkspacePlugin), dev ? "start" : "end");
20753
+ const pluginFile = resolve(root, generatedNitroWorkspacePlugin);
20754
+ kit.addPlugin(pluginFile, dev ? "start" : "end");
20755
+ if (!dev) {
20756
+ const modules = Array.isArray(kit.config.modules) ? kit.config.modules : [];
20757
+ kit.config.modules = [...modules, {
20758
+ name: "vitehub-workspace-durability-registry",
20759
+ setup({ options }) {
20760
+ if (!options.plugins.some((file) => file.replaceAll("\\", "/").endsWith("/.vitehub/nitro/durability/plugin.mjs"))) return;
20761
+ const registry = resolve(root, generatedNitroWorkspaceDurabilityRegistry);
20762
+ const fallback = resolve(root, generatedNitroWorkspaceDurabilityFallback);
20763
+ const importerFile = pluginFile.replaceAll("\\", "/");
20764
+ const registryImport = moduleImportSpecifier(pluginFile, resolve(root, generatedNitroWorkspaceRegistry));
20765
+ const plugin = {
20766
+ name: "vitehub-workspace-durability-registry",
20767
+ resolveId: {
20768
+ order: "pre",
20769
+ handler(id, importer) {
20770
+ if (id === WORKSPACE_REGISTRY_ID) return fallback;
20771
+ if (id === registryImport && importer === importerFile) return registry;
20772
+ }
20773
+ }
20774
+ };
20775
+ options.buildPlugins = [...options.buildPlugins, plugin];
20776
+ }
20777
+ }];
20778
+ }
21083
20779
  kit.addHandler({
21084
20780
  handler: ownModule(import.meta.url, "runtime/request"),
21085
20781
  middleware: true
@@ -21206,6 +20902,16 @@ async function writeNitroWorkspacePlugin(root, config, options, definitions, clo
21206
20902
  await writeFileIfChanged(registryFile, createWorkspaceRegistryContents(registryFile, definitions, definitionOverrides));
21207
20903
  const durabilityRegistryFile = resolve(root, generatedNitroWorkspaceDurabilityRegistry);
21208
20904
  await writeFileIfChanged(durabilityRegistryFile, createWorkspaceRegistryContents(durabilityRegistryFile, definitions, definitionOverrides, true));
20905
+ const fallbackFile = resolve(root, generatedNitroWorkspaceDurabilityFallback);
20906
+ const loaderFile = resolve(root, generatedNitroWorkspaceDurabilityLoader);
20907
+ const names = JSON.stringify(definitions.map((definition) => definition.name));
20908
+ await writeFileIfChanged(loaderFile, `export { default } from ${JSON.stringify(moduleImportSpecifier(loaderFile, durabilityRegistryFile))}\n`);
20909
+ await writeFileIfChanged(fallbackFile, [
20910
+ `const names = ${names}`,
20911
+ `const loadRegistry = () => import(${JSON.stringify(moduleImportSpecifier(fallbackFile, loaderFile))})`,
20912
+ "export default Object.fromEntries(names.map(name => [name, async () => (await loadRegistry()).default[name]()]))",
20913
+ ""
20914
+ ].join("\n"));
21209
20915
  await writeFileIfChanged(pluginFile, renderNitroWorkspacePlugin(runtimeConfig, moduleImportSpecifier(pluginFile, registryFile), resolveNitroHostedStoreProviders(runtimeConfig, definitions.length, storeUsage), cloudflareRuntime));
21210
20916
  }
21211
20917
  async function createWorkspaceNitroConfig(options = {}) {
@@ -21254,7 +20960,7 @@ function stripWorkspaceInternalOptions(options) {
21254
20960
  return publicOptions;
21255
20961
  }
21256
20962
  function hubWorkspace(options) {
21257
- const packageLoading = createNativePackageLoading();
20963
+ const packageLoading = createNativePackageLoading([import.meta.resolve(WORKSPACE_PACKAGE_NAME)]);
21258
20964
  const internalOptions = options;
21259
20965
  let hosting = internalOptions ? internalOptions.hosting : void 0;
21260
20966
  const publicOptions = stripWorkspaceInternalOptions(options);
@@ -21279,13 +20985,12 @@ function hubWorkspace(options) {
21279
20985
  }
21280
20986
  function invalidateVirtualWorkspaceModules() {
21281
20987
  if (!server) return;
21282
- const moduleGraph = server.moduleGraph;
21283
20988
  const ids = [
21284
20989
  RESOLVED_WORKSPACE_REGISTRY_ID,
21285
20990
  RESOLVED_WORKSPACES_ID,
21286
20991
  ...manifest.workspaces.map((w) => `${RESOLVED_WORKSPACE_PREFIX}${w.name}`)
21287
20992
  ];
21288
- for (const id of ids) {
20993
+ for (const { moduleGraph } of Object.values(server.environments)) for (const id of ids) {
21289
20994
  const mod = moduleGraph.getModuleById(id);
21290
20995
  if (mod) moduleGraph.invalidateModule(mod);
21291
20996
  }
@@ -21390,7 +21095,7 @@ function hubWorkspace(options) {
21390
21095
  if (!isServerEnvironment(name, config)) return;
21391
21096
  return { resolve: {
21392
21097
  dedupe: dedupeAddition(config.resolve?.dedupe),
21393
- ...packageLoading.configureEnvironment(name, env) ? {} : { noExternal: noExternalAddition(config.resolve?.noExternal) }
21098
+ ...packageLoading.configureEnvironment(name, env, config) ? {} : { noExternal: noExternalAddition(config.resolve?.noExternal) }
21394
21099
  } };
21395
21100
  },
21396
21101
  async buildStart() {
@@ -21418,12 +21123,11 @@ function hubWorkspace(options) {
21418
21123
  providerOutputGenerations.defer(this, providerOutput, {
21419
21124
  owner: "workspace",
21420
21125
  rootDir: roots.projectRoot,
21421
- write: async ({ readCloudflareState, signal, write }) => {
21126
+ write: async ({ addVercelRuntimePackages, readCloudflareState, write }) => {
21422
21127
  const definitions = discoverDefinitions(roots, serverDirs, contributions);
21423
- await copyVercelFunctionRuntimePackages({
21128
+ addVercelRuntimePackages({
21424
21129
  packages: vercelFunctionRuntimePackages(),
21425
- rootDir: roots.projectRoot,
21426
- signal
21130
+ rootDir: roots.projectRoot
21427
21131
  });
21428
21132
  await writeCloudflareArtifactsProviderOutput(roots.projectRoot, resolved.build?.outDir ?? "dist/client", workspaceOptions, definitions, readCloudflareState, write, resolved.resolve ? workspaceDefinitionLoaderAliases(resolved.resolve.alias) : void 0);
21429
21133
  }
@@ -21550,7 +21254,7 @@ function hubWorkspace(options) {
21550
21254
  }
21551
21255
  },
21552
21256
  load: {
21553
- filter: { id: WORKSPACE_LOAD_ID_PATTERN },
21257
+ filter: { id: new RegExp(`${WORKSPACE_LOAD_ID_PATTERN.source}|/vitehub-grants(?:-[\\w-]+)?\\.js$`) },
21554
21258
  handler(id) {
21555
21259
  if (id === RESOLVED_WORKSPACE_REGISTRY_ID) return registryContents;
21556
21260
  if (id === RESOLVED_WORKSPACES_ID) return `export const workspaces = ${JSON.stringify(manifest.workspaces)};\nexport default { workspaces };\n`;