@rpgjs/client 5.0.0-alpha.43 → 5.0.0-alpha.44
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/Game/AnimationManager.js +25 -24
- package/dist/Game/AnimationManager.js.map +1 -1
- package/dist/Game/Event.js +11 -10
- package/dist/Game/Event.js.map +1 -1
- package/dist/Game/Map.js +78 -94
- package/dist/Game/Map.js.map +1 -1
- package/dist/Game/Object.js +182 -216
- package/dist/Game/Object.js.map +1 -1
- package/dist/Game/Player.js +11 -10
- package/dist/Game/Player.js.map +1 -1
- package/dist/Gui/Gui.js +440 -473
- package/dist/Gui/Gui.js.map +1 -1
- package/dist/Gui/NotificationManager.js +48 -50
- package/dist/Gui/NotificationManager.js.map +1 -1
- package/dist/Resource.js +132 -113
- package/dist/Resource.js.map +1 -1
- package/dist/RpgClientEngine.js +1333 -1486
- package/dist/RpgClientEngine.js.map +1 -1
- package/dist/Sound.js +162 -92
- package/dist/Sound.js.map +1 -1
- package/dist/_virtual/_@oxc-project_runtime@0.115.0/helpers/decorate.js +9 -0
- package/dist/_virtual/_@oxc-project_runtime@0.115.0/helpers/decorateMetadata.js +6 -0
- package/dist/components/animations/animation.ce.js +22 -19
- package/dist/components/animations/animation.ce.js.map +1 -1
- package/dist/components/animations/hit.ce.js +67 -68
- package/dist/components/animations/hit.ce.js.map +1 -1
- package/dist/components/animations/index.js +9 -8
- package/dist/components/animations/index.js.map +1 -1
- package/dist/components/character.ce.js +390 -314
- package/dist/components/character.ce.js.map +1 -1
- package/dist/components/dynamics/parse-value.js +42 -52
- package/dist/components/dynamics/parse-value.js.map +1 -1
- package/dist/components/dynamics/text.ce.js +71 -139
- package/dist/components/dynamics/text.ce.js.map +1 -1
- package/dist/components/gui/box.ce.js +26 -25
- package/dist/components/gui/box.ce.js.map +1 -1
- package/dist/components/gui/dialogbox/index.ce.js +202 -149
- package/dist/components/gui/dialogbox/index.ce.js.map +1 -1
- package/dist/components/gui/gameover.ce.js +190 -138
- package/dist/components/gui/gameover.ce.js.map +1 -1
- package/dist/components/gui/hud/hud.ce.js +90 -33
- package/dist/components/gui/hud/hud.ce.js.map +1 -1
- package/dist/components/gui/index.js +14 -0
- package/dist/components/gui/menu/equip-menu.ce.js +478 -346
- package/dist/components/gui/menu/equip-menu.ce.js.map +1 -1
- package/dist/components/gui/menu/exit-menu.ce.js +52 -33
- package/dist/components/gui/menu/exit-menu.ce.js.map +1 -1
- package/dist/components/gui/menu/items-menu.ce.js +341 -226
- package/dist/components/gui/menu/items-menu.ce.js.map +1 -1
- package/dist/components/gui/menu/main-menu.ce.js +414 -205
- package/dist/components/gui/menu/main-menu.ce.js.map +1 -1
- package/dist/components/gui/menu/options-menu.ce.js +46 -26
- package/dist/components/gui/menu/options-menu.ce.js.map +1 -1
- package/dist/components/gui/menu/skills-menu.ce.js +104 -50
- package/dist/components/gui/menu/skills-menu.ce.js.map +1 -1
- package/dist/components/gui/mobile/index.js +18 -21
- package/dist/components/gui/mobile/index.js.map +1 -1
- package/dist/components/gui/mobile/mobile.ce.js +76 -15
- package/dist/components/gui/mobile/mobile.ce.js.map +1 -1
- package/dist/components/gui/notification/notification.ce.js +62 -36
- package/dist/components/gui/notification/notification.ce.js.map +1 -1
- package/dist/components/gui/save-load.ce.js +386 -239
- package/dist/components/gui/save-load.ce.js.map +1 -1
- package/dist/components/gui/shop/shop.ce.js +649 -319
- package/dist/components/gui/shop/shop.ce.js.map +1 -1
- package/dist/components/gui/title-screen.ce.js +187 -145
- package/dist/components/gui/title-screen.ce.js.map +1 -1
- package/dist/components/index.js +4 -0
- package/dist/components/prebuilt/hp-bar.ce.js +114 -104
- package/dist/components/prebuilt/hp-bar.ce.js.map +1 -1
- package/dist/components/prebuilt/index.js +2 -0
- package/dist/components/prebuilt/light-halo.ce.js +92 -74
- package/dist/components/prebuilt/light-halo.ce.js.map +1 -1
- package/dist/components/scenes/canvas.ce.js +58 -42
- package/dist/components/scenes/canvas.ce.js.map +1 -1
- package/dist/components/scenes/draw-map.ce.js +87 -64
- package/dist/components/scenes/draw-map.ce.js.map +1 -1
- package/dist/components/scenes/event-layer.ce.js +26 -16
- package/dist/components/scenes/event-layer.ce.js.map +1 -1
- package/dist/core/inject.js +11 -10
- package/dist/core/inject.js.map +1 -1
- package/dist/core/setup.js +13 -13
- package/dist/core/setup.js.map +1 -1
- package/dist/index.js +44 -41
- package/dist/module.js +169 -168
- package/dist/module.js.map +1 -1
- package/dist/node_modules/.pnpm/@signe_di@2.8.3/node_modules/@signe/di/dist/index.js +209 -298
- package/dist/node_modules/.pnpm/@signe_di@2.8.3/node_modules/@signe/di/dist/index.js.map +1 -1
- package/dist/node_modules/.pnpm/@signe_reactive@2.8.3/node_modules/@signe/reactive/dist/index.js +430 -507
- package/dist/node_modules/.pnpm/@signe_reactive@2.8.3/node_modules/@signe/reactive/dist/index.js.map +1 -1
- package/dist/node_modules/.pnpm/@signe_room@2.8.3/node_modules/@signe/room/dist/index.js +2062 -2571
- package/dist/node_modules/.pnpm/@signe_room@2.8.3/node_modules/@signe/room/dist/index.js.map +1 -1
- package/dist/node_modules/.pnpm/@signe_sync@2.8.3/node_modules/@signe/sync/dist/chunk-7QVYU63E.js +8 -3
- package/dist/node_modules/.pnpm/@signe_sync@2.8.3/node_modules/@signe/sync/dist/chunk-7QVYU63E.js.map +1 -1
- package/dist/node_modules/.pnpm/@signe_sync@2.8.3/node_modules/@signe/sync/dist/client/index.js +78 -101
- package/dist/node_modules/.pnpm/@signe_sync@2.8.3/node_modules/@signe/sync/dist/client/index.js.map +1 -1
- package/dist/node_modules/.pnpm/@signe_sync@2.8.3/node_modules/@signe/sync/dist/index.js +264 -401
- package/dist/node_modules/.pnpm/@signe_sync@2.8.3/node_modules/@signe/sync/dist/index.js.map +1 -1
- package/dist/node_modules/.pnpm/dset@3.1.4/node_modules/dset/dist/index.js +9 -7
- package/dist/node_modules/.pnpm/dset@3.1.4/node_modules/dset/dist/index.js.map +1 -1
- package/dist/node_modules/.pnpm/partysocket@1.1.3/node_modules/partysocket/dist/chunk-HAC622V3.js +106 -165
- package/dist/node_modules/.pnpm/partysocket@1.1.3/node_modules/partysocket/dist/chunk-HAC622V3.js.map +1 -1
- package/dist/node_modules/.pnpm/partysocket@1.1.3/node_modules/partysocket/dist/chunk-S74YV6PU.js +361 -461
- package/dist/node_modules/.pnpm/partysocket@1.1.3/node_modules/partysocket/dist/chunk-S74YV6PU.js.map +1 -1
- package/dist/node_modules/.pnpm/partysocket@1.1.3/node_modules/partysocket/dist/index.js +2 -0
- package/dist/node_modules/.pnpm/zod@3.24.2/node_modules/zod/lib/index.js +3633 -4280
- package/dist/node_modules/.pnpm/zod@3.24.2/node_modules/zod/lib/index.js.map +1 -1
- package/dist/presets/animation.js +37 -25
- package/dist/presets/animation.js.map +1 -1
- package/dist/presets/faceset.js +49 -22
- package/dist/presets/faceset.js.map +1 -1
- package/dist/presets/icon.js +13 -13
- package/dist/presets/icon.js.map +1 -1
- package/dist/presets/index.js +15 -14
- package/dist/presets/index.js.map +1 -1
- package/dist/presets/lpc.js +96 -93
- package/dist/presets/lpc.js.map +1 -1
- package/dist/presets/rmspritesheet.js +40 -39
- package/dist/presets/rmspritesheet.js.map +1 -1
- package/dist/services/AbstractSocket.js +10 -8
- package/dist/services/AbstractSocket.js.map +1 -1
- package/dist/services/keyboardControls.js +20 -18
- package/dist/services/keyboardControls.js.map +1 -1
- package/dist/services/loadMap.js +120 -36
- package/dist/services/loadMap.js.map +1 -1
- package/dist/services/mmorpg.js +128 -136
- package/dist/services/mmorpg.js.map +1 -1
- package/dist/services/save.js +74 -66
- package/dist/services/save.js.map +1 -1
- package/dist/services/standalone.js +165 -167
- package/dist/services/standalone.js.map +1 -1
- package/dist/utils/getEntityProp.js +49 -51
- package/dist/utils/getEntityProp.js.map +1 -1
- package/package.json +8 -8
- package/src/components/character.ce +1 -1
- package/src/components/scenes/draw-map.ce +3 -1
- package/dist/index.js.map +0 -1
package/dist/node_modules/.pnpm/@signe_reactive@2.8.3/node_modules/@signe/reactive/dist/index.js
CHANGED
|
@@ -1,540 +1,463 @@
|
|
|
1
|
-
import { BehaviorSubject,
|
|
2
|
-
|
|
1
|
+
import { BehaviorSubject, Observable, combineLatest, filter, finalize, map } from "rxjs";
|
|
2
|
+
//#region ../../node_modules/.pnpm/@signe+reactive@2.8.3/node_modules/@signe/reactive/dist/index.js
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
|
-
var __name = (target, value) => __defProp(target, "name", {
|
|
4
|
+
var __name = (target, value) => __defProp(target, "name", {
|
|
5
|
+
value,
|
|
6
|
+
configurable: true
|
|
7
|
+
});
|
|
5
8
|
var ArraySubject = class extends BehaviorSubject {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
return true;
|
|
98
|
-
}, "set")
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
get items() {
|
|
102
|
-
return this._items;
|
|
103
|
-
}
|
|
104
|
-
set items(newItems) {
|
|
105
|
-
this.createProxy(newItems);
|
|
106
|
-
this.next({
|
|
107
|
-
type: "reset",
|
|
108
|
-
items: newItems
|
|
109
|
-
});
|
|
110
|
-
}
|
|
9
|
+
static {
|
|
10
|
+
__name(this, "ArraySubject");
|
|
11
|
+
}
|
|
12
|
+
_items = [];
|
|
13
|
+
constructor(items = []) {
|
|
14
|
+
super({
|
|
15
|
+
type: "init",
|
|
16
|
+
items
|
|
17
|
+
});
|
|
18
|
+
this.createProxy(items);
|
|
19
|
+
}
|
|
20
|
+
createProxy(items) {
|
|
21
|
+
this._items = new Proxy(items, {
|
|
22
|
+
get: /* @__PURE__ */ __name((target, prop, receiver) => {
|
|
23
|
+
const origMethod = target[prop];
|
|
24
|
+
if (typeof origMethod === "function") return (...args) => {
|
|
25
|
+
let changeType = "update";
|
|
26
|
+
let index = void 0;
|
|
27
|
+
let isMutateFn = false;
|
|
28
|
+
let itemsToEmit = [];
|
|
29
|
+
let changeSplice = true;
|
|
30
|
+
switch (prop) {
|
|
31
|
+
case "push":
|
|
32
|
+
index = target.length;
|
|
33
|
+
changeType = "add";
|
|
34
|
+
isMutateFn = true;
|
|
35
|
+
break;
|
|
36
|
+
case "pop":
|
|
37
|
+
index = target.length - 1;
|
|
38
|
+
changeType = "remove";
|
|
39
|
+
isMutateFn = true;
|
|
40
|
+
break;
|
|
41
|
+
case "unshift":
|
|
42
|
+
index = 0;
|
|
43
|
+
changeType = "add";
|
|
44
|
+
isMutateFn = true;
|
|
45
|
+
break;
|
|
46
|
+
case "shift":
|
|
47
|
+
index = 0;
|
|
48
|
+
changeType = "remove";
|
|
49
|
+
isMutateFn = true;
|
|
50
|
+
break;
|
|
51
|
+
case "splice":
|
|
52
|
+
index = args[0];
|
|
53
|
+
const deleteCount = args[1];
|
|
54
|
+
const newItems = args.slice(2);
|
|
55
|
+
itemsToEmit = newItems;
|
|
56
|
+
if (deleteCount > 0 && newItems.length === 0) changeType = "remove";
|
|
57
|
+
else if (deleteCount === 0 && newItems.length > 0) changeType = "add";
|
|
58
|
+
else if (deleteCount === 0 && newItems.length === 0) changeSplice = false;
|
|
59
|
+
else changeType = "update";
|
|
60
|
+
isMutateFn = true;
|
|
61
|
+
break;
|
|
62
|
+
}
|
|
63
|
+
const result = origMethod.apply(target, args);
|
|
64
|
+
if (isMutateFn && changeSplice) if (prop === "splice") this.next({
|
|
65
|
+
type: changeType,
|
|
66
|
+
index,
|
|
67
|
+
items: itemsToEmit
|
|
68
|
+
});
|
|
69
|
+
else this.next({
|
|
70
|
+
type: changeType,
|
|
71
|
+
index,
|
|
72
|
+
items: args
|
|
73
|
+
});
|
|
74
|
+
return result;
|
|
75
|
+
};
|
|
76
|
+
return Reflect.get(target, prop, receiver);
|
|
77
|
+
}, "get"),
|
|
78
|
+
set: /* @__PURE__ */ __name((target, prop, value) => {
|
|
79
|
+
const index = !isNaN(Number(prop)) ? Number(prop) : void 0;
|
|
80
|
+
target[prop] = value;
|
|
81
|
+
this.next({
|
|
82
|
+
type: "update",
|
|
83
|
+
index,
|
|
84
|
+
items: [value]
|
|
85
|
+
});
|
|
86
|
+
return true;
|
|
87
|
+
}, "set")
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
get items() {
|
|
91
|
+
return this._items;
|
|
92
|
+
}
|
|
93
|
+
set items(newItems) {
|
|
94
|
+
this.createProxy(newItems);
|
|
95
|
+
this.next({
|
|
96
|
+
type: "reset",
|
|
97
|
+
items: newItems
|
|
98
|
+
});
|
|
99
|
+
}
|
|
111
100
|
};
|
|
112
101
|
var isArraySubject = /* @__PURE__ */ __name((value) => {
|
|
113
|
-
|
|
102
|
+
return "_items" in value;
|
|
114
103
|
}, "isArraySubject");
|
|
115
104
|
var ObjectSubject = class extends BehaviorSubject {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
105
|
+
static {
|
|
106
|
+
__name(this, "ObjectSubject");
|
|
107
|
+
}
|
|
108
|
+
_obj;
|
|
109
|
+
constructor(obj = {}) {
|
|
110
|
+
super({
|
|
111
|
+
type: "init",
|
|
112
|
+
value: obj
|
|
113
|
+
});
|
|
114
|
+
this.createProxy(obj);
|
|
115
|
+
}
|
|
116
|
+
createProxy(obj) {
|
|
117
|
+
this._obj = new Proxy(obj, {
|
|
118
|
+
get: /* @__PURE__ */ __name((target, prop, receiver) => {
|
|
119
|
+
return Reflect.get(target, prop, receiver);
|
|
120
|
+
}, "get"),
|
|
121
|
+
set: /* @__PURE__ */ __name((target, prop, value, receiver) => {
|
|
122
|
+
const key = prop;
|
|
123
|
+
const changeType = key in target ? "update" : "add";
|
|
124
|
+
target[key] = value;
|
|
125
|
+
this.next({
|
|
126
|
+
type: changeType,
|
|
127
|
+
key,
|
|
128
|
+
value
|
|
129
|
+
});
|
|
130
|
+
return true;
|
|
131
|
+
}, "set"),
|
|
132
|
+
deleteProperty: /* @__PURE__ */ __name((target, prop) => {
|
|
133
|
+
const key = prop;
|
|
134
|
+
if (key in target) {
|
|
135
|
+
const value = target[key];
|
|
136
|
+
delete target[key];
|
|
137
|
+
this.next({
|
|
138
|
+
type: "remove",
|
|
139
|
+
key,
|
|
140
|
+
value
|
|
141
|
+
});
|
|
142
|
+
return true;
|
|
143
|
+
}
|
|
144
|
+
return false;
|
|
145
|
+
}, "deleteProperty")
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
get obj() {
|
|
149
|
+
return this._obj;
|
|
150
|
+
}
|
|
151
|
+
set obj(newObj) {
|
|
152
|
+
this.createProxy(newObj);
|
|
153
|
+
this.next({
|
|
154
|
+
type: "reset",
|
|
155
|
+
value: newObj
|
|
156
|
+
});
|
|
157
|
+
}
|
|
169
158
|
};
|
|
170
159
|
var isObjectSubject = /* @__PURE__ */ __name((value) => {
|
|
171
|
-
|
|
160
|
+
return "_obj" in value;
|
|
172
161
|
}, "isObjectSubject");
|
|
173
|
-
var
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
globalObj[globalKey] = {
|
|
200
|
-
currentDependencyTracker: null,
|
|
201
|
-
currentSubscriptionsTracker: null
|
|
202
|
-
};
|
|
203
|
-
}
|
|
204
|
-
return globalObj[globalKey];
|
|
205
|
-
}, "getGlobalReactiveStore");
|
|
206
|
-
var reactiveStore = getGlobalReactiveStore();
|
|
162
|
+
var reactiveStore = (/* @__PURE__ */ __name(() => {
|
|
163
|
+
const globalKey = "__REACTIVE_STORE__";
|
|
164
|
+
if (typeof globalThis !== "undefined") {
|
|
165
|
+
if (!globalThis[globalKey]) globalThis[globalKey] = {
|
|
166
|
+
currentDependencyTracker: null,
|
|
167
|
+
currentSubscriptionsTracker: null
|
|
168
|
+
};
|
|
169
|
+
return globalThis[globalKey];
|
|
170
|
+
}
|
|
171
|
+
let globalObj;
|
|
172
|
+
if (typeof window !== "undefined") globalObj = window;
|
|
173
|
+
else if (typeof process !== "undefined" && process.versions && process.versions.node) globalObj = Function("return this")();
|
|
174
|
+
else if (typeof self !== "undefined") globalObj = self;
|
|
175
|
+
else {
|
|
176
|
+
console.warn("Unable to find global object, using local instance");
|
|
177
|
+
return {
|
|
178
|
+
currentDependencyTracker: null,
|
|
179
|
+
currentSubscriptionsTracker: null
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
if (!globalObj[globalKey]) globalObj[globalKey] = {
|
|
183
|
+
currentDependencyTracker: null,
|
|
184
|
+
currentSubscriptionsTracker: null
|
|
185
|
+
};
|
|
186
|
+
return globalObj[globalKey];
|
|
187
|
+
}, "getGlobalReactiveStore"))();
|
|
207
188
|
var trackDependency = /* @__PURE__ */ __name((signal2) => {
|
|
208
|
-
|
|
209
|
-
reactiveStore.currentDependencyTracker(signal2);
|
|
210
|
-
}
|
|
189
|
+
if (reactiveStore.currentDependencyTracker) reactiveStore.currentDependencyTracker(signal2);
|
|
211
190
|
}, "trackDependency");
|
|
212
191
|
function signal(defaultValue, options) {
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
});
|
|
262
|
-
} else if (subject instanceof ObjectSubject) {
|
|
263
|
-
subject.next({
|
|
264
|
-
type: "init",
|
|
265
|
-
value: subject.obj
|
|
266
|
-
});
|
|
267
|
-
} else {
|
|
268
|
-
subject.next(subject.value);
|
|
269
|
-
}
|
|
270
|
-
};
|
|
271
|
-
fn.mutate = (mutateFn) => {
|
|
272
|
-
const value = getValue();
|
|
273
|
-
mutateFn(value);
|
|
274
|
-
};
|
|
275
|
-
fn.update = (updateFn) => {
|
|
276
|
-
const updatedValue = updateFn(getValue());
|
|
277
|
-
fn.set(updatedValue);
|
|
278
|
-
};
|
|
279
|
-
fn.observable = subject.asObservable().pipe(filter(() => !fn._isFrozen));
|
|
280
|
-
fn._subject = subject;
|
|
281
|
-
return fn;
|
|
192
|
+
let subject;
|
|
193
|
+
if (Array.isArray(defaultValue)) subject = new ArraySubject(defaultValue);
|
|
194
|
+
else if (typeof defaultValue === "object" && defaultValue !== null) subject = new ObjectSubject(defaultValue);
|
|
195
|
+
else subject = new BehaviorSubject(defaultValue);
|
|
196
|
+
const getValue = /* @__PURE__ */ __name(() => {
|
|
197
|
+
if (subject instanceof ArraySubject) return subject.items;
|
|
198
|
+
else if (subject instanceof ObjectSubject) return subject.obj;
|
|
199
|
+
return subject.value;
|
|
200
|
+
}, "getValue");
|
|
201
|
+
const fn = /* @__PURE__ */ __name(function() {
|
|
202
|
+
trackDependency(fn);
|
|
203
|
+
return getValue();
|
|
204
|
+
}, "fn");
|
|
205
|
+
fn.set = (value) => {
|
|
206
|
+
const currentValue = getValue();
|
|
207
|
+
let shouldEmit = true;
|
|
208
|
+
if (options?.equal) shouldEmit = !options.equal(currentValue, value);
|
|
209
|
+
else shouldEmit = currentValue !== value;
|
|
210
|
+
if (shouldEmit) if (subject instanceof ArraySubject) subject.items = value;
|
|
211
|
+
else if (subject instanceof ObjectSubject) subject.obj = value;
|
|
212
|
+
else subject.next(value);
|
|
213
|
+
};
|
|
214
|
+
fn._isFrozen = false;
|
|
215
|
+
fn.freeze = () => {
|
|
216
|
+
fn._isFrozen = true;
|
|
217
|
+
};
|
|
218
|
+
fn.unfreeze = () => {
|
|
219
|
+
fn._isFrozen = false;
|
|
220
|
+
if (subject instanceof ArraySubject) subject.next({
|
|
221
|
+
type: "init",
|
|
222
|
+
items: subject.items
|
|
223
|
+
});
|
|
224
|
+
else if (subject instanceof ObjectSubject) subject.next({
|
|
225
|
+
type: "init",
|
|
226
|
+
value: subject.obj
|
|
227
|
+
});
|
|
228
|
+
else subject.next(subject.value);
|
|
229
|
+
};
|
|
230
|
+
fn.mutate = (mutateFn) => {
|
|
231
|
+
mutateFn(getValue());
|
|
232
|
+
};
|
|
233
|
+
fn.update = (updateFn) => {
|
|
234
|
+
const updatedValue = updateFn(getValue());
|
|
235
|
+
fn.set(updatedValue);
|
|
236
|
+
};
|
|
237
|
+
fn.observable = subject.asObservable().pipe(filter(() => !fn._isFrozen));
|
|
238
|
+
fn._subject = subject;
|
|
239
|
+
return fn;
|
|
282
240
|
}
|
|
283
241
|
__name(signal, "signal");
|
|
284
242
|
function isSignal(value) {
|
|
285
|
-
|
|
243
|
+
return !!(value && value.observable);
|
|
286
244
|
}
|
|
287
245
|
__name(isSignal, "isSignal");
|
|
288
246
|
function isComputed(value) {
|
|
289
|
-
|
|
247
|
+
return isSignal(value) && !!value.dependencies;
|
|
290
248
|
}
|
|
291
249
|
__name(isComputed, "isComputed");
|
|
292
250
|
function computed(computeFunction, disposableFn) {
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
fn.subscription = computedObservable.subscribe((value) => {
|
|
323
|
-
lastComputedValue = value;
|
|
324
|
-
});
|
|
325
|
-
fn.dependencies = dependencies;
|
|
326
|
-
reactiveStore.currentSubscriptionsTracker?.(fn.subscription);
|
|
327
|
-
init = false;
|
|
328
|
-
return fn;
|
|
251
|
+
const dependencies = /* @__PURE__ */ new Set();
|
|
252
|
+
let init = true;
|
|
253
|
+
let lastComputedValue;
|
|
254
|
+
const previousTracker = reactiveStore.currentDependencyTracker;
|
|
255
|
+
reactiveStore.currentDependencyTracker = (signal2) => {
|
|
256
|
+
dependencies.add(signal2);
|
|
257
|
+
};
|
|
258
|
+
lastComputedValue = computeFunction();
|
|
259
|
+
if (computeFunction["isEffect"]) disposableFn = lastComputedValue;
|
|
260
|
+
reactiveStore.currentDependencyTracker = previousTracker;
|
|
261
|
+
const computedObservable = combineLatest([...dependencies].map((dep) => {
|
|
262
|
+
if (isComputed(dep) && "dependencies" in dep) {
|
|
263
|
+
const computedDep = dep;
|
|
264
|
+
if (computedDep.dependencies.size === 0) return new BehaviorSubject(computedDep()).asObservable();
|
|
265
|
+
}
|
|
266
|
+
return dep.observable;
|
|
267
|
+
})).pipe(filter(() => !init), map(() => computeFunction()), finalize(() => disposableFn?.()));
|
|
268
|
+
const fn = /* @__PURE__ */ __name(function() {
|
|
269
|
+
trackDependency(fn);
|
|
270
|
+
return lastComputedValue;
|
|
271
|
+
}, "fn");
|
|
272
|
+
fn.observable = computedObservable;
|
|
273
|
+
fn.subscription = computedObservable.subscribe((value) => {
|
|
274
|
+
lastComputedValue = value;
|
|
275
|
+
});
|
|
276
|
+
fn.dependencies = dependencies;
|
|
277
|
+
reactiveStore.currentSubscriptionsTracker?.(fn.subscription);
|
|
278
|
+
init = false;
|
|
279
|
+
return fn;
|
|
329
280
|
}
|
|
330
281
|
__name(computed, "computed");
|
|
331
282
|
function linkedSignal(computationOrOptions, simpleOptions) {
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
fn.dependencies = dependencies;
|
|
490
|
-
fn._subject = subject;
|
|
491
|
-
fn.set = (value) => {
|
|
492
|
-
if (!isOverridden) {
|
|
493
|
-
overrideDepVersion = depVersion;
|
|
494
|
-
if (computationFn && sourceSignal) {
|
|
495
|
-
const sourceValue = untracked(() => {
|
|
496
|
-
if (typeof sourceSignal === "function") {
|
|
497
|
-
const source = sourceSignal;
|
|
498
|
-
return isSignal(source) ? source() : sourceSignal();
|
|
499
|
-
}
|
|
500
|
-
return sourceSignal();
|
|
501
|
-
});
|
|
502
|
-
previousValue = {
|
|
503
|
-
source: sourceValue,
|
|
504
|
-
value
|
|
505
|
-
};
|
|
506
|
-
}
|
|
507
|
-
}
|
|
508
|
-
isOverridden = true;
|
|
509
|
-
overriddenValue = value;
|
|
510
|
-
lastComputedValue = value;
|
|
511
|
-
subject.next(value);
|
|
512
|
-
};
|
|
513
|
-
reactiveStore.currentSubscriptionsTracker?.(fn.subscription);
|
|
514
|
-
init = false;
|
|
515
|
-
return fn;
|
|
283
|
+
const dependencies = /* @__PURE__ */ new Set();
|
|
284
|
+
let init = true;
|
|
285
|
+
let lastComputedValue;
|
|
286
|
+
let computeFunction;
|
|
287
|
+
let sourceSignal;
|
|
288
|
+
let computationFn;
|
|
289
|
+
let equalFn;
|
|
290
|
+
let previousValue;
|
|
291
|
+
let isOverridden = false;
|
|
292
|
+
let overriddenValue;
|
|
293
|
+
let depVersion = 0;
|
|
294
|
+
let overrideDepVersion = null;
|
|
295
|
+
if (typeof computationOrOptions === "function") {
|
|
296
|
+
computeFunction = computationOrOptions;
|
|
297
|
+
equalFn = simpleOptions?.equal;
|
|
298
|
+
} else {
|
|
299
|
+
const options = computationOrOptions;
|
|
300
|
+
sourceSignal = options.source;
|
|
301
|
+
computationFn = options.computation;
|
|
302
|
+
equalFn = options.equal;
|
|
303
|
+
if (typeof sourceSignal === "function" && !isSignal(sourceSignal)) {
|
|
304
|
+
const sourceFn = sourceSignal;
|
|
305
|
+
computeFunction = /* @__PURE__ */ __name(() => {
|
|
306
|
+
const sourceValue = sourceFn();
|
|
307
|
+
if (computationFn.length > 1) {
|
|
308
|
+
const result = computationFn(sourceValue, previousValue);
|
|
309
|
+
previousValue = {
|
|
310
|
+
source: sourceValue,
|
|
311
|
+
value: result
|
|
312
|
+
};
|
|
313
|
+
return result;
|
|
314
|
+
} else {
|
|
315
|
+
const result = computationFn(sourceValue);
|
|
316
|
+
previousValue = {
|
|
317
|
+
source: sourceValue,
|
|
318
|
+
value: result
|
|
319
|
+
};
|
|
320
|
+
return result;
|
|
321
|
+
}
|
|
322
|
+
}, "computeFunction");
|
|
323
|
+
} else {
|
|
324
|
+
const source = typeof sourceSignal === "function" ? sourceSignal : sourceSignal;
|
|
325
|
+
computeFunction = /* @__PURE__ */ __name(() => {
|
|
326
|
+
const sourceValue = source();
|
|
327
|
+
if (computationFn.length > 1) {
|
|
328
|
+
const result = computationFn(sourceValue, previousValue);
|
|
329
|
+
previousValue = {
|
|
330
|
+
source: sourceValue,
|
|
331
|
+
value: result
|
|
332
|
+
};
|
|
333
|
+
return result;
|
|
334
|
+
} else {
|
|
335
|
+
const result = computationFn(sourceValue);
|
|
336
|
+
previousValue = {
|
|
337
|
+
source: sourceValue,
|
|
338
|
+
value: result
|
|
339
|
+
};
|
|
340
|
+
return result;
|
|
341
|
+
}
|
|
342
|
+
}, "computeFunction");
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
const previousTracker = reactiveStore.currentDependencyTracker;
|
|
346
|
+
reactiveStore.currentDependencyTracker = (signal2) => {
|
|
347
|
+
dependencies.add(signal2);
|
|
348
|
+
};
|
|
349
|
+
if (sourceSignal && typeof sourceSignal === "function" && !isSignal(sourceSignal)) lastComputedValue = computeFunction();
|
|
350
|
+
else if (sourceSignal && isSignal(sourceSignal)) {
|
|
351
|
+
dependencies.add(sourceSignal);
|
|
352
|
+
lastComputedValue = computeFunction();
|
|
353
|
+
} else lastComputedValue = computeFunction();
|
|
354
|
+
reactiveStore.currentDependencyTracker = previousTracker;
|
|
355
|
+
const subject = new BehaviorSubject(lastComputedValue);
|
|
356
|
+
const observables = [...dependencies].map((dep) => {
|
|
357
|
+
if (isComputed(dep) && "dependencies" in dep) {
|
|
358
|
+
const computedDep = dep;
|
|
359
|
+
if (computedDep.dependencies.size === 0) return new BehaviorSubject(computedDep()).asObservable();
|
|
360
|
+
}
|
|
361
|
+
return dep.observable;
|
|
362
|
+
});
|
|
363
|
+
let linkedObservable;
|
|
364
|
+
if (observables.length > 0) linkedObservable = combineLatest(observables).pipe(filter(() => !init), map(() => {
|
|
365
|
+
const computed2 = computeFunction();
|
|
366
|
+
if (equalFn) {
|
|
367
|
+
if (!equalFn(lastComputedValue, computed2)) {
|
|
368
|
+
lastComputedValue = computed2;
|
|
369
|
+
isOverridden = false;
|
|
370
|
+
}
|
|
371
|
+
} else if (lastComputedValue !== computed2) {
|
|
372
|
+
lastComputedValue = computed2;
|
|
373
|
+
isOverridden = false;
|
|
374
|
+
}
|
|
375
|
+
return lastComputedValue;
|
|
376
|
+
}));
|
|
377
|
+
else linkedObservable = subject.asObservable().pipe(filter(() => !init));
|
|
378
|
+
const fn = /* @__PURE__ */ __name(function() {
|
|
379
|
+
trackDependency(fn);
|
|
380
|
+
if (isOverridden && dependencies.size > 0) {
|
|
381
|
+
if (overrideDepVersion !== depVersion) {
|
|
382
|
+
const computed2 = computeFunction();
|
|
383
|
+
isOverridden = false;
|
|
384
|
+
overriddenValue = void 0;
|
|
385
|
+
lastComputedValue = computed2;
|
|
386
|
+
overrideDepVersion = null;
|
|
387
|
+
return computed2;
|
|
388
|
+
}
|
|
389
|
+
return overriddenValue;
|
|
390
|
+
}
|
|
391
|
+
if (isOverridden) return overriddenValue;
|
|
392
|
+
if (dependencies.size === 0) lastComputedValue = computeFunction();
|
|
393
|
+
return lastComputedValue;
|
|
394
|
+
}, "fn");
|
|
395
|
+
fn.observable = new Observable((observer) => {
|
|
396
|
+
const depSubscription = linkedObservable.subscribe((value) => {
|
|
397
|
+
if (dependencies.size > 0) {
|
|
398
|
+
depVersion++;
|
|
399
|
+
isOverridden = false;
|
|
400
|
+
overrideDepVersion = null;
|
|
401
|
+
lastComputedValue = value;
|
|
402
|
+
} else lastComputedValue = value;
|
|
403
|
+
observer.next(value);
|
|
404
|
+
});
|
|
405
|
+
let subjectSubscription;
|
|
406
|
+
if (dependencies.size === 0) subjectSubscription = subject.pipe(filter(() => !init)).subscribe((value) => {
|
|
407
|
+
observer.next(value);
|
|
408
|
+
});
|
|
409
|
+
observer.next(lastComputedValue);
|
|
410
|
+
return () => {
|
|
411
|
+
depSubscription.unsubscribe();
|
|
412
|
+
if (subjectSubscription) subjectSubscription.unsubscribe();
|
|
413
|
+
};
|
|
414
|
+
});
|
|
415
|
+
fn.subscription = fn.observable.subscribe(() => {});
|
|
416
|
+
fn.dependencies = dependencies;
|
|
417
|
+
fn._subject = subject;
|
|
418
|
+
fn.set = (value) => {
|
|
419
|
+
if (!isOverridden) {
|
|
420
|
+
overrideDepVersion = depVersion;
|
|
421
|
+
if (computationFn && sourceSignal) previousValue = {
|
|
422
|
+
source: untracked(() => {
|
|
423
|
+
if (typeof sourceSignal === "function") {
|
|
424
|
+
const source = sourceSignal;
|
|
425
|
+
return isSignal(source) ? source() : sourceSignal();
|
|
426
|
+
}
|
|
427
|
+
return sourceSignal();
|
|
428
|
+
}),
|
|
429
|
+
value
|
|
430
|
+
};
|
|
431
|
+
}
|
|
432
|
+
isOverridden = true;
|
|
433
|
+
overriddenValue = value;
|
|
434
|
+
lastComputedValue = value;
|
|
435
|
+
subject.next(value);
|
|
436
|
+
};
|
|
437
|
+
reactiveStore.currentSubscriptionsTracker?.(fn.subscription);
|
|
438
|
+
init = false;
|
|
439
|
+
return fn;
|
|
516
440
|
}
|
|
517
441
|
__name(linkedSignal, "linkedSignal");
|
|
518
442
|
function untracked(fn) {
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
443
|
+
const prevDepTracker = reactiveStore.currentDependencyTracker;
|
|
444
|
+
const prevSubTracker = reactiveStore.currentSubscriptionsTracker;
|
|
445
|
+
reactiveStore.currentDependencyTracker = null;
|
|
446
|
+
reactiveStore.currentSubscriptionsTracker = null;
|
|
447
|
+
try {
|
|
448
|
+
return fn();
|
|
449
|
+
} finally {
|
|
450
|
+
reactiveStore.currentDependencyTracker = prevDepTracker;
|
|
451
|
+
reactiveStore.currentSubscriptionsTracker = prevSubTracker;
|
|
452
|
+
}
|
|
529
453
|
}
|
|
530
454
|
__name(untracked, "untracked");
|
|
531
|
-
|
|
532
|
-
// src/effect.ts
|
|
533
455
|
function effect(fn) {
|
|
534
|
-
|
|
535
|
-
|
|
456
|
+
fn["isEffect"] = true;
|
|
457
|
+
return computed(fn);
|
|
536
458
|
}
|
|
537
459
|
__name(effect, "effect");
|
|
460
|
+
//#endregion
|
|
461
|
+
export { isArraySubject, isComputed, isObjectSubject, isSignal, signal };
|
|
538
462
|
|
|
539
|
-
|
|
540
|
-
//# sourceMappingURL=index.js.map
|
|
463
|
+
//# sourceMappingURL=index.js.map
|