voodoojs 0.4.6

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 (54) hide show
  1. package/README.md +77 -0
  2. package/dist/chunk-234ZLC6W.js +401 -0
  3. package/dist/chunk-4HQEOXTK.js +10271 -0
  4. package/dist/chunk-5777LJVW.js +64 -0
  5. package/dist/chunk-5CKGDARU.js +1845 -0
  6. package/dist/chunk-A2UOVQBP.js +82 -0
  7. package/dist/chunk-E27NRARW.js +16 -0
  8. package/dist/chunk-JZIYRIY6.js +1196 -0
  9. package/dist/chunk-NNU6WOOU.js +641 -0
  10. package/dist/chunk-PQZEVFVZ.js +448 -0
  11. package/dist/chunk-RJUNPXQF.js +946 -0
  12. package/dist/chunk-U76IRJKH.js +72 -0
  13. package/dist/essential.cjs +13889 -0
  14. package/dist/essential.d.cts +24 -0
  15. package/dist/essential.d.ts +24 -0
  16. package/dist/essential.js +51 -0
  17. package/dist/gpu.cjs +2008 -0
  18. package/dist/gpu.d.cts +68 -0
  19. package/dist/gpu.d.ts +68 -0
  20. package/dist/gpu.js +273 -0
  21. package/dist/http.cjs +467 -0
  22. package/dist/http.d.cts +148 -0
  23. package/dist/http.d.ts +148 -0
  24. package/dist/http.js +7 -0
  25. package/dist/index-CaLD-0oh.d.cts +608 -0
  26. package/dist/index-CaLD-0oh.d.ts +608 -0
  27. package/dist/index-DTllqUtj.d.cts +261 -0
  28. package/dist/index-DTllqUtj.d.ts +261 -0
  29. package/dist/index.cjs +23063 -0
  30. package/dist/index.d.cts +1603 -0
  31. package/dist/index.d.ts +1603 -0
  32. package/dist/index.js +6924 -0
  33. package/dist/query-CKJ4oSpG.d.cts +1595 -0
  34. package/dist/query-DQFRmu3u.d.ts +1595 -0
  35. package/dist/reactivity.cjs +676 -0
  36. package/dist/reactivity.d.cts +188 -0
  37. package/dist/reactivity.d.ts +188 -0
  38. package/dist/reactivity.js +4 -0
  39. package/dist/socket.cjs +2685 -0
  40. package/dist/socket.d.cts +167 -0
  41. package/dist/socket.d.ts +167 -0
  42. package/dist/socket.js +238 -0
  43. package/dist/style-XEUAGGJK.js +5 -0
  44. package/dist/utils.cjs +397 -0
  45. package/dist/utils.d.cts +111 -0
  46. package/dist/utils.d.ts +111 -0
  47. package/dist/utils.js +4 -0
  48. package/dist/voodoo.core.js +8213 -0
  49. package/dist/voodoo.core.min.js +146 -0
  50. package/dist/voodoo.full.js +21193 -0
  51. package/dist/voodoo.full.min.js +1784 -0
  52. package/dist/voodoo.js +14185 -0
  53. package/dist/voodoo.min.js +420 -0
  54. package/package.json +127 -0
@@ -0,0 +1,188 @@
1
+ /**
2
+ * @module reactivity
3
+ *
4
+ * The reactive core of Voodoo.js.
5
+ *
6
+ * The model: a Proxy plus per-key dependency tracking, scheduled on a
7
+ * microtask. There is no Virtual DOM. When `count` changes, only the effects
8
+ * that read `count` re-run, and each effect updates only the DOM node it wrote
9
+ * itself.
10
+ *
11
+ * This module never touches the DOM and never assumes `window`, so it runs on
12
+ * Node, Bun and Deno with no adaptation.
13
+ */
14
+ type Dep = Set<ReactiveEffect>;
15
+ type EffectScheduler = () => void;
16
+ interface EffectOptions {
17
+ /** Runs instead of the effect itself when a dependency changes. */
18
+ scheduler?: EffectScheduler;
19
+ /** Does not run immediately on creation. */
20
+ lazy?: boolean;
21
+ /** Called when the effect is stopped. */
22
+ onStop?: () => void;
23
+ /** The scope that owns the effect, for automatic cleanup. */
24
+ scope?: EffectScope;
25
+ }
26
+ interface Ref<T = any> {
27
+ value: T;
28
+ readonly __v_isRef: true;
29
+ }
30
+ interface ComputedRef<T = any> extends Ref<T> {
31
+ readonly value: T;
32
+ readonly effect: ReactiveEffect;
33
+ }
34
+ interface WatchOptions {
35
+ immediate?: boolean;
36
+ deep?: boolean;
37
+ flush?: 'pre' | 'post' | 'sync';
38
+ }
39
+ type WatchStopHandle = () => void;
40
+ /**
41
+ * Resolves once the queue of updates has been applied to the DOM.
42
+ *
43
+ * ```js
44
+ * count.value++
45
+ * await V.nextTick()
46
+ * // the DOM already reflects the change
47
+ * ```
48
+ */
49
+ declare function nextTick<T = void>(fn?: () => T): Promise<T | void>;
50
+ declare function queueJob(job: ReactiveEffect): void;
51
+ /** Schedules a callback to run after the DOM has been updated. */
52
+ declare function queuePostFlush(cb: () => void): void;
53
+ /** Applies everything still pending right away. Useful in tests. */
54
+ declare function flushSync(): void;
55
+ type ErrorHandler = (err: unknown, context: string) => void;
56
+ declare function setErrorHandler(fn: ErrorHandler | null): void;
57
+ declare function handleError(err: unknown, context: string): void;
58
+ declare function warn(msg: string, ...args: unknown[]): void;
59
+ declare function pauseTracking(): void;
60
+ declare function enableTracking(): void;
61
+ declare function resetTracking(): void;
62
+ declare function getActiveEffect(): ReactiveEffect | undefined;
63
+ /**
64
+ * Why every field here is `declare`d and then assigned in the constructor.
65
+ *
66
+ * The package compiles with `useDefineForClassFields`, and the build target is
67
+ * below the level where class fields exist natively, so a field written as
68
+ * `active = true` is emitted as an `Object.defineProperty` call. This class is
69
+ * built once per binding on the page — one per row of a list, thousands of times
70
+ * on a real screen — and the CPU profile of a thousand-row build showed the
71
+ * define helper alone above one percent of total time. `declare` removes the
72
+ * emitted definition, the constructor creates the same own, writable,
73
+ * enumerable, configurable properties by plain assignment, and the assignment
74
+ * order is kept identical so the object shape does not change.
75
+ */
76
+ declare class ReactiveEffect<T = any> {
77
+ readonly id: number;
78
+ active: boolean;
79
+ /** `true` while the effect is waiting in the scheduler queue. */
80
+ queued: boolean;
81
+ deps: Dep[];
82
+ parent: ReactiveEffect | undefined;
83
+ scheduler: EffectScheduler | undefined;
84
+ onStop: (() => void) | undefined;
85
+ /** Cleanup callbacks registered by the effect itself. */
86
+ cleanups: Array<() => void>;
87
+ fn: () => T;
88
+ constructor(fn: () => T, options?: EffectOptions);
89
+ run(): T | undefined;
90
+ /** Registers a function called before the next run and on stop. */
91
+ onInvalidate(fn: () => void): void;
92
+ private runCleanups;
93
+ stop(): void;
94
+ }
95
+ interface EffectRunner<T = any> {
96
+ (): T | undefined;
97
+ effect: ReactiveEffect<T>;
98
+ }
99
+ /**
100
+ * Creates a reactive effect. Runs once on creation and re-runs whenever any
101
+ * state read inside it changes.
102
+ *
103
+ * ```js
104
+ * const state = V.reactive({ count: 0 })
105
+ * V.effect(() => console.log(state.count))
106
+ * state.count++ // triggers the log
107
+ * ```
108
+ */
109
+ declare function effect<T = any>(fn: () => T, options?: EffectOptions): EffectRunner<T>;
110
+ declare function stop(runner: EffectRunner | ReactiveEffect): void;
111
+ /** Fields are `declare`d and assigned in the constructor for the reason given on `ReactiveEffect`. */
112
+ declare class EffectScope {
113
+ effects: ReactiveEffect[];
114
+ cleanups: Array<() => void>;
115
+ children: EffectScope[];
116
+ active: boolean;
117
+ parent: EffectScope | undefined;
118
+ constructor(detached?: boolean);
119
+ run<T>(fn: () => T): T | undefined;
120
+ onDispose(fn: () => void): void;
121
+ stop(): void;
122
+ }
123
+ declare function effectScope(detached?: boolean): EffectScope;
124
+ declare function getActiveScope(): EffectScope | undefined;
125
+ declare const ITERATE_KEY: unique symbol;
126
+ declare function track(target: object, key: PropertyKey): void;
127
+ declare const enum TriggerType {
128
+ SET = "set",
129
+ ADD = "add",
130
+ DELETE = "delete",
131
+ CLEAR = "clear"
132
+ }
133
+ declare function trigger(target: object, type: TriggerType, key?: PropertyKey, _newValue?: unknown): void;
134
+ /** Marks an object so it is never turned into a reactive proxy. */
135
+ declare function markRaw<T extends object>(value: T): T;
136
+ /** Returns the original object behind a reactive proxy. */
137
+ declare function toRaw<T>(observed: T): T;
138
+ declare function isReactive(value: unknown): boolean;
139
+ /**
140
+ * Makes an object deeply reactive.
141
+ *
142
+ * ```js
143
+ * const state = V.reactive({ user: { name: 'Ana' }, tags: [] })
144
+ * state.user.name = 'Bia' // triggers effects that read user.name
145
+ * state.tags.push('novo') // triggers effects that read tags
146
+ * ```
147
+ */
148
+ declare function reactive<T extends object>(target: T): T;
149
+ declare function hasChanged(value: unknown, oldValue: unknown): boolean;
150
+ declare function isRef<T>(r: unknown): r is Ref<T>;
151
+ /**
152
+ * Reactive reference for primitive values.
153
+ *
154
+ * ```js
155
+ * const count = V.ref(0)
156
+ * V.effect(() => console.log(count.value))
157
+ * count.value++
158
+ * ```
159
+ */
160
+ declare function ref<T>(value: T): Ref<T>;
161
+ declare function shallowRef<T>(value: T): Ref<T>;
162
+ declare function unref<T>(value: T | Ref<T>): T;
163
+ /**
164
+ * Derived value with cache. Only recalculates when a dependency changes.
165
+ *
166
+ * ```js
167
+ * const full = V.computed(() => `${state.first} ${state.last}`)
168
+ * full.value
169
+ * ```
170
+ */
171
+ declare function computed<T>(getterOrOptions: (() => T) | {
172
+ get: () => T;
173
+ set: (v: T) => void;
174
+ }): ComputedRef<T>;
175
+ type WatchSource<T = any> = Ref<T> | (() => T) | object;
176
+ type WatchCallback<T = any> = (value: T, oldValue: T | undefined, onInvalidate: (fn: () => void) => void) => void;
177
+ /**
178
+ * Watches a reactive source and calls the callback when it changes.
179
+ *
180
+ * ```js
181
+ * V.watch(() => state.search, (newValue, oldValue) => search(newValue))
182
+ * ```
183
+ */
184
+ declare function watch<T>(source: WatchSource<T>, cb: WatchCallback<T>, options?: WatchOptions): WatchStopHandle;
185
+ /** Executes the effect immediately and re-executes when dependencies change. */
186
+ declare function watchEffect(fn: (onInvalidate: (c: () => void) => void) => void): WatchStopHandle;
187
+
188
+ export { type ComputedRef, type Dep, type EffectOptions, type EffectRunner, type EffectScheduler, EffectScope, ITERATE_KEY, ReactiveEffect, type Ref, TriggerType, type WatchCallback, type WatchOptions, type WatchSource, type WatchStopHandle, computed, effect, effectScope, enableTracking, flushSync, getActiveEffect, getActiveScope, handleError, hasChanged, isReactive, isRef, markRaw, nextTick, pauseTracking, queueJob, queuePostFlush, reactive, ref, resetTracking, setErrorHandler, shallowRef, stop, toRaw, track, trigger, unref, warn, watch, watchEffect };
@@ -0,0 +1,188 @@
1
+ /**
2
+ * @module reactivity
3
+ *
4
+ * The reactive core of Voodoo.js.
5
+ *
6
+ * The model: a Proxy plus per-key dependency tracking, scheduled on a
7
+ * microtask. There is no Virtual DOM. When `count` changes, only the effects
8
+ * that read `count` re-run, and each effect updates only the DOM node it wrote
9
+ * itself.
10
+ *
11
+ * This module never touches the DOM and never assumes `window`, so it runs on
12
+ * Node, Bun and Deno with no adaptation.
13
+ */
14
+ type Dep = Set<ReactiveEffect>;
15
+ type EffectScheduler = () => void;
16
+ interface EffectOptions {
17
+ /** Runs instead of the effect itself when a dependency changes. */
18
+ scheduler?: EffectScheduler;
19
+ /** Does not run immediately on creation. */
20
+ lazy?: boolean;
21
+ /** Called when the effect is stopped. */
22
+ onStop?: () => void;
23
+ /** The scope that owns the effect, for automatic cleanup. */
24
+ scope?: EffectScope;
25
+ }
26
+ interface Ref<T = any> {
27
+ value: T;
28
+ readonly __v_isRef: true;
29
+ }
30
+ interface ComputedRef<T = any> extends Ref<T> {
31
+ readonly value: T;
32
+ readonly effect: ReactiveEffect;
33
+ }
34
+ interface WatchOptions {
35
+ immediate?: boolean;
36
+ deep?: boolean;
37
+ flush?: 'pre' | 'post' | 'sync';
38
+ }
39
+ type WatchStopHandle = () => void;
40
+ /**
41
+ * Resolves once the queue of updates has been applied to the DOM.
42
+ *
43
+ * ```js
44
+ * count.value++
45
+ * await V.nextTick()
46
+ * // the DOM already reflects the change
47
+ * ```
48
+ */
49
+ declare function nextTick<T = void>(fn?: () => T): Promise<T | void>;
50
+ declare function queueJob(job: ReactiveEffect): void;
51
+ /** Schedules a callback to run after the DOM has been updated. */
52
+ declare function queuePostFlush(cb: () => void): void;
53
+ /** Applies everything still pending right away. Useful in tests. */
54
+ declare function flushSync(): void;
55
+ type ErrorHandler = (err: unknown, context: string) => void;
56
+ declare function setErrorHandler(fn: ErrorHandler | null): void;
57
+ declare function handleError(err: unknown, context: string): void;
58
+ declare function warn(msg: string, ...args: unknown[]): void;
59
+ declare function pauseTracking(): void;
60
+ declare function enableTracking(): void;
61
+ declare function resetTracking(): void;
62
+ declare function getActiveEffect(): ReactiveEffect | undefined;
63
+ /**
64
+ * Why every field here is `declare`d and then assigned in the constructor.
65
+ *
66
+ * The package compiles with `useDefineForClassFields`, and the build target is
67
+ * below the level where class fields exist natively, so a field written as
68
+ * `active = true` is emitted as an `Object.defineProperty` call. This class is
69
+ * built once per binding on the page — one per row of a list, thousands of times
70
+ * on a real screen — and the CPU profile of a thousand-row build showed the
71
+ * define helper alone above one percent of total time. `declare` removes the
72
+ * emitted definition, the constructor creates the same own, writable,
73
+ * enumerable, configurable properties by plain assignment, and the assignment
74
+ * order is kept identical so the object shape does not change.
75
+ */
76
+ declare class ReactiveEffect<T = any> {
77
+ readonly id: number;
78
+ active: boolean;
79
+ /** `true` while the effect is waiting in the scheduler queue. */
80
+ queued: boolean;
81
+ deps: Dep[];
82
+ parent: ReactiveEffect | undefined;
83
+ scheduler: EffectScheduler | undefined;
84
+ onStop: (() => void) | undefined;
85
+ /** Cleanup callbacks registered by the effect itself. */
86
+ cleanups: Array<() => void>;
87
+ fn: () => T;
88
+ constructor(fn: () => T, options?: EffectOptions);
89
+ run(): T | undefined;
90
+ /** Registers a function called before the next run and on stop. */
91
+ onInvalidate(fn: () => void): void;
92
+ private runCleanups;
93
+ stop(): void;
94
+ }
95
+ interface EffectRunner<T = any> {
96
+ (): T | undefined;
97
+ effect: ReactiveEffect<T>;
98
+ }
99
+ /**
100
+ * Creates a reactive effect. Runs once on creation and re-runs whenever any
101
+ * state read inside it changes.
102
+ *
103
+ * ```js
104
+ * const state = V.reactive({ count: 0 })
105
+ * V.effect(() => console.log(state.count))
106
+ * state.count++ // triggers the log
107
+ * ```
108
+ */
109
+ declare function effect<T = any>(fn: () => T, options?: EffectOptions): EffectRunner<T>;
110
+ declare function stop(runner: EffectRunner | ReactiveEffect): void;
111
+ /** Fields are `declare`d and assigned in the constructor for the reason given on `ReactiveEffect`. */
112
+ declare class EffectScope {
113
+ effects: ReactiveEffect[];
114
+ cleanups: Array<() => void>;
115
+ children: EffectScope[];
116
+ active: boolean;
117
+ parent: EffectScope | undefined;
118
+ constructor(detached?: boolean);
119
+ run<T>(fn: () => T): T | undefined;
120
+ onDispose(fn: () => void): void;
121
+ stop(): void;
122
+ }
123
+ declare function effectScope(detached?: boolean): EffectScope;
124
+ declare function getActiveScope(): EffectScope | undefined;
125
+ declare const ITERATE_KEY: unique symbol;
126
+ declare function track(target: object, key: PropertyKey): void;
127
+ declare const enum TriggerType {
128
+ SET = "set",
129
+ ADD = "add",
130
+ DELETE = "delete",
131
+ CLEAR = "clear"
132
+ }
133
+ declare function trigger(target: object, type: TriggerType, key?: PropertyKey, _newValue?: unknown): void;
134
+ /** Marks an object so it is never turned into a reactive proxy. */
135
+ declare function markRaw<T extends object>(value: T): T;
136
+ /** Returns the original object behind a reactive proxy. */
137
+ declare function toRaw<T>(observed: T): T;
138
+ declare function isReactive(value: unknown): boolean;
139
+ /**
140
+ * Makes an object deeply reactive.
141
+ *
142
+ * ```js
143
+ * const state = V.reactive({ user: { name: 'Ana' }, tags: [] })
144
+ * state.user.name = 'Bia' // triggers effects that read user.name
145
+ * state.tags.push('novo') // triggers effects that read tags
146
+ * ```
147
+ */
148
+ declare function reactive<T extends object>(target: T): T;
149
+ declare function hasChanged(value: unknown, oldValue: unknown): boolean;
150
+ declare function isRef<T>(r: unknown): r is Ref<T>;
151
+ /**
152
+ * Reactive reference for primitive values.
153
+ *
154
+ * ```js
155
+ * const count = V.ref(0)
156
+ * V.effect(() => console.log(count.value))
157
+ * count.value++
158
+ * ```
159
+ */
160
+ declare function ref<T>(value: T): Ref<T>;
161
+ declare function shallowRef<T>(value: T): Ref<T>;
162
+ declare function unref<T>(value: T | Ref<T>): T;
163
+ /**
164
+ * Derived value with cache. Only recalculates when a dependency changes.
165
+ *
166
+ * ```js
167
+ * const full = V.computed(() => `${state.first} ${state.last}`)
168
+ * full.value
169
+ * ```
170
+ */
171
+ declare function computed<T>(getterOrOptions: (() => T) | {
172
+ get: () => T;
173
+ set: (v: T) => void;
174
+ }): ComputedRef<T>;
175
+ type WatchSource<T = any> = Ref<T> | (() => T) | object;
176
+ type WatchCallback<T = any> = (value: T, oldValue: T | undefined, onInvalidate: (fn: () => void) => void) => void;
177
+ /**
178
+ * Watches a reactive source and calls the callback when it changes.
179
+ *
180
+ * ```js
181
+ * V.watch(() => state.search, (newValue, oldValue) => search(newValue))
182
+ * ```
183
+ */
184
+ declare function watch<T>(source: WatchSource<T>, cb: WatchCallback<T>, options?: WatchOptions): WatchStopHandle;
185
+ /** Executes the effect immediately and re-executes when dependencies change. */
186
+ declare function watchEffect(fn: (onInvalidate: (c: () => void) => void) => void): WatchStopHandle;
187
+
188
+ export { type ComputedRef, type Dep, type EffectOptions, type EffectRunner, type EffectScheduler, EffectScope, ITERATE_KEY, ReactiveEffect, type Ref, TriggerType, type WatchCallback, type WatchOptions, type WatchSource, type WatchStopHandle, computed, effect, effectScope, enableTracking, flushSync, getActiveEffect, getActiveScope, handleError, hasChanged, isReactive, isRef, markRaw, nextTick, pauseTracking, queueJob, queuePostFlush, reactive, ref, resetTracking, setErrorHandler, shallowRef, stop, toRaw, track, trigger, unref, warn, watch, watchEffect };
@@ -0,0 +1,4 @@
1
+ export { EffectScope, ITERATE_KEY, ReactiveEffect, TriggerType, computed, effect, effectScope, enableTracking, flushSync, getActiveEffect, getActiveScope, handleError, hasChanged, isReactive, isRef, markRaw, nextTick, pauseTracking, queueJob, queuePostFlush, reactive, ref, resetTracking, setErrorHandler, shallowRef, stop, toRaw, track, trigger, unref, warn, watch, watchEffect } from './chunk-NNU6WOOU.js';
2
+ import './chunk-E27NRARW.js';
3
+ //# sourceMappingURL=reactivity.js.map
4
+ //# sourceMappingURL=reactivity.js.map