streetui 1.0.0

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 (58) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +127 -0
  3. package/dist/bin.cjs +894 -0
  4. package/dist/bin.cjs.map +1 -0
  5. package/dist/bin.d.cts +1 -0
  6. package/dist/bin.d.ts +1 -0
  7. package/dist/bin.js +892 -0
  8. package/dist/bin.js.map +1 -0
  9. package/dist/compile-B0q07Hzq.d.cts +656 -0
  10. package/dist/compile-B0q07Hzq.d.ts +656 -0
  11. package/dist/create-bin.cjs +896 -0
  12. package/dist/create-bin.cjs.map +1 -0
  13. package/dist/create-bin.d.cts +1 -0
  14. package/dist/create-bin.d.ts +1 -0
  15. package/dist/create-bin.js +894 -0
  16. package/dist/create-bin.js.map +1 -0
  17. package/dist/hydration-diagnostics-BE6xVWD1.d.cts +89 -0
  18. package/dist/hydration-diagnostics-Bck5dMbz.d.ts +89 -0
  19. package/dist/index.cjs +4284 -0
  20. package/dist/index.cjs.map +1 -0
  21. package/dist/index.d.cts +1759 -0
  22. package/dist/index.d.ts +1759 -0
  23. package/dist/index.js +4114 -0
  24. package/dist/index.js.map +1 -0
  25. package/dist/server-84Rz4g8W.d.cts +165 -0
  26. package/dist/server-D9GPmB49.d.ts +165 -0
  27. package/dist/server.cjs +972 -0
  28. package/dist/server.cjs.map +1 -0
  29. package/dist/server.d.cts +2 -0
  30. package/dist/server.d.ts +2 -0
  31. package/dist/server.js +940 -0
  32. package/dist/server.js.map +1 -0
  33. package/dist/testing.cjs +1754 -0
  34. package/dist/testing.cjs.map +1 -0
  35. package/dist/testing.d.cts +113 -0
  36. package/dist/testing.d.ts +113 -0
  37. package/dist/testing.js +1719 -0
  38. package/dist/testing.js.map +1 -0
  39. package/package.json +113 -0
  40. package/templates/basic/README.md +39 -0
  41. package/templates/basic/_gitignore +15 -0
  42. package/templates/basic/_package.json +21 -0
  43. package/templates/basic/public/styles.css +40 -0
  44. package/templates/basic/src/app.ts +62 -0
  45. package/templates/basic/src/main.ts +39 -0
  46. package/templates/basic/src/server.ts +40 -0
  47. package/templates/basic/streetui.config.ts +6 -0
  48. package/templates/basic/tsconfig.json +16 -0
  49. package/templates/ssr/README.md +46 -0
  50. package/templates/ssr/_gitignore +15 -0
  51. package/templates/ssr/_package.json +21 -0
  52. package/templates/ssr/public/favicon.svg +4 -0
  53. package/templates/ssr/public/styles.css +61 -0
  54. package/templates/ssr/src/app.ts +135 -0
  55. package/templates/ssr/src/main.ts +53 -0
  56. package/templates/ssr/src/server.ts +47 -0
  57. package/templates/ssr/streetui.config.ts +14 -0
  58. package/templates/ssr/tsconfig.json +16 -0
@@ -0,0 +1,165 @@
1
+ import { C as CompiledApplication } from './compile-B0q07Hzq.cjs';
2
+
3
+ /**
4
+ * DOMAdapter — framework-owned abstraction over DOM operations.
5
+ *
6
+ * The renderer depends on this interface, never on raw browser globals,
7
+ * which makes the renderer testable and portable.
8
+ */
9
+ interface DOMAdapter {
10
+ createElement(tag: string, ns?: string): Element;
11
+ createTextNode(data: string): Text;
12
+ createComment(data: string): Comment;
13
+ createFragment(): DocumentFragment;
14
+ appendChild(parent: Node, child: Node): void;
15
+ insertBefore(parent: Node, child: Node, reference: Node | null): void;
16
+ removeChild(parent: Node, child: Node): void;
17
+ replaceChild(parent: Node, newChild: Node, oldChild: Node): void;
18
+ setAttribute(element: Element, name: string, value: string): void;
19
+ removeAttribute(element: Element, name: string): void;
20
+ getAttribute(element: Element, name: string): string | null;
21
+ setProperty(element: Element, name: string, value: unknown): void;
22
+ setTextContent(node: Node, text: string): void;
23
+ getTextContent(node: Node): string | null;
24
+ addEventListener(target: EventTarget, type: string, handler: EventListener, options?: AddEventListenerOptions): void;
25
+ removeEventListener(target: EventTarget, type: string, handler: EventListener, options?: EventListenerOptions): void;
26
+ querySelector(root: Element | Document, selector: string): Element | null;
27
+ querySelectorAll(root: Element | Document, selector: string): NodeListOf<Element>;
28
+ getElementById(id: string): Element | null;
29
+ /**
30
+ * Move focus to an element. On the server (or when the element cannot receive
31
+ * focus) this is a safe no-op, keeping focus management SSR-compatible.
32
+ */
33
+ focus(element: Element): void;
34
+ isElement(node: Node): node is Element;
35
+ isTextNode(node: Node): node is Text;
36
+ /** Lower-cased tag name of an element (e.g. "div", "h1"). */
37
+ tagName(element: Element): string;
38
+ parentNode(node: Node): Node | null;
39
+ nextSibling(node: Node): Node | null;
40
+ /** First child node (element, text, or otherwise), or null. */
41
+ firstChild(node: Node): Node | null;
42
+ /** All child nodes of an element in order (empty for leaf/text nodes). */
43
+ childNodes(node: Node): Node[];
44
+ }
45
+
46
+ /**
47
+ * Server implementation of `DOMAdapter`.
48
+ *
49
+ * Builds a lightweight in-memory tree (see `server-node.ts`) instead of touching
50
+ * a real browser DOM, then lets the caller serialize it to an HTML string. It is
51
+ * completely free of browser globals, so the exact same renderer that runs in
52
+ * the browser can produce HTML on the server.
53
+ *
54
+ * The `DOMAdapter` interface is typed against the lib DOM types (`Element`,
55
+ * `Node`, `Text`, …). Our server nodes structurally stand in for those at
56
+ * runtime, so the boundary uses `as unknown as` casts in one place. Everything
57
+ * inside operates on the real server-node model.
58
+ */
59
+
60
+ declare class ServerDOMAdapter implements DOMAdapter {
61
+ createElement(tag: string, _ns?: string): Element;
62
+ createTextNode(data: string): Text;
63
+ createComment(data: string): Comment;
64
+ createFragment(): DocumentFragment;
65
+ appendChild(parent: Node, child: Node): void;
66
+ insertBefore(parent: Node, child: Node, reference: Node | null): void;
67
+ removeChild(parent: Node, child: Node): void;
68
+ replaceChild(parent: Node, newChild: Node, oldChild: Node): void;
69
+ private _detach;
70
+ setAttribute(element: Element, name: string, value: string): void;
71
+ removeAttribute(element: Element, name: string): void;
72
+ getAttribute(element: Element, name: string): string | null;
73
+ setProperty(element: Element, name: string, value: unknown): void;
74
+ setTextContent(node: Node, text: string): void;
75
+ getTextContent(node: Node): string | null;
76
+ addEventListener(): void;
77
+ removeEventListener(): void;
78
+ querySelector(): Element | null;
79
+ querySelectorAll(): NodeListOf<Element>;
80
+ getElementById(): Element | null;
81
+ focus(): void;
82
+ isElement(node: Node): node is Element;
83
+ isTextNode(node: Node): node is Text;
84
+ tagName(element: Element): string;
85
+ parentNode(node: Node): Node | null;
86
+ nextSibling(node: Node): Node | null;
87
+ firstChild(node: Node): Node | null;
88
+ childNodes(node: Node): Node[];
89
+ /** Serialize a node's children ("inner HTML") to an HTML string. */
90
+ serializeInner(node: Node): string;
91
+ /** Serialize a node (including itself) to an HTML string. */
92
+ serializeOuter(node: Node): string;
93
+ }
94
+ declare const serverDOMAdapter: ServerDOMAdapter;
95
+
96
+ /**
97
+ * SSR state transfer (dehydration) — move server-resolved data to the client.
98
+ *
99
+ * When the server resolves resources before rendering, their data must reach
100
+ * the client so hydration can seed them (via `resource({ initialData })`)
101
+ * instead of refetching. StreetUI does this with a single, framework-scoped
102
+ * `<script>` payload rather than blindly interpolating `JSON.stringify` into
103
+ * markup.
104
+ *
105
+ * Safety (v0.4 rule #16): the JSON is emitted into a
106
+ * `<script type="application/json">` block — an inert data island the browser
107
+ * never executes — and every character that could terminate that block or be
108
+ * reinterpreted by the HTML/JS parser is escaped to its `\uXXXX` form. Because
109
+ * `<` inside JSON parses back to `<`, the payload round-trips exactly
110
+ * while being impossible to break out of. This is deterministic (stable key
111
+ * order is the caller's responsibility) and typed at the boundary as
112
+ * `Record<string, unknown>` — never `any`.
113
+ */
114
+
115
+ /** Attribute marking StreetUI's state island so the client can find it. */
116
+ declare const STATE_MARKER_ATTR = "data-streetui-state";
117
+ /**
118
+ * Serialize a state map to an HTML `<script>` island for inclusion in the
119
+ * server-rendered document (typically just before the closing tag of the
120
+ * mount container). Returns an empty string for an empty map.
121
+ */
122
+ declare function serializeState(state: Record<string, unknown>): string;
123
+ /**
124
+ * Read the state island back on the client. Searches `root` for StreetUI's
125
+ * state `<script>` and parses it. Returns an empty object when absent or
126
+ * unparseable (hydration then proceeds as a cold client render). Routed through
127
+ * the DOM adapter so it is testable and never assumes a global `document`.
128
+ */
129
+ declare function readState(dom: DOMAdapter, root: Element | Document): Record<string, unknown>;
130
+
131
+ /**
132
+ * Server-side rendering — `renderToString`.
133
+ *
134
+ * Runs the *exact same* mount pipeline used in the browser (`mountGraph`), but
135
+ * against a `ServerDOMAdapter` that builds a lightweight in-memory node tree
136
+ * instead of a real browser DOM. The tree is then serialized to a normal HTML
137
+ * string. Because both browser and server share the DSL → Compiler → Graph →
138
+ * Runtime → Renderer pipeline, there is no second, SSR-specific renderer and no
139
+ * virtual DOM.
140
+ *
141
+ * Lifecycle (v0.4 rule #20): the initial synchronous mount may open signal
142
+ * subscriptions (via `wireSignalBindings`/`wireReactiveList`). On the server
143
+ * those would be live forever, so once the HTML is serialized we dispose the
144
+ * root instance — tearing down every subscription and listener. SSR therefore
145
+ * has a *render* lifecycle only; the live *runtime* lifecycle is established
146
+ * later on the client by `hydrate`.
147
+ */
148
+
149
+ interface RenderToStringOptions {
150
+ /**
151
+ * Override the server DOM adapter (rarely needed). Defaults to a fresh
152
+ * `ServerDOMAdapter` per call so concurrent renders never share state.
153
+ */
154
+ readonly domAdapter?: ServerDOMAdapter;
155
+ }
156
+ /**
157
+ * Render a compiled StreetUI application to an HTML string.
158
+ *
159
+ * The returned markup contains only the application's own elements (the
160
+ * synthetic container is not emitted), so callers embed it wherever they mount
161
+ * on the client — e.g. inside `<div id="app">…</div>`.
162
+ */
163
+ declare function renderToString(compiled: CompiledApplication, options?: RenderToStringOptions): string;
164
+
165
+ export { type DOMAdapter as D, type RenderToStringOptions as R, STATE_MARKER_ATTR as S, ServerDOMAdapter as a, renderToString as b, serverDOMAdapter as c, readState as r, serializeState as s };
@@ -0,0 +1,165 @@
1
+ import { C as CompiledApplication } from './compile-B0q07Hzq.js';
2
+
3
+ /**
4
+ * DOMAdapter — framework-owned abstraction over DOM operations.
5
+ *
6
+ * The renderer depends on this interface, never on raw browser globals,
7
+ * which makes the renderer testable and portable.
8
+ */
9
+ interface DOMAdapter {
10
+ createElement(tag: string, ns?: string): Element;
11
+ createTextNode(data: string): Text;
12
+ createComment(data: string): Comment;
13
+ createFragment(): DocumentFragment;
14
+ appendChild(parent: Node, child: Node): void;
15
+ insertBefore(parent: Node, child: Node, reference: Node | null): void;
16
+ removeChild(parent: Node, child: Node): void;
17
+ replaceChild(parent: Node, newChild: Node, oldChild: Node): void;
18
+ setAttribute(element: Element, name: string, value: string): void;
19
+ removeAttribute(element: Element, name: string): void;
20
+ getAttribute(element: Element, name: string): string | null;
21
+ setProperty(element: Element, name: string, value: unknown): void;
22
+ setTextContent(node: Node, text: string): void;
23
+ getTextContent(node: Node): string | null;
24
+ addEventListener(target: EventTarget, type: string, handler: EventListener, options?: AddEventListenerOptions): void;
25
+ removeEventListener(target: EventTarget, type: string, handler: EventListener, options?: EventListenerOptions): void;
26
+ querySelector(root: Element | Document, selector: string): Element | null;
27
+ querySelectorAll(root: Element | Document, selector: string): NodeListOf<Element>;
28
+ getElementById(id: string): Element | null;
29
+ /**
30
+ * Move focus to an element. On the server (or when the element cannot receive
31
+ * focus) this is a safe no-op, keeping focus management SSR-compatible.
32
+ */
33
+ focus(element: Element): void;
34
+ isElement(node: Node): node is Element;
35
+ isTextNode(node: Node): node is Text;
36
+ /** Lower-cased tag name of an element (e.g. "div", "h1"). */
37
+ tagName(element: Element): string;
38
+ parentNode(node: Node): Node | null;
39
+ nextSibling(node: Node): Node | null;
40
+ /** First child node (element, text, or otherwise), or null. */
41
+ firstChild(node: Node): Node | null;
42
+ /** All child nodes of an element in order (empty for leaf/text nodes). */
43
+ childNodes(node: Node): Node[];
44
+ }
45
+
46
+ /**
47
+ * Server implementation of `DOMAdapter`.
48
+ *
49
+ * Builds a lightweight in-memory tree (see `server-node.ts`) instead of touching
50
+ * a real browser DOM, then lets the caller serialize it to an HTML string. It is
51
+ * completely free of browser globals, so the exact same renderer that runs in
52
+ * the browser can produce HTML on the server.
53
+ *
54
+ * The `DOMAdapter` interface is typed against the lib DOM types (`Element`,
55
+ * `Node`, `Text`, …). Our server nodes structurally stand in for those at
56
+ * runtime, so the boundary uses `as unknown as` casts in one place. Everything
57
+ * inside operates on the real server-node model.
58
+ */
59
+
60
+ declare class ServerDOMAdapter implements DOMAdapter {
61
+ createElement(tag: string, _ns?: string): Element;
62
+ createTextNode(data: string): Text;
63
+ createComment(data: string): Comment;
64
+ createFragment(): DocumentFragment;
65
+ appendChild(parent: Node, child: Node): void;
66
+ insertBefore(parent: Node, child: Node, reference: Node | null): void;
67
+ removeChild(parent: Node, child: Node): void;
68
+ replaceChild(parent: Node, newChild: Node, oldChild: Node): void;
69
+ private _detach;
70
+ setAttribute(element: Element, name: string, value: string): void;
71
+ removeAttribute(element: Element, name: string): void;
72
+ getAttribute(element: Element, name: string): string | null;
73
+ setProperty(element: Element, name: string, value: unknown): void;
74
+ setTextContent(node: Node, text: string): void;
75
+ getTextContent(node: Node): string | null;
76
+ addEventListener(): void;
77
+ removeEventListener(): void;
78
+ querySelector(): Element | null;
79
+ querySelectorAll(): NodeListOf<Element>;
80
+ getElementById(): Element | null;
81
+ focus(): void;
82
+ isElement(node: Node): node is Element;
83
+ isTextNode(node: Node): node is Text;
84
+ tagName(element: Element): string;
85
+ parentNode(node: Node): Node | null;
86
+ nextSibling(node: Node): Node | null;
87
+ firstChild(node: Node): Node | null;
88
+ childNodes(node: Node): Node[];
89
+ /** Serialize a node's children ("inner HTML") to an HTML string. */
90
+ serializeInner(node: Node): string;
91
+ /** Serialize a node (including itself) to an HTML string. */
92
+ serializeOuter(node: Node): string;
93
+ }
94
+ declare const serverDOMAdapter: ServerDOMAdapter;
95
+
96
+ /**
97
+ * SSR state transfer (dehydration) — move server-resolved data to the client.
98
+ *
99
+ * When the server resolves resources before rendering, their data must reach
100
+ * the client so hydration can seed them (via `resource({ initialData })`)
101
+ * instead of refetching. StreetUI does this with a single, framework-scoped
102
+ * `<script>` payload rather than blindly interpolating `JSON.stringify` into
103
+ * markup.
104
+ *
105
+ * Safety (v0.4 rule #16): the JSON is emitted into a
106
+ * `<script type="application/json">` block — an inert data island the browser
107
+ * never executes — and every character that could terminate that block or be
108
+ * reinterpreted by the HTML/JS parser is escaped to its `\uXXXX` form. Because
109
+ * `<` inside JSON parses back to `<`, the payload round-trips exactly
110
+ * while being impossible to break out of. This is deterministic (stable key
111
+ * order is the caller's responsibility) and typed at the boundary as
112
+ * `Record<string, unknown>` — never `any`.
113
+ */
114
+
115
+ /** Attribute marking StreetUI's state island so the client can find it. */
116
+ declare const STATE_MARKER_ATTR = "data-streetui-state";
117
+ /**
118
+ * Serialize a state map to an HTML `<script>` island for inclusion in the
119
+ * server-rendered document (typically just before the closing tag of the
120
+ * mount container). Returns an empty string for an empty map.
121
+ */
122
+ declare function serializeState(state: Record<string, unknown>): string;
123
+ /**
124
+ * Read the state island back on the client. Searches `root` for StreetUI's
125
+ * state `<script>` and parses it. Returns an empty object when absent or
126
+ * unparseable (hydration then proceeds as a cold client render). Routed through
127
+ * the DOM adapter so it is testable and never assumes a global `document`.
128
+ */
129
+ declare function readState(dom: DOMAdapter, root: Element | Document): Record<string, unknown>;
130
+
131
+ /**
132
+ * Server-side rendering — `renderToString`.
133
+ *
134
+ * Runs the *exact same* mount pipeline used in the browser (`mountGraph`), but
135
+ * against a `ServerDOMAdapter` that builds a lightweight in-memory node tree
136
+ * instead of a real browser DOM. The tree is then serialized to a normal HTML
137
+ * string. Because both browser and server share the DSL → Compiler → Graph →
138
+ * Runtime → Renderer pipeline, there is no second, SSR-specific renderer and no
139
+ * virtual DOM.
140
+ *
141
+ * Lifecycle (v0.4 rule #20): the initial synchronous mount may open signal
142
+ * subscriptions (via `wireSignalBindings`/`wireReactiveList`). On the server
143
+ * those would be live forever, so once the HTML is serialized we dispose the
144
+ * root instance — tearing down every subscription and listener. SSR therefore
145
+ * has a *render* lifecycle only; the live *runtime* lifecycle is established
146
+ * later on the client by `hydrate`.
147
+ */
148
+
149
+ interface RenderToStringOptions {
150
+ /**
151
+ * Override the server DOM adapter (rarely needed). Defaults to a fresh
152
+ * `ServerDOMAdapter` per call so concurrent renders never share state.
153
+ */
154
+ readonly domAdapter?: ServerDOMAdapter;
155
+ }
156
+ /**
157
+ * Render a compiled StreetUI application to an HTML string.
158
+ *
159
+ * The returned markup contains only the application's own elements (the
160
+ * synthetic container is not emitted), so callers embed it wherever they mount
161
+ * on the client — e.g. inside `<div id="app">…</div>`.
162
+ */
163
+ declare function renderToString(compiled: CompiledApplication, options?: RenderToStringOptions): string;
164
+
165
+ export { type DOMAdapter as D, type RenderToStringOptions as R, STATE_MARKER_ATTR as S, ServerDOMAdapter as a, renderToString as b, serverDOMAdapter as c, readState as r, serializeState as s };