@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
|
@@ -1,464 +1,327 @@
|
|
|
1
|
-
import { __name } from
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
// src/utils.ts
|
|
1
|
+
import { __name } from "./chunk-7QVYU63E.js";
|
|
2
|
+
import { isArraySubject, isComputed, isObjectSubject, isSignal } from "../../../../../@signe_reactive@2.8.3/node_modules/@signe/reactive/dist/index.js";
|
|
3
|
+
//#region ../../node_modules/.pnpm/@signe+sync@2.8.3/node_modules/@signe/sync/dist/index.js
|
|
5
4
|
function isFunction(val) {
|
|
6
|
-
|
|
5
|
+
return {}.toString.call(val) === "[object Function]";
|
|
7
6
|
}
|
|
8
7
|
__name(isFunction, "isFunction");
|
|
9
8
|
function isClass(obj) {
|
|
10
|
-
|
|
9
|
+
return typeof obj === "function" && obj.prototype && obj.prototype.constructor === obj;
|
|
11
10
|
}
|
|
12
11
|
__name(isClass, "isClass");
|
|
13
12
|
var isObject = /* @__PURE__ */ __name((item) => item && typeof item === "object" && !Array.isArray(item) && item !== null, "isObject");
|
|
14
13
|
function isInstanceOfClass(value) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
return Object.getPrototypeOf(value) !== Object.prototype;
|
|
14
|
+
if (value === null || typeof value !== "object" || value === void 0 || Array.isArray(value)) return false;
|
|
15
|
+
return Object.getPrototypeOf(value) !== Object.prototype;
|
|
19
16
|
}
|
|
20
17
|
__name(isInstanceOfClass, "isInstanceOfClass");
|
|
21
18
|
function generateShortUUID() {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
19
|
+
const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
20
|
+
let uuid = "";
|
|
21
|
+
for (let i = 0; i < 8; i++) {
|
|
22
|
+
const randomIndex = Math.floor(Math.random() * 62);
|
|
23
|
+
uuid += chars[randomIndex];
|
|
24
|
+
}
|
|
25
|
+
return uuid;
|
|
29
26
|
}
|
|
30
27
|
__name(generateShortUUID, "generateShortUUID");
|
|
31
|
-
|
|
32
|
-
// src/core.ts
|
|
33
28
|
var DELETE_TOKEN = "$delete";
|
|
34
29
|
var syncClass = /* @__PURE__ */ __name((instance, options = {}) => {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
30
|
+
const cacheSync = /* @__PURE__ */ new Map();
|
|
31
|
+
const cachePersist = /* @__PURE__ */ new Map();
|
|
32
|
+
instance.$valuesChanges = {
|
|
33
|
+
set: /* @__PURE__ */ __name((path, value) => {
|
|
34
|
+
cacheSync.set(path, value);
|
|
35
|
+
options.onSync?.(cacheSync);
|
|
36
|
+
}, "set"),
|
|
37
|
+
setPersist: /* @__PURE__ */ __name((path, value) => {
|
|
38
|
+
if (path == "") path = ".";
|
|
39
|
+
cachePersist.set(path, value);
|
|
40
|
+
options.onPersist?.(cachePersist);
|
|
41
|
+
}, "setPersist"),
|
|
42
|
+
has: /* @__PURE__ */ __name((path) => {
|
|
43
|
+
return cacheSync.has(path);
|
|
44
|
+
}, "has"),
|
|
45
|
+
get: /* @__PURE__ */ __name((path) => {
|
|
46
|
+
return cacheSync.get(path);
|
|
47
|
+
}, "get")
|
|
48
|
+
};
|
|
49
|
+
createSyncClass(instance);
|
|
55
50
|
}, "syncClass");
|
|
56
51
|
function createStatesSnapshot(instance) {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
if (persist2) {
|
|
67
|
-
persistObject[key] = value;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
return persistObject;
|
|
52
|
+
let persistObject = {};
|
|
53
|
+
if (instance?.$snapshot) for (const key of instance.$snapshot.keys()) {
|
|
54
|
+
const signal = instance.$snapshot.get(key);
|
|
55
|
+
const persist2 = signal.options.persist ?? true;
|
|
56
|
+
let value = signal();
|
|
57
|
+
if (isObject(value) || Array.isArray(value)) continue;
|
|
58
|
+
if (persist2) persistObject[key] = value;
|
|
59
|
+
}
|
|
60
|
+
return persistObject;
|
|
72
61
|
}
|
|
73
62
|
__name(createStatesSnapshot, "createStatesSnapshot");
|
|
74
63
|
var SNAPSHOT_SKIP = Symbol("snapshot-skip");
|
|
75
64
|
var serializeSnapshotDeep = /* @__PURE__ */ __name((value, path, options, seen) => {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
return result2;
|
|
103
|
-
}
|
|
104
|
-
const result = {};
|
|
105
|
-
const idKey = isInstanceOfClass(value) ? value.constructor?._propertyMetadata?.get("id") : void 0;
|
|
106
|
-
const entries = Object.entries(value).filter(([key]) => isInstanceOfClass(value) ? key.startsWith("__") || (idKey ? key === idKey : false) : true);
|
|
107
|
-
for (const [key, childValue] of entries) {
|
|
108
|
-
const normalizedKey = key.startsWith("__") ? key.slice(2) : key;
|
|
109
|
-
const childPath = path ? `${path}.${normalizedKey}` : normalizedKey;
|
|
110
|
-
const serialized = serializeSnapshotDeep(childValue, childPath, options, seen);
|
|
111
|
-
if (serialized !== SNAPSHOT_SKIP) {
|
|
112
|
-
result[normalizedKey] = serialized;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
return result;
|
|
116
|
-
}
|
|
117
|
-
return value;
|
|
65
|
+
if (isSignal(value)) return serializeSnapshotDeep(value(), path, options, seen);
|
|
66
|
+
if (value instanceof Map) return SNAPSHOT_SKIP;
|
|
67
|
+
if (options.filter && !options.filter(value, path)) return SNAPSHOT_SKIP;
|
|
68
|
+
if (value instanceof Date) return options.dateToString ? options.dateToString(value) : value.toISOString();
|
|
69
|
+
if (value && typeof value === "object") {
|
|
70
|
+
if (seen.has(value)) return SNAPSHOT_SKIP;
|
|
71
|
+
seen.add(value);
|
|
72
|
+
if (Array.isArray(value)) {
|
|
73
|
+
const result2 = [];
|
|
74
|
+
value.forEach((item, index) => {
|
|
75
|
+
const serialized = serializeSnapshotDeep(item, path ? `${path}.${index}` : String(index), options, seen);
|
|
76
|
+
if (serialized !== SNAPSHOT_SKIP) result2.push(serialized);
|
|
77
|
+
});
|
|
78
|
+
return result2;
|
|
79
|
+
}
|
|
80
|
+
const result = {};
|
|
81
|
+
const idKey = isInstanceOfClass(value) ? value.constructor?._propertyMetadata?.get("id") : void 0;
|
|
82
|
+
const entries = Object.entries(value).filter(([key]) => isInstanceOfClass(value) ? key.startsWith("__") || (idKey ? key === idKey : false) : true);
|
|
83
|
+
for (const [key, childValue] of entries) {
|
|
84
|
+
const normalizedKey = key.startsWith("__") ? key.slice(2) : key;
|
|
85
|
+
const serialized = serializeSnapshotDeep(childValue, path ? `${path}.${normalizedKey}` : normalizedKey, options, seen);
|
|
86
|
+
if (serialized !== SNAPSHOT_SKIP) result[normalizedKey] = serialized;
|
|
87
|
+
}
|
|
88
|
+
return result;
|
|
89
|
+
}
|
|
90
|
+
return value;
|
|
118
91
|
}, "serializeSnapshotDeep");
|
|
119
92
|
function createStatesSnapshotDeep(instance, options = {}) {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
const value = signal();
|
|
129
|
-
const serialized = serializeSnapshotDeep(value, key, options, /* @__PURE__ */ new WeakSet());
|
|
130
|
-
if (serialized !== SNAPSHOT_SKIP) {
|
|
131
|
-
persistObject[key] = serialized;
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
return persistObject;
|
|
93
|
+
const persistObject = {};
|
|
94
|
+
if (instance?.$snapshot) for (const key of instance.$snapshot.keys()) {
|
|
95
|
+
const signal = instance.$snapshot.get(key);
|
|
96
|
+
if (!(signal.options.persist ?? true)) continue;
|
|
97
|
+
const serialized = serializeSnapshotDeep(signal(), key, options, /* @__PURE__ */ new WeakSet());
|
|
98
|
+
if (serialized !== SNAPSHOT_SKIP) persistObject[key] = serialized;
|
|
99
|
+
}
|
|
100
|
+
return persistObject;
|
|
136
101
|
}
|
|
137
102
|
__name(createStatesSnapshotDeep, "createStatesSnapshotDeep");
|
|
138
103
|
function setMetadata(target, key, value) {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
if (isSignal(target[propId])) {
|
|
143
|
-
target[propId].set(value);
|
|
144
|
-
} else {
|
|
145
|
-
target[propId] = value;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
104
|
+
const propId = target.constructor._propertyMetadata?.get(key);
|
|
105
|
+
if (propId) if (isSignal(target[propId])) target[propId].set(value);
|
|
106
|
+
else target[propId] = value;
|
|
148
107
|
}
|
|
149
108
|
__name(setMetadata, "setMetadata");
|
|
150
109
|
var createSyncClass = /* @__PURE__ */ __name((currentClass, parentKey = null, parentClass = null, path = "") => {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
if (syncToClient) {
|
|
176
|
-
currentClass.$valuesChanges.set(newPath, transformedValue);
|
|
177
|
-
}
|
|
178
|
-
if (persist2) {
|
|
179
|
-
if (parentClass) currentClass.$valuesChanges.setPersist(path, transformedValue);
|
|
180
|
-
}
|
|
181
|
-
if (isComputed(signal)) {
|
|
182
|
-
signal.observable.subscribe((newValue) => {
|
|
183
|
-
if (syncToClient) {
|
|
184
|
-
const transformedNewValue = transform ? transform(newValue) : newValue;
|
|
185
|
-
currentClass.$valuesChanges.set(newPath, transformedNewValue);
|
|
186
|
-
}
|
|
187
|
-
});
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
}
|
|
110
|
+
currentClass.$path = path;
|
|
111
|
+
if (parentClass) currentClass.$valuesChanges = parentClass.$valuesChanges;
|
|
112
|
+
if (parentKey) setMetadata(currentClass, "id", parentKey);
|
|
113
|
+
if (currentClass.$snapshot) for (const key of currentClass.$snapshot.keys()) {
|
|
114
|
+
const signal = currentClass.$snapshot.get(key);
|
|
115
|
+
const syncToClient = signal.options?.syncToClient ?? true;
|
|
116
|
+
const persist2 = signal.options?.persist ?? true;
|
|
117
|
+
const transform = signal.options?.transform;
|
|
118
|
+
let signalValue = signal();
|
|
119
|
+
if (transform) signalValue = transform(signalValue);
|
|
120
|
+
if (isObject(signalValue) || Array.isArray(signalValue)) signalValue = { ...signalValue };
|
|
121
|
+
const transformedValue = signalValue;
|
|
122
|
+
const newPath = (path ? path + "." : "") + key;
|
|
123
|
+
if (syncToClient) currentClass.$valuesChanges.set(newPath, transformedValue);
|
|
124
|
+
if (persist2) {
|
|
125
|
+
if (parentClass) currentClass.$valuesChanges.setPersist(path, transformedValue);
|
|
126
|
+
}
|
|
127
|
+
if (isComputed(signal)) signal.observable.subscribe((newValue) => {
|
|
128
|
+
if (syncToClient) {
|
|
129
|
+
const transformedNewValue = transform ? transform(newValue) : newValue;
|
|
130
|
+
currentClass.$valuesChanges.set(newPath, transformedNewValue);
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
}
|
|
191
134
|
}, "createSyncClass");
|
|
192
135
|
var type = /* @__PURE__ */ __name((_signal, path, options = {}, currentInstance) => {
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
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
|
-
|
|
263
|
-
if (isComputed(signal)) {
|
|
264
|
-
savePath(fullPath, value);
|
|
265
|
-
} else if (isObjectSubject(signal._subject)) {
|
|
266
|
-
handleObjectSubject(value, fullPath);
|
|
267
|
-
} else if (isArraySubject(signal._subject)) {
|
|
268
|
-
handleArraySubject(value, fullPath);
|
|
269
|
-
} else {
|
|
270
|
-
savePath(fullPath, value);
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
});
|
|
274
|
-
if (!currentInstance.$snapshot) {
|
|
275
|
-
currentInstance.$snapshot = /* @__PURE__ */ new Map();
|
|
276
|
-
}
|
|
277
|
-
currentInstance.$snapshot.set(path, signal);
|
|
278
|
-
}, "setupSubscription");
|
|
279
|
-
if (!isSignal(_signal)) {
|
|
280
|
-
if (_signal && typeof _signal === "object" && !Array.isArray(_signal)) {
|
|
281
|
-
for (const key in _signal) {
|
|
282
|
-
if (Object.prototype.hasOwnProperty.call(_signal, key)) {
|
|
283
|
-
const value = _signal[key];
|
|
284
|
-
const propertyPath = `${path}.${key}`;
|
|
285
|
-
if (isSignal(value)) {
|
|
286
|
-
setupSubscription(value, propertyPath);
|
|
287
|
-
} else if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
288
|
-
type(value, propertyPath, options, currentInstance);
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
init = false;
|
|
293
|
-
}
|
|
294
|
-
return _signal;
|
|
295
|
-
}
|
|
296
|
-
setupSubscription(_signal, path);
|
|
297
|
-
init = false;
|
|
298
|
-
return _signal;
|
|
136
|
+
const { syncToClient = true, persist: persist2 = true, transform } = options;
|
|
137
|
+
let init = true;
|
|
138
|
+
const handleObjectSubject = /* @__PURE__ */ __name((value, propPath) => {
|
|
139
|
+
const newPath = `${propPath}${value.key ? `.${value.key}` : ""}`;
|
|
140
|
+
if ([
|
|
141
|
+
"add",
|
|
142
|
+
"reset",
|
|
143
|
+
"update"
|
|
144
|
+
].includes(value.type)) if (isInstanceOfClass(value.value)) createSyncClass(value.value, value.key, currentInstance, newPath);
|
|
145
|
+
else if (value.type === "update" && (isObject(value.value) || Array.isArray(value.value))) createSyncClass(value.value, value.key, currentInstance, newPath);
|
|
146
|
+
else savePath(newPath, value.value);
|
|
147
|
+
else if (value.type === "remove") savePath(newPath, DELETE_TOKEN);
|
|
148
|
+
}, "handleObjectSubject");
|
|
149
|
+
const handleArraySubject = /* @__PURE__ */ __name((value, propPath) => {
|
|
150
|
+
if (value.type === "reset" && Array.isArray(value.items)) {
|
|
151
|
+
value.items.forEach((item, index) => {
|
|
152
|
+
const newPath2 = `${propPath}.${index}`;
|
|
153
|
+
if (isInstanceOfClass(item)) createSyncClass(item, value.key, currentInstance, newPath2);
|
|
154
|
+
else savePath(newPath2, item);
|
|
155
|
+
});
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
const newPath = `${propPath}.${value.index}`;
|
|
159
|
+
const firstItem = value.items?.[0];
|
|
160
|
+
if (["add", "update"].includes(value.type) && firstItem !== void 0) if (isInstanceOfClass(firstItem)) createSyncClass(firstItem, value.key, currentInstance, newPath);
|
|
161
|
+
else if (value.type === "update" && (isObject(firstItem) || Array.isArray(firstItem))) createSyncClass(firstItem, value.key, currentInstance, newPath);
|
|
162
|
+
else savePath(newPath, firstItem);
|
|
163
|
+
else if (value.type === "remove") savePath(newPath, DELETE_TOKEN);
|
|
164
|
+
}, "handleArraySubject");
|
|
165
|
+
const savePath = /* @__PURE__ */ __name((propPath, value) => {
|
|
166
|
+
const transformedValue = transform && value !== "$delete" ? transform(value) : value;
|
|
167
|
+
if (syncToClient) currentInstance.$valuesChanges.set(propPath, transformedValue);
|
|
168
|
+
if (persist2 && currentInstance.$path !== void 0) currentInstance.$valuesChanges.setPersist(transformedValue == "$delete" ? propPath : currentInstance.$path, transformedValue);
|
|
169
|
+
}, "savePath");
|
|
170
|
+
const setupSubscription = /* @__PURE__ */ __name((signal, signalPath) => {
|
|
171
|
+
if (!isSignal(signal)) return;
|
|
172
|
+
if (syncToClient && currentInstance.$valuesChanges) {
|
|
173
|
+
const initialValue = signal();
|
|
174
|
+
const transformedInitialValue = transform ? transform(initialValue) : initialValue;
|
|
175
|
+
currentInstance.$valuesChanges.set(signalPath, transformedInitialValue);
|
|
176
|
+
}
|
|
177
|
+
signal.options = options;
|
|
178
|
+
signal.observable.subscribe((value) => {
|
|
179
|
+
if (init) return;
|
|
180
|
+
if (currentInstance.$path !== void 0) {
|
|
181
|
+
const fullPath = `${currentInstance.$path ? currentInstance.$path + "." : ""}${signalPath}`;
|
|
182
|
+
if (isComputed(signal)) savePath(fullPath, value);
|
|
183
|
+
else if (isObjectSubject(signal._subject)) handleObjectSubject(value, fullPath);
|
|
184
|
+
else if (isArraySubject(signal._subject)) handleArraySubject(value, fullPath);
|
|
185
|
+
else savePath(fullPath, value);
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
if (!currentInstance.$snapshot) currentInstance.$snapshot = /* @__PURE__ */ new Map();
|
|
189
|
+
currentInstance.$snapshot.set(path, signal);
|
|
190
|
+
}, "setupSubscription");
|
|
191
|
+
if (!isSignal(_signal)) {
|
|
192
|
+
if (_signal && typeof _signal === "object" && !Array.isArray(_signal)) {
|
|
193
|
+
for (const key in _signal) if (Object.prototype.hasOwnProperty.call(_signal, key)) {
|
|
194
|
+
const value = _signal[key];
|
|
195
|
+
const propertyPath = `${path}.${key}`;
|
|
196
|
+
if (isSignal(value)) setupSubscription(value, propertyPath);
|
|
197
|
+
else if (value && typeof value === "object" && !Array.isArray(value)) type(value, propertyPath, options, currentInstance);
|
|
198
|
+
}
|
|
199
|
+
init = false;
|
|
200
|
+
}
|
|
201
|
+
return _signal;
|
|
202
|
+
}
|
|
203
|
+
setupSubscription(_signal, path);
|
|
204
|
+
init = false;
|
|
205
|
+
return _signal;
|
|
299
206
|
}, "type");
|
|
300
|
-
|
|
301
|
-
// src/decorators.ts
|
|
302
207
|
function sync(options) {
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
Object.defineProperty(target, propertyKey, {
|
|
335
|
-
get: getter,
|
|
336
|
-
set: setter,
|
|
337
|
-
enumerable: true,
|
|
338
|
-
configurable: true
|
|
339
|
-
});
|
|
340
|
-
};
|
|
208
|
+
let classType;
|
|
209
|
+
let persist2 = true;
|
|
210
|
+
let syncToClient = true;
|
|
211
|
+
let transform;
|
|
212
|
+
if (typeof options === "function") classType = options;
|
|
213
|
+
else if (typeof options === "object") {
|
|
214
|
+
classType = options.classType;
|
|
215
|
+
if (options.hasOwnProperty("persist")) persist2 = options.persist;
|
|
216
|
+
if (options.hasOwnProperty("syncToClient")) syncToClient = options.syncToClient;
|
|
217
|
+
if (options.hasOwnProperty("transform")) transform = options.transform;
|
|
218
|
+
}
|
|
219
|
+
return function(target, propertyKey) {
|
|
220
|
+
const privatePropertyKey = `__${propertyKey}`;
|
|
221
|
+
const getter = /* @__PURE__ */ __name(function() {
|
|
222
|
+
return this[privatePropertyKey];
|
|
223
|
+
}, "getter");
|
|
224
|
+
const setter = /* @__PURE__ */ __name(function(newVal) {
|
|
225
|
+
this[privatePropertyKey] = type(newVal, propertyKey, {
|
|
226
|
+
classType,
|
|
227
|
+
persist: persist2,
|
|
228
|
+
syncToClient,
|
|
229
|
+
transform
|
|
230
|
+
}, this);
|
|
231
|
+
}, "setter");
|
|
232
|
+
Object.defineProperty(target, propertyKey, {
|
|
233
|
+
get: getter,
|
|
234
|
+
set: setter,
|
|
235
|
+
enumerable: true,
|
|
236
|
+
configurable: true
|
|
237
|
+
});
|
|
238
|
+
};
|
|
341
239
|
}
|
|
342
240
|
__name(sync, "sync");
|
|
343
241
|
function id() {
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
target.constructor._propertyMetadata.set("id", propertyKey);
|
|
349
|
-
};
|
|
242
|
+
return function(target, propertyKey) {
|
|
243
|
+
if (!target.constructor._propertyMetadata) target.constructor._propertyMetadata = /* @__PURE__ */ new Map();
|
|
244
|
+
target.constructor._propertyMetadata.set("id", propertyKey);
|
|
245
|
+
};
|
|
350
246
|
}
|
|
351
247
|
__name(id, "id");
|
|
352
248
|
function users(options) {
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
sync(options)(target, propertyKey);
|
|
359
|
-
};
|
|
249
|
+
return function(target, propertyKey) {
|
|
250
|
+
if (!target.constructor._propertyMetadata) target.constructor._propertyMetadata = /* @__PURE__ */ new Map();
|
|
251
|
+
target.constructor._propertyMetadata.set("users", propertyKey);
|
|
252
|
+
sync(options)(target, propertyKey);
|
|
253
|
+
};
|
|
360
254
|
}
|
|
361
255
|
__name(users, "users");
|
|
362
256
|
function persist() {
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
257
|
+
return sync({
|
|
258
|
+
persist: true,
|
|
259
|
+
syncToClient: false
|
|
260
|
+
});
|
|
367
261
|
}
|
|
368
262
|
__name(persist, "persist");
|
|
369
263
|
function connected() {
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
sync({
|
|
376
|
-
persist: false
|
|
377
|
-
})(target, propertyKey);
|
|
378
|
-
};
|
|
264
|
+
return function(target, propertyKey) {
|
|
265
|
+
if (!target.constructor._propertyMetadata) target.constructor._propertyMetadata = /* @__PURE__ */ new Map();
|
|
266
|
+
target.constructor._propertyMetadata.set("connected", propertyKey);
|
|
267
|
+
sync({ persist: false })(target, propertyKey);
|
|
268
|
+
};
|
|
379
269
|
}
|
|
380
270
|
__name(connected, "connected");
|
|
381
271
|
function load(rootInstance, values, valueIsObject) {
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
} else {
|
|
385
|
-
loadFromPaths(rootInstance, values);
|
|
386
|
-
}
|
|
272
|
+
if (valueIsObject) loadFromObject(rootInstance, values);
|
|
273
|
+
else loadFromPaths(rootInstance, values);
|
|
387
274
|
}
|
|
388
275
|
__name(load, "load");
|
|
389
276
|
function loadFromPaths(rootInstance, values) {
|
|
390
|
-
|
|
391
|
-
const parts = path.split(".");
|
|
392
|
-
loadValue(rootInstance, parts, value);
|
|
393
|
-
}
|
|
277
|
+
for (const [path, value] of Object.entries(values)) loadValue(rootInstance, path.split("."), value);
|
|
394
278
|
}
|
|
395
279
|
__name(loadFromPaths, "loadFromPaths");
|
|
396
280
|
function loadFromObject(rootInstance, values, currentPath = "") {
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
const parts = newPath.split(".");
|
|
404
|
-
loadValue(rootInstance, parts, value);
|
|
405
|
-
}
|
|
406
|
-
}
|
|
281
|
+
for (let key in values) {
|
|
282
|
+
const value = values[key];
|
|
283
|
+
const newPath = currentPath ? `${currentPath}.${key}` : key;
|
|
284
|
+
if (typeof value === "object" && !Array.isArray(value) && value !== null) loadFromObject(rootInstance, value, newPath);
|
|
285
|
+
else loadValue(rootInstance, newPath.split("."), value);
|
|
286
|
+
}
|
|
407
287
|
}
|
|
408
288
|
__name(loadFromObject, "loadFromObject");
|
|
409
289
|
function loadValue(rootInstance, parts, value) {
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
if (currentValue === void 0) {
|
|
432
|
-
const parentInstance = getByPath(rootInstance, parts.slice(0, i).join("."));
|
|
433
|
-
const classType = parentInstance?.options?.classType;
|
|
434
|
-
if (classType) {
|
|
435
|
-
current[part] = !isClass(classType) ? classType(part) : new classType();
|
|
436
|
-
setMetadata(current[part], "id", part);
|
|
437
|
-
} else {
|
|
438
|
-
current[part] = {};
|
|
439
|
-
}
|
|
440
|
-
}
|
|
441
|
-
current = current[part];
|
|
442
|
-
}
|
|
443
|
-
}
|
|
290
|
+
let current = rootInstance;
|
|
291
|
+
for (let i = 0; i < parts.length; i++) {
|
|
292
|
+
const part = parts[i];
|
|
293
|
+
if (i === parts.length - 1) if (value == "$delete") {
|
|
294
|
+
if (isSignal(current)) current = current();
|
|
295
|
+
Reflect.deleteProperty(current, part);
|
|
296
|
+
} else if (current[part]?._subject) current[part].set(value);
|
|
297
|
+
else if (isSignal(current) && Array.isArray(current()) && !isNaN(Number(part))) current()[Number(part)] = value;
|
|
298
|
+
else current[part] = value;
|
|
299
|
+
else {
|
|
300
|
+
if (isSignal(current)) current = current();
|
|
301
|
+
if (current[part] === void 0) {
|
|
302
|
+
const classType = getByPath(rootInstance, parts.slice(0, i).join("."))?.options?.classType;
|
|
303
|
+
if (classType) {
|
|
304
|
+
current[part] = !isClass(classType) ? classType(part) : new classType();
|
|
305
|
+
setMetadata(current[part], "id", part);
|
|
306
|
+
} else current[part] = {};
|
|
307
|
+
}
|
|
308
|
+
current = current[part];
|
|
309
|
+
}
|
|
310
|
+
}
|
|
444
311
|
}
|
|
445
312
|
__name(loadValue, "loadValue");
|
|
446
313
|
function getByPath(root, path) {
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
} else {
|
|
456
|
-
return void 0;
|
|
457
|
-
}
|
|
458
|
-
}
|
|
459
|
-
return current;
|
|
314
|
+
const parts = path.split(".");
|
|
315
|
+
let current = root;
|
|
316
|
+
for (const part of parts) {
|
|
317
|
+
if (isSignal(current)) current = current();
|
|
318
|
+
if (current[part]) current = current[part];
|
|
319
|
+
else return;
|
|
320
|
+
}
|
|
321
|
+
return current;
|
|
460
322
|
}
|
|
461
323
|
__name(getByPath, "getByPath");
|
|
324
|
+
//#endregion
|
|
325
|
+
export { DELETE_TOKEN, createStatesSnapshot, createStatesSnapshotDeep, generateShortUUID, getByPath, id, load, persist, sync, syncClass, users };
|
|
462
326
|
|
|
463
|
-
|
|
464
|
-
//# sourceMappingURL=index.js.map
|
|
327
|
+
//# sourceMappingURL=index.js.map
|