@luna_ui/luna 0.11.0 → 0.17.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 (86) hide show
  1. package/dist/api-DAWeanTX.js +1 -0
  2. package/dist/api-qXll116-.d.ts +80 -0
  3. package/dist/cli.mjs +27 -22
  4. package/dist/css/index.js +1 -0
  5. package/dist/event-utils.d.ts +1 -1
  6. package/dist/event-utils.js +1 -1
  7. package/dist/{index-BZoM-af5.d.ts → index-VY8G32hr.d.ts} +16 -76
  8. package/dist/index.d.ts +4 -3
  9. package/dist/index.js +1 -1
  10. package/dist/jsx-dev-runtime.js +1 -1
  11. package/dist/jsx-runtime.d.ts +1 -1
  12. package/dist/jsx-runtime.js +1 -1
  13. package/dist/raw.d.ts +2 -0
  14. package/dist/raw.js +1 -0
  15. package/dist/resource.d.ts +41 -0
  16. package/dist/resource.js +1 -0
  17. package/dist/router-lite.d.ts +44 -0
  18. package/dist/router-lite.js +1 -0
  19. package/dist/signals-shared.d.ts +12 -0
  20. package/dist/signals-shared.js +1 -0
  21. package/dist/signals.d.ts +2 -3
  22. package/dist/signals.js +1 -1
  23. package/dist/vite-plugin.d.ts +7708 -2
  24. package/dist/vite-plugin.js +7 -6
  25. package/package.json +30 -11
  26. package/dist/event-utils-9cHYnvun.js +0 -1
  27. package/dist/src-BFWjzzPo.js +0 -1
  28. package/src/css/extract.ts +0 -798
  29. package/src/css/index.ts +0 -10
  30. package/src/css/inject.ts +0 -205
  31. package/src/css/inline.ts +0 -182
  32. package/src/css/minify.ts +0 -70
  33. package/src/css/optimizer.ts +0 -6
  34. package/src/css/runtime.ts +0 -344
  35. package/src/css-optimizer/README.md +0 -353
  36. package/src/css-optimizer/cooccurrence.ts +0 -100
  37. package/src/css-optimizer/core.ts +0 -263
  38. package/src/css-optimizer/extractors.ts +0 -243
  39. package/src/css-optimizer/hash.ts +0 -54
  40. package/src/css-optimizer/index.ts +0 -129
  41. package/src/css-optimizer/merge.ts +0 -109
  42. package/src/css-optimizer/moonbit-analyzer.ts +0 -210
  43. package/src/css-optimizer/parser.ts +0 -120
  44. package/src/css-optimizer/pattern.ts +0 -171
  45. package/src/css-optimizer/transformers.ts +0 -301
  46. package/src/css-optimizer/types.ts +0 -128
  47. package/src/event-utils.ts +0 -227
  48. package/src/hydration/createHydrator.ts +0 -62
  49. package/src/hydration/delegate.ts +0 -62
  50. package/src/hydration/drag.ts +0 -214
  51. package/src/hydration/index.ts +0 -12
  52. package/src/hydration/keyboard.ts +0 -64
  53. package/src/hydration/toggle.ts +0 -101
  54. package/src/index.ts +0 -908
  55. package/src/jsx-dev-runtime.ts +0 -2
  56. package/src/jsx-runtime.ts +0 -398
  57. package/src/signals.ts +0 -113
  58. package/src/vite-plugin.ts +0 -718
  59. package/tests/__screenshots__/apg.test.ts/APG-Components---Accessibility-Tests-Button-Pattern-disabled-button-has-aria-disabled-1.png +0 -0
  60. package/tests/__screenshots__/resource.test.ts/Resource-API--SolidJS-style--createResource-error-is-undefined-when-pending-1.png +0 -0
  61. package/tests/__screenshots__/resource.test.ts/Resource-API--SolidJS-style--createResource-transitions-to-success-on-resolve-1.png +0 -0
  62. package/tests/apg.test.ts +0 -466
  63. package/tests/context.test.ts +0 -118
  64. package/tests/css-optimizer-extractors.test.ts +0 -264
  65. package/tests/css-optimizer-integration.test.ts +0 -566
  66. package/tests/css-optimizer-transformers.test.ts +0 -301
  67. package/tests/css-optimizer.test.ts +0 -646
  68. package/tests/css-runtime.bench.ts +0 -442
  69. package/tests/css-runtime.test.ts +0 -342
  70. package/tests/debounced.test.ts +0 -165
  71. package/tests/dom.test.ts +0 -873
  72. package/tests/integration.test.ts +0 -405
  73. package/tests/issue-11-show-null-to-truthy.test.ts +0 -176
  74. package/tests/issue-5-for-infinite-loop.test.ts +0 -516
  75. package/tests/jsx-runtime.test.tsx +0 -393
  76. package/tests/lifecycle.test.ts +0 -833
  77. package/tests/move-before.bench.ts +0 -304
  78. package/tests/preact-signals-comparison.test.ts +0 -1608
  79. package/tests/resource.test.ts +0 -170
  80. package/tests/router.test.ts +0 -117
  81. package/tests/show-initial-mount-leak.test.tsx +0 -182
  82. package/tests/solidjs-api.test.ts +0 -660
  83. package/tests/static-perf.bench.ts +0 -64
  84. package/tests/store.test.ts +0 -263
  85. package/tests/tsx-syntax.test.tsx +0 -404
  86. /package/dist/{event-utils-BkTM7rk5.d.ts → event-utils-BvAf0NwN.d.ts} +0 -0
@@ -1,2 +0,0 @@
1
- // JSX Dev Runtime - re-exports jsx-runtime for development mode
2
- export { jsx, jsxs, Fragment, jsxDEV } from "./jsx-runtime";
@@ -1,398 +0,0 @@
1
- // JSX Runtime for @luna_ui/luna
2
- // Usage: Configure tsconfig.json with:
3
- // "jsx": "react-jsx",
4
- // "jsxImportSource": "@luna_ui/luna"
5
-
6
- import { text, textDyn, createElement, Fragment as fragment } from "./index";
7
-
8
- // Types for reactive attributes (can be static value or accessor function)
9
- type MaybeAccessor<T> = T | (() => T);
10
-
11
- // Common HTML attributes with reactive support
12
- interface HTMLAttributes {
13
- // Core attributes
14
- id?: MaybeAccessor<string>;
15
- className?: MaybeAccessor<string>;
16
- class?: MaybeAccessor<string>;
17
- style?: MaybeAccessor<string | Record<string, string | number>>;
18
- title?: MaybeAccessor<string>;
19
- tabIndex?: MaybeAccessor<number>;
20
- hidden?: MaybeAccessor<boolean>;
21
-
22
- // React-compatible innerHTML (use with caution)
23
- // Static: dangerouslySetInnerHTML={{ __html: "<b>html</b>" }}
24
- // Dynamic: dangerouslySetInnerHTML={() => ({ __html: htmlSignal() })}
25
- dangerouslySetInnerHTML?: { __html: string } | (() => { __html: string });
26
-
27
- // Form attributes
28
- type?: MaybeAccessor<string>;
29
- name?: MaybeAccessor<string>;
30
- value?: MaybeAccessor<string | number>;
31
- placeholder?: MaybeAccessor<string>;
32
- disabled?: MaybeAccessor<boolean>;
33
- checked?: MaybeAccessor<boolean>;
34
- readonly?: MaybeAccessor<boolean>;
35
- required?: MaybeAccessor<boolean>;
36
- min?: MaybeAccessor<string | number>;
37
- max?: MaybeAccessor<string | number>;
38
- step?: MaybeAccessor<string | number>;
39
- pattern?: MaybeAccessor<string>;
40
-
41
- // Link/Media attributes
42
- href?: MaybeAccessor<string>;
43
- src?: MaybeAccessor<string>;
44
- alt?: MaybeAccessor<string>;
45
- target?: MaybeAccessor<string>;
46
- rel?: MaybeAccessor<string>;
47
-
48
- // ARIA attributes
49
- role?: MaybeAccessor<string>;
50
- "aria-label"?: MaybeAccessor<string>;
51
- "aria-hidden"?: MaybeAccessor<boolean | "true" | "false">;
52
- "aria-expanded"?: MaybeAccessor<boolean | "true" | "false">;
53
- "aria-selected"?: MaybeAccessor<boolean | "true" | "false">;
54
- "aria-disabled"?: MaybeAccessor<boolean | "true" | "false">;
55
-
56
- // Data attributes
57
- [key: `data-${string}`]: MaybeAccessor<string | number | boolean>;
58
-
59
- // Event handlers
60
- onClick?: (e: MouseEvent) => void;
61
- onInput?: (e: Event) => void;
62
- onChange?: (e: Event) => void;
63
- onSubmit?: (e: Event) => void;
64
- onKeyDown?: (e: KeyboardEvent) => void;
65
- onKeyUp?: (e: KeyboardEvent) => void;
66
- onKeyPress?: (e: KeyboardEvent) => void;
67
- onFocus?: (e: FocusEvent) => void;
68
- onBlur?: (e: FocusEvent) => void;
69
- onMouseEnter?: (e: MouseEvent) => void;
70
- onMouseLeave?: (e: MouseEvent) => void;
71
- onMouseDown?: (e: MouseEvent) => void;
72
- onMouseUp?: (e: MouseEvent) => void;
73
- onMouseMove?: (e: MouseEvent) => void;
74
- onTouchStart?: (e: TouchEvent) => void;
75
- onTouchEnd?: (e: TouchEvent) => void;
76
- onTouchMove?: (e: TouchEvent) => void;
77
- onScroll?: (e: Event) => void;
78
- onLoad?: (e: Event) => void;
79
- onError?: (e: Event) => void;
80
-
81
- // Ref callback
82
- ref?: (el: HTMLElement) => void;
83
-
84
- // Children
85
- children?: JSX.Element | JSX.Element[] | string | number | (() => string | number);
86
-
87
- // Allow any other attribute
88
- [key: string]: unknown;
89
- }
90
-
91
- // Internal types for MoonBit interop
92
- interface Attr {
93
- _0: string;
94
- _1: AttrValue;
95
- }
96
-
97
- interface AttrValue {
98
- $tag: 0 | 1 | 2;
99
- _0: unknown;
100
- }
101
-
102
- // Convert style object to CSS string
103
- function styleToString(style: unknown): string {
104
- if (typeof style === "string") return style;
105
- if (typeof style !== "object" || style === null) return "";
106
- return Object.entries(style)
107
- .map(([key, value]) => {
108
- // Convert camelCase to kebab-case
109
- const cssKey = key.replace(/([A-Z])/g, "-$1").toLowerCase();
110
- return `${cssKey}: ${value}`;
111
- })
112
- .join("; ");
113
- }
114
-
115
- // Convert JSX props to createElement attrs format
116
- function convertProps(props: Record<string, unknown> | null | undefined): Attr[] {
117
- if (!props) return [];
118
- const attrs: Attr[] = [];
119
- for (const [key, value] of Object.entries(props)) {
120
- if (key === "children") continue;
121
-
122
- // Map JSX prop names to DOM attribute format
123
- let attrName = key;
124
- let attrValue: AttrValue;
125
-
126
- // Handle className -> class
127
- if (key === "className") {
128
- attrName = "class";
129
- }
130
-
131
- // Handle dangerouslySetInnerHTML (React-compatible)
132
- if (key === "dangerouslySetInnerHTML") {
133
- if (typeof value === "function") {
134
- // Dynamic innerHTML
135
- const getter = value as () => { __html: string };
136
- attrValue = { $tag: 1, _0: () => getter().__html }; // AttrValue.Dynamic
137
- } else if (value && typeof value === "object" && "__html" in value) {
138
- // Static innerHTML
139
- attrValue = { $tag: 0, _0: (value as { __html: string }).__html }; // AttrValue.Static
140
- } else {
141
- continue; // Invalid format, skip
142
- }
143
- attrs.push({ _0: "__innerHTML", _1: attrValue });
144
- continue;
145
- }
146
-
147
- // Handle style object -> CSS string
148
- if (key === "style") {
149
- if (typeof value === "function") {
150
- // Dynamic style
151
- const getter = value as () => unknown;
152
- attrValue = { $tag: 1, _0: () => styleToString(getter()) }; // AttrValue.Dynamic
153
- } else {
154
- attrValue = { $tag: 0, _0: styleToString(value) }; // AttrValue.Static
155
- }
156
- attrs.push({ _0: attrName, _1: attrValue });
157
- continue;
158
- }
159
-
160
- // Handle ref callback
161
- if (key === "ref" && typeof value === "function") {
162
- attrName = "__ref";
163
- attrValue = { $tag: 2, _0: value }; // AttrValue.Handler
164
- attrs.push({ _0: attrName, _1: attrValue });
165
- continue;
166
- }
167
-
168
- // Handle event handlers (onClick -> click for addEventListener)
169
- if (key.startsWith("on") && typeof value === "function") {
170
- // Remove "on" prefix and lowercase first char: onClick -> click
171
- attrName = key.slice(2).toLowerCase();
172
- attrValue = { $tag: 2, _0: value }; // AttrValue.Handler
173
- attrs.push({ _0: attrName, _1: attrValue });
174
- continue;
175
- }
176
-
177
- // Handle dynamic values (functions)
178
- // For reactive props, pass the accessor function directly: class={className}
179
- if (typeof value === "function") {
180
- attrValue = { $tag: 1, _0: value }; // AttrValue.Dynamic
181
- } else {
182
- attrValue = { $tag: 0, _0: String(value) }; // AttrValue.Static
183
- }
184
-
185
- attrs.push({ _0: attrName, _1: attrValue });
186
- }
187
- return attrs;
188
- }
189
-
190
- type Child = string | number | JSX.Element | (() => unknown) | Child[];
191
-
192
- function convertChildren(children: unknown): unknown[] {
193
- if (!children) return [];
194
- let childArray: unknown[];
195
- if (!Array.isArray(children)) {
196
- childArray = [children];
197
- } else {
198
- childArray = children;
199
- }
200
- return childArray.flat().map((child) => {
201
- if (typeof child === "string") {
202
- return text(child);
203
- }
204
- if (typeof child === "number") {
205
- return text(String(child));
206
- }
207
- // Handle functions:
208
- // - No args (length === 0): signal accessor -> textDyn
209
- // - With args (length > 0): render function -> pass through
210
- if (typeof child === "function") {
211
- if (child.length === 0) {
212
- return textDyn(() => String(child()));
213
- }
214
- // Render function, pass through as-is
215
- return child;
216
- }
217
- return child;
218
- }).filter(Boolean);
219
- }
220
-
221
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
222
- type Component = (props: any) => JSX.Element;
223
-
224
- // JSX factory function
225
- export function jsx(type: string | Component, props: Record<string, unknown> | null): JSX.Element {
226
- const { children, ...rest } = props || {};
227
-
228
- // Function component - pass children as-is, don't convert
229
- // This preserves functions like () => <Child /> for control flow components (Show, For, etc.)
230
- if (typeof type === "function") {
231
- return type({ ...rest, children });
232
- }
233
-
234
- // Element - convert children to DomNodes
235
- if (typeof type === "string") {
236
- const attrs = convertProps(rest);
237
- const childNodes = convertChildren(children);
238
- return createElement(type, attrs, childNodes) as JSX.Element;
239
- }
240
-
241
- throw new Error(`Invalid JSX type: ${type}`);
242
- }
243
-
244
- // jsxs is the same as jsx for our implementation
245
- export const jsxs = jsx;
246
-
247
- // Fragment wraps children in a DomNode fragment
248
- export function Fragment({ children }: { children?: unknown }): unknown {
249
- const childNodes = convertChildren(children);
250
- // Use MoonBit's fragment function to create a proper DomNode fragment
251
- return fragment(childNodes);
252
- }
253
-
254
- // Export jsxDEV for development mode
255
- export const jsxDEV = jsx;
256
-
257
- // Import LunaNode type from index
258
- import type { LunaNode } from "./index";
259
-
260
- // JSX namespace for TypeScript
261
- export namespace JSX {
262
- export type Element = LunaNode;
263
- export interface IntrinsicElements {
264
- // All HTML elements use HTMLAttributes with reactive support
265
- a: HTMLAttributes;
266
- abbr: HTMLAttributes;
267
- address: HTMLAttributes;
268
- area: HTMLAttributes;
269
- article: HTMLAttributes;
270
- aside: HTMLAttributes;
271
- audio: HTMLAttributes;
272
- b: HTMLAttributes;
273
- base: HTMLAttributes;
274
- bdi: HTMLAttributes;
275
- bdo: HTMLAttributes;
276
- blockquote: HTMLAttributes;
277
- body: HTMLAttributes;
278
- br: HTMLAttributes;
279
- button: HTMLAttributes;
280
- canvas: HTMLAttributes;
281
- caption: HTMLAttributes;
282
- cite: HTMLAttributes;
283
- code: HTMLAttributes;
284
- col: HTMLAttributes;
285
- colgroup: HTMLAttributes;
286
- data: HTMLAttributes;
287
- datalist: HTMLAttributes;
288
- dd: HTMLAttributes;
289
- del: HTMLAttributes;
290
- details: HTMLAttributes;
291
- dfn: HTMLAttributes;
292
- dialog: HTMLAttributes;
293
- div: HTMLAttributes;
294
- dl: HTMLAttributes;
295
- dt: HTMLAttributes;
296
- em: HTMLAttributes;
297
- embed: HTMLAttributes;
298
- fieldset: HTMLAttributes;
299
- figcaption: HTMLAttributes;
300
- figure: HTMLAttributes;
301
- footer: HTMLAttributes;
302
- form: HTMLAttributes;
303
- h1: HTMLAttributes;
304
- h2: HTMLAttributes;
305
- h3: HTMLAttributes;
306
- h4: HTMLAttributes;
307
- h5: HTMLAttributes;
308
- h6: HTMLAttributes;
309
- head: HTMLAttributes;
310
- header: HTMLAttributes;
311
- hgroup: HTMLAttributes;
312
- hr: HTMLAttributes;
313
- html: HTMLAttributes;
314
- i: HTMLAttributes;
315
- iframe: HTMLAttributes;
316
- img: HTMLAttributes;
317
- input: HTMLAttributes;
318
- ins: HTMLAttributes;
319
- kbd: HTMLAttributes;
320
- label: HTMLAttributes;
321
- legend: HTMLAttributes;
322
- li: HTMLAttributes;
323
- link: HTMLAttributes;
324
- main: HTMLAttributes;
325
- map: HTMLAttributes;
326
- mark: HTMLAttributes;
327
- menu: HTMLAttributes;
328
- meta: HTMLAttributes;
329
- meter: HTMLAttributes;
330
- nav: HTMLAttributes;
331
- noscript: HTMLAttributes;
332
- object: HTMLAttributes;
333
- ol: HTMLAttributes;
334
- optgroup: HTMLAttributes;
335
- option: HTMLAttributes;
336
- output: HTMLAttributes;
337
- p: HTMLAttributes;
338
- picture: HTMLAttributes;
339
- pre: HTMLAttributes;
340
- progress: HTMLAttributes;
341
- q: HTMLAttributes;
342
- rp: HTMLAttributes;
343
- rt: HTMLAttributes;
344
- ruby: HTMLAttributes;
345
- s: HTMLAttributes;
346
- samp: HTMLAttributes;
347
- script: HTMLAttributes;
348
- search: HTMLAttributes;
349
- section: HTMLAttributes;
350
- select: HTMLAttributes;
351
- slot: HTMLAttributes;
352
- small: HTMLAttributes;
353
- source: HTMLAttributes;
354
- span: HTMLAttributes;
355
- strong: HTMLAttributes;
356
- style: HTMLAttributes;
357
- sub: HTMLAttributes;
358
- summary: HTMLAttributes;
359
- sup: HTMLAttributes;
360
- table: HTMLAttributes;
361
- tbody: HTMLAttributes;
362
- td: HTMLAttributes;
363
- template: HTMLAttributes;
364
- textarea: HTMLAttributes;
365
- tfoot: HTMLAttributes;
366
- th: HTMLAttributes;
367
- thead: HTMLAttributes;
368
- time: HTMLAttributes;
369
- title: HTMLAttributes;
370
- tr: HTMLAttributes;
371
- track: HTMLAttributes;
372
- u: HTMLAttributes;
373
- ul: HTMLAttributes;
374
- var: HTMLAttributes;
375
- video: HTMLAttributes;
376
- wbr: HTMLAttributes;
377
- // SVG elements
378
- svg: HTMLAttributes;
379
- path: HTMLAttributes;
380
- circle: HTMLAttributes;
381
- rect: HTMLAttributes;
382
- line: HTMLAttributes;
383
- polyline: HTMLAttributes;
384
- polygon: HTMLAttributes;
385
- ellipse: HTMLAttributes;
386
- g: HTMLAttributes;
387
- text: HTMLAttributes;
388
- tspan: HTMLAttributes;
389
- defs: HTMLAttributes;
390
- use: HTMLAttributes;
391
- image: HTMLAttributes;
392
- // Allow any custom element
393
- [key: string]: HTMLAttributes;
394
- }
395
- export interface ElementChildrenAttribute {
396
- children: {};
397
- }
398
- }
package/src/signals.ts DELETED
@@ -1,113 +0,0 @@
1
- // @ts-nocheck
2
- // Signals-only entrypoint for smaller bundles
3
-
4
- export type Accessor<T> = () => T;
5
- export type Setter<T> = (value: T | ((prev: T) => T)) => void;
6
- export type Signal<T> = [Accessor<T>, Setter<T>];
7
-
8
- import {
9
- // Signal API (internal)
10
- createSignal as _createSignal,
11
- get as _get,
12
- set as _set,
13
- update as _update,
14
- peek as _peek,
15
- subscribe as _subscribe,
16
- map as _map,
17
- createMemo as _createMemo,
18
- combine as _combine,
19
- effect as _effect,
20
- renderEffect as _renderEffect,
21
- // Batch & owner
22
- batchStart,
23
- batchEnd,
24
- runUntracked,
25
- batch,
26
- onCleanup,
27
- createRoot,
28
- getOwner,
29
- runWithOwner,
30
- hasOwner,
31
- onMount,
32
- } from "../../../target/js/release/build/js/api_signals/api_signals.js";
33
-
34
- // ============================================================================
35
- // SolidJS-compatible Signal API
36
- // ============================================================================
37
-
38
- /**
39
- * Creates a reactive signal (SolidJS-style)
40
- */
41
- export function createSignal<T>(initialValue: T): Signal<T> {
42
- const signal = _createSignal(initialValue);
43
-
44
- const getter: Accessor<T> = () => _get(signal);
45
-
46
- const setter: Setter<T> = (valueOrUpdater) => {
47
- if (typeof valueOrUpdater === "function") {
48
- _update(signal, valueOrUpdater);
49
- } else {
50
- _set(signal, valueOrUpdater);
51
- }
52
- };
53
-
54
- return [getter, setter];
55
- }
56
-
57
- /**
58
- * Creates a reactive effect (SolidJS-style)
59
- * Deferred execution via microtask - runs after rendering completes
60
- */
61
- export function createEffect(fn: () => void): () => void {
62
- return _effect(fn);
63
- }
64
-
65
- /**
66
- * Creates a render effect (SolidJS-style)
67
- * Immediate/synchronous execution - runs during rendering
68
- */
69
- export function createRenderEffect(fn: () => void): () => void {
70
- return _renderEffect(fn);
71
- }
72
-
73
- /**
74
- * Creates a memoized computed value (SolidJS-style)
75
- */
76
- export function createMemo<T>(fn: () => T): Accessor<T> {
77
- return _createMemo(fn);
78
- }
79
-
80
- /**
81
- * Runs a function without tracking dependencies (SolidJS-style alias)
82
- */
83
- export { runUntracked as untrack };
84
-
85
- // Re-export unchanged APIs
86
- export {
87
- // Batch control
88
- batchStart,
89
- batchEnd,
90
- batch,
91
- // Cleanup
92
- onCleanup,
93
- // Owner/Root
94
- createRoot,
95
- getOwner,
96
- runWithOwner,
97
- hasOwner,
98
- onMount,
99
- };
100
-
101
- // Low-level/legacy exports (for direct use)
102
- export {
103
- _get as get,
104
- _set as set,
105
- _update as update,
106
- _peek as peek,
107
- _subscribe as subscribe,
108
- _map as map,
109
- _combine as combine,
110
- _effect as effect,
111
- _renderEffect as renderEffect,
112
- runUntracked,
113
- };