@lytjs/reactivity 5.0.1 → 6.4.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 (56) hide show
  1. package/README.md +327 -202
  2. package/dist/async.cjs +276 -0
  3. package/dist/async.cjs.map +1 -0
  4. package/dist/async.d.cts +32 -0
  5. package/dist/async.d.ts +32 -0
  6. package/dist/async.mjs +273 -0
  7. package/dist/async.mjs.map +1 -0
  8. package/dist/index.cjs +1679 -1
  9. package/dist/index.cjs.map +1 -0
  10. package/dist/index.d.cts +226 -0
  11. package/dist/index.d.ts +226 -0
  12. package/dist/index.mjs +1612 -1
  13. package/dist/index.mjs.map +1 -0
  14. package/dist/ref-CwOCKoy2.d.cts +42 -0
  15. package/dist/ref-CwOCKoy2.d.ts +42 -0
  16. package/dist/scope-BC3djHz7.d.cts +345 -0
  17. package/dist/scope-CTxSo201.d.ts +345 -0
  18. package/dist/scope.cjs +74 -0
  19. package/dist/scope.cjs.map +1 -0
  20. package/dist/scope.d.cts +2 -0
  21. package/dist/scope.d.ts +2 -0
  22. package/dist/scope.mjs +70 -0
  23. package/dist/scope.mjs.map +1 -0
  24. package/dist/signal-DWrUYmvd.d.cts +109 -0
  25. package/dist/signal-DWrUYmvd.d.ts +109 -0
  26. package/dist/signal-component.cjs +39 -0
  27. package/dist/signal-component.cjs.map +1 -0
  28. package/dist/signal-component.d.cts +31 -0
  29. package/dist/signal-component.d.ts +31 -0
  30. package/dist/signal-component.mjs +35 -0
  31. package/dist/signal-component.mjs.map +1 -0
  32. package/dist/signal.cjs +350 -1
  33. package/dist/signal.cjs.map +1 -0
  34. package/dist/signal.d.cts +1 -0
  35. package/dist/signal.d.ts +1 -0
  36. package/dist/signal.mjs +334 -1
  37. package/dist/signal.mjs.map +1 -0
  38. package/package.json +54 -31
  39. package/dist/types/computed.d.ts +0 -70
  40. package/dist/types/computed.d.ts.map +0 -1
  41. package/dist/types/effect.d.ts +0 -157
  42. package/dist/types/effect.d.ts.map +0 -1
  43. package/dist/types/index.d.ts +0 -21
  44. package/dist/types/index.d.ts.map +0 -1
  45. package/dist/types/reactive.d.ts +0 -98
  46. package/dist/types/reactive.d.ts.map +0 -1
  47. package/dist/types/ref.d.ts +0 -128
  48. package/dist/types/ref.d.ts.map +0 -1
  49. package/dist/types/scheduler.d.ts +0 -44
  50. package/dist/types/scheduler.d.ts.map +0 -1
  51. package/dist/types/signal-component.d.ts +0 -45
  52. package/dist/types/signal-component.d.ts.map +0 -1
  53. package/dist/types/signal.d.ts +0 -87
  54. package/dist/types/signal.d.ts.map +0 -1
  55. package/dist/types/watch.d.ts +0 -125
  56. package/dist/types/watch.d.ts.map +0 -1
@@ -0,0 +1,226 @@
1
+ import { U as UnwrapNestedRefs, b as DeepReadonly, C as ComputedGetter, l as WritableComputedOptions, m as WritableComputedRef, k as WatchSource, g as WatchCallbackWithImmediate, j as WatchOptions, i as WatchHandle, O as OnCleanup, h as WatchEffectOptions } from './scope-BC3djHz7.cjs';
2
+ export { a as ComputedSetter, D as DebuggerEvent, E as EffectScope, c as EffectScopeOptions, R as ReactiveEffectOptions, d as ReactiveEffectRunner, e as ReactiveObject, T as ToRefs, f as UnwrapRef, W as WatchCallback, n as batch, o as batchAsync, p as effect, q as effectScope, r as enableTracking, s as getCurrentScope, t as getSkippedTrackingCount, u as onEffectCleanup, v as onScopeDispose, w as pauseTracking, x as resetSkippedTrackingCount, y as resetTracking, z as shouldSkipTracking, A as stop, B as untrack, F as withFirstRenderOptimization } from './scope-BC3djHz7.cjs';
3
+ import { C as ComputedRef } from './ref-CwOCKoy2.cjs';
4
+ export { R as Ref, S as ShallowRef, c as customRef, i as isComputedRef, a as isShallowRef, r as ref, s as shallowRef, t as toRef, b as toRefs, d as toValue, e as triggerRef, u as unref } from './ref-CwOCKoy2.cjs';
5
+ export { C as ComputedRefSymbol, a as ComputedSignal, R as ReactiveSymbol, b as ReadonlySignal, c as ReadonlySymbol, d as RefSymbol, S as ShallowRefSymbol, e as Signal, f as Subscriber, W as WritableComputedSignal, g as WritableSignal, m as computedSignal, r as readonlySignal, s as set, n as signal, o as signalBatch, l as signalComputed, p as signalUntrack, u as update, v as valueOf, w as writableComputedSignal } from './signal-DWrUYmvd.cjs';
6
+ import { RefLike } from '@lytjs/shared-types';
7
+
8
+ /**
9
+ * 获取响应式对象的原始值
10
+ */
11
+ declare function toRaw<T>(observed: T): T;
12
+ /**
13
+ * 判断一个值是否为 ref
14
+ */
15
+ declare function isRef<T = unknown>(r: unknown): r is RefLike<T>;
16
+
17
+ declare function reactive<T extends object>(target: T): UnwrapNestedRefs<T>;
18
+ declare function shallowReactive<T extends object>(target: T): T;
19
+ declare function readonly<T extends object>(target: T): DeepReadonly<UnwrapNestedRefs<T>>;
20
+ declare function shallowReadonly<T extends object>(target: T): Readonly<T>;
21
+ declare function isReactive(value: unknown): boolean;
22
+ declare function isReadonly(value: unknown): boolean;
23
+ declare function isProxy(value: unknown): boolean;
24
+
25
+ declare function markRaw<T extends object>(value: T): T;
26
+
27
+ /**
28
+ * 设置 SSR 模式。
29
+ * 在 SSR 环境中调用 setSSRMode(true) 可让 computed 在创建时立即求值,
30
+ * 避免在服务端渲染时因懒求值导致的不一致问题。
31
+ *
32
+ * 注意:此设置为模块级全局状态,多实例/测试场景下可能产生状态泄漏。
33
+ * 如需隔离,请确保不同环境使用独立的模块加载上下文。
34
+ */
35
+ declare function setSSRMode(isSSR: boolean): void;
36
+ declare function computed<T>(getterOrOptions: ComputedGetter<T> | WritableComputedOptions<T>): ComputedRef<T> | WritableComputedRef<T>;
37
+
38
+ /**
39
+ * 侦听一个或多个响应式数据源,并在数据变化时执行回调。
40
+ *
41
+ * @param source - 要侦听的数据源,可以是 ref、reactive 对象、getter 函数,或它们的数组
42
+ * @param cb - 数据变化时的回调函数
43
+ * @param options - 侦听选项
44
+ * @returns 停止侦听的句柄函数
45
+ *
46
+ * @remarks
47
+ * 关于 scheduler 参数签名:
48
+ * watch 的 scheduler 与 ReactiveEffect 的 scheduler 参数签名不同。
49
+ * - ReactiveEffect.scheduler: () => void(无参数,由 effect 系统内部调用)
50
+ * - watch scheduler: (job: () => void, ...args: unknown[]) => unknown
51
+ * 其中 job 是 watch 内部封装的变更检测+回调执行函数。
52
+ * 当用户提供 scheduler 时,watch 会将 job 作为第一个参数传入,
53
+ * 用户可以在 scheduler 中决定何时执行 job(如节流、防抖等)。
54
+ */
55
+ declare function watch<T, Immediate extends Readonly<boolean> = false>(source: WatchSource<T> | WatchSource<T>[], cb: WatchCallbackWithImmediate<T, Immediate>, options?: WatchOptions<Immediate>): WatchHandle;
56
+ declare function watchEffect(effectFn: (onCleanup: OnCleanup) => void, options?: WatchEffectOptions): WatchHandle;
57
+ declare function watchPostEffect(effectFn: (onCleanup: OnCleanup) => void, options?: WatchEffectOptions): WatchHandle;
58
+ declare function watchSyncEffect(effectFn: (onCleanup: OnCleanup) => void, options?: WatchEffectOptions): WatchHandle;
59
+
60
+ /**
61
+ * @lytjs/reactivity - batch.ts
62
+ * FIX: P2-4 REACTIVITY-NEW-05 - 批量操作 API
63
+ *
64
+ * 提供 batchScope 函数,支持嵌套批量操作和自动提交。
65
+ * 允许在批量作用域内执行多个响应式操作,只在作用域结束时统一触发更新。
66
+ */
67
+ /** 批量作用域配置选项 */
68
+ interface BatchScopeOptions {
69
+ /** 是否异步提交(默认 false) */
70
+ async?: boolean;
71
+ /** 作用域名称(用于调试) */
72
+ name?: string;
73
+ /** 错误处理回调 */
74
+ onError?: (error: unknown) => void;
75
+ }
76
+ /** 批量作用域上下文 */
77
+ interface BatchScopeContext {
78
+ /** 当前嵌套深度 */
79
+ depth: number;
80
+ /** 作用域名称 */
81
+ name: string;
82
+ /** 是否已提交 */
83
+ committed: boolean;
84
+ /** 是否已取消 */
85
+ cancelled: boolean;
86
+ }
87
+ /** 批量操作回调 */
88
+ type BatchScopeCallback<T> = (ctx: BatchScopeContext) => T;
89
+ /**
90
+ * 创建批量作用域并执行回调函数。
91
+ * 在作用域内所有响应式操作会被批量收集,只在作用域结束时统一触发更新。
92
+ *
93
+ * 支持嵌套调用:嵌套的 batchScope 会继承外层的批量状态,
94
+ * 只有最外层作用域结束时才会真正提交所有更新。
95
+ *
96
+ * @example
97
+ * ```typescript
98
+ * batchScope((ctx) => {
99
+ * signal1.set(1);
100
+ * signal2.set(2);
101
+ * // 此时不会触发更新
102
+ *
103
+ * batchScope((innerCtx) => {
104
+ * signal3.set(3);
105
+ * // 嵌套作用域,仍然不会触发更新
106
+ * });
107
+ * });
108
+ * // 所有更新在这里统一触发
109
+ * ```
110
+ *
111
+ * @param callback - 在批量作用域内执行的回调函数
112
+ * @param options - 批量作用域配置选项
113
+ * @returns 回调函数的返回值
114
+ */
115
+ declare function batchScope<T>(callback: BatchScopeCallback<T>, options?: BatchScopeOptions): T;
116
+ /**
117
+ * 创建异步批量作用域。
118
+ * 与 batchScope 类似,但支持 async/await。
119
+ *
120
+ * @example
121
+ * ```typescript
122
+ * await batchScopeAsync(async (ctx) => {
123
+ * signal1.set(1);
124
+ * await someAsyncOperation();
125
+ * signal2.set(2);
126
+ * });
127
+ * ```
128
+ *
129
+ * @param callback - 异步回调函数
130
+ * @param options - 批量作用域配置选项
131
+ * @returns Promise,在批量作用域完成时 resolve
132
+ */
133
+ declare function batchScopeAsync<T>(callback: BatchScopeCallback<Promise<T> | T>, options?: BatchScopeOptions): Promise<T>;
134
+ /**
135
+ * 在批量作用域内执行无追踪操作。
136
+ * 函数内读取 signal 不会建立依赖关系。
137
+ *
138
+ * @param fn - 要执行的函数
139
+ * @returns 函数的返回值
140
+ */
141
+ declare function batchScopeUntrack<T>(fn: () => T): T;
142
+ /**
143
+ * 获取当前批量作用域深度。
144
+ * 0 表示不在任何批量作用域内。
145
+ */
146
+ declare function getBatchScopeDepth(): number;
147
+ /**
148
+ * 获取当前活跃的批量作用域信息。
149
+ * 返回当前作用域栈的只读副本。
150
+ */
151
+ declare function getCurrentBatchScopeStack(): ReadonlyArray<BatchScopeContext>;
152
+ /**
153
+ * 检查当前是否在批量作用域内。
154
+ */
155
+ declare function isInBatchScope(): boolean;
156
+ /**
157
+ * 等待所有待处理的批量操作完成(异步模式)。
158
+ * 返回一个 Promise,在所有异步批量操作完成后 resolve。
159
+ *
160
+ * FIX: P2-2 flushBatchScopes 中 pendingCallbacks 始终为空(死代码)。
161
+ * 原因:batchScope 的异步模式使用 batchAsync 而非 pendingCallbacks 注册回调,
162
+ * 导致 pendingCallbacks 永远不会被填充。移除死代码,避免误导维护者。
163
+ * 如需等待异步 batchScope 完成,应直接 await batchScopeAsync()。
164
+ *
165
+ * FIX: P2-batch1-7 保留原因:
166
+ * 1. API 兼容性:此函数是公共 API 的一部分,直接删除会导致破坏性变更
167
+ * 2. 未来扩展:可用于实现等待所有异步 batchScope 完成的功能
168
+ * 3. 测试用途:提供一种同步刷新所有批量操作的方式(即使当前为空操作)
169
+ * 4. 类型安全:返回 Promise<void> 与异步 API 签名保持一致
170
+ *
171
+ * @deprecated 当前实现为空操作,如需等待异步 batchScope 完成,请直接使用 await batchScopeAsync()
172
+ */
173
+ declare function flushBatchScopes(): Promise<void>;
174
+
175
+ /** DevTools 信号依赖信息 */
176
+ interface DevToolsSignalInfo {
177
+ id: string;
178
+ name: string;
179
+ value: unknown;
180
+ dependencies: string[];
181
+ dependents: string[];
182
+ }
183
+ /** DevTools effect 信息 */
184
+ interface DevToolsEffectInfo {
185
+ id: string;
186
+ name: string;
187
+ active: boolean;
188
+ dependencies: string[];
189
+ }
190
+ /** LytJS DevTools 全局对象接口 */
191
+ interface LytJSDevTools {
192
+ /** 版本号 */
193
+ version: string;
194
+ /** 获取所有信号信息 */
195
+ getSignals: () => DevToolsSignalInfo[];
196
+ /** 获取所有 effect 信息 */
197
+ getEffects: () => DevToolsEffectInfo[];
198
+ /** 监听信号变化 */
199
+ onSignalChange: (callback: (signalId: string, value: unknown) => void) => () => void;
200
+ /** 监听 effect 执行 */
201
+ onEffectRun: (callback: (effectId: string) => void) => () => void;
202
+ /** 启用/禁用调试 */
203
+ setEnabled: (enabled: boolean) => void;
204
+ /** 当前是否启用 */
205
+ isEnabled: () => boolean;
206
+ }
207
+ /** 调试工具全局对象 */
208
+ declare global {
209
+ interface Window {
210
+ __LYTJS_DEVTOOLS__?: LytJSDevTools;
211
+ }
212
+ }
213
+ /**
214
+ * 通知 DevTools 信号变化
215
+ * @internal
216
+ * FIX: P2-4 使用批处理合并高频通知,减少监听器调用次数
217
+ */
218
+ declare function _notifyDevToolsSignalChange(signalId: string, value: unknown): void;
219
+ /**
220
+ * 通知 DevTools effect 执行
221
+ * @internal
222
+ * FIX: P2-4 使用批处理合并高频通知,减少监听器调用次数
223
+ */
224
+ declare function _notifyDevToolsEffectRun(effectId: string): void;
225
+
226
+ export { type BatchScopeCallback, type BatchScopeContext, type BatchScopeOptions, ComputedGetter, ComputedRef, DeepReadonly, type DevToolsEffectInfo, type DevToolsSignalInfo, type LytJSDevTools, UnwrapNestedRefs, WatchEffectOptions, WatchHandle, WatchOptions, WatchSource, WritableComputedOptions, WritableComputedRef, _notifyDevToolsEffectRun, _notifyDevToolsSignalChange, batchScope, batchScopeAsync, batchScopeUntrack, computed, flushBatchScopes, getBatchScopeDepth, getCurrentBatchScopeStack, isInBatchScope, isProxy, isReactive, isReadonly, isRef, markRaw, reactive, readonly, setSSRMode, shallowReactive, shallowReadonly, toRaw, watch, watchEffect, watchPostEffect, watchSyncEffect };
@@ -0,0 +1,226 @@
1
+ import { U as UnwrapNestedRefs, b as DeepReadonly, C as ComputedGetter, l as WritableComputedOptions, m as WritableComputedRef, k as WatchSource, g as WatchCallbackWithImmediate, j as WatchOptions, i as WatchHandle, O as OnCleanup, h as WatchEffectOptions } from './scope-CTxSo201.js';
2
+ export { a as ComputedSetter, D as DebuggerEvent, E as EffectScope, c as EffectScopeOptions, R as ReactiveEffectOptions, d as ReactiveEffectRunner, e as ReactiveObject, T as ToRefs, f as UnwrapRef, W as WatchCallback, n as batch, o as batchAsync, p as effect, q as effectScope, r as enableTracking, s as getCurrentScope, t as getSkippedTrackingCount, u as onEffectCleanup, v as onScopeDispose, w as pauseTracking, x as resetSkippedTrackingCount, y as resetTracking, z as shouldSkipTracking, A as stop, B as untrack, F as withFirstRenderOptimization } from './scope-CTxSo201.js';
3
+ import { C as ComputedRef } from './ref-CwOCKoy2.js';
4
+ export { R as Ref, S as ShallowRef, c as customRef, i as isComputedRef, a as isShallowRef, r as ref, s as shallowRef, t as toRef, b as toRefs, d as toValue, e as triggerRef, u as unref } from './ref-CwOCKoy2.js';
5
+ export { C as ComputedRefSymbol, a as ComputedSignal, R as ReactiveSymbol, b as ReadonlySignal, c as ReadonlySymbol, d as RefSymbol, S as ShallowRefSymbol, e as Signal, f as Subscriber, W as WritableComputedSignal, g as WritableSignal, m as computedSignal, r as readonlySignal, s as set, n as signal, o as signalBatch, l as signalComputed, p as signalUntrack, u as update, v as valueOf, w as writableComputedSignal } from './signal-DWrUYmvd.js';
6
+ import { RefLike } from '@lytjs/shared-types';
7
+
8
+ /**
9
+ * 获取响应式对象的原始值
10
+ */
11
+ declare function toRaw<T>(observed: T): T;
12
+ /**
13
+ * 判断一个值是否为 ref
14
+ */
15
+ declare function isRef<T = unknown>(r: unknown): r is RefLike<T>;
16
+
17
+ declare function reactive<T extends object>(target: T): UnwrapNestedRefs<T>;
18
+ declare function shallowReactive<T extends object>(target: T): T;
19
+ declare function readonly<T extends object>(target: T): DeepReadonly<UnwrapNestedRefs<T>>;
20
+ declare function shallowReadonly<T extends object>(target: T): Readonly<T>;
21
+ declare function isReactive(value: unknown): boolean;
22
+ declare function isReadonly(value: unknown): boolean;
23
+ declare function isProxy(value: unknown): boolean;
24
+
25
+ declare function markRaw<T extends object>(value: T): T;
26
+
27
+ /**
28
+ * 设置 SSR 模式。
29
+ * 在 SSR 环境中调用 setSSRMode(true) 可让 computed 在创建时立即求值,
30
+ * 避免在服务端渲染时因懒求值导致的不一致问题。
31
+ *
32
+ * 注意:此设置为模块级全局状态,多实例/测试场景下可能产生状态泄漏。
33
+ * 如需隔离,请确保不同环境使用独立的模块加载上下文。
34
+ */
35
+ declare function setSSRMode(isSSR: boolean): void;
36
+ declare function computed<T>(getterOrOptions: ComputedGetter<T> | WritableComputedOptions<T>): ComputedRef<T> | WritableComputedRef<T>;
37
+
38
+ /**
39
+ * 侦听一个或多个响应式数据源,并在数据变化时执行回调。
40
+ *
41
+ * @param source - 要侦听的数据源,可以是 ref、reactive 对象、getter 函数,或它们的数组
42
+ * @param cb - 数据变化时的回调函数
43
+ * @param options - 侦听选项
44
+ * @returns 停止侦听的句柄函数
45
+ *
46
+ * @remarks
47
+ * 关于 scheduler 参数签名:
48
+ * watch 的 scheduler 与 ReactiveEffect 的 scheduler 参数签名不同。
49
+ * - ReactiveEffect.scheduler: () => void(无参数,由 effect 系统内部调用)
50
+ * - watch scheduler: (job: () => void, ...args: unknown[]) => unknown
51
+ * 其中 job 是 watch 内部封装的变更检测+回调执行函数。
52
+ * 当用户提供 scheduler 时,watch 会将 job 作为第一个参数传入,
53
+ * 用户可以在 scheduler 中决定何时执行 job(如节流、防抖等)。
54
+ */
55
+ declare function watch<T, Immediate extends Readonly<boolean> = false>(source: WatchSource<T> | WatchSource<T>[], cb: WatchCallbackWithImmediate<T, Immediate>, options?: WatchOptions<Immediate>): WatchHandle;
56
+ declare function watchEffect(effectFn: (onCleanup: OnCleanup) => void, options?: WatchEffectOptions): WatchHandle;
57
+ declare function watchPostEffect(effectFn: (onCleanup: OnCleanup) => void, options?: WatchEffectOptions): WatchHandle;
58
+ declare function watchSyncEffect(effectFn: (onCleanup: OnCleanup) => void, options?: WatchEffectOptions): WatchHandle;
59
+
60
+ /**
61
+ * @lytjs/reactivity - batch.ts
62
+ * FIX: P2-4 REACTIVITY-NEW-05 - 批量操作 API
63
+ *
64
+ * 提供 batchScope 函数,支持嵌套批量操作和自动提交。
65
+ * 允许在批量作用域内执行多个响应式操作,只在作用域结束时统一触发更新。
66
+ */
67
+ /** 批量作用域配置选项 */
68
+ interface BatchScopeOptions {
69
+ /** 是否异步提交(默认 false) */
70
+ async?: boolean;
71
+ /** 作用域名称(用于调试) */
72
+ name?: string;
73
+ /** 错误处理回调 */
74
+ onError?: (error: unknown) => void;
75
+ }
76
+ /** 批量作用域上下文 */
77
+ interface BatchScopeContext {
78
+ /** 当前嵌套深度 */
79
+ depth: number;
80
+ /** 作用域名称 */
81
+ name: string;
82
+ /** 是否已提交 */
83
+ committed: boolean;
84
+ /** 是否已取消 */
85
+ cancelled: boolean;
86
+ }
87
+ /** 批量操作回调 */
88
+ type BatchScopeCallback<T> = (ctx: BatchScopeContext) => T;
89
+ /**
90
+ * 创建批量作用域并执行回调函数。
91
+ * 在作用域内所有响应式操作会被批量收集,只在作用域结束时统一触发更新。
92
+ *
93
+ * 支持嵌套调用:嵌套的 batchScope 会继承外层的批量状态,
94
+ * 只有最外层作用域结束时才会真正提交所有更新。
95
+ *
96
+ * @example
97
+ * ```typescript
98
+ * batchScope((ctx) => {
99
+ * signal1.set(1);
100
+ * signal2.set(2);
101
+ * // 此时不会触发更新
102
+ *
103
+ * batchScope((innerCtx) => {
104
+ * signal3.set(3);
105
+ * // 嵌套作用域,仍然不会触发更新
106
+ * });
107
+ * });
108
+ * // 所有更新在这里统一触发
109
+ * ```
110
+ *
111
+ * @param callback - 在批量作用域内执行的回调函数
112
+ * @param options - 批量作用域配置选项
113
+ * @returns 回调函数的返回值
114
+ */
115
+ declare function batchScope<T>(callback: BatchScopeCallback<T>, options?: BatchScopeOptions): T;
116
+ /**
117
+ * 创建异步批量作用域。
118
+ * 与 batchScope 类似,但支持 async/await。
119
+ *
120
+ * @example
121
+ * ```typescript
122
+ * await batchScopeAsync(async (ctx) => {
123
+ * signal1.set(1);
124
+ * await someAsyncOperation();
125
+ * signal2.set(2);
126
+ * });
127
+ * ```
128
+ *
129
+ * @param callback - 异步回调函数
130
+ * @param options - 批量作用域配置选项
131
+ * @returns Promise,在批量作用域完成时 resolve
132
+ */
133
+ declare function batchScopeAsync<T>(callback: BatchScopeCallback<Promise<T> | T>, options?: BatchScopeOptions): Promise<T>;
134
+ /**
135
+ * 在批量作用域内执行无追踪操作。
136
+ * 函数内读取 signal 不会建立依赖关系。
137
+ *
138
+ * @param fn - 要执行的函数
139
+ * @returns 函数的返回值
140
+ */
141
+ declare function batchScopeUntrack<T>(fn: () => T): T;
142
+ /**
143
+ * 获取当前批量作用域深度。
144
+ * 0 表示不在任何批量作用域内。
145
+ */
146
+ declare function getBatchScopeDepth(): number;
147
+ /**
148
+ * 获取当前活跃的批量作用域信息。
149
+ * 返回当前作用域栈的只读副本。
150
+ */
151
+ declare function getCurrentBatchScopeStack(): ReadonlyArray<BatchScopeContext>;
152
+ /**
153
+ * 检查当前是否在批量作用域内。
154
+ */
155
+ declare function isInBatchScope(): boolean;
156
+ /**
157
+ * 等待所有待处理的批量操作完成(异步模式)。
158
+ * 返回一个 Promise,在所有异步批量操作完成后 resolve。
159
+ *
160
+ * FIX: P2-2 flushBatchScopes 中 pendingCallbacks 始终为空(死代码)。
161
+ * 原因:batchScope 的异步模式使用 batchAsync 而非 pendingCallbacks 注册回调,
162
+ * 导致 pendingCallbacks 永远不会被填充。移除死代码,避免误导维护者。
163
+ * 如需等待异步 batchScope 完成,应直接 await batchScopeAsync()。
164
+ *
165
+ * FIX: P2-batch1-7 保留原因:
166
+ * 1. API 兼容性:此函数是公共 API 的一部分,直接删除会导致破坏性变更
167
+ * 2. 未来扩展:可用于实现等待所有异步 batchScope 完成的功能
168
+ * 3. 测试用途:提供一种同步刷新所有批量操作的方式(即使当前为空操作)
169
+ * 4. 类型安全:返回 Promise<void> 与异步 API 签名保持一致
170
+ *
171
+ * @deprecated 当前实现为空操作,如需等待异步 batchScope 完成,请直接使用 await batchScopeAsync()
172
+ */
173
+ declare function flushBatchScopes(): Promise<void>;
174
+
175
+ /** DevTools 信号依赖信息 */
176
+ interface DevToolsSignalInfo {
177
+ id: string;
178
+ name: string;
179
+ value: unknown;
180
+ dependencies: string[];
181
+ dependents: string[];
182
+ }
183
+ /** DevTools effect 信息 */
184
+ interface DevToolsEffectInfo {
185
+ id: string;
186
+ name: string;
187
+ active: boolean;
188
+ dependencies: string[];
189
+ }
190
+ /** LytJS DevTools 全局对象接口 */
191
+ interface LytJSDevTools {
192
+ /** 版本号 */
193
+ version: string;
194
+ /** 获取所有信号信息 */
195
+ getSignals: () => DevToolsSignalInfo[];
196
+ /** 获取所有 effect 信息 */
197
+ getEffects: () => DevToolsEffectInfo[];
198
+ /** 监听信号变化 */
199
+ onSignalChange: (callback: (signalId: string, value: unknown) => void) => () => void;
200
+ /** 监听 effect 执行 */
201
+ onEffectRun: (callback: (effectId: string) => void) => () => void;
202
+ /** 启用/禁用调试 */
203
+ setEnabled: (enabled: boolean) => void;
204
+ /** 当前是否启用 */
205
+ isEnabled: () => boolean;
206
+ }
207
+ /** 调试工具全局对象 */
208
+ declare global {
209
+ interface Window {
210
+ __LYTJS_DEVTOOLS__?: LytJSDevTools;
211
+ }
212
+ }
213
+ /**
214
+ * 通知 DevTools 信号变化
215
+ * @internal
216
+ * FIX: P2-4 使用批处理合并高频通知,减少监听器调用次数
217
+ */
218
+ declare function _notifyDevToolsSignalChange(signalId: string, value: unknown): void;
219
+ /**
220
+ * 通知 DevTools effect 执行
221
+ * @internal
222
+ * FIX: P2-4 使用批处理合并高频通知,减少监听器调用次数
223
+ */
224
+ declare function _notifyDevToolsEffectRun(effectId: string): void;
225
+
226
+ export { type BatchScopeCallback, type BatchScopeContext, type BatchScopeOptions, ComputedGetter, ComputedRef, DeepReadonly, type DevToolsEffectInfo, type DevToolsSignalInfo, type LytJSDevTools, UnwrapNestedRefs, WatchEffectOptions, WatchHandle, WatchOptions, WatchSource, WritableComputedOptions, WritableComputedRef, _notifyDevToolsEffectRun, _notifyDevToolsSignalChange, batchScope, batchScopeAsync, batchScopeUntrack, computed, flushBatchScopes, getBatchScopeDepth, getCurrentBatchScopeStack, isInBatchScope, isProxy, isReactive, isReadonly, isRef, markRaw, reactive, readonly, setSSRMode, shallowReactive, shallowReadonly, toRaw, watch, watchEffect, watchPostEffect, watchSyncEffect };