@markless/router 0.4.0 → 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.
@@ -1,6 +1,6 @@
1
1
  import { extname, isAbsolute, normalize, relative, resolve } from "pathe";
2
2
  //#region src/typescript-plugin/index.ts
3
- const PAGE_EXTENSIONS = new Set([".tsrx", ".mdx"]);
3
+ const PAGE_EXTENSIONS = /* @__PURE__ */ new Set([".tsrx", ".mdx"]);
4
4
  function init(modules) {
5
5
  const typeScript = modules.typescript;
6
6
  return { create(info) {
@@ -15,7 +15,8 @@ function init(modules) {
15
15
  const projectRoot = getProjectRoot(typeScript, info);
16
16
  const pagesDir = resolvePagesDir(getConfiguredProjectRoot(info) ?? projectRoot, pluginConfig);
17
17
  proxy.getCompletionsAtPosition = (fileName, position, options, formattingSettings) => {
18
- return withRouteHrefCompletions(typeScript, info, pagesDir, fileName, position, languageService.getCompletionsAtPosition(fileName, position, options, formattingSettings));
18
+ const completions = languageService.getCompletionsAtPosition(fileName, position, options, formattingSettings);
19
+ return withRouteHrefCompletions(typeScript, info, pagesDir, fileName, position, completions);
19
20
  };
20
21
  return proxy;
21
22
  } };
@@ -57,7 +58,7 @@ function isRouteHrefCompletionContext(typeScript, info, fileName, position) {
57
58
  }
58
59
  function isInsideStringLikeToken(typeScript, source, position) {
59
60
  const scanner = typeScript.createScanner(typeScript.ScriptTarget.Latest, false, typeScript.LanguageVariant.JSX, source);
60
- const stringLikeTokens = new Set([
61
+ const stringLikeTokens = /* @__PURE__ */ new Set([
61
62
  typeScript.SyntaxKind.StringLiteral,
62
63
  typeScript.SyntaxKind.NoSubstitutionTemplateLiteral,
63
64
  typeScript.SyntaxKind.TemplateHead,
@@ -164,13 +165,15 @@ function routeHrefCompletion(fileId) {
164
165
  }
165
166
  function isReservedOrUnsupportedPage(fileId) {
166
167
  const extension = extname(fileId);
167
- const routeFile = normalize(fileId.slice(0, -extension.length));
168
+ const withoutExtension = fileId.slice(0, -extension.length);
169
+ const routeFile = normalize(withoutExtension);
168
170
  const segments = routeFile === "." ? [] : routeFile.split("/").filter(Boolean);
169
171
  return segments[0] === "api" || segments.length === 1 && (segments[0] === "404" || segments[0] === "500");
170
172
  }
171
173
  function routeFromFileId(fileId) {
172
174
  const extension = extname(fileId);
173
- const routeFile = normalize(fileId.slice(0, -extension.length));
175
+ const withoutExtension = fileId.slice(0, -extension.length);
176
+ const routeFile = normalize(withoutExtension);
174
177
  const segments = routeFile === "." ? [] : routeFile.split("/").filter(Boolean);
175
178
  if (segments.at(-1) === "index") segments.pop();
176
179
  const params = [];
@@ -1,4 +1,3 @@
1
1
  //#region src/vite/entries/route-href.d.ts
2
- declare function __marklessRouteHref(pattern: string, params: Readonly<Record<string, unknown>>): string;
3
- //#endregion
4
- export { __marklessRouteHref };
2
+ export declare function __marklessRouteHref(pattern: string, params: Readonly<Record<string, unknown>>): string;
3
+ //#endregion
@@ -1,18 +1,2 @@
1
- //#region src/vite/entries/route-href.ts
2
- const routeParamPattern = /\[\.\.\.([A-Za-z_$][\w$]*)\]|\[([A-Za-z_$][\w$]*)\]/g;
3
- function __marklessRouteHref(pattern, params) {
4
- return pattern.replace(routeParamPattern, (_match, catchAll, dynamic) => {
5
- const name = catchAll || dynamic;
6
- const value = params?.[name];
7
- if (catchAll) return encodeCatchAllParam(pattern, value);
8
- if (value === null || value === void 0) throw new Error(`Typed route error: ${pattern} requires params:\n- ${name}`);
9
- return encodeURIComponent(String(value));
10
- });
11
- }
12
- function encodeCatchAllParam(pattern, value) {
13
- const segments = Array.isArray(value) ? value : value === null || value === void 0 ? [] : String(value).split("/");
14
- if (segments.length === 0 || segments.some((segment) => String(segment) === "")) throw new Error(`Typed route error: ${pattern} requires a non-empty catch-all param.`);
15
- return segments.map((segment) => encodeURIComponent(String(segment))).join("/");
16
- }
17
- //#endregion
1
+ import { t as __marklessRouteHref } from "../route-href-CGooO_g6.js";
18
2
  export { __marklessRouteHref };
@@ -1,8 +1,7 @@
1
1
  //#region src/vite/runtime/create-route-discovery.d.ts
2
- interface RouteDiscovery {
2
+ export interface RouteDiscovery {
3
3
  readonly pageModuleLoaders: Record<string, () => Promise<unknown>>;
4
4
  readonly routeFileIds: readonly string[];
5
5
  }
6
- declare function createRouteDiscovery(discoveredPageModuleLoaders: Record<string, () => Promise<unknown>>): RouteDiscovery;
7
- //#endregion
8
- export { RouteDiscovery, createRouteDiscovery };
6
+ export declare function createRouteDiscovery(discoveredPageModuleLoaders: Record<string, () => Promise<unknown>>): RouteDiscovery;
7
+ //#endregion
@@ -1,4 +1,4 @@
1
- import { i as normalizeRouteFileId } from "../../route-manifest-DPgGIyrS.js";
1
+ import { a as normalizeRouteFileId } from "../../route-manifest-Bw_nFohL.js";
2
2
  //#region src/vite/runtime/create-route-discovery.ts
3
3
  function createRouteDiscovery(discoveredPageModuleLoaders) {
4
4
  const pageModuleLoaders = Object.fromEntries(Object.entries(discoveredPageModuleLoaders).map(([file, loader]) => [normalizeRouteFileId(file), loader]));
@@ -1,21 +1,27 @@
1
1
  import { ModulePreloadInput } from "@markless/web/render-to-string";
2
-
3
2
  //#region src/vite/runtime/create-server-entry.d.ts
4
- interface ServerEntryOptions {
3
+ export interface ServerEntryOptions {
5
4
  readonly dev?: boolean;
5
+ readonly base?: string;
6
6
  readonly navigationEntryPath?: string;
7
+ readonly prefetch?: boolean;
7
8
  readonly resumeEntryPath?: string;
8
9
  readonly prerenderWakeEntryPath?: string;
9
10
  readonly routeModulePreloads?: Record<string, readonly ModulePreloadInput[]>;
10
11
  readonly routeSsrModulePreloads?: Record<string, readonly ModulePreloadInput[]>;
11
12
  readonly routeStylesheets?: Record<string, readonly string[]>;
13
+ readonly documentStylesheets?: readonly string[];
14
+ readonly importMap?: string;
12
15
  readonly documentModuleLoader: (() => Promise<unknown>) | undefined;
16
+ readonly documentNavigation?: 'client' | 'document';
13
17
  readonly pageModuleLoaders: Record<string, () => Promise<unknown>>;
14
18
  readonly routeFileIds: readonly string[];
15
19
  readonly render?: 'streaming' | 'blocking';
20
+ readonly navigation?: 'fragment' | 'render';
21
+ readonly fragmentEntryPath?: string;
22
+ readonly fragmentNavigationSource?: string;
16
23
  }
17
- declare function createServerEntry(options: ServerEntryOptions): {
24
+ export declare function createServerEntry(options: ServerEntryOptions): {
18
25
  fetch: (request: Request) => Promise<Response>;
19
26
  };
20
- //#endregion
21
- export { ServerEntryOptions, createServerEntry };
27
+ //#endregion