@vuu-ui/vuu-utils 3.1.0-beta.3 → 3.1.0-beta.4
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/package.json +8 -8
- package/src/index.js +4 -4
- package/src/vendor/@dnd-kit/abstract/index.d.ts +1279 -0
- package/src/vendor/@dnd-kit/abstract/index.js +1472 -0
- package/src/vendor/@dnd-kit/abstract/index.js.map +1 -0
- package/src/vendor/@dnd-kit/abstract/modifiers.d.ts +134 -0
- package/src/vendor/@dnd-kit/abstract/modifiers.js +100 -0
- package/src/vendor/@dnd-kit/abstract/modifiers.js.map +1 -0
- package/src/vendor/@dnd-kit/abstract/package.json +60 -0
- package/src/vendor/@dnd-kit/collision/dist/index.d.ts +46 -0
- package/src/vendor/@dnd-kit/collision/dist/index.js +175 -0
- package/src/vendor/@dnd-kit/collision/package.json +42 -0
- package/src/vendor/@dnd-kit/dom/index.d.ts +298 -0
- package/src/vendor/@dnd-kit/dom/index.js +1977 -0
- package/src/vendor/@dnd-kit/dom/index.js.map +1 -0
- package/src/vendor/@dnd-kit/dom/modifiers.d.ts +26 -0
- package/src/vendor/@dnd-kit/dom/modifiers.js +117 -0
- package/src/vendor/@dnd-kit/dom/modifiers.js.map +1 -0
- package/src/vendor/@dnd-kit/dom/package.json +92 -0
- package/src/vendor/@dnd-kit/dom/plugins/debug.d.ts +8 -0
- package/src/vendor/@dnd-kit/dom/plugins/debug.js +125 -0
- package/src/vendor/@dnd-kit/dom/plugins/debug.js.map +1 -0
- package/src/vendor/@dnd-kit/dom/sortable.d.ts +125 -0
- package/src/vendor/@dnd-kit/dom/sortable.js +822 -0
- package/src/vendor/@dnd-kit/dom/sortable.js.map +1 -0
- package/src/vendor/@dnd-kit/dom/utilities.d.ts +215 -0
- package/src/vendor/@dnd-kit/dom/utilities.js +1361 -0
- package/src/vendor/@dnd-kit/dom/utilities.js.map +1 -0
- package/src/vendor/@dnd-kit/geometry/dist/index.d.ts +178 -0
- package/src/vendor/@dnd-kit/geometry/dist/index.js +347 -0
- package/src/vendor/@dnd-kit/geometry/package.json +31 -0
- package/src/vendor/@dnd-kit/react/hooks.d.ts +30 -0
- package/src/vendor/@dnd-kit/react/hooks.js +133 -0
- package/src/vendor/@dnd-kit/react/index.d.ts +84 -0
- package/src/vendor/@dnd-kit/react/index.js +617 -0
- package/src/vendor/@dnd-kit/react/package.json +80 -0
- package/src/vendor/@dnd-kit/react/sortable.d.ts +26 -0
- package/src/vendor/@dnd-kit/react/sortable.js +175 -0
- package/src/vendor/@dnd-kit/react/utilities.d.ts +7 -0
- package/src/vendor/@dnd-kit/react/utilities.js +18 -0
- package/src/vendor/@dnd-kit/state/dist/index.d.ts +54 -0
- package/src/vendor/@dnd-kit/state/dist/index.js +328 -0
- package/src/vendor/@dnd-kit/state/package.json +33 -0
- package/src/vendor/@preact/signals-core/dist/signals-core.js +1 -0
- package/src/vendor/@preact/signals-core/dist/signals-core.js.map +1 -0
- package/src/vendor/@preact/signals-core/package.json +4 -0
- package/src/vendor/tslib/CopyrightNotice.txt +15 -0
- package/src/vendor/tslib/LICENSE.txt +12 -0
- package/src/vendor/tslib/README.md +164 -0
- package/src/vendor/tslib/SECURITY.md +41 -0
- package/src/vendor/tslib/modules/index.d.ts +38 -0
- package/src/vendor/tslib/modules/index.js +70 -0
- package/src/vendor/tslib/modules/package.json +3 -0
- package/src/vendor/tslib/package.json +47 -0
- package/src/vendor/tslib/tslib.d.ts +460 -0
- package/src/vendor/tslib/tslib.es6.html +1 -0
- package/src/vendor/tslib/tslib.es6.js +402 -0
- package/src/vendor/tslib/tslib.es6.mjs +401 -0
- package/src/vendor/tslib/tslib.html +1 -0
- package/src/vendor/tslib/tslib.js +484 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Data } from '@dnd-kit/abstract';
|
|
2
|
+
import { SortableInput, Sortable } from '@dnd-kit/dom/sortable';
|
|
3
|
+
export { isSortable } from '@dnd-kit/dom/sortable';
|
|
4
|
+
import { RefObject, MutableRefObject } from 'react';
|
|
5
|
+
|
|
6
|
+
type Ref<T> = RefObject<T | null | undefined> | MutableRefObject<T>;
|
|
7
|
+
type RefOrValue<T> = T | Ref<T> | null | undefined;
|
|
8
|
+
|
|
9
|
+
interface UseSortableInput<T extends Data = Data> extends Omit<SortableInput<T>, 'handle' | 'element' | 'target'> {
|
|
10
|
+
handle?: RefOrValue<Element>;
|
|
11
|
+
element?: RefOrValue<Element>;
|
|
12
|
+
target?: RefOrValue<Element>;
|
|
13
|
+
}
|
|
14
|
+
declare function useSortable<T extends Data = Data>(input: UseSortableInput<T>): {
|
|
15
|
+
sortable: Sortable<T>;
|
|
16
|
+
readonly isDragging: boolean;
|
|
17
|
+
readonly isDropping: boolean;
|
|
18
|
+
readonly isDragSource: boolean;
|
|
19
|
+
readonly isDropTarget: boolean;
|
|
20
|
+
handleRef: (element: Element | null) => void;
|
|
21
|
+
ref: (element: Element | null) => void;
|
|
22
|
+
sourceRef: (element: Element | null) => void;
|
|
23
|
+
targetRef: (element: Element | null) => void;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export { type UseSortableInput, useSortable };
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { useCallback } from 'react';
|
|
2
|
+
import { batch, deepEqual } from '../state/dist/index.js';
|
|
3
|
+
import { defaultSortableTransition, Sortable } from '../dom/sortable.js';
|
|
4
|
+
export { isSortable } from '../dom/sortable.js';
|
|
5
|
+
import { useInstance } from './index.js';
|
|
6
|
+
import { useDeepSignal, useOnValueChange, useIsomorphicLayoutEffect, useImmediateEffect, useOnElementChange } from './hooks.js';
|
|
7
|
+
import { currentValue } from './utilities.js';
|
|
8
|
+
|
|
9
|
+
var __defProp = Object.defineProperty;
|
|
10
|
+
var __defProps = Object.defineProperties;
|
|
11
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
12
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
13
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
15
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
16
|
+
var __spreadValues = (a, b) => {
|
|
17
|
+
for (var prop in b || (b = {}))
|
|
18
|
+
if (__hasOwnProp.call(b, prop))
|
|
19
|
+
__defNormalProp(a, prop, b[prop]);
|
|
20
|
+
if (__getOwnPropSymbols)
|
|
21
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
22
|
+
if (__propIsEnum.call(b, prop))
|
|
23
|
+
__defNormalProp(a, prop, b[prop]);
|
|
24
|
+
}
|
|
25
|
+
return a;
|
|
26
|
+
};
|
|
27
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
28
|
+
function useSortable(input) {
|
|
29
|
+
const {
|
|
30
|
+
accept,
|
|
31
|
+
collisionDetector,
|
|
32
|
+
collisionPriority,
|
|
33
|
+
id,
|
|
34
|
+
data,
|
|
35
|
+
element,
|
|
36
|
+
handle,
|
|
37
|
+
index,
|
|
38
|
+
group,
|
|
39
|
+
disabled,
|
|
40
|
+
feedback,
|
|
41
|
+
modifiers,
|
|
42
|
+
sensors,
|
|
43
|
+
target,
|
|
44
|
+
type
|
|
45
|
+
} = input;
|
|
46
|
+
const transition = __spreadValues(__spreadValues({}, defaultSortableTransition), input.transition);
|
|
47
|
+
const sortable = useInstance((manager) => {
|
|
48
|
+
return new Sortable(
|
|
49
|
+
__spreadProps(__spreadValues({}, input), {
|
|
50
|
+
transition,
|
|
51
|
+
register: false,
|
|
52
|
+
handle: currentValue(handle),
|
|
53
|
+
element: currentValue(element),
|
|
54
|
+
target: currentValue(target),
|
|
55
|
+
feedback
|
|
56
|
+
}),
|
|
57
|
+
manager
|
|
58
|
+
);
|
|
59
|
+
});
|
|
60
|
+
const trackedSortable = useDeepSignal(sortable, shouldUpdateSynchronously);
|
|
61
|
+
useOnValueChange(id, () => sortable.id = id);
|
|
62
|
+
useIsomorphicLayoutEffect(() => {
|
|
63
|
+
batch(() => {
|
|
64
|
+
sortable.group = group;
|
|
65
|
+
sortable.index = index;
|
|
66
|
+
});
|
|
67
|
+
}, [sortable, group, index]);
|
|
68
|
+
useOnValueChange(type, () => sortable.type = type);
|
|
69
|
+
useOnValueChange(
|
|
70
|
+
accept,
|
|
71
|
+
() => sortable.accept = accept,
|
|
72
|
+
void 0,
|
|
73
|
+
deepEqual
|
|
74
|
+
);
|
|
75
|
+
useOnValueChange(data, () => data && (sortable.data = data));
|
|
76
|
+
useOnValueChange(
|
|
77
|
+
index,
|
|
78
|
+
() => {
|
|
79
|
+
var _a;
|
|
80
|
+
if (((_a = sortable.manager) == null ? void 0 : _a.dragOperation.status.idle) && (transition == null ? void 0 : transition.idle)) {
|
|
81
|
+
sortable.refreshShape();
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
useImmediateEffect
|
|
85
|
+
);
|
|
86
|
+
useOnElementChange(handle, (handle2) => sortable.handle = handle2);
|
|
87
|
+
useOnElementChange(element, (element2) => sortable.element = element2);
|
|
88
|
+
useOnElementChange(target, (target2) => sortable.target = target2);
|
|
89
|
+
useOnValueChange(disabled, () => sortable.disabled = disabled === true);
|
|
90
|
+
useOnValueChange(sensors, () => sortable.sensors = sensors);
|
|
91
|
+
useOnValueChange(
|
|
92
|
+
collisionDetector,
|
|
93
|
+
() => sortable.collisionDetector = collisionDetector
|
|
94
|
+
);
|
|
95
|
+
useOnValueChange(
|
|
96
|
+
collisionPriority,
|
|
97
|
+
() => sortable.collisionPriority = collisionPriority
|
|
98
|
+
);
|
|
99
|
+
useOnValueChange(feedback, () => sortable.feedback = feedback != null ? feedback : "default");
|
|
100
|
+
useOnValueChange(
|
|
101
|
+
transition,
|
|
102
|
+
() => sortable.transition = transition,
|
|
103
|
+
void 0,
|
|
104
|
+
deepEqual
|
|
105
|
+
);
|
|
106
|
+
useOnValueChange(
|
|
107
|
+
modifiers,
|
|
108
|
+
() => sortable.modifiers = modifiers,
|
|
109
|
+
void 0,
|
|
110
|
+
deepEqual
|
|
111
|
+
);
|
|
112
|
+
useOnValueChange(
|
|
113
|
+
input.alignment,
|
|
114
|
+
() => sortable.alignment = input.alignment
|
|
115
|
+
);
|
|
116
|
+
return {
|
|
117
|
+
sortable: trackedSortable,
|
|
118
|
+
get isDragging() {
|
|
119
|
+
return trackedSortable.isDragging;
|
|
120
|
+
},
|
|
121
|
+
get isDropping() {
|
|
122
|
+
return trackedSortable.isDropping;
|
|
123
|
+
},
|
|
124
|
+
get isDragSource() {
|
|
125
|
+
return trackedSortable.isDragSource;
|
|
126
|
+
},
|
|
127
|
+
get isDropTarget() {
|
|
128
|
+
return trackedSortable.isDropTarget;
|
|
129
|
+
},
|
|
130
|
+
handleRef: useCallback(
|
|
131
|
+
(element2) => {
|
|
132
|
+
sortable.handle = element2 != null ? element2 : void 0;
|
|
133
|
+
},
|
|
134
|
+
[sortable]
|
|
135
|
+
),
|
|
136
|
+
ref: useCallback(
|
|
137
|
+
(element2) => {
|
|
138
|
+
var _a, _b;
|
|
139
|
+
if (!element2 && ((_a = sortable.element) == null ? void 0 : _a.isConnected) && !((_b = sortable.manager) == null ? void 0 : _b.dragOperation.status.idle)) {
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
sortable.element = element2 != null ? element2 : void 0;
|
|
143
|
+
},
|
|
144
|
+
[sortable]
|
|
145
|
+
),
|
|
146
|
+
sourceRef: useCallback(
|
|
147
|
+
(element2) => {
|
|
148
|
+
var _a, _b;
|
|
149
|
+
if (!element2 && ((_a = sortable.source) == null ? void 0 : _a.isConnected) && !((_b = sortable.manager) == null ? void 0 : _b.dragOperation.status.idle)) {
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
sortable.source = element2 != null ? element2 : void 0;
|
|
153
|
+
},
|
|
154
|
+
[sortable]
|
|
155
|
+
),
|
|
156
|
+
targetRef: useCallback(
|
|
157
|
+
(element2) => {
|
|
158
|
+
var _a, _b;
|
|
159
|
+
if (!element2 && ((_a = sortable.target) == null ? void 0 : _a.isConnected) && !((_b = sortable.manager) == null ? void 0 : _b.dragOperation.status.idle)) {
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
sortable.target = element2 != null ? element2 : void 0;
|
|
163
|
+
},
|
|
164
|
+
[sortable]
|
|
165
|
+
)
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
function shouldUpdateSynchronously(key, oldValue, newValue) {
|
|
169
|
+
if (key === "isDragSource" && !newValue && oldValue) return true;
|
|
170
|
+
return false;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
export { useSortable };
|
|
174
|
+
//# sourceMappingURL=sortable.js.map
|
|
175
|
+
//# sourceMappingURL=sortable.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { RefObject, MutableRefObject } from 'react';
|
|
2
|
+
|
|
3
|
+
type Ref<T> = RefObject<T | null | undefined> | MutableRefObject<T>;
|
|
4
|
+
type RefOrValue<T> = T | Ref<T> | null | undefined;
|
|
5
|
+
declare function currentValue<T>(value: RefOrValue<T>): NonNullable<T> | undefined;
|
|
6
|
+
|
|
7
|
+
export { type RefOrValue, currentValue };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// src/utilities/currentValue.ts
|
|
2
|
+
function isRef(value) {
|
|
3
|
+
return value != null && typeof value === "object" && "current" in value;
|
|
4
|
+
}
|
|
5
|
+
function currentValue(value) {
|
|
6
|
+
var _a;
|
|
7
|
+
if (value == null) {
|
|
8
|
+
return void 0;
|
|
9
|
+
}
|
|
10
|
+
if (isRef(value)) {
|
|
11
|
+
return (_a = value.current) != null ? _a : void 0;
|
|
12
|
+
}
|
|
13
|
+
return value;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export { currentValue };
|
|
17
|
+
//# sourceMappingURL=utilities.js.map
|
|
18
|
+
//# sourceMappingURL=utilities.js.map
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { ReadonlySignal, effect } from '@preact/signals-core';
|
|
2
|
+
export { ReadonlySignal, Signal, batch, effect, signal, untracked } from '@preact/signals-core';
|
|
3
|
+
|
|
4
|
+
declare function computed<T>(compute: () => T, comparator?: (a: T, b: T) => boolean): ReadonlySignal<T>;
|
|
5
|
+
|
|
6
|
+
declare function deepEqual<T>(a: T, b: T): boolean;
|
|
7
|
+
|
|
8
|
+
declare function reactive<This, Value>({ get }: ClassAccessorDecoratorTarget<This, Value>, _: ClassAccessorDecoratorContext<This, Value>): ClassAccessorDecoratorResult<This, Value>;
|
|
9
|
+
declare function derived<This, Return>(target: (this: This) => Return, _: ClassGetterDecoratorContext<This, Return>): (this: This) => Return;
|
|
10
|
+
/**
|
|
11
|
+
* Make a field enumerable (or non‑enumerable) on every instance.
|
|
12
|
+
*
|
|
13
|
+
* @enumerable(true) – enumerable
|
|
14
|
+
* @enumerable(false) – non‑enumerable
|
|
15
|
+
*/
|
|
16
|
+
declare function enumerable(enumerable?: boolean): (_value: unknown, context: ClassFieldDecoratorContext<any, any> | ClassGetterDecoratorContext<any, any> | ClassSetterDecoratorContext<any, any> | ClassAccessorDecoratorContext<any, any> | ClassMethodDecoratorContext<any, any>) => void;
|
|
17
|
+
|
|
18
|
+
type CleanupFunction = () => void;
|
|
19
|
+
type Effect = Parameters<typeof effect>[0];
|
|
20
|
+
|
|
21
|
+
declare function effects(...entries: Effect[]): CleanupFunction;
|
|
22
|
+
|
|
23
|
+
type WithHistory<T> = {
|
|
24
|
+
current: T;
|
|
25
|
+
initial: T;
|
|
26
|
+
previous: T | undefined;
|
|
27
|
+
};
|
|
28
|
+
declare class ValueHistory<T> implements WithHistory<T> {
|
|
29
|
+
#private;
|
|
30
|
+
protected readonly defaultValue: T;
|
|
31
|
+
protected readonly equals: (a: T, b: T) => boolean;
|
|
32
|
+
constructor(defaultValue: T, equals?: (a: T, b: T) => boolean);
|
|
33
|
+
/** Current value */
|
|
34
|
+
get current(): T;
|
|
35
|
+
/** Initial value */
|
|
36
|
+
get initial(): T;
|
|
37
|
+
/** Previous value */
|
|
38
|
+
get previous(): T | undefined;
|
|
39
|
+
/** Set the current value */
|
|
40
|
+
set current(value: T);
|
|
41
|
+
/** Reset the state to the initial value */
|
|
42
|
+
reset(value?: T): void;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
declare function snapshot<T extends object>(value: T): T;
|
|
46
|
+
|
|
47
|
+
declare class WeakStore<WeakKey extends object, Key extends string | number | symbol, Value extends Record<Key, any>> {
|
|
48
|
+
#private;
|
|
49
|
+
get(key: WeakKey | undefined, id: Key): Value | undefined;
|
|
50
|
+
set(key: WeakKey | undefined, id: Key, value: Value): Map<Key, Value> | undefined;
|
|
51
|
+
clear(key: WeakKey | undefined): void;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export { type CleanupFunction, type Effect, ValueHistory, WeakStore, type WithHistory, computed, deepEqual, derived, effects, enumerable, reactive, snapshot };
|
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __defProps = Object.defineProperties;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
7
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
9
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
11
|
+
var __knownSymbol = (name, symbol) => (symbol = Symbol[name]) ? symbol : Symbol.for("Symbol." + name);
|
|
12
|
+
var __typeError = (msg) => {
|
|
13
|
+
throw TypeError(msg);
|
|
14
|
+
};
|
|
15
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
16
|
+
var __spreadValues = (a, b) => {
|
|
17
|
+
for (var prop in b || (b = {}))
|
|
18
|
+
if (__hasOwnProp.call(b, prop))
|
|
19
|
+
__defNormalProp(a, prop, b[prop]);
|
|
20
|
+
if (__getOwnPropSymbols)
|
|
21
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
22
|
+
if (__propIsEnum.call(b, prop))
|
|
23
|
+
__defNormalProp(a, prop, b[prop]);
|
|
24
|
+
}
|
|
25
|
+
return a;
|
|
26
|
+
};
|
|
27
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
28
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
29
|
+
var __export = (target, all) => {
|
|
30
|
+
for (var name in all)
|
|
31
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
32
|
+
};
|
|
33
|
+
var __copyProps = (to, from, except, desc) => {
|
|
34
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
35
|
+
for (let key of __getOwnPropNames(from))
|
|
36
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
37
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
38
|
+
}
|
|
39
|
+
return to;
|
|
40
|
+
};
|
|
41
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
42
|
+
var __decoratorStart = (base) => {
|
|
43
|
+
var _a2;
|
|
44
|
+
return [, , , __create((_a2 = base == null ? void 0 : base[__knownSymbol("metadata")]) != null ? _a2 : null)];
|
|
45
|
+
};
|
|
46
|
+
var __decoratorStrings = ["class", "method", "getter", "setter", "accessor", "field", "value", "get", "set"];
|
|
47
|
+
var __expectFn = (fn) => fn !== void 0 && typeof fn !== "function" ? __typeError("Function expected") : fn;
|
|
48
|
+
var __decoratorContext = (kind, name, done, metadata, fns) => ({ kind: __decoratorStrings[kind], name, metadata, addInitializer: (fn) => done._ ? __typeError("Already initialized") : fns.push(__expectFn(fn || null)) });
|
|
49
|
+
var __decoratorMetadata = (array, target) => __defNormalProp(target, __knownSymbol("metadata"), array[3]);
|
|
50
|
+
var __runInitializers = (array, flags, self, value) => {
|
|
51
|
+
for (var i = 0, fns = array[flags >> 1], n = fns && fns.length; i < n; i++) flags & 1 ? fns[i].call(self) : value = fns[i].call(self, value);
|
|
52
|
+
return value;
|
|
53
|
+
};
|
|
54
|
+
var __decorateElement = (array, flags, name, decorators, target, extra) => {
|
|
55
|
+
var fn, it, done, ctx, access, k = flags & 7, s = !!(flags & 8), p = !!(flags & 16);
|
|
56
|
+
var j = k > 3 ? array.length + 1 : k ? s ? 1 : 2 : 0, key = __decoratorStrings[k + 5];
|
|
57
|
+
var initializers = k > 3 && (array[j - 1] = []), extraInitializers = array[j] || (array[j] = []);
|
|
58
|
+
var desc = k && (!p && !s && (target = target.prototype), k < 5 && (k > 3 || !p) && __getOwnPropDesc(k < 4 ? target : { get [name]() {
|
|
59
|
+
return __privateGet(this, extra);
|
|
60
|
+
}, set [name](x) {
|
|
61
|
+
return __privateSet(this, extra, x);
|
|
62
|
+
} }, name));
|
|
63
|
+
k ? p && k < 4 && __name(extra, (k > 2 ? "set " : k > 1 ? "get " : "") + name) : __name(target, name);
|
|
64
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
65
|
+
ctx = __decoratorContext(k, name, done = {}, array[3], extraInitializers);
|
|
66
|
+
if (k) {
|
|
67
|
+
ctx.static = s, ctx.private = p, access = ctx.access = { has: p ? (x) => __privateIn(target, x) : (x) => name in x };
|
|
68
|
+
if (k ^ 3) access.get = p ? (x) => (k ^ 1 ? __privateGet : __privateMethod)(x, target, k ^ 4 ? extra : desc.get) : (x) => x[name];
|
|
69
|
+
if (k > 2) access.set = p ? (x, y) => __privateSet(x, target, y, k ^ 4 ? extra : desc.set) : (x, y) => x[name] = y;
|
|
70
|
+
}
|
|
71
|
+
it = (0, decorators[i])(k ? k < 4 ? p ? extra : desc[key] : k > 4 ? void 0 : { get: desc.get, set: desc.set } : target, ctx), done._ = 1;
|
|
72
|
+
if (k ^ 4 || it === void 0) __expectFn(it) && (k > 4 ? initializers.unshift(it) : k ? p ? extra = it : desc[key] = it : target = it);
|
|
73
|
+
else if (typeof it !== "object" || it === null) __typeError("Object expected");
|
|
74
|
+
else __expectFn(fn = it.get) && (desc.get = fn), __expectFn(fn = it.set) && (desc.set = fn), __expectFn(fn = it.init) && initializers.unshift(fn);
|
|
75
|
+
}
|
|
76
|
+
return k || __decoratorMetadata(array, target), desc && __defProp(target, name, desc), p ? k ^ 4 ? extra : desc : target;
|
|
77
|
+
};
|
|
78
|
+
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
79
|
+
var __privateIn = (member, obj) => Object(obj) !== obj ? __typeError('Cannot use the "in" operator on this value') : member.has(obj);
|
|
80
|
+
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
81
|
+
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
82
|
+
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
83
|
+
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
84
|
+
|
|
85
|
+
// src/index.ts
|
|
86
|
+
var src_exports = {};
|
|
87
|
+
__export(src_exports, {
|
|
88
|
+
Signal: () => import_signals_core6.Signal,
|
|
89
|
+
ValueHistory: () => ValueHistory,
|
|
90
|
+
WeakStore: () => WeakStore,
|
|
91
|
+
batch: () => import_signals_core6.batch,
|
|
92
|
+
computed: () => computed,
|
|
93
|
+
deepEqual: () => deepEqual,
|
|
94
|
+
derived: () => derived,
|
|
95
|
+
effect: () => import_signals_core6.effect,
|
|
96
|
+
effects: () => effects,
|
|
97
|
+
enumerable: () => enumerable,
|
|
98
|
+
reactive: () => reactive,
|
|
99
|
+
signal: () => import_signals_core6.signal,
|
|
100
|
+
snapshot: () => snapshot,
|
|
101
|
+
untracked: () => import_signals_core6.untracked
|
|
102
|
+
});
|
|
103
|
+
module.exports = __toCommonJS(src_exports);
|
|
104
|
+
var import_signals_core6 = require("../../../@preact/signals-core/dist/signals-core.js");
|
|
105
|
+
|
|
106
|
+
// src/computed.ts
|
|
107
|
+
var import_signals_core = require("../../../@preact/signals-core/dist/signals-core.js");
|
|
108
|
+
function computed(compute, comparator) {
|
|
109
|
+
if (comparator) {
|
|
110
|
+
let previousValue;
|
|
111
|
+
return (0, import_signals_core.computed)(() => {
|
|
112
|
+
const value = compute();
|
|
113
|
+
if (value && previousValue && comparator(previousValue, value)) {
|
|
114
|
+
return previousValue;
|
|
115
|
+
}
|
|
116
|
+
previousValue = value;
|
|
117
|
+
return value;
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
return (0, import_signals_core.computed)(compute);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// src/comparators.ts
|
|
124
|
+
function deepEqual(a, b) {
|
|
125
|
+
if (Object.is(a, b)) {
|
|
126
|
+
return true;
|
|
127
|
+
}
|
|
128
|
+
if (a === null || b === null) return false;
|
|
129
|
+
if (typeof a === "function" && typeof b === "function") {
|
|
130
|
+
return a === b;
|
|
131
|
+
}
|
|
132
|
+
if (a instanceof Set && b instanceof Set) {
|
|
133
|
+
if (a.size !== b.size) {
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
136
|
+
for (const value of a) {
|
|
137
|
+
if (!b.has(value)) {
|
|
138
|
+
return false;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return true;
|
|
142
|
+
}
|
|
143
|
+
if (Array.isArray(a)) {
|
|
144
|
+
if (!Array.isArray(b) || a.length !== b.length) {
|
|
145
|
+
return false;
|
|
146
|
+
}
|
|
147
|
+
const hasDifferentValues = a.some(
|
|
148
|
+
(value, index) => !deepEqual(value, b[index])
|
|
149
|
+
);
|
|
150
|
+
return !hasDifferentValues;
|
|
151
|
+
}
|
|
152
|
+
if (typeof a === "object" && typeof b === "object") {
|
|
153
|
+
const aKeys = Object.keys(a);
|
|
154
|
+
const bKeys = Object.keys(b);
|
|
155
|
+
if (aKeys.length !== bKeys.length) return false;
|
|
156
|
+
const hasDifferentValues = aKeys.some(
|
|
157
|
+
(key) => !deepEqual(a[key], b[key])
|
|
158
|
+
);
|
|
159
|
+
return !hasDifferentValues;
|
|
160
|
+
}
|
|
161
|
+
return false;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// src/decorators.ts
|
|
165
|
+
var import_signals_core2 = require("../../../@preact/signals-core/dist/signals-core.js");
|
|
166
|
+
function reactive({ get }, _) {
|
|
167
|
+
return {
|
|
168
|
+
init(value) {
|
|
169
|
+
return (0, import_signals_core2.signal)(value);
|
|
170
|
+
},
|
|
171
|
+
get() {
|
|
172
|
+
const current = get.call(this);
|
|
173
|
+
return current.value;
|
|
174
|
+
},
|
|
175
|
+
set(newValue) {
|
|
176
|
+
const current = get.call(this);
|
|
177
|
+
if (current.peek() === newValue) {
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
current.value = newValue;
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
function derived(target, _) {
|
|
185
|
+
const map = /* @__PURE__ */ new WeakMap();
|
|
186
|
+
return function() {
|
|
187
|
+
let result = map.get(this);
|
|
188
|
+
if (!result) {
|
|
189
|
+
result = computed(target.bind(this));
|
|
190
|
+
map.set(this, result);
|
|
191
|
+
}
|
|
192
|
+
return result.value;
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
function enumerable(enumerable2 = true) {
|
|
196
|
+
return function(_value, context) {
|
|
197
|
+
context.addInitializer(function() {
|
|
198
|
+
const host = context.kind === "field" ? this : context.static ? this : Object.getPrototypeOf(this);
|
|
199
|
+
const descriptor = Object.getOwnPropertyDescriptor(host, context.name);
|
|
200
|
+
if (descriptor) {
|
|
201
|
+
Object.defineProperty(host, context.name, __spreadProps(__spreadValues({}, descriptor), { enumerable: enumerable2 }));
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
// src/effects.ts
|
|
208
|
+
var import_signals_core3 = require("../../../@preact/signals-core/dist/signals-core.js");
|
|
209
|
+
function effects(...entries) {
|
|
210
|
+
const effects2 = entries.map(import_signals_core3.effect);
|
|
211
|
+
return () => effects2.forEach((cleanup) => cleanup());
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
// src/history.ts
|
|
215
|
+
var import_signals_core4 = require("../../../@preact/signals-core/dist/signals-core.js");
|
|
216
|
+
var _previous_dec, _initial_dec, _current_dec, _current_dec2, _previous_dec2, _initial_dec2, _init, _initial, _a, initial_get, initial_set, _ValueHistory_instances, _previous, _b, previous_get, previous_set, _current, _c, current_get, current_set;
|
|
217
|
+
_initial_dec2 = [reactive], _previous_dec2 = [reactive], _current_dec2 = [reactive], _current_dec = [enumerable()], _initial_dec = [enumerable()], _previous_dec = [enumerable()];
|
|
218
|
+
var ValueHistory = class {
|
|
219
|
+
constructor(defaultValue, equals = Object.is) {
|
|
220
|
+
this.defaultValue = defaultValue;
|
|
221
|
+
this.equals = equals;
|
|
222
|
+
__runInitializers(_init, 5, this);
|
|
223
|
+
__privateAdd(this, _ValueHistory_instances);
|
|
224
|
+
// @ts-ignore
|
|
225
|
+
__privateAdd(this, _initial, __runInitializers(_init, 8, this)), __runInitializers(_init, 11, this);
|
|
226
|
+
// @ts-ignore
|
|
227
|
+
__privateAdd(this, _previous, __runInitializers(_init, 12, this)), __runInitializers(_init, 15, this);
|
|
228
|
+
// @ts-ignore
|
|
229
|
+
__privateAdd(this, _current, __runInitializers(_init, 16, this)), __runInitializers(_init, 19, this);
|
|
230
|
+
this.reset = this.reset.bind(this);
|
|
231
|
+
this.reset();
|
|
232
|
+
}
|
|
233
|
+
get current() {
|
|
234
|
+
return __privateGet(this, _ValueHistory_instances, current_get);
|
|
235
|
+
}
|
|
236
|
+
get initial() {
|
|
237
|
+
return __privateGet(this, _ValueHistory_instances, initial_get);
|
|
238
|
+
}
|
|
239
|
+
get previous() {
|
|
240
|
+
return __privateGet(this, _ValueHistory_instances, previous_get);
|
|
241
|
+
}
|
|
242
|
+
/** Set the current value */
|
|
243
|
+
set current(value) {
|
|
244
|
+
const current = (0, import_signals_core4.untracked)(() => __privateGet(this, _ValueHistory_instances, current_get));
|
|
245
|
+
if (value && current && this.equals(current, value)) {
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
(0, import_signals_core4.batch)(() => {
|
|
249
|
+
if (!__privateGet(this, _ValueHistory_instances, initial_get)) {
|
|
250
|
+
__privateSet(this, _ValueHistory_instances, value, initial_set);
|
|
251
|
+
}
|
|
252
|
+
__privateSet(this, _ValueHistory_instances, current, previous_set);
|
|
253
|
+
__privateSet(this, _ValueHistory_instances, value, current_set);
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
/** Reset the state to the initial value */
|
|
257
|
+
reset(value = this.defaultValue) {
|
|
258
|
+
(0, import_signals_core4.batch)(() => {
|
|
259
|
+
__privateSet(this, _ValueHistory_instances, void 0, previous_set);
|
|
260
|
+
__privateSet(this, _ValueHistory_instances, value, initial_set);
|
|
261
|
+
__privateSet(this, _ValueHistory_instances, value, current_set);
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
};
|
|
265
|
+
_init = __decoratorStart(null);
|
|
266
|
+
_initial = new WeakMap();
|
|
267
|
+
_ValueHistory_instances = new WeakSet();
|
|
268
|
+
_previous = new WeakMap();
|
|
269
|
+
_current = new WeakMap();
|
|
270
|
+
_a = __decorateElement(_init, 20, "#initial", _initial_dec2, _ValueHistory_instances, _initial), initial_get = _a.get, initial_set = _a.set;
|
|
271
|
+
_b = __decorateElement(_init, 20, "#previous", _previous_dec2, _ValueHistory_instances, _previous), previous_get = _b.get, previous_set = _b.set;
|
|
272
|
+
_c = __decorateElement(_init, 20, "#current", _current_dec2, _ValueHistory_instances, _current), current_get = _c.get, current_set = _c.set;
|
|
273
|
+
__decorateElement(_init, 2, "current", _current_dec, ValueHistory);
|
|
274
|
+
__decorateElement(_init, 2, "initial", _initial_dec, ValueHistory);
|
|
275
|
+
__decorateElement(_init, 2, "previous", _previous_dec, ValueHistory);
|
|
276
|
+
__decoratorMetadata(_init, ValueHistory);
|
|
277
|
+
|
|
278
|
+
// src/snapshot.ts
|
|
279
|
+
var import_signals_core5 = require("../../../@preact/signals-core/dist/signals-core.js");
|
|
280
|
+
function snapshot(value) {
|
|
281
|
+
return (0, import_signals_core5.untracked)(() => {
|
|
282
|
+
const output = {};
|
|
283
|
+
for (const key in value) {
|
|
284
|
+
output[key] = value[key];
|
|
285
|
+
}
|
|
286
|
+
return output;
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
// src/store.ts
|
|
291
|
+
var _store;
|
|
292
|
+
var WeakStore = class {
|
|
293
|
+
constructor() {
|
|
294
|
+
__privateAdd(this, _store, /* @__PURE__ */ new WeakMap());
|
|
295
|
+
}
|
|
296
|
+
get(key, id) {
|
|
297
|
+
var _a2;
|
|
298
|
+
return key ? (_a2 = __privateGet(this, _store).get(key)) == null ? void 0 : _a2.get(id) : void 0;
|
|
299
|
+
}
|
|
300
|
+
set(key, id, value) {
|
|
301
|
+
var _a2;
|
|
302
|
+
if (!key) return;
|
|
303
|
+
if (!__privateGet(this, _store).has(key)) __privateGet(this, _store).set(key, /* @__PURE__ */ new Map());
|
|
304
|
+
return (_a2 = __privateGet(this, _store).get(key)) == null ? void 0 : _a2.set(id, value);
|
|
305
|
+
}
|
|
306
|
+
clear(key) {
|
|
307
|
+
var _a2;
|
|
308
|
+
return key ? (_a2 = __privateGet(this, _store).get(key)) == null ? void 0 : _a2.clear() : void 0;
|
|
309
|
+
}
|
|
310
|
+
};
|
|
311
|
+
_store = new WeakMap();
|
|
312
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
313
|
+
0 && (module.exports = {
|
|
314
|
+
Signal,
|
|
315
|
+
ValueHistory,
|
|
316
|
+
WeakStore,
|
|
317
|
+
batch,
|
|
318
|
+
computed,
|
|
319
|
+
deepEqual,
|
|
320
|
+
derived,
|
|
321
|
+
effect,
|
|
322
|
+
effects,
|
|
323
|
+
enumerable,
|
|
324
|
+
reactive,
|
|
325
|
+
signal,
|
|
326
|
+
snapshot,
|
|
327
|
+
untracked
|
|
328
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@dnd-kit/state",
|
|
3
|
+
"version": "0.1.21",
|
|
4
|
+
"main": "./dist/index.js",
|
|
5
|
+
"module": "./dist/index.mjs",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"sideEffects": false,
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"files": [
|
|
10
|
+
"dist/**"
|
|
11
|
+
],
|
|
12
|
+
"scripts": {
|
|
13
|
+
"build": "tsup src/index.ts --format esm,cjs --dts --external react",
|
|
14
|
+
"dev": "tsup src/index.ts --format esm,cjs --watch --dts --external react",
|
|
15
|
+
"test": "bun test",
|
|
16
|
+
"lint": "TIMING=1 eslint src/**/*.ts* --fix",
|
|
17
|
+
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist"
|
|
18
|
+
},
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"@preact/signals-core": "^1.10.0",
|
|
21
|
+
"tslib": "^2.6.2"
|
|
22
|
+
},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"@dnd-kit/eslint-config": "*",
|
|
25
|
+
"bun-types": "^1.2.15",
|
|
26
|
+
"eslint": "^8.38.0",
|
|
27
|
+
"tsup": "8.3.0",
|
|
28
|
+
"typescript": "^5.5.2"
|
|
29
|
+
},
|
|
30
|
+
"publishConfig": {
|
|
31
|
+
"access": "public"
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var i=Symbol.for("preact-signals");function t(){if(!(h>1)){var i,t=!1;while(void 0!==n){var r=n;n=void 0;s++;while(void 0!==r){var o=r.o;r.o=void 0;r.f&=-3;if(!(8&r.f)&&u(r))try{r.c()}catch(r){if(!t){i=r;t=!0}}r=o}}s=0;h--;if(t)throw i}else h--}var r=void 0;function o(i){var t=r;r=void 0;try{return i()}finally{r=t}}var n=void 0,h=0,s=0,f=0;function v(i){if(void 0!==r){var t=i.n;if(void 0===t||t.t!==r){t={i:0,S:i,p:r.s,n:void 0,t:r,e:void 0,x:void 0,r:t};if(void 0!==r.s)r.s.n=t;r.s=t;i.n=t;if(32&r.f)i.S(t);return t}else if(-1===t.i){t.i=0;if(void 0!==t.n){t.n.p=t.p;if(void 0!==t.p)t.p.n=t.n;t.p=r.s;t.n=void 0;r.s.n=t;r.s=t}return t}}}function e(i,t){this.v=i;this.i=0;this.n=void 0;this.t=void 0;this.W=null==t?void 0:t.watched;this.Z=null==t?void 0:t.unwatched}e.prototype.brand=i;e.prototype.h=function(){return!0};e.prototype.S=function(i){var t=this,r=this.t;if(r!==i&&void 0===i.e){i.x=r;this.t=i;if(void 0!==r)r.e=i;else o(function(){var i;null==(i=t.W)||i.call(t)})}};e.prototype.U=function(i){var t=this;if(void 0!==this.t){var r=i.e,n=i.x;if(void 0!==r){r.x=n;i.e=void 0}if(void 0!==n){n.e=r;i.x=void 0}if(i===this.t){this.t=n;if(void 0===n)o(function(){var i;null==(i=t.Z)||i.call(t)})}}};e.prototype.subscribe=function(i){var t=this;return x(function(){var o=t.value,n=r;r=void 0;try{i(o)}finally{r=n}})};e.prototype.valueOf=function(){return this.value};e.prototype.toString=function(){return this.value+""};e.prototype.toJSON=function(){return this.value};e.prototype.peek=function(){var i=r;r=void 0;try{return this.value}finally{r=i}};Object.defineProperty(e.prototype,"value",{get:function(){var i=v(this);if(void 0!==i)i.i=this.i;return this.v},set:function(i){if(i!==this.v){if(s>100)throw new Error("Cycle detected");this.v=i;this.i++;f++;h++;try{for(var r=this.t;void 0!==r;r=r.x)r.t.N()}finally{t()}}}});function u(i){for(var t=i.s;void 0!==t;t=t.n)if(t.S.i!==t.i||!t.S.h()||t.S.i!==t.i)return!0;return!1}function d(i){for(var t=i.s;void 0!==t;t=t.n){var r=t.S.n;if(void 0!==r)t.r=r;t.S.n=t;t.i=-1;if(void 0===t.n){i.s=t;break}}}function c(i){var t=i.s,r=void 0;while(void 0!==t){var o=t.p;if(-1===t.i){t.S.U(t);if(void 0!==o)o.n=t.n;if(void 0!==t.n)t.n.p=o}else r=t;t.S.n=t.r;if(void 0!==t.r)t.r=void 0;t=o}i.s=r}function a(i,t){e.call(this,void 0);this.x=i;this.s=void 0;this.g=f-1;this.f=4;this.W=null==t?void 0:t.watched;this.Z=null==t?void 0:t.unwatched}a.prototype=new e;a.prototype.h=function(){this.f&=-3;if(1&this.f)return!1;if(32==(36&this.f))return!0;this.f&=-5;if(this.g===f)return!0;this.g=f;this.f|=1;if(this.i>0&&!u(this)){this.f&=-2;return!0}var i=r;try{d(this);r=this;var t=this.x();if(16&this.f||this.v!==t||0===this.i){this.v=t;this.f&=-17;this.i++}}catch(i){this.v=i;this.f|=16;this.i++}r=i;c(this);this.f&=-2;return!0};a.prototype.S=function(i){if(void 0===this.t){this.f|=36;for(var t=this.s;void 0!==t;t=t.n)t.S.S(t)}e.prototype.S.call(this,i)};a.prototype.U=function(i){if(void 0!==this.t){e.prototype.U.call(this,i);if(void 0===this.t){this.f&=-33;for(var t=this.s;void 0!==t;t=t.n)t.S.U(t)}}};a.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var i=this.t;void 0!==i;i=i.x)i.t.N()}};Object.defineProperty(a.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var i=v(this);this.h();if(void 0!==i)i.i=this.i;if(16&this.f)throw this.v;return this.v}});function l(i){var o=i.u;i.u=void 0;if("function"==typeof o){h++;var n=r;r=void 0;try{o()}catch(t){i.f&=-2;i.f|=8;y(i);throw t}finally{r=n;t()}}}function y(i){for(var t=i.s;void 0!==t;t=t.n)t.S.U(t);i.x=void 0;i.s=void 0;l(i)}function w(i){if(r!==this)throw new Error("Out-of-order effect");c(this);r=i;this.f&=-2;if(8&this.f)y(this);t()}function p(i){this.x=i;this.u=void 0;this.s=void 0;this.o=void 0;this.f=32}p.prototype.c=function(){var i=this.S();try{if(8&this.f)return;if(void 0===this.x)return;var t=this.x();if("function"==typeof t)this.u=t}finally{i()}};p.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1;this.f&=-9;l(this);d(this);h++;var i=r;r=this;return w.bind(this,i)};p.prototype.N=function(){if(!(2&this.f)){this.f|=2;this.o=n;n=this}};p.prototype.d=function(){this.f|=8;if(!(1&this.f))y(this)};p.prototype.dispose=function(){this.d()};function x(i){var t=new p(i);try{t.c()}catch(i){t.d();throw i}var r=t.d.bind(t);r[Symbol.dispose]=r;return r}exports.Signal=e;exports.batch=function(i){if(h>0)return i();h++;try{return i()}finally{t()}};exports.computed=function(i,t){return new a(i,t)};exports.effect=x;exports.signal=function(i,t){return new e(i,t)};exports.untracked=o;//# sourceMappingURL=signals-core.js.map
|