nuclo 0.2.7 → 0.2.9
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.md +45 -0
- package/README.md +30 -6
- package/dist/{core/runtimeBootstrap.d.ts → bootstrap.d.ts} +1 -1
- package/dist/bootstrap.d.ts.map +1 -0
- package/dist/{core/attributeManager.d.ts → element/attributes.d.ts} +2 -2
- package/dist/element/attributes.d.ts.map +1 -0
- package/dist/{core/classNameMerger.d.ts → element/class-name.d.ts} +1 -1
- package/dist/element/class-name.d.ts.map +1 -0
- package/dist/{utility/on.d.ts → element/events.d.ts} +1 -1
- package/dist/element/events.d.ts.map +1 -0
- package/dist/{internal/applyModifiers.d.ts → element/factory.d.ts} +12 -19
- package/dist/element/factory.d.ts.map +1 -0
- package/dist/{core/styleManager.d.ts → element/inline-style.d.ts} +1 -1
- package/dist/element/inline-style.d.ts.map +1 -0
- package/dist/element/modifiers.d.ts +11 -0
- package/dist/element/modifiers.d.ts.map +1 -0
- package/dist/{core/tagConstants.d.ts → element/tags.d.ts} +2 -1
- package/dist/element/tags.d.ts.map +1 -0
- package/dist/{hydration/context.d.ts → hydration.d.ts} +1 -1
- package/dist/hydration.d.ts.map +1 -0
- package/dist/index.d.ts +13 -14
- package/dist/index.d.ts.map +1 -1
- package/dist/list/index.d.ts +6 -1
- package/dist/list/index.d.ts.map +1 -1
- package/dist/list/runtime.d.ts +1 -1
- package/dist/list/runtime.d.ts.map +1 -1
- package/dist/nuclo.cjs +1 -1
- package/dist/nuclo.cjs.map +1 -1
- package/dist/nuclo.mjs +1 -1
- package/dist/nuclo.mjs.map +1 -1
- package/dist/nuclo.umd.js +1 -1
- package/dist/nuclo.umd.js.map +1 -1
- package/dist/polyfill/nuclo.polyfill.cjs.map +1 -1
- package/dist/polyfill/nuclo.polyfill.mjs.map +1 -1
- package/dist/render.d.ts.map +1 -0
- package/dist/shared/conditions.d.ts.map +1 -0
- package/dist/{utility → shared}/dom.d.ts +30 -0
- package/dist/shared/dom.d.ts.map +1 -0
- package/dist/shared/environment.d.ts.map +1 -0
- package/dist/{utility/errorHandler.d.ts → shared/errors.d.ts} +1 -1
- package/dist/shared/errors.d.ts.map +1 -0
- package/dist/shared/renderables.d.ts.map +1 -0
- package/dist/{utility/stringUtils.d.ts → shared/strings.d.ts} +1 -1
- package/dist/shared/strings.d.ts.map +1 -0
- package/dist/{utility/typeGuards.d.ts → shared/type-guards.d.ts} +1 -1
- package/dist/shared/type-guards.d.ts.map +1 -0
- package/dist/ssr/index.d.ts +1 -1
- package/dist/ssr/index.d.ts.map +1 -1
- package/dist/ssr/nuclo.ssr.cjs.map +1 -1
- package/dist/ssr/nuclo.ssr.mjs.map +1 -1
- package/dist/ssr/{renderToString.d.ts → render-to-string.d.ts} +1 -1
- package/dist/ssr/render-to-string.d.ts.map +1 -0
- package/dist/style/css.d.ts +3 -345
- package/dist/style/css.d.ts.map +1 -1
- package/dist/style/index.d.ts +1 -1
- package/dist/style/index.d.ts.map +1 -1
- package/dist/update/conditional.d.ts +3 -0
- package/dist/update/conditional.d.ts.map +1 -0
- package/dist/{core/reactiveAttributes.d.ts → update/reactive-attributes.d.ts} +3 -3
- package/dist/update/reactive-attributes.d.ts.map +1 -0
- package/dist/{core/reactiveText.d.ts → update/reactive-text.d.ts} +3 -3
- package/dist/update/reactive-text.d.ts.map +1 -0
- package/dist/{core/reactiveCleanup.d.ts → update/registry.d.ts} +22 -1
- package/dist/update/registry.d.ts.map +1 -0
- package/dist/{utility → update}/scope.d.ts +4 -0
- package/dist/update/scope.d.ts.map +1 -0
- package/dist/update/update.d.ts +4 -0
- package/dist/update/update.d.ts.map +1 -0
- package/dist/when/builder.d.ts.map +1 -1
- package/dist/when/runtime.d.ts +5 -1
- package/dist/when/runtime.d.ts.map +1 -1
- package/package.json +21 -6
- package/types/core/base.d.ts +12 -3
- package/types/features/on.d.ts +1 -1
- package/types/features/style.d.ts +10 -26
- package/types/index.d.ts +113 -2
- package/types/polyfill.d.ts +131 -0
- package/types/ssr.d.ts +45 -0
- package/types/style.d.ts +404 -0
- package/dist/core/attributeManager.d.ts.map +0 -1
- package/dist/core/classNameMerger.d.ts.map +0 -1
- package/dist/core/conditionalUpdater.d.ts +0 -3
- package/dist/core/conditionalUpdater.d.ts.map +0 -1
- package/dist/core/elementFactory.d.ts +0 -9
- package/dist/core/elementFactory.d.ts.map +0 -1
- package/dist/core/modifierProcessor.d.ts +0 -3
- package/dist/core/modifierProcessor.d.ts.map +0 -1
- package/dist/core/reactiveAttributes.d.ts.map +0 -1
- package/dist/core/reactiveCleanup.d.ts.map +0 -1
- package/dist/core/reactiveText.d.ts.map +0 -1
- package/dist/core/runtimeBootstrap.d.ts.map +0 -1
- package/dist/core/styleManager.d.ts.map +0 -1
- package/dist/core/tagConstants.d.ts.map +0 -1
- package/dist/core/tagRegistry.d.ts +0 -4
- package/dist/core/tagRegistry.d.ts.map +0 -1
- package/dist/core/updateController.d.ts +0 -2
- package/dist/core/updateController.d.ts.map +0 -1
- package/dist/core/updateScope.d.ts +0 -5
- package/dist/core/updateScope.d.ts.map +0 -1
- package/dist/hydration/context.d.ts.map +0 -1
- package/dist/internal/applyModifiers.d.ts.map +0 -1
- package/dist/list/renderer.d.ts +0 -7
- package/dist/list/renderer.d.ts.map +0 -1
- package/dist/ssr/renderToString.d.ts.map +0 -1
- package/dist/utility/conditionalInfo.d.ts +0 -22
- package/dist/utility/conditionalInfo.d.ts.map +0 -1
- package/dist/utility/conditions.d.ts.map +0 -1
- package/dist/utility/dom.d.ts.map +0 -1
- package/dist/utility/domTypeHelpers.d.ts +0 -35
- package/dist/utility/domTypeHelpers.d.ts.map +0 -1
- package/dist/utility/environment.d.ts.map +0 -1
- package/dist/utility/errorHandler.d.ts.map +0 -1
- package/dist/utility/events.d.ts +0 -2
- package/dist/utility/events.d.ts.map +0 -1
- package/dist/utility/modifierPredicates.d.ts +0 -7
- package/dist/utility/modifierPredicates.d.ts.map +0 -1
- package/dist/utility/on.d.ts.map +0 -1
- package/dist/utility/render.d.ts.map +0 -1
- package/dist/utility/renderables.d.ts.map +0 -1
- package/dist/utility/scope.d.ts.map +0 -1
- package/dist/utility/stringUtils.d.ts.map +0 -1
- package/dist/utility/typeGuards.d.ts.map +0 -1
- package/dist/when/renderer.d.ts +0 -6
- package/dist/when/renderer.d.ts.map +0 -1
- /package/dist/{utility/render.d.ts → render.d.ts} +0 -0
- /package/dist/{utility → shared}/conditions.d.ts +0 -0
- /package/dist/{utility → shared}/environment.d.ts +0 -0
- /package/dist/{utility → shared}/renderables.d.ts +0 -0
package/types/features/on.d.ts
CHANGED
|
@@ -31,8 +31,8 @@ declare global {
|
|
|
31
31
|
* @param options Native addEventListener options.
|
|
32
32
|
*/
|
|
33
33
|
function on<
|
|
34
|
+
K extends keyof HTMLElementEventMap,
|
|
34
35
|
TTagName extends ElementTagName = ElementTagName,
|
|
35
|
-
K extends keyof HTMLElementEventMap = keyof HTMLElementEventMap,
|
|
36
36
|
>(
|
|
37
37
|
type: K,
|
|
38
38
|
listener: TypedEventListener<HTMLElementTagNameMap[TTagName], HTMLElementEventMap[K]>,
|
|
@@ -11,9 +11,13 @@
|
|
|
11
11
|
//
|
|
12
12
|
// The themeless defaults (css, cx, keyframes, globalStyle) are registered as
|
|
13
13
|
// globals by the runtime bootstrap; themed instances come from createCss().
|
|
14
|
+
//
|
|
15
|
+
// The type definitions live in types/style.d.ts (NOT src/) so they resolve in
|
|
16
|
+
// the published package, which ships only dist/ and types/.
|
|
14
17
|
|
|
15
18
|
import type {
|
|
16
19
|
ClassInput as NucloClassInput,
|
|
20
|
+
CssInstance as NucloCssInstance,
|
|
17
21
|
CSSProperties as NucloCSSProperties,
|
|
18
22
|
FlatStyle as NucloFlatStyle,
|
|
19
23
|
KeyframeFrames as NucloKeyframeFrames,
|
|
@@ -26,7 +30,7 @@ import type {
|
|
|
26
30
|
VariantProps as NucloVariantProps,
|
|
27
31
|
VariantsConfig as NucloVariantsConfig,
|
|
28
32
|
VariantsFn as NucloVariantsFn,
|
|
29
|
-
} from "
|
|
33
|
+
} from "../style";
|
|
30
34
|
|
|
31
35
|
declare global {
|
|
32
36
|
export type Size = NucloSize;
|
|
@@ -43,31 +47,11 @@ declare global {
|
|
|
43
47
|
export type VariantsConfig<T extends ThemeConfig, V extends VariantDefinitions<T>> = NucloVariantsConfig<T, V>;
|
|
44
48
|
export type VariantsFn<V extends VariantDefinitions> = NucloVariantsFn<V>;
|
|
45
49
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
css(style: Style<T>): StyleResult;
|
|
52
|
-
/**
|
|
53
|
-
* Compose class lists with exact conflict resolution: when two inputs
|
|
54
|
-
* style the same (query, selector, property), the last one wins.
|
|
55
|
-
* Accepts results, raw class strings, nested arrays, and falsy values.
|
|
56
|
-
*/
|
|
57
|
-
cx(...inputs: ClassInput[]): StyleResult;
|
|
58
|
-
/**
|
|
59
|
-
* Compile a typed variants recipe (base + named variant groups + defaults
|
|
60
|
-
* + compound variants) into a call-with-props function returning a
|
|
61
|
-
* composed StyleResult. Variant names and values are inferred and checked.
|
|
62
|
-
*/
|
|
63
|
-
variants<const V extends VariantDefinitions<T>>(config: VariantsConfig<T, V>): VariantsFn<V>;
|
|
64
|
-
/** Register a @keyframes block; returns its generated animation name. */
|
|
65
|
-
keyframes(frames: KeyframeFrames<T>): string;
|
|
66
|
-
/** Global selector styles (body, resets). Flat properties only. */
|
|
67
|
-
globalStyle(selector: string, style: FlatStyle<T>): void;
|
|
68
|
-
/** The theme this instance was created with. */
|
|
69
|
-
theme: T;
|
|
70
|
-
}
|
|
50
|
+
/**
|
|
51
|
+
* A themed styling instance: css/cx/variants/keyframes/globalStyle bound to
|
|
52
|
+
* a theme. Returned by createCss().
|
|
53
|
+
*/
|
|
54
|
+
export type CssInstance<T extends ThemeConfig = ThemeConfig> = NucloCssInstance<T>;
|
|
71
55
|
|
|
72
56
|
/**
|
|
73
57
|
* Create a themed styling instance. Theme tokens (colors, fonts, shadows,
|
package/types/index.d.ts
CHANGED
|
@@ -11,7 +11,69 @@ import "./features/on";
|
|
|
11
11
|
import "./features/render";
|
|
12
12
|
import "./features/style";
|
|
13
13
|
|
|
14
|
-
//
|
|
14
|
+
// ---------------------------------------------------------------------------
|
|
15
|
+
// Module export surface — mirrors the runtime exports of src/index.ts so that
|
|
16
|
+
// module-style consumers (import { render } from "nuclo") get the same types
|
|
17
|
+
// as global-style consumers (import "nuclo"). Keep in sync with src/index.ts.
|
|
18
|
+
// ---------------------------------------------------------------------------
|
|
19
|
+
|
|
20
|
+
// Runtime bootstrap / tag registry
|
|
21
|
+
export function initializeRuntime(): void;
|
|
22
|
+
export function registerGlobalTagBuilders(target?: Record<string, unknown>): void;
|
|
23
|
+
export const HTML_TAGS: ReadonlyArray<ElementTagName>;
|
|
24
|
+
export const SVG_TAGS: ReadonlyArray<SVGTagName>;
|
|
25
|
+
export const SELF_CLOSING_TAGS: ReadonlyArray<ElementTagName>;
|
|
26
|
+
export function createHtmlTagBuilder<TTagName extends ElementTagName>(
|
|
27
|
+
tagName: TTagName,
|
|
28
|
+
): ExpandedElementBuilder<TTagName>;
|
|
29
|
+
export function createSvgTagBuilder<TTagName extends SVGTagName>(
|
|
30
|
+
tagName: TTagName,
|
|
31
|
+
): ExpandedSVGElementBuilder<TTagName>;
|
|
32
|
+
|
|
33
|
+
// Modifier application
|
|
34
|
+
export function applyNodeModifier<TTagName extends ElementTagName>(
|
|
35
|
+
parent: ExpandedElement<TTagName>,
|
|
36
|
+
modifier: NodeModLike<TTagName>,
|
|
37
|
+
index: number,
|
|
38
|
+
): Node | null;
|
|
39
|
+
export function applyAttributes<TTagName extends ElementTagName>(
|
|
40
|
+
element: ExpandedElement<TTagName>,
|
|
41
|
+
attributes: ExpandedElementAttributes<TTagName>,
|
|
42
|
+
mergeClassName?: boolean,
|
|
43
|
+
): void;
|
|
44
|
+
export function createHtmlElementWithModifiers<TTagName extends ElementTagName>(
|
|
45
|
+
tagName: TTagName,
|
|
46
|
+
modifiers: ReadonlyArray<NodeModLike<TTagName>>,
|
|
47
|
+
): ExpandedElement<TTagName>;
|
|
48
|
+
export function createSvgElementWithModifiers<TTagName extends SVGTagName>(
|
|
49
|
+
tagName: TTagName,
|
|
50
|
+
modifiers: ReadonlyArray<SVGElementModifierLike<TTagName>>,
|
|
51
|
+
): SVGElementTagNameMap[TTagName];
|
|
52
|
+
|
|
53
|
+
// Core primitives (same signatures as the globals)
|
|
54
|
+
export function list<T, TTagName extends ElementTagName = ElementTagName>(
|
|
55
|
+
itemsProvider: ListItemsProvider<T>,
|
|
56
|
+
render: ListRenderFunction<T, TTagName>,
|
|
57
|
+
): ListModifier<TTagName>;
|
|
58
|
+
export function when<TTagName extends ElementTagName = ElementTagName>(
|
|
59
|
+
condition: WhenCondition,
|
|
60
|
+
...content: WhenContent<TTagName>[]
|
|
61
|
+
): WhenBuilder<TTagName>;
|
|
62
|
+
export function update(...scopeIds: string[]): void;
|
|
63
|
+
export function scope<TTagName extends ElementTagName = ElementTagName>(
|
|
64
|
+
...ids: string[]
|
|
65
|
+
): NodeModFn<TTagName>;
|
|
66
|
+
export function render<TTagName extends ElementTagName = ElementTagName>(
|
|
67
|
+
nodeModFn: NodeModFn<TTagName>,
|
|
68
|
+
parent?: Element,
|
|
69
|
+
index?: number,
|
|
70
|
+
): ExpandedElement<TTagName>;
|
|
71
|
+
export function hydrate<TTagName extends ElementTagName = ElementTagName>(
|
|
72
|
+
nodeModFn: NodeModFn<TTagName>,
|
|
73
|
+
parent?: Element,
|
|
74
|
+
): ExpandedElement<TTagName>;
|
|
75
|
+
|
|
76
|
+
// on() helper (same overloads as the global)
|
|
15
77
|
export function on<K extends keyof HTMLElementEventMap, TTagName extends ElementTagName = ElementTagName>(
|
|
16
78
|
type: K,
|
|
17
79
|
listener: TypedEventListener<HTMLElementTagNameMap[TTagName], HTMLElementEventMap[K]>,
|
|
@@ -23,4 +85,53 @@ export function on<K extends string, E extends Event = Event, TTagName extends E
|
|
|
23
85
|
options?: boolean | AddEventListenerOptions
|
|
24
86
|
): NodeModFn<TTagName>;
|
|
25
87
|
|
|
26
|
-
|
|
88
|
+
// DOM helpers
|
|
89
|
+
export function appendChildren(
|
|
90
|
+
parent: Element | Node,
|
|
91
|
+
...children: Array<Element | Node | string | null | undefined>
|
|
92
|
+
): Element | Node;
|
|
93
|
+
export function createComment(text: string): Comment | null;
|
|
94
|
+
export function createConditionalComment(tagName: string, suffix?: string): Comment | null;
|
|
95
|
+
export function replaceNodeSafely(oldNode: Node, newNode: Node): boolean;
|
|
96
|
+
|
|
97
|
+
// Type guards / environment
|
|
98
|
+
export function isBoolean(value: unknown): value is boolean;
|
|
99
|
+
export function isFunction(value: unknown): value is (...args: unknown[]) => unknown;
|
|
100
|
+
export function isNode<T>(value: T): value is T & Node;
|
|
101
|
+
export function isObject(value: unknown): value is object;
|
|
102
|
+
export function isPrimitive(value: unknown): value is Primitive;
|
|
103
|
+
export function isTagLike<T>(value: T): value is T & { tagName?: string };
|
|
104
|
+
export function isZeroArityFunction(value: unknown): value is () => unknown;
|
|
105
|
+
export const isBrowser: boolean;
|
|
106
|
+
|
|
107
|
+
// Styling (themeless default instance + themed factory)
|
|
108
|
+
export function createCss<const T extends ThemeConfig>(theme?: T): CssInstance<T>;
|
|
109
|
+
export function css(style: Style<object>): StyleResult;
|
|
110
|
+
export function cx(...inputs: ClassInput[]): StyleResult;
|
|
111
|
+
export function variants<const V extends VariantDefinitions<object>>(
|
|
112
|
+
config: VariantsConfig<object, V>,
|
|
113
|
+
): VariantsFn<V>;
|
|
114
|
+
export function keyframes(frames: KeyframeFrames<object>): string;
|
|
115
|
+
export function globalStyle(selector: string, style: FlatStyle<object>): void;
|
|
116
|
+
export function getCssText(): string;
|
|
117
|
+
export function resetStyles(): void;
|
|
118
|
+
export function setSSRCollector(fn: ((rule: string) => void) | null): void;
|
|
119
|
+
|
|
120
|
+
// Styling types (same names as the globals, importable as module types)
|
|
121
|
+
export type {
|
|
122
|
+
ClassInput,
|
|
123
|
+
CssInstance,
|
|
124
|
+
CSSProperties,
|
|
125
|
+
FlatStyle,
|
|
126
|
+
KeyframeFrames,
|
|
127
|
+
KeyframeStop,
|
|
128
|
+
Pseudo,
|
|
129
|
+
Size,
|
|
130
|
+
Style,
|
|
131
|
+
StyleResult,
|
|
132
|
+
ThemeConfig,
|
|
133
|
+
VariantDefinitions,
|
|
134
|
+
VariantProps,
|
|
135
|
+
VariantsConfig,
|
|
136
|
+
VariantsFn,
|
|
137
|
+
} from "./style";
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type declarations for the `nuclo/polyfill` subpath.
|
|
3
|
+
*
|
|
4
|
+
* Hand-written (mirroring src/polyfill/index.ts) and shipped from `types/` so
|
|
5
|
+
* the subpath stays typed even when `dist/` holds only watch-mode JS bundles —
|
|
6
|
+
* `tsdown --watch` cleans dist and emits no declarations. Keep in sync with
|
|
7
|
+
* src/polyfill/*.
|
|
8
|
+
*
|
|
9
|
+
* The primary use is the side-effect import (`import "nuclo/polyfill"`), which
|
|
10
|
+
* installs document/Event/Node/Element/HTMLElement on globalThis when they are
|
|
11
|
+
* missing (Node.js SSR). The named exports below expose the polyfill classes.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
// Load the ambient nuclo globals (ExpandedElement, ElementTagName, …).
|
|
15
|
+
import "./index";
|
|
16
|
+
|
|
17
|
+
/** Minimal Node base used for instanceof checks in the Node.js polyfill. */
|
|
18
|
+
export class NucloNode {
|
|
19
|
+
nodeType: number;
|
|
20
|
+
nodeName: string;
|
|
21
|
+
nodeValue: string | null;
|
|
22
|
+
parentNode: unknown;
|
|
23
|
+
textContent: string;
|
|
24
|
+
get childNodes(): NodeListOf<ChildNode>;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** Text node polyfill. */
|
|
28
|
+
export class NucloText {
|
|
29
|
+
nodeType: number;
|
|
30
|
+
nodeName: string;
|
|
31
|
+
data: string;
|
|
32
|
+
textContent: string;
|
|
33
|
+
parentNode: unknown;
|
|
34
|
+
nodeValue: string;
|
|
35
|
+
constructor(data: string);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** Element polyfill: the subset of the DOM Element surface nuclo SSR uses. */
|
|
39
|
+
export class NucloElement extends NucloNode {
|
|
40
|
+
tagName: string;
|
|
41
|
+
children: unknown[];
|
|
42
|
+
className: string;
|
|
43
|
+
id: string;
|
|
44
|
+
namespaceURI?: string;
|
|
45
|
+
sheet?: CSSStyleSheet | null;
|
|
46
|
+
rawMods?: unknown[];
|
|
47
|
+
mods?: unknown[];
|
|
48
|
+
attributes: Map<string, string>;
|
|
49
|
+
style: CSSStyleDeclaration;
|
|
50
|
+
classList: DOMTokenList;
|
|
51
|
+
innerHTML: string;
|
|
52
|
+
constructor(tagName: string);
|
|
53
|
+
appendChild<T extends Node>(child: T): T;
|
|
54
|
+
insertBefore<T extends Node>(newNode: T, referenceNode: Node | null): T;
|
|
55
|
+
removeChild<T extends Node>(child: T): T;
|
|
56
|
+
replaceChild<T extends Node>(newChild: Node, oldChild: T): T;
|
|
57
|
+
setAttribute(name: string, value: string): void;
|
|
58
|
+
getAttribute(name: string): string | null;
|
|
59
|
+
removeAttribute(name: string): void;
|
|
60
|
+
hasAttribute(name: string): boolean;
|
|
61
|
+
addEventListener(type: string, listener: EventListener): void;
|
|
62
|
+
removeEventListener(type: string, listener: EventListener): void;
|
|
63
|
+
dispatchEvent(event: Event): boolean;
|
|
64
|
+
querySelector(selector: string): Element | null;
|
|
65
|
+
querySelectorAll(selector: string): NodeListOf<Element>;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** Document polyfill backing `document` in Node.js. */
|
|
69
|
+
export class NucloDocument {
|
|
70
|
+
head: ExpandedElement;
|
|
71
|
+
body: ExpandedElement;
|
|
72
|
+
createElement(tagName: string, options?: unknown): ExpandedElement;
|
|
73
|
+
createElementNS(namespace: string, tagName: string, options?: unknown): ExpandedElement;
|
|
74
|
+
createTextNode(data: string): Text;
|
|
75
|
+
createComment(data: string): Comment;
|
|
76
|
+
createDocumentFragment(): DocumentFragment;
|
|
77
|
+
querySelector(selector: string): Element | null;
|
|
78
|
+
querySelectorAll(selector: string): NodeListOf<Element>;
|
|
79
|
+
addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void;
|
|
80
|
+
removeEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void;
|
|
81
|
+
dispatchEvent(event: Event): boolean;
|
|
82
|
+
contains(node: Node): boolean;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** Event polyfill (structurally compatible with the DOM Event interface). */
|
|
86
|
+
export class NucloEvent implements Event {
|
|
87
|
+
type: string;
|
|
88
|
+
bubbles: boolean;
|
|
89
|
+
cancelable: boolean;
|
|
90
|
+
composed: boolean;
|
|
91
|
+
currentTarget: EventTarget | null;
|
|
92
|
+
defaultPrevented: boolean;
|
|
93
|
+
eventPhase: number;
|
|
94
|
+
isTrusted: boolean;
|
|
95
|
+
target: EventTarget | null;
|
|
96
|
+
timeStamp: number;
|
|
97
|
+
readonly AT_TARGET: 2;
|
|
98
|
+
readonly BUBBLING_PHASE: 3;
|
|
99
|
+
readonly CAPTURING_PHASE: 1;
|
|
100
|
+
readonly NONE: 0;
|
|
101
|
+
returnValue: boolean;
|
|
102
|
+
srcElement: EventTarget | null;
|
|
103
|
+
cancelBubble: boolean;
|
|
104
|
+
constructor(type: string, eventInitDict?: EventInit);
|
|
105
|
+
composedPath(): EventTarget[];
|
|
106
|
+
initEvent(type: string, bubbles?: boolean, cancelable?: boolean): void;
|
|
107
|
+
preventDefault(): void;
|
|
108
|
+
stopImmediatePropagation(): void;
|
|
109
|
+
stopPropagation(): void;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/** CustomEvent polyfill. */
|
|
113
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
114
|
+
export class NucloCustomEvent<T = any> extends NucloEvent implements CustomEvent<T> {
|
|
115
|
+
detail: T;
|
|
116
|
+
constructor(type: string, eventInitDict?: CustomEventInit<T>);
|
|
117
|
+
initCustomEvent(type: string, bubbles?: boolean, cancelable?: boolean, detail?: T): void;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/** The active document: the browser global when present, else the polyfill. */
|
|
121
|
+
export const document: Document | NucloDocument;
|
|
122
|
+
/** The active Event constructor: the browser global when present, else the polyfill. */
|
|
123
|
+
export const Event: typeof globalThis.Event | typeof NucloEvent;
|
|
124
|
+
/** The active CustomEvent constructor: the browser global when present, else the polyfill. */
|
|
125
|
+
export const CustomEvent: typeof globalThis.CustomEvent | typeof NucloCustomEvent;
|
|
126
|
+
/** Alias of NucloNode (installed as globalThis.Node when missing). */
|
|
127
|
+
export const Node: typeof NucloNode;
|
|
128
|
+
/** Alias of NucloElement (installed as globalThis.Element when missing). */
|
|
129
|
+
export const Element: typeof NucloElement;
|
|
130
|
+
/** Alias of NucloElement (installed as globalThis.HTMLElement when missing). */
|
|
131
|
+
export const HTMLElement: typeof NucloElement;
|
package/types/ssr.d.ts
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type declarations for the `nuclo/ssr` subpath.
|
|
3
|
+
*
|
|
4
|
+
* Hand-written (mirroring src/ssr/index.ts) and shipped from `types/` so the
|
|
5
|
+
* subpath stays typed even when `dist/` holds only watch-mode JS bundles —
|
|
6
|
+
* `tsdown --watch` cleans dist and emits no declarations. Keep in sync with
|
|
7
|
+
* src/ssr/index.ts.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
// Load the ambient nuclo globals (NodeModFn, ElementTagName, tag builders, …)
|
|
11
|
+
// so SSR-only consumers get them without importing the main entry.
|
|
12
|
+
import "./index";
|
|
13
|
+
|
|
14
|
+
/** Anything renderToString accepts: a component factory, a DOM node, or nothing. */
|
|
15
|
+
export type RenderableInput =
|
|
16
|
+
| NodeModFn<ElementTagName>
|
|
17
|
+
| Element
|
|
18
|
+
| Node
|
|
19
|
+
| null
|
|
20
|
+
| undefined;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Renders a Nuclo component (or DOM node) to an HTML string.
|
|
24
|
+
* Text children keep their `<!-- text-N -->` markers so the output is hydratable.
|
|
25
|
+
*/
|
|
26
|
+
export function renderToString(input: RenderableInput): string;
|
|
27
|
+
|
|
28
|
+
/** Renders multiple Nuclo components to HTML strings. */
|
|
29
|
+
export function renderManyToString(inputs: RenderableInput[]): string[];
|
|
30
|
+
|
|
31
|
+
/** Renders a Nuclo component wrapped in a container element. */
|
|
32
|
+
export function renderToStringWithContainer(
|
|
33
|
+
input: RenderableInput,
|
|
34
|
+
containerTag?: string,
|
|
35
|
+
containerAttrs?: Record<string, string>,
|
|
36
|
+
): string;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Install a hook receiving every newly minted CSS rule (wrapped in its
|
|
40
|
+
* at-rule, if any). Installed once at server startup; pass null to remove.
|
|
41
|
+
*/
|
|
42
|
+
export function setSSRCollector(fn: ((rule: string) => void) | null): void;
|
|
43
|
+
|
|
44
|
+
/** Serialize every registered atomic CSS rule (for a <style> tag in SSR output). */
|
|
45
|
+
export function getCssText(): string;
|