@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,366 +1,277 @@
|
|
|
1
|
+
//#region ../../node_modules/.pnpm/@signe+di@2.8.3/node_modules/@signe/di/dist/index.js
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", {
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
var __name = (target, value) => __defProp(target, "name", {
|
|
4
|
+
value,
|
|
5
|
+
configurable: true
|
|
6
|
+
});
|
|
5
7
|
var DEFAULT_INSTANCE_KEY = "__default__";
|
|
6
8
|
function toTokenName(token) {
|
|
7
|
-
|
|
9
|
+
return typeof token === "function" ? token.name : token;
|
|
8
10
|
}
|
|
9
11
|
__name(toTokenName, "toTokenName");
|
|
10
12
|
function toInstanceKey(name) {
|
|
11
|
-
|
|
13
|
+
return name ?? DEFAULT_INSTANCE_KEY;
|
|
12
14
|
}
|
|
13
15
|
__name(toInstanceKey, "toInstanceKey");
|
|
14
16
|
function getRecord(context, token) {
|
|
15
|
-
|
|
17
|
+
return context.get("inject:" + toTokenName(token));
|
|
16
18
|
}
|
|
17
19
|
__name(getRecord, "getRecord");
|
|
18
20
|
function ensureRecord(context, token) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
context.set(key, record);
|
|
29
|
-
return record;
|
|
21
|
+
const key = "inject:" + toTokenName(token);
|
|
22
|
+
let record = context.get(key);
|
|
23
|
+
if (!record) record = {
|
|
24
|
+
multi: false,
|
|
25
|
+
values: /* @__PURE__ */ new Map(),
|
|
26
|
+
injected: /* @__PURE__ */ new Set()
|
|
27
|
+
};
|
|
28
|
+
context.set(key, record);
|
|
29
|
+
return record;
|
|
30
30
|
}
|
|
31
31
|
__name(ensureRecord, "ensureRecord");
|
|
32
32
|
function provide(context, token, value, options = {}) {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
record.multi = true;
|
|
40
|
-
}
|
|
41
|
-
record.values.set(instanceKey, value);
|
|
42
|
-
return value;
|
|
33
|
+
const record = ensureRecord(context, token);
|
|
34
|
+
const instanceKey = toInstanceKey(options.name);
|
|
35
|
+
if (options.multi) record.multi = true;
|
|
36
|
+
if (!record.multi && instanceKey !== DEFAULT_INSTANCE_KEY) record.multi = true;
|
|
37
|
+
record.values.set(instanceKey, value);
|
|
38
|
+
return value;
|
|
43
39
|
}
|
|
44
40
|
__name(provide, "provide");
|
|
45
41
|
function isInjected(context, token, options = {}) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
return record.injected.has(toInstanceKey(options.name));
|
|
52
|
-
}
|
|
53
|
-
if (record.multi) {
|
|
54
|
-
return record.injected.size > 0;
|
|
55
|
-
}
|
|
56
|
-
return record.injected.has(DEFAULT_INSTANCE_KEY);
|
|
42
|
+
const record = getRecord(context, token);
|
|
43
|
+
if (!record) return false;
|
|
44
|
+
if (options.name) return record.injected.has(toInstanceKey(options.name));
|
|
45
|
+
if (record.multi) return record.injected.size > 0;
|
|
46
|
+
return record.injected.has(DEFAULT_INSTANCE_KEY);
|
|
57
47
|
}
|
|
58
48
|
__name(isInjected, "isInjected");
|
|
59
49
|
function isProvided(context, token, options = {}) {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
return record.values.has(toInstanceKey(options.name));
|
|
66
|
-
}
|
|
67
|
-
if (record.multi) {
|
|
68
|
-
return record.values.size > 0;
|
|
69
|
-
}
|
|
70
|
-
return record.values.has(DEFAULT_INSTANCE_KEY);
|
|
50
|
+
const record = getRecord(context, token);
|
|
51
|
+
if (!record) return false;
|
|
52
|
+
if (options.name) return record.values.has(toInstanceKey(options.name));
|
|
53
|
+
if (record.multi) return record.values.size > 0;
|
|
54
|
+
return record.values.has(DEFAULT_INSTANCE_KEY);
|
|
71
55
|
}
|
|
72
56
|
__name(isProvided, "isProvided");
|
|
73
57
|
function hasInstance(context, token, options = {}) {
|
|
74
|
-
|
|
58
|
+
return isProvided(context, token, options);
|
|
75
59
|
}
|
|
76
60
|
__name(hasInstance, "hasInstance");
|
|
77
61
|
function handleMissingInjection(token, options) {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
82
|
-
throw new Error(`Injection provider ${name} not found`);
|
|
62
|
+
const name = toTokenName(token);
|
|
63
|
+
if (options.name) throw new Error(`Injection provider ${name} with name ${options.name} not found`);
|
|
64
|
+
throw new Error(`Injection provider ${name} not found`);
|
|
83
65
|
}
|
|
84
66
|
__name(handleMissingInjection, "handleMissingInjection");
|
|
85
67
|
function markInjected(record, key) {
|
|
86
|
-
|
|
68
|
+
record.injected.add(key);
|
|
87
69
|
}
|
|
88
70
|
__name(markInjected, "markInjected");
|
|
89
71
|
function markAllInjected(record) {
|
|
90
|
-
|
|
91
|
-
record.injected.add(key);
|
|
92
|
-
}
|
|
72
|
+
for (const key of record.values.keys()) record.injected.add(key);
|
|
93
73
|
}
|
|
94
74
|
__name(markAllInjected, "markAllInjected");
|
|
95
75
|
function inject(context, token, options = {}) {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
if (value === void 0) {
|
|
127
|
-
if (options.optional) {
|
|
128
|
-
return void 0;
|
|
129
|
-
}
|
|
130
|
-
return handleMissingInjection(token, options);
|
|
131
|
-
}
|
|
132
|
-
markInjected(record, DEFAULT_INSTANCE_KEY);
|
|
133
|
-
return value;
|
|
76
|
+
const record = getRecord(context, token);
|
|
77
|
+
if (!record) {
|
|
78
|
+
if (options.optional) return options.multi ? [] : void 0;
|
|
79
|
+
return handleMissingInjection(token, options);
|
|
80
|
+
}
|
|
81
|
+
if (options.name) {
|
|
82
|
+
const instanceKey = toInstanceKey(options.name);
|
|
83
|
+
if (!record.values.has(instanceKey)) {
|
|
84
|
+
if (options.optional) return;
|
|
85
|
+
return handleMissingInjection(token, options);
|
|
86
|
+
}
|
|
87
|
+
const value2 = record.values.get(instanceKey);
|
|
88
|
+
markInjected(record, instanceKey);
|
|
89
|
+
return value2;
|
|
90
|
+
}
|
|
91
|
+
if (options.multi || record.multi) {
|
|
92
|
+
if (record.values.size === 0) {
|
|
93
|
+
if (options.optional) return [];
|
|
94
|
+
return handleMissingInjection(token, options);
|
|
95
|
+
}
|
|
96
|
+
markAllInjected(record);
|
|
97
|
+
return Array.from(record.values.values());
|
|
98
|
+
}
|
|
99
|
+
const value = record.values.get(DEFAULT_INSTANCE_KEY);
|
|
100
|
+
if (value === void 0) {
|
|
101
|
+
if (options.optional) return;
|
|
102
|
+
return handleMissingInjection(token, options);
|
|
103
|
+
}
|
|
104
|
+
markInjected(record, DEFAULT_INSTANCE_KEY);
|
|
105
|
+
return value;
|
|
134
106
|
}
|
|
135
107
|
__name(inject, "inject");
|
|
136
108
|
function override(providers, newProvider, options) {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
return newProvider;
|
|
153
|
-
} else if (typeof provider === "object" && provider.provide === key) {
|
|
154
|
-
return newProvider;
|
|
155
|
-
}
|
|
156
|
-
return provider;
|
|
157
|
-
});
|
|
158
|
-
if (upsert && !exists) {
|
|
159
|
-
mappedProviders.push(newProvider);
|
|
160
|
-
}
|
|
161
|
-
return mappedProviders;
|
|
109
|
+
let { upsert = false, key } = options ?? {};
|
|
110
|
+
if (!key) key = typeof newProvider === "function" ? newProvider.name : newProvider.provide;
|
|
111
|
+
const flatProviders = providers.flat();
|
|
112
|
+
const exists = flatProviders.some((provider) => {
|
|
113
|
+
if (typeof provider === "function") return provider.name === key;
|
|
114
|
+
else if (typeof provider === "object") return provider.provide === key;
|
|
115
|
+
return false;
|
|
116
|
+
});
|
|
117
|
+
const mappedProviders = flatProviders.map((provider) => {
|
|
118
|
+
if (typeof provider === "function" && provider.name === key) return newProvider;
|
|
119
|
+
else if (typeof provider === "object" && provider.provide === key) return newProvider;
|
|
120
|
+
return provider;
|
|
121
|
+
});
|
|
122
|
+
if (upsert && !exists) mappedProviders.push(newProvider);
|
|
123
|
+
return mappedProviders;
|
|
162
124
|
}
|
|
163
125
|
__name(override, "override");
|
|
164
126
|
function findProviders(providers, name) {
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
} else if (findProvider(provider, name)) {
|
|
170
|
-
results.push(provider);
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
return results;
|
|
127
|
+
const results = [];
|
|
128
|
+
for (const provider of providers) if (Array.isArray(provider)) results.push(...findProviders(provider, name));
|
|
129
|
+
else if (findProvider(provider, name)) results.push(provider);
|
|
130
|
+
return results;
|
|
174
131
|
}
|
|
175
132
|
__name(findProviders, "findProviders");
|
|
176
133
|
function findProvider(providers, name) {
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
return null;
|
|
134
|
+
if (!Array.isArray(providers)) {
|
|
135
|
+
if (typeof providers === "object" && "provide" in providers) {
|
|
136
|
+
const provider = providers;
|
|
137
|
+
const providerName = typeof provider.provide === "function" ? provider.provide.name : provider.provide;
|
|
138
|
+
if (name instanceof RegExp) {
|
|
139
|
+
if (name.test(providerName)) return providers;
|
|
140
|
+
} else if (providerName === name) return providers;
|
|
141
|
+
}
|
|
142
|
+
return null;
|
|
143
|
+
}
|
|
144
|
+
for (const provider of providers) {
|
|
145
|
+
if (Array.isArray(provider)) {
|
|
146
|
+
const found = findProvider(provider, name);
|
|
147
|
+
if (found) return found;
|
|
148
|
+
continue;
|
|
149
|
+
}
|
|
150
|
+
if (typeof provider === "object" && "provide" in provider) {
|
|
151
|
+
const providerName = typeof provider.provide === "function" ? provider.provide.name : provider.provide;
|
|
152
|
+
if (name instanceof RegExp) {
|
|
153
|
+
if (name.test(providerName)) return provider;
|
|
154
|
+
} else if (providerName === name) return provider;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
return null;
|
|
205
158
|
}
|
|
206
159
|
__name(findProvider, "findProvider");
|
|
207
|
-
|
|
208
|
-
// src/merge-config.ts
|
|
209
160
|
function processProvider(mergedConfig, baseConfig, provider) {
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
const existingProvider = findProvider(baseConfig.providers, provider.provide);
|
|
217
|
-
if (existingProvider) {
|
|
218
|
-
mergedConfig.providers = override(mergedConfig.providers, provider);
|
|
219
|
-
} else {
|
|
220
|
-
mergedConfig.providers.push(provider);
|
|
221
|
-
}
|
|
161
|
+
if (Array.isArray(provider)) {
|
|
162
|
+
for (const nestedProvider of provider) processProvider(mergedConfig, baseConfig, nestedProvider);
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
if (findProvider(baseConfig.providers, provider.provide)) mergedConfig.providers = override(mergedConfig.providers, provider);
|
|
166
|
+
else mergedConfig.providers.push(provider);
|
|
222
167
|
}
|
|
223
168
|
__name(processProvider, "processProvider");
|
|
224
169
|
function mergeConfig(baseConfig, config) {
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
};
|
|
233
|
-
for (const provider of config.providers) {
|
|
234
|
-
processProvider(mergedConfig, baseConfig, provider);
|
|
235
|
-
}
|
|
236
|
-
return mergedConfig;
|
|
170
|
+
const mergedConfig = {
|
|
171
|
+
...baseConfig,
|
|
172
|
+
...config,
|
|
173
|
+
providers: [...baseConfig.providers]
|
|
174
|
+
};
|
|
175
|
+
for (const provider of config.providers) processProvider(mergedConfig, baseConfig, provider);
|
|
176
|
+
return mergedConfig;
|
|
237
177
|
}
|
|
238
178
|
__name(mergeConfig, "mergeConfig");
|
|
239
|
-
|
|
240
|
-
// src/provider.ts
|
|
241
179
|
function extractProvideOptions(source) {
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
return {
|
|
250
|
-
multi,
|
|
251
|
-
name
|
|
252
|
-
};
|
|
180
|
+
if (!source) return;
|
|
181
|
+
const { multi, name } = source;
|
|
182
|
+
if (multi === void 0 && name === void 0) return;
|
|
183
|
+
return {
|
|
184
|
+
multi,
|
|
185
|
+
name
|
|
186
|
+
};
|
|
253
187
|
}
|
|
254
188
|
__name(extractProvideOptions, "extractProvideOptions");
|
|
255
189
|
function getDeps(provider) {
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
}
|
|
259
|
-
return provider.deps ?? [];
|
|
190
|
+
if (typeof provider === "function") return provider.deps ?? [];
|
|
191
|
+
return provider.deps ?? [];
|
|
260
192
|
}
|
|
261
193
|
__name(getDeps, "getDeps");
|
|
262
194
|
function sortProviders(providers) {
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
}
|
|
292
|
-
result.push(provider);
|
|
293
|
-
}
|
|
294
|
-
visited.add(name);
|
|
295
|
-
}
|
|
296
|
-
stack.delete(name);
|
|
297
|
-
}, "visit");
|
|
298
|
-
for (const p of providers) {
|
|
299
|
-
const token = typeof p === "function" ? p : p.provide;
|
|
300
|
-
visit(token);
|
|
301
|
-
}
|
|
302
|
-
return result;
|
|
195
|
+
const tokenName = /* @__PURE__ */ __name((t) => typeof t === "function" ? t.name : t, "tokenName");
|
|
196
|
+
const map = /* @__PURE__ */ new Map();
|
|
197
|
+
for (const p of providers) {
|
|
198
|
+
const token = tokenName(typeof p === "function" ? p : p.provide);
|
|
199
|
+
const list = map.get(token);
|
|
200
|
+
if (list) list.push(p);
|
|
201
|
+
else map.set(token, [p]);
|
|
202
|
+
}
|
|
203
|
+
const result = [];
|
|
204
|
+
const visited = /* @__PURE__ */ new Set();
|
|
205
|
+
const stack = /* @__PURE__ */ new Set();
|
|
206
|
+
const visit = /* @__PURE__ */ __name((token) => {
|
|
207
|
+
const name = tokenName(token);
|
|
208
|
+
if (visited.has(name)) return;
|
|
209
|
+
if (stack.has(name)) throw new Error(`Circular dependency detected for provider ${name}`);
|
|
210
|
+
stack.add(name);
|
|
211
|
+
const providersForToken = map.get(name);
|
|
212
|
+
if (providersForToken) {
|
|
213
|
+
for (const provider of providersForToken) {
|
|
214
|
+
for (const dep of getDeps(provider)) visit(dep);
|
|
215
|
+
result.push(provider);
|
|
216
|
+
}
|
|
217
|
+
visited.add(name);
|
|
218
|
+
}
|
|
219
|
+
stack.delete(name);
|
|
220
|
+
}, "visit");
|
|
221
|
+
for (const p of providers) visit(typeof p === "function" ? p : p.provide);
|
|
222
|
+
return result;
|
|
303
223
|
}
|
|
304
224
|
__name(sortProviders, "sortProviders");
|
|
305
225
|
async function injector(context, providers) {
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
instance = await instance;
|
|
330
|
-
}
|
|
331
|
-
} else if ("useExisting" in provider) {
|
|
332
|
-
instance = inject(context, provider.useExisting);
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
provide(context, token, instance, options);
|
|
336
|
-
}
|
|
226
|
+
providers = providers.flat();
|
|
227
|
+
providers = sortProviders(providers);
|
|
228
|
+
for (const provider of providers) {
|
|
229
|
+
let token;
|
|
230
|
+
let instance;
|
|
231
|
+
let options;
|
|
232
|
+
if (typeof provider === "function") {
|
|
233
|
+
token = provider;
|
|
234
|
+
instance = new provider(context);
|
|
235
|
+
options = extractProvideOptions(provider.diOptions ?? provider.di);
|
|
236
|
+
} else {
|
|
237
|
+
token = provider.provide;
|
|
238
|
+
options = extractProvideOptions(provider);
|
|
239
|
+
const provideUserClass = provider.useClass;
|
|
240
|
+
if (typeof provideUserClass === "function") instance = new provideUserClass(context);
|
|
241
|
+
else if ("useValue" in provider) instance = provider.useValue;
|
|
242
|
+
else if ("useFactory" in provider) {
|
|
243
|
+
instance = provider.useFactory?.(context);
|
|
244
|
+
if (instance instanceof Promise) instance = await instance;
|
|
245
|
+
} else if ("useExisting" in provider) instance = inject(context, provider.useExisting);
|
|
246
|
+
}
|
|
247
|
+
provide(context, token, instance, options);
|
|
248
|
+
}
|
|
337
249
|
}
|
|
338
250
|
__name(injector, "injector");
|
|
339
|
-
|
|
340
|
-
// src/context.ts
|
|
341
251
|
var Context = class {
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
252
|
+
static {
|
|
253
|
+
__name(this, "Context");
|
|
254
|
+
}
|
|
255
|
+
/** Internal storage for injected values */
|
|
256
|
+
values = {};
|
|
257
|
+
/**
|
|
258
|
+
* Sets a value in the context
|
|
259
|
+
* @param key - Unique identifier for the value
|
|
260
|
+
* @param value - Value to store
|
|
261
|
+
*/
|
|
262
|
+
set(key, value) {
|
|
263
|
+
this.values[key] = value;
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Retrieves a value from the context
|
|
267
|
+
* @param key - Unique identifier for the value
|
|
268
|
+
* @returns The stored value or undefined if not found
|
|
269
|
+
*/
|
|
270
|
+
get(key) {
|
|
271
|
+
return this.values[key];
|
|
272
|
+
}
|
|
363
273
|
};
|
|
274
|
+
//#endregion
|
|
275
|
+
export { Context, inject, injector };
|
|
364
276
|
|
|
365
|
-
|
|
366
|
-
//# sourceMappingURL=index.js.map
|
|
277
|
+
//# sourceMappingURL=index.js.map
|