@angular-wave/angular.ts 0.7.3 → 0.7.5

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 (237) hide show
  1. package/.prettierignore +2 -1
  2. package/@types/core/exception-handler.d.ts +2 -2
  3. package/@types/core/task-tracker-factory.d.ts +2 -2
  4. package/@types/directive/channel/channel.d.ts +2 -18
  5. package/@types/directive/http/http.d.ts +3 -0
  6. package/@types/directive/script/script.d.ts +2 -2
  7. package/@types/directive/setter/setter.d.ts +2 -2
  8. package/@types/injection-tokens.d.ts +3 -0
  9. package/@types/interface.d.ts +11 -0
  10. package/@types/loader.d.ts +3 -4
  11. package/@types/router/params/param-factory.d.ts +10 -2
  12. package/@types/router/params/param.d.ts +22 -3
  13. package/@types/router/template-factory.d.ts +2 -2
  14. package/@types/router/url/url-service.d.ts +2 -2
  15. package/@types/services/http/http.d.ts +2 -2
  16. package/@types/services/http/interface.d.ts +219 -0
  17. package/@types/services/http-backend/http-backend.d.ts +26 -19
  18. package/@types/services/log/interface.d.ts +33 -0
  19. package/@types/services/log/log.d.ts +25 -0
  20. package/@types/{core → services}/pubsub/pubsub.d.ts +6 -6
  21. package/@types/services/template-cache/interface.d.ts +4 -0
  22. package/@types/services/template-cache/template-cache.d.ts +11 -0
  23. package/@types/services/template-request.d.ts +1 -1
  24. package/@types/shared/cache.d.ts +9 -0
  25. package/@types/shared/dom.d.ts +2 -2
  26. package/Makefile +2 -2
  27. package/dist/angular-ts.esm.js +168 -165
  28. package/dist/angular-ts.umd.js +168 -165
  29. package/dist/angular-ts.umd.min.js +1 -1
  30. package/docs/assets/scss/_variables_project.scss +1 -1
  31. package/docs/assets/scss/_variables_project_after_bs.scss +5 -5
  32. package/docs/assets/scss/index.scss +2 -3
  33. package/docs/content/_index.md +1 -1
  34. package/docs/content/docs/_index.md +59 -25
  35. package/docs/content/docs/directive/_index.md +4 -0
  36. package/docs/content/docs/directive/app.md +11 -0
  37. package/docs/content/docs/directive/aria.md +0 -0
  38. package/docs/content/docs/directive/blur.md +38 -0
  39. package/docs/content/docs/directive/channel.md +37 -0
  40. package/docs/content/docs/directive/class-even.md +47 -0
  41. package/docs/content/docs/directive/class-odd.md +48 -0
  42. package/docs/content/docs/directive/class.md +64 -0
  43. package/docs/content/docs/directive/click.md +38 -0
  44. package/docs/content/docs/directive/cloak.md +74 -0
  45. package/docs/content/docs/directive/copy.md +38 -0
  46. package/docs/content/docs/directive/cut.md +40 -0
  47. package/docs/content/docs/directive/dblclick.md +38 -0
  48. package/docs/content/docs/directive/focus.md +38 -0
  49. package/docs/content/docs/directive/include.md +7 -0
  50. package/docs/content/docs/directive/keydown.md +0 -0
  51. package/docs/content/docs/directive/keyup.md +0 -0
  52. package/docs/content/docs/directive/load.md +0 -0
  53. package/docs/content/docs/directive/mousedown.md +38 -0
  54. package/docs/content/docs/directive/mouseenter.md +38 -0
  55. package/docs/content/docs/directive/mouseleave.md +38 -0
  56. package/docs/content/docs/directive/mousemove.md +38 -0
  57. package/docs/content/docs/directive/mouseout.md +38 -0
  58. package/docs/content/docs/directive/mouseover.md +38 -0
  59. package/docs/content/docs/directive/mouseup.md +38 -0
  60. package/docs/content/docs/filter/_index.md +4 -0
  61. package/docs/content/docs/provider/_index.md +4 -0
  62. package/docs/content/docs/provider/eventBusProvider.md +35 -0
  63. package/docs/content/docs/provider/logProvider.md +59 -0
  64. package/docs/content/docs/provider/templateCacheProvider.md +35 -0
  65. package/docs/content/docs/service/_index.md +4 -0
  66. package/docs/content/docs/service/eventBus.md +56 -0
  67. package/docs/content/docs/service/log.md +113 -0
  68. package/docs/content/docs/service/templateCache.md +64 -0
  69. package/docs/hugo.yaml +3 -3
  70. package/docs/layouts/404.html +1 -1
  71. package/docs/layouts/partials/hooks/head-end.html +3 -0
  72. package/docs/layouts/shortcodes/showhtml.html +2 -0
  73. package/docs/layouts/shortcodes/showjs.html +2 -0
  74. package/docs/layouts/shortcodes/showraw.html +1 -0
  75. package/docs/static/examples/counter/counter-test.html +17 -0
  76. package/docs/static/examples/counter/counter.html +5 -0
  77. package/docs/static/examples/counter/counter.test.js +28 -0
  78. package/docs/static/examples/eventbus/eventbus-test.html +19 -0
  79. package/docs/static/examples/eventbus/eventbus.html +13 -0
  80. package/docs/static/examples/eventbus/eventbus.js +15 -0
  81. package/docs/static/examples/eventbus/eventbus.test.js +19 -0
  82. package/docs/static/examples/ng-blur/ng-blur.html +9 -0
  83. package/docs/static/examples/ng-channel/ng-channel-test.html +17 -0
  84. package/docs/static/examples/ng-channel/ng-channel.html +24 -0
  85. package/docs/static/examples/ng-channel/ng-channel.test.js +31 -0
  86. package/docs/static/examples/ng-class/ng-class.html +71 -0
  87. package/docs/static/examples/ng-class-even/ng-class-even.html +8 -0
  88. package/docs/static/examples/ng-class-odd/ng-class-odd.html +8 -0
  89. package/docs/static/examples/ng-click/ng-click.html +6 -0
  90. package/docs/static/examples/ng-copy/ng-copy.html +6 -0
  91. package/docs/static/examples/ng-cut/ng-cut.html +6 -0
  92. package/docs/static/examples/ng-dblclick/ng-dblclick.html +10 -0
  93. package/docs/static/examples/ng-focus/ng-focus.html +9 -0
  94. package/docs/static/examples/ng-mousedown/ng-mousedown.html +6 -0
  95. package/docs/static/examples/ng-mouseenter/ng-mouseenter.html +4 -0
  96. package/docs/static/examples/ng-mouseleave/ng-mouseleave.html +4 -0
  97. package/docs/static/examples/ng-mousemove/ng-mousemove.html +4 -0
  98. package/docs/static/examples/ng-mouseout/ng-mouseout.html +4 -0
  99. package/docs/static/examples/ng-mouseover/ng-mouseover.html +4 -0
  100. package/docs/static/examples/ng-mouseup/ng-mouseup.html +4 -0
  101. package/docs/static/typedoc/assets/hierarchy.js +1 -1
  102. package/docs/static/typedoc/assets/navigation.js +1 -1
  103. package/docs/static/typedoc/assets/search.js +1 -1
  104. package/docs/static/typedoc/classes/LogProvider.html +6 -0
  105. package/docs/static/typedoc/classes/PubSub.html +71 -0
  106. package/docs/static/typedoc/classes/PubSubProvider.html +3 -0
  107. package/docs/static/typedoc/classes/TemplateCacheProvider.html +5 -0
  108. package/docs/static/typedoc/hierarchy.html +1 -1
  109. package/docs/static/typedoc/index.html +1 -1
  110. package/docs/static/typedoc/interfaces/ChangesObject.html +1 -1
  111. package/docs/static/typedoc/interfaces/ComponentOptions.html +1 -1
  112. package/docs/static/typedoc/interfaces/Controller.html +1 -1
  113. package/docs/static/typedoc/interfaces/Directive.html +1 -1
  114. package/docs/static/typedoc/interfaces/DirectivePrePost.html +1 -1
  115. package/docs/static/typedoc/interfaces/HttpHeadersGetter.html +1 -0
  116. package/docs/static/typedoc/interfaces/HttpProviderDefaults.html +31 -0
  117. package/docs/static/typedoc/interfaces/HttpRequestConfigHeaders.html +6 -0
  118. package/docs/static/typedoc/interfaces/HttpRequestTransformer.html +1 -0
  119. package/docs/static/typedoc/interfaces/HttpResponse.html +8 -0
  120. package/docs/static/typedoc/interfaces/HttpResponseTransformer.html +1 -0
  121. package/docs/static/typedoc/interfaces/HttpService.html +38 -0
  122. package/docs/static/typedoc/interfaces/LogService.html +12 -0
  123. package/docs/static/typedoc/interfaces/NgModelController.html +1 -1
  124. package/docs/static/typedoc/interfaces/NgModelOptions.html +1 -1
  125. package/docs/static/typedoc/interfaces/Provider.html +1 -1
  126. package/docs/static/typedoc/interfaces/RequestConfig.html +48 -0
  127. package/docs/static/typedoc/interfaces/RequestShortcutConfig.html +38 -0
  128. package/docs/static/typedoc/interfaces/ServiceProvider.html +1 -1
  129. package/docs/static/typedoc/interfaces/TranscludeFunctionObject.html +1 -1
  130. package/docs/static/typedoc/types/AnnotatedFactory.html +1 -1
  131. package/docs/static/typedoc/types/CloneAttachFunction.html +1 -1
  132. package/docs/static/typedoc/types/ControllerConstructor.html +1 -1
  133. package/docs/static/typedoc/types/DirectiveCompileFn.html +1 -1
  134. package/docs/static/typedoc/types/DirectiveController.html +1 -1
  135. package/docs/static/typedoc/types/DirectiveFactory.html +1 -1
  136. package/docs/static/typedoc/types/DirectiveLinkFn.html +1 -1
  137. package/docs/static/typedoc/types/ExpandoStore.html +2 -0
  138. package/docs/static/typedoc/types/Expression.html +1 -1
  139. package/docs/static/typedoc/types/FilterFactory.html +1 -1
  140. package/docs/static/typedoc/types/FilterFn.html +1 -1
  141. package/docs/static/typedoc/types/HttpPromise.html +1 -0
  142. package/docs/static/typedoc/types/Injectable.html +1 -1
  143. package/docs/static/typedoc/types/InjectableFactory.html +1 -1
  144. package/docs/static/typedoc/types/LogCall.html +2 -0
  145. package/docs/static/typedoc/types/LogServiceFactory.html +2 -0
  146. package/docs/static/typedoc/types/OnChangesObject.html +1 -1
  147. package/docs/static/typedoc/types/SwapInsertPosition.html +1 -1
  148. package/docs/static/typedoc/types/TController.html +1 -1
  149. package/docs/static/typedoc/types/TemplateCache.html +2 -0
  150. package/docs/static/typedoc/variables/EventBus.html +1 -0
  151. package/index.html +4 -2
  152. package/package.json +3 -3
  153. package/src/animations/animate-css.js +5 -1
  154. package/src/binding.spec.js +3 -1
  155. package/src/core/compile/compile.spec.js +12 -5
  156. package/src/core/core.html +0 -1
  157. package/src/core/exception-handler.js +1 -1
  158. package/src/core/prop.spec.js +1 -0
  159. package/src/core/task-tracker-factory.js +2 -2
  160. package/src/directive/bind/bind.spec.js +1 -4
  161. package/src/directive/channel/channel.js +8 -24
  162. package/src/directive/channel/channel.spec.js +4 -2
  163. package/src/directive/class/class.js +16 -0
  164. package/src/directive/class/class.spec.js +2 -0
  165. package/src/directive/events/event.spec.js +1 -0
  166. package/src/directive/events/events.js +21 -24
  167. package/src/directive/form/form.spec.js +2 -0
  168. package/src/directive/http/http.js +4 -4
  169. package/src/directive/if/if.spec.js +2 -0
  170. package/src/directive/include/include.spec.js +1 -0
  171. package/src/directive/input/input.spec.js +1 -0
  172. package/src/directive/model/model.spec.js +3 -0
  173. package/src/directive/model-options/model-options.spec.js +2 -0
  174. package/src/directive/observe/{test.html → observe-demo.html} +0 -1
  175. package/src/directive/observe/observe.spec.js +2 -1
  176. package/src/{core/pubsub/pubsub.html → directive/on/on.html} +1 -1
  177. package/src/{core → directive/on}/on.spec.js +5 -3
  178. package/src/directive/on/on.test.js +11 -0
  179. package/src/directive/options/options.spec.js +1 -0
  180. package/src/directive/script/script.js +1 -1
  181. package/src/directive/select/select.spec.js +1 -0
  182. package/src/directive/setter/setter.js +1 -1
  183. package/src/directive/setter/setter.spec.js +2 -0
  184. package/src/directive/switch/switch.spec.js +1 -0
  185. package/src/injection-tokens.js +3 -0
  186. package/src/interface.ts +10 -0
  187. package/src/loader.js +3 -6
  188. package/src/public.js +3 -3
  189. package/src/router/directives/state-directives.spec.js +3 -1
  190. package/src/router/params/param-factory.js +6 -0
  191. package/src/router/params/param.js +22 -7
  192. package/src/router/router.html +0 -1
  193. package/src/router/router.test.js +2 -1
  194. package/src/router/services.spec.js +2 -0
  195. package/src/router/state/state-builder.js +3 -0
  196. package/src/router/state/state-builder.spec.js +2 -0
  197. package/src/router/state/state-service.js +1 -1
  198. package/src/router/state-filter.spec.js +2 -0
  199. package/src/router/template-factory.html +19 -0
  200. package/src/router/template-factory.js +3 -3
  201. package/src/router/template-factory.spec.js +1 -0
  202. package/src/router/template-factory.test.js +12 -0
  203. package/src/router/transition/transition-hook.js +1 -1
  204. package/src/router/url/url-service.js +1 -1
  205. package/src/router/view-scroll.spec.js +3 -1
  206. package/src/services/http/http.js +4 -4
  207. package/src/services/http/http.test.js +1 -1
  208. package/src/services/http/interface.ts +243 -0
  209. package/src/services/http-backend/http-backend.js +21 -11
  210. package/src/services/log/interface.ts +39 -0
  211. package/src/services/log/log.html +19 -0
  212. package/src/services/log/log.js +74 -0
  213. package/src/services/log/log.spec.js +64 -0
  214. package/src/services/log/log.test.js +11 -0
  215. package/src/services/pubsub/pubsub.html +19 -0
  216. package/src/{core → services}/pubsub/pubsub.js +6 -5
  217. package/src/{core → services}/pubsub/pubsub.spec.js +3 -3
  218. package/src/{core → services}/pubsub/pubsub.test.js +1 -1
  219. package/src/services/template-cache/interface.ts +4 -0
  220. package/src/services/template-cache/template-cache.html +22 -0
  221. package/src/services/template-cache/template-cache.js +13 -0
  222. package/src/services/template-cache/template-cache.spec.js +62 -0
  223. package/src/services/template-cache/template-cache.test.js +11 -0
  224. package/src/services/template-request.js +2 -2
  225. package/src/shared/cache.js +9 -0
  226. package/src/shared/dom.js +13 -7
  227. package/utils/express.js +7 -9
  228. package/@types/core/cache/cache-factory.d.ts +0 -22
  229. package/@types/core/cache/cache.d.ts +0 -28
  230. package/@types/services/log.d.ts +0 -53
  231. package/src/core/cache/cache-factory.js +0 -19
  232. package/src/core/cache/cache.js +0 -27
  233. package/src/directive/class/class.md +0 -90
  234. package/src/directive/cloak/cloak.md +0 -24
  235. package/src/examples/counter.html +0 -20
  236. package/src/services/log.js +0 -95
  237. package/src/services/log.md +0 -39
@@ -3,38 +3,22 @@ import { $injectTokens } from "../../injection-tokens.js";
3
3
 
4
4
  ngChannelDirective.$inject = [$injectTokens.$eventBus];
5
5
  /**
6
- * Dynamically updates an element's content based on events published on a specified channel.
7
- * If data is sent via `$eventBus` on the specified `ngChannel`, the directive attempts to update the element's content accordingly,
8
- * either by directly setting the inner HTML or merging the scope's data if the element contains a template.
9
- *
10
- * If the element has a template and incoming data is an object, the directive will merge all key/value pairs onto the scope,
11
- * allowing Angular expressions (`{{ yourModel }}`) to be evaluated and rendered.
12
- *
13
- * When the scope is destroyed, the directive automatically unsubscribes from the channel.
14
- * Example:
15
- *
16
- * HTML:
17
- * <div ng-channel="userChannel">Hello {{ user.firstName }} {{ user.lastName }}</div>
18
- *
19
- * JavaScript:
20
- * angular.$eventBus.publish('userChannel', { user: { firstName: 'John', lastName: 'Smith' } });
21
- *
22
- * @param {import("../../core/pubsub/pubsub.js").PubSub} $eventBus
6
+ * @param {import("../../services/pubsub/pubsub.js").PubSub} $eventBus
23
7
  * @returns {import("../../interface.ts").Directive}
24
8
  */
25
9
  export function ngChannelDirective($eventBus) {
26
10
  return {
27
11
  link: (scope, element, attrs) => {
28
- const hasTemplate = element.childNodes.length > 0;
29
12
  const channel = attrs["ngChannel"];
13
+ const hasTemplateContent = element.childNodes.length > 0;
30
14
 
31
- const key = $eventBus.subscribe(channel, (val) => {
32
- if (!hasTemplate) {
33
- element.innerHTML = val;
34
- } else {
35
- if (isObject(val)) {
36
- scope.$merge(val);
15
+ const key = $eventBus.subscribe(channel, (value) => {
16
+ if (hasTemplateContent) {
17
+ if (isObject(value)) {
18
+ scope.$merge(value);
37
19
  }
20
+ } else {
21
+ element.innerHTML = value;
38
22
  }
39
23
  });
40
24
 
@@ -1,12 +1,14 @@
1
1
  import { Angular } from "../../loader.js";
2
- import { EventBus } from "../../core/pubsub/pubsub";
2
+ import { EventBus } from "../../services/pubsub/pubsub.js";
3
+ import { dealoc } from "../../shared/dom.js";
3
4
  import { wait } from "../../shared/test-utils.js";
4
5
 
5
6
  describe("channel", () => {
6
7
  let $compile, $scope, element, unsubscribeSpy;
7
8
 
8
9
  beforeEach(() => {
9
- window.angular = new Angular();
10
+ dealoc(document.getElementById("app"));
11
+ let angular = new Angular();
10
12
  angular.module("myModule", ["ng"]);
11
13
  angular
12
14
  .bootstrap(document.getElementById("app"), ["myModule"])
@@ -2,6 +2,8 @@ import { getCacheData, setCacheData } from "../../shared/dom.js";
2
2
  import { hasAnimate, isObject, isString } from "../../shared/utils.js";
3
3
 
4
4
  /**
5
+ * @param {string} name
6
+ * @param {boolean|number} selector
5
7
  * @returns {() => import("../../interface.ts").Directive}
6
8
  */
7
9
  function classDirective(name, selector) {
@@ -17,6 +19,7 @@ function classDirective(name, selector) {
17
19
  link(scope, element, attr) {
18
20
  let classCounts = getCacheData(element, "$classCounts");
19
21
  let oldModulo = true;
22
+ /** @type {string|undefined} */
20
23
  let oldClassString;
21
24
 
22
25
  if (!classCounts) {
@@ -35,6 +38,9 @@ function classDirective(name, selector) {
35
38
  ngClassWatchAction(toClassString(val));
36
39
  });
37
40
 
41
+ /**
42
+ * @param {string} classString
43
+ */
38
44
  function addClasses(classString) {
39
45
  classString = digestClassCounts(split(classString), 1);
40
46
  if (hasAnimate(element)) {
@@ -48,6 +54,9 @@ function classDirective(name, selector) {
48
54
  }
49
55
  }
50
56
 
57
+ /**
58
+ * @param {string} classString
59
+ */
51
60
  function removeClasses(classString) {
52
61
  classString = digestClassCounts(split(classString), -1);
53
62
  if (hasAnimate(element)) {
@@ -61,6 +70,10 @@ function classDirective(name, selector) {
61
70
  }
62
71
  }
63
72
 
73
+ /**
74
+ * @param {string} oldClassString
75
+ * @param {string} newClassString
76
+ */
64
77
  function updateClasses(oldClassString, newClassString) {
65
78
  const oldClassArray = split(oldClassString);
66
79
  const newClassArray = split(newClassString);
@@ -111,6 +124,9 @@ function classDirective(name, selector) {
111
124
  oldModulo = newModulo;
112
125
  }
113
126
 
127
+ /**
128
+ * @param {string} newClassString
129
+ */
114
130
  function ngClassWatchAction(newClassString) {
115
131
  if (oldModulo === selector) {
116
132
  updateClasses(oldClassString, newClassString);
@@ -1,4 +1,5 @@
1
1
  import { Angular } from "../../loader.js";
2
+ import { dealoc } from "../../shared/dom.js";
2
3
  import { wait } from "../../shared/test-utils.js";
3
4
 
4
5
  describe("ngClass", () => {
@@ -8,6 +9,7 @@ describe("ngClass", () => {
8
9
  let injector;
9
10
 
10
11
  beforeEach(() => {
12
+ dealoc(document.getElementById("app"));
11
13
  window.angular = new Angular();
12
14
  window.angular.module("test", []);
13
15
  injector = window.angular.bootstrap(document.getElementById("app"), [
@@ -13,6 +13,7 @@ describe("event directives", () => {
13
13
  let app = document.getElementById("app");
14
14
 
15
15
  beforeEach(() => {
16
+ dealoc(document.getElementById("app"));
16
17
  angular = window.angular = new Angular();
17
18
  window.angular
18
19
  .module("myModule", ["ng"])
@@ -6,31 +6,28 @@ import { directiveNormalize } from "../../shared/utils.js";
6
6
  */
7
7
  export const ngEventDirectives = {};
8
8
 
9
- "click copy cut dblclick focus blur keydown keyup keypress load mouseover mousein mouseout mouseleave paste submit touchstart touchend touchmove"
9
+ "click copy cut dblclick focus blur keydown keyup keypress load mousedown mouseenter mouseleave mousemove mouseout mouseover mouseup paste submit touchstart touchend touchmove"
10
10
  .split(" ")
11
- .forEach(
12
- /** @param { string } eventName */
13
- (eventName) => {
14
- const directiveName = directiveNormalize(`ng-${eventName}`);
15
- ngEventDirectives[directiveName] = [
16
- "$parse",
17
- "$exceptionHandler",
18
- /**
19
- * @param {import("../../core/parse/interface.ts").ParseService} $parse
20
- * @param {import('../../core/exception-handler.js').ErrorHandler} $exceptionHandler
21
- * @returns
22
- */
23
- ($parse, $exceptionHandler) => {
24
- return createEventDirective(
25
- $parse,
26
- $exceptionHandler,
27
- directiveName,
28
- eventName,
29
- );
30
- },
31
- ];
32
- },
33
- );
11
+ .forEach((eventName) => {
12
+ const directiveName = directiveNormalize(`ng-${eventName}`);
13
+ ngEventDirectives[directiveName] = [
14
+ "$parse",
15
+ "$exceptionHandler",
16
+ /**
17
+ * @param {import("../../core/parse/interface.ts").ParseService} $parse
18
+ * @param {import('../../core/exception-handler.js').ErrorHandler} $exceptionHandler
19
+ * @returns
20
+ */
21
+ ($parse, $exceptionHandler) => {
22
+ return createEventDirective(
23
+ $parse,
24
+ $exceptionHandler,
25
+ directiveName,
26
+ eventName,
27
+ );
28
+ },
29
+ ];
30
+ });
34
31
 
35
32
  /**
36
33
  *
@@ -17,6 +17,7 @@ describe("form", () => {
17
17
  let injector;
18
18
 
19
19
  beforeEach(() => {
20
+ dealoc(document.getElementById("app"));
20
21
  window.angular = new Angular();
21
22
  window.angular
22
23
  .module("myModule", ["ng"])
@@ -1403,6 +1404,7 @@ describe("form", () => {
1403
1404
  let dummy = document.getElementById("app");
1404
1405
  doc = '<form name="myForm"></form>';
1405
1406
  dummy.append(doc);
1407
+ dealoc(document.getElementById("app"));
1406
1408
  let angular = new Angular();
1407
1409
  window.angular = new Angular();
1408
1410
  myModule = window.angular.module("myModule", []);
@@ -1,3 +1,5 @@
1
+ import { isObject } from "../../shared/utils.js";
2
+
1
3
  /**
2
4
  * @param {"get" | "delete" | "post" | "put"} method
3
5
  * @returns {import('../../interface.ts').DirectiveFactory}
@@ -18,8 +20,6 @@ export const ngPutDirective = defineDirective("put");
18
20
  * @typedef {"click" | "change" | "submit"} EventType
19
21
  */
20
22
 
21
- import { isObject } from "../../shared/utils";
22
-
23
23
  /**
24
24
  * Selects DOM event to listen for based on the element type.
25
25
  *
@@ -128,9 +128,9 @@ export function handleSwapResponse(html, swap, target, scope, $compile) {
128
128
  */
129
129
  export function createHttpDirective(method, attrName) {
130
130
  /**
131
- * @param {{ [key: string]: Function }} $http
131
+ * @param {import("interface.ts").HttpService} $http
132
132
  * @param {import("../../core/compile/compile.js").CompileFn} $compile
133
- * @param {import("../../services/log.js").LogService} $log
133
+ * @param {import("../../services/log/interface.ts").LogService} $log
134
134
  * @returns {import('../../interface.ts').Directive}
135
135
  */
136
136
  return function ($http, $compile, $log) {
@@ -1,5 +1,6 @@
1
1
  import {
2
2
  createElementFromHTML,
3
+ dealoc,
3
4
  getCacheData,
4
5
  setCacheData,
5
6
  } from "../../shared/dom.js";
@@ -17,6 +18,7 @@ describe("ngIf", () => {
17
18
  let angular;
18
19
 
19
20
  beforeEach(function () {
21
+ dealoc(document.getElementById("app"));
20
22
  angular = window.angular = new Angular();
21
23
  window.angular.module("test", []);
22
24
  injector = window.angular.bootstrap(document.getElementById("app"), [
@@ -18,6 +18,7 @@ describe("ngInclude", () => {
18
18
 
19
19
  beforeEach(() => {
20
20
  errorLog = [];
21
+ dealoc(document.getElementById("app"));
21
22
  delete window.angular;
22
23
  angular = window.angular = new Angular();
23
24
  module = angular
@@ -14,6 +14,7 @@ describe("input", () => {
14
14
  let error = [];
15
15
 
16
16
  beforeEach(() => {
17
+ dealoc(document.getElementById("app"));
17
18
  error = [];
18
19
  window.angular = new Angular();
19
20
  window.angular
@@ -17,6 +17,7 @@ describe("ngModel", () => {
17
17
 
18
18
  beforeEach(() => {
19
19
  errors = [];
20
+ dealoc(document.getElementById("app"));
20
21
  window.angular = new Angular();
21
22
  window.angular
22
23
  .module("myModule", ["ng"])
@@ -1554,6 +1555,7 @@ describe("ngModel", () => {
1554
1555
  let module;
1555
1556
 
1556
1557
  beforeEach(() => {
1558
+ dealoc(document.getElementById("app"));
1557
1559
  window.angular = new Angular();
1558
1560
  module = window.angular
1559
1561
  .module("myModule", [])
@@ -1900,6 +1902,7 @@ describe("data-change", () => {
1900
1902
  let el = document.getElementById("app");
1901
1903
 
1902
1904
  beforeEach(() => {
1905
+ dealoc(document.getElementById("app"));
1903
1906
  window.angular = new Angular();
1904
1907
  });
1905
1908
 
@@ -33,6 +33,7 @@ describe("ngModelOptions", () => {
33
33
  let injector;
34
34
 
35
35
  beforeEach(() => {
36
+ dealoc(document.getElementById("app"));
36
37
  window.angular = new Angular();
37
38
  window.angular
38
39
  .module("myModule", ["ng"])
@@ -1001,6 +1002,7 @@ describe("ngModelOptions", () => {
1001
1002
  let inputElm, module, $rootScope, angular;
1002
1003
 
1003
1004
  beforeEach(() => {
1005
+ dealoc(document.getElementById("app"));
1004
1006
  window.angular = angular = new Angular();
1005
1007
  module = angular.module("myModule", []).directive("foo", () => ({
1006
1008
  replace: true,
@@ -47,7 +47,6 @@
47
47
  <script type="module">
48
48
  import {
49
49
  fluentSelect,
50
- fluentOption,
51
50
  fluentTab,
52
51
  fluentTabPanel,
53
52
  fluentTabs,
@@ -1,11 +1,12 @@
1
1
  import { Angular } from "../../loader.js";
2
- import { createElementFromHTML } from "../../shared/dom.js";
2
+ import { createElementFromHTML, dealoc } from "../../shared/dom.js";
3
3
  import { wait } from "../../shared/test-utils.js";
4
4
 
5
5
  describe("observe", () => {
6
6
  let $compile, $scope, $rootScope, element, observerSpy;
7
7
 
8
8
  beforeEach(() => {
9
+ dealoc(document.getElementById("app"));
9
10
  window.angular = new Angular();
10
11
  angular.module("myModule", ["ng"]);
11
12
  angular
@@ -11,7 +11,7 @@
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/pubsub/pubsub.spec.js"></script>
14
+ <script type="module" src="/src/directive/on/on.spec.js"></script>
15
15
  </head>
16
16
  <body>
17
17
  <div id="app"></div>
@@ -1,6 +1,6 @@
1
- import { Angular } from "../loader.js";
2
- import { browserTrigger, wait } from "../shared/test-utils.js";
3
- import { createInjector } from "./di/injector.js";
1
+ import { Angular } from "../../loader.js";
2
+ import { browserTrigger, wait } from "../../shared/test-utils.js";
3
+ import { createInjector } from "../../core/di/injector.js";
4
4
 
5
5
  describe("ngOn* event binding", () => {
6
6
  let $rootScope, module, injector, $compile;
@@ -19,6 +19,8 @@ describe("ngOn* event binding", () => {
19
19
  const element = $compile('<span ng-on-foo="name = name + 3"></span>')(
20
20
  $rootScope,
21
21
  );
22
+ expect($rootScope.name).toBe("Misko");
23
+
22
24
  browserTrigger(element, "foo");
23
25
  expect($rootScope.name).toBe("Misko3");
24
26
  });
@@ -0,0 +1,11 @@
1
+ import { test, expect } from "@playwright/test";
2
+
3
+ const TEST_URL = "src/directive/on/on.html";
4
+
5
+ test("unit tests contain no errors", async ({ page }) => {
6
+ await page.goto(TEST_URL);
7
+ await page.content();
8
+ await expect(page.locator(".jasmine-overall-result")).toHaveText(
9
+ /0 failures/,
10
+ );
11
+ });
@@ -160,6 +160,7 @@ describe("ngOptions", () => {
160
160
  errors = [];
161
161
  element = document.getElementById("app");
162
162
  element.innerHTML = "test";
163
+ dealoc(document.getElementById("app"));
163
164
  window.angular = new Angular();
164
165
  window.angular
165
166
  .module("myModule", ["ng"])
@@ -1,7 +1,7 @@
1
1
  scriptDirective.$inject = ["$templateCache"];
2
2
 
3
3
  /**
4
- * @param {import('../../core/cache/cache-factory').TemplateCache} $templateCache
4
+ * @param {import('../../services/template-cache/interface.ts').TemplateCache} $templateCache
5
5
  * @returns {import('../../interface.ts').Directive}
6
6
  */
7
7
  export function scriptDirective($templateCache) {
@@ -57,6 +57,7 @@ describe("select", () => {
57
57
  }
58
58
 
59
59
  beforeEach(() => {
60
+ dealoc(document.getElementById("app"));
60
61
  errors = [];
61
62
  window.angular = new Angular();
62
63
  window.angular
@@ -1,7 +1,7 @@
1
1
  ngSetterDirective.$inject = ["$parse", "$log"];
2
2
  /**
3
3
  * @param {import('../../core/parse/interface.ts').ParseService} $parse
4
- * @param {import('../../services/log.js').LogService} $log
4
+ * @param {import('../../services/log/interface.ts').LogService} $log
5
5
  * @returns {import('../../interface.ts').Directive}
6
6
  */
7
7
  export function ngSetterDirective($parse, $log) {
@@ -1,10 +1,12 @@
1
1
  import { Angular } from "../../loader.js";
2
+ import { dealoc } from "../../shared/dom.js";
2
3
  import { wait } from "../../shared/test-utils.js";
3
4
 
4
5
  describe("setter", () => {
5
6
  let $compile, $rootScope, $parse, observerSpy, $log;
6
7
 
7
8
  beforeEach(() => {
9
+ dealoc(document.getElementById("app"));
8
10
  window.angular = new Angular();
9
11
  angular.module("myModule", []);
10
12
  angular
@@ -8,6 +8,7 @@ describe("ngSwitch", () => {
8
8
  let element;
9
9
 
10
10
  beforeEach(() => {
11
+ dealoc(document.getElementById("app"));
11
12
  window.angular = new Angular();
12
13
  window.angular.module("test", []);
13
14
  let injector = window.angular.bootstrap(
@@ -9,6 +9,9 @@
9
9
  * angular.$injectTokens.$animate,
10
10
  * angular.$injectTokens.$templateRequest,
11
11
  * ];
12
+ *
13
+ * function myDirective($animate, $templateRequest) { ... }
14
+ *
12
15
  * ```
13
16
  * @type Readonly<Record<string, string>>
14
17
  */
package/src/interface.ts CHANGED
@@ -1,5 +1,11 @@
1
1
  import { Attributes } from "./core/compile/attributes.js";
2
2
  import { Scope } from "./core/scope/scope.js";
3
+ export * from "./services/http/interface.ts";
4
+ export * from "./services/log/interface.ts";
5
+ export * from "./services/log/log.js";
6
+ export * from "./services/pubsub/pubsub.js";
7
+ export * from "./services/template-cache/interface.ts";
8
+ export * from "./services/template-cache/template-cache.js";
3
9
 
4
10
  /**
5
11
  * A JavaScript expression represented as a string, typically used in interpolation bindings.
@@ -12,6 +18,10 @@ import { Scope } from "./core/scope/scope.js";
12
18
  */
13
19
  export type Expression = string;
14
20
 
21
+ export type ExpandoStore = {
22
+ data: { [key: string]: any };
23
+ };
24
+
15
25
  /**
16
26
  * A dependency-annotated factory array used by AngularTS DI system.
17
27
  *
package/src/loader.js CHANGED
@@ -12,12 +12,12 @@ import {
12
12
  getScope,
13
13
  setCacheData,
14
14
  } from "./shared/dom.js";
15
+ import { Cache } from "./shared/cache.js";
15
16
  import { annotate, createInjector } from "./core/di/injector.js";
16
17
  import { NgModule } from "./core/di/ng-module.js";
17
- import { Cache } from "./core/cache/cache.js";
18
18
  import { registerNgModule } from "./public.js";
19
19
  import { unnestR } from "./shared/common.js";
20
- import { EventBus } from "./core/pubsub/pubsub.js";
20
+ import { EventBus } from "./services/pubsub/pubsub.js";
21
21
  import { $injectTokens } from "./injection-tokens.js";
22
22
 
23
23
  const ngMinErr = minErr("ng");
@@ -35,12 +35,9 @@ const modules = {};
35
35
 
36
36
  export class Angular {
37
37
  constructor() {
38
- Cache.clear(); // a ensure new instance of angular gets a clean cache
39
-
40
- /** @type {Map<number, import("./core/cache/cache.js").ExpandoStore>} */
41
38
  this.$cache = Cache;
42
39
 
43
- /** @type {import('./core/pubsub/pubsub.js').PubSub} */
40
+ /** @type {import('./services/pubsub/pubsub.js').PubSub} */
44
41
  this.$eventBus = EventBus;
45
42
 
46
43
  /**
package/src/public.js CHANGED
@@ -57,7 +57,7 @@ import {
57
57
  AnimateAsyncRunFactoryProvider,
58
58
  AnimateRunnerFactoryProvider,
59
59
  } from "./animations/animate-runner.js";
60
- import { TemplateCacheProvider } from "./core/cache/cache-factory.js";
60
+ import { TemplateCacheProvider } from "./services/template-cache/template-cache.js";
61
61
  import { ControllerProvider } from "./core/controller/controller.js";
62
62
  import { ExceptionHandlerProvider } from "./core/exception-handler.js";
63
63
  import { FilterProvider } from "./core/filter/filter.js";
@@ -68,7 +68,7 @@ import {
68
68
  } from "./services/http/http.js";
69
69
  import { HttpBackendProvider } from "./services/http-backend/http-backend.js";
70
70
  import { LocationProvider } from "./core/location/location.js";
71
- import { LogProvider } from "./services/log.js";
71
+ import { LogProvider } from "./services/log/log.js";
72
72
  import { ParseProvider } from "./core/parse/parse.js";
73
73
  import { RootScopeProvider } from "./core/scope/scope.js";
74
74
  import { SceProvider, SceDelegateProvider } from "./core/sce/sce.js";
@@ -127,7 +127,7 @@ import {
127
127
  } from "./router/directives/view-directive.js";
128
128
  import { ngChannelDirective } from "./directive/channel/channel.js";
129
129
  import { ngSetterDirective } from "./directive/setter/setter.js";
130
- import { PubSubProvider } from "./core/pubsub/pubsub.js";
130
+ import { PubSubProvider } from "./services/pubsub/pubsub.js";
131
131
  import {
132
132
  ngDeleteDirective,
133
133
  ngGetDirective,
@@ -1,5 +1,5 @@
1
1
  import { Angular } from "../../loader.js";
2
- import { createElementFromHTML } from "../../shared/dom.js";
2
+ import { createElementFromHTML, dealoc } from "../../shared/dom.js";
3
3
  import { browserTrigger, wait } from "../../shared/test-utils.js";
4
4
 
5
5
  describe("ngStateRef", () => {
@@ -18,6 +18,7 @@ describe("ngStateRef", () => {
18
18
  $urlService;
19
19
 
20
20
  beforeEach(() => {
21
+ dealoc(document.getElementById("app"));
21
22
  app.innerHTML = "";
22
23
  window.location.hash = "";
23
24
  window.angular = new Angular();
@@ -663,6 +664,7 @@ describe("ngSrefActive", () => {
663
664
  _stateProvider;
664
665
 
665
666
  beforeEach(() => {
667
+ dealoc(document.getElementById("app"));
666
668
  window.location.hash = "";
667
669
  window.angular = new Angular();
668
670
  let module = window.angular.module("defaultModule", []);
@@ -1,7 +1,13 @@
1
1
  import { DefType, Param } from "./param.js";
2
2
 
3
3
  export class ParamFactory {
4
+ /**
5
+ * @param {import("../url/url-config.js").UrlConfigProvider} urlServiceConfig
6
+ */
4
7
  constructor(urlServiceConfig) {
8
+ /**
9
+ * @type {import("../url/url-config.js").UrlConfigProvider}
10
+ */
5
11
  this.urlServiceConfig = urlServiceConfig;
6
12
  }
7
13
 
@@ -8,13 +8,15 @@ const isShorthand = (cfg) =>
8
8
  Object.prototype.hasOwnProperty.bind(cfg || {}),
9
9
  ).length === 0;
10
10
 
11
- let DefType;
12
- (function (DefType) {
13
- DefType[(DefType["PATH"] = 0)] = "PATH";
14
- DefType[(DefType["SEARCH"] = 1)] = "SEARCH";
15
- DefType[(DefType["CONFIG"] = 2)] = "CONFIG";
16
- })(DefType || (DefType = {}));
17
- export { DefType };
11
+ /**
12
+ * @private
13
+ * @enum {number}
14
+ */
15
+ export const DefType = {
16
+ PATH: 0,
17
+ SEARCH: 1,
18
+ CONFIG: 2,
19
+ };
18
20
 
19
21
  function getParamDeclaration(paramName, location, state) {
20
22
  const noReloadOnSearch =
@@ -27,6 +29,7 @@ function getParamDeclaration(paramName, location, state) {
27
29
  );
28
30
  return Object.assign(defaultConfig, paramConfig);
29
31
  }
32
+
30
33
  function unwrapShorthand(cfg) {
31
34
  cfg = isShorthand(cfg) ? { value: cfg } : cfg;
32
35
  getStaticDefaultValue["__cacheable"] = true;
@@ -36,6 +39,7 @@ function unwrapShorthand(cfg) {
36
39
  const $$fn = isInjectable(cfg.value) ? cfg.value : getStaticDefaultValue;
37
40
  return Object.assign(cfg, { $$fn });
38
41
  }
42
+
39
43
  function getType(cfg, urlType, location, id, paramTypes) {
40
44
  if (cfg.type && urlType && urlType.name !== "string")
41
45
  throw new Error(`Param '${id}' has two type configurations.`);
@@ -60,6 +64,7 @@ function getType(cfg, urlType, location, id, paramTypes) {
60
64
  }
61
65
  return cfg.type instanceof ParamType ? cfg.type : paramTypes.type(cfg.type);
62
66
  }
67
+
63
68
  /** returns false, true, or the squash value to indicate the "default parameter url squash policy". */
64
69
  function getSquashPolicy(config, isOptional, defaultPolicy) {
65
70
  const squash = config.squash;
@@ -70,6 +75,7 @@ function getSquashPolicy(config, isOptional, defaultPolicy) {
70
75
  `Invalid squash policy: '${squash}'. Valid policies: false, true, or arbitrary string`,
71
76
  );
72
77
  }
78
+
73
79
  function getReplace(config, arrayMode, isOptional, squash) {
74
80
  const defaultPolicy = [
75
81
  { from: "", to: isOptional || arrayMode ? undefined : "" },
@@ -83,7 +89,16 @@ function getReplace(config, arrayMode, isOptional, squash) {
83
89
  (item) => configuredKeys.indexOf(item.from) === -1,
84
90
  ).concat(replace);
85
91
  }
92
+
86
93
  export class Param {
94
+ /**
95
+ *
96
+ * @param {*} id
97
+ * @param {*} type
98
+ * @param {DefType} location
99
+ * @param {import("../url/url-config.js").UrlConfigProvider} urlConfig
100
+ * @param {*} state
101
+ */
87
102
  constructor(id, type, location, urlConfig, state) {
88
103
  const config = getParamDeclaration(id, location, state);
89
104
  type = getType(config, type, location, id, urlConfig.paramTypes);