@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
@@ -4,7 +4,7 @@
4
4
  export class UrlService {
5
5
  static $inject: string[];
6
6
  /**
7
- * @param {import("../../core/location/location").LocationProvider} $locationProvider
7
+ * @param {import("../../services/location/location").LocationProvider} $locationProvider
8
8
  * @param {import("../../router/state/state-service.js").StateProvider} stateService
9
9
  * @param globals
10
10
  * @param {import("../../router/url/url-config.js").UrlConfigProvider} urlConfigProvider
@@ -17,8 +17,7 @@ export class UrlService {
17
17
  );
18
18
  stateService: import("../../router/state/state-service.js").StateProvider;
19
19
  $locationProvider: any;
20
- $location: import("../../core/location/location.js").Location;
21
- $browser: import("../../services/browser.js").Browser;
20
+ $location: import("../../services/location/location.js").Location;
22
21
  /** Provides services related to the URL */
23
22
  urlRuleFactory: UrlRuleFactory;
24
23
  /**
@@ -60,13 +59,12 @@ export class UrlService {
60
59
  *
61
60
  * @return the hash (anchor) portion of the url
62
61
  */
63
- hash: () => string | import("../../core/location/location.js").Location;
62
+ hash: () => string | import("../../services/location/location.js").Location;
64
63
  _urlListeners: any[];
65
64
  $get: (
66
65
  | string
67
66
  | ((
68
- $location: import("../../core/location/location.js").Location,
69
- $browser: import("../../services/browser.js").Browser,
67
+ $location: import("../../services/location/location.js").Location,
70
68
  $rootScope: import("../../core/scope/scope.js").Scope,
71
69
  ) => UrlService)
72
70
  )[];
@@ -132,7 +130,7 @@ export class UrlService {
132
130
  newUrl?: string,
133
131
  replace?: boolean,
134
132
  state?: any,
135
- ): string | import("../../core/location/location.js").Location;
133
+ ): string | import("../../services/location/location.js").Location;
136
134
  /**
137
135
  * @internal
138
136
  *
@@ -157,7 +155,7 @@ export class UrlService {
157
155
  parts(): {
158
156
  path: any;
159
157
  search: any;
160
- hash: string | import("../../core/location/location.js").Location;
158
+ hash: string | import("../../services/location/location.js").Location;
161
159
  };
162
160
  /**
163
161
  * Activates the best rule for the current URL
@@ -211,7 +209,7 @@ export class UrlService {
211
209
  */
212
210
  match(url: any): any;
213
211
  update(read: any): void;
214
- location: string | import("../../core/location/location.js").Location;
212
+ location: string | import("../../services/location/location.js").Location;
215
213
  /**
216
214
  * Internal API.
217
215
  *
@@ -13,7 +13,7 @@ export class AnchorScrollProvider {
13
13
  $get: (
14
14
  | string
15
15
  | ((
16
- $location: import("../core/location/location.js").Location,
16
+ $location: import("../services/location/location.js").Location,
17
17
  $rootScope: import("../core/scope/scope.js").Scope,
18
18
  ) => AnchorScrollFunction)
19
19
  )[];
@@ -41,8 +41,8 @@
41
41
  *
42
42
  * @see {@link angular.ErrorHandler AngularTS ErrorHandler}
43
43
  */
44
- /** @typedef {import('../services/log/interface.ts').LogService} LogService */
45
- /** @typedef {import("./error-handler.ts").ErrorHandler} ErrorHandler */
44
+ /** @typedef {import('../log/interface.ts').LogService} LogService */
45
+ /** @typedef {import("./interface.ts").Interface} ErrorHandler */
46
46
  /**
47
47
  * Provider for `$exceptionHandler` service. Delegates uncaught exceptions to `$log.error()` by default.
48
48
  * Can be overridden to implement custom error-handling logic.
@@ -54,5 +54,5 @@ export class ExceptionHandlerProvider {
54
54
  errorHandler: ErrorHandler;
55
55
  $get: (string | (($log: LogService) => ErrorHandler))[];
56
56
  }
57
- export type LogService = import("../services/log/interface.ts").LogService;
58
- export type ErrorHandler = import("./error-handler.ts").ErrorHandler;
57
+ export type LogService = import("../log/interface.ts").LogService;
58
+ export type ErrorHandler = import("./interface.ts").Interface;
@@ -4,4 +4,4 @@
4
4
  * @param exception - The exception associated with the error.
5
5
  * @param [cause] - Optional information about the context in which the error was thrown.
6
6
  */
7
- export type ErrorHandler = (exception: Error, cause?: string) => void;
7
+ export type Interface = (exception: Error, cause?: string) => void;
@@ -55,9 +55,7 @@ export class HttpProvider {
55
55
  $get: (
56
56
  | string
57
57
  | ((
58
- $browser: any,
59
58
  $httpBackend: any,
60
- $rootScope: import("../../core/scope/scope.js").Scope,
61
59
  $injector: import("../../core/di/internal-injector.js").InjectorService,
62
60
  $sce: any,
63
61
  ) => {
@@ -126,14 +126,14 @@ export interface RequestConfig extends RequestShortcutConfig {
126
126
  }
127
127
  | undefined;
128
128
  }
129
+ export type HttpResponseStatus = "complete" | "error" | "timeout" | "abort";
129
130
  export interface HttpResponse<T> {
130
131
  data: T;
131
132
  status: number;
132
133
  headers: HttpHeadersGetter;
133
134
  config: RequestConfig;
134
135
  statusText: string;
135
- /** Added in AngularJS 1.6.6 */
136
- xhrStatus: "complete" | "error" | "timeout" | "abort";
136
+ xhrStatus: HttpResponseStatus;
137
137
  }
138
138
  export type HttpPromise<T> = Promise<HttpResponse<T>>;
139
139
  /**
@@ -1,10 +1,7 @@
1
1
  /**
2
- * @param {import('../browser.js').Browser} $browser
3
2
  * @returns
4
3
  */
5
- export function createHttpBackend(
6
- $browser: import("../browser.js").Browser,
7
- ): (
4
+ export function createHttpBackend(): (
8
5
  method: any,
9
6
  url: any,
10
7
  post: any,
@@ -33,21 +30,16 @@ export function createHttpBackend(
33
30
  *
34
31
  */
35
32
  export class HttpBackendProvider {
36
- $get: (
37
- | string
38
- | ((
39
- $browser: import("../browser.js").Browser,
40
- ) => (
41
- method: any,
42
- url: any,
43
- post: any,
44
- callback: any,
45
- headers: any,
46
- timeout: any,
47
- withCredentials: any,
48
- responseType: any,
49
- eventHandlers: any,
50
- uploadEventHandlers: any,
51
- ) => void)
52
- )[];
33
+ $get: (() => (
34
+ method: any,
35
+ url: any,
36
+ post: any,
37
+ callback: any,
38
+ headers: any,
39
+ timeout: any,
40
+ withCredentials: any,
41
+ responseType: any,
42
+ eventHandlers: any,
43
+ uploadEventHandlers: any,
44
+ ) => void)[];
53
45
  }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * A callback function that gets called when the browser URL or state changes.
3
+ *
4
+ * @param url - The new URL after the change (with trailing `#` removed).
5
+ * @param state - The new history state associated with the URL (`history.state`).
6
+ * @returns void
7
+ */
8
+ export type UrlChangeListener = (url: string, state: History["state"]) => void;
@@ -37,8 +37,8 @@ export class Location {
37
37
  * @type {boolean}
38
38
  */
39
39
  $$replace: boolean;
40
- /** @type {import('../url-utils/url-utils').HttpProtocol} */
41
- $$protocol: any;
40
+ /** @type {string} */
41
+ $$protocol: string;
42
42
  /** @type {string} */
43
43
  $$host: string;
44
44
  /**
@@ -81,9 +81,9 @@ export class Location {
81
81
  /**
82
82
  *
83
83
  * Return protocol of current URL.
84
- * @return {import("../url-utils/url-utils").HttpProtocol} protocol of current URL
84
+ * @return {string} protocol of current URL
85
85
  */
86
- protocol(): any;
86
+ protocol(): string;
87
87
  /**
88
88
  * This method is getter only.
89
89
  *
@@ -227,14 +227,15 @@ export class LocationHtml5Url extends Location {
227
227
  * This object is exposed as $location service when developer doesn't opt into html5 mode.
228
228
  * It also serves as the base class for html5 mode fallback on legacy browsers.
229
229
  *
230
- * @constructor
231
- * @param {string} appBase application base URL
232
- * @param {string} appBaseNoFile application base URL stripped of any filename
233
- * @param {string} hashPrefix hashbang prefix
234
230
  */
235
231
  export class LocationHashbangUrl extends Location {
236
- constructor(appBase: any, appBaseNoFile: any, hashPrefix: any);
237
- hashPrefix: any;
232
+ /**
233
+ * @param {string} appBase application base URL
234
+ * @param {string} appBaseNoFile application base URL stripped of any filename
235
+ * @param {string} hashPrefix hashbang prefix
236
+ */
237
+ constructor(appBase: string, appBaseNoFile: string, hashPrefix: string);
238
+ hashPrefix: string;
238
239
  /**
239
240
  * Parse given hashbang URL into properties
240
241
  * @param {string} url Hashbang URL
@@ -252,6 +253,46 @@ export class LocationProvider {
252
253
  hashPrefixConf: string;
253
254
  /** @type {Html5Mode} */
254
255
  html5ModeConf: Html5Mode;
256
+ /** @type {Array<import("./interface.js").UrlChangeListener>} */
257
+ urlChangeListeners: Array<import("./interface.js").UrlChangeListener>;
258
+ urlChangeInit: boolean;
259
+ /** @type {History['state']} */
260
+ cachedState: History["state"];
261
+ /** @typeof {History.state} */
262
+ lastHistoryState: any;
263
+ /** @type {string} */
264
+ lastBrowserUrl: string;
265
+ setUrl(url: any, state: any): this;
266
+ /**
267
+ * Returns the current URL with any empty hash (`#`) removed.
268
+ * @return {string}
269
+ */
270
+ getUrl(): string;
271
+ /**
272
+ * Returns the cached state.
273
+ * @returns {History['state']} The cached state.
274
+ */
275
+ state(): History["state"];
276
+ /**
277
+ * Caches the current state.
278
+ *
279
+ * @private
280
+ */
281
+ private cacheState;
282
+ lastCachedState: any;
283
+ /**
284
+ * Fires the state or URL change event.
285
+ *
286
+ * @private
287
+ */
288
+ private fireStateOrUrlChange;
289
+ /**
290
+ * Registers a callback to be called when the URL changes.
291
+ *
292
+ * @param {import("./interface.js").UrlChangeListener} callback - The callback function to register.
293
+ * @returns void
294
+ */
295
+ onUrlChange(callback: import("./interface.js").UrlChangeListener): void;
255
296
  /**
256
297
  * The default value for the prefix is `'!'`.
257
298
  * @param {string=} prefix Prefix for hash part (containing path and search)
@@ -278,8 +319,7 @@ export class LocationProvider {
278
319
  $get: (
279
320
  | string
280
321
  | ((
281
- $rootScope: import("../scope/scope.js").Scope,
282
- $browser: any,
322
+ $rootScope: import("../../core/scope/scope.js").Scope,
283
323
  $rootElement: Element,
284
324
  ) => Location)
285
325
  )[];
@@ -243,4 +243,4 @@ export class SceDelegateProvider {
243
243
  })
244
244
  )[];
245
245
  }
246
- export type ErrorHandler = import("../error-handler.ts").ErrorHandler;
246
+ export type ErrorHandler = import("../exception/interface.ts").Interface;
@@ -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
+ }
@@ -7,5 +7,5 @@ export class TemplateCacheProvider {
7
7
  /**
8
8
  * @returns {import('./interface.ts').TemplateCache}
9
9
  */
10
- $get: () => import("./interface.ts").TemplateCache;
10
+ $get(): import("./interface.ts").TemplateCache;
11
11
  }
@@ -43,7 +43,7 @@ export class TemplateRequestProvider {
43
43
  $get: (
44
44
  | string
45
45
  | ((
46
- $exceptionHandler: import("../core/exception-handler.js").ErrorHandler,
46
+ $exceptionHandler: import("./exception/exception-handler.js").ErrorHandler,
47
47
  $templateCache: import("../services/template-cache/interface.ts").TemplateCache,
48
48
  $http: any,
49
49
  $sce: any,
@@ -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
  */
@@ -240,6 +240,12 @@ export function domInsert(
240
240
  parentElement: any,
241
241
  afterElement: any,
242
242
  ): void;
243
+ /**
244
+ * Returns the base href of the document.
245
+ *
246
+ * @returns {string} The base href.
247
+ */
248
+ export function getBaseHref(): string;
243
249
  /**
244
250
  * A list of boolean attributes in HTML.
245
251
  * @type {string[]}
@@ -6,6 +6,7 @@
6
6
  export function browserTrigger(element: HTMLElement, options: any): void;
7
7
  /**
8
8
  * Delays execution for a specified number of milliseconds.
9
+ * TODO remove
9
10
  *
10
11
  * @param {number} [t=0] - The number of milliseconds to wait. Defaults to 0.
11
12
  * @returns {Promise<void>} A promise that resolves after the delay.
@@ -0,0 +1,47 @@
1
+ export type HttpProtocol = "http" | "https";
2
+ /**
3
+ * A normalized representation of a parsed URL.
4
+ */
5
+ export interface ParsedUrl {
6
+ /**
7
+ * The full URL string, including protocol, host, path, query, and hash.
8
+ * Example: "https://example.com:8080/path?query=1#section"
9
+ */
10
+ href: string;
11
+ /**
12
+ * The protocol scheme of the URL, without the trailing colon.
13
+ * Example: "http" or "https"
14
+ */
15
+ protocol: string;
16
+ /**
17
+ * The host part of the URL, including hostname and port (if specified).
18
+ * Example: "example.com:8080"
19
+ */
20
+ host: string;
21
+ /**
22
+ * The query string portion of the URL, without the leading "?".
23
+ * Example: "query=1&sort=asc"
24
+ */
25
+ search: string;
26
+ /**
27
+ * The fragment identifier (hash) of the URL, without the leading "#".
28
+ * Example: "section2"
29
+ */
30
+ hash: string;
31
+ /**
32
+ * The domain or IP address (including IPv6 in brackets) of the URL.
33
+ * Example: "example.com" or "[::1]"
34
+ */
35
+ hostname: string;
36
+ /**
37
+ * The port number of the URL as a string, or an empty string if not specified.
38
+ * Example: "8080" or ""
39
+ */
40
+ port: string;
41
+ /**
42
+ * The path of the URL, always beginning with a leading slash.
43
+ * Example: "/path/to/resource"
44
+ */
45
+ pathname: string;
46
+ }
47
+ export type ResolvableUrl = string | ParsedUrl;
@@ -1,49 +1,59 @@
1
- export function urlResolve(url: any): any;
1
+ /**
2
+ * @param {import("./interface.js").ResolvableUrl} url
3
+ * @return {import("./interface.js").ParsedUrl}
4
+ */
5
+ export function urlResolve(
6
+ url: import("./interface.js").ResolvableUrl,
7
+ ): import("./interface.js").ParsedUrl;
2
8
  /**
3
9
  * Parse a request URL and determine whether this is a same-origin request as the application
4
10
  * document.
5
11
  *
6
- * @param {string|object} requestUrl The url of the request as a string that will be resolved
12
+ * @param {import("./interface.js").ResolvableUrl} requestUrl The url of the request as a string that will be resolved
7
13
  * or a parsed URL object.
8
14
  * @returns {boolean} Whether the request is for the same origin as the application document.
9
15
  */
10
- export function urlIsSameOrigin(requestUrl: string | object): boolean;
16
+ export function urlIsSameOrigin(
17
+ requestUrl: import("./interface.js").ResolvableUrl,
18
+ ): boolean;
11
19
  /**
12
20
  * Parse a request URL and determine whether it is same-origin as the current document base URL.
13
21
  *
14
22
  * Note: The base URL is usually the same as the document location (`location.href`) but can
15
23
  * be overriden by using the `<base>` tag.
16
24
  *
17
- * @param {string|object} requestUrl The url of the request as a string that will be resolved
25
+ * @param {import("./interface.js").ResolvableUrl} requestUrl The url of the request as a string that will be resolved
18
26
  * or a parsed URL object.
19
27
  * @returns {boolean} Whether the URL is same-origin as the document base URL.
20
28
  */
21
- export function urlIsSameOriginAsBaseUrl(requestUrl: string | object): boolean;
29
+ export function urlIsSameOriginAsBaseUrl(
30
+ requestUrl: import("./interface.js").ResolvableUrl,
31
+ ): boolean;
22
32
  /**
23
33
  * Create a function that can check a URL's origin against a list of allowed/trusted origins.
24
34
  * The current location's origin is implicitly trusted.
25
35
  *
26
36
  * @param {string[]} trustedOriginUrls - A list of URLs (strings), whose origins are trusted.
27
37
  *
28
- * @returns {Function} - A function that receives a URL (string or parsed URL object) and returns
38
+ * @returns {(url: import("./interface.js").ResolvableUrl) => boolean } - A function that receives a URL (string or parsed URL object) and returns
29
39
  * whether it is of an allowed origin.
30
40
  */
31
41
  export function urlIsAllowedOriginFactory(
32
42
  trustedOriginUrls: string[],
33
- ): Function;
43
+ ): (url: import("./interface.js").ResolvableUrl) => boolean;
34
44
  /**
35
45
  * Determine if two URLs share the same origin.
36
46
  *
37
- * @param {string|Object} url1 - First URL to compare as a string or a normalized URL in the form of
47
+ * @param {import("./interface.js").ResolvableUrl} url1 - First URL to compare as a string or a normalized URL in the form of
38
48
  * a dictionary object returned by `urlResolve()`.
39
- * @param {string|object} url2 - Second URL to compare as a string or a normalized URL in the form
49
+ * @param {import("./interface.js").ResolvableUrl} url2 - Second URL to compare as a string or a normalized URL in the form
40
50
  * of a dictionary object returned by `urlResolve()`.
41
51
  *
42
52
  * @returns {boolean} - True if both URLs have the same origin, and false otherwise.
43
53
  */
44
54
  export function urlsAreSameOrigin(
45
- url1: string | any,
46
- url2: string | object,
55
+ url1: import("./interface.js").ResolvableUrl,
56
+ url2: import("./interface.js").ResolvableUrl,
47
57
  ): boolean;
48
58
  /**
49
59
  * Returns the current document base URL.
@@ -51,6 +61,9 @@ export function urlsAreSameOrigin(
51
61
  */
52
62
  export function getBaseUrl(): string;
53
63
  /**
54
- * HTTP protocol
64
+ * Removes a trailing hash ('#') from the given URL if it exists.
65
+ *
66
+ * @param {string} url
67
+ * @returns {string}
55
68
  */
56
- export type HttpProtocol = "http" | "https";
69
+ export function trimEmptyHash(url: string): string;
@@ -533,6 +533,21 @@ export function hasOwn(obj: object, key: string | number | symbol): boolean;
533
533
  * @returns {Function} A new function that will call `fn` only once.
534
534
  */
535
535
  export function callBackOnce(fn: Function): Function;
536
+ /**
537
+ * Wraps a function so it will only be called starting from the second invocation.
538
+ * The first call does nothing and returns undefined.
539
+ *
540
+ * @param {Function} fn - The function to wrap.
541
+ * @returns {Function} A new function that will skip the first call.
542
+ */
543
+ export function callBackAfterFirst(fn: Function): Function;
544
+ /**
545
+ * Delays execution for a specified number of milliseconds.
546
+ *
547
+ * @param {number} [t=0] - The number of milliseconds to wait. Defaults to 0.
548
+ * @returns {Promise<void>} A promise that resolves after the delay.
549
+ */
550
+ export function wait(t?: number): Promise<void>;
536
551
  export const isProxySymbol: unique symbol;
537
552
  export const ngAttrPrefixes: string[];
538
553
  /**
package/Makefile CHANGED
@@ -28,10 +28,11 @@ types:
28
28
  @rm -rf @types
29
29
  @echo "Generating *.d.ts"
30
30
  @npx -p typescript tsc --project tsconfig.types.json
31
+ $(MAKE) pretty
31
32
 
32
33
 
33
34
  TYPEDOC_DIR = docs/static/typedoc
34
- typedoc: types pretty
35
+ doc: types
35
36
  @rm -rf $(TYPEDOC_DIR)
36
37
  @npm run generate-docs
37
38
  @npx prettier ./typedoc --write
@@ -40,7 +41,7 @@ typedoc: types pretty
40
41
  serve:
41
42
  @npm run serve
42
43
 
43
- prepare-release: test check types typedoc pretty build
44
+ prepare-release: test check types doc pretty build
44
45
 
45
46
  PLAYWRIGHT_TEST := npx playwright test
46
47