hadars 0.1.40 → 0.2.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.
- package/README.md +85 -70
- package/cli-lib.ts +89 -12
- package/dist/chunk-HWOLYLPF.js +332 -0
- package/dist/{chunk-2ENP7IAW.js → chunk-LY5MTHFV.js} +360 -203
- package/dist/cli.js +506 -274
- package/dist/cloudflare.cjs +1394 -0
- package/dist/cloudflare.d.cts +64 -0
- package/dist/cloudflare.d.ts +64 -0
- package/dist/cloudflare.js +68 -0
- package/dist/{hadars-Bh-V5YXg.d.cts → hadars-DEBSYAQl.d.cts} +1 -36
- package/dist/{hadars-Bh-V5YXg.d.ts → hadars-DEBSYAQl.d.ts} +1 -36
- package/dist/index.cjs +129 -156
- package/dist/index.d.cts +5 -11
- package/dist/index.d.ts +5 -11
- package/dist/index.js +129 -155
- package/dist/lambda.cjs +391 -229
- package/dist/lambda.d.cts +1 -2
- package/dist/lambda.d.ts +1 -2
- package/dist/lambda.js +18 -307
- package/dist/slim-react/index.cjs +361 -203
- package/dist/slim-react/index.d.cts +24 -8
- package/dist/slim-react/index.d.ts +24 -8
- package/dist/slim-react/index.js +3 -1
- package/dist/ssr-render-worker.js +352 -221
- package/dist/utils/Head.tsx +132 -187
- package/package.json +7 -2
- package/src/build.ts +7 -6
- package/src/cloudflare.ts +139 -0
- package/src/index.tsx +0 -3
- package/src/lambda.ts +6 -2
- package/src/slim-react/context.ts +2 -1
- package/src/slim-react/index.ts +21 -18
- package/src/slim-react/render.ts +379 -240
- package/src/slim-react/renderContext.ts +105 -45
- package/src/ssr-render-worker.ts +14 -44
- package/src/types/hadars.ts +0 -1
- package/src/utils/Head.tsx +132 -187
- package/src/utils/cookies.ts +1 -1
- package/src/utils/response.tsx +68 -33
- package/src/utils/serve.ts +29 -27
- package/src/utils/ssrHandler.ts +54 -25
- package/src/utils/staticFile.ts +2 -7
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { SlimNode } from "./types";
|
|
2
|
+
import { getContextValue } from "./renderContext";
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Minimal Context implementation for SSR.
|
|
@@ -46,7 +47,7 @@ export function createContext<T>(defaultValue: T): Context<T> {
|
|
|
46
47
|
|
|
47
48
|
context.Consumer = ({ children }) => {
|
|
48
49
|
return (children as unknown as (value: T) => SlimNode)(
|
|
49
|
-
context
|
|
50
|
+
getContextValue<T>(context),
|
|
50
51
|
);
|
|
51
52
|
};
|
|
52
53
|
|
package/src/slim-react/index.ts
CHANGED
|
@@ -74,22 +74,20 @@ export function useContext<T>(context: Context<T>): T {
|
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
// ---- Rendering ----
|
|
77
|
-
import { renderToStream, renderToString, renderToReadableStream } from "./render";
|
|
78
|
-
export { renderToStream, renderToString, renderToReadableStream, type RenderOptions } from "./render";
|
|
77
|
+
import { renderToStream, renderToString, renderToReadableStream, renderPreflight } from "./render";
|
|
78
|
+
export { renderToStream, renderToString, renderToReadableStream, renderPreflight, type RenderOptions } from "./render";
|
|
79
79
|
|
|
80
80
|
// ---- Suspense (as a JSX tag) ----
|
|
81
81
|
import { SUSPENSE_TYPE } from "./types";
|
|
82
82
|
export const Suspense = SUSPENSE_TYPE;
|
|
83
83
|
|
|
84
84
|
// ---- Compat utilities ----
|
|
85
|
-
import { SLIM_ELEMENT, type SlimElement, type SlimNode } from "./types";
|
|
85
|
+
import { SLIM_ELEMENT, REACT19_ELEMENT, type SlimElement, type SlimNode } from "./types";
|
|
86
86
|
|
|
87
87
|
export function isValidElement(obj: unknown): obj is SlimElement {
|
|
88
|
-
return
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
(obj as any).$$typeof === SLIM_ELEMENT
|
|
92
|
-
);
|
|
88
|
+
if (typeof obj !== "object" || obj === null) return false;
|
|
89
|
+
const t = (obj as any).$$typeof;
|
|
90
|
+
return t === SLIM_ELEMENT || t === REACT19_ELEMENT;
|
|
93
91
|
}
|
|
94
92
|
|
|
95
93
|
export function cloneElement(
|
|
@@ -98,7 +96,7 @@ export function cloneElement(
|
|
|
98
96
|
...children: SlimNode[]
|
|
99
97
|
): SlimElement {
|
|
100
98
|
return {
|
|
101
|
-
$$typeof: SLIM_ELEMENT,
|
|
99
|
+
$$typeof: (element as any).$$typeof || SLIM_ELEMENT,
|
|
102
100
|
type: element.type,
|
|
103
101
|
props: {
|
|
104
102
|
...element.props,
|
|
@@ -115,18 +113,23 @@ export function cloneElement(
|
|
|
115
113
|
|
|
116
114
|
export function forwardRef<P = any>(
|
|
117
115
|
render: (props: P, ref: any) => SlimNode,
|
|
118
|
-
):
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
(render as any).displayName || (render as any).name || "ForwardRef"
|
|
123
|
-
|
|
116
|
+
): any {
|
|
117
|
+
return {
|
|
118
|
+
$$typeof: Symbol.for("react.forward_ref"),
|
|
119
|
+
render,
|
|
120
|
+
displayName: (render as any).displayName || (render as any).name || "ForwardRef",
|
|
121
|
+
};
|
|
124
122
|
}
|
|
125
123
|
|
|
126
124
|
export function memo<P = any>(
|
|
127
125
|
component: (props: P) => SlimNode,
|
|
128
|
-
|
|
129
|
-
|
|
126
|
+
compare?: (prevProps: P, nextProps: P) => boolean,
|
|
127
|
+
): any {
|
|
128
|
+
return {
|
|
129
|
+
$$typeof: Symbol.for("react.memo"),
|
|
130
|
+
type: component,
|
|
131
|
+
compare: compare ?? null,
|
|
132
|
+
};
|
|
130
133
|
}
|
|
131
134
|
|
|
132
135
|
export function lazy<P = any>(
|
|
@@ -221,7 +224,7 @@ const React = {
|
|
|
221
224
|
// Compat
|
|
222
225
|
Children, Component, PureComponent,
|
|
223
226
|
// Rendering
|
|
224
|
-
renderToStream, renderToString, renderToReadableStream,
|
|
227
|
+
renderToStream, renderToString, renderToReadableStream, renderPreflight,
|
|
225
228
|
// Version
|
|
226
229
|
version,
|
|
227
230
|
};
|