@emberkit/core 0.2.0 → 0.2.3
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 +199 -0
- package/dist/boundaries/error-boundary.d.ts +29 -0
- package/dist/boundaries/error-boundary.d.ts.map +1 -0
- package/dist/boundaries/errors.d.ts +39 -0
- package/dist/boundaries/errors.d.ts.map +1 -0
- package/dist/boundaries/index.d.ts +5 -0
- package/dist/boundaries/index.d.ts.map +1 -0
- package/dist/boundaries/loading-boundary.d.ts +42 -0
- package/dist/boundaries/loading-boundary.d.ts.map +1 -0
- package/dist/cache/index.d.ts +60 -0
- package/dist/cache/index.d.ts.map +1 -0
- package/dist/cache/index.js +24 -22
- package/dist/compiler/compiler.d.ts +6 -0
- package/dist/compiler/compiler.d.ts.map +1 -0
- package/dist/compiler/helpers/attributes.d.ts +4 -0
- package/dist/compiler/helpers/attributes.d.ts.map +1 -0
- package/dist/compiler/helpers/utils.d.ts +10 -0
- package/dist/compiler/helpers/utils.d.ts.map +1 -0
- package/dist/compiler/index.d.ts +5 -0
- package/dist/compiler/index.d.ts.map +1 -0
- package/dist/compiler/types.d.ts +40 -0
- package/dist/compiler/types.d.ts.map +1 -0
- package/dist/context/index.d.ts +34 -0
- package/dist/context/index.d.ts.map +1 -0
- package/dist/context/types.d.ts +10 -0
- package/dist/context/types.d.ts.map +1 -0
- package/dist/dev-server/index.d.ts +30 -0
- package/dist/dev-server/index.d.ts.map +1 -0
- package/dist/dev-server/index.js +27 -27
- package/dist/forms/index.d.ts +58 -0
- package/dist/forms/index.d.ts.map +1 -0
- package/dist/forms/index.js +1 -1
- package/dist/forms/mutations.d.ts +48 -0
- package/dist/forms/mutations.d.ts.map +1 -0
- package/dist/forms/mutations.js +4 -1
- package/dist/hmr/client.d.ts +18 -0
- package/dist/hmr/client.d.ts.map +1 -0
- package/dist/hmr/client.js +1 -1
- package/dist/hmr/index.d.ts +3 -0
- package/dist/hmr/index.d.ts.map +1 -0
- package/dist/hmr/types.d.ts +42 -0
- package/dist/hmr/types.d.ts.map +1 -0
- package/dist/hmr/types.js +7 -7
- package/dist/hydration/helpers/analyzer.d.ts +9 -0
- package/dist/hydration/helpers/analyzer.d.ts.map +1 -0
- package/dist/hydration/helpers/hydration.d.ts +19 -0
- package/dist/hydration/helpers/hydration.d.ts.map +1 -0
- package/dist/hydration/helpers/hydration.js +1 -1
- package/dist/hydration/index.d.ts +4 -0
- package/dist/hydration/index.d.ts.map +1 -0
- package/dist/hydration/types.d.ts +27 -0
- package/dist/hydration/types.d.ts.map +1 -0
- package/dist/hydration/types.js +32 -8
- package/dist/image/index.d.ts +9 -0
- package/dist/image/index.d.ts.map +1 -0
- package/dist/image/index.js +1 -1
- package/dist/image/processor.d.ts +57 -0
- package/dist/image/processor.d.ts.map +1 -0
- package/dist/image/processor.js +20 -15
- package/dist/index.d.ts +20 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -2
- package/dist/jsx-dev-runtime.d.ts +11 -0
- package/dist/jsx-dev-runtime.d.ts.map +1 -0
- package/dist/jsx-runtime.d.ts +11 -0
- package/dist/jsx-runtime.d.ts.map +1 -0
- package/dist/loader/helpers/loader.d.ts +6 -0
- package/dist/loader/helpers/loader.d.ts.map +1 -0
- package/dist/loader/index.d.ts +3 -0
- package/dist/loader/index.d.ts.map +1 -0
- package/dist/loader/types.d.ts +34 -0
- package/dist/loader/types.d.ts.map +1 -0
- package/dist/markdown/index.d.ts +77 -0
- package/dist/markdown/index.d.ts.map +1 -0
- package/dist/markdown/index.js +178 -172
- package/dist/mdx/index.d.ts +43 -0
- package/dist/mdx/index.d.ts.map +1 -0
- package/dist/mdx/index.js +46 -40
- package/dist/mdx/loader.d.ts +3 -0
- package/dist/mdx/loader.d.ts.map +1 -0
- package/dist/meta/head-registry.d.ts +5 -0
- package/dist/meta/head-registry.d.ts.map +1 -0
- package/dist/meta/head.d.ts +29 -0
- package/dist/meta/head.d.ts.map +1 -0
- package/dist/meta/index.d.ts +91 -0
- package/dist/meta/index.d.ts.map +1 -0
- package/dist/meta/index.js +16 -16
- package/dist/navigation/helpers/navigation.d.ts +15 -0
- package/dist/navigation/helpers/navigation.d.ts.map +1 -0
- package/dist/navigation/helpers/navigation.js +4 -4
- package/dist/navigation/helpers/useNavigate.d.ts +6 -0
- package/dist/navigation/helpers/useNavigate.d.ts.map +1 -0
- package/dist/navigation/index.d.ts +5 -0
- package/dist/navigation/index.d.ts.map +1 -0
- package/dist/navigation/types.d.ts +24 -0
- package/dist/navigation/types.d.ts.map +1 -0
- package/dist/navigation/types.js +1 -2
- package/dist/plugin/index.d.ts +73 -0
- package/dist/plugin/index.d.ts.map +1 -0
- package/dist/plugin/index.js +4 -4
- package/dist/router/helpers/path.d.ts +15 -0
- package/dist/router/helpers/path.d.ts.map +1 -0
- package/dist/router/helpers/route.d.ts +6 -0
- package/dist/router/helpers/route.d.ts.map +1 -0
- package/dist/router/helpers/route.js +10 -3
- package/dist/router/index.d.ts +35 -0
- package/dist/router/index.d.ts.map +1 -0
- package/dist/router/types.d.ts +30 -0
- package/dist/router/types.d.ts.map +1 -0
- package/dist/router/types.js +1 -3
- package/dist/runtime/helpers/element.d.ts +7 -0
- package/dist/runtime/helpers/element.d.ts.map +1 -0
- package/dist/runtime/helpers/render.d.ts +8 -0
- package/dist/runtime/helpers/render.d.ts.map +1 -0
- package/dist/runtime/helpers/render.js +37 -8
- package/dist/runtime/index.d.ts +16 -0
- package/dist/runtime/index.d.ts.map +1 -0
- package/dist/runtime/index.js +63 -7
- package/dist/runtime/types.d.ts +65 -0
- package/dist/runtime/types.d.ts.map +1 -0
- package/dist/signals/helpers/core.d.ts +11 -0
- package/dist/signals/helpers/core.d.ts.map +1 -0
- package/dist/signals/helpers/core.js +34 -12
- package/dist/signals/helpers/utils.d.ts +7 -0
- package/dist/signals/helpers/utils.d.ts.map +1 -0
- package/dist/signals/index.d.ts +4 -0
- package/dist/signals/index.d.ts.map +1 -0
- package/dist/signals/types.d.ts +23 -0
- package/dist/signals/types.d.ts.map +1 -0
- package/dist/ssg/index.d.ts +38 -0
- package/dist/ssg/index.d.ts.map +1 -0
- package/dist/ssg/index.js +8 -15
- package/dist/ssr/helpers/render-html.d.ts +16 -0
- package/dist/ssr/helpers/render-html.d.ts.map +1 -0
- package/dist/ssr/helpers/render-html.js +3 -2
- package/dist/ssr/helpers/ssr.d.ts +14 -0
- package/dist/ssr/helpers/ssr.d.ts.map +1 -0
- package/dist/ssr/helpers/ssr.js +3 -1
- package/dist/ssr/index.d.ts +4 -0
- package/dist/ssr/index.d.ts.map +1 -0
- package/dist/ssr/types.d.ts +29 -0
- package/dist/ssr/types.d.ts.map +1 -0
- package/dist/vite-plugin/index.d.ts +5 -0
- package/dist/vite-plugin/index.d.ts.map +1 -0
- package/dist/vite-plugin/index.js +207 -28
- package/dist/vite-plugin/types.d.ts +44 -0
- package/dist/vite-plugin/types.d.ts.map +1 -0
- package/dist/vite-plugin/types.js +4 -0
- package/package.json +12 -10
package/dist/runtime/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { renderToString, getHandler, clearHandlers } from './helpers/render.js';
|
|
2
|
+
import { getSignalByIndex } from '../signals/helpers/core.js';
|
|
2
3
|
export function createElement(type, props, ...children) {
|
|
3
4
|
const resolvedProps = props ?? {};
|
|
4
5
|
const flatChildren = children.flat().filter((child) => child != null && child !== false);
|
|
@@ -32,6 +33,66 @@ function renderToTarget(layout, target, routeComponent) {
|
|
|
32
33
|
const html = renderToString(jsxElement);
|
|
33
34
|
target.innerHTML = html;
|
|
34
35
|
attachEventHandlers(target);
|
|
36
|
+
hydrateSignalBindings(target);
|
|
37
|
+
}
|
|
38
|
+
function hydrateSignalBindings(container) {
|
|
39
|
+
const els = container.querySelectorAll('[data-ek-bind]');
|
|
40
|
+
els.forEach((el) => {
|
|
41
|
+
const idx = parseInt(el.getAttribute('data-ek-bind') ?? '', 10);
|
|
42
|
+
if (isNaN(idx))
|
|
43
|
+
return;
|
|
44
|
+
const sig = getSignalByIndex(idx);
|
|
45
|
+
if (!sig)
|
|
46
|
+
return;
|
|
47
|
+
const showClasses = el.getAttribute('data-ek-show') ?? '';
|
|
48
|
+
const hideClasses = el.getAttribute('data-ek-hide') ?? '';
|
|
49
|
+
const showWhen = el.getAttribute('data-ek-show-when');
|
|
50
|
+
const hideClass = el.getAttribute('data-ek-hide-class') ?? 'hidden';
|
|
51
|
+
const activeWhen = el.getAttribute('data-ek-active-when');
|
|
52
|
+
const activeClass = el.getAttribute('data-ek-active-class');
|
|
53
|
+
const inactiveClassAttr = el.getAttribute('data-ek-inactive-class');
|
|
54
|
+
sig.subscribe((val) => {
|
|
55
|
+
if (activeWhen != null && activeClass != null && activeClass.length > 0) {
|
|
56
|
+
const isActive = String(val) === activeWhen;
|
|
57
|
+
activeClass.split(' ').forEach((c) => {
|
|
58
|
+
if (c)
|
|
59
|
+
el.classList.toggle(c, isActive);
|
|
60
|
+
});
|
|
61
|
+
if (inactiveClassAttr && inactiveClassAttr.length > 0) {
|
|
62
|
+
inactiveClassAttr.split(' ').forEach((c) => {
|
|
63
|
+
if (c)
|
|
64
|
+
el.classList.toggle(c, !isActive);
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
if (activeClass != null &&
|
|
70
|
+
activeClass.length > 0 &&
|
|
71
|
+
(!inactiveClassAttr || inactiveClassAttr.length === 0)) {
|
|
72
|
+
const isVisible = !!val;
|
|
73
|
+
activeClass.split(' ').forEach((c) => {
|
|
74
|
+
if (c)
|
|
75
|
+
el.classList.toggle(c, isVisible);
|
|
76
|
+
});
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
if (showWhen != null) {
|
|
80
|
+
el.classList.toggle(hideClass, String(val) !== showWhen);
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
if (showClasses || hideClasses) {
|
|
84
|
+
const isVisible = !!val;
|
|
85
|
+
if (showClasses) {
|
|
86
|
+
showClasses.split(' ').forEach((c) => el.classList.toggle(c, isVisible));
|
|
87
|
+
}
|
|
88
|
+
if (hideClasses) {
|
|
89
|
+
hideClasses.split(' ').forEach((c) => el.classList.toggle(c, !isVisible));
|
|
90
|
+
}
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
el.textContent = String(val);
|
|
94
|
+
});
|
|
95
|
+
});
|
|
35
96
|
}
|
|
36
97
|
export function render(element, container, options) {
|
|
37
98
|
if (!element)
|
|
@@ -40,9 +101,7 @@ export function render(element, container, options) {
|
|
|
40
101
|
if (!target) {
|
|
41
102
|
throw new Error(`Container element not found: ${container}`);
|
|
42
103
|
}
|
|
43
|
-
const layout = typeof element === 'function'
|
|
44
|
-
? element
|
|
45
|
-
: null;
|
|
104
|
+
const layout = typeof element === 'function' ? element : null;
|
|
46
105
|
if (!layout) {
|
|
47
106
|
const html = renderToString(element);
|
|
48
107
|
target.innerHTML = html;
|
|
@@ -125,8 +184,5 @@ export function flushSync(fn) {
|
|
|
125
184
|
fn();
|
|
126
185
|
}
|
|
127
186
|
export function isElement(element) {
|
|
128
|
-
return
|
|
129
|
-
element !== null &&
|
|
130
|
-
'type' in element &&
|
|
131
|
-
'props' in element);
|
|
187
|
+
return typeof element === 'object' && element !== null && 'type' in element && 'props' in element;
|
|
132
188
|
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
export interface JSXElementProps {
|
|
2
|
+
children?: JSXNode | JSXNode[];
|
|
3
|
+
key?: string;
|
|
4
|
+
ref?: {
|
|
5
|
+
current: Element | null;
|
|
6
|
+
};
|
|
7
|
+
[key: string]: unknown;
|
|
8
|
+
}
|
|
9
|
+
export type JSXNode = JSXElement | string | number | null | false | undefined;
|
|
10
|
+
export interface JSXElement {
|
|
11
|
+
type: string | ((props: JSXElementProps) => JSXNode);
|
|
12
|
+
props: JSXElementProps;
|
|
13
|
+
}
|
|
14
|
+
export type RouteChildren = JSXNode;
|
|
15
|
+
export interface RouteComponent<P extends JSXElementProps = JSXElementProps> {
|
|
16
|
+
(props: P): JSXNode;
|
|
17
|
+
displayName?: string;
|
|
18
|
+
}
|
|
19
|
+
declare module 'react' {
|
|
20
|
+
namespace JSX {
|
|
21
|
+
interface Element extends JSXElement {
|
|
22
|
+
}
|
|
23
|
+
interface IntrinsicElements {
|
|
24
|
+
[elemName: string]: JSXElementProps;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
export interface FC<P extends JSXElementProps = JSXElementProps> {
|
|
29
|
+
(props: P): JSXNode;
|
|
30
|
+
displayName?: string;
|
|
31
|
+
}
|
|
32
|
+
export type DOMElement = JSXElement & {
|
|
33
|
+
type: string;
|
|
34
|
+
};
|
|
35
|
+
export interface RenderOptions {
|
|
36
|
+
container: Element | string;
|
|
37
|
+
hydrate?: boolean;
|
|
38
|
+
}
|
|
39
|
+
export interface EmberKitConfig {
|
|
40
|
+
mode: 'static' | 'ssr' | 'spa' | 'hybrid';
|
|
41
|
+
output: string;
|
|
42
|
+
jsx: 'automatic' | 'classic';
|
|
43
|
+
target: string;
|
|
44
|
+
vite?: Record<string, unknown>;
|
|
45
|
+
plugins?: unknown[];
|
|
46
|
+
}
|
|
47
|
+
export interface RouteParams<T extends Record<string, string> = Record<string, string>> {
|
|
48
|
+
params: T;
|
|
49
|
+
query: Record<string, string | string[]>;
|
|
50
|
+
request: Request;
|
|
51
|
+
}
|
|
52
|
+
export interface LoaderData<T> {
|
|
53
|
+
data: T;
|
|
54
|
+
error?: never;
|
|
55
|
+
}
|
|
56
|
+
export interface LoaderError {
|
|
57
|
+
data?: never;
|
|
58
|
+
error: {
|
|
59
|
+
code: string;
|
|
60
|
+
message: string;
|
|
61
|
+
status: number;
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
export type LoaderResult<T> = LoaderData<T> | LoaderError;
|
|
65
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/runtime/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,EAAE,OAAO,GAAG,OAAO,EAAE,CAAC;IAC/B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE;QAAE,OAAO,EAAE,OAAO,GAAG,IAAI,CAAA;KAAE,CAAC;IAClC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,MAAM,MAAM,OAAO,GAAG,UAAU,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,KAAK,GAAG,SAAS,CAAC;AAE9E,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,GAAG,CAAC,CAAC,KAAK,EAAE,eAAe,KAAK,OAAO,CAAC,CAAC;IACrD,KAAK,EAAE,eAAe,CAAC;CACxB;AAED,MAAM,MAAM,aAAa,GAAG,OAAO,CAAC;AAEpC,MAAM,WAAW,cAAc,CAAC,CAAC,SAAS,eAAe,GAAG,eAAe;IACzE,CAAC,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAGD,OAAO,QAAQ,OAAO,CAAC;IACrB,UAAU,GAAG,CAAC;QACZ,UAAU,OAAQ,SAAQ,UAAU;SAAG;QACvC,UAAU,iBAAiB;YACzB,CAAC,QAAQ,EAAE,MAAM,GAAG,eAAe,CAAC;SACrC;KACF;CACF;AAGD,MAAM,WAAW,EAAE,CAAC,CAAC,SAAS,eAAe,GAAG,eAAe;IAC7D,CAAC,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,MAAM,UAAU,GAAG,UAAU,GAAG;IACpC,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,WAAW,aAAa;IAC5B,SAAS,EAAE,OAAO,GAAG,MAAM,CAAC;IAC5B,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,QAAQ,GAAG,KAAK,GAAG,KAAK,GAAG,QAAQ,CAAC;IAC1C,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,WAAW,GAAG,SAAS,CAAC;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,OAAO,CAAC,EAAE,OAAO,EAAE,CAAC;CACrB;AAED,MAAM,WAAW,WAAW,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IACpF,MAAM,EAAE,CAAC,CAAC;IACV,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,CAAC;IACzC,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,UAAU,CAAC,CAAC;IAC3B,IAAI,EAAE,CAAC,CAAC;IACR,KAAK,CAAC,EAAE,KAAK,CAAC;CACf;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,CAAC,EAAE,KAAK,CAAC;IACb,KAAK,EAAE;QACL,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;QAChB,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;CACH;AAED,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI,UAAU,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Signal, SignalOptions } from '../types.js';
|
|
2
|
+
export declare function resetSigIndex(): void;
|
|
3
|
+
export declare function getSignalByIndex(idx: number): {
|
|
4
|
+
subscribe: (fn: (v: unknown) => void) => () => void;
|
|
5
|
+
} | undefined;
|
|
6
|
+
export declare function createSignal<T>(initialValue: T, options?: SignalOptions<T>): [() => T, (newValue: T | ((prev: T) => T)) => void] & Signal<T>;
|
|
7
|
+
export declare function createMemo<T>(computation: () => T, _options?: SignalOptions<T>): Signal<T>;
|
|
8
|
+
export declare function createEffect(callback: () => void | (() => void)): () => void;
|
|
9
|
+
export declare function batch<T>(fn: () => T): T;
|
|
10
|
+
export declare function untrack<T>(fn: () => T): T;
|
|
11
|
+
//# sourceMappingURL=core.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../../src/signals/helpers/core.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAKzD,wBAAgB,aAAa,IAAI,IAAI,CAEpC;AAED,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,MAAM,GACV;IAAE,SAAS,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,OAAO,KAAK,IAAI,KAAK,MAAM,IAAI,CAAA;CAAE,GAAG,SAAS,CAErE;AAED,wBAAgB,YAAY,CAAC,CAAC,EAC5B,YAAY,EAAE,CAAC,EACf,OAAO,GAAE,aAAa,CAAC,CAAC,CAAM,GAC7B,CAAC,MAAM,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,IAAI,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAmEjE;AAED,wBAAgB,UAAU,CAAC,CAAC,EAAE,WAAW,EAAE,MAAM,CAAC,EAAE,QAAQ,CAAC,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAqB1F;AAED,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,GAAG,MAAM,IAAI,CAqB5E;AAED,wBAAgB,KAAK,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,CAEvC;AAED,wBAAgB,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,CAEzC"}
|
|
@@ -1,32 +1,54 @@
|
|
|
1
|
-
|
|
1
|
+
let sigIndex = 0;
|
|
2
|
+
const sigRegistry = new Map();
|
|
3
|
+
export function resetSigIndex() {
|
|
4
|
+
sigIndex = 0;
|
|
5
|
+
}
|
|
6
|
+
export function getSignalByIndex(idx) {
|
|
7
|
+
return sigRegistry.get(idx);
|
|
8
|
+
}
|
|
2
9
|
export function createSignal(initialValue, options = {}) {
|
|
3
|
-
const { equals = DEFAULT_EQUALS } = options;
|
|
4
10
|
let value = initialValue;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
11
|
+
const subs = new Set();
|
|
12
|
+
const idx = sigIndex++;
|
|
8
13
|
function getter() {
|
|
9
14
|
return value;
|
|
10
15
|
}
|
|
16
|
+
getter.__idx = idx;
|
|
11
17
|
function setter(newValue) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
18
|
+
const next = typeof newValue === 'function' ? newValue(value) : newValue;
|
|
19
|
+
if (value === next)
|
|
20
|
+
return;
|
|
21
|
+
value = next;
|
|
22
|
+
if (subs.size > 0) {
|
|
23
|
+
const fns = [...subs];
|
|
24
|
+
for (let i = 0; i < fns.length; i++)
|
|
25
|
+
fns[i](value);
|
|
15
26
|
}
|
|
16
27
|
}
|
|
28
|
+
function subscribe(fn) {
|
|
29
|
+
subs.add(fn);
|
|
30
|
+
return () => subs.delete(fn);
|
|
31
|
+
}
|
|
32
|
+
sigRegistry.set(idx, { subscribe: subscribe });
|
|
17
33
|
const signal = {
|
|
18
34
|
get value() {
|
|
19
35
|
return value;
|
|
20
36
|
},
|
|
21
37
|
set value(newValue) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
38
|
+
const next = typeof newValue === 'function' ? newValue(value) : newValue;
|
|
39
|
+
if (value === next)
|
|
40
|
+
return;
|
|
41
|
+
value = next;
|
|
42
|
+
if (subs.size > 0) {
|
|
43
|
+
const fns = [...subs];
|
|
44
|
+
for (let i = 0; i < fns.length; i++)
|
|
45
|
+
fns[i](value);
|
|
25
46
|
}
|
|
26
47
|
},
|
|
27
48
|
peek() {
|
|
28
49
|
return value;
|
|
29
50
|
},
|
|
51
|
+
subscribe,
|
|
30
52
|
[Symbol.iterator]() {
|
|
31
53
|
let index = 0;
|
|
32
54
|
const methods = [getter, setter];
|
|
@@ -43,7 +65,6 @@ export function createSignal(initialValue, options = {}) {
|
|
|
43
65
|
};
|
|
44
66
|
},
|
|
45
67
|
};
|
|
46
|
-
// Make it array-like for tuple destructuring: [getter, setter]
|
|
47
68
|
signal[0] = getter;
|
|
48
69
|
signal[1] = setter;
|
|
49
70
|
signal.length = 2;
|
|
@@ -67,6 +88,7 @@ export function createMemo(computation, _options) {
|
|
|
67
88
|
}
|
|
68
89
|
return value;
|
|
69
90
|
},
|
|
91
|
+
subscribe: () => (() => { }),
|
|
70
92
|
};
|
|
71
93
|
}
|
|
72
94
|
export function createEffect(callback) {
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Signal, ReadonlySignal } from '../types.js';
|
|
2
|
+
export declare function isSignal(value: unknown): value is Signal<unknown>;
|
|
3
|
+
export declare function isReadonlySignal<T>(signal: Signal<T>): signal is ReadonlySignal<T>;
|
|
4
|
+
export declare function getSignalValue<T>(signal: Signal<T>): T;
|
|
5
|
+
export declare function setSignalValue<T>(signal: Signal<T>, value: T): void;
|
|
6
|
+
export declare function readSignal<T>(signal: Signal<T>): T;
|
|
7
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/signals/helpers/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE1D,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAAC,OAAO,CAAC,CAGjE;AAED,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI,cAAc,CAAC,CAAC,CAAC,CAElF;AAED,wBAAgB,cAAc,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAEtD;AAED,wBAAgB,cAAc,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI,CAOnE;AAED,wBAAgB,UAAU,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAElD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/signals/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export interface SignalOptions<T> {
|
|
2
|
+
equals?: (prev: T, next: T) => boolean;
|
|
3
|
+
}
|
|
4
|
+
export interface Signal<T> {
|
|
5
|
+
value: T;
|
|
6
|
+
readonly peek: () => T;
|
|
7
|
+
subscribe: (fn: (v: T) => void) => () => void;
|
|
8
|
+
}
|
|
9
|
+
export interface ReadonlySignal<T> {
|
|
10
|
+
readonly value: T;
|
|
11
|
+
readonly peek: () => T;
|
|
12
|
+
subscribe: (fn: (v: T) => void) => () => void;
|
|
13
|
+
}
|
|
14
|
+
export interface WritableSignal<T> extends Signal<T> {
|
|
15
|
+
value: T;
|
|
16
|
+
}
|
|
17
|
+
export interface EffectCleanup {
|
|
18
|
+
readonly: () => void;
|
|
19
|
+
}
|
|
20
|
+
export type EffectCallback = () => void | (() => void);
|
|
21
|
+
export type EqualityFn<T> = (prev: T, next: T) => boolean;
|
|
22
|
+
export declare const DEFAULT_EQUALS: <T>(prev: T, next: T) => boolean;
|
|
23
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/signals/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa,CAAC,CAAC;IAC9B,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,KAAK,OAAO,CAAC;CACxC;AAED,MAAM,WAAW,MAAM,CAAC,CAAC;IACvB,KAAK,EAAE,CAAC,CAAC;IACT,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IACvB,SAAS,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,IAAI,KAAK,MAAM,IAAI,CAAC;CAC/C;AAED,MAAM,WAAW,cAAc,CAAC,CAAC;IAC/B,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC;IAClB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IACvB,SAAS,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,IAAI,KAAK,MAAM,IAAI,CAAC;CAC/C;AAED,MAAM,WAAW,cAAc,CAAC,CAAC,CAAE,SAAQ,MAAM,CAAC,CAAC,CAAC;IAClD,KAAK,EAAE,CAAC,CAAC;CACV;AAED,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,MAAM,IAAI,CAAC;CACtB;AAED,MAAM,MAAM,cAAc,GAAG,MAAM,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC;AAEvD,MAAM,MAAM,UAAU,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,KAAK,OAAO,CAAC;AAE1D,eAAO,MAAM,cAAc,GAAI,CAAC,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,YAAkB,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export interface SSGConfig {
|
|
2
|
+
outDir: string;
|
|
3
|
+
routes: string[];
|
|
4
|
+
prerender?: boolean;
|
|
5
|
+
cacheControl?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface SSGManifest {
|
|
8
|
+
pages: Map<string, string>;
|
|
9
|
+
errors: Map<string, Error>;
|
|
10
|
+
buildTime: number;
|
|
11
|
+
}
|
|
12
|
+
export interface StaticPage {
|
|
13
|
+
path: string;
|
|
14
|
+
html: string;
|
|
15
|
+
status: number;
|
|
16
|
+
headers: Record<string, string>;
|
|
17
|
+
}
|
|
18
|
+
export declare class SSGBuilder {
|
|
19
|
+
private config;
|
|
20
|
+
private manifest;
|
|
21
|
+
constructor(config: SSGConfig);
|
|
22
|
+
build(renderFn: (path: string) => Promise<string>): Promise<SSGManifest>;
|
|
23
|
+
getBuildStats(): {
|
|
24
|
+
pages: number;
|
|
25
|
+
errors: number;
|
|
26
|
+
time: number;
|
|
27
|
+
};
|
|
28
|
+
getManifest(): SSGManifest;
|
|
29
|
+
}
|
|
30
|
+
export declare function generateStaticPages(routes: string[], renderFn: (path: string) => Promise<string>, options?: Partial<SSGConfig>): Promise<SSGManifest>;
|
|
31
|
+
export declare function createSSGManifest(pages: StaticPage[]): SSGManifest;
|
|
32
|
+
export declare function serializeManifest(manifest: SSGManifest): string;
|
|
33
|
+
export declare function deserializeManifest(json: string): SSGManifest;
|
|
34
|
+
export declare const STATIC_ROUTE_PATTERNS: string[];
|
|
35
|
+
export declare function isStaticRoute(path: string): boolean;
|
|
36
|
+
export declare function crawlRoutes(startPath: string, shouldCrawl: (path: string) => Promise<boolean>, getLinks: (html: string) => string[]): Promise<string[]>;
|
|
37
|
+
export declare function estimateBuildTime(pages: number): number;
|
|
38
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ssg/index.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC3B,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAC3B,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACjC;AAED,qBAAa,UAAU;IACrB,OAAO,CAAC,MAAM,CAAsB;IACpC,OAAO,CAAC,QAAQ,CAAc;gBAElB,MAAM,EAAE,SAAS;IAcvB,KAAK,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,WAAW,CAAC;IA+B9E,aAAa,IAAI;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE;IAQhE,WAAW,IAAI,WAAW;CAG3B;AAED,wBAAsB,mBAAmB,CACvC,MAAM,EAAE,MAAM,EAAE,EAChB,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,EAC3C,OAAO,GAAE,OAAO,CAAC,SAAS,CAAM,GAC/B,OAAO,CAAC,WAAW,CAAC,CAQtB;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,UAAU,EAAE,GAAG,WAAW,CAMlE;AAED,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,WAAW,GAAG,MAAM,CAM/D;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,CAQ7D;AAED,eAAO,MAAM,qBAAqB,UAAmD,CAAC;AAEtF,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAInD;AAED,wBAAsB,WAAW,CAC/B,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,EAC/C,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,EAAE,GACnC,OAAO,CAAC,MAAM,EAAE,CAAC,CA4BnB;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEvD"}
|
package/dist/ssg/index.js
CHANGED
|
@@ -39,9 +39,6 @@ export class SSGBuilder {
|
|
|
39
39
|
this.manifest.buildTime = Date.now() - start;
|
|
40
40
|
return this.manifest;
|
|
41
41
|
}
|
|
42
|
-
getManifest() {
|
|
43
|
-
return this.manifest;
|
|
44
|
-
}
|
|
45
42
|
getBuildStats() {
|
|
46
43
|
return {
|
|
47
44
|
pages: this.manifest.pages.size,
|
|
@@ -49,6 +46,9 @@ export class SSGBuilder {
|
|
|
49
46
|
time: this.manifest.buildTime,
|
|
50
47
|
};
|
|
51
48
|
}
|
|
49
|
+
getManifest() {
|
|
50
|
+
return this.manifest;
|
|
51
|
+
}
|
|
52
52
|
}
|
|
53
53
|
export async function generateStaticPages(routes, renderFn, options = {}) {
|
|
54
54
|
const builder = new SSGBuilder({
|
|
@@ -80,18 +80,9 @@ export function deserializeManifest(json) {
|
|
|
80
80
|
buildTime: data.buildTime,
|
|
81
81
|
};
|
|
82
82
|
}
|
|
83
|
-
export const STATIC_ROUTE_PATTERNS = [
|
|
84
|
-
'/',
|
|
85
|
-
'/about',
|
|
86
|
-
'/contact',
|
|
87
|
-
'/blog',
|
|
88
|
-
'/pricing',
|
|
89
|
-
];
|
|
83
|
+
export const STATIC_ROUTE_PATTERNS = ['/', '/about', '/contact', '/blog', '/pricing'];
|
|
90
84
|
export function isStaticRoute(path) {
|
|
91
|
-
return (!path.includes('[') &&
|
|
92
|
-
!path.includes(':') &&
|
|
93
|
-
!path.startsWith('/api/') &&
|
|
94
|
-
!path.includes('...'));
|
|
85
|
+
return (!path.includes('[') && !path.includes(':') && !path.startsWith('/api/') && !path.includes('...'));
|
|
95
86
|
}
|
|
96
87
|
export async function crawlRoutes(startPath, shouldCrawl, getLinks) {
|
|
97
88
|
const visited = new Set();
|
|
@@ -103,7 +94,9 @@ export async function crawlRoutes(startPath, shouldCrawl, getLinks) {
|
|
|
103
94
|
}
|
|
104
95
|
visited.add(path);
|
|
105
96
|
if (await shouldCrawl(path)) {
|
|
106
|
-
const html = await fetch(path)
|
|
97
|
+
const html = await fetch(path)
|
|
98
|
+
.then((r) => r.text())
|
|
99
|
+
.catch(() => '');
|
|
107
100
|
const links = getLinks(html);
|
|
108
101
|
for (const link of links) {
|
|
109
102
|
if (!visited.has(link)) {
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { JSXNode } from '../../runtime/types.js';
|
|
2
|
+
export declare function renderToHTMLString(element: JSXNode | null): string;
|
|
3
|
+
export declare function renderChildrenToHTML(children: (string | number | JSXNode)[]): string;
|
|
4
|
+
export declare function createHtmlDocument(html: string, options?: {
|
|
5
|
+
title?: string;
|
|
6
|
+
lang?: string;
|
|
7
|
+
doctype?: string;
|
|
8
|
+
baseUrl?: string;
|
|
9
|
+
headExtra?: string;
|
|
10
|
+
}): string;
|
|
11
|
+
export declare function escapeHtml(text: string): string;
|
|
12
|
+
export declare function createMetaTags(meta: Record<string, string>): string;
|
|
13
|
+
export declare function createLinkTags(links: Record<string, string>): string;
|
|
14
|
+
export declare function createScriptTags(scripts: string[]): string;
|
|
15
|
+
export declare function createStyleTags(styles: string[]): string;
|
|
16
|
+
//# sourceMappingURL=render-html.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"render-html.d.ts","sourceRoot":"","sources":["../../../src/ssr/helpers/render-html.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAc,MAAM,wBAAwB,CAAC;AAElE,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,GAAG,MAAM,CAQlE;AAED,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,CAAC,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,EAAE,GAAG,MAAM,CAEpF;AAED,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE;IACP,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;CACf,GACL,MAAM,CAwBR;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAO/C;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAInE;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAIpE;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,CAE1D;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,CAExD"}
|
|
@@ -15,8 +15,9 @@ export function renderChildrenToHTML(children) {
|
|
|
15
15
|
return children.map((child) => renderToHTMLString(child)).join('');
|
|
16
16
|
}
|
|
17
17
|
export function createHtmlDocument(html, options = {}) {
|
|
18
|
-
const { title = '', lang = 'en', doctype = '<!DOCTYPE html>', baseUrl = '', headExtra = '' } = options;
|
|
19
|
-
const fullHtml = doctype +
|
|
18
|
+
const { title = '', lang = 'en', doctype = '<!DOCTYPE html>', baseUrl = '', headExtra = '', } = options;
|
|
19
|
+
const fullHtml = doctype +
|
|
20
|
+
'\n' +
|
|
20
21
|
`<html${lang ? ` lang="${lang}"` : ''}>\n` +
|
|
21
22
|
'<head>\n' +
|
|
22
23
|
`<meta charset="utf-8">\n` +
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { JSXNode } from '../../runtime/types.js';
|
|
2
|
+
import type { LoaderResult } from '../../loader/types.js';
|
|
3
|
+
import type { SSRRenderOptions, SSRRenderResult } from '../types.js';
|
|
4
|
+
export declare function renderSSR(element: JSXNode | null, options?: SSRRenderOptions): SSRRenderResult;
|
|
5
|
+
export declare function renderSSRWithError(element: JSXNode | null, error: LoaderResult<unknown> | null, options?: SSRRenderOptions): SSRRenderResult;
|
|
6
|
+
export declare function renderSSRWithHeaders(element: JSXNode | null, headers: Record<string, string>, options?: SSRRenderOptions): SSRRenderResult;
|
|
7
|
+
export declare function createStreamingRenderer(): {
|
|
8
|
+
write(html: string): void;
|
|
9
|
+
writeChunk(type: "html" | "status" | "error", content: string): void;
|
|
10
|
+
end(): string;
|
|
11
|
+
reset(): void;
|
|
12
|
+
};
|
|
13
|
+
export declare function injectScripts(html: string, scripts: string[]): string;
|
|
14
|
+
//# sourceMappingURL=ssr.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ssr.d.ts","sourceRoot":"","sources":["../../../src/ssr/helpers/ssr.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAG1D,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAGrE,wBAAgB,SAAS,CACvB,OAAO,EAAE,OAAO,GAAG,IAAI,EACvB,OAAO,GAAE,gBAAqB,GAC7B,eAAe,CA4BjB;AAED,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,OAAO,GAAG,IAAI,EACvB,KAAK,EAAE,YAAY,CAAC,OAAO,CAAC,GAAG,IAAI,EACnC,OAAO,GAAE,gBAAqB,GAC7B,eAAe,CAyBjB;AAED,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,OAAO,GAAG,IAAI,EACvB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC/B,OAAO,GAAE,gBAAqB,GAC7B,eAAe,CAQjB;AAED,wBAAgB,uBAAuB;gBAIvB,MAAM,GAAG,IAAI;qBAIR,MAAM,GAAG,QAAQ,GAAG,OAAO,WAAW,MAAM,GAAG,IAAI;WAU7D,MAAM;aAIJ,IAAI;EAIhB;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,CAWrE"}
|
package/dist/ssr/helpers/ssr.js
CHANGED
|
@@ -29,7 +29,9 @@ export function renderSSR(element, options = {}) {
|
|
|
29
29
|
export function renderSSRWithError(element, error, options = {}) {
|
|
30
30
|
const status = error && 'error' in error ? error.error.status : 500;
|
|
31
31
|
const message = error && 'error' in error ? error.error.message : 'Internal Server Error';
|
|
32
|
-
const errorHtml = error
|
|
32
|
+
const errorHtml = error
|
|
33
|
+
? `<div class="error"><h1>Error ${status}</h1><p>${message}</p></div>`
|
|
34
|
+
: '';
|
|
33
35
|
const html = renderToHTMLString(element) + errorHtml;
|
|
34
36
|
const collectedHead = drainHeadContent();
|
|
35
37
|
const allHeadExtra = [options.headExtra, collectedHead].filter(Boolean).join('\n');
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ssr/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,0BAA0B,CAAC;AACzC,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { LoaderResult } from '../loader/types.js';
|
|
2
|
+
export interface SSRContext {
|
|
3
|
+
request: Request;
|
|
4
|
+
params: Record<string, string>;
|
|
5
|
+
query: Record<string, string | string[]>;
|
|
6
|
+
loaderData: Record<string, LoaderResult<unknown>>;
|
|
7
|
+
}
|
|
8
|
+
export interface SSRRenderOptions {
|
|
9
|
+
doctype?: string;
|
|
10
|
+
title?: string;
|
|
11
|
+
lang?: string;
|
|
12
|
+
baseUrl?: string;
|
|
13
|
+
streaming?: boolean;
|
|
14
|
+
headExtra?: string;
|
|
15
|
+
}
|
|
16
|
+
export interface SSRRenderResult {
|
|
17
|
+
html: string;
|
|
18
|
+
status: number;
|
|
19
|
+
headers: Headers;
|
|
20
|
+
}
|
|
21
|
+
export interface StreamChunk {
|
|
22
|
+
type: 'html' | 'error' | 'status';
|
|
23
|
+
content: string;
|
|
24
|
+
}
|
|
25
|
+
export declare const DEFAULT_DOCTYPE = "<!DOCTYPE html>";
|
|
26
|
+
export declare const DEFAULT_LANG = "en";
|
|
27
|
+
export declare const STATUS_CODES: Record<number, string>;
|
|
28
|
+
export declare function getStatusText(status: number): string;
|
|
29
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/ssr/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,CAAC;IACzC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC;CACnD;AAED,MAAM,WAAW,gBAAgB;IAC/B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAC;IAClC,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,eAAO,MAAM,eAAe,oBAAoB,CAAC;AACjD,eAAO,MAAM,YAAY,OAAO,CAAC;AAEjC,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAkB/C,CAAC;AAEF,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAEpD"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Plugin } from 'vite';
|
|
2
|
+
import type { EmberKitPluginOptions, EmberKitMode } from './types.js';
|
|
3
|
+
export declare function emberkitVitePlugin(userOptions?: EmberKitPluginOptions): Plugin;
|
|
4
|
+
export type { EmberKitPluginOptions, EmberKitMode };
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/vite-plugin/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AACnC,OAAO,KAAK,EAAE,qBAAqB,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAsBtE,wBAAgB,kBAAkB,CAAC,WAAW,GAAE,qBAA0B,GAAG,MAAM,CA0FlF;AAk3BD,YAAY,EAAE,qBAAqB,EAAE,YAAY,EAAE,CAAC"}
|