nuclo 0.2.6 → 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.
Files changed (128) hide show
  1. package/LICENSE.md +45 -0
  2. package/README.md +78 -7
  3. package/dist/{core/runtimeBootstrap.d.ts → bootstrap.d.ts} +1 -1
  4. package/dist/bootstrap.d.ts.map +1 -0
  5. package/dist/{core/attributeManager.d.ts → element/attributes.d.ts} +2 -2
  6. package/dist/element/attributes.d.ts.map +1 -0
  7. package/dist/{core/classNameMerger.d.ts → element/class-name.d.ts} +1 -1
  8. package/dist/element/class-name.d.ts.map +1 -0
  9. package/dist/{utility/on.d.ts → element/events.d.ts} +1 -1
  10. package/dist/element/events.d.ts.map +1 -0
  11. package/dist/{internal/applyModifiers.d.ts → element/factory.d.ts} +12 -19
  12. package/dist/element/factory.d.ts.map +1 -0
  13. package/dist/{core/styleManager.d.ts → element/inline-style.d.ts} +1 -1
  14. package/dist/element/inline-style.d.ts.map +1 -0
  15. package/dist/element/modifiers.d.ts +11 -0
  16. package/dist/element/modifiers.d.ts.map +1 -0
  17. package/dist/{core/tagConstants.d.ts → element/tags.d.ts} +2 -1
  18. package/dist/element/tags.d.ts.map +1 -0
  19. package/dist/{hydration/context.d.ts → hydration.d.ts} +1 -1
  20. package/dist/hydration.d.ts.map +1 -0
  21. package/dist/index.d.ts +13 -14
  22. package/dist/index.d.ts.map +1 -1
  23. package/dist/list/index.d.ts +6 -1
  24. package/dist/list/index.d.ts.map +1 -1
  25. package/dist/list/runtime.d.ts +1 -1
  26. package/dist/list/runtime.d.ts.map +1 -1
  27. package/dist/nuclo.cjs +1 -1
  28. package/dist/nuclo.cjs.map +1 -1
  29. package/dist/nuclo.mjs +1 -1
  30. package/dist/nuclo.mjs.map +1 -1
  31. package/dist/nuclo.umd.js +1 -1
  32. package/dist/nuclo.umd.js.map +1 -1
  33. package/dist/polyfill/nuclo.polyfill.cjs.map +1 -1
  34. package/dist/polyfill/nuclo.polyfill.mjs.map +1 -1
  35. package/dist/render.d.ts.map +1 -0
  36. package/dist/shared/conditions.d.ts.map +1 -0
  37. package/dist/{utility → shared}/dom.d.ts +30 -0
  38. package/dist/shared/dom.d.ts.map +1 -0
  39. package/dist/shared/environment.d.ts.map +1 -0
  40. package/dist/{utility/errorHandler.d.ts → shared/errors.d.ts} +1 -1
  41. package/dist/shared/errors.d.ts.map +1 -0
  42. package/dist/shared/renderables.d.ts.map +1 -0
  43. package/dist/{utility/stringUtils.d.ts → shared/strings.d.ts} +1 -1
  44. package/dist/shared/strings.d.ts.map +1 -0
  45. package/dist/{utility/typeGuards.d.ts → shared/type-guards.d.ts} +1 -1
  46. package/dist/shared/type-guards.d.ts.map +1 -0
  47. package/dist/ssr/index.d.ts +1 -1
  48. package/dist/ssr/index.d.ts.map +1 -1
  49. package/dist/ssr/nuclo.ssr.cjs.map +1 -1
  50. package/dist/ssr/nuclo.ssr.mjs.map +1 -1
  51. package/dist/ssr/{renderToString.d.ts → render-to-string.d.ts} +1 -1
  52. package/dist/ssr/render-to-string.d.ts.map +1 -0
  53. package/dist/style/css.d.ts +8 -303
  54. package/dist/style/css.d.ts.map +1 -1
  55. package/dist/style/index.d.ts +1 -1
  56. package/dist/style/index.d.ts.map +1 -1
  57. package/dist/update/conditional.d.ts +3 -0
  58. package/dist/update/conditional.d.ts.map +1 -0
  59. package/dist/{core/reactiveAttributes.d.ts → update/reactive-attributes.d.ts} +3 -3
  60. package/dist/update/reactive-attributes.d.ts.map +1 -0
  61. package/dist/{core/reactiveText.d.ts → update/reactive-text.d.ts} +3 -3
  62. package/dist/update/reactive-text.d.ts.map +1 -0
  63. package/dist/{core/reactiveCleanup.d.ts → update/registry.d.ts} +22 -1
  64. package/dist/update/registry.d.ts.map +1 -0
  65. package/dist/{utility → update}/scope.d.ts +4 -0
  66. package/dist/update/scope.d.ts.map +1 -0
  67. package/dist/update/update.d.ts +4 -0
  68. package/dist/update/update.d.ts.map +1 -0
  69. package/dist/when/builder.d.ts.map +1 -1
  70. package/dist/when/runtime.d.ts +5 -1
  71. package/dist/when/runtime.d.ts.map +1 -1
  72. package/package.json +23 -8
  73. package/types/core/base.d.ts +12 -3
  74. package/types/features/on.d.ts +1 -1
  75. package/types/features/style.d.ts +27 -21
  76. package/types/index.d.ts +113 -2
  77. package/types/polyfill.d.ts +131 -0
  78. package/types/ssr.d.ts +45 -0
  79. package/types/style.d.ts +404 -0
  80. package/dist/core/attributeManager.d.ts.map +0 -1
  81. package/dist/core/classNameMerger.d.ts.map +0 -1
  82. package/dist/core/conditionalUpdater.d.ts +0 -3
  83. package/dist/core/conditionalUpdater.d.ts.map +0 -1
  84. package/dist/core/elementFactory.d.ts +0 -9
  85. package/dist/core/elementFactory.d.ts.map +0 -1
  86. package/dist/core/modifierProcessor.d.ts +0 -3
  87. package/dist/core/modifierProcessor.d.ts.map +0 -1
  88. package/dist/core/reactiveAttributes.d.ts.map +0 -1
  89. package/dist/core/reactiveCleanup.d.ts.map +0 -1
  90. package/dist/core/reactiveText.d.ts.map +0 -1
  91. package/dist/core/runtimeBootstrap.d.ts.map +0 -1
  92. package/dist/core/styleManager.d.ts.map +0 -1
  93. package/dist/core/tagConstants.d.ts.map +0 -1
  94. package/dist/core/tagRegistry.d.ts +0 -4
  95. package/dist/core/tagRegistry.d.ts.map +0 -1
  96. package/dist/core/updateController.d.ts +0 -2
  97. package/dist/core/updateController.d.ts.map +0 -1
  98. package/dist/core/updateScope.d.ts +0 -5
  99. package/dist/core/updateScope.d.ts.map +0 -1
  100. package/dist/hydration/context.d.ts.map +0 -1
  101. package/dist/internal/applyModifiers.d.ts.map +0 -1
  102. package/dist/list/renderer.d.ts +0 -7
  103. package/dist/list/renderer.d.ts.map +0 -1
  104. package/dist/ssr/renderToString.d.ts.map +0 -1
  105. package/dist/utility/conditionalInfo.d.ts +0 -22
  106. package/dist/utility/conditionalInfo.d.ts.map +0 -1
  107. package/dist/utility/conditions.d.ts.map +0 -1
  108. package/dist/utility/dom.d.ts.map +0 -1
  109. package/dist/utility/domTypeHelpers.d.ts +0 -35
  110. package/dist/utility/domTypeHelpers.d.ts.map +0 -1
  111. package/dist/utility/environment.d.ts.map +0 -1
  112. package/dist/utility/errorHandler.d.ts.map +0 -1
  113. package/dist/utility/events.d.ts +0 -2
  114. package/dist/utility/events.d.ts.map +0 -1
  115. package/dist/utility/modifierPredicates.d.ts +0 -7
  116. package/dist/utility/modifierPredicates.d.ts.map +0 -1
  117. package/dist/utility/on.d.ts.map +0 -1
  118. package/dist/utility/render.d.ts.map +0 -1
  119. package/dist/utility/renderables.d.ts.map +0 -1
  120. package/dist/utility/scope.d.ts.map +0 -1
  121. package/dist/utility/stringUtils.d.ts.map +0 -1
  122. package/dist/utility/typeGuards.d.ts.map +0 -1
  123. package/dist/when/renderer.d.ts +0 -6
  124. package/dist/when/renderer.d.ts.map +0 -1
  125. /package/dist/{utility/render.d.ts → render.d.ts} +0 -0
  126. /package/dist/{utility → shared}/conditions.d.ts +0 -0
  127. /package/dist/{utility → shared}/environment.d.ts +0 -0
  128. /package/dist/{utility → shared}/renderables.d.ts +0 -0
@@ -11,16 +11,26 @@
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,
23
+ KeyframeFrames as NucloKeyframeFrames,
24
+ KeyframeStop as NucloKeyframeStop,
19
25
  Size as NucloSize,
20
26
  Style as NucloStyle,
21
27
  StyleResult as NucloStyleResult,
22
28
  ThemeConfig as NucloThemeConfig,
23
- } from "../../src/style/css";
29
+ VariantDefinitions as NucloVariantDefinitions,
30
+ VariantProps as NucloVariantProps,
31
+ VariantsConfig as NucloVariantsConfig,
32
+ VariantsFn as NucloVariantsFn,
33
+ } from "../style";
24
34
 
25
35
  declare global {
26
36
  export type Size = NucloSize;
@@ -30,26 +40,18 @@ declare global {
30
40
  export type Style<T extends ThemeConfig = ThemeConfig> = NucloStyle<T>;
31
41
  export type StyleResult = NucloStyleResult;
32
42
  export type ClassInput = NucloClassInput;
43
+ export type KeyframeStop = NucloKeyframeStop;
44
+ export type KeyframeFrames<T extends ThemeConfig = ThemeConfig> = NucloKeyframeFrames<T>;
45
+ export type VariantDefinitions<T extends ThemeConfig = ThemeConfig> = NucloVariantDefinitions<T>;
46
+ export type VariantProps<V extends VariantDefinitions> = NucloVariantProps<V>;
47
+ export type VariantsConfig<T extends ThemeConfig, V extends VariantDefinitions<T>> = NucloVariantsConfig<T, V>;
48
+ export type VariantsFn<V extends VariantDefinitions> = NucloVariantsFn<V>;
33
49
 
34
- export interface CssInstance<T extends ThemeConfig = ThemeConfig> {
35
- /**
36
- * Compile a style object into atomic CSS classes.
37
- * Returns `{ className }` — usable directly as a nuclo attributes object.
38
- */
39
- css(style: Style<T>): StyleResult;
40
- /**
41
- * Compose class lists with exact conflict resolution: when two inputs
42
- * style the same (query, selector, property), the last one wins.
43
- * Accepts results, raw class strings, and falsy values for conditionals.
44
- */
45
- cx(...inputs: ClassInput[]): StyleResult;
46
- /** Register a @keyframes block; returns its generated animation name. */
47
- keyframes(frames: Record<string, FlatStyle<T>>): string;
48
- /** Global selector styles (body, resets). Flat properties only. */
49
- globalStyle(selector: string, style: FlatStyle<T>): void;
50
- /** The theme this instance was created with. */
51
- theme: T;
52
- }
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>;
53
55
 
54
56
  /**
55
57
  * Create a themed styling instance. Theme tokens (colors, fonts, shadows,
@@ -62,8 +64,12 @@ declare global {
62
64
  function css(style: Style<object>): StyleResult;
63
65
  /** Compose class lists with last-wins conflict resolution. */
64
66
  function cx(...inputs: ClassInput[]): StyleResult;
67
+ /** Themeless variants() recipe helper. */
68
+ function variants<const V extends VariantDefinitions<object>>(
69
+ config: VariantsConfig<object, V>,
70
+ ): VariantsFn<V>;
65
71
  /** Themeless keyframes() helper. */
66
- function keyframes(frames: Record<string, FlatStyle<object>>): string;
72
+ function keyframes(frames: KeyframeFrames<object>): string;
67
73
  /** Themeless globalStyle() helper. */
68
74
  function globalStyle(selector: string, style: FlatStyle<object>): void;
69
75
  }
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
- // Re-export on() helper for module-style consumers (import { on } from "nuclo")
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
- export {};
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;