@angular-wave/angular.ts 0.9.2 → 0.9.4

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 (196) hide show
  1. package/@types/angular.d.ts +4 -19
  2. package/@types/animations/animate.d.ts +2 -2
  3. package/@types/animations/animation.d.ts +1 -1
  4. package/@types/core/compile/attributes.d.ts +1 -1
  5. package/@types/core/compile/compile.d.ts +2 -2
  6. package/@types/core/controller/controller.d.ts +1 -1
  7. package/@types/core/controller/interface.d.ts +6 -0
  8. package/@types/core/di/ng-module.d.ts +27 -26
  9. package/@types/core/filter/filter.d.ts +5 -5
  10. package/@types/core/interpolate/interface.d.ts +13 -0
  11. package/@types/core/interpolate/interpolate.d.ts +1 -13
  12. package/@types/core/scope/scope.d.ts +4 -1
  13. package/@types/directive/http/http.d.ts +16 -16
  14. package/@types/directive/http/interface.d.ts +27 -0
  15. package/@types/directive/include/include.d.ts +4 -4
  16. package/@types/directive/inject/inject.d.ts +12 -0
  17. package/@types/directive/model/model.d.ts +1 -1
  18. package/@types/directive/script/script.d.ts +2 -2
  19. package/@types/directive/setter/setter.d.ts +4 -4
  20. package/@types/filters/filter.d.ts +2 -2
  21. package/@types/filters/filters.d.ts +2 -2
  22. package/@types/filters/interface.d.ts +8 -0
  23. package/@types/filters/limit-to.d.ts +2 -2
  24. package/@types/filters/order-by.d.ts +2 -2
  25. package/@types/index.d.ts +84 -1
  26. package/@types/interface.d.ts +105 -82
  27. package/@types/router/state/interface.d.ts +8 -8
  28. package/@types/router/state-filters.d.ts +4 -4
  29. package/@types/router/template-factory.d.ts +6 -6
  30. package/@types/router/transition/hook-builder.d.ts +5 -2
  31. package/@types/router/transition/hook-registry.d.ts +11 -2
  32. package/@types/router/transition/transition-service.d.ts +6 -2
  33. package/@types/router/transition/transition.d.ts +2 -2
  34. package/@types/router/view/view.d.ts +1 -8
  35. package/@types/router/view-scroll.d.ts +4 -2
  36. package/@types/services/{anchor-scroll.d.ts → anchor-scroll/anchor-scroll.d.ts} +2 -2
  37. package/@types/services/exception/exception-handler.d.ts +2 -2
  38. package/@types/services/exception/interface.d.ts +1 -1
  39. package/@types/services/http/http.d.ts +40 -2
  40. package/@types/services/http/interface.d.ts +11 -0
  41. package/@types/services/location/location.d.ts +1 -4
  42. package/@types/services/sce/sce.d.ts +3 -4
  43. package/@types/services/template-cache/template-cache.d.ts +4 -4
  44. package/@types/services/template-request/interface.d.ts +22 -0
  45. package/@types/services/{template-request.d.ts → template-request/template-request.d.ts} +4 -7
  46. package/@types/shared/common.d.ts +8 -69
  47. package/@types/shared/hof.d.ts +7 -7
  48. package/dist/angular-ts.esm.js +509 -570
  49. package/dist/angular-ts.umd.js +509 -570
  50. package/dist/angular-ts.umd.min.js +1 -1
  51. package/{src/filters → docs/content/docs/filter}/filter.md +18 -9
  52. package/{src/filters → docs/content/docs/filter}/json.md +6 -3
  53. package/docs/content/docs/filter/limit-to.md +30 -0
  54. package/docs/content/docs/filter/order-by.md +123 -0
  55. package/docs/content/docs/provider/sceProvider.md +194 -0
  56. package/docs/content/docs/provider/templateRequestProvider.md +5 -0
  57. package/docs/content/docs/service/compile.md +5 -0
  58. package/docs/content/docs/service/controller.md +5 -0
  59. package/docs/content/docs/service/http.md +161 -0
  60. package/docs/content/docs/service/interpolation.md +5 -0
  61. package/docs/content/docs/service/log.md +1 -1
  62. package/docs/content/docs/service/parse.md +5 -0
  63. package/docs/content/docs/service/rootElement.md +5 -0
  64. package/docs/content/docs/service/rootScope.md +5 -0
  65. package/docs/content/docs/service/sce.md +194 -0
  66. package/docs/content/docs/service/templateRequest.md +5 -0
  67. package/docs/content/docs/values/_index.md +4 -0
  68. package/docs/content/docs/values/document.md +29 -0
  69. package/docs/content/docs/values/window.md +29 -0
  70. package/docs/layouts/shortcodes/version.html +1 -1
  71. package/docs/static/examples/document/document.html +3 -0
  72. package/docs/static/examples/i18n/i18n.html +77 -0
  73. package/docs/static/examples/window/window.html +4 -0
  74. package/docs/static/typedoc/assets/hierarchy.js +1 -1
  75. package/docs/static/typedoc/assets/highlight.css +0 -49
  76. package/docs/static/typedoc/assets/navigation.js +1 -1
  77. package/docs/static/typedoc/assets/search.js +1 -1
  78. package/docs/static/typedoc/classes/PubSubProvider.html +3 -2
  79. package/docs/static/typedoc/classes/TemplateCacheProvider.html +1 -1
  80. package/docs/static/typedoc/hierarchy.html +1 -1
  81. package/docs/static/typedoc/index.html +1 -1
  82. package/docs/static/typedoc/interfaces/HttpProviderDefaults.html +1 -1
  83. package/docs/static/typedoc/interfaces/RequestConfig.html +1 -1
  84. package/docs/static/typedoc/interfaces/RequestShortcutConfig.html +1 -1
  85. package/docs/static/typedoc/interfaces/ServiceProvider.html +3 -3
  86. package/docs/static/typedoc/types/HttpParamSerializer.html +2 -0
  87. package/docs/static/typedoc/types/{Expression.html → HttpParams.html} +1 -5
  88. package/legacy.d.ts +0 -921
  89. package/package.json +1 -1
  90. package/src/angular.js +2 -9
  91. package/src/animations/animate.js +1 -1
  92. package/src/animations/animation.js +7 -7
  93. package/src/core/compile/compile.js +3 -2
  94. package/src/core/controller/controller.js +10 -6
  95. package/src/core/controller/interface.ts +6 -0
  96. package/src/core/di/injector.js +1 -1
  97. package/src/core/di/internal-injector.js +2 -0
  98. package/src/core/di/ng-module.js +16 -13
  99. package/src/core/filter/filter.js +3 -3
  100. package/src/core/interpolate/interface.ts +14 -0
  101. package/src/core/interpolate/interpolate.js +7 -5
  102. package/src/core/scope/scope.js +4 -1
  103. package/src/directive/http/delete.spec.js +5 -8
  104. package/src/directive/http/http.js +16 -16
  105. package/src/directive/http/interface.ts +36 -0
  106. package/src/directive/http/put.spec.js +5 -8
  107. package/src/directive/include/include.js +2 -2
  108. package/src/{services/http-backend/http-backend.html → directive/inject/inject.html} +1 -4
  109. package/src/directive/inject/inject.js +35 -0
  110. package/src/directive/inject/inject.spec.js +108 -0
  111. package/src/{services/http-backend/http-backend.test.js → directive/inject/inject.test.js} +1 -1
  112. package/src/directive/script/script.js +1 -1
  113. package/src/directive/setter/setter.js +2 -2
  114. package/src/filters/filter.js +1 -1
  115. package/src/filters/filters.js +1 -1
  116. package/src/filters/interface.ts +9 -0
  117. package/src/filters/limit-to.js +1 -1
  118. package/src/filters/order-by.js +1 -1
  119. package/src/index.ts +96 -0
  120. package/src/injection-tokens.js +4 -1
  121. package/src/interface.ts +102 -93
  122. package/src/ng.js +6 -4
  123. package/src/ng.spec.js +12 -0
  124. package/src/router/directives/state-directives.js +1 -1
  125. package/src/router/directives/view-directive.spec.js +19 -35
  126. package/src/router/state/interface.ts +8 -8
  127. package/src/router/state/state-builder.js +4 -4
  128. package/src/router/state/state-registry.js +7 -2
  129. package/src/router/state/state-service.js +2 -14
  130. package/src/router/state-filters.js +2 -2
  131. package/src/router/template-factory.js +3 -3
  132. package/src/router/template-factory.spec.js +10 -19
  133. package/src/router/transition/hook-builder.js +5 -1
  134. package/src/router/transition/hook-registry.js +12 -3
  135. package/src/router/transition/transition-service.js +4 -9
  136. package/src/router/transition/transition.js +3 -2
  137. package/src/router/url/url-service.js +2 -2
  138. package/src/router/view/view.js +3 -15
  139. package/src/router/view-scroll.js +2 -2
  140. package/src/services/{anchor-scroll.js → anchor-scroll/anchor-scroll.js} +4 -4
  141. package/src/services/exception/exception-handler.js +1 -1
  142. package/src/services/exception/interface.ts +1 -1
  143. package/src/services/http/http.js +200 -13
  144. package/src/services/http/http.spec.js +388 -9
  145. package/src/services/http/interface.ts +13 -0
  146. package/src/services/location/location.js +1 -1
  147. package/src/services/pubsub/pubsub.js +0 -1
  148. package/src/services/sce/sce.js +18 -13
  149. package/src/services/template-cache/template-cache.js +2 -2
  150. package/src/services/template-request/interface.ts +23 -0
  151. package/src/services/{template-request.js → template-request/template-request.js} +6 -6
  152. package/src/shared/common.js +7 -80
  153. package/src/shared/hof.js +23 -17
  154. package/typedoc.json +1 -1
  155. package/@types/services/cookie-reader.d.ts +0 -4
  156. package/@types/services/http-backend/http-backend.d.ts +0 -58
  157. package/@types/services/template-cache/interface.d.ts +0 -10
  158. package/docs/static/typedoc/interfaces/ChangesObject.html +0 -6
  159. package/docs/static/typedoc/interfaces/ComponentOptions.html +0 -16
  160. package/docs/static/typedoc/interfaces/Controller.html +0 -12
  161. package/docs/static/typedoc/interfaces/Directive.html +0 -37
  162. package/docs/static/typedoc/interfaces/DirectivePrePost.html +0 -4
  163. package/docs/static/typedoc/interfaces/NgModelController.html +0 -30
  164. package/docs/static/typedoc/interfaces/NgModelOptions.html +0 -16
  165. package/docs/static/typedoc/interfaces/Provider.html +0 -34
  166. package/docs/static/typedoc/interfaces/TemplateCache.html +0 -7
  167. package/docs/static/typedoc/interfaces/TranscludeFunctionObject.html +0 -8
  168. package/docs/static/typedoc/types/AnnotatedDirectiveFactory.html +0 -1
  169. package/docs/static/typedoc/types/AnnotatedFactory.html +0 -8
  170. package/docs/static/typedoc/types/CloneAttachFunction.html +0 -2
  171. package/docs/static/typedoc/types/ControllerConstructor.html +0 -2
  172. package/docs/static/typedoc/types/DirectiveCompileFn.html +0 -2
  173. package/docs/static/typedoc/types/DirectiveController.html +0 -2
  174. package/docs/static/typedoc/types/DirectiveFactory.html +0 -1
  175. package/docs/static/typedoc/types/DirectiveFactoryFn.html +0 -1
  176. package/docs/static/typedoc/types/DirectiveLinkFn.html +0 -2
  177. package/docs/static/typedoc/types/ExpandoStore.html +0 -2
  178. package/docs/static/typedoc/types/FilterFactory.html +0 -2
  179. package/docs/static/typedoc/types/FilterFn.html +0 -2
  180. package/docs/static/typedoc/types/Injectable.html +0 -4
  181. package/docs/static/typedoc/types/InjectableClass.html +0 -1
  182. package/docs/static/typedoc/types/InjectableFactory.html +0 -1
  183. package/docs/static/typedoc/types/OnChangesObject.html +0 -2
  184. package/docs/static/typedoc/types/SwapModeType.html +0 -2
  185. package/docs/static/typedoc/types/TController.html +0 -2
  186. package/docs/static/typedoc/variables/SwapMode.html +0 -11
  187. package/src/filters/limit-to.md +0 -19
  188. package/src/filters/order-by.md +0 -83
  189. package/src/router/state/README.md +0 -21
  190. package/src/services/cookie-reader.js +0 -48
  191. package/src/services/http/http.md +0 -413
  192. package/src/services/http-backend/http-backend.js +0 -158
  193. package/src/services/http-backend/http-backend.spec.js +0 -389
  194. package/src/services/sce/sce.md +0 -300
  195. package/src/services/template-cache/interface.ts +0 -10
  196. /package/src/services/{anchor-scroll.html → anchor-scroll/anchor-scroll.html} +0 -0
@@ -0,0 +1,108 @@
1
+ import { Angular } from "../../angular.js";
2
+ import { dealoc } from "../../shared/dom.js";
3
+ import { wait } from "../../shared/test-utils.js";
4
+
5
+ describe("ngInject", () => {
6
+ let $compile, $rootScope, el, $test, $log;
7
+
8
+ beforeEach(() => {
9
+ el = document.getElementById("app");
10
+ dealoc(el);
11
+ el.innerHTML = "";
12
+ let angular = new Angular();
13
+ angular
14
+ .module("default", [])
15
+ .value("$test", { a: 1 })
16
+ .value("$a", { x: 1 })
17
+ .value("$b", { y: 2 })
18
+ .service(
19
+ "userService",
20
+ class {
21
+ constructor() {
22
+ this.name = "Bob";
23
+ }
24
+ },
25
+ )
26
+ .factory("userFactory", () => {
27
+ return {
28
+ name: "Fred",
29
+ };
30
+ });
31
+ angular
32
+ .bootstrap(el, ["default"])
33
+ .invoke((_$compile_, _$rootScope_, _$test_, _$log_) => {
34
+ $compile = _$compile_;
35
+ $rootScope = _$rootScope_;
36
+ $test = _$test_;
37
+ $log = _$log_;
38
+ });
39
+ });
40
+
41
+ it("should make $injectable available to scope", async () => {
42
+ expect($test.a).toEqual(1);
43
+ el.innerHTML = `<div ng-inject="$test"> {{ $test.a }} </div>`;
44
+ $compile(el)($rootScope);
45
+ await wait();
46
+ expect($rootScope.$test).toEqual($test);
47
+ expect(el.innerText).toEqual("1");
48
+ });
49
+
50
+ it("should evaluate expressions referencing injected", async () => {
51
+ expect($test.a).toEqual(1);
52
+ el.innerHTML = `<div ng-inject="$test"> {{ $test.a + 1}} </div>`;
53
+ $compile(el)($rootScope);
54
+ await wait();
55
+ expect($rootScope.$test).toEqual($test);
56
+ expect(el.innerText).toEqual("2");
57
+ });
58
+
59
+ it("should evaluate expressions for multiple references", async () => {
60
+ expect($test.a).toEqual(1);
61
+ el.innerHTML = `<div ng-inject="$test;$a;$b"> {{ $test.a + $a.x + $b.y}} </div>`;
62
+ $compile(el)($rootScope);
63
+ await wait();
64
+ expect($rootScope.$test).toEqual($test);
65
+ expect(el.innerText).toEqual("4");
66
+ });
67
+
68
+ it("should warn and skip missing injectables", async () => {
69
+ const warnSpy = spyOn($log, "warn");
70
+ el.innerHTML = `<div ng-inject="$notExisting"> {{ $notExisting }} </div>`;
71
+ $compile(el)($rootScope);
72
+ await wait();
73
+
74
+ expect(warnSpy).toHaveBeenCalledWith(
75
+ "Injectable $notExisting not found in $injector",
76
+ );
77
+ expect($rootScope.$notExisting).toBeUndefined();
78
+ });
79
+
80
+ it("should not modify scope if ng-inject is empty", async () => {
81
+ el.innerHTML = `<div ng-inject=""> {{ 123 }} </div>`;
82
+ $compile(el)($rootScope);
83
+ await wait();
84
+ expect($rootScope.$test).toBeUndefined();
85
+ expect(el.innerText.trim()).toBe("123");
86
+ });
87
+
88
+ it("should ignore non-$ identifiers", async () => {
89
+ el.innerHTML = `<div ng-inject="someVar = 5"> {{ someVar }} </div>`;
90
+ $compile(el)($rootScope);
91
+ await wait();
92
+ expect($rootScope.someVar).toBe(5);
93
+ });
94
+
95
+ it("should inject identifiers ending in *Service", async () => {
96
+ el.innerHTML = `<div ng-inject="userService"> {{ userService.name }} </div>`;
97
+ $compile(el)($rootScope);
98
+ await wait();
99
+ expect(el.innerText.trim()).toBe("Bob");
100
+ });
101
+
102
+ it("should inject identifiers ending in *Factory", async () => {
103
+ el.innerHTML = `<div ng-inject="userFactory"> {{ userFactory.name }} </div>`;
104
+ $compile(el)($rootScope);
105
+ await wait();
106
+ expect(el.innerText.trim()).toBe("Fred");
107
+ });
108
+ });
@@ -1,6 +1,6 @@
1
1
  import { test, expect } from "@playwright/test";
2
2
 
3
- const TEST_URL = "src/services/http-backend/http-backend.html";
3
+ const TEST_URL = "src/directive/inject/inject.html";
4
4
 
5
5
  test("unit tests contain no errors", async ({ page }) => {
6
6
  await page.goto(TEST_URL);
@@ -1,7 +1,7 @@
1
1
  scriptDirective.$inject = ["$templateCache"];
2
2
 
3
3
  /**
4
- * @param {import('../../services/template-cache/interface.ts').TemplateCache} $templateCache
4
+ * @param {ng.TemplateCacheService} $templateCache
5
5
  * @returns {import('../../interface.ts').Directive}
6
6
  */
7
7
  export function scriptDirective($templateCache) {
@@ -3,8 +3,8 @@ import { $injectTokens as $t } from "../../injection-tokens.js";
3
3
  ngSetterDirective.$inject = [$t.$parse, $t.$log];
4
4
 
5
5
  /**
6
- * @param {import('../../core/parse/interface.ts').ParseService} $parse
7
- * @param {import('../../services/log/interface.ts').LogService} $log
6
+ * @param {ng.ParseService} $parse
7
+ * @param {ng.LogService} $log
8
8
  * @returns {import('interface.ts').Directive}
9
9
  */
10
10
  export function ngSetterDirective($parse, $log) {
@@ -9,7 +9,7 @@ import {
9
9
  } from "../shared/utils.js";
10
10
 
11
11
  /**
12
- * @returns {import('../interface.ts').FilterFn}
12
+ * @returns {ng.FilterFn}
13
13
  */
14
14
  export function filterFilter() {
15
15
  /**
@@ -227,7 +227,7 @@ export function formatNumber(
227
227
  }
228
228
 
229
229
  /**
230
- * @returns {import('../interface.ts').FilterFn}
230
+ * @returns {ng.FilterFn}
231
231
  */
232
232
  export function jsonFilter() {
233
233
  return function (object, spacing) {
@@ -0,0 +1,9 @@
1
+ /**
2
+ * A filter function takes an input and optional arguments, and returns a transformed value.
3
+ */
4
+ export type FilterFn = (input: any, ...args: any[]) => any;
5
+
6
+ /**
7
+ * A filter factory function that returns a FilterFn.
8
+ */
9
+ export type FilterFactory = (...args: any[]) => FilterFn;
@@ -7,7 +7,7 @@ import {
7
7
  } from "../shared/utils.js";
8
8
 
9
9
  /**
10
- * @returns {import('../interface.ts').FilterFn}
10
+ * @returns {ng.FilterFn}
11
11
  */
12
12
  export function limitToFilter() {
13
13
  /**
@@ -11,7 +11,7 @@ import { $injectTokens } from "../injection-tokens.js";
11
11
  orderByFilter.$inject = [$injectTokens.$parse];
12
12
 
13
13
  /**
14
- * @returns {import('../interface.ts').FilterFn}
14
+ * @returns {ng.FilterFn}
15
15
  */
16
16
  export function orderByFilter($parse) {
17
17
  return function (array, sortPredicate, reverseOrder, compareFn) {
package/src/index.ts ADDED
@@ -0,0 +1,96 @@
1
+ import {
2
+ AnchorScrollProvider,
3
+ AnchorScrollService as TAnchorScrollService,
4
+ } from "./services/anchor-scroll/anchor-scroll.js";
5
+ import { ControllerService as TControllerService } from "./core/controller/interface.ts";
6
+ import { ErrorHandler } from "./services/exception/interface.ts";
7
+ export * from "./services/http/interface.ts";
8
+ export * from "./services/log/interface.ts";
9
+ export * from "./services/log/log.js";
10
+ export * from "./services/location/interface.ts";
11
+ export * from "./services/location/location.js";
12
+ export * from "./services/pubsub/pubsub.js";
13
+ export * from "./services/template-cache/template-cache.js";
14
+ export * from "./index.js";
15
+
16
+ import { Angular } from "./angular.js";
17
+ import { Attributes } from "./core/compile/attributes.js";
18
+ import { Scope } from "./core/scope/scope.js";
19
+ import { NgModule } from "./core/di/ng-module.js";
20
+ import { PubSubProvider, PubSub } from "./services/pubsub/pubsub.js";
21
+ import type { ErrorHandlingConfig as TErrorHandlingConfig } from "./shared/interface.ts";
22
+ import { InjectorService } from "./core/di/internal-injector.js";
23
+ import { CompileFn } from "./core/compile/compile.js";
24
+ import {
25
+ HttpParamSerializer,
26
+ HttpService as THttpService,
27
+ LogService as TLogService,
28
+ } from "./interface.ts";
29
+ import { ParseService as TParseService } from "./core/parse/interface.ts";
30
+ import { TemplateRequestService as TTemplateRequestService } from "./services/template-request/interface.ts";
31
+ import { HttpParamSerializerProvider } from "./services/http/http.js";
32
+ import { FilterFactory, FilterFn as TFilterFn } from "./filters/interface.ts";
33
+ import { InterpolateService as TInterpolateService } from "./core/interpolate/interface.ts";
34
+ import { InterpolateProvider } from "./core/interpolate/interpolate.js";
35
+ import { SceDelegateProvider, SceProvider } from "./services/sce/sce.js";
36
+ import {
37
+ Directive as TDirective,
38
+ DirectiveFactory as TDirectiveFactory,
39
+ Component as TComponent,
40
+ Controller as TController,
41
+ } from "./interface.ts";
42
+ import { StateProvider } from "./router/state/state-service.js";
43
+
44
+ declare global {
45
+ interface Function {
46
+ $inject?: readonly string[] | undefined;
47
+ }
48
+
49
+ namespace ng {
50
+ // Core types
51
+ type Angular = InstanceType<typeof Angular>;
52
+ type Attributes = InstanceType<typeof Attributes>;
53
+ type Directive = TDirective;
54
+ type DirectiveFactory = TDirectiveFactory;
55
+ type Component = TComponent;
56
+ type Controller = TController;
57
+ type Scope = InstanceType<typeof Scope>;
58
+ type NgModule = InstanceType<typeof NgModule>;
59
+ type PubSubProvider = InstanceType<typeof PubSubProvider>;
60
+ type FilterFn = TFilterFn;
61
+
62
+ // Providers
63
+ type AnchorScrollProvider = InstanceType<typeof AnchorScrollProvider>;
64
+ type InterpolateProvider = InstanceType<typeof InterpolateProvider>;
65
+ type HttpParamSerializerProvider = InstanceType<
66
+ typeof HttpParamSerializerProvider
67
+ >;
68
+
69
+ type SceProvider = InstanceType<typeof SceProvider>;
70
+ type SceDelegateProvider = InstanceType<typeof SceDelegateProvider>;
71
+
72
+ // Services
73
+ type AnchorScrollService = TAnchorScrollService;
74
+ type CompileService = CompileFn;
75
+ type ControllerService = TControllerService;
76
+ type ExceptionHandlerService = ErrorHandler;
77
+ type FilterService = FilterFactory;
78
+ type HttpParamSerializerSerService = HttpParamSerializer;
79
+ type HttpService = THttpService;
80
+ type InterpolateService = TInterpolateService;
81
+ type InjectorService = InstanceType<typeof InjectorService>;
82
+ type LogService = TLogService;
83
+ type ParseService = TParseService;
84
+ type PubSubService = InstanceType<typeof PubSub>;
85
+ type RootElementService = Element;
86
+ type RootScopeService = InstanceType<typeof Scope>;
87
+ type StateService = InstanceType<typeof StateProvider>;
88
+ type TemplateCacheService = InstanceType<typeof Map<string, string>>;
89
+ type TemplateRequestService = TTemplateRequestService;
90
+
91
+ // Support types
92
+ type ErrorHandlingConfig = TErrorHandlingConfig;
93
+ type WindowService = Window;
94
+ type DocumentService = Document;
95
+ }
96
+ }
@@ -35,11 +35,11 @@ export const $injectTokens = Object.freeze({
35
35
  $aria: "$aria",
36
36
  $compile: "$compile",
37
37
  $controller: "$controller",
38
+ $document: "$document",
38
39
  $eventBus: "$eventBus",
39
40
  $exceptionHandler: "$exceptionHandler",
40
41
  $filter: "$filter",
41
42
  $http: "$http",
42
- $httpBackend: "$httpBackend",
43
43
  $httpParamSerializer: "$httpParamSerializer",
44
44
  $interpolate: "$interpolate",
45
45
  $location: "$location",
@@ -53,6 +53,8 @@ export const $injectTokens = Object.freeze({
53
53
  $sceDelegate: "$sceDelegate",
54
54
  $state: "$state",
55
55
  $stateRegistry: "$stateRegistry",
56
+ $$sanitizeUri: "$$sanitizeUri",
57
+ $$sanitizeUriProvider: "$$sanitizeUriProvider",
56
58
  $templateCache: "$templateCache",
57
59
  $templateFactory: "$templateFactory",
58
60
  $templateRequest: "$templateRequest",
@@ -60,6 +62,7 @@ export const $injectTokens = Object.freeze({
60
62
  $urlConfig: "$urlConfig",
61
63
  $url: "$url",
62
64
  $view: "$view",
65
+ $window: "$window",
63
66
  // provide literals
64
67
  $provide: "$provide",
65
68
  $injector: "$injector",
package/src/interface.ts CHANGED
@@ -4,28 +4,26 @@ export * from "./services/log/log.js";
4
4
  export * from "./services/location/interface.ts";
5
5
  export * from "./services/location/location.js";
6
6
  export * from "./services/pubsub/pubsub.js";
7
- export * from "./services/template-cache/interface.ts";
8
7
  export * from "./services/template-cache/template-cache.js";
9
8
  export * from "./index.js";
10
9
 
11
10
  import { Attributes } from "./core/compile/attributes.js";
12
11
  import { Scope } from "./core/scope/scope.js";
13
- import { NgModule } from "./core/di/ng-module.js";
14
- import { PubSubProvider, PubSub } from "./services/pubsub/pubsub.js";
15
- import type { ErrorHandlingConfig as iErrorHandlingConfig } from "./shared/interface.ts";
16
-
17
- declare global {
18
- interface Function {
19
- $inject?: readonly string[] | undefined;
20
- }
21
-
22
- namespace ng {
23
- type Scope = typeof Scope;
24
- type NgModule = typeof NgModule;
25
- type PubSubProvider = typeof PubSubProvider;
26
- type PubSub = typeof PubSub;
27
- type ErrorHandlingConfig = iErrorHandlingConfig;
28
- }
12
+
13
+ /**
14
+ * Configuration options for the AngularTS bootstrap process.
15
+ *
16
+ * @property strictDi - If `true`, disables automatic function annotation
17
+ * for the application. This helps identify code that breaks under minification.
18
+ * Defaults to `false`.
19
+ */
20
+ export interface AngularBootstrapConfig {
21
+ /**
22
+ * Disable automatic function annotation for the application.
23
+ * This helps find bugs that would break under minified code.
24
+ * Defaults to `false`.
25
+ */
26
+ strictDi?: boolean;
29
27
  }
30
28
 
31
29
  /**
@@ -44,27 +42,49 @@ export type ExpandoStore = {
44
42
  };
45
43
 
46
44
  /**
47
- * A dependency-annotated factory array used by AngularTS DI system.
48
- *
49
- * It consists of zero or more dependency names (as strings), followed by
50
- * a factory function that takes those dependencies as arguments.
45
+ * Dependency-annotated factory array used by AngularTS DI system.
51
46
  *
52
47
  * Example:
53
- * ```ts
54
- * ['dep1', 'dep2', function(dep1, dep2) { ... }]
55
- * ```
48
+ * ['dep1', 'dep2', (dep1, dep2) => new MyController(dep1, dep2)]
49
+ */
50
+ export type AnnotatedFactory<TFunction extends (...args: any[]) => any> = [
51
+ ...string[],
52
+ TFunction,
53
+ ];
54
+
55
+ /**
56
+ * A class (constructor function) that can be instantiated.
56
57
  */
57
- export type AnnotatedFactory = [...string[], (...args: any[]) => any];
58
- export type InjectableFactory = (...args: any[]) => any;
59
- export type InjectableClass = new (...args: any[]) => any;
58
+ export type InjectableClass<TInstance = any> = new (...args: any) => TInstance;
60
59
 
61
60
  /**
62
- * A factory that can be either a standalone function or a dependency-annotated array or a class (constructor function).
61
+ * A factory that can be:
62
+ * - a standalone function,
63
+ * - a dependency-annotated array,
64
+ * - or a class constructor.
63
65
  *
64
- * The array form is used to support minification-safe dependency injection.
65
- * See {@link AnnotatedFactory}.
66
+ * Parentheses are required around constructor types when used in unions.
66
67
  */
67
- export type Injectable = AnnotatedFactory | InjectableFactory | InjectableClass;
68
+ export type Injectable<
69
+ T extends ((...args: any[]) => any) | (abstract new (...args: any[]) => any),
70
+ > =
71
+ | AnnotatedFactory<
72
+ T extends abstract new (...args: any[]) => any
73
+ ? (...args: ConstructorParameters<T>) => InstanceType<T>
74
+ : T
75
+ >
76
+ | (T extends abstract new (...args: any[]) => any
77
+ ? InjectableClass<InstanceType<T>>
78
+ : never)
79
+ | T;
80
+
81
+ interface ServiceProviderClass {
82
+ new (...args: any[]): ServiceProvider;
83
+ }
84
+
85
+ interface ServiceProviderFactory {
86
+ (...args: any[]): ServiceProvider;
87
+ }
68
88
 
69
89
  /**
70
90
  * An object that defines how a service is constructed.
@@ -73,7 +93,7 @@ export type Injectable = AnnotatedFactory | InjectableFactory | InjectableClass;
73
93
  * either as a plain factory function or as an {@link AnnotatedFactory}.
74
94
  */
75
95
  export interface ServiceProvider {
76
- $get: Injectable;
96
+ $get: Injectable<any>;
77
97
  }
78
98
 
79
99
  /**
@@ -114,14 +134,14 @@ export interface Provider {
114
134
  * @param name - The name of the service.
115
135
  * @param factoryFn - A function (or annotated array) that returns the service instance.
116
136
  */
117
- factory(name: string, factoryFn: Injectable): Provider;
137
+ factory(name: string, factoryFn: Injectable<any>): Provider;
118
138
 
119
139
  /**
120
140
  * Register a constructor function to create a service.
121
141
  * @param name - The name of the service.
122
142
  * @param constructor - A class or function to instantiate.
123
143
  */
124
- service(name: string, constructor: Injectable): Provider;
144
+ service(name: string, constructor: Injectable<any>): Provider;
125
145
 
126
146
  /**
127
147
  * Register a fixed value as a service.
@@ -145,16 +165,6 @@ export interface Provider {
145
165
  decorator(name: string, fn: Function): Provider;
146
166
  }
147
167
 
148
- /**
149
- * A filter function takes an input and optional arguments, and returns a transformed value.
150
- */
151
- export type FilterFn = (input: any, ...args: any[]) => any;
152
-
153
- /**
154
- * A filter factory function that returns a FilterFn.
155
- */
156
- export type FilterFactory = (...args: any[]) => FilterFn;
157
-
158
168
  /**
159
169
  * A controller constructor function used in AngularTS.
160
170
  */
@@ -192,23 +202,48 @@ export interface Controller {
192
202
  }
193
203
 
194
204
  /**
195
- * Defines a component's configuration object.
205
+ * Defines a component's configuration object (a simplified directive definition object).
196
206
  */
197
- export interface ComponentOptions {
198
- /** Controller function or injectable string reference */
199
- controller?: string | Injectable;
200
- /** Alias name for the controller in templates */
201
- controllerAs?: string;
202
- /** Inline HTML template */
203
- template?: string | Injectable;
204
- /** URL of the HTML template */
205
- templateUrl?: string | Injectable;
206
- /** Binding definitions (e.g., `@`, `=`, `<`) */
207
- bindings?: Record<string, string>;
208
- /** Enable transclusion or specify named slots */
209
- transclude?: boolean | Record<string, string>;
210
- /** Required controllers from other directives */
211
- require?: Record<string, string>;
207
+ export interface Component {
208
+ controller?: string | Injectable<ControllerConstructor> | undefined;
209
+ /**
210
+ * An identifier name for a reference to the controller. If present, the controller will be published to its scope under
211
+ * the specified name. If not present, this will default to '$ctrl'.
212
+ */
213
+ controllerAs?: string | undefined;
214
+ /**
215
+ * html template as a string or a function that returns an html template as a string which should be used as the
216
+ * contents of this component. Empty string by default.
217
+ * If template is a function, then it is injected with the following locals:
218
+ * $element - Current element
219
+ * $attrs - Current attributes object for the element
220
+ * Use the array form to define dependencies (necessary if strictDi is enabled and you require dependency injection)
221
+ */
222
+ template?: string | Injectable<(...args: any[]) => string> | undefined;
223
+ /**
224
+ * Path or function that returns a path to an html template that should be used as the contents of this component.
225
+ * If templateUrl is a function, then it is injected with the following locals:
226
+ * $element - Current element
227
+ * $attrs - Current attributes object for the element
228
+ * Use the array form to define dependencies (necessary if strictDi is enabled and you require dependency injection)
229
+ */
230
+ templateUrl?: string | Injectable<(...args: any[]) => string> | undefined;
231
+ /**
232
+ * Define DOM attribute binding to component properties. Component properties are always bound to the component
233
+ * controller and not to the scope.
234
+ */
235
+ bindings?: { [boundProperty: string]: string } | undefined;
236
+ /**
237
+ * Whether transclusion is enabled. Disabled by default.
238
+ */
239
+ transclude?: boolean | { [slot: string]: string } | undefined;
240
+ /**
241
+ * Requires the controllers of other directives and binds them to this component's controller.
242
+ * The object keys specify the property names under which the required controllers (object values) will be bound.
243
+ * Note that the required controllers will not be available during the instantiation of the controller,
244
+ * but they are guaranteed to be available just before the $onInit method is executed!
245
+ */
246
+ require?: { [controller: string]: string } | undefined;
212
247
  }
213
248
 
214
249
  /**
@@ -263,7 +298,7 @@ export interface Directive {
263
298
  /** Compile function for the directive */
264
299
  compile?: DirectiveCompileFn;
265
300
  /** Controller constructor or injectable string name */
266
- controller?: string | Injectable | any;
301
+ controller?: string | Injectable<any> | any;
267
302
  /** Alias name for the controller in templates */
268
303
  controllerAs?: string;
269
304
  /** Whether to bind scope to controller */
@@ -383,39 +418,13 @@ export interface NgModelController {
383
418
  /** Current value shown in the view */
384
419
  $viewValue: any;
385
420
  }
386
- /**
387
- * Possible values for `data-swap` attribute
388
- */
389
- export const SwapMode = {
390
- /** (default) Replaces the contents inside the element */
391
- innerHTML: "innerHTML",
392
-
393
- /** Replaces the entire element, including the tag itself */
394
- outerHTML: "outerHTML",
395
-
396
- /** Inserts plain text (without parsing HTML) */
397
- textContent: "textContent",
398
-
399
- /** Inserts HTML immediately before the element itself */
400
- beforebegin: "beforebegin",
401
421
 
402
- /** Inserts HTML inside the element, before its first child */
403
- afterbegin: "afterbegin",
404
-
405
- /** Inserts HTML inside the element, after its last child */
406
- beforeend: "beforeend",
407
-
408
- /** Inserts HTML immediately after the element itself */
409
- afterend: "afterend",
410
-
411
- /** Removes the element entirely */
412
- delete: "delete",
413
-
414
- /** Performs no insertion (no-op) */
415
- none: "none",
416
- } as const;
422
+ export interface RootElementService extends Element {}
417
423
 
418
424
  /**
419
- * Union type representing all possible DOM insertion modes.
425
+ * The minimal local definitions required by $controller(ctrl, locals) calls.
420
426
  */
421
- export type SwapModeType = keyof typeof SwapMode;
427
+ export interface ControllerLocals {
428
+ $scope: Scope;
429
+ $element: Element;
430
+ }
package/src/ng.js CHANGED
@@ -50,7 +50,7 @@ import {
50
50
  import { ngModelOptionsDirective } from "./directive/model-options/model-options.js";
51
51
  import { ngAttributeAliasDirectives } from "./directive/attrs/attrs.js";
52
52
  import { ngEventDirectives } from "./directive/events/events.js";
53
- import { AnchorScrollProvider } from "./services/anchor-scroll.js";
53
+ import { AnchorScrollProvider } from "./services/anchor-scroll/anchor-scroll.js";
54
54
  import { AnimateProvider } from "./animations/animate.js";
55
55
  import {
56
56
  AnimateAsyncRunFactoryProvider,
@@ -65,13 +65,12 @@ import {
65
65
  HttpParamSerializerProvider,
66
66
  HttpProvider,
67
67
  } from "./services/http/http.js";
68
- import { HttpBackendProvider } from "./services/http-backend/http-backend.js";
69
68
  import { LocationProvider } from "./services/location/location.js";
70
69
  import { LogProvider } from "./services/log/log.js";
71
70
  import { ParseProvider } from "./core/parse/parse.js";
72
71
  import { RootScopeProvider } from "./core/scope/scope.js";
73
72
  import { SceDelegateProvider, SceProvider } from "./services/sce/sce.js";
74
- import { TemplateRequestProvider } from "./services/template-request.js";
73
+ import { TemplateRequestProvider } from "./services/template-request/template-request.js";
75
74
  import { SanitizeUriProvider } from "./core/sanitize/sanitize-uri.js";
76
75
  import {
77
76
  ngMessageDefaultDirective,
@@ -133,6 +132,7 @@ import {
133
132
  ngPutDirective,
134
133
  } from "./directive/http/http.js";
135
134
  import { $injectTokens as $t } from "./injection-tokens.js";
135
+ import { ngInjectDirective } from "./directive/inject/inject.js";
136
136
 
137
137
  /**
138
138
  * Initializes core `ng` module.
@@ -152,6 +152,8 @@ export function registerNgModule(angular) {
152
152
  $provide.provider({
153
153
  $$sanitizeUri: SanitizeUriProvider,
154
154
  });
155
+ $provide.value("$window", window);
156
+ $provide.value("$document", document);
155
157
  $provide
156
158
  .provider($t.$compile, CompileProvider)
157
159
  .directive({
@@ -176,6 +178,7 @@ export function registerNgModule(angular) {
176
178
  ngHide: ngHideDirective,
177
179
  ngIf: ngIfDirective,
178
180
  ngInclude: ngIncludeDirective,
181
+ ngInject: ngInjectDirective,
179
182
  ngInit: ngInitDirective,
180
183
  ngMessages: ngMessagesDirective,
181
184
  ngMessage: ngMessageDirective,
@@ -253,7 +256,6 @@ export function registerNgModule(angular) {
253
256
  $interpolate: InterpolateProvider,
254
257
  $http: HttpProvider,
255
258
  $httpParamSerializer: HttpParamSerializerProvider,
256
- $httpBackend: HttpBackendProvider,
257
259
  $location: LocationProvider,
258
260
  $log: LogProvider,
259
261
  $parse: ParseProvider,
package/src/ng.spec.js CHANGED
@@ -30,4 +30,16 @@ describe("public", () => {
30
30
  const injector = createInjector(["ng"]);
31
31
  expect(injector.has("$rootScope")).toBe(true);
32
32
  });
33
+
34
+ it("sets up $window", () => {
35
+ const injector = createInjector(["ng"]);
36
+ expect(injector.has("$window")).toBe(true);
37
+ expect(injector.get("$window")).toBe(window);
38
+ });
39
+
40
+ it("sets up $document", () => {
41
+ const injector = createInjector(["ng"]);
42
+ expect(injector.has("$document")).toBe(true);
43
+ expect(injector.get("$document")).toBe(document);
44
+ });
33
45
  });
@@ -355,7 +355,7 @@ export function $StateRefActiveDirective(
355
355
  };
356
356
  states.push(stateInfo);
357
357
  return function removeState() {
358
- removeFrom(states)(stateInfo);
358
+ removeFrom(states, stateInfo);
359
359
  };
360
360
  }
361
361
  // Update route state