@adaptive-js/ssr 0.0.0-stage → 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.
- package/LICENSE +21 -0
- package/README.md +24 -2
- package/dist/html/boundaries.d.ts +3 -0
- package/dist/html/boundaries.js +45 -0
- package/dist/html/boundaries.js.map +1 -0
- package/dist/html/children.d.ts +3 -0
- package/dist/html/children.js +27 -0
- package/dist/html/children.js.map +1 -0
- package/dist/html/constants.d.ts +4 -0
- package/dist/html/constants.js +28 -0
- package/dist/html/constants.js.map +1 -0
- package/dist/html/escape.d.ts +4 -0
- package/dist/html/escape.js +17 -0
- package/dist/html/escape.js.map +1 -0
- package/dist/html/hydration.d.ts +6 -0
- package/dist/html/hydration.js +53 -0
- package/dist/html/hydration.js.map +1 -0
- package/dist/html/index.d.ts +2 -0
- package/dist/html/index.js +6 -0
- package/dist/html/index.js.map +1 -0
- package/dist/html/reactive.d.ts +6 -0
- package/dist/html/reactive.js +35 -0
- package/dist/html/reactive.js.map +1 -0
- package/dist/html/render.d.ts +7 -0
- package/dist/html/render.js +112 -0
- package/dist/html/render.js.map +1 -0
- package/dist/html/types.d.ts +21 -0
- package/dist/html/types.js +5 -0
- package/dist/html/types.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/package.json +51 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Antonio Johnathan
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,25 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @adaptive-js/ssr
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Server-side rendering primitives for AdaptiveJS.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @adaptive-js/ssr
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { renderToString, renderToStringWithMetadata } from "@adaptive-js/ssr";
|
|
15
|
+
|
|
16
|
+
const html = renderToString(<App />);
|
|
17
|
+
|
|
18
|
+
const { html: page, clientModuleIds } = renderToStringWithMetadata(<App />);
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
`renderToStringWithMetadata` also returns the client module ids discovered while rendering, which the build uses to emit the hydration bundle.
|
|
22
|
+
|
|
23
|
+
## License
|
|
24
|
+
|
|
25
|
+
MIT
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2026 Antonio Johnathan
|
|
3
|
+
* Boundaries client/hydrate - ilhas
|
|
4
|
+
*/
|
|
5
|
+
import { CLIENT_BOUNDARY_END, CLIENT_BOUNDARY_MODE_CLIENT, CLIENT_BOUNDARY_MODE_HYDRATE, CLIENT_BOUNDARY_START_PREFIX, HYDRATE_SLOT_END, HYDRATE_SLOT_START } from "@adaptive-js/shared";
|
|
6
|
+
import { encodeCommentPayload } from "./escape.js";
|
|
7
|
+
import { getVNodeChildren } from "./children.js";
|
|
8
|
+
import { renderManifest } from "./hydration.js";
|
|
9
|
+
import { renderNode } from "./render.js";
|
|
10
|
+
export function renderHydrateSlot(node, context) {
|
|
11
|
+
return `<!--${HYDRATE_SLOT_START}-->${renderNode(getVNodeChildren(node), context)}<!--${HYDRATE_SLOT_END}-->`;
|
|
12
|
+
}
|
|
13
|
+
export function renderClientBoundary(node, context) {
|
|
14
|
+
const props = node.props ?? {};
|
|
15
|
+
const moduleId = String(props["data-adaptive-client-module"] ?? "");
|
|
16
|
+
const mode = String(props["data-adaptive-client-mode"] ?? CLIENT_BOUNDARY_MODE_CLIENT);
|
|
17
|
+
const exportName = String(props["data-adaptive-client-export"] ?? "default");
|
|
18
|
+
const rawProps = String(props["data-adaptive-client-props"] ?? "{}");
|
|
19
|
+
// createBoundary escreve o booleano, mas o mesmo marcador pode chegar aqui
|
|
20
|
+
// como atributo de um elemento real, ja serializado como string.
|
|
21
|
+
const rawHasChildren = props["data-adaptive-client-has-children"];
|
|
22
|
+
const hasChildren = rawHasChildren === true || rawHasChildren === "true";
|
|
23
|
+
let boundaryId = "";
|
|
24
|
+
if (mode === CLIENT_BOUNDARY_MODE_HYDRATE) {
|
|
25
|
+
const next = context.hydrateBoundaryCounter?.value ?? 0;
|
|
26
|
+
if (context.hydrateBoundaryCounter)
|
|
27
|
+
context.hydrateBoundaryCounter.value++;
|
|
28
|
+
boundaryId = `b${next}`;
|
|
29
|
+
}
|
|
30
|
+
if (moduleId)
|
|
31
|
+
context.clientModuleIds?.add(moduleId);
|
|
32
|
+
const bCtx = {
|
|
33
|
+
...context,
|
|
34
|
+
currentBoundaryId: boundaryId,
|
|
35
|
+
hydrateAidCounter: mode === CLIENT_BOUNDARY_MODE_HYDRATE ? { value: 0 } : undefined,
|
|
36
|
+
hydrateReactiveCounter: mode === CLIENT_BOUNDARY_MODE_HYDRATE ? { value: 0 } : undefined,
|
|
37
|
+
hydrateManifest: mode === CLIENT_BOUNDARY_MODE_HYDRATE ? [] : undefined,
|
|
38
|
+
hydrateInstructionCounters: mode === CLIENT_BOUNDARY_MODE_HYDRATE ? { event: 0, ref: 0, reactive: 0, dynamicProp: 0 } : undefined
|
|
39
|
+
};
|
|
40
|
+
const inner = renderNode(getVNodeChildren(node), bCtx);
|
|
41
|
+
const manifest = bCtx.hydrateManifest?.length ? renderManifest(boundaryId, bCtx.hydrateManifest) : "";
|
|
42
|
+
const payload = encodeCommentPayload({ mode, moduleId, exportName, rawProps, hasChildren, boundaryId });
|
|
43
|
+
return `<!--${CLIENT_BOUNDARY_START_PREFIX}${payload}-->${inner}${manifest}<!--${CLIENT_BOUNDARY_END}-->`;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=boundaries.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"boundaries.js","sourceRoot":"","sources":["../../src/html/boundaries.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACL,mBAAmB,EACnB,2BAA2B,EAC3B,4BAA4B,EAC5B,4BAA4B,EAC5B,gBAAgB,EAChB,kBAAkB,EACnB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEhD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,MAAM,UAAU,iBAAiB,CAAC,IAAS,EAAE,OAAsB;IACjE,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,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS;QACnF,sBAAsB,EAAE,IAAI,KAAK,4BAA4B,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS;QACxF,eAAe,EAAE,IAAI,KAAK,4BAA4B,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS;QACvE,0BAA0B,EAAE,IAAI,KAAK,4BAA4B,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS;KAClI,CAAC;IAEF,MAAM,KAAK,GAAG,UAAU,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC;IACvD,MAAM,QAAQ,GAAG,IAAI,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC,CAAC,cAAc,CAAC,UAAU,EAAE,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IACtG,MAAM,OAAO,GAAG,oBAAoB,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,WAAW,EAAE,UAAU,EAAE,CAAC,CAAC;IAExG,OAAO,OAAO,4BAA4B,GAAG,OAAO,MAAM,KAAK,GAAG,QAAQ,OAAO,mBAAmB,KAAK,CAAC;AAC5G,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2026 Antonio Johnathan
|
|
3
|
+
* Normalização de children e props
|
|
4
|
+
*/
|
|
5
|
+
export function getVNodeChildren(node) {
|
|
6
|
+
const c = node?.children ?? node?.props?.children;
|
|
7
|
+
if (c == null)
|
|
8
|
+
return [];
|
|
9
|
+
return Array.isArray(c) ? c : [c];
|
|
10
|
+
}
|
|
11
|
+
export function resolveComponentProps(node) {
|
|
12
|
+
const props = { ...(node.props ?? {}) };
|
|
13
|
+
const children = getVNodeChildren(node);
|
|
14
|
+
if (children.length > 0) {
|
|
15
|
+
props.children = children.length === 1 ? children[0] : children;
|
|
16
|
+
}
|
|
17
|
+
return props;
|
|
18
|
+
}
|
|
19
|
+
export function safePreview(fn) {
|
|
20
|
+
try {
|
|
21
|
+
return fn();
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
return "";
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=children.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"children.js","sourceRoot":"","sources":["../../src/html/children.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,UAAU,gBAAgB,CAAC,IAAS;IACxC,MAAM,CAAC,GAAG,IAAI,EAAE,QAAQ,IAAI,IAAI,EAAE,KAAK,EAAE,QAAQ,CAAC;IAClD,IAAI,CAAC,IAAI,IAAI;QAAE,OAAO,EAAE,CAAC;IACzB,OAAO,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACpC,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,IAAS;IAC7C,MAAM,KAAK,GAAG,EAAE,GAAG,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC,EAAE,CAAC;IACxC,MAAM,QAAQ,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC;IACxC,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACxB,KAAK,CAAC,QAAQ,GAAG,QAAQ,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;IAClE,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,EAAa;IACvC,IAAI,CAAC;QAAC,OAAO,EAAE,EAAE,CAAC;IAAC,CAAC;IAAC,MAAM,CAAC;QAAC,OAAO,EAAE,CAAC;IAAC,CAAC;AAC3C,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2026 Antonio Johnathan
|
|
3
|
+
* SSR constants - sem lógica, só dados
|
|
4
|
+
*/
|
|
5
|
+
export const FRAGMENT = Symbol.for("adaptive.fragment");
|
|
6
|
+
export const SVG_TAGS = new Set([
|
|
7
|
+
"svg", "circle", "defs", "g", "line", "path", "rect", "text", "ellipse", "polygon", "polyline",
|
|
8
|
+
"use", "clipPath", "mask", "linearGradient", "radialGradient", "stop", "foreignObject"
|
|
9
|
+
]);
|
|
10
|
+
export const SVG_ATTRIBUTE_NAME_MAP = {
|
|
11
|
+
className: "class",
|
|
12
|
+
strokeWidth: "stroke-width",
|
|
13
|
+
strokeLinecap: "stroke-linecap",
|
|
14
|
+
strokeLinejoin: "stroke-linejoin",
|
|
15
|
+
strokeDasharray: "stroke-dasharray",
|
|
16
|
+
strokeDashoffset: "strokeDashoffset",
|
|
17
|
+
strokeMiterlimit: "stroke-miterlimit",
|
|
18
|
+
fillRule: "fill-rule",
|
|
19
|
+
clipRule: "clip-rule",
|
|
20
|
+
viewBox: "viewBox",
|
|
21
|
+
preserveAspectRatio: "preserveAspectRatio",
|
|
22
|
+
vectorEffect: "vector-effect",
|
|
23
|
+
xmlnsXlink: "xmlns:xlink"
|
|
24
|
+
};
|
|
25
|
+
export const SELF_CLOSING_TAGS = new Set([
|
|
26
|
+
"area", "base", "br", "col", "embed", "hr", "img", "input", "link", "meta", "param", "source", "track", "wbr"
|
|
27
|
+
]);
|
|
28
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/html/constants.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,CAAC,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;AAExD,MAAM,CAAC,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC;IAC9B,KAAK,EAAC,QAAQ,EAAC,MAAM,EAAC,GAAG,EAAC,MAAM,EAAC,MAAM,EAAC,MAAM,EAAC,MAAM,EAAC,SAAS,EAAC,SAAS,EAAC,UAAU;IACpF,KAAK,EAAC,UAAU,EAAC,MAAM,EAAC,gBAAgB,EAAC,gBAAgB,EAAC,MAAM,EAAC,eAAe;CACjF,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,sBAAsB,GAA2B;IAC5D,SAAS,EAAE,OAAO;IAClB,WAAW,EAAE,cAAc;IAC3B,aAAa,EAAE,gBAAgB;IAC/B,cAAc,EAAE,iBAAiB;IACjC,eAAe,EAAE,kBAAkB;IACnC,gBAAgB,EAAE,kBAAkB;IACpC,gBAAgB,EAAE,mBAAmB;IACrC,QAAQ,EAAE,WAAW;IACrB,QAAQ,EAAE,WAAW;IACrB,OAAO,EAAE,SAAS;IAClB,mBAAmB,EAAE,qBAAqB;IAC1C,YAAY,EAAE,eAAe;IAC7B,UAAU,EAAE,aAAa;CAC1B,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,GAAG,CAAC;IACvC,MAAM,EAAC,MAAM,EAAC,IAAI,EAAC,KAAK,EAAC,OAAO,EAAC,IAAI,EAAC,KAAK,EAAC,OAAO,EAAC,MAAM,EAAC,MAAM,EAAC,OAAO,EAAC,QAAQ,EAAC,OAAO,EAAC,KAAK;CACjG,CAAC,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2026 Antonio Johnathan
|
|
3
|
+
* Helpers puros de escape - sem dependência de framework
|
|
4
|
+
*/
|
|
5
|
+
export function escapeAttr(v) {
|
|
6
|
+
return v.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">");
|
|
7
|
+
}
|
|
8
|
+
export function escapeHtml(v) {
|
|
9
|
+
return v.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
10
|
+
}
|
|
11
|
+
export function escapeScriptJson(v) {
|
|
12
|
+
return v.replace(/<\/script/gi, "<\\/script");
|
|
13
|
+
}
|
|
14
|
+
export function encodeCommentPayload(v) {
|
|
15
|
+
return encodeURIComponent(JSON.stringify(v));
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=escape.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"escape.js","sourceRoot":"","sources":["../../src/html/escape.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,UAAU,UAAU,CAAC,CAAS;IAClC,OAAO,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;AACtG,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,CAAS;IAClC,OAAO,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;AAC9E,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,CAAS;IACxC,OAAO,CAAC,CAAC,OAAO,CAAC,aAAa,EAAE,YAAY,CAAC,CAAC;AAChD,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,CAAM;IACzC,OAAO,kBAAkB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;AAC/C,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type HydrationManifestInstruction } from "@adaptive-js/shared";
|
|
2
|
+
import type { RenderContext } from "./types.js";
|
|
3
|
+
export declare function nextKey(context: RenderContext, kind: "event" | "ref" | "reactive" | "dynamicProp"): string;
|
|
4
|
+
export declare function maybeAllocateHydrationId(props: Record<string, any>, context: RenderContext): string | null;
|
|
5
|
+
export declare function appendManifestForProps(props: Record<string, any>, id: string, context: RenderContext): void;
|
|
6
|
+
export declare function renderManifest(boundaryId: string, instructions: HydrationManifestInstruction[]): string;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2026 Antonio Johnathan
|
|
3
|
+
* Manifest de hidratação fina - data-aid, eventos, refs, props dinâmicas
|
|
4
|
+
*/
|
|
5
|
+
import { HYDRATION_BOUNDARY_ID_ATTR, HYDRATION_MANIFEST_ATTR } from "@adaptive-js/shared";
|
|
6
|
+
import { isSupportedDynamicHydrationPropName } from "@adaptive-js/shared";
|
|
7
|
+
import { escapeAttr, escapeScriptJson } from "./escape.js";
|
|
8
|
+
export function nextKey(context, kind) {
|
|
9
|
+
const c = context.hydrateInstructionCounters;
|
|
10
|
+
if (!c)
|
|
11
|
+
return "";
|
|
12
|
+
const v = c[kind]++;
|
|
13
|
+
return kind === "event" ? `e${v}` : kind === "ref" ? `f${v}` : kind === "reactive" ? `rx${v}` : `p${v}`;
|
|
14
|
+
}
|
|
15
|
+
export function maybeAllocateHydrationId(props, context) {
|
|
16
|
+
if (!context.hydrateAidCounter)
|
|
17
|
+
return null;
|
|
18
|
+
if (props["data-aid"] != null)
|
|
19
|
+
return String(props["data-aid"]);
|
|
20
|
+
const needs = Object.entries(props).some(([k, v]) => {
|
|
21
|
+
if (k === "children" || k === "key")
|
|
22
|
+
return false;
|
|
23
|
+
if (k === "ref")
|
|
24
|
+
return v != null;
|
|
25
|
+
if (k.startsWith("on"))
|
|
26
|
+
return typeof v === "function";
|
|
27
|
+
return typeof v === "function" && isSupportedDynamicHydrationPropName(k);
|
|
28
|
+
});
|
|
29
|
+
if (!needs)
|
|
30
|
+
return null;
|
|
31
|
+
const id = context.hydrateAidCounter.value++;
|
|
32
|
+
return context.currentBoundaryId ? `${context.currentBoundaryId}:${id}` : String(id);
|
|
33
|
+
}
|
|
34
|
+
export function appendManifestForProps(props, id, context) {
|
|
35
|
+
if (!context.hydrateManifest)
|
|
36
|
+
return;
|
|
37
|
+
for (const [key, value] of Object.entries(props)) {
|
|
38
|
+
if (key.startsWith("on") && typeof value === "function") {
|
|
39
|
+
context.hydrateManifest.push({ key: nextKey(context, "event"), kind: "event", id, event: key.slice(2).toLowerCase() });
|
|
40
|
+
}
|
|
41
|
+
else if (key === "ref" && value != null) {
|
|
42
|
+
context.hydrateManifest.push({ key: nextKey(context, "ref"), kind: "ref", id });
|
|
43
|
+
}
|
|
44
|
+
else if (key !== "children" && typeof value === "function" && isSupportedDynamicHydrationPropName(key)) {
|
|
45
|
+
context.hydrateManifest.push({ key: nextKey(context, "dynamicProp"), kind: "dynamic-prop", id, prop: key });
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
export function renderManifest(boundaryId, instructions) {
|
|
50
|
+
const payload = escapeScriptJson(JSON.stringify({ boundaryId, instructions }));
|
|
51
|
+
return `<script type="application/json" ${HYDRATION_MANIFEST_ATTR}="true" ${HYDRATION_BOUNDARY_ID_ATTR}="${escapeAttr(boundaryId)}">${payload}</script>`;
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=hydration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hydration.js","sourceRoot":"","sources":["../../src/html/hydration.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACL,0BAA0B,EAC1B,uBAAuB,EAExB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,mCAAmC,EAAE,MAAM,qBAAqB,CAAC;AAC1E,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAG3D,MAAM,UAAU,OAAO,CAAC,OAAsB,EAAE,IAAkD;IAChG,MAAM,CAAC,GAAG,OAA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AAC,UAAkB,EAAE,YAA4C;IAC7F,MAAM,OAAO,GAAG,gBAAgB,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,UAAU,EAAE,YAAY,EAAE,CAAC,CAAC,CAAC;IAC/E,OAAO,mCAAmC,uBAAuB,WAAW,0BAA0B,KAAK,UAAU,CAAC,UAAU,CAAC,KAAK,OAAO,WAAW,CAAC;AAC3J,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/html/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,cAAc,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare function resolveReactiveMarkerPair(value: any): {
|
|
2
|
+
start: string;
|
|
3
|
+
end: string;
|
|
4
|
+
};
|
|
5
|
+
export declare function resolveManifestKind(start: string): "reactive-range" | "reactive-struct" | "reactive-list" | "reactive-async";
|
|
6
|
+
export declare function resolvePreview(v: any): any;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2026 Antonio Johnathan
|
|
3
|
+
* Lógica de markers reativos - decide que tipo de comentário gerar
|
|
4
|
+
*/
|
|
5
|
+
import { REACTIVE_ASYNC_END, REACTIVE_ASYNC_START, REACTIVE_CHILD_END, REACTIVE_CHILD_START, REACTIVE_LIST_END, REACTIVE_LIST_START, REACTIVE_STRUCT_END, REACTIVE_STRUCT_START } from "@adaptive-js/shared";
|
|
6
|
+
export function resolveReactiveMarkerPair(value) {
|
|
7
|
+
if (value != null && typeof value === "object" && typeof value.then === "function") {
|
|
8
|
+
return { start: REACTIVE_ASYNC_START, end: REACTIVE_ASYNC_END };
|
|
9
|
+
}
|
|
10
|
+
if (Array.isArray(value)) {
|
|
11
|
+
const isText = value.every((x) => Array.isArray(x)
|
|
12
|
+
? x.every((y) => y == null || typeof y !== "object")
|
|
13
|
+
: x == null || typeof x !== "object");
|
|
14
|
+
return isText
|
|
15
|
+
? { start: REACTIVE_CHILD_START, end: REACTIVE_CHILD_END }
|
|
16
|
+
: { start: REACTIVE_LIST_START, end: REACTIVE_LIST_END };
|
|
17
|
+
}
|
|
18
|
+
if (value == null || typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
|
|
19
|
+
return { start: REACTIVE_CHILD_START, end: REACTIVE_CHILD_END };
|
|
20
|
+
}
|
|
21
|
+
return { start: REACTIVE_STRUCT_START, end: REACTIVE_STRUCT_END };
|
|
22
|
+
}
|
|
23
|
+
export function resolveManifestKind(start) {
|
|
24
|
+
if (start === REACTIVE_CHILD_START)
|
|
25
|
+
return "reactive-range";
|
|
26
|
+
if (start === REACTIVE_STRUCT_START)
|
|
27
|
+
return "reactive-struct";
|
|
28
|
+
if (start === REACTIVE_LIST_START)
|
|
29
|
+
return "reactive-list";
|
|
30
|
+
return "reactive-async";
|
|
31
|
+
}
|
|
32
|
+
export function resolvePreview(v) {
|
|
33
|
+
return v != null && typeof v === "object" && typeof v.then === "function" ? "" : v;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=reactive.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reactive.js","sourceRoot":"","sources":["../../src/html/reactive.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,kBAAkB,EAClB,oBAAoB,EACpB,iBAAiB,EACjB,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACtB,MAAM,qBAAqB,CAAC;AAE7B,MAAM,UAAU,yBAAyB,CAAC,KAAU;IAClD,IAAI,KAAK,IAAI,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAQ,KAAa,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;QAC5F,OAAO,EAAE,KAAK,EAAE,oBAAoB,EAAE,GAAG,EAAE,kBAAkB,EAAE,CAAC;IAClE,CAAC;IAC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,IAAI,OAAQ,CAAS,CAAC,IAAI,KAAK,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;AAC9F,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { RenderContext } from "./types.js";
|
|
2
|
+
export declare function renderToString(node: any): string;
|
|
3
|
+
export declare function renderToStringWithMetadata(node: any): {
|
|
4
|
+
html: string;
|
|
5
|
+
clientModuleIds: string[];
|
|
6
|
+
};
|
|
7
|
+
export declare function renderNode(node: any, context: RenderContext): string;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2026 Antonio Johnathan
|
|
3
|
+
* Core SSR - renderNode é o único que conhece a árvore toda
|
|
4
|
+
*/
|
|
5
|
+
import { CONTEXT_PROVIDER_TAG, getClientComponentMetadata, runWithServerContext } from "@adaptive-js/shared";
|
|
6
|
+
import { isClientBoundaryTag, isHydrateSlotTag } from "@adaptive-js/shared";
|
|
7
|
+
import { CLIENT_BOUNDARY_MODE_CLIENT } from "@adaptive-js/shared";
|
|
8
|
+
import { FRAGMENT, SELF_CLOSING_TAGS, SVG_TAGS, SVG_ATTRIBUTE_NAME_MAP } from "./constants.js";
|
|
9
|
+
import { escapeAttr, escapeHtml } from "./escape.js";
|
|
10
|
+
import { serializeStyleLike } from "@adaptive-js/shared";
|
|
11
|
+
import { getVNodeChildren, resolveComponentProps, safePreview } from "./children.js";
|
|
12
|
+
import { resolveReactiveMarkerPair, resolveManifestKind, resolvePreview } from "./reactive.js";
|
|
13
|
+
import { maybeAllocateHydrationId, appendManifestForProps, nextKey } from "./hydration.js";
|
|
14
|
+
import { renderClientBoundary, renderHydrateSlot } from "./boundaries.js";
|
|
15
|
+
export function renderToString(node) {
|
|
16
|
+
// O contador precisa existir mesmo sem metadata: sem ele todo boundary
|
|
17
|
+
// hydrate sai com boundaryId "b0" e o client nao distingue as ilhas.
|
|
18
|
+
return renderNode(node, { hydrateBoundaryCounter: { value: 0 } });
|
|
19
|
+
}
|
|
20
|
+
export function renderToStringWithMetadata(node) {
|
|
21
|
+
const context = {
|
|
22
|
+
clientModuleIds: new Set(),
|
|
23
|
+
hydrateBoundaryCounter: { value: 0 }
|
|
24
|
+
};
|
|
25
|
+
return {
|
|
26
|
+
html: renderNode(node, context),
|
|
27
|
+
clientModuleIds: Array.from(context.clientModuleIds ?? [])
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
export function renderNode(node, context) {
|
|
31
|
+
// thunk reativo - hidratação fina
|
|
32
|
+
if (typeof node === "function") {
|
|
33
|
+
const preview = safePreview(node);
|
|
34
|
+
const localId = context.hydrateReactiveCounter ? String(context.hydrateReactiveCounter.value++) : null;
|
|
35
|
+
const reactiveId = localId && context.currentBoundaryId ? `${context.currentBoundaryId}:${localId}` : localId;
|
|
36
|
+
const marker = resolveReactiveMarkerPair(preview);
|
|
37
|
+
if (context.hydrateManifest && reactiveId) {
|
|
38
|
+
context.hydrateManifest.push({
|
|
39
|
+
key: nextKey(context, "reactive"),
|
|
40
|
+
kind: resolveManifestKind(marker.start),
|
|
41
|
+
id: reactiveId
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
const start = reactiveId ? `${marker.start}:${reactiveId}` : marker.start;
|
|
45
|
+
const end = reactiveId ? `${marker.end}:${reactiveId}` : marker.end;
|
|
46
|
+
const innerCtx = { ...context, hydrateManifest: undefined, hydrateInstructionCounters: undefined, hydrateAidCounter: undefined };
|
|
47
|
+
return `<!--${start}-->${renderNode(resolvePreview(preview), innerCtx)}<!--${end}-->`;
|
|
48
|
+
}
|
|
49
|
+
if (node == null || node === false || node === true)
|
|
50
|
+
return "";
|
|
51
|
+
if (typeof node === "string" || typeof node === "number")
|
|
52
|
+
return escapeHtml(String(node));
|
|
53
|
+
if (Array.isArray(node))
|
|
54
|
+
return node.map((c) => renderNode(c, context)).join("");
|
|
55
|
+
if (node.tag === CONTEXT_PROVIDER_TAG) {
|
|
56
|
+
return runWithServerContext(node.props.context.id, node.props.value, () => renderNode(node.children ?? [], context));
|
|
57
|
+
}
|
|
58
|
+
if (typeof node.tag === "function") {
|
|
59
|
+
const meta = getClientComponentMetadata?.(node.tag) ?? null;
|
|
60
|
+
const result = node.tag(resolveComponentProps(node));
|
|
61
|
+
if (meta?.mode === CLIENT_BOUNDARY_MODE_CLIENT || meta?.mode === "client") {
|
|
62
|
+
return renderNode(result, {
|
|
63
|
+
...context,
|
|
64
|
+
hydrateManifest: undefined,
|
|
65
|
+
hydrateInstructionCounters: undefined,
|
|
66
|
+
hydrateAidCounter: undefined,
|
|
67
|
+
hydrateReactiveCounter: undefined
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
return renderNode(result, context);
|
|
71
|
+
}
|
|
72
|
+
if (isHydrateSlotTag(node.tag))
|
|
73
|
+
return renderHydrateSlot(node, context);
|
|
74
|
+
if (isClientBoundaryTag(node.tag))
|
|
75
|
+
return renderClientBoundary(node, context);
|
|
76
|
+
if (node.tag === FRAGMENT || node.tag === "Fragment" || typeof node.tag === "symbol") {
|
|
77
|
+
return renderNode(getVNodeChildren(node), context);
|
|
78
|
+
}
|
|
79
|
+
const { tag, props = {} } = node;
|
|
80
|
+
const children = getVNodeChildren(node);
|
|
81
|
+
const isSvg = SVG_TAGS.has(tag);
|
|
82
|
+
let propsString = "";
|
|
83
|
+
const hydrateId = maybeAllocateHydrationId(props, context);
|
|
84
|
+
if (hydrateId && props["data-aid"] == null) {
|
|
85
|
+
propsString += ` data-aid="${escapeAttr(hydrateId)}"`;
|
|
86
|
+
appendManifestForProps(props, hydrateId, context);
|
|
87
|
+
}
|
|
88
|
+
for (const [key, value] of Object.entries(props)) {
|
|
89
|
+
if (key === "children" || key === "key" || key === "ref" || value == null || key === "data-aid")
|
|
90
|
+
continue;
|
|
91
|
+
if (key.startsWith("on") && typeof value === "function")
|
|
92
|
+
continue;
|
|
93
|
+
const attr = isSvg ? (SVG_ATTRIBUTE_NAME_MAP[key] ?? key) : key === "className" ? "class" : key;
|
|
94
|
+
if (key === "style") {
|
|
95
|
+
const s = serializeStyleLike(value);
|
|
96
|
+
if (s)
|
|
97
|
+
propsString += ` style="${escapeAttr(s)}"`;
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
const resolved = typeof value === "function" ? safePreview(value) : value;
|
|
101
|
+
if (resolved == null || resolved === false)
|
|
102
|
+
continue;
|
|
103
|
+
if (resolved === true)
|
|
104
|
+
propsString += ` ${attr}`;
|
|
105
|
+
else
|
|
106
|
+
propsString += ` ${attr}="${escapeAttr(String(resolved))}"`;
|
|
107
|
+
}
|
|
108
|
+
if (SELF_CLOSING_TAGS.has(tag))
|
|
109
|
+
return `<${tag}${propsString} />`;
|
|
110
|
+
return `<${tag}${propsString}>${renderNode(children, context)}</${tag}>`;
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=render.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"render.js","sourceRoot":"","sources":["../../src/html/render.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,oBAAoB,EAAE,0BAA0B,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC7G,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC5E,OAAO,EAAE,2BAA2B,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAAE,QAAQ,EAAE,iBAAiB,EAAE,QAAQ,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAC/F,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACrF,OAAO,EAAE,yBAAyB,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/F,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AAQ,GAAG,OAAO,KAAK,KAAK,UAAU,CAAC,CAAC,CAAC,WAAW,CAAC,KAAY,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;QACjF,IAAI,QAAQ,IAAI,IAAI,IAAI,QAAQ,KAAK,KAAK;YAAE,SAAS;QACrD,IAAI,QAAQ,KAAK,IAAI;YAAE,WAAW,IAAI,IAAI,IAAI,EAAE,CAAC;;YAC5C,WAAW,IAAI,IAAI,IAAI,KAAK,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC;IACnE,CAAC;IAED,IAAI,iBAAiB,CAAC,GAAG,CAAC,GAAG,CAAC;QAAE,OAAO,IAAI,GAAG,GAAG,WAAW,KAAK,CAAC;IAClE,OAAO,IAAI,GAAG,GAAG,WAAW,IAAI,UAAU,CAAC,QAAQ,EAAE,OAAO,CAAC,KAAK,GAAG,GAAG,CAAC;AAC3E,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { HydrationManifestInstruction } from "@adaptive-js/shared";
|
|
2
|
+
export type RenderContext = {
|
|
3
|
+
clientModuleIds?: Set<string>;
|
|
4
|
+
hydrateAidCounter?: {
|
|
5
|
+
value: number;
|
|
6
|
+
};
|
|
7
|
+
hydrateReactiveCounter?: {
|
|
8
|
+
value: number;
|
|
9
|
+
};
|
|
10
|
+
hydrateBoundaryCounter?: {
|
|
11
|
+
value: number;
|
|
12
|
+
};
|
|
13
|
+
hydrateManifest?: HydrationManifestInstruction[];
|
|
14
|
+
currentBoundaryId?: string;
|
|
15
|
+
hydrateInstructionCounters?: {
|
|
16
|
+
event: number;
|
|
17
|
+
ref: number;
|
|
18
|
+
reactive: number;
|
|
19
|
+
dynamicProp: number;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/html/types.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,cAAc,iBAAiB,CAAA;AAC/B,cAAc,qBAAqB,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,53 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adaptive-js/ssr",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Server-side rendering primitives for AdaptiveJS.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"adaptive-js",
|
|
7
|
+
"ssr",
|
|
8
|
+
"server-rendering",
|
|
9
|
+
"html"
|
|
10
|
+
],
|
|
11
|
+
"author": "Antonio Johnathan",
|
|
12
|
+
"license": "MIT",
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "git+https://github.com/SrJohnathan/adaptive-js.git",
|
|
16
|
+
"directory": "packages/ssr"
|
|
17
|
+
},
|
|
18
|
+
"homepage": "https://github.com/SrJohnathan/adaptive-js/tree/main/packages/ssr#readme",
|
|
19
|
+
"bugs": {
|
|
20
|
+
"url": "https://github.com/SrJohnathan/adaptive-js/issues"
|
|
21
|
+
},
|
|
22
|
+
"type": "module",
|
|
23
|
+
"main": "dist/index.js",
|
|
24
|
+
"types": "dist/index.d.ts",
|
|
25
|
+
"exports": {
|
|
26
|
+
".": {
|
|
27
|
+
"types": "./dist/index.d.ts",
|
|
28
|
+
"import": "./dist/index.js"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"files": [
|
|
32
|
+
"dist"
|
|
33
|
+
],
|
|
34
|
+
"scripts": {
|
|
35
|
+
"build": "npm run clean && tsc -p tsconfig.json",
|
|
36
|
+
"clean": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\"",
|
|
37
|
+
"prepublishOnly": "npm run build"
|
|
38
|
+
},
|
|
39
|
+
"engines": {
|
|
40
|
+
"node": ">=20.0.0"
|
|
41
|
+
},
|
|
42
|
+
"publishConfig": {
|
|
43
|
+
"access": "public"
|
|
44
|
+
},
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"@adaptive-js/shared": "0.0.1",
|
|
47
|
+
"@adaptive-js/jsx": "0.0.1"
|
|
48
|
+
},
|
|
49
|
+
"devDependencies": {
|
|
50
|
+
"typescript": "^6.0.3",
|
|
51
|
+
"@types/node": "^25.6.0"
|
|
52
|
+
}
|
|
53
|
+
}
|