@reckona/mreact-server 0.0.1

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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"native-flight.d.ts","sourceRoot":"","sources":["../src/native-flight.ts"],"names":[],"mappings":"AAeA,UAAU,kBAAkB;IAC1B,kBAAkB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,UAAU,CAAC;IACnD,oBAAoB,CAAC,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,MAAM,CAAC;IACxD,gBAAgB,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;IAC5C,eAAe,CAAC,EAAE,CAAC,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;CAClE;AAID,wBAAgB,eAAe,IAAI,kBAAkB,GAAG,SAAS,CAOhE"}
@@ -0,0 +1,63 @@
1
+ // Native binding loader for the Flight encode/decode hot path
2
+ // (issue 081). Mirrors the pattern in
3
+ // `packages/router/src/native-route-matcher.ts`: try the
4
+ // platform-specific prebuilt package first, then fall back to the
5
+ // workspace package built locally, then give up silently so the JS
6
+ // implementation stays the portable default.
7
+ //
8
+ // Selection is opt-in via `MR_FLIGHT_NATIVE=1` until benchmarks meet
9
+ // the issue 081 acceptance criteria. Once they do, this flips to
10
+ // "native by default, opt-out via MR_FLIGHT_NATIVE=0".
11
+ import { createRequire } from "node:module";
12
+ import { dirname, join } from "node:path";
13
+ import { fileURLToPath } from "node:url";
14
+ let loadedModule;
15
+ export function getNativeFlight() {
16
+ if (!shouldUseNativeFlight()) {
17
+ return undefined;
18
+ }
19
+ const native = loadNativeFlightModule();
20
+ return native === false ? undefined : native;
21
+ }
22
+ function shouldUseNativeFlight() {
23
+ return process.env.MR_FLIGHT_NATIVE === "1";
24
+ }
25
+ function loadNativeFlightModule() {
26
+ if (loadedModule !== undefined) {
27
+ return loadedModule;
28
+ }
29
+ const require = createRequire(import.meta.url);
30
+ for (const candidate of nativeModuleCandidates()) {
31
+ try {
32
+ loadedModule = require(candidate);
33
+ return loadedModule;
34
+ }
35
+ catch {
36
+ // Native package is optional. Fall through to the next candidate.
37
+ }
38
+ }
39
+ loadedModule = false;
40
+ return false;
41
+ }
42
+ function nativeModuleCandidates() {
43
+ const currentDir = dirname(fileURLToPath(import.meta.url));
44
+ const workspaceNativePackage = join(currentDir, "..", "..", "router-native");
45
+ return [
46
+ ...nativePlatformPackageCandidates(process.platform, process.arch),
47
+ "@reckona/mreact-router-native",
48
+ workspaceNativePackage,
49
+ ];
50
+ }
51
+ function nativePlatformPackageCandidates(platform, arch) {
52
+ if (platform === "linux" && arch === "x64") {
53
+ return ["@reckona/mreact-router-native-linux-x64-gnu"];
54
+ }
55
+ if (platform === "darwin" && arch === "arm64") {
56
+ return ["@reckona/mreact-router-native-darwin-arm64"];
57
+ }
58
+ if (platform === "win32" && arch === "x64") {
59
+ return ["@reckona/mreact-router-native-win32-x64-msvc"];
60
+ }
61
+ return [];
62
+ }
63
+ //# sourceMappingURL=native-flight.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"native-flight.js","sourceRoot":"","sources":["../src/native-flight.ts"],"names":[],"mappings":"AAAA,8DAA8D;AAC9D,sCAAsC;AACtC,yDAAyD;AACzD,kEAAkE;AAClE,mEAAmE;AACnE,6CAA6C;AAC7C,EAAE;AACF,qEAAqE;AACrE,iEAAiE;AACjE,uDAAuD;AAEvD,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;AASzC,IAAI,YAAoD,CAAC;AAEzD,MAAM,UAAU,eAAe;IAC7B,IAAI,CAAC,qBAAqB,EAAE,EAAE,CAAC;QAC7B,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,MAAM,GAAG,sBAAs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AO,EAAE,CAAC;QAC9C,OAAO,CAAC,4CAA4C,CAAC,CAAC;IACxD,CAAC;IACD,IAAI,QAAQ,KAAK,OAAO,IAAI,IAAI,KAAK,KAAK,EAAE,CAAC;QAC3C,OAAO,CAAC,8CAA8C,CAAC,CAAC;IAC1D,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function applyOutOfOrderFragments(root?: ParentNode): void;
2
+ //# sourceMappingURL=reorder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reorder.d.ts","sourceRoot":"","sources":["../src/reorder.ts"],"names":[],"mappings":"AAAA,wBAAgB,wBAAwB,CAAC,IAAI,GAAE,UAAqB,GAAG,IAAI,CAyB1E"}
@@ -0,0 +1,19 @@
1
+ export function applyOutOfOrderFragments(root = document) {
2
+ const fragments = Array.from(root.querySelectorAll("template[data-mreact-oob-fragment]"));
3
+ for (const fragment of fragments) {
4
+ const id = fragment.dataset.mreactOobFragment;
5
+ if (id === undefined) {
6
+ continue;
7
+ }
8
+ const placeholder = root.querySelector(`[data-mreact-oob-placeholder="${cssEscape(id)}"]`);
9
+ if (placeholder === null) {
10
+ continue;
11
+ }
12
+ placeholder.replaceWith(fragment.content.cloneNode(true));
13
+ fragment.remove();
14
+ }
15
+ }
16
+ function cssEscape(value) {
17
+ return value.replaceAll("\\", "\\\\").replaceAll("\"", "\\\"");
18
+ }
19
+ //# sourceMappingURL=reorder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reorder.js","sourceRoot":"","sources":["../src/reorder.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,wBAAwB,CAAC,OAAmB,QAAQ;IAClE,MAAM,SAAS,GAAG,KAAK,CAAC,IAAI,CAC1B,IAAI,CAAC,gBAAgB,CACnB,oCAAoC,CACrC,CACF,CAAC;IAEF,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;QACjC,MAAM,EAAE,GAAG,QAAQ,CAAC,OAAO,CAAC,iBAAiB,CAAC;QAE9C,IAAI,EAAE,KAAK,SAAS,EAAE,CAAC;YACrB,SAAS;QACX,CAAC;QAED,MAAM,WAAW,GAAG,IAAI,CAAC,aAAa,CACpC,iCAAiC,SAAS,CAAC,EAAE,CAAC,IAAI,CACnD,CAAC;QAEF,IAAI,WAAW,KAAK,IAAI,EAAE,CAAC;YACzB,SAAS;QACX,CAAC;QAED,WAAW,CAAC,WAAW,CAAC,QAAQ,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;QAC1D,QAAQ,CAAC,MAAM,EAAE,CAAC;IACpB,CAAC;AACH,CAAC;AAED,SAAS,SAAS,CAAC,KAAa;IAC9B,OAAO,KAAK,CAAC,UAAU,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,UAAU,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;AACjE,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { isDangerousHtmlAttribute, isDangerousHtmlOptIn, isSrcsetAttribute, isUnsafeMetaRefreshContent, isUnsafeUrlAttribute, isUrlAttribute, safeUrlAttributeValue, } from "@reckona/mreact-shared/url-safety";
2
+ //# sourceMappingURL=url-safety.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"url-safety.d.ts","sourceRoot":"","sources":["../src/url-safety.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EACxB,oBAAoB,EACpB,iBAAiB,EACjB,0BAA0B,EAC1B,oBAAoB,EACpB,cAAc,EACd,qBAAqB,GACtB,MAAM,mCAAmC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { isDangerousHtmlAttribute, isDangerousHtmlOptIn, isSrcsetAttribute, isUnsafeMetaRefreshContent, isUnsafeUrlAttribute, isUrlAttribute, safeUrlAttributeValue, } from "@reckona/mreact-shared/url-safety";
2
+ //# sourceMappingURL=url-safety.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"url-safety.js","sourceRoot":"","sources":["../src/url-safety.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EACxB,oBAAoB,EACpB,iBAAiB,EACjB,0BAA0B,EAC1B,oBAAoB,EACpB,cAAc,EACd,qBAAqB,GACtB,MAAM,mCAAmC,CAAC"}
package/package.json ADDED
@@ -0,0 +1,58 @@
1
+ {
2
+ "name": "@reckona/mreact-server",
3
+ "version": "0.0.1",
4
+ "description": "Server rendering, streaming, hydration, and Flight primitives for mreact.",
5
+ "keywords": [
6
+ "flight",
7
+ "jsx",
8
+ "mreact",
9
+ "server",
10
+ "ssr",
11
+ "streaming",
12
+ "typescript"
13
+ ],
14
+ "homepage": "https://github.com/t-k/mreact/tree/main/packages/server#readme",
15
+ "bugs": {
16
+ "url": "https://github.com/t-k/mreact/issues"
17
+ },
18
+ "license": "MIT",
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "https://github.com/t-k/mreact.git",
22
+ "directory": "packages/server"
23
+ },
24
+ "files": [
25
+ "dist/**/*.js",
26
+ "dist/**/*.js.map",
27
+ "dist/**/*.d.ts",
28
+ "dist/**/*.d.ts.map"
29
+ ],
30
+ "type": "module",
31
+ "sideEffects": false,
32
+ "types": "./dist/index.d.ts",
33
+ "exports": {
34
+ ".": {
35
+ "types": "./dist/index.d.ts",
36
+ "default": "./dist/index.js"
37
+ },
38
+ "./reorder": {
39
+ "types": "./dist/reorder.d.ts",
40
+ "default": "./dist/reorder.js"
41
+ },
42
+ "./flight": {
43
+ "types": "./dist/flight.d.ts",
44
+ "default": "./dist/flight.js"
45
+ },
46
+ "./buffer-sink": {
47
+ "types": "./dist/buffer-sink.d.ts",
48
+ "default": "./dist/buffer-sink.js"
49
+ }
50
+ },
51
+ "publishConfig": {
52
+ "access": "public"
53
+ },
54
+ "dependencies": {
55
+ "@reckona/mreact-compat": "0.0.1",
56
+ "@reckona/mreact-shared": "0.0.1"
57
+ }
58
+ }