sibujs 4.5.0 → 4.6.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/dist/browser.cjs +309 -129
- package/dist/browser.d.cts +46 -14
- package/dist/browser.d.ts +46 -14
- package/dist/browser.js +8 -6
- package/dist/build.cjs +184 -72
- package/dist/build.js +15 -16
- package/dist/cdn.dev.global.js +12 -12
- package/dist/cdn.full.dev.global.js +11 -11
- package/dist/cdn.full.global.js +10 -10
- package/dist/cdn.global.js +12 -12
- package/dist/{chunk-IXKSNWV5.js → chunk-2INLLLMZ.js} +1 -1
- package/dist/chunk-3ISI6ACU.js +44 -0
- package/dist/{chunk-ONOHFDLG.js → chunk-47M47FOM.js} +3 -3
- package/dist/chunk-5HZXGZ6T.js +24 -0
- package/dist/{chunk-KKLW7YWL.js → chunk-5MT6SJ3P.js} +275 -144
- package/dist/{chunk-UGRX3S57.js → chunk-5Q4R7HCL.js} +12 -3
- package/dist/{chunk-S373NSMK.js → chunk-7GQCWFOE.js} +150 -59
- package/dist/{chunk-FTIR4QW2.js → chunk-7NCARGJW.js} +6 -8
- package/dist/{chunk-5DXA2J44.js → chunk-7XHATCIH.js} +5 -2
- package/dist/{chunk-VZKNK2V7.js → chunk-AIF3Z2T7.js} +296 -38
- package/dist/{chunk-4PMLNECI.js → chunk-BAAG6ZTI.js} +98 -29
- package/dist/{chunk-XZZOBQAY.js → chunk-D33YTSX5.js} +2 -2
- package/dist/{chunk-TBYTO6BS.js → chunk-DKGBBKOF.js} +136 -80
- package/dist/{chunk-NIOYEGBQ.js → chunk-HURREPU2.js} +27 -13
- package/dist/{chunk-GW3SCCZG.js → chunk-HYXDKS4N.js} +153 -110
- package/dist/chunk-J6FW5TV6.js +233 -0
- package/dist/{chunk-PCT43HW3.js → chunk-JSXPZCET.js} +1 -1
- package/dist/chunk-NYNYSPK7.js +318 -0
- package/dist/{chunk-RJE2BNI4.js → chunk-ORMZXBKQ.js} +108 -45
- package/dist/{chunk-OMJJM3KM.js → chunk-OXUY2A6L.js} +287 -130
- package/dist/{chunk-3JZ4L5TJ.js → chunk-PK6FK2G2.js} +181 -66
- package/dist/{chunk-RBTPLM32.js → chunk-QE4TTDU3.js} +2 -2
- package/dist/{chunk-2DCGACUU.js → chunk-SXXVZMKZ.js} +251 -66
- package/dist/{chunk-R25EFXXC.js → chunk-TUCPL2HB.js} +3 -3
- package/dist/{chunk-7LN645I6.js → chunk-UZQ6ALFS.js} +3 -3
- package/dist/{chunk-KEISJXBU.js → chunk-VVWPJ543.js} +6 -8
- package/dist/{chunk-RIXRAYIU.js → chunk-XC4MEKGA.js} +3 -3
- package/dist/{chunk-B3WHI2QA.js → chunk-XRRZKZYX.js} +55 -31
- package/dist/{contracts-DBdg9J_a.d.cts → contracts-DRIuclVT.d.cts} +10 -2
- package/dist/{contracts-DBdg9J_a.d.ts → contracts-DRIuclVT.d.ts} +10 -2
- package/dist/{customElement-OB9CIsc5.d.cts → customElement-MmInOW1U.d.cts} +21 -0
- package/dist/{customElement-OB9CIsc5.d.ts → customElement-MmInOW1U.d.ts} +21 -0
- package/dist/data.cjs +213 -117
- package/dist/data.d.cts +47 -9
- package/dist/data.d.ts +47 -9
- package/dist/data.js +12 -9
- package/dist/devtools.cjs +81 -57
- package/dist/devtools.js +7 -8
- package/dist/dispose-GEIG2KOF.js +28 -0
- package/dist/ecosystem.cjs +309 -104
- package/dist/ecosystem.d.cts +19 -3
- package/dist/ecosystem.d.ts +19 -3
- package/dist/ecosystem.js +12 -12
- package/dist/extras.cjs +2133 -863
- package/dist/extras.d.cts +10 -9
- package/dist/extras.d.ts +10 -9
- package/dist/extras.js +39 -28
- package/dist/index.cjs +184 -72
- package/dist/index.d.cts +22 -5
- package/dist/index.d.ts +22 -5
- package/dist/index.js +24 -27
- package/dist/motion.cjs +107 -41
- package/dist/motion.js +5 -5
- package/dist/patterns.cjs +317 -39
- package/dist/patterns.d.cts +27 -9
- package/dist/patterns.d.ts +27 -9
- package/dist/patterns.js +8 -8
- package/dist/performance.cjs +308 -216
- package/dist/performance.d.cts +2 -2
- package/dist/performance.d.ts +2 -2
- package/dist/performance.js +8 -9
- package/dist/plugin-DVgSnTfK.d.cts +112 -0
- package/dist/plugin-DVgSnTfK.d.ts +112 -0
- package/dist/plugins.cjs +549 -202
- package/dist/plugins.d.cts +3 -3
- package/dist/plugins.d.ts +3 -3
- package/dist/plugins.js +35 -23
- package/dist/signal-EotCj4hS.d.cts +110 -0
- package/dist/signal-EotCj4hS.d.ts +110 -0
- package/dist/{ssr-BiPRdZ6n.d.cts → ssr-Bli9XRW5.d.cts} +5 -0
- package/dist/{ssr-BiPRdZ6n.d.ts → ssr-Bli9XRW5.d.ts} +5 -0
- package/dist/{ssr-Y7XOEPEN.js → ssr-XOTUASDO.js} +4 -5
- package/dist/ssr.cjs +176 -72
- package/dist/ssr.d.cts +9 -3
- package/dist/ssr.d.ts +9 -3
- package/dist/ssr.js +11 -12
- package/dist/{startup-BMpaiMhP.d.ts → startup-BLfSeL15.d.cts} +73 -22
- package/dist/{startup-BMpaiMhP.d.cts → startup-BLfSeL15.d.ts} +73 -22
- package/dist/{tagFactory-DVoDpHye.d.ts → tagFactory-DFstCLQV.d.cts} +2 -100
- package/dist/{tagFactory-DVoDpHye.d.cts → tagFactory-DkaNVUNV.d.ts} +2 -100
- package/dist/testing.cjs +2484 -2185
- package/dist/testing.d.cts +56 -5
- package/dist/testing.d.ts +56 -5
- package/dist/testing.js +580 -307
- package/dist/ui.cjs +707 -317
- package/dist/ui.d.cts +40 -7
- package/dist/ui.d.ts +40 -7
- package/dist/ui.js +151 -56
- package/dist/widgets.cjs +246 -278
- package/dist/widgets.js +9 -10
- package/package.json +1 -1
- package/dist/chunk-2WLZ6757.js +0 -149
- package/dist/chunk-CCSJMTRN.js +0 -15
- package/dist/chunk-QKRPLZ2V.js +0 -108
- package/dist/chunk-VUF4ALSW.js +0 -60
- package/dist/chunk-WWV3SJ3L.js +0 -131
- package/dist/dispose-46BOMMQJ.js +0 -19
- package/dist/plugin-D30wlGW5.d.cts +0 -71
- package/dist/plugin-D30wlGW5.d.ts +0 -71
package/dist/plugins.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { T as TrustedHTML } from './ssr-
|
|
2
|
-
export { P as PluginContext, a as PluginRegistry, S as SibuPlugin, c as createPlugin,
|
|
3
|
-
export { M as Migration, S as SemVer, V as VERSION, b as bundlerMetadata, c as checkCompatibility,
|
|
1
|
+
import { T as TrustedHTML } from './ssr-Bli9XRW5.cjs';
|
|
2
|
+
export { P as PluginContext, a as PluginInstallCancelledError, b as PluginRegistry, S as SibuPlugin, c as createPlugin, d as createPluginRegistry, i as inject, e as isPluginInstallCancelledError, p as plugin, r as resetPlugins, s as setDefaultPluginRegistry, t as triggerPluginError, f as triggerPluginMount, g as triggerPluginUnmount } from './plugin-DVgSnTfK.cjs';
|
|
3
|
+
export { L as LazyModule, M as Migration, a as MigrationStorageError, P as PackageExportTarget, S as SemVer, V as VERSION, b as bundlerMetadata, c as checkCompatibility, d as compareSemVer, e as createBootSequence, f as createBundle, g as createMigrationRunner, h as createModuleRegistry, i as createSSRCache, j as createTestHarness, k as deferNonCritical, l as env, m as healthCheck, n as lazyModule, p as packageInfo, o as parseSemVer, q as preloadCritical, r as prerenderRoutes, s as satisfies } from './startup-BLfSeL15.cjs';
|
|
4
4
|
|
|
5
5
|
type Translations = Record<string, string>;
|
|
6
6
|
type Params$1 = Record<string, string | number>;
|
package/dist/plugins.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { T as TrustedHTML } from './ssr-
|
|
2
|
-
export { P as PluginContext, a as PluginRegistry, S as SibuPlugin, c as createPlugin,
|
|
3
|
-
export { M as Migration, S as SemVer, V as VERSION, b as bundlerMetadata, c as checkCompatibility,
|
|
1
|
+
import { T as TrustedHTML } from './ssr-Bli9XRW5.js';
|
|
2
|
+
export { P as PluginContext, a as PluginInstallCancelledError, b as PluginRegistry, S as SibuPlugin, c as createPlugin, d as createPluginRegistry, i as inject, e as isPluginInstallCancelledError, p as plugin, r as resetPlugins, s as setDefaultPluginRegistry, t as triggerPluginError, f as triggerPluginMount, g as triggerPluginUnmount } from './plugin-DVgSnTfK.js';
|
|
3
|
+
export { L as LazyModule, M as Migration, a as MigrationStorageError, P as PackageExportTarget, S as SemVer, V as VERSION, b as bundlerMetadata, c as checkCompatibility, d as compareSemVer, e as createBootSequence, f as createBundle, g as createMigrationRunner, h as createModuleRegistry, i as createSSRCache, j as createTestHarness, k as deferNonCritical, l as env, m as healthCheck, n as lazyModule, p as packageInfo, o as parseSemVer, q as preloadCritical, r as prerenderRoutes, s as satisfies } from './startup-BLfSeL15.js';
|
|
4
4
|
|
|
5
5
|
type Translations = Record<string, string>;
|
|
6
6
|
type Params$1 = Record<string, string | number>;
|
package/dist/plugins.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
MigrationStorageError,
|
|
2
3
|
VERSION,
|
|
3
4
|
bundlerMetadata,
|
|
4
5
|
checkCompatibility,
|
|
@@ -18,62 +19,63 @@ import {
|
|
|
18
19
|
preloadCritical,
|
|
19
20
|
prerenderRoutes,
|
|
20
21
|
satisfies
|
|
21
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-5MT6SJ3P.js";
|
|
22
23
|
import {
|
|
23
24
|
isUnsafeKey
|
|
24
25
|
} from "./chunk-H3SRKIYX.js";
|
|
25
26
|
import {
|
|
27
|
+
PluginInstallCancelledError,
|
|
26
28
|
createPlugin,
|
|
27
29
|
createPluginRegistry,
|
|
28
30
|
inject,
|
|
31
|
+
isPluginInstallCancelledError,
|
|
29
32
|
plugin,
|
|
30
33
|
resetPlugins,
|
|
31
34
|
setDefaultPluginRegistry,
|
|
32
35
|
triggerPluginError,
|
|
33
36
|
triggerPluginMount,
|
|
34
37
|
triggerPluginUnmount
|
|
35
|
-
} from "./chunk-
|
|
38
|
+
} from "./chunk-J6FW5TV6.js";
|
|
36
39
|
import {
|
|
37
40
|
span
|
|
38
|
-
} from "./chunk-
|
|
41
|
+
} from "./chunk-JSXPZCET.js";
|
|
39
42
|
import {
|
|
40
43
|
escapeScriptJson,
|
|
41
44
|
renderToString,
|
|
42
45
|
serializeHeadEntry
|
|
43
|
-
} from "./chunk-
|
|
46
|
+
} from "./chunk-HURREPU2.js";
|
|
44
47
|
import {
|
|
45
48
|
resolveClassValue
|
|
46
|
-
} from "./chunk-
|
|
47
|
-
import "./chunk-
|
|
49
|
+
} from "./chunk-VVWPJ543.js";
|
|
50
|
+
import "./chunk-47M47FOM.js";
|
|
48
51
|
import {
|
|
49
52
|
isUrlAttribute,
|
|
50
53
|
sanitizeStyleAttribute,
|
|
51
54
|
sanitizeUrl,
|
|
52
55
|
stripControlChars
|
|
53
|
-
} from "./chunk-
|
|
56
|
+
} from "./chunk-2INLLLMZ.js";
|
|
54
57
|
import {
|
|
55
58
|
globalSingleton
|
|
56
59
|
} from "./chunk-7ZHH77QA.js";
|
|
57
60
|
import {
|
|
58
61
|
effect
|
|
59
|
-
} from "./chunk-
|
|
62
|
+
} from "./chunk-XC4MEKGA.js";
|
|
60
63
|
import {
|
|
61
64
|
getRequestStore
|
|
62
|
-
} from "./chunk-
|
|
63
|
-
import
|
|
64
|
-
dispose,
|
|
65
|
-
registerDisposer
|
|
66
|
-
} from "./chunk-QKRPLZ2V.js";
|
|
65
|
+
} from "./chunk-7XHATCIH.js";
|
|
66
|
+
import "./chunk-5HZXGZ6T.js";
|
|
67
67
|
import {
|
|
68
68
|
signal
|
|
69
|
-
} from "./chunk-
|
|
69
|
+
} from "./chunk-D33YTSX5.js";
|
|
70
70
|
import {
|
|
71
71
|
track
|
|
72
|
-
} from "./chunk-
|
|
72
|
+
} from "./chunk-5Q4R7HCL.js";
|
|
73
73
|
import {
|
|
74
74
|
devWarn,
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
dispose,
|
|
76
|
+
isDev,
|
|
77
|
+
registerDisposer
|
|
78
|
+
} from "./chunk-NYNYSPK7.js";
|
|
77
79
|
|
|
78
80
|
// src/plugins/i18n.ts
|
|
79
81
|
var _i18n = globalSingleton(/* @__PURE__ */ Symbol.for("sibujs.i18n.v1"), () => ({
|
|
@@ -131,6 +133,15 @@ function getAvailableLocales() {
|
|
|
131
133
|
}
|
|
132
134
|
|
|
133
135
|
// src/plugins/router.ts
|
|
136
|
+
function splitRouteUrl(url) {
|
|
137
|
+
const hashIndex = url.indexOf("#");
|
|
138
|
+
const beforeHash = hashIndex === -1 ? url : url.slice(0, hashIndex);
|
|
139
|
+
const hash = hashIndex === -1 ? "" : url.slice(hashIndex + 1);
|
|
140
|
+
const queryIndex = beforeHash.indexOf("?");
|
|
141
|
+
const path = queryIndex === -1 ? beforeHash : beforeHash.slice(0, queryIndex);
|
|
142
|
+
const query = queryIndex === -1 ? "" : beforeHash.slice(queryIndex + 1);
|
|
143
|
+
return { path, query, hash };
|
|
144
|
+
}
|
|
134
145
|
function classifyNavigationTarget(path) {
|
|
135
146
|
if (path === "") return "internal";
|
|
136
147
|
const normalized = stripControlChars(path).replace(/\\/g, "/");
|
|
@@ -849,8 +860,7 @@ var _SibuRouter = class _SibuRouter {
|
|
|
849
860
|
return (path || "/") + window.location.search + window.location.hash;
|
|
850
861
|
}
|
|
851
862
|
createRouteContext(fullPath) {
|
|
852
|
-
const
|
|
853
|
-
const [path, queryString = ""] = pathWithQuery.split("?");
|
|
863
|
+
const { path, query: queryString, hash } = splitRouteUrl(fullPath);
|
|
854
864
|
const query = Object.fromEntries(new URLSearchParams(queryString));
|
|
855
865
|
const match = this.matcher.match(path || "/");
|
|
856
866
|
const params = match?.params || {};
|
|
@@ -1597,8 +1607,7 @@ function RouterLink(props, children) {
|
|
|
1597
1607
|
const rawHref = _routerRef.current["resolvePath"](to);
|
|
1598
1608
|
const kind = classifyNavigationTarget(rawHref);
|
|
1599
1609
|
const href = kind === "unsafe" ? "#" : rawHref;
|
|
1600
|
-
const
|
|
1601
|
-
const [hrefPathRaw, hrefQueryRaw = ""] = hrefBeforeHash.split("?");
|
|
1610
|
+
const { path: hrefPathRaw, query: hrefQueryRaw, hash: hrefHash } = splitRouteUrl(href);
|
|
1602
1611
|
const targetPath = normalizePathname(hrefPathRaw);
|
|
1603
1612
|
const targetQuery = normalizeQuery(hrefQueryRaw);
|
|
1604
1613
|
const link = document.createElement("a");
|
|
@@ -2193,8 +2202,8 @@ function hydrateRouter(routes, options) {
|
|
|
2193
2202
|
const liveUrl = `${window.location.pathname}${window.location.search}${window.location.hash}`;
|
|
2194
2203
|
const resolved = resolveServerRoute(liveUrl, routes);
|
|
2195
2204
|
const bootstrapEpoch = __getNavigationEpoch();
|
|
2196
|
-
import("./ssr-
|
|
2197
|
-
const { replaceChildrenSafely } = await import("./dispose-
|
|
2205
|
+
import("./ssr-XOTUASDO.js").then(async ({ hydrate }) => {
|
|
2206
|
+
const { replaceChildrenSafely } = await import("./dispose-GEIG2KOF.js");
|
|
2198
2207
|
if (__getNavigationEpoch() !== bootstrapEpoch) return;
|
|
2199
2208
|
if (resolved.component) {
|
|
2200
2209
|
hydrate(resolved.component, container);
|
|
@@ -2228,7 +2237,9 @@ function escapeAttrLocal(str) {
|
|
|
2228
2237
|
}
|
|
2229
2238
|
export {
|
|
2230
2239
|
KeepAliveRoute,
|
|
2240
|
+
MigrationStorageError,
|
|
2231
2241
|
Outlet,
|
|
2242
|
+
PluginInstallCancelledError,
|
|
2232
2243
|
Route,
|
|
2233
2244
|
RouterLink,
|
|
2234
2245
|
SibuRouter,
|
|
@@ -2272,6 +2283,7 @@ export {
|
|
|
2272
2283
|
healthCheck,
|
|
2273
2284
|
hydrateRouter,
|
|
2274
2285
|
inject,
|
|
2286
|
+
isPluginInstallCancelledError,
|
|
2275
2287
|
lazy,
|
|
2276
2288
|
lazyModule,
|
|
2277
2289
|
navigate,
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
declare const __accessor: unique symbol;
|
|
2
|
+
/**
|
|
3
|
+
* A reactive signal getter returned by signal(), derived(), and similar primitives.
|
|
4
|
+
*
|
|
5
|
+
* Pass an Accessor directly into reactive prop positions — never call it there:
|
|
6
|
+
* ```ts
|
|
7
|
+
* const [count, setCount] = signal(0);
|
|
8
|
+
*
|
|
9
|
+
* div(count) // ✓ reactive — Accessor passed directly
|
|
10
|
+
* div(() => count()) // ✓ reactive — explicit arrow wrapper
|
|
11
|
+
* div(count()) // ✗ static — evaluated once, not reactive
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
type Accessor<T> = (() => T) & {
|
|
15
|
+
readonly [__accessor]?: never;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* An {@link Accessor} that owns a subscription, timer or listener and must be
|
|
19
|
+
* released when its consumer goes away. Returned by helpers such as `debounce`,
|
|
20
|
+
* `throttle` and `previous`.
|
|
21
|
+
*/
|
|
22
|
+
type DisposableAccessor<T> = Accessor<T> & {
|
|
23
|
+
/** Stop the underlying subscription and cancel pending work. The accessor keeps its last value. */
|
|
24
|
+
dispose(): void;
|
|
25
|
+
};
|
|
26
|
+
type SetState<T> = (next: T | ((prev: T) => T)) => void;
|
|
27
|
+
type StateTuple<T> = [Accessor<T>, SetState<T>];
|
|
28
|
+
/** Options for signal */
|
|
29
|
+
interface SignalOptions<T = unknown> {
|
|
30
|
+
/** Debug name for devtools inspection. Only used in development. */
|
|
31
|
+
name?: string;
|
|
32
|
+
/** Custom equality function. Defaults to Object.is(). */
|
|
33
|
+
equals?: (prev: T, next: T) => boolean;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* signal creates a reactive signal that holds a value of type T.
|
|
37
|
+
* Returns a tuple: [getter, setter].
|
|
38
|
+
*
|
|
39
|
+
* @param initial Initial value
|
|
40
|
+
* @param options Optional config: `{ name: "count" }` for devtools labeling
|
|
41
|
+
* @returns A `[getter, setter]` tuple. Calling the getter inside a reactive
|
|
42
|
+
* context subscribes to the signal; the setter accepts a value or an updater.
|
|
43
|
+
*/
|
|
44
|
+
declare function signal<T>(initial: T, options?: SignalOptions<T>): StateTuple<T>;
|
|
45
|
+
/**
|
|
46
|
+
* A valueless reactive token standing in for state SibuJS does not own.
|
|
47
|
+
*
|
|
48
|
+
* See {@link external}.
|
|
49
|
+
*/
|
|
50
|
+
interface ExternalSource {
|
|
51
|
+
/**
|
|
52
|
+
* Declare, from inside a reactive computation, that it reads the external
|
|
53
|
+
* state this source represents. Call it in the same places you would read a
|
|
54
|
+
* signal — the top of a binding getter, a `derived()` body, an `effect()`.
|
|
55
|
+
*
|
|
56
|
+
* Outside a tracking context it is a no-op, exactly like reading a signal.
|
|
57
|
+
*/
|
|
58
|
+
track(): void;
|
|
59
|
+
/**
|
|
60
|
+
* Declare that the external state changed. Every consumer that called
|
|
61
|
+
* {@link ExternalSource.track} is invalidated.
|
|
62
|
+
*
|
|
63
|
+
* Participates in `batch()` like any signal write: inside a batch, consumers
|
|
64
|
+
* are notified once when the outermost batch flushes.
|
|
65
|
+
*/
|
|
66
|
+
invalidate(): void;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Create a reactive source for state that lives outside SibuJS — a domain
|
|
70
|
+
* engine, a media element, a canvas scene, an editor document, a cache a
|
|
71
|
+
* socket writes into.
|
|
72
|
+
*
|
|
73
|
+
* The pattern is two lines: `track()` where you read, `invalidate()` after you
|
|
74
|
+
* mutate.
|
|
75
|
+
*
|
|
76
|
+
* ```ts
|
|
77
|
+
* import { Chess } from "chess.js";
|
|
78
|
+
* import { external } from "sibujs";
|
|
79
|
+
*
|
|
80
|
+
* const game = new Chess(); // owns the rules and the mutable state
|
|
81
|
+
* const moved = external(); // owns "something changed"
|
|
82
|
+
*
|
|
83
|
+
* ctx.text("@status", () => {
|
|
84
|
+
* moved.track(); // this binding reads the engine
|
|
85
|
+
* return game.isCheckmate() ? "Checkmate" : `${game.turn()} to move`;
|
|
86
|
+
* });
|
|
87
|
+
*
|
|
88
|
+
* game.move({ from: "e2", to: "e4" });
|
|
89
|
+
* moved.invalidate(); // every consumer above re-reads
|
|
90
|
+
* ```
|
|
91
|
+
*
|
|
92
|
+
* **One source is one invalidation domain.** Every consumer of a source
|
|
93
|
+
* re-runs on every `invalidate()`, so the granularity of your updates is
|
|
94
|
+
* exactly the granularity of your sources: one for a whole engine is the
|
|
95
|
+
* cheapest to write, several (`board`, `clock`, `history`) let an update touch
|
|
96
|
+
* only what it affects. See `docs/architecture/external-state.md` for the
|
|
97
|
+
* trade-offs and when subdividing is worth it.
|
|
98
|
+
*
|
|
99
|
+
* Ownership, disposal and error routing are the consumer's, not the source's:
|
|
100
|
+
* a disposed binding or effect is never invalidated, and a consumer that
|
|
101
|
+
* throws is reported through the normal runtime error pipeline with its own
|
|
102
|
+
* phase and node.
|
|
103
|
+
*
|
|
104
|
+
* @param options `name` labels the source in devtools (development only).
|
|
105
|
+
*/
|
|
106
|
+
declare function external(options?: {
|
|
107
|
+
name?: string;
|
|
108
|
+
}): ExternalSource;
|
|
109
|
+
|
|
110
|
+
export { type Accessor as A, type DisposableAccessor as D, type ExternalSource as E, type SignalOptions as S, external as e, signal as s };
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
declare const __accessor: unique symbol;
|
|
2
|
+
/**
|
|
3
|
+
* A reactive signal getter returned by signal(), derived(), and similar primitives.
|
|
4
|
+
*
|
|
5
|
+
* Pass an Accessor directly into reactive prop positions — never call it there:
|
|
6
|
+
* ```ts
|
|
7
|
+
* const [count, setCount] = signal(0);
|
|
8
|
+
*
|
|
9
|
+
* div(count) // ✓ reactive — Accessor passed directly
|
|
10
|
+
* div(() => count()) // ✓ reactive — explicit arrow wrapper
|
|
11
|
+
* div(count()) // ✗ static — evaluated once, not reactive
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
type Accessor<T> = (() => T) & {
|
|
15
|
+
readonly [__accessor]?: never;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* An {@link Accessor} that owns a subscription, timer or listener and must be
|
|
19
|
+
* released when its consumer goes away. Returned by helpers such as `debounce`,
|
|
20
|
+
* `throttle` and `previous`.
|
|
21
|
+
*/
|
|
22
|
+
type DisposableAccessor<T> = Accessor<T> & {
|
|
23
|
+
/** Stop the underlying subscription and cancel pending work. The accessor keeps its last value. */
|
|
24
|
+
dispose(): void;
|
|
25
|
+
};
|
|
26
|
+
type SetState<T> = (next: T | ((prev: T) => T)) => void;
|
|
27
|
+
type StateTuple<T> = [Accessor<T>, SetState<T>];
|
|
28
|
+
/** Options for signal */
|
|
29
|
+
interface SignalOptions<T = unknown> {
|
|
30
|
+
/** Debug name for devtools inspection. Only used in development. */
|
|
31
|
+
name?: string;
|
|
32
|
+
/** Custom equality function. Defaults to Object.is(). */
|
|
33
|
+
equals?: (prev: T, next: T) => boolean;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* signal creates a reactive signal that holds a value of type T.
|
|
37
|
+
* Returns a tuple: [getter, setter].
|
|
38
|
+
*
|
|
39
|
+
* @param initial Initial value
|
|
40
|
+
* @param options Optional config: `{ name: "count" }` for devtools labeling
|
|
41
|
+
* @returns A `[getter, setter]` tuple. Calling the getter inside a reactive
|
|
42
|
+
* context subscribes to the signal; the setter accepts a value or an updater.
|
|
43
|
+
*/
|
|
44
|
+
declare function signal<T>(initial: T, options?: SignalOptions<T>): StateTuple<T>;
|
|
45
|
+
/**
|
|
46
|
+
* A valueless reactive token standing in for state SibuJS does not own.
|
|
47
|
+
*
|
|
48
|
+
* See {@link external}.
|
|
49
|
+
*/
|
|
50
|
+
interface ExternalSource {
|
|
51
|
+
/**
|
|
52
|
+
* Declare, from inside a reactive computation, that it reads the external
|
|
53
|
+
* state this source represents. Call it in the same places you would read a
|
|
54
|
+
* signal — the top of a binding getter, a `derived()` body, an `effect()`.
|
|
55
|
+
*
|
|
56
|
+
* Outside a tracking context it is a no-op, exactly like reading a signal.
|
|
57
|
+
*/
|
|
58
|
+
track(): void;
|
|
59
|
+
/**
|
|
60
|
+
* Declare that the external state changed. Every consumer that called
|
|
61
|
+
* {@link ExternalSource.track} is invalidated.
|
|
62
|
+
*
|
|
63
|
+
* Participates in `batch()` like any signal write: inside a batch, consumers
|
|
64
|
+
* are notified once when the outermost batch flushes.
|
|
65
|
+
*/
|
|
66
|
+
invalidate(): void;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Create a reactive source for state that lives outside SibuJS — a domain
|
|
70
|
+
* engine, a media element, a canvas scene, an editor document, a cache a
|
|
71
|
+
* socket writes into.
|
|
72
|
+
*
|
|
73
|
+
* The pattern is two lines: `track()` where you read, `invalidate()` after you
|
|
74
|
+
* mutate.
|
|
75
|
+
*
|
|
76
|
+
* ```ts
|
|
77
|
+
* import { Chess } from "chess.js";
|
|
78
|
+
* import { external } from "sibujs";
|
|
79
|
+
*
|
|
80
|
+
* const game = new Chess(); // owns the rules and the mutable state
|
|
81
|
+
* const moved = external(); // owns "something changed"
|
|
82
|
+
*
|
|
83
|
+
* ctx.text("@status", () => {
|
|
84
|
+
* moved.track(); // this binding reads the engine
|
|
85
|
+
* return game.isCheckmate() ? "Checkmate" : `${game.turn()} to move`;
|
|
86
|
+
* });
|
|
87
|
+
*
|
|
88
|
+
* game.move({ from: "e2", to: "e4" });
|
|
89
|
+
* moved.invalidate(); // every consumer above re-reads
|
|
90
|
+
* ```
|
|
91
|
+
*
|
|
92
|
+
* **One source is one invalidation domain.** Every consumer of a source
|
|
93
|
+
* re-runs on every `invalidate()`, so the granularity of your updates is
|
|
94
|
+
* exactly the granularity of your sources: one for a whole engine is the
|
|
95
|
+
* cheapest to write, several (`board`, `clock`, `history`) let an update touch
|
|
96
|
+
* only what it affects. See `docs/architecture/external-state.md` for the
|
|
97
|
+
* trade-offs and when subdividing is worth it.
|
|
98
|
+
*
|
|
99
|
+
* Ownership, disposal and error routing are the consumer's, not the source's:
|
|
100
|
+
* a disposed binding or effect is never invalidated, and a consumer that
|
|
101
|
+
* throws is reported through the normal runtime error pipeline with its own
|
|
102
|
+
* phase and node.
|
|
103
|
+
*
|
|
104
|
+
* @param options `name` labels the source in devtools (development only).
|
|
105
|
+
*/
|
|
106
|
+
declare function external(options?: {
|
|
107
|
+
name?: string;
|
|
108
|
+
}): ExternalSource;
|
|
109
|
+
|
|
110
|
+
export { type Accessor as A, type DisposableAccessor as D, type ExternalSource as E, type SignalOptions as S, external as e, signal as s };
|
|
@@ -166,6 +166,11 @@ declare function resetSSRState(): void;
|
|
|
166
166
|
*
|
|
167
167
|
* The returned element contains the fallback UI with a `data-sibu-suspense-id`
|
|
168
168
|
* marker. The promise resolves to `{ id, html }` once async content is ready.
|
|
169
|
+
*
|
|
170
|
+
* The promise never rejects. Any failure to produce the content HTML — the
|
|
171
|
+
* content factory throwing synchronously, its promise rejecting, the timeout,
|
|
172
|
+
* or rendering the resolved element throwing — resolves it with the fallback
|
|
173
|
+
* HTML, so the stream still produces a deterministic swap payload.
|
|
169
174
|
*/
|
|
170
175
|
declare function ssrSuspense(props: {
|
|
171
176
|
fallback: () => HTMLElement;
|
|
@@ -166,6 +166,11 @@ declare function resetSSRState(): void;
|
|
|
166
166
|
*
|
|
167
167
|
* The returned element contains the fallback UI with a `data-sibu-suspense-id`
|
|
168
168
|
* marker. The promise resolves to `{ id, html }` once async content is ready.
|
|
169
|
+
*
|
|
170
|
+
* The promise never rejects. Any failure to produce the content HTML — the
|
|
171
|
+
* content factory throwing synchronously, its promise rejecting, the timeout,
|
|
172
|
+
* or rendering the resolved element throwing — resolves it with the fallback
|
|
173
|
+
* HTML, so the stream still produces a deterministic swap payload.
|
|
169
174
|
*/
|
|
170
175
|
declare function ssrSuspense(props: {
|
|
171
176
|
fallback: () => HTMLElement;
|
|
@@ -17,11 +17,10 @@ import {
|
|
|
17
17
|
ssrSuspense,
|
|
18
18
|
suspenseSwapScript,
|
|
19
19
|
trustHTML
|
|
20
|
-
} from "./chunk-
|
|
21
|
-
import "./chunk-
|
|
22
|
-
import "./chunk-
|
|
23
|
-
import "./chunk-
|
|
24
|
-
import "./chunk-2WLZ6757.js";
|
|
20
|
+
} from "./chunk-HURREPU2.js";
|
|
21
|
+
import "./chunk-2INLLLMZ.js";
|
|
22
|
+
import "./chunk-7XHATCIH.js";
|
|
23
|
+
import "./chunk-NYNYSPK7.js";
|
|
25
24
|
export {
|
|
26
25
|
collectStream,
|
|
27
26
|
deserializeState,
|