@reckona/mreact-router 0.0.206 → 0.0.207
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/client.d.ts.map +1 -1
- package/dist/client.js +5 -8
- package/dist/client.js.map +1 -1
- package/dist/native-escape.d.ts.map +1 -1
- package/dist/native-escape.js +14 -1
- package/dist/native-escape.js.map +1 -1
- package/package.json +11 -11
- package/src/client.ts +5 -8
- package/src/native-escape.ts +15 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"native-escape.d.ts","sourceRoot":"","sources":["../src/native-escape.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"native-escape.d.ts","sourceRoot":"","sources":["../src/native-escape.ts"],"names":[],"mappings":"AAUA;;GAEG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,SAAS,OAAO,EAAE,GAAG,MAAM,EAAE,CAKpE"}
|
package/dist/native-escape.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
2
|
import { nativeModulePackageCandidates } from "./native-route-matcher.js";
|
|
3
|
-
import { escapeHtmlAttribute as escapeHtml } from "@reckona/mreact-shared/html-escape";
|
|
4
3
|
let nativeModule;
|
|
5
4
|
let nativeRequire;
|
|
6
5
|
/**
|
|
@@ -11,6 +10,20 @@ export function escapeHtmlBatch(values) {
|
|
|
11
10
|
const native = loadNativeEscapeModule();
|
|
12
11
|
return native?.escapeHtmlBatch?.(strings) ?? strings.map(escapeHtml);
|
|
13
12
|
}
|
|
13
|
+
function escapeHtml(value) {
|
|
14
|
+
return value.replace(/[&<>"]/g, (character) => {
|
|
15
|
+
switch (character) {
|
|
16
|
+
case "&":
|
|
17
|
+
return "&";
|
|
18
|
+
case "<":
|
|
19
|
+
return "<";
|
|
20
|
+
case ">":
|
|
21
|
+
return ">";
|
|
22
|
+
default:
|
|
23
|
+
return """;
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
}
|
|
14
27
|
function loadNativeEscapeModule() {
|
|
15
28
|
if (nativeModule === undefined) {
|
|
16
29
|
const require = nativePackageRequire();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"native-escape.js","sourceRoot":"","sources":["../src/native-escape.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,6BAA6B,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"native-escape.js","sourceRoot":"","sources":["../src/native-escape.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,6BAA6B,EAAE,MAAM,2BAA2B,CAAC;AAM1E,IAAI,YAAoD,CAAC;AACzD,IAAI,aAAmE,CAAC;AAExE;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,MAA0B;IACxD,MAAM,OAAO,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,CAAC;IAC3D,MAAM,MAAM,GAAG,sBAAsB,EAAE,CAAC;IAExC,OAAO,MAAM,EAAE,eAAe,EAAE,CAAC,OAAO,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;AACvE,CAAC;AAED,SAAS,UAAU,CAAC,KAAa;IAC/B,OAAO,KAAK,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC,SAAS,EAAE,EAAE;QAC5C,QAAQ,SAAS,EAAE,CAAC;YAClB,KAAK,GAAG;gBACN,OAAO,OAAO,CAAC;YACjB,KAAK,GAAG;gBACN,OAAO,MAAM,CAAC;YAChB,KAAK,GAAG;gBACN,OAAO,MAAM,CAAC;YAChB;gBACE,OAAO,QAAQ,CAAC;QACpB,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAS,sBAAsB;IAC7B,IAAI,YAAY,KAAK,SAAS,EAAE,CAAC;QAC/B,MAAM,OAAO,GAAG,oBAAoB,EAAE,CAAC;QAEvC,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;YAC1B,YAAY,GAAG,KAAK,CAAC;YACrB,OAAO,SAAS,CAAC;QACnB,CAAC;QAED,KAAK,MAAM,SAAS,IAAI,6BAA6B,CAAC,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;YACtF,IAAI,CAAC;gBACH,YAAY,GAAG,OAAO,CAAC,SAAS,CAAuB,CAAC;gBACxD,MAAM;YACR,CAAC;YAAC,MAAM,CAAC;gBACP,yEAAyE;YAC3E,CAAC;QACH,CAAC;QACD,YAAY,KAAK,KAAK,CAAC;IACzB,CAAC;IAED,OAAO,YAAY,KAAK,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,YAAY,CAAC;AAC3D,CAAC;AAED,SAAS,oBAAoB;IAC3B,IAAI,aAAa,KAAK,SAAS,EAAE,CAAC;QAChC,IAAI,CAAC;YACH,aAAa;gBACX,IAAI,GAAG,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,aAAa,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;QAC3F,CAAC;QAAC,MAAM,CAAC;YACP,aAAa,GAAG,KAAK,CAAC;QACxB,CAAC;IACH,CAAC;IAED,OAAO,aAAa,KAAK,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,aAAa,CAAC;AAC7D,CAAC","sourcesContent":["import { createRequire } from \"node:module\";\nimport { nativeModulePackageCandidates } from \"./native-route-matcher.js\";\n\ninterface NativeEscapeModule {\n escapeHtmlBatch?: (values: string[]) => string[];\n}\n\nlet nativeModule: NativeEscapeModule | false | undefined;\nlet nativeRequire: ReturnType<typeof createRequire> | false | undefined;\n\n/**\n * Escapes a batch of values as HTML text using the native helper when available.\n */\nexport function escapeHtmlBatch(values: readonly unknown[]): string[] {\n const strings = values.map((value) => String(value ?? \"\"));\n const native = loadNativeEscapeModule();\n\n return native?.escapeHtmlBatch?.(strings) ?? strings.map(escapeHtml);\n}\n\nfunction escapeHtml(value: string): string {\n return value.replace(/[&<>\"]/g, (character) => {\n switch (character) {\n case \"&\":\n return \"&\";\n case \"<\":\n return \"<\";\n case \">\":\n return \">\";\n default:\n return \""\";\n }\n });\n}\n\nfunction loadNativeEscapeModule(): NativeEscapeModule | undefined {\n if (nativeModule === undefined) {\n const require = nativePackageRequire();\n\n if (require === undefined) {\n nativeModule = false;\n return undefined;\n }\n\n for (const candidate of nativeModulePackageCandidates(process.platform, process.arch)) {\n try {\n nativeModule = require(candidate) as NativeEscapeModule;\n break;\n } catch {\n // Native package is optional. JS escaping remains the portable fallback.\n }\n }\n nativeModule ??= false;\n }\n\n return nativeModule === false ? undefined : nativeModule;\n}\n\nfunction nativePackageRequire(): ReturnType<typeof createRequire> | undefined {\n if (nativeRequire === undefined) {\n try {\n nativeRequire =\n new URL(import.meta.url).protocol === \"file:\" ? createRequire(import.meta.url) : false;\n } catch {\n nativeRequire = false;\n }\n }\n\n return nativeRequire === false ? undefined : nativeRequire;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reckona/mreact-router",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.207",
|
|
4
4
|
"description": "File-system app router, SSR, actions, and deployment adapters for mreact.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"jsx",
|
|
@@ -111,20 +111,20 @@
|
|
|
111
111
|
"dependencies": {
|
|
112
112
|
"@typescript/typescript6": "^6.0.2",
|
|
113
113
|
"esbuild": ">=0.28.1 <0.29",
|
|
114
|
-
"@reckona/mreact": "0.0.
|
|
115
|
-
"@reckona/mreact-compat": "0.0.
|
|
116
|
-
"@reckona/mreact-compiler": "0.0.
|
|
117
|
-
"@reckona/mreact-
|
|
118
|
-
"@reckona/mreact-
|
|
119
|
-
"@reckona/mreact-
|
|
120
|
-
"@reckona/mreact-
|
|
121
|
-
"@reckona/mreact-
|
|
122
|
-
"@reckona/mreact-
|
|
114
|
+
"@reckona/mreact": "0.0.207",
|
|
115
|
+
"@reckona/mreact-compat": "0.0.207",
|
|
116
|
+
"@reckona/mreact-compiler": "0.0.207",
|
|
117
|
+
"@reckona/mreact-devtools": "0.0.207",
|
|
118
|
+
"@reckona/mreact-query": "0.0.207",
|
|
119
|
+
"@reckona/mreact-reactive-core": "0.0.207",
|
|
120
|
+
"@reckona/mreact-server": "0.0.207",
|
|
121
|
+
"@reckona/mreact-reactive-dom": "0.0.207",
|
|
122
|
+
"@reckona/mreact-shared": "0.0.207"
|
|
123
123
|
},
|
|
124
124
|
"peerDependencies": {
|
|
125
125
|
"vite": ">=8.1.4 <9"
|
|
126
126
|
},
|
|
127
127
|
"optionalDependencies": {
|
|
128
|
-
"@reckona/mreact-router-native": "0.0.
|
|
128
|
+
"@reckona/mreact-router-native": "0.0.207"
|
|
129
129
|
}
|
|
130
130
|
}
|
package/src/client.ts
CHANGED
|
@@ -3373,6 +3373,7 @@ function __mreactResolveRouteNode(value) {
|
|
|
3373
3373
|
: `function __mreactSyncDomRefBindings() {}
|
|
3374
3374
|
`;
|
|
3375
3375
|
const boundaryOnlyHydrationBlock = routeRequiresFullHydration
|
|
3376
|
+
|| clientReferenceManifest.length === 0
|
|
3376
3377
|
? ""
|
|
3377
3378
|
: `${routeCellHydrationIndent}if (!__mreactHasNonSerializableClientBoundaries(__mreactMarker) && __mreactHydrateClientBoundaries(document, __mreactClientReferences, __mreactClientReferenceComponents)) {
|
|
3378
3379
|
${routeCellHydrationIndent} __mreactMarker.setAttribute(${JSON.stringify(routeHydrationContract.hydratedAttribute)}, "true");
|
|
@@ -3426,8 +3427,7 @@ ${restoreRequestUrl ? " if (__mreactProps.request) __mreactProps.request.url =
|
|
|
3426
3427
|
}
|
|
3427
3428
|
${routeCellHydrationStart}${routeCleanupHydrationStart}${boundaryOnlyHydrationBlock}${routeComponentGuard}${routeCellHydrationIndent}const __mreactNode = ${routeHydrationNodeExpression};
|
|
3428
3429
|
${routeCellHydrationIndent}__mreactResumeRoute(__mreactMarker, __mreactNode);
|
|
3429
|
-
${routeCellHydrationIndent}__mreactHydrateClientBoundaries(document, __mreactClientReferences, __mreactClientReferenceComponents);
|
|
3430
|
-
${routeCellHydrationIndent}__mreactMarker.setAttribute(__mreactRouteHydratedAttribute, "true");
|
|
3430
|
+
${clientReferenceManifest.length === 0 ? "" : `${routeCellHydrationIndent}__mreactHydrateClientBoundaries(document, __mreactClientReferences, __mreactClientReferenceComponents);\n`}${routeCellHydrationIndent}__mreactMarker.setAttribute(__mreactRouteHydratedAttribute, "true");
|
|
3431
3431
|
${routeCellHydrationIndent}__mreactMarkRouteHydrated();
|
|
3432
3432
|
${routeCellHydrationEnd}}
|
|
3433
3433
|
${routeCellDropFunction}
|
|
@@ -4893,9 +4893,7 @@ function __mreactHydrateClientBoundaries(marker, references, components) {
|
|
|
4893
4893
|
}
|
|
4894
4894
|
|
|
4895
4895
|
const propsElement = __mreactClientBoundaryPropsElement(placeholder, name);
|
|
4896
|
-
|
|
4897
|
-
? {}
|
|
4898
|
-
: JSON.parse(propsElement.textContent);
|
|
4896
|
+
let props = propsElement?.textContent ? JSON.parse(propsElement.textContent) : {};
|
|
4899
4897
|
const fallbackChildren = __mreactClientBoundaryFallbackChildren(placeholder, propsElement);
|
|
4900
4898
|
|
|
4901
4899
|
if (fallbackChildren !== undefined) {
|
|
@@ -4920,9 +4918,8 @@ function __mreactHydrateClientBoundaries(marker, references, components) {
|
|
|
4920
4918
|
continue;
|
|
4921
4919
|
}
|
|
4922
4920
|
|
|
4923
|
-
|
|
4924
|
-
|
|
4925
|
-
placeholder.replaceWith(node);
|
|
4921
|
+
props = component(props);
|
|
4922
|
+
placeholder.replaceWith(...(props == null || typeof props === "boolean" ? [] : [props]));
|
|
4926
4923
|
propsElement?.remove();
|
|
4927
4924
|
hydrated = true;
|
|
4928
4925
|
}
|
package/src/native-escape.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
2
|
import { nativeModulePackageCandidates } from "./native-route-matcher.js";
|
|
3
|
-
import { escapeHtmlAttribute as escapeHtml } from "@reckona/mreact-shared/html-escape";
|
|
4
3
|
|
|
5
4
|
interface NativeEscapeModule {
|
|
6
5
|
escapeHtmlBatch?: (values: string[]) => string[];
|
|
@@ -19,6 +18,21 @@ export function escapeHtmlBatch(values: readonly unknown[]): string[] {
|
|
|
19
18
|
return native?.escapeHtmlBatch?.(strings) ?? strings.map(escapeHtml);
|
|
20
19
|
}
|
|
21
20
|
|
|
21
|
+
function escapeHtml(value: string): string {
|
|
22
|
+
return value.replace(/[&<>"]/g, (character) => {
|
|
23
|
+
switch (character) {
|
|
24
|
+
case "&":
|
|
25
|
+
return "&";
|
|
26
|
+
case "<":
|
|
27
|
+
return "<";
|
|
28
|
+
case ">":
|
|
29
|
+
return ">";
|
|
30
|
+
default:
|
|
31
|
+
return """;
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
22
36
|
function loadNativeEscapeModule(): NativeEscapeModule | undefined {
|
|
23
37
|
if (nativeModule === undefined) {
|
|
24
38
|
const require = nativePackageRequire();
|