@zeus-js/signal 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/signal.cjs.js +16 -16
- package/dist/signal.cjs.prod.js +15 -15
- package/dist/signal.d.ts +3 -570
- package/dist/signal.esm-browser.js +18 -18
- package/dist/signal.esm-bundler.js +16 -16
- package/dist/signal.global.js +18 -18
- package/package.json +4 -4
package/dist/signal.cjs.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* signal v0.0.
|
|
2
|
+
* signal v0.1.0-beta.0
|
|
3
3
|
* (c) 2026 baicie
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
**/
|
|
@@ -8,7 +8,7 @@ Object.defineProperties(exports, {
|
|
|
8
8
|
[Symbol.toStringTag]: { value: "Module" }
|
|
9
9
|
});
|
|
10
10
|
let _zeus_js_shared = require("@zeus-js/shared");
|
|
11
|
-
//#region packages/signal/src/constants.ts
|
|
11
|
+
//#region packages/core/signal/src/constants.ts
|
|
12
12
|
let TrackOpTypes = /* @__PURE__ */ function(TrackOpTypes) {
|
|
13
13
|
TrackOpTypes["GET"] = "get";
|
|
14
14
|
TrackOpTypes["HAS"] = "has";
|
|
@@ -32,12 +32,12 @@ let ReactiveFlags = /* @__PURE__ */ function(ReactiveFlags) {
|
|
|
32
32
|
return ReactiveFlags;
|
|
33
33
|
}({});
|
|
34
34
|
//#endregion
|
|
35
|
-
//#region packages/signal/src/warning.ts
|
|
35
|
+
//#region packages/core/signal/src/warning.ts
|
|
36
36
|
function warn(msg, ...args) {
|
|
37
37
|
console.warn(`[Zeus warn] ${msg}`, ...args);
|
|
38
38
|
}
|
|
39
39
|
//#endregion
|
|
40
|
-
//#region packages/signal/src/effectScope.ts
|
|
40
|
+
//#region packages/core/signal/src/effectScope.ts
|
|
41
41
|
let activeEffectScope;
|
|
42
42
|
var EffectScope = class {
|
|
43
43
|
constructor(detached = false) {
|
|
@@ -177,7 +177,7 @@ function onScopeDispose(fn, failSilently = false) {
|
|
|
177
177
|
else if (!failSilently) warn("onScopeDispose() is called when there is no active effect scope to be associated with.");
|
|
178
178
|
}
|
|
179
179
|
//#endregion
|
|
180
|
-
//#region packages/signal/src/effect.ts
|
|
180
|
+
//#region packages/core/signal/src/effect.ts
|
|
181
181
|
let activeSub;
|
|
182
182
|
let EffectFlags = /* @__PURE__ */ function(EffectFlags) {
|
|
183
183
|
/**
|
|
@@ -531,7 +531,7 @@ function getCurrentEffect() {
|
|
|
531
531
|
return activeSub instanceof ReactiveEffect ? activeSub : void 0;
|
|
532
532
|
}
|
|
533
533
|
//#endregion
|
|
534
|
-
//#region packages/signal/src/dep.ts
|
|
534
|
+
//#region packages/core/signal/src/dep.ts
|
|
535
535
|
/**
|
|
536
536
|
* Incremented every time a reactive change happens
|
|
537
537
|
* This is used to give computed a fast path to avoid re-compute when nothing
|
|
@@ -722,7 +722,7 @@ function trigger(target, type, key, newValue, oldValue, oldTarget) {
|
|
|
722
722
|
endBatch();
|
|
723
723
|
}
|
|
724
724
|
//#endregion
|
|
725
|
-
//#region packages/signal/src/arrayInstrumentations.ts
|
|
725
|
+
//#region packages/core/signal/src/arrayInstrumentations.ts
|
|
726
726
|
/**
|
|
727
727
|
* Track array iteration and return:
|
|
728
728
|
* - if input is reactive: a cloned raw array with reactive values
|
|
@@ -907,7 +907,7 @@ function noTracking(self, method, args = []) {
|
|
|
907
907
|
return res;
|
|
908
908
|
}
|
|
909
909
|
//#endregion
|
|
910
|
-
//#region packages/signal/src/ref.ts
|
|
910
|
+
//#region packages/core/signal/src/ref.ts
|
|
911
911
|
let _ReactiveFlags$IS_REF, _ReactiveFlags$IS_SHA;
|
|
912
912
|
/*@__NO_SIDE_EFFECTS__*/
|
|
913
913
|
function isRef(r) {
|
|
@@ -961,7 +961,7 @@ var RefImpl = class {
|
|
|
961
961
|
}
|
|
962
962
|
};
|
|
963
963
|
//#endregion
|
|
964
|
-
//#region packages/signal/src/baseHandlers.ts
|
|
964
|
+
//#region packages/core/signal/src/baseHandlers.ts
|
|
965
965
|
const isNonTrackableKeys = /*@__PURE__*/ (0, _zeus_js_shared.makeMap)(`__proto__,__v_isRef,__isVue`);
|
|
966
966
|
const builtInSymbols = new Set(/*@__PURE__*/ Object.getOwnPropertyNames(Symbol).filter((key) => key !== "arguments" && key !== "caller").map((key) => Symbol[key]).filter(_zeus_js_shared.isSymbol));
|
|
967
967
|
function hasOwnProperty(key) {
|
|
@@ -1065,7 +1065,7 @@ var ReadonlyReactiveHandler = class extends BaseReactiveHandler {
|
|
|
1065
1065
|
const mutableHandlers = /*@__PURE__*/ new MutableReactiveHandler();
|
|
1066
1066
|
const readonlyHandlers = /*@__PURE__*/ new ReadonlyReactiveHandler();
|
|
1067
1067
|
//#endregion
|
|
1068
|
-
//#region packages/signal/src/collectionHandlers.ts
|
|
1068
|
+
//#region packages/core/signal/src/collectionHandlers.ts
|
|
1069
1069
|
const toShallow = (value) => value;
|
|
1070
1070
|
const getProto = (v) => Reflect.getPrototypeOf(v);
|
|
1071
1071
|
function createIterableMethod(method, isReadonly, isShallow) {
|
|
@@ -1224,7 +1224,7 @@ function checkIdentityKeys(target, has, key) {
|
|
|
1224
1224
|
}
|
|
1225
1225
|
}
|
|
1226
1226
|
//#endregion
|
|
1227
|
-
//#region packages/signal/src/reactive.ts
|
|
1227
|
+
//#region packages/core/signal/src/reactive.ts
|
|
1228
1228
|
const reactiveMap = /* @__PURE__ */ new WeakMap();
|
|
1229
1229
|
const shallowReactiveMap = /* @__PURE__ */ new WeakMap();
|
|
1230
1230
|
const readonlyMap = /* @__PURE__ */ new WeakMap();
|
|
@@ -1393,7 +1393,7 @@ const toReactive = (value) => (0, _zeus_js_shared.isObject)(value) ? /* @__PURE_
|
|
|
1393
1393
|
*/
|
|
1394
1394
|
const toReadonly = (value) => (0, _zeus_js_shared.isObject)(value) ? /* @__PURE__ */ readonly(value) : value;
|
|
1395
1395
|
//#endregion
|
|
1396
|
-
//#region packages/signal/src/state.ts
|
|
1396
|
+
//#region packages/core/signal/src/state.ts
|
|
1397
1397
|
function state(value) {
|
|
1398
1398
|
if (arguments.length === 0) return /* @__PURE__ */ ref();
|
|
1399
1399
|
return isProxyable(value) ? /* @__PURE__ */ reactive(value) : /* @__PURE__ */ ref(value);
|
|
@@ -1415,7 +1415,7 @@ function isPlainObject$1(value) {
|
|
|
1415
1415
|
return proto === Object.prototype || proto === null;
|
|
1416
1416
|
}
|
|
1417
1417
|
//#endregion
|
|
1418
|
-
//#region packages/signal/src/computed.ts
|
|
1418
|
+
//#region packages/core/signal/src/computed.ts
|
|
1419
1419
|
/**
|
|
1420
1420
|
* @private exported by @vue/reactivity for Vue core use, but not exported from
|
|
1421
1421
|
* the main vue package
|
|
@@ -1478,7 +1478,7 @@ function computed(getterOrOptions, debugOptions, isSSR = false) {
|
|
|
1478
1478
|
return cRef;
|
|
1479
1479
|
}
|
|
1480
1480
|
//#endregion
|
|
1481
|
-
//#region packages/signal/src/scheduler.ts
|
|
1481
|
+
//#region packages/core/signal/src/scheduler.ts
|
|
1482
1482
|
const queue = /* @__PURE__ */ new Set();
|
|
1483
1483
|
let flushing = false;
|
|
1484
1484
|
let pending = false;
|
|
@@ -1504,7 +1504,7 @@ function nextTick() {
|
|
|
1504
1504
|
return Promise.resolve();
|
|
1505
1505
|
}
|
|
1506
1506
|
//#endregion
|
|
1507
|
-
//#region packages/signal/src/watch.ts
|
|
1507
|
+
//#region packages/core/signal/src/watch.ts
|
|
1508
1508
|
let WatchErrorCodes = /* @__PURE__ */ function(WatchErrorCodes) {
|
|
1509
1509
|
WatchErrorCodes[WatchErrorCodes["WATCH_GETTER"] = 2] = "WATCH_GETTER";
|
|
1510
1510
|
WatchErrorCodes[WatchErrorCodes["WATCH_CALLBACK"] = 3] = "WATCH_CALLBACK";
|
|
@@ -1672,7 +1672,7 @@ function traverse(value, depth = Infinity, seen) {
|
|
|
1672
1672
|
return value;
|
|
1673
1673
|
}
|
|
1674
1674
|
//#endregion
|
|
1675
|
-
//#region packages/signal/src/lifecycle.ts
|
|
1675
|
+
//#region packages/core/signal/src/lifecycle.ts
|
|
1676
1676
|
function onCleanup(fn) {
|
|
1677
1677
|
if (getCurrentEffect()) {
|
|
1678
1678
|
onEffectCleanup(fn, true);
|
package/dist/signal.cjs.prod.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* signal v0.0.
|
|
2
|
+
* signal v0.1.0-beta.0
|
|
3
3
|
* (c) 2026 baicie
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
**/
|
|
@@ -8,7 +8,7 @@ Object.defineProperties(exports, {
|
|
|
8
8
|
[Symbol.toStringTag]: { value: "Module" }
|
|
9
9
|
});
|
|
10
10
|
let _zeus_js_shared = require("@zeus-js/shared");
|
|
11
|
-
//#region packages/signal/src/constants.ts
|
|
11
|
+
//#region packages/core/signal/src/constants.ts
|
|
12
12
|
let TrackOpTypes = /* @__PURE__ */ function(TrackOpTypes) {
|
|
13
13
|
TrackOpTypes["GET"] = "get";
|
|
14
14
|
TrackOpTypes["HAS"] = "has";
|
|
@@ -32,7 +32,7 @@ let ReactiveFlags = /* @__PURE__ */ function(ReactiveFlags) {
|
|
|
32
32
|
return ReactiveFlags;
|
|
33
33
|
}({});
|
|
34
34
|
//#endregion
|
|
35
|
-
//#region packages/signal/src/effectScope.ts
|
|
35
|
+
//#region packages/core/signal/src/effectScope.ts
|
|
36
36
|
let activeEffectScope;
|
|
37
37
|
var EffectScope = class {
|
|
38
38
|
constructor(detached = false) {
|
|
@@ -171,7 +171,7 @@ function onScopeDispose(fn, failSilently = false) {
|
|
|
171
171
|
if (activeEffectScope) activeEffectScope.cleanups.push(fn);
|
|
172
172
|
}
|
|
173
173
|
//#endregion
|
|
174
|
-
//#region packages/signal/src/effect.ts
|
|
174
|
+
//#region packages/core/signal/src/effect.ts
|
|
175
175
|
let activeSub;
|
|
176
176
|
let EffectFlags = /* @__PURE__ */ function(EffectFlags) {
|
|
177
177
|
/**
|
|
@@ -522,7 +522,7 @@ function getCurrentEffect() {
|
|
|
522
522
|
return activeSub instanceof ReactiveEffect ? activeSub : void 0;
|
|
523
523
|
}
|
|
524
524
|
//#endregion
|
|
525
|
-
//#region packages/signal/src/dep.ts
|
|
525
|
+
//#region packages/core/signal/src/dep.ts
|
|
526
526
|
/**
|
|
527
527
|
* Incremented every time a reactive change happens
|
|
528
528
|
* This is used to give computed a fast path to avoid re-compute when nothing
|
|
@@ -698,7 +698,7 @@ function trigger(target, type, key, newValue, oldValue, oldTarget) {
|
|
|
698
698
|
endBatch();
|
|
699
699
|
}
|
|
700
700
|
//#endregion
|
|
701
|
-
//#region packages/signal/src/arrayInstrumentations.ts
|
|
701
|
+
//#region packages/core/signal/src/arrayInstrumentations.ts
|
|
702
702
|
/**
|
|
703
703
|
* Track array iteration and return:
|
|
704
704
|
* - if input is reactive: a cloned raw array with reactive values
|
|
@@ -883,7 +883,7 @@ function noTracking(self, method, args = []) {
|
|
|
883
883
|
return res;
|
|
884
884
|
}
|
|
885
885
|
//#endregion
|
|
886
|
-
//#region packages/signal/src/ref.ts
|
|
886
|
+
//#region packages/core/signal/src/ref.ts
|
|
887
887
|
let _ReactiveFlags$IS_REF, _ReactiveFlags$IS_SHA;
|
|
888
888
|
/*@__NO_SIDE_EFFECTS__*/
|
|
889
889
|
function isRef(r) {
|
|
@@ -927,7 +927,7 @@ var RefImpl = class {
|
|
|
927
927
|
}
|
|
928
928
|
};
|
|
929
929
|
//#endregion
|
|
930
|
-
//#region packages/signal/src/baseHandlers.ts
|
|
930
|
+
//#region packages/core/signal/src/baseHandlers.ts
|
|
931
931
|
const isNonTrackableKeys = /*@__PURE__*/ (0, _zeus_js_shared.makeMap)(`__proto__,__v_isRef,__isVue`);
|
|
932
932
|
const builtInSymbols = new Set(/*@__PURE__*/ Object.getOwnPropertyNames(Symbol).filter((key) => key !== "arguments" && key !== "caller").map((key) => Symbol[key]).filter(_zeus_js_shared.isSymbol));
|
|
933
933
|
function hasOwnProperty(key) {
|
|
@@ -1027,7 +1027,7 @@ var ReadonlyReactiveHandler = class extends BaseReactiveHandler {
|
|
|
1027
1027
|
const mutableHandlers = /*@__PURE__*/ new MutableReactiveHandler();
|
|
1028
1028
|
const readonlyHandlers = /*@__PURE__*/ new ReadonlyReactiveHandler();
|
|
1029
1029
|
//#endregion
|
|
1030
|
-
//#region packages/signal/src/collectionHandlers.ts
|
|
1030
|
+
//#region packages/core/signal/src/collectionHandlers.ts
|
|
1031
1031
|
const toShallow = (value) => value;
|
|
1032
1032
|
const getProto = (v) => Reflect.getPrototypeOf(v);
|
|
1033
1033
|
function createIterableMethod(method, isReadonly, isShallow) {
|
|
@@ -1175,7 +1175,7 @@ function createInstrumentationGetter(isReadonly, shallow) {
|
|
|
1175
1175
|
const mutableCollectionHandlers = { get: /*@__PURE__*/ createInstrumentationGetter(false, false) };
|
|
1176
1176
|
const readonlyCollectionHandlers = { get: /*@__PURE__*/ createInstrumentationGetter(true, false) };
|
|
1177
1177
|
//#endregion
|
|
1178
|
-
//#region packages/signal/src/reactive.ts
|
|
1178
|
+
//#region packages/core/signal/src/reactive.ts
|
|
1179
1179
|
const reactiveMap = /* @__PURE__ */ new WeakMap();
|
|
1180
1180
|
const shallowReactiveMap = /* @__PURE__ */ new WeakMap();
|
|
1181
1181
|
const readonlyMap = /* @__PURE__ */ new WeakMap();
|
|
@@ -1341,7 +1341,7 @@ const toReactive = (value) => (0, _zeus_js_shared.isObject)(value) ? /* @__PURE_
|
|
|
1341
1341
|
*/
|
|
1342
1342
|
const toReadonly = (value) => (0, _zeus_js_shared.isObject)(value) ? /* @__PURE__ */ readonly(value) : value;
|
|
1343
1343
|
//#endregion
|
|
1344
|
-
//#region packages/signal/src/state.ts
|
|
1344
|
+
//#region packages/core/signal/src/state.ts
|
|
1345
1345
|
function state(value) {
|
|
1346
1346
|
if (arguments.length === 0) return /* @__PURE__ */ ref();
|
|
1347
1347
|
return isProxyable(value) ? /* @__PURE__ */ reactive(value) : /* @__PURE__ */ ref(value);
|
|
@@ -1363,7 +1363,7 @@ function isPlainObject$1(value) {
|
|
|
1363
1363
|
return proto === Object.prototype || proto === null;
|
|
1364
1364
|
}
|
|
1365
1365
|
//#endregion
|
|
1366
|
-
//#region packages/signal/src/computed.ts
|
|
1366
|
+
//#region packages/core/signal/src/computed.ts
|
|
1367
1367
|
/**
|
|
1368
1368
|
* @private exported by @vue/reactivity for Vue core use, but not exported from
|
|
1369
1369
|
* the main vue package
|
|
@@ -1416,7 +1416,7 @@ function computed(getterOrOptions, debugOptions, isSSR = false) {
|
|
|
1416
1416
|
return new ComputedRefImpl(getter, setter, isSSR);
|
|
1417
1417
|
}
|
|
1418
1418
|
//#endregion
|
|
1419
|
-
//#region packages/signal/src/scheduler.ts
|
|
1419
|
+
//#region packages/core/signal/src/scheduler.ts
|
|
1420
1420
|
const queue = /* @__PURE__ */ new Set();
|
|
1421
1421
|
let flushing = false;
|
|
1422
1422
|
let pending = false;
|
|
@@ -1442,7 +1442,7 @@ function nextTick() {
|
|
|
1442
1442
|
return Promise.resolve();
|
|
1443
1443
|
}
|
|
1444
1444
|
//#endregion
|
|
1445
|
-
//#region packages/signal/src/watch.ts
|
|
1445
|
+
//#region packages/core/signal/src/watch.ts
|
|
1446
1446
|
let WatchErrorCodes = /* @__PURE__ */ function(WatchErrorCodes) {
|
|
1447
1447
|
WatchErrorCodes[WatchErrorCodes["WATCH_GETTER"] = 2] = "WATCH_GETTER";
|
|
1448
1448
|
WatchErrorCodes[WatchErrorCodes["WATCH_CALLBACK"] = 3] = "WATCH_CALLBACK";
|
|
@@ -1601,7 +1601,7 @@ function traverse(value, depth = Infinity, seen) {
|
|
|
1601
1601
|
return value;
|
|
1602
1602
|
}
|
|
1603
1603
|
//#endregion
|
|
1604
|
-
//#region packages/signal/src/lifecycle.ts
|
|
1604
|
+
//#region packages/core/signal/src/lifecycle.ts
|
|
1605
1605
|
function onCleanup(fn) {
|
|
1606
1606
|
if (getCurrentEffect()) {
|
|
1607
1607
|
onEffectCleanup(fn, true);
|
package/dist/signal.d.ts
CHANGED
|
@@ -3,11 +3,11 @@ export interface ValueState<T = unknown> {
|
|
|
3
3
|
set value(value: T);
|
|
4
4
|
}
|
|
5
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
|
|
6
|
+
export type State<T> = T extends ValueStateInput ? ValueState<T> : T extends ProxyableInput ? Reactive<T> : ValueState<T>;
|
|
7
7
|
type ValueStateInput = null | undefined | Date | RegExp | Error | Promise<any> | Function | Node;
|
|
8
|
-
type Reactive
|
|
8
|
+
type Reactive<T extends object> = T;
|
|
9
9
|
export declare function state<T extends ValueStateInput>(value: T): ValueState<T>;
|
|
10
|
-
export declare function state<T extends ProxyableInput>(value: T): Reactive
|
|
10
|
+
export declare function state<T extends ProxyableInput>(value: T): Reactive<T>;
|
|
11
11
|
export declare function state<T>(value: T): ValueState<T>;
|
|
12
12
|
export declare function state<T = undefined>(): ValueState<T | undefined>;
|
|
13
13
|
export declare function isValueState<T = unknown>(value: unknown): value is ValueState<T>;
|
|
@@ -32,7 +32,6 @@ export declare enum ReactiveFlags {
|
|
|
32
32
|
IS_REF = "__v_isRef"
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
import type { TrackOpTypes, TriggerOpTypes } from './constants';
|
|
36
35
|
export type EffectScheduler = (...args: any[]) => any;
|
|
37
36
|
export type DebuggerEvent = {
|
|
38
37
|
effect: Subscriber;
|
|
@@ -58,7 +57,6 @@ export interface ReactiveEffectRunner<T = any> {
|
|
|
58
57
|
(): T;
|
|
59
58
|
effect: ReactiveEffect;
|
|
60
59
|
}
|
|
61
|
-
declare let activeSub: Subscriber | undefined;
|
|
62
60
|
export declare enum EffectFlags {
|
|
63
61
|
/**
|
|
64
62
|
* ReactiveEffect only
|
|
@@ -139,344 +137,7 @@ export declare function untrack<T>(fn: () => T): T;
|
|
|
139
137
|
*/
|
|
140
138
|
export declare function getCurrentEffect(): ReactiveEffect | undefined;
|
|
141
139
|
|
|
142
|
-
/**
|
|
143
|
-
* Make a map and return a function for checking if a key
|
|
144
|
-
* is in that map.
|
|
145
|
-
* IMPORTANT: all calls of this function must be prefixed with
|
|
146
|
-
* \/\*#\_\_PURE\_\_\*\/
|
|
147
|
-
* So that rollup can tree-shake them if necessary.
|
|
148
|
-
*/
|
|
149
|
-
declare function makeMap(str: string): (key: string) => boolean;
|
|
150
|
-
|
|
151
|
-
declare const EMPTY_OBJ: {
|
|
152
|
-
readonly [key: string]: any;
|
|
153
|
-
};
|
|
154
|
-
declare const EMPTY_ARR: readonly never[];
|
|
155
|
-
declare const NOOP: () => void;
|
|
156
|
-
/**
|
|
157
|
-
* Always return false.
|
|
158
|
-
*/
|
|
159
|
-
declare const NO: () => boolean;
|
|
160
|
-
declare const isOn: (key: string) => boolean;
|
|
161
|
-
declare const isModelListener: (key: string) => key is `onUpdate:${string}`;
|
|
162
|
-
declare const extend: typeof Object.assign;
|
|
163
|
-
declare const remove: <T>(arr: T[], el: T) => void;
|
|
164
|
-
declare const hasOwn: (val: object, key: string | symbol) => key is keyof typeof val;
|
|
165
|
-
declare const isArray: typeof Array.isArray;
|
|
166
|
-
declare const isMap: (val: unknown) => val is Map<any, any>;
|
|
167
|
-
declare const isSet: (val: unknown) => val is Set<any>;
|
|
168
|
-
declare const isDate: (val: unknown) => val is Date;
|
|
169
|
-
declare const isRegExp: (val: unknown) => val is RegExp;
|
|
170
|
-
declare const isFunction: (val: unknown) => val is Function;
|
|
171
|
-
declare const isString: (val: unknown) => val is string;
|
|
172
|
-
declare const isSymbol: (val: unknown) => val is symbol;
|
|
173
|
-
declare const isObject: (val: unknown) => val is Record<any, any>;
|
|
174
|
-
declare const isPromise: <T = any>(val: unknown) => val is Promise<T>;
|
|
175
|
-
declare const objectToString: typeof Object.prototype.toString;
|
|
176
|
-
declare const toTypeString: (value: unknown) => string;
|
|
177
|
-
declare const toRawType: (value: unknown) => string;
|
|
178
|
-
declare const isPlainObject: (val: unknown) => val is object;
|
|
179
|
-
declare const isIntegerKey: (key: unknown) => boolean;
|
|
180
|
-
/**
|
|
181
|
-
* @private
|
|
182
|
-
*/
|
|
183
|
-
declare const camelize: (str: string) => string;
|
|
184
|
-
/**
|
|
185
|
-
* @private
|
|
186
|
-
*/
|
|
187
|
-
declare const hyphenate: (str: string) => string;
|
|
188
|
-
/**
|
|
189
|
-
* @private
|
|
190
|
-
*/
|
|
191
|
-
declare const capitalize: <T extends string>(str: T) => Capitalize<T>;
|
|
192
|
-
/**
|
|
193
|
-
* @private
|
|
194
|
-
*/
|
|
195
|
-
declare const toHandlerKey: <T extends string>(str: T) => T extends '' ? '' : `on${Capitalize<T>}`;
|
|
196
|
-
declare const hasChanged: (value: any, oldValue: any) => boolean;
|
|
197
|
-
declare const invokeArrayFns: (fns: Function[], ...arg: any[]) => void;
|
|
198
|
-
declare const def: (obj: object, key: string | symbol, value: any, writable?: boolean) => void;
|
|
199
|
-
/**
|
|
200
|
-
* "123-foo" will be parsed to 123
|
|
201
|
-
* This is used for the .number modifier in v-model
|
|
202
|
-
*/
|
|
203
|
-
declare const looseToNumber: (val: any) => any;
|
|
204
|
-
/**
|
|
205
|
-
* Only concerns number-like strings
|
|
206
|
-
* "123-foo" will be returned as-is
|
|
207
|
-
*/
|
|
208
|
-
declare const toNumber: (val: any) => any;
|
|
209
|
-
declare const getGlobalThis: () => any;
|
|
210
|
-
declare function genPropsAccessExp(name: string): string;
|
|
211
|
-
declare function genCacheKey(source: string, options: any): string;
|
|
212
|
-
|
|
213
|
-
type Prettify<T> = {
|
|
214
|
-
[K in keyof T]: T[K];
|
|
215
|
-
} & {};
|
|
216
|
-
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
|
|
217
|
-
type LooseRequired<T> = {
|
|
218
|
-
[P in keyof (T & Required<T>)]: T[P];
|
|
219
|
-
};
|
|
220
|
-
type IfAny<T, Y, N> = 0 extends 1 & T ? Y : N;
|
|
221
|
-
type IsKeyValues<T, K = string> = IfAny<T, false, T extends object ? (keyof T extends K ? true : false) : false>;
|
|
222
|
-
/**
|
|
223
|
-
* Utility for extracting the parameters from a function overload (for typed emits)
|
|
224
|
-
* https://github.com/microsoft/TypeScript/issues/32164#issuecomment-1146737709
|
|
225
|
-
*/
|
|
226
|
-
type OverloadParameters<T extends (...args: any[]) => any> = Parameters<OverloadUnion<T>>;
|
|
227
|
-
type OverloadProps<TOverload> = Pick<TOverload, keyof TOverload>;
|
|
228
|
-
type OverloadUnionRecursive<TOverload, TPartialOverload = unknown> = TOverload extends (...args: infer TArgs) => infer TReturn ? TPartialOverload extends TOverload ? never : OverloadUnionRecursive<TPartialOverload & TOverload, TPartialOverload & ((...args: TArgs) => TReturn) & OverloadProps<TOverload>> | ((...args: TArgs) => TReturn) : never;
|
|
229
|
-
type OverloadUnion<TOverload extends (...args: any[]) => any> = Exclude<OverloadUnionRecursive<(() => never) & TOverload>, TOverload extends () => never ? never : () => never>;
|
|
230
|
-
|
|
231
|
-
import { ReactiveFlags } from './constants';
|
|
232
|
-
import type { RawSymbol, Ref, UnwrapRefSimple } from './ref';
|
|
233
|
-
interface Target {
|
|
234
|
-
[ReactiveFlags.SKIP]?: boolean;
|
|
235
|
-
[ReactiveFlags.IS_REACTIVE]?: boolean;
|
|
236
|
-
[ReactiveFlags.IS_READONLY]?: boolean;
|
|
237
|
-
[ReactiveFlags.IS_SHALLOW]?: boolean;
|
|
238
|
-
[ReactiveFlags.RAW]?: any;
|
|
239
|
-
}
|
|
240
|
-
declare const reactiveMap: WeakMap<Target, any>;
|
|
241
|
-
declare const shallowReactiveMap: WeakMap<Target, any>;
|
|
242
|
-
declare const readonlyMap: WeakMap<Target, any>;
|
|
243
|
-
declare const shallowReadonlyMap: WeakMap<Target, any>;
|
|
244
|
-
type UnwrapNestedRefs<T> = T extends Ref ? T : UnwrapRefSimple<T>;
|
|
245
|
-
declare const ReactiveMarkerSymbol: unique symbol;
|
|
246
|
-
interface ReactiveMarker {
|
|
247
|
-
[ReactiveMarkerSymbol]?: void;
|
|
248
|
-
}
|
|
249
|
-
type Reactive<T> = UnwrapNestedRefs<T> & (T extends readonly any[] ? ReactiveMarker : {});
|
|
250
|
-
/**
|
|
251
|
-
* Returns a reactive proxy of the object.
|
|
252
|
-
*
|
|
253
|
-
* The reactive conversion is "deep": it affects all nested properties. A
|
|
254
|
-
* reactive object also deeply unwraps any properties that are refs while
|
|
255
|
-
* maintaining reactivity.
|
|
256
|
-
*
|
|
257
|
-
* @example
|
|
258
|
-
* ```js
|
|
259
|
-
* const obj = reactive({ count: 0 })
|
|
260
|
-
* ```
|
|
261
|
-
*
|
|
262
|
-
* @param target - The source object.
|
|
263
|
-
* @see {@link https://vuejs.org/api/reactivity-core.html#reactive}
|
|
264
|
-
*/
|
|
265
|
-
declare function reactive<T extends object>(target: T): Reactive<T>;
|
|
266
|
-
declare class ShallowReactiveBrandClass {
|
|
267
|
-
private __shallowReactiveBrand?;
|
|
268
|
-
}
|
|
269
|
-
type ShallowReactiveBrand = ShallowReactiveBrandClass;
|
|
270
|
-
type ShallowReactive<T> = T & ShallowReactiveBrand;
|
|
271
|
-
/**
|
|
272
|
-
* Shallow version of {@link reactive}.
|
|
273
|
-
*
|
|
274
|
-
* Unlike {@link reactive}, there is no deep conversion: only root-level
|
|
275
|
-
* properties are reactive for a shallow reactive object. Property values are
|
|
276
|
-
* stored and exposed as-is - this also means properties with ref values will
|
|
277
|
-
* not be automatically unwrapped.
|
|
278
|
-
*
|
|
279
|
-
* @example
|
|
280
|
-
* ```js
|
|
281
|
-
* const state = shallowReactive({
|
|
282
|
-
* foo: 1,
|
|
283
|
-
* nested: {
|
|
284
|
-
* bar: 2
|
|
285
|
-
* }
|
|
286
|
-
* })
|
|
287
|
-
*
|
|
288
|
-
* // mutating state's own properties is reactive
|
|
289
|
-
* state.foo++
|
|
290
|
-
*
|
|
291
|
-
* // ...but does not convert nested objects
|
|
292
|
-
* isReactive(state.nested) // false
|
|
293
|
-
*
|
|
294
|
-
* // NOT reactive
|
|
295
|
-
* state.nested.bar++
|
|
296
|
-
* ```
|
|
297
|
-
*
|
|
298
|
-
* @param target - The source object.
|
|
299
|
-
* @see {@link https://vuejs.org/api/reactivity-advanced.html#shallowreactive}
|
|
300
|
-
*/
|
|
301
|
-
declare function shallowReactive<T extends object>(target: T): ShallowReactive<T>;
|
|
302
|
-
type Primitive = string | number | boolean | bigint | symbol | undefined | null;
|
|
303
|
-
type Builtin = Primitive | Function | Date | Error | RegExp;
|
|
304
|
-
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 {} ? {
|
|
305
|
-
readonly [K in keyof T]: DeepReadonly<T[K]>;
|
|
306
|
-
} : Readonly<T>;
|
|
307
|
-
/**
|
|
308
|
-
* Takes an object (reactive or plain) or a ref and returns a readonly proxy to
|
|
309
|
-
* the original.
|
|
310
|
-
*
|
|
311
|
-
* A readonly proxy is deep: any nested property accessed will be readonly as
|
|
312
|
-
* well. It also has the same ref-unwrapping behavior as {@link reactive},
|
|
313
|
-
* except the unwrapped values will also be made readonly.
|
|
314
|
-
*
|
|
315
|
-
* @example
|
|
316
|
-
* ```js
|
|
317
|
-
* const original = reactive({ count: 0 })
|
|
318
|
-
*
|
|
319
|
-
* const copy = readonly(original)
|
|
320
|
-
*
|
|
321
|
-
* watchEffect(() => {
|
|
322
|
-
* // works for reactivity tracking
|
|
323
|
-
* console.log(copy.count)
|
|
324
|
-
* })
|
|
325
|
-
*
|
|
326
|
-
* // mutating original will trigger watchers relying on the copy
|
|
327
|
-
* original.count++
|
|
328
|
-
*
|
|
329
|
-
* // mutating the copy will fail and result in a warning
|
|
330
|
-
* copy.count++ // warning!
|
|
331
|
-
* ```
|
|
332
|
-
*
|
|
333
|
-
* @param target - The source object.
|
|
334
|
-
* @see {@link https://vuejs.org/api/reactivity-core.html#readonly}
|
|
335
|
-
*/
|
|
336
|
-
declare function readonly<T extends object>(target: T): DeepReadonly<UnwrapNestedRefs<T>>;
|
|
337
|
-
/**
|
|
338
|
-
* Shallow version of {@link readonly}.
|
|
339
|
-
*
|
|
340
|
-
* Unlike {@link readonly}, there is no deep conversion: only root-level
|
|
341
|
-
* properties are made readonly. Property values are stored and exposed as-is -
|
|
342
|
-
* this also means properties with ref values will not be automatically
|
|
343
|
-
* unwrapped.
|
|
344
|
-
*
|
|
345
|
-
* @example
|
|
346
|
-
* ```js
|
|
347
|
-
* const state = shallowReadonly({
|
|
348
|
-
* foo: 1,
|
|
349
|
-
* nested: {
|
|
350
|
-
* bar: 2
|
|
351
|
-
* }
|
|
352
|
-
* })
|
|
353
|
-
*
|
|
354
|
-
* // mutating state's own properties will fail
|
|
355
|
-
* state.foo++
|
|
356
|
-
*
|
|
357
|
-
* // ...but works on nested objects
|
|
358
|
-
* isReadonly(state.nested) // false
|
|
359
|
-
*
|
|
360
|
-
* // works
|
|
361
|
-
* state.nested.bar++
|
|
362
|
-
* ```
|
|
363
|
-
*
|
|
364
|
-
* @param target - The source object.
|
|
365
|
-
* @see {@link https://vuejs.org/api/reactivity-advanced.html#shallowreadonly}
|
|
366
|
-
*/
|
|
367
|
-
declare function shallowReadonly<T extends object>(target: T): Readonly<T>;
|
|
368
|
-
/**
|
|
369
|
-
* Checks if an object is a proxy created by {@link reactive} or
|
|
370
|
-
* {@link shallowReactive} (or {@link ref} in some cases).
|
|
371
|
-
*
|
|
372
|
-
* @example
|
|
373
|
-
* ```js
|
|
374
|
-
* isReactive(reactive({})) // => true
|
|
375
|
-
* isReactive(readonly(reactive({}))) // => true
|
|
376
|
-
* isReactive(ref({}).value) // => true
|
|
377
|
-
* isReactive(readonly(ref({})).value) // => true
|
|
378
|
-
* isReactive(ref(true)) // => false
|
|
379
|
-
* isReactive(shallowRef({}).value) // => false
|
|
380
|
-
* isReactive(shallowReactive({})) // => true
|
|
381
|
-
* ```
|
|
382
|
-
*
|
|
383
|
-
* @param value - The value to check.
|
|
384
|
-
* @see {@link https://vuejs.org/api/reactivity-utilities.html#isreactive}
|
|
385
|
-
*/
|
|
386
|
-
declare function isReactive(value: unknown): boolean;
|
|
387
|
-
/**
|
|
388
|
-
* Checks whether the passed value is a readonly object. The properties of a
|
|
389
|
-
* readonly object can change, but they can't be assigned directly via the
|
|
390
|
-
* passed object.
|
|
391
|
-
*
|
|
392
|
-
* The proxies created by {@link readonly} and {@link shallowReadonly} are
|
|
393
|
-
* both considered readonly, as is a computed ref without a set function.
|
|
394
|
-
*
|
|
395
|
-
* @param value - The value to check.
|
|
396
|
-
* @see {@link https://vuejs.org/api/reactivity-utilities.html#isreadonly}
|
|
397
|
-
*/
|
|
398
|
-
declare function isReadonly(value: unknown): boolean;
|
|
399
|
-
declare function isShallow(value: unknown): boolean;
|
|
400
|
-
/**
|
|
401
|
-
* Checks if an object is a proxy created by {@link reactive},
|
|
402
|
-
* {@link readonly}, {@link shallowReactive} or {@link shallowReadonly}.
|
|
403
|
-
*
|
|
404
|
-
* @param value - The value to check.
|
|
405
|
-
* @see {@link https://vuejs.org/api/reactivity-utilities.html#isproxy}
|
|
406
|
-
*/
|
|
407
|
-
declare function isProxy(value: any): boolean;
|
|
408
|
-
/**
|
|
409
|
-
* Returns the raw, original object of a Vue-created proxy.
|
|
410
|
-
*
|
|
411
|
-
* `toRaw()` can return the original object from proxies created by
|
|
412
|
-
* {@link reactive}, {@link readonly}, {@link shallowReactive} or
|
|
413
|
-
* {@link shallowReadonly}.
|
|
414
|
-
*
|
|
415
|
-
* This is an escape hatch that can be used to temporarily read without
|
|
416
|
-
* incurring proxy access / tracking overhead or write without triggering
|
|
417
|
-
* changes. It is **not** recommended to hold a persistent reference to the
|
|
418
|
-
* original object. Use with caution.
|
|
419
|
-
*
|
|
420
|
-
* @example
|
|
421
|
-
* ```js
|
|
422
|
-
* const foo = {}
|
|
423
|
-
* const reactiveFoo = reactive(foo)
|
|
424
|
-
*
|
|
425
|
-
* console.log(toRaw(reactiveFoo) === foo) // true
|
|
426
|
-
* ```
|
|
427
|
-
*
|
|
428
|
-
* @param observed - The object for which the "raw" value is requested.
|
|
429
|
-
* @see {@link https://vuejs.org/api/reactivity-advanced.html#toraw}
|
|
430
|
-
*/
|
|
431
|
-
declare function toRaw<T>(observed: T): T;
|
|
432
|
-
type Raw<T> = T & {
|
|
433
|
-
[RawSymbol]?: true;
|
|
434
|
-
};
|
|
435
|
-
/**
|
|
436
|
-
* Marks an object so that it will never be converted to a proxy. Returns the
|
|
437
|
-
* object itself.
|
|
438
|
-
*
|
|
439
|
-
* @example
|
|
440
|
-
* ```js
|
|
441
|
-
* const foo = markRaw({})
|
|
442
|
-
* console.log(isReactive(reactive(foo))) // false
|
|
443
|
-
*
|
|
444
|
-
* // also works when nested inside other reactive objects
|
|
445
|
-
* const bar = reactive({ foo })
|
|
446
|
-
* console.log(isReactive(bar.foo)) // false
|
|
447
|
-
* ```
|
|
448
|
-
*
|
|
449
|
-
* **Warning:** `markRaw()` together with the shallow APIs such as
|
|
450
|
-
* {@link shallowReactive} allow you to selectively opt-out of the default
|
|
451
|
-
* deep reactive/readonly conversion and embed raw, non-proxied objects in your
|
|
452
|
-
* state graph.
|
|
453
|
-
*
|
|
454
|
-
* @param value - The object to be marked as "raw".
|
|
455
|
-
* @see {@link https://vuejs.org/api/reactivity-advanced.html#markraw}
|
|
456
|
-
*/
|
|
457
|
-
declare function markRaw<T extends object>(value: T): Raw<T>;
|
|
458
|
-
/**
|
|
459
|
-
* Returns a reactive proxy of the given value (if possible).
|
|
460
|
-
*
|
|
461
|
-
* If the given value is not an object, the original value itself is returned.
|
|
462
|
-
*
|
|
463
|
-
* @param value - The value for which a reactive proxy shall be created.
|
|
464
|
-
*/
|
|
465
|
-
declare const toReactive: <T extends unknown>(value: T) => T;
|
|
466
|
-
/**
|
|
467
|
-
* Returns a readonly proxy of the given value (if possible).
|
|
468
|
-
*
|
|
469
|
-
* If the given value is not an object, the original value itself is returned.
|
|
470
|
-
*
|
|
471
|
-
* @param value - The value for which a readonly proxy shall be created.
|
|
472
|
-
*/
|
|
473
|
-
declare const toReadonly: <T extends unknown>(value: T) => DeepReadonly<T>;
|
|
474
|
-
|
|
475
|
-
import { type IfAny } from '@zeus-js/shared';
|
|
476
|
-
import { type Builtin, type ShallowReactiveBrand } from './reactive';
|
|
477
|
-
import type { ComputedRef, WritableComputedRef } from './computed';
|
|
478
140
|
declare const RefSymbol: unique symbol;
|
|
479
|
-
declare const RawSymbol: unique symbol;
|
|
480
141
|
interface Ref<T = any, S = T> {
|
|
481
142
|
get value(): T;
|
|
482
143
|
set value(_: S);
|
|
@@ -487,219 +148,7 @@ interface Ref<T = any, S = T> {
|
|
|
487
148
|
*/
|
|
488
149
|
[RefSymbol]: true;
|
|
489
150
|
}
|
|
490
|
-
/**
|
|
491
|
-
* Checks if a value is a ref object.
|
|
492
|
-
*
|
|
493
|
-
* @param r - The value to inspect.
|
|
494
|
-
* @see {@link https://vuejs.org/api/reactivity-utilities.html#isref}
|
|
495
|
-
*/
|
|
496
|
-
declare function isRef<T>(r: Ref<T> | unknown): r is Ref<T>;
|
|
497
|
-
/**
|
|
498
|
-
* Takes an inner value and returns a reactive and mutable ref object, which
|
|
499
|
-
* has a single property `.value` that points to the inner value.
|
|
500
|
-
*
|
|
501
|
-
* @param value - The object to wrap in the ref.
|
|
502
|
-
* @see {@link https://vuejs.org/api/reactivity-core.html#ref}
|
|
503
|
-
*/
|
|
504
|
-
declare function ref<T>(value: T): [T] extends [Ref] ? IfAny<T, Ref<T>, T> : Ref<UnwrapRef<T>, UnwrapRef<T> | T>;
|
|
505
|
-
declare function ref<T = any>(): Ref<T | undefined>;
|
|
506
|
-
declare const ShallowRefMarker: unique symbol;type ShallowRef<T = any, S = T> = Ref<T, S> & {
|
|
507
|
-
[ShallowRefMarker]?: true;
|
|
508
|
-
};
|
|
509
|
-
/**
|
|
510
|
-
* Shallow version of {@link ref}.
|
|
511
|
-
*
|
|
512
|
-
* @example
|
|
513
|
-
* ```js
|
|
514
|
-
* const state = shallowRef({ count: 1 })
|
|
515
|
-
*
|
|
516
|
-
* // does NOT trigger change
|
|
517
|
-
* state.value.count = 2
|
|
518
|
-
*
|
|
519
|
-
* // does trigger change
|
|
520
|
-
* state.value = { count: 2 }
|
|
521
|
-
* ```
|
|
522
|
-
*
|
|
523
|
-
* @param value - The "inner value" for the shallow ref.
|
|
524
|
-
* @see {@link https://vuejs.org/api/reactivity-advanced.html#shallowref}
|
|
525
|
-
*/
|
|
526
|
-
declare function shallowRef<T>(value: T): Ref extends T ? T extends Ref ? IfAny<T, ShallowRef<T>, T> : ShallowRef<T> : ShallowRef<T>;
|
|
527
|
-
declare function shallowRef<T = any>(): ShallowRef<T | undefined>;
|
|
528
|
-
/**
|
|
529
|
-
* Force trigger effects that depends on a shallow ref. This is typically used
|
|
530
|
-
* after making deep mutations to the inner value of a shallow ref.
|
|
531
|
-
*
|
|
532
|
-
* @example
|
|
533
|
-
* ```js
|
|
534
|
-
* const shallow = shallowRef({
|
|
535
|
-
* greet: 'Hello, world'
|
|
536
|
-
* })
|
|
537
|
-
*
|
|
538
|
-
* // Logs "Hello, world" once for the first run-through
|
|
539
|
-
* watchEffect(() => {
|
|
540
|
-
* console.log(shallow.value.greet)
|
|
541
|
-
* })
|
|
542
|
-
*
|
|
543
|
-
* // This won't trigger the effect because the ref is shallow
|
|
544
|
-
* shallow.value.greet = 'Hello, universe'
|
|
545
|
-
*
|
|
546
|
-
* // Logs "Hello, universe"
|
|
547
|
-
* triggerRef(shallow)
|
|
548
|
-
* ```
|
|
549
|
-
*
|
|
550
|
-
* @param ref - The ref whose tied effects shall be executed.
|
|
551
|
-
* @see {@link https://vuejs.org/api/reactivity-advanced.html#triggerref}
|
|
552
|
-
*/
|
|
553
|
-
declare function triggerRef(ref: Ref): void;
|
|
554
|
-
type MaybeRef<T = any> = T | Ref<T> | ShallowRef<T> | WritableComputedRef<T>;
|
|
555
|
-
type MaybeRefOrGetter<T = any> = MaybeRef<T> | ComputedRef<T> | (() => T);
|
|
556
|
-
/**
|
|
557
|
-
* Returns the inner value if the argument is a ref, otherwise return the
|
|
558
|
-
* argument itself. This is a sugar function for
|
|
559
|
-
* `val = isRef(val) ? val.value : val`.
|
|
560
|
-
*
|
|
561
|
-
* @example
|
|
562
|
-
* ```js
|
|
563
|
-
* function useFoo(x: number | Ref<number>) {
|
|
564
|
-
* const unwrapped = unref(x)
|
|
565
|
-
* // unwrapped is guaranteed to be number now
|
|
566
|
-
* }
|
|
567
|
-
* ```
|
|
568
|
-
*
|
|
569
|
-
* @param ref - Ref or plain value to be converted into the plain value.
|
|
570
|
-
* @see {@link https://vuejs.org/api/reactivity-utilities.html#unref}
|
|
571
|
-
*/
|
|
572
|
-
declare function unref<T>(ref: MaybeRef<T> | ComputedRef<T>): T;
|
|
573
|
-
/**
|
|
574
|
-
* Normalizes values / refs / getters to values.
|
|
575
|
-
* This is similar to {@link unref}, except that it also normalizes getters.
|
|
576
|
-
* If the argument is a getter, it will be invoked and its return value will
|
|
577
|
-
* be returned.
|
|
578
|
-
*
|
|
579
|
-
* @example
|
|
580
|
-
* ```js
|
|
581
|
-
* toValue(1) // 1
|
|
582
|
-
* toValue(ref(1)) // 1
|
|
583
|
-
* toValue(() => 1) // 1
|
|
584
|
-
* ```
|
|
585
|
-
*
|
|
586
|
-
* @param source - A getter, an existing ref, or a non-function value.
|
|
587
|
-
* @see {@link https://vuejs.org/api/reactivity-utilities.html#tovalue}
|
|
588
|
-
*/
|
|
589
|
-
declare function toValue<T>(source: MaybeRefOrGetter<T>): T;
|
|
590
|
-
/**
|
|
591
|
-
* Returns a proxy for the given object that shallowly unwraps properties that
|
|
592
|
-
* are refs. If the object already is reactive, it's returned as-is. If not, a
|
|
593
|
-
* new reactive proxy is created.
|
|
594
|
-
*
|
|
595
|
-
* @param objectWithRefs - Either an already-reactive object or a simple object
|
|
596
|
-
* that contains refs.
|
|
597
|
-
*/
|
|
598
|
-
declare function proxyRefs<T extends object>(objectWithRefs: T): ShallowUnwrapRef<T>;
|
|
599
|
-
type CustomRefFactory<T, S = T> = (track: () => void, trigger: () => void) => {
|
|
600
|
-
get: () => T;
|
|
601
|
-
set: (value: S) => void;
|
|
602
|
-
};
|
|
603
|
-
/**
|
|
604
|
-
* Creates a customized ref with explicit control over its dependency tracking
|
|
605
|
-
* and updates triggering.
|
|
606
|
-
*
|
|
607
|
-
* @param factory - The function that receives the `track` and `trigger` callbacks.
|
|
608
|
-
* @see {@link https://vuejs.org/api/reactivity-advanced.html#customref}
|
|
609
|
-
*/
|
|
610
|
-
declare function customRef<T, S = T>(factory: CustomRefFactory<T, S>): Ref<T, S>;
|
|
611
|
-
type ToRefs<T = any> = {
|
|
612
|
-
[K in keyof T]: ToRef<T[K]>;
|
|
613
|
-
};
|
|
614
|
-
type ArrayStringKey<T> = T extends readonly any[] ? number extends T['length'] ? `${number}` : never : never;
|
|
615
|
-
type ToRefKey<T> = keyof T | ArrayStringKey<T>;
|
|
616
|
-
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;
|
|
617
|
-
/**
|
|
618
|
-
* Converts a reactive object to a plain object where each property of the
|
|
619
|
-
* resulting object is a ref pointing to the corresponding property of the
|
|
620
|
-
* original object. Each individual ref is created using {@link toRef}.
|
|
621
|
-
*
|
|
622
|
-
* @param object - Reactive object to be made into an object of linked refs.
|
|
623
|
-
* @see {@link https://vuejs.org/api/reactivity-utilities.html#torefs}
|
|
624
|
-
*/
|
|
625
|
-
declare function toRefs<T extends object>(object: T): ToRefs<T>;
|
|
626
|
-
type ToRef<T> = IfAny<T, Ref<T>, [T] extends [Ref] ? T : Ref<T>>;
|
|
627
|
-
/**
|
|
628
|
-
* Used to normalize values / refs / getters into refs.
|
|
629
|
-
*
|
|
630
|
-
* @example
|
|
631
|
-
* ```js
|
|
632
|
-
* // returns existing refs as-is
|
|
633
|
-
* toRef(existingRef)
|
|
634
|
-
*
|
|
635
|
-
* // creates a ref that calls the getter on .value access
|
|
636
|
-
* toRef(() => props.foo)
|
|
637
|
-
*
|
|
638
|
-
* // creates normal refs from non-function values
|
|
639
|
-
* // equivalent to ref(1)
|
|
640
|
-
* toRef(1)
|
|
641
|
-
* ```
|
|
642
|
-
*
|
|
643
|
-
* Can also be used to create a ref for a property on a source reactive object.
|
|
644
|
-
* The created ref is synced with its source property: mutating the source
|
|
645
|
-
* property will update the ref, and vice-versa.
|
|
646
|
-
*
|
|
647
|
-
* @example
|
|
648
|
-
* ```js
|
|
649
|
-
* const state = reactive({
|
|
650
|
-
* foo: 1,
|
|
651
|
-
* bar: 2
|
|
652
|
-
* })
|
|
653
|
-
*
|
|
654
|
-
* const fooRef = toRef(state, 'foo')
|
|
655
|
-
*
|
|
656
|
-
* // mutating the ref updates the original
|
|
657
|
-
* fooRef.value++
|
|
658
|
-
* console.log(state.foo) // 2
|
|
659
|
-
*
|
|
660
|
-
* // mutating the original also updates the ref
|
|
661
|
-
* state.foo++
|
|
662
|
-
* console.log(fooRef.value) // 3
|
|
663
|
-
* ```
|
|
664
|
-
*
|
|
665
|
-
* @param source - A getter, an existing ref, a non-function value, or a
|
|
666
|
-
* reactive object to create a property ref from.
|
|
667
|
-
* @param [key] - (optional) Name of the property in the reactive object.
|
|
668
|
-
* @see {@link https://vuejs.org/api/reactivity-utilities.html#toref}
|
|
669
|
-
*/
|
|
670
|
-
declare function toRef<T>(value: T): T extends () => infer R ? Readonly<Ref<R>> : T extends Ref ? T : Ref<UnwrapRef<T>>;
|
|
671
|
-
declare function toRef<T extends object, K extends ToRefKey<T>>(object: T, key: K): ToRef<ToRefValue<T, K>>;
|
|
672
|
-
declare function toRef<T extends object, K extends ToRefKey<T>>(object: T, key: K, defaultValue: ToRefValue<T, K>): ToRef<Exclude<ToRefValue<T, K>, undefined>>;
|
|
673
|
-
/**
|
|
674
|
-
* This is a special exported interface for other packages to declare
|
|
675
|
-
* additional types that should bail out for ref unwrapping. For example
|
|
676
|
-
* \@vue/runtime-dom can declare it like so in its d.ts:
|
|
677
|
-
*
|
|
678
|
-
* ``` ts
|
|
679
|
-
* declare module '@vue/reactivity' {
|
|
680
|
-
* export interface RefUnwrapBailTypes {
|
|
681
|
-
* runtimeDOMBailTypes: Node | Window
|
|
682
|
-
* }
|
|
683
|
-
* }
|
|
684
|
-
* ```
|
|
685
|
-
*/
|
|
686
|
-
interface RefUnwrapBailTypes {
|
|
687
|
-
}
|
|
688
|
-
type ShallowUnwrapRef<T> = T extends ShallowReactiveBrand ? T : {
|
|
689
|
-
[K in keyof T]: DistributeRef<T[K]>;
|
|
690
|
-
};
|
|
691
|
-
type DistributeRef<T> = T extends Ref<infer V, unknown> ? V : T;
|
|
692
|
-
type UnwrapRef<T> = T extends ShallowRef<infer V, unknown> ? V : T extends Ref<infer V, unknown> ? UnwrapRefSimple<V> : UnwrapRefSimple<T>;
|
|
693
|
-
type UnwrapRefSimple<T> = T extends Builtin | Ref | RefUnwrapBailTypes[keyof RefUnwrapBailTypes] | {
|
|
694
|
-
[RawSymbol]?: true;
|
|
695
|
-
} ? 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> ? {
|
|
696
|
-
[K in keyof T]: UnwrapRefSimple<T[K]>;
|
|
697
|
-
} : T extends object ? {
|
|
698
|
-
[P in keyof T]: P extends symbol ? T[P] : UnwrapRef<T[P]>;
|
|
699
|
-
} : T;
|
|
700
151
|
|
|
701
|
-
import { type DebuggerEvent, type DebuggerOptions, type Subscriber } from './effect';
|
|
702
|
-
import type { Ref } from './ref';
|
|
703
152
|
declare const ComputedRefSymbol: unique symbol;
|
|
704
153
|
declare const WritableComputedRefSymbol: unique symbol;
|
|
705
154
|
interface BaseComputedRef<T, S = T> extends Ref<T, S> {
|
|
@@ -775,15 +224,6 @@ export declare function queueJob(job: () => void): void;
|
|
|
775
224
|
export declare function flushJobs(): void;
|
|
776
225
|
export declare function nextTick(): Promise<void>;
|
|
777
226
|
|
|
778
|
-
import { type TrackOpTypes, TriggerOpTypes } from './constants';
|
|
779
|
-
/**
|
|
780
|
-
* Incremented every time a reactive change happens
|
|
781
|
-
* This is used to give computed a fast path to avoid re-compute when nothing
|
|
782
|
-
* has changed.
|
|
783
|
-
*/
|
|
784
|
-
declare let globalVersion: number;
|
|
785
|
-
type KeyToDepMap = Map<any, Dep>;
|
|
786
|
-
declare const targetMap: WeakMap<object, KeyToDepMap>;
|
|
787
227
|
export declare const ITERATE_KEY: unique symbol;
|
|
788
228
|
export declare const MAP_KEY_ITERATE_KEY: unique symbol;
|
|
789
229
|
export declare const ARRAY_ITERATE_KEY: unique symbol;
|
|
@@ -807,9 +247,7 @@ export declare function track(target: object, type: TrackOpTypes, key: unknown):
|
|
|
807
247
|
* @param key - Can be used to target a specific reactive property in the target object.
|
|
808
248
|
*/
|
|
809
249
|
export declare function trigger(target: object, type: TriggerOpTypes, key?: unknown, newValue?: unknown, oldValue?: unknown, oldTarget?: Map<unknown, unknown> | Set<unknown>): void;
|
|
810
|
-
declare function getDepFromReactive(object: any, key: string | number | symbol): Dep | undefined;
|
|
811
250
|
|
|
812
|
-
declare let activeEffectScope: EffectScope | undefined;
|
|
813
251
|
export declare class EffectScope {
|
|
814
252
|
detached: boolean;
|
|
815
253
|
private _isPaused;
|
|
@@ -861,11 +299,7 @@ export declare function reactiveReadArray<T>(array: T[]): T[];
|
|
|
861
299
|
* Track array iteration and return raw array
|
|
862
300
|
*/
|
|
863
301
|
export declare function shallowReadArray<T>(arr: T[]): T[];
|
|
864
|
-
declare const arrayInstrumentations: Record<string | symbol, Function>;
|
|
865
302
|
|
|
866
|
-
import { type DebuggerOptions, ReactiveEffect } from './effect';
|
|
867
|
-
import { type Ref } from './ref';
|
|
868
|
-
import type { ComputedRef } from './computed';
|
|
869
303
|
export declare enum WatchErrorCodes {
|
|
870
304
|
WATCH_GETTER = 2,
|
|
871
305
|
WATCH_CALLBACK = 3,
|
|
@@ -911,4 +345,3 @@ export declare function traverse(value: unknown, depth?: number, seen?: Map<unkn
|
|
|
911
345
|
export declare function onCleanup(fn: () => void): void;
|
|
912
346
|
|
|
913
347
|
export { EffectScope as Scope, effectScope as scope, };
|
|
914
|
-
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* signal v0.0.
|
|
2
|
+
* signal v0.1.0-beta.0
|
|
3
3
|
* (c) 2026 baicie
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
**/
|
|
6
|
-
//#region packages/shared/src/makeMap.ts
|
|
6
|
+
//#region packages/core/shared/src/makeMap.ts
|
|
7
7
|
/**
|
|
8
8
|
* Make a map and return a function for checking if a key
|
|
9
9
|
* is in that map.
|
|
@@ -18,7 +18,7 @@ function makeMap(str) {
|
|
|
18
18
|
return (val) => val in map;
|
|
19
19
|
}
|
|
20
20
|
//#endregion
|
|
21
|
-
//#region packages/shared/src/general.ts
|
|
21
|
+
//#region packages/core/shared/src/general.ts
|
|
22
22
|
const EMPTY_OBJ = Object.freeze({});
|
|
23
23
|
Object.freeze([]);
|
|
24
24
|
const NOOP = () => {};
|
|
@@ -57,7 +57,7 @@ const capitalize = cacheStringFunction((str) => {
|
|
|
57
57
|
});
|
|
58
58
|
const hasChanged = (value, oldValue) => !Object.is(value, oldValue);
|
|
59
59
|
//#endregion
|
|
60
|
-
//#region packages/signal/src/constants.ts
|
|
60
|
+
//#region packages/core/signal/src/constants.ts
|
|
61
61
|
let TrackOpTypes = /* @__PURE__ */ function(TrackOpTypes) {
|
|
62
62
|
TrackOpTypes["GET"] = "get";
|
|
63
63
|
TrackOpTypes["HAS"] = "has";
|
|
@@ -81,12 +81,12 @@ let ReactiveFlags = /* @__PURE__ */ function(ReactiveFlags) {
|
|
|
81
81
|
return ReactiveFlags;
|
|
82
82
|
}({});
|
|
83
83
|
//#endregion
|
|
84
|
-
//#region packages/signal/src/warning.ts
|
|
84
|
+
//#region packages/core/signal/src/warning.ts
|
|
85
85
|
function warn(msg, ...args) {
|
|
86
86
|
console.warn(`[Zeus warn] ${msg}`, ...args);
|
|
87
87
|
}
|
|
88
88
|
//#endregion
|
|
89
|
-
//#region packages/signal/src/effectScope.ts
|
|
89
|
+
//#region packages/core/signal/src/effectScope.ts
|
|
90
90
|
let activeEffectScope;
|
|
91
91
|
var EffectScope = class {
|
|
92
92
|
constructor(detached = false) {
|
|
@@ -226,7 +226,7 @@ function onScopeDispose(fn, failSilently = false) {
|
|
|
226
226
|
else if (!failSilently) warn("onScopeDispose() is called when there is no active effect scope to be associated with.");
|
|
227
227
|
}
|
|
228
228
|
//#endregion
|
|
229
|
-
//#region packages/signal/src/effect.ts
|
|
229
|
+
//#region packages/core/signal/src/effect.ts
|
|
230
230
|
let activeSub;
|
|
231
231
|
let EffectFlags = /* @__PURE__ */ function(EffectFlags) {
|
|
232
232
|
/**
|
|
@@ -580,7 +580,7 @@ function getCurrentEffect() {
|
|
|
580
580
|
return activeSub instanceof ReactiveEffect ? activeSub : void 0;
|
|
581
581
|
}
|
|
582
582
|
//#endregion
|
|
583
|
-
//#region packages/signal/src/dep.ts
|
|
583
|
+
//#region packages/core/signal/src/dep.ts
|
|
584
584
|
/**
|
|
585
585
|
* Incremented every time a reactive change happens
|
|
586
586
|
* This is used to give computed a fast path to avoid re-compute when nothing
|
|
@@ -771,7 +771,7 @@ function trigger(target, type, key, newValue, oldValue, oldTarget) {
|
|
|
771
771
|
endBatch();
|
|
772
772
|
}
|
|
773
773
|
//#endregion
|
|
774
|
-
//#region packages/signal/src/arrayInstrumentations.ts
|
|
774
|
+
//#region packages/core/signal/src/arrayInstrumentations.ts
|
|
775
775
|
/**
|
|
776
776
|
* Track array iteration and return:
|
|
777
777
|
* - if input is reactive: a cloned raw array with reactive values
|
|
@@ -956,7 +956,7 @@ function noTracking(self, method, args = []) {
|
|
|
956
956
|
return res;
|
|
957
957
|
}
|
|
958
958
|
//#endregion
|
|
959
|
-
//#region packages/signal/src/ref.ts
|
|
959
|
+
//#region packages/core/signal/src/ref.ts
|
|
960
960
|
let _ReactiveFlags$IS_REF, _ReactiveFlags$IS_SHA;
|
|
961
961
|
/*@__NO_SIDE_EFFECTS__*/
|
|
962
962
|
function isRef(r) {
|
|
@@ -1010,7 +1010,7 @@ var RefImpl = class {
|
|
|
1010
1010
|
}
|
|
1011
1011
|
};
|
|
1012
1012
|
//#endregion
|
|
1013
|
-
//#region packages/signal/src/baseHandlers.ts
|
|
1013
|
+
//#region packages/core/signal/src/baseHandlers.ts
|
|
1014
1014
|
const isNonTrackableKeys = /*@__PURE__*/ makeMap(`__proto__,__v_isRef,__isVue`);
|
|
1015
1015
|
const builtInSymbols = new Set(/*@__PURE__*/ Object.getOwnPropertyNames(Symbol).filter((key) => key !== "arguments" && key !== "caller").map((key) => Symbol[key]).filter(isSymbol));
|
|
1016
1016
|
function hasOwnProperty(key) {
|
|
@@ -1114,7 +1114,7 @@ var ReadonlyReactiveHandler = class extends BaseReactiveHandler {
|
|
|
1114
1114
|
const mutableHandlers = /*@__PURE__*/ new MutableReactiveHandler();
|
|
1115
1115
|
const readonlyHandlers = /*@__PURE__*/ new ReadonlyReactiveHandler();
|
|
1116
1116
|
//#endregion
|
|
1117
|
-
//#region packages/signal/src/collectionHandlers.ts
|
|
1117
|
+
//#region packages/core/signal/src/collectionHandlers.ts
|
|
1118
1118
|
const toShallow = (value) => value;
|
|
1119
1119
|
const getProto = (v) => Reflect.getPrototypeOf(v);
|
|
1120
1120
|
function createIterableMethod(method, isReadonly, isShallow) {
|
|
@@ -1273,7 +1273,7 @@ function checkIdentityKeys(target, has, key) {
|
|
|
1273
1273
|
}
|
|
1274
1274
|
}
|
|
1275
1275
|
//#endregion
|
|
1276
|
-
//#region packages/signal/src/reactive.ts
|
|
1276
|
+
//#region packages/core/signal/src/reactive.ts
|
|
1277
1277
|
const reactiveMap = /* @__PURE__ */ new WeakMap();
|
|
1278
1278
|
const shallowReactiveMap = /* @__PURE__ */ new WeakMap();
|
|
1279
1279
|
const readonlyMap = /* @__PURE__ */ new WeakMap();
|
|
@@ -1442,7 +1442,7 @@ const toReactive = (value) => isObject(value) ? /* @__PURE__ */ reactive(value)
|
|
|
1442
1442
|
*/
|
|
1443
1443
|
const toReadonly = (value) => isObject(value) ? /* @__PURE__ */ readonly(value) : value;
|
|
1444
1444
|
//#endregion
|
|
1445
|
-
//#region packages/signal/src/state.ts
|
|
1445
|
+
//#region packages/core/signal/src/state.ts
|
|
1446
1446
|
function state(value) {
|
|
1447
1447
|
if (arguments.length === 0) return /* @__PURE__ */ ref();
|
|
1448
1448
|
return isProxyable(value) ? /* @__PURE__ */ reactive(value) : /* @__PURE__ */ ref(value);
|
|
@@ -1464,7 +1464,7 @@ function isPlainObject(value) {
|
|
|
1464
1464
|
return proto === Object.prototype || proto === null;
|
|
1465
1465
|
}
|
|
1466
1466
|
//#endregion
|
|
1467
|
-
//#region packages/signal/src/computed.ts
|
|
1467
|
+
//#region packages/core/signal/src/computed.ts
|
|
1468
1468
|
/**
|
|
1469
1469
|
* @private exported by @vue/reactivity for Vue core use, but not exported from
|
|
1470
1470
|
* the main vue package
|
|
@@ -1527,7 +1527,7 @@ function computed(getterOrOptions, debugOptions, isSSR = false) {
|
|
|
1527
1527
|
return cRef;
|
|
1528
1528
|
}
|
|
1529
1529
|
//#endregion
|
|
1530
|
-
//#region packages/signal/src/scheduler.ts
|
|
1530
|
+
//#region packages/core/signal/src/scheduler.ts
|
|
1531
1531
|
const queue = /* @__PURE__ */ new Set();
|
|
1532
1532
|
let flushing = false;
|
|
1533
1533
|
let pending = false;
|
|
@@ -1553,7 +1553,7 @@ function nextTick() {
|
|
|
1553
1553
|
return Promise.resolve();
|
|
1554
1554
|
}
|
|
1555
1555
|
//#endregion
|
|
1556
|
-
//#region packages/signal/src/watch.ts
|
|
1556
|
+
//#region packages/core/signal/src/watch.ts
|
|
1557
1557
|
let WatchErrorCodes = /* @__PURE__ */ function(WatchErrorCodes) {
|
|
1558
1558
|
WatchErrorCodes[WatchErrorCodes["WATCH_GETTER"] = 2] = "WATCH_GETTER";
|
|
1559
1559
|
WatchErrorCodes[WatchErrorCodes["WATCH_CALLBACK"] = 3] = "WATCH_CALLBACK";
|
|
@@ -1721,7 +1721,7 @@ function traverse(value, depth = Infinity, seen) {
|
|
|
1721
1721
|
return value;
|
|
1722
1722
|
}
|
|
1723
1723
|
//#endregion
|
|
1724
|
-
//#region packages/signal/src/lifecycle.ts
|
|
1724
|
+
//#region packages/core/signal/src/lifecycle.ts
|
|
1725
1725
|
function onCleanup(fn) {
|
|
1726
1726
|
if (getCurrentEffect()) {
|
|
1727
1727
|
onEffectCleanup(fn, true);
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* signal v0.0.
|
|
2
|
+
* signal v0.1.0-beta.0
|
|
3
3
|
* (c) 2026 baicie
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
**/
|
|
6
6
|
import { EMPTY_OBJ, NOOP, capitalize, extend, hasChanged, hasOwn, isArray, isFunction, isIntegerKey, isMap, isObject, isPlainObject, isSet, isSymbol, makeMap, remove, toRawType } from "@zeus-js/shared";
|
|
7
|
-
//#region packages/signal/src/constants.ts
|
|
7
|
+
//#region packages/core/signal/src/constants.ts
|
|
8
8
|
let TrackOpTypes = /* @__PURE__ */ function(TrackOpTypes) {
|
|
9
9
|
TrackOpTypes["GET"] = "get";
|
|
10
10
|
TrackOpTypes["HAS"] = "has";
|
|
@@ -28,12 +28,12 @@ let ReactiveFlags = /* @__PURE__ */ function(ReactiveFlags) {
|
|
|
28
28
|
return ReactiveFlags;
|
|
29
29
|
}({});
|
|
30
30
|
//#endregion
|
|
31
|
-
//#region packages/signal/src/warning.ts
|
|
31
|
+
//#region packages/core/signal/src/warning.ts
|
|
32
32
|
function warn(msg, ...args) {
|
|
33
33
|
console.warn(`[Zeus warn] ${msg}`, ...args);
|
|
34
34
|
}
|
|
35
35
|
//#endregion
|
|
36
|
-
//#region packages/signal/src/effectScope.ts
|
|
36
|
+
//#region packages/core/signal/src/effectScope.ts
|
|
37
37
|
let activeEffectScope;
|
|
38
38
|
var EffectScope = class {
|
|
39
39
|
constructor(detached = false) {
|
|
@@ -173,7 +173,7 @@ function onScopeDispose(fn, failSilently = false) {
|
|
|
173
173
|
else if (!failSilently) warn("onScopeDispose() is called when there is no active effect scope to be associated with.");
|
|
174
174
|
}
|
|
175
175
|
//#endregion
|
|
176
|
-
//#region packages/signal/src/effect.ts
|
|
176
|
+
//#region packages/core/signal/src/effect.ts
|
|
177
177
|
let activeSub;
|
|
178
178
|
let EffectFlags = /* @__PURE__ */ function(EffectFlags) {
|
|
179
179
|
/**
|
|
@@ -527,7 +527,7 @@ function getCurrentEffect() {
|
|
|
527
527
|
return activeSub instanceof ReactiveEffect ? activeSub : void 0;
|
|
528
528
|
}
|
|
529
529
|
//#endregion
|
|
530
|
-
//#region packages/signal/src/dep.ts
|
|
530
|
+
//#region packages/core/signal/src/dep.ts
|
|
531
531
|
/**
|
|
532
532
|
* Incremented every time a reactive change happens
|
|
533
533
|
* This is used to give computed a fast path to avoid re-compute when nothing
|
|
@@ -718,7 +718,7 @@ function trigger(target, type, key, newValue, oldValue, oldTarget) {
|
|
|
718
718
|
endBatch();
|
|
719
719
|
}
|
|
720
720
|
//#endregion
|
|
721
|
-
//#region packages/signal/src/arrayInstrumentations.ts
|
|
721
|
+
//#region packages/core/signal/src/arrayInstrumentations.ts
|
|
722
722
|
/**
|
|
723
723
|
* Track array iteration and return:
|
|
724
724
|
* - if input is reactive: a cloned raw array with reactive values
|
|
@@ -903,7 +903,7 @@ function noTracking(self, method, args = []) {
|
|
|
903
903
|
return res;
|
|
904
904
|
}
|
|
905
905
|
//#endregion
|
|
906
|
-
//#region packages/signal/src/ref.ts
|
|
906
|
+
//#region packages/core/signal/src/ref.ts
|
|
907
907
|
let _ReactiveFlags$IS_REF, _ReactiveFlags$IS_SHA;
|
|
908
908
|
/*@__NO_SIDE_EFFECTS__*/
|
|
909
909
|
function isRef(r) {
|
|
@@ -957,7 +957,7 @@ var RefImpl = class {
|
|
|
957
957
|
}
|
|
958
958
|
};
|
|
959
959
|
//#endregion
|
|
960
|
-
//#region packages/signal/src/baseHandlers.ts
|
|
960
|
+
//#region packages/core/signal/src/baseHandlers.ts
|
|
961
961
|
const isNonTrackableKeys = /*@__PURE__*/ makeMap(`__proto__,__v_isRef,__isVue`);
|
|
962
962
|
const builtInSymbols = new Set(/*@__PURE__*/ Object.getOwnPropertyNames(Symbol).filter((key) => key !== "arguments" && key !== "caller").map((key) => Symbol[key]).filter(isSymbol));
|
|
963
963
|
function hasOwnProperty(key) {
|
|
@@ -1061,7 +1061,7 @@ var ReadonlyReactiveHandler = class extends BaseReactiveHandler {
|
|
|
1061
1061
|
const mutableHandlers = /*@__PURE__*/ new MutableReactiveHandler();
|
|
1062
1062
|
const readonlyHandlers = /*@__PURE__*/ new ReadonlyReactiveHandler();
|
|
1063
1063
|
//#endregion
|
|
1064
|
-
//#region packages/signal/src/collectionHandlers.ts
|
|
1064
|
+
//#region packages/core/signal/src/collectionHandlers.ts
|
|
1065
1065
|
const toShallow = (value) => value;
|
|
1066
1066
|
const getProto = (v) => Reflect.getPrototypeOf(v);
|
|
1067
1067
|
function createIterableMethod(method, isReadonly, isShallow) {
|
|
@@ -1220,7 +1220,7 @@ function checkIdentityKeys(target, has, key) {
|
|
|
1220
1220
|
}
|
|
1221
1221
|
}
|
|
1222
1222
|
//#endregion
|
|
1223
|
-
//#region packages/signal/src/reactive.ts
|
|
1223
|
+
//#region packages/core/signal/src/reactive.ts
|
|
1224
1224
|
const reactiveMap = /* @__PURE__ */ new WeakMap();
|
|
1225
1225
|
const shallowReactiveMap = /* @__PURE__ */ new WeakMap();
|
|
1226
1226
|
const readonlyMap = /* @__PURE__ */ new WeakMap();
|
|
@@ -1389,7 +1389,7 @@ const toReactive = (value) => isObject(value) ? /* @__PURE__ */ reactive(value)
|
|
|
1389
1389
|
*/
|
|
1390
1390
|
const toReadonly = (value) => isObject(value) ? /* @__PURE__ */ readonly(value) : value;
|
|
1391
1391
|
//#endregion
|
|
1392
|
-
//#region packages/signal/src/state.ts
|
|
1392
|
+
//#region packages/core/signal/src/state.ts
|
|
1393
1393
|
function state(value) {
|
|
1394
1394
|
if (arguments.length === 0) return /* @__PURE__ */ ref();
|
|
1395
1395
|
return isProxyable(value) ? /* @__PURE__ */ reactive(value) : /* @__PURE__ */ ref(value);
|
|
@@ -1411,7 +1411,7 @@ function isPlainObject$1(value) {
|
|
|
1411
1411
|
return proto === Object.prototype || proto === null;
|
|
1412
1412
|
}
|
|
1413
1413
|
//#endregion
|
|
1414
|
-
//#region packages/signal/src/computed.ts
|
|
1414
|
+
//#region packages/core/signal/src/computed.ts
|
|
1415
1415
|
/**
|
|
1416
1416
|
* @private exported by @vue/reactivity for Vue core use, but not exported from
|
|
1417
1417
|
* the main vue package
|
|
@@ -1474,7 +1474,7 @@ function computed(getterOrOptions, debugOptions, isSSR = false) {
|
|
|
1474
1474
|
return cRef;
|
|
1475
1475
|
}
|
|
1476
1476
|
//#endregion
|
|
1477
|
-
//#region packages/signal/src/scheduler.ts
|
|
1477
|
+
//#region packages/core/signal/src/scheduler.ts
|
|
1478
1478
|
const queue = /* @__PURE__ */ new Set();
|
|
1479
1479
|
let flushing = false;
|
|
1480
1480
|
let pending = false;
|
|
@@ -1500,7 +1500,7 @@ function nextTick() {
|
|
|
1500
1500
|
return Promise.resolve();
|
|
1501
1501
|
}
|
|
1502
1502
|
//#endregion
|
|
1503
|
-
//#region packages/signal/src/watch.ts
|
|
1503
|
+
//#region packages/core/signal/src/watch.ts
|
|
1504
1504
|
let WatchErrorCodes = /* @__PURE__ */ function(WatchErrorCodes) {
|
|
1505
1505
|
WatchErrorCodes[WatchErrorCodes["WATCH_GETTER"] = 2] = "WATCH_GETTER";
|
|
1506
1506
|
WatchErrorCodes[WatchErrorCodes["WATCH_CALLBACK"] = 3] = "WATCH_CALLBACK";
|
|
@@ -1668,7 +1668,7 @@ function traverse(value, depth = Infinity, seen) {
|
|
|
1668
1668
|
return value;
|
|
1669
1669
|
}
|
|
1670
1670
|
//#endregion
|
|
1671
|
-
//#region packages/signal/src/lifecycle.ts
|
|
1671
|
+
//#region packages/core/signal/src/lifecycle.ts
|
|
1672
1672
|
function onCleanup(fn) {
|
|
1673
1673
|
if (getCurrentEffect()) {
|
|
1674
1674
|
onEffectCleanup(fn, true);
|
package/dist/signal.global.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* signal v0.0.
|
|
2
|
+
* signal v0.1.0-beta.0
|
|
3
3
|
* (c) 2026 baicie
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
**/
|
|
6
6
|
var ZeusSignal = (function(exports) {
|
|
7
7
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
8
|
-
//#region packages/shared/src/makeMap.ts
|
|
8
|
+
//#region packages/core/shared/src/makeMap.ts
|
|
9
9
|
/**
|
|
10
10
|
* Make a map and return a function for checking if a key
|
|
11
11
|
* is in that map.
|
|
@@ -20,7 +20,7 @@ var ZeusSignal = (function(exports) {
|
|
|
20
20
|
return (val) => val in map;
|
|
21
21
|
}
|
|
22
22
|
//#endregion
|
|
23
|
-
//#region packages/shared/src/general.ts
|
|
23
|
+
//#region packages/core/shared/src/general.ts
|
|
24
24
|
const EMPTY_OBJ = Object.freeze({});
|
|
25
25
|
Object.freeze([]);
|
|
26
26
|
const NOOP = () => {};
|
|
@@ -59,7 +59,7 @@ var ZeusSignal = (function(exports) {
|
|
|
59
59
|
});
|
|
60
60
|
const hasChanged = (value, oldValue) => !Object.is(value, oldValue);
|
|
61
61
|
//#endregion
|
|
62
|
-
//#region packages/signal/src/constants.ts
|
|
62
|
+
//#region packages/core/signal/src/constants.ts
|
|
63
63
|
let TrackOpTypes = /* @__PURE__ */ function(TrackOpTypes) {
|
|
64
64
|
TrackOpTypes["GET"] = "get";
|
|
65
65
|
TrackOpTypes["HAS"] = "has";
|
|
@@ -83,12 +83,12 @@ var ZeusSignal = (function(exports) {
|
|
|
83
83
|
return ReactiveFlags;
|
|
84
84
|
}({});
|
|
85
85
|
//#endregion
|
|
86
|
-
//#region packages/signal/src/warning.ts
|
|
86
|
+
//#region packages/core/signal/src/warning.ts
|
|
87
87
|
function warn(msg, ...args) {
|
|
88
88
|
console.warn(`[Zeus warn] ${msg}`, ...args);
|
|
89
89
|
}
|
|
90
90
|
//#endregion
|
|
91
|
-
//#region packages/signal/src/effectScope.ts
|
|
91
|
+
//#region packages/core/signal/src/effectScope.ts
|
|
92
92
|
let activeEffectScope;
|
|
93
93
|
var EffectScope = class {
|
|
94
94
|
constructor(detached = false) {
|
|
@@ -228,7 +228,7 @@ var ZeusSignal = (function(exports) {
|
|
|
228
228
|
else if (!failSilently) warn("onScopeDispose() is called when there is no active effect scope to be associated with.");
|
|
229
229
|
}
|
|
230
230
|
//#endregion
|
|
231
|
-
//#region packages/signal/src/effect.ts
|
|
231
|
+
//#region packages/core/signal/src/effect.ts
|
|
232
232
|
let activeSub;
|
|
233
233
|
let EffectFlags = /* @__PURE__ */ function(EffectFlags) {
|
|
234
234
|
/**
|
|
@@ -582,7 +582,7 @@ var ZeusSignal = (function(exports) {
|
|
|
582
582
|
return activeSub instanceof ReactiveEffect ? activeSub : void 0;
|
|
583
583
|
}
|
|
584
584
|
//#endregion
|
|
585
|
-
//#region packages/signal/src/dep.ts
|
|
585
|
+
//#region packages/core/signal/src/dep.ts
|
|
586
586
|
/**
|
|
587
587
|
* Incremented every time a reactive change happens
|
|
588
588
|
* This is used to give computed a fast path to avoid re-compute when nothing
|
|
@@ -773,7 +773,7 @@ var ZeusSignal = (function(exports) {
|
|
|
773
773
|
endBatch();
|
|
774
774
|
}
|
|
775
775
|
//#endregion
|
|
776
|
-
//#region packages/signal/src/arrayInstrumentations.ts
|
|
776
|
+
//#region packages/core/signal/src/arrayInstrumentations.ts
|
|
777
777
|
/**
|
|
778
778
|
* Track array iteration and return:
|
|
779
779
|
* - if input is reactive: a cloned raw array with reactive values
|
|
@@ -958,7 +958,7 @@ var ZeusSignal = (function(exports) {
|
|
|
958
958
|
return res;
|
|
959
959
|
}
|
|
960
960
|
//#endregion
|
|
961
|
-
//#region packages/signal/src/ref.ts
|
|
961
|
+
//#region packages/core/signal/src/ref.ts
|
|
962
962
|
let _ReactiveFlags$IS_REF, _ReactiveFlags$IS_SHA;
|
|
963
963
|
/*@__NO_SIDE_EFFECTS__*/
|
|
964
964
|
function isRef(r) {
|
|
@@ -1012,7 +1012,7 @@ var ZeusSignal = (function(exports) {
|
|
|
1012
1012
|
}
|
|
1013
1013
|
};
|
|
1014
1014
|
//#endregion
|
|
1015
|
-
//#region packages/signal/src/baseHandlers.ts
|
|
1015
|
+
//#region packages/core/signal/src/baseHandlers.ts
|
|
1016
1016
|
const isNonTrackableKeys = /*@__PURE__*/ makeMap(`__proto__,__v_isRef,__isVue`);
|
|
1017
1017
|
const builtInSymbols = new Set(/*@__PURE__*/ Object.getOwnPropertyNames(Symbol).filter((key) => key !== "arguments" && key !== "caller").map((key) => Symbol[key]).filter(isSymbol));
|
|
1018
1018
|
function hasOwnProperty(key) {
|
|
@@ -1116,7 +1116,7 @@ var ZeusSignal = (function(exports) {
|
|
|
1116
1116
|
const mutableHandlers = /*@__PURE__*/ new MutableReactiveHandler();
|
|
1117
1117
|
const readonlyHandlers = /*@__PURE__*/ new ReadonlyReactiveHandler();
|
|
1118
1118
|
//#endregion
|
|
1119
|
-
//#region packages/signal/src/collectionHandlers.ts
|
|
1119
|
+
//#region packages/core/signal/src/collectionHandlers.ts
|
|
1120
1120
|
const toShallow = (value) => value;
|
|
1121
1121
|
const getProto = (v) => Reflect.getPrototypeOf(v);
|
|
1122
1122
|
function createIterableMethod(method, isReadonly, isShallow) {
|
|
@@ -1275,7 +1275,7 @@ var ZeusSignal = (function(exports) {
|
|
|
1275
1275
|
}
|
|
1276
1276
|
}
|
|
1277
1277
|
//#endregion
|
|
1278
|
-
//#region packages/signal/src/reactive.ts
|
|
1278
|
+
//#region packages/core/signal/src/reactive.ts
|
|
1279
1279
|
const reactiveMap = /* @__PURE__ */ new WeakMap();
|
|
1280
1280
|
const shallowReactiveMap = /* @__PURE__ */ new WeakMap();
|
|
1281
1281
|
const readonlyMap = /* @__PURE__ */ new WeakMap();
|
|
@@ -1444,7 +1444,7 @@ var ZeusSignal = (function(exports) {
|
|
|
1444
1444
|
*/
|
|
1445
1445
|
const toReadonly = (value) => isObject(value) ? /* @__PURE__ */ readonly(value) : value;
|
|
1446
1446
|
//#endregion
|
|
1447
|
-
//#region packages/signal/src/state.ts
|
|
1447
|
+
//#region packages/core/signal/src/state.ts
|
|
1448
1448
|
function state(value) {
|
|
1449
1449
|
if (arguments.length === 0) return /* @__PURE__ */ ref();
|
|
1450
1450
|
return isProxyable(value) ? /* @__PURE__ */ reactive(value) : /* @__PURE__ */ ref(value);
|
|
@@ -1466,7 +1466,7 @@ var ZeusSignal = (function(exports) {
|
|
|
1466
1466
|
return proto === Object.prototype || proto === null;
|
|
1467
1467
|
}
|
|
1468
1468
|
//#endregion
|
|
1469
|
-
//#region packages/signal/src/computed.ts
|
|
1469
|
+
//#region packages/core/signal/src/computed.ts
|
|
1470
1470
|
/**
|
|
1471
1471
|
* @private exported by @vue/reactivity for Vue core use, but not exported from
|
|
1472
1472
|
* the main vue package
|
|
@@ -1529,7 +1529,7 @@ var ZeusSignal = (function(exports) {
|
|
|
1529
1529
|
return cRef;
|
|
1530
1530
|
}
|
|
1531
1531
|
//#endregion
|
|
1532
|
-
//#region packages/signal/src/scheduler.ts
|
|
1532
|
+
//#region packages/core/signal/src/scheduler.ts
|
|
1533
1533
|
const queue = /* @__PURE__ */ new Set();
|
|
1534
1534
|
let flushing = false;
|
|
1535
1535
|
let pending = false;
|
|
@@ -1555,7 +1555,7 @@ var ZeusSignal = (function(exports) {
|
|
|
1555
1555
|
return Promise.resolve();
|
|
1556
1556
|
}
|
|
1557
1557
|
//#endregion
|
|
1558
|
-
//#region packages/signal/src/watch.ts
|
|
1558
|
+
//#region packages/core/signal/src/watch.ts
|
|
1559
1559
|
let WatchErrorCodes = /* @__PURE__ */ function(WatchErrorCodes) {
|
|
1560
1560
|
WatchErrorCodes[WatchErrorCodes["WATCH_GETTER"] = 2] = "WATCH_GETTER";
|
|
1561
1561
|
WatchErrorCodes[WatchErrorCodes["WATCH_CALLBACK"] = 3] = "WATCH_CALLBACK";
|
|
@@ -1723,7 +1723,7 @@ var ZeusSignal = (function(exports) {
|
|
|
1723
1723
|
return value;
|
|
1724
1724
|
}
|
|
1725
1725
|
//#endregion
|
|
1726
|
-
//#region packages/signal/src/lifecycle.ts
|
|
1726
|
+
//#region packages/core/signal/src/lifecycle.ts
|
|
1727
1727
|
function onCleanup(fn) {
|
|
1728
1728
|
if (getCurrentEffect()) {
|
|
1729
1729
|
onEffectCleanup(fn, true);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeus-js/signal",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.1.0-beta.0",
|
|
4
4
|
"description": "@zeus-js/signal",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "dist/signal.esm-bundler.js",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"repository": {
|
|
30
30
|
"type": "git",
|
|
31
31
|
"url": "git+https://github.com/baicie/zeus.git",
|
|
32
|
-
"directory": "packages/signal"
|
|
32
|
+
"directory": "packages/core/signal"
|
|
33
33
|
},
|
|
34
34
|
"buildOptions": {
|
|
35
35
|
"name": "ZeusSignal",
|
|
@@ -48,9 +48,9 @@
|
|
|
48
48
|
"bugs": {
|
|
49
49
|
"url": "https://github.com/baicie/zeus/issues"
|
|
50
50
|
},
|
|
51
|
-
"homepage": "https://github.com/baicie/zeus/tree/main/packages/signal#readme",
|
|
51
|
+
"homepage": "https://github.com/baicie/zeus/tree/main/packages/core/signal#readme",
|
|
52
52
|
"dependencies": {
|
|
53
53
|
"alien-signals": "^3.2.1",
|
|
54
|
-
"@zeus-js/shared": "0.0.
|
|
54
|
+
"@zeus-js/shared": "0.1.0-beta.0"
|
|
55
55
|
}
|
|
56
56
|
}
|