@web-atoms/core 2.6.21 → 2.6.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/App.d.ts +1 -1
- package/dist/App.d.ts.map +1 -1
- package/dist/App.js.map +1 -1
- package/dist/core/SingleInvoker.d.ts.map +1 -1
- package/dist/core/SingleInvoker.js.map +1 -1
- package/dist/core/sleep.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist-esm/App.d.ts +1 -1
- package/dist-esm/App.d.ts.map +1 -1
- package/dist-esm/App.js +231 -235
- package/dist-esm/App.js.map +1 -1
- package/dist-esm/Atom.js +93 -96
- package/dist-esm/MockApp.js +17 -18
- package/dist-esm/Pack.js +1 -3
- package/dist-esm/core/AtomBinder.js +189 -187
- package/dist-esm/core/AtomComponent.js +479 -502
- package/dist-esm/core/AtomDispatcher.js +46 -48
- package/dist-esm/core/AtomDisposableList.js +24 -25
- package/dist-esm/core/AtomEnumerator.js +15 -16
- package/dist-esm/core/AtomList.js +193 -192
- package/dist-esm/core/AtomLoader.js +229 -215
- package/dist-esm/core/AtomMap.js +7 -8
- package/dist-esm/core/AtomOnce.js +22 -24
- package/dist-esm/core/AtomSelectableList.js +240 -243
- package/dist-esm/core/AtomUri.js +70 -72
- package/dist-esm/core/AtomWatcher.js +105 -111
- package/dist-esm/core/Bind.js +271 -269
- package/dist-esm/core/BindableProperty.js +26 -27
- package/dist-esm/core/CancelTokenFactory.js +21 -24
- package/dist-esm/core/Color.js +1 -2
- package/dist-esm/core/Colors.js +545 -231
- package/dist-esm/core/Command.js +236 -223
- package/dist-esm/core/Defer.js +21 -22
- package/dist-esm/core/EventScope.js +96 -88
- package/dist-esm/core/ExpressionParser.js +132 -144
- package/dist-esm/core/ExtendControl.js +7 -8
- package/dist-esm/core/FormattedError.js +7 -8
- package/dist-esm/core/FormattedString.js +4 -5
- package/dist-esm/core/Hacks.js +41 -42
- package/dist-esm/core/IFetchEvent.js +1 -2
- package/dist-esm/core/IScreen.js +1 -2
- package/dist-esm/core/IValueConverter.js +1 -2
- package/dist-esm/core/InheritedProperty.js +61 -63
- package/dist-esm/core/InjectProperty.js +12 -13
- package/dist-esm/core/KeyValuePairs.js +1 -2
- package/dist-esm/core/Markdown.js +14 -17
- package/dist-esm/core/MarkdownError.js +6 -7
- package/dist-esm/core/PropertyBinding.js +1 -2
- package/dist-esm/core/PropertyMap.js +28 -27
- package/dist-esm/core/Route.js +149 -148
- package/dist-esm/core/SingleInvoker.d.ts.map +1 -1
- package/dist-esm/core/SingleInvoker.js +32 -35
- package/dist-esm/core/SingleInvoker.js.map +1 -1
- package/dist-esm/core/StringHelper.js +49 -51
- package/dist-esm/core/TransientDisposable.js +14 -16
- package/dist-esm/core/WatchProperty.js +18 -17
- package/dist-esm/core/WebImage.js +7 -8
- package/dist-esm/core/XNode.js +134 -117
- package/dist-esm/core/sleep.js +21 -24
- package/dist-esm/core/sleep.js.map +1 -1
- package/dist-esm/core/types.js +102 -103
- package/dist-esm/di/DISingleton.js +7 -5
- package/dist-esm/di/DITransient.js +7 -5
- package/dist-esm/di/IMockOrInject.js +1 -2
- package/dist-esm/di/IServiceProvider.js +1 -2
- package/dist-esm/di/Inject.js +67 -67
- package/dist-esm/di/Register.js +25 -26
- package/dist-esm/di/RegisterScoped.js +4 -3
- package/dist-esm/di/RegisterSingleton.js +4 -3
- package/dist-esm/di/ServiceCollection.js +38 -37
- package/dist-esm/di/ServiceProvider.js +94 -94
- package/dist-esm/di/TypeKey.js +13 -12
- package/dist-esm/services/BusyIndicatorService.js +7 -11
- package/dist-esm/services/CacheService.js +54 -62
- package/dist-esm/services/FetchBuilder.js +327 -278
- package/dist-esm/services/JsonService.js +118 -116
- package/dist-esm/services/MockNavigationService.js +127 -126
- package/dist-esm/services/NavigationService.js +95 -102
- package/dist-esm/services/ReferenceService.js +30 -33
- package/dist-esm/services/http/AjaxOptions.js +1 -3
- package/dist-esm/services/http/JsonError.js +16 -15
- package/dist-esm/services/http/RestService.js +314 -323
- package/dist-esm/style/StyleRule.js +1 -2
- package/dist-esm/test.js +0 -1
- package/dist-esm/tsconfig.esm.tsbuildinfo +1 -1
- package/dist-esm/unit/AtomTest.js +10 -11
- package/dist-esm/view-model/Action.js +258 -223
- package/dist-esm/view-model/AtomViewModel.js +234 -232
- package/dist-esm/view-model/AtomWindowViewModel.js +13 -14
- package/dist-esm/view-model/BindableUrlParameter.js +7 -8
- package/dist-esm/view-model/Delay.js +21 -25
- package/dist-esm/view-model/Disposable.js +28 -29
- package/dist-esm/view-model/Load.js +72 -73
- package/dist-esm/view-model/Once.js +33 -35
- package/dist-esm/view-model/baseTypes.js +4 -5
- package/dist-esm/view-model/bindPromise.js +24 -27
- package/dist-esm/view-model/bindProperty.js +3 -4
- package/dist-esm/view-model/bindUrlParameter.js +39 -43
- package/dist-esm/web/controls/AtomComboBox.js +56 -63
- package/dist-esm/web/controls/AtomControl.js +485 -490
- package/dist-esm/web/controls/AtomGridSplitter.js +57 -50
- package/dist-esm/web/controls/AtomGridView.js +230 -222
- package/dist-esm/web/controls/AtomItemsControl.js +677 -688
- package/dist-esm/web/controls/AtomPage.js +6 -7
- package/dist-esm/web/controls/AtomTemplate.js +1 -3
- package/dist-esm/web/controls/AtomTemplateControl.js +28 -29
- package/dist-esm/web/controls/AtomViewStack.js +19 -20
- package/dist-esm/web/core/AtomUI.js +200 -200
- package/dist-esm/web/core/Encoder.js +142 -152
- package/dist-esm/web/core/HtmlNode.js +141 -139
- package/dist-esm/web/images/Busy.js +1 -2
- package/dist-esm/web/images/BusyDataUrl.js +2 -869
- package/dist-esm/web/images/Button.js +1 -2
- package/dist-esm/web/images/ButtonDataUrl.js +2 -30
- package/dist-esm/web/images/CloseButton.js +1 -2
- package/dist-esm/web/images/CloseButtonDataUrl.js +2 -30
- package/dist-esm/web/images/CloseButtonHover.js +1 -2
- package/dist-esm/web/images/CloseButtonHoverDataUrl.js +2 -24
- package/dist-esm/web/services/LastTarget.js +31 -29
- package/dist-esm/web/services/MarkdownService.js +19 -31
- package/dist-esm/web/services/NotificationPopup.js +28 -21
- package/dist-esm/web/services/PopupService.js +512 -478
- package/dist-esm/web/services/PopupWindow.js +266 -247
- package/dist-esm/web/styles/AtomAlertWindowStyle.js +39 -40
- package/dist-esm/web/styles/AtomFrameStyle.js +15 -16
- package/dist-esm/web/styles/AtomNotificationStyle.js +19 -20
- package/dist-esm/web/styles/AtomPageLinkStyle.js +11 -12
- package/dist-esm/web/styles/AtomPopupStyle.js +9 -10
- package/dist-esm/web/styles/AtomStyle.js +61 -64
- package/dist-esm/web/styles/AtomStyleSheet.js +50 -51
- package/dist-esm/web/styles/AtomWindowStyle.js +116 -117
- package/dist-esm/web/styles/IStyleDeclaration.js +1 -2
- package/dist-esm/web/styles/StyleBuilder.js +79 -80
- package/package.json +3 -1
- package/src/App.ts +1 -1
- package/src/core/SingleInvoker.ts +1 -1
- package/src/core/sleep.ts +1 -1
|
@@ -1,75 +1,73 @@
|
|
|
1
1
|
import { AtomBinder } from "./AtomBinder.js";
|
|
2
2
|
const cache = {};
|
|
3
3
|
function getSymbolKey(name) {
|
|
4
|
-
|
|
4
|
+
return cache[name] ??= Symbol(name);
|
|
5
5
|
}
|
|
6
6
|
function refreshInherited(ac, key, storageKey) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
firstChild = void 0;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
if (firstChild) {
|
|
31
|
-
stack.push(firstChild);
|
|
32
|
-
}
|
|
33
|
-
start = start.nextElementSibling;
|
|
7
|
+
const e = ac.element;
|
|
8
|
+
if (!e) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
AtomBinder.refreshValue(ac, key);
|
|
12
|
+
let start = e.firstElementChild;
|
|
13
|
+
if (!start) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
const stack = [start];
|
|
17
|
+
while (stack.length) {
|
|
18
|
+
start = stack.pop();
|
|
19
|
+
while (start) {
|
|
20
|
+
let firstChild = start.firstElementChild;
|
|
21
|
+
const childControl = start.atomControl;
|
|
22
|
+
if (childControl) {
|
|
23
|
+
if (childControl[storageKey] === undefined) {
|
|
24
|
+
AtomBinder.refreshValue(childControl, key);
|
|
25
|
+
} else {
|
|
26
|
+
firstChild = void 0;
|
|
34
27
|
}
|
|
28
|
+
}
|
|
29
|
+
if (firstChild) {
|
|
30
|
+
stack.push(firstChild);
|
|
31
|
+
}
|
|
32
|
+
start = start.nextElementSibling;
|
|
35
33
|
}
|
|
34
|
+
}
|
|
36
35
|
}
|
|
37
36
|
export function getOwnInheritedProperty(target, key) {
|
|
38
|
-
|
|
37
|
+
return target[getSymbolKey(key)];
|
|
39
38
|
}
|
|
40
39
|
export function InheritedProperty(target, key) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
63
|
-
this[keyName] = newVal;
|
|
64
|
-
refreshInherited(this, key, keyName);
|
|
65
|
-
};
|
|
66
|
-
if (delete target[key]) {
|
|
67
|
-
Object.defineProperty(target, key, {
|
|
68
|
-
get: getter,
|
|
69
|
-
set: setter,
|
|
70
|
-
enumerable: true,
|
|
71
|
-
configurable: true
|
|
72
|
-
});
|
|
40
|
+
const iVal = target[key];
|
|
41
|
+
const keyName = getSymbolKey(key);
|
|
42
|
+
target[keyName] = iVal;
|
|
43
|
+
const getter = function () {
|
|
44
|
+
let start = this;
|
|
45
|
+
do {
|
|
46
|
+
const p = start[keyName];
|
|
47
|
+
if (typeof p !== "undefined") {
|
|
48
|
+
return p;
|
|
49
|
+
}
|
|
50
|
+
if (!start.element) {
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
start = start.parent;
|
|
54
|
+
} while (start);
|
|
55
|
+
return undefined;
|
|
56
|
+
};
|
|
57
|
+
const setter = function (newVal) {
|
|
58
|
+
const oldValue = this[keyName];
|
|
59
|
+
if (oldValue && oldValue.dispose) {
|
|
60
|
+
oldValue.dispose();
|
|
73
61
|
}
|
|
74
|
-
|
|
75
|
-
|
|
62
|
+
this[keyName] = newVal;
|
|
63
|
+
refreshInherited(this, key, keyName);
|
|
64
|
+
};
|
|
65
|
+
if (delete target[key]) {
|
|
66
|
+
Object.defineProperty(target, key, {
|
|
67
|
+
get: getter,
|
|
68
|
+
set: setter,
|
|
69
|
+
enumerable: true,
|
|
70
|
+
configurable: true
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
export default function InjectProperty(target, key) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
//# sourceMappingURL=InjectProperty.js.map
|
|
2
|
+
Object.defineProperty(target, key, {
|
|
3
|
+
get: function () {
|
|
4
|
+
const plist = Reflect.getMetadata("design:type", target, key);
|
|
5
|
+
const result = this.app.resolve(plist);
|
|
6
|
+
Object.defineProperty(this, key, {
|
|
7
|
+
get: () => result
|
|
8
|
+
});
|
|
9
|
+
return result;
|
|
10
|
+
},
|
|
11
|
+
configurable: true
|
|
12
|
+
});
|
|
13
|
+
}
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export {};
|
|
2
|
-
//# sourceMappingURL=KeyValuePairs.js.map
|
|
1
|
+
export {};
|
|
@@ -1,20 +1,17 @@
|
|
|
1
1
|
import MarkdownService from "../web/services/MarkdownService.js";
|
|
2
2
|
import FormattedString from "./FormattedString.js";
|
|
3
3
|
export default class Markdown extends FormattedString {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
//# sourceMappingURL=Markdown.js.map
|
|
4
|
+
static from(text) {
|
|
5
|
+
return new Markdown(text);
|
|
6
|
+
}
|
|
7
|
+
applyTo(app, element) {
|
|
8
|
+
element.innerHTML = this.toHtmlString(app);
|
|
9
|
+
}
|
|
10
|
+
toString() {
|
|
11
|
+
return this.text;
|
|
12
|
+
}
|
|
13
|
+
toHtmlString(app) {
|
|
14
|
+
const ms = app ? app.resolve(MarkdownService) : MarkdownService.instance;
|
|
15
|
+
return ms.toHtml(this.text);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import FormattedError from "./FormattedError.js";
|
|
2
2
|
import Markdown from "./Markdown.js";
|
|
3
3
|
export default class MarkdownError extends FormattedError {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
//# sourceMappingURL=MarkdownError.js.map
|
|
4
|
+
constructor(text) {
|
|
5
|
+
const a = super(Markdown.from(text));
|
|
6
|
+
a.__proto__ = MarkdownError.prototype;
|
|
7
|
+
return a;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export { PropertyBinding } from "./AtomComponent.js";
|
|
2
|
-
//# sourceMappingURL=PropertyBinding.js.map
|
|
1
|
+
export { PropertyBinding } from "./AtomComponent.js";
|
|
@@ -1,31 +1,32 @@
|
|
|
1
1
|
import { TypeKey } from "../di/TypeKey.js";
|
|
2
2
|
export class PropertyMap {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
nameList.push(name);
|
|
22
|
-
}
|
|
23
|
-
c = Object.getPrototypeOf(c);
|
|
3
|
+
static from(o) {
|
|
4
|
+
const c = Object.getPrototypeOf(o);
|
|
5
|
+
const key = TypeKey.get(c);
|
|
6
|
+
const map = PropertyMap.map;
|
|
7
|
+
const m = map[key] || (map[key] = PropertyMap.createMap(o));
|
|
8
|
+
return m;
|
|
9
|
+
}
|
|
10
|
+
static {
|
|
11
|
+
this.map = {};
|
|
12
|
+
}
|
|
13
|
+
static createMap(c) {
|
|
14
|
+
const map = {};
|
|
15
|
+
const nameList = [];
|
|
16
|
+
while (c) {
|
|
17
|
+
const names = Object.getOwnPropertyNames(c);
|
|
18
|
+
for (const name of names) {
|
|
19
|
+
if (/hasOwnProperty|constructor|toString|isValid|errors/i.test(name)) {
|
|
20
|
+
continue;
|
|
24
21
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
22
|
+
map[name] = true;
|
|
23
|
+
nameList.push(name);
|
|
24
|
+
}
|
|
25
|
+
c = Object.getPrototypeOf(c);
|
|
29
26
|
}
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
const m = new PropertyMap();
|
|
28
|
+
m.map = map;
|
|
29
|
+
m.names = nameList;
|
|
30
|
+
return m;
|
|
31
|
+
}
|
|
32
|
+
}
|
package/dist-esm/core/Route.js
CHANGED
|
@@ -1,165 +1,166 @@
|
|
|
1
1
|
import { StringHelper } from "./StringHelper.js";
|
|
2
2
|
export class Variable {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
let r = "[^\\/]{1,500}";
|
|
8
|
-
if (this.parseAsNumber) {
|
|
9
|
-
r = "[0-9]{1,500}";
|
|
10
|
-
}
|
|
11
|
-
if (this.optional) {
|
|
12
|
-
return `(/(?<${this.variable}>${r}))?`;
|
|
13
|
-
}
|
|
14
|
-
return `/${StringHelper.escapeRegExp(this.prefix)}(?<${this.variable}>${r})${StringHelper.escapeRegExp(this.suffix)}`;
|
|
3
|
+
get regex() {
|
|
4
|
+
if (this.catchAll) {
|
|
5
|
+
return `(/(?<${this.variable}>.+)?)?`;
|
|
15
6
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
if (v === "false") {
|
|
51
|
-
return false;
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
break;
|
|
7
|
+
let r = "[^\\/]{1,500}";
|
|
8
|
+
if (this.parseAsNumber) {
|
|
9
|
+
r = "[0-9]{1,500}";
|
|
10
|
+
}
|
|
11
|
+
if (this.optional) {
|
|
12
|
+
return `(/(?<${this.variable}>${r}))?`;
|
|
13
|
+
}
|
|
14
|
+
return `/${StringHelper.escapeRegExp(this.prefix)}(?<${this.variable}>${r})${StringHelper.escapeRegExp(this.suffix)}`;
|
|
15
|
+
}
|
|
16
|
+
constructor(variable, name) {
|
|
17
|
+
this.variable = variable;
|
|
18
|
+
this.name = name;
|
|
19
|
+
this.prefix = "";
|
|
20
|
+
this.suffix = "";
|
|
21
|
+
this.convert = v => v;
|
|
22
|
+
if (variable.startsWith("*")) {
|
|
23
|
+
this.catchAll = true;
|
|
24
|
+
variable = variable.substring(1);
|
|
25
|
+
}
|
|
26
|
+
if (variable.endsWith("?")) {
|
|
27
|
+
this.optional = true;
|
|
28
|
+
variable = variable.substring(0, variable.length - 1);
|
|
29
|
+
}
|
|
30
|
+
const index = variable.indexOf(":");
|
|
31
|
+
if (index !== -1) {
|
|
32
|
+
const parseAs = variable.substring(index + 1);
|
|
33
|
+
variable = variable.substring(0, index);
|
|
34
|
+
switch (parseAs) {
|
|
35
|
+
case "number":
|
|
36
|
+
this.parseAsNumber = true;
|
|
37
|
+
this.convert = v => {
|
|
38
|
+
const r = parseFloat(v);
|
|
39
|
+
if (Number.isNaN(r)) {
|
|
40
|
+
return void 0;
|
|
55
41
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
42
|
+
return r;
|
|
43
|
+
};
|
|
44
|
+
break;
|
|
45
|
+
case "boolean":
|
|
46
|
+
this.convert = v => {
|
|
47
|
+
if (v === "true") {
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
if (v === "false") {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
break;
|
|
55
|
+
}
|
|
59
56
|
}
|
|
57
|
+
this.variable = variable;
|
|
58
|
+
this.name ??= variable;
|
|
59
|
+
}
|
|
60
60
|
}
|
|
61
61
|
export default class Route {
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
static encodeUrl(url) {
|
|
63
|
+
return url;
|
|
64
|
+
}
|
|
65
|
+
static create(route, queries, order = 0) {
|
|
66
|
+
if (!route.startsWith("/")) {
|
|
67
|
+
throw new Error("String Route must start with /");
|
|
64
68
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
69
|
+
return new Route(route, queries, order);
|
|
70
|
+
}
|
|
71
|
+
constructor(route, queries, order = 0) {
|
|
72
|
+
this.route = route;
|
|
73
|
+
this.order = order;
|
|
74
|
+
this.queries = new Map();
|
|
75
|
+
this.variables = [];
|
|
76
|
+
this.substitutions = [];
|
|
77
|
+
if (queries) {
|
|
78
|
+
for (const iterator of queries) {
|
|
79
|
+
let [name, variable = name] = iterator.split("=");
|
|
80
|
+
if (variable.startsWith("{")) {
|
|
81
|
+
variable = variable.substring(1, variable.length - 1);
|
|
68
82
|
}
|
|
69
|
-
|
|
83
|
+
this.queries.set(name, variable);
|
|
84
|
+
}
|
|
70
85
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
if (queries) {
|
|
78
|
-
for (const iterator of queries) {
|
|
79
|
-
let [name, variable = name] = iterator.split("=");
|
|
80
|
-
if (variable.startsWith("{")) {
|
|
81
|
-
variable = variable.substring(1, variable.length - 1);
|
|
82
|
-
}
|
|
83
|
-
this.queries.set(name, variable);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
const tokens = route.substring(1).split(/\//g);
|
|
87
|
-
let regex = "^";
|
|
86
|
+
const tokens = route.substring(1).split(/\//g);
|
|
87
|
+
let regex = "^";
|
|
88
|
+
this.substitutions.push("/");
|
|
89
|
+
let catchAll = false;
|
|
90
|
+
for (const iterator of tokens) {
|
|
91
|
+
if (regex.length > 2) {
|
|
88
92
|
this.substitutions.push("/");
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
93
|
+
}
|
|
94
|
+
const match = /\{(\*?[\p{L}:]{1,50}\??)\}/u.exec(iterator);
|
|
95
|
+
if (!match) {
|
|
96
|
+
this.substitutions.push(iterator);
|
|
97
|
+
regex += StringHelper.escapeRegExp("/");
|
|
98
|
+
regex += StringHelper.escapeRegExp(iterator);
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
const start = match.index;
|
|
102
|
+
const index = match[0].length;
|
|
103
|
+
const name = match[1];
|
|
104
|
+
const prefix = iterator.substring(0, start);
|
|
105
|
+
const suffix = iterator.substring(index + 1);
|
|
106
|
+
const v = new Variable(name);
|
|
107
|
+
v.prefix = prefix;
|
|
108
|
+
v.suffix = suffix;
|
|
109
|
+
regex += v.regex;
|
|
110
|
+
this.variables.push(v);
|
|
111
|
+
this.substitutions.push(v);
|
|
112
|
+
catchAll ||= v.catchAll;
|
|
113
|
+
}
|
|
114
|
+
if (!catchAll) {
|
|
115
|
+
regex += "\\/?$";
|
|
116
|
+
}
|
|
117
|
+
this.regex = new RegExp(regex, "i");
|
|
118
|
+
}
|
|
119
|
+
matches(route, q) {
|
|
120
|
+
const matches = this.regex.exec(route);
|
|
121
|
+
if (matches?.length > 0) {
|
|
122
|
+
const result = {};
|
|
123
|
+
const {
|
|
124
|
+
groups
|
|
125
|
+
} = matches;
|
|
126
|
+
for (const iterator of this.variables) {
|
|
127
|
+
const v = groups[iterator.variable];
|
|
128
|
+
if (v !== void 0 && v !== null) {
|
|
129
|
+
const converted = iterator.convert(decodeURIComponent(v));
|
|
130
|
+
if (converted === void 0) {
|
|
131
|
+
return null;
|
|
132
|
+
}
|
|
133
|
+
result[iterator.variable] = converted;
|
|
113
134
|
}
|
|
114
|
-
|
|
115
|
-
|
|
135
|
+
}
|
|
136
|
+
if (q) {
|
|
137
|
+
for (let [key, value] of q.entries()) {
|
|
138
|
+
const variable = this.queries.get(key) ?? key;
|
|
139
|
+
result[variable] = value;
|
|
116
140
|
}
|
|
117
|
-
|
|
141
|
+
}
|
|
142
|
+
return result;
|
|
118
143
|
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
return null;
|
|
130
|
-
}
|
|
131
|
-
result[iterator.variable] = converted;
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
if (q) {
|
|
135
|
-
for (let [key, value] of q.entries()) {
|
|
136
|
-
const variable = this.queries.get(key) ?? key;
|
|
137
|
-
result[variable] = value;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
return result;
|
|
141
|
-
}
|
|
142
|
-
return null;
|
|
144
|
+
return null;
|
|
145
|
+
}
|
|
146
|
+
substitute(vars) {
|
|
147
|
+
let result = "";
|
|
148
|
+
for (const iterator of this.substitutions) {
|
|
149
|
+
if (typeof iterator === "string") {
|
|
150
|
+
result += iterator;
|
|
151
|
+
continue;
|
|
152
|
+
}
|
|
153
|
+
result += vars[iterator.variable] ?? "";
|
|
143
154
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
}
|
|
151
|
-
result += vars[iterator.variable] ?? "";
|
|
155
|
+
if (this.queries.size > 0) {
|
|
156
|
+
result += "?";
|
|
157
|
+
for (const [key, variable] of this.queries.entries()) {
|
|
158
|
+
const value = vars[variable];
|
|
159
|
+
if (value) {
|
|
160
|
+
result += `${encodeURIComponent(key)}=${encodeURIComponent(value)}&`;
|
|
152
161
|
}
|
|
153
|
-
|
|
154
|
-
result += "?";
|
|
155
|
-
for (const [key, variable] of this.queries.entries()) {
|
|
156
|
-
const value = vars[variable];
|
|
157
|
-
if (value) {
|
|
158
|
-
result += `${encodeURIComponent(key)}=${encodeURIComponent(value)}&`;
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
return result;
|
|
162
|
+
}
|
|
163
163
|
}
|
|
164
|
-
|
|
165
|
-
|
|
164
|
+
return result;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SingleInvoker.d.ts","sourceRoot":"","sources":["../../src/core/SingleInvoker.ts"],"names":[],"mappings":"AACA,OAAO,mBAAmB,MAAM,0BAA0B,CAAC;AAI3D,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,mBAAmB;IAE1D,OAAO,CAAC,IAAI,
|
|
1
|
+
{"version":3,"file":"SingleInvoker.d.ts","sourceRoot":"","sources":["../../src/core/SingleInvoker.ts"],"names":[],"mappings":"AACA,OAAO,mBAAmB,MAAM,0BAA0B,CAAC;AAI3D,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,mBAAmB;IAE1D,OAAO,CAAC,IAAI,CAA0B;IAE/B,OAAO;IAQP,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE,QAAQ,EAAE,KAAK,GAAE,MAAY,GAAG,IAAI;IAa5D,KAAK,CAAC,EAAE,EAAE,QAAQ,EAAE,KAAK,GAAE,MAAU,EAAE,GAAG,CAAC,EAAE,MAAM,GAAI,IAAI;CAarE"}
|