@modern-js/render 0.0.0-nightly-20251223160450 → 0.0.0-nightly-20251225160330
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/cjs/client/index.js +5 -9
- package/dist/cjs/server/rsc/index.js +3 -1
- package/dist/cjs/server/rsc/processRSCStream.js +59 -0
- package/dist/esm/client/index.js +6 -10
- package/dist/esm/server/rsc/index.js +1 -0
- package/dist/esm/server/rsc/processRSCStream.js +86 -0
- package/dist/esm-node/client/index.js +6 -10
- package/dist/esm-node/server/rsc/index.js +1 -0
- package/dist/esm-node/server/rsc/processRSCStream.js +35 -0
- package/dist/types/server/rsc/index.d.ts +1 -0
- package/dist/types/server/rsc/processRSCStream.d.ts +1 -0
- package/package.json +4 -4
package/dist/cjs/client/index.js
CHANGED
|
@@ -54,16 +54,12 @@ function RscClientRoot({ rscPayload }) {
|
|
|
54
54
|
});
|
|
55
55
|
}
|
|
56
56
|
const ElementsContext = /* @__PURE__ */ (0, import_react2.createContext)(null);
|
|
57
|
-
const JSX_SHELL_STREAM_END_MARK = "<!--<?- SHELL_STREAM_END ?>-->";
|
|
58
57
|
const ServerElementsProvider = ({ elements, children }) => {
|
|
59
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.
|
|
60
|
-
children:
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}),
|
|
65
|
-
JSX_SHELL_STREAM_END_MARK
|
|
66
|
-
]
|
|
58
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {
|
|
59
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ElementsContext.Provider, {
|
|
60
|
+
value: elements,
|
|
61
|
+
children
|
|
62
|
+
})
|
|
67
63
|
});
|
|
68
64
|
};
|
|
69
65
|
const RSCServerSlot = () => {
|
|
@@ -16,7 +16,9 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
16
16
|
var rsc_exports = {};
|
|
17
17
|
module.exports = __toCommonJS(rsc_exports);
|
|
18
18
|
__reExport(rsc_exports, require("./rsc"), module.exports);
|
|
19
|
+
__reExport(rsc_exports, require("./processRSCStream"), module.exports);
|
|
19
20
|
// Annotate the CommonJS export names for ESM import in node:
|
|
20
21
|
0 && (module.exports = {
|
|
21
|
-
...require("./rsc")
|
|
22
|
+
...require("./rsc"),
|
|
23
|
+
...require("./processRSCStream")
|
|
22
24
|
});
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var processRSCStream_exports = {};
|
|
20
|
+
__export(processRSCStream_exports, {
|
|
21
|
+
processRSCStream: () => processRSCStream
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(processRSCStream_exports);
|
|
24
|
+
async function processRSCStream(rscStream, controller, encoder) {
|
|
25
|
+
try {
|
|
26
|
+
const reader = rscStream.getReader();
|
|
27
|
+
const decoder = new TextDecoder("utf-8", {
|
|
28
|
+
fatal: true
|
|
29
|
+
});
|
|
30
|
+
while (true) {
|
|
31
|
+
const { done, value } = await reader.read();
|
|
32
|
+
if (done)
|
|
33
|
+
break;
|
|
34
|
+
try {
|
|
35
|
+
const chunk = JSON.stringify(decoder.decode(value, {
|
|
36
|
+
stream: true
|
|
37
|
+
}));
|
|
38
|
+
const scriptTag = `<script>(self.__FLIGHT_DATA||=[]).push(${chunk})</script>`;
|
|
39
|
+
controller.enqueue(encoder.encode(scriptTag));
|
|
40
|
+
} catch (err) {
|
|
41
|
+
const base64 = JSON.stringify(btoa(String.fromCodePoint(...value)));
|
|
42
|
+
const scriptTag = `<script>(self.__FLIGHT_DATA||=[]).push(Uint8Array.from(atob(${base64}), m => m.codePointAt(0)))</script>`;
|
|
43
|
+
controller.enqueue(encoder.encode(scriptTag));
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
const remaining = decoder.decode();
|
|
47
|
+
if (remaining.length) {
|
|
48
|
+
const scriptTag = `<script>(self.__FLIGHT_DATA||=[]).push(${JSON.stringify(remaining)})</script>`;
|
|
49
|
+
controller.enqueue(encoder.encode(scriptTag));
|
|
50
|
+
}
|
|
51
|
+
controller.close();
|
|
52
|
+
} catch (error) {
|
|
53
|
+
controller.error(error);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
57
|
+
0 && (module.exports = {
|
|
58
|
+
processRSCStream
|
|
59
|
+
});
|
package/dist/esm/client/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { _ as _sliced_to_array } from "@swc/helpers/_/_sliced_to_array";
|
|
2
|
-
import { jsx as _jsx,
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import React from "react";
|
|
4
4
|
import { createContext, useState } from "react";
|
|
5
5
|
import { createFromReadableStream, createServerReference } from "react-server-dom-webpack/client.browser";
|
|
@@ -15,17 +15,13 @@ function RscClientRoot(param) {
|
|
|
15
15
|
});
|
|
16
16
|
}
|
|
17
17
|
var ElementsContext = /* @__PURE__ */ createContext(null);
|
|
18
|
-
var JSX_SHELL_STREAM_END_MARK = "<!--<?- SHELL_STREAM_END ?>-->";
|
|
19
18
|
var ServerElementsProvider = function(param) {
|
|
20
19
|
var elements = param.elements, children = param.children;
|
|
21
|
-
return /* @__PURE__ */
|
|
22
|
-
children:
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}),
|
|
27
|
-
JSX_SHELL_STREAM_END_MARK
|
|
28
|
-
]
|
|
20
|
+
return /* @__PURE__ */ _jsx(_Fragment, {
|
|
21
|
+
children: /* @__PURE__ */ _jsx(ElementsContext.Provider, {
|
|
22
|
+
value: elements,
|
|
23
|
+
children
|
|
24
|
+
})
|
|
29
25
|
});
|
|
30
26
|
};
|
|
31
27
|
var RSCServerSlot = function() {
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
|
|
2
|
+
import { _ as _to_consumable_array } from "@swc/helpers/_/_to_consumable_array";
|
|
3
|
+
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
|
4
|
+
function processRSCStream(rscStream, controller, encoder) {
|
|
5
|
+
return _processRSCStream.apply(this, arguments);
|
|
6
|
+
}
|
|
7
|
+
function _processRSCStream() {
|
|
8
|
+
_processRSCStream = _async_to_generator(function(rscStream, controller, encoder) {
|
|
9
|
+
var reader, decoder, _ref, done, value, chunk, scriptTag, _String, base64, scriptTag1, remaining, scriptTag2, error;
|
|
10
|
+
return _ts_generator(this, function(_state) {
|
|
11
|
+
switch (_state.label) {
|
|
12
|
+
case 0:
|
|
13
|
+
_state.trys.push([
|
|
14
|
+
0,
|
|
15
|
+
4,
|
|
16
|
+
,
|
|
17
|
+
5
|
|
18
|
+
]);
|
|
19
|
+
reader = rscStream.getReader();
|
|
20
|
+
decoder = new TextDecoder("utf-8", {
|
|
21
|
+
fatal: true
|
|
22
|
+
});
|
|
23
|
+
_state.label = 1;
|
|
24
|
+
case 1:
|
|
25
|
+
if (false)
|
|
26
|
+
return [
|
|
27
|
+
3,
|
|
28
|
+
3
|
|
29
|
+
];
|
|
30
|
+
return [
|
|
31
|
+
4,
|
|
32
|
+
reader.read()
|
|
33
|
+
];
|
|
34
|
+
case 2:
|
|
35
|
+
_ref = _state.sent(), done = _ref.done, value = _ref.value;
|
|
36
|
+
if (done)
|
|
37
|
+
return [
|
|
38
|
+
3,
|
|
39
|
+
3
|
|
40
|
+
];
|
|
41
|
+
try {
|
|
42
|
+
chunk = JSON.stringify(decoder.decode(value, {
|
|
43
|
+
stream: true
|
|
44
|
+
}));
|
|
45
|
+
scriptTag = "<script>(self.__FLIGHT_DATA||=[]).push(".concat(chunk, ")</script>");
|
|
46
|
+
controller.enqueue(encoder.encode(scriptTag));
|
|
47
|
+
} catch (err) {
|
|
48
|
+
;
|
|
49
|
+
base64 = JSON.stringify(btoa((_String = String).fromCodePoint.apply(_String, _to_consumable_array(value))));
|
|
50
|
+
scriptTag1 = "<script>(self.__FLIGHT_DATA||=[]).push(Uint8Array.from(atob(".concat(base64, "), m => m.codePointAt(0)))</script>");
|
|
51
|
+
controller.enqueue(encoder.encode(scriptTag1));
|
|
52
|
+
}
|
|
53
|
+
return [
|
|
54
|
+
3,
|
|
55
|
+
1
|
|
56
|
+
];
|
|
57
|
+
case 3:
|
|
58
|
+
remaining = decoder.decode();
|
|
59
|
+
if (remaining.length) {
|
|
60
|
+
scriptTag2 = "<script>(self.__FLIGHT_DATA||=[]).push(".concat(JSON.stringify(remaining), ")</script>");
|
|
61
|
+
controller.enqueue(encoder.encode(scriptTag2));
|
|
62
|
+
}
|
|
63
|
+
controller.close();
|
|
64
|
+
return [
|
|
65
|
+
3,
|
|
66
|
+
5
|
|
67
|
+
];
|
|
68
|
+
case 4:
|
|
69
|
+
error = _state.sent();
|
|
70
|
+
controller.error(error);
|
|
71
|
+
return [
|
|
72
|
+
3,
|
|
73
|
+
5
|
|
74
|
+
];
|
|
75
|
+
case 5:
|
|
76
|
+
return [
|
|
77
|
+
2
|
|
78
|
+
];
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
return _processRSCStream.apply(this, arguments);
|
|
83
|
+
}
|
|
84
|
+
export {
|
|
85
|
+
processRSCStream
|
|
86
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx as _jsx,
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import React from "react";
|
|
3
3
|
import { createContext, useState } from "react";
|
|
4
4
|
import { createFromReadableStream, createServerReference } from "react-server-dom-webpack/client.browser";
|
|
@@ -13,16 +13,12 @@ function RscClientRoot({ rscPayload }) {
|
|
|
13
13
|
});
|
|
14
14
|
}
|
|
15
15
|
const ElementsContext = /* @__PURE__ */ createContext(null);
|
|
16
|
-
const JSX_SHELL_STREAM_END_MARK = "<!--<?- SHELL_STREAM_END ?>-->";
|
|
17
16
|
const ServerElementsProvider = ({ elements, children }) => {
|
|
18
|
-
return /* @__PURE__ */
|
|
19
|
-
children:
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}),
|
|
24
|
-
JSX_SHELL_STREAM_END_MARK
|
|
25
|
-
]
|
|
17
|
+
return /* @__PURE__ */ _jsx(_Fragment, {
|
|
18
|
+
children: /* @__PURE__ */ _jsx(ElementsContext.Provider, {
|
|
19
|
+
value: elements,
|
|
20
|
+
children
|
|
21
|
+
})
|
|
26
22
|
});
|
|
27
23
|
};
|
|
28
24
|
const RSCServerSlot = () => {
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
async function processRSCStream(rscStream, controller, encoder) {
|
|
2
|
+
try {
|
|
3
|
+
const reader = rscStream.getReader();
|
|
4
|
+
const decoder = new TextDecoder("utf-8", {
|
|
5
|
+
fatal: true
|
|
6
|
+
});
|
|
7
|
+
while (true) {
|
|
8
|
+
const { done, value } = await reader.read();
|
|
9
|
+
if (done)
|
|
10
|
+
break;
|
|
11
|
+
try {
|
|
12
|
+
const chunk = JSON.stringify(decoder.decode(value, {
|
|
13
|
+
stream: true
|
|
14
|
+
}));
|
|
15
|
+
const scriptTag = `<script>(self.__FLIGHT_DATA||=[]).push(${chunk})</script>`;
|
|
16
|
+
controller.enqueue(encoder.encode(scriptTag));
|
|
17
|
+
} catch (err) {
|
|
18
|
+
const base64 = JSON.stringify(btoa(String.fromCodePoint(...value)));
|
|
19
|
+
const scriptTag = `<script>(self.__FLIGHT_DATA||=[]).push(Uint8Array.from(atob(${base64}), m => m.codePointAt(0)))</script>`;
|
|
20
|
+
controller.enqueue(encoder.encode(scriptTag));
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
const remaining = decoder.decode();
|
|
24
|
+
if (remaining.length) {
|
|
25
|
+
const scriptTag = `<script>(self.__FLIGHT_DATA||=[]).push(${JSON.stringify(remaining)})</script>`;
|
|
26
|
+
controller.enqueue(encoder.encode(scriptTag));
|
|
27
|
+
}
|
|
28
|
+
controller.close();
|
|
29
|
+
} catch (error) {
|
|
30
|
+
controller.error(error);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
export {
|
|
34
|
+
processRSCStream
|
|
35
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function processRSCStream(rscStream: ReadableStream, controller: ReadableStreamDefaultController<Uint8Array>, encoder: TextEncoder): Promise<void>;
|
package/package.json
CHANGED
|
@@ -15,15 +15,15 @@
|
|
|
15
15
|
"modern",
|
|
16
16
|
"modern.js"
|
|
17
17
|
],
|
|
18
|
-
"version": "0.0.0-nightly-
|
|
18
|
+
"version": "0.0.0-nightly-20251225160330",
|
|
19
19
|
"files": [
|
|
20
20
|
"dist",
|
|
21
21
|
"hook.d.ts"
|
|
22
22
|
],
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@swc/helpers": "^0.5.17",
|
|
25
|
-
"@modern-js/types": "0.0.0-nightly-
|
|
26
|
-
"@modern-js/utils": "0.0.0-nightly-
|
|
25
|
+
"@modern-js/types": "0.0.0-nightly-20251225160330",
|
|
26
|
+
"@modern-js/utils": "0.0.0-nightly-20251225160330"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@types/jest": "^29",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"react": "^18.3.1",
|
|
34
34
|
"react-dom": "^18.3.1",
|
|
35
35
|
"typescript": "^5",
|
|
36
|
-
"@modern-js/server-core": "0.0.0-nightly-
|
|
36
|
+
"@modern-js/server-core": "0.0.0-nightly-20251225160330"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
39
|
"react": ">=17.0.0",
|