@rpgjs/client 5.0.0-alpha.10 → 5.0.0-alpha.11
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/Map.d.ts +4 -0
- package/dist/Gui/Gui.d.ts +82 -5
- package/dist/RpgClient.d.ts +35 -5
- package/dist/RpgClientEngine.d.ts +3 -0
- package/dist/components/gui/index.d.ts +3 -3
- package/dist/index.d.ts +1 -0
- package/dist/index.js +6 -5
- package/dist/index.js.map +1 -1
- package/dist/index10.js +105 -4
- package/dist/index10.js.map +1 -1
- package/dist/index11.js +20 -7
- package/dist/index11.js.map +1 -1
- package/dist/index12.js +6 -8
- package/dist/index12.js.map +1 -1
- package/dist/index13.js +9 -14
- package/dist/index13.js.map +1 -1
- package/dist/index14.js +8 -100
- package/dist/index14.js.map +1 -1
- package/dist/index15.js +141 -35
- package/dist/index15.js.map +1 -1
- package/dist/index16.js +45 -186
- package/dist/index16.js.map +1 -1
- package/dist/index17.js +229 -5
- package/dist/index17.js.map +1 -1
- package/dist/index18.js +5 -383
- package/dist/index18.js.map +1 -1
- package/dist/index19.js +384 -28
- package/dist/index19.js.map +1 -1
- package/dist/index2.js +15 -8
- package/dist/index2.js.map +1 -1
- package/dist/index20.js +31 -17
- package/dist/index20.js.map +1 -1
- package/dist/index21.js +17 -2413
- package/dist/index21.js.map +1 -1
- package/dist/index22.js +2587 -88
- package/dist/index22.js.map +1 -1
- package/dist/index23.js +108 -103
- package/dist/index23.js.map +1 -1
- package/dist/index29.js.map +1 -1
- package/dist/index3.js +2 -2
- package/dist/index30.js +14 -1
- package/dist/index30.js.map +1 -1
- package/dist/index37.js +56 -169
- package/dist/index37.js.map +1 -1
- package/dist/index38.js +162 -489
- package/dist/index38.js.map +1 -1
- package/dist/index39.js +496 -56
- package/dist/index39.js.map +1 -1
- package/dist/index4.js +2 -2
- package/dist/index41.js +21 -7
- package/dist/index41.js.map +1 -1
- package/dist/index5.js +1 -1
- package/dist/index6.js +1 -1
- package/dist/index7.js +1 -1
- package/dist/index8.js +1 -1
- package/dist/index9.js +105 -14
- package/dist/index9.js.map +1 -1
- package/dist/services/mmorpg.d.ts +1 -1
- package/dist/services/standalone.d.ts +1 -1
- package/package.json +7 -5
- package/src/Game/AnimationManager.ts +1 -0
- package/src/Game/Map.ts +9 -1
- package/src/Game/Object.ts +28 -6
- package/src/Gui/Gui.ts +141 -16
- package/src/RpgClient.ts +36 -5
- package/src/RpgClientEngine.ts +11 -1
- package/src/components/character.ce +11 -9
- package/src/components/gui/box.ce +17 -0
- package/src/components/gui/dialogbox/index.ce +1 -0
- package/src/components/gui/index.ts +3 -4
- package/src/components/scenes/event-layer.ce +6 -0
- package/src/index.ts +2 -1
package/dist/index17.js
CHANGED
|
@@ -1,9 +1,233 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
|
|
4
|
+
// src/inject.ts
|
|
5
|
+
function provide(context, name, value) {
|
|
6
|
+
context.set("inject:" + name, value);
|
|
7
|
+
return value;
|
|
8
|
+
}
|
|
9
|
+
__name(provide, "provide");
|
|
10
|
+
function isInjected(context, name) {
|
|
11
|
+
return context.get("injected:" + name) === true;
|
|
12
|
+
}
|
|
13
|
+
__name(isInjected, "isInjected");
|
|
14
|
+
function isProvided(context, name) {
|
|
15
|
+
return context.get("inject:" + name) !== void 0;
|
|
16
|
+
}
|
|
17
|
+
__name(isProvided, "isProvided");
|
|
18
|
+
function inject(context, service, args = []) {
|
|
19
|
+
const isClass = typeof service === "function";
|
|
20
|
+
const name = isClass ? service.name : service;
|
|
21
|
+
const value = context.get("inject:" + name);
|
|
22
|
+
if (value) {
|
|
23
|
+
context.set("injected:" + name, true);
|
|
24
|
+
return value;
|
|
25
|
+
}
|
|
26
|
+
throw new Error(`Injection provider ${name} not found`);
|
|
27
|
+
}
|
|
28
|
+
__name(inject, "inject");
|
|
29
|
+
function override(providers, newProvider, options) {
|
|
30
|
+
let { upsert = false, key } = options ?? {};
|
|
31
|
+
if (!key) {
|
|
32
|
+
key = typeof newProvider === "function" ? newProvider.name : newProvider.provide;
|
|
33
|
+
}
|
|
34
|
+
const flatProviders = providers.flat();
|
|
35
|
+
const exists = flatProviders.some((provider) => {
|
|
36
|
+
if (typeof provider === "function") {
|
|
37
|
+
return provider.name === key;
|
|
38
|
+
} else if (typeof provider === "object") {
|
|
39
|
+
return provider.provide === key;
|
|
40
|
+
}
|
|
41
|
+
return false;
|
|
42
|
+
});
|
|
43
|
+
const mappedProviders = flatProviders.map((provider) => {
|
|
44
|
+
if (typeof provider === "function" && provider.name === key) {
|
|
45
|
+
return newProvider;
|
|
46
|
+
} else if (typeof provider === "object" && provider.provide === key) {
|
|
47
|
+
return newProvider;
|
|
48
|
+
}
|
|
49
|
+
return provider;
|
|
50
|
+
});
|
|
51
|
+
if (upsert && !exists) {
|
|
52
|
+
mappedProviders.push(newProvider);
|
|
53
|
+
}
|
|
54
|
+
return mappedProviders;
|
|
55
|
+
}
|
|
56
|
+
__name(override, "override");
|
|
57
|
+
function findProviders(providers, name) {
|
|
58
|
+
const results = [];
|
|
59
|
+
for (const provider of providers) {
|
|
60
|
+
if (Array.isArray(provider)) {
|
|
61
|
+
results.push(...findProviders(provider, name));
|
|
62
|
+
} else if (findProvider(provider, name)) {
|
|
63
|
+
results.push(provider);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return results;
|
|
67
|
+
}
|
|
68
|
+
__name(findProviders, "findProviders");
|
|
69
|
+
function findProvider(providers, name) {
|
|
70
|
+
if (!Array.isArray(providers)) {
|
|
71
|
+
if (typeof providers === "object" && "provide" in providers) {
|
|
72
|
+
const provider = providers;
|
|
73
|
+
const providerName = typeof provider.provide === "function" ? provider.provide.name : provider.provide;
|
|
74
|
+
if (name instanceof RegExp) {
|
|
75
|
+
if (name.test(providerName)) return providers;
|
|
76
|
+
} else {
|
|
77
|
+
if (providerName === name) return providers;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
for (const provider of providers) {
|
|
83
|
+
if (Array.isArray(provider)) {
|
|
84
|
+
const found = findProvider(provider, name);
|
|
85
|
+
if (found) return found;
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
if (typeof provider === "object" && "provide" in provider) {
|
|
89
|
+
const providerName = typeof provider.provide === "function" ? provider.provide.name : provider.provide;
|
|
90
|
+
if (name instanceof RegExp) {
|
|
91
|
+
if (name.test(providerName)) return provider;
|
|
92
|
+
} else {
|
|
93
|
+
if (providerName === name) return provider;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
__name(findProvider, "findProvider");
|
|
100
|
+
|
|
101
|
+
// src/merge-config.ts
|
|
102
|
+
function processProvider(mergedConfig, baseConfig, provider) {
|
|
103
|
+
if (Array.isArray(provider)) {
|
|
104
|
+
for (const nestedProvider of provider) {
|
|
105
|
+
processProvider(mergedConfig, baseConfig, nestedProvider);
|
|
106
|
+
}
|
|
107
|
+
return;
|
|
5
108
|
}
|
|
109
|
+
const existingProvider = findProvider(baseConfig.providers, provider.provide);
|
|
110
|
+
if (existingProvider) {
|
|
111
|
+
mergedConfig.providers = override(mergedConfig.providers, provider);
|
|
112
|
+
} else {
|
|
113
|
+
mergedConfig.providers.push(provider);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
__name(processProvider, "processProvider");
|
|
117
|
+
function mergeConfig(baseConfig, config) {
|
|
118
|
+
const mergedConfig = {
|
|
119
|
+
...baseConfig,
|
|
120
|
+
...config,
|
|
121
|
+
providers: [
|
|
122
|
+
...baseConfig.providers
|
|
123
|
+
]
|
|
124
|
+
// Start with a copy of base providers
|
|
125
|
+
};
|
|
126
|
+
for (const provider of config.providers) {
|
|
127
|
+
processProvider(mergedConfig, baseConfig, provider);
|
|
128
|
+
}
|
|
129
|
+
return mergedConfig;
|
|
130
|
+
}
|
|
131
|
+
__name(mergeConfig, "mergeConfig");
|
|
132
|
+
|
|
133
|
+
// src/provider.ts
|
|
134
|
+
function getDeps(provider) {
|
|
135
|
+
if (typeof provider === "function") {
|
|
136
|
+
return provider.deps ?? [];
|
|
137
|
+
}
|
|
138
|
+
return provider.deps ?? [];
|
|
6
139
|
}
|
|
140
|
+
__name(getDeps, "getDeps");
|
|
141
|
+
function sortProviders(providers) {
|
|
142
|
+
const tokenName = /* @__PURE__ */ __name((t) => typeof t === "function" ? t.name : t, "tokenName");
|
|
143
|
+
const map = /* @__PURE__ */ new Map();
|
|
144
|
+
for (const p of providers) {
|
|
145
|
+
const token = tokenName(typeof p === "function" ? p : p.provide);
|
|
146
|
+
map.set(token, p);
|
|
147
|
+
}
|
|
148
|
+
const result = [];
|
|
149
|
+
const visited = /* @__PURE__ */ new Set();
|
|
150
|
+
const stack = /* @__PURE__ */ new Set();
|
|
151
|
+
const visit = /* @__PURE__ */ __name((token) => {
|
|
152
|
+
const name = tokenName(token);
|
|
153
|
+
if (visited.has(name)) return;
|
|
154
|
+
if (stack.has(name)) {
|
|
155
|
+
throw new Error(`Circular dependency detected for provider ${name}`);
|
|
156
|
+
}
|
|
157
|
+
stack.add(name);
|
|
158
|
+
const provider = map.get(name);
|
|
159
|
+
if (provider) {
|
|
160
|
+
for (const dep of getDeps(provider)) {
|
|
161
|
+
visit(dep);
|
|
162
|
+
}
|
|
163
|
+
visited.add(name);
|
|
164
|
+
result.push(provider);
|
|
165
|
+
}
|
|
166
|
+
stack.delete(name);
|
|
167
|
+
}, "visit");
|
|
168
|
+
for (const p of providers) {
|
|
169
|
+
const token = typeof p === "function" ? p : p.provide;
|
|
170
|
+
visit(token);
|
|
171
|
+
}
|
|
172
|
+
return result;
|
|
173
|
+
}
|
|
174
|
+
__name(sortProviders, "sortProviders");
|
|
175
|
+
async function injector(context, providers) {
|
|
176
|
+
providers = providers.flat();
|
|
177
|
+
providers = sortProviders(providers);
|
|
178
|
+
for (const provider of providers) {
|
|
179
|
+
let token;
|
|
180
|
+
let instance;
|
|
181
|
+
if (typeof provider === "function") {
|
|
182
|
+
token = provider;
|
|
183
|
+
instance = new provider(context);
|
|
184
|
+
} else {
|
|
185
|
+
token = provider.provide;
|
|
186
|
+
const provideUserClass = provider.useClass;
|
|
187
|
+
const isClass = typeof provideUserClass === "function";
|
|
188
|
+
if (isClass) {
|
|
189
|
+
instance = new provideUserClass(context);
|
|
190
|
+
} else if ("useValue" in provider) {
|
|
191
|
+
instance = provider.useValue;
|
|
192
|
+
} else if ("useFactory" in provider) {
|
|
193
|
+
instance = provider.useFactory?.(context);
|
|
194
|
+
if (instance instanceof Promise) {
|
|
195
|
+
instance = await instance;
|
|
196
|
+
}
|
|
197
|
+
} else if ("useExisting" in provider) {
|
|
198
|
+
instance = inject(context, provider.useExisting);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
const name = typeof token === "function" ? token.name : token;
|
|
202
|
+
provide(context, name, instance);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
__name(injector, "injector");
|
|
206
|
+
|
|
207
|
+
// src/context.ts
|
|
208
|
+
var Context = class {
|
|
209
|
+
static {
|
|
210
|
+
__name(this, "Context");
|
|
211
|
+
}
|
|
212
|
+
/** Internal storage for injected values */
|
|
213
|
+
values = {};
|
|
214
|
+
/**
|
|
215
|
+
* Sets a value in the context
|
|
216
|
+
* @param key - Unique identifier for the value
|
|
217
|
+
* @param value - Value to store
|
|
218
|
+
*/
|
|
219
|
+
set(key, value) {
|
|
220
|
+
this.values[key] = value;
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Retrieves a value from the context
|
|
224
|
+
* @param key - Unique identifier for the value
|
|
225
|
+
* @returns The stored value or undefined if not found
|
|
226
|
+
*/
|
|
227
|
+
get(key) {
|
|
228
|
+
return this.values[key];
|
|
229
|
+
}
|
|
230
|
+
};
|
|
7
231
|
|
|
8
|
-
export {
|
|
232
|
+
export { Context, findProvider, findProviders, inject, injector, isInjected, isProvided, mergeConfig, override, provide };
|
|
9
233
|
//# sourceMappingURL=index17.js.map
|
package/dist/index17.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index17.js","sources":["../src/services/AbstractSocket.ts"],"sourcesContent":["import { Context } from \"@signe/di\";\n\nexport const WebSocketToken = \"websocket\";\n\nexport abstract class AbstractWebsocket {\n constructor(protected context: Context) {}\n\n abstract connection(listeners?: (data: any) => void): Promise<void>;\n abstract emit(event: string, data: any): void;\n abstract on(event: string, callback: (data: any) => void): void;\n abstract off(event: string, callback: (data: any) => void): void;\n abstract updateProperties(params: { room: string, host?: string }): void;\n abstract reconnect(listeners?: (data: any) => void): void;\n}\n"],"names":[],"mappings":"AAEO,MAAM,cAAiB,GAAA;AAEvB,MAAe,iBAAkB,CAAA;AAAA,EACtC,YAAsB,OAAkB,EAAA;AAAlB,IAAA,IAAA,CAAA,OAAA,GAAA,OAAA;AAAA;AAQxB;;;;"}
|
|
1
|
+
{"version":3,"file":"index17.js","sources":["../../../node_modules/.pnpm/@signe+di@2.4.0/node_modules/@signe/di/dist/index.js"],"sourcesContent":["var __defProp = Object.defineProperty;\nvar __name = (target, value) => __defProp(target, \"name\", { value, configurable: true });\n\n// src/inject.ts\nfunction provide(context, name, value) {\n context.set(\"inject:\" + name, value);\n return value;\n}\n__name(provide, \"provide\");\nfunction isInjected(context, name) {\n return context.get(\"injected:\" + name) === true;\n}\n__name(isInjected, \"isInjected\");\nfunction isProvided(context, name) {\n return context.get(\"inject:\" + name) !== void 0;\n}\n__name(isProvided, \"isProvided\");\nfunction inject(context, service, args = []) {\n const isClass = typeof service === \"function\";\n const name = isClass ? service.name : service;\n const value = context.get(\"inject:\" + name);\n if (value) {\n context.set(\"injected:\" + name, true);\n return value;\n }\n throw new Error(`Injection provider ${name} not found`);\n}\n__name(inject, \"inject\");\nfunction override(providers, newProvider, options) {\n let { upsert = false, key } = options ?? {};\n if (!key) {\n key = typeof newProvider === \"function\" ? newProvider.name : newProvider.provide;\n }\n const flatProviders = providers.flat();\n const exists = flatProviders.some((provider) => {\n if (typeof provider === \"function\") {\n return provider.name === key;\n } else if (typeof provider === \"object\") {\n return provider.provide === key;\n }\n return false;\n });\n const mappedProviders = flatProviders.map((provider) => {\n if (typeof provider === \"function\" && provider.name === key) {\n return newProvider;\n } else if (typeof provider === \"object\" && provider.provide === key) {\n return newProvider;\n }\n return provider;\n });\n if (upsert && !exists) {\n mappedProviders.push(newProvider);\n }\n return mappedProviders;\n}\n__name(override, \"override\");\nfunction findProviders(providers, name) {\n const results = [];\n for (const provider of providers) {\n if (Array.isArray(provider)) {\n results.push(...findProviders(provider, name));\n } else if (findProvider(provider, name)) {\n results.push(provider);\n }\n }\n return results;\n}\n__name(findProviders, \"findProviders\");\nfunction findProvider(providers, name) {\n if (!Array.isArray(providers)) {\n if (typeof providers === \"object\" && \"provide\" in providers) {\n const provider = providers;\n const providerName = typeof provider.provide === \"function\" ? provider.provide.name : provider.provide;\n if (name instanceof RegExp) {\n if (name.test(providerName)) return providers;\n } else {\n if (providerName === name) return providers;\n }\n }\n return null;\n }\n for (const provider of providers) {\n if (Array.isArray(provider)) {\n const found = findProvider(provider, name);\n if (found) return found;\n continue;\n }\n if (typeof provider === \"object\" && \"provide\" in provider) {\n const providerName = typeof provider.provide === \"function\" ? provider.provide.name : provider.provide;\n if (name instanceof RegExp) {\n if (name.test(providerName)) return provider;\n } else {\n if (providerName === name) return provider;\n }\n }\n }\n return null;\n}\n__name(findProvider, \"findProvider\");\n\n// src/merge-config.ts\nfunction processProvider(mergedConfig, baseConfig, provider) {\n if (Array.isArray(provider)) {\n for (const nestedProvider of provider) {\n processProvider(mergedConfig, baseConfig, nestedProvider);\n }\n return;\n }\n const existingProvider = findProvider(baseConfig.providers, provider.provide);\n if (existingProvider) {\n mergedConfig.providers = override(mergedConfig.providers, provider);\n } else {\n mergedConfig.providers.push(provider);\n }\n}\n__name(processProvider, \"processProvider\");\nfunction mergeConfig(baseConfig, config) {\n const mergedConfig = {\n ...baseConfig,\n ...config,\n providers: [\n ...baseConfig.providers\n ]\n // Start with a copy of base providers\n };\n for (const provider of config.providers) {\n processProvider(mergedConfig, baseConfig, provider);\n }\n return mergedConfig;\n}\n__name(mergeConfig, \"mergeConfig\");\n\n// src/provider.ts\nfunction getDeps(provider) {\n if (typeof provider === \"function\") {\n return provider.deps ?? [];\n }\n return provider.deps ?? [];\n}\n__name(getDeps, \"getDeps\");\nfunction sortProviders(providers) {\n const tokenName = /* @__PURE__ */ __name((t) => typeof t === \"function\" ? t.name : t, \"tokenName\");\n const map = /* @__PURE__ */ new Map();\n for (const p of providers) {\n const token = tokenName(typeof p === \"function\" ? p : p.provide);\n map.set(token, p);\n }\n const result = [];\n const visited = /* @__PURE__ */ new Set();\n const stack = /* @__PURE__ */ new Set();\n const visit = /* @__PURE__ */ __name((token) => {\n const name = tokenName(token);\n if (visited.has(name)) return;\n if (stack.has(name)) {\n throw new Error(`Circular dependency detected for provider ${name}`);\n }\n stack.add(name);\n const provider = map.get(name);\n if (provider) {\n for (const dep of getDeps(provider)) {\n visit(dep);\n }\n visited.add(name);\n result.push(provider);\n }\n stack.delete(name);\n }, \"visit\");\n for (const p of providers) {\n const token = typeof p === \"function\" ? p : p.provide;\n visit(token);\n }\n return result;\n}\n__name(sortProviders, \"sortProviders\");\nasync function injector(context, providers) {\n providers = providers.flat();\n providers = sortProviders(providers);\n for (const provider of providers) {\n let token;\n let instance;\n if (typeof provider === \"function\") {\n token = provider;\n instance = new provider(context);\n } else {\n token = provider.provide;\n const provideUserClass = provider.useClass;\n const isClass = typeof provideUserClass === \"function\";\n if (isClass) {\n instance = new provideUserClass(context);\n } else if (\"useValue\" in provider) {\n instance = provider.useValue;\n } else if (\"useFactory\" in provider) {\n instance = provider.useFactory?.(context);\n if (instance instanceof Promise) {\n instance = await instance;\n }\n } else if (\"useExisting\" in provider) {\n instance = inject(context, provider.useExisting);\n }\n }\n const name = typeof token === \"function\" ? token.name : token;\n provide(context, name, instance);\n }\n}\n__name(injector, \"injector\");\n\n// src/context.ts\nvar Context = class {\n static {\n __name(this, \"Context\");\n }\n /** Internal storage for injected values */\n values = {};\n /**\n * Sets a value in the context\n * @param key - Unique identifier for the value\n * @param value - Value to store\n */\n set(key, value) {\n this.values[key] = value;\n }\n /**\n * Retrieves a value from the context\n * @param key - Unique identifier for the value\n * @returns The stored value or undefined if not found\n */\n get(key) {\n return this.values[key];\n }\n};\nexport {\n Context,\n findProvider,\n findProviders,\n inject,\n injector,\n isInjected,\n isProvided,\n mergeConfig,\n override,\n provide\n};\n//# sourceMappingURL=index.js.map"],"names":[],"mappings":"AAAA,IAAI,SAAS,GAAG,MAAM,CAAC,cAAc;AACrC,IAAI,MAAM,GAAG,CAAC,MAAM,EAAE,KAAK,KAAK,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC;;AAExF;AACA,SAAS,OAAO,CAAC,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE;AACvC,EAAE,OAAO,CAAC,GAAG,CAAC,SAAS,GAAG,IAAI,EAAE,KAAK,CAAC;AACtC,EAAE,OAAO,KAAK;AACd;AACA,MAAM,CAAC,OAAO,EAAE,SAAS,CAAC;AAC1B,SAAS,UAAU,CAAC,OAAO,EAAE,IAAI,EAAE;AACnC,EAAE,OAAO,OAAO,CAAC,GAAG,CAAC,WAAW,GAAG,IAAI,CAAC,KAAK,IAAI;AACjD;AACA,MAAM,CAAC,UAAU,EAAE,YAAY,CAAC;AAChC,SAAS,UAAU,CAAC,OAAO,EAAE,IAAI,EAAE;AACnC,EAAE,OAAO,OAAO,CAAC,GAAG,CAAC,SAAS,GAAG,IAAI,CAAC,KAAK,MAAM;AACjD;AACA,MAAM,CAAC,UAAU,EAAE,YAAY,CAAC;AAChC,SAAS,MAAM,CAAC,OAAO,E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AQ,CAAC,WAAW,CAAC;AACxD;AACA;AACA,IAAI,MAAM,IAAI,GAAG,OAAO,KAAK,KAAK,UAAU,GAAG,KAAK,CAAC,IAAI,GAAG,KAAK;AACjE,IAAI,OAAO,CAAC,OAAO,EAAE,IAAI,EAAE,QAAQ,CAAC;AACpC;AACA;AACA,MAAM,CAAC,QAAQ,EAAE,UAAU,CAAC;;AAE5B;AACG,IAAC,OAAO,GAAG,MAAM;AACpB,EAAE;AACF,IAAI,MAAM,CAAC,IAAI,EAAE,SAAS,CAAC;AAC3B;AACA;AACA,EAAE,MAAM,GAAG,EAAE;AACb;AACA;AACA;AACA;AACA;AACA,EAAE,GAAG,CAAC,GAAG,EAAE,KAAK,EAAE;AAClB,IAAI,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK;AAC5B;AACA;AACA;AACA;AACA;AACA;AACA,EAAE,GAAG,CAAC,GAAG,EAAE;AACX,IAAI,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC;AAC3B;AACA;;;;","x_google_ignoreList":[0]}
|
package/dist/index18.js
CHANGED
|
@@ -1,387 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
function isFunction(val) {
|
|
6
|
-
return {}.toString.call(val) === "[object Function]";
|
|
7
|
-
}
|
|
8
|
-
__name(isFunction, "isFunction");
|
|
9
|
-
function isClass(obj) {
|
|
10
|
-
return typeof obj === "function" && obj.prototype && obj.prototype.constructor === obj;
|
|
11
|
-
}
|
|
12
|
-
__name(isClass, "isClass");
|
|
13
|
-
var isObject = /* @__PURE__ */ __name((item) => item && typeof item === "object" && !Array.isArray(item) && item !== null, "isObject");
|
|
14
|
-
function isInstanceOfClass(value) {
|
|
15
|
-
if (value === null || typeof value !== "object" || value === void 0 || Array.isArray(value)) {
|
|
16
|
-
return false;
|
|
17
|
-
}
|
|
18
|
-
return Object.getPrototypeOf(value) !== Object.prototype;
|
|
19
|
-
}
|
|
20
|
-
__name(isInstanceOfClass, "isInstanceOfClass");
|
|
21
|
-
function generateShortUUID() {
|
|
22
|
-
const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
23
|
-
let uuid = "";
|
|
24
|
-
for (let i = 0; i < 8; i++) {
|
|
25
|
-
const randomIndex = Math.floor(Math.random() * chars.length);
|
|
26
|
-
uuid += chars[randomIndex];
|
|
27
|
-
}
|
|
28
|
-
return uuid;
|
|
29
|
-
}
|
|
30
|
-
__name(generateShortUUID, "generateShortUUID");
|
|
31
|
-
|
|
32
|
-
// src/core.ts
|
|
33
|
-
var DELETE_TOKEN = "$delete";
|
|
34
|
-
var syncClass = /* @__PURE__ */ __name((instance, options = {}) => {
|
|
35
|
-
const cacheSync = /* @__PURE__ */ new Map();
|
|
36
|
-
const cachePersist = /* @__PURE__ */ new Map();
|
|
37
|
-
instance.$valuesChanges = {
|
|
38
|
-
set: /* @__PURE__ */ __name((path, value) => {
|
|
39
|
-
cacheSync.set(path, value);
|
|
40
|
-
options.onSync?.(cacheSync);
|
|
41
|
-
}, "set"),
|
|
42
|
-
setPersist: /* @__PURE__ */ __name((path, value) => {
|
|
43
|
-
if (path == "") path = ".";
|
|
44
|
-
cachePersist.set(path, value);
|
|
45
|
-
options.onPersist?.(cachePersist);
|
|
46
|
-
}, "setPersist"),
|
|
47
|
-
has: /* @__PURE__ */ __name((path) => {
|
|
48
|
-
return cacheSync.has(path);
|
|
49
|
-
}, "has"),
|
|
50
|
-
get: /* @__PURE__ */ __name((path) => {
|
|
51
|
-
return cacheSync.get(path);
|
|
52
|
-
}, "get")
|
|
53
|
-
};
|
|
54
|
-
createSyncClass(instance);
|
|
55
|
-
}, "syncClass");
|
|
56
|
-
function createStatesSnapshot(instance) {
|
|
57
|
-
let persistObject = {};
|
|
58
|
-
if (instance?.$snapshot) {
|
|
59
|
-
for (const key of instance.$snapshot.keys()) {
|
|
60
|
-
const signal = instance.$snapshot.get(key);
|
|
61
|
-
const persist2 = signal.options.persist ?? true;
|
|
62
|
-
let value = signal();
|
|
63
|
-
if (isObject(value) || Array.isArray(value)) {
|
|
64
|
-
continue;
|
|
65
|
-
}
|
|
66
|
-
if (persist2) {
|
|
67
|
-
persistObject[key] = value;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
return persistObject;
|
|
72
|
-
}
|
|
73
|
-
__name(createStatesSnapshot, "createStatesSnapshot");
|
|
74
|
-
function setMetadata(target, key, value) {
|
|
75
|
-
const meta = target.constructor._propertyMetadata;
|
|
76
|
-
const propId = meta?.get(key);
|
|
77
|
-
if (propId) {
|
|
78
|
-
if (isSignal(target[propId])) {
|
|
79
|
-
target[propId].set(value);
|
|
80
|
-
} else {
|
|
81
|
-
target[propId] = value;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
__name(setMetadata, "setMetadata");
|
|
86
|
-
var createSyncClass = /* @__PURE__ */ __name((currentClass, parentKey = null, parentClass = null, path = "") => {
|
|
87
|
-
currentClass.$path = path;
|
|
88
|
-
if (parentClass) {
|
|
89
|
-
currentClass.$valuesChanges = parentClass.$valuesChanges;
|
|
90
|
-
}
|
|
91
|
-
if (parentKey) {
|
|
92
|
-
setMetadata(currentClass, "id", parentKey);
|
|
93
|
-
}
|
|
94
|
-
if (currentClass.$snapshot) {
|
|
95
|
-
for (const key of currentClass.$snapshot.keys()) {
|
|
96
|
-
const signal = currentClass.$snapshot.get(key);
|
|
97
|
-
const syncToClient = signal.options?.syncToClient ?? true;
|
|
98
|
-
const persist2 = signal.options?.persist ?? true;
|
|
99
|
-
let signalValue = signal();
|
|
100
|
-
if (isObject(signalValue) || Array.isArray(signalValue)) {
|
|
101
|
-
signalValue = {
|
|
102
|
-
...signalValue
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
const newPath = (path ? path + "." : "") + key;
|
|
106
|
-
if (syncToClient) {
|
|
107
|
-
currentClass.$valuesChanges.set(newPath, signalValue);
|
|
108
|
-
}
|
|
109
|
-
if (persist2) {
|
|
110
|
-
if (parentClass) currentClass.$valuesChanges.setPersist(path, signalValue);
|
|
111
|
-
}
|
|
112
|
-
if (isComputed(signal)) {
|
|
113
|
-
signal.observable.subscribe((newValue) => {
|
|
114
|
-
if (syncToClient) {
|
|
115
|
-
currentClass.$valuesChanges.set(newPath, newValue);
|
|
116
|
-
}
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
}, "createSyncClass");
|
|
122
|
-
var type = /* @__PURE__ */ __name((_signal, path, options = {}, currentInstance) => {
|
|
123
|
-
const { syncToClient = true, persist: persist2 = true } = options;
|
|
124
|
-
let init = true;
|
|
125
|
-
const handleObjectSubject = /* @__PURE__ */ __name((value, propPath) => {
|
|
126
|
-
const newPath = `${propPath}${value.key ? `.${value.key}` : ""}`;
|
|
127
|
-
if ([
|
|
128
|
-
"add",
|
|
129
|
-
"reset",
|
|
130
|
-
"update"
|
|
131
|
-
].includes(value.type)) {
|
|
132
|
-
if (isInstanceOfClass(value.value)) {
|
|
133
|
-
createSyncClass(value.value, value.key, currentInstance, newPath);
|
|
134
|
-
} else if (value.type === "update" && (isObject(value.value) || Array.isArray(value.value))) {
|
|
135
|
-
createSyncClass(value.value, value.key, currentInstance, newPath);
|
|
136
|
-
} else {
|
|
137
|
-
savePath(newPath, value.value);
|
|
138
|
-
}
|
|
139
|
-
} else if (value.type === "remove") {
|
|
140
|
-
savePath(newPath, DELETE_TOKEN);
|
|
141
|
-
}
|
|
142
|
-
}, "handleObjectSubject");
|
|
143
|
-
const handleArraySubject = /* @__PURE__ */ __name((value, propPath) => {
|
|
144
|
-
if (value.type === "reset" && Array.isArray(value.items)) {
|
|
145
|
-
value.items.forEach((item, index) => {
|
|
146
|
-
const newPath2 = `${propPath}.${index}`;
|
|
147
|
-
if (isInstanceOfClass(item)) {
|
|
148
|
-
createSyncClass(item, value.key, currentInstance, newPath2);
|
|
149
|
-
} else {
|
|
150
|
-
savePath(newPath2, item);
|
|
151
|
-
}
|
|
152
|
-
});
|
|
153
|
-
return;
|
|
154
|
-
}
|
|
155
|
-
const newPath = `${propPath}.${value.index}`;
|
|
156
|
-
const firstItem = value.items?.[0];
|
|
157
|
-
if ([
|
|
158
|
-
"add",
|
|
159
|
-
"update"
|
|
160
|
-
].includes(value.type) && firstItem !== void 0) {
|
|
161
|
-
if (isInstanceOfClass(firstItem)) {
|
|
162
|
-
createSyncClass(firstItem, value.key, currentInstance, newPath);
|
|
163
|
-
} else if (value.type === "update" && (isObject(firstItem) || Array.isArray(firstItem))) {
|
|
164
|
-
createSyncClass(firstItem, value.key, currentInstance, newPath);
|
|
165
|
-
} else {
|
|
166
|
-
savePath(newPath, firstItem);
|
|
167
|
-
}
|
|
168
|
-
} else if (value.type === "remove") {
|
|
169
|
-
savePath(newPath, DELETE_TOKEN);
|
|
170
|
-
}
|
|
171
|
-
}, "handleArraySubject");
|
|
172
|
-
const savePath = /* @__PURE__ */ __name((propPath, value) => {
|
|
173
|
-
if (syncToClient) {
|
|
174
|
-
currentInstance.$valuesChanges.set(propPath, value);
|
|
175
|
-
}
|
|
176
|
-
if (persist2 && currentInstance.$path !== void 0) {
|
|
177
|
-
currentInstance.$valuesChanges.setPersist(value == DELETE_TOKEN ? propPath : currentInstance.$path, value);
|
|
178
|
-
}
|
|
179
|
-
}, "savePath");
|
|
180
|
-
const setupSubscription = /* @__PURE__ */ __name((signal, signalPath) => {
|
|
181
|
-
if (!isSignal(signal)) return;
|
|
182
|
-
if (syncToClient && currentInstance.$valuesChanges) {
|
|
183
|
-
const initialValue = signal();
|
|
184
|
-
currentInstance.$valuesChanges.set(signalPath, initialValue);
|
|
185
|
-
}
|
|
186
|
-
signal.options = options;
|
|
187
|
-
signal.observable.subscribe((value) => {
|
|
188
|
-
if (init) return;
|
|
189
|
-
if (currentInstance.$path !== void 0) {
|
|
190
|
-
const fullPath = `${currentInstance.$path ? currentInstance.$path + "." : ""}${signalPath}`;
|
|
191
|
-
if (isComputed(signal)) {
|
|
192
|
-
savePath(fullPath, value);
|
|
193
|
-
} else if (isObjectSubject(signal._subject)) {
|
|
194
|
-
handleObjectSubject(value, fullPath);
|
|
195
|
-
} else if (isArraySubject(signal._subject)) {
|
|
196
|
-
handleArraySubject(value, fullPath);
|
|
197
|
-
} else {
|
|
198
|
-
savePath(fullPath, value);
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
});
|
|
202
|
-
if (!currentInstance.$snapshot) {
|
|
203
|
-
currentInstance.$snapshot = /* @__PURE__ */ new Map();
|
|
204
|
-
}
|
|
205
|
-
currentInstance.$snapshot.set(path, signal);
|
|
206
|
-
}, "setupSubscription");
|
|
207
|
-
if (!isSignal(_signal)) {
|
|
208
|
-
if (_signal && typeof _signal === "object" && !Array.isArray(_signal)) {
|
|
209
|
-
for (const key in _signal) {
|
|
210
|
-
if (Object.prototype.hasOwnProperty.call(_signal, key)) {
|
|
211
|
-
const value = _signal[key];
|
|
212
|
-
const propertyPath = `${path}.${key}`;
|
|
213
|
-
if (isSignal(value)) {
|
|
214
|
-
setupSubscription(value, propertyPath);
|
|
215
|
-
} else if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
216
|
-
type(value, propertyPath, options, currentInstance);
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
init = false;
|
|
221
|
-
}
|
|
222
|
-
return _signal;
|
|
223
|
-
}
|
|
224
|
-
setupSubscription(_signal, path);
|
|
225
|
-
init = false;
|
|
226
|
-
return _signal;
|
|
227
|
-
}, "type");
|
|
228
|
-
|
|
229
|
-
// src/decorators.ts
|
|
230
|
-
function sync(options) {
|
|
231
|
-
let classType;
|
|
232
|
-
let persist2 = true;
|
|
233
|
-
let syncToClient = true;
|
|
234
|
-
if (typeof options === "function") {
|
|
235
|
-
classType = options;
|
|
236
|
-
} else if (typeof options === "object") {
|
|
237
|
-
classType = options.classType;
|
|
238
|
-
if (options.hasOwnProperty("persist")) {
|
|
239
|
-
persist2 = options.persist;
|
|
240
|
-
}
|
|
241
|
-
if (options.hasOwnProperty("syncToClient")) {
|
|
242
|
-
syncToClient = options.syncToClient;
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
return function(target, propertyKey) {
|
|
246
|
-
const privatePropertyKey = `__${propertyKey}`;
|
|
247
|
-
const getter = /* @__PURE__ */ __name(function() {
|
|
248
|
-
return this[privatePropertyKey];
|
|
249
|
-
}, "getter");
|
|
250
|
-
const setter = /* @__PURE__ */ __name(function(newVal) {
|
|
251
|
-
this[privatePropertyKey] = type(newVal, propertyKey, {
|
|
252
|
-
classType,
|
|
253
|
-
persist: persist2,
|
|
254
|
-
syncToClient
|
|
255
|
-
}, this);
|
|
256
|
-
}, "setter");
|
|
257
|
-
Object.defineProperty(target, propertyKey, {
|
|
258
|
-
get: getter,
|
|
259
|
-
set: setter,
|
|
260
|
-
enumerable: true,
|
|
261
|
-
configurable: true
|
|
262
|
-
});
|
|
263
|
-
};
|
|
264
|
-
}
|
|
265
|
-
__name(sync, "sync");
|
|
266
|
-
function id() {
|
|
267
|
-
return function(target, propertyKey) {
|
|
268
|
-
if (!target.constructor._propertyMetadata) {
|
|
269
|
-
target.constructor._propertyMetadata = /* @__PURE__ */ new Map();
|
|
270
|
-
}
|
|
271
|
-
target.constructor._propertyMetadata.set("id", propertyKey);
|
|
272
|
-
};
|
|
273
|
-
}
|
|
274
|
-
__name(id, "id");
|
|
275
|
-
function users(options) {
|
|
276
|
-
return function(target, propertyKey) {
|
|
277
|
-
if (!target.constructor._propertyMetadata) {
|
|
278
|
-
target.constructor._propertyMetadata = /* @__PURE__ */ new Map();
|
|
279
|
-
}
|
|
280
|
-
target.constructor._propertyMetadata.set("users", propertyKey);
|
|
281
|
-
sync(options)(target, propertyKey);
|
|
282
|
-
};
|
|
283
|
-
}
|
|
284
|
-
__name(users, "users");
|
|
285
|
-
function persist() {
|
|
286
|
-
return sync({
|
|
287
|
-
persist: true,
|
|
288
|
-
syncToClient: false
|
|
289
|
-
});
|
|
290
|
-
}
|
|
291
|
-
__name(persist, "persist");
|
|
292
|
-
function connected() {
|
|
293
|
-
return function(target, propertyKey) {
|
|
294
|
-
if (!target.constructor._propertyMetadata) {
|
|
295
|
-
target.constructor._propertyMetadata = /* @__PURE__ */ new Map();
|
|
296
|
-
}
|
|
297
|
-
target.constructor._propertyMetadata.set("connected", propertyKey);
|
|
298
|
-
sync({
|
|
299
|
-
persist: false
|
|
300
|
-
})(target, propertyKey);
|
|
301
|
-
};
|
|
302
|
-
}
|
|
303
|
-
__name(connected, "connected");
|
|
304
|
-
function load(rootInstance, values, valueIsObject) {
|
|
305
|
-
if (valueIsObject) {
|
|
306
|
-
loadFromObject(rootInstance, values);
|
|
307
|
-
} else {
|
|
308
|
-
loadFromPaths(rootInstance, values);
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
__name(load, "load");
|
|
312
|
-
function loadFromPaths(rootInstance, values) {
|
|
313
|
-
for (const [path, value] of Object.entries(values)) {
|
|
314
|
-
const parts = path.split(".");
|
|
315
|
-
loadValue(rootInstance, parts, value);
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
__name(loadFromPaths, "loadFromPaths");
|
|
319
|
-
function loadFromObject(rootInstance, values, currentPath = "") {
|
|
320
|
-
for (let key in values) {
|
|
321
|
-
const value = values[key];
|
|
322
|
-
const newPath = currentPath ? `${currentPath}.${key}` : key;
|
|
323
|
-
if (typeof value === "object" && !Array.isArray(value) && value !== null) {
|
|
324
|
-
loadFromObject(rootInstance, value, newPath);
|
|
325
|
-
} else {
|
|
326
|
-
const parts = newPath.split(".");
|
|
327
|
-
loadValue(rootInstance, parts, value);
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
__name(loadFromObject, "loadFromObject");
|
|
332
|
-
function loadValue(rootInstance, parts, value) {
|
|
333
|
-
let current = rootInstance;
|
|
334
|
-
for (let i = 0; i < parts.length; i++) {
|
|
335
|
-
const part = parts[i];
|
|
336
|
-
if (i === parts.length - 1) {
|
|
337
|
-
if (value == DELETE_TOKEN) {
|
|
338
|
-
if (isSignal(current)) {
|
|
339
|
-
current = current();
|
|
340
|
-
}
|
|
341
|
-
Reflect.deleteProperty(current, part);
|
|
342
|
-
} else if (current[part]?._subject) {
|
|
343
|
-
current[part].set(value);
|
|
344
|
-
} else if (isSignal(current) && Array.isArray(current()) && !isNaN(Number(part))) {
|
|
345
|
-
current()[Number(part)] = value;
|
|
346
|
-
} else {
|
|
347
|
-
current[part] = value;
|
|
348
|
-
}
|
|
349
|
-
} else {
|
|
350
|
-
if (isSignal(current)) {
|
|
351
|
-
current = current();
|
|
352
|
-
}
|
|
353
|
-
const currentValue = current[part];
|
|
354
|
-
if (currentValue === void 0) {
|
|
355
|
-
const parentInstance = getByPath(rootInstance, parts.slice(0, i).join("."));
|
|
356
|
-
const classType = parentInstance?.options?.classType;
|
|
357
|
-
if (classType) {
|
|
358
|
-
current[part] = !isClass(classType) ? classType(part) : new classType();
|
|
359
|
-
setMetadata(current[part], "id", part);
|
|
360
|
-
} else {
|
|
361
|
-
current[part] = {};
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
current = current[part];
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
}
|
|
368
|
-
__name(loadValue, "loadValue");
|
|
369
|
-
function getByPath(root, path) {
|
|
370
|
-
const parts = path.split(".");
|
|
371
|
-
let current = root;
|
|
372
|
-
for (const part of parts) {
|
|
373
|
-
if (isSignal(current)) {
|
|
374
|
-
current = current();
|
|
375
|
-
}
|
|
376
|
-
if (current[part]) {
|
|
377
|
-
current = current[part];
|
|
378
|
-
} else {
|
|
379
|
-
return void 0;
|
|
380
|
-
}
|
|
1
|
+
const WebSocketToken = "websocket";
|
|
2
|
+
class AbstractWebsocket {
|
|
3
|
+
constructor(context) {
|
|
4
|
+
this.context = context;
|
|
381
5
|
}
|
|
382
|
-
return current;
|
|
383
6
|
}
|
|
384
|
-
__name(getByPath, "getByPath");
|
|
385
7
|
|
|
386
|
-
export {
|
|
8
|
+
export { AbstractWebsocket, WebSocketToken };
|
|
387
9
|
//# sourceMappingURL=index18.js.map
|