@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.
Files changed (137) hide show
  1. package/dist/App.d.ts +1 -1
  2. package/dist/App.d.ts.map +1 -1
  3. package/dist/App.js.map +1 -1
  4. package/dist/core/SingleInvoker.d.ts.map +1 -1
  5. package/dist/core/SingleInvoker.js.map +1 -1
  6. package/dist/core/sleep.js.map +1 -1
  7. package/dist/tsconfig.tsbuildinfo +1 -1
  8. package/dist-esm/App.d.ts +1 -1
  9. package/dist-esm/App.d.ts.map +1 -1
  10. package/dist-esm/App.js +231 -235
  11. package/dist-esm/App.js.map +1 -1
  12. package/dist-esm/Atom.js +93 -96
  13. package/dist-esm/MockApp.js +17 -18
  14. package/dist-esm/Pack.js +1 -3
  15. package/dist-esm/core/AtomBinder.js +189 -187
  16. package/dist-esm/core/AtomComponent.js +479 -502
  17. package/dist-esm/core/AtomDispatcher.js +46 -48
  18. package/dist-esm/core/AtomDisposableList.js +24 -25
  19. package/dist-esm/core/AtomEnumerator.js +15 -16
  20. package/dist-esm/core/AtomList.js +193 -192
  21. package/dist-esm/core/AtomLoader.js +229 -215
  22. package/dist-esm/core/AtomMap.js +7 -8
  23. package/dist-esm/core/AtomOnce.js +22 -24
  24. package/dist-esm/core/AtomSelectableList.js +240 -243
  25. package/dist-esm/core/AtomUri.js +70 -72
  26. package/dist-esm/core/AtomWatcher.js +105 -111
  27. package/dist-esm/core/Bind.js +271 -269
  28. package/dist-esm/core/BindableProperty.js +26 -27
  29. package/dist-esm/core/CancelTokenFactory.js +21 -24
  30. package/dist-esm/core/Color.js +1 -2
  31. package/dist-esm/core/Colors.js +545 -231
  32. package/dist-esm/core/Command.js +236 -223
  33. package/dist-esm/core/Defer.js +21 -22
  34. package/dist-esm/core/EventScope.js +96 -88
  35. package/dist-esm/core/ExpressionParser.js +132 -144
  36. package/dist-esm/core/ExtendControl.js +7 -8
  37. package/dist-esm/core/FormattedError.js +7 -8
  38. package/dist-esm/core/FormattedString.js +4 -5
  39. package/dist-esm/core/Hacks.js +41 -42
  40. package/dist-esm/core/IFetchEvent.js +1 -2
  41. package/dist-esm/core/IScreen.js +1 -2
  42. package/dist-esm/core/IValueConverter.js +1 -2
  43. package/dist-esm/core/InheritedProperty.js +61 -63
  44. package/dist-esm/core/InjectProperty.js +12 -13
  45. package/dist-esm/core/KeyValuePairs.js +1 -2
  46. package/dist-esm/core/Markdown.js +14 -17
  47. package/dist-esm/core/MarkdownError.js +6 -7
  48. package/dist-esm/core/PropertyBinding.js +1 -2
  49. package/dist-esm/core/PropertyMap.js +28 -27
  50. package/dist-esm/core/Route.js +149 -148
  51. package/dist-esm/core/SingleInvoker.d.ts.map +1 -1
  52. package/dist-esm/core/SingleInvoker.js +32 -35
  53. package/dist-esm/core/SingleInvoker.js.map +1 -1
  54. package/dist-esm/core/StringHelper.js +49 -51
  55. package/dist-esm/core/TransientDisposable.js +14 -16
  56. package/dist-esm/core/WatchProperty.js +18 -17
  57. package/dist-esm/core/WebImage.js +7 -8
  58. package/dist-esm/core/XNode.js +134 -117
  59. package/dist-esm/core/sleep.js +21 -24
  60. package/dist-esm/core/sleep.js.map +1 -1
  61. package/dist-esm/core/types.js +102 -103
  62. package/dist-esm/di/DISingleton.js +7 -5
  63. package/dist-esm/di/DITransient.js +7 -5
  64. package/dist-esm/di/IMockOrInject.js +1 -2
  65. package/dist-esm/di/IServiceProvider.js +1 -2
  66. package/dist-esm/di/Inject.js +67 -67
  67. package/dist-esm/di/Register.js +25 -26
  68. package/dist-esm/di/RegisterScoped.js +4 -3
  69. package/dist-esm/di/RegisterSingleton.js +4 -3
  70. package/dist-esm/di/ServiceCollection.js +38 -37
  71. package/dist-esm/di/ServiceProvider.js +94 -94
  72. package/dist-esm/di/TypeKey.js +13 -12
  73. package/dist-esm/services/BusyIndicatorService.js +7 -11
  74. package/dist-esm/services/CacheService.js +54 -62
  75. package/dist-esm/services/FetchBuilder.js +327 -278
  76. package/dist-esm/services/JsonService.js +118 -116
  77. package/dist-esm/services/MockNavigationService.js +127 -126
  78. package/dist-esm/services/NavigationService.js +95 -102
  79. package/dist-esm/services/ReferenceService.js +30 -33
  80. package/dist-esm/services/http/AjaxOptions.js +1 -3
  81. package/dist-esm/services/http/JsonError.js +16 -15
  82. package/dist-esm/services/http/RestService.js +314 -323
  83. package/dist-esm/style/StyleRule.js +1 -2
  84. package/dist-esm/test.js +0 -1
  85. package/dist-esm/tsconfig.esm.tsbuildinfo +1 -1
  86. package/dist-esm/unit/AtomTest.js +10 -11
  87. package/dist-esm/view-model/Action.js +258 -223
  88. package/dist-esm/view-model/AtomViewModel.js +234 -232
  89. package/dist-esm/view-model/AtomWindowViewModel.js +13 -14
  90. package/dist-esm/view-model/BindableUrlParameter.js +7 -8
  91. package/dist-esm/view-model/Delay.js +21 -25
  92. package/dist-esm/view-model/Disposable.js +28 -29
  93. package/dist-esm/view-model/Load.js +72 -73
  94. package/dist-esm/view-model/Once.js +33 -35
  95. package/dist-esm/view-model/baseTypes.js +4 -5
  96. package/dist-esm/view-model/bindPromise.js +24 -27
  97. package/dist-esm/view-model/bindProperty.js +3 -4
  98. package/dist-esm/view-model/bindUrlParameter.js +39 -43
  99. package/dist-esm/web/controls/AtomComboBox.js +56 -63
  100. package/dist-esm/web/controls/AtomControl.js +485 -490
  101. package/dist-esm/web/controls/AtomGridSplitter.js +57 -50
  102. package/dist-esm/web/controls/AtomGridView.js +230 -222
  103. package/dist-esm/web/controls/AtomItemsControl.js +677 -688
  104. package/dist-esm/web/controls/AtomPage.js +6 -7
  105. package/dist-esm/web/controls/AtomTemplate.js +1 -3
  106. package/dist-esm/web/controls/AtomTemplateControl.js +28 -29
  107. package/dist-esm/web/controls/AtomViewStack.js +19 -20
  108. package/dist-esm/web/core/AtomUI.js +200 -200
  109. package/dist-esm/web/core/Encoder.js +142 -152
  110. package/dist-esm/web/core/HtmlNode.js +141 -139
  111. package/dist-esm/web/images/Busy.js +1 -2
  112. package/dist-esm/web/images/BusyDataUrl.js +2 -869
  113. package/dist-esm/web/images/Button.js +1 -2
  114. package/dist-esm/web/images/ButtonDataUrl.js +2 -30
  115. package/dist-esm/web/images/CloseButton.js +1 -2
  116. package/dist-esm/web/images/CloseButtonDataUrl.js +2 -30
  117. package/dist-esm/web/images/CloseButtonHover.js +1 -2
  118. package/dist-esm/web/images/CloseButtonHoverDataUrl.js +2 -24
  119. package/dist-esm/web/services/LastTarget.js +31 -29
  120. package/dist-esm/web/services/MarkdownService.js +19 -31
  121. package/dist-esm/web/services/NotificationPopup.js +28 -21
  122. package/dist-esm/web/services/PopupService.js +512 -478
  123. package/dist-esm/web/services/PopupWindow.js +266 -247
  124. package/dist-esm/web/styles/AtomAlertWindowStyle.js +39 -40
  125. package/dist-esm/web/styles/AtomFrameStyle.js +15 -16
  126. package/dist-esm/web/styles/AtomNotificationStyle.js +19 -20
  127. package/dist-esm/web/styles/AtomPageLinkStyle.js +11 -12
  128. package/dist-esm/web/styles/AtomPopupStyle.js +9 -10
  129. package/dist-esm/web/styles/AtomStyle.js +61 -64
  130. package/dist-esm/web/styles/AtomStyleSheet.js +50 -51
  131. package/dist-esm/web/styles/AtomWindowStyle.js +116 -117
  132. package/dist-esm/web/styles/IStyleDeclaration.js +1 -2
  133. package/dist-esm/web/styles/StyleBuilder.js +79 -80
  134. package/package.json +3 -1
  135. package/src/App.ts +1 -1
  136. package/src/core/SingleInvoker.ts +1 -1
  137. 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
- return cache[name] ??= Symbol(name);
4
+ return cache[name] ??= Symbol(name);
5
5
  }
6
6
  function refreshInherited(ac, key, storageKey) {
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
- }
26
- else {
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
- return target[getSymbolKey(key)];
37
+ return target[getSymbolKey(key)];
39
38
  }
40
39
  export function InheritedProperty(target, key) {
41
- const iVal = target[key];
42
- const keyName = getSymbolKey(key);
43
- target[keyName] = iVal;
44
- const getter = function () {
45
- let start = this;
46
- do {
47
- const p = start[keyName];
48
- if (typeof p !== "undefined") {
49
- return p;
50
- }
51
- if (!start.element) {
52
- break;
53
- }
54
- start = start.parent;
55
- } while (start);
56
- return undefined;
57
- };
58
- const setter = function (newVal) {
59
- const oldValue = this[keyName];
60
- if (oldValue && oldValue.dispose) {
61
- oldValue.dispose();
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
- //# sourceMappingURL=InheritedProperty.js.map
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
- 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
- }
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
- 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
15
- ? app.resolve(MarkdownService)
16
- : MarkdownService.instance;
17
- return ms.toHtml(this.text);
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
- constructor(text) {
5
- const a = super(Markdown.from(text));
6
- a.__proto__ = MarkdownError.prototype;
7
- return a;
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
- 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 { this.map = {}; }
11
- static createMap(c) {
12
- const map = {};
13
- const nameList = [];
14
- while (c) {
15
- const names = Object.getOwnPropertyNames(c);
16
- for (const name of names) {
17
- if (/hasOwnProperty|constructor|toString|isValid|errors/i.test(name)) {
18
- continue;
19
- }
20
- map[name] = true;
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
- const m = new PropertyMap();
26
- m.map = map;
27
- m.names = nameList;
28
- return m;
22
+ map[name] = true;
23
+ nameList.push(name);
24
+ }
25
+ c = Object.getPrototypeOf(c);
29
26
  }
30
- }
31
- //# sourceMappingURL=PropertyMap.js.map
27
+ const m = new PropertyMap();
28
+ m.map = map;
29
+ m.names = nameList;
30
+ return m;
31
+ }
32
+ }
@@ -1,165 +1,166 @@
1
1
  import { StringHelper } from "./StringHelper.js";
2
2
  export class Variable {
3
- get regex() {
4
- if (this.catchAll) {
5
- return `(/(?<${this.variable}>.+)?)?`;
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
- 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;
41
- }
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;
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
- this.variable = variable;
58
- this.name ??= variable;
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
- static encodeUrl(url) {
63
- return url;
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
- static create(route, queries, order = 0) {
66
- if (!route.startsWith("/")) {
67
- throw new Error("String Route must start with /");
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
- return new Route(route, queries, order);
83
+ this.queries.set(name, variable);
84
+ }
70
85
  }
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);
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
- let catchAll = false;
90
- for (const iterator of tokens) {
91
- if (regex.length > 2) {
92
- this.substitutions.push("/");
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;
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
- if (!catchAll) {
115
- regex += "\\/?$";
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
- this.regex = new RegExp(regex, "i");
141
+ }
142
+ return result;
118
143
  }
119
- matches(route, q) {
120
- const matches = this.regex.exec(route);
121
- if (matches?.length > 0) {
122
- const result = {};
123
- const { groups } = matches;
124
- for (const iterator of this.variables) {
125
- const v = groups[iterator.variable];
126
- if (v !== void 0 && v !== null) {
127
- const converted = iterator.convert(decodeURIComponent(v));
128
- if (converted === void 0) {
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
- substitute(vars) {
145
- let result = "";
146
- for (const iterator of this.substitutions) {
147
- if (typeof iterator === "string") {
148
- result += iterator;
149
- continue;
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
- if (this.queries.size > 0) {
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
- //# sourceMappingURL=Route.js.map
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,CAA6B;IAElC,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"}
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"}