@dooboostore/simple-web-component 1.0.24 → 1.0.26
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/README.md +162 -33
- package/dist/cjs/decorators/addEventListener.js +1 -1
- package/dist/cjs/decorators/addEventListener.js.map +2 -2
- package/dist/cjs/decorators/applyAttribute.js +148 -0
- package/dist/cjs/decorators/applyAttribute.js.map +7 -0
- package/dist/cjs/decorators/applyClass.js +164 -0
- package/dist/cjs/decorators/applyClass.js.map +7 -0
- package/dist/cjs/decorators/applyNode.js +87 -194
- package/dist/cjs/decorators/applyNode.js.map +2 -2
- package/dist/cjs/decorators/{style.js → applyStyle.js} +50 -60
- package/dist/cjs/decorators/applyStyle.js.map +7 -0
- package/dist/cjs/decorators/attribute.js +10 -16
- package/dist/cjs/decorators/attribute.js.map +2 -2
- package/dist/cjs/decorators/changedAttributeHost.js +1 -1
- package/dist/cjs/decorators/changedAttributeHost.js.map +2 -2
- package/dist/cjs/decorators/elementDefine.js +14 -23
- package/dist/cjs/decorators/elementDefine.js.map +2 -2
- package/dist/cjs/decorators/emitCustomEvent.js +5 -2
- package/dist/cjs/decorators/emitCustomEvent.js.map +2 -2
- package/dist/cjs/decorators/index.js +3 -3
- package/dist/cjs/decorators/index.js.map +2 -2
- package/dist/cjs/decorators/lifecycles.js +9 -9
- package/dist/cjs/decorators/lifecycles.js.map +2 -2
- package/dist/cjs/decorators/query.js +1 -1
- package/dist/cjs/decorators/query.js.map +2 -2
- package/dist/cjs/decorators/queryAll.js +1 -1
- package/dist/cjs/decorators/queryAll.js.map +2 -2
- package/dist/cjs/elements/SwcAppEngine.js +19 -4
- package/dist/cjs/elements/SwcAppEngine.js.map +2 -2
- package/dist/cjs/elements/SwcAppMixin.js +2 -0
- package/dist/cjs/elements/SwcAppMixin.js.map +2 -2
- package/dist/cjs/utils/Utils.js +1 -1
- package/dist/cjs/utils/Utils.js.map +2 -2
- package/dist/esm/decorators/addEventListener.js +1 -1
- package/dist/esm/decorators/addEventListener.js.map +2 -2
- package/dist/esm/decorators/applyAttribute.js +129 -0
- package/dist/esm/decorators/applyAttribute.js.map +7 -0
- package/dist/esm/decorators/applyClass.js +145 -0
- package/dist/esm/decorators/applyClass.js.map +7 -0
- package/dist/esm/decorators/applyNode.js +87 -194
- package/dist/esm/decorators/applyNode.js.map +2 -2
- package/dist/esm/decorators/{style.js → applyStyle.js} +47 -57
- package/dist/esm/decorators/applyStyle.js.map +7 -0
- package/dist/esm/decorators/attribute.js +10 -16
- package/dist/esm/decorators/attribute.js.map +2 -2
- package/dist/esm/decorators/changedAttributeHost.js +1 -1
- package/dist/esm/decorators/changedAttributeHost.js.map +2 -2
- package/dist/esm/decorators/elementDefine.js +14 -23
- package/dist/esm/decorators/elementDefine.js.map +2 -2
- package/dist/esm/decorators/emitCustomEvent.js +5 -2
- package/dist/esm/decorators/emitCustomEvent.js.map +2 -2
- package/dist/esm/decorators/index.js +3 -3
- package/dist/esm/decorators/index.js.map +1 -1
- package/dist/esm/decorators/lifecycles.js +9 -9
- package/dist/esm/decorators/lifecycles.js.map +2 -2
- package/dist/esm/decorators/query.js +1 -1
- package/dist/esm/decorators/query.js.map +2 -2
- package/dist/esm/decorators/queryAll.js +1 -1
- package/dist/esm/decorators/queryAll.js.map +2 -2
- package/dist/esm/elements/SwcAppEngine.js +19 -4
- package/dist/esm/elements/SwcAppEngine.js.map +2 -2
- package/dist/esm/elements/SwcAppMixin.js +2 -0
- package/dist/esm/elements/SwcAppMixin.js.map +2 -2
- package/dist/esm/utils/Utils.js +1 -1
- package/dist/esm/utils/Utils.js.map +2 -2
- package/dist/esm-bundle/dooboostore-simple-web-component.esm.js +2853 -574
- package/dist/esm-bundle/dooboostore-simple-web-component.esm.js.map +4 -4
- package/dist/types/decorators/addEventListener.d.ts.map +1 -1
- package/dist/types/decorators/applyAttribute.d.ts +22 -0
- package/dist/types/decorators/applyAttribute.d.ts.map +1 -0
- package/dist/types/decorators/applyClass.d.ts +65 -0
- package/dist/types/decorators/applyClass.d.ts.map +1 -0
- package/dist/types/decorators/applyNode.d.ts +15 -123
- package/dist/types/decorators/applyNode.d.ts.map +1 -1
- package/dist/types/decorators/applyStyle.d.ts +21 -0
- package/dist/types/decorators/applyStyle.d.ts.map +1 -0
- package/dist/types/decorators/attribute.d.ts +10 -19
- package/dist/types/decorators/attribute.d.ts.map +1 -1
- package/dist/types/decorators/changedAttributeHost.d.ts.map +1 -1
- package/dist/types/decorators/elementDefine.d.ts.map +1 -1
- package/dist/types/decorators/emitCustomEvent.d.ts +1 -1
- package/dist/types/decorators/emitCustomEvent.d.ts.map +1 -1
- package/dist/types/decorators/index.d.ts +3 -3
- package/dist/types/decorators/index.d.ts.map +1 -1
- package/dist/types/decorators/lifecycles.d.ts.map +1 -1
- package/dist/types/decorators/query.d.ts.map +1 -1
- package/dist/types/decorators/queryAll.d.ts.map +1 -1
- package/dist/types/elements/SwcAppEngine.d.ts +7 -0
- package/dist/types/elements/SwcAppEngine.d.ts.map +1 -1
- package/dist/types/elements/SwcAppMixin.d.ts +1 -1
- package/dist/types/elements/SwcAppMixin.d.ts.map +1 -1
- package/dist/types/utils/Utils.d.ts.map +1 -1
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js +2853 -574
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js.map +4 -4
- package/package.json +2 -2
- package/src/decorators/addEventListener.ts +1 -1
- package/src/decorators/applyAttribute.ts +147 -0
- package/src/decorators/applyClass.ts +158 -0
- package/src/decorators/applyNode.ts +112 -330
- package/src/decorators/applyStyle.ts +128 -0
- package/src/decorators/attribute.ts +21 -55
- package/src/decorators/changedAttributeHost.ts +1 -1
- package/src/decorators/elementDefine.ts +18 -39
- package/src/decorators/emitCustomEvent.ts +6 -3
- package/src/decorators/index.ts +3 -3
- package/src/decorators/lifecycles.ts +9 -11
- package/src/decorators/query.ts +1 -1
- package/src/decorators/queryAll.ts +1 -1
- package/src/elements/SwcAppEngine.ts +32 -4
- package/src/elements/SwcAppMixin.ts +2 -0
- package/src/utils/Utils.ts +2 -1
- package/dist/cjs/decorators/classList.js +0 -177
- package/dist/cjs/decorators/classList.js.map +0 -7
- package/dist/cjs/decorators/setAttribute.js +0 -111
- package/dist/cjs/decorators/setAttribute.js.map +0 -7
- package/dist/cjs/decorators/style.js.map +0 -7
- package/dist/esm/decorators/classList.js +0 -158
- package/dist/esm/decorators/classList.js.map +0 -7
- package/dist/esm/decorators/setAttribute.js +0 -92
- package/dist/esm/decorators/setAttribute.js.map +0 -7
- package/dist/esm/decorators/style.js.map +0 -7
- package/dist/types/decorators/classList.d.ts +0 -71
- package/dist/types/decorators/classList.d.ts.map +0 -1
- package/dist/types/decorators/setAttribute.d.ts +0 -23
- package/dist/types/decorators/setAttribute.d.ts.map +0 -1
- package/dist/types/decorators/style.d.ts +0 -58
- package/dist/types/decorators/style.d.ts.map +0 -1
- package/src/decorators/classList.ts +0 -234
- package/src/decorators/setAttribute.ts +0 -114
- package/src/decorators/style.ts +0 -185
|
@@ -297,8 +297,8 @@ var require_Reflect = __commonJS({
|
|
|
297
297
|
keys.push(key);
|
|
298
298
|
}
|
|
299
299
|
}
|
|
300
|
-
for (var
|
|
301
|
-
var key = parentKeys_1[
|
|
300
|
+
for (var _a4 = 0, parentKeys_1 = parentKeys; _a4 < parentKeys_1.length; _a4++) {
|
|
301
|
+
var key = parentKeys_1[_a4];
|
|
302
302
|
var hasKey = set.has(key);
|
|
303
303
|
if (!hasKey) {
|
|
304
304
|
set.add(key);
|
|
@@ -1110,10 +1110,10 @@ var require_Reflect = __commonJS({
|
|
|
1110
1110
|
});
|
|
1111
1111
|
|
|
1112
1112
|
// src/bundle-entry.ts
|
|
1113
|
-
var
|
|
1113
|
+
var import_reflect_metadata3 = __toESM(require_Reflect(), 1);
|
|
1114
1114
|
|
|
1115
1115
|
// src/index.ts
|
|
1116
|
-
var
|
|
1116
|
+
var import_reflect_metadata2 = __toESM(require_Reflect(), 1);
|
|
1117
1117
|
|
|
1118
1118
|
// ../core/dist/esm/valid/ValidUtils.js
|
|
1119
1119
|
var ValidUtils;
|
|
@@ -4789,6 +4789,107 @@ var Observable = class {
|
|
|
4789
4789
|
}
|
|
4790
4790
|
};
|
|
4791
4791
|
|
|
4792
|
+
// ../core/dist/esm/message/Subject.js
|
|
4793
|
+
var Subject = class extends Observable {
|
|
4794
|
+
constructor() {
|
|
4795
|
+
super((subscriber) => {
|
|
4796
|
+
return this._subscribeToSubject(subscriber);
|
|
4797
|
+
});
|
|
4798
|
+
this._observers = /* @__PURE__ */ new Set();
|
|
4799
|
+
this._isStopped = false;
|
|
4800
|
+
this._hasError = false;
|
|
4801
|
+
}
|
|
4802
|
+
_subscribeToSubject(subscriber) {
|
|
4803
|
+
const partialObserver = {
|
|
4804
|
+
next: subscriber.next.bind(subscriber),
|
|
4805
|
+
error: subscriber.error.bind(subscriber),
|
|
4806
|
+
complete: subscriber.complete.bind(subscriber)
|
|
4807
|
+
};
|
|
4808
|
+
if (this._isStopped) {
|
|
4809
|
+
if (this._hasError) {
|
|
4810
|
+
partialObserver.error?.(this._error);
|
|
4811
|
+
} else {
|
|
4812
|
+
partialObserver.complete?.();
|
|
4813
|
+
}
|
|
4814
|
+
return Subscription.EMPTY;
|
|
4815
|
+
}
|
|
4816
|
+
this._observers.add(partialObserver);
|
|
4817
|
+
return new Subscription(() => {
|
|
4818
|
+
this._observers.delete(partialObserver);
|
|
4819
|
+
});
|
|
4820
|
+
}
|
|
4821
|
+
next(data) {
|
|
4822
|
+
if (this._isStopped) {
|
|
4823
|
+
return;
|
|
4824
|
+
}
|
|
4825
|
+
this._observers.forEach((observer) => {
|
|
4826
|
+
observer.next?.(data);
|
|
4827
|
+
});
|
|
4828
|
+
}
|
|
4829
|
+
error(err) {
|
|
4830
|
+
if (this._isStopped) {
|
|
4831
|
+
return;
|
|
4832
|
+
}
|
|
4833
|
+
this._hasError = true;
|
|
4834
|
+
this._error = err;
|
|
4835
|
+
this._isStopped = true;
|
|
4836
|
+
this._observers.forEach((observer) => observer.error?.(err));
|
|
4837
|
+
this._observers.clear();
|
|
4838
|
+
}
|
|
4839
|
+
complete() {
|
|
4840
|
+
if (this._isStopped) {
|
|
4841
|
+
return;
|
|
4842
|
+
}
|
|
4843
|
+
this._isStopped = true;
|
|
4844
|
+
this._observers.forEach((observer) => observer.complete?.());
|
|
4845
|
+
this._observers.clear();
|
|
4846
|
+
}
|
|
4847
|
+
asObservable() {
|
|
4848
|
+
return new Observable((subscriber) => {
|
|
4849
|
+
return this._subscribeToSubject(subscriber);
|
|
4850
|
+
});
|
|
4851
|
+
}
|
|
4852
|
+
};
|
|
4853
|
+
|
|
4854
|
+
// ../core/dist/esm/message/ReplaySubject.js
|
|
4855
|
+
var ReplaySubject = class extends Subject {
|
|
4856
|
+
// Removed: private _error: E | undefined;
|
|
4857
|
+
// Removed: private _isStopped = false;
|
|
4858
|
+
constructor(bufferSize = Infinity) {
|
|
4859
|
+
super();
|
|
4860
|
+
this.bufferSize = bufferSize;
|
|
4861
|
+
this._buffer = [];
|
|
4862
|
+
}
|
|
4863
|
+
next(data) {
|
|
4864
|
+
if (this._isStopped) {
|
|
4865
|
+
return;
|
|
4866
|
+
}
|
|
4867
|
+
this._buffer.push(data);
|
|
4868
|
+
if (this._buffer.length > this.bufferSize) {
|
|
4869
|
+
this._buffer.shift();
|
|
4870
|
+
}
|
|
4871
|
+
super.next(data);
|
|
4872
|
+
}
|
|
4873
|
+
error(err) {
|
|
4874
|
+
super.error(err);
|
|
4875
|
+
}
|
|
4876
|
+
complete() {
|
|
4877
|
+
super.complete();
|
|
4878
|
+
}
|
|
4879
|
+
_subscribeToSubject(subscriber) {
|
|
4880
|
+
this._buffer.forEach((value) => subscriber.next(value));
|
|
4881
|
+
if (this._isStopped) {
|
|
4882
|
+
if (this._hasError) {
|
|
4883
|
+
subscriber.error(this._error);
|
|
4884
|
+
} else {
|
|
4885
|
+
subscriber.complete();
|
|
4886
|
+
}
|
|
4887
|
+
return Subscription.EMPTY;
|
|
4888
|
+
}
|
|
4889
|
+
return super._subscribeToSubject(subscriber);
|
|
4890
|
+
}
|
|
4891
|
+
};
|
|
4892
|
+
|
|
4792
4893
|
// ../core/dist/esm/message/AutoCloseSubscription.js
|
|
4793
4894
|
var AutoCloseSubscription = class extends Subscription {
|
|
4794
4895
|
constructor(userUnsubscribe) {
|
|
@@ -5123,6 +5224,284 @@ var Promises;
|
|
|
5123
5224
|
})(Result = Promises2.Result || (Promises2.Result = {}));
|
|
5124
5225
|
})(Promises || (Promises = {}));
|
|
5125
5226
|
|
|
5227
|
+
// ../core/dist/esm/fetch/Fetcher.js
|
|
5228
|
+
var Fetcher = class {
|
|
5229
|
+
createPipe(config) {
|
|
5230
|
+
return {};
|
|
5231
|
+
}
|
|
5232
|
+
fetch(config) {
|
|
5233
|
+
return new Promise((resolve, reject) => {
|
|
5234
|
+
const pipe = this.createPipe(config);
|
|
5235
|
+
Promise.resolve().then(() => {
|
|
5236
|
+
this.before(config, pipe);
|
|
5237
|
+
config?.before?.();
|
|
5238
|
+
}).then(() => {
|
|
5239
|
+
return this.execute(config);
|
|
5240
|
+
}).then((data) => {
|
|
5241
|
+
const hasError = config.config?.hasErrorChecker?.(data);
|
|
5242
|
+
if (hasError) {
|
|
5243
|
+
throw hasError;
|
|
5244
|
+
}
|
|
5245
|
+
pipe.responseData = data;
|
|
5246
|
+
this.afterSuccess(config, pipe);
|
|
5247
|
+
config?.afterSuccess?.();
|
|
5248
|
+
const gdata = config?.transform ? config.transform(data) : data;
|
|
5249
|
+
this.afterSuccessTransform(config, pipe);
|
|
5250
|
+
resolve(gdata);
|
|
5251
|
+
}).catch(async (e) => {
|
|
5252
|
+
this.error(config, pipe, e);
|
|
5253
|
+
config?.error?.();
|
|
5254
|
+
if (config?.errorTransform) {
|
|
5255
|
+
e = await config.errorTransform(e);
|
|
5256
|
+
}
|
|
5257
|
+
e = await this.errorTransform(e);
|
|
5258
|
+
reject(e);
|
|
5259
|
+
}).finally(() => {
|
|
5260
|
+
this.finally(config, pipe);
|
|
5261
|
+
config?.finally?.();
|
|
5262
|
+
});
|
|
5263
|
+
});
|
|
5264
|
+
}
|
|
5265
|
+
};
|
|
5266
|
+
|
|
5267
|
+
// ../core/dist/esm/fetch/HttpFetcher.js
|
|
5268
|
+
var HttpResponseError = class extends Error {
|
|
5269
|
+
};
|
|
5270
|
+
var HttpFetcher = class extends Fetcher {
|
|
5271
|
+
get(config) {
|
|
5272
|
+
config.config ?? (config.config = {});
|
|
5273
|
+
config.config.fetch = config.config?.fetch ?? {};
|
|
5274
|
+
config.config.fetch.method = "GET";
|
|
5275
|
+
return this.fetch(config);
|
|
5276
|
+
}
|
|
5277
|
+
post(config) {
|
|
5278
|
+
config.config ?? (config.config = {});
|
|
5279
|
+
config.config.fetch = config.config?.fetch ?? {};
|
|
5280
|
+
config.config.fetch.method = "POST";
|
|
5281
|
+
return this.fetch(config);
|
|
5282
|
+
}
|
|
5283
|
+
patch(config) {
|
|
5284
|
+
config.config ?? (config.config = {});
|
|
5285
|
+
config.config.fetch = config.config?.fetch ?? {};
|
|
5286
|
+
config.config.fetch.method = "PATCH";
|
|
5287
|
+
return this.fetch(config);
|
|
5288
|
+
}
|
|
5289
|
+
put(config) {
|
|
5290
|
+
config.config ?? (config.config = {});
|
|
5291
|
+
config.config.fetch = config.config?.fetch ?? {};
|
|
5292
|
+
config.config.fetch.method = "PUT";
|
|
5293
|
+
return this.fetch(config);
|
|
5294
|
+
}
|
|
5295
|
+
head(config) {
|
|
5296
|
+
config.config ?? (config.config = {});
|
|
5297
|
+
config.config.fetch = config.config?.fetch ?? {};
|
|
5298
|
+
config.config.fetch.method = "HEAD";
|
|
5299
|
+
return this.fetch(config);
|
|
5300
|
+
}
|
|
5301
|
+
delete(config) {
|
|
5302
|
+
config.config ?? (config.config = {});
|
|
5303
|
+
config.config.fetch = config.config?.fetch ?? {};
|
|
5304
|
+
config.config.fetch.method = "DELETE";
|
|
5305
|
+
return this.fetch(config);
|
|
5306
|
+
}
|
|
5307
|
+
async beforeProxyFetch(config) {
|
|
5308
|
+
return config;
|
|
5309
|
+
}
|
|
5310
|
+
async afterProxyFetch(config) {
|
|
5311
|
+
return config.response;
|
|
5312
|
+
}
|
|
5313
|
+
afterSuccess(config, pipe) {
|
|
5314
|
+
}
|
|
5315
|
+
afterSuccessTransform(config, pipe) {
|
|
5316
|
+
}
|
|
5317
|
+
before(config, pipe) {
|
|
5318
|
+
}
|
|
5319
|
+
error(config, pipe, e) {
|
|
5320
|
+
}
|
|
5321
|
+
finally(config, pipe) {
|
|
5322
|
+
}
|
|
5323
|
+
beforeFetch(fetch2) {
|
|
5324
|
+
}
|
|
5325
|
+
afterFetch(fetch2, response) {
|
|
5326
|
+
}
|
|
5327
|
+
// protected async errorTransform(e: any): Promise<HttpResponseError<any>> {
|
|
5328
|
+
async errorTransform(e) {
|
|
5329
|
+
const httpResponseError = new HttpResponseError();
|
|
5330
|
+
httpResponseError.error = e;
|
|
5331
|
+
if (e instanceof Response) {
|
|
5332
|
+
httpResponseError.response = e;
|
|
5333
|
+
try {
|
|
5334
|
+
httpResponseError.body = await e.clone().text();
|
|
5335
|
+
httpResponseError.message = e.statusText;
|
|
5336
|
+
} catch (e2) {
|
|
5337
|
+
httpResponseError.body = e2;
|
|
5338
|
+
httpResponseError.message = e2.message;
|
|
5339
|
+
}
|
|
5340
|
+
} else {
|
|
5341
|
+
httpResponseError.body = e;
|
|
5342
|
+
httpResponseError.message = e.message;
|
|
5343
|
+
}
|
|
5344
|
+
return httpResponseError;
|
|
5345
|
+
}
|
|
5346
|
+
async execute(fetcherRequest) {
|
|
5347
|
+
let target = fetcherRequest.target;
|
|
5348
|
+
let config = fetcherRequest.config;
|
|
5349
|
+
if (!(target instanceof URL) && typeof target !== "string") {
|
|
5350
|
+
const searchParams = ConvertUtils.toURLSearchParams(target.searchParams ?? {});
|
|
5351
|
+
try {
|
|
5352
|
+
const url = typeof target.url === "string" ? new URL(target.url) : target.url;
|
|
5353
|
+
searchParams.forEach((value, key) => {
|
|
5354
|
+
url.searchParams.append(key, value);
|
|
5355
|
+
});
|
|
5356
|
+
target = url;
|
|
5357
|
+
} catch (e) {
|
|
5358
|
+
if (typeof target.url === "string") {
|
|
5359
|
+
const searchParamString = searchParams.toString();
|
|
5360
|
+
target = target.url + (searchParamString ? "?" + searchParamString : "");
|
|
5361
|
+
} else {
|
|
5362
|
+
target = "";
|
|
5363
|
+
}
|
|
5364
|
+
}
|
|
5365
|
+
}
|
|
5366
|
+
const beforeProxyData = { requestInfo: target, init: config?.fetch };
|
|
5367
|
+
let beforeData = config?.beforeProxyFetch ? await config?.beforeProxyFetch(config) : beforeProxyData.requestInfo;
|
|
5368
|
+
beforeData = config?.skipGlobalBeforeProxyFetch ? beforeProxyData : await this.beforeProxyFetch(beforeProxyData);
|
|
5369
|
+
target = beforeData.requestInfo;
|
|
5370
|
+
if (beforeData.init) {
|
|
5371
|
+
config ?? (config = {});
|
|
5372
|
+
config.fetch = beforeData.init;
|
|
5373
|
+
}
|
|
5374
|
+
let abortedTimeout;
|
|
5375
|
+
if (config?.fetch && "timeout" in config.fetch) {
|
|
5376
|
+
const abortController = new AbortController();
|
|
5377
|
+
abortedTimeout = setTimeout(() => {
|
|
5378
|
+
if (config?.fetch?.signal) {
|
|
5379
|
+
const inputSignal = config.fetch.signal;
|
|
5380
|
+
const listener = () => {
|
|
5381
|
+
if (!abortController.signal.aborted) {
|
|
5382
|
+
abortController.abort();
|
|
5383
|
+
}
|
|
5384
|
+
inputSignal.removeEventListener("abort", listener);
|
|
5385
|
+
};
|
|
5386
|
+
inputSignal.addEventListener("abort", listener);
|
|
5387
|
+
}
|
|
5388
|
+
if (!abortController.signal.aborted) {
|
|
5389
|
+
abortController.abort();
|
|
5390
|
+
}
|
|
5391
|
+
}, config.fetch.timeout);
|
|
5392
|
+
config.fetch.signal = abortController.signal;
|
|
5393
|
+
}
|
|
5394
|
+
this.beforeFetch({ target, requestInit: config?.fetch });
|
|
5395
|
+
return (config.fetcher ?? fetch)(target, config?.fetch).then(async (it) => {
|
|
5396
|
+
this.afterFetch({ target, requestInit: config?.fetch }, it);
|
|
5397
|
+
const afterProxyData = {
|
|
5398
|
+
fetch: { target, requestInit: config.fetch },
|
|
5399
|
+
config: beforeData,
|
|
5400
|
+
response: it
|
|
5401
|
+
};
|
|
5402
|
+
it = config?.afterProxyFetch ? await config.afterProxyFetch(afterProxyData) : it;
|
|
5403
|
+
it = config?.skipGlobalAfterProxyFetch ? it : await this.afterProxyFetch(afterProxyData);
|
|
5404
|
+
config?.fetchResponseAfterCallBack?.(it, config);
|
|
5405
|
+
if (!config?.allowedResponseNotOk && !it.ok) {
|
|
5406
|
+
throw it;
|
|
5407
|
+
}
|
|
5408
|
+
const data = config?.hasResponseErrorChecker?.(it, config);
|
|
5409
|
+
if (data) {
|
|
5410
|
+
throw data;
|
|
5411
|
+
}
|
|
5412
|
+
return it;
|
|
5413
|
+
}).finally(() => {
|
|
5414
|
+
if (abortedTimeout) {
|
|
5415
|
+
clearTimeout(abortedTimeout);
|
|
5416
|
+
}
|
|
5417
|
+
});
|
|
5418
|
+
}
|
|
5419
|
+
};
|
|
5420
|
+
|
|
5421
|
+
// ../core/dist/esm/fetch/HttpJsonFetcher.js
|
|
5422
|
+
var HttpJsonFetcher = class extends HttpFetcher {
|
|
5423
|
+
updateJsonFetchConfigAndData(config) {
|
|
5424
|
+
var _a4, _b2;
|
|
5425
|
+
const headers = {
|
|
5426
|
+
"Content-Type": "application/json",
|
|
5427
|
+
Accept: "application/json, text/plain, */*"
|
|
5428
|
+
};
|
|
5429
|
+
config.config ?? (config.config = {});
|
|
5430
|
+
(_a4 = config.config).fetch ?? (_a4.fetch = {});
|
|
5431
|
+
(_b2 = config.config.fetch).headers ?? (_b2.headers = {});
|
|
5432
|
+
config.config.fetch.headers = { ...headers, ...config.config.fetch?.headers };
|
|
5433
|
+
if (config.config?.fetch?.body && typeof config.config?.fetch?.body !== "string") {
|
|
5434
|
+
config.config.fetch.body = JSON.stringify(config.config.fetch.body);
|
|
5435
|
+
}
|
|
5436
|
+
return config;
|
|
5437
|
+
}
|
|
5438
|
+
get(config) {
|
|
5439
|
+
return super.get(config);
|
|
5440
|
+
}
|
|
5441
|
+
delete(config) {
|
|
5442
|
+
return super.delete(config);
|
|
5443
|
+
}
|
|
5444
|
+
post(config) {
|
|
5445
|
+
return super.post(config);
|
|
5446
|
+
}
|
|
5447
|
+
patch(config) {
|
|
5448
|
+
return super.patch(config);
|
|
5449
|
+
}
|
|
5450
|
+
put(config) {
|
|
5451
|
+
return super.put(config);
|
|
5452
|
+
}
|
|
5453
|
+
head(config) {
|
|
5454
|
+
return super.head(config);
|
|
5455
|
+
}
|
|
5456
|
+
postJson(config) {
|
|
5457
|
+
return super.post(this.updateJsonFetchConfigAndData(config));
|
|
5458
|
+
}
|
|
5459
|
+
patchJson(config) {
|
|
5460
|
+
return super.patch(this.updateJsonFetchConfigAndData(config));
|
|
5461
|
+
}
|
|
5462
|
+
putJson(config) {
|
|
5463
|
+
return super.put(this.updateJsonFetchConfigAndData(config));
|
|
5464
|
+
}
|
|
5465
|
+
async errorTransform(e) {
|
|
5466
|
+
const httpResponseError = new HttpResponseError();
|
|
5467
|
+
httpResponseError.error = e;
|
|
5468
|
+
if (e instanceof Response) {
|
|
5469
|
+
httpResponseError.response = e;
|
|
5470
|
+
try {
|
|
5471
|
+
httpResponseError.body = await e.clone().json();
|
|
5472
|
+
httpResponseError.message = e.statusText;
|
|
5473
|
+
} catch (parseError) {
|
|
5474
|
+
httpResponseError.body = parseError;
|
|
5475
|
+
httpResponseError.message = parseError.message;
|
|
5476
|
+
}
|
|
5477
|
+
} else {
|
|
5478
|
+
httpResponseError.body = e;
|
|
5479
|
+
httpResponseError.message = e.message;
|
|
5480
|
+
}
|
|
5481
|
+
return httpResponseError;
|
|
5482
|
+
}
|
|
5483
|
+
// protected execute(target: HttpFetcherTarget, config?: HttpJsonFetcherConfig<C, any>): Promise<any> {
|
|
5484
|
+
execute(fetcherRequest) {
|
|
5485
|
+
return super.execute(fetcherRequest).then((response) => {
|
|
5486
|
+
const config = fetcherRequest.config;
|
|
5487
|
+
const transform = config?.responseTransform ?? (config?.bypassTransform ? "response" : config?.transformText ? "text" : void 0);
|
|
5488
|
+
if (transform === "response") {
|
|
5489
|
+
return response;
|
|
5490
|
+
} else if (transform === "text") {
|
|
5491
|
+
return response?.text();
|
|
5492
|
+
} else if (typeof transform === "function") {
|
|
5493
|
+
return transform(response);
|
|
5494
|
+
} else {
|
|
5495
|
+
return response?.text().then((it) => {
|
|
5496
|
+
if ((it ?? "").length > 0) {
|
|
5497
|
+
return JSON.parse(it);
|
|
5498
|
+
}
|
|
5499
|
+
});
|
|
5500
|
+
}
|
|
5501
|
+
});
|
|
5502
|
+
}
|
|
5503
|
+
};
|
|
5504
|
+
|
|
5126
5505
|
// ../core/dist/esm/entity/object/obj/RenderDrawObj.js
|
|
5127
5506
|
var RenderDrawObj = class extends Obj {
|
|
5128
5507
|
render(draw, config) {
|
|
@@ -5716,7 +6095,7 @@ var Expression;
|
|
|
5716
6095
|
})(Expression || (Expression = {}));
|
|
5717
6096
|
|
|
5718
6097
|
// src/decorators/addEventListener.ts
|
|
5719
|
-
var ADD_EVENT_LISTENER_METADATA_KEY = Symbol("simple-web-component:add-event-listener");
|
|
6098
|
+
var ADD_EVENT_LISTENER_METADATA_KEY = Symbol.for("simple-web-component:add-event-listener");
|
|
5720
6099
|
function addEventListener(selectorOrTarget, type, options = {}) {
|
|
5721
6100
|
return (targetObj, propertyKey, descriptor) => {
|
|
5722
6101
|
const constructor = targetObj.constructor;
|
|
@@ -5737,15 +6116,15 @@ function addEventListenerHost(type, options) {
|
|
|
5737
6116
|
}
|
|
5738
6117
|
|
|
5739
6118
|
// src/decorators/lifecycles.ts
|
|
5740
|
-
var ON_CONSTRUCTOR_METADATA_KEY = Symbol("simple-web-component:on-constructor");
|
|
5741
|
-
var ON_BEFORE_CONNECTED_METADATA_KEY = Symbol("simple-web-component:on-before-connected");
|
|
5742
|
-
var ON_AFTER_CONNECTED_METADATA_KEY = Symbol("simple-web-component:on-after-connected");
|
|
5743
|
-
var ON_BEFORE_DISCONNECTED_METADATA_KEY = Symbol("simple-web-component:on-before-disconnected");
|
|
5744
|
-
var ON_AFTER_DISCONNECTED_METADATA_KEY = Symbol("simple-web-component:on-after-disconnected");
|
|
5745
|
-
var ON_BEFORE_ADOPTED_METADATA_KEY = Symbol("simple-web-component:on-before-adopted");
|
|
5746
|
-
var ON_AFTER_ADOPTED_METADATA_KEY = Symbol("simple-web-component:on-after-adopted");
|
|
5747
|
-
var ON_ADD_EVENT_LISTENER_METADATA_KEY = Symbol("simple-web-component:on-add-event-listener");
|
|
5748
|
-
var INNER_HTML_METADATA_KEY = Symbol("simple-web-component:inner-html");
|
|
6119
|
+
var ON_CONSTRUCTOR_METADATA_KEY = Symbol.for("simple-web-component:on-constructor");
|
|
6120
|
+
var ON_BEFORE_CONNECTED_METADATA_KEY = Symbol.for("simple-web-component:on-before-connected");
|
|
6121
|
+
var ON_AFTER_CONNECTED_METADATA_KEY = Symbol.for("simple-web-component:on-after-connected");
|
|
6122
|
+
var ON_BEFORE_DISCONNECTED_METADATA_KEY = Symbol.for("simple-web-component:on-before-disconnected");
|
|
6123
|
+
var ON_AFTER_DISCONNECTED_METADATA_KEY = Symbol.for("simple-web-component:on-after-disconnected");
|
|
6124
|
+
var ON_BEFORE_ADOPTED_METADATA_KEY = Symbol.for("simple-web-component:on-before-adopted");
|
|
6125
|
+
var ON_AFTER_ADOPTED_METADATA_KEY = Symbol.for("simple-web-component:on-after-adopted");
|
|
6126
|
+
var ON_ADD_EVENT_LISTENER_METADATA_KEY = Symbol.for("simple-web-component:on-add-event-listener");
|
|
6127
|
+
var INNER_HTML_METADATA_KEY = Symbol.for("simple-web-component:inner-html");
|
|
5749
6128
|
var ATTRIBUTE_CHANGED_WILDCARD = "*";
|
|
5750
6129
|
function createLifecycleDecorator(metadataKey) {
|
|
5751
6130
|
return (target, propertyKey) => {
|
|
@@ -5796,7 +6175,7 @@ var getOnConnectedInnerHtmlMetadata = (target) => {
|
|
|
5796
6175
|
};
|
|
5797
6176
|
|
|
5798
6177
|
// src/decorators/attribute.ts
|
|
5799
|
-
var
|
|
6178
|
+
var ATTRIBUTE_FIELD_METADATA_KEY = Symbol.for("simple-web-component:attribute-field");
|
|
5800
6179
|
var convertValue = (val, type) => {
|
|
5801
6180
|
if (val === null || val === void 0) return val;
|
|
5802
6181
|
if (type === Number) return Number(val);
|
|
@@ -5854,15 +6233,14 @@ function attribute(selector, options = {}) {
|
|
|
5854
6233
|
const constructor = target.constructor;
|
|
5855
6234
|
const privateKey = Symbol(String(propertyKey));
|
|
5856
6235
|
const designType = Reflect.getMetadata("design:type", target, propertyKey);
|
|
5857
|
-
let metaList = ReflectUtils.getOwnMetadata(
|
|
6236
|
+
let metaList = ReflectUtils.getOwnMetadata(ATTRIBUTE_FIELD_METADATA_KEY, constructor);
|
|
5858
6237
|
if (!metaList) {
|
|
5859
6238
|
metaList = [];
|
|
5860
|
-
ReflectUtils.defineMetadata(
|
|
6239
|
+
ReflectUtils.defineMetadata(ATTRIBUTE_FIELD_METADATA_KEY, metaList, constructor);
|
|
5861
6240
|
}
|
|
5862
6241
|
metaList.push({ propertyKey, selector, options, privateKey });
|
|
5863
6242
|
const applySetAttribute = (inst, targets, attrName, nv) => {
|
|
5864
6243
|
targets.forEach((it) => {
|
|
5865
|
-
console.log("----->", it);
|
|
5866
6244
|
if (it && typeof it.setAttribute === "function") {
|
|
5867
6245
|
if (nv === null) {
|
|
5868
6246
|
it.removeAttribute(attrName);
|
|
@@ -5880,7 +6258,6 @@ function attribute(selector, options = {}) {
|
|
|
5880
6258
|
const conf = getElementConfig(this);
|
|
5881
6259
|
const currentWin = this._resolveWindow?.(conf) || (typeof window !== "undefined" ? window : void 0);
|
|
5882
6260
|
const targetType = options.type || designType;
|
|
5883
|
-
console.log("type-->", propertyKey, targetType);
|
|
5884
6261
|
if (this.__swc_syncing_init || options.connectedInitialize && !this.__swc_connected) {
|
|
5885
6262
|
return convertValue(this[privateKey], targetType);
|
|
5886
6263
|
}
|
|
@@ -5896,7 +6273,6 @@ function attribute(selector, options = {}) {
|
|
|
5896
6273
|
return convertValue(this[privateKey], targetType);
|
|
5897
6274
|
},
|
|
5898
6275
|
set(nv) {
|
|
5899
|
-
const targetType = options.type || designType;
|
|
5900
6276
|
const attrName = options.name || String(propertyKey);
|
|
5901
6277
|
const conf = getElementConfig(this);
|
|
5902
6278
|
const currentWin = this._resolveWindow?.(conf) || (typeof window !== "undefined" ? window : void 0);
|
|
@@ -5921,13 +6297,9 @@ function attribute(selector, options = {}) {
|
|
|
5921
6297
|
});
|
|
5922
6298
|
};
|
|
5923
6299
|
}
|
|
5924
|
-
var findAllAttributeMetadata = (target) => {
|
|
5925
|
-
return ReflectUtils.findAllMetadata(ATTRIBUTE_METADATA_KEY, target).flat();
|
|
5926
|
-
};
|
|
5927
6300
|
function attributeHost(targetOrAttrOrOptions, propertyKeyOrOptions) {
|
|
5928
6301
|
if (propertyKeyOrOptions !== void 0 && (typeof propertyKeyOrOptions === "string" || typeof propertyKeyOrOptions === "symbol")) {
|
|
5929
|
-
|
|
5930
|
-
return attribute(":host", { name: fieldName })(targetOrAttrOrOptions, propertyKeyOrOptions);
|
|
6302
|
+
return attribute(":host", { name: String(propertyKeyOrOptions) })(targetOrAttrOrOptions, propertyKeyOrOptions);
|
|
5931
6303
|
}
|
|
5932
6304
|
if (typeof targetOrAttrOrOptions === "string") {
|
|
5933
6305
|
const attrName = targetOrAttrOrOptions;
|
|
@@ -5936,19 +6308,20 @@ function attributeHost(targetOrAttrOrOptions, propertyKeyOrOptions) {
|
|
|
5936
6308
|
} else if (typeof targetOrAttrOrOptions === "object") {
|
|
5937
6309
|
const options = targetOrAttrOrOptions;
|
|
5938
6310
|
return (target, propertyKey) => {
|
|
5939
|
-
|
|
5940
|
-
return attribute(":host", { ...options, name: fieldName })(target, propertyKey);
|
|
6311
|
+
return attribute(":host", { ...options, name: String(propertyKey) })(target, propertyKey);
|
|
5941
6312
|
};
|
|
5942
6313
|
} else {
|
|
5943
6314
|
return (target, propertyKey) => {
|
|
5944
|
-
|
|
5945
|
-
return attribute(":host", { name: fieldName })(target, propertyKey);
|
|
6315
|
+
return attribute(":host", { name: String(propertyKey) })(target, propertyKey);
|
|
5946
6316
|
};
|
|
5947
6317
|
}
|
|
5948
6318
|
}
|
|
6319
|
+
var findAllAttributeMetadata = (target) => {
|
|
6320
|
+
return ReflectUtils.findAllMetadata(ATTRIBUTE_FIELD_METADATA_KEY, target).flat();
|
|
6321
|
+
};
|
|
5949
6322
|
|
|
5950
6323
|
// src/decorators/changedAttributeHost.ts
|
|
5951
|
-
var ON_ATTRIBUTE_CHANGED_METADATA_KEY = Symbol("simple-web-component:on-attribute-changed");
|
|
6324
|
+
var ON_ATTRIBUTE_CHANGED_METADATA_KEY = Symbol.for("simple-web-component:on-attribute-changed");
|
|
5952
6325
|
function changedAttributeHost(attributeName) {
|
|
5953
6326
|
return (target, propertyKey) => {
|
|
5954
6327
|
const constructor = target.constructor;
|
|
@@ -5974,102 +6347,43 @@ var findAllAttributeChangedMetadata = (target) => {
|
|
|
5974
6347
|
return ReflectUtils.findAllMapMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, target);
|
|
5975
6348
|
};
|
|
5976
6349
|
|
|
5977
|
-
// src/decorators/setAttribute.ts
|
|
5978
|
-
var SET_ATTRIBUTE_METADATA_KEY = Symbol("simple-web-component:set-attribute");
|
|
5979
|
-
function setAttribute(selector, name, options = {}) {
|
|
5980
|
-
return (target, propertyKey, descriptor) => {
|
|
5981
|
-
const constructor = target.constructor;
|
|
5982
|
-
let metaList = ReflectUtils.getOwnMetadata(SET_ATTRIBUTE_METADATA_KEY, constructor);
|
|
5983
|
-
if (!metaList) {
|
|
5984
|
-
metaList = /* @__PURE__ */ new Map();
|
|
5985
|
-
ReflectUtils.defineMetadata(SET_ATTRIBUTE_METADATA_KEY, metaList, constructor);
|
|
5986
|
-
}
|
|
5987
|
-
metaList.set(propertyKey, { propertyKey, selector, name, options });
|
|
5988
|
-
const original = descriptor.value;
|
|
5989
|
-
descriptor.value = async function(...args) {
|
|
5990
|
-
ensureInit2(this);
|
|
5991
|
-
const res = await original.apply(this, args);
|
|
5992
|
-
if (res !== void 0) {
|
|
5993
|
-
const hostSet = SwcUtils.getHostSet(this);
|
|
5994
|
-
const conf = getElementConfig(this);
|
|
5995
|
-
const currentWin = this._resolveWindow?.(conf) || (typeof window !== "undefined" ? window : void 0);
|
|
5996
|
-
const targetEls = [];
|
|
5997
|
-
const r = options.root || "auto";
|
|
5998
|
-
const applyRoot = (t) => {
|
|
5999
|
-
if (!t) return;
|
|
6000
|
-
if (r === "auto") {
|
|
6001
|
-
targetEls.push(t);
|
|
6002
|
-
} else {
|
|
6003
|
-
if (r === "light" || r === "all") targetEls.push(t);
|
|
6004
|
-
if ((r === "shadow" || r === "all") && t.shadowRoot) targetEls.push(t.shadowRoot);
|
|
6005
|
-
}
|
|
6006
|
-
};
|
|
6007
|
-
if (selector === ":window") targetEls.push(currentWin);
|
|
6008
|
-
else if (selector === ":document") targetEls.push(currentWin.document);
|
|
6009
|
-
else if (selector === ":parentHost") applyRoot(hostSet.$parentHost);
|
|
6010
|
-
else if (selector === ":appHost") applyRoot(hostSet.$appHost);
|
|
6011
|
-
else if (selector === ":firstHost") applyRoot(hostSet.$firstHost);
|
|
6012
|
-
else if (selector === ":lastHost") applyRoot(hostSet.$lastHost);
|
|
6013
|
-
else if (selector === ":firstAppHost") applyRoot(hostSet.$firstAppHost);
|
|
6014
|
-
else if (selector === ":lastAppHost") applyRoot(hostSet.$lastAppHost);
|
|
6015
|
-
else if (selector === ":hosts") hostSet.$hosts.forEach(applyRoot);
|
|
6016
|
-
else if (selector === ":appHosts") hostSet.$appHosts.forEach(applyRoot);
|
|
6017
|
-
else if (selector === ":host" || !selector) applyRoot(this);
|
|
6018
|
-
else {
|
|
6019
|
-
const roots = [];
|
|
6020
|
-
if (r === "shadow") {
|
|
6021
|
-
if (this.shadowRoot) roots.push(this.shadowRoot);
|
|
6022
|
-
} else if (r === "light") {
|
|
6023
|
-
roots.push(this);
|
|
6024
|
-
} else if (r === "all") {
|
|
6025
|
-
roots.push(this);
|
|
6026
|
-
if (this.shadowRoot) roots.push(this.shadowRoot);
|
|
6027
|
-
} else {
|
|
6028
|
-
roots.push(this.shadowRoot || this);
|
|
6029
|
-
}
|
|
6030
|
-
roots.forEach((root) => targetEls.push(...root.querySelectorAll(selector)));
|
|
6031
|
-
}
|
|
6032
|
-
targetEls.forEach((targetEl) => {
|
|
6033
|
-
if (!targetEl || typeof targetEl.setAttribute !== "function") return;
|
|
6034
|
-
if (res === null) targetEl.removeAttribute(name);
|
|
6035
|
-
else targetEl.setAttribute(name, String(res));
|
|
6036
|
-
});
|
|
6037
|
-
}
|
|
6038
|
-
return res;
|
|
6039
|
-
};
|
|
6040
|
-
};
|
|
6041
|
-
}
|
|
6042
|
-
var getSetAttributeMetadata = (target) => {
|
|
6043
|
-
const constructor = target instanceof Function ? target : target.constructor;
|
|
6044
|
-
return ReflectUtils.getMetadata(SET_ATTRIBUTE_METADATA_KEY, constructor);
|
|
6045
|
-
};
|
|
6046
|
-
var findAllSetAttributeMetadata = (target) => {
|
|
6047
|
-
const result = /* @__PURE__ */ new Map();
|
|
6048
|
-
const maps = ReflectUtils.findAllMetadata(SET_ATTRIBUTE_METADATA_KEY, target);
|
|
6049
|
-
maps.forEach((map) => {
|
|
6050
|
-
if (map instanceof Map) {
|
|
6051
|
-
map.forEach((v, k) => result.set(k, v));
|
|
6052
|
-
}
|
|
6053
|
-
});
|
|
6054
|
-
return result;
|
|
6055
|
-
};
|
|
6056
|
-
function setAttributeHost(name, options) {
|
|
6057
|
-
return setAttribute(":host", name, options);
|
|
6058
|
-
}
|
|
6059
|
-
|
|
6060
6350
|
// src/decorators/applyNode.ts
|
|
6061
|
-
var APPLY_NODE_METADATA_KEY = Symbol("simple-web-component:apply-node");
|
|
6351
|
+
var APPLY_NODE_METADATA_KEY = Symbol.for("simple-web-component:apply-node");
|
|
6062
6352
|
var normalizeNodes = (res, doc) => {
|
|
6063
6353
|
const items = Array.isArray(res) ? res : [res];
|
|
6064
6354
|
return items.map((it) => {
|
|
6065
|
-
if (it instanceof Node)
|
|
6066
|
-
return it;
|
|
6355
|
+
if (it instanceof Node) return it;
|
|
6067
6356
|
return doc.createTextNode(it !== void 0 && it !== null ? String(it) : "");
|
|
6068
6357
|
});
|
|
6069
6358
|
};
|
|
6359
|
+
var applyToDom = (targetEl, res, pos, doc) => {
|
|
6360
|
+
if (!targetEl) return;
|
|
6361
|
+
if (pos === "innerHtml") {
|
|
6362
|
+
targetEl.innerHTML = res !== void 0 && res !== null ? String(res) : "";
|
|
6363
|
+
return;
|
|
6364
|
+
}
|
|
6365
|
+
if (pos === "innerText") {
|
|
6366
|
+
if (targetEl.innerText !== void 0) {
|
|
6367
|
+
targetEl.innerText = res !== void 0 && res !== null ? String(res) : "";
|
|
6368
|
+
}
|
|
6369
|
+
return;
|
|
6370
|
+
}
|
|
6371
|
+
const isShadowRoot = targetEl instanceof ShadowRoot;
|
|
6372
|
+
const nodes = normalizeNodes(res, doc);
|
|
6373
|
+
if (pos === "replace") {
|
|
6374
|
+
if (!isShadowRoot) targetEl.replaceWith(...nodes);
|
|
6375
|
+
} else if (pos === "replaceChildren") {
|
|
6376
|
+
targetEl.replaceChildren(...nodes);
|
|
6377
|
+
} else {
|
|
6378
|
+
if (pos === "beforeEnd") targetEl.append(...nodes);
|
|
6379
|
+
else if (pos === "afterBegin") targetEl.prepend(...nodes);
|
|
6380
|
+
else if (pos === "beforeBegin" && !isShadowRoot) targetEl.before(...nodes);
|
|
6381
|
+
else if (pos === "afterEnd" && !isShadowRoot) targetEl.after(...nodes);
|
|
6382
|
+
}
|
|
6383
|
+
};
|
|
6070
6384
|
function applyNode(selector, options = { position: "beforeEnd" }) {
|
|
6071
|
-
return (
|
|
6072
|
-
const constructor =
|
|
6385
|
+
return (targetObj, propertyKey, descriptor) => {
|
|
6386
|
+
const constructor = targetObj.constructor;
|
|
6073
6387
|
let metaList = ReflectUtils.getOwnMetadata(APPLY_NODE_METADATA_KEY, constructor);
|
|
6074
6388
|
if (!metaList) {
|
|
6075
6389
|
metaList = /* @__PURE__ */ new Map();
|
|
@@ -6077,94 +6391,58 @@ function applyNode(selector, options = { position: "beforeEnd" }) {
|
|
|
6077
6391
|
}
|
|
6078
6392
|
metaList.set(propertyKey, { propertyKey, selector, options });
|
|
6079
6393
|
const original = descriptor.value;
|
|
6080
|
-
descriptor.value =
|
|
6394
|
+
descriptor.value = function(...args) {
|
|
6081
6395
|
ensureInit2(this);
|
|
6082
|
-
const
|
|
6083
|
-
|
|
6084
|
-
|
|
6085
|
-
|
|
6086
|
-
|
|
6087
|
-
const pos = options.position || "beforeEnd";
|
|
6396
|
+
const conf = getElementConfig(this);
|
|
6397
|
+
const currentWin = this._resolveWindow?.(conf) || (typeof window !== "undefined" ? window : void 0);
|
|
6398
|
+
const currentDoc = currentWin.document;
|
|
6399
|
+
const hostSet = SwcUtils.getHelperAndHostSet(currentWin, this);
|
|
6400
|
+
const getTarget = () => {
|
|
6088
6401
|
const r = options.root || "auto";
|
|
6089
6402
|
const applyRoot = (t) => {
|
|
6090
|
-
if (!t
|
|
6091
|
-
|
|
6092
|
-
if (r === "
|
|
6093
|
-
|
|
6094
|
-
if (r === "
|
|
6095
|
-
return t.shadowRoot;
|
|
6096
|
-
if (r === "light")
|
|
6097
|
-
return t;
|
|
6098
|
-
if (r === "all")
|
|
6099
|
-
return t.shadowRoot || t;
|
|
6403
|
+
if (!t) return t;
|
|
6404
|
+
if (r === "auto") return t.shadowRoot || t;
|
|
6405
|
+
if (r === "shadow") return t.shadowRoot;
|
|
6406
|
+
if (r === "light") return t;
|
|
6407
|
+
if (r === "all") return t.shadowRoot || t;
|
|
6100
6408
|
return t;
|
|
6101
6409
|
};
|
|
6102
|
-
|
|
6103
|
-
if (
|
|
6104
|
-
|
|
6105
|
-
|
|
6106
|
-
|
|
6107
|
-
|
|
6108
|
-
|
|
6109
|
-
|
|
6110
|
-
|
|
6111
|
-
|
|
6112
|
-
|
|
6113
|
-
|
|
6114
|
-
|
|
6115
|
-
|
|
6116
|
-
|
|
6117
|
-
|
|
6118
|
-
|
|
6119
|
-
}
|
|
6120
|
-
|
|
6121
|
-
|
|
6122
|
-
|
|
6123
|
-
} else if (selector === ":parentHost") {
|
|
6124
|
-
targetEl = applyRoot(hostSet.$parentHost);
|
|
6125
|
-
} else if (selector === ":appHost") {
|
|
6126
|
-
targetEl = applyRoot(hostSet.$appHost);
|
|
6127
|
-
} else if (selector === ":firstHost") {
|
|
6128
|
-
targetEl = applyRoot(hostSet.$firstHost);
|
|
6129
|
-
} else if (selector === ":lastHost") {
|
|
6130
|
-
targetEl = applyRoot(hostSet.$lastHost);
|
|
6131
|
-
} else if (selector === ":firstAppHost") {
|
|
6132
|
-
targetEl = applyRoot(hostSet.$firstHost);
|
|
6133
|
-
} else if (selector === ":lastAppHost") {
|
|
6134
|
-
targetEl = applyRoot(hostSet.$lastAppHost);
|
|
6135
|
-
} else {
|
|
6136
|
-
const targetRoot = applyRoot(this);
|
|
6137
|
-
targetEl = targetRoot ? targetRoot.querySelector(selector) : null;
|
|
6138
|
-
}
|
|
6139
|
-
if (targetEl) {
|
|
6140
|
-
const isShadowRoot = targetEl instanceof ShadowRoot;
|
|
6141
|
-
const nodes = normalizeNodes(res, currentDoc);
|
|
6142
|
-
if (pos === "replace") {
|
|
6143
|
-
if (!isShadowRoot) {
|
|
6144
|
-
targetEl.replaceWith(...nodes);
|
|
6145
|
-
}
|
|
6146
|
-
} else if (pos === "replaceChildren") {
|
|
6147
|
-
targetEl.replaceChildren(...nodes);
|
|
6148
|
-
} else if (pos === "innerHtml") {
|
|
6149
|
-
targetEl.innerHTML = res !== void 0 && res !== null ? String(res) : "";
|
|
6150
|
-
} else if (pos === "innerText") {
|
|
6151
|
-
if (targetEl.innerText !== void 0) {
|
|
6152
|
-
targetEl.innerText = res !== void 0 && res !== null ? String(res) : "";
|
|
6153
|
-
}
|
|
6154
|
-
} else {
|
|
6155
|
-
if (pos === "beforeEnd")
|
|
6156
|
-
targetEl.append(...nodes);
|
|
6157
|
-
else if (pos === "afterBegin")
|
|
6158
|
-
targetEl.prepend(...nodes);
|
|
6159
|
-
else if (pos === "beforeBegin" && !isShadowRoot)
|
|
6160
|
-
targetEl.before(...nodes);
|
|
6161
|
-
else if (pos === "afterEnd" && !isShadowRoot)
|
|
6162
|
-
targetEl.after(...nodes);
|
|
6163
|
-
}
|
|
6164
|
-
}
|
|
6410
|
+
if (selector === ":host") return applyRoot(this);
|
|
6411
|
+
if (selector === ":parentHost") return applyRoot(hostSet.$parentHost);
|
|
6412
|
+
if (selector === ":appHost") return applyRoot(hostSet.$appHost);
|
|
6413
|
+
if (selector === ":firstHost") return applyRoot(hostSet.$firstHost);
|
|
6414
|
+
if (selector === ":lastHost") return applyRoot(hostSet.$lastHost);
|
|
6415
|
+
const targetRoot = applyRoot(this);
|
|
6416
|
+
return targetRoot ? targetRoot.querySelector(selector) : null;
|
|
6417
|
+
};
|
|
6418
|
+
const targetEl = getTarget();
|
|
6419
|
+
const res = original.apply(this, args);
|
|
6420
|
+
const runApply = (target, val) => {
|
|
6421
|
+
const pos = options.position || "beforeEnd";
|
|
6422
|
+
const defaultFilter = (t, v) => {
|
|
6423
|
+
if (v instanceof Node) return !t.contains(v);
|
|
6424
|
+
if (pos === "innerHtml" && typeof v === "string") return t.innerHTML !== v;
|
|
6425
|
+
if (pos === "replaceChildren" && v instanceof Node) return !t.contains(v);
|
|
6426
|
+
return true;
|
|
6427
|
+
};
|
|
6428
|
+
const activeFilter = options.filter || defaultFilter;
|
|
6429
|
+
if (activeFilter(target, val, hostSet)) {
|
|
6430
|
+
applyToDom(target, val, pos, currentDoc);
|
|
6165
6431
|
}
|
|
6432
|
+
};
|
|
6433
|
+
if (res instanceof Promise) {
|
|
6434
|
+
if (targetEl && options.loading) {
|
|
6435
|
+
const loadingRes = options.loading.call(this, hostSet);
|
|
6436
|
+
applyToDom(targetEl, loadingRes, options.position || "beforeEnd", currentDoc);
|
|
6437
|
+
}
|
|
6438
|
+
return res.then((finalRes) => {
|
|
6439
|
+
if (finalRes !== void 0 && targetEl) runApply(targetEl, finalRes);
|
|
6440
|
+
return finalRes;
|
|
6441
|
+
});
|
|
6442
|
+
} else {
|
|
6443
|
+
if (res !== void 0 && targetEl) runApply(targetEl, res);
|
|
6444
|
+
return res;
|
|
6166
6445
|
}
|
|
6167
|
-
return res;
|
|
6168
6446
|
};
|
|
6169
6447
|
};
|
|
6170
6448
|
}
|
|
@@ -6179,110 +6457,29 @@ var findAllApplyNodeMetadata = (target) => {
|
|
|
6179
6457
|
return result;
|
|
6180
6458
|
};
|
|
6181
6459
|
function applyNodeHost(targetOrOptions, propertyKey, descriptor) {
|
|
6182
|
-
|
|
6183
|
-
|
|
6184
|
-
|
|
6185
|
-
}
|
|
6186
|
-
if (typeof targetOrOptions === "object" && targetOrOptions !== null) {
|
|
6187
|
-
const options = targetOrOptions;
|
|
6188
|
-
return applyNode(":host", { ...options, position: options.position || "beforeEnd" });
|
|
6189
|
-
} else {
|
|
6190
|
-
return applyNode(":host", { position: "beforeEnd" });
|
|
6191
|
-
}
|
|
6192
|
-
}
|
|
6193
|
-
function applyBeforeBeginNode(selector, options) {
|
|
6194
|
-
return applyNode(selector, { ...options, position: "beforeBegin" });
|
|
6195
|
-
}
|
|
6196
|
-
function applyAfterBeginNode(selector, options) {
|
|
6197
|
-
return applyNode(selector, { ...options, position: "afterBegin" });
|
|
6460
|
+
if (propertyKey !== void 0) return applyNode(":host", { position: "beforeEnd" })(targetOrOptions, propertyKey, descriptor);
|
|
6461
|
+
const opt = targetOrOptions || {};
|
|
6462
|
+
return applyNode(":host", { position: "beforeEnd", ...opt });
|
|
6198
6463
|
}
|
|
6199
|
-
function
|
|
6200
|
-
return applyNode(
|
|
6464
|
+
function applyReplaceChildrenNodeHost(targetOrOptions, propertyKey, descriptor) {
|
|
6465
|
+
if (propertyKey !== void 0) return applyNode(":host", { position: "replaceChildren" })(targetOrOptions, propertyKey, descriptor);
|
|
6466
|
+
const opt = targetOrOptions || {};
|
|
6467
|
+
return applyNode(":host", { position: "replaceChildren", ...opt });
|
|
6201
6468
|
}
|
|
6202
|
-
function
|
|
6203
|
-
return applyNode(
|
|
6469
|
+
function applyInnerHtmlNodeHost(targetOrOptions, propertyKey, descriptor) {
|
|
6470
|
+
if (propertyKey !== void 0) return applyNode(":host", { position: "innerHtml" })(targetOrOptions, propertyKey, descriptor);
|
|
6471
|
+
const opt = targetOrOptions || {};
|
|
6472
|
+
return applyNode(":host", { position: "innerHtml", ...opt });
|
|
6204
6473
|
}
|
|
6205
|
-
function
|
|
6206
|
-
return applyNode(selector, { ...options, position: "replace" });
|
|
6207
|
-
}
|
|
6208
|
-
function applyReplaceChildrenNode(selector, options) {
|
|
6474
|
+
function applyReplaceChildrenNode(selector, options = {}) {
|
|
6209
6475
|
return applyNode(selector, { ...options, position: "replaceChildren" });
|
|
6210
6476
|
}
|
|
6211
|
-
function applyInnerHtmlNode(selector, options) {
|
|
6477
|
+
function applyInnerHtmlNode(selector, options = {}) {
|
|
6212
6478
|
return applyNode(selector, { ...options, position: "innerHtml" });
|
|
6213
6479
|
}
|
|
6214
|
-
function applyInnerTextNode(selector, options) {
|
|
6215
|
-
return applyNode(selector, { ...options, position: "innerText" });
|
|
6216
|
-
}
|
|
6217
|
-
function applyRemoveNode(selector, options) {
|
|
6218
|
-
return applyNode(selector, { ...options, position: "remove" });
|
|
6219
|
-
}
|
|
6220
|
-
function applyBeforeBeginNodeHost(targetOrOptions, propertyKey, descriptor) {
|
|
6221
|
-
if (propertyKey !== void 0) {
|
|
6222
|
-
const decorator = applyNode(":host", { position: "beforeBegin" });
|
|
6223
|
-
return decorator(targetOrOptions, propertyKey, descriptor);
|
|
6224
|
-
}
|
|
6225
|
-
return applyNode(":host", { ...targetOrOptions || {}, position: "beforeBegin" });
|
|
6226
|
-
}
|
|
6227
|
-
function applyAfterBeginNodeHost(optionsOrTarget, propertyKey, descriptor) {
|
|
6228
|
-
if (propertyKey !== void 0) {
|
|
6229
|
-
const decorator = applyNode(":host", { position: "afterBegin" });
|
|
6230
|
-
return decorator(optionsOrTarget, propertyKey, descriptor);
|
|
6231
|
-
}
|
|
6232
|
-
return applyNode(":host", { ...optionsOrTarget || {}, position: "afterBegin" });
|
|
6233
|
-
}
|
|
6234
|
-
function applyBeforeEndNodeHost(optionsOrTarget, propertyKey, descriptor) {
|
|
6235
|
-
if (propertyKey !== void 0) {
|
|
6236
|
-
const decorator = applyNode(":host", { position: "beforeEnd" });
|
|
6237
|
-
return decorator(optionsOrTarget, propertyKey, descriptor);
|
|
6238
|
-
}
|
|
6239
|
-
return applyNode(":host", { ...optionsOrTarget || {}, position: "beforeEnd" });
|
|
6240
|
-
}
|
|
6241
|
-
function applyAfterEndNodeHost(optionsOrTarget, propertyKey, descriptor) {
|
|
6242
|
-
if (propertyKey !== void 0) {
|
|
6243
|
-
const decorator = applyNode(":host", { position: "afterEnd" });
|
|
6244
|
-
return decorator(optionsOrTarget, propertyKey, descriptor);
|
|
6245
|
-
}
|
|
6246
|
-
return applyNode(":host", { ...optionsOrTarget || {}, position: "afterEnd" });
|
|
6247
|
-
}
|
|
6248
|
-
function applyReplaceNodeHost(optionsOrTarget, propertyKey, descriptor) {
|
|
6249
|
-
if (propertyKey !== void 0) {
|
|
6250
|
-
const decorator = applyNode(":host", { position: "replace" });
|
|
6251
|
-
return decorator(optionsOrTarget, propertyKey, descriptor);
|
|
6252
|
-
}
|
|
6253
|
-
return applyNode(":host", { ...optionsOrTarget || {}, position: "replace" });
|
|
6254
|
-
}
|
|
6255
|
-
function applyReplaceChildrenNodeHost(optionsOrTarget, propertyKey, descriptor) {
|
|
6256
|
-
if (propertyKey !== void 0) {
|
|
6257
|
-
const decorator = applyNode(":host", { position: "replaceChildren" });
|
|
6258
|
-
return decorator(optionsOrTarget, propertyKey, descriptor);
|
|
6259
|
-
}
|
|
6260
|
-
return applyNode(":host", { ...optionsOrTarget || {}, position: "replaceChildren" });
|
|
6261
|
-
}
|
|
6262
|
-
function applyInnerHtmlNodeHost(optionsOrTarget, propertyKey, descriptor) {
|
|
6263
|
-
if (propertyKey !== void 0) {
|
|
6264
|
-
const decorator = applyNode(":host", { position: "innerHtml" });
|
|
6265
|
-
return decorator(optionsOrTarget, propertyKey, descriptor);
|
|
6266
|
-
}
|
|
6267
|
-
return applyNode(":host", { ...optionsOrTarget || {}, position: "innerHtml" });
|
|
6268
|
-
}
|
|
6269
|
-
function applyInnerTextNodeHost(optionsOrTarget, propertyKey, descriptor) {
|
|
6270
|
-
if (propertyKey !== void 0) {
|
|
6271
|
-
const decorator = applyNode(":host", { position: "innerText" });
|
|
6272
|
-
return decorator(optionsOrTarget, propertyKey, descriptor);
|
|
6273
|
-
}
|
|
6274
|
-
return applyNode(":host", { ...optionsOrTarget || {}, position: "innerText" });
|
|
6275
|
-
}
|
|
6276
|
-
function applyRemoveNodeHost(optionsOrTarget, propertyKey, descriptor) {
|
|
6277
|
-
if (propertyKey !== void 0) {
|
|
6278
|
-
const decorator = applyNode(":host", { position: "remove" });
|
|
6279
|
-
return decorator(optionsOrTarget, propertyKey, descriptor);
|
|
6280
|
-
}
|
|
6281
|
-
return applyNode(":host", { ...optionsOrTarget || {}, position: "remove" });
|
|
6282
|
-
}
|
|
6283
6480
|
|
|
6284
6481
|
// src/decorators/query.ts
|
|
6285
|
-
var QUERY_METADATA_KEY = Symbol("simple-web-component:query");
|
|
6482
|
+
var QUERY_METADATA_KEY = Symbol.for("simple-web-component:query");
|
|
6286
6483
|
function query(selectorOrTarget, options = {}) {
|
|
6287
6484
|
return (targetObj, propertyKey, descriptor) => {
|
|
6288
6485
|
if (descriptor !== void 0) {
|
|
@@ -6453,7 +6650,7 @@ function lastAppHost(targetOrOptions, propertyKey) {
|
|
|
6453
6650
|
}
|
|
6454
6651
|
|
|
6455
6652
|
// src/decorators/queryAll.ts
|
|
6456
|
-
var QUERY_ALL_METADATA_KEY = Symbol("simple-web-component:query-all");
|
|
6653
|
+
var QUERY_ALL_METADATA_KEY = Symbol.for("simple-web-component:query-all");
|
|
6457
6654
|
function queryAll(selectorOrTarget, options = {}) {
|
|
6458
6655
|
return (targetObj, propertyKey, descriptor) => {
|
|
6459
6656
|
if (descriptor !== void 0) {
|
|
@@ -6620,35 +6817,38 @@ function allLastAppHost(targetOrOptions, propertyKey) {
|
|
|
6620
6817
|
}
|
|
6621
6818
|
}
|
|
6622
6819
|
|
|
6623
|
-
// src/decorators/
|
|
6624
|
-
var
|
|
6625
|
-
function
|
|
6626
|
-
return (selector, options = {}) => {
|
|
6820
|
+
// src/decorators/applyClass.ts
|
|
6821
|
+
var CLASS_METADATA_KEY = Symbol.for("simple-web-component:class");
|
|
6822
|
+
function createClassDecorator(action) {
|
|
6823
|
+
return (selector, classMapOrOptions, options = {}) => {
|
|
6627
6824
|
return (target, propertyKey, descriptor) => {
|
|
6628
6825
|
const constructor = target.constructor;
|
|
6629
|
-
let metaList = ReflectUtils.getOwnMetadata(
|
|
6826
|
+
let metaList = ReflectUtils.getOwnMetadata(CLASS_METADATA_KEY, constructor);
|
|
6630
6827
|
if (!metaList) {
|
|
6631
6828
|
metaList = /* @__PURE__ */ new Map();
|
|
6632
|
-
ReflectUtils.defineMetadata(
|
|
6829
|
+
ReflectUtils.defineMetadata(CLASS_METADATA_KEY, metaList, constructor);
|
|
6633
6830
|
}
|
|
6634
|
-
|
|
6831
|
+
let classMap = void 0;
|
|
6832
|
+
let finalOptions = options;
|
|
6833
|
+
if (typeof classMapOrOptions === "string" || typeof classMapOrOptions === "object" && classMapOrOptions !== null && !("root" in classMapOrOptions)) {
|
|
6834
|
+
classMap = classMapOrOptions;
|
|
6835
|
+
} else if (typeof classMapOrOptions === "object" && classMapOrOptions !== null && "root" in classMapOrOptions) {
|
|
6836
|
+
finalOptions = classMapOrOptions;
|
|
6837
|
+
}
|
|
6838
|
+
metaList.set(propertyKey, { propertyKey, selector, action, options: finalOptions });
|
|
6635
6839
|
const original = descriptor.value;
|
|
6636
6840
|
descriptor.value = async function(...args) {
|
|
6637
6841
|
ensureInit2(this);
|
|
6638
6842
|
const res = await original.apply(this, args);
|
|
6639
6843
|
if (res !== void 0) {
|
|
6640
|
-
const
|
|
6641
|
-
const
|
|
6844
|
+
const win = this.ownerDocument?.defaultView || window;
|
|
6845
|
+
const host2 = this;
|
|
6846
|
+
const hostSet = { ...SwcUtils.getHelperAndHostSet(win, host2), $this: this };
|
|
6847
|
+
const r = finalOptions.root || "auto";
|
|
6642
6848
|
const targetEls = [];
|
|
6643
6849
|
const applyRoot = (t) => {
|
|
6644
|
-
if (!t || !(t instanceof HTMLElement)) return;
|
|
6645
|
-
|
|
6646
|
-
targetEls.push(t);
|
|
6647
|
-
} else {
|
|
6648
|
-
if (r === "light" || r === "all") targetEls.push(t);
|
|
6649
|
-
if ((r === "shadow" || r === "all") && t.shadowRoot) {
|
|
6650
|
-
}
|
|
6651
|
-
}
|
|
6850
|
+
if (!t || !(t instanceof win.HTMLElement)) return;
|
|
6851
|
+
targetEls.push(t);
|
|
6652
6852
|
};
|
|
6653
6853
|
if (selector === ":parentHost") applyRoot(hostSet.$parentHost);
|
|
6654
6854
|
else if (selector === ":appHost") applyRoot(hostSet.$appHost);
|
|
@@ -6658,102 +6858,84 @@ function createClassListDecorator(action) {
|
|
|
6658
6858
|
else if (selector === ":lastAppHost") applyRoot(hostSet.$lastAppHost);
|
|
6659
6859
|
else if (selector === ":hosts") hostSet.$hosts.forEach(applyRoot);
|
|
6660
6860
|
else if (selector === ":appHosts") hostSet.$appHosts.forEach(applyRoot);
|
|
6661
|
-
else if (selector === ":host" || !selector) applyRoot(
|
|
6861
|
+
else if (selector === ":host" || !selector) applyRoot(host2);
|
|
6662
6862
|
else {
|
|
6663
|
-
|
|
6664
|
-
|
|
6665
|
-
|
|
6666
|
-
} else if (r === "light") {
|
|
6667
|
-
const found = this.querySelectorAll(selector);
|
|
6668
|
-
if (found) targetEls.push(...Array.from(found));
|
|
6669
|
-
} else if (r === "all") {
|
|
6670
|
-
const sFound = this.shadowRoot?.querySelectorAll(selector);
|
|
6671
|
-
const lFound = this.querySelectorAll(selector);
|
|
6672
|
-
if (sFound) targetEls.push(...Array.from(sFound));
|
|
6673
|
-
if (lFound) targetEls.push(...Array.from(lFound));
|
|
6674
|
-
} else {
|
|
6675
|
-
const found = (this.shadowRoot || this).querySelectorAll(selector);
|
|
6863
|
+
const targetRoot = r === "auto" ? host2.shadowRoot || host2 : r === "shadow" ? host2.shadowRoot : host2;
|
|
6864
|
+
if (targetRoot) {
|
|
6865
|
+
const found = targetRoot.querySelectorAll(selector);
|
|
6676
6866
|
if (found) targetEls.push(...Array.from(found));
|
|
6677
6867
|
}
|
|
6678
6868
|
}
|
|
6679
6869
|
targetEls.forEach((targetEl) => {
|
|
6870
|
+
const resolvedRes = typeof res === "function" ? res(targetEl, hostSet) : res;
|
|
6680
6871
|
if (action === "set") {
|
|
6681
6872
|
let classes = "";
|
|
6682
|
-
if (typeof
|
|
6683
|
-
classes =
|
|
6873
|
+
if (classMap && typeof classMap === "string") {
|
|
6874
|
+
classes = resolvedRes ? classMap : "";
|
|
6875
|
+
} else if (typeof resolvedRes === "object" && resolvedRes !== null && !Array.isArray(resolvedRes)) {
|
|
6876
|
+
classes = Object.entries(resolvedRes).filter(([_, force]) => typeof force === "function" ? force(targetEl, hostSet) : !!force).map(([cls]) => cls).join(" ");
|
|
6684
6877
|
} else {
|
|
6685
|
-
classes = Array.isArray(
|
|
6878
|
+
classes = Array.isArray(resolvedRes) ? resolvedRes.join(" ") : String(resolvedRes);
|
|
6686
6879
|
}
|
|
6687
6880
|
targetEl.className = classes;
|
|
6688
|
-
} else if (action === "update") {
|
|
6689
|
-
if (typeof
|
|
6690
|
-
|
|
6691
|
-
|
|
6881
|
+
} else if (action === "update" || action === "toggle") {
|
|
6882
|
+
if (classMap && typeof classMap === "string") {
|
|
6883
|
+
targetEl.classList.toggle(classMap, !!resolvedRes);
|
|
6884
|
+
} else if (typeof resolvedRes === "object" && resolvedRes !== null && !Array.isArray(resolvedRes)) {
|
|
6885
|
+
Object.entries(resolvedRes).forEach(([cls, force]) => {
|
|
6886
|
+
const isActive = typeof force === "function" ? force(targetEl, hostSet) : !!force;
|
|
6887
|
+
targetEl.classList.toggle(cls, isActive);
|
|
6692
6888
|
});
|
|
6693
|
-
} else
|
|
6694
|
-
const classes = Array.isArray(
|
|
6695
|
-
targetEl.classList.add(...classes);
|
|
6889
|
+
} else {
|
|
6890
|
+
const classes = Array.isArray(resolvedRes) ? resolvedRes.map(String) : [String(resolvedRes)];
|
|
6891
|
+
if (action === "update") targetEl.classList.add(...classes);
|
|
6892
|
+
else classes.forEach((c) => targetEl.classList.toggle(c));
|
|
6893
|
+
}
|
|
6894
|
+
} else if (action === "add" || action === "remove") {
|
|
6895
|
+
if (classMap && typeof classMap === "string" && !!resolvedRes) {
|
|
6896
|
+
if (action === "add") targetEl.classList.add(classMap);
|
|
6897
|
+
else targetEl.classList.remove(classMap);
|
|
6898
|
+
} else if (typeof resolvedRes === "object" && resolvedRes !== null && !Array.isArray(resolvedRes)) {
|
|
6899
|
+
Object.entries(resolvedRes).forEach(([cls, force]) => {
|
|
6900
|
+
const shouldExecute = typeof force === "function" ? force(targetEl, hostSet) : !!force;
|
|
6901
|
+
if (shouldExecute) {
|
|
6902
|
+
if (action === "add") targetEl.classList.add(cls);
|
|
6903
|
+
else targetEl.classList.remove(cls);
|
|
6904
|
+
}
|
|
6905
|
+
});
|
|
6906
|
+
} else {
|
|
6907
|
+
const classes = Array.isArray(resolvedRes) ? resolvedRes.map(String) : [String(resolvedRes)];
|
|
6908
|
+
if (action === "add") targetEl.classList.add(...classes);
|
|
6909
|
+
else targetEl.classList.remove(...classes);
|
|
6696
6910
|
}
|
|
6697
|
-
} else if (action === "add") {
|
|
6698
|
-
const classes = Array.isArray(res) ? res.map(String) : [String(res)];
|
|
6699
|
-
targetEl.classList.add(...classes);
|
|
6700
|
-
} else if (action === "remove") {
|
|
6701
|
-
const classes = Array.isArray(res) ? res.map(String) : [String(res)];
|
|
6702
|
-
targetEl.classList.remove(...classes);
|
|
6703
|
-
} else if (action === "toggle") {
|
|
6704
|
-
const classes = Array.isArray(res) ? res.map(String) : [String(res)];
|
|
6705
|
-
classes.forEach((c) => targetEl.classList.toggle(c));
|
|
6706
6911
|
}
|
|
6707
6912
|
});
|
|
6708
6913
|
}
|
|
6709
6914
|
return res;
|
|
6710
6915
|
};
|
|
6916
|
+
return descriptor;
|
|
6711
6917
|
};
|
|
6712
6918
|
};
|
|
6713
6919
|
}
|
|
6714
|
-
|
|
6715
|
-
|
|
6716
|
-
var addClassList = (selector, options = {}) => createClassListDecorator("add")(selector, options);
|
|
6717
|
-
var removeClassList = (selector, options = {}) => createClassListDecorator("remove")(selector, options);
|
|
6718
|
-
var toggleClassList = (selector, options = {}) => createClassListDecorator("toggle")(selector, options);
|
|
6719
|
-
function setClassListHost(targetOrOptions, propertyKey, descriptor) {
|
|
6720
|
-
if (propertyKey !== void 0) {
|
|
6721
|
-
const decorator = createClassListDecorator("set")(":host", {});
|
|
6722
|
-
return decorator(targetOrOptions, propertyKey, descriptor);
|
|
6723
|
-
}
|
|
6724
|
-
return createClassListDecorator("set")(":host", targetOrOptions || {});
|
|
6920
|
+
function applyClass(selector, action = "update", options = {}) {
|
|
6921
|
+
return createClassDecorator(action)(selector, options);
|
|
6725
6922
|
}
|
|
6726
|
-
|
|
6727
|
-
|
|
6728
|
-
|
|
6729
|
-
|
|
6730
|
-
|
|
6731
|
-
|
|
6923
|
+
var setClass = (selector, classMapOrOptions, options = {}) => createClassDecorator("set")(selector, classMapOrOptions, options);
|
|
6924
|
+
var updateClass = (selector, classMapOrOptions, options = {}) => createClassDecorator("update")(selector, classMapOrOptions, options);
|
|
6925
|
+
var addClass = (selector, classMapOrOptions, options = {}) => createClassDecorator("add")(selector, classMapOrOptions, options);
|
|
6926
|
+
var removeClass = (selector, classMapOrOptions, options = {}) => createClassDecorator("remove")(selector, classMapOrOptions, options);
|
|
6927
|
+
var toggleClass = (selector, classMapOrOptions, options = {}) => createClassDecorator("toggle")(selector, classMapOrOptions, options);
|
|
6928
|
+
function applyClassHost(action = "update", options = {}) {
|
|
6929
|
+
return createClassDecorator(action)(":host", options);
|
|
6732
6930
|
}
|
|
6733
|
-
|
|
6734
|
-
|
|
6735
|
-
|
|
6736
|
-
|
|
6737
|
-
|
|
6738
|
-
|
|
6739
|
-
}
|
|
6740
|
-
function removeClassListHost(targetOrOptions, propertyKey, descriptor) {
|
|
6741
|
-
if (propertyKey !== void 0) {
|
|
6742
|
-
const decorator = createClassListDecorator("remove")(":host", {});
|
|
6743
|
-
return decorator(targetOrOptions, propertyKey, descriptor);
|
|
6744
|
-
}
|
|
6745
|
-
return createClassListDecorator("remove")(":host", targetOrOptions || {});
|
|
6746
|
-
}
|
|
6747
|
-
function toggleClassListHost(targetOrOptions, propertyKey, descriptor) {
|
|
6748
|
-
if (propertyKey !== void 0) {
|
|
6749
|
-
const decorator = createClassListDecorator("toggle")(":host", {});
|
|
6750
|
-
return decorator(targetOrOptions, propertyKey, descriptor);
|
|
6751
|
-
}
|
|
6752
|
-
return createClassListDecorator("toggle")(":host", targetOrOptions || {});
|
|
6753
|
-
}
|
|
6754
|
-
var findAllClassListMetadata = (target) => {
|
|
6931
|
+
var setClassHost = (classMapOrOptions, options = {}) => createClassDecorator("set")(":host", classMapOrOptions, options);
|
|
6932
|
+
var updateClassHost = (classMapOrOptions, options = {}) => createClassDecorator("update")(":host", classMapOrOptions, options);
|
|
6933
|
+
var addClassHost = (classMapOrOptions, options = {}) => createClassDecorator("add")(":host", classMapOrOptions, options);
|
|
6934
|
+
var removeClassHost = (classMapOrOptions, options = {}) => createClassDecorator("remove")(":host", classMapOrOptions, options);
|
|
6935
|
+
var toggleClassHost = (classMapOrOptions, options = {}) => createClassDecorator("toggle")(":host", classMapOrOptions, options);
|
|
6936
|
+
var findAllClassMetadata = (target) => {
|
|
6755
6937
|
const result = /* @__PURE__ */ new Map();
|
|
6756
|
-
const maps = ReflectUtils.findAllMetadata(
|
|
6938
|
+
const maps = ReflectUtils.findAllMetadata(CLASS_METADATA_KEY, target);
|
|
6757
6939
|
maps.forEach((map) => {
|
|
6758
6940
|
if (map instanceof Map) {
|
|
6759
6941
|
map.forEach((v, k) => result.set(k, v));
|
|
@@ -6762,8 +6944,8 @@ var findAllClassListMetadata = (target) => {
|
|
|
6762
6944
|
return result;
|
|
6763
6945
|
};
|
|
6764
6946
|
|
|
6765
|
-
// src/decorators/
|
|
6766
|
-
var STYLE_METADATA_KEY = Symbol("simple-web-component:style");
|
|
6947
|
+
// src/decorators/applyStyle.ts
|
|
6948
|
+
var STYLE_METADATA_KEY = Symbol.for("simple-web-component:style");
|
|
6767
6949
|
function createStyleDecorator(action) {
|
|
6768
6950
|
return (selector, options = {}) => {
|
|
6769
6951
|
return (target, propertyKey, descriptor) => {
|
|
@@ -6779,18 +6961,14 @@ function createStyleDecorator(action) {
|
|
|
6779
6961
|
ensureInit2(this);
|
|
6780
6962
|
const res = await original.apply(this, args);
|
|
6781
6963
|
if (res !== void 0) {
|
|
6964
|
+
const win = this.ownerDocument?.defaultView || window;
|
|
6965
|
+
const host2 = this;
|
|
6966
|
+
const hostSet = { ...SwcUtils.getHelperAndHostSet(win, host2), $this: this };
|
|
6782
6967
|
const r = options.root || "auto";
|
|
6783
|
-
const hostSet = SwcUtils.getHostSet(this);
|
|
6784
6968
|
const targetEls = [];
|
|
6785
6969
|
const applyRoot = (t) => {
|
|
6786
|
-
if (!t || !(t instanceof HTMLElement)) return;
|
|
6787
|
-
|
|
6788
|
-
targetEls.push(t);
|
|
6789
|
-
} else {
|
|
6790
|
-
if (r === "light" || r === "all") targetEls.push(t);
|
|
6791
|
-
if ((r === "shadow" || r === "all") && t.shadowRoot) {
|
|
6792
|
-
}
|
|
6793
|
-
}
|
|
6970
|
+
if (!t || !(t instanceof win.HTMLElement)) return;
|
|
6971
|
+
targetEls.push(t);
|
|
6794
6972
|
};
|
|
6795
6973
|
if (selector === ":parentHost") applyRoot(hostSet.$parentHost);
|
|
6796
6974
|
else if (selector === ":appHost") applyRoot(hostSet.$appHost);
|
|
@@ -6800,71 +6978,63 @@ function createStyleDecorator(action) {
|
|
|
6800
6978
|
else if (selector === ":lastAppHost") applyRoot(hostSet.$lastAppHost);
|
|
6801
6979
|
else if (selector === ":hosts") hostSet.$hosts.forEach(applyRoot);
|
|
6802
6980
|
else if (selector === ":appHosts") hostSet.$appHosts.forEach(applyRoot);
|
|
6803
|
-
else if (selector === ":host" || !selector) applyRoot(
|
|
6981
|
+
else if (selector === ":host" || !selector) applyRoot(host2);
|
|
6804
6982
|
else {
|
|
6805
|
-
|
|
6806
|
-
|
|
6807
|
-
|
|
6808
|
-
} else if (r === "light") {
|
|
6809
|
-
const found = this.querySelectorAll(selector);
|
|
6810
|
-
if (found) targetEls.push(...Array.from(found));
|
|
6811
|
-
} else if (r === "all") {
|
|
6812
|
-
const sFound = this.shadowRoot?.querySelectorAll(selector);
|
|
6813
|
-
const lFound = this.querySelectorAll(selector);
|
|
6814
|
-
if (sFound) targetEls.push(...Array.from(sFound));
|
|
6815
|
-
if (lFound) targetEls.push(...Array.from(lFound));
|
|
6816
|
-
} else {
|
|
6817
|
-
const found = (this.shadowRoot || this).querySelectorAll(selector);
|
|
6983
|
+
const targetRoot = r === "auto" ? host2.shadowRoot || host2 : r === "shadow" ? host2.shadowRoot : host2;
|
|
6984
|
+
if (targetRoot) {
|
|
6985
|
+
const found = targetRoot.querySelectorAll(selector);
|
|
6818
6986
|
if (found) targetEls.push(...Array.from(found));
|
|
6819
6987
|
}
|
|
6820
6988
|
}
|
|
6821
6989
|
targetEls.forEach((targetEl) => {
|
|
6822
|
-
|
|
6823
|
-
|
|
6824
|
-
if (
|
|
6825
|
-
|
|
6826
|
-
|
|
6827
|
-
|
|
6828
|
-
|
|
6829
|
-
|
|
6830
|
-
|
|
6831
|
-
|
|
6990
|
+
const resolvedRes = typeof res === "function" ? res(targetEl, hostSet) : res;
|
|
6991
|
+
if (action === "set" || action === "update") {
|
|
6992
|
+
if (action === "set") targetEl.style.cssText = "";
|
|
6993
|
+
if (typeof resolvedRes === "object" && resolvedRes !== null && !Array.isArray(resolvedRes)) {
|
|
6994
|
+
Object.entries(resolvedRes).forEach(([prop, val]) => {
|
|
6995
|
+
const finalVal = typeof val === "function" ? val(targetEl, hostSet) : val;
|
|
6996
|
+
if (finalVal === null || finalVal === void 0) {
|
|
6997
|
+
targetEl.style.removeProperty(prop);
|
|
6998
|
+
} else {
|
|
6999
|
+
targetEl.style[prop] = String(finalVal);
|
|
7000
|
+
}
|
|
7001
|
+
});
|
|
7002
|
+
} else if (typeof resolvedRes === "string") {
|
|
7003
|
+
targetEl.style.cssText = resolvedRes;
|
|
6832
7004
|
}
|
|
6833
7005
|
} else if (action === "remove") {
|
|
6834
|
-
|
|
6835
|
-
|
|
7006
|
+
if (typeof resolvedRes === "object" && resolvedRes !== null && !Array.isArray(resolvedRes)) {
|
|
7007
|
+
Object.entries(resolvedRes).forEach(([prop, val]) => {
|
|
7008
|
+
const shouldRemove = typeof val === "function" ? val(targetEl, hostSet) : !!val;
|
|
7009
|
+
if (shouldRemove) {
|
|
7010
|
+
targetEl.style.removeProperty(prop);
|
|
7011
|
+
}
|
|
7012
|
+
});
|
|
7013
|
+
} else {
|
|
7014
|
+
const props = Array.isArray(resolvedRes) ? resolvedRes : [resolvedRes];
|
|
7015
|
+
props.forEach((p) => targetEl.style.removeProperty(String(p)));
|
|
7016
|
+
}
|
|
6836
7017
|
}
|
|
6837
7018
|
});
|
|
6838
7019
|
}
|
|
6839
7020
|
return res;
|
|
6840
7021
|
};
|
|
7022
|
+
return descriptor;
|
|
6841
7023
|
};
|
|
6842
7024
|
};
|
|
6843
7025
|
}
|
|
6844
|
-
|
|
6845
|
-
|
|
6846
|
-
if (propertyKey !== void 0) {
|
|
6847
|
-
const decorator = createStyleDecorator("set")(":host", {});
|
|
6848
|
-
return decorator(targetOrOptions, propertyKey, descriptor);
|
|
6849
|
-
}
|
|
6850
|
-
return createStyleDecorator("set")(":host", targetOrOptions || {});
|
|
7026
|
+
function applyStyle(selector, action = "update", options = {}) {
|
|
7027
|
+
return createStyleDecorator(action)(selector, options);
|
|
6851
7028
|
}
|
|
7029
|
+
var setStyle = (selector, options = {}) => createStyleDecorator("set")(selector, options);
|
|
6852
7030
|
var updateStyle = (selector, options = {}) => createStyleDecorator("update")(selector, options);
|
|
6853
|
-
function updateStyleHost(targetOrOptions, propertyKey, descriptor) {
|
|
6854
|
-
if (propertyKey !== void 0) {
|
|
6855
|
-
const decorator = createStyleDecorator("update")(":host", {});
|
|
6856
|
-
return decorator(targetOrOptions, propertyKey, descriptor);
|
|
6857
|
-
}
|
|
6858
|
-
return createStyleDecorator("update")(":host", targetOrOptions || {});
|
|
6859
|
-
}
|
|
6860
7031
|
var removeStyle = (selector, options = {}) => createStyleDecorator("remove")(selector, options);
|
|
6861
|
-
function
|
|
6862
|
-
|
|
6863
|
-
const decorator = createStyleDecorator("remove")(":host", {});
|
|
6864
|
-
return decorator(targetOrOptions, propertyKey, descriptor);
|
|
6865
|
-
}
|
|
6866
|
-
return createStyleDecorator("remove")(":host", targetOrOptions || {});
|
|
7032
|
+
function applyStyleHost(action = "update", options = {}) {
|
|
7033
|
+
return createStyleDecorator(action)(":host", options);
|
|
6867
7034
|
}
|
|
7035
|
+
var setStyleHost = (options = {}) => createStyleDecorator("set")(":host", options);
|
|
7036
|
+
var updateStyleHost = (options = {}) => createStyleDecorator("update")(":host", options);
|
|
7037
|
+
var removeStyleHost = (options = {}) => createStyleDecorator("remove")(":host", options);
|
|
6868
7038
|
var findAllStyleMetadata = (target) => {
|
|
6869
7039
|
const result = /* @__PURE__ */ new Map();
|
|
6870
7040
|
const maps = ReflectUtils.findAllMetadata(STYLE_METADATA_KEY, target);
|
|
@@ -6876,8 +7046,123 @@ var findAllStyleMetadata = (target) => {
|
|
|
6876
7046
|
return result;
|
|
6877
7047
|
};
|
|
6878
7048
|
|
|
7049
|
+
// src/decorators/applyAttribute.ts
|
|
7050
|
+
var ATTRIBUTE_APPLY_METADATA_KEY = Symbol.for("simple-web-component:attribute-apply");
|
|
7051
|
+
function createAttributeDecorator(action) {
|
|
7052
|
+
return (selector, nameOrOptions, options = {}) => {
|
|
7053
|
+
return (target, propertyKey, descriptor) => {
|
|
7054
|
+
const constructor = target.constructor;
|
|
7055
|
+
let metaList = ReflectUtils.getOwnMetadata(ATTRIBUTE_APPLY_METADATA_KEY, constructor);
|
|
7056
|
+
if (!metaList) {
|
|
7057
|
+
metaList = /* @__PURE__ */ new Map();
|
|
7058
|
+
ReflectUtils.defineMetadata(ATTRIBUTE_APPLY_METADATA_KEY, metaList, constructor);
|
|
7059
|
+
}
|
|
7060
|
+
let attributeName = typeof nameOrOptions === "string" ? nameOrOptions : void 0;
|
|
7061
|
+
let finalOptions = options;
|
|
7062
|
+
if (typeof nameOrOptions === "object" && nameOrOptions !== null) {
|
|
7063
|
+
finalOptions = nameOrOptions;
|
|
7064
|
+
}
|
|
7065
|
+
metaList.set(propertyKey, {
|
|
7066
|
+
propertyKey,
|
|
7067
|
+
selector,
|
|
7068
|
+
action,
|
|
7069
|
+
options: { ...finalOptions, name: attributeName }
|
|
7070
|
+
});
|
|
7071
|
+
const original = descriptor.value;
|
|
7072
|
+
descriptor.value = async function(...args) {
|
|
7073
|
+
ensureInit2(this);
|
|
7074
|
+
const res = await original.apply(this, args);
|
|
7075
|
+
if (res !== void 0) {
|
|
7076
|
+
const win = this.ownerDocument?.defaultView || window;
|
|
7077
|
+
const host2 = this;
|
|
7078
|
+
const hostSet = { ...SwcUtils.getHelperAndHostSet(win, host2), $this: this };
|
|
7079
|
+
const r = finalOptions.root || "auto";
|
|
7080
|
+
const targetEls = [];
|
|
7081
|
+
const applyRoot = (t) => {
|
|
7082
|
+
if (!t || !(t instanceof win.HTMLElement)) return;
|
|
7083
|
+
targetEls.push(t);
|
|
7084
|
+
};
|
|
7085
|
+
if (selector === ":parentHost") applyRoot(hostSet.$parentHost);
|
|
7086
|
+
else if (selector === ":appHost") applyRoot(hostSet.$appHost);
|
|
7087
|
+
else if (selector === ":firstHost") applyRoot(hostSet.$firstHost);
|
|
7088
|
+
else if (selector === ":lastHost") applyRoot(hostSet.$lastHost);
|
|
7089
|
+
else if (selector === ":firstAppHost") applyRoot(hostSet.$firstAppHost);
|
|
7090
|
+
else if (selector === ":lastAppHost") applyRoot(hostSet.$lastAppHost);
|
|
7091
|
+
else if (selector === ":hosts") hostSet.$hosts.forEach(applyRoot);
|
|
7092
|
+
else if (selector === ":appHosts") hostSet.$appHosts.forEach(applyRoot);
|
|
7093
|
+
else if (selector === ":host" || !selector) applyRoot(host2);
|
|
7094
|
+
else {
|
|
7095
|
+
const targetRoot = r === "auto" ? host2.shadowRoot || host2 : r === "shadow" ? host2.shadowRoot : host2;
|
|
7096
|
+
if (targetRoot) {
|
|
7097
|
+
const found = targetRoot.querySelectorAll(selector);
|
|
7098
|
+
if (found) targetEls.push(...Array.from(found));
|
|
7099
|
+
}
|
|
7100
|
+
}
|
|
7101
|
+
targetEls.forEach((targetEl) => {
|
|
7102
|
+
const resolvedRes = typeof res === "function" ? res(targetEl, hostSet) : res;
|
|
7103
|
+
if (action === "set" || action === "update") {
|
|
7104
|
+
if (attributeName) {
|
|
7105
|
+
if (resolvedRes === null || resolvedRes === void 0 || resolvedRes === false) {
|
|
7106
|
+
targetEl.removeAttribute(attributeName);
|
|
7107
|
+
} else {
|
|
7108
|
+
targetEl.setAttribute(attributeName, resolvedRes === true ? "" : String(resolvedRes));
|
|
7109
|
+
}
|
|
7110
|
+
} else if (typeof resolvedRes === "object" && resolvedRes !== null && !Array.isArray(resolvedRes)) {
|
|
7111
|
+
Object.entries(resolvedRes).forEach(([attr, val]) => {
|
|
7112
|
+
const finalVal = typeof val === "function" ? val(targetEl, hostSet) : val;
|
|
7113
|
+
if (finalVal === null || finalVal === void 0 || finalVal === false) {
|
|
7114
|
+
targetEl.removeAttribute(attr);
|
|
7115
|
+
} else {
|
|
7116
|
+
targetEl.setAttribute(attr, finalVal === true ? "" : String(finalVal));
|
|
7117
|
+
}
|
|
7118
|
+
});
|
|
7119
|
+
}
|
|
7120
|
+
} else if (action === "remove") {
|
|
7121
|
+
if (attributeName) {
|
|
7122
|
+
targetEl.removeAttribute(attributeName);
|
|
7123
|
+
} else if (typeof resolvedRes === "object" && resolvedRes !== null && !Array.isArray(resolvedRes)) {
|
|
7124
|
+
Object.entries(resolvedRes).forEach(([attr, val]) => {
|
|
7125
|
+
const shouldRemove = typeof val === "function" ? val(targetEl, hostSet) : !!val;
|
|
7126
|
+
if (shouldRemove) targetEl.removeAttribute(attr);
|
|
7127
|
+
});
|
|
7128
|
+
} else {
|
|
7129
|
+
const attrs = Array.isArray(resolvedRes) ? resolvedRes : [resolvedRes];
|
|
7130
|
+
attrs.forEach((a) => targetEl.removeAttribute(String(a)));
|
|
7131
|
+
}
|
|
7132
|
+
}
|
|
7133
|
+
});
|
|
7134
|
+
}
|
|
7135
|
+
return res;
|
|
7136
|
+
};
|
|
7137
|
+
return descriptor;
|
|
7138
|
+
};
|
|
7139
|
+
};
|
|
7140
|
+
}
|
|
7141
|
+
function applyAttribute(selector, action = "update", options = {}) {
|
|
7142
|
+
return createAttributeDecorator(action)(selector, options);
|
|
7143
|
+
}
|
|
7144
|
+
var setAttribute = (selector, nameOrOptions, options = {}) => createAttributeDecorator("set")(selector, nameOrOptions, options);
|
|
7145
|
+
var updateAttribute = (selector, nameOrOptions, options = {}) => createAttributeDecorator("update")(selector, nameOrOptions, options);
|
|
7146
|
+
var removeAttribute = (selector, nameOrOptions, options = {}) => createAttributeDecorator("remove")(selector, nameOrOptions, options);
|
|
7147
|
+
function applyAttributeHost(action = "update", options = {}) {
|
|
7148
|
+
return createAttributeDecorator(action)(":host", options);
|
|
7149
|
+
}
|
|
7150
|
+
var setAttributeHost = (nameOrOptions, options = {}) => createAttributeDecorator("set")(":host", nameOrOptions, options);
|
|
7151
|
+
var updateAttributeHost = (nameOrOptions, options = {}) => createAttributeDecorator("update")(":host", nameOrOptions, options);
|
|
7152
|
+
var removeAttributeHost = (nameOrOptions, options = {}) => createAttributeDecorator("remove")(":host", nameOrOptions, options);
|
|
7153
|
+
var findAllAttributeApplyMetadata = (target) => {
|
|
7154
|
+
const result = /* @__PURE__ */ new Map();
|
|
7155
|
+
const maps = ReflectUtils.findAllMetadata(ATTRIBUTE_APPLY_METADATA_KEY, target);
|
|
7156
|
+
maps.forEach((map) => {
|
|
7157
|
+
if (map instanceof Map) {
|
|
7158
|
+
map.forEach((v, k) => result.set(k, v));
|
|
7159
|
+
}
|
|
7160
|
+
});
|
|
7161
|
+
return result;
|
|
7162
|
+
};
|
|
7163
|
+
|
|
6879
7164
|
// src/utils/Utils.ts
|
|
6880
|
-
var SWC_NOT_FOUND = Symbol("
|
|
7165
|
+
var SWC_NOT_FOUND = Symbol.for("simple-web-component:not-found");
|
|
6881
7166
|
var htmlFragment = (html, doc) => {
|
|
6882
7167
|
const d = doc || (typeof document !== "undefined" ? document : void 0);
|
|
6883
7168
|
if (!d) throw new Error("Document is not available");
|
|
@@ -7114,7 +7399,7 @@ var SwcUtils;
|
|
|
7114
7399
|
})(SwcUtils || (SwcUtils = {}));
|
|
7115
7400
|
|
|
7116
7401
|
// src/decorators/emitCustomEvent.ts
|
|
7117
|
-
var EMIT_CUSTOM_EVENT_METADATA_KEY = Symbol("simple-web-component:emit-custom-event");
|
|
7402
|
+
var EMIT_CUSTOM_EVENT_METADATA_KEY = Symbol.for("simple-web-component:emit-custom-event");
|
|
7118
7403
|
function emitCustomEvent(selectorOrTarget, type, options = {}) {
|
|
7119
7404
|
return (targetObj, propertyKey, descriptor) => {
|
|
7120
7405
|
const constructor = targetObj.constructor;
|
|
@@ -7183,7 +7468,10 @@ var getEmitCustomEventMetadataList = (target) => {
|
|
|
7183
7468
|
const constructor = target instanceof Function ? target : target.constructor;
|
|
7184
7469
|
return ReflectUtils.getMetadata(EMIT_CUSTOM_EVENT_METADATA_KEY, constructor);
|
|
7185
7470
|
};
|
|
7186
|
-
function emitCustomEventHost(type, options) {
|
|
7471
|
+
function emitCustomEventHost(type, options = {}) {
|
|
7472
|
+
if (!options.attributeName) {
|
|
7473
|
+
options.attributeName = `on-emit-${type}`;
|
|
7474
|
+
}
|
|
7187
7475
|
return emitCustomEvent(":host", type, options);
|
|
7188
7476
|
}
|
|
7189
7477
|
|
|
@@ -7275,7 +7563,46 @@ var SituationTypeContainers = class {
|
|
|
7275
7563
|
return this.containers.find(predicate);
|
|
7276
7564
|
}
|
|
7277
7565
|
};
|
|
7566
|
+
var isTargetSymbol = (config) => {
|
|
7567
|
+
return "symbol" in config && config.symbol !== void 0;
|
|
7568
|
+
};
|
|
7569
|
+
var isTargetType = (config) => {
|
|
7570
|
+
return "type" in config && config.type !== void 0;
|
|
7571
|
+
};
|
|
7572
|
+
var isTargetScheme = (config) => {
|
|
7573
|
+
return "scheme" in config && config.scheme !== void 0;
|
|
7574
|
+
};
|
|
7575
|
+
var isTargetFactory = (config) => {
|
|
7576
|
+
return "factory" in config && typeof config.factory === "function" && !("symbol" in config) && !("type" in config) && !("scheme" in config);
|
|
7577
|
+
};
|
|
7278
7578
|
var InjectMetadataKey = Symbol("Inject");
|
|
7579
|
+
var injectProcess = (config, target, propertyKey, parameterIndex) => {
|
|
7580
|
+
if (propertyKey && typeof target === "object") {
|
|
7581
|
+
const otarget = target;
|
|
7582
|
+
target = target.constructor;
|
|
7583
|
+
const saves = Reflect.getOwnMetadata(InjectMetadataKey, target, propertyKey) || [];
|
|
7584
|
+
const type = ReflectUtils.getParameterTypes(otarget, propertyKey)[parameterIndex];
|
|
7585
|
+
saves.push({ index: parameterIndex, config, propertyKey, type });
|
|
7586
|
+
ReflectUtils.defineMetadata(InjectMetadataKey, saves, target, propertyKey);
|
|
7587
|
+
} else if (!propertyKey || typeof target === "function") {
|
|
7588
|
+
const existingInjectdParameters = ReflectUtils.getMetadata(InjectMetadataKey, target) || [];
|
|
7589
|
+
const type = ReflectUtils.getParameterTypes(target)[parameterIndex];
|
|
7590
|
+
existingInjectdParameters.push({ index: parameterIndex, config, type });
|
|
7591
|
+
ReflectUtils.defineMetadata(InjectMetadataKey, existingInjectdParameters, target);
|
|
7592
|
+
}
|
|
7593
|
+
};
|
|
7594
|
+
function Inject(configOrTarget, propertyKey, parameterIndex) {
|
|
7595
|
+
if (propertyKey && parameterIndex !== void 0) {
|
|
7596
|
+
injectProcess({}, configOrTarget, propertyKey, parameterIndex);
|
|
7597
|
+
} else {
|
|
7598
|
+
return (target, propertyKey2, parameterIndex2) => {
|
|
7599
|
+
injectProcess(configOrTarget, target, propertyKey2, parameterIndex2);
|
|
7600
|
+
};
|
|
7601
|
+
}
|
|
7602
|
+
}
|
|
7603
|
+
var getInject = (target, propertyKey) => {
|
|
7604
|
+
return ReflectUtils.findMetadata(InjectMetadataKey, target, propertyKey) ?? [];
|
|
7605
|
+
};
|
|
7279
7606
|
|
|
7280
7607
|
// src/types.ts
|
|
7281
7608
|
var InjectSituationType = /* @__PURE__ */ ((InjectSituationType2) => {
|
|
@@ -7293,7 +7620,7 @@ var InjectSituationType = /* @__PURE__ */ ((InjectSituationType2) => {
|
|
|
7293
7620
|
})(InjectSituationType || {});
|
|
7294
7621
|
|
|
7295
7622
|
// src/decorators/elementDefine.ts
|
|
7296
|
-
var ELEMENT_CONFIG_KEY = Symbol("simple-web-component:element-config");
|
|
7623
|
+
var ELEMENT_CONFIG_KEY = Symbol.for("simple-web-component:element-config");
|
|
7297
7624
|
var getElementConfig = (target) => {
|
|
7298
7625
|
const constructor = target instanceof Function ? target : target.constructor;
|
|
7299
7626
|
return ReflectUtils.getMetadata(ELEMENT_CONFIG_KEY, constructor);
|
|
@@ -7408,7 +7735,6 @@ var setupPrototype = (proto) => {
|
|
|
7408
7735
|
const oldHandler = handlers.get(attrName);
|
|
7409
7736
|
if (oldHandler) el.removeEventListener(eventName, oldHandler);
|
|
7410
7737
|
const handler = async (event) => {
|
|
7411
|
-
console.log("execute handler", event);
|
|
7412
7738
|
const parent = SwcUtils.findNearestSwcHost(el);
|
|
7413
7739
|
const hostSet = SwcUtils.getHostSet(parent || el);
|
|
7414
7740
|
const conf = getElementConfig(this);
|
|
@@ -7429,7 +7755,6 @@ var setupPrototype = (proto) => {
|
|
|
7429
7755
|
};
|
|
7430
7756
|
proto.__swc_executeAttributeEvent = async function(el, attrName, script, event) {
|
|
7431
7757
|
ensureInit2(this);
|
|
7432
|
-
console.log("execute handler2", event);
|
|
7433
7758
|
const parent = SwcUtils.findNearestSwcHost(el);
|
|
7434
7759
|
const hostSet = SwcUtils.getHostSet(parent || el);
|
|
7435
7760
|
const conf = getElementConfig(this);
|
|
@@ -7469,12 +7794,22 @@ var elementDefine = (name, config = {}) => (constructor) => {
|
|
|
7469
7794
|
const emitCustomEventList = getEmitCustomEventMetadataList(constructor) || [];
|
|
7470
7795
|
const emitHostCustomEventList = emitCustomEventList.filter((meta) => meta.selector === ":host" || meta.selector === "");
|
|
7471
7796
|
const addEventListenerList = getAddEventListenerMetadata(constructor) || [];
|
|
7472
|
-
const addHostEventListenerList = addEventListenerList.filter((meta) => meta.selector === ":host" || meta.selector === "");
|
|
7473
7797
|
const attrChangeMap = findAllAttributeChangedMetadata(constructor);
|
|
7474
7798
|
const attributeList = findAllAttributeMetadata(constructor);
|
|
7799
|
+
const applyAttributeMap = findAllAttributeApplyMetadata(constructor);
|
|
7475
7800
|
const swcLifecycleAttributes = ["swc-on-constructor", "swc-on-connected", "swc-on-disconnected", "swc-on-before-connected", "swc-on-after-connected", "swc-on-before-disconnected", "swc-on-after-disconnected", "swc-on-before-adopted", "swc-on-after-adopted", "swc-on-attribute-changed"];
|
|
7476
7801
|
const swcOnEvents = DOM_EVENT_NAMES.map((e) => `swc-on-${e}`);
|
|
7477
|
-
const
|
|
7802
|
+
const attributeApplyNames = Array.from(applyAttributeMap.values()).map((it) => it.options.name).filter(Boolean);
|
|
7803
|
+
const attributeListNames = attributeList.map((it) => it.options.name || String(it.propertyKey));
|
|
7804
|
+
const mergedObservedAttributes = [.../* @__PURE__ */ new Set([
|
|
7805
|
+
...metadata.observedAttributes ?? [],
|
|
7806
|
+
...attrChangeMap.keys(),
|
|
7807
|
+
...attributeApplyNames,
|
|
7808
|
+
...attributeListNames,
|
|
7809
|
+
...emitHostCustomEventList.map((it) => it.options.attributeName).filter(Boolean),
|
|
7810
|
+
...swcLifecycleAttributes,
|
|
7811
|
+
...swcOnEvents
|
|
7812
|
+
])];
|
|
7478
7813
|
const connectedInnerHtmlList = getOnConnectedInnerHtmlMetadata(constructor) || [];
|
|
7479
7814
|
const proto = constructor.prototype;
|
|
7480
7815
|
setupPrototype(proto);
|
|
@@ -7493,7 +7828,6 @@ var elementDefine = (name, config = {}) => (constructor) => {
|
|
|
7493
7828
|
for (const m of bMethods) this._invokeLifecycleMethod(m, hostSet);
|
|
7494
7829
|
}
|
|
7495
7830
|
attributeList.forEach((meta) => {
|
|
7496
|
-
const attrName = meta.options.name || String(meta.propertyKey);
|
|
7497
7831
|
if (meta.options.connectedInitialize === true) {
|
|
7498
7832
|
this.__swc_syncing_init = true;
|
|
7499
7833
|
try {
|
|
@@ -7633,22 +7967,6 @@ var elementDefine = (name, config = {}) => (constructor) => {
|
|
|
7633
7967
|
}
|
|
7634
7968
|
});
|
|
7635
7969
|
});
|
|
7636
|
-
addHostEventListenerList.forEach((meta) => {
|
|
7637
|
-
const { type, options } = meta;
|
|
7638
|
-
const opts = { capture: options.capture, once: options.once, passive: options.passive };
|
|
7639
|
-
const handler = async (event) => {
|
|
7640
|
-
if (options.stopPropagation) event.stopPropagation();
|
|
7641
|
-
if (options.stopImmediatePropagation) event.stopImmediatePropagation();
|
|
7642
|
-
if (options.preventDefault) event.preventDefault();
|
|
7643
|
-
const currentHostSet = SwcUtils.getHostSet(this);
|
|
7644
|
-
const args = { event, ...currentHostSet, $el: this, $root: this.getRootNode() };
|
|
7645
|
-
await this[meta.propertyKey](event, currentHostSet, args);
|
|
7646
|
-
};
|
|
7647
|
-
this.addEventListener(type, handler, opts);
|
|
7648
|
-
if (options.removeOnDisconnected === true) {
|
|
7649
|
-
this._boundListeners.push({ target: this, type, handler, options: opts });
|
|
7650
|
-
}
|
|
7651
|
-
});
|
|
7652
7970
|
if (originalConnected) originalConnected.apply(this);
|
|
7653
7971
|
const aMethods = findAllLifecycleMetadata(this, ON_AFTER_CONNECTED_METADATA_KEY);
|
|
7654
7972
|
if (aMethods) {
|
|
@@ -7726,100 +8044,1680 @@ var elementDefine = (name, config = {}) => (constructor) => {
|
|
|
7726
8044
|
return constructor;
|
|
7727
8045
|
};
|
|
7728
8046
|
|
|
8047
|
+
// ../simple-boot/dist/esm/throwable/SimError.js
|
|
8048
|
+
var SimError = class {
|
|
8049
|
+
constructor(message, name, stack) {
|
|
8050
|
+
this.message = message;
|
|
8051
|
+
this.name = name;
|
|
8052
|
+
this.stack = stack;
|
|
8053
|
+
}
|
|
8054
|
+
};
|
|
8055
|
+
|
|
8056
|
+
// ../simple-boot/dist/esm/throwable/SimNoSuch.js
|
|
8057
|
+
var SimNoSuch = class extends SimError {
|
|
8058
|
+
constructor(message, name, stack) {
|
|
8059
|
+
super(message, name, stack);
|
|
8060
|
+
}
|
|
8061
|
+
};
|
|
8062
|
+
|
|
7729
8063
|
// ../simple-boot/dist/esm/decorators/SimDecorator.js
|
|
8064
|
+
var Lifecycle = /* @__PURE__ */ ((Lifecycle2) => {
|
|
8065
|
+
Lifecycle2["Singleton"] = "Singleton";
|
|
8066
|
+
Lifecycle2["Transient"] = "Transient";
|
|
8067
|
+
return Lifecycle2;
|
|
8068
|
+
})(Lifecycle || {});
|
|
8069
|
+
var sims = /* @__PURE__ */ new Map();
|
|
8070
|
+
var containers = /* @__PURE__ */ new Set();
|
|
7730
8071
|
var SimMetadataKey = Symbol("Sim");
|
|
8072
|
+
var isNotNullObjetInstance = (target) => target != null && target !== void 0 && typeof target === "object";
|
|
8073
|
+
var simProcess = (config, inputTarget) => {
|
|
8074
|
+
const target = (() => {
|
|
8075
|
+
if (typeof inputTarget === "object") {
|
|
8076
|
+
return config.scope === "Singleton" ? inputTarget : ValidUtils.isPlainObject(inputTarget) ? { ...inputTarget } : inputTarget;
|
|
8077
|
+
}
|
|
8078
|
+
if (ValidUtils.isArrowFunction(inputTarget)) {
|
|
8079
|
+
return () => inputTarget();
|
|
8080
|
+
}
|
|
8081
|
+
return inputTarget;
|
|
8082
|
+
})();
|
|
8083
|
+
let targetType;
|
|
8084
|
+
if (isNotNullObjetInstance(target)) {
|
|
8085
|
+
targetType = target.constructor;
|
|
8086
|
+
} else {
|
|
8087
|
+
targetType = target;
|
|
8088
|
+
}
|
|
8089
|
+
config.scope = config?.scope ?? "Singleton";
|
|
8090
|
+
ReflectUtils.defineMetadata(SimMetadataKey, config, targetType);
|
|
8091
|
+
const adding = (targetKey, target2 = targetKey) => {
|
|
8092
|
+
const items = sims.get(targetKey) ?? /* @__PURE__ */ new Set();
|
|
8093
|
+
items.add(target2);
|
|
8094
|
+
sims.set(targetKey, items);
|
|
8095
|
+
};
|
|
8096
|
+
if (Array.isArray(config?.type)) {
|
|
8097
|
+
config?.type.forEach((it) => {
|
|
8098
|
+
adding(it, target);
|
|
8099
|
+
});
|
|
8100
|
+
} else if (config.type) {
|
|
8101
|
+
adding(config?.type, target);
|
|
8102
|
+
} else {
|
|
8103
|
+
adding(target);
|
|
8104
|
+
}
|
|
8105
|
+
};
|
|
8106
|
+
function Sim(configOrTarget) {
|
|
8107
|
+
if (typeof configOrTarget === "function") {
|
|
8108
|
+
simProcess({}, configOrTarget);
|
|
8109
|
+
} else {
|
|
8110
|
+
return (target) => {
|
|
8111
|
+
simProcess(configOrTarget, target);
|
|
8112
|
+
};
|
|
8113
|
+
}
|
|
8114
|
+
}
|
|
8115
|
+
var getSim = (target) => {
|
|
8116
|
+
if (target != null && target !== void 0 && typeof target === "object") {
|
|
8117
|
+
target = Object.getPrototypeOf(target).constructor;
|
|
8118
|
+
}
|
|
8119
|
+
try {
|
|
8120
|
+
return ReflectUtils.getMetadata(SimMetadataKey, target);
|
|
8121
|
+
} catch (e) {
|
|
8122
|
+
}
|
|
8123
|
+
};
|
|
7731
8124
|
var PostConstructMetadataKey = Symbol("PostConstruct");
|
|
8125
|
+
var getPostConstructs = (target) => {
|
|
8126
|
+
return ReflectUtils.getMetadata(PostConstructMetadataKey, target) ?? [];
|
|
8127
|
+
};
|
|
8128
|
+
|
|
8129
|
+
// ../simple-boot/dist/esm/simstance/SimAtomic.js
|
|
8130
|
+
var SimAtomic = class {
|
|
8131
|
+
constructor(type, simstanceManager, config) {
|
|
8132
|
+
this.type = type;
|
|
8133
|
+
this.simstanceManager = simstanceManager;
|
|
8134
|
+
this.config = config;
|
|
8135
|
+
this.value = type.value;
|
|
8136
|
+
}
|
|
8137
|
+
getConfig(key = SimMetadataKey) {
|
|
8138
|
+
return ReflectUtils.getMetadata(key, this.type.originalType);
|
|
8139
|
+
}
|
|
8140
|
+
getConfigs() {
|
|
8141
|
+
return ReflectUtils.getMetadatas(this.type.originalType);
|
|
8142
|
+
}
|
|
8143
|
+
getValue(config) {
|
|
8144
|
+
if (config?.refresh) {
|
|
8145
|
+
this.value = void 0;
|
|
8146
|
+
}
|
|
8147
|
+
if (!this.value) {
|
|
8148
|
+
if (typeof this.type.targetKeyType === "symbol") {
|
|
8149
|
+
this.value = this.simstanceManager.findFirstSim(this.type.targetKeyType)?.getValue();
|
|
8150
|
+
} else {
|
|
8151
|
+
this.value = this.simstanceManager.getOrNewSim({ target: this.type.targetKeyType, originTypeTarget: this.type.originalType, newInstanceCarrier: config?.newInstanceCarrier });
|
|
8152
|
+
}
|
|
8153
|
+
}
|
|
8154
|
+
return this.value;
|
|
8155
|
+
}
|
|
8156
|
+
};
|
|
8157
|
+
|
|
8158
|
+
// ../simple-boot/dist/esm/SimOption.js
|
|
8159
|
+
var SimOption = class {
|
|
8160
|
+
constructor({ rootRouter, container, cache, advice = [], excludeProxys, proxy, using } = {}) {
|
|
8161
|
+
this.rootRouter = rootRouter;
|
|
8162
|
+
this.container = container;
|
|
8163
|
+
this.advice = advice;
|
|
8164
|
+
this.excludeProxys = excludeProxys;
|
|
8165
|
+
this.proxy = proxy;
|
|
8166
|
+
this.using = using;
|
|
8167
|
+
this.cache = cache;
|
|
8168
|
+
}
|
|
8169
|
+
addAdvicce(advice) {
|
|
8170
|
+
this.advice ?? (this.advice = []);
|
|
8171
|
+
this.advice.push(advice);
|
|
8172
|
+
}
|
|
8173
|
+
setAdvice(...advice) {
|
|
8174
|
+
this.advice = advice;
|
|
8175
|
+
return this;
|
|
8176
|
+
}
|
|
8177
|
+
};
|
|
8178
|
+
|
|
8179
|
+
// ../simple-boot/dist/esm/decorators/MetaDataAtomic.js
|
|
8180
|
+
var MetaDataAtomic = class {
|
|
8181
|
+
constructor(target, metaData) {
|
|
8182
|
+
this.target = target;
|
|
8183
|
+
this.metaData = metaData;
|
|
8184
|
+
}
|
|
8185
|
+
};
|
|
8186
|
+
var MetaDataPropertyAtomic = class extends MetaDataAtomic {
|
|
8187
|
+
constructor(target, metaData, property, parameter) {
|
|
8188
|
+
super(target, metaData);
|
|
8189
|
+
this.property = property;
|
|
8190
|
+
this.parameter = parameter;
|
|
8191
|
+
}
|
|
8192
|
+
call(...parameter) {
|
|
8193
|
+
return this.target[this.property](...parameter);
|
|
8194
|
+
}
|
|
8195
|
+
};
|
|
7732
8196
|
|
|
7733
8197
|
// ../simple-boot/dist/esm/decorators/aop/AOPDecorator.js
|
|
7734
8198
|
var AfterMetadataKey = Symbol("After");
|
|
7735
8199
|
var BeforeMetadataKey = Symbol("Before");
|
|
7736
8200
|
var AroundMetadataKey = Symbol("Around");
|
|
8201
|
+
var getAfter = (target, propertyKey) => {
|
|
8202
|
+
return ReflectUtils.getMetadata(AfterMetadataKey, target, propertyKey);
|
|
8203
|
+
};
|
|
8204
|
+
var getAfters = (target) => {
|
|
8205
|
+
return ObjectUtils.allProtoTypeName(target).map((it) => new MetaDataPropertyAtomic(target, getAfter(target, it), it)).filter((it) => it.metaData !== void 0) || [];
|
|
8206
|
+
};
|
|
8207
|
+
var getProtoAfters = (target, propertyKey, type) => {
|
|
8208
|
+
return getAfters(target).filter((it) => propertyKey === it.metaData?.property && type === it.metaData.type?.prototype) || [];
|
|
8209
|
+
};
|
|
8210
|
+
var getBefore = (target, propertyKey) => {
|
|
8211
|
+
return ReflectUtils.getMetadata(BeforeMetadataKey, target, propertyKey);
|
|
8212
|
+
};
|
|
8213
|
+
var getBefores = (target) => {
|
|
8214
|
+
return ObjectUtils.allProtoTypeName(target).map((it) => new MetaDataPropertyAtomic(target, getBefore(target, it), it)).filter((it) => it.metaData !== void 0) || [];
|
|
8215
|
+
};
|
|
8216
|
+
var getProtoBefores = (target, propertyKey, type) => {
|
|
8217
|
+
return getBefores(target).filter((it) => propertyKey === it.metaData?.property && type === it.metaData.type?.prototype) || [];
|
|
8218
|
+
};
|
|
7737
8219
|
|
|
7738
8220
|
// ../simple-boot/dist/esm/decorators/exception/ExceptionDecorator.js
|
|
8221
|
+
var ExceptionHandlerSituationType = /* @__PURE__ */ ((ExceptionHandlerSituationType2) => {
|
|
8222
|
+
ExceptionHandlerSituationType2["ERROR_OBJECT"] = "SIMPLE_BOOT_CORE://ExceptionHandler/ERROR_OBJECT";
|
|
8223
|
+
ExceptionHandlerSituationType2["PARAMETER"] = "SIMPLE_BOOT_CORE://ExceptionHandler/PARAMETER";
|
|
8224
|
+
return ExceptionHandlerSituationType2;
|
|
8225
|
+
})(ExceptionHandlerSituationType || {});
|
|
7739
8226
|
var ExceptionHandlerMetadataKey = Symbol("ExceptionHandler");
|
|
8227
|
+
var getExceptionHandlers = (target) => {
|
|
8228
|
+
if (target !== null && void 0 !== target && typeof target === "object") {
|
|
8229
|
+
target = target.constructor;
|
|
8230
|
+
}
|
|
8231
|
+
return ReflectUtils.getMetadata(ExceptionHandlerMetadataKey, target);
|
|
8232
|
+
};
|
|
8233
|
+
var targetExceptionHandlers = (target, error) => {
|
|
8234
|
+
const exceptionHandlers = getExceptionHandlers(target);
|
|
8235
|
+
const emptyTargets = exceptionHandlers?.filter((it) => it.config.type === void 0);
|
|
8236
|
+
const targets = exceptionHandlers?.filter((it) => ObjectUtils.isPrototypeOfTarget(it.config.type, error));
|
|
8237
|
+
const targetSorts = targets?.sort((a, b) => {
|
|
8238
|
+
const aPrototypeOfDepth = ObjectUtils.prototypeOfDepth(error, a.config.type);
|
|
8239
|
+
const bPrototypeOfDepth = ObjectUtils.prototypeOfDepth(error, b.config.type);
|
|
8240
|
+
return aPrototypeOfDepth.length - bPrototypeOfDepth.length;
|
|
8241
|
+
});
|
|
8242
|
+
return (targetSorts ?? []).concat(...emptyTargets ?? []);
|
|
8243
|
+
};
|
|
8244
|
+
var targetExceptionHandler = (target, error, excludeMethods = []) => {
|
|
8245
|
+
let exceptionHandlers = targetExceptionHandlers(target, error);
|
|
8246
|
+
exceptionHandlers = exceptionHandlers?.filter((it) => !excludeMethods.includes(it.method));
|
|
8247
|
+
if (exceptionHandlers && exceptionHandlers.length > 0) {
|
|
8248
|
+
return exceptionHandlers[0];
|
|
8249
|
+
} else {
|
|
8250
|
+
return void 0;
|
|
8251
|
+
}
|
|
8252
|
+
};
|
|
7740
8253
|
|
|
7741
|
-
// ../simple-boot/dist/esm/
|
|
7742
|
-
var
|
|
7743
|
-
|
|
7744
|
-
|
|
7745
|
-
|
|
7746
|
-
|
|
7747
|
-
|
|
7748
|
-
|
|
7749
|
-
|
|
7750
|
-
|
|
7751
|
-
|
|
7752
|
-
|
|
7753
|
-
|
|
7754
|
-
|
|
7755
|
-
|
|
7756
|
-
|
|
7757
|
-
|
|
7758
|
-
|
|
7759
|
-
|
|
7760
|
-
RouterAction2.isHasActivate = (obj) => {
|
|
7761
|
-
return typeof obj?.hasActivate === "function";
|
|
7762
|
-
};
|
|
7763
|
-
})(RouterAction || (RouterAction = {}));
|
|
7764
|
-
|
|
7765
|
-
// ../core-web/dist/esm/element/CanvasUtils.js
|
|
7766
|
-
var CanvasUtils;
|
|
7767
|
-
((CanvasUtils2) => {
|
|
7768
|
-
let Context2D;
|
|
7769
|
-
((Context2D2) => {
|
|
7770
|
-
Context2D2.resetTransform = (context) => {
|
|
7771
|
-
context.setTransform(1, 0, 0, 1, 0, 0);
|
|
7772
|
-
};
|
|
7773
|
-
})(Context2D = CanvasUtils2.Context2D || (CanvasUtils2.Context2D = {}));
|
|
7774
|
-
CanvasUtils2.fontSize = (ctx, config) => {
|
|
7775
|
-
const { text, maxWidth, maxHeight, fontOption } = config;
|
|
7776
|
-
if (!text || maxWidth <= 0 || maxHeight <= 0) {
|
|
7777
|
-
return 0;
|
|
8254
|
+
// ../simple-boot/dist/esm/proxy/SimProxyHandler.js
|
|
8255
|
+
var SimProxyHandler = class {
|
|
8256
|
+
constructor(simpleApplication, simstanceManager, simOption) {
|
|
8257
|
+
this.simpleApplication = simpleApplication;
|
|
8258
|
+
this.simstanceManager = simstanceManager;
|
|
8259
|
+
this.simOption = simOption;
|
|
8260
|
+
}
|
|
8261
|
+
// 잘받게 해놨네 ㅋㅋ simstanceManager
|
|
8262
|
+
get(target, name) {
|
|
8263
|
+
if (name === "_SimpleBoot_application") {
|
|
8264
|
+
return this.simpleApplication;
|
|
8265
|
+
} else if (name === "_SimpleBoot_simstanceManager") {
|
|
8266
|
+
return this.simstanceManager;
|
|
8267
|
+
} else if (name === "_SimpleBoot_simOption") {
|
|
8268
|
+
return this.simOption;
|
|
8269
|
+
} else if (name === "_SimpleBoot_origin") {
|
|
8270
|
+
return target;
|
|
8271
|
+
} else {
|
|
8272
|
+
return target[name];
|
|
7778
8273
|
}
|
|
7779
|
-
|
|
7780
|
-
|
|
7781
|
-
|
|
8274
|
+
}
|
|
8275
|
+
set(obj, prop, value, receiver) {
|
|
8276
|
+
value = this.simstanceManager?.proxy(value);
|
|
8277
|
+
obj[prop] = value;
|
|
8278
|
+
return true;
|
|
8279
|
+
}
|
|
8280
|
+
apply(target, thisArg, argumentsList) {
|
|
8281
|
+
let r;
|
|
8282
|
+
try {
|
|
8283
|
+
this.aopBefore(thisArg, target);
|
|
8284
|
+
try {
|
|
8285
|
+
r = Reflect.apply(target, thisArg, argumentsList);
|
|
8286
|
+
} catch (e) {
|
|
8287
|
+
throw e;
|
|
8288
|
+
} finally {
|
|
8289
|
+
this.aopAfter(thisArg, target);
|
|
8290
|
+
}
|
|
8291
|
+
} catch (e) {
|
|
8292
|
+
console.error(e);
|
|
8293
|
+
const inHandlers = this.getExceptionHandler(e, thisArg, target);
|
|
8294
|
+
if (inHandlers.length > 0 && inHandlers[0]) {
|
|
8295
|
+
const inHandler = inHandlers[0];
|
|
8296
|
+
this.executeExceptionHandler(e, inHandler, argumentsList);
|
|
8297
|
+
} else {
|
|
8298
|
+
throw e;
|
|
8299
|
+
}
|
|
7782
8300
|
}
|
|
7783
|
-
|
|
7784
|
-
|
|
7785
|
-
|
|
7786
|
-
|
|
8301
|
+
return r;
|
|
8302
|
+
}
|
|
8303
|
+
executeExceptionHandler(e, inHandler, argumentsList) {
|
|
8304
|
+
const otherStorage = /* @__PURE__ */ new Map();
|
|
8305
|
+
otherStorage.set(e.constructor, e);
|
|
8306
|
+
const situationErrorTypeContainer = new SituationTypeContainer({
|
|
8307
|
+
situationType: ExceptionHandlerSituationType.ERROR_OBJECT,
|
|
8308
|
+
data: e
|
|
8309
|
+
});
|
|
8310
|
+
const situationParameterTypeContainer = new SituationTypeContainer({
|
|
8311
|
+
situationType: ExceptionHandlerSituationType.PARAMETER,
|
|
8312
|
+
data: argumentsList
|
|
8313
|
+
});
|
|
8314
|
+
otherStorage.set(SituationTypeContainers, new SituationTypeContainers([situationErrorTypeContainer, situationParameterTypeContainer]));
|
|
8315
|
+
argumentsList?.forEach((it) => {
|
|
8316
|
+
otherStorage.set(it.constructor, it);
|
|
8317
|
+
});
|
|
8318
|
+
try {
|
|
8319
|
+
this.simstanceManager.executeBindParameterSim(
|
|
8320
|
+
{
|
|
8321
|
+
target: inHandler.thisArg,
|
|
8322
|
+
targetKey: inHandler.config.propertyKey
|
|
8323
|
+
},
|
|
8324
|
+
otherStorage
|
|
8325
|
+
);
|
|
8326
|
+
} catch (es) {
|
|
8327
|
+
e = es;
|
|
7787
8328
|
}
|
|
7788
|
-
|
|
7789
|
-
|
|
7790
|
-
|
|
7791
|
-
|
|
7792
|
-
let iteration = 0;
|
|
7793
|
-
while (minSizeForWidth <= maxSizeForWidth && iteration < maxIterations) {
|
|
7794
|
-
const midSize = Math.floor((minSizeForWidth + maxSizeForWidth) / 2);
|
|
7795
|
-
if (midSize === 0) break;
|
|
7796
|
-
ctx.font = `${fontOption?.fontWeight || "normal"} ${midSize}px ${fontOption?.fontFamily || "sans-serif"}`;
|
|
7797
|
-
const maxLineWidth = Math.max(...lines.map((line) => ctx.measureText(line).width));
|
|
7798
|
-
if (maxLineWidth <= maxWidth) {
|
|
7799
|
-
bestSizeForWidth = midSize;
|
|
7800
|
-
minSizeForWidth = midSize + 1;
|
|
7801
|
-
} else {
|
|
7802
|
-
maxSizeForWidth = midSize - 1;
|
|
8329
|
+
if (inHandler.config.config.throw) {
|
|
8330
|
+
const exceptionHandler = this.getExceptionHandler(e, inHandler.thisArg, inHandler.config.method);
|
|
8331
|
+
if ((exceptionHandler?.length ?? 0) > 0) {
|
|
8332
|
+
this.executeExceptionHandler(e, exceptionHandler[0], argumentsList);
|
|
7803
8333
|
}
|
|
7804
|
-
iteration++;
|
|
7805
8334
|
}
|
|
7806
|
-
|
|
7807
|
-
|
|
7808
|
-
|
|
7809
|
-
|
|
7810
|
-
|
|
7811
|
-
|
|
7812
|
-
|
|
7813
|
-
|
|
7814
|
-
|
|
7815
|
-
(
|
|
7816
|
-
|
|
7817
|
-
if (
|
|
7818
|
-
|
|
7819
|
-
|
|
7820
|
-
|
|
7821
|
-
|
|
7822
|
-
|
|
8335
|
+
}
|
|
8336
|
+
getExceptionHandler(e, thisArg, target) {
|
|
8337
|
+
const globalConfigSets = this.simOption.advice.map((it) => this.simstanceManager?.getOrNewSim({ target: it })).filter((it) => it).map((it) => {
|
|
8338
|
+
return { thisArg: it, config: targetExceptionHandler(it, e, [target]) };
|
|
8339
|
+
}) ?? [];
|
|
8340
|
+
const thisConfigSet = { thisArg, config: targetExceptionHandler(thisArg, e, [target]) };
|
|
8341
|
+
const inHandlers = [thisConfigSet, ...globalConfigSets].filter((it) => it && it.config);
|
|
8342
|
+
return inHandlers;
|
|
8343
|
+
}
|
|
8344
|
+
aopBefore(obj, protoType) {
|
|
8345
|
+
const propertyName = ObjectUtils.prototypeName(obj, protoType);
|
|
8346
|
+
if (propertyName && obj) {
|
|
8347
|
+
getProtoBefores(obj, propertyName).forEach((it) => {
|
|
8348
|
+
it.call(obj, protoType, propertyName);
|
|
8349
|
+
});
|
|
8350
|
+
for (let i = 0; i < this.simOption.advice.length; i++) {
|
|
8351
|
+
const sim = this.simstanceManager?.getOrNewSim({ target: this.simOption.advice[i] });
|
|
8352
|
+
const protoBefores = getProtoBefores(sim, propertyName, Object.getPrototypeOf(obj));
|
|
8353
|
+
protoBefores.forEach((it) => {
|
|
8354
|
+
it.call(obj, protoType, propertyName);
|
|
8355
|
+
});
|
|
8356
|
+
}
|
|
8357
|
+
}
|
|
8358
|
+
}
|
|
8359
|
+
aopAfter(obj, protoType) {
|
|
8360
|
+
const propertyName = ObjectUtils.prototypeName(obj, protoType);
|
|
8361
|
+
if (propertyName) {
|
|
8362
|
+
getProtoAfters(obj, propertyName).forEach((it) => {
|
|
8363
|
+
it.call(obj, protoType, propertyName);
|
|
8364
|
+
});
|
|
8365
|
+
for (let i = 0; i < this.simOption.advice.length; i++) {
|
|
8366
|
+
const sim = this.simstanceManager?.getOrNewSim({ target: this.simOption.advice[i] });
|
|
8367
|
+
const protoBefores = getProtoAfters(sim, propertyName, Object.getPrototypeOf(obj));
|
|
8368
|
+
protoBefores.forEach((it) => {
|
|
8369
|
+
it.call(obj, protoType, propertyName);
|
|
8370
|
+
});
|
|
8371
|
+
}
|
|
8372
|
+
}
|
|
8373
|
+
}
|
|
8374
|
+
has(target, key) {
|
|
8375
|
+
if (key === "_SimpleBoot_isProxy") {
|
|
8376
|
+
return true;
|
|
8377
|
+
}
|
|
8378
|
+
return key in target;
|
|
8379
|
+
}
|
|
8380
|
+
};
|
|
8381
|
+
|
|
8382
|
+
// ../simple-boot/dist/esm/lifecycle/OnSimCreate.js
|
|
8383
|
+
var isOnSimCreate = (obj) => {
|
|
8384
|
+
return typeof obj?.onSimCreate === "function";
|
|
8385
|
+
};
|
|
8386
|
+
|
|
8387
|
+
// ../simple-boot/dist/esm/lifecycle/OnSimCreateCompleted.js
|
|
8388
|
+
var isOnSimCreateProxyCompleted = (obj) => {
|
|
8389
|
+
return typeof obj?.onSimCreateProxyCompleted === "function";
|
|
8390
|
+
};
|
|
8391
|
+
|
|
8392
|
+
// ../simple-boot/dist/esm/decorators/SimNoProxy.js
|
|
8393
|
+
var SimNoProxyKey = Symbol("Sim:NoProxy");
|
|
8394
|
+
var getSimNoProxy = (target, propertyKey) => {
|
|
8395
|
+
try {
|
|
8396
|
+
if (propertyKey === void 0) {
|
|
8397
|
+
return Reflect.getMetadata(SimNoProxyKey, target);
|
|
8398
|
+
}
|
|
8399
|
+
return Reflect.getMetadata(SimNoProxyKey, target, propertyKey);
|
|
8400
|
+
} catch (e) {
|
|
8401
|
+
return void 0;
|
|
8402
|
+
}
|
|
8403
|
+
};
|
|
8404
|
+
var isSimNoProxy = (target, propertyKey) => {
|
|
8405
|
+
if (target === null || target === void 0) {
|
|
8406
|
+
return false;
|
|
8407
|
+
}
|
|
8408
|
+
return getSimNoProxy(target, propertyKey) === true;
|
|
8409
|
+
};
|
|
8410
|
+
|
|
8411
|
+
// ../simple-boot/dist/esm/simstance/SimstanceManager.js
|
|
8412
|
+
var SimstanceManager = class _SimstanceManager {
|
|
8413
|
+
// private otherInstanceSim?: Map<ConstructorType<any> | Function, any>;
|
|
8414
|
+
constructor(simpleApplication, option) {
|
|
8415
|
+
this.simpleApplication = simpleApplication;
|
|
8416
|
+
this.option = option;
|
|
8417
|
+
this._storage = /* @__PURE__ */ new Map();
|
|
8418
|
+
this.name = "simstanceManager-" + RandomUtils.uuid4();
|
|
8419
|
+
this.setStoreSet(SimpleApplication, this.simpleApplication);
|
|
8420
|
+
this.setStoreSet(_SimstanceManager, this);
|
|
8421
|
+
this.setStoreSet(option.constructor, option);
|
|
8422
|
+
this.setStoreSet(SimOption, option);
|
|
8423
|
+
this.simProxyHandler = new SimProxyHandler(this.simpleApplication, this, option);
|
|
8424
|
+
}
|
|
8425
|
+
get storage() {
|
|
8426
|
+
return this._storage;
|
|
8427
|
+
}
|
|
8428
|
+
getSimAtomics() {
|
|
8429
|
+
const r = [];
|
|
8430
|
+
Array.from(this.storage.entries()).forEach(([targetKeyType, targetMap]) => {
|
|
8431
|
+
r.push(
|
|
8432
|
+
...Array.from(Array.from(targetMap.keys())).map(
|
|
8433
|
+
(sit) => new SimAtomic(
|
|
8434
|
+
{
|
|
8435
|
+
targetKeyType,
|
|
8436
|
+
originalType: sit
|
|
8437
|
+
},
|
|
8438
|
+
this
|
|
8439
|
+
)
|
|
8440
|
+
)
|
|
8441
|
+
);
|
|
8442
|
+
});
|
|
8443
|
+
return r;
|
|
8444
|
+
}
|
|
8445
|
+
getSimConfig(schemeOrSymbol) {
|
|
8446
|
+
const newVar = this.getSimAtomics().filter((it) => {
|
|
8447
|
+
const config = it?.getConfig();
|
|
8448
|
+
const symbols = ConvertUtils.flatArray(config?.symbol);
|
|
8449
|
+
const schemes = ConvertUtils.flatArray(config?.scheme);
|
|
8450
|
+
if (typeof schemeOrSymbol === "symbol") {
|
|
8451
|
+
return schemeOrSymbol && it && symbols.includes(schemeOrSymbol);
|
|
8452
|
+
} else if (typeof schemeOrSymbol === "string") {
|
|
8453
|
+
return schemeOrSymbol && it && schemes.includes(schemeOrSymbol);
|
|
8454
|
+
} else {
|
|
8455
|
+
return false;
|
|
8456
|
+
}
|
|
8457
|
+
}) || [];
|
|
8458
|
+
return newVar;
|
|
8459
|
+
}
|
|
8460
|
+
findSims(data) {
|
|
8461
|
+
let r = [];
|
|
8462
|
+
if (data) {
|
|
8463
|
+
const simAtomics = this.getSimAtomics();
|
|
8464
|
+
r = simAtomics.filter((it) => {
|
|
8465
|
+
let b = false;
|
|
8466
|
+
const config = it.getConfig();
|
|
8467
|
+
const symbols = ConvertUtils.flatArray(config?.symbol).filter(ValidUtils.isDefined);
|
|
8468
|
+
const schemes = ConvertUtils.flatArray(config?.scheme).filter(ValidUtils.isDefined);
|
|
8469
|
+
if (typeof data === "symbol") {
|
|
8470
|
+
b = symbols.includes(data);
|
|
8471
|
+
} else {
|
|
8472
|
+
const { scheme, type } = data;
|
|
8473
|
+
b = (scheme ? schemes.includes(scheme) : true) && (type ? it.type.targetKeyType === type : true);
|
|
8474
|
+
}
|
|
8475
|
+
return b;
|
|
8476
|
+
});
|
|
8477
|
+
}
|
|
8478
|
+
return r;
|
|
8479
|
+
}
|
|
8480
|
+
findFirstSim(data) {
|
|
8481
|
+
if (typeof data === "symbol") {
|
|
8482
|
+
return this.findSims(data)[0];
|
|
8483
|
+
} else {
|
|
8484
|
+
return this.findSims(data)[0];
|
|
8485
|
+
}
|
|
8486
|
+
}
|
|
8487
|
+
findLastSim(data) {
|
|
8488
|
+
if (typeof data === "symbol") {
|
|
8489
|
+
return this.findSims(data).reverse()[0];
|
|
8490
|
+
} else {
|
|
8491
|
+
return this.findSims(data).reverse()[0];
|
|
8492
|
+
}
|
|
8493
|
+
}
|
|
8494
|
+
flatStoreSets() {
|
|
8495
|
+
return new Map(
|
|
8496
|
+
Array.from(this.storage.values()).map((it) => Array.from(it.entries())).flat()
|
|
8497
|
+
);
|
|
8498
|
+
}
|
|
8499
|
+
getStoreSets(targetKey) {
|
|
8500
|
+
const map = this.storage.get(targetKey);
|
|
8501
|
+
const datas = (Array.from(map?.entries?.() ?? []) ?? []).reverse();
|
|
8502
|
+
return datas.map((it) => ({ type: it[0], instance: it[1] }));
|
|
8503
|
+
}
|
|
8504
|
+
getStoreSet(targetKey, target) {
|
|
8505
|
+
const sets = this.getStoreSets(targetKey);
|
|
8506
|
+
let find = sets.find((it) => it.type === target);
|
|
8507
|
+
if (!find && (!target || target === targetKey)) {
|
|
8508
|
+
find = sets.find((it) => it.instance);
|
|
8509
|
+
}
|
|
8510
|
+
if (!find?.instance) {
|
|
8511
|
+
const type = target ?? targetKey;
|
|
8512
|
+
if (typeof type === "object") {
|
|
8513
|
+
const find2 = this.storage.get(type);
|
|
8514
|
+
if (find2) {
|
|
8515
|
+
return { type, instance: type };
|
|
8516
|
+
}
|
|
8517
|
+
}
|
|
8518
|
+
const flatStoreSets = this.flatStoreSets();
|
|
8519
|
+
const data = flatStoreSets.get(type);
|
|
8520
|
+
if (data) {
|
|
8521
|
+
this.setStoreSet(targetKey, data, type);
|
|
8522
|
+
}
|
|
8523
|
+
return { type, instance: data };
|
|
8524
|
+
} else {
|
|
8525
|
+
return find;
|
|
8526
|
+
}
|
|
8527
|
+
}
|
|
8528
|
+
getStoreInstance(targetKey, target) {
|
|
8529
|
+
return this.getStoreSet(targetKey, target)?.instance;
|
|
8530
|
+
}
|
|
8531
|
+
getOrNewSim({ target, originTypeTarget = target, newInstanceCarrier }) {
|
|
8532
|
+
if (target) {
|
|
8533
|
+
const registed = this.getStoreSet(target, originTypeTarget);
|
|
8534
|
+
if (registed?.type && !registed?.instance) {
|
|
8535
|
+
return this.resolve({
|
|
8536
|
+
targetKey: target,
|
|
8537
|
+
target: originTypeTarget,
|
|
8538
|
+
newInstanceCarrier
|
|
8539
|
+
});
|
|
8540
|
+
}
|
|
8541
|
+
return registed?.instance;
|
|
8542
|
+
}
|
|
8543
|
+
}
|
|
8544
|
+
setStoreSet(targetKey, obj, target = targetKey) {
|
|
8545
|
+
const itemMap = this.storage.get(targetKey) ?? /* @__PURE__ */ new Map();
|
|
8546
|
+
itemMap.set(target, obj);
|
|
8547
|
+
this.storage.set(targetKey, itemMap);
|
|
8548
|
+
}
|
|
8549
|
+
registerStore(targetKey, regTyps) {
|
|
8550
|
+
const itemMap = this.storage.get(targetKey) ?? /* @__PURE__ */ new Map();
|
|
8551
|
+
regTyps.forEach((it) => {
|
|
8552
|
+
const { type, value } = typeof it === "object" ? { type: it.constructor, value: it } : { type: it, value: void 0 };
|
|
8553
|
+
if (!itemMap.has(type) || value !== void 0 && itemMap.get(type) === void 0) {
|
|
8554
|
+
itemMap.set(type, value);
|
|
8555
|
+
}
|
|
8556
|
+
});
|
|
8557
|
+
this.storage.set(targetKey, itemMap);
|
|
8558
|
+
}
|
|
8559
|
+
// 진입점
|
|
8560
|
+
resolve({ target, targetKey, newInstanceCarrier = { newInstances: [], depth: 0 } }) {
|
|
8561
|
+
const registed = this.getStoreSet(targetKey, target);
|
|
8562
|
+
if (registed?.instance) {
|
|
8563
|
+
return registed.instance;
|
|
8564
|
+
}
|
|
8565
|
+
if (this.storage.has(targetKey) && void 0 === registed?.instance) {
|
|
8566
|
+
newInstanceCarrier.depth++;
|
|
8567
|
+
const newSim = this.newSim({
|
|
8568
|
+
target: registed?.type ?? targetKey,
|
|
8569
|
+
newInstanceCarrier,
|
|
8570
|
+
simCreateAfter: (data) => {
|
|
8571
|
+
if (getSim(registed?.type ?? target ?? targetKey)?.scope === Lifecycle.Singleton) {
|
|
8572
|
+
this.setStoreSet(targetKey, data, target);
|
|
8573
|
+
}
|
|
8574
|
+
}
|
|
8575
|
+
});
|
|
8576
|
+
newInstanceCarrier.depth--;
|
|
8577
|
+
if (newInstanceCarrier.depth === 0) {
|
|
8578
|
+
newInstanceCarrier.newInstances.forEach((it) => {
|
|
8579
|
+
this.callBindPostConstruct(it);
|
|
8580
|
+
});
|
|
8581
|
+
}
|
|
8582
|
+
if (isOnSimCreate(newSim)) {
|
|
8583
|
+
newSim.onSimCreate();
|
|
8584
|
+
}
|
|
8585
|
+
return newSim;
|
|
8586
|
+
}
|
|
8587
|
+
const simNoSuch = new SimNoSuch("SimNoSuch: no simple instance(resolve) name:" + targetKey?.prototype?.constructor?.name + "," + targetKey);
|
|
8588
|
+
console.error(simNoSuch);
|
|
8589
|
+
throw simNoSuch;
|
|
8590
|
+
}
|
|
8591
|
+
newSim({ target, simCreateAfter, otherStorage, newInstanceCarrier }) {
|
|
8592
|
+
const parameters = this.getParameterSim({
|
|
8593
|
+
target,
|
|
8594
|
+
otherStorage,
|
|
8595
|
+
newInstanceCarrier
|
|
8596
|
+
});
|
|
8597
|
+
const r = ValidUtils.isFunction(target) && !target.prototype ? target(...parameters) : new target(...parameters);
|
|
8598
|
+
let p = this.proxy(r);
|
|
8599
|
+
const config = getSim(target);
|
|
8600
|
+
if (config?.proxy) {
|
|
8601
|
+
const proxys = (Array.isArray(config.proxy) ? config.proxy : [config.proxy]).filter(ValidUtils.isDefined);
|
|
8602
|
+
proxys.forEach((it) => {
|
|
8603
|
+
if (typeof it === "object") {
|
|
8604
|
+
p = new Proxy(p, it);
|
|
8605
|
+
} else {
|
|
8606
|
+
const simConfig = getSim(it);
|
|
8607
|
+
p = new Proxy(p, simConfig ? this.getOrNewSim({ target: it }) : this.newSim({ target: it }));
|
|
8608
|
+
}
|
|
8609
|
+
});
|
|
8610
|
+
}
|
|
8611
|
+
newInstanceCarrier?.newInstances.push(p);
|
|
8612
|
+
simCreateAfter?.(p);
|
|
8613
|
+
if (isOnSimCreateProxyCompleted(p)) {
|
|
8614
|
+
p.onSimCreateProxyCompleted(p);
|
|
8615
|
+
}
|
|
8616
|
+
return p;
|
|
8617
|
+
}
|
|
8618
|
+
callBindPostConstruct(obj) {
|
|
8619
|
+
const postConstruct = getPostConstructs(obj);
|
|
8620
|
+
postConstruct.forEach((it) => {
|
|
8621
|
+
obj[it.property](...this.getParameterSim({ target: obj, targetKey: it.property }));
|
|
8622
|
+
});
|
|
8623
|
+
}
|
|
8624
|
+
async executeBindParameterSimPromise({ target, targetKey, firstCheckMaker, parameterCount, inputParameters }, otherStorage) {
|
|
8625
|
+
const binds = this.getParameterSim({ target, targetKey, firstCheckMaker, otherStorage, parameterCount, inputParameters });
|
|
8626
|
+
if (typeof target === "object" && targetKey) {
|
|
8627
|
+
const targetMethod = target[targetKey];
|
|
8628
|
+
return targetMethod?.bind(target)?.(...binds);
|
|
8629
|
+
} else if (typeof target === "function" && !targetKey) {
|
|
8630
|
+
return new target(...binds);
|
|
8631
|
+
}
|
|
8632
|
+
}
|
|
8633
|
+
executeBindParameterSim({ target, targetKey, firstCheckMaker, parameterCount, inputParameters }, otherStorage) {
|
|
8634
|
+
const binds = this.getParameterSim({ target, targetKey, firstCheckMaker, otherStorage, parameterCount, inputParameters });
|
|
8635
|
+
if (typeof target === "object" && targetKey) {
|
|
8636
|
+
const targetMethod = target[targetKey];
|
|
8637
|
+
return targetMethod?.bind(target)?.(...binds);
|
|
8638
|
+
} else if (typeof target === "function" && !targetKey) {
|
|
8639
|
+
return new target(...binds);
|
|
8640
|
+
}
|
|
8641
|
+
}
|
|
8642
|
+
getParameterSim({ target, targetKey, firstCheckMaker, otherStorage, newInstanceCarrier, parameterCount, inputParameters = [] }) {
|
|
8643
|
+
const paramTypes = ReflectUtils.getParameterTypes(target, targetKey) || [];
|
|
8644
|
+
let injections = [];
|
|
8645
|
+
const injects = getInject(target, targetKey);
|
|
8646
|
+
const loopCount = Math.max(paramTypes.length, parameterCount ?? 0);
|
|
8647
|
+
const loopArray = new Array(loopCount).fill(void 0);
|
|
8648
|
+
injections = loopArray.map((_, idx) => {
|
|
8649
|
+
const token = paramTypes[idx];
|
|
8650
|
+
const saveInject = injects?.find((it) => it.index === idx);
|
|
8651
|
+
for (const f of firstCheckMaker ?? []) {
|
|
8652
|
+
const firstCheckObj = f({ target, targetKey }, token, idx, saveInject);
|
|
8653
|
+
if (void 0 !== firstCheckObj) {
|
|
8654
|
+
return firstCheckObj;
|
|
8655
|
+
}
|
|
8656
|
+
}
|
|
8657
|
+
if (saveInject) {
|
|
8658
|
+
const inject = saveInject.config;
|
|
8659
|
+
let obj = otherStorage?.get(token);
|
|
8660
|
+
if (token === Array && (isTargetType(inject) || isTargetScheme(inject) || isTargetSymbol(inject))) {
|
|
8661
|
+
const p = [];
|
|
8662
|
+
if (isTargetType(inject) && inject.type) {
|
|
8663
|
+
p.push(
|
|
8664
|
+
...this.getStoreSets(inject.type).map(
|
|
8665
|
+
(it) => this.resolve({
|
|
8666
|
+
targetKey: inject.type,
|
|
8667
|
+
target: it.type,
|
|
8668
|
+
newInstanceCarrier
|
|
8669
|
+
})
|
|
8670
|
+
).reverse()
|
|
8671
|
+
);
|
|
8672
|
+
}
|
|
8673
|
+
if (isTargetSymbol(inject)) {
|
|
8674
|
+
p.push(...this.getSimConfig(inject.symbol).map((it) => it.getValue({ newInstanceCarrier })));
|
|
8675
|
+
}
|
|
8676
|
+
if (isTargetScheme(inject)) {
|
|
8677
|
+
p.push(...this.getSimConfig(inject.scheme).map((it) => it.getValue({ newInstanceCarrier })));
|
|
8678
|
+
}
|
|
8679
|
+
return p;
|
|
8680
|
+
}
|
|
8681
|
+
if (inject.situationType && otherStorage) {
|
|
8682
|
+
const situations = otherStorage.get(SituationTypeContainers);
|
|
8683
|
+
const situation = otherStorage.get(SituationTypeContainer);
|
|
8684
|
+
if (inject.situationType === situation?.situationType) {
|
|
8685
|
+
obj = situation.data;
|
|
8686
|
+
} else if (situations && situations.length > 0) {
|
|
8687
|
+
const find = situations.find((a) => {
|
|
8688
|
+
if (a.index !== void 0) {
|
|
8689
|
+
return a.situationType === inject.situationType && a.index === idx;
|
|
8690
|
+
} else {
|
|
8691
|
+
return a.situationType === inject.situationType;
|
|
8692
|
+
}
|
|
8693
|
+
});
|
|
8694
|
+
if (find) {
|
|
8695
|
+
obj = find.data;
|
|
8696
|
+
}
|
|
8697
|
+
}
|
|
8698
|
+
}
|
|
8699
|
+
if (!obj) {
|
|
8700
|
+
const currentInstance = typeof target === "object" ? target : void 0;
|
|
8701
|
+
if (isTargetFactory(inject)) {
|
|
8702
|
+
obj = inject.factory({
|
|
8703
|
+
instance: currentInstance,
|
|
8704
|
+
methodName: String(targetKey),
|
|
8705
|
+
parameter: inputParameters,
|
|
8706
|
+
application: this.simpleApplication
|
|
8707
|
+
});
|
|
8708
|
+
} else {
|
|
8709
|
+
let findLastSim;
|
|
8710
|
+
if (isTargetSymbol(inject)) {
|
|
8711
|
+
findLastSim = this.findLastSim(inject.symbol);
|
|
8712
|
+
} else if (isTargetType(inject) || isTargetScheme(inject)) {
|
|
8713
|
+
findLastSim = this.findLastSim(inject);
|
|
8714
|
+
}
|
|
8715
|
+
try {
|
|
8716
|
+
obj = findLastSim ? this.resolve({
|
|
8717
|
+
targetKey: findLastSim?.type.targetKeyType ?? token,
|
|
8718
|
+
newInstanceCarrier
|
|
8719
|
+
}) : this.resolve({
|
|
8720
|
+
targetKey: token,
|
|
8721
|
+
newInstanceCarrier
|
|
8722
|
+
});
|
|
8723
|
+
if (inject.factory && obj) {
|
|
8724
|
+
if (typeof inject.factory === "function") {
|
|
8725
|
+
obj = inject.factory({
|
|
8726
|
+
instance: currentInstance,
|
|
8727
|
+
methodName: String(targetKey),
|
|
8728
|
+
parameter: inputParameters,
|
|
8729
|
+
application: this.simpleApplication,
|
|
8730
|
+
injectInstance: obj
|
|
8731
|
+
});
|
|
8732
|
+
}
|
|
8733
|
+
}
|
|
8734
|
+
} catch (e) {
|
|
8735
|
+
if (inject.optional) {
|
|
8736
|
+
return void 0;
|
|
8737
|
+
} else {
|
|
8738
|
+
throw e;
|
|
8739
|
+
}
|
|
8740
|
+
}
|
|
8741
|
+
}
|
|
8742
|
+
}
|
|
8743
|
+
if (inject.proxy && obj) {
|
|
8744
|
+
if (ValidUtils.isConstructor(inject.proxy)) {
|
|
8745
|
+
const handler = getSim(inject.proxy) ? this.getOrNewSim({ target: inject.proxy }) : new inject.proxy();
|
|
8746
|
+
if (handler) {
|
|
8747
|
+
obj = new Proxy(obj, handler);
|
|
8748
|
+
}
|
|
8749
|
+
} else if (typeof inject.proxy === "function") {
|
|
8750
|
+
const handler = inject.proxy({
|
|
8751
|
+
application: this.simpleApplication,
|
|
8752
|
+
instance: obj
|
|
8753
|
+
});
|
|
8754
|
+
if (handler) {
|
|
8755
|
+
obj = new Proxy(obj, handler);
|
|
8756
|
+
}
|
|
8757
|
+
}
|
|
8758
|
+
}
|
|
8759
|
+
return obj;
|
|
8760
|
+
} else {
|
|
8761
|
+
return otherStorage?.get(token) ?? (token ? this.resolve({ targetKey: token, newInstanceCarrier }) : void 0);
|
|
8762
|
+
}
|
|
8763
|
+
});
|
|
8764
|
+
return injections;
|
|
8765
|
+
}
|
|
8766
|
+
proxy(target) {
|
|
8767
|
+
try {
|
|
8768
|
+
const noProxy = isSimNoProxy(target);
|
|
8769
|
+
const isExcludeProxy = this.option.excludeProxys?.some((it) => target instanceof it);
|
|
8770
|
+
if (!noProxy && !isExcludeProxy && target !== null && getSim(target) && typeof target === "object" && !("_SimpleBoot_isProxy" in target)) {
|
|
8771
|
+
for (const key in target) {
|
|
8772
|
+
if (!isSimNoProxy(target, key)) {
|
|
8773
|
+
target[key] = this.proxy(target[key]);
|
|
8774
|
+
}
|
|
8775
|
+
}
|
|
8776
|
+
const protoTypeName = ObjectUtils.ownPropertyNames(target);
|
|
8777
|
+
protoTypeName.filter((it) => typeof target[it] === "function").filter((it) => !isSimNoProxy(target, it)).filter((it) => !("_SimpleBoot_isProxy" in target[it])).forEach((it) => {
|
|
8778
|
+
target[it] = new Proxy(target[it], this.simProxyHandler);
|
|
8779
|
+
});
|
|
8780
|
+
if (this.simProxyHandler) {
|
|
8781
|
+
target = new Proxy(target, this.simProxyHandler);
|
|
8782
|
+
}
|
|
8783
|
+
}
|
|
8784
|
+
if (this.option.proxy) {
|
|
8785
|
+
target = this.option.proxy.onAfterProxy(target);
|
|
8786
|
+
}
|
|
8787
|
+
return target;
|
|
8788
|
+
} catch (e) {
|
|
8789
|
+
console.log("sim proxy error");
|
|
8790
|
+
throw e;
|
|
8791
|
+
}
|
|
8792
|
+
}
|
|
8793
|
+
run(otherInstanceSim = /* @__PURE__ */ new Map()) {
|
|
8794
|
+
for (const [k, v] of Array.from(otherInstanceSim.entries())) {
|
|
8795
|
+
if (typeof k === "symbol") {
|
|
8796
|
+
simProcess({ symbol: k }, v);
|
|
8797
|
+
} else if (typeof k === "object") {
|
|
8798
|
+
simProcess(k, v);
|
|
8799
|
+
} else {
|
|
8800
|
+
simProcess({ type: k }, v);
|
|
8801
|
+
}
|
|
8802
|
+
}
|
|
8803
|
+
const myContainers = ConvertUtils.flatArray(this.option.container).filter(ValidUtils.isDefined);
|
|
8804
|
+
Array.from(sims.entries()).forEach(([type, value]) => {
|
|
8805
|
+
const targetContainers = ConvertUtils.flatArray(getSim(type)?.container).filter(ValidUtils.isDefined);
|
|
8806
|
+
let isInclude = false;
|
|
8807
|
+
if (myContainers.length <= 0 && targetContainers.length <= 0) {
|
|
8808
|
+
isInclude = true;
|
|
8809
|
+
} else if (targetContainers.length <= 0) {
|
|
8810
|
+
isInclude = true;
|
|
8811
|
+
} else {
|
|
8812
|
+
isInclude = myContainers.some((it) => targetContainers.includes(it));
|
|
8813
|
+
}
|
|
8814
|
+
this.registerStore(type, value);
|
|
8815
|
+
});
|
|
8816
|
+
this.callBindPostConstruct(this);
|
|
8817
|
+
this.getSimAtomics().forEach((it) => {
|
|
8818
|
+
if (it.getConfig()?.autoCreate) {
|
|
8819
|
+
it.getValue();
|
|
8820
|
+
}
|
|
8821
|
+
});
|
|
8822
|
+
}
|
|
8823
|
+
};
|
|
8824
|
+
|
|
8825
|
+
// ../simple-boot/dist/esm/intent/Intent.js
|
|
8826
|
+
var Intent = class {
|
|
8827
|
+
constructor(uri, data, event) {
|
|
8828
|
+
this.uri = uri;
|
|
8829
|
+
this.data = data;
|
|
8830
|
+
this.event = event;
|
|
8831
|
+
this.sessionData = /* @__PURE__ */ new Map();
|
|
8832
|
+
if (typeof uri === "string") {
|
|
8833
|
+
const match = uri.match(/^Symbol\.for\((.+)\):\/(.*)$/);
|
|
8834
|
+
if (match) {
|
|
8835
|
+
const symbol = Symbol.for(match[1]);
|
|
8836
|
+
this.uri = {
|
|
8837
|
+
symbol,
|
|
8838
|
+
uri: match[2]
|
|
8839
|
+
};
|
|
8840
|
+
}
|
|
8841
|
+
}
|
|
8842
|
+
}
|
|
8843
|
+
get symbols() {
|
|
8844
|
+
if (typeof this.uri === "object") {
|
|
8845
|
+
return Array.isArray(this.uri.symbol) ? this.uri.symbol : [this.uri.symbol];
|
|
8846
|
+
}
|
|
8847
|
+
return void 0;
|
|
8848
|
+
}
|
|
8849
|
+
get scheme() {
|
|
8850
|
+
if (typeof this.uri === "string") {
|
|
8851
|
+
const parts = this.uri.split("://");
|
|
8852
|
+
if (parts.length > 1) {
|
|
8853
|
+
return parts[0];
|
|
8854
|
+
}
|
|
8855
|
+
return void 0;
|
|
8856
|
+
} else {
|
|
8857
|
+
return void 0;
|
|
8858
|
+
}
|
|
8859
|
+
}
|
|
8860
|
+
get paths() {
|
|
8861
|
+
return this.pathname.split("/") ?? [];
|
|
8862
|
+
}
|
|
8863
|
+
get fullPath() {
|
|
8864
|
+
const uri = typeof this.uri === "string" ? this.uri : this.uri.uri;
|
|
8865
|
+
const paths = uri.split("://");
|
|
8866
|
+
return paths[paths.length >= 2 ? 1 : 0] ?? "";
|
|
8867
|
+
}
|
|
8868
|
+
get pathname() {
|
|
8869
|
+
const paths = this.fullPath.split("?");
|
|
8870
|
+
return paths[0];
|
|
8871
|
+
}
|
|
8872
|
+
get query() {
|
|
8873
|
+
const paths = this.fullPath.split("?");
|
|
8874
|
+
return paths[1] ?? "";
|
|
8875
|
+
}
|
|
8876
|
+
getQueryParamDecodeURI(key) {
|
|
8877
|
+
const p = this.queryParamsDecodeURI;
|
|
8878
|
+
if (key) {
|
|
8879
|
+
return p[key];
|
|
8880
|
+
} else {
|
|
8881
|
+
return p;
|
|
8882
|
+
}
|
|
8883
|
+
}
|
|
8884
|
+
getQueryParamDecodeURIFirst(key) {
|
|
8885
|
+
const param = this.getQueryParamDecodeURI(key);
|
|
8886
|
+
if (Array.isArray(param)) {
|
|
8887
|
+
return param[0];
|
|
8888
|
+
} else {
|
|
8889
|
+
return param;
|
|
8890
|
+
}
|
|
8891
|
+
}
|
|
8892
|
+
getQueryParam(key) {
|
|
8893
|
+
const p = this.queryParams;
|
|
8894
|
+
if (key) {
|
|
8895
|
+
return p[key];
|
|
8896
|
+
} else {
|
|
8897
|
+
return p;
|
|
8898
|
+
}
|
|
8899
|
+
}
|
|
8900
|
+
getQueryParamFirst(key) {
|
|
8901
|
+
const param = this.getQueryParam(key);
|
|
8902
|
+
if (Array.isArray(param)) {
|
|
8903
|
+
return param[0];
|
|
8904
|
+
} else {
|
|
8905
|
+
return param;
|
|
8906
|
+
}
|
|
8907
|
+
}
|
|
8908
|
+
get queryParams() {
|
|
8909
|
+
const param = {};
|
|
8910
|
+
this.query.split("&")?.forEach((it) => {
|
|
8911
|
+
const a = it.split("=");
|
|
8912
|
+
if (param[a[0]]) {
|
|
8913
|
+
if (Array.isArray(param[a[0]])) {
|
|
8914
|
+
param[a[0]].push(a[1]);
|
|
8915
|
+
} else {
|
|
8916
|
+
param[a[0]] = [param[a[0]], a[1]];
|
|
8917
|
+
}
|
|
8918
|
+
} else {
|
|
8919
|
+
param[a[0]] = a[1];
|
|
8920
|
+
}
|
|
8921
|
+
});
|
|
8922
|
+
return param;
|
|
8923
|
+
}
|
|
8924
|
+
get queryParamsDecodeURI() {
|
|
8925
|
+
const params = this.queryParams;
|
|
8926
|
+
for (const key in params) {
|
|
8927
|
+
if (params.hasOwnProperty(key)) {
|
|
8928
|
+
const param = params[key];
|
|
8929
|
+
if (Array.isArray(param)) {
|
|
8930
|
+
params[key] = param.map((p) => decodeURIComponent(p));
|
|
8931
|
+
} else {
|
|
8932
|
+
params[key] = decodeURIComponent(param);
|
|
8933
|
+
}
|
|
8934
|
+
}
|
|
8935
|
+
}
|
|
8936
|
+
return params;
|
|
8937
|
+
}
|
|
8938
|
+
getPathnameData(urlExpression) {
|
|
8939
|
+
return Expression.Path.pathNameData(this.pathname, urlExpression);
|
|
8940
|
+
}
|
|
8941
|
+
get isSymbolScheme() {
|
|
8942
|
+
return this.symbols !== void 0;
|
|
8943
|
+
}
|
|
8944
|
+
};
|
|
8945
|
+
|
|
8946
|
+
// ../simple-boot/dist/esm/intent/IntentSubscribe.js
|
|
8947
|
+
var isIntentSubscribe = (obj) => {
|
|
8948
|
+
return !!obj && typeof obj.intentSubscribe === "function";
|
|
8949
|
+
};
|
|
8950
|
+
|
|
8951
|
+
// ../simple-boot/dist/esm/intent/IntentManager.js
|
|
8952
|
+
var isRouterPublishType = (it) => typeof it === "object" && it !== null && typeof it.router === "string" && typeof it.rootRouter === "function";
|
|
8953
|
+
var isSymbolPublishType = (it) => typeof it === "object" && it !== null && "symbol" in it && "path" in it;
|
|
8954
|
+
var isSchemePublishType = (it) => typeof it === "object" && it !== null && "scheme" in it && "path" in it;
|
|
8955
|
+
var IntentManager = class {
|
|
8956
|
+
constructor(simpleApplication, simstanceManager, routerManager, simOption) {
|
|
8957
|
+
this.simpleApplication = simpleApplication;
|
|
8958
|
+
this.simstanceManager = simstanceManager;
|
|
8959
|
+
this.routerManager = routerManager;
|
|
8960
|
+
this.simOption = simOption;
|
|
8961
|
+
this.subject = new Subject();
|
|
8962
|
+
}
|
|
8963
|
+
get observable() {
|
|
8964
|
+
return this.subject.asObservable();
|
|
8965
|
+
}
|
|
8966
|
+
async makeIntentData(it, data) {
|
|
8967
|
+
const target = [];
|
|
8968
|
+
const rootRouter = isRouterPublishType(it) ? it.rootRouter : this.simOption.rootRouter;
|
|
8969
|
+
if (isRouterPublishType(it)) {
|
|
8970
|
+
it = it.router;
|
|
8971
|
+
}
|
|
8972
|
+
const routerMatch = typeof it === "string" && it.match(/^Router\((.+)\):\/(.*)$/);
|
|
8973
|
+
if (routerMatch && typeof it === "string") {
|
|
8974
|
+
const routerBasePath = routerMatch[1];
|
|
8975
|
+
const actualPath = routerMatch[2];
|
|
8976
|
+
const routerModule = await this.routerManager.routing(routerBasePath, {
|
|
8977
|
+
router: rootRouter
|
|
8978
|
+
});
|
|
8979
|
+
const instance = routerModule.getModuleInstance();
|
|
8980
|
+
if (instance) {
|
|
8981
|
+
target.push(instance);
|
|
8982
|
+
}
|
|
8983
|
+
it = new Intent(actualPath, data);
|
|
8984
|
+
} else if (isSymbolPublishType(it)) {
|
|
8985
|
+
it = new Intent({ symbol: it.symbol, uri: it.path }, data);
|
|
8986
|
+
} else if (isSchemePublishType(it)) {
|
|
8987
|
+
it = new Intent(`${it.scheme}://${it.path}`, data);
|
|
8988
|
+
} else if (typeof it === "string") {
|
|
8989
|
+
it = new Intent(it, data);
|
|
8990
|
+
}
|
|
8991
|
+
const intent = it;
|
|
8992
|
+
if (!routerMatch) {
|
|
8993
|
+
if (intent.symbols) {
|
|
8994
|
+
target.push(...intent.symbols.map((sym) => this.simstanceManager.findSims(sym)).flat());
|
|
8995
|
+
} else if (intent.scheme) {
|
|
8996
|
+
target.push(...this.simstanceManager.getSimConfig(intent.scheme));
|
|
8997
|
+
} else {
|
|
8998
|
+
target.push(...this.simstanceManager.getSimAtomics());
|
|
8999
|
+
}
|
|
9000
|
+
}
|
|
9001
|
+
return { intent, target };
|
|
9002
|
+
}
|
|
9003
|
+
async publishMeta(it, data) {
|
|
9004
|
+
const { intent, target } = await this.makeIntentData(it, data);
|
|
9005
|
+
const r = [];
|
|
9006
|
+
const targetInstances = target.map((it2) => {
|
|
9007
|
+
if (it2 instanceof SimAtomic) {
|
|
9008
|
+
return it2.getValue();
|
|
9009
|
+
} else {
|
|
9010
|
+
return it2;
|
|
9011
|
+
}
|
|
9012
|
+
});
|
|
9013
|
+
this.subject.next(intent);
|
|
9014
|
+
for (let data2 of targetInstances) {
|
|
9015
|
+
let orNewSim = data2;
|
|
9016
|
+
if (orNewSim) {
|
|
9017
|
+
const filteredPaths = intent.paths.filter((i) => i);
|
|
9018
|
+
if (filteredPaths.length > 0) {
|
|
9019
|
+
let callthis = orNewSim;
|
|
9020
|
+
let lastProp = "";
|
|
9021
|
+
filteredPaths.forEach((i) => {
|
|
9022
|
+
callthis = orNewSim;
|
|
9023
|
+
orNewSim = orNewSim?.[i];
|
|
9024
|
+
lastProp = i;
|
|
9025
|
+
});
|
|
9026
|
+
if (orNewSim && typeof orNewSim === "function") {
|
|
9027
|
+
const intentData = Array.isArray(intent.data) ? intent.data : intent.data !== void 0 ? [intent.data] : [];
|
|
9028
|
+
const result = await this.simstanceManager.executeBindParameterSimPromise({
|
|
9029
|
+
target: callthis,
|
|
9030
|
+
targetKey: lastProp,
|
|
9031
|
+
parameterCount: intentData.length,
|
|
9032
|
+
inputParameters: intentData,
|
|
9033
|
+
firstCheckMaker: [
|
|
9034
|
+
(obj, token, idx) => {
|
|
9035
|
+
if (idx < intentData.length) {
|
|
9036
|
+
return intentData[idx];
|
|
9037
|
+
}
|
|
9038
|
+
if (token === Intent && idx === 0) {
|
|
9039
|
+
return intent;
|
|
9040
|
+
}
|
|
9041
|
+
}
|
|
9042
|
+
]
|
|
9043
|
+
});
|
|
9044
|
+
r.push(result);
|
|
9045
|
+
} else if (orNewSim) {
|
|
9046
|
+
callthis[lastProp] = intent.data;
|
|
9047
|
+
r.push(callthis[lastProp]);
|
|
9048
|
+
}
|
|
9049
|
+
} else {
|
|
9050
|
+
const intentData = Array.isArray(intent.data) ? intent.data : intent.data !== void 0 ? [intent.data] : [];
|
|
9051
|
+
if (isIntentSubscribe(orNewSim)) {
|
|
9052
|
+
r.push(orNewSim.intentSubscribe(...intentData));
|
|
9053
|
+
}
|
|
9054
|
+
}
|
|
9055
|
+
}
|
|
9056
|
+
}
|
|
9057
|
+
return { return: r, target };
|
|
9058
|
+
}
|
|
9059
|
+
async publish(it, data) {
|
|
9060
|
+
const rdata = await this.publishMeta(it, data);
|
|
9061
|
+
return rdata.return;
|
|
9062
|
+
}
|
|
9063
|
+
};
|
|
9064
|
+
|
|
9065
|
+
// ../simple-boot/dist/esm/decorators/inject/Injection.js
|
|
9066
|
+
var InjectionMetadataKey = Symbol("Injection");
|
|
9067
|
+
var getInjection = (target, propertyKey) => {
|
|
9068
|
+
return ReflectUtils.getMetadata(InjectionMetadataKey, target, propertyKey);
|
|
9069
|
+
};
|
|
9070
|
+
|
|
9071
|
+
// ../simple-boot/dist/esm/throwable/MethodNoSuch.js
|
|
9072
|
+
var MethodNoSuch = class extends SimError {
|
|
9073
|
+
constructor(message, name, propertyKeys, stack) {
|
|
9074
|
+
super(message, name, stack);
|
|
9075
|
+
this.propertyKeys = propertyKeys;
|
|
9076
|
+
}
|
|
9077
|
+
};
|
|
9078
|
+
|
|
9079
|
+
// ../simple-boot/dist/esm/decorators/route/Router.js
|
|
9080
|
+
var RouterMetadataKey = Symbol("Router");
|
|
9081
|
+
var getRouter = (target) => {
|
|
9082
|
+
if (target != null && typeof target === "object") {
|
|
9083
|
+
target = target.constructor;
|
|
9084
|
+
}
|
|
9085
|
+
try {
|
|
9086
|
+
return ReflectUtils.getMetadata(RouterMetadataKey, target);
|
|
9087
|
+
} catch (e) {
|
|
9088
|
+
}
|
|
9089
|
+
};
|
|
9090
|
+
var RouteMetadataKey = Symbol("RouteMetadataKey");
|
|
9091
|
+
|
|
9092
|
+
// ../simple-boot/dist/esm/route/RouterModule.js
|
|
9093
|
+
var RouterModule = class {
|
|
9094
|
+
constructor(simstanceManager, router, module, routerChains = []) {
|
|
9095
|
+
this.simstanceManager = simstanceManager;
|
|
9096
|
+
this.router = router;
|
|
9097
|
+
this.module = module;
|
|
9098
|
+
this.routerChains = routerChains;
|
|
9099
|
+
}
|
|
9100
|
+
get path() {
|
|
9101
|
+
return this._path;
|
|
9102
|
+
}
|
|
9103
|
+
set path(value) {
|
|
9104
|
+
this._path = value;
|
|
9105
|
+
}
|
|
9106
|
+
get data() {
|
|
9107
|
+
return this._data;
|
|
9108
|
+
}
|
|
9109
|
+
set data(value) {
|
|
9110
|
+
this._data = value;
|
|
9111
|
+
}
|
|
9112
|
+
get intent() {
|
|
9113
|
+
return this._intent;
|
|
9114
|
+
}
|
|
9115
|
+
set intent(value) {
|
|
9116
|
+
this._intent = value;
|
|
9117
|
+
}
|
|
9118
|
+
get propertyKeys() {
|
|
9119
|
+
return this._propertyKeys;
|
|
9120
|
+
}
|
|
9121
|
+
set propertyKeys(value) {
|
|
9122
|
+
this._propertyKeys = value;
|
|
9123
|
+
}
|
|
9124
|
+
get pathData() {
|
|
9125
|
+
return this._pathData;
|
|
9126
|
+
}
|
|
9127
|
+
getPathData() {
|
|
9128
|
+
return this._pathData;
|
|
9129
|
+
}
|
|
9130
|
+
set pathData(value) {
|
|
9131
|
+
this._pathData = value;
|
|
9132
|
+
}
|
|
9133
|
+
getRouterPath(join = "") {
|
|
9134
|
+
return this.getRouterPaths().map((it) => it ?? "").join(join);
|
|
9135
|
+
}
|
|
9136
|
+
getRouterPaths() {
|
|
9137
|
+
return this.routerChains.map((it) => getRouter(it instanceof SimAtomic ? it.type.targetKeyType : it)?.path);
|
|
9138
|
+
}
|
|
9139
|
+
getRouterPathData(pathName) {
|
|
9140
|
+
return Expression.Path.pathNameData(pathName, this.getRouterPath());
|
|
9141
|
+
}
|
|
9142
|
+
getModuleInstance(propertyKey, instanceBind = true) {
|
|
9143
|
+
const instance = this.simstanceManager.getOrNewSim({ target: this.module?.targetKeyType, originTypeTarget: this.module?.originalType });
|
|
9144
|
+
if (propertyKey && this.propertyKeys && this.propertyKeys.includes(propertyKey)) {
|
|
9145
|
+
let instanceElement = instance[propertyKey];
|
|
9146
|
+
if (instanceBind && typeof instanceBind === "boolean") {
|
|
9147
|
+
instanceElement = instanceElement.bind(instance);
|
|
9148
|
+
} else if (instanceBind && typeof instanceBind === "object") {
|
|
9149
|
+
instanceElement = instanceElement.bind(instanceBind);
|
|
9150
|
+
}
|
|
9151
|
+
return instanceElement;
|
|
9152
|
+
} else {
|
|
9153
|
+
return instance;
|
|
9154
|
+
}
|
|
9155
|
+
}
|
|
9156
|
+
executeModuleProperty(propertyKey, ...param) {
|
|
9157
|
+
const target = this.getModuleInstance();
|
|
9158
|
+
if (propertyKey) {
|
|
9159
|
+
const config = getInjection(target, propertyKey);
|
|
9160
|
+
if (config) {
|
|
9161
|
+
const other = /* @__PURE__ */ new Map();
|
|
9162
|
+
param.forEach((it) => other.set(it.constructor, it));
|
|
9163
|
+
return this.simstanceManager.executeBindParameterSim({ target, targetKey: propertyKey }, other);
|
|
9164
|
+
} else {
|
|
9165
|
+
if (target[propertyKey]) {
|
|
9166
|
+
return target[propertyKey]?.(...param);
|
|
9167
|
+
} else {
|
|
9168
|
+
throw new MethodNoSuch(`${propertyKey.toString()} noSuch`, propertyKey.toString(), propertyKey);
|
|
9169
|
+
}
|
|
9170
|
+
}
|
|
9171
|
+
}
|
|
9172
|
+
}
|
|
9173
|
+
get firstRouteChain() {
|
|
9174
|
+
return this.routerChains[0];
|
|
9175
|
+
}
|
|
9176
|
+
get firstRouteChainValue() {
|
|
9177
|
+
return this.firstRouteChain?.getValue();
|
|
9178
|
+
}
|
|
9179
|
+
get lastRouteChain() {
|
|
9180
|
+
return this.routerChains[this.routerChains.length - 1];
|
|
9181
|
+
}
|
|
9182
|
+
get lastRouteChainValue() {
|
|
9183
|
+
return this.lastRouteChain?.getValue();
|
|
9184
|
+
}
|
|
9185
|
+
hasActivateInLastRoute(obj) {
|
|
9186
|
+
return this.lastRouteChainValue?.hasActivate(obj) === true;
|
|
9187
|
+
}
|
|
9188
|
+
getQueryParamDecodeURI(key) {
|
|
9189
|
+
if (this.intent) {
|
|
9190
|
+
return this.intent.getQueryParamDecodeURI(key);
|
|
9191
|
+
}
|
|
9192
|
+
}
|
|
9193
|
+
getQueryParamDecodeURIFirst(key) {
|
|
9194
|
+
if (this.intent) {
|
|
9195
|
+
return this.intent.getQueryParamDecodeURIFirst(key);
|
|
9196
|
+
}
|
|
9197
|
+
}
|
|
9198
|
+
getQueryParam(key) {
|
|
9199
|
+
if (this.intent) {
|
|
9200
|
+
return this.intent.getQueryParam(key);
|
|
9201
|
+
}
|
|
9202
|
+
}
|
|
9203
|
+
getQueryParamFirst(key) {
|
|
9204
|
+
if (this.intent) {
|
|
9205
|
+
return this.intent.getQueryParamFirst(key);
|
|
9206
|
+
}
|
|
9207
|
+
}
|
|
9208
|
+
get queryParams() {
|
|
9209
|
+
if (this.intent) {
|
|
9210
|
+
return this.intent.queryParams;
|
|
9211
|
+
}
|
|
9212
|
+
}
|
|
9213
|
+
get queryParamsAfterDecodeURI() {
|
|
9214
|
+
if (this.intent) {
|
|
9215
|
+
return this.intent.queryParamsDecodeURI;
|
|
9216
|
+
}
|
|
9217
|
+
}
|
|
9218
|
+
};
|
|
9219
|
+
|
|
9220
|
+
// ../simple-boot/dist/esm/route/RouterAction.js
|
|
9221
|
+
var RouterAction;
|
|
9222
|
+
((RouterAction2) => {
|
|
9223
|
+
RouterAction2.isCanActivate = (obj) => {
|
|
9224
|
+
return typeof obj?.canActivate === "function";
|
|
9225
|
+
};
|
|
9226
|
+
RouterAction2.isOnRouting = (obj) => {
|
|
9227
|
+
return typeof obj?.onRouting === "function";
|
|
9228
|
+
};
|
|
9229
|
+
RouterAction2.isHasActivate = (obj) => {
|
|
9230
|
+
return typeof obj?.hasActivate === "function";
|
|
9231
|
+
};
|
|
9232
|
+
})(RouterAction || (RouterAction = {}));
|
|
9233
|
+
|
|
9234
|
+
// ../simple-boot/dist/esm/route/RouterManager.js
|
|
9235
|
+
var RouterManager = class {
|
|
9236
|
+
constructor(simpleApplication, simstanceManager, simOption) {
|
|
9237
|
+
this.simpleApplication = simpleApplication;
|
|
9238
|
+
this.simstanceManager = simstanceManager;
|
|
9239
|
+
this.simOption = simOption;
|
|
9240
|
+
this.subject = new Subject();
|
|
9241
|
+
}
|
|
9242
|
+
// @SimNoProxy
|
|
9243
|
+
get observable() {
|
|
9244
|
+
return this.subject.asObservable();
|
|
9245
|
+
}
|
|
9246
|
+
routingMap(option) {
|
|
9247
|
+
const targetRouter = option?.router ?? this.simOption.rootRouter;
|
|
9248
|
+
if (!targetRouter) {
|
|
9249
|
+
throw new Error("no router");
|
|
9250
|
+
}
|
|
9251
|
+
const map = {};
|
|
9252
|
+
if (targetRouter) {
|
|
9253
|
+
const targetType = typeof targetRouter === "object" ? targetRouter.constructor : targetRouter;
|
|
9254
|
+
const targetValue = typeof targetRouter === "object" ? targetRouter : void 0;
|
|
9255
|
+
const routerAtomic = new SimAtomic({ targetKeyType: targetType, originalType: targetType, value: targetValue }, this.simstanceManager);
|
|
9256
|
+
const routerData = routerAtomic.getConfig(RouterMetadataKey);
|
|
9257
|
+
if (routerData) {
|
|
9258
|
+
const currentPrefix = (option?.prefix ?? "") + routerData.path;
|
|
9259
|
+
if (routerData.route && routerData.route[""]) {
|
|
9260
|
+
map[currentPrefix] = routerData.route[""];
|
|
9261
|
+
}
|
|
9262
|
+
if (routerData.route) {
|
|
9263
|
+
Object.entries(routerData.route).forEach(([key, value]) => {
|
|
9264
|
+
map[currentPrefix + key] = value;
|
|
9265
|
+
});
|
|
9266
|
+
}
|
|
9267
|
+
routerData.routers?.forEach((it) => {
|
|
9268
|
+
Object.assign(map, this.routingMap({ ...option, router: it, prefix: currentPrefix }));
|
|
9269
|
+
});
|
|
9270
|
+
}
|
|
9271
|
+
}
|
|
9272
|
+
return map;
|
|
9273
|
+
}
|
|
9274
|
+
/** 일반적인 lifecycle 타지않는 그냥 find.. 의미가없을듯.
|
|
9275
|
+
* @deprecated
|
|
9276
|
+
*/
|
|
9277
|
+
async routings(intent, option) {
|
|
9278
|
+
const targetRouter = option?.router ?? this.simOption.rootRouter;
|
|
9279
|
+
if (!targetRouter) {
|
|
9280
|
+
throw new Error("no router");
|
|
9281
|
+
}
|
|
9282
|
+
const targetType = typeof targetRouter === "object" ? targetRouter.constructor : targetRouter;
|
|
9283
|
+
const targetValue = typeof targetRouter === "object" ? targetRouter : void 0;
|
|
9284
|
+
const routerAtomic = new SimAtomic({ targetKeyType: targetType, originalType: targetType, value: targetValue }, this.simstanceManager);
|
|
9285
|
+
const allMatches = this._collectAllMatchingModules(routerAtomic, intent, []);
|
|
9286
|
+
const exactModuleMatches = allMatches.filter((rm) => rm.path === intent.pathname && rm.module);
|
|
9287
|
+
if (exactModuleMatches.length > 0) {
|
|
9288
|
+
exactModuleMatches.forEach((it) => this.subject.next({ intent, routerManager: this, routerModule: it }));
|
|
9289
|
+
return exactModuleMatches;
|
|
9290
|
+
}
|
|
9291
|
+
const exactPathMatches = allMatches.filter((rm) => rm.path === intent.pathname);
|
|
9292
|
+
if (exactPathMatches.length > 0) {
|
|
9293
|
+
exactPathMatches.forEach((it) => this.subject.next({ intent, routerManager: this, routerModule: it }));
|
|
9294
|
+
return exactPathMatches;
|
|
9295
|
+
}
|
|
9296
|
+
return [];
|
|
9297
|
+
}
|
|
9298
|
+
async routing(intent, option) {
|
|
9299
|
+
if (typeof intent === "string") {
|
|
9300
|
+
intent = new Intent(intent);
|
|
9301
|
+
}
|
|
9302
|
+
const targetRouter = option?.router ?? this.simOption.rootRouter;
|
|
9303
|
+
const callCheckOnRouting = option?.noOnRouting !== true;
|
|
9304
|
+
if (!targetRouter) {
|
|
9305
|
+
debugger;
|
|
9306
|
+
throw new Error("no router");
|
|
9307
|
+
}
|
|
9308
|
+
const targetType = typeof targetRouter === "object" ? targetRouter.constructor : targetRouter;
|
|
9309
|
+
const targetValue = typeof targetRouter === "object" ? targetRouter : void 0;
|
|
9310
|
+
const routerAtomic = typeof targetType === "symbol" ? this.simstanceManager.findFirstSim(targetType) : new SimAtomic({ targetKeyType: targetType, originalType: targetType, value: targetValue }, this.simstanceManager);
|
|
9311
|
+
const rootRouter = routerAtomic.getValue();
|
|
9312
|
+
const executeModuleResult = this.getExecuteModule(routerAtomic, intent, [], option);
|
|
9313
|
+
if (executeModuleResult) {
|
|
9314
|
+
const [executeModule, routerChains] = executeModuleResult;
|
|
9315
|
+
executeModule.routerChains = routerChains;
|
|
9316
|
+
this.activeRouterModule = executeModule;
|
|
9317
|
+
const routingDataSet = { intent, routerModule: executeModule, routerManager: this };
|
|
9318
|
+
if (routerChains.length > 0) {
|
|
9319
|
+
for (let i = 0; i < routerChains.length; i++) {
|
|
9320
|
+
const current = routerChains[i];
|
|
9321
|
+
const next = routerChains[i + 1];
|
|
9322
|
+
const value = current.getValue();
|
|
9323
|
+
if (RouterAction.isCanActivate(value) && next) {
|
|
9324
|
+
await value.canActivate(routingDataSet, next.getValue());
|
|
9325
|
+
}
|
|
9326
|
+
if (callCheckOnRouting && RouterAction.isOnRouting(value) && next) {
|
|
9327
|
+
await value.onRouting(routingDataSet);
|
|
9328
|
+
}
|
|
9329
|
+
}
|
|
9330
|
+
}
|
|
9331
|
+
this.activeRouterModule = executeModule;
|
|
9332
|
+
const moduleInstance = executeModule.getModuleInstance();
|
|
9333
|
+
if (!executeModule?.module) {
|
|
9334
|
+
const routerChain = executeModule.routerChains[executeModule.routerChains.length - 1];
|
|
9335
|
+
const value = routerChain?.getValue();
|
|
9336
|
+
if (RouterAction.isCanActivate(value)) {
|
|
9337
|
+
await value.canActivate(routingDataSet, moduleInstance);
|
|
9338
|
+
}
|
|
9339
|
+
if (callCheckOnRouting && RouterAction.isOnRouting(value)) {
|
|
9340
|
+
await value.onRouting(routingDataSet);
|
|
9341
|
+
}
|
|
9342
|
+
} else {
|
|
9343
|
+
const value = executeModule.router?.getValue();
|
|
9344
|
+
if (RouterAction.isCanActivate(value)) {
|
|
9345
|
+
await value.canActivate(routingDataSet, moduleInstance);
|
|
9346
|
+
}
|
|
9347
|
+
if (callCheckOnRouting && RouterAction.isOnRouting(value)) {
|
|
9348
|
+
await value.onRouting(routingDataSet);
|
|
9349
|
+
}
|
|
9350
|
+
if (moduleInstance && callCheckOnRouting && RouterAction.isOnRouting(moduleInstance)) {
|
|
9351
|
+
await moduleInstance.onRouting(routingDataSet);
|
|
9352
|
+
}
|
|
9353
|
+
}
|
|
9354
|
+
const find = this.activeRouterModule;
|
|
9355
|
+
this.subject.next({ intent, routerModule: find, routerManager: this });
|
|
9356
|
+
return find;
|
|
9357
|
+
} else {
|
|
9358
|
+
const empty = await this._handleNotFoundRouting(rootRouter, intent);
|
|
9359
|
+
this.subject.next({ intent, routerModule: empty, routerManager: this });
|
|
9360
|
+
return empty;
|
|
9361
|
+
}
|
|
9362
|
+
}
|
|
9363
|
+
/**
|
|
9364
|
+
* URL과 일치하는 라우트를 찾지 못했을 경우를 처리합니다.
|
|
9365
|
+
* "Not Found" 상태를 나타내는 비어있는 RouterModule 객체를 생성하여 반환합니다.
|
|
9366
|
+
* 이 과정에서 rootRouter의 라이프사이클을 호출하여 공통 레이아웃등을 처리할 수 있습니다.
|
|
9367
|
+
* @param rootRouter 앱의 최상위 라우터 인스턴스
|
|
9368
|
+
* @param intent 확인에 실패한 원본 Intent 객체
|
|
9369
|
+
* @private
|
|
9370
|
+
*/
|
|
9371
|
+
async _handleNotFoundRouting(rootRouter, intent) {
|
|
9372
|
+
const routerModule = new RouterModule(this.simstanceManager, rootRouter, void 0, []);
|
|
9373
|
+
const routingDataSet = { intent, routerModule, routerManager: this };
|
|
9374
|
+
const value = rootRouter;
|
|
9375
|
+
if (RouterAction.isCanActivate(value)) {
|
|
9376
|
+
await value.canActivate(routingDataSet, null);
|
|
9377
|
+
}
|
|
9378
|
+
if (RouterAction.isOnRouting(value)) {
|
|
9379
|
+
await value.onRouting(routingDataSet);
|
|
9380
|
+
}
|
|
9381
|
+
this.activeRouterModule = routerModule;
|
|
9382
|
+
return this.activeRouterModule;
|
|
9383
|
+
}
|
|
9384
|
+
getExecuteModule(router, intent, parentRouters, option) {
|
|
9385
|
+
const path = intent.pathname;
|
|
9386
|
+
const routerConfig = router.getConfig(RouterMetadataKey);
|
|
9387
|
+
if (routerConfig) {
|
|
9388
|
+
const filters = [];
|
|
9389
|
+
if (Array.isArray(routerConfig.filters)) {
|
|
9390
|
+
filters.push(...routerConfig.filters);
|
|
9391
|
+
} else if (routerConfig.filters) {
|
|
9392
|
+
filters.push(routerConfig.filters);
|
|
9393
|
+
}
|
|
9394
|
+
const noAccept = filters.some((it) => (typeof it === "function" ? this.simstanceManager.getOrNewSim({ target: it }) : it)?.isAccept(intent) === false);
|
|
9395
|
+
if (noAccept) {
|
|
9396
|
+
return;
|
|
9397
|
+
}
|
|
9398
|
+
const routerStrings = parentRouters.map((it) => it.getConfig(RouterMetadataKey)?.path || "");
|
|
9399
|
+
const isRoot = this.isRootUrl(routerConfig.path, routerStrings, path);
|
|
9400
|
+
if (isRoot) {
|
|
9401
|
+
const currentParentRouters = [...parentRouters, router];
|
|
9402
|
+
if (routerConfig.routers && routerConfig.routers.length > 0) {
|
|
9403
|
+
let bestMatchModule = void 0;
|
|
9404
|
+
let bestMatchLength = -1;
|
|
9405
|
+
for (const child of routerConfig.routers) {
|
|
9406
|
+
const routerAtomic = typeof child === "symbol" ? this.simstanceManager.findFirstSim(child) : new SimAtomic({ targetKeyType: child, originalType: child }, this.simstanceManager);
|
|
9407
|
+
if (!routerAtomic) {
|
|
9408
|
+
continue;
|
|
9409
|
+
}
|
|
9410
|
+
const executeModule = this.getExecuteModule(routerAtomic, intent, currentParentRouters, option);
|
|
9411
|
+
if (executeModule) {
|
|
9412
|
+
const [rm, chains] = executeModule;
|
|
9413
|
+
const currentMatchLength = rm.path?.length || 0;
|
|
9414
|
+
if (currentMatchLength > bestMatchLength) {
|
|
9415
|
+
bestMatchLength = currentMatchLength;
|
|
9416
|
+
bestMatchModule = executeModule;
|
|
9417
|
+
} else if (currentMatchLength === bestMatchLength) {
|
|
9418
|
+
if (option?.find?.router === "last") {
|
|
9419
|
+
bestMatchModule = executeModule;
|
|
9420
|
+
}
|
|
9421
|
+
}
|
|
9422
|
+
}
|
|
9423
|
+
}
|
|
9424
|
+
if (bestMatchModule) {
|
|
9425
|
+
return bestMatchModule;
|
|
9426
|
+
}
|
|
9427
|
+
}
|
|
9428
|
+
const module = this.findRouterOrModule(router, routerConfig, routerStrings, intent);
|
|
9429
|
+
if (module) {
|
|
9430
|
+
return [module, currentParentRouters];
|
|
9431
|
+
}
|
|
9432
|
+
}
|
|
9433
|
+
}
|
|
9434
|
+
}
|
|
9435
|
+
// path: 지금 내 라우터의 path, parentRoots: 부모router path들, url: 사용자가 원하는 full intent url
|
|
9436
|
+
isRootUrl(path, parentRoots, url) {
|
|
9437
|
+
const searchString = parentRoots.join("") + (path || "");
|
|
9438
|
+
if (searchString === "/") {
|
|
9439
|
+
return true;
|
|
9440
|
+
}
|
|
9441
|
+
const searchs = searchString.split("/");
|
|
9442
|
+
const urls = url.split("/");
|
|
9443
|
+
const trimmedUrls = urls.slice(0, searchs.length).join("/");
|
|
9444
|
+
return !!Expression.Path.pathNameData(trimmedUrls, searchString);
|
|
9445
|
+
}
|
|
9446
|
+
_collectAllMatchingModules(router, intent, parentRouters) {
|
|
9447
|
+
const matches = [];
|
|
9448
|
+
const path = intent.pathname;
|
|
9449
|
+
const routerConfig = router.getConfig(RouterMetadataKey);
|
|
9450
|
+
if (routerConfig) {
|
|
9451
|
+
const filters = [];
|
|
9452
|
+
if (Array.isArray(routerConfig.filters)) {
|
|
9453
|
+
filters.push(...routerConfig.filters);
|
|
9454
|
+
} else if (routerConfig.filters) {
|
|
9455
|
+
filters.push(routerConfig.filters);
|
|
9456
|
+
}
|
|
9457
|
+
const noAccept = filters.some((it) => (typeof it === "function" ? this.simstanceManager.getOrNewSim({ target: it }) : it)?.isAccept(intent) === false);
|
|
9458
|
+
if (noAccept) {
|
|
9459
|
+
return matches;
|
|
9460
|
+
}
|
|
9461
|
+
const routerStrings = parentRouters.map((it) => it.getConfig(RouterMetadataKey)?.path || "");
|
|
9462
|
+
const isRoot = this.isRootUrl(routerConfig.path, routerStrings, path);
|
|
9463
|
+
if (isRoot) {
|
|
9464
|
+
const currentParentRouters = [...parentRouters, router];
|
|
9465
|
+
if (routerConfig.routers && routerConfig.routers.length > 0) {
|
|
9466
|
+
for (const child of routerConfig.routers) {
|
|
9467
|
+
const routerAtomic = typeof child === "symbol" ? this.simstanceManager.findFirstSim(child) : new SimAtomic({ targetKeyType: child, originalType: child }, this.simstanceManager);
|
|
9468
|
+
if (!routerAtomic) {
|
|
9469
|
+
continue;
|
|
9470
|
+
}
|
|
9471
|
+
matches.push(...this._collectAllMatchingModules(routerAtomic, intent, currentParentRouters));
|
|
9472
|
+
}
|
|
9473
|
+
}
|
|
9474
|
+
const module = this.findRouterOrModule(router, routerConfig, routerStrings, intent);
|
|
9475
|
+
if (module) {
|
|
9476
|
+
module.routerChains = currentParentRouters;
|
|
9477
|
+
matches.push(module);
|
|
9478
|
+
}
|
|
9479
|
+
}
|
|
9480
|
+
}
|
|
9481
|
+
return matches;
|
|
9482
|
+
}
|
|
9483
|
+
findRouterOrModule(router, routerData, parentRoots, intent) {
|
|
9484
|
+
const module = this.findRouting(router, routerData, parentRoots, intent);
|
|
9485
|
+
if (module?.module) {
|
|
9486
|
+
module.intent = intent;
|
|
9487
|
+
return module;
|
|
9488
|
+
}
|
|
9489
|
+
const urlRoot = parentRoots.join("") + (routerData.path || "");
|
|
9490
|
+
if (this.isRootUrl(routerData.path, parentRoots, intent.pathname)) {
|
|
9491
|
+
const rm = new RouterModule(this.simstanceManager, router);
|
|
9492
|
+
rm.intent = intent;
|
|
9493
|
+
rm.path = urlRoot;
|
|
9494
|
+
rm.pathData = intent.getPathnameData(urlRoot);
|
|
9495
|
+
return rm;
|
|
9496
|
+
}
|
|
9497
|
+
return void 0;
|
|
9498
|
+
}
|
|
9499
|
+
findRouting(router, routerData, parentRoots, intent) {
|
|
9500
|
+
const urlRoot = parentRoots.join("") + routerData.path;
|
|
9501
|
+
if (routerData.route) {
|
|
9502
|
+
for (const it of Object.keys(routerData.route).filter((it2) => !it2.startsWith("_"))) {
|
|
9503
|
+
const path = urlRoot + it;
|
|
9504
|
+
const pathnameData = intent.getPathnameData(path);
|
|
9505
|
+
if (pathnameData) {
|
|
9506
|
+
try {
|
|
9507
|
+
const dataSet = this.findRouteProperty(routerData.route, it, intent);
|
|
9508
|
+
const rm = new RouterModule(this.simstanceManager, router, dataSet.child);
|
|
9509
|
+
rm.data = dataSet.data;
|
|
9510
|
+
rm.path = path;
|
|
9511
|
+
rm.pathData = pathnameData;
|
|
9512
|
+
rm.propertyKeys = dataSet.propertyKeys;
|
|
9513
|
+
return rm;
|
|
9514
|
+
} catch (e) {
|
|
9515
|
+
}
|
|
9516
|
+
}
|
|
9517
|
+
}
|
|
9518
|
+
}
|
|
9519
|
+
}
|
|
9520
|
+
findRouteProperty(route, propertyName, intent) {
|
|
9521
|
+
let child;
|
|
9522
|
+
let data;
|
|
9523
|
+
let propertyKeys;
|
|
9524
|
+
const routeElement = route[propertyName];
|
|
9525
|
+
if (typeof routeElement === "function") {
|
|
9526
|
+
child = { targetKeyType: routeElement, originalType: routeElement };
|
|
9527
|
+
} else if (typeof routeElement === "symbol") {
|
|
9528
|
+
const findSimType = this.simstanceManager.findLastSim(routeElement)?.type;
|
|
9529
|
+
if (findSimType?.originalType) {
|
|
9530
|
+
child = { targetKeyType: findSimType.originalType, originalType: findSimType.originalType };
|
|
9531
|
+
}
|
|
9532
|
+
} else if (typeof routeElement === "string") {
|
|
9533
|
+
return this.findRouteProperty(route, routeElement, intent);
|
|
9534
|
+
} else if (Array.isArray(routeElement)) {
|
|
9535
|
+
const r = routeElement?.[0];
|
|
9536
|
+
if (typeof r === "object" && "filters" in r && "target" in r) {
|
|
9537
|
+
const filters = [];
|
|
9538
|
+
if (Array.isArray(r.filters)) {
|
|
9539
|
+
filters.push(...r.filters);
|
|
9540
|
+
} else if (r.filters) {
|
|
9541
|
+
filters.push(r.filters);
|
|
9542
|
+
}
|
|
9543
|
+
const noAccept = filters.some((it) => (typeof it === "function" ? this.simstanceManager.getOrNewSim({ target: it }) : it)?.isAccept(intent) === false);
|
|
9544
|
+
if (!noAccept) {
|
|
9545
|
+
child = { targetKeyType: r.target, originalType: r.target };
|
|
9546
|
+
}
|
|
9547
|
+
} else {
|
|
9548
|
+
child = { targetKeyType: r, originalType: r };
|
|
9549
|
+
}
|
|
9550
|
+
data = routeElement?.[1];
|
|
9551
|
+
} else if (typeof routeElement === "object" && "target" in routeElement && "propertyKeys" in routeElement) {
|
|
9552
|
+
const noAccept = routeElement.filters?.filter((it) => it).some((it) => (typeof it === "function" ? this.simstanceManager.getOrNewSim({ target: it }) : it)?.isAccept(intent) === false);
|
|
9553
|
+
if (!noAccept) {
|
|
9554
|
+
child = { targetKeyType: routeElement.target, originalType: routeElement.target };
|
|
9555
|
+
propertyKeys = routeElement.propertyKeys;
|
|
9556
|
+
}
|
|
9557
|
+
} else if (typeof routeElement === "object" && "filters" in routeElement && "target" in routeElement) {
|
|
9558
|
+
const filters = [];
|
|
9559
|
+
if (Array.isArray(routeElement.filters)) {
|
|
9560
|
+
filters.push(...routeElement.filters);
|
|
9561
|
+
} else if (routeElement.filters) {
|
|
9562
|
+
filters.push(routeElement.filters);
|
|
9563
|
+
}
|
|
9564
|
+
const noAccept = filters.some((it) => (typeof it === "function" ? this.simstanceManager.getOrNewSim({ target: it }) : it)?.isAccept(intent) === false);
|
|
9565
|
+
if (!noAccept) {
|
|
9566
|
+
child = { targetKeyType: routeElement.target, originalType: routeElement.target };
|
|
9567
|
+
}
|
|
9568
|
+
}
|
|
9569
|
+
return {
|
|
9570
|
+
child,
|
|
9571
|
+
data,
|
|
9572
|
+
propertyKeys
|
|
9573
|
+
};
|
|
9574
|
+
}
|
|
9575
|
+
};
|
|
9576
|
+
|
|
9577
|
+
// ../simple-boot/dist/esm/SimpleApplication.js
|
|
9578
|
+
var SimpleApplication = class _SimpleApplication {
|
|
9579
|
+
// public rootRouter?: ConstructorType<any>;
|
|
9580
|
+
// constructor();
|
|
9581
|
+
// constructor(option: SimOption);
|
|
9582
|
+
// constructor(rootRouter?: ConstructorType<Object> | Function);
|
|
9583
|
+
// constructor(rootRouter?: ConstructorType<Object> | Function, option?: SimOption);
|
|
9584
|
+
// constructor(rootRouter?: (ConstructorType<Object> | Function) | SimOption, option = new SimOption()) {
|
|
9585
|
+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
9586
|
+
constructor(option = new SimOption()) {
|
|
9587
|
+
this.option = option;
|
|
9588
|
+
this.simstanceManager = new SimstanceManager(this, option);
|
|
9589
|
+
this.simstanceManager.setStoreSet(SimstanceManager, this.simstanceManager);
|
|
9590
|
+
this.routerManager = new RouterManager(this, this.simstanceManager, option);
|
|
9591
|
+
this.intentManager = new IntentManager(this, this.simstanceManager, this.routerManager, option);
|
|
9592
|
+
this.simstanceManager.setStoreSet(IntentManager, this.intentManager);
|
|
9593
|
+
this.simstanceManager.setStoreSet(RouterManager, this.routerManager);
|
|
9594
|
+
containers.add(this);
|
|
9595
|
+
}
|
|
9596
|
+
getSimstanceManager() {
|
|
9597
|
+
return this.simstanceManager;
|
|
9598
|
+
}
|
|
9599
|
+
getIntentManager() {
|
|
9600
|
+
return this.intentManager;
|
|
9601
|
+
}
|
|
9602
|
+
getRouterManager() {
|
|
9603
|
+
return this.routerManager;
|
|
9604
|
+
}
|
|
9605
|
+
run(otherInstanceSim) {
|
|
9606
|
+
otherInstanceSim ?? (otherInstanceSim = /* @__PURE__ */ new Map());
|
|
9607
|
+
otherInstanceSim.set(_SimpleApplication, this);
|
|
9608
|
+
this.simstanceManager.run(otherInstanceSim);
|
|
9609
|
+
return this;
|
|
9610
|
+
}
|
|
9611
|
+
simAtomic(type) {
|
|
9612
|
+
if (typeof type === "symbol") {
|
|
9613
|
+
return this.simstanceManager.findFirstSim(type);
|
|
9614
|
+
} else if (typeof type === "function") {
|
|
9615
|
+
return this.simstanceManager.findFirstSim({ type });
|
|
9616
|
+
}
|
|
9617
|
+
}
|
|
9618
|
+
simAtomics(type) {
|
|
9619
|
+
if (typeof type === "symbol") {
|
|
9620
|
+
return this.simstanceManager.findSims(type) ?? [];
|
|
9621
|
+
} else if (typeof type === "function") {
|
|
9622
|
+
return this.simstanceManager.findSims({ type }) ?? [];
|
|
9623
|
+
} else {
|
|
9624
|
+
return [];
|
|
9625
|
+
}
|
|
9626
|
+
}
|
|
9627
|
+
getInstance(type) {
|
|
9628
|
+
const i = this.sim(type);
|
|
9629
|
+
if (i) {
|
|
9630
|
+
return i;
|
|
9631
|
+
} else {
|
|
9632
|
+
throw new SimNoSuch("SimNoSuch: no simple instance(getInstance) name:" + type?.prototype?.constructor?.name + "," + type);
|
|
9633
|
+
}
|
|
9634
|
+
}
|
|
9635
|
+
sim(type) {
|
|
9636
|
+
return this.simAtomic(type)?.getValue();
|
|
9637
|
+
}
|
|
9638
|
+
sims(type) {
|
|
9639
|
+
return this.simAtomics(type).map((it) => it.getValue());
|
|
9640
|
+
}
|
|
9641
|
+
addSim(configOrTarget, target) {
|
|
9642
|
+
const r = Sim(configOrTarget);
|
|
9643
|
+
if (typeof r === "function" && target) {
|
|
9644
|
+
r(target);
|
|
9645
|
+
}
|
|
9646
|
+
}
|
|
9647
|
+
publishIntent(i, data) {
|
|
9648
|
+
return this.intentManager.publish(i, data);
|
|
9649
|
+
}
|
|
9650
|
+
routing(i, option) {
|
|
9651
|
+
if (i instanceof Intent) {
|
|
9652
|
+
return this.routerManager.routing(i, option);
|
|
9653
|
+
} else if (typeof i === "string") {
|
|
9654
|
+
const intent = new Intent(i);
|
|
9655
|
+
return this.routerManager.routing(intent, option);
|
|
9656
|
+
} else {
|
|
9657
|
+
const intent = new Intent(i.path, i.data);
|
|
9658
|
+
return this.routerManager.routing(intent, option);
|
|
9659
|
+
}
|
|
9660
|
+
}
|
|
9661
|
+
};
|
|
9662
|
+
|
|
9663
|
+
// ../core-web/dist/esm/element/CanvasUtils.js
|
|
9664
|
+
var CanvasUtils;
|
|
9665
|
+
((CanvasUtils2) => {
|
|
9666
|
+
let Context2D;
|
|
9667
|
+
((Context2D2) => {
|
|
9668
|
+
Context2D2.resetTransform = (context) => {
|
|
9669
|
+
context.setTransform(1, 0, 0, 1, 0, 0);
|
|
9670
|
+
};
|
|
9671
|
+
})(Context2D = CanvasUtils2.Context2D || (CanvasUtils2.Context2D = {}));
|
|
9672
|
+
CanvasUtils2.fontSize = (ctx, config) => {
|
|
9673
|
+
const { text, maxWidth, maxHeight, fontOption } = config;
|
|
9674
|
+
if (!text || maxWidth <= 0 || maxHeight <= 0) {
|
|
9675
|
+
return 0;
|
|
9676
|
+
}
|
|
9677
|
+
const lines = text.split("\n").filter((line) => line.trim().length > 0);
|
|
9678
|
+
if (lines.length === 0) {
|
|
9679
|
+
return 0;
|
|
9680
|
+
}
|
|
9681
|
+
const lineHeightMultiplier = 1.2;
|
|
9682
|
+
const maxFontSizeByHeight = Math.floor(maxHeight / (lines.length * lineHeightMultiplier));
|
|
9683
|
+
if (maxFontSizeByHeight <= 0) {
|
|
9684
|
+
return 0;
|
|
9685
|
+
}
|
|
9686
|
+
let minSizeForWidth = 1;
|
|
9687
|
+
let maxSizeForWidth = maxFontSizeByHeight;
|
|
9688
|
+
let bestSizeForWidth = 0;
|
|
9689
|
+
const maxIterations = 100;
|
|
9690
|
+
let iteration = 0;
|
|
9691
|
+
while (minSizeForWidth <= maxSizeForWidth && iteration < maxIterations) {
|
|
9692
|
+
const midSize = Math.floor((minSizeForWidth + maxSizeForWidth) / 2);
|
|
9693
|
+
if (midSize === 0) break;
|
|
9694
|
+
ctx.font = `${fontOption?.fontWeight || "normal"} ${midSize}px ${fontOption?.fontFamily || "sans-serif"}`;
|
|
9695
|
+
const maxLineWidth = Math.max(...lines.map((line) => ctx.measureText(line).width));
|
|
9696
|
+
if (maxLineWidth <= maxWidth) {
|
|
9697
|
+
bestSizeForWidth = midSize;
|
|
9698
|
+
minSizeForWidth = midSize + 1;
|
|
9699
|
+
} else {
|
|
9700
|
+
maxSizeForWidth = midSize - 1;
|
|
9701
|
+
}
|
|
9702
|
+
iteration++;
|
|
9703
|
+
}
|
|
9704
|
+
return Math.min(bestSizeForWidth, maxFontSizeByHeight);
|
|
9705
|
+
};
|
|
9706
|
+
CanvasUtils2.textMetrics = (context, text) => {
|
|
9707
|
+
return context.measureText(text);
|
|
9708
|
+
};
|
|
9709
|
+
})(CanvasUtils || (CanvasUtils = {}));
|
|
9710
|
+
|
|
9711
|
+
// ../core-web/dist/esm/element/ElementUtils.js
|
|
9712
|
+
var ElementUtils;
|
|
9713
|
+
((ElementUtils2) => {
|
|
9714
|
+
function removeAllChildren(el, els) {
|
|
9715
|
+
if (!els) {
|
|
9716
|
+
el.replaceChildren();
|
|
9717
|
+
} else if (Array.isArray(els)) {
|
|
9718
|
+
el.replaceChildren(...els);
|
|
9719
|
+
} else {
|
|
9720
|
+
el.replaceChildren(els);
|
|
7823
9721
|
}
|
|
7824
9722
|
}
|
|
7825
9723
|
ElementUtils2.removeAllChildren = removeAllChildren;
|
|
@@ -8522,13 +10420,400 @@ var ValidUtils2;
|
|
|
8522
10420
|
return /Mobi/i.test(targetWindow.navigator.userAgent);
|
|
8523
10421
|
};
|
|
8524
10422
|
})(ValidUtils2 || (ValidUtils2 = {}));
|
|
10423
|
+
|
|
10424
|
+
// ../simple-boot/dist/esm/index.js
|
|
10425
|
+
var import_reflect_metadata = __toESM(require_Reflect(), 1);
|
|
10426
|
+
|
|
10427
|
+
// ../simple-boot/dist/esm/alert/AlertAction.js
|
|
10428
|
+
var AlertAction = /* @__PURE__ */ ((AlertAction2) => {
|
|
10429
|
+
AlertAction2["ACTIVE"] = "ACTIVE";
|
|
10430
|
+
AlertAction2["IN_ACTIVE"] = "IN_ACTIVE";
|
|
10431
|
+
return AlertAction2;
|
|
10432
|
+
})(AlertAction || {});
|
|
10433
|
+
|
|
10434
|
+
// ../simple-boot/dist/esm/alert/Alert.js
|
|
10435
|
+
var Alert = class {
|
|
10436
|
+
constructor(alertService, config) {
|
|
10437
|
+
this.alertService = alertService;
|
|
10438
|
+
this.config = config;
|
|
10439
|
+
this.isActive = false;
|
|
10440
|
+
this.activateBefore = [];
|
|
10441
|
+
this.activateAfter = [];
|
|
10442
|
+
this.deActivateBefore = [];
|
|
10443
|
+
this.deActivateAfter = [];
|
|
10444
|
+
this.data = /* @__PURE__ */ new Map();
|
|
10445
|
+
if (config?.uuid) {
|
|
10446
|
+
this.uuid = config.uuid;
|
|
10447
|
+
} else {
|
|
10448
|
+
this.uuid = RandomUtils.uuid();
|
|
10449
|
+
}
|
|
10450
|
+
}
|
|
10451
|
+
addOpenBefore(fn) {
|
|
10452
|
+
this.activateBefore.push(fn);
|
|
10453
|
+
}
|
|
10454
|
+
addOpenAfter(fn) {
|
|
10455
|
+
this.activateAfter.push(fn);
|
|
10456
|
+
}
|
|
10457
|
+
addCloseBefore(fn) {
|
|
10458
|
+
this.deActivateBefore.push(fn);
|
|
10459
|
+
}
|
|
10460
|
+
addCloseAfter(fn) {
|
|
10461
|
+
this.deActivateAfter.push(fn);
|
|
10462
|
+
}
|
|
10463
|
+
setData(key, value) {
|
|
10464
|
+
this.data.set(key, value);
|
|
10465
|
+
}
|
|
10466
|
+
getData(key) {
|
|
10467
|
+
return this.data.get(key);
|
|
10468
|
+
}
|
|
10469
|
+
async activate() {
|
|
10470
|
+
try {
|
|
10471
|
+
await Promise.allSettled(this.activateBefore.map((it) => it())).then((it) => {
|
|
10472
|
+
this.result = this.make();
|
|
10473
|
+
this.alertService?.publish({ action: AlertAction.ACTIVE, alert: this });
|
|
10474
|
+
this.isActive = true;
|
|
10475
|
+
if (this.config?.closeTime !== void 0 && this.config?.closeTime > 0) {
|
|
10476
|
+
setTimeout(() => {
|
|
10477
|
+
this.deActivate();
|
|
10478
|
+
}, this.config.closeTime);
|
|
10479
|
+
}
|
|
10480
|
+
this.config?.activate?.(this.result, this);
|
|
10481
|
+
});
|
|
10482
|
+
} catch (e) {
|
|
10483
|
+
} finally {
|
|
10484
|
+
await Promise.allSettled(this.activateAfter.map((it) => it())).then((it) => {
|
|
10485
|
+
});
|
|
10486
|
+
}
|
|
10487
|
+
}
|
|
10488
|
+
async deActivate() {
|
|
10489
|
+
try {
|
|
10490
|
+
await Promise.allSettled(this.deActivateBefore.map((it) => it())).then((it) => {
|
|
10491
|
+
this.alertService?.publish({ action: AlertAction.IN_ACTIVE, alert: this });
|
|
10492
|
+
this.isActive = false;
|
|
10493
|
+
this.config?.deActivate?.(this.result, this);
|
|
10494
|
+
});
|
|
10495
|
+
} catch (e) {
|
|
10496
|
+
} finally {
|
|
10497
|
+
await Promise.allSettled(this.deActivateAfter.map((it) => it())).then((it) => {
|
|
10498
|
+
});
|
|
10499
|
+
}
|
|
10500
|
+
}
|
|
10501
|
+
};
|
|
10502
|
+
|
|
10503
|
+
// ../simple-boot/dist/esm/alert/AlertFactory.js
|
|
10504
|
+
var __decorate = function(decorators, target, key, desc) {
|
|
10505
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
10506
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
10507
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
10508
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
10509
|
+
};
|
|
10510
|
+
var AlertFactory;
|
|
10511
|
+
(function(AlertFactory2) {
|
|
10512
|
+
AlertFactory2.SYMBOL = Symbol("AlertFactory");
|
|
10513
|
+
})(AlertFactory || (AlertFactory = {}));
|
|
10514
|
+
var DefaultAlertFactory = class DefaultAlertFactory2 {
|
|
10515
|
+
create(data) {
|
|
10516
|
+
return void 0;
|
|
10517
|
+
}
|
|
10518
|
+
};
|
|
10519
|
+
DefaultAlertFactory = __decorate([
|
|
10520
|
+
Sim({ symbol: AlertFactory.SYMBOL })
|
|
10521
|
+
], DefaultAlertFactory);
|
|
10522
|
+
|
|
10523
|
+
// ../simple-boot/dist/esm/alert/AlertType.js
|
|
10524
|
+
var AlertType = /* @__PURE__ */ ((AlertType2) => {
|
|
10525
|
+
AlertType2["DANGER"] = "DANGER";
|
|
10526
|
+
AlertType2["NORMAL"] = "NORMAL";
|
|
10527
|
+
AlertType2["PROGRESS"] = "PROGRESS";
|
|
10528
|
+
AlertType2["SUCCESS"] = "SUCCESS";
|
|
10529
|
+
AlertType2["ERROR"] = "ERROR";
|
|
10530
|
+
AlertType2["INFO"] = "INFO";
|
|
10531
|
+
AlertType2["WARNING"] = "WARNING";
|
|
10532
|
+
AlertType2["CONSOLE"] = "CONSOLE";
|
|
10533
|
+
AlertType2["ETC"] = "ETC";
|
|
10534
|
+
return AlertType2;
|
|
10535
|
+
})(AlertType || {});
|
|
10536
|
+
|
|
10537
|
+
// ../simple-boot/dist/esm/alert/AlertService.js
|
|
10538
|
+
var __decorate2 = function(decorators, target, key, desc) {
|
|
10539
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
10540
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
10541
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
10542
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
10543
|
+
};
|
|
10544
|
+
var __metadata = function(k, v) {
|
|
10545
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10546
|
+
};
|
|
10547
|
+
var __param = function(paramIndex, decorator) {
|
|
10548
|
+
return function(target, key) {
|
|
10549
|
+
decorator(target, key, paramIndex);
|
|
10550
|
+
};
|
|
10551
|
+
};
|
|
10552
|
+
var _a;
|
|
10553
|
+
var AlertService = class AlertService2 {
|
|
10554
|
+
constructor(alertFactory) {
|
|
10555
|
+
this.name = (/* @__PURE__ */ new Date()).toUTCString();
|
|
10556
|
+
this.subject = new ReplaySubject();
|
|
10557
|
+
this.alertFactory = alertFactory;
|
|
10558
|
+
}
|
|
10559
|
+
// @PostConstruct
|
|
10560
|
+
// postConstruct(
|
|
10561
|
+
// ) {
|
|
10562
|
+
// this.alertFactory = alertFactory;
|
|
10563
|
+
// }
|
|
10564
|
+
get observable() {
|
|
10565
|
+
return this.subject.asObservable();
|
|
10566
|
+
}
|
|
10567
|
+
publish(data) {
|
|
10568
|
+
this.subject.next(data);
|
|
10569
|
+
}
|
|
10570
|
+
create(factory, config) {
|
|
10571
|
+
return new class extends Alert {
|
|
10572
|
+
make() {
|
|
10573
|
+
return factory(this);
|
|
10574
|
+
}
|
|
10575
|
+
}(this, config);
|
|
10576
|
+
}
|
|
10577
|
+
createFromFactory(type, config) {
|
|
10578
|
+
return this.alertFactory?.create({ caller: this, type, config });
|
|
10579
|
+
}
|
|
10580
|
+
danger(config) {
|
|
10581
|
+
return this.createFromFactory(AlertType.DANGER, config);
|
|
10582
|
+
}
|
|
10583
|
+
progress(config) {
|
|
10584
|
+
config = config ?? {};
|
|
10585
|
+
return this.createFromFactory(AlertType.PROGRESS, config);
|
|
10586
|
+
}
|
|
10587
|
+
success(config) {
|
|
10588
|
+
return this.createFromFactory(AlertType.SUCCESS, config);
|
|
10589
|
+
}
|
|
10590
|
+
info(config) {
|
|
10591
|
+
return this.createFromFactory(AlertType.INFO, config);
|
|
10592
|
+
}
|
|
10593
|
+
error(config) {
|
|
10594
|
+
return this.createFromFactory(AlertType.ERROR, config);
|
|
10595
|
+
}
|
|
10596
|
+
warning(config) {
|
|
10597
|
+
return this.createFromFactory(AlertType.WARNING, config);
|
|
10598
|
+
}
|
|
10599
|
+
};
|
|
10600
|
+
AlertService = __decorate2([
|
|
10601
|
+
Sim,
|
|
10602
|
+
__param(0, Inject({ symbol: AlertFactory.SYMBOL })),
|
|
10603
|
+
__metadata("design:paramtypes", [typeof (_a = typeof AlertFactory !== "undefined" && AlertFactory) === "function" ? _a : Object])
|
|
10604
|
+
], AlertService);
|
|
10605
|
+
|
|
10606
|
+
// ../simple-boot/dist/esm/decorators/cache/CacheDecorator.js
|
|
10607
|
+
var simpleApplicationCache = /* @__PURE__ */ new WeakMap();
|
|
10608
|
+
var getCacheSet = (simpleApplication) => {
|
|
10609
|
+
return simpleApplicationCache.get(simpleApplication);
|
|
10610
|
+
};
|
|
10611
|
+
var findCacheByKey = (simpleApplication, key) => {
|
|
10612
|
+
const storage = simpleApplicationCache.get(simpleApplication);
|
|
10613
|
+
if (storage) {
|
|
10614
|
+
return Array.from(storage.config.entries()).find(([k, v]) => k === key);
|
|
10615
|
+
}
|
|
10616
|
+
};
|
|
10617
|
+
var findCacheByKeyStartWith = (simpleApplication, key) => {
|
|
10618
|
+
const storage = simpleApplicationCache.get(simpleApplication);
|
|
10619
|
+
if (storage) {
|
|
10620
|
+
return Array.from(storage.config.entries()).filter(([k, v]) => k.startsWith(key));
|
|
10621
|
+
} else {
|
|
10622
|
+
return [];
|
|
10623
|
+
}
|
|
10624
|
+
};
|
|
10625
|
+
var deleteCacheByKey = (simpleApplication, key) => {
|
|
10626
|
+
const storage = simpleApplicationCache.get(simpleApplication);
|
|
10627
|
+
if (storage) {
|
|
10628
|
+
storage.storage.delete(key);
|
|
10629
|
+
findCacheByKeyStartWith(simpleApplication, key).forEach(([k, v]) => {
|
|
10630
|
+
const data = storage.config.get(k);
|
|
10631
|
+
if (data?.expireTimeout) {
|
|
10632
|
+
clearTimeout(data.expireTimeout);
|
|
10633
|
+
}
|
|
10634
|
+
storage.config.delete(k);
|
|
10635
|
+
storage.storage.delete(k);
|
|
10636
|
+
});
|
|
10637
|
+
}
|
|
10638
|
+
};
|
|
10639
|
+
var deleteCacheByKeyStartWith = (simpleApplication, key) => {
|
|
10640
|
+
findCacheByKeyStartWith(simpleApplication, key).forEach(([key2, data]) => deleteCacheByKey(simpleApplication, key2));
|
|
10641
|
+
};
|
|
10642
|
+
var CacheMetadataKey = Symbol("Cache");
|
|
10643
|
+
|
|
10644
|
+
// ../simple-boot/dist/esm/cache/CacheManager.js
|
|
10645
|
+
var __decorate3 = function(decorators, target, key, desc) {
|
|
10646
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
10647
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
10648
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
10649
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
10650
|
+
};
|
|
10651
|
+
var __metadata2 = function(k, v) {
|
|
10652
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10653
|
+
};
|
|
10654
|
+
var _a2;
|
|
10655
|
+
var CacheManager = class CacheManager2 {
|
|
10656
|
+
constructor(simpleApplication) {
|
|
10657
|
+
this.simpleApplication = simpleApplication;
|
|
10658
|
+
}
|
|
10659
|
+
findCacheByKey(key) {
|
|
10660
|
+
return findCacheByKey(this.simpleApplication, key);
|
|
10661
|
+
}
|
|
10662
|
+
findCacheByKeyStartWith(key) {
|
|
10663
|
+
return findCacheByKeyStartWith(this.simpleApplication, key);
|
|
10664
|
+
}
|
|
10665
|
+
deleteCacheByKey(key) {
|
|
10666
|
+
return deleteCacheByKey(this.simpleApplication, key);
|
|
10667
|
+
}
|
|
10668
|
+
deleteCacheByKeyStartWith(key) {
|
|
10669
|
+
return deleteCacheByKeyStartWith(this.simpleApplication, key);
|
|
10670
|
+
}
|
|
10671
|
+
getCacheSet() {
|
|
10672
|
+
return getCacheSet(this.simpleApplication);
|
|
10673
|
+
}
|
|
10674
|
+
};
|
|
10675
|
+
CacheManager = __decorate3([
|
|
10676
|
+
Sim,
|
|
10677
|
+
__metadata2("design:paramtypes", [typeof (_a2 = typeof SimpleApplication !== "undefined" && SimpleApplication) === "function" ? _a2 : Object])
|
|
10678
|
+
], CacheManager);
|
|
10679
|
+
|
|
10680
|
+
// ../simple-boot/dist/esm/decorators/event/EventListener.js
|
|
10681
|
+
var EventListenerMetadataKey = Symbol("EventListener");
|
|
10682
|
+
|
|
10683
|
+
// ../simple-boot/dist/esm/decorators/validate/Validation.js
|
|
10684
|
+
var ValidMetadataKey = Symbol("ValidMetadataKey");
|
|
10685
|
+
var ValidationMetadataKey = Symbol("ValidationMetadataKey");
|
|
10686
|
+
|
|
10687
|
+
// ../simple-boot/dist/esm/fetch/ApiService.js
|
|
10688
|
+
var __decorate4 = function(decorators, target, key, desc) {
|
|
10689
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
10690
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
10691
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
10692
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
10693
|
+
};
|
|
10694
|
+
var __metadata3 = function(k, v) {
|
|
10695
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10696
|
+
};
|
|
10697
|
+
var _a3;
|
|
10698
|
+
var _b;
|
|
10699
|
+
var ApiServiceInterceptor;
|
|
10700
|
+
(function(ApiServiceInterceptor2) {
|
|
10701
|
+
ApiServiceInterceptor2.TOKEN = Symbol("ApiServiceInterceptor");
|
|
10702
|
+
ApiServiceInterceptor2.resolveAll = (simstanceManager) => {
|
|
10703
|
+
try {
|
|
10704
|
+
return (simstanceManager.findSims(ApiServiceInterceptor2.TOKEN) ?? []).map((it) => it.getValue()).filter(ValidUtils.isDefined);
|
|
10705
|
+
} catch (e) {
|
|
10706
|
+
return [];
|
|
10707
|
+
}
|
|
10708
|
+
};
|
|
10709
|
+
})(ApiServiceInterceptor || (ApiServiceInterceptor = {}));
|
|
10710
|
+
var ApiService = class ApiService2 extends HttpJsonFetcher {
|
|
10711
|
+
constructor(simstanceManager, alertService) {
|
|
10712
|
+
super();
|
|
10713
|
+
this.simstanceManager = simstanceManager;
|
|
10714
|
+
this.subject = new Subject();
|
|
10715
|
+
this.alertService = alertService;
|
|
10716
|
+
}
|
|
10717
|
+
// @PostConstruct
|
|
10718
|
+
// postConstruct(alertService: AlertService<any>) {
|
|
10719
|
+
// this.alertService = alertService;
|
|
10720
|
+
// }
|
|
10721
|
+
get observable() {
|
|
10722
|
+
return this.subject.asObservable();
|
|
10723
|
+
}
|
|
10724
|
+
createPipe(config) {
|
|
10725
|
+
return {};
|
|
10726
|
+
}
|
|
10727
|
+
async beforeProxyFetch(config) {
|
|
10728
|
+
let interceptors = ApiServiceInterceptor.resolveAll(this.simstanceManager);
|
|
10729
|
+
for (const interceptor of interceptors) {
|
|
10730
|
+
if (interceptor.beforeProxyFetch) {
|
|
10731
|
+
config = await interceptor.beforeProxyFetch(config);
|
|
10732
|
+
}
|
|
10733
|
+
}
|
|
10734
|
+
this.subject.next({ type: "beforeFetchData", config });
|
|
10735
|
+
return config;
|
|
10736
|
+
}
|
|
10737
|
+
async afterProxyFetch(config) {
|
|
10738
|
+
let interceptors = ApiServiceInterceptor.resolveAll(this.simstanceManager);
|
|
10739
|
+
let r = config.response;
|
|
10740
|
+
for (const interceptor of interceptors) {
|
|
10741
|
+
if (interceptor.afterProxyFetch) {
|
|
10742
|
+
r = await interceptor.afterProxyFetch(config);
|
|
10743
|
+
}
|
|
10744
|
+
}
|
|
10745
|
+
this.subject.next({ type: "afterFetchData", response: r });
|
|
10746
|
+
return r;
|
|
10747
|
+
}
|
|
10748
|
+
beforeFetch(fetch2) {
|
|
10749
|
+
this.subject.next({ type: "beforeFetch", fetch: fetch2 });
|
|
10750
|
+
}
|
|
10751
|
+
afterFetch(fetch2, response) {
|
|
10752
|
+
this.subject.next({ type: "afterFetch", fetch: fetch2, response });
|
|
10753
|
+
}
|
|
10754
|
+
before(config, pipe) {
|
|
10755
|
+
this.subject.next({ type: "progress", config, pipe });
|
|
10756
|
+
config.config?.config?.callBackProgress?.(config, pipe);
|
|
10757
|
+
if (config.config?.config?.alertProgress) {
|
|
10758
|
+
const alert = this.alertService?.progress({ title: config.config.config.title });
|
|
10759
|
+
if (alert) {
|
|
10760
|
+
pipe.progress = alert;
|
|
10761
|
+
alert.activate();
|
|
10762
|
+
}
|
|
10763
|
+
}
|
|
10764
|
+
}
|
|
10765
|
+
afterSuccess(config, pipe) {
|
|
10766
|
+
this.subject.next({ type: "success", config, pipe });
|
|
10767
|
+
config.config?.config?.callBackSuccess?.(config, pipe);
|
|
10768
|
+
if (config.config?.config?.alertSuccessMsg) {
|
|
10769
|
+
this.alertService?.success({ title: config.config.config.title })?.activate();
|
|
10770
|
+
}
|
|
10771
|
+
}
|
|
10772
|
+
afterSuccessTransform(config, pipe) {
|
|
10773
|
+
}
|
|
10774
|
+
finally(config, pipe) {
|
|
10775
|
+
this.subject.next({ type: "final", config, pipe });
|
|
10776
|
+
config.config?.config?.callBackFinal?.(config, pipe);
|
|
10777
|
+
pipe.progress?.deActivate();
|
|
10778
|
+
}
|
|
10779
|
+
error(config, pipe, e) {
|
|
10780
|
+
console.log("error", e);
|
|
10781
|
+
this.subject.next({ type: "error", config, pipe, e });
|
|
10782
|
+
config.config?.config?.callBackError?.(config, pipe, e);
|
|
10783
|
+
if (config.config?.config?.alertErrorMsg) {
|
|
10784
|
+
this.alertService?.danger({
|
|
10785
|
+
title: `${config.config.config.title ? config.config.config.title : ""}${e.message ? `(${e.message})` : ""}`
|
|
10786
|
+
})?.activate();
|
|
10787
|
+
}
|
|
10788
|
+
if (config.config?.config?.enableErrorConsole) {
|
|
10789
|
+
console.error(`apiService Error ${config?.config?.config?.title}`, e);
|
|
10790
|
+
}
|
|
10791
|
+
}
|
|
10792
|
+
async execute(fetcherRequest) {
|
|
10793
|
+
const target = fetcherRequest.target;
|
|
10794
|
+
const config = fetcherRequest.config;
|
|
10795
|
+
let r = { target, config };
|
|
10796
|
+
const interceptor = ApiServiceInterceptor.resolveAll(this.simstanceManager) ?? [];
|
|
10797
|
+
for (const apiServiceInterceptor of interceptor) {
|
|
10798
|
+
if (apiServiceInterceptor.beforeProxyExecute) {
|
|
10799
|
+
r = await apiServiceInterceptor.beforeProxyExecute?.(r);
|
|
10800
|
+
}
|
|
10801
|
+
}
|
|
10802
|
+
return super.execute(r);
|
|
10803
|
+
}
|
|
10804
|
+
};
|
|
10805
|
+
ApiService = __decorate4([
|
|
10806
|
+
Sim,
|
|
10807
|
+
__metadata3("design:paramtypes", [typeof (_a3 = typeof SimstanceManager !== "undefined" && SimstanceManager) === "function" ? _a3 : Object, typeof (_b = typeof AlertService !== "undefined" && AlertService) === "function" ? _b : Object])
|
|
10808
|
+
], ApiService);
|
|
8525
10809
|
export {
|
|
8526
10810
|
ADD_EVENT_LISTENER_METADATA_KEY,
|
|
8527
10811
|
APPLY_NODE_METADATA_KEY,
|
|
10812
|
+
ATTRIBUTE_APPLY_METADATA_KEY,
|
|
8528
10813
|
ATTRIBUTE_CHANGED_WILDCARD,
|
|
8529
|
-
|
|
10814
|
+
ATTRIBUTE_FIELD_METADATA_KEY,
|
|
8530
10815
|
BROWSER_GLOBALS,
|
|
8531
|
-
|
|
10816
|
+
CLASS_METADATA_KEY,
|
|
8532
10817
|
DOM_EVENT_NAMES,
|
|
8533
10818
|
ELEMENT_CONFIG_KEY,
|
|
8534
10819
|
EMIT_CUSTOM_EVENT_METADATA_KEY,
|
|
@@ -8546,12 +10831,11 @@ export {
|
|
|
8546
10831
|
ON_CONSTRUCTOR_METADATA_KEY,
|
|
8547
10832
|
QUERY_ALL_METADATA_KEY,
|
|
8548
10833
|
QUERY_METADATA_KEY,
|
|
8549
|
-
SET_ATTRIBUTE_METADATA_KEY,
|
|
8550
10834
|
STYLE_METADATA_KEY,
|
|
8551
10835
|
SWC_NOT_FOUND,
|
|
8552
10836
|
SwcUtils,
|
|
8553
|
-
|
|
8554
|
-
|
|
10837
|
+
addClass,
|
|
10838
|
+
addClassHost,
|
|
8555
10839
|
addEventListener,
|
|
8556
10840
|
addEventListenerHost,
|
|
8557
10841
|
allAppHost,
|
|
@@ -8562,26 +10846,18 @@ export {
|
|
|
8562
10846
|
allLastHost,
|
|
8563
10847
|
allParentHost,
|
|
8564
10848
|
appHost,
|
|
8565
|
-
|
|
8566
|
-
|
|
8567
|
-
|
|
8568
|
-
|
|
8569
|
-
applyBeforeBeginNode,
|
|
8570
|
-
applyBeforeBeginNodeHost,
|
|
8571
|
-
applyBeforeEndNode,
|
|
8572
|
-
applyBeforeEndNodeHost,
|
|
10849
|
+
applyAttribute,
|
|
10850
|
+
applyAttributeHost,
|
|
10851
|
+
applyClass,
|
|
10852
|
+
applyClassHost,
|
|
8573
10853
|
applyInnerHtmlNode,
|
|
8574
10854
|
applyInnerHtmlNodeHost,
|
|
8575
|
-
applyInnerTextNode,
|
|
8576
|
-
applyInnerTextNodeHost,
|
|
8577
10855
|
applyNode,
|
|
8578
10856
|
applyNodeHost,
|
|
8579
|
-
applyRemoveNode,
|
|
8580
|
-
applyRemoveNodeHost,
|
|
8581
10857
|
applyReplaceChildrenNode,
|
|
8582
10858
|
applyReplaceChildrenNodeHost,
|
|
8583
|
-
|
|
8584
|
-
|
|
10859
|
+
applyStyle,
|
|
10860
|
+
applyStyleHost,
|
|
8585
10861
|
attribute,
|
|
8586
10862
|
attributeHost,
|
|
8587
10863
|
changedAttributeHost,
|
|
@@ -8592,11 +10868,11 @@ export {
|
|
|
8592
10868
|
emitCustomEventHost,
|
|
8593
10869
|
ensureInit2 as ensureInit,
|
|
8594
10870
|
findAllApplyNodeMetadata,
|
|
10871
|
+
findAllAttributeApplyMetadata,
|
|
8595
10872
|
findAllAttributeChangedMetadata,
|
|
8596
10873
|
findAllAttributeMetadata,
|
|
8597
|
-
|
|
10874
|
+
findAllClassMetadata,
|
|
8598
10875
|
findAllLifecycleMetadata,
|
|
8599
|
-
findAllSetAttributeMetadata,
|
|
8600
10876
|
findAllStyleMetadata,
|
|
8601
10877
|
firstAppHost,
|
|
8602
10878
|
firstHost,
|
|
@@ -8607,7 +10883,6 @@ export {
|
|
|
8607
10883
|
getOnConnectedInnerHtmlMetadata,
|
|
8608
10884
|
getQueryAllMetadata,
|
|
8609
10885
|
getQueryMetadata,
|
|
8610
|
-
getSetAttributeMetadata,
|
|
8611
10886
|
host,
|
|
8612
10887
|
htmlAElement,
|
|
8613
10888
|
htmlArticleElement,
|
|
@@ -8639,22 +10914,26 @@ export {
|
|
|
8639
10914
|
queryAll,
|
|
8640
10915
|
queryAllHost,
|
|
8641
10916
|
queryHost,
|
|
8642
|
-
|
|
8643
|
-
|
|
10917
|
+
removeAttribute,
|
|
10918
|
+
removeAttributeHost,
|
|
10919
|
+
removeClass,
|
|
10920
|
+
removeClassHost,
|
|
8644
10921
|
removeStyle,
|
|
8645
10922
|
removeStyleHost,
|
|
8646
10923
|
resolveTargetEls,
|
|
8647
10924
|
setAttribute,
|
|
8648
10925
|
setAttributeHost,
|
|
8649
|
-
|
|
8650
|
-
|
|
10926
|
+
setClass,
|
|
10927
|
+
setClassHost,
|
|
8651
10928
|
setStyle,
|
|
8652
10929
|
setStyleHost,
|
|
8653
10930
|
textNode,
|
|
8654
|
-
|
|
8655
|
-
|
|
8656
|
-
|
|
8657
|
-
|
|
10931
|
+
toggleClass,
|
|
10932
|
+
toggleClassHost,
|
|
10933
|
+
updateAttribute,
|
|
10934
|
+
updateAttributeHost,
|
|
10935
|
+
updateClass,
|
|
10936
|
+
updateClassHost,
|
|
8658
10937
|
updateStyle,
|
|
8659
10938
|
updateStyleHost
|
|
8660
10939
|
};
|