@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.
- package/@types/animations/raf-scheduler.d.ts +2 -2
- package/@types/animations/shared.d.ts +0 -1
- package/@types/core/compile/attributes.d.ts +3 -3
- package/@types/core/compile/compile.d.ts +1 -1
- package/@types/core/di/injector.d.ts +0 -1
- package/@types/core/di/internal-injector.d.ts +1 -0
- package/@types/core/di/ng-module.d.ts +5 -0
- package/@types/core/filter/filter.d.ts +11 -13
- package/@types/core/sanitize/sanitize-uri.d.ts +3 -6
- package/@types/core/scope/scope.d.ts +1 -1
- package/@types/directive/attrs/attrs.d.ts +7 -1
- package/@types/directive/events/events.d.ts +9 -3
- package/@types/directive/http/http.d.ts +6 -2
- package/@types/directive/include/include.d.ts +2 -2
- package/@types/directive/input/input.d.ts +2 -12
- package/@types/directive/messages/messages.d.ts +9 -48
- package/@types/directive/model/model.d.ts +3 -3
- package/@types/directive/options/options.d.ts +13 -20
- package/@types/directive/switch/switch.d.ts +1 -0
- package/@types/directive/transclude/transclude.d.ts +10 -6
- package/@types/interface.d.ts +54 -18
- package/@types/router/common/glob.d.ts +5 -1
- package/@types/router/directives/view-directive.d.ts +2 -19
- package/@types/router/globals.d.ts +1 -2
- package/@types/router/state/state-registry.d.ts +1 -2
- package/@types/router/url/url-service.d.ts +7 -9
- package/@types/services/anchor-scroll.d.ts +1 -1
- package/@types/{core → services/exception}/exception-handler.d.ts +4 -4
- package/@types/{core/error-handler.d.ts → services/exception/interface.d.ts} +1 -1
- package/@types/services/http/http.d.ts +0 -2
- package/@types/services/http/interface.d.ts +2 -2
- package/@types/services/http-backend/http-backend.d.ts +13 -21
- package/@types/services/location/interface.d.ts +8 -0
- package/@types/{core → services}/location/location.d.ts +52 -12
- package/@types/{core → services}/sce/sce.d.ts +1 -1
- package/@types/services/template-cache/interface.d.ts +8 -2
- package/@types/services/template-cache/template-cache.d.ts +1 -1
- package/@types/services/template-request.d.ts +1 -1
- package/@types/shared/cache.d.ts +0 -2
- package/@types/shared/dom.d.ts +6 -0
- package/@types/shared/test-utils.d.ts +1 -0
- package/@types/shared/url-utils/interface.d.ts +47 -0
- package/@types/{core → shared}/url-utils/url-utils.d.ts +26 -13
- package/@types/shared/utils.d.ts +15 -0
- package/Makefile +3 -2
- package/dist/angular-ts.esm.js +982 -1190
- package/dist/angular-ts.umd.js +982 -1190
- package/dist/angular-ts.umd.min.js +1 -1
- package/docs/content/docs/directive/bind.md +9 -7
- package/docs/content/docs/directive/get.md +203 -0
- package/docs/content/docs/provider/templateCacheProvider.md +66 -1
- package/docs/content/docs/service/templateCache.md +2 -2
- package/docs/layouts/partials/hooks/head-end.html +1 -1
- package/docs/layouts/shortcodes/showcss.html +2 -0
- package/docs/static/examples/ng-bind/ng-bind.html +2 -2
- package/docs/static/typedoc/assets/hierarchy.js +1 -1
- package/docs/static/typedoc/assets/navigation.js +1 -1
- package/docs/static/typedoc/assets/search.js +1 -1
- package/docs/static/typedoc/classes/NgModule.html +32 -0
- package/docs/static/typedoc/classes/TemplateCacheProvider.html +1 -1
- package/docs/static/typedoc/hierarchy.html +1 -1
- package/docs/static/typedoc/index.html +1 -1
- package/docs/static/typedoc/interfaces/Directive.html +5 -4
- package/docs/static/typedoc/interfaces/HttpProviderDefaults.html +1 -1
- package/docs/static/typedoc/interfaces/HttpResponse.html +2 -3
- package/docs/static/typedoc/interfaces/Provider.html +15 -10
- package/docs/static/typedoc/interfaces/RequestConfig.html +1 -1
- package/docs/static/typedoc/interfaces/RequestShortcutConfig.html +1 -1
- package/docs/static/typedoc/interfaces/TemplateCache.html +7 -0
- package/docs/static/typedoc/types/AnnotatedDirectiveFactory.html +1 -0
- package/docs/static/typedoc/types/DirectiveFactory.html +1 -2
- package/docs/static/typedoc/types/DirectiveFactoryFn.html +1 -0
- package/docs/static/typedoc/types/HttpResponseStatus.html +1 -0
- package/docs/static/typedoc/types/{TemplateCache.html → SwapModeType.html} +1 -1
- package/docs/static/typedoc/variables/SwapMode.html +11 -0
- package/legacy.d.ts +0 -10
- package/package.json +1 -3
- package/src/animations/animate-children-directive.js +2 -2
- package/src/animations/raf-scheduler.js +1 -1
- package/src/animations/shared.js +0 -9
- package/src/core/compile/attributes.js +1 -1
- package/src/core/compile/compile.js +3 -3
- package/src/core/di/injector.js +4 -17
- package/src/core/di/internal-injector.js +4 -1
- package/src/core/di/ng-module.js +12 -27
- package/src/core/filter/filter.js +28 -28
- package/src/core/parse/interpreter.js +32 -38
- package/src/core/sanitize/sanitize-uri.js +3 -3
- package/src/core/scope/scope.js +2 -2
- package/src/directive/attrs/attrs.js +7 -4
- package/src/directive/events/events.js +6 -2
- package/src/directive/http/delete.spec.js +2 -0
- package/src/directive/http/get.spec.js +280 -3
- package/src/directive/http/http.js +100 -12
- package/src/directive/http/http.test.js +2 -2
- package/src/directive/http/post.spec.js +2 -0
- package/src/directive/http/put.spec.js +2 -0
- package/src/directive/include/include.js +7 -7
- package/src/directive/input/input.js +6 -28
- package/src/directive/messages/messages.js +4 -0
- package/src/directive/model/model.js +1 -1
- package/src/directive/options/options.js +454 -464
- package/src/directive/setter/setter.js +12 -14
- package/src/directive/setter/setter.spec.js +39 -16
- package/src/directive/switch/switch.js +1 -0
- package/src/directive/transclude/transclude.js +87 -89
- package/src/injection-tokens.js +1 -1
- package/src/interface.ts +68 -19
- package/src/loader.js +4 -9
- package/src/public.js +9 -15
- package/src/router/common/glob.js +5 -0
- package/src/router/directives/state-directives.spec.js +1 -1
- package/src/router/directives/view-directive.js +9 -1
- package/src/router/globals.js +0 -1
- package/src/router/state/state-registry.js +0 -1
- package/src/router/state-filters.js +2 -2
- package/src/router/url/url-service.js +5 -9
- package/src/services/anchor-scroll.html +0 -7
- package/src/services/anchor-scroll.js +1 -1
- package/src/{core → services/exception}/exception-handler.js +2 -2
- package/src/{core/error-handler.ts → services/exception/interface.ts} +1 -1
- package/src/services/http/http.js +2 -13
- package/src/services/http/interface.ts +2 -2
- package/src/services/http-backend/http-backend.js +4 -14
- package/src/services/http-backend/http-backend.spec.js +1 -4
- package/src/services/location/interface.ts +8 -0
- package/src/{core → services}/location/location.html +4 -1
- package/src/{core → services}/location/location.js +128 -26
- package/src/{core → services}/location/location.spec.js +2 -2
- package/src/{core → services}/location/location.test.js +1 -1
- package/src/{core → services}/sce/sce.html +1 -1
- package/src/{core → services}/sce/sce.js +9 -3
- package/src/{core → services}/sce/sce.spec.js +2 -3
- package/src/{core → services}/sce/sce.test.js +1 -1
- package/src/services/template-cache/interface.ts +8 -2
- package/src/services/template-cache/template-cache.js +3 -1
- package/src/services/template-cache/template-cache.spec.js +72 -0
- package/src/services/template-request.js +2 -1
- package/src/shared/cache.js +0 -2
- package/src/shared/dom.js +10 -0
- package/src/shared/test-utils.js +1 -0
- package/src/shared/url-utils/interface.ts +56 -0
- package/src/{core → shared}/url-utils/url-utils.html +4 -1
- package/src/{core → shared}/url-utils/url-utils.js +26 -23
- package/src/{core → shared}/url-utils/url-utils.spec.js +0 -8
- package/src/{core → shared}/url-utils/url-utils.test.js +1 -1
- package/src/shared/utils.js +28 -0
- package/utils/express.js +9 -1
- package/@types/core/task-tracker-factory.d.ts +0 -76
- package/@types/services/browser.d.ts +0 -101
- package/docs/static/typedoc/types/SwapInsertPosition.html +0 -2
- package/jsdoc.json +0 -22
- package/src/core/task-tracker-factory.js +0 -145
- package/src/services/browser.js +0 -212
- /package/src/{core → services}/location/location.md +0 -0
- /package/src/{core → services}/sce/sce.md +0 -0
- /package/src/{core → shared}/url-utils/url-utils.md +0 -0
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* A cache for mapping template
|
|
2
|
+
* A cache interface for mapping template urls to their XHR responses.
|
|
3
3
|
*/
|
|
4
|
-
export
|
|
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
|
+
}
|
|
@@ -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('
|
|
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);
|
package/src/shared/cache.js
CHANGED
|
@@ -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
|
+
}
|
package/src/shared/test-utils.js
CHANGED
|
@@ -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
|
|
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))
|
|
16
|
-
|
|
17
|
-
const href = url;
|
|
14
|
+
if (!isString(url))
|
|
15
|
+
return /** @type {import("./interface.js").ParsedUrl} */ (url);
|
|
18
16
|
|
|
19
|
-
urlParsingNode.setAttribute("href",
|
|
17
|
+
urlParsingNode.setAttribute("href", /** @type {string} */ (url));
|
|
20
18
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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 {
|
|
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 {
|
|
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 {
|
|
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 {
|
|
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 {
|
|
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 {
|
|
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");
|
package/src/shared/utils.js
CHANGED
|
@@ -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", (
|
|
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">"textContent"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"innerHTML"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"outerHTML"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"delete"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"none"</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
|
-
}
|