@yoyaflow/yoya-ui 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yoyaflow/yoya-ui",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "A browser-native JS UI library with declarative HTML authoring: component library, router, i18n, theming and layout, works with or without a build tool, SSR-ready.",
5
5
  "type": "module",
6
6
  "private": false,
package/types/ssr.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import type { ComponentLike, I18n, ViewNode } from './core.js';
2
+ import type { HtmlElementNode } from './html.js';
2
3
 
3
4
  export type PageFactory<S = unknown> = (state: S) => ViewNode | ComponentLike | PageFactory<S>;
4
5
 
@@ -79,3 +80,45 @@ export function hydrate<S = unknown>(
79
80
  state?: S | null,
80
81
  options?: SsrI18nOption<S>
81
82
  ): ViewNode;
83
+
84
+ /** Document builder node used by renderPage: head/body callbacks build the page. */
85
+ export class PageDocumentNode extends HtmlElementNode {
86
+ head(callback: (node: HtmlElementNode, state: unknown) => void): PageDocumentNode;
87
+ body(callback: (node: HtmlElementNode, state: unknown) => void): PageDocumentNode;
88
+ vBody(...args: unknown[]): PageDocumentNode;
89
+ }
90
+
91
+ export interface RenderPageConfig<S = unknown> {
92
+ page: (page: PageDocumentNode, state: S | null) => void;
93
+ }
94
+
95
+ export interface RenderPageOptions<S = unknown> extends SsrI18nOption<S> {
96
+ /** Per-request dictionary; builds an I18n instance from state.lang. */
97
+ messages?: Record<string, any>;
98
+ maxNodes?: number;
99
+ /** State container id. Defaults to "__YOYA_DATA__". */
100
+ stateId?: string;
101
+ /** Hydration container id. Defaults to "app". */
102
+ containerId?: string;
103
+ /** Client entry script src. Defaults to "/client.js". */
104
+ client?: string;
105
+ }
106
+
107
+ /** Renders a complete HTML document from DSL-defined head/body. */
108
+ export function renderPage<S = unknown>(
109
+ config: RenderPageConfig<S>,
110
+ state?: S | null,
111
+ options?: RenderPageOptions<S>
112
+ ): string;
113
+
114
+ export interface HydrateOrMountOptions<S = unknown> extends SsrI18nOption<S> {
115
+ messages?: Record<string, any>;
116
+ stateId?: string;
117
+ target?: string | ParentNode;
118
+ }
119
+
120
+ /** Client bootstrap: reads state and hydrates or mounts in one call. */
121
+ export function hydrateOrMount<S = unknown>(
122
+ component: ViewNode | ComponentLike | PageFactory<S>,
123
+ options?: HydrateOrMountOptions<S>
124
+ ): ViewNode | null;
@@ -1,4 +1,9 @@
1
1
  /**
2
- * Entry types for `yoya-ui/ssr`: server-side rendering helpers.
2
+ * Entry types for `yoya-ui/ssr`: server-side complete entry
3
+ * (core + html + layout + router + i18n + rendering helpers).
3
4
  */
5
+ export * from './core.js';
6
+ export * from './html.js';
7
+ export * from './layout.js';
8
+ export * from './router.js';
4
9
  export * from './ssr.js';