@reckona/mreact-router 0.0.145 → 0.0.147

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env node
2
+ import { readFile } from "node:fs/promises";
2
3
  import { resolve } from "node:path";
3
- import { buildApp, packageAwsLambdaArtifact, packageCloudflarePagesArtifact } from "./build.js";
4
+ import { buildApp, packageAwsLambdaArtifact, packageCloudflarePagesArtifact, } from "./build.js";
4
5
  import { buildTargetsFromCliTarget, createCliRequestLogger, formatCliHelp, parseCliArguments, resolveCliAllowedHosts, resolveCliDevPort, resolveCliHost, resolveCliHostPolicy, resolveCliRequestLogMode, } from "./cli-options.js";
5
6
  import { startDevServer } from "./dev-server.js";
6
7
  import { startServer } from "./serve.js";
@@ -25,19 +26,36 @@ if (parsed !== undefined) {
25
26
  ? createCliRequestLogger()
26
27
  : undefined;
27
28
  if (command === "build") {
29
+ const startedAt = performance.now();
30
+ let activeBuildPhase;
31
+ console.log(`mreact-router build v${await readRouterCliVersion()}`);
32
+ console.log(`Target: ${formatCliBuildTarget(parsed.target)}`);
33
+ console.log(`Root: ${process.cwd()}`);
34
+ console.log("Config: loading...");
28
35
  const loaded = routeArg === undefined
29
36
  ? await loadMreactRouterViteConfigDetails({ command: "build", cwd: process.cwd() })
30
37
  : { project: { appDir: resolve(routeArg) }, viteConfig: undefined };
31
- const result = await buildApp({
32
- ...loaded.project,
33
- ...(parsed.clientSourceMaps === undefined
34
- ? {}
35
- : { clientSourceMaps: parsed.clientSourceMaps }),
36
- outDir: resolve(".mreact"),
37
- targets: buildTargetsFromCliTarget(parsed.target),
38
- viteConfig: loaded.viteConfig,
39
- });
40
- console.log(`Built ${result.routes.length} routes.`);
38
+ try {
39
+ const result = await buildApp({
40
+ ...loaded.project,
41
+ ...(parsed.clientSourceMaps === undefined
42
+ ? {}
43
+ : { clientSourceMaps: parsed.clientSourceMaps }),
44
+ onBuildProgress(event) {
45
+ activeBuildPhase = updateBuildProgressLog(event, activeBuildPhase);
46
+ },
47
+ outDir: resolve(".mreact"),
48
+ targets: buildTargetsFromCliTarget(parsed.target),
49
+ viteConfig: loaded.viteConfig,
50
+ });
51
+ console.log(`Built ${result.routes.length} routes in ${formatDurationSeconds(performance.now() - startedAt)}.`);
52
+ }
53
+ catch (error) {
54
+ if (activeBuildPhase !== undefined) {
55
+ throw new Error(`Build failed during ${formatBuildPhaseFailureLabel(activeBuildPhase)}: ${error instanceof Error ? error.message : String(error)}`);
56
+ }
57
+ throw error;
58
+ }
41
59
  }
42
60
  else if (command === "package") {
43
61
  if (routeArg === "aws-lambda") {
@@ -63,7 +81,11 @@ if (parsed !== undefined) {
63
81
  else if (command === "dev") {
64
82
  const loaded = routeArg === undefined
65
83
  ? await loadMreactRouterViteConfigDetails({ command: "serve", cwd: process.cwd() })
66
- : { project: { appDir: resolve(routeArg) }, serverPort: undefined, viteConfig: undefined };
84
+ : {
85
+ project: { appDir: resolve(routeArg) },
86
+ serverPort: undefined,
87
+ viteConfig: undefined,
88
+ };
67
89
  const server = await startDevServer({
68
90
  ...loaded.project,
69
91
  logger,
@@ -94,4 +116,88 @@ if (parsed !== undefined) {
94
116
  process.exitCode = 1;
95
117
  }
96
118
  }
119
+ async function readRouterCliVersion() {
120
+ try {
121
+ const source = await readFile(new URL("../package.json", import.meta.url), "utf8");
122
+ const json = JSON.parse(source);
123
+ return typeof json.version === "string" ? json.version : "unknown";
124
+ }
125
+ catch {
126
+ return "unknown";
127
+ }
128
+ }
129
+ function formatCliBuildTarget(target) {
130
+ return target ?? "default";
131
+ }
132
+ function updateBuildProgressLog(event, activePhase) {
133
+ if (event.kind === "routes-discovered") {
134
+ console.log(`Routes: ${event.count} discovered`);
135
+ return activePhase;
136
+ }
137
+ if (event.kind !== "phase-start") {
138
+ return activePhase;
139
+ }
140
+ const message = buildPhaseProgressMessage(event.phase);
141
+ if (message !== undefined) {
142
+ console.log(message);
143
+ }
144
+ return event.phase;
145
+ }
146
+ function buildPhaseProgressMessage(phase) {
147
+ switch (phase) {
148
+ case "scan":
149
+ return "Routes: discovering...";
150
+ case "serverModules":
151
+ return "Server: building...";
152
+ case "clientBundles":
153
+ return "Client: building...";
154
+ case "writeManifests":
155
+ return "Artifacts: writing...";
156
+ default:
157
+ return undefined;
158
+ }
159
+ }
160
+ function formatBuildPhaseFailureLabel(phase) {
161
+ switch (phase) {
162
+ case "scan":
163
+ return "route discovery";
164
+ case "collectFiles":
165
+ return "source file collection";
166
+ case "analyzeSources":
167
+ return "source analysis";
168
+ case "validate":
169
+ return "production route validation";
170
+ case "prepareOutput":
171
+ return "output preparation";
172
+ case "publicAssets":
173
+ return "public asset collection";
174
+ case "serverActionManifest":
175
+ return "server action manifest generation";
176
+ case "serverModules":
177
+ return "server output build";
178
+ case "importPolicy":
179
+ return "import policy generation";
180
+ case "serverModuleArtifacts":
181
+ return "server artifact writing";
182
+ case "clientBundles":
183
+ return "client output build";
184
+ case "navigationRuntime":
185
+ return "navigation runtime build";
186
+ case "prerender":
187
+ return "static prerender";
188
+ case "cloudflare":
189
+ return "Cloudflare artifact generation";
190
+ case "writeManifests":
191
+ return "manifest writing";
192
+ case "adapterArtifacts":
193
+ return "adapter artifact writing";
194
+ }
195
+ }
196
+ function formatDurationSeconds(ms) {
197
+ const seconds = ms / 1000;
198
+ if (seconds < 10) {
199
+ return `${Math.round(seconds * 10) / 10}s`;
200
+ }
201
+ return `${Math.round(seconds)}s`;
202
+ }
97
203
  //# sourceMappingURL=cli.js.map
package/dist/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,wBAAwB,EAAE,8BAA8B,EAAE,MAAM,YAAY,CAAC;AAChG,OAAO,EACL,yBAAyB,EACzB,sBAAsB,EACtB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M,CAAC,UAAU;iBAC9B,CAAC,CAAC;gBACH,OAAO,CAAC,GAAG,CAAC,8BAA8B,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC;YAC1D,CAAC;iBAAM,IAAI,OAAO,KAAK,OAAO,EAAE,CAAC;gBAC/B,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC;oBAC/B,YAAY,EAAE,sBAAsB,CAAC,MAAM,CAAC,YAAY,EAAE,OAAO,CAAC,GAAG,CAAC;oBACtE,UAAU,EAAE,oBAAoB,CAAC,MAAM,CAAC,UAAU,EAAE,OAAO,CAAC,GAAG,CAAC;oBAChE,QAAQ,EAAE,cAAc,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC;oBAClD,MAAM;oBACN,MAAM,EAAE,OAAO,CAAC,QAAQ,IAAI,SAAS,CAAC;oBACtC,IAAI,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,IAAI,CAAC;iBACvC,CAAC,CAAC;gBACH,OAAO,CAAC,GAAG,CAAC,6CAA6C,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC;YACzE,CAAC;iBAAM,CAAC;gBACN,OAAO,CAAC,KAAK,CAAC,oBAAoB,OAAO,EAAE,CAAC,CAAC;gBAC7C,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;YACvB,CAAC;QACH,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;QACtE,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;IACvB,CAAC;AACH,CAAC","sourcesContent":["#!/usr/bin/env node\n\nimport { resolve } from \"node:path\";\nimport { buildApp, packageAwsLambdaArtifact, packageCloudflarePagesArtifact } from \"./build.js\";\nimport {\n buildTargetsFromCliTarget,\n createCliRequestLogger,\n formatCliHelp,\n parseCliArguments,\n resolveCliAllowedHosts,\n resolveCliDevPort,\n resolveCliHost,\n resolveCliHostPolicy,\n resolveCliRequestLogMode,\n} from \"./cli-options.js\";\nimport { startDevServer } from \"./dev-server.js\";\nimport { startServer } from \"./serve.js\";\nimport { loadMreactRouterViteConfigDetails } from \"./vite-config.js\";\n\nlet parsed;\n\ntry {\n parsed = parseCliArguments(process.argv.slice(2));\n} catch (error) {\n console.error(error instanceof Error ? error.message : String(error));\n process.exitCode = 1;\n}\n\nif (parsed !== undefined) {\n const command = parsed.command;\n const routeArg = parsed.routeArg;\n\n try {\n if (parsed.help === true || command === \"help\") {\n console.log(formatCliHelp(command === \"help\" ? routeArg : command));\n } else {\n const logger =\n resolveCliRequestLogMode(parsed.log, process.env) === \"requests\"\n ? createCliRequestLogger()\n : undefined;\n\n if (command === \"build\") {\n const loaded =\n routeArg === undefined\n ? await loadMreactRouterViteConfigDetails({ command: \"build\", cwd: process.cwd() })\n : { project: { appDir: resolve(routeArg) }, viteConfig: undefined };\n const result = await buildApp({\n ...loaded.project,\n ...(parsed.clientSourceMaps === undefined\n ? {}\n : { clientSourceMaps: parsed.clientSourceMaps }),\n outDir: resolve(\".mreact\"),\n targets: buildTargetsFromCliTarget(parsed.target),\n viteConfig: loaded.viteConfig,\n });\n console.log(`Built ${result.routes.length} routes.`);\n } else if (command === \"package\") {\n if (routeArg === \"aws-lambda\") {\n const manifest = await packageAwsLambdaArtifact({\n fromDir: resolve(parsed.from ?? \".mreact\"),\n ...(parsed.handler === undefined ? {} : { handlerEntry: resolve(parsed.handler) }),\n outDir: resolve(parsed.out ?? \".lambda\"),\n skipRuntimeDependencyCheck: parsed.skipRuntimeDependencyCheck,\n });\n console.log(\n `Packaged AWS Lambda artifact with ${manifest.files.length} files (${manifest.totalBytes} bytes).`,\n );\n } else if (routeArg === \"cloudflare-pages\") {\n const manifest = await packageCloudflarePagesArtifact({\n fromDir: resolve(parsed.from ?? \".mreact\"),\n outDir: resolve(parsed.out ?? \".mreact/pages\"),\n });\n console.log(\n `Packaged Cloudflare Pages artifact with ${manifest.files.length} files (${manifest.totalBytes} bytes).`,\n );\n } else {\n throw new Error(\n `Unsupported package target ${JSON.stringify(routeArg)}. Expected \"aws-lambda\" or \"cloudflare-pages\".`,\n );\n }\n } else if (command === \"dev\") {\n const loaded =\n routeArg === undefined\n ? await loadMreactRouterViteConfigDetails({ command: \"serve\", cwd: process.cwd() })\n : { project: { appDir: resolve(routeArg) }, serverPort: undefined, viteConfig: undefined };\n const server = await startDevServer({\n ...loaded.project,\n logger,\n port: resolveCliDevPort(parsed.port, process.env, loaded.serverPort),\n viteConfig: loaded.viteConfig,\n });\n console.log(`mreact app router ready at ${server.url}`);\n } else if (command === \"start\") {\n const server = await startServer({\n allowedHosts: resolveCliAllowedHosts(parsed.allowedHosts, process.env),\n hostPolicy: resolveCliHostPolicy(parsed.hostPolicy, process.env),\n hostname: resolveCliHost(parsed.host, process.env),\n logger,\n outDir: resolve(routeArg ?? \".mreact\"),\n port: Number(process.env.PORT ?? 3001),\n });\n console.log(`mreact app router serving built output at ${server.url}`);\n } else {\n console.error(`Unknown command: ${command}`);\n process.exitCode = 1;\n }\n }\n } catch (error) {\n console.error(error instanceof Error ? error.message : String(error));\n process.exitCode = 1;\n }\n}\n"]}
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EACL,QAAQ,EACR,wBAAwB,EACxB,8BAA8B,GAG/B,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,yBAAyB,EACzB,sBAAsB,EAEtB,aAAa,EACb,iBAAiB,EACjB,sBAAsB,EACtB,iBAAiB,EACjB,cAAc,EACd,oBAAoB,EACpB,wBAAwB,GACzB,MAAM,kBAAkB,CAAC;AAC1B,OAAO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B;YAC1B,OAAO,yBAAyB,CAAC;QACnC,KAAK,eAAe;YAClB,OAAO,qBAAqB,CAAC;QAC/B,KAAK,mBAAmB;YACtB,OAAO,0BAA0B,CAAC;QACpC,KAAK,WAAW;YACd,OAAO,kBAAkB,CAAC;QAC5B,KAAK,YAAY;YACf,OAAO,gCAAgC,CAAC;QAC1C,KAAK,gBAAgB;YACnB,OAAO,kBAAkB,CAAC;QAC5B,KAAK,kBAAkB;YACrB,OAAO,0BAA0B,CAAC;IACtC,CAAC;AACH,CAAC;AAED,SAAS,qBAAqB,CAAC,EAAU;IACvC,MAAM,OAAO,GAAG,EAAE,GAAG,IAAI,CAAC;IAE1B,IAAI,OAAO,GAAG,EAAE,EAAE,CAAC;QACjB,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,GAAG,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC;IAC7C,CAAC;IAED,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC;AACnC,CAAC","sourcesContent":["#!/usr/bin/env node\n\nimport { readFile } from \"node:fs/promises\";\nimport { resolve } from \"node:path\";\nimport {\n buildApp,\n packageAwsLambdaArtifact,\n packageCloudflarePagesArtifact,\n type BuildAppPhase,\n type BuildAppProgressEvent,\n} from \"./build.js\";\nimport {\n buildTargetsFromCliTarget,\n createCliRequestLogger,\n type CliBuildTarget,\n formatCliHelp,\n parseCliArguments,\n resolveCliAllowedHosts,\n resolveCliDevPort,\n resolveCliHost,\n resolveCliHostPolicy,\n resolveCliRequestLogMode,\n} from \"./cli-options.js\";\nimport { startDevServer } from \"./dev-server.js\";\nimport { startServer } from \"./serve.js\";\nimport { loadMreactRouterViteConfigDetails } from \"./vite-config.js\";\n\nlet parsed;\n\ntry {\n parsed = parseCliArguments(process.argv.slice(2));\n} catch (error) {\n console.error(error instanceof Error ? error.message : String(error));\n process.exitCode = 1;\n}\n\nif (parsed !== undefined) {\n const command = parsed.command;\n const routeArg = parsed.routeArg;\n\n try {\n if (parsed.help === true || command === \"help\") {\n console.log(formatCliHelp(command === \"help\" ? routeArg : command));\n } else {\n const logger =\n resolveCliRequestLogMode(parsed.log, process.env) === \"requests\"\n ? createCliRequestLogger()\n : undefined;\n\n if (command === \"build\") {\n const startedAt = performance.now();\n let activeBuildPhase: BuildAppPhase | undefined;\n console.log(`mreact-router build v${await readRouterCliVersion()}`);\n console.log(`Target: ${formatCliBuildTarget(parsed.target)}`);\n console.log(`Root: ${process.cwd()}`);\n console.log(\"Config: loading...\");\n const loaded =\n routeArg === undefined\n ? await loadMreactRouterViteConfigDetails({ command: \"build\", cwd: process.cwd() })\n : { project: { appDir: resolve(routeArg) }, viteConfig: undefined };\n try {\n const result = await buildApp({\n ...loaded.project,\n ...(parsed.clientSourceMaps === undefined\n ? {}\n : { clientSourceMaps: parsed.clientSourceMaps }),\n onBuildProgress(event) {\n activeBuildPhase = updateBuildProgressLog(event, activeBuildPhase);\n },\n outDir: resolve(\".mreact\"),\n targets: buildTargetsFromCliTarget(parsed.target),\n viteConfig: loaded.viteConfig,\n });\n console.log(\n `Built ${result.routes.length} routes in ${formatDurationSeconds(performance.now() - startedAt)}.`,\n );\n } catch (error) {\n if (activeBuildPhase !== undefined) {\n throw new Error(\n `Build failed during ${formatBuildPhaseFailureLabel(activeBuildPhase)}: ${\n error instanceof Error ? error.message : String(error)\n }`,\n );\n }\n throw error;\n }\n } else if (command === \"package\") {\n if (routeArg === \"aws-lambda\") {\n const manifest = await packageAwsLambdaArtifact({\n fromDir: resolve(parsed.from ?? \".mreact\"),\n ...(parsed.handler === undefined ? {} : { handlerEntry: resolve(parsed.handler) }),\n outDir: resolve(parsed.out ?? \".lambda\"),\n skipRuntimeDependencyCheck: parsed.skipRuntimeDependencyCheck,\n });\n console.log(\n `Packaged AWS Lambda artifact with ${manifest.files.length} files (${manifest.totalBytes} bytes).`,\n );\n } else if (routeArg === \"cloudflare-pages\") {\n const manifest = await packageCloudflarePagesArtifact({\n fromDir: resolve(parsed.from ?? \".mreact\"),\n outDir: resolve(parsed.out ?? \".mreact/pages\"),\n });\n console.log(\n `Packaged Cloudflare Pages artifact with ${manifest.files.length} files (${manifest.totalBytes} bytes).`,\n );\n } else {\n throw new Error(\n `Unsupported package target ${JSON.stringify(routeArg)}. Expected \"aws-lambda\" or \"cloudflare-pages\".`,\n );\n }\n } else if (command === \"dev\") {\n const loaded =\n routeArg === undefined\n ? await loadMreactRouterViteConfigDetails({ command: \"serve\", cwd: process.cwd() })\n : {\n project: { appDir: resolve(routeArg) },\n serverPort: undefined,\n viteConfig: undefined,\n };\n const server = await startDevServer({\n ...loaded.project,\n logger,\n port: resolveCliDevPort(parsed.port, process.env, loaded.serverPort),\n viteConfig: loaded.viteConfig,\n });\n console.log(`mreact app router ready at ${server.url}`);\n } else if (command === \"start\") {\n const server = await startServer({\n allowedHosts: resolveCliAllowedHosts(parsed.allowedHosts, process.env),\n hostPolicy: resolveCliHostPolicy(parsed.hostPolicy, process.env),\n hostname: resolveCliHost(parsed.host, process.env),\n logger,\n outDir: resolve(routeArg ?? \".mreact\"),\n port: Number(process.env.PORT ?? 3001),\n });\n console.log(`mreact app router serving built output at ${server.url}`);\n } else {\n console.error(`Unknown command: ${command}`);\n process.exitCode = 1;\n }\n }\n } catch (error) {\n console.error(error instanceof Error ? error.message : String(error));\n process.exitCode = 1;\n }\n}\n\nasync function readRouterCliVersion(): Promise<string> {\n try {\n const source = await readFile(new URL(\"../package.json\", import.meta.url), \"utf8\");\n const json = JSON.parse(source) as { version?: unknown };\n\n return typeof json.version === \"string\" ? json.version : \"unknown\";\n } catch {\n return \"unknown\";\n }\n}\n\nfunction formatCliBuildTarget(target: CliBuildTarget | undefined): string {\n return target ?? \"default\";\n}\n\nfunction updateBuildProgressLog(\n event: BuildAppProgressEvent,\n activePhase: BuildAppPhase | undefined,\n): BuildAppPhase | undefined {\n if (event.kind === \"routes-discovered\") {\n console.log(`Routes: ${event.count} discovered`);\n return activePhase;\n }\n\n if (event.kind !== \"phase-start\") {\n return activePhase;\n }\n\n const message = buildPhaseProgressMessage(event.phase);\n if (message !== undefined) {\n console.log(message);\n }\n\n return event.phase;\n}\n\nfunction buildPhaseProgressMessage(phase: BuildAppPhase): string | undefined {\n switch (phase) {\n case \"scan\":\n return \"Routes: discovering...\";\n case \"serverModules\":\n return \"Server: building...\";\n case \"clientBundles\":\n return \"Client: building...\";\n case \"writeManifests\":\n return \"Artifacts: writing...\";\n default:\n return undefined;\n }\n}\n\nfunction formatBuildPhaseFailureLabel(phase: BuildAppPhase): string {\n switch (phase) {\n case \"scan\":\n return \"route discovery\";\n case \"collectFiles\":\n return \"source file collection\";\n case \"analyzeSources\":\n return \"source analysis\";\n case \"validate\":\n return \"production route validation\";\n case \"prepareOutput\":\n return \"output preparation\";\n case \"publicAssets\":\n return \"public asset collection\";\n case \"serverActionManifest\":\n return \"server action manifest generation\";\n case \"serverModules\":\n return \"server output build\";\n case \"importPolicy\":\n return \"import policy generation\";\n case \"serverModuleArtifacts\":\n return \"server artifact writing\";\n case \"clientBundles\":\n return \"client output build\";\n case \"navigationRuntime\":\n return \"navigation runtime build\";\n case \"prerender\":\n return \"static prerender\";\n case \"cloudflare\":\n return \"Cloudflare artifact generation\";\n case \"writeManifests\":\n return \"manifest writing\";\n case \"adapterArtifacts\":\n return \"adapter artifact writing\";\n }\n}\n\nfunction formatDurationSeconds(ms: number): string {\n const seconds = ms / 1000;\n\n if (seconds < 10) {\n return `${Math.round(seconds * 10) / 10}s`;\n }\n\n return `${Math.round(seconds)}s`;\n}\n"]}
package/dist/index.d.ts CHANGED
@@ -38,7 +38,7 @@ export declare const getSession: typeof getSessionInternal;
38
38
  * @deprecated Import session helpers from `@reckona/mreact-auth` instead.
39
39
  */
40
40
  export declare const rotateSession: typeof rotateSessionInternal;
41
- export type { AwsLambdaArtifactManifest, BuildAppPhase, BuildAppPhaseTiming, BuildAppOptions, BuildAppResult, BuiltImportPolicyArtifact, CloudflarePagesArtifactManifest, PackageAwsLambdaArtifactOptions, PackageCloudflarePagesArtifactOptions, } from "./build.js";
41
+ export type { AwsLambdaArtifactManifest, BuildAppPhase, BuildAppPhaseTiming, BuildAppOptions, BuildAppProgressEvent, BuildAppResult, BuiltImportPolicyArtifact, CloudflarePagesArtifactManifest, PackageAwsLambdaArtifactOptions, PackageCloudflarePagesArtifactOptions, } from "./build.js";
42
42
  export type { ServerActionContext } from "./actions.js";
43
43
  export type { AppRouteHref, DynamicHrefOptions, RouteParamsFor, RouteSearchParams, RouteSearchValue, StaticHrefOptions, } from "./typed-routes.js";
44
44
  export type { InferLoaderData, LayoutProps, LoaderContext, GenerateMetadataContext, ManifestContext, ManifestDescriptor, MetadataImage, MetadataScalar, MetadataThemeColor, MetadataViewport, MReactNode, PageProps, RobotsContext, RobotsManifest, RobotsRule, RouteHeadDescriptor, RouteHandlerContext, RouteMetadata, RouteParams, RouteSecurityHeaders, RouteStrictTransportSecurity, SitemapContext, SitemapEntry, } from "./types.js";
@@ -47,7 +47,7 @@ export type { AssetHelperOptions, AssetLinkDescriptor, AssetManifest, AssetManif
47
47
  export type { AppRouterCache, AppRouterCacheEntry, CacheControlOptions, MemoryRouteCacheOptions, RouteCachePolicy, } from "./cache.js";
48
48
  export type { CookieOptions } from "./cookies.js";
49
49
  export type { AppRouterImportPolicy } from "./import-policy.js";
50
- export type { LinkChild, LinkOptions, LinkPrefetch, LinkProps, LinkScroll, LinkTransition, } from "./link.js";
50
+ export type { LinkChild, LinkOptions, LinkPrefetch, LinkProps, LinkScroll, LinkTransition, TrustedLinkHtml, } from "./link.js";
51
51
  export type { AppRouterNavigationState, AppRouterNavigationStateListener, AppRouterNavigationType, } from "./navigation-state.js";
52
52
  export type { RouterRuntimeCacheStat } from "./runtime-cache.js";
53
53
  export type { MemorySessionStoreOptionsInternal as MemorySessionStoreOptions };
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,wB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I,gCAAgC,EAC5D,aAAa,IAAI,qBAAqB,EACtC,cAAc,IAAI,sBAAsB,EACxC,UAAU,IAAI,kBAAkB,EAChC,aAAa,IAAI,qBAAqB,GACvC,MAAM,cAAc,CAAC;AAQtB;;GAEG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,gCAAgC,CAAC;AACzE;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,qBAAqB,CAAC;AACnD;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,sBAAsB,CAAC;AACrD;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,kBAAkB,CAAC;AAC7C;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,qBAAqB,CAAC;AAiGnD,OAAO,EACL,mBAAmB,EACnB,cAAc,EACd,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,WAAW,CAAC;AAkBnB,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAM/C,OAAO,EACL,iBAAiB,EACjB,uBAAuB,GACxB,MAAM,YAAY,CAAC;AAiBpB,OAAO,EAAE,8BAA8B,EAAE,4BAA4B,EAAE,MAAM,sBAAsB,CAAC;AACpG,OAAO,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AASxF,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC","sourcesContent":["export { buildApp, packageAwsLambdaArtifact, packageCloudflarePagesArtifact } from \"./build.js\";\nexport { assetHref, assetPreloadLinks } from \"./assets.js\";\nexport { cacheControl, createMemoryRouteCache, revalidatePath } from \"./cache.js\";\nexport { deleteCookie, parseCookieHeader, serializeCookie, setCookie } from \"./cookies.js\";\nexport { defineMessages, detectLocale } from \"./i18n.js\";\nexport { defer, isDeferredLoaderData } from \"./deferred.js\";\nexport type { DeferredLoaderData } from \"./deferred.js\";\nexport { Link, linkProps } from \"./link.js\";\nexport { href } from \"./typed-routes.js\";\nexport { parseMultipartStream } from \"./multipart.js\";\nexport type {\n MultipartFixedLengthStream,\n MultipartStreamFieldOptions,\n MultipartStreamParseOptions,\n MultipartStreamPart,\n} from \"./multipart.js\";\nexport { getNavigationState, subscribeNavigationState } from \"./navigation-state.js\";\nexport { getRouterRuntimeCacheStats } from \"./runtime-cache.js\";\nexport type { HttpUpgradeHandler } from \"./upgrade.js\";\nexport {\n cookies,\n headers,\n html,\n isNotFoundError,\n isRedirectError,\n json,\n next,\n notFound,\n parseForm,\n redirect,\n redirect303,\n redirectExternal,\n rewrite,\n textError,\n} from \"./navigation.js\";\nexport type { ParseSchema } from \"./navigation.js\";\nexport { createMemoryPrerenderStore } from \"./prerender-store.js\";\nexport { getServerRuntimeState } from \"./runtime-state.js\";\nimport {\n createMemorySessionStore as createMemorySessionStoreInternal,\n createSession as createSessionInternal,\n destroySession as destroySessionInternal,\n getSession as getSessionInternal,\n rotateSession as rotateSessionInternal,\n} from \"./session.js\";\nimport type {\n MemorySessionStoreOptions as MemorySessionStoreOptionsInternal,\n SessionCookieOptions as SessionCookieOptionsInternal,\n SessionRecord as SessionRecordInternal,\n SessionStore as SessionStoreInternal,\n} from \"./session.js\";\n\n/**\n * @deprecated Import session helpers from `@reckona/mreact-auth` instead.\n */\nexport const createMemorySessionStore = createMemorySessionStoreInternal;\n/**\n * @deprecated Import session helpers from `@reckona/mreact-auth` instead.\n */\nexport const createSession = createSessionInternal;\n/**\n * @deprecated Import session helpers from `@reckona/mreact-auth` instead.\n */\nexport const destroySession = destroySessionInternal;\n/**\n * @deprecated Import session helpers from `@reckona/mreact-auth` instead.\n */\nexport const getSession = getSessionInternal;\n/**\n * @deprecated Import session helpers from `@reckona/mreact-auth` instead.\n */\nexport const rotateSession = rotateSessionInternal;\nexport type {\n AwsLambdaArtifactManifest,\n BuildAppPhase,\n BuildAppPhaseTiming,\n BuildAppOptions,\n BuildAppResult,\n BuiltImportPolicyArtifact,\n CloudflarePagesArtifactManifest,\n PackageAwsLambdaArtifactOptions,\n PackageCloudflarePagesArtifactOptions,\n} from \"./build.js\";\nexport type { ServerActionContext } from \"./actions.js\";\nexport type {\n AppRouteHref,\n DynamicHrefOptions,\n RouteParamsFor,\n RouteSearchParams,\n RouteSearchValue,\n StaticHrefOptions,\n} from \"./typed-routes.js\";\nexport type {\n InferLoaderData,\n LayoutProps,\n LoaderContext,\n GenerateMetadataContext,\n ManifestContext,\n ManifestDescriptor,\n MetadataImage,\n MetadataScalar,\n MetadataThemeColor,\n MetadataViewport,\n MReactNode,\n PageProps,\n RobotsContext,\n RobotsManifest,\n RobotsRule,\n RouteHeadDescriptor,\n RouteHandlerContext,\n RouteMetadata,\n RouteParams,\n RouteSecurityHeaders,\n RouteStrictTransportSecurity,\n SitemapContext,\n SitemapEntry,\n} from \"./types.js\";\nexport type {\n AppRouterBuildTarget,\n AppRouterClientConsoleMethod,\n AppRouterClientSourceMapMode,\n AppRouterClientSourceMapOption,\n AppRouterProductionOptions,\n} from \"./config.js\";\nexport type {\n AssetHelperOptions,\n AssetLinkDescriptor,\n AssetManifest,\n AssetManifestEntry,\n} from \"./assets.js\";\nexport type {\n AppRouterCache,\n AppRouterCacheEntry,\n CacheControlOptions,\n MemoryRouteCacheOptions,\n RouteCachePolicy,\n} from \"./cache.js\";\nexport type { CookieOptions } from \"./cookies.js\";\nexport type { AppRouterImportPolicy } from \"./import-policy.js\";\nexport type {\n LinkChild,\n LinkOptions,\n LinkPrefetch,\n LinkProps,\n LinkScroll,\n LinkTransition,\n} from \"./link.js\";\nexport type {\n AppRouterNavigationState,\n AppRouterNavigationStateListener,\n AppRouterNavigationType,\n} from \"./navigation-state.js\";\nexport type { RouterRuntimeCacheStat } from \"./runtime-cache.js\";\nexport type { MemorySessionStoreOptionsInternal as MemorySessionStoreOptions };\nexport type {\n AppRouterCspInlineNonceWarningLogEvent,\n AppRouterLogError,\n AppRouterLogEvent,\n AppRouterLogger,\n AppRouterLogLevel,\n AppRouterRuntime,\n AppRouterRequestEndLogEvent,\n AppRouterRequestErrorLogEvent,\n AppRouterRenderTimingLogEvent,\n AppRouterRequestStartLogEvent,\n AppRouterRequestTimingLogEvent,\n} from \"./logger.js\";\nexport type { DetectedLocale, LocaleRoutingOptions, MessageTree } from \"./i18n.js\";\nexport {\n createFormCsrfToken,\n formCsrfCookie,\n formCsrfFieldName,\n validateFormCsrf,\n} from \"./csrf.js\";\nexport type {\n AppRouterAllowedServerAction,\n AppRouterServerActionOptions,\n PreparedFormActionReference,\n} from \"./actions.js\";\n/**\n * @deprecated Import session helpers and types from `@reckona/mreact-auth` instead.\n */\nexport type SessionCookieOptions = SessionCookieOptionsInternal;\n/**\n * @deprecated Import session helpers and types from `@reckona/mreact-auth` instead.\n */\nexport type SessionRecord<TData = unknown> = SessionRecordInternal<TData>;\n/**\n * @deprecated Import session helpers and types from `@reckona/mreact-auth` instead.\n */\nexport type SessionStore<TData = unknown> = SessionStoreInternal<TData>;\nexport { startDevServer } from \"./dev-server.js\";\nexport type { StartDevServerOptions } from \"./dev-server.js\";\nexport { renderAppRequest } from \"./render.js\";\nexport type {\n AppRouterResponseHook,\n AppRouterResponseHookContext,\n RenderAppRequestOptions,\n} from \"./render.js\";\nexport {\n parseTraceContext,\n traceContextFromRequest,\n} from \"./trace.js\";\nexport type {\n RouterInstrumentation,\n RouterMiddlewareEndInstrumentationEvent,\n RouterMiddlewareInstrumentationEvent,\n RouterRequestEndInstrumentationEvent,\n RouterRequestInstrumentationEvent,\n RouterRouteEndInstrumentationEvent,\n RouterRouteInstrumentationEvent,\n RouterTraceContext,\n} from \"./trace.js\";\nexport type {\n FileSystemPrerenderStoreOptions,\n KeyValuePrerenderStoreAdapter,\n KeyValuePrerenderStoreOptions,\n MemoryPrerenderStoreOptions,\n} from \"./prerender-store.js\";\nexport { createFileSystemPrerenderStore, createKeyValuePrerenderStore } from \"./prerender-store.js\";\nexport { preloadBuiltAppRuntime, renderBuiltAppRequest, startServer } from \"./serve.js\";\nexport type {\n BuiltAppRuntimePreloadMode,\n AppRouterPrerenderStore,\n BuiltAppRuntimePreloadStrategy,\n RenderBuiltAppRequestOptions,\n RequestHostPolicy,\n StartServerOptions,\n} from \"./serve.js\";\nexport { matchRoute, scanAppRoutes } from \"./routes.js\";\nexport type { AppFileConvention } from \"./file-conventions.js\";\nexport type {\n AppAssetRoute,\n AppMetadataRoute,\n AppRoute,\n MatchedRoute,\n PageRoute,\n RouteSegment,\n ServerRoute,\n} from \"./routes.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,wBAAwB,EAAE,8BAA8B,EAAE,MAAM,YAAY,CAAC;AAChG,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,sBAAsB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAClF,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC3F,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzD,OAAO,EAAE,KAAK,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAE5D,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAOtD,OAAO,EAAE,kBAAkB,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AACrF,OAAO,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AAEhE,OAAO,EACL,OAAO,EACP,OAAO,EACP,IAAI,EACJ,eAAe,EACf,eAAe,EACf,IAAI,EACJ,IAAI,EACJ,QAAQ,EACR,SAAS,EACT,QAAQ,EACR,WAAW,EACX,gBAAgB,EAChB,OAAO,EACP,SAAS,GACV,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAClE,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EACL,wBAAwB,IAAI,gCAAgC,EAC5D,aAAa,IAAI,qBAAqB,EACtC,cAAc,IAAI,sBAAsB,EACxC,UAAU,IAAI,kBAAkB,EAChC,aAAa,IAAI,qBAAqB,GACvC,MAAM,cAAc,CAAC;AAQtB;;GAEG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,gCAAgC,CAAC;AACzE;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,qBAAqB,CAAC;AACnD;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,sBAAsB,CAAC;AACrD;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,kBAAkB,CAAC;AAC7C;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,qBAAqB,CAAC;AAmGnD,OAAO,EACL,mBAAmB,EACnB,cAAc,EACd,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,WAAW,CAAC;AAkBnB,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAM/C,OAAO,EACL,iBAAiB,EACjB,uBAAuB,GACxB,MAAM,YAAY,CAAC;AAiBpB,OAAO,EAAE,8BAA8B,EAAE,4BAA4B,EAAE,MAAM,sBAAsB,CAAC;AACpG,OAAO,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AASxF,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC","sourcesContent":["export { buildApp, packageAwsLambdaArtifact, packageCloudflarePagesArtifact } from \"./build.js\";\nexport { assetHref, assetPreloadLinks } from \"./assets.js\";\nexport { cacheControl, createMemoryRouteCache, revalidatePath } from \"./cache.js\";\nexport { deleteCookie, parseCookieHeader, serializeCookie, setCookie } from \"./cookies.js\";\nexport { defineMessages, detectLocale } from \"./i18n.js\";\nexport { defer, isDeferredLoaderData } from \"./deferred.js\";\nexport type { DeferredLoaderData } from \"./deferred.js\";\nexport { Link, linkProps } from \"./link.js\";\nexport { href } from \"./typed-routes.js\";\nexport { parseMultipartStream } from \"./multipart.js\";\nexport type {\n MultipartFixedLengthStream,\n MultipartStreamFieldOptions,\n MultipartStreamParseOptions,\n MultipartStreamPart,\n} from \"./multipart.js\";\nexport { getNavigationState, subscribeNavigationState } from \"./navigation-state.js\";\nexport { getRouterRuntimeCacheStats } from \"./runtime-cache.js\";\nexport type { HttpUpgradeHandler } from \"./upgrade.js\";\nexport {\n cookies,\n headers,\n html,\n isNotFoundError,\n isRedirectError,\n json,\n next,\n notFound,\n parseForm,\n redirect,\n redirect303,\n redirectExternal,\n rewrite,\n textError,\n} from \"./navigation.js\";\nexport type { ParseSchema } from \"./navigation.js\";\nexport { createMemoryPrerenderStore } from \"./prerender-store.js\";\nexport { getServerRuntimeState } from \"./runtime-state.js\";\nimport {\n createMemorySessionStore as createMemorySessionStoreInternal,\n createSession as createSessionInternal,\n destroySession as destroySessionInternal,\n getSession as getSessionInternal,\n rotateSession as rotateSessionInternal,\n} from \"./session.js\";\nimport type {\n MemorySessionStoreOptions as MemorySessionStoreOptionsInternal,\n SessionCookieOptions as SessionCookieOptionsInternal,\n SessionRecord as SessionRecordInternal,\n SessionStore as SessionStoreInternal,\n} from \"./session.js\";\n\n/**\n * @deprecated Import session helpers from `@reckona/mreact-auth` instead.\n */\nexport const createMemorySessionStore = createMemorySessionStoreInternal;\n/**\n * @deprecated Import session helpers from `@reckona/mreact-auth` instead.\n */\nexport const createSession = createSessionInternal;\n/**\n * @deprecated Import session helpers from `@reckona/mreact-auth` instead.\n */\nexport const destroySession = destroySessionInternal;\n/**\n * @deprecated Import session helpers from `@reckona/mreact-auth` instead.\n */\nexport const getSession = getSessionInternal;\n/**\n * @deprecated Import session helpers from `@reckona/mreact-auth` instead.\n */\nexport const rotateSession = rotateSessionInternal;\nexport type {\n AwsLambdaArtifactManifest,\n BuildAppPhase,\n BuildAppPhaseTiming,\n BuildAppOptions,\n BuildAppProgressEvent,\n BuildAppResult,\n BuiltImportPolicyArtifact,\n CloudflarePagesArtifactManifest,\n PackageAwsLambdaArtifactOptions,\n PackageCloudflarePagesArtifactOptions,\n} from \"./build.js\";\nexport type { ServerActionContext } from \"./actions.js\";\nexport type {\n AppRouteHref,\n DynamicHrefOptions,\n RouteParamsFor,\n RouteSearchParams,\n RouteSearchValue,\n StaticHrefOptions,\n} from \"./typed-routes.js\";\nexport type {\n InferLoaderData,\n LayoutProps,\n LoaderContext,\n GenerateMetadataContext,\n ManifestContext,\n ManifestDescriptor,\n MetadataImage,\n MetadataScalar,\n MetadataThemeColor,\n MetadataViewport,\n MReactNode,\n PageProps,\n RobotsContext,\n RobotsManifest,\n RobotsRule,\n RouteHeadDescriptor,\n RouteHandlerContext,\n RouteMetadata,\n RouteParams,\n RouteSecurityHeaders,\n RouteStrictTransportSecurity,\n SitemapContext,\n SitemapEntry,\n} from \"./types.js\";\nexport type {\n AppRouterBuildTarget,\n AppRouterClientConsoleMethod,\n AppRouterClientSourceMapMode,\n AppRouterClientSourceMapOption,\n AppRouterProductionOptions,\n} from \"./config.js\";\nexport type {\n AssetHelperOptions,\n AssetLinkDescriptor,\n AssetManifest,\n AssetManifestEntry,\n} from \"./assets.js\";\nexport type {\n AppRouterCache,\n AppRouterCacheEntry,\n CacheControlOptions,\n MemoryRouteCacheOptions,\n RouteCachePolicy,\n} from \"./cache.js\";\nexport type { CookieOptions } from \"./cookies.js\";\nexport type { AppRouterImportPolicy } from \"./import-policy.js\";\nexport type {\n LinkChild,\n LinkOptions,\n LinkPrefetch,\n LinkProps,\n LinkScroll,\n LinkTransition,\n TrustedLinkHtml,\n} from \"./link.js\";\nexport type {\n AppRouterNavigationState,\n AppRouterNavigationStateListener,\n AppRouterNavigationType,\n} from \"./navigation-state.js\";\nexport type { RouterRuntimeCacheStat } from \"./runtime-cache.js\";\nexport type { MemorySessionStoreOptionsInternal as MemorySessionStoreOptions };\nexport type {\n AppRouterCspInlineNonceWarningLogEvent,\n AppRouterLogError,\n AppRouterLogEvent,\n AppRouterLogger,\n AppRouterLogLevel,\n AppRouterRuntime,\n AppRouterRequestEndLogEvent,\n AppRouterRequestErrorLogEvent,\n AppRouterRenderTimingLogEvent,\n AppRouterRequestStartLogEvent,\n AppRouterRequestTimingLogEvent,\n} from \"./logger.js\";\nexport type { DetectedLocale, LocaleRoutingOptions, MessageTree } from \"./i18n.js\";\nexport {\n createFormCsrfToken,\n formCsrfCookie,\n formCsrfFieldName,\n validateFormCsrf,\n} from \"./csrf.js\";\nexport type {\n AppRouterAllowedServerAction,\n AppRouterServerActionOptions,\n PreparedFormActionReference,\n} from \"./actions.js\";\n/**\n * @deprecated Import session helpers and types from `@reckona/mreact-auth` instead.\n */\nexport type SessionCookieOptions = SessionCookieOptionsInternal;\n/**\n * @deprecated Import session helpers and types from `@reckona/mreact-auth` instead.\n */\nexport type SessionRecord<TData = unknown> = SessionRecordInternal<TData>;\n/**\n * @deprecated Import session helpers and types from `@reckona/mreact-auth` instead.\n */\nexport type SessionStore<TData = unknown> = SessionStoreInternal<TData>;\nexport { startDevServer } from \"./dev-server.js\";\nexport type { StartDevServerOptions } from \"./dev-server.js\";\nexport { renderAppRequest } from \"./render.js\";\nexport type {\n AppRouterResponseHook,\n AppRouterResponseHookContext,\n RenderAppRequestOptions,\n} from \"./render.js\";\nexport {\n parseTraceContext,\n traceContextFromRequest,\n} from \"./trace.js\";\nexport type {\n RouterInstrumentation,\n RouterMiddlewareEndInstrumentationEvent,\n RouterMiddlewareInstrumentationEvent,\n RouterRequestEndInstrumentationEvent,\n RouterRequestInstrumentationEvent,\n RouterRouteEndInstrumentationEvent,\n RouterRouteInstrumentationEvent,\n RouterTraceContext,\n} from \"./trace.js\";\nexport type {\n FileSystemPrerenderStoreOptions,\n KeyValuePrerenderStoreAdapter,\n KeyValuePrerenderStoreOptions,\n MemoryPrerenderStoreOptions,\n} from \"./prerender-store.js\";\nexport { createFileSystemPrerenderStore, createKeyValuePrerenderStore } from \"./prerender-store.js\";\nexport { preloadBuiltAppRuntime, renderBuiltAppRequest, startServer } from \"./serve.js\";\nexport type {\n BuiltAppRuntimePreloadMode,\n AppRouterPrerenderStore,\n BuiltAppRuntimePreloadStrategy,\n RenderBuiltAppRequestOptions,\n RequestHostPolicy,\n StartServerOptions,\n} from \"./serve.js\";\nexport { matchRoute, scanAppRoutes } from \"./routes.js\";\nexport type { AppFileConvention } from \"./file-conventions.js\";\nexport type {\n AppAssetRoute,\n AppMetadataRoute,\n AppRoute,\n MatchedRoute,\n PageRoute,\n RouteSegment,\n ServerRoute,\n} from \"./routes.js\";\n"]}
package/dist/link.d.ts CHANGED
@@ -1,9 +1,13 @@
1
1
  import type { HtmlSink } from "@reckona/mreact-shared/compiler-contract";
2
2
  import type { ReactCompatElement, ReactCompatNode } from "@reckona/mreact-compat";
3
+ declare const TRUSTED_LINK_HTML: unique symbol;
3
4
  export type LinkPrefetch = "intent" | "viewport" | "none" | false;
4
5
  export type LinkScroll = "top" | "preserve";
5
6
  export type LinkTransition = "auto" | "none" | false;
6
- export type LinkChild = ReactCompatNode | Node | readonly LinkChild[];
7
+ export type TrustedLinkHtml = {
8
+ readonly [TRUSTED_LINK_HTML]: string;
9
+ };
10
+ export type LinkChild = ReactCompatNode | Node | TrustedLinkHtml | readonly LinkChild[];
7
11
  export interface LinkOptions {
8
12
  href: string;
9
13
  prefetch?: LinkPrefetch | undefined;
@@ -18,4 +22,5 @@ export interface LinkProps extends LinkOptions {
18
22
  export declare function linkProps(options: LinkOptions): Record<string, string>;
19
23
  export declare function Link(props: LinkProps): ReactCompatElement;
20
24
  export declare function Link(sink: HtmlSink, props: LinkProps): void;
25
+ export {};
21
26
  //# sourceMappingURL=link.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"link.d.ts","sourceRoot":"","sources":["../src/link.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0CAA0C,CAAC;AACzE,OAAO,KAAK,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAGlF,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,UAAU,GAAG,MAAM,GAAG,KAAK,CAAC;AAClE,MAAM,MAAM,UAAU,GAAG,KAAK,GAAG,UAAU,CAAC;AAC5C,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,MAAM,GAAG,KAAK,CAAC;AACrD,MAAM,MAAM,SAAS,GAAG,eAAe,GAAG,IAAI,GAAG,SAAS,SAAS,EAAE,CAAC;AAEtE,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,YAAY,GAAG,SAAS,CAAC;IACpC,MAAM,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC7B,MAAM,CAAC,EAAE,UAAU,GAAG,SAAS,CAAC;IAChC,UAAU,CAAC,EAAE,cAAc,GAAG,SAAS,CAAC;CACzC;AAED,MAAM,WAAW,SAAU,SAAQ,WAAW;IAC5C,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC;CAC9B;AAED,wBAAgB,SAAS,CAAC,OAAO,EAAE,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CActE;AAED,wBAAgB,IAAI,CAAC,KAAK,EAAE,SAAS,GAAG,kBAAkB,CAAC;AAC3D,wBAAgB,IAAI,CAAC,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,SAAS,GAAG,IAAI,CAAC"}
1
+ {"version":3,"file":"link.d.ts","sourceRoot":"","sources":["../src/link.ts"],"names":[],"mappings":"AACA,OAAO,KAA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ribute, escapeHtmlText } from "@reckona/mreact-shared/html-escape";
2
2
  import { safeUrlAttributeValue } from "@reckona/mreact-shared/url-safety";
3
+ const TRUSTED_LINK_HTML = Symbol.for("modular.react.router.trusted_link_html");
3
4
  export function linkProps(options) {
4
5
  return {
5
6
  href: options.href,
@@ -22,6 +23,9 @@ export function Link(sinkOrProps, maybeProps) {
22
23
  }
23
24
  return renderLink(sinkOrProps);
24
25
  }
26
+ Link.trustedHtml = (html) => ({
27
+ [TRUSTED_LINK_HTML]: html,
28
+ });
25
29
  function renderLink(props) {
26
30
  const { href, prefetch, reload, scroll, transition, ...rest } = props;
27
31
  const propsWithLinkAttrs = {
@@ -113,15 +117,15 @@ function renderChildren(child) {
113
117
  if (Array.isArray(child)) {
114
118
  return child.map(renderChildren).join("");
115
119
  }
116
- if (typeof child === "string" && isPreRenderedSafeHtmlChild(child)) {
117
- return child;
120
+ if (isTrustedLinkHtml(child)) {
121
+ return child[TRUSTED_LINK_HTML];
118
122
  }
119
123
  return escapeHtmlText(child);
120
124
  }
121
- function isPreRenderedSafeHtmlChild(value) {
122
- if (!/[<&]/.test(value)) {
123
- return false;
124
- }
125
- return !/(?:<\s*\/?\s*(?:script|style|iframe|object|embed|link|meta|base)\b|\son[a-z]+\s*=|javascript\s*:)/iu.test(value);
125
+ function isTrustedLinkHtml(value) {
126
+ return (typeof value === "object" &&
127
+ value !== null &&
128
+ TRUSTED_LINK_HTML in value &&
129
+ typeof value[TRUSTED_LINK_HTML] === "string");
126
130
  }
127
131
  //# sourceMappingURL=link.js.map
package/dist/link.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"link.js","sourceRoot":"","sources":["../src/link.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAGzF,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAoB1E,MAAM,UAAU,SAAS,CAAC,OAAoB;IAC5C,OAAO;QACL,IAA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E,CAAC;QACnE,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,cAAc,CAAC,KAAK,CAAC,CAAC;AAC/B,CAAC;AAED,SAAS,0BAA0B,CAAC,KAAa;IAC/C,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QACxB,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,CAAC,qGAAqG,CAAC,IAAI,CAChH,KAAK,CACN,CAAC;AACJ,CAAC","sourcesContent":["import { escapeHtmlAttribute, escapeHtmlText } from \"@reckona/mreact-shared/html-escape\";\nimport type { HtmlSink } from \"@reckona/mreact-shared/compiler-contract\";\nimport type { ReactCompatElement, ReactCompatNode } from \"@reckona/mreact-compat\";\nimport { safeUrlAttributeValue } from \"@reckona/mreact-shared/url-safety\";\n\nexport type LinkPrefetch = \"intent\" | \"viewport\" | \"none\" | false;\nexport type LinkScroll = \"top\" | \"preserve\";\nexport type LinkTransition = \"auto\" | \"none\" | false;\nexport type LinkChild = ReactCompatNode | Node | readonly LinkChild[];\n\nexport interface LinkOptions {\n href: string;\n prefetch?: LinkPrefetch | undefined;\n reload?: boolean | undefined;\n scroll?: LinkScroll | undefined;\n transition?: LinkTransition | undefined;\n}\n\nexport interface LinkProps extends LinkOptions {\n children?: LinkChild;\n [attribute: string]: unknown;\n}\n\nexport function linkProps(options: LinkOptions): Record<string, string> {\n return {\n href: options.href,\n ...(options.prefetch === undefined || options.prefetch === \"intent\"\n ? {}\n : { \"data-mreact-prefetch\": options.prefetch === false ? \"none\" : options.prefetch }),\n ...(options.reload === true ? { \"data-mreact-reload\": \"true\" } : {}),\n ...(options.scroll === undefined || options.scroll === \"top\"\n ? {}\n : { \"data-mreact-scroll\": options.scroll }),\n ...(options.transition === undefined || options.transition === false || options.transition === \"none\"\n ? {}\n : { \"data-mreact-transition\": options.transition }),\n };\n}\n\nexport function Link(props: LinkProps): ReactCompatElement;\nexport function Link(sink: HtmlSink, props: LinkProps): void;\nexport function Link(\n sinkOrProps: HtmlSink | LinkProps,\n maybeProps?: LinkProps,\n): ReactCompatElement | string | HTMLAnchorElement | void {\n if (maybeProps !== undefined) {\n (sinkOrProps as HtmlSink).append(renderLinkString(maybeProps));\n return;\n }\n\n return renderLink(sinkOrProps as LinkProps);\n}\n\nfunction renderLink(props: LinkProps): string | HTMLAnchorElement {\n const { href, prefetch, reload, scroll, transition, ...rest } = props;\n const propsWithLinkAttrs = {\n ...rest,\n ...linkProps({ href, prefetch, reload, scroll, transition }),\n };\n\n if (typeof document !== \"undefined\" && typeof document.createElement === \"function\") {\n return createAnchorElement(propsWithLinkAttrs);\n }\n\n return renderAnchorString(propsWithLinkAttrs);\n}\n\nfunction renderLinkString(props: LinkProps): string {\n const { href, prefetch, reload, scroll, transition, ...rest } = props;\n\n return renderAnchorString({\n ...rest,\n ...linkProps({ href, prefetch, reload, scroll, transition }),\n });\n}\n\nfunction createAnchorElement(props: Record<string, unknown>): HTMLAnchorElement {\n const anchor = document.createElement(\"a\");\n\n for (const [name, value] of Object.entries(props)) {\n if (name === \"children\") {\n appendLinkChild(anchor, value as LinkChild);\n continue;\n }\n\n if (!shouldSetAttribute(name, value)) {\n continue;\n }\n\n const attrName = attributeName(name);\n const safeValue = safeUrlAttributeValue(attrName, String(value));\n\n if (safeValue === undefined) {\n continue;\n }\n\n anchor.setAttribute(attrName, safeValue);\n }\n\n return anchor;\n}\n\nfunction appendLinkChild(parent: Node, child: LinkChild): void {\n if (child === null || child === undefined || typeof child === \"boolean\") {\n return;\n }\n\n if (Array.isArray(child)) {\n for (const item of child) {\n appendLinkChild(parent, item);\n }\n return;\n }\n\n if (child instanceof Node) {\n parent.appendChild(child);\n return;\n }\n\n parent.appendChild(document.createTextNode(String(child)));\n}\n\nfunction renderAnchorString(props: Record<string, unknown>): string {\n return `<a${renderAnchorAttributes(props)}>${renderChildren(props.children as LinkChild)}</a>`;\n}\n\nfunction renderAnchorAttributes(props: Record<string, unknown>): string {\n const attrs: string[] = [];\n\n for (const [name, value] of Object.entries(props)) {\n if (name === \"children\" || !shouldSetAttribute(name, value)) {\n continue;\n }\n\n const attrName = attributeName(name);\n const attrValue = String(value);\n const safeValue = safeUrlAttributeValue(attrName, attrValue);\n\n if (safeValue === undefined) {\n continue;\n }\n\n attrs.push(`${escapeHtmlAttribute(attrName)}=\"${escapeHtmlAttribute(safeValue)}\"`);\n }\n\n return attrs.length === 0 ? \"\" : ` ${attrs.join(\" \")}`;\n}\n\nfunction shouldSetAttribute(name: string, value: unknown): boolean {\n return (\n name !== \"key\" &&\n name !== \"ref\" &&\n value !== null &&\n value !== undefined &&\n value !== false &&\n typeof value !== \"function\" &&\n typeof value !== \"symbol\"\n );\n}\n\nfunction attributeName(name: string): string {\n return name === \"className\" ? \"class\" : name;\n}\n\nfunction renderChildren(child: LinkChild): string {\n if (child === null || child === undefined || typeof child === \"boolean\") {\n return \"\";\n }\n\n if (Array.isArray(child)) {\n return child.map(renderChildren).join(\"\");\n }\n\n if (typeof child === \"string\" && isPreRenderedSafeHtmlChild(child)) {\n return child;\n }\n\n return escapeHtmlText(child);\n}\n\nfunction isPreRenderedSafeHtmlChild(value: string): boolean {\n if (!/[<&]/.test(value)) {\n return false;\n }\n\n return !/(?:<\\s*\\/?\\s*(?:script|style|iframe|object|embed|link|meta|base)\\b|\\son[a-z]+\\s*=|javascript\\s*:)/iu.test(\n value,\n );\n}\n"]}
1
+ {"version":3,"file":"link.js","sourceRoot":"","sources":["../src/link.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAGzF,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAE1E,MAAM,iBAAiB,GAAG,MAAM,CAAC,GAAG,CAAC,wCAAwC,CAAC,CAAC;AAqB/E,MAAM,UAAU,SAAS,CAAC,OAAoB;IAC5C,OAAO;QACL,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,GAAG,CAAC,OAAO,CAAC,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,IAAI,iBAAiB,CAAC,KAAK,CAAC,EAAE,CAAC;QAC7B,OAAO,KAAK,CAAC,iBAAiB,CAAC,CAAC;IAClC,CAAC;IAED,OAAO,cAAc,CAAC,KAAK,CAAC,CAAC;AAC/B,CAAC;AAED,SAAS,iBAAiB,CAAC,KAAc;IACvC,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,iBAAiB,IAAI,KAAK;QAC1B,OAAQ,KAAyB,CAAC,iBAAiB,CAAC,KAAK,QAAQ,CAClE,CAAC;AACJ,CAAC","sourcesContent":["import { escapeHtmlAttribute, escapeHtmlText } from \"@reckona/mreact-shared/html-escape\";\nimport type { HtmlSink } from \"@reckona/mreact-shared/compiler-contract\";\nimport type { ReactCompatElement, ReactCompatNode } from \"@reckona/mreact-compat\";\nimport { safeUrlAttributeValue } from \"@reckona/mreact-shared/url-safety\";\n\nconst TRUSTED_LINK_HTML = Symbol.for(\"modular.react.router.trusted_link_html\");\n\nexport type LinkPrefetch = \"intent\" | \"viewport\" | \"none\" | false;\nexport type LinkScroll = \"top\" | \"preserve\";\nexport type LinkTransition = \"auto\" | \"none\" | false;\nexport type TrustedLinkHtml = { readonly [TRUSTED_LINK_HTML]: string };\nexport type LinkChild = ReactCompatNode | Node | TrustedLinkHtml | readonly LinkChild[];\n\nexport interface LinkOptions {\n href: string;\n prefetch?: LinkPrefetch | undefined;\n reload?: boolean | undefined;\n scroll?: LinkScroll | undefined;\n transition?: LinkTransition | undefined;\n}\n\nexport interface LinkProps extends LinkOptions {\n children?: LinkChild;\n [attribute: string]: unknown;\n}\n\nexport function linkProps(options: LinkOptions): Record<string, string> {\n return {\n href: options.href,\n ...(options.prefetch === undefined || options.prefetch === \"intent\"\n ? {}\n : { \"data-mreact-prefetch\": options.prefetch === false ? \"none\" : options.prefetch }),\n ...(options.reload === true ? { \"data-mreact-reload\": \"true\" } : {}),\n ...(options.scroll === undefined || options.scroll === \"top\"\n ? {}\n : { \"data-mreact-scroll\": options.scroll }),\n ...(options.transition === undefined || options.transition === false || options.transition === \"none\"\n ? {}\n : { \"data-mreact-transition\": options.transition }),\n };\n}\n\nexport function Link(props: LinkProps): ReactCompatElement;\nexport function Link(sink: HtmlSink, props: LinkProps): void;\nexport function Link(\n sinkOrProps: HtmlSink | LinkProps,\n maybeProps?: LinkProps,\n): ReactCompatElement | string | HTMLAnchorElement | void {\n if (maybeProps !== undefined) {\n (sinkOrProps as HtmlSink).append(renderLinkString(maybeProps));\n return;\n }\n\n return renderLink(sinkOrProps as LinkProps);\n}\n\n(Link as typeof Link & { trustedHtml(html: string): TrustedLinkHtml }).trustedHtml = (\n html: string,\n): TrustedLinkHtml => ({\n [TRUSTED_LINK_HTML]: html,\n});\n\nfunction renderLink(props: LinkProps): string | HTMLAnchorElement {\n const { href, prefetch, reload, scroll, transition, ...rest } = props;\n const propsWithLinkAttrs = {\n ...rest,\n ...linkProps({ href, prefetch, reload, scroll, transition }),\n };\n\n if (typeof document !== \"undefined\" && typeof document.createElement === \"function\") {\n return createAnchorElement(propsWithLinkAttrs);\n }\n\n return renderAnchorString(propsWithLinkAttrs);\n}\n\nfunction renderLinkString(props: LinkProps): string {\n const { href, prefetch, reload, scroll, transition, ...rest } = props;\n\n return renderAnchorString({\n ...rest,\n ...linkProps({ href, prefetch, reload, scroll, transition }),\n });\n}\n\nfunction createAnchorElement(props: Record<string, unknown>): HTMLAnchorElement {\n const anchor = document.createElement(\"a\");\n\n for (const [name, value] of Object.entries(props)) {\n if (name === \"children\") {\n appendLinkChild(anchor, value as LinkChild);\n continue;\n }\n\n if (!shouldSetAttribute(name, value)) {\n continue;\n }\n\n const attrName = attributeName(name);\n const safeValue = safeUrlAttributeValue(attrName, String(value));\n\n if (safeValue === undefined) {\n continue;\n }\n\n anchor.setAttribute(attrName, safeValue);\n }\n\n return anchor;\n}\n\nfunction appendLinkChild(parent: Node, child: LinkChild): void {\n if (child === null || child === undefined || typeof child === \"boolean\") {\n return;\n }\n\n if (Array.isArray(child)) {\n for (const item of child) {\n appendLinkChild(parent, item);\n }\n return;\n }\n\n if (child instanceof Node) {\n parent.appendChild(child);\n return;\n }\n\n parent.appendChild(document.createTextNode(String(child)));\n}\n\nfunction renderAnchorString(props: Record<string, unknown>): string {\n return `<a${renderAnchorAttributes(props)}>${renderChildren(props.children as LinkChild)}</a>`;\n}\n\nfunction renderAnchorAttributes(props: Record<string, unknown>): string {\n const attrs: string[] = [];\n\n for (const [name, value] of Object.entries(props)) {\n if (name === \"children\" || !shouldSetAttribute(name, value)) {\n continue;\n }\n\n const attrName = attributeName(name);\n const attrValue = String(value);\n const safeValue = safeUrlAttributeValue(attrName, attrValue);\n\n if (safeValue === undefined) {\n continue;\n }\n\n attrs.push(`${escapeHtmlAttribute(attrName)}=\"${escapeHtmlAttribute(safeValue)}\"`);\n }\n\n return attrs.length === 0 ? \"\" : ` ${attrs.join(\" \")}`;\n}\n\nfunction shouldSetAttribute(name: string, value: unknown): boolean {\n return (\n name !== \"key\" &&\n name !== \"ref\" &&\n value !== null &&\n value !== undefined &&\n value !== false &&\n typeof value !== \"function\" &&\n typeof value !== \"symbol\"\n );\n}\n\nfunction attributeName(name: string): string {\n return name === \"className\" ? \"class\" : name;\n}\n\nfunction renderChildren(child: LinkChild): string {\n if (child === null || child === undefined || typeof child === \"boolean\") {\n return \"\";\n }\n\n if (Array.isArray(child)) {\n return child.map(renderChildren).join(\"\");\n }\n\n if (isTrustedLinkHtml(child)) {\n return child[TRUSTED_LINK_HTML];\n }\n\n return escapeHtmlText(child);\n}\n\nfunction isTrustedLinkHtml(value: unknown): value is TrustedLinkHtml {\n return (\n typeof value === \"object\" &&\n value !== null &&\n TRUSTED_LINK_HTML in value &&\n typeof (value as TrustedLinkHtml)[TRUSTED_LINK_HTML] === \"string\"\n );\n}\n"]}
@@ -5,10 +5,11 @@ interface NativeRouteMatcherInstance {
5
5
  interface NativeMatchOutput {
6
6
  index: number;
7
7
  params: Record<string, string>;
8
+ catchAllParams?: Record<string, string[]> | undefined;
8
9
  }
9
10
  export declare function createNativeRouteMatcher(sortedRoutes: readonly AppRoute[]): RouteMatcher | undefined;
10
11
  export declare function __matchNativeRouteForTesting(matcher: NativeRouteMatcherInstance, sortedRoutes: readonly AppRoute[], pathname: string): MatchedRoute | undefined;
11
- export declare function normalizeNativeParams(route: AppRoute, params: Record<string, string>): MatchedRoute["params"];
12
+ export declare function normalizeNativeParams(route: AppRoute, params: Record<string, string>, catchAllParams?: Record<string, string[]>): MatchedRoute["params"];
12
13
  export declare function shouldUseNativeRouteMatcher(routeCount: number, mode: string | undefined): boolean;
13
14
  export declare function nativeModulePackageCandidates(platform: NodeJS.Platform, arch: string): string[];
14
15
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"native-route-matcher.d.ts","sourceRoot":"","sources":["../src/native-route-matcher.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAExE,UAAU,0BAA0B;IAClC,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,iBAAiB,GAAG,IAAI,GAAG,SAAS,CAAC;CACpE;AAUD,UAAU,iBAAiB;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAChC;AAKD,wBAAgB,wBAAwB,CACtC,YAAY,EAAE,SAAS,QAAQ,EAAE,GAChC,YAAY,GAAG,SAAS,CA8B1B;AAED,wBAAgB,4BAA4B,CAC1C,OAAO,EAAE,0BAA0B,EACnC,YAAY,EAAE,SAAS,QAAQ,EAAE,EACjC,QAAQ,EAAE,MAAM,GACf,YAAY,GAAG,SAAS,CAE1B;AA4BD,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,QAAQ,EACf,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC7B,YAAY,CAAC,QAAQ,CAAC,CAiBxB;AAUD,wBAAgB,2BAA2B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AAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAO/F"}
@@ -44,33 +44,30 @@ function matchNativeRoute(matcher, sortedRoutes, pathname) {
44
44
  ? undefined
45
45
  : {
46
46
  route,
47
- params: normalizeNativeParams(route, output.params),
47
+ params: normalizeNativeParams(route, output.params, output.catchAllParams),
48
48
  };
49
49
  }
50
- export function normalizeNativeParams(route, params) {
50
+ export function normalizeNativeParams(route, params, catchAllParams = {}) {
51
51
  const normalized = { ...params };
52
52
  for (const segment of route.segments) {
53
53
  if (segment.kind !== "catch-all") {
54
54
  continue;
55
55
  }
56
+ const catchAllValue = catchAllParams[segment.name];
57
+ if (catchAllValue !== undefined) {
58
+ normalized[segment.name] = catchAllValue;
59
+ continue;
60
+ }
56
61
  const value = normalized[segment.name];
57
62
  if (typeof value === "string") {
58
63
  normalized[segment.name] = value
59
64
  .split("/")
60
65
  .filter((part) => part !== "")
61
- .map((part) => safeDecodeURIComponent(part) ?? part);
66
+ .map((part) => part);
62
67
  }
63
68
  }
64
69
  return normalized;
65
70
  }
66
- function safeDecodeURIComponent(value) {
67
- try {
68
- return decodeURIComponent(value);
69
- }
70
- catch {
71
- return undefined;
72
- }
73
- }
74
71
  export function shouldUseNativeRouteMatcher(routeCount, mode) {
75
72
  if (mode === "1" || mode === "true") {
76
73
  return true;
@@ -1 +1 @@
1
- {"version":3,"file":"native-route-matcher.js","sourceRoot":"","sources":["../src/native-route-matcher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAoBzC,IAAI,kBAAgE,CAAC;AACrE,MAAM,+BAA+B,GAAG,GAAG,CAAC;AAE5C,MAAM,UAAU,wBAAwB,CACtC,YAAiC;IAEjC,IACE,CAAC,2BAA2B,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AAC,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,IAAI,CAAC;QAChE,sBAAsB;KACvB,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,6BAA6B,CAAC,QAAyB,EAAE,IAAY;IACnF,MAAM,eAAe,GAAG,yBAAyB,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;IAElE,OAAO;QACL,GAAG,CAAC,eAAe,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC;QAC3D,+BAA+B;KAChC,CAAC;AACJ,CAAC;AAED,SAAS,yBAAyB,CAAC,QAAyB,EAAE,IAAY;IACxE,IAAI,QAAQ,KAAK,OAAO,IAAI,IAAI,KAAK,KAAK,EAAE,CAAC;QAC3C,OAAO,6CAA6C,CAAC;IACvD,CAAC;IAED,IAAI,QAAQ,KAAK,QAAQ,IAAI,IAAI,KAAK,OAAO,EAAE,CAAC;QAC9C,OAAO,4CAA4C,CAAC;IACtD,CAAC;IAED,IAAI,QAAQ,KAAK,OAAO,IAAI,IAAI,KAAK,KAAK,EAAE,CAAC;QAC3C,OAAO,8CAA8C,CAAC;IACxD,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["import { createRequire } from \"node:module\";\nimport { dirname, join } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport type { AppRoute, MatchedRoute, RouteMatcher } from \"./routes.js\";\n\ninterface NativeRouteMatcherInstance {\n matchRoute(pathname: string): NativeMatchOutput | null | undefined;\n}\n\ninterface NativeRouteMatcherConstructor {\n new (routesJson: string): NativeRouteMatcherInstance;\n}\n\ninterface NativeRouteMatcherModule {\n NativeRouteMatcher?: NativeRouteMatcherConstructor | undefined;\n}\n\ninterface NativeMatchOutput {\n index: number;\n params: Record<string, string>;\n}\n\nlet loadedNativeModule: NativeRouteMatcherModule | false | undefined;\nconst nativeRouteMatcherAutoThreshold = 100;\n\nexport function createNativeRouteMatcher(\n sortedRoutes: readonly AppRoute[],\n): RouteMatcher | undefined {\n if (\n !shouldUseNativeRouteMatcher(\n sortedRoutes.length,\n process.env.MREACT_APP_ROUTER_NATIVE_ROUTE_MATCHER,\n )\n ) {\n return undefined;\n }\n\n const nativeModule = loadNativeRouteMatcherModule();\n const NativeRouteMatcher = nativeModule === false\n ? undefined\n : nativeModule.NativeRouteMatcher;\n\n if (NativeRouteMatcher === undefined) {\n return undefined;\n }\n\n const nativeRoutes = sortedRoutes.map((route, index) => ({\n index,\n segments: route.segments,\n }));\n const matcher = new NativeRouteMatcher(JSON.stringify(nativeRoutes));\n\n return {\n match(pathname): MatchedRoute | undefined {\n return matchNativeRoute(matcher, sortedRoutes, pathname);\n },\n };\n}\n\nexport function __matchNativeRouteForTesting(\n matcher: NativeRouteMatcherInstance,\n sortedRoutes: readonly AppRoute[],\n pathname: string,\n): MatchedRoute | undefined {\n return matchNativeRoute(matcher, sortedRoutes, pathname);\n}\n\nfunction matchNativeRoute(\n matcher: NativeRouteMatcherInstance,\n sortedRoutes: readonly AppRoute[],\n pathname: string,\n): MatchedRoute | undefined {\n let output: NativeMatchOutput | null | undefined;\n try {\n output = matcher.matchRoute(pathname);\n } catch {\n return undefined;\n }\n\n if (output == null) {\n return undefined;\n }\n\n const route = sortedRoutes[output.index];\n\n return route === undefined\n ? undefined\n : {\n route,\n params: normalizeNativeParams(route, output.params),\n };\n}\n\nexport function normalizeNativeParams(\n route: AppRoute,\n params: Record<string, string>,\n): MatchedRoute[\"params\"] {\n const normalized: MatchedRoute[\"params\"] = { ...params };\n\n for (const segment of route.segments) {\n if (segment.kind !== \"catch-all\") {\n continue;\n }\n const value = normalized[segment.name];\n if (typeof value === \"string\") {\n normalized[segment.name] = value\n .split(\"/\")\n .filter((part: string) => part !== \"\")\n .map((part: string) => safeDecodeURIComponent(part) ?? part);\n }\n }\n\n return normalized;\n}\n\nfunction safeDecodeURIComponent(value: string): string | undefined {\n try {\n return decodeURIComponent(value);\n } catch {\n return undefined;\n }\n}\n\nexport function shouldUseNativeRouteMatcher(\n routeCount: number,\n mode: string | undefined,\n): boolean {\n if (mode === \"1\" || mode === \"true\") {\n return true;\n }\n\n if (mode === \"0\" || mode === \"false\") {\n return false;\n }\n\n return routeCount >= nativeRouteMatcherAutoThreshold;\n}\n\nfunction loadNativeRouteMatcherModule(): NativeRouteMatcherModule | false {\n if (loadedNativeModule !== undefined) {\n return loadedNativeModule;\n }\n\n const require = nativePackageRequire();\n\n if (require === undefined) {\n loadedNativeModule = false;\n return loadedNativeModule;\n }\n\n for (const candidate of nativeModuleCandidates()) {\n try {\n loadedNativeModule = require(candidate) as NativeRouteMatcherModule;\n return loadedNativeModule;\n } catch {\n // Native package is optional. The JS matcher remains the portable fallback.\n }\n }\n\n loadedNativeModule = false;\n return false;\n}\n\nfunction nativePackageRequire(): ReturnType<typeof createRequire> | undefined {\n try {\n return new URL(import.meta.url).protocol === \"file:\" ? createRequire(import.meta.url) : undefined;\n } catch {\n return undefined;\n }\n}\n\nfunction nativeModuleCandidates(): string[] {\n const currentDir = dirname(fileURLToPath(import.meta.url));\n const workspaceNativePackage = join(currentDir, \"..\", \"..\", \"router-native\");\n\n return [\n ...nativeModulePackageCandidates(process.platform, process.arch),\n workspaceNativePackage,\n ];\n}\n\nexport function nativeModulePackageCandidates(platform: NodeJS.Platform, arch: string): string[] {\n const platformPackage = nativePlatformPackageName(platform, arch);\n\n return [\n ...(platformPackage === undefined ? [] : [platformPackage]),\n \"@reckona/mreact-router-native\",\n ];\n}\n\nfunction nativePlatformPackageName(platform: NodeJS.Platform, arch: string): string | undefined {\n if (platform === \"linux\" && arch === \"x64\") {\n return \"@reckona/mreact-router-native-linux-x64-gnu\";\n }\n\n if (platform === \"darwin\" && arch === \"arm64\") {\n return \"@reckona/mreact-router-native-darwin-arm64\";\n }\n\n if (platform === \"win32\" && arch === \"x64\") {\n return \"@reckona/mreact-router-native-win32-x64-msvc\";\n }\n\n return undefined;\n}\n"]}
1
+ {"version":3,"file":"native-route-matcher.js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C,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IACpG,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC;AAED,SAAS,sBAAsB;IAC7B,MAAM,UAAU,GAAG,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IAC3D,MAAM,sBAAsB,GAAG,IAAI,CAAC,UAAU,EAAE,IAAI,EAAE,IAAI,EAAE,eAAe,CAAC,CAAC;IAE7E,OAAO;QACL,GAAG,6BAA6B,CAAC,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,IAAI,CAAC;QAChE,sBAAsB;KACvB,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,6BAA6B,CAAC,QAAyB,EAAE,IAAY;IACnF,MAAM,eAAe,GAAG,yBAAyB,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;IAElE,OAAO;QACL,GAAG,CAAC,eAAe,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC;QAC3D,+BAA+B;KAChC,CAAC;AACJ,CAAC;AAED,SAAS,yBAAyB,CAAC,QAAyB,EAAE,IAAY;IACxE,IAAI,QAAQ,KAAK,OAAO,IAAI,IAAI,KAAK,KAAK,EAAE,CAAC;QAC3C,OAAO,6CAA6C,CAAC;IACvD,CAAC;IAED,IAAI,QAAQ,KAAK,QAAQ,IAAI,IAAI,KAAK,OAAO,EAAE,CAAC;QAC9C,OAAO,4CAA4C,CAAC;IACtD,CAAC;IAED,IAAI,QAAQ,KAAK,OAAO,IAAI,IAAI,KAAK,KAAK,EAAE,CAAC;QAC3C,OAAO,8CAA8C,CAAC;IACxD,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["import { createRequire } from \"node:module\";\nimport { dirname, join } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport type { AppRoute, MatchedRoute, RouteMatcher } from \"./routes.js\";\n\ninterface NativeRouteMatcherInstance {\n matchRoute(pathname: string): NativeMatchOutput | null | undefined;\n}\n\ninterface NativeRouteMatcherConstructor {\n new (routesJson: string): NativeRouteMatcherInstance;\n}\n\ninterface NativeRouteMatcherModule {\n NativeRouteMatcher?: NativeRouteMatcherConstructor | undefined;\n}\n\ninterface NativeMatchOutput {\n index: number;\n params: Record<string, string>;\n catchAllParams?: Record<string, string[]> | undefined;\n}\n\nlet loadedNativeModule: NativeRouteMatcherModule | false | undefined;\nconst nativeRouteMatcherAutoThreshold = 100;\n\nexport function createNativeRouteMatcher(\n sortedRoutes: readonly AppRoute[],\n): RouteMatcher | undefined {\n if (\n !shouldUseNativeRouteMatcher(\n sortedRoutes.length,\n process.env.MREACT_APP_ROUTER_NATIVE_ROUTE_MATCHER,\n )\n ) {\n return undefined;\n }\n\n const nativeModule = loadNativeRouteMatcherModule();\n const NativeRouteMatcher = nativeModule === false\n ? undefined\n : nativeModule.NativeRouteMatcher;\n\n if (NativeRouteMatcher === undefined) {\n return undefined;\n }\n\n const nativeRoutes = sortedRoutes.map((route, index) => ({\n index,\n segments: route.segments,\n }));\n const matcher = new NativeRouteMatcher(JSON.stringify(nativeRoutes));\n\n return {\n match(pathname): MatchedRoute | undefined {\n return matchNativeRoute(matcher, sortedRoutes, pathname);\n },\n };\n}\n\nexport function __matchNativeRouteForTesting(\n matcher: NativeRouteMatcherInstance,\n sortedRoutes: readonly AppRoute[],\n pathname: string,\n): MatchedRoute | undefined {\n return matchNativeRoute(matcher, sortedRoutes, pathname);\n}\n\nfunction matchNativeRoute(\n matcher: NativeRouteMatcherInstance,\n sortedRoutes: readonly AppRoute[],\n pathname: string,\n): MatchedRoute | undefined {\n let output: NativeMatchOutput | null | undefined;\n try {\n output = matcher.matchRoute(pathname);\n } catch {\n return undefined;\n }\n\n if (output == null) {\n return undefined;\n }\n\n const route = sortedRoutes[output.index];\n\n return route === undefined\n ? undefined\n : {\n route,\n params: normalizeNativeParams(route, output.params, output.catchAllParams),\n };\n}\n\nexport function normalizeNativeParams(\n route: AppRoute,\n params: Record<string, string>,\n catchAllParams: Record<string, string[]> = {},\n): MatchedRoute[\"params\"] {\n const normalized: MatchedRoute[\"params\"] = { ...params };\n\n for (const segment of route.segments) {\n if (segment.kind !== \"catch-all\") {\n continue;\n }\n const catchAllValue = catchAllParams[segment.name];\n if (catchAllValue !== undefined) {\n normalized[segment.name] = catchAllValue;\n continue;\n }\n\n const value = normalized[segment.name];\n if (typeof value === \"string\") {\n normalized[segment.name] = value\n .split(\"/\")\n .filter((part: string) => part !== \"\")\n .map((part: string) => part);\n }\n }\n\n return normalized;\n}\n\nexport function shouldUseNativeRouteMatcher(\n routeCount: number,\n mode: string | undefined,\n): boolean {\n if (mode === \"1\" || mode === \"true\") {\n return true;\n }\n\n if (mode === \"0\" || mode === \"false\") {\n return false;\n }\n\n return routeCount >= nativeRouteMatcherAutoThreshold;\n}\n\nfunction loadNativeRouteMatcherModule(): NativeRouteMatcherModule | false {\n if (loadedNativeModule !== undefined) {\n return loadedNativeModule;\n }\n\n const require = nativePackageRequire();\n\n if (require === undefined) {\n loadedNativeModule = false;\n return loadedNativeModule;\n }\n\n for (const candidate of nativeModuleCandidates()) {\n try {\n loadedNativeModule = require(candidate) as NativeRouteMatcherModule;\n return loadedNativeModule;\n } catch {\n // Native package is optional. The JS matcher remains the portable fallback.\n }\n }\n\n loadedNativeModule = false;\n return false;\n}\n\nfunction nativePackageRequire(): ReturnType<typeof createRequire> | undefined {\n try {\n return new URL(import.meta.url).protocol === \"file:\" ? createRequire(import.meta.url) : undefined;\n } catch {\n return undefined;\n }\n}\n\nfunction nativeModuleCandidates(): string[] {\n const currentDir = dirname(fileURLToPath(import.meta.url));\n const workspaceNativePackage = join(currentDir, \"..\", \"..\", \"router-native\");\n\n return [\n ...nativeModulePackageCandidates(process.platform, process.arch),\n workspaceNativePackage,\n ];\n}\n\nexport function nativeModulePackageCandidates(platform: NodeJS.Platform, arch: string): string[] {\n const platformPackage = nativePlatformPackageName(platform, arch);\n\n return [\n ...(platformPackage === undefined ? [] : [platformPackage]),\n \"@reckona/mreact-router-native\",\n ];\n}\n\nfunction nativePlatformPackageName(platform: NodeJS.Platform, arch: string): string | undefined {\n if (platform === \"linux\" && arch === \"x64\") {\n return \"@reckona/mreact-router-native-linux-x64-gnu\";\n }\n\n if (platform === \"darwin\" && arch === \"arm64\") {\n return \"@reckona/mreact-router-native-darwin-arm64\";\n }\n\n if (platform === \"win32\" && arch === \"x64\") {\n return \"@reckona/mreact-router-native-win32-x64-msvc\";\n }\n\n return undefined;\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reckona/mreact-router",
3
- "version": "0.0.145",
3
+ "version": "0.0.147",
4
4
  "description": "File-system app router, SSR, actions, and deployment adapters for mreact.",
5
5
  "keywords": [
6
6
  "jsx",
@@ -105,20 +105,20 @@
105
105
  },
106
106
  "dependencies": {
107
107
  "typescript": "^6.0.3",
108
- "@reckona/mreact": "0.0.145",
109
- "@reckona/mreact-compat": "0.0.145",
110
- "@reckona/mreact-compiler": "0.0.145",
111
- "@reckona/mreact-devtools": "0.0.145",
112
- "@reckona/mreact-query": "0.0.145",
113
- "@reckona/mreact-reactive-core": "0.0.145",
114
- "@reckona/mreact-reactive-dom": "0.0.145",
115
- "@reckona/mreact-server": "0.0.145",
116
- "@reckona/mreact-shared": "0.0.145"
108
+ "@reckona/mreact": "0.0.147",
109
+ "@reckona/mreact-compat": "0.0.147",
110
+ "@reckona/mreact-compiler": "0.0.147",
111
+ "@reckona/mreact-query": "0.0.147",
112
+ "@reckona/mreact-reactive-core": "0.0.147",
113
+ "@reckona/mreact-devtools": "0.0.147",
114
+ "@reckona/mreact-server": "0.0.147",
115
+ "@reckona/mreact-shared": "0.0.147",
116
+ "@reckona/mreact-reactive-dom": "0.0.147"
117
117
  },
118
118
  "peerDependencies": {
119
119
  "vite": ">=8 <9"
120
120
  },
121
121
  "optionalDependencies": {
122
- "@reckona/mreact-router-native": "0.0.145"
122
+ "@reckona/mreact-router-native": "0.0.147"
123
123
  }
124
124
  }