@zeus-js/zeus 0.0.2 → 0.1.0-beta.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/zeus.d.mts CHANGED
@@ -1,1307 +1,10 @@
1
- export interface ValueState<T = unknown> {
2
- get value(): T;
3
- set value(value: T);
4
- }
5
- type ProxyableInput = Record<PropertyKey, any> | readonly any[] | Map<unknown, unknown> | Set<unknown> | WeakMap<object, unknown> | WeakSet<object>;
6
- export type State<T> = T extends ValueStateInput ? ValueState<T> : T extends ProxyableInput ? Reactive$1<T> : ValueState<T>;
7
- type ValueStateInput = null | undefined | Date | RegExp | Error | Promise<any> | Function | Node;
8
- type Reactive$1<T extends object> = T;
9
- export declare function state<T extends ValueStateInput>(value: T): ValueState<T>;
10
- export declare function state<T extends ProxyableInput>(value: T): Reactive$1<T>;
11
- export declare function state<T>(value: T): ValueState<T>;
12
- export declare function state<T = undefined>(): ValueState<T | undefined>;
13
- declare function isValueState<T = unknown>(value: unknown): value is ValueState<T>;
1
+ export { ComputedRef, Scope, State, ValueState, WatchHandle, WatchOptions, batch, computed, effect, nextTick, onCleanup, scope, state, untrack, watch } from '@zeus-js/signal';
2
+ import { JSXValue } from '@zeus-js/runtime-dom';
3
+ export { Component, Context, ContextBridgeProps, ContextProviderProps, DefineElementContext, DefineElementMeta, DefineElementOptions, DefineElementSetup, For, ForProps, Host, HostProps, JSXValue, Show, ShowProps, Slot, SlotProps, createContext, defineElement, inject, provide, render, useContext } from '@zeus-js/runtime-dom';
14
4
 
15
- declare enum TrackOpTypes {
16
- GET = "get",
17
- HAS = "has",
18
- ITERATE = "iterate"
19
- }
20
- declare enum TriggerOpTypes {
21
- SET = "set",
22
- ADD = "add",
23
- DELETE = "delete",
24
- CLEAR = "clear"
25
- }
26
- declare enum ReactiveFlags {
27
- SKIP = "__v_skip",
28
- IS_REACTIVE = "__v_isReactive",
29
- IS_READONLY = "__v_isReadonly",
30
- IS_SHALLOW = "__v_isShallow",
31
- RAW = "__v_raw",
32
- IS_REF = "__v_isRef"
33
- }
5
+ export declare const Fragment: unique symbol;
34
6
 
35
- import { type Link } from './dep';
36
- import type { ComputedRefImpl } from './computed';
37
- import type { TrackOpTypes, TriggerOpTypes } from './constants';
38
- type EffectScheduler = (...args: any[]) => any;
39
- type DebuggerEvent = {
40
- effect: Subscriber;
41
- } & DebuggerEventExtraInfo;
42
- type DebuggerEventExtraInfo = {
43
- target: object;
44
- type: TrackOpTypes | TriggerOpTypes;
45
- key: any;
46
- newValue?: any;
47
- oldValue?: any;
48
- oldTarget?: Map<any, any> | Set<any>;
49
- };
50
- interface DebuggerOptions {
51
- onTrack?: (event: DebuggerEvent) => void;
52
- onTrigger?: (event: DebuggerEvent) => void;
53
- }
54
- interface ReactiveEffectOptions extends DebuggerOptions {
55
- scheduler?: EffectScheduler;
56
- allowRecurse?: boolean;
57
- onStop?: () => void;
58
- }
59
- interface ReactiveEffectRunner<T = any> {
60
- (): T;
61
- effect: ReactiveEffect;
62
- }
63
- declare let activeSub: Subscriber | undefined;
64
- declare enum EffectFlags {
65
- /**
66
- * ReactiveEffect only
67
- */
68
- ACTIVE = 1,
69
- RUNNING = 2,
70
- TRACKING = 4,
71
- NOTIFIED = 8,
72
- DIRTY = 16,
73
- ALLOW_RECURSE = 32,
74
- PAUSED = 64,
75
- EVALUATED = 128
76
- }
77
- /**
78
- * Subscriber is a type that tracks (or subscribes to) a list of deps.
79
- */
80
- interface Subscriber extends DebuggerOptions {
81
- /**
82
- * Head of the doubly linked list representing the deps
83
- * @internal
84
- */
85
- deps?: Link;
86
- /**
87
- * Tail of the same list
88
- * @internal
89
- */
90
- depsTail?: Link;
91
- /**
92
- * @internal
93
- */
94
- flags: EffectFlags;
95
- /**
96
- * @internal
97
- */
98
- next?: Subscriber;
99
- /**
100
- * returning `true` indicates it's a computed that needs to call notify
101
- * on its dep too
102
- * @internal
103
- */
104
- notify(): true | void;
105
- }
106
- declare class ReactiveEffect<T = any> implements Subscriber, ReactiveEffectOptions {
107
- fn: () => T;
108
- /**
109
- * @internal
110
- */
111
- deps?: Link;
112
- /**
113
- * @internal
114
- */
115
- depsTail?: Link;
116
- /**
117
- * @internal
118
- */
119
- flags: EffectFlags;
120
- /**
121
- * @internal
122
- */
123
- next?: Subscriber;
124
- /**
125
- * @internal
126
- */
127
- cleanup?: () => void;
128
- scheduler?: EffectScheduler;
129
- onStop?: () => void;
130
- onTrack?: (event: DebuggerEvent) => void;
131
- onTrigger?: (event: DebuggerEvent) => void;
132
- constructor(fn: () => T);
133
- pause(): void;
134
- resume(): void;
135
- /**
136
- * @internal
137
- */
138
- notify(): void;
139
- run(): T;
140
- stop(): void;
141
- trigger(): void;
142
- /**
143
- * @internal
144
- */
145
- runIfDirty(): void;
146
- get dirty(): boolean;
147
- }
148
- /**
149
- * @internal
150
- */
151
- declare function queueSubscriber(sub: Subscriber, isComputed?: boolean): void;
152
- /**
153
- * @internal
154
- */
155
- declare function startBatch(): void;
156
- /**
157
- * Run batched effects when all batches have ended
158
- * @internal
159
- */
160
- declare function endBatch(): void;
161
- /**
162
- * Returning false indicates the refresh failed
163
- * @internal
164
- */
165
- declare function refreshComputed(computed: ComputedRefImpl): undefined;
166
- export declare function effect<T = any>(fn: () => T, options?: ReactiveEffectOptions): ReactiveEffectRunner<T>;
167
- /**
168
- * Stops the effect associated with the given runner.
169
- *
170
- * @param runner - Association with the effect to stop tracking.
171
- */
172
- declare function stop(runner: ReactiveEffectRunner): void;
173
- /**
174
- * @internal
175
- */
176
- declare let shouldTrack: boolean;
177
- /**
178
- * Temporarily pauses tracking.
179
- */
180
- declare function pauseTracking(): void;
181
- /**
182
- * Re-enables effect tracking (if it was paused).
183
- */
184
- declare function enableTracking(): void;
185
- /**
186
- * Resets the previous global effect tracking state.
187
- */
188
- declare function resetTracking(): void;
189
- /**
190
- * Registers a cleanup function for the current active effect.
191
- * The cleanup function is called right before the next effect run, or when the
192
- * effect is stopped.
193
- *
194
- * Throws a warning if there is no current active effect. The warning can be
195
- * suppressed by passing `true` to the second argument.
196
- *
197
- * @param fn - the cleanup function to be registered
198
- * @param failSilently - if `true`, will not throw warning when called without
199
- * an active effect.
200
- */
201
- declare function onEffectCleanup(fn: () => void, failSilently?: boolean): void;
202
- /**
203
- * Batches reactive updates synchronously within the given function.
204
- * All updates triggered inside `fn` are deferred until the function completes,
205
- * then flushed together in a single batch.
206
- */
207
- export declare function batch<T>(fn: () => T): T;
208
- /**
209
- * Executes the given function without tracking reactive dependencies.
210
- * Any reactive reads inside `fn` will not trigger effect re-runs.
211
- */
212
- export declare function untrack<T>(fn: () => T): T;
213
- /**
214
- * Returns the currently executing reactive effect, if any.
215
- */
216
- declare function getCurrentEffect(): ReactiveEffect | undefined;
217
-
218
- import { type TrackOpTypes, TriggerOpTypes } from './constants';
219
- import { type DebuggerEventExtraInfo, type Subscriber } from './effect';
220
- import type { ComputedRefImpl } from './computed';
221
- /**
222
- * Incremented every time a reactive change happens
223
- * This is used to give computed a fast path to avoid re-compute when nothing
224
- * has changed.
225
- */
226
- declare let globalVersion: number;
227
- /**
228
- * Represents a link between a source (Dep) and a subscriber (Effect or Computed).
229
- * Deps and subs have a many-to-many relationship - each link between a
230
- * dep and a sub is represented by a Link instance.
231
- *
232
- * A Link is also a node in two doubly-linked lists - one for the associated
233
- * sub to track all its deps, and one for the associated dep to track all its
234
- * subs.
235
- *
236
- * @internal
237
- */
238
- declare class Link {
239
- sub: Subscriber;
240
- dep: Dep;
241
- /**
242
- * - Before each effect run, all previous dep links' version are reset to -1
243
- * - During the run, a link's version is synced with the source dep on access
244
- * - After the run, links with version -1 (that were never used) are cleaned
245
- * up
246
- */
247
- version: number;
248
- /**
249
- * Pointers for doubly-linked lists
250
- */
251
- nextDep?: Link;
252
- prevDep?: Link;
253
- nextSub?: Link;
254
- prevSub?: Link;
255
- prevActiveLink?: Link;
256
- constructor(sub: Subscriber, dep: Dep);
257
- }
258
- /**
259
- * @internal
260
- */
261
- declare class Dep {
262
- computed?: ComputedRefImpl | undefined;
263
- version: number;
264
- /**
265
- * Link between this dep and the current active effect
266
- */
267
- activeLink?: Link;
268
- /**
269
- * Doubly linked list representing the subscribing effects (tail)
270
- */
271
- subs?: Link;
272
- /**
273
- * Doubly linked list representing the subscribing effects (head)
274
- * DEV only, for invoking onTrigger hooks in correct order
275
- */
276
- subsHead?: Link;
277
- /**
278
- * For object property deps cleanup
279
- */
280
- map?: KeyToDepMap;
281
- key?: unknown;
282
- /**
283
- * Subscriber counter
284
- */
285
- sc: number;
286
- /**
287
- * @internal
288
- */
289
- readonly __v_skip = true;
290
- constructor(computed?: ComputedRefImpl | undefined);
291
- track(debugInfo?: DebuggerEventExtraInfo): Link | undefined;
292
- trigger(debugInfo?: DebuggerEventExtraInfo): void;
293
- notify(debugInfo?: DebuggerEventExtraInfo): void;
294
- }
295
- type KeyToDepMap = Map<any, Dep>;
296
- declare const targetMap: WeakMap<object, KeyToDepMap>;
297
- declare const ITERATE_KEY: unique symbol;
298
- declare const MAP_KEY_ITERATE_KEY: unique symbol;
299
- declare const ARRAY_ITERATE_KEY: unique symbol;
300
- /**
301
- * Tracks access to a reactive property.
302
- *
303
- * This will check which effect is running at the moment and record it as dep
304
- * which records all effects that depend on the reactive property.
305
- *
306
- * @param target - Object holding the reactive property.
307
- * @param type - Defines the type of access to the reactive property.
308
- * @param key - Identifier of the reactive property to track.
309
- */
310
- declare function track(target: object, type: TrackOpTypes, key: unknown): void;
311
- /**
312
- * Finds all deps associated with the target (or a specific property) and
313
- * triggers the effects stored within.
314
- *
315
- * @param target - The reactive object.
316
- * @param type - Defines the type of the operation that needs to trigger effects.
317
- * @param key - Can be used to target a specific reactive property in the target object.
318
- */
319
- declare function trigger(target: object, type: TriggerOpTypes, key?: unknown, newValue?: unknown, oldValue?: unknown, oldTarget?: Map<unknown, unknown> | Set<unknown>): void;
320
- declare function getDepFromReactive(object: any, key: string | number | symbol): Dep | undefined;
321
-
322
- import { ReactiveFlags } from './constants';
323
- import type { RawSymbol, Ref, UnwrapRefSimple } from './ref';
324
- interface Target {
325
- [ReactiveFlags.SKIP]?: boolean;
326
- [ReactiveFlags.IS_REACTIVE]?: boolean;
327
- [ReactiveFlags.IS_READONLY]?: boolean;
328
- [ReactiveFlags.IS_SHALLOW]?: boolean;
329
- [ReactiveFlags.RAW]?: any;
330
- }
331
- declare const reactiveMap: WeakMap<Target, any>;
332
- declare const shallowReactiveMap: WeakMap<Target, any>;
333
- declare const readonlyMap: WeakMap<Target, any>;
334
- declare const shallowReadonlyMap: WeakMap<Target, any>;
335
- type UnwrapNestedRefs<T> = T extends Ref ? T : UnwrapRefSimple<T>;
336
- declare const ReactiveMarkerSymbol: unique symbol;
337
- interface ReactiveMarker {
338
- [ReactiveMarkerSymbol]?: void;
339
- }
340
- type Reactive<T> = UnwrapNestedRefs<T> & (T extends readonly any[] ? ReactiveMarker : {});
341
- /**
342
- * Returns a reactive proxy of the object.
343
- *
344
- * The reactive conversion is "deep": it affects all nested properties. A
345
- * reactive object also deeply unwraps any properties that are refs while
346
- * maintaining reactivity.
347
- *
348
- * @example
349
- * ```js
350
- * const obj = reactive({ count: 0 })
351
- * ```
352
- *
353
- * @param target - The source object.
354
- * @see {@link https://vuejs.org/api/reactivity-core.html#reactive}
355
- */
356
- declare function reactive<T extends object>(target: T): Reactive<T>;
357
- declare class ShallowReactiveBrandClass {
358
- private __shallowReactiveBrand?;
359
- }
360
- type ShallowReactiveBrand = ShallowReactiveBrandClass;
361
- type ShallowReactive<T> = T & ShallowReactiveBrand;
362
- /**
363
- * Shallow version of {@link reactive}.
364
- *
365
- * Unlike {@link reactive}, there is no deep conversion: only root-level
366
- * properties are reactive for a shallow reactive object. Property values are
367
- * stored and exposed as-is - this also means properties with ref values will
368
- * not be automatically unwrapped.
369
- *
370
- * @example
371
- * ```js
372
- * const state = shallowReactive({
373
- * foo: 1,
374
- * nested: {
375
- * bar: 2
376
- * }
377
- * })
378
- *
379
- * // mutating state's own properties is reactive
380
- * state.foo++
381
- *
382
- * // ...but does not convert nested objects
383
- * isReactive(state.nested) // false
384
- *
385
- * // NOT reactive
386
- * state.nested.bar++
387
- * ```
388
- *
389
- * @param target - The source object.
390
- * @see {@link https://vuejs.org/api/reactivity-advanced.html#shallowreactive}
391
- */
392
- declare function shallowReactive<T extends object>(target: T): ShallowReactive<T>;
393
- type Primitive = string | number | boolean | bigint | symbol | undefined | null;
394
- type Builtin = Primitive | Function | Date | Error | RegExp;
395
- type DeepReadonly<T> = T extends Builtin ? T : T extends Map<infer K, infer V> ? ReadonlyMap<DeepReadonly<K>, DeepReadonly<V>> : T extends ReadonlyMap<infer K, infer V> ? ReadonlyMap<DeepReadonly<K>, DeepReadonly<V>> : T extends WeakMap<infer K, infer V> ? WeakMap<DeepReadonly<K>, DeepReadonly<V>> : T extends Set<infer U> ? ReadonlySet<DeepReadonly<U>> : T extends ReadonlySet<infer U> ? ReadonlySet<DeepReadonly<U>> : T extends WeakSet<infer U> ? WeakSet<DeepReadonly<U>> : T extends Promise<infer U> ? Promise<DeepReadonly<U>> : T extends Ref<infer U, unknown> ? Readonly<Ref<DeepReadonly<U>>> : T extends {} ? {
396
- readonly [K in keyof T]: DeepReadonly<T[K]>;
397
- } : Readonly<T>;
398
- /**
399
- * Takes an object (reactive or plain) or a ref and returns a readonly proxy to
400
- * the original.
401
- *
402
- * A readonly proxy is deep: any nested property accessed will be readonly as
403
- * well. It also has the same ref-unwrapping behavior as {@link reactive},
404
- * except the unwrapped values will also be made readonly.
405
- *
406
- * @example
407
- * ```js
408
- * const original = reactive({ count: 0 })
409
- *
410
- * const copy = readonly(original)
411
- *
412
- * watchEffect(() => {
413
- * // works for reactivity tracking
414
- * console.log(copy.count)
415
- * })
416
- *
417
- * // mutating original will trigger watchers relying on the copy
418
- * original.count++
419
- *
420
- * // mutating the copy will fail and result in a warning
421
- * copy.count++ // warning!
422
- * ```
423
- *
424
- * @param target - The source object.
425
- * @see {@link https://vuejs.org/api/reactivity-core.html#readonly}
426
- */
427
- declare function readonly<T extends object>(target: T): DeepReadonly<UnwrapNestedRefs<T>>;
428
- /**
429
- * Shallow version of {@link readonly}.
430
- *
431
- * Unlike {@link readonly}, there is no deep conversion: only root-level
432
- * properties are made readonly. Property values are stored and exposed as-is -
433
- * this also means properties with ref values will not be automatically
434
- * unwrapped.
435
- *
436
- * @example
437
- * ```js
438
- * const state = shallowReadonly({
439
- * foo: 1,
440
- * nested: {
441
- * bar: 2
442
- * }
443
- * })
444
- *
445
- * // mutating state's own properties will fail
446
- * state.foo++
447
- *
448
- * // ...but works on nested objects
449
- * isReadonly(state.nested) // false
450
- *
451
- * // works
452
- * state.nested.bar++
453
- * ```
454
- *
455
- * @param target - The source object.
456
- * @see {@link https://vuejs.org/api/reactivity-advanced.html#shallowreadonly}
457
- */
458
- declare function shallowReadonly<T extends object>(target: T): Readonly<T>;
459
- /**
460
- * Checks if an object is a proxy created by {@link reactive} or
461
- * {@link shallowReactive} (or {@link ref} in some cases).
462
- *
463
- * @example
464
- * ```js
465
- * isReactive(reactive({})) // => true
466
- * isReactive(readonly(reactive({}))) // => true
467
- * isReactive(ref({}).value) // => true
468
- * isReactive(readonly(ref({})).value) // => true
469
- * isReactive(ref(true)) // => false
470
- * isReactive(shallowRef({}).value) // => false
471
- * isReactive(shallowReactive({})) // => true
472
- * ```
473
- *
474
- * @param value - The value to check.
475
- * @see {@link https://vuejs.org/api/reactivity-utilities.html#isreactive}
476
- */
477
- declare function isReactive(value: unknown): boolean;
478
- /**
479
- * Checks whether the passed value is a readonly object. The properties of a
480
- * readonly object can change, but they can't be assigned directly via the
481
- * passed object.
482
- *
483
- * The proxies created by {@link readonly} and {@link shallowReadonly} are
484
- * both considered readonly, as is a computed ref without a set function.
485
- *
486
- * @param value - The value to check.
487
- * @see {@link https://vuejs.org/api/reactivity-utilities.html#isreadonly}
488
- */
489
- declare function isReadonly(value: unknown): boolean;
490
- declare function isShallow(value: unknown): boolean;
491
- /**
492
- * Checks if an object is a proxy created by {@link reactive},
493
- * {@link readonly}, {@link shallowReactive} or {@link shallowReadonly}.
494
- *
495
- * @param value - The value to check.
496
- * @see {@link https://vuejs.org/api/reactivity-utilities.html#isproxy}
497
- */
498
- declare function isProxy(value: any): boolean;
499
- /**
500
- * Returns the raw, original object of a Vue-created proxy.
501
- *
502
- * `toRaw()` can return the original object from proxies created by
503
- * {@link reactive}, {@link readonly}, {@link shallowReactive} or
504
- * {@link shallowReadonly}.
505
- *
506
- * This is an escape hatch that can be used to temporarily read without
507
- * incurring proxy access / tracking overhead or write without triggering
508
- * changes. It is **not** recommended to hold a persistent reference to the
509
- * original object. Use with caution.
510
- *
511
- * @example
512
- * ```js
513
- * const foo = {}
514
- * const reactiveFoo = reactive(foo)
515
- *
516
- * console.log(toRaw(reactiveFoo) === foo) // true
517
- * ```
518
- *
519
- * @param observed - The object for which the "raw" value is requested.
520
- * @see {@link https://vuejs.org/api/reactivity-advanced.html#toraw}
521
- */
522
- declare function toRaw<T>(observed: T): T;
523
- type Raw<T> = T & {
524
- [RawSymbol]?: true;
525
- };
526
- /**
527
- * Marks an object so that it will never be converted to a proxy. Returns the
528
- * object itself.
529
- *
530
- * @example
531
- * ```js
532
- * const foo = markRaw({})
533
- * console.log(isReactive(reactive(foo))) // false
534
- *
535
- * // also works when nested inside other reactive objects
536
- * const bar = reactive({ foo })
537
- * console.log(isReactive(bar.foo)) // false
538
- * ```
539
- *
540
- * **Warning:** `markRaw()` together with the shallow APIs such as
541
- * {@link shallowReactive} allow you to selectively opt-out of the default
542
- * deep reactive/readonly conversion and embed raw, non-proxied objects in your
543
- * state graph.
544
- *
545
- * @param value - The object to be marked as "raw".
546
- * @see {@link https://vuejs.org/api/reactivity-advanced.html#markraw}
547
- */
548
- declare function markRaw<T extends object>(value: T): Raw<T>;
549
- /**
550
- * Returns a reactive proxy of the given value (if possible).
551
- *
552
- * If the given value is not an object, the original value itself is returned.
553
- *
554
- * @param value - The value for which a reactive proxy shall be created.
555
- */
556
- declare const toReactive: <T extends unknown>(value: T) => T;
557
- /**
558
- * Returns a readonly proxy of the given value (if possible).
559
- *
560
- * If the given value is not an object, the original value itself is returned.
561
- *
562
- * @param value - The value for which a readonly proxy shall be created.
563
- */
564
- declare const toReadonly: <T extends unknown>(value: T) => DeepReadonly<T>;
565
-
566
- import { type IfAny } from '@zeus-js/shared';
567
- import { type Builtin, type ShallowReactiveBrand } from './reactive';
568
- import type { ComputedRef, WritableComputedRef } from './computed';
569
- declare const RefSymbol: unique symbol;
570
- declare const RawSymbol: unique symbol;
571
- interface Ref<T = any, S = T> {
572
- get value(): T;
573
- set value(_: S);
574
- /**
575
- * Type differentiator only.
576
- * We need this to be in public d.ts but don't want it to show up in IDE
577
- * autocomplete, so we use a private Symbol instead.
578
- */
579
- [RefSymbol]: true;
580
- }
581
- /**
582
- * Checks if a value is a ref object.
583
- *
584
- * @param r - The value to inspect.
585
- * @see {@link https://vuejs.org/api/reactivity-utilities.html#isref}
586
- */
587
- declare function isRef<T>(r: Ref<T> | unknown): r is Ref<T>;
588
- /**
589
- * Takes an inner value and returns a reactive and mutable ref object, which
590
- * has a single property `.value` that points to the inner value.
591
- *
592
- * @param value - The object to wrap in the ref.
593
- * @see {@link https://vuejs.org/api/reactivity-core.html#ref}
594
- */
595
- declare function ref<T>(value: T): [T] extends [Ref] ? IfAny<T, Ref<T>, T> : Ref<UnwrapRef<T>, UnwrapRef<T> | T>;
596
- declare function ref<T = any>(): Ref<T | undefined>;
597
- declare const ShallowRefMarker: unique symbol;type ShallowRef<T = any, S = T> = Ref<T, S> & {
598
- [ShallowRefMarker]?: true;
599
- };
600
- /**
601
- * Shallow version of {@link ref}.
602
- *
603
- * @example
604
- * ```js
605
- * const state = shallowRef({ count: 1 })
606
- *
607
- * // does NOT trigger change
608
- * state.value.count = 2
609
- *
610
- * // does trigger change
611
- * state.value = { count: 2 }
612
- * ```
613
- *
614
- * @param value - The "inner value" for the shallow ref.
615
- * @see {@link https://vuejs.org/api/reactivity-advanced.html#shallowref}
616
- */
617
- declare function shallowRef<T>(value: T): Ref extends T ? T extends Ref ? IfAny<T, ShallowRef<T>, T> : ShallowRef<T> : ShallowRef<T>;
618
- declare function shallowRef<T = any>(): ShallowRef<T | undefined>;
619
- /**
620
- * Force trigger effects that depends on a shallow ref. This is typically used
621
- * after making deep mutations to the inner value of a shallow ref.
622
- *
623
- * @example
624
- * ```js
625
- * const shallow = shallowRef({
626
- * greet: 'Hello, world'
627
- * })
628
- *
629
- * // Logs "Hello, world" once for the first run-through
630
- * watchEffect(() => {
631
- * console.log(shallow.value.greet)
632
- * })
633
- *
634
- * // This won't trigger the effect because the ref is shallow
635
- * shallow.value.greet = 'Hello, universe'
636
- *
637
- * // Logs "Hello, universe"
638
- * triggerRef(shallow)
639
- * ```
640
- *
641
- * @param ref - The ref whose tied effects shall be executed.
642
- * @see {@link https://vuejs.org/api/reactivity-advanced.html#triggerref}
643
- */
644
- declare function triggerRef(ref: Ref): void;
645
- type MaybeRef<T = any> = T | Ref<T> | ShallowRef<T> | WritableComputedRef<T>;
646
- type MaybeRefOrGetter<T = any> = MaybeRef<T> | ComputedRef<T> | (() => T);
647
- /**
648
- * Returns the inner value if the argument is a ref, otherwise return the
649
- * argument itself. This is a sugar function for
650
- * `val = isRef(val) ? val.value : val`.
651
- *
652
- * @example
653
- * ```js
654
- * function useFoo(x: number | Ref<number>) {
655
- * const unwrapped = unref(x)
656
- * // unwrapped is guaranteed to be number now
657
- * }
658
- * ```
659
- *
660
- * @param ref - Ref or plain value to be converted into the plain value.
661
- * @see {@link https://vuejs.org/api/reactivity-utilities.html#unref}
662
- */
663
- declare function unref<T>(ref: MaybeRef<T> | ComputedRef<T>): T;
664
- /**
665
- * Normalizes values / refs / getters to values.
666
- * This is similar to {@link unref}, except that it also normalizes getters.
667
- * If the argument is a getter, it will be invoked and its return value will
668
- * be returned.
669
- *
670
- * @example
671
- * ```js
672
- * toValue(1) // 1
673
- * toValue(ref(1)) // 1
674
- * toValue(() => 1) // 1
675
- * ```
676
- *
677
- * @param source - A getter, an existing ref, or a non-function value.
678
- * @see {@link https://vuejs.org/api/reactivity-utilities.html#tovalue}
679
- */
680
- declare function toValue<T>(source: MaybeRefOrGetter<T>): T;
681
- /**
682
- * Returns a proxy for the given object that shallowly unwraps properties that
683
- * are refs. If the object already is reactive, it's returned as-is. If not, a
684
- * new reactive proxy is created.
685
- *
686
- * @param objectWithRefs - Either an already-reactive object or a simple object
687
- * that contains refs.
688
- */
689
- declare function proxyRefs<T extends object>(objectWithRefs: T): ShallowUnwrapRef<T>;
690
- type CustomRefFactory<T, S = T> = (track: () => void, trigger: () => void) => {
691
- get: () => T;
692
- set: (value: S) => void;
693
- };
694
- /**
695
- * Creates a customized ref with explicit control over its dependency tracking
696
- * and updates triggering.
697
- *
698
- * @param factory - The function that receives the `track` and `trigger` callbacks.
699
- * @see {@link https://vuejs.org/api/reactivity-advanced.html#customref}
700
- */
701
- declare function customRef<T, S = T>(factory: CustomRefFactory<T, S>): Ref<T, S>;
702
- type ToRefs<T = any> = {
703
- [K in keyof T]: ToRef<T[K]>;
704
- };
705
- type ArrayStringKey<T> = T extends readonly any[] ? number extends T['length'] ? `${number}` : never : never;
706
- type ToRefKey<T> = keyof T | ArrayStringKey<T>;
707
- type ToRefValue<T extends object, K extends ToRefKey<T>> = K extends keyof T ? T[K] : T extends readonly (infer V)[] ? K extends ArrayStringKey<T> ? V : never : never;
708
- /**
709
- * Converts a reactive object to a plain object where each property of the
710
- * resulting object is a ref pointing to the corresponding property of the
711
- * original object. Each individual ref is created using {@link toRef}.
712
- *
713
- * @param object - Reactive object to be made into an object of linked refs.
714
- * @see {@link https://vuejs.org/api/reactivity-utilities.html#torefs}
715
- */
716
- declare function toRefs<T extends object>(object: T): ToRefs<T>;
717
- type ToRef<T> = IfAny<T, Ref<T>, [T] extends [Ref] ? T : Ref<T>>;
718
- /**
719
- * Used to normalize values / refs / getters into refs.
720
- *
721
- * @example
722
- * ```js
723
- * // returns existing refs as-is
724
- * toRef(existingRef)
725
- *
726
- * // creates a ref that calls the getter on .value access
727
- * toRef(() => props.foo)
728
- *
729
- * // creates normal refs from non-function values
730
- * // equivalent to ref(1)
731
- * toRef(1)
732
- * ```
733
- *
734
- * Can also be used to create a ref for a property on a source reactive object.
735
- * The created ref is synced with its source property: mutating the source
736
- * property will update the ref, and vice-versa.
737
- *
738
- * @example
739
- * ```js
740
- * const state = reactive({
741
- * foo: 1,
742
- * bar: 2
743
- * })
744
- *
745
- * const fooRef = toRef(state, 'foo')
746
- *
747
- * // mutating the ref updates the original
748
- * fooRef.value++
749
- * console.log(state.foo) // 2
750
- *
751
- * // mutating the original also updates the ref
752
- * state.foo++
753
- * console.log(fooRef.value) // 3
754
- * ```
755
- *
756
- * @param source - A getter, an existing ref, a non-function value, or a
757
- * reactive object to create a property ref from.
758
- * @param [key] - (optional) Name of the property in the reactive object.
759
- * @see {@link https://vuejs.org/api/reactivity-utilities.html#toref}
760
- */
761
- declare function toRef<T>(value: T): T extends () => infer R ? Readonly<Ref<R>> : T extends Ref ? T : Ref<UnwrapRef<T>>;
762
- declare function toRef<T extends object, K extends ToRefKey<T>>(object: T, key: K): ToRef<ToRefValue<T, K>>;
763
- declare function toRef<T extends object, K extends ToRefKey<T>>(object: T, key: K, defaultValue: ToRefValue<T, K>): ToRef<Exclude<ToRefValue<T, K>, undefined>>;
764
- /**
765
- * This is a special exported interface for other packages to declare
766
- * additional types that should bail out for ref unwrapping. For example
767
- * \@vue/runtime-dom can declare it like so in its d.ts:
768
- *
769
- * ``` ts
770
- * declare module '@vue/reactivity' {
771
- * export interface RefUnwrapBailTypes {
772
- * runtimeDOMBailTypes: Node | Window
773
- * }
774
- * }
775
- * ```
776
- */
777
- interface RefUnwrapBailTypes {
778
- }
779
- type ShallowUnwrapRef<T> = T extends ShallowReactiveBrand ? T : {
780
- [K in keyof T]: DistributeRef<T[K]>;
781
- };
782
- type DistributeRef<T> = T extends Ref<infer V, unknown> ? V : T;
783
- type UnwrapRef<T> = T extends ShallowRef<infer V, unknown> ? V : T extends Ref<infer V, unknown> ? UnwrapRefSimple<V> : UnwrapRefSimple<T>;
784
- type UnwrapRefSimple<T> = T extends Builtin | Ref | RefUnwrapBailTypes[keyof RefUnwrapBailTypes] | {
785
- [RawSymbol]?: true;
786
- } ? T : T extends ShallowReactiveBrand ? T : T extends Map<infer K, infer V> ? Map<K, UnwrapRefSimple<V>> & UnwrapRef<Omit<T, keyof Map<any, any>>> : T extends WeakMap<infer K, infer V> ? WeakMap<K, UnwrapRefSimple<V>> & UnwrapRef<Omit<T, keyof WeakMap<any, any>>> : T extends Set<infer V> ? Set<UnwrapRefSimple<V>> & UnwrapRef<Omit<T, keyof Set<any>>> : T extends WeakSet<infer V> ? WeakSet<UnwrapRefSimple<V>> & UnwrapRef<Omit<T, keyof WeakSet<any>>> : T extends ReadonlyArray<any> ? {
787
- [K in keyof T]: UnwrapRefSimple<T[K]>;
788
- } : T extends object ? {
789
- [P in keyof T]: P extends symbol ? T[P] : UnwrapRef<T[P]>;
790
- } : T;
791
-
792
- import { Dep, type Link } from './dep';
793
- import { type DebuggerEvent, type DebuggerOptions, EffectFlags, type Subscriber } from './effect';
794
- import type { Ref } from './ref';
795
- declare const ComputedRefSymbol: unique symbol;
796
- declare const WritableComputedRefSymbol: unique symbol;
797
- interface BaseComputedRef<T, S = T> extends Ref<T, S> {
798
- [ComputedRefSymbol]: true;
799
- /**
800
- * @deprecated computed no longer uses effect
801
- */
802
- effect: ComputedRefImpl;
803
- }
804
- export interface ComputedRef<T = any> extends BaseComputedRef<T> {
805
- readonly value: T;
806
- }
807
- interface WritableComputedRef<T, S = T> extends BaseComputedRef<T, S> {
808
- [WritableComputedRefSymbol]: true;
809
- }
810
- type ComputedGetter<T> = (oldValue?: T) => T;
811
- type ComputedSetter<T> = (newValue: T) => void;
812
- interface WritableComputedOptions<T, S = T> {
813
- get: ComputedGetter<T>;
814
- set: ComputedSetter<S>;
815
- }
816
- /**
817
- * @private exported by @vue/reactivity for Vue core use, but not exported from
818
- * the main vue package
819
- */
820
- declare class ComputedRefImpl<T = any> implements Subscriber {
821
- fn: ComputedGetter<T>;
822
- private readonly setter;
823
- /**
824
- * @internal
825
- */
826
- _value: any;
827
- /**
828
- * @internal
829
- */
830
- readonly dep: Dep;
831
- /**
832
- * @internal
833
- */
834
- readonly __v_isRef = true;
835
- /**
836
- * @internal
837
- */
838
- readonly __v_isReadonly: boolean;
839
- /**
840
- * @internal
841
- */
842
- deps?: Link;
843
- /**
844
- * @internal
845
- */
846
- depsTail?: Link;
847
- /**
848
- * @internal
849
- */
850
- flags: EffectFlags;
851
- /**
852
- * @internal
853
- */
854
- globalVersion: number;
855
- /**
856
- * @internal
857
- */
858
- isSSR: boolean;
859
- /**
860
- * @internal
861
- */
862
- next?: Subscriber;
863
- effect: this;
864
- onTrack?: (event: DebuggerEvent) => void;
865
- onTrigger?: (event: DebuggerEvent) => void;
866
- /**
867
- * Dev only
868
- * @internal
869
- */
870
- _warnRecursive?: boolean;
871
- constructor(fn: ComputedGetter<T>, setter: ComputedSetter<T> | undefined, isSSR: boolean);
872
- /**
873
- * @internal
874
- */
875
- notify(): true | void;
876
- get value(): T;
877
- set value(newValue: T);
878
- }
879
- /**
880
- * Takes a getter function and returns a readonly reactive ref object for the
881
- * returned value from the getter. It can also take an object with get and set
882
- * functions to create a writable ref object.
883
- *
884
- * @example
885
- * ```js
886
- * // Creating a readonly computed ref:
887
- * const count = ref(1)
888
- * const plusOne = computed(() => count.value + 1)
889
- *
890
- * console.log(plusOne.value) // 2
891
- * plusOne.value++ // error
892
- * ```
893
- *
894
- * ```js
895
- * // Creating a writable computed ref:
896
- * const count = ref(1)
897
- * const plusOne = computed({
898
- * get: () => count.value + 1,
899
- * set: (val) => {
900
- * count.value = val - 1
901
- * }
902
- * })
903
- *
904
- * plusOne.value = 1
905
- * console.log(count.value) // 0
906
- * ```
907
- *
908
- * @param getter - Function that produces the next value.
909
- * @param debugOptions - For debugging. See {@link https://vuejs.org/guide/extras/reactivity-in-depth.html#computed-debugging}.
910
- * @see {@link https://vuejs.org/api/reactivity-core.html#computed}
911
- */
912
- export declare function computed<T>(getter: ComputedGetter<T>, debugOptions?: DebuggerOptions): ComputedRef<T>;
913
- export declare function computed<T, S = T>(options: WritableComputedOptions<T, S>, debugOptions?: DebuggerOptions): WritableComputedRef<T, S>;
914
-
915
- declare function queueJob(job: () => void): void;
916
- declare function flushJobs(): void;
917
- export declare function nextTick(): Promise<void>;
918
-
919
- import type { ReactiveEffect } from './effect';
920
- declare let activeEffectScope: EffectScope | undefined;
921
- export declare class EffectScope {
922
- detached: boolean;
923
- /**
924
- * @internal
925
- */
926
- private _active;
927
- /**
928
- * @internal track `on` calls, allow `on` call multiple times
929
- */
930
- private _on;
931
- /**
932
- * @internal
933
- */
934
- effects: ReactiveEffect[];
935
- /**
936
- * @internal
937
- */
938
- cleanups: (() => void)[];
939
- private _isPaused;
940
- private _warnOnRun;
941
- /**
942
- * only assigned by undetached scope
943
- * @internal
944
- */
945
- parent: EffectScope | undefined;
946
- /**
947
- * record undetached scopes
948
- * @internal
949
- */
950
- scopes: EffectScope[] | undefined;
951
- /**
952
- * track a child scope's index in its parent's scopes array for optimized
953
- * removal
954
- * @internal
955
- */
956
- private index;
957
- readonly __v_skip = true;
958
- constructor(detached?: boolean);
959
- get active(): boolean;
960
- pause(): void;
961
- /**
962
- * Resumes the effect scope, including all child scopes and effects.
963
- */
964
- resume(): void;
965
- run<T>(fn: () => T): T | undefined;
966
- prevScope: EffectScope | undefined;
967
- /**
968
- * This should only be called on non-detached scopes
969
- * @internal
970
- */
971
- on(): void;
972
- /**
973
- * This should only be called on non-detached scopes
974
- * @internal
975
- */
976
- off(): void;
977
- stop(fromParent?: boolean): void;
978
- }
979
- /**
980
- * Creates an effect scope object which can capture the reactive effects (i.e.
981
- * computed and watchers) created within it so that these effects can be
982
- * disposed together. For detailed use cases of this API, please consult its
983
- * corresponding {@link https://github.com/vuejs/rfcs/blob/master/active-rfcs/0041-reactivity-effect-scope.md | RFC}.
984
- *
985
- * @param detached - Can be used to create a "detached" effect scope.
986
- * @see {@link https://vuejs.org/api/reactivity-advanced.html#effectscope}
987
- */
988
- export declare function effectScope(detached?: boolean): EffectScope;
989
- /**
990
- * Returns the current active effect scope if there is one.
991
- *
992
- * @see {@link https://vuejs.org/api/reactivity-advanced.html#getcurrentscope}
993
- */
994
- declare function getCurrentScope(): EffectScope | undefined;
995
- /**
996
- * Registers a dispose callback on the current active effect scope. The
997
- * callback will be invoked when the associated effect scope is stopped.
998
- *
999
- * @param fn - The callback function to attach to the scope's cleanup.
1000
- * @see {@link https://vuejs.org/api/reactivity-advanced.html#onscopedispose}
1001
- */
1002
- declare function onScopeDispose(fn: () => void, failSilently?: boolean): void;
1003
-
1004
- /**
1005
- * Track array iteration and return:
1006
- * - if input is reactive: a cloned raw array with reactive values
1007
- * - if input is non-reactive or shallowReactive: the original raw array
1008
- */
1009
- declare function reactiveReadArray<T>(array: T[]): T[];
1010
- /**
1011
- * Track array iteration and return raw array
1012
- */
1013
- declare function shallowReadArray<T>(arr: T[]): T[];
1014
- declare const arrayInstrumentations: Record<string | symbol, Function>;
1015
-
1016
- import { type DebuggerOptions, ReactiveEffect } from './effect';
1017
- import { type Ref } from './ref';
1018
- import type { ComputedRef } from './computed';
1019
- declare enum WatchErrorCodes {
1020
- WATCH_GETTER = 2,
1021
- WATCH_CALLBACK = 3,
1022
- WATCH_CLEANUP = 4
1023
- }
1024
- type WatchEffect = (onCleanup: OnCleanup) => void;
1025
- type WatchSource<T = any> = Ref<T, any> | ComputedRef<T> | (() => T);
1026
- type WatchCallback<V = any, OV = any> = (value: V, oldValue: OV, onCleanup: OnCleanup) => any;
1027
- type OnCleanup = (cleanupFn: () => void) => void;
1028
- export interface WatchOptions<Immediate = boolean> extends DebuggerOptions {
1029
- immediate?: Immediate;
1030
- deep?: boolean | number;
1031
- once?: boolean;
1032
- scheduler?: WatchScheduler;
1033
- onWarn?: (msg: string, ...args: any[]) => void;
1034
- /**
1035
- * @internal
1036
- */
1037
- augmentJob?: (job: (...args: any[]) => void) => void;
1038
- /**
1039
- * @internal
1040
- */
1041
- call?: (fn: Function | Function[], type: WatchErrorCodes, args?: unknown[]) => void;
1042
- }
1043
- type WatchStopHandle = () => void;
1044
- export interface WatchHandle extends WatchStopHandle {
1045
- pause: () => void;
1046
- resume: () => void;
1047
- stop: () => void;
1048
- }
1049
- type WatchScheduler = (job: () => void, isFirstRun: boolean) => void;
1050
- /**
1051
- * Returns the current active effect if there is one.
1052
- */
1053
- declare function getCurrentWatcher(): ReactiveEffect<any> | undefined;
1054
- /**
1055
- * Registers a cleanup callback on the current active effect. This
1056
- * registered cleanup callback will be invoked right before the
1057
- * associated effect re-runs.
1058
- *
1059
- * @param cleanupFn - The callback function to attach to the effect's cleanup.
1060
- * @param failSilently - if `true`, will not throw warning when called without
1061
- * an active effect.
1062
- * @param owner - The effect that this cleanup function should be attached to.
1063
- * By default, the current active effect.
1064
- */
1065
- declare function onWatcherCleanup(cleanupFn: () => void, failSilently?: boolean, owner?: ReactiveEffect | undefined): void;
1066
- export declare function watch(source: WatchSource | WatchSource[] | WatchEffect | object, cb?: WatchCallback | null, options?: WatchOptions): WatchHandle;
1067
- declare function traverse(value: unknown, depth?: number, seen?: Map<unknown, number>): unknown;
1068
-
1069
- export declare function onCleanup(fn: () => void): void;
1070
-
1071
- type JSXPrimitive = string | number | boolean | null | undefined;
1072
- export type JSXValue = JSXPrimitive | Node | JSXValue[];
1073
- type JSXGetter = () => JSXValue;
1074
- export type Component<P extends Record<string, unknown> = Record<string, unknown>> = (props: P) => JSXValue;
1075
- type TemplateFactory<T extends Node = Node> = () => T;
1076
- type AttrValue = string | number | boolean | null | undefined;
1077
- type ClassValue = string | null | undefined | false | Record<string, boolean | null | undefined> | Array<ClassValue>;
1078
- type StyleValue = string | null | undefined | Partial<CSSStyleDeclaration> | Record<string, string | number | null | undefined>;
1079
- type RefTarget<T> = ((value: T | null) => void) | {
1080
- value: T | null;
1081
- } | {
1082
- current: T | null;
1083
- };
1084
-
1085
- import type { TemplateFactory } from './types';
1086
- declare function template<T extends Node = Node>(html: string, _isImportNode?: boolean, _isSVG?: boolean, _isMathML?: boolean): TemplateFactory<T>;
1087
-
1088
- import type { JSXValue } from './types';
1089
- type ContextId = symbol;
1090
- export interface Context<T = unknown> {
1091
- readonly id: ContextId;
1092
- /**
1093
- * The default value passed to createContext().
1094
- *
1095
- * Note:
1096
- * - `defaultValue` itself may be `undefined`.
1097
- * - Use `hasDefaultValue` to check whether a default value was provided.
1098
- */
1099
- readonly defaultValue: T | undefined;
1100
- readonly hasDefaultValue: boolean;
1101
- readonly Provider: ContextProvider<T>;
1102
- readonly Bridge: ContextBridge<T>;
1103
- }
1104
- export interface ContextProviderProps<T> {
1105
- value: T;
1106
- children?: JSXValue | (() => JSXValue);
1107
- /**
1108
- * When true, creates a DOM context boundary for native custom elements /
1109
- * Web Components that live outside the Zeus owner tree.
1110
- */
1111
- bridge?: boolean;
1112
- }
1113
- export interface ContextBridgeProps<T> {
1114
- value: T;
1115
- children?: JSXValue | (() => JSXValue);
1116
- }
1117
- type ContextProvider<T> = (props: ContextProviderProps<T>) => JSXValue;
1118
- type ContextBridge<T> = (props: ContextBridgeProps<T>) => JSXValue;
1119
- interface Owner {
1120
- parent?: Owner;
1121
- provides: Map<ContextId, unknown>;
1122
- }
1123
- declare function getCurrentOwner(): Owner | undefined;
1124
- declare function createOwner(parent?: Owner | undefined): Owner;
1125
- declare function runWithOwner<T>(owner: Owner | undefined, fn: () => T): T;
1126
- /**
1127
- * @internal
1128
- *
1129
- * Avoid using this in normal code.
1130
- * Most runtime paths should use runWithOwner() so owner restoration is guaranteed.
1131
- */
1132
- declare function setCurrentOwner(owner: Owner | undefined): void;
1133
- export declare function createContext<T>(): Context<T>;
1134
- export declare function createContext<T>(defaultValue: T): Context<T>;
1135
- export declare function provide<T>(context: Context<T>, value: T): void;
1136
- export declare function inject<T>(context: Context<T>): T;
1137
- export declare function inject<T>(context: Context<T>, fallback: T): T;
1138
- export declare function useContext<T>(context: Context<T>): T;
1139
- export declare function useContext<T>(context: Context<T>, fallback: T): T;
1140
- declare const ZEUS_CONTEXT_REQUEST = "zeus:context-request";
1141
- interface ZeusContextRequestDetail<T = unknown> {
1142
- id: ContextId;
1143
- resolved: boolean;
1144
- value?: T;
1145
- resolve: (value: T) => void;
1146
- }
1147
- type ZeusContextRequestEvent<T = unknown> = CustomEvent<ZeusContextRequestDetail<T>>;
1148
- interface DOMContextResolution<T> {
1149
- found: boolean;
1150
- value: T | undefined;
1151
- }
1152
- /**
1153
- * Creates a transparent DOM element that acts as a context boundary.
1154
- * Native custom elements inside it can use `requestDOMContext` to receive
1155
- * context values via the DOM event protocol.
1156
- */
1157
- declare function createDOMContextBoundary<T>(context: Context<T>, value: T, children: JSXValue): Element;
1158
- /**
1159
- * Registers a context value on a DOM target so that any descendant custom
1160
- * element can pick it up via `requestDOMContext`.
1161
- */
1162
- declare function provideDOMContext<T>(target: EventTarget, context: Context<T>, value: T): void;
1163
- /**
1164
- * Internal precise DOM context resolver.
1165
- *
1166
- * Unlike requestDOMContext(), this can distinguish:
1167
- * - found: false, value: undefined
1168
- * - found: true, value: undefined
1169
- */
1170
- declare function resolveDOMContext<T>(host: HTMLElement, context: Context<T>): DOMContextResolution<T>;
1171
- /**
1172
- * Public compatibility API.
1173
- *
1174
- * Returns the resolved value if found, otherwise undefined.
1175
- * If you need to distinguish "not found" from "found undefined",
1176
- * use resolveDOMContext().
1177
- */
1178
- declare function requestDOMContext<T>(host: HTMLElement, context: Context<T>): T | undefined;
1179
-
1180
- import { createOwner } from './context';
1181
- import type { JSXValue } from './types';
1182
- interface RenderOptions {
1183
- owner?: ReturnType<typeof createOwner>;
1184
- }
1185
- export declare function render(value: JSXValue | (() => JSXValue), container: Element | DocumentFragment, options?: RenderOptions): () => void;
1186
-
1187
- import type { JSXValue } from './types';
1188
- declare class DynamicRange {
1189
- private readonly parent;
1190
- private readonly marker;
1191
- private nodes;
1192
- constructor(parent: Node, marker: Node | null);
1193
- replace(value: JSXValue): void;
1194
- clear(): void;
1195
- current(): readonly Node[];
1196
- }
1197
- declare function insertTracked(parent: Node, value: JSXValue, marker: Node | null): Node[];
1198
- declare function removeNodes(nodes: readonly Node[]): void;
1199
- declare function moveRangeBefore(nodes: readonly Node[], parent: Node, marker: Node | null): void;
1200
- declare function firstNode(nodes: readonly Node[]): Node | null;
1201
- declare function lastNode(nodes: readonly Node[]): Node | null;
1202
-
1203
- import { insertTracked } from './range';
1204
- import type { JSXValue } from './types';declare function insert(parent: Node, value: JSXValue, marker?: Node | null): void;
1205
- declare function mountDynamic(parent: Node, marker: Node, value: () => JSXValue): void;
1206
-
1207
- declare function marker(parent: ParentNode, index: number): Comment;
1208
- declare function child(parent: ParentNode, index: number): ChildNode;
1209
- declare function removeNodes$1(nodes: readonly Node[]): void;
1210
-
1211
- import type { AttrValue, ClassValue, JSXValue, StyleValue } from './types';
1212
- declare function bindText(node: Text, value: () => JSXValue): void;
1213
- declare function bindTextContent(el: Node, value: () => JSXValue): void;
1214
- declare function setAttr(el: Element, name: string, value: AttrValue): void;
1215
- declare function bindAttr(el: Element, name: string, value: () => AttrValue): void;
1216
- declare function bindProp<T extends Element, K extends keyof T>(el: T, name: K, value: () => T[K]): void;
1217
- declare function bindClass(el: Element, value: () => ClassValue): void;
1218
- declare function normalizeClass(value: ClassValue): string;
1219
- declare function bindStyle(el: HTMLElement | SVGElement, value: () => StyleValue): void;
1220
-
1221
- declare function bindEvent(el: Element, name: string, handler: EventListener): void;
1222
- declare function delegateEvents(events: readonly string[]): void;
1223
- declare function resetDelegatedEvents(): void;
1224
-
1225
- import type { RefTarget } from './types';
1226
- declare function setRef<T>(target: RefTarget<T> | null | undefined, value: T | null): void;
1227
- declare function bindRef<T extends Element>(el: T, target: RefTarget<T> | null | undefined): void;
1228
-
1229
- import type { JSXValue } from './types';
1230
- declare function createComponent<P extends Record<string, unknown>, R extends JSXValue>(component: (props: P) => R, props: P): R;
1231
-
1232
- import type { JSXValue } from './types';
1233
- export type ShowProps = {
1234
- when: unknown;
1235
- fallback?: JSXValue | (() => JSXValue);
1236
- children?: JSXValue | (() => JSXValue);
1237
- };
1238
- export declare function Show(props: ShowProps): JSXValue;
1239
- declare function resolveValue(value: JSXValue | (() => JSXValue) | undefined): JSXValue;
1240
- declare function mountShow(parent: Node, marker: Node, when: () => unknown, children: () => JSXValue, fallback?: () => JSXValue): void;
1241
- export type ForProps<T, K = unknown> = {
1242
- each: readonly T[] | null | undefined;
1243
- by?: (item: T, index: number) => K;
1244
- children: (item: T, index: number) => JSXValue;
1245
- };
1246
- export declare function For<T, K = unknown>(props: ForProps<T, K>): JSXValue;
1247
- declare function mountFor<T, K = unknown>(parent: Node, marker: Node, each: () => readonly T[] | null | undefined, key: ((item: T, index: number) => K) | undefined, render: (item: T, index: number) => JSXValue): void;
1248
-
1249
- import type { Context } from './context';
1250
- import type { JSXValue } from './types';
1251
- type ElementPropConstructor = StringConstructor | NumberConstructor | BooleanConstructor | ObjectConstructor | ArrayConstructor;
1252
- type PropDefinition<T = unknown> = ElementPropConstructor | {
1253
- type?: ElementPropConstructor;
1254
- attr?: string | false;
1255
- reflect?: boolean;
1256
- default?: T | (() => T);
1257
- };
1258
- type PropOptions<P extends Record<string, unknown>> = Partial<{
1259
- [K in keyof P]: PropDefinition<P[K]>;
1260
- }>;
1261
- export interface DefineElementOptions<P extends Record<string, unknown>> {
1262
- shadow?: boolean | ShadowRootInit;
1263
- props?: PropOptions<P>;
1264
- styles?: string | string[];
1265
- consumes?: Context<any>[];
1266
- }
1267
- export interface DefineElementContext<E extends HTMLElement = HTMLElement> {
1268
- host: E;
1269
- emit: (name: string, detail?: unknown, options?: CustomEventInit) => boolean;
1270
- }
1271
- export type DefineElementSetup<P extends Record<string, unknown>, E extends HTMLElement = HTMLElement> = (props: Readonly<P>, context: DefineElementContext<E>) => JSXValue;
1272
- export declare function defineElement<P extends Record<string, unknown> = Record<string, unknown>, E extends HTMLElement = HTMLElement>(tagName: string, options: DefineElementOptions<P>, setup: DefineElementSetup<P, E>): CustomElementConstructor;
1273
-
1274
- import type { JSXValue } from './types';
1275
- export interface HostProps {
1276
- children?: JSXValue | (() => JSXValue);
1277
- }
1278
- export interface SlotProps {
1279
- name?: string;
1280
- children?: JSXValue | (() => JSXValue);
1281
- }
1282
- export declare function Host(props: HostProps): JSXValue;
1283
- export declare function Slot(props: SlotProps): JSXValue;
1284
-
1285
- import type { JSXValue } from './types';
1286
- declare function createSlot(name?: string, fallback?: () => JSXValue): JSXValue;
1287
-
1288
- type HostRenderMode = 'light' | 'shadow';
1289
- interface HostRenderContext {
1290
- host: HTMLElement;
1291
- mode: HostRenderMode;
1292
- lightChildren: readonly Node[];
1293
- }
1294
- declare function getCurrentHostContext(): HostRenderContext | undefined;
1295
- declare function withHostContext<T>(context: HostRenderContext | undefined, fn: () => T): T;
1296
- declare function captureCurrentHostContext(): HostRenderContext | undefined;
1297
- declare function withCapturedHostContext<T extends (...args: never[]) => unknown>(fn: T): T;
1298
-
1299
- import './types';
1300
-
1301
- import { type JSXValue } from '@zeus-js/runtime-dom';
1302
- export declare const Fragment: unique symbol;export declare function jsx(type: string | ((props: Record<string, unknown>) => JSXValue), props: Record<string, unknown> | null): JSXValue;
1303
- export declare function jsxs(type: string | ((props: Record<string, unknown>) => JSXValue), props: Record<string, unknown> | null): JSXValue;
1304
- export declare function jsxDEV(type: string | ((props: Record<string, unknown>) => JSXValue), props: Record<string, unknown> | null): JSXValue;
1305
-
1306
- export { EffectScope as Scope, effectScope as scope, };
7
+ export declare function jsx(type: string | typeof Fragment | ((props: Record<string, unknown>) => JSXValue), props: Record<string, unknown> | null): JSXValue;
8
+ export declare function jsxs(type: string | typeof Fragment | ((props: Record<string, unknown>) => JSXValue), props: Record<string, unknown> | null): JSXValue;
9
+ export declare function jsxDEV(type: string | typeof Fragment | ((props: Record<string, unknown>) => JSXValue), props: Record<string, unknown> | null): JSXValue;
1307
10