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.
Files changed (109) hide show
  1. package/dist/browser.cjs +309 -129
  2. package/dist/browser.d.cts +46 -14
  3. package/dist/browser.d.ts +46 -14
  4. package/dist/browser.js +8 -6
  5. package/dist/build.cjs +184 -72
  6. package/dist/build.js +15 -16
  7. package/dist/cdn.dev.global.js +12 -12
  8. package/dist/cdn.full.dev.global.js +11 -11
  9. package/dist/cdn.full.global.js +10 -10
  10. package/dist/cdn.global.js +12 -12
  11. package/dist/{chunk-IXKSNWV5.js → chunk-2INLLLMZ.js} +1 -1
  12. package/dist/chunk-3ISI6ACU.js +44 -0
  13. package/dist/{chunk-ONOHFDLG.js → chunk-47M47FOM.js} +3 -3
  14. package/dist/chunk-5HZXGZ6T.js +24 -0
  15. package/dist/{chunk-KKLW7YWL.js → chunk-5MT6SJ3P.js} +275 -144
  16. package/dist/{chunk-UGRX3S57.js → chunk-5Q4R7HCL.js} +12 -3
  17. package/dist/{chunk-S373NSMK.js → chunk-7GQCWFOE.js} +150 -59
  18. package/dist/{chunk-FTIR4QW2.js → chunk-7NCARGJW.js} +6 -8
  19. package/dist/{chunk-5DXA2J44.js → chunk-7XHATCIH.js} +5 -2
  20. package/dist/{chunk-VZKNK2V7.js → chunk-AIF3Z2T7.js} +296 -38
  21. package/dist/{chunk-4PMLNECI.js → chunk-BAAG6ZTI.js} +98 -29
  22. package/dist/{chunk-XZZOBQAY.js → chunk-D33YTSX5.js} +2 -2
  23. package/dist/{chunk-TBYTO6BS.js → chunk-DKGBBKOF.js} +136 -80
  24. package/dist/{chunk-NIOYEGBQ.js → chunk-HURREPU2.js} +27 -13
  25. package/dist/{chunk-GW3SCCZG.js → chunk-HYXDKS4N.js} +153 -110
  26. package/dist/chunk-J6FW5TV6.js +233 -0
  27. package/dist/{chunk-PCT43HW3.js → chunk-JSXPZCET.js} +1 -1
  28. package/dist/chunk-NYNYSPK7.js +318 -0
  29. package/dist/{chunk-RJE2BNI4.js → chunk-ORMZXBKQ.js} +108 -45
  30. package/dist/{chunk-OMJJM3KM.js → chunk-OXUY2A6L.js} +287 -130
  31. package/dist/{chunk-3JZ4L5TJ.js → chunk-PK6FK2G2.js} +181 -66
  32. package/dist/{chunk-RBTPLM32.js → chunk-QE4TTDU3.js} +2 -2
  33. package/dist/{chunk-2DCGACUU.js → chunk-SXXVZMKZ.js} +251 -66
  34. package/dist/{chunk-R25EFXXC.js → chunk-TUCPL2HB.js} +3 -3
  35. package/dist/{chunk-7LN645I6.js → chunk-UZQ6ALFS.js} +3 -3
  36. package/dist/{chunk-KEISJXBU.js → chunk-VVWPJ543.js} +6 -8
  37. package/dist/{chunk-RIXRAYIU.js → chunk-XC4MEKGA.js} +3 -3
  38. package/dist/{chunk-B3WHI2QA.js → chunk-XRRZKZYX.js} +55 -31
  39. package/dist/{contracts-DBdg9J_a.d.cts → contracts-DRIuclVT.d.cts} +10 -2
  40. package/dist/{contracts-DBdg9J_a.d.ts → contracts-DRIuclVT.d.ts} +10 -2
  41. package/dist/{customElement-OB9CIsc5.d.cts → customElement-MmInOW1U.d.cts} +21 -0
  42. package/dist/{customElement-OB9CIsc5.d.ts → customElement-MmInOW1U.d.ts} +21 -0
  43. package/dist/data.cjs +213 -117
  44. package/dist/data.d.cts +47 -9
  45. package/dist/data.d.ts +47 -9
  46. package/dist/data.js +12 -9
  47. package/dist/devtools.cjs +81 -57
  48. package/dist/devtools.js +7 -8
  49. package/dist/dispose-GEIG2KOF.js +28 -0
  50. package/dist/ecosystem.cjs +309 -104
  51. package/dist/ecosystem.d.cts +19 -3
  52. package/dist/ecosystem.d.ts +19 -3
  53. package/dist/ecosystem.js +12 -12
  54. package/dist/extras.cjs +2133 -863
  55. package/dist/extras.d.cts +10 -9
  56. package/dist/extras.d.ts +10 -9
  57. package/dist/extras.js +39 -28
  58. package/dist/index.cjs +184 -72
  59. package/dist/index.d.cts +22 -5
  60. package/dist/index.d.ts +22 -5
  61. package/dist/index.js +24 -27
  62. package/dist/motion.cjs +107 -41
  63. package/dist/motion.js +5 -5
  64. package/dist/patterns.cjs +317 -39
  65. package/dist/patterns.d.cts +27 -9
  66. package/dist/patterns.d.ts +27 -9
  67. package/dist/patterns.js +8 -8
  68. package/dist/performance.cjs +308 -216
  69. package/dist/performance.d.cts +2 -2
  70. package/dist/performance.d.ts +2 -2
  71. package/dist/performance.js +8 -9
  72. package/dist/plugin-DVgSnTfK.d.cts +112 -0
  73. package/dist/plugin-DVgSnTfK.d.ts +112 -0
  74. package/dist/plugins.cjs +549 -202
  75. package/dist/plugins.d.cts +3 -3
  76. package/dist/plugins.d.ts +3 -3
  77. package/dist/plugins.js +35 -23
  78. package/dist/signal-EotCj4hS.d.cts +110 -0
  79. package/dist/signal-EotCj4hS.d.ts +110 -0
  80. package/dist/{ssr-BiPRdZ6n.d.cts → ssr-Bli9XRW5.d.cts} +5 -0
  81. package/dist/{ssr-BiPRdZ6n.d.ts → ssr-Bli9XRW5.d.ts} +5 -0
  82. package/dist/{ssr-Y7XOEPEN.js → ssr-XOTUASDO.js} +4 -5
  83. package/dist/ssr.cjs +176 -72
  84. package/dist/ssr.d.cts +9 -3
  85. package/dist/ssr.d.ts +9 -3
  86. package/dist/ssr.js +11 -12
  87. package/dist/{startup-BMpaiMhP.d.ts → startup-BLfSeL15.d.cts} +73 -22
  88. package/dist/{startup-BMpaiMhP.d.cts → startup-BLfSeL15.d.ts} +73 -22
  89. package/dist/{tagFactory-DVoDpHye.d.ts → tagFactory-DFstCLQV.d.cts} +2 -100
  90. package/dist/{tagFactory-DVoDpHye.d.cts → tagFactory-DkaNVUNV.d.ts} +2 -100
  91. package/dist/testing.cjs +2484 -2185
  92. package/dist/testing.d.cts +56 -5
  93. package/dist/testing.d.ts +56 -5
  94. package/dist/testing.js +580 -307
  95. package/dist/ui.cjs +707 -317
  96. package/dist/ui.d.cts +40 -7
  97. package/dist/ui.d.ts +40 -7
  98. package/dist/ui.js +151 -56
  99. package/dist/widgets.cjs +246 -278
  100. package/dist/widgets.js +9 -10
  101. package/package.json +1 -1
  102. package/dist/chunk-2WLZ6757.js +0 -149
  103. package/dist/chunk-CCSJMTRN.js +0 -15
  104. package/dist/chunk-QKRPLZ2V.js +0 -108
  105. package/dist/chunk-VUF4ALSW.js +0 -60
  106. package/dist/chunk-WWV3SJ3L.js +0 -131
  107. package/dist/dispose-46BOMMQJ.js +0 -19
  108. package/dist/plugin-D30wlGW5.d.cts +0 -71
  109. package/dist/plugin-D30wlGW5.d.ts +0 -71
@@ -26,32 +26,45 @@ declare function createModuleRegistry(): {
26
26
  * Returns an object with only the requested exports.
27
27
  */
28
28
  declare function createBundle<T extends object>(modules: Record<string, () => unknown>): T;
29
+ /** Handle returned by {@link lazyModule}. */
30
+ interface LazyModule<T> {
31
+ /** Whether a load has completed successfully. Read-only. */
32
+ readonly loaded: boolean;
33
+ /** Load the module (once) and resolve to it. Concurrent calls share one load. */
34
+ get(): Promise<T>;
35
+ }
29
36
  /**
30
37
  * Lazy module loader that only imports a module when first accessed.
31
38
  * Uses ES module dynamic import under the hood.
32
39
  * Caches the result after the first successful load.
40
+ *
41
+ * Concurrent `get()` calls made before the first load settles share that one
42
+ * load. A failed load is not cached: the next `get()` retries.
33
43
  */
34
- declare function lazyModule<T>(loader: () => Promise<T>): {
35
- get: () => Promise<T>;
36
- loaded: boolean;
44
+ declare function lazyModule<T>(loader: () => Promise<T>): LazyModule<T>;
45
+ /** One `exports` entry: a module entry point, or a prebuilt CDN script. */
46
+ type PackageExportTarget = {
47
+ types: string;
48
+ import: string;
49
+ require: string;
50
+ } | {
51
+ default: string;
37
52
  };
38
53
  /**
39
54
  * Package metadata for distribution tooling.
40
- * Provides entry point information and can generate Node.js subpath exports maps.
55
+ * Provides entry point information and generates the Node.js subpath exports
56
+ * map that the published package actually uses.
41
57
  */
42
58
  declare const packageInfo: {
43
59
  name: string;
44
60
  version: string;
45
61
  entryPoints: Record<string, string>;
46
62
  /**
47
- * Generate a package.json `exports` map for Node.js subpath exports.
48
- * Maps each entry point to its import, require, and types paths.
63
+ * Generate the package.json `exports` map. Module entries resolve to the
64
+ * `.js` (ESM), `.cjs` and `.d.ts` files tsup emits into `dist/`; CDN entries
65
+ * resolve to their prebuilt global script.
49
66
  */
50
- generateExportsMap(): Record<string, {
51
- import: string;
52
- require: string;
53
- types: string;
54
- }>;
67
+ generateExportsMap(): Record<string, PackageExportTarget>;
55
68
  };
56
69
 
57
70
  /**
@@ -127,16 +140,14 @@ declare const env: {
127
140
  isTest: boolean;
128
141
  };
129
142
 
130
- /**
131
- * Versioning and migration utilities for SibuJS applications.
132
- * Provides semantic version management, migration tooling, and compatibility checks.
133
- */
134
143
  /** Semantic version representation */
135
144
  interface SemVer {
136
145
  major: number;
137
146
  minor: number;
138
147
  patch: number;
139
148
  prerelease?: string;
149
+ /** Build metadata (after `+`). Ignored when comparing versions. */
150
+ build?: string;
140
151
  }
141
152
  /** Migration definition */
142
153
  interface Migration {
@@ -146,11 +157,19 @@ interface Migration {
146
157
  down?: () => void | Promise<void>;
147
158
  }
148
159
  /**
149
- * Framework version constant.
160
+ * Framework version: the published package version, stamped at build time.
161
+ * Only raw, unbundled source reports "dev". (It was hard-coded to "1.0.0", so
162
+ * compatibility checks compared against a version the package never had.)
150
163
  */
151
- declare const VERSION = "1.0.0";
164
+ declare const VERSION: string;
152
165
  /**
153
166
  * Parse a semantic version string into components.
167
+ *
168
+ * Accepts full SemVer 2.0.0 (`1.2.3`, `1.2.3-beta.1`, `1.2.3+build.5`), an
169
+ * optional leading `v`, surrounding whitespace, and the abbreviated `1` and
170
+ * `1.2` forms. Anything else — trailing characters, extra components, empty or
171
+ * illegal identifiers, numeric leading zeros — throws. (`parseInt` used to accept
172
+ * numeric prefixes such as `1.2.3garbage` and ignore extra components.)
154
173
  */
155
174
  declare function parseSemVer(version: string): SemVer;
156
175
  /**
@@ -162,22 +181,46 @@ declare function compareSemVer(a: string | SemVer, b: string | SemVer): -1 | 0 |
162
181
  * Check if a version satisfies a semver range (supports ^, ~, >=, <=, =).
163
182
  */
164
183
  declare function satisfies(version: string, range: string): boolean;
184
+ /**
185
+ * A migration step succeeded but recording its version in storage failed.
186
+ *
187
+ * Reported separately from a failing `up()` / `down()` because the migration's
188
+ * own work DID happen: storage is now behind reality and needs attention, but
189
+ * the step itself must not be retried as if it had failed.
190
+ */
191
+ declare class MigrationStorageError extends Error {
192
+ /** The migration whose checkpoint could not be written. */
193
+ readonly version: string;
194
+ constructor(version: string, cause: unknown);
195
+ }
165
196
  /**
166
197
  * Create a migration runner for managing schema/state version upgrades.
198
+ *
199
+ * `migrate()` and `rollback()` are serialized across ALL runners in this realm
200
+ * that use the same storage object and storage key; runners with a different
201
+ * key (or storage) run independently. Coordination does not extend across
202
+ * tabs or workers.
167
203
  */
168
204
  declare function createMigrationRunner(config: {
169
205
  /** Current version of the app/data */
170
206
  currentVersion: string;
171
207
  /** Storage key for persisting applied migration version */
172
208
  storageKey?: string;
209
+ /** Storage holding the applied version (default: `localStorage`) */
210
+ storage?: Storage;
173
211
  /** Available migrations, sorted by version */
174
212
  migrations: Migration[];
175
213
  }): {
176
214
  /** Get the last applied migration version from storage */
177
- getAppliedVersion(): string | null;
215
+ getAppliedVersion: () => string | null;
178
216
  /** Get pending migrations that haven't been applied */
179
- getPending(): Migration[];
180
- /** Run all pending migrations in order */
217
+ getPending: () => Migration[];
218
+ /**
219
+ * Run all pending migrations in order. Concurrent calls (and calls racing
220
+ * `rollback()`) run one after another, each recomputing what is pending —
221
+ * on this runner and on every other runner in this realm sharing its
222
+ * storage and storage key.
223
+ */
181
224
  migrate(): Promise<{
182
225
  applied: string[];
183
226
  errors: Array<{
@@ -185,7 +228,15 @@ declare function createMigrationRunner(config: {
185
228
  error: Error;
186
229
  }>;
187
230
  }>;
188
- /** Rollback to a specific version */
231
+ /**
232
+ * Rollback to a specific version.
233
+ *
234
+ * The applied version is checkpointed after EVERY successful `down()`, so a
235
+ * rollback that fails part-way leaves storage describing what is actually
236
+ * still applied, and a retry does not repeat completed `down()` steps.
237
+ * Throws the failing `down()`'s error, a missing-`down()` error, or a
238
+ * {@link MigrationStorageError} if a checkpoint cannot be written.
239
+ */
189
240
  rollback(targetVersion: string): Promise<{
190
241
  rolledBack: string[];
191
242
  }>;
@@ -288,4 +339,4 @@ declare function createBootSequence(): {
288
339
  }>;
289
340
  };
290
341
 
291
- export { type Migration as M, type SemVer as S, VERSION as V, compareSemVer as a, bundlerMetadata as b, checkCompatibility as c, createBootSequence as d, createBundle as e, createMigrationRunner as f, createModuleRegistry as g, createSSRCache as h, createTestHarness as i, deferNonCritical as j, env as k, healthCheck as l, lazyModule as m, parseSemVer as n, preloadCritical as o, packageInfo as p, prerenderRoutes as q, satisfies as s };
342
+ export { type LazyModule as L, type Migration as M, type PackageExportTarget as P, type SemVer as S, VERSION as V, MigrationStorageError as a, bundlerMetadata as b, checkCompatibility as c, compareSemVer as d, createBootSequence as e, createBundle as f, createMigrationRunner as g, createModuleRegistry as h, createSSRCache as i, createTestHarness as j, deferNonCritical as k, env as l, healthCheck as m, lazyModule as n, parseSemVer as o, packageInfo as p, preloadCritical as q, prerenderRoutes as r, satisfies as s };
@@ -26,32 +26,45 @@ declare function createModuleRegistry(): {
26
26
  * Returns an object with only the requested exports.
27
27
  */
28
28
  declare function createBundle<T extends object>(modules: Record<string, () => unknown>): T;
29
+ /** Handle returned by {@link lazyModule}. */
30
+ interface LazyModule<T> {
31
+ /** Whether a load has completed successfully. Read-only. */
32
+ readonly loaded: boolean;
33
+ /** Load the module (once) and resolve to it. Concurrent calls share one load. */
34
+ get(): Promise<T>;
35
+ }
29
36
  /**
30
37
  * Lazy module loader that only imports a module when first accessed.
31
38
  * Uses ES module dynamic import under the hood.
32
39
  * Caches the result after the first successful load.
40
+ *
41
+ * Concurrent `get()` calls made before the first load settles share that one
42
+ * load. A failed load is not cached: the next `get()` retries.
33
43
  */
34
- declare function lazyModule<T>(loader: () => Promise<T>): {
35
- get: () => Promise<T>;
36
- loaded: boolean;
44
+ declare function lazyModule<T>(loader: () => Promise<T>): LazyModule<T>;
45
+ /** One `exports` entry: a module entry point, or a prebuilt CDN script. */
46
+ type PackageExportTarget = {
47
+ types: string;
48
+ import: string;
49
+ require: string;
50
+ } | {
51
+ default: string;
37
52
  };
38
53
  /**
39
54
  * Package metadata for distribution tooling.
40
- * Provides entry point information and can generate Node.js subpath exports maps.
55
+ * Provides entry point information and generates the Node.js subpath exports
56
+ * map that the published package actually uses.
41
57
  */
42
58
  declare const packageInfo: {
43
59
  name: string;
44
60
  version: string;
45
61
  entryPoints: Record<string, string>;
46
62
  /**
47
- * Generate a package.json `exports` map for Node.js subpath exports.
48
- * Maps each entry point to its import, require, and types paths.
63
+ * Generate the package.json `exports` map. Module entries resolve to the
64
+ * `.js` (ESM), `.cjs` and `.d.ts` files tsup emits into `dist/`; CDN entries
65
+ * resolve to their prebuilt global script.
49
66
  */
50
- generateExportsMap(): Record<string, {
51
- import: string;
52
- require: string;
53
- types: string;
54
- }>;
67
+ generateExportsMap(): Record<string, PackageExportTarget>;
55
68
  };
56
69
 
57
70
  /**
@@ -127,16 +140,14 @@ declare const env: {
127
140
  isTest: boolean;
128
141
  };
129
142
 
130
- /**
131
- * Versioning and migration utilities for SibuJS applications.
132
- * Provides semantic version management, migration tooling, and compatibility checks.
133
- */
134
143
  /** Semantic version representation */
135
144
  interface SemVer {
136
145
  major: number;
137
146
  minor: number;
138
147
  patch: number;
139
148
  prerelease?: string;
149
+ /** Build metadata (after `+`). Ignored when comparing versions. */
150
+ build?: string;
140
151
  }
141
152
  /** Migration definition */
142
153
  interface Migration {
@@ -146,11 +157,19 @@ interface Migration {
146
157
  down?: () => void | Promise<void>;
147
158
  }
148
159
  /**
149
- * Framework version constant.
160
+ * Framework version: the published package version, stamped at build time.
161
+ * Only raw, unbundled source reports "dev". (It was hard-coded to "1.0.0", so
162
+ * compatibility checks compared against a version the package never had.)
150
163
  */
151
- declare const VERSION = "1.0.0";
164
+ declare const VERSION: string;
152
165
  /**
153
166
  * Parse a semantic version string into components.
167
+ *
168
+ * Accepts full SemVer 2.0.0 (`1.2.3`, `1.2.3-beta.1`, `1.2.3+build.5`), an
169
+ * optional leading `v`, surrounding whitespace, and the abbreviated `1` and
170
+ * `1.2` forms. Anything else — trailing characters, extra components, empty or
171
+ * illegal identifiers, numeric leading zeros — throws. (`parseInt` used to accept
172
+ * numeric prefixes such as `1.2.3garbage` and ignore extra components.)
154
173
  */
155
174
  declare function parseSemVer(version: string): SemVer;
156
175
  /**
@@ -162,22 +181,46 @@ declare function compareSemVer(a: string | SemVer, b: string | SemVer): -1 | 0 |
162
181
  * Check if a version satisfies a semver range (supports ^, ~, >=, <=, =).
163
182
  */
164
183
  declare function satisfies(version: string, range: string): boolean;
184
+ /**
185
+ * A migration step succeeded but recording its version in storage failed.
186
+ *
187
+ * Reported separately from a failing `up()` / `down()` because the migration's
188
+ * own work DID happen: storage is now behind reality and needs attention, but
189
+ * the step itself must not be retried as if it had failed.
190
+ */
191
+ declare class MigrationStorageError extends Error {
192
+ /** The migration whose checkpoint could not be written. */
193
+ readonly version: string;
194
+ constructor(version: string, cause: unknown);
195
+ }
165
196
  /**
166
197
  * Create a migration runner for managing schema/state version upgrades.
198
+ *
199
+ * `migrate()` and `rollback()` are serialized across ALL runners in this realm
200
+ * that use the same storage object and storage key; runners with a different
201
+ * key (or storage) run independently. Coordination does not extend across
202
+ * tabs or workers.
167
203
  */
168
204
  declare function createMigrationRunner(config: {
169
205
  /** Current version of the app/data */
170
206
  currentVersion: string;
171
207
  /** Storage key for persisting applied migration version */
172
208
  storageKey?: string;
209
+ /** Storage holding the applied version (default: `localStorage`) */
210
+ storage?: Storage;
173
211
  /** Available migrations, sorted by version */
174
212
  migrations: Migration[];
175
213
  }): {
176
214
  /** Get the last applied migration version from storage */
177
- getAppliedVersion(): string | null;
215
+ getAppliedVersion: () => string | null;
178
216
  /** Get pending migrations that haven't been applied */
179
- getPending(): Migration[];
180
- /** Run all pending migrations in order */
217
+ getPending: () => Migration[];
218
+ /**
219
+ * Run all pending migrations in order. Concurrent calls (and calls racing
220
+ * `rollback()`) run one after another, each recomputing what is pending —
221
+ * on this runner and on every other runner in this realm sharing its
222
+ * storage and storage key.
223
+ */
181
224
  migrate(): Promise<{
182
225
  applied: string[];
183
226
  errors: Array<{
@@ -185,7 +228,15 @@ declare function createMigrationRunner(config: {
185
228
  error: Error;
186
229
  }>;
187
230
  }>;
188
- /** Rollback to a specific version */
231
+ /**
232
+ * Rollback to a specific version.
233
+ *
234
+ * The applied version is checkpointed after EVERY successful `down()`, so a
235
+ * rollback that fails part-way leaves storage describing what is actually
236
+ * still applied, and a retry does not repeat completed `down()` steps.
237
+ * Throws the failing `down()`'s error, a missing-`down()` error, or a
238
+ * {@link MigrationStorageError} if a checkpoint cannot be written.
239
+ */
189
240
  rollback(targetVersion: string): Promise<{
190
241
  rolledBack: string[];
191
242
  }>;
@@ -288,4 +339,4 @@ declare function createBootSequence(): {
288
339
  }>;
289
340
  };
290
341
 
291
- export { type Migration as M, type SemVer as S, VERSION as V, compareSemVer as a, bundlerMetadata as b, checkCompatibility as c, createBootSequence as d, createBundle as e, createMigrationRunner as f, createModuleRegistry as g, createSSRCache as h, createTestHarness as i, deferNonCritical as j, env as k, healthCheck as l, lazyModule as m, parseSemVer as n, preloadCritical as o, packageInfo as p, prerenderRoutes as q, satisfies as s };
342
+ export { type LazyModule as L, type Migration as M, type PackageExportTarget as P, type SemVer as S, VERSION as V, MigrationStorageError as a, bundlerMetadata as b, checkCompatibility as c, compareSemVer as d, createBootSequence as e, createBundle as f, createMigrationRunner as g, createModuleRegistry as h, createSSRCache as i, createTestHarness as j, deferNonCritical as k, env as l, healthCheck as m, lazyModule as n, parseSemVer as o, packageInfo as p, preloadCritical as q, prerenderRoutes as r, satisfies as s };
@@ -1,102 +1,4 @@
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
- type SetState<T> = (next: T | ((prev: T) => T)) => void;
18
- type StateTuple<T> = [Accessor<T>, SetState<T>];
19
- /** Options for signal */
20
- interface SignalOptions<T = unknown> {
21
- /** Debug name for devtools inspection. Only used in development. */
22
- name?: string;
23
- /** Custom equality function. Defaults to Object.is(). */
24
- equals?: (prev: T, next: T) => boolean;
25
- }
26
- /**
27
- * signal creates a reactive signal that holds a value of type T.
28
- * Returns a tuple: [getter, setter].
29
- *
30
- * @param initial Initial value
31
- * @param options Optional config: `{ name: "count" }` for devtools labeling
32
- * @returns A `[getter, setter]` tuple. Calling the getter inside a reactive
33
- * context subscribes to the signal; the setter accepts a value or an updater.
34
- */
35
- declare function signal<T>(initial: T, options?: SignalOptions<T>): StateTuple<T>;
36
- /**
37
- * A valueless reactive token standing in for state SibuJS does not own.
38
- *
39
- * See {@link external}.
40
- */
41
- interface ExternalSource {
42
- /**
43
- * Declare, from inside a reactive computation, that it reads the external
44
- * state this source represents. Call it in the same places you would read a
45
- * signal — the top of a binding getter, a `derived()` body, an `effect()`.
46
- *
47
- * Outside a tracking context it is a no-op, exactly like reading a signal.
48
- */
49
- track(): void;
50
- /**
51
- * Declare that the external state changed. Every consumer that called
52
- * {@link ExternalSource.track} is invalidated.
53
- *
54
- * Participates in `batch()` like any signal write: inside a batch, consumers
55
- * are notified once when the outermost batch flushes.
56
- */
57
- invalidate(): void;
58
- }
59
- /**
60
- * Create a reactive source for state that lives outside SibuJS — a domain
61
- * engine, a media element, a canvas scene, an editor document, a cache a
62
- * socket writes into.
63
- *
64
- * The pattern is two lines: `track()` where you read, `invalidate()` after you
65
- * mutate.
66
- *
67
- * ```ts
68
- * import { Chess } from "chess.js";
69
- * import { external } from "sibujs";
70
- *
71
- * const game = new Chess(); // owns the rules and the mutable state
72
- * const moved = external(); // owns "something changed"
73
- *
74
- * ctx.text("@status", () => {
75
- * moved.track(); // this binding reads the engine
76
- * return game.isCheckmate() ? "Checkmate" : `${game.turn()} to move`;
77
- * });
78
- *
79
- * game.move({ from: "e2", to: "e4" });
80
- * moved.invalidate(); // every consumer above re-reads
81
- * ```
82
- *
83
- * **One source is one invalidation domain.** Every consumer of a source
84
- * re-runs on every `invalidate()`, so the granularity of your updates is
85
- * exactly the granularity of your sources: one for a whole engine is the
86
- * cheapest to write, several (`board`, `clock`, `history`) let an update touch
87
- * only what it affects. See `docs/architecture/external-state.md` for the
88
- * trade-offs and when subdividing is worth it.
89
- *
90
- * Ownership, disposal and error routing are the consumer's, not the source's:
91
- * a disposed binding or effect is never invalidated, and a consumer that
92
- * throws is reported through the normal runtime error pipeline with its own
93
- * phase and node.
94
- *
95
- * @param options `name` labels the source in devtools (development only).
96
- */
97
- declare function external(options?: {
98
- name?: string;
99
- }): ExternalSource;
1
+ import { A as Accessor } from './signal-EotCj4hS.cjs';
100
2
 
101
3
  /**
102
4
  * derived creates a derived reactive signal whose value updates when dependencies change.
@@ -212,4 +114,4 @@ interface TagProps {
212
114
  */
213
115
  declare const tagFactory: (tag: string, ns?: string) => (first?: TagProps | NodeChildren, second?: NodeChildren) => Element;
214
116
 
215
- export { type Accessor as A, type DerivedAccessor as D, type ExternalSource as E, type NodeChild as N, SVG_NS as S, type TagProps as T, type NodeChildren as a, type Dispose as b, type SignalOptions as c, derived as d, external as e, signal as s, tagFactory as t };
117
+ export { type DerivedAccessor as D, type NodeChild as N, SVG_NS as S, type TagProps as T, type NodeChildren as a, type Dispose as b, derived as d, tagFactory as t };
@@ -1,102 +1,4 @@
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
- type SetState<T> = (next: T | ((prev: T) => T)) => void;
18
- type StateTuple<T> = [Accessor<T>, SetState<T>];
19
- /** Options for signal */
20
- interface SignalOptions<T = unknown> {
21
- /** Debug name for devtools inspection. Only used in development. */
22
- name?: string;
23
- /** Custom equality function. Defaults to Object.is(). */
24
- equals?: (prev: T, next: T) => boolean;
25
- }
26
- /**
27
- * signal creates a reactive signal that holds a value of type T.
28
- * Returns a tuple: [getter, setter].
29
- *
30
- * @param initial Initial value
31
- * @param options Optional config: `{ name: "count" }` for devtools labeling
32
- * @returns A `[getter, setter]` tuple. Calling the getter inside a reactive
33
- * context subscribes to the signal; the setter accepts a value or an updater.
34
- */
35
- declare function signal<T>(initial: T, options?: SignalOptions<T>): StateTuple<T>;
36
- /**
37
- * A valueless reactive token standing in for state SibuJS does not own.
38
- *
39
- * See {@link external}.
40
- */
41
- interface ExternalSource {
42
- /**
43
- * Declare, from inside a reactive computation, that it reads the external
44
- * state this source represents. Call it in the same places you would read a
45
- * signal — the top of a binding getter, a `derived()` body, an `effect()`.
46
- *
47
- * Outside a tracking context it is a no-op, exactly like reading a signal.
48
- */
49
- track(): void;
50
- /**
51
- * Declare that the external state changed. Every consumer that called
52
- * {@link ExternalSource.track} is invalidated.
53
- *
54
- * Participates in `batch()` like any signal write: inside a batch, consumers
55
- * are notified once when the outermost batch flushes.
56
- */
57
- invalidate(): void;
58
- }
59
- /**
60
- * Create a reactive source for state that lives outside SibuJS — a domain
61
- * engine, a media element, a canvas scene, an editor document, a cache a
62
- * socket writes into.
63
- *
64
- * The pattern is two lines: `track()` where you read, `invalidate()` after you
65
- * mutate.
66
- *
67
- * ```ts
68
- * import { Chess } from "chess.js";
69
- * import { external } from "sibujs";
70
- *
71
- * const game = new Chess(); // owns the rules and the mutable state
72
- * const moved = external(); // owns "something changed"
73
- *
74
- * ctx.text("@status", () => {
75
- * moved.track(); // this binding reads the engine
76
- * return game.isCheckmate() ? "Checkmate" : `${game.turn()} to move`;
77
- * });
78
- *
79
- * game.move({ from: "e2", to: "e4" });
80
- * moved.invalidate(); // every consumer above re-reads
81
- * ```
82
- *
83
- * **One source is one invalidation domain.** Every consumer of a source
84
- * re-runs on every `invalidate()`, so the granularity of your updates is
85
- * exactly the granularity of your sources: one for a whole engine is the
86
- * cheapest to write, several (`board`, `clock`, `history`) let an update touch
87
- * only what it affects. See `docs/architecture/external-state.md` for the
88
- * trade-offs and when subdividing is worth it.
89
- *
90
- * Ownership, disposal and error routing are the consumer's, not the source's:
91
- * a disposed binding or effect is never invalidated, and a consumer that
92
- * throws is reported through the normal runtime error pipeline with its own
93
- * phase and node.
94
- *
95
- * @param options `name` labels the source in devtools (development only).
96
- */
97
- declare function external(options?: {
98
- name?: string;
99
- }): ExternalSource;
1
+ import { A as Accessor } from './signal-EotCj4hS.js';
100
2
 
101
3
  /**
102
4
  * derived creates a derived reactive signal whose value updates when dependencies change.
@@ -212,4 +114,4 @@ interface TagProps {
212
114
  */
213
115
  declare const tagFactory: (tag: string, ns?: string) => (first?: TagProps | NodeChildren, second?: NodeChildren) => Element;
214
116
 
215
- export { type Accessor as A, type DerivedAccessor as D, type ExternalSource as E, type NodeChild as N, SVG_NS as S, type TagProps as T, type NodeChildren as a, type Dispose as b, type SignalOptions as c, derived as d, external as e, signal as s, tagFactory as t };
117
+ export { type DerivedAccessor as D, type NodeChild as N, SVG_NS as S, type TagProps as T, type NodeChildren as a, type Dispose as b, derived as d, tagFactory as t };