@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,145 +0,0 @@
1
- /** @typedef {import('../interface.ts').ServiceProvider} ServiceProvider */
2
- /** @typedef {import('../interface.ts').AnnotatedFactory} AnnotatedFactory */
3
-
4
- /**
5
- * @implements {ServiceProvider}
6
- */
7
- export class TaskTrackerFactoryProvider {
8
- /** @type {AnnotatedFactory} */
9
- $get = [
10
- "$log",
11
- /**
12
- * Creates a new `TaskTracker` instance.
13
- *
14
- * @param {import('../services/log/interface.ts').LogService} log - The logging service.
15
- * @returns {TaskTracker} A new `TaskTracker` instance.
16
- */
17
- (log) => new TaskTracker(log),
18
- ];
19
- }
20
-
21
- /**
22
- * A factory function to create `TaskTracker` instances.
23
- *
24
- * A `TaskTracker` tracks pending tasks (grouped by type) and notifies interested
25
- * parties when all pending tasks (or tasks of a specific type) have been completed.
26
- */
27
- export class TaskTracker {
28
- /**
29
- * @param {import('../services/log/interface.ts').LogService} log - The logging service.
30
- */
31
- constructor(log) {
32
- /** @private */
33
- this.log = log;
34
-
35
- /** @private */
36
- this.taskCounts = {};
37
-
38
- /** @private */
39
- this.taskCallbacks = [];
40
-
41
- /**
42
- * Special task types used for tracking all tasks and default tasks.
43
- * @type {string}
44
- */
45
- this.ALL_TASKS_TYPE = "$$all$$";
46
-
47
- /**
48
- * Default task type.
49
- * @type {string}
50
- */
51
- this.DEFAULT_TASK_TYPE = "$$default$$";
52
- }
53
-
54
- /**
55
- * Completes a task and decrements the associated task counter.
56
- * If the counter reaches 0, all corresponding callbacks are executed.
57
- *
58
- * @param {Function} fn - The function to execute when completing the task.
59
- * @param {string} [taskType=this.DEFAULT_TASK_TYPE] - The type of task being completed.
60
- */
61
- completeTask(fn, taskType = this.DEFAULT_TASK_TYPE) {
62
- try {
63
- fn();
64
- } finally {
65
- if (this.taskCounts[taskType]) {
66
- this.taskCounts[taskType]--;
67
- this.taskCounts[this.ALL_TASKS_TYPE]--;
68
- }
69
-
70
- const countForType = this.taskCounts[taskType];
71
- const countForAll = this.taskCounts[this.ALL_TASKS_TYPE];
72
-
73
- // If either the overall task queue or the specific task type queue is empty, run callbacks.
74
- if (!countForAll || !countForType) {
75
- const getNextCallback = !countForAll
76
- ? this.getLastCallback.bind(this)
77
- : () => this.getLastCallbackForType(taskType);
78
-
79
- let nextCb;
80
- while ((nextCb = getNextCallback())) {
81
- try {
82
- nextCb();
83
- } catch (e) {
84
- this.log.error(e);
85
- }
86
- }
87
- }
88
- }
89
- }
90
-
91
- /**
92
- * Increments the task count for the specified task type.
93
- *
94
- * @param {string} [taskType=this.DEFAULT_TASK_TYPE] - The type of task whose count will be increased.
95
- */
96
- incTaskCount(taskType = this.DEFAULT_TASK_TYPE) {
97
- this.taskCounts[taskType] = (this.taskCounts[taskType] || 0) + 1;
98
- this.taskCounts[this.ALL_TASKS_TYPE] =
99
- (this.taskCounts[this.ALL_TASKS_TYPE] || 0) + 1;
100
- }
101
-
102
- /**
103
- * Registers a callback to be executed when all pending tasks of the specified type are completed.
104
- * If there are no pending tasks of the specified type, the callback is executed immediately.
105
- *
106
- * @param {Function} callback - The function to execute when no pending tasks remain.
107
- * @param {string} [taskType=this.ALL_TASKS_TYPE] - The type of tasks to wait for completion.
108
- */
109
- notifyWhenNoPendingTasks(callback, taskType = this.ALL_TASKS_TYPE) {
110
- if (!this.taskCounts[taskType]) {
111
- callback();
112
- } else {
113
- this.taskCallbacks.push({ type: taskType, cb: callback });
114
- }
115
- }
116
-
117
- /**
118
- * Retrieves and removes the last registered callback from the queue.
119
- *
120
- * @private
121
- * @returns {Function|undefined} The last callback function or undefined if none exist.
122
- */
123
- getLastCallback() {
124
- const cbInfo = this.taskCallbacks.pop();
125
- return cbInfo ? cbInfo.cb : undefined;
126
- }
127
-
128
- /**
129
- * Retrieves and removes the last registered callback for the specified task type.
130
- *
131
- * @private
132
- * @param {string} taskType - The type of task for which the callback was registered.
133
- * @returns {Function|undefined} The last callback function for the task type, or undefined if none exist.
134
- */
135
- getLastCallbackForType(taskType) {
136
- for (let i = this.taskCallbacks.length - 1; i >= 0; --i) {
137
- const cbInfo = this.taskCallbacks[i];
138
- if (cbInfo.type === taskType) {
139
- this.taskCallbacks.splice(i, 1);
140
- return cbInfo.cb;
141
- }
142
- }
143
- return undefined;
144
- }
145
- }
@@ -1,212 +0,0 @@
1
- import { urlResolve } from "../core/url-utils/url-utils.js";
2
- import { equals } from "../shared/utils.js";
3
-
4
- /**
5
- * Removes a trailing hash ('#') from the given URL if it exists.
6
- *
7
- * @param {string} url
8
- * @returns {string}
9
- */
10
- export function trimEmptyHash(url) {
11
- return url.replace(/#$/, "");
12
- }
13
-
14
- /**
15
- * @typedef {function(string, string|null): any} UrlChangeListener
16
- */
17
-
18
- /**
19
- * This object has two goals:
20
- *
21
- * - hide all the global state in the browser caused by the window object
22
- * - abstract away all the browser specific features and inconsistencies
23
- */
24
- export class Browser {
25
- /**
26
- * @param {import('../core/task-tracker-factory.js').TaskTracker} taskTracker
27
- */
28
- constructor(taskTracker) {
29
- /**
30
- * @type {import('../core/task-tracker-factory.js').TaskTracker} taskTracker
31
- */
32
- this.taskTracker = taskTracker;
33
- this.pendingDeferIds = {};
34
- /** @type {Array<UrlChangeListener>} */
35
- this.urlChangeListeners = [];
36
- this.urlChangeInit = false;
37
-
38
- /** @type {any} */
39
- this.cachedState = null;
40
- /** @type {any} */
41
- this.lastHistoryState = null;
42
- /** @type {string} */
43
- this.lastBrowserUrl = window.location.href;
44
- /** @type {HTMLBaseElement | null} */
45
- this.baseElement = document.querySelector("base");
46
-
47
- // Task-tracking API
48
- this.$$completeOutstandingRequest =
49
- this.taskTracker.completeTask.bind(taskTracker);
50
- this.$$incOutstandingRequestCount =
51
- this.taskTracker.incTaskCount.bind(taskTracker);
52
- this.notifyWhenNoOutstandingRequests =
53
- this.taskTracker.notifyWhenNoPendingTasks.bind(taskTracker);
54
-
55
- this.cacheState();
56
- }
57
-
58
- /// ///////////////////////////////////////////////////////////
59
- // URL API
60
- /// ///////////////////////////////////////////////////////////
61
-
62
- url(url, state) {
63
- if (state === undefined) {
64
- state = null;
65
- }
66
-
67
- // setter
68
- if (url) {
69
- url = urlResolve(url).href;
70
-
71
- if (this.lastBrowserUrl === url && this.lastHistoryState === state) {
72
- return this;
73
- }
74
-
75
- this.lastBrowserUrl = url;
76
- this.lastHistoryState = state;
77
- history.pushState(state, "", url);
78
- this.cacheState();
79
- return this;
80
- }
81
-
82
- // getter
83
- return trimEmptyHash(window.location.href);
84
- }
85
-
86
- /**
87
- * Returns the cached state.
88
- *
89
- * @returns {any} The cached state.
90
- */
91
- state() {
92
- return this.cachedState;
93
- }
94
-
95
- /**
96
- * Caches the current state and fires the URL change event.
97
- *
98
- * @private
99
- */
100
- cacheStateAndFireUrlChange() {
101
- this.fireStateOrUrlChange();
102
- }
103
-
104
- /**
105
- * Caches the current state.
106
- *
107
- * @private
108
- */
109
- cacheState() {
110
- const currentState = history.state ?? null;
111
- if (!equals(currentState, this.lastCachedState)) {
112
- this.cachedState = currentState;
113
- this.lastCachedState = currentState;
114
- this.lastHistoryState = currentState;
115
- }
116
- }
117
-
118
- /**
119
- * Fires the state or URL change event.
120
- *
121
- * @private
122
- */
123
- fireStateOrUrlChange() {
124
- const prevLastHistoryState = this.lastHistoryState;
125
- this.cacheState();
126
-
127
- if (
128
- this.lastBrowserUrl === this.url() &&
129
- prevLastHistoryState === this.cachedState
130
- ) {
131
- return;
132
- }
133
-
134
- this.lastBrowserUrl = /** @type {string} */ (this.url());
135
- this.lastHistoryState = this.cachedState;
136
- this.urlChangeListeners.forEach((listener) => {
137
- listener(trimEmptyHash(window.location.href), this.cachedState);
138
- });
139
- }
140
-
141
- /**
142
- * Registers a callback to be called when the URL changes.
143
- *
144
- * @param {UrlChangeListener} callback - The callback function to register.
145
- * @returns {UrlChangeListener} The registered callback function.
146
- */
147
- onUrlChange(callback) {
148
- if (!this.urlChangeInit) {
149
- window.addEventListener(
150
- "popstate",
151
- this.cacheStateAndFireUrlChange.bind(this),
152
- );
153
- window.addEventListener(
154
- "hashchange",
155
- this.cacheStateAndFireUrlChange.bind(this),
156
- );
157
-
158
- this.urlChangeInit = true;
159
- }
160
-
161
- this.urlChangeListeners.push(callback);
162
- return callback;
163
- }
164
-
165
- $$applicationDestroyed() {
166
- window.removeEventListener(
167
- "popstate",
168
- this.cacheStateAndFireUrlChange.bind(this),
169
- );
170
- window.removeEventListener(
171
- "hashchange",
172
- this.cacheStateAndFireUrlChange.bind(this),
173
- );
174
- }
175
-
176
- $$checkUrlChange() {
177
- this.fireStateOrUrlChange();
178
- }
179
-
180
- /// ///////////////////////////////////////////////////////////
181
- // Misc API
182
- /// ///////////////////////////////////////////////////////////
183
-
184
- /**
185
- * Returns the base href of the document.
186
- *
187
- * @returns {string} The base href.
188
- */
189
- baseHref() {
190
- const href = this.baseElement?.getAttribute("href");
191
- return href ? href.replace(/^(https?:)?\/\/[^/]*/, "") : "";
192
- }
193
- }
194
-
195
- /**
196
- * This object has two goals:
197
- *
198
- * - hide all the global state in the browser caused by the window object
199
- * - abstract away all the browser specific features and inconsistencies
200
- *
201
- * Remove this in the future
202
- */
203
- export class BrowserProvider {
204
- $get = [
205
- "$$taskTrackerFactory",
206
- /**
207
- * @param {import('../core/task-tracker-factory.js').TaskTracker} $$taskTrackerFactory
208
- * @returns {Browser}
209
- */
210
- ($$taskTrackerFactory) => new Browser($$taskTrackerFactory),
211
- ];
212
- }
File without changes
File without changes
File without changes