sibujs 1.3.0 → 1.5.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.
- package/README.md +105 -119
- package/dist/browser.cjs +53 -14
- package/dist/browser.d.cts +14 -9
- package/dist/browser.d.ts +14 -9
- package/dist/browser.js +4 -4
- package/dist/build.cjs +125 -135
- package/dist/build.d.cts +1 -1
- package/dist/build.d.ts +1 -1
- package/dist/build.js +11 -91
- package/dist/cdn.global.js +6 -6
- package/dist/chunk-5ZYQ6KDD.js +154 -0
- package/dist/chunk-6BMPXPUW.js +26 -0
- package/dist/chunk-7GRNSCFT.js +1097 -0
- package/dist/chunk-BGTHZHJ5.js +1016 -0
- package/dist/chunk-BMPL52BF.js +654 -0
- package/dist/chunk-CNZ35WI2.js +178 -0
- package/dist/chunk-GJPXRJ45.js +37 -0
- package/dist/chunk-JCDUJN2F.js +2779 -0
- package/dist/chunk-K4G4ZQNR.js +286 -0
- package/dist/chunk-M4NLBH4I.js +725 -0
- package/dist/chunk-MB6QFH3I.js +2776 -0
- package/dist/chunk-MYRV7VDM.js +742 -0
- package/dist/chunk-NZIIMDWI.js +84 -0
- package/dist/chunk-P3XWXJZU.js +282 -0
- package/dist/chunk-PDZQY43A.js +616 -0
- package/dist/chunk-RJ46C3CS.js +1293 -0
- package/dist/chunk-SFKNRVCU.js +292 -0
- package/dist/chunk-TDGZL5CU.js +365 -0
- package/dist/chunk-UHNL42EF.js +2730 -0
- package/dist/chunk-VAPYJN4X.js +368 -0
- package/dist/chunk-VQDZK23A.js +1023 -0
- package/dist/chunk-VQNQZCWJ.js +61 -0
- package/dist/chunk-XHK6BDAJ.js +76 -0
- package/dist/chunk-XUEEGU5O.js +409 -0
- package/dist/chunk-ZWKZCBO6.js +317 -0
- package/dist/contracts-ey_Qh8ef.d.cts +239 -0
- package/dist/contracts-ey_Qh8ef.d.ts +239 -0
- package/dist/contracts-xo5ckdRP.d.cts +240 -0
- package/dist/contracts-xo5ckdRP.d.ts +240 -0
- package/dist/customElement-BL3Uo8dL.d.cts +318 -0
- package/dist/customElement-BL3Uo8dL.d.ts +318 -0
- package/dist/data.cjs +52 -11
- package/dist/data.js +6 -6
- package/dist/devtools.cjs +22 -24
- package/dist/devtools.d.cts +1 -1
- package/dist/devtools.d.ts +1 -1
- package/dist/devtools.js +26 -28
- package/dist/ecosystem.cjs +31 -6
- package/dist/ecosystem.d.cts +4 -4
- package/dist/ecosystem.d.ts +4 -4
- package/dist/ecosystem.js +7 -7
- package/dist/extras.cjs +305 -131
- package/dist/extras.d.cts +3 -3
- package/dist/extras.d.ts +3 -3
- package/dist/extras.js +21 -29
- package/dist/index.cjs +124 -56
- package/dist/index.d.cts +60 -72
- package/dist/index.d.ts +60 -72
- package/dist/index.js +10 -14
- package/dist/motion.cjs +13 -2
- package/dist/motion.d.cts +1 -1
- package/dist/motion.d.ts +1 -1
- package/dist/motion.js +3 -3
- package/dist/patterns.cjs +91 -46
- package/dist/patterns.d.cts +46 -60
- package/dist/patterns.d.ts +46 -60
- package/dist/patterns.js +6 -14
- package/dist/performance.cjs +97 -12
- package/dist/performance.d.cts +6 -1
- package/dist/performance.d.ts +6 -1
- package/dist/performance.js +5 -3
- package/dist/plugins.cjs +20 -14
- package/dist/plugins.d.cts +3 -3
- package/dist/plugins.d.ts +3 -3
- package/dist/plugins.js +17 -19
- package/dist/ssr.cjs +9 -0
- package/dist/ssr.d.cts +1 -1
- package/dist/ssr.d.ts +1 -1
- package/dist/ssr.js +7 -7
- package/dist/testing.js +2 -2
- package/dist/ui.cjs +130 -53
- package/dist/ui.d.cts +13 -16
- package/dist/ui.d.ts +13 -16
- package/dist/ui.js +7 -9
- package/dist/widgets.cjs +31 -6
- package/dist/widgets.js +5 -5
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -319,14 +319,12 @@ declare function each<T>(getArray: () => T[], render: (item: () => T, index: ()
|
|
|
319
319
|
*
|
|
320
320
|
* @example
|
|
321
321
|
* ```ts
|
|
322
|
-
* div(
|
|
323
|
-
*
|
|
324
|
-
*
|
|
325
|
-
*
|
|
326
|
-
*
|
|
327
|
-
*
|
|
328
|
-
* ]
|
|
329
|
-
* });
|
|
322
|
+
* div([
|
|
323
|
+
* Fragment([
|
|
324
|
+
* p("First"),
|
|
325
|
+
* p("Second"),
|
|
326
|
+
* ])
|
|
327
|
+
* ]);
|
|
330
328
|
* ```
|
|
331
329
|
*
|
|
332
330
|
* @param nodes Array of child nodes to include in the fragment
|
|
@@ -338,6 +336,10 @@ declare function Fragment(nodes: NodeChildren[]): DocumentFragment;
|
|
|
338
336
|
* Portal renders nodes into a DOM node outside the parent component hierarchy.
|
|
339
337
|
* Useful for modals, tooltips, dropdowns, and overlays.
|
|
340
338
|
*
|
|
339
|
+
* Cleanup integrates with `dispose()` / `registerDisposer()` so portals
|
|
340
|
+
* are properly torn down when the anchor is disposed by `when()`, `match()`,
|
|
341
|
+
* `each()`, or manual `dispose(anchor)`.
|
|
342
|
+
*
|
|
341
343
|
* @param nodes Function that returns the content to render
|
|
342
344
|
* @param target Target DOM element (defaults to document.body)
|
|
343
345
|
* @returns A Comment anchor node in the original position
|
|
@@ -345,11 +347,11 @@ declare function Fragment(nodes: NodeChildren[]): DocumentFragment;
|
|
|
345
347
|
* @example
|
|
346
348
|
* ```ts
|
|
347
349
|
* // Render modal at document.body
|
|
348
|
-
* Portal(() => div(
|
|
350
|
+
* Portal(() => div("modal", "Modal content"));
|
|
349
351
|
*
|
|
350
352
|
* // Render into specific container
|
|
351
353
|
* const overlay = document.getElementById("overlay-root")!;
|
|
352
|
-
* Portal(() => div(
|
|
354
|
+
* Portal(() => div("Tooltip"), overlay);
|
|
353
355
|
* ```
|
|
354
356
|
*/
|
|
355
357
|
declare function Portal(nodes: () => HTMLElement, target?: HTMLElement): Comment;
|
|
@@ -382,7 +384,7 @@ declare function unregisterComponent(name: string): void;
|
|
|
382
384
|
* @example
|
|
383
385
|
* ```ts
|
|
384
386
|
* registerComponent("Widget", MyWidget);
|
|
385
|
-
* div(
|
|
387
|
+
* div([resolveComponent("Widget")]);
|
|
386
388
|
* ```
|
|
387
389
|
*/
|
|
388
390
|
declare function resolveComponent(name: string): HTMLElement;
|
|
@@ -418,7 +420,7 @@ declare function getSlot(slots: Slots | undefined, name?: string): SlotFn | unde
|
|
|
418
420
|
* @example
|
|
419
421
|
* ```ts
|
|
420
422
|
* const [visible, setVisible] = signal(true);
|
|
421
|
-
* div(
|
|
423
|
+
* div([show(() => visible(), span("I toggle!"))]);
|
|
422
424
|
* ```
|
|
423
425
|
*/
|
|
424
426
|
declare function show<T extends Element>(condition: () => boolean, element: T): T;
|
|
@@ -435,8 +437,8 @@ declare function show<T extends Element>(condition: () => boolean, element: T):
|
|
|
435
437
|
* ```ts
|
|
436
438
|
* when(
|
|
437
439
|
* () => isLoggedIn(),
|
|
438
|
-
* () => div(
|
|
439
|
-
* () => div(
|
|
440
|
+
* () => div("Welcome!"),
|
|
441
|
+
* () => div("Please log in")
|
|
440
442
|
* );
|
|
441
443
|
* ```
|
|
442
444
|
*/
|
|
@@ -459,7 +461,7 @@ declare function when<T>(condition: () => T, thenBranch: () => NodeChild, elseBr
|
|
|
459
461
|
* error: () => ErrorMessage(),
|
|
460
462
|
* success: () => Content(),
|
|
461
463
|
* },
|
|
462
|
-
* () => div(
|
|
464
|
+
* () => div("Unknown status")
|
|
463
465
|
* );
|
|
464
466
|
* ```
|
|
465
467
|
*/
|
|
@@ -527,8 +529,7 @@ type ActionFn<T = void> = (element: HTMLElement, param: T) => (() => void) | und
|
|
|
527
529
|
* action(el, clickOutside, () => setOpen(false));
|
|
528
530
|
* action(el, longPress, { duration: 500, callback: onLongPress });
|
|
529
531
|
* },
|
|
530
|
-
*
|
|
531
|
-
* });
|
|
532
|
+
* }, "Content");
|
|
532
533
|
* ```
|
|
533
534
|
*/
|
|
534
535
|
declare function action<T>(element: HTMLElement, actionFn: ActionFn<T>, param: T): void;
|
|
@@ -636,10 +637,10 @@ declare function setGlobalErrorHandler(handler: ErrorHandler): void;
|
|
|
636
637
|
* ```ts
|
|
637
638
|
* function Field(labelText: string) {
|
|
638
639
|
* const id = createId("field");
|
|
639
|
-
* return div(
|
|
640
|
-
* label({ for: id,
|
|
640
|
+
* return div([
|
|
641
|
+
* label({ for: id }, labelText),
|
|
641
642
|
* input({ id }),
|
|
642
|
-
* ]
|
|
643
|
+
* ]);
|
|
643
644
|
* }
|
|
644
645
|
* ```
|
|
645
646
|
*/
|
|
@@ -675,15 +676,15 @@ declare function checkLeaks(warnThreshold?: number): number;
|
|
|
675
676
|
|
|
676
677
|
declare const __accessor: unique symbol;
|
|
677
678
|
/**
|
|
678
|
-
* A reactive signal getter returned by signal(), derived(),
|
|
679
|
+
* A reactive signal getter returned by signal(), derived(), and similar primitives.
|
|
679
680
|
*
|
|
680
681
|
* Pass an Accessor directly into reactive prop positions — never call it there:
|
|
681
682
|
* ```ts
|
|
682
683
|
* const [count, setCount] = signal(0);
|
|
683
684
|
*
|
|
684
|
-
* div(
|
|
685
|
-
* div(
|
|
686
|
-
* div(
|
|
685
|
+
* div(count) // ✓ reactive — Accessor passed directly
|
|
686
|
+
* div(() => count()) // ✓ reactive — explicit arrow wrapper
|
|
687
|
+
* div(count()) // ✗ static — evaluated once, not reactive
|
|
687
688
|
* ```
|
|
688
689
|
*/
|
|
689
690
|
type Accessor<T> = (() => T) & {
|
|
@@ -828,28 +829,6 @@ interface Ref<T> {
|
|
|
828
829
|
declare function ref<T>(initial: T): Ref<T>;
|
|
829
830
|
declare function ref<T = undefined>(): Ref<T | undefined>;
|
|
830
831
|
|
|
831
|
-
/**
|
|
832
|
-
* memo returns a memoized value that only recomputes when its
|
|
833
|
-
* reactive dependencies change. This is semantically identical to
|
|
834
|
-
* derived but named for convenience.
|
|
835
|
-
*
|
|
836
|
-
* Use this to avoid expensive computations on every render cycle.
|
|
837
|
-
*
|
|
838
|
-
* @param factory Function that computes the memoized value
|
|
839
|
-
* @returns Getter function that returns the memoized value
|
|
840
|
-
*/
|
|
841
|
-
declare function memo<T>(factory: () => T): Accessor<T>;
|
|
842
|
-
|
|
843
|
-
/**
|
|
844
|
-
* memoFn returns a memoized callback function that only updates
|
|
845
|
-
* when its reactive dependencies change. This prevents unnecessary
|
|
846
|
-
* re-creations of callback functions passed to child components.
|
|
847
|
-
*
|
|
848
|
-
* @param callback The callback function to memoize
|
|
849
|
-
* @returns Getter that returns the current memoized callback
|
|
850
|
-
*/
|
|
851
|
-
declare function memoFn<T extends (...args: any[]) => any>(callback: () => T): Accessor<T>;
|
|
852
|
-
|
|
853
832
|
/**
|
|
854
833
|
* Reactive array hook. Provides common array operations that
|
|
855
834
|
* automatically trigger reactive updates.
|
|
@@ -925,16 +904,23 @@ declare function reactiveArray<T>(initial?: T[]): [Accessor<readonly T[]>, Array
|
|
|
925
904
|
/**
|
|
926
905
|
* Deep equality comparison for objects and arrays.
|
|
927
906
|
* Falls back to Object.is for primitives.
|
|
928
|
-
* Handles circular references
|
|
907
|
+
* Handles circular references, shared sub-references, and common
|
|
908
|
+
* built-in types (Date, RegExp, Map, Set, ArrayBuffer, TypedArrays).
|
|
909
|
+
*
|
|
910
|
+
* The `seen` parameter tracks `(a, b)` pairs — not just `a` — so that
|
|
911
|
+
* a shared sub-object compared against two different partners is always
|
|
912
|
+
* fully checked, while genuine cycles (same a-with-same-b revisited)
|
|
913
|
+
* still terminate.
|
|
929
914
|
*/
|
|
930
|
-
declare function deepEqual(a: unknown, b: unknown, seen?: Set<
|
|
915
|
+
declare function deepEqual(a: unknown, b: unknown, seen?: Map<object, Set<object>>): boolean;
|
|
931
916
|
/**
|
|
932
917
|
* Like signal but uses deep equality comparison instead of Object.is.
|
|
933
918
|
* This prevents unnecessary re-renders when setting an object/array
|
|
934
919
|
* to a structurally identical value.
|
|
935
920
|
*
|
|
936
921
|
* @param initial Initial value
|
|
937
|
-
* @returns Tuple [getter, setter]
|
|
922
|
+
* @returns Tuple [getter, setter] — same shape as `signal()`, preserving
|
|
923
|
+
* the `Accessor<T>` brand on the getter.
|
|
938
924
|
*
|
|
939
925
|
* @example
|
|
940
926
|
* ```ts
|
|
@@ -943,7 +929,7 @@ declare function deepEqual(a: unknown, b: unknown, seen?: Set<unknown>): boolean
|
|
|
943
929
|
* setUser({ name: "Bob", age: 25 }); // Notifies — different value
|
|
944
930
|
* ```
|
|
945
931
|
*/
|
|
946
|
-
declare function deepSignal<T>(initial: T): [
|
|
932
|
+
declare function deepSignal<T>(initial: T): [Accessor<T>, (next: T | ((prev: T) => T)) => void];
|
|
947
933
|
|
|
948
934
|
/**
|
|
949
935
|
* Creates a writable computed value — a derived getter paired with
|
|
@@ -1039,7 +1025,7 @@ declare function asyncDerived<T>(factory: () => Promise<T>, initial: T): AsyncDe
|
|
|
1039
1025
|
* console.log("Component was removed");
|
|
1040
1026
|
* });
|
|
1041
1027
|
*
|
|
1042
|
-
* return div(
|
|
1028
|
+
* return div("Hello");
|
|
1043
1029
|
* }
|
|
1044
1030
|
* ```
|
|
1045
1031
|
*/
|
|
@@ -1076,7 +1062,7 @@ declare function onUnmount(callback: CleanupFn, element: HTMLElement): void;
|
|
|
1076
1062
|
* ```ts
|
|
1077
1063
|
* function RealtimeBar(siteId: string) {
|
|
1078
1064
|
* const ws = new WebSocket(`/ws/sites/${siteId}/realtime`);
|
|
1079
|
-
* const root = div(
|
|
1065
|
+
* const root = div("Realtime data...");
|
|
1080
1066
|
* onCleanup(() => ws.close(), root);
|
|
1081
1067
|
* return root;
|
|
1082
1068
|
* }
|
|
@@ -1085,29 +1071,31 @@ declare function onUnmount(callback: CleanupFn, element: HTMLElement): void;
|
|
|
1085
1071
|
declare function onCleanup(callback: CleanupFn, element: Node): void;
|
|
1086
1072
|
|
|
1087
1073
|
/**
|
|
1088
|
-
* Context API for SibuJS —
|
|
1089
|
-
*
|
|
1074
|
+
* Context API for SibuJS — a reactive global value that any component
|
|
1075
|
+
* can read without prop drilling.
|
|
1076
|
+
*
|
|
1077
|
+
* Note: this is a **global reactive store**, not a subtree-scoped DI
|
|
1078
|
+
* system. Calling `provide()` sets the value for ALL consumers, not
|
|
1079
|
+
* just descendants of the provider. For most apps this is sufficient
|
|
1080
|
+
* — use separate `context()` instances for independent scopes.
|
|
1090
1081
|
*
|
|
1091
1082
|
* @example
|
|
1092
1083
|
* ```ts
|
|
1093
1084
|
* // Create a context with a default value
|
|
1094
1085
|
* const ThemeContext = context("light");
|
|
1095
1086
|
*
|
|
1096
|
-
* //
|
|
1097
|
-
*
|
|
1098
|
-
* ThemeContext.provide("dark");
|
|
1099
|
-
* return div({ nodes: [Child()] });
|
|
1100
|
-
* }
|
|
1087
|
+
* // Set the value (global — affects all consumers)
|
|
1088
|
+
* ThemeContext.provide("dark");
|
|
1101
1089
|
*
|
|
1102
|
-
* //
|
|
1090
|
+
* // Read reactively from any component
|
|
1103
1091
|
* function Child() {
|
|
1104
1092
|
* const theme = ThemeContext.use(); // reactive getter
|
|
1105
|
-
* return div(
|
|
1093
|
+
* return div(() => `Theme: ${theme()}`);
|
|
1106
1094
|
* }
|
|
1107
1095
|
* ```
|
|
1108
1096
|
*/
|
|
1109
1097
|
interface Context<T> {
|
|
1110
|
-
/**
|
|
1098
|
+
/** Set the context value globally. Affects all consumers. */
|
|
1111
1099
|
provide(value: T): void;
|
|
1112
1100
|
/** Get a reactive getter for the current context value. */
|
|
1113
1101
|
use(): () => T;
|
|
@@ -1265,7 +1253,7 @@ declare function nextTick(): Promise<void>;
|
|
|
1265
1253
|
* input({ on: { input: e => setQuery(e.target.value) } });
|
|
1266
1254
|
*
|
|
1267
1255
|
* // heavy list reads deferredQuery() and updates one frame later
|
|
1268
|
-
* each(() => heavyFilter(items, deferredQuery()), row => li(
|
|
1256
|
+
* each(() => heavyFilter(items, deferredQuery()), row => li(row.name));
|
|
1269
1257
|
* ```
|
|
1270
1258
|
*/
|
|
1271
1259
|
declare function defer<T>(getter: () => T): () => T;
|
|
@@ -1334,7 +1322,7 @@ type LazyImport = () => Promise<{
|
|
|
1334
1322
|
* // Use inside Suspense for custom loading UI
|
|
1335
1323
|
* Suspense({
|
|
1336
1324
|
* nodes: () => LazyDashboard(),
|
|
1337
|
-
* fallback: () => div(
|
|
1325
|
+
* fallback: () => div("Loading dashboard..."),
|
|
1338
1326
|
* });
|
|
1339
1327
|
*
|
|
1340
1328
|
* // Or use standalone — shows default "Loading..." text
|
|
@@ -1352,7 +1340,7 @@ declare function lazy(importFn: LazyImport): Component;
|
|
|
1352
1340
|
* ```ts
|
|
1353
1341
|
* Suspense({
|
|
1354
1342
|
* nodes: () => LazyChart(),
|
|
1355
|
-
* fallback: () => div(
|
|
1343
|
+
* fallback: () => div("Loading chart..."),
|
|
1356
1344
|
* });
|
|
1357
1345
|
* ```
|
|
1358
1346
|
*
|
|
@@ -1392,7 +1380,7 @@ interface ErrorBoundaryProps {
|
|
|
1392
1380
|
* const [route, setRoute] = signal("/");
|
|
1393
1381
|
* ErrorBoundary({
|
|
1394
1382
|
* resetKeys: [route],
|
|
1395
|
-
* nodes: () => div(
|
|
1383
|
+
* nodes: () => div(riskyPageFor(route())),
|
|
1396
1384
|
* });
|
|
1397
1385
|
* ```
|
|
1398
1386
|
*/
|
|
@@ -1451,13 +1439,13 @@ interface ErrorDisplayProps {
|
|
|
1451
1439
|
*
|
|
1452
1440
|
* @example
|
|
1453
1441
|
* ```ts
|
|
1454
|
-
* button(
|
|
1455
|
-
* on: { click: async () => {
|
|
1442
|
+
* button(
|
|
1443
|
+
* { on: { click: async () => {
|
|
1456
1444
|
* try { await save(); }
|
|
1457
1445
|
* catch (err) { mount(ErrorDisplay({ error: err, onRetry: save }), errorHost); }
|
|
1458
|
-
* }},
|
|
1459
|
-
*
|
|
1460
|
-
*
|
|
1446
|
+
* }}},
|
|
1447
|
+
* "Save",
|
|
1448
|
+
* );
|
|
1461
1449
|
* ```
|
|
1462
1450
|
*/
|
|
1463
1451
|
declare function ErrorDisplay(props: ErrorDisplayProps): Element;
|
|
@@ -1483,4 +1471,4 @@ interface LoadingProps {
|
|
|
1483
1471
|
*/
|
|
1484
1472
|
declare function Loading(props?: LoadingProps): HTMLElement;
|
|
1485
1473
|
|
|
1486
|
-
export { type Accessor, type ActionFn, type AnchorProps, type ArrayActions, type AsyncDerivedState, type AudioProps, type ButtonProps, type Context, DynamicComponent, type EffectOptions, ErrorBoundary, type ErrorBoundaryProps, ErrorDisplay, type ErrorDisplayProps, type ErrorSeverity, type FormProps, Fragment, type ImgProps, type InputProps, type InputType, KeepAlive, type KeepAliveOptions, type LabelProps, Loading, type LoadingProps, type LongPressOptions, type MediaProps, NodeChild, NodeChildren, type OptionProps, Portal, type Ref, type SelectProps, type SignalOptions, type SlotFn, type Slots, type StoreActions, Suspense, type SuspenseProps, TagProps, type TextareaProps, type TypedTagFunction, type VideoProps, __resetIdCounter, a, abbr, action, address, area, array, article, aside, asyncDerived, audio, autoResize, b, base, batch, bdi, bdo, bindDynamic, blockquote, body, br, button, canvas, caption, catchError, catchErrorAsync, center, checkLeaks, circle, cite, clickOutside, clipPath, code, col, colgroup, context, copyOnClick, createId, customElement, data, datalist, dd, deepEqual, deepSignal, defer, defs, del, derived, details, dfn, dialog, disableSSR, dispose, div, dl, dt, each, effect, ellipse, em, embed, enableSSR, enqueueBatchedSignal, fieldset, figcaption, figure, font, footer, form, g, getSlot, h1, h2, h3, h4, h5, h6, head, header, hr, html, i, iframe, img, input, ins, isBatching, isSSR, kbd, label, lazy, legend, li, line, linearGradient, link, longPress, main, map, mark, marker, marquee, mask, match, math,
|
|
1474
|
+
export { type Accessor, type ActionFn, type AnchorProps, type ArrayActions, type AsyncDerivedState, type AudioProps, type ButtonProps, type Context, DynamicComponent, type EffectOptions, ErrorBoundary, type ErrorBoundaryProps, ErrorDisplay, type ErrorDisplayProps, type ErrorSeverity, type FormProps, Fragment, type ImgProps, type InputProps, type InputType, KeepAlive, type KeepAliveOptions, type LabelProps, Loading, type LoadingProps, type LongPressOptions, type MediaProps, NodeChild, NodeChildren, type OptionProps, Portal, type Ref, type SelectProps, type SignalOptions, type SlotFn, type Slots, type StoreActions, Suspense, type SuspenseProps, TagProps, type TextareaProps, type TypedTagFunction, type VideoProps, __resetIdCounter, a, abbr, action, address, area, array, article, aside, asyncDerived, audio, autoResize, b, base, batch, bdi, bdo, bindDynamic, blockquote, body, br, button, canvas, caption, catchError, catchErrorAsync, center, checkLeaks, circle, cite, clickOutside, clipPath, code, col, colgroup, context, copyOnClick, createId, customElement, data, datalist, dd, deepEqual, deepSignal, defer, defs, del, derived, details, dfn, dialog, disableSSR, dispose, div, dl, dt, each, effect, ellipse, em, embed, enableSSR, enqueueBatchedSignal, fieldset, figcaption, figure, font, footer, form, g, getSlot, h1, h2, h3, h4, h5, h6, head, header, hr, html, i, iframe, img, input, ins, isBatching, isSSR, kbd, label, lazy, legend, li, line, linearGradient, link, longPress, main, map, mark, marker, marquee, mask, match, math, menu, meta, meter, mount, nav, nextTick, noscript, object, ol, on, onCleanup, onMount, onUnmount, optgroup, option, output, p, param, path, pattern, picture, polygon, polyline, portal, pre, progress, q, radialGradient, reactiveArray, rect, ref, registerComponent, registerDisposer, resolveComponent, rp, rt, ruby, s, samp, script, section, select, setGlobalErrorHandler, show, signal, slot, small, source, span, stop, store, strict, strictEffect, strong, style, sub, summary, sup, svg, symbol, table, tbody, td, template, text, textarea, tfoot, th, thead, time, title, tr, track, transition, trapFocus, tspan, u, ul, unregisterComponent, untracked, use, var_, video, watch, when, withSSR, writable };
|
package/dist/index.d.ts
CHANGED
|
@@ -319,14 +319,12 @@ declare function each<T>(getArray: () => T[], render: (item: () => T, index: ()
|
|
|
319
319
|
*
|
|
320
320
|
* @example
|
|
321
321
|
* ```ts
|
|
322
|
-
* div(
|
|
323
|
-
*
|
|
324
|
-
*
|
|
325
|
-
*
|
|
326
|
-
*
|
|
327
|
-
*
|
|
328
|
-
* ]
|
|
329
|
-
* });
|
|
322
|
+
* div([
|
|
323
|
+
* Fragment([
|
|
324
|
+
* p("First"),
|
|
325
|
+
* p("Second"),
|
|
326
|
+
* ])
|
|
327
|
+
* ]);
|
|
330
328
|
* ```
|
|
331
329
|
*
|
|
332
330
|
* @param nodes Array of child nodes to include in the fragment
|
|
@@ -338,6 +336,10 @@ declare function Fragment(nodes: NodeChildren[]): DocumentFragment;
|
|
|
338
336
|
* Portal renders nodes into a DOM node outside the parent component hierarchy.
|
|
339
337
|
* Useful for modals, tooltips, dropdowns, and overlays.
|
|
340
338
|
*
|
|
339
|
+
* Cleanup integrates with `dispose()` / `registerDisposer()` so portals
|
|
340
|
+
* are properly torn down when the anchor is disposed by `when()`, `match()`,
|
|
341
|
+
* `each()`, or manual `dispose(anchor)`.
|
|
342
|
+
*
|
|
341
343
|
* @param nodes Function that returns the content to render
|
|
342
344
|
* @param target Target DOM element (defaults to document.body)
|
|
343
345
|
* @returns A Comment anchor node in the original position
|
|
@@ -345,11 +347,11 @@ declare function Fragment(nodes: NodeChildren[]): DocumentFragment;
|
|
|
345
347
|
* @example
|
|
346
348
|
* ```ts
|
|
347
349
|
* // Render modal at document.body
|
|
348
|
-
* Portal(() => div(
|
|
350
|
+
* Portal(() => div("modal", "Modal content"));
|
|
349
351
|
*
|
|
350
352
|
* // Render into specific container
|
|
351
353
|
* const overlay = document.getElementById("overlay-root")!;
|
|
352
|
-
* Portal(() => div(
|
|
354
|
+
* Portal(() => div("Tooltip"), overlay);
|
|
353
355
|
* ```
|
|
354
356
|
*/
|
|
355
357
|
declare function Portal(nodes: () => HTMLElement, target?: HTMLElement): Comment;
|
|
@@ -382,7 +384,7 @@ declare function unregisterComponent(name: string): void;
|
|
|
382
384
|
* @example
|
|
383
385
|
* ```ts
|
|
384
386
|
* registerComponent("Widget", MyWidget);
|
|
385
|
-
* div(
|
|
387
|
+
* div([resolveComponent("Widget")]);
|
|
386
388
|
* ```
|
|
387
389
|
*/
|
|
388
390
|
declare function resolveComponent(name: string): HTMLElement;
|
|
@@ -418,7 +420,7 @@ declare function getSlot(slots: Slots | undefined, name?: string): SlotFn | unde
|
|
|
418
420
|
* @example
|
|
419
421
|
* ```ts
|
|
420
422
|
* const [visible, setVisible] = signal(true);
|
|
421
|
-
* div(
|
|
423
|
+
* div([show(() => visible(), span("I toggle!"))]);
|
|
422
424
|
* ```
|
|
423
425
|
*/
|
|
424
426
|
declare function show<T extends Element>(condition: () => boolean, element: T): T;
|
|
@@ -435,8 +437,8 @@ declare function show<T extends Element>(condition: () => boolean, element: T):
|
|
|
435
437
|
* ```ts
|
|
436
438
|
* when(
|
|
437
439
|
* () => isLoggedIn(),
|
|
438
|
-
* () => div(
|
|
439
|
-
* () => div(
|
|
440
|
+
* () => div("Welcome!"),
|
|
441
|
+
* () => div("Please log in")
|
|
440
442
|
* );
|
|
441
443
|
* ```
|
|
442
444
|
*/
|
|
@@ -459,7 +461,7 @@ declare function when<T>(condition: () => T, thenBranch: () => NodeChild, elseBr
|
|
|
459
461
|
* error: () => ErrorMessage(),
|
|
460
462
|
* success: () => Content(),
|
|
461
463
|
* },
|
|
462
|
-
* () => div(
|
|
464
|
+
* () => div("Unknown status")
|
|
463
465
|
* );
|
|
464
466
|
* ```
|
|
465
467
|
*/
|
|
@@ -527,8 +529,7 @@ type ActionFn<T = void> = (element: HTMLElement, param: T) => (() => void) | und
|
|
|
527
529
|
* action(el, clickOutside, () => setOpen(false));
|
|
528
530
|
* action(el, longPress, { duration: 500, callback: onLongPress });
|
|
529
531
|
* },
|
|
530
|
-
*
|
|
531
|
-
* });
|
|
532
|
+
* }, "Content");
|
|
532
533
|
* ```
|
|
533
534
|
*/
|
|
534
535
|
declare function action<T>(element: HTMLElement, actionFn: ActionFn<T>, param: T): void;
|
|
@@ -636,10 +637,10 @@ declare function setGlobalErrorHandler(handler: ErrorHandler): void;
|
|
|
636
637
|
* ```ts
|
|
637
638
|
* function Field(labelText: string) {
|
|
638
639
|
* const id = createId("field");
|
|
639
|
-
* return div(
|
|
640
|
-
* label({ for: id,
|
|
640
|
+
* return div([
|
|
641
|
+
* label({ for: id }, labelText),
|
|
641
642
|
* input({ id }),
|
|
642
|
-
* ]
|
|
643
|
+
* ]);
|
|
643
644
|
* }
|
|
644
645
|
* ```
|
|
645
646
|
*/
|
|
@@ -675,15 +676,15 @@ declare function checkLeaks(warnThreshold?: number): number;
|
|
|
675
676
|
|
|
676
677
|
declare const __accessor: unique symbol;
|
|
677
678
|
/**
|
|
678
|
-
* A reactive signal getter returned by signal(), derived(),
|
|
679
|
+
* A reactive signal getter returned by signal(), derived(), and similar primitives.
|
|
679
680
|
*
|
|
680
681
|
* Pass an Accessor directly into reactive prop positions — never call it there:
|
|
681
682
|
* ```ts
|
|
682
683
|
* const [count, setCount] = signal(0);
|
|
683
684
|
*
|
|
684
|
-
* div(
|
|
685
|
-
* div(
|
|
686
|
-
* div(
|
|
685
|
+
* div(count) // ✓ reactive — Accessor passed directly
|
|
686
|
+
* div(() => count()) // ✓ reactive — explicit arrow wrapper
|
|
687
|
+
* div(count()) // ✗ static — evaluated once, not reactive
|
|
687
688
|
* ```
|
|
688
689
|
*/
|
|
689
690
|
type Accessor<T> = (() => T) & {
|
|
@@ -828,28 +829,6 @@ interface Ref<T> {
|
|
|
828
829
|
declare function ref<T>(initial: T): Ref<T>;
|
|
829
830
|
declare function ref<T = undefined>(): Ref<T | undefined>;
|
|
830
831
|
|
|
831
|
-
/**
|
|
832
|
-
* memo returns a memoized value that only recomputes when its
|
|
833
|
-
* reactive dependencies change. This is semantically identical to
|
|
834
|
-
* derived but named for convenience.
|
|
835
|
-
*
|
|
836
|
-
* Use this to avoid expensive computations on every render cycle.
|
|
837
|
-
*
|
|
838
|
-
* @param factory Function that computes the memoized value
|
|
839
|
-
* @returns Getter function that returns the memoized value
|
|
840
|
-
*/
|
|
841
|
-
declare function memo<T>(factory: () => T): Accessor<T>;
|
|
842
|
-
|
|
843
|
-
/**
|
|
844
|
-
* memoFn returns a memoized callback function that only updates
|
|
845
|
-
* when its reactive dependencies change. This prevents unnecessary
|
|
846
|
-
* re-creations of callback functions passed to child components.
|
|
847
|
-
*
|
|
848
|
-
* @param callback The callback function to memoize
|
|
849
|
-
* @returns Getter that returns the current memoized callback
|
|
850
|
-
*/
|
|
851
|
-
declare function memoFn<T extends (...args: any[]) => any>(callback: () => T): Accessor<T>;
|
|
852
|
-
|
|
853
832
|
/**
|
|
854
833
|
* Reactive array hook. Provides common array operations that
|
|
855
834
|
* automatically trigger reactive updates.
|
|
@@ -925,16 +904,23 @@ declare function reactiveArray<T>(initial?: T[]): [Accessor<readonly T[]>, Array
|
|
|
925
904
|
/**
|
|
926
905
|
* Deep equality comparison for objects and arrays.
|
|
927
906
|
* Falls back to Object.is for primitives.
|
|
928
|
-
* Handles circular references
|
|
907
|
+
* Handles circular references, shared sub-references, and common
|
|
908
|
+
* built-in types (Date, RegExp, Map, Set, ArrayBuffer, TypedArrays).
|
|
909
|
+
*
|
|
910
|
+
* The `seen` parameter tracks `(a, b)` pairs — not just `a` — so that
|
|
911
|
+
* a shared sub-object compared against two different partners is always
|
|
912
|
+
* fully checked, while genuine cycles (same a-with-same-b revisited)
|
|
913
|
+
* still terminate.
|
|
929
914
|
*/
|
|
930
|
-
declare function deepEqual(a: unknown, b: unknown, seen?: Set<
|
|
915
|
+
declare function deepEqual(a: unknown, b: unknown, seen?: Map<object, Set<object>>): boolean;
|
|
931
916
|
/**
|
|
932
917
|
* Like signal but uses deep equality comparison instead of Object.is.
|
|
933
918
|
* This prevents unnecessary re-renders when setting an object/array
|
|
934
919
|
* to a structurally identical value.
|
|
935
920
|
*
|
|
936
921
|
* @param initial Initial value
|
|
937
|
-
* @returns Tuple [getter, setter]
|
|
922
|
+
* @returns Tuple [getter, setter] — same shape as `signal()`, preserving
|
|
923
|
+
* the `Accessor<T>` brand on the getter.
|
|
938
924
|
*
|
|
939
925
|
* @example
|
|
940
926
|
* ```ts
|
|
@@ -943,7 +929,7 @@ declare function deepEqual(a: unknown, b: unknown, seen?: Set<unknown>): boolean
|
|
|
943
929
|
* setUser({ name: "Bob", age: 25 }); // Notifies — different value
|
|
944
930
|
* ```
|
|
945
931
|
*/
|
|
946
|
-
declare function deepSignal<T>(initial: T): [
|
|
932
|
+
declare function deepSignal<T>(initial: T): [Accessor<T>, (next: T | ((prev: T) => T)) => void];
|
|
947
933
|
|
|
948
934
|
/**
|
|
949
935
|
* Creates a writable computed value — a derived getter paired with
|
|
@@ -1039,7 +1025,7 @@ declare function asyncDerived<T>(factory: () => Promise<T>, initial: T): AsyncDe
|
|
|
1039
1025
|
* console.log("Component was removed");
|
|
1040
1026
|
* });
|
|
1041
1027
|
*
|
|
1042
|
-
* return div(
|
|
1028
|
+
* return div("Hello");
|
|
1043
1029
|
* }
|
|
1044
1030
|
* ```
|
|
1045
1031
|
*/
|
|
@@ -1076,7 +1062,7 @@ declare function onUnmount(callback: CleanupFn, element: HTMLElement): void;
|
|
|
1076
1062
|
* ```ts
|
|
1077
1063
|
* function RealtimeBar(siteId: string) {
|
|
1078
1064
|
* const ws = new WebSocket(`/ws/sites/${siteId}/realtime`);
|
|
1079
|
-
* const root = div(
|
|
1065
|
+
* const root = div("Realtime data...");
|
|
1080
1066
|
* onCleanup(() => ws.close(), root);
|
|
1081
1067
|
* return root;
|
|
1082
1068
|
* }
|
|
@@ -1085,29 +1071,31 @@ declare function onUnmount(callback: CleanupFn, element: HTMLElement): void;
|
|
|
1085
1071
|
declare function onCleanup(callback: CleanupFn, element: Node): void;
|
|
1086
1072
|
|
|
1087
1073
|
/**
|
|
1088
|
-
* Context API for SibuJS —
|
|
1089
|
-
*
|
|
1074
|
+
* Context API for SibuJS — a reactive global value that any component
|
|
1075
|
+
* can read without prop drilling.
|
|
1076
|
+
*
|
|
1077
|
+
* Note: this is a **global reactive store**, not a subtree-scoped DI
|
|
1078
|
+
* system. Calling `provide()` sets the value for ALL consumers, not
|
|
1079
|
+
* just descendants of the provider. For most apps this is sufficient
|
|
1080
|
+
* — use separate `context()` instances for independent scopes.
|
|
1090
1081
|
*
|
|
1091
1082
|
* @example
|
|
1092
1083
|
* ```ts
|
|
1093
1084
|
* // Create a context with a default value
|
|
1094
1085
|
* const ThemeContext = context("light");
|
|
1095
1086
|
*
|
|
1096
|
-
* //
|
|
1097
|
-
*
|
|
1098
|
-
* ThemeContext.provide("dark");
|
|
1099
|
-
* return div({ nodes: [Child()] });
|
|
1100
|
-
* }
|
|
1087
|
+
* // Set the value (global — affects all consumers)
|
|
1088
|
+
* ThemeContext.provide("dark");
|
|
1101
1089
|
*
|
|
1102
|
-
* //
|
|
1090
|
+
* // Read reactively from any component
|
|
1103
1091
|
* function Child() {
|
|
1104
1092
|
* const theme = ThemeContext.use(); // reactive getter
|
|
1105
|
-
* return div(
|
|
1093
|
+
* return div(() => `Theme: ${theme()}`);
|
|
1106
1094
|
* }
|
|
1107
1095
|
* ```
|
|
1108
1096
|
*/
|
|
1109
1097
|
interface Context<T> {
|
|
1110
|
-
/**
|
|
1098
|
+
/** Set the context value globally. Affects all consumers. */
|
|
1111
1099
|
provide(value: T): void;
|
|
1112
1100
|
/** Get a reactive getter for the current context value. */
|
|
1113
1101
|
use(): () => T;
|
|
@@ -1265,7 +1253,7 @@ declare function nextTick(): Promise<void>;
|
|
|
1265
1253
|
* input({ on: { input: e => setQuery(e.target.value) } });
|
|
1266
1254
|
*
|
|
1267
1255
|
* // heavy list reads deferredQuery() and updates one frame later
|
|
1268
|
-
* each(() => heavyFilter(items, deferredQuery()), row => li(
|
|
1256
|
+
* each(() => heavyFilter(items, deferredQuery()), row => li(row.name));
|
|
1269
1257
|
* ```
|
|
1270
1258
|
*/
|
|
1271
1259
|
declare function defer<T>(getter: () => T): () => T;
|
|
@@ -1334,7 +1322,7 @@ type LazyImport = () => Promise<{
|
|
|
1334
1322
|
* // Use inside Suspense for custom loading UI
|
|
1335
1323
|
* Suspense({
|
|
1336
1324
|
* nodes: () => LazyDashboard(),
|
|
1337
|
-
* fallback: () => div(
|
|
1325
|
+
* fallback: () => div("Loading dashboard..."),
|
|
1338
1326
|
* });
|
|
1339
1327
|
*
|
|
1340
1328
|
* // Or use standalone — shows default "Loading..." text
|
|
@@ -1352,7 +1340,7 @@ declare function lazy(importFn: LazyImport): Component;
|
|
|
1352
1340
|
* ```ts
|
|
1353
1341
|
* Suspense({
|
|
1354
1342
|
* nodes: () => LazyChart(),
|
|
1355
|
-
* fallback: () => div(
|
|
1343
|
+
* fallback: () => div("Loading chart..."),
|
|
1356
1344
|
* });
|
|
1357
1345
|
* ```
|
|
1358
1346
|
*
|
|
@@ -1392,7 +1380,7 @@ interface ErrorBoundaryProps {
|
|
|
1392
1380
|
* const [route, setRoute] = signal("/");
|
|
1393
1381
|
* ErrorBoundary({
|
|
1394
1382
|
* resetKeys: [route],
|
|
1395
|
-
* nodes: () => div(
|
|
1383
|
+
* nodes: () => div(riskyPageFor(route())),
|
|
1396
1384
|
* });
|
|
1397
1385
|
* ```
|
|
1398
1386
|
*/
|
|
@@ -1451,13 +1439,13 @@ interface ErrorDisplayProps {
|
|
|
1451
1439
|
*
|
|
1452
1440
|
* @example
|
|
1453
1441
|
* ```ts
|
|
1454
|
-
* button(
|
|
1455
|
-
* on: { click: async () => {
|
|
1442
|
+
* button(
|
|
1443
|
+
* { on: { click: async () => {
|
|
1456
1444
|
* try { await save(); }
|
|
1457
1445
|
* catch (err) { mount(ErrorDisplay({ error: err, onRetry: save }), errorHost); }
|
|
1458
|
-
* }},
|
|
1459
|
-
*
|
|
1460
|
-
*
|
|
1446
|
+
* }}},
|
|
1447
|
+
* "Save",
|
|
1448
|
+
* );
|
|
1461
1449
|
* ```
|
|
1462
1450
|
*/
|
|
1463
1451
|
declare function ErrorDisplay(props: ErrorDisplayProps): Element;
|
|
@@ -1483,4 +1471,4 @@ interface LoadingProps {
|
|
|
1483
1471
|
*/
|
|
1484
1472
|
declare function Loading(props?: LoadingProps): HTMLElement;
|
|
1485
1473
|
|
|
1486
|
-
export { type Accessor, type ActionFn, type AnchorProps, type ArrayActions, type AsyncDerivedState, type AudioProps, type ButtonProps, type Context, DynamicComponent, type EffectOptions, ErrorBoundary, type ErrorBoundaryProps, ErrorDisplay, type ErrorDisplayProps, type ErrorSeverity, type FormProps, Fragment, type ImgProps, type InputProps, type InputType, KeepAlive, type KeepAliveOptions, type LabelProps, Loading, type LoadingProps, type LongPressOptions, type MediaProps, NodeChild, NodeChildren, type OptionProps, Portal, type Ref, type SelectProps, type SignalOptions, type SlotFn, type Slots, type StoreActions, Suspense, type SuspenseProps, TagProps, type TextareaProps, type TypedTagFunction, type VideoProps, __resetIdCounter, a, abbr, action, address, area, array, article, aside, asyncDerived, audio, autoResize, b, base, batch, bdi, bdo, bindDynamic, blockquote, body, br, button, canvas, caption, catchError, catchErrorAsync, center, checkLeaks, circle, cite, clickOutside, clipPath, code, col, colgroup, context, copyOnClick, createId, customElement, data, datalist, dd, deepEqual, deepSignal, defer, defs, del, derived, details, dfn, dialog, disableSSR, dispose, div, dl, dt, each, effect, ellipse, em, embed, enableSSR, enqueueBatchedSignal, fieldset, figcaption, figure, font, footer, form, g, getSlot, h1, h2, h3, h4, h5, h6, head, header, hr, html, i, iframe, img, input, ins, isBatching, isSSR, kbd, label, lazy, legend, li, line, linearGradient, link, longPress, main, map, mark, marker, marquee, mask, match, math,
|
|
1474
|
+
export { type Accessor, type ActionFn, type AnchorProps, type ArrayActions, type AsyncDerivedState, type AudioProps, type ButtonProps, type Context, DynamicComponent, type EffectOptions, ErrorBoundary, type ErrorBoundaryProps, ErrorDisplay, type ErrorDisplayProps, type ErrorSeverity, type FormProps, Fragment, type ImgProps, type InputProps, type InputType, KeepAlive, type KeepAliveOptions, type LabelProps, Loading, type LoadingProps, type LongPressOptions, type MediaProps, NodeChild, NodeChildren, type OptionProps, Portal, type Ref, type SelectProps, type SignalOptions, type SlotFn, type Slots, type StoreActions, Suspense, type SuspenseProps, TagProps, type TextareaProps, type TypedTagFunction, type VideoProps, __resetIdCounter, a, abbr, action, address, area, array, article, aside, asyncDerived, audio, autoResize, b, base, batch, bdi, bdo, bindDynamic, blockquote, body, br, button, canvas, caption, catchError, catchErrorAsync, center, checkLeaks, circle, cite, clickOutside, clipPath, code, col, colgroup, context, copyOnClick, createId, customElement, data, datalist, dd, deepEqual, deepSignal, defer, defs, del, derived, details, dfn, dialog, disableSSR, dispose, div, dl, dt, each, effect, ellipse, em, embed, enableSSR, enqueueBatchedSignal, fieldset, figcaption, figure, font, footer, form, g, getSlot, h1, h2, h3, h4, h5, h6, head, header, hr, html, i, iframe, img, input, ins, isBatching, isSSR, kbd, label, lazy, legend, li, line, linearGradient, link, longPress, main, map, mark, marker, marquee, mask, match, math, menu, meta, meter, mount, nav, nextTick, noscript, object, ol, on, onCleanup, onMount, onUnmount, optgroup, option, output, p, param, path, pattern, picture, polygon, polyline, portal, pre, progress, q, radialGradient, reactiveArray, rect, ref, registerComponent, registerDisposer, resolveComponent, rp, rt, ruby, s, samp, script, section, select, setGlobalErrorHandler, show, signal, slot, small, source, span, stop, store, strict, strictEffect, strong, style, sub, summary, sup, svg, symbol, table, tbody, td, template, text, textarea, tfoot, th, thead, time, title, tr, track, transition, trapFocus, tspan, u, ul, unregisterComponent, untracked, use, var_, video, watch, when, withSSR, writable };
|