@angular-wave/angular.ts 0.7.7 → 0.7.8

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 (157) hide show
  1. package/@types/animations/raf-scheduler.d.ts +2 -2
  2. package/@types/animations/shared.d.ts +0 -1
  3. package/@types/core/compile/attributes.d.ts +3 -3
  4. package/@types/core/compile/compile.d.ts +1 -1
  5. package/@types/core/di/injector.d.ts +0 -1
  6. package/@types/core/di/internal-injector.d.ts +1 -0
  7. package/@types/core/di/ng-module.d.ts +5 -0
  8. package/@types/core/filter/filter.d.ts +11 -13
  9. package/@types/core/sanitize/sanitize-uri.d.ts +3 -6
  10. package/@types/core/scope/scope.d.ts +1 -1
  11. package/@types/directive/attrs/attrs.d.ts +7 -1
  12. package/@types/directive/events/events.d.ts +9 -3
  13. package/@types/directive/http/http.d.ts +6 -2
  14. package/@types/directive/include/include.d.ts +2 -2
  15. package/@types/directive/input/input.d.ts +2 -12
  16. package/@types/directive/messages/messages.d.ts +9 -48
  17. package/@types/directive/model/model.d.ts +3 -3
  18. package/@types/directive/options/options.d.ts +13 -20
  19. package/@types/directive/switch/switch.d.ts +1 -0
  20. package/@types/directive/transclude/transclude.d.ts +10 -6
  21. package/@types/interface.d.ts +54 -18
  22. package/@types/router/common/glob.d.ts +5 -1
  23. package/@types/router/directives/view-directive.d.ts +2 -19
  24. package/@types/router/globals.d.ts +1 -2
  25. package/@types/router/state/state-registry.d.ts +1 -2
  26. package/@types/router/url/url-service.d.ts +7 -9
  27. package/@types/services/anchor-scroll.d.ts +1 -1
  28. package/@types/{core → services/exception}/exception-handler.d.ts +4 -4
  29. package/@types/{core/error-handler.d.ts → services/exception/interface.d.ts} +1 -1
  30. package/@types/services/http/http.d.ts +0 -2
  31. package/@types/services/http/interface.d.ts +2 -2
  32. package/@types/services/http-backend/http-backend.d.ts +13 -21
  33. package/@types/services/location/interface.d.ts +8 -0
  34. package/@types/{core → services}/location/location.d.ts +52 -12
  35. package/@types/{core → services}/sce/sce.d.ts +1 -1
  36. package/@types/services/template-cache/interface.d.ts +8 -2
  37. package/@types/services/template-cache/template-cache.d.ts +1 -1
  38. package/@types/services/template-request.d.ts +1 -1
  39. package/@types/shared/cache.d.ts +0 -2
  40. package/@types/shared/dom.d.ts +6 -0
  41. package/@types/shared/test-utils.d.ts +1 -0
  42. package/@types/shared/url-utils/interface.d.ts +47 -0
  43. package/@types/{core → shared}/url-utils/url-utils.d.ts +26 -13
  44. package/@types/shared/utils.d.ts +15 -0
  45. package/Makefile +3 -2
  46. package/dist/angular-ts.esm.js +982 -1190
  47. package/dist/angular-ts.umd.js +982 -1190
  48. package/dist/angular-ts.umd.min.js +1 -1
  49. package/docs/content/docs/directive/bind.md +9 -7
  50. package/docs/content/docs/directive/get.md +203 -0
  51. package/docs/content/docs/provider/templateCacheProvider.md +66 -1
  52. package/docs/content/docs/service/templateCache.md +2 -2
  53. package/docs/layouts/partials/hooks/head-end.html +1 -1
  54. package/docs/layouts/shortcodes/showcss.html +2 -0
  55. package/docs/static/examples/ng-bind/ng-bind.html +2 -2
  56. package/docs/static/typedoc/assets/hierarchy.js +1 -1
  57. package/docs/static/typedoc/assets/navigation.js +1 -1
  58. package/docs/static/typedoc/assets/search.js +1 -1
  59. package/docs/static/typedoc/classes/NgModule.html +32 -0
  60. package/docs/static/typedoc/classes/TemplateCacheProvider.html +1 -1
  61. package/docs/static/typedoc/hierarchy.html +1 -1
  62. package/docs/static/typedoc/index.html +1 -1
  63. package/docs/static/typedoc/interfaces/Directive.html +5 -4
  64. package/docs/static/typedoc/interfaces/HttpProviderDefaults.html +1 -1
  65. package/docs/static/typedoc/interfaces/HttpResponse.html +2 -3
  66. package/docs/static/typedoc/interfaces/Provider.html +15 -10
  67. package/docs/static/typedoc/interfaces/RequestConfig.html +1 -1
  68. package/docs/static/typedoc/interfaces/RequestShortcutConfig.html +1 -1
  69. package/docs/static/typedoc/interfaces/TemplateCache.html +7 -0
  70. package/docs/static/typedoc/types/AnnotatedDirectiveFactory.html +1 -0
  71. package/docs/static/typedoc/types/DirectiveFactory.html +1 -2
  72. package/docs/static/typedoc/types/DirectiveFactoryFn.html +1 -0
  73. package/docs/static/typedoc/types/HttpResponseStatus.html +1 -0
  74. package/docs/static/typedoc/types/{TemplateCache.html → SwapModeType.html} +1 -1
  75. package/docs/static/typedoc/variables/SwapMode.html +11 -0
  76. package/legacy.d.ts +0 -10
  77. package/package.json +1 -3
  78. package/src/animations/animate-children-directive.js +2 -2
  79. package/src/animations/raf-scheduler.js +1 -1
  80. package/src/animations/shared.js +0 -9
  81. package/src/core/compile/attributes.js +1 -1
  82. package/src/core/compile/compile.js +3 -3
  83. package/src/core/di/injector.js +4 -17
  84. package/src/core/di/internal-injector.js +4 -1
  85. package/src/core/di/ng-module.js +12 -27
  86. package/src/core/filter/filter.js +28 -28
  87. package/src/core/parse/interpreter.js +32 -38
  88. package/src/core/sanitize/sanitize-uri.js +3 -3
  89. package/src/core/scope/scope.js +2 -2
  90. package/src/directive/attrs/attrs.js +7 -4
  91. package/src/directive/events/events.js +6 -2
  92. package/src/directive/http/delete.spec.js +2 -0
  93. package/src/directive/http/get.spec.js +280 -3
  94. package/src/directive/http/http.js +100 -12
  95. package/src/directive/http/http.test.js +2 -2
  96. package/src/directive/http/post.spec.js +2 -0
  97. package/src/directive/http/put.spec.js +2 -0
  98. package/src/directive/include/include.js +7 -7
  99. package/src/directive/input/input.js +6 -28
  100. package/src/directive/messages/messages.js +4 -0
  101. package/src/directive/model/model.js +1 -1
  102. package/src/directive/options/options.js +454 -464
  103. package/src/directive/setter/setter.js +12 -14
  104. package/src/directive/setter/setter.spec.js +39 -16
  105. package/src/directive/switch/switch.js +1 -0
  106. package/src/directive/transclude/transclude.js +87 -89
  107. package/src/injection-tokens.js +1 -1
  108. package/src/interface.ts +68 -19
  109. package/src/loader.js +4 -9
  110. package/src/public.js +9 -15
  111. package/src/router/common/glob.js +5 -0
  112. package/src/router/directives/state-directives.spec.js +1 -1
  113. package/src/router/directives/view-directive.js +9 -1
  114. package/src/router/globals.js +0 -1
  115. package/src/router/state/state-registry.js +0 -1
  116. package/src/router/state-filters.js +2 -2
  117. package/src/router/url/url-service.js +5 -9
  118. package/src/services/anchor-scroll.html +0 -7
  119. package/src/services/anchor-scroll.js +1 -1
  120. package/src/{core → services/exception}/exception-handler.js +2 -2
  121. package/src/{core/error-handler.ts → services/exception/interface.ts} +1 -1
  122. package/src/services/http/http.js +2 -13
  123. package/src/services/http/interface.ts +2 -2
  124. package/src/services/http-backend/http-backend.js +4 -14
  125. package/src/services/http-backend/http-backend.spec.js +1 -4
  126. package/src/services/location/interface.ts +8 -0
  127. package/src/{core → services}/location/location.html +4 -1
  128. package/src/{core → services}/location/location.js +128 -26
  129. package/src/{core → services}/location/location.spec.js +2 -2
  130. package/src/{core → services}/location/location.test.js +1 -1
  131. package/src/{core → services}/sce/sce.html +1 -1
  132. package/src/{core → services}/sce/sce.js +9 -3
  133. package/src/{core → services}/sce/sce.spec.js +2 -3
  134. package/src/{core → services}/sce/sce.test.js +1 -1
  135. package/src/services/template-cache/interface.ts +8 -2
  136. package/src/services/template-cache/template-cache.js +3 -1
  137. package/src/services/template-cache/template-cache.spec.js +72 -0
  138. package/src/services/template-request.js +2 -1
  139. package/src/shared/cache.js +0 -2
  140. package/src/shared/dom.js +10 -0
  141. package/src/shared/test-utils.js +1 -0
  142. package/src/shared/url-utils/interface.ts +56 -0
  143. package/src/{core → shared}/url-utils/url-utils.html +4 -1
  144. package/src/{core → shared}/url-utils/url-utils.js +26 -23
  145. package/src/{core → shared}/url-utils/url-utils.spec.js +0 -8
  146. package/src/{core → shared}/url-utils/url-utils.test.js +1 -1
  147. package/src/shared/utils.js +28 -0
  148. package/utils/express.js +9 -1
  149. package/@types/core/task-tracker-factory.d.ts +0 -76
  150. package/@types/services/browser.d.ts +0 -101
  151. package/docs/static/typedoc/types/SwapInsertPosition.html +0 -2
  152. package/jsdoc.json +0 -22
  153. package/src/core/task-tracker-factory.js +0 -145
  154. package/src/services/browser.js +0 -212
  155. /package/src/{core → services}/location/location.md +0 -0
  156. /package/src/{core → services}/sce/sce.md +0 -0
  157. /package/src/{core → shared}/url-utils/url-utils.md +0 -0
@@ -1,6 +1,6 @@
1
1
  import { test, expect } from "@playwright/test";
2
2
 
3
- const TEST_URL = "src/core/sce/sce.html";
3
+ const TEST_URL = "src/services/sce/sce.html";
4
4
 
5
5
  test("unit tests contain no errors", async ({ page }) => {
6
6
  await page.goto(TEST_URL);
@@ -1,4 +1,10 @@
1
1
  /**
2
- * A cache for mapping template names to their respective content.
2
+ * A cache interface for mapping template urls to their XHR responses.
3
3
  */
4
- export type TemplateCache = Map<string, string>;
4
+ export interface TemplateCache {
5
+ get(key: string): any | undefined;
6
+ set(key: string, value: any): this;
7
+ has(key: string): boolean;
8
+ delete(key: string): boolean;
9
+ clear(): void;
10
+ }
@@ -9,5 +9,7 @@ export class TemplateCacheProvider {
9
9
  /**
10
10
  * @returns {import('./interface.ts').TemplateCache}
11
11
  */
12
- $get = () => this.cache;
12
+ $get() {
13
+ return this.cache;
14
+ }
13
15
  }
@@ -59,4 +59,76 @@ describe("$templateCache", () => {
59
59
  "<p>This is the content of the template</p>",
60
60
  );
61
61
  });
62
+
63
+ it("can be swapped for localStorage", async () => {
64
+ dealoc(el);
65
+ angular = new Angular();
66
+ angular.module("customStorage", []).config(($templateCacheProvider) => {
67
+ templateCacheProvider = $templateCacheProvider;
68
+ templateCacheProvider.cache = new LocalStorageMap();
69
+ templateCacheProvider.cache.set("test", "hello");
70
+ });
71
+ angular
72
+ .bootstrap(el, ["customStorage"])
73
+ .invoke((_$templateCache_, _$compile_, _$rootScope_) => {
74
+ templateCache = _$templateCache_;
75
+ $compile = _$compile_;
76
+ $scope = _$rootScope_;
77
+ });
78
+
79
+ expect(templateCache instanceof LocalStorageMap).toBeTrue();
80
+ el.innerHTML = `
81
+ <div ng-include="'test'">test</div>
82
+ `;
83
+ expect(el.innerText).toEqual("test");
84
+ $compile(el)($scope);
85
+ await wait();
86
+ expect(el.innerText).toEqual("hello");
87
+ expect(window.localStorage.getItem("test")).toEqual("hello");
88
+ });
62
89
  });
90
+
91
+ class LocalStorageMap {
92
+ constructor(prefix = "") {
93
+ this.prefix = prefix;
94
+ }
95
+
96
+ _key(key) {
97
+ return `${this.prefix}${key}`;
98
+ }
99
+
100
+ get(key) {
101
+ const raw = localStorage.getItem(this._key(key));
102
+ if (raw === null) return undefined;
103
+ try {
104
+ return JSON.parse(raw);
105
+ } catch {
106
+ return raw;
107
+ }
108
+ }
109
+
110
+ set(key, value) {
111
+ localStorage.setItem(this._key(key), value);
112
+ return this;
113
+ }
114
+
115
+ has(key) {
116
+ return localStorage.getItem(this._key(key)) !== null;
117
+ }
118
+
119
+ delete(key) {
120
+ localStorage.removeItem(this._key(key));
121
+ return true;
122
+ }
123
+
124
+ clear() {
125
+ const toRemove = [];
126
+ for (let i = 0; i < localStorage.length; i++) {
127
+ const k = localStorage.key(i);
128
+ if (k && k.startsWith(this.prefix)) {
129
+ toRemove.push(k);
130
+ }
131
+ }
132
+ toRemove.forEach((k) => localStorage.removeItem(k));
133
+ }
134
+ }
@@ -60,7 +60,7 @@ export function TemplateRequestProvider() {
60
60
  "$sce",
61
61
  /**
62
62
  *
63
- * @param {import('../core/exception-handler.js').ErrorHandler} $exceptionHandler
63
+ * @param {import('./exception/exception-handler.js').ErrorHandler} $exceptionHandler
64
64
  * @param {import('../services/template-cache/interface.ts').TemplateCache} $templateCache
65
65
  * @param {import("interface.ts").HttpService} $http
66
66
  * @param {*} $sce
@@ -75,6 +75,7 @@ export function TemplateRequestProvider() {
75
75
  // resources for keys that already are included in there. This also makes
76
76
  // AngularTS accept any script directive, no matter its name. However, we
77
77
  // still need to unwrap trusted types.
78
+
78
79
  if (!isString(tpl) || !$templateCache.has(tpl)) {
79
80
  try {
80
81
  tpl = $sce.getTrustedResourceUrl(tpl);
@@ -1,8 +1,6 @@
1
1
  /**
2
2
  * Expando cache for adding properties to DOM nodes with JavaScript.
3
3
  * This used to be an Object in JQLite decorator, but swapped out for a Map
4
- * for performance reasons and convenience methods. A proxy is available for
5
- * additional logic handling.
6
4
  *
7
5
  * @type {Map<number, import('../interface.ts').ExpandoStore>}
8
6
  */
package/src/shared/dom.js CHANGED
@@ -704,3 +704,13 @@ function extractElementNode(element) {
704
704
  }
705
705
  }
706
706
  }
707
+
708
+ /**
709
+ * Returns the base href of the document.
710
+ *
711
+ * @returns {string} The base href.
712
+ */
713
+ export function getBaseHref() {
714
+ const href = document.querySelector("base")?.getAttribute("href");
715
+ return href ? href.replace(/^(https?:)?\/\/[^/]*/, "") : "";
716
+ }
@@ -22,6 +22,7 @@ export function browserTrigger(element, options) {
22
22
 
23
23
  /**
24
24
  * Delays execution for a specified number of milliseconds.
25
+ * TODO remove
25
26
  *
26
27
  * @param {number} [t=0] - The number of milliseconds to wait. Defaults to 0.
27
28
  * @returns {Promise<void>} A promise that resolves after the delay.
@@ -0,0 +1,56 @@
1
+ export type HttpProtocol = "http" | "https";
2
+
3
+ /**
4
+ * A normalized representation of a parsed URL.
5
+ */
6
+ export interface ParsedUrl {
7
+ /**
8
+ * The full URL string, including protocol, host, path, query, and hash.
9
+ * Example: "https://example.com:8080/path?query=1#section"
10
+ */
11
+ href: string;
12
+
13
+ /**
14
+ * The protocol scheme of the URL, without the trailing colon.
15
+ * Example: "http" or "https"
16
+ */
17
+ protocol: string;
18
+
19
+ /**
20
+ * The host part of the URL, including hostname and port (if specified).
21
+ * Example: "example.com:8080"
22
+ */
23
+ host: string;
24
+
25
+ /**
26
+ * The query string portion of the URL, without the leading "?".
27
+ * Example: "query=1&sort=asc"
28
+ */
29
+ search: string;
30
+
31
+ /**
32
+ * The fragment identifier (hash) of the URL, without the leading "#".
33
+ * Example: "section2"
34
+ */
35
+ hash: string;
36
+
37
+ /**
38
+ * The domain or IP address (including IPv6 in brackets) of the URL.
39
+ * Example: "example.com" or "[::1]"
40
+ */
41
+ hostname: string;
42
+
43
+ /**
44
+ * The port number of the URL as a string, or an empty string if not specified.
45
+ * Example: "8080" or ""
46
+ */
47
+ port: string;
48
+
49
+ /**
50
+ * The path of the URL, always beginning with a leading slash.
51
+ * Example: "/path/to/resource"
52
+ */
53
+ pathname: string;
54
+ }
55
+
56
+ export type ResolvableUrl = string | ParsedUrl;
@@ -11,7 +11,10 @@
11
11
  <script src="/jasmine/jasmine-html.js"></script>
12
12
  <script src="/jasmine/boot0.js"></script>
13
13
  <script src="/jasmine/boot1.js"></script>
14
- <script type="module" src="/src/core/url-utils/url-utils.spec.js"></script>
14
+ <script
15
+ type="module"
16
+ src="/src/shared/url-utils/url-utils.spec.js"
17
+ ></script>
15
18
  </head>
16
19
  <body>
17
20
  <div id="app"></div>
@@ -1,31 +1,24 @@
1
1
  import { isString } from "../../shared/utils.js";
2
2
 
3
- /**
4
- * HTTP protocol
5
- * @typedef {"http"|"https"} HttpProtocol
6
- */
7
-
8
3
  const urlParsingNode = document.createElement("a");
9
4
  const originUrl = urlResolve(window.location.href);
10
5
  let baseUrlParsingNode;
11
6
 
12
7
  urlParsingNode.href = "http://[::1]";
13
8
 
9
+ /**
10
+ * @param {import("./interface.js").ResolvableUrl} url
11
+ * @return {import("./interface.js").ParsedUrl}
12
+ */
14
13
  export function urlResolve(url) {
15
- if (!isString(url)) return url;
16
-
17
- const href = url;
14
+ if (!isString(url))
15
+ return /** @type {import("./interface.js").ParsedUrl} */ (url);
18
16
 
19
- urlParsingNode.setAttribute("href", href);
17
+ urlParsingNode.setAttribute("href", /** @type {string} */ (url));
20
18
 
21
- let { hostname } = urlParsingNode;
22
- // Support: IE 9-11 only, Edge 16-17 only (fixed in 18 Preview)
23
- // IE/Edge don't wrap IPv6 addresses' hostnames in square brackets
24
- // when parsed out of an anchor element.
25
- const ipv6InBrackets = urlParsingNode.hostname === "[::1]";
26
- if (!ipv6InBrackets && hostname.indexOf(":") > -1) {
27
- hostname = `[${hostname}]`;
28
- }
19
+ const hostname = urlParsingNode.hostname.includes(":")
20
+ ? `[${urlParsingNode.hostname}]`
21
+ : urlParsingNode.hostname;
29
22
 
30
23
  return {
31
24
  href: urlParsingNode.href,
@@ -50,7 +43,7 @@ export function urlResolve(url) {
50
43
  * Parse a request URL and determine whether this is a same-origin request as the application
51
44
  * document.
52
45
  *
53
- * @param {string|object} requestUrl The url of the request as a string that will be resolved
46
+ * @param {import("./interface.js").ResolvableUrl} requestUrl The url of the request as a string that will be resolved
54
47
  * or a parsed URL object.
55
48
  * @returns {boolean} Whether the request is for the same origin as the application document.
56
49
  */
@@ -64,7 +57,7 @@ export function urlIsSameOrigin(requestUrl) {
64
57
  * Note: The base URL is usually the same as the document location (`location.href`) but can
65
58
  * be overriden by using the `<base>` tag.
66
59
  *
67
- * @param {string|object} requestUrl The url of the request as a string that will be resolved
60
+ * @param {import("./interface.js").ResolvableUrl} requestUrl The url of the request as a string that will be resolved
68
61
  * or a parsed URL object.
69
62
  * @returns {boolean} Whether the URL is same-origin as the document base URL.
70
63
  */
@@ -78,7 +71,7 @@ export function urlIsSameOriginAsBaseUrl(requestUrl) {
78
71
  *
79
72
  * @param {string[]} trustedOriginUrls - A list of URLs (strings), whose origins are trusted.
80
73
  *
81
- * @returns {Function} - A function that receives a URL (string or parsed URL object) and returns
74
+ * @returns {(url: import("./interface.js").ResolvableUrl) => boolean } - A function that receives a URL (string or parsed URL object) and returns
82
75
  * whether it is of an allowed origin.
83
76
  */
84
77
  export function urlIsAllowedOriginFactory(trustedOriginUrls) {
@@ -91,7 +84,7 @@ export function urlIsAllowedOriginFactory(trustedOriginUrls) {
91
84
  * based on a list of trusted-origin URLs. The current location's origin is implicitly
92
85
  * trusted.
93
86
  *
94
- * @param {string|Object} requestUrl - The URL to be checked (provided as a string that will be
87
+ * @param {import("./interface.js").ResolvableUrl} requestUrl - The URL to be checked (provided as a string that will be
95
88
  * resolved or a parsed URL object).
96
89
  *
97
90
  * @returns {boolean} - Whether the specified URL is of an allowed origin.
@@ -107,9 +100,9 @@ export function urlIsAllowedOriginFactory(trustedOriginUrls) {
107
100
  /**
108
101
  * Determine if two URLs share the same origin.
109
102
  *
110
- * @param {string|Object} url1 - First URL to compare as a string or a normalized URL in the form of
103
+ * @param {import("./interface.js").ResolvableUrl} url1 - First URL to compare as a string or a normalized URL in the form of
111
104
  * a dictionary object returned by `urlResolve()`.
112
- * @param {string|object} url2 - Second URL to compare as a string or a normalized URL in the form
105
+ * @param {import("./interface.js").ResolvableUrl} url2 - Second URL to compare as a string or a normalized URL in the form
113
106
  * of a dictionary object returned by `urlResolve()`.
114
107
  *
115
108
  * @returns {boolean} - True if both URLs have the same origin, and false otherwise.
@@ -141,3 +134,13 @@ export function getBaseUrl() {
141
134
  }
142
135
  return baseUrlParsingNode.href;
143
136
  }
137
+
138
+ /**
139
+ * Removes a trailing hash ('#') from the given URL if it exists.
140
+ *
141
+ * @param {string} url
142
+ * @returns {string}
143
+ */
144
+ export function trimEmptyHash(url) {
145
+ return url.replace(/#$/, "");
146
+ }
@@ -36,14 +36,6 @@ describe("urlUtils", () => {
36
36
  expect(parsed.pathname).toBe("/");
37
37
  });
38
38
 
39
- it("should return an IPv6 hostname wrapped in brackets", () => {
40
- // Support: IE 9-11 only, Edge 16-17 only (fixed in 18 Preview)
41
- // IE/Edge don't wrap IPv6 addresses' hostnames in square brackets
42
- // when parsed out of an anchor element.
43
- const parsed = urlResolve("http://[::1]/");
44
- expect(parsed.hostname).toBe("[::1]");
45
- });
46
-
47
39
  it("should not put the domain in brackets for the hostname field", () => {
48
40
  const parsed = urlResolve("https://google.com/");
49
41
  expect(parsed.hostname).toBe("google.com");
@@ -1,6 +1,6 @@
1
1
  import { test, expect } from "@playwright/test";
2
2
 
3
- const TEST_URL = "src/core/url-utils/url-utils.html";
3
+ const TEST_URL = "src/shared/url-utils/url-utils.html";
4
4
 
5
5
  test("unit tests contain no errors", async ({ page }) => {
6
6
  await page.goto(TEST_URL);
@@ -1211,3 +1211,31 @@ export function callBackOnce(fn) {
1211
1211
  }
1212
1212
  };
1213
1213
  }
1214
+
1215
+ /**
1216
+ * Wraps a function so it will only be called starting from the second invocation.
1217
+ * The first call does nothing and returns undefined.
1218
+ *
1219
+ * @param {Function} fn - The function to wrap.
1220
+ * @returns {Function} A new function that will skip the first call.
1221
+ */
1222
+ export function callBackAfterFirst(fn) {
1223
+ let calledOnce = false;
1224
+
1225
+ return function (...args) {
1226
+ if (calledOnce) {
1227
+ return fn.apply(this, args);
1228
+ }
1229
+ calledOnce = true;
1230
+ };
1231
+ }
1232
+
1233
+ /**
1234
+ * Delays execution for a specified number of milliseconds.
1235
+ *
1236
+ * @param {number} [t=0] - The number of milliseconds to wait. Defaults to 0.
1237
+ * @returns {Promise<void>} A promise that resolves after the delay.
1238
+ */
1239
+ export function wait(t = 0) {
1240
+ return new Promise((resolve) => setTimeout(resolve, t));
1241
+ }
package/utils/express.js CHANGED
@@ -72,6 +72,10 @@ app.get("/jsoninterpolation", (req, res) => {
72
72
  res.json("{{expr}}");
73
73
  });
74
74
 
75
+ app.get("/now", (req, res) => {
76
+ res.send(Date.now().toString(10));
77
+ });
78
+
75
79
  app.get("/scopeinit", (req, res) => {
76
80
  res.send('<div ng-init="name=1"></div>');
77
81
  });
@@ -112,6 +116,10 @@ app.get("/hello2", (req, res) => {
112
116
  res.send("Hello2");
113
117
  });
114
118
 
119
+ app.get("/include", (req, res) => {
120
+ res.send("<div ng-include=\"'/mock/hello'\"></div>");
121
+ });
122
+
115
123
  app.get("/third", (req, res) => {
116
124
  res.send("<div third>{{1+2}}</div>");
117
125
  });
@@ -132,7 +140,7 @@ app.get("/422", (req, res) => {
132
140
  res.status(422).send("Invalid data");
133
141
  });
134
142
 
135
- app.get("/never", (req, res) => {
143
+ app.get("/never", () => {
136
144
  setTimeout(() => {}, 500);
137
145
  });
138
146
 
@@ -1,76 +0,0 @@
1
- /** @typedef {import('../interface.ts').ServiceProvider} ServiceProvider */
2
- /** @typedef {import('../interface.ts').AnnotatedFactory} AnnotatedFactory */
3
- /**
4
- * @implements {ServiceProvider}
5
- */
6
- export class TaskTrackerFactoryProvider implements ServiceProvider {
7
- /** @type {AnnotatedFactory} */
8
- $get: AnnotatedFactory;
9
- }
10
- /**
11
- * A factory function to create `TaskTracker` instances.
12
- *
13
- * A `TaskTracker` tracks pending tasks (grouped by type) and notifies interested
14
- * parties when all pending tasks (or tasks of a specific type) have been completed.
15
- */
16
- export class TaskTracker {
17
- /**
18
- * @param {import('../services/log/interface.ts').LogService} log - The logging service.
19
- */
20
- constructor(log: import("../services/log/interface.ts").LogService);
21
- /** @private */
22
- private log;
23
- /** @private */
24
- private taskCounts;
25
- /** @private */
26
- private taskCallbacks;
27
- /**
28
- * Special task types used for tracking all tasks and default tasks.
29
- * @type {string}
30
- */
31
- ALL_TASKS_TYPE: string;
32
- /**
33
- * Default task type.
34
- * @type {string}
35
- */
36
- DEFAULT_TASK_TYPE: string;
37
- /**
38
- * Completes a task and decrements the associated task counter.
39
- * If the counter reaches 0, all corresponding callbacks are executed.
40
- *
41
- * @param {Function} fn - The function to execute when completing the task.
42
- * @param {string} [taskType=this.DEFAULT_TASK_TYPE] - The type of task being completed.
43
- */
44
- completeTask(fn: Function, taskType?: string): void;
45
- /**
46
- * Increments the task count for the specified task type.
47
- *
48
- * @param {string} [taskType=this.DEFAULT_TASK_TYPE] - The type of task whose count will be increased.
49
- */
50
- incTaskCount(taskType?: string): void;
51
- /**
52
- * Registers a callback to be executed when all pending tasks of the specified type are completed.
53
- * If there are no pending tasks of the specified type, the callback is executed immediately.
54
- *
55
- * @param {Function} callback - The function to execute when no pending tasks remain.
56
- * @param {string} [taskType=this.ALL_TASKS_TYPE] - The type of tasks to wait for completion.
57
- */
58
- notifyWhenNoPendingTasks(callback: Function, taskType?: string): void;
59
- /**
60
- * Retrieves and removes the last registered callback from the queue.
61
- *
62
- * @private
63
- * @returns {Function|undefined} The last callback function or undefined if none exist.
64
- */
65
- private getLastCallback;
66
- /**
67
- * Retrieves and removes the last registered callback for the specified task type.
68
- *
69
- * @private
70
- * @param {string} taskType - The type of task for which the callback was registered.
71
- * @returns {Function|undefined} The last callback function for the task type, or undefined if none exist.
72
- */
73
- private getLastCallbackForType;
74
- }
75
- export type ServiceProvider = import("../interface.ts").ServiceProvider;
76
- export type AnnotatedFactory = import("../interface.ts").AnnotatedFactory;
@@ -1,101 +0,0 @@
1
- /**
2
- * Removes a trailing hash ('#') from the given URL if it exists.
3
- *
4
- * @param {string} url
5
- * @returns {string}
6
- */
7
- export function trimEmptyHash(url: string): string;
8
- /**
9
- * @typedef {function(string, string|null): any} UrlChangeListener
10
- */
11
- /**
12
- * This object has two goals:
13
- *
14
- * - hide all the global state in the browser caused by the window object
15
- * - abstract away all the browser specific features and inconsistencies
16
- */
17
- export class Browser {
18
- /**
19
- * @param {import('../core/task-tracker-factory.js').TaskTracker} taskTracker
20
- */
21
- constructor(
22
- taskTracker: import("../core/task-tracker-factory.js").TaskTracker,
23
- );
24
- /**
25
- * @type {import('../core/task-tracker-factory.js').TaskTracker} taskTracker
26
- */
27
- taskTracker: import("../core/task-tracker-factory.js").TaskTracker;
28
- pendingDeferIds: {};
29
- /** @type {Array<UrlChangeListener>} */
30
- urlChangeListeners: Array<UrlChangeListener>;
31
- urlChangeInit: boolean;
32
- /** @type {any} */
33
- cachedState: any;
34
- /** @type {any} */
35
- lastHistoryState: any;
36
- /** @type {string} */
37
- lastBrowserUrl: string;
38
- /** @type {HTMLBaseElement | null} */
39
- baseElement: HTMLBaseElement | null;
40
- $$completeOutstandingRequest: any;
41
- $$incOutstandingRequestCount: any;
42
- notifyWhenNoOutstandingRequests: any;
43
- url(url: any, state: any): string | this;
44
- /**
45
- * Returns the cached state.
46
- *
47
- * @returns {any} The cached state.
48
- */
49
- state(): any;
50
- /**
51
- * Caches the current state and fires the URL change event.
52
- *
53
- * @private
54
- */
55
- private cacheStateAndFireUrlChange;
56
- /**
57
- * Caches the current state.
58
- *
59
- * @private
60
- */
61
- private cacheState;
62
- lastCachedState: any;
63
- /**
64
- * Fires the state or URL change event.
65
- *
66
- * @private
67
- */
68
- private fireStateOrUrlChange;
69
- /**
70
- * Registers a callback to be called when the URL changes.
71
- *
72
- * @param {UrlChangeListener} callback - The callback function to register.
73
- * @returns {UrlChangeListener} The registered callback function.
74
- */
75
- onUrlChange(callback: UrlChangeListener): UrlChangeListener;
76
- $$applicationDestroyed(): void;
77
- $$checkUrlChange(): void;
78
- /**
79
- * Returns the base href of the document.
80
- *
81
- * @returns {string} The base href.
82
- */
83
- baseHref(): string;
84
- }
85
- /**
86
- * This object has two goals:
87
- *
88
- * - hide all the global state in the browser caused by the window object
89
- * - abstract away all the browser specific features and inconsistencies
90
- *
91
- * Remove this in the future
92
- */
93
- export class BrowserProvider {
94
- $get: (
95
- | string
96
- | ((
97
- $$taskTrackerFactory: import("../core/task-tracker-factory.js").TaskTracker,
98
- ) => Browser)
99
- )[];
100
- }
101
- export type UrlChangeListener = (arg0: string, arg1: string | null) => any;
@@ -1,2 +0,0 @@
1
- <!DOCTYPE html><html class="default" lang="en" data-base="../"><head><meta charset="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>SwapInsertPosition | AngularTS</title><meta name="description" content="Documentation for AngularTS"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script defer src="../assets/main.js"></script><script async src="../assets/icons.js" id="tsd-icons-script"></script><script async src="../assets/search.js" id="tsd-search-script"></script><script async src="../assets/navigation.js" id="tsd-nav-script"></script><script async src="../assets/hierarchy.js" id="tsd-hierarchy-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => window.app?app.showPage():document.body.style.removeProperty("display"),500)</script><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><a href="../index.html" class="title">AngularTS</a><div id="tsd-toolbar-links"></div><button id="tsd-search-trigger" class="tsd-widget" aria-label="Search"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-search"></use></svg></button><dialog id="tsd-search" aria-label="Search"><input role="combobox" id="tsd-search-input" aria-controls="tsd-search-results" aria-autocomplete="list" aria-expanded="true" autocapitalize="off" autocomplete="off" placeholder="Search the docs" maxLength="100"/><ul role="listbox" id="tsd-search-results"></ul><div id="tsd-search-status" aria-live="polite" aria-atomic="true"><div>Preparing search index...</div></div></dialog><a href="#" class="tsd-widget menu" id="tsd-toolbar-menu-trigger" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-menu"></use></svg></a></div></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><ul class="tsd-breadcrumb" aria-label="Breadcrumb"><li><a href="" aria-current="page">SwapInsertPosition</a></li></ul><h1>Type Alias SwapInsertPosition</h1></div><div class="tsd-signature"><span class="tsd-kind-type-alias">SwapInsertPosition</span><span class="tsd-signature-symbol">:</span><br/>    <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">InsertPosition</span><br/>    <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">&quot;textContent&quot;</span><br/>    <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">&quot;innerHTML&quot;</span><br/>    <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">&quot;outerHTML&quot;</span><br/>    <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">&quot;delete&quot;</span><br/>    <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">&quot;none&quot;</span></div><div class="tsd-comment tsd-typography"><p>Possible values for <code>data-swap</code> attribute</p>
2
- </div><div class="tsd-comment tsd-typography"></div></div><div class="col-sidebar"><div class="page-menu"><div class="tsd-navigation settings"><details class="tsd-accordion"><summary class="tsd-accordion-summary"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg><h3>Settings</h3></summary><div class="tsd-accordion-details"><div class="tsd-filter-visibility"><span class="settings-label">Member Visibility</span><ul id="tsd-filter-options"><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-protected" name="protected"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Protected</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-inherited" name="inherited" checked/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Inherited</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-external" name="external"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>External</span></label></li></ul></div><div class="tsd-theme-toggle"><label class="settings-label" for="tsd-theme">Theme</label><select id="tsd-theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div></div><div class="site-menu"><nav class="tsd-navigation"><a href="../index.html">AngularTS</a><ul class="tsd-small-nested-navigation" id="tsd-nav-container"><li>Loading...</li></ul></nav></div></div></div><footer><p class="tsd-generator">Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></footer><div class="overlay"></div></body></html>
package/jsdoc.json DELETED
@@ -1,22 +0,0 @@
1
- {
2
- "tags": {
3
- "allowUnknownTags": false
4
- },
5
- "source": {
6
- "include": "./src",
7
- "includePattern": "\\.js$",
8
- "excludePattern": "(node_modules/|docs|\\.spec.js$|\\.test.js$)"
9
- },
10
- "plugins": ["plugins/markdown"],
11
- "opts": {
12
- "template": "assets/template/docdash/",
13
- "encoding": "utf8",
14
- "destination": "docs/",
15
- "recurse": true,
16
- "verbose": true
17
- },
18
- "templates": {
19
- "cleverLinks": false,
20
- "monospaceLinks": false
21
- }
22
- }