@angular-wave/angular.ts 0.12.0 → 0.14.0

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 (61) hide show
  1. package/@types/angular.d.ts +3 -3
  2. package/@types/animations/animation.d.ts +1 -1
  3. package/@types/animations/raf-scheduler.d.ts +1 -3
  4. package/@types/core/compile/attributes.d.ts +2 -2
  5. package/@types/core/compile/compile.d.ts +2 -2
  6. package/@types/core/di/ng-module/ng-module.d.ts +33 -36
  7. package/@types/core/filter/filter.d.ts +12 -13
  8. package/@types/core/scope/interface.d.ts +1 -1
  9. package/@types/core/scope/scope.d.ts +9 -10
  10. package/@types/directive/aria/aria.d.ts +3 -3
  11. package/@types/directive/bind/bind.d.ts +2 -2
  12. package/@types/directive/class/class.d.ts +3 -3
  13. package/@types/directive/events/events.d.ts +2 -2
  14. package/@types/directive/form/form.d.ts +12 -2
  15. package/@types/directive/include/include.d.ts +4 -4
  16. package/@types/directive/input/input.d.ts +2 -2
  17. package/@types/directive/messages/messages.d.ts +1 -1
  18. package/@types/directive/model/model.d.ts +26 -20
  19. package/@types/directive/model-options/model-options.d.ts +4 -1
  20. package/@types/directive/options/options.d.ts +4 -4
  21. package/@types/directive/select/select.d.ts +1 -1
  22. package/@types/directive/style/style.d.ts +2 -2
  23. package/@types/directive/worker/interface.d.ts +2 -0
  24. package/@types/directive/worker/worker.d.ts +2 -0
  25. package/@types/filters/interface.d.ts +7 -1
  26. package/@types/interface.d.ts +66 -34
  27. package/@types/namespace.d.ts +60 -13
  28. package/@types/router/common/trace.d.ts +1 -0
  29. package/@types/router/directives/view-directive.d.ts +2 -2
  30. package/@types/router/transition/transition.d.ts +0 -1
  31. package/@types/router/url/url-config.d.ts +1 -1
  32. package/@types/router/url/url-rule.d.ts +0 -10
  33. package/@types/router/url/url-service.d.ts +3 -6
  34. package/@types/router/view/view.d.ts +0 -16
  35. package/@types/services/anchor-scroll/anchor-scroll.d.ts +1 -1
  36. package/@types/services/cookie/cookie.d.ts +80 -0
  37. package/@types/services/cookie/interface.d.ts +12 -0
  38. package/@types/services/exception/exception.d.ts +56 -0
  39. package/@types/services/exception/interface.d.ts +3 -3
  40. package/@types/services/http/http.d.ts +10 -2
  41. package/@types/services/location/location.d.ts +10 -6
  42. package/@types/services/pubsub/pubsub.d.ts +2 -1
  43. package/@types/services/rest/interface.d.ts +17 -0
  44. package/@types/services/rest/rest.d.ts +106 -0
  45. package/@types/services/rest/rfc.d.ts +40 -0
  46. package/@types/services/sce/sce.d.ts +1 -1
  47. package/@types/services/storage/interface.d.ts +1 -0
  48. package/@types/shared/common.d.ts +1 -1
  49. package/@types/shared/dom.d.ts +8 -11
  50. package/@types/shared/hof.d.ts +2 -2
  51. package/@types/shared/interface.d.ts +1 -0
  52. package/@types/shared/noderef.d.ts +1 -0
  53. package/@types/shared/strings.d.ts +6 -8
  54. package/@types/shared/utils.d.ts +73 -25
  55. package/LICENSE +1 -0
  56. package/README.md +3 -90
  57. package/dist/angular-ts.esm.js +10120 -6051
  58. package/dist/angular-ts.umd.js +10120 -6051
  59. package/dist/angular-ts.umd.min.js +1 -1
  60. package/package.json +1 -6
  61. package/@types/services/exception/exception-handler.d.ts +0 -58
@@ -10,8 +10,16 @@ export * from "./index.js";
10
10
  export * from "./angular.js";
11
11
  export * from "./core/di/internal-injector.js";
12
12
  export * from "./core/scope/scope.js";
13
+ export * from "./services/cookie/cookie.js";
14
+ export * from "./services/cookie/interface.ts";
15
+ export * from "./services/exception/exception.ts";
16
+ export * from "./services/exception/interface.ts";
17
+ export * from "./core/parse/interface.ts";
18
+ export * from "./filters/interface.ts";
19
+ export * from "./core/filter/filter.js";
13
20
  import { Attributes } from "./core/compile/attributes.js";
14
21
  import { Scope } from "./core/scope/scope.js";
22
+ import { NgModelController } from "./directive/model/model.js";
15
23
  /**
16
24
  * Configuration options for the AngularTS bootstrap process.
17
25
  *
@@ -64,7 +72,7 @@ export type InjectableClass<TInstance = any> = new (...args: any) => TInstance;
64
72
  *
65
73
  * Parentheses are required around constructor types when used in unions.
66
74
  */
67
- type FactoryFunction<T> = T extends abstract new (...args: any[]) => any
75
+ export type FactoryFunction<T> = T extends abstract new (...args: any[]) => any
68
76
  ? (...args: ConstructorParameters<T>) => InstanceType<T>
69
77
  : T;
70
78
  export type Injectable<
@@ -75,6 +83,12 @@ export type Injectable<
75
83
  ? InjectableClass<InstanceType<T>>
76
84
  : never)
77
85
  | T;
86
+ export interface ServiceProviderClass {
87
+ new (...args: any[]): ServiceProvider;
88
+ }
89
+ export interface ServiceProviderFactory {
90
+ (...args: any[]): ServiceProvider;
91
+ }
78
92
  /**
79
93
  * An object that defines how a service is constructed.
80
94
  *
@@ -163,6 +177,57 @@ export interface ChangesObject<T = any> {
163
177
  * Mapping of binding property names to their change metadata.
164
178
  */
165
179
  export type OnChangesObject = Record<string, ChangesObject>;
180
+ /**
181
+ * Interface for the $onInit lifecycle hook
182
+ * https://docs.angularjs.org/api/ng/service/$compile#life-cycle-hooks
183
+ */
184
+ export interface OnInit {
185
+ /**
186
+ * Called on each controller after all the controllers on an element have been constructed and had their bindings
187
+ * initialized (and before the pre & post linking functions for the directives on this element). This is a good
188
+ * place to put initialization code for your controller.
189
+ */
190
+ $onInit(): void;
191
+ }
192
+ /**
193
+ * Interface for the $onChanges lifecycle hook
194
+ * https://docs.angularjs.org/api/ng/service/$compile#life-cycle-hooks
195
+ */
196
+ export interface OnChanges {
197
+ /**
198
+ * Called whenever one-way bindings are updated. The onChangesObj is a hash whose keys are the names of the bound
199
+ * properties that have changed, and the values are an {@link IChangesObject} object of the form
200
+ * { currentValue, previousValue, isFirstChange() }. Use this hook to trigger updates within a component such as
201
+ * cloning the bound value to prevent accidental mutation of the outer value.
202
+ */
203
+ $onChanges(onChangesObj: OnChangesObject): void;
204
+ }
205
+ /**
206
+ * Interface for the $onDestroy lifecycle hook
207
+ * https://docs.angularjs.org/api/ng/service/$compile#life-cycle-hooks
208
+ */
209
+ export interface OnDestroy {
210
+ /**
211
+ * Called on a controller when its containing scope is destroyed. Use this hook for releasing external resources,
212
+ * watches and event handlers.
213
+ */
214
+ $onDestroy(): void;
215
+ }
216
+ /**
217
+ * Interface for the $postLink lifecycle hook
218
+ * https://docs.angularjs.org/api/ng/service/$compile#life-cycle-hooks
219
+ */
220
+ export interface PostLink {
221
+ /**
222
+ * Called after this controller's element and its children have been linked. Similar to the post-link function this
223
+ * hook can be used to set up DOM event handlers and do direct DOM manipulation. Note that child elements that contain
224
+ * templateUrl directives will not have been compiled and linked since they are waiting for their template to load
225
+ * asynchronously and their own compilation and linking has been suspended until that occurs. This hook can be considered
226
+ * analogous to the ngAfterViewInit and ngAfterContentInit hooks in Angular 2. Since the compilation process is rather
227
+ * different in Angular 1 there is no direct mapping and care should be taken when upgrading.
228
+ */
229
+ $postLink(): void;
230
+ }
166
231
  /**
167
232
  * AngularTS component lifecycle interface.
168
233
  * Directive controllers have a well-defined lifecycle. Each controller can implement "lifecycle hooks". These are methods that
@@ -388,39 +453,6 @@ export interface NgModelOptions {
388
453
  /** Whether to remove trailing :00 seconds */
389
454
  timeStripZeroSeconds?: boolean;
390
455
  }
391
- /**
392
- * Controller API for ngModel directive.
393
- */
394
- export interface NgModelController {
395
- /** Updates the view when the model changes */
396
- $render(): void;
397
- /** Sets the validity state of the control */
398
- $setValidity(validationErrorKey: string, isValid: boolean): void;
399
- /** Updates the model value */
400
- $setViewValue(value: any, trigger?: string): void;
401
- /** Marks the control as pristine */
402
- $setPristine(): void;
403
- /** Marks the control as dirty */
404
- $setDirty(): void;
405
- /** Re-validates the model */
406
- $validate(): void;
407
- /** Marks the control as touched */
408
- $setTouched(): void;
409
- /** Marks the control as untouched */
410
- $setUntouched(): void;
411
- /** Rolls back to previous view value */
412
- $rollbackViewValue(): void;
413
- /** Commits the current view value to the model */
414
- $commitViewValue(): void;
415
- /** Processes view-to-model transformations */
416
- $processModelValue(): void;
417
- /** Determines if value is considered empty */
418
- $isEmpty(value: any): boolean;
419
- /** Overrides the model options dynamically */
420
- $overrideModelOptions(options: NgModelOptions): void;
421
- /** Current value shown in the view */
422
- $viewValue: any;
423
- }
424
456
  export interface RootElementService extends Element {}
425
457
  /**
426
458
  * The minimal local definitions required by $controller(ctrl, locals) calls.
@@ -13,15 +13,17 @@ import {
13
13
  AnchorScrollService as TAnchorScrollService,
14
14
  } from "./services/anchor-scroll/anchor-scroll.js";
15
15
  import { ControllerService as TControllerService } from "./core/controller/interface.ts";
16
- import { ErrorHandler as TErrorHandler } from "./services/exception/interface.ts";
16
+ import { ExceptionHandler as TExceptionHandler } from "./services/exception/interface.ts";
17
17
  import { ParseService as TParseService } from "./core/parse/interface.ts";
18
18
  import { TemplateRequestService as TTemplateRequestService } from "./services/template-request/interface.ts";
19
19
  import { HttpParamSerializer as THttpParamSerializer } from "./services/http/interface.ts";
20
20
  import { HttpParamSerializerProvider as THttpParamSerializerProvider } from "./services/http/http.js";
21
21
  import {
22
22
  FilterFactory as TFilterFactory,
23
+ FilterService as TFilterService,
23
24
  FilterFn as TFilterFn,
24
25
  } from "./filters/interface.ts";
26
+ import { FilterProvider as TFilterProvider } from "./core/filter/filter.js";
25
27
  import { InterpolateService as TInterpolateService } from "./core/interpolate/interface.ts";
26
28
  import { InterpolateProvider as TInterpolateProvider } from "./core/interpolate/interpolate.js";
27
29
  import {
@@ -38,15 +40,21 @@ import {
38
40
  import {
39
41
  Directive as TDirective,
40
42
  DirectiveFactory as TDirectiveFactory,
43
+ AnnotatedDirectiveFactory as TAnnotatedDirectiveFactory,
41
44
  Component as TComponent,
42
45
  Controller as TController,
46
+ ControllerConstructor as TControllerConstructor,
43
47
  Injectable as TInjectable,
48
+ Expression as TExpression,
44
49
  } from "./interface.ts";
45
50
  import {
46
51
  SseService as TSseService,
47
52
  SseConfig as TSseConfig,
48
53
  } from "./services/sse/interface.ts";
49
- import type { ErrorHandlingConfig as TErrorHandlingConfig } from "./shared/interface.ts";
54
+ import type {
55
+ ErrorHandlingConfig as TErrorHandlingConfig,
56
+ Validator as TValidator,
57
+ } from "./shared/interface.ts";
50
58
  import {
51
59
  BoundTranscludeFn as TBoundTranscludeFn,
52
60
  CompileFn as TCompileFn,
@@ -64,8 +72,23 @@ import {
64
72
  import { Provider as TProvideService } from "./interface.ts";
65
73
  import { Location as TLocationService } from "./services/location/location.js";
66
74
  import { AnimateService as TAnimateService } from "./animations/interface.ts";
67
- import { StorageBackend as TStorageBackend } from "./services/storage/interface.ts";
75
+ import {
76
+ StorageBackend as TStorageBackend,
77
+ StorageType as TStorageType,
78
+ } from "./services/storage/interface.ts";
68
79
  import { StreamConnectionConfig as TStreamConnectionConfig } from "./services/stream/interface.ts";
80
+ import { CookieService as TCookieService } from "./services/cookie/cookie.js";
81
+ import {
82
+ CookieStoreOptions as TCookieStoreOptions,
83
+ CookieOptions as TCookieOptions,
84
+ } from "./services/cookie/interface.ts";
85
+ import {
86
+ RestDefinition as TRestDefinition,
87
+ EntityClass as TEntityClass,
88
+ } from "./services/rest/interface.ts";
89
+ import { RestService as TRestService } from "./services/rest/rest.js";
90
+ import { ServiceProvider as TServiceProvider } from "./interface.ts";
91
+ import { NgModelController as TNgModelController } from "./directive/model/model.js";
69
92
  declare global {
70
93
  interface Function {
71
94
  $inject?: readonly string[] | undefined;
@@ -77,18 +100,23 @@ declare global {
77
100
  type Angular = TAngular;
78
101
  type Attributes = TAttributes & Record<string, any>;
79
102
  type Directive<TController = any> = TDirective<TController>;
80
- type DirectiveFactory = TDirectiveFactory;
81
- type Component = TComponent;
103
+ type DirectiveFactory = TDirectiveFactory & Function;
104
+ type AnnotatedDirectiveFactory = TAnnotatedDirectiveFactory;
105
+ type Component = TComponent & Record<string, any>;
82
106
  type Controller = TController;
83
- type Scope = TScope;
107
+ type Scope = TScope & Record<string, any>;
84
108
  type NgModule = TNgModule;
85
109
  type PubSubProvider = TPubSubProvider;
86
- type FilterFn = TFilterFn;
87
110
  type CompositeLinkFn = TCompositeLinkFn;
88
- type PublicLinkFn = TPublicLinkFn;
111
+ type PublicLinkFn = TPublicLinkFn & {
112
+ pre: any;
113
+ post: any;
114
+ };
89
115
  type NodeLinkFn = TNodeLinkFn;
90
116
  type NodeLinkFnCtx = TNodeLinkFnCtx;
91
- type TranscludeFn = TTranscludeFn;
117
+ type TranscludeFn = TTranscludeFn & {
118
+ $$slots: any;
119
+ };
92
120
  type BoundTranscludeFn = TBoundTranscludeFn;
93
121
  type LinkFnMapping = TLinkFnMapping;
94
122
  type AnchorScrollProvider = TAnchorScrollProvider;
@@ -96,12 +124,18 @@ declare global {
96
124
  type HttpParamSerializerProvider = THttpParamSerializerProvider;
97
125
  type SceProvider = TSceProvider;
98
126
  type SceDelegateProvider = TSceDelegateProvider;
127
+ type FilterProvider = TFilterProvider;
99
128
  type AnchorScrollService = TAnchorScrollService;
100
129
  type AnimateService = TAnimateService;
101
130
  type CompileService = TCompileFn;
102
131
  type ControllerService = TControllerService;
103
- type ExceptionHandlerService = TErrorHandler;
104
- type FilterService = TFilterFactory;
132
+ type CookieService = TCookieService;
133
+ type ExceptionHandlerService = TExceptionHandler;
134
+ type FilterFn = TFilterFn;
135
+ type FilterFactory = TFilterFactory & {
136
+ $$moduleName: string;
137
+ };
138
+ type FilterService = TFilterService;
105
139
  type HttpParamSerializerSerService = THttpParamSerializer;
106
140
  type HttpService = THttpService;
107
141
  type InterpolateService = TInterpolateService;
@@ -112,7 +146,7 @@ declare global {
112
146
  type ProvideService = TProvideService;
113
147
  type PubSubService = TPubSub;
114
148
  type RootElementService = Element;
115
- type RootScopeService = TScope;
149
+ type RootScopeService = TScope & Record<string, any>;
116
150
  type StateService = TStateProvider;
117
151
  type SseService = TSseService;
118
152
  type SseConfig = TSseConfig;
@@ -129,8 +163,21 @@ declare global {
129
163
  T extends
130
164
  | ((...args: any[]) => any)
131
165
  | (abstract new (...args: any[]) => any),
132
- > = TInjectable<T>;
166
+ > = TInjectable<T> & {
167
+ $$moduleName: string;
168
+ };
133
169
  type StorageBackend = TStorageBackend;
170
+ type StorageType = TStorageType;
134
171
  type StreamConnectionConfig = TStreamConnectionConfig;
172
+ type CookieOptions = TCookieOptions;
173
+ type ControllerConstructor = TControllerConstructor;
174
+ type CookieStoreOptions = TCookieStoreOptions;
175
+ type RestService<T, ID> = TRestService<T, ID>;
176
+ type RestDefinition<T> = TRestDefinition<T>;
177
+ type EntityClass<T> = TEntityClass<T>;
178
+ type ServiceProvider = TServiceProvider;
179
+ type Expression = TExpression;
180
+ type NgModelController = TNgModelController;
181
+ type Validator = TValidator;
135
182
  }
136
183
  }
@@ -12,6 +12,7 @@ export namespace Category {
12
12
  export class Trace {
13
13
  _enabled: {};
14
14
  approximateDigests: number;
15
+ $logger: any;
15
16
  _set(enabled: any, categories: any): void;
16
17
  enable(...categories: any[]): void;
17
18
  disable(...categories: any[]): void;
@@ -4,7 +4,7 @@ export function $ViewDirectiveFill(
4
4
  $transitions: any,
5
5
  ): {
6
6
  priority: number;
7
- compile: (tElement: any) => (scope: any, $element: any) => void;
7
+ compile(tElement: any): (scope: any, $element: any) => void;
8
8
  };
9
9
  export namespace $ViewDirectiveFill {
10
10
  let $inject: string[];
@@ -135,4 +135,4 @@ export namespace $ViewDirectiveFill {
135
135
  * ```
136
136
  */
137
137
  /** @type {import("../../interface.ts").AnnotatedDirectiveFactory} */
138
- export let ngView: import("../../interface.ts").AnnotatedDirectiveFactory;
138
+ export const ngView: import("../../interface.ts").AnnotatedDirectiveFactory;
@@ -1,4 +1,3 @@
1
- /** @typedef {import('./interface.ts').IHookRegistry} IHookRegistry */
2
1
  /**
3
2
  * Represents a transition between two states.
4
3
  *
@@ -20,7 +20,7 @@ export class UrlConfigProvider {
20
20
  _isStrictMode: boolean;
21
21
  /** @type {boolean} */
22
22
  _defaultSquashPolicy: boolean;
23
- $get: (() => any)[];
23
+ $get: () => this;
24
24
  /**
25
25
  * Defines whether URL matching should be case sensitive (the default behavior), or not.
26
26
  *
@@ -1,13 +1,3 @@
1
- /**
2
- * Creates a [[UrlRule]]
3
- *
4
- * Creates a [[UrlRule]] from a:
5
- *
6
- * - `string`
7
- * - [[UrlMatcher]]
8
- * - `RegExp`
9
- * - [[StateObject]]
10
- */
11
1
  export class UrlRuleFactory {
12
2
  /**
13
3
  * @param {import('../url/url-service.js').UrlService} urlService
@@ -60,10 +60,7 @@ export class UrlService {
60
60
  getHash(): string;
61
61
  $get: (
62
62
  | string
63
- | ((
64
- $location: import("../../services/location/location.js").Location,
65
- $rootScope: import("../../core/scope/scope.js").Scope,
66
- ) => UrlService)
63
+ | (($location: ng.LocationService, $rootScope: ng.Scope) => UrlService)
67
64
  )[];
68
65
  /**
69
66
  * @returns {string}
@@ -234,11 +231,11 @@ export class UrlService {
234
231
  /**
235
232
  * Creates a [[UrlMatcher]] for the specified pattern.
236
233
  *
237
- * @param pattern The URL pattern.
234
+ * @param urlPattern The URL pattern.
238
235
  * @param config The config object hash.
239
236
  * @returns The UrlMatcher.
240
237
  */
241
- compile(pattern: any, config: any): UrlMatcher;
238
+ compile(urlPattern: any, config: any): UrlMatcher;
242
239
  /**
243
240
  * Returns true if the specified object is a [[UrlMatcher]], or false otherwise.
244
241
  *
@@ -1,19 +1,3 @@
1
- /**
2
- * The View service
3
- *
4
- * This service pairs existing `ng-view` components (which live in the DOM)
5
- * with view configs (from the state declaration objects: [[StateDeclaration.views]]).
6
- *
7
- * - After a successful Transition, the views from the newly entered states are activated via [[activateViewConfig]].
8
- * The views from exited states are deactivated via [[deactivateViewConfig]].
9
- * (See: the [[registerActivateViews]] Transition Hook)
10
- *
11
- * - As `ng-view` components pop in and out of existence, they register themselves using [[registerUIView]].
12
- *
13
- * - When the [[sync]] function is called, the registered `ng-view`(s) ([[ActiveUIView]])
14
- * are configured with the matching [[ViewConfig]](s)
15
- *
16
- */
17
1
  export class ViewService {
18
2
  _ngViews: any[];
19
3
  _viewConfigs: any[];
@@ -14,7 +14,7 @@ export class AnchorScrollProvider {
14
14
  | string
15
15
  | ((
16
16
  $location: import("../../services/location/location.js").Location,
17
- $rootScope: import("../../core/scope/scope.js").Scope,
17
+ $rootScope: ng.Scope,
18
18
  ) => AnchorScrollFunction)
19
19
  )[];
20
20
  }
@@ -0,0 +1,80 @@
1
+ /**
2
+ * Service provider that creates a {@link CookieService $cookie} service.
3
+ * @type {ng.ServiceProvider}
4
+ */
5
+ export class CookieProvider {
6
+ defaults: {};
7
+ $get: (
8
+ | string
9
+ | (($exceptionHandler: ng.ExceptionHandlerService) => CookieService)
10
+ )[];
11
+ }
12
+ /**
13
+ *
14
+ * Provides high-level APIs for interacting with browser cookies:
15
+ * - Raw get/set/remove
16
+ * - JSON serialization helpers
17
+ * - Global defaults supplied by $cookiesProvider
18
+ */
19
+ export class CookieService {
20
+ /**
21
+ * @param {ng.CookieOptions} defaults
22
+ * Default cookie attributes defined by `$cookiesProvider.defaults`.
23
+ * @param {ng.ExceptionHandlerService} $exceptionHandler
24
+ */
25
+ constructor(
26
+ defaults: ng.CookieOptions,
27
+ $exceptionHandler: ng.ExceptionHandlerService,
28
+ );
29
+ /** @type {ng.CookieOptions} */
30
+ defaults: ng.CookieOptions;
31
+ $exceptionHandler: import("../exception/interface.ts").ExceptionHandler;
32
+ /**
33
+ * Retrieves a raw cookie value.
34
+ *
35
+ * @param {string} key
36
+ * @returns {string|null}
37
+ * @throws {URIError} – If decodeURIComponent fails.
38
+ */
39
+ get(key: string): string | null;
40
+ /**
41
+ * Retrieves a cookie and deserializes its JSON content.
42
+ *
43
+ * @template T
44
+ * @param {string} key
45
+ * @returns {T|null}
46
+ * @throws {SyntaxError} if cookie JSON is invalid
47
+ */
48
+ getObject<T>(key: string): T | null;
49
+ /**
50
+ * Returns an object containing all raw cookies.
51
+ *
52
+ * @returns {Record<string, string>}
53
+ * @throws {URIError} – If decodeURIComponent fails
54
+ */
55
+ getAll(): Record<string, string>;
56
+ /**
57
+ * Sets a raw cookie value.
58
+ *
59
+ * @param {string} key
60
+ * @param {string} value
61
+ * @param {ng.CookieOptions} [options]
62
+ */
63
+ put(key: string, value: string, options?: ng.CookieOptions): void;
64
+ /**
65
+ * Serializes an object as JSON and stores it as a cookie.
66
+ *
67
+ * @param {string} key
68
+ * @param {any} value
69
+ * @param {ng.CookieOptions} [options]
70
+ * @throws {TypeError} if Object cannot be converted to JSON
71
+ */
72
+ putObject(key: string, value: any, options?: ng.CookieOptions): void;
73
+ /**
74
+ * Removes a cookie by setting an expired date.
75
+ *
76
+ * @param {string} key
77
+ * @param {ng.CookieOptions} [options]
78
+ */
79
+ remove(key: string, options?: ng.CookieOptions): void;
80
+ }
@@ -0,0 +1,12 @@
1
+ export interface CookieOptions {
2
+ path?: string;
3
+ domain?: string;
4
+ expires?: Date | string | number;
5
+ secure?: boolean;
6
+ samesite?: "Lax" | "Strict" | "None";
7
+ }
8
+ export interface CookieStoreOptions {
9
+ serialize?: (value: any) => string;
10
+ deserialize?: (text: string) => any;
11
+ cookie?: CookieOptions;
12
+ }
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Unified exception handler used throughout AngularTS.
3
+ *
4
+ * This service receives uncaught exceptions from both synchronous and asynchronous operations.
5
+ * Its purpose is to provide a central point through which the framework
6
+ * processes errors.
7
+ *
8
+ * By default, `$exceptionHandler` simply rethrows the exception. This ensures fail-fast
9
+ * behavior, making errors visible immediately in development and in unit tests.
10
+ * Applications may override this service to introduce custom error handling.
11
+ *
12
+ * ### Example: Custom `$exceptionHandler`
13
+ *
14
+ * ```js
15
+ * angular
16
+ * .module('app')
17
+ * .factory('$exceptionHandler', function(myLogger) {
18
+ * return function handleError(error) {
19
+ * myLogger.capture(error);
20
+ * // Rethrow to preserve fail-fast behavior:
21
+ * throw error;
22
+ * };
23
+ * });
24
+ * ```
25
+ *
26
+ * IMPORTANT: custom implementation should always rethrow the error as the framework assumes that `$exceptionHandler` always does the throwing.
27
+ *
28
+ * ### Manual Invocation
29
+ *
30
+ * You can invoke the exception handler directly when catching errors in your own code:
31
+ *
32
+ * ```js
33
+ * try {
34
+ * riskyOperation();
35
+ * } catch (err) {
36
+ * $exceptionHandler(err);
37
+ * }
38
+ * ```
39
+ *
40
+ * @see {@link ng.ExceptionHandlerService} ExceptionHandlerService
41
+ */
42
+ /**
43
+ * Provider for the `$exceptionHandler` service.
44
+ *
45
+ * The default implementation rethrows exceptions, enabling strict fail-fast behavior.
46
+ * Applications may replace the handler via by setting `errorHandler`property or by providing their own
47
+ * `$exceptionHandler` factory.
48
+ */
49
+ export class ExceptionHandlerProvider {
50
+ /** @type {ng.ExceptionHandlerService} */
51
+ handler: ng.ExceptionHandlerService;
52
+ /**
53
+ * @returns {ng.ExceptionHandlerService}
54
+ */
55
+ $get(): ng.ExceptionHandlerService;
56
+ }
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * A callback type for handling errors.
3
3
  *
4
- * @param exception - The exception associated with the error.
5
- * @param [cause] - Optional information about the context in which the error was thrown.
4
+ * @param {Error} exception - The exception associated with the error.
5
+ * @throws {Error}
6
6
  */
7
- export type ErrorHandler = (exception: Error, cause?: string) => void;
7
+ export type ExceptionHandler = (exception: Error) => never;
@@ -25,7 +25,7 @@ export function HttpProvider(): void;
25
25
  export class HttpProvider {
26
26
  defaults: {
27
27
  transformResponse: (typeof defaultHttpResponseTransform)[];
28
- transformRequest: ((d: any) => any)[];
28
+ transformRequest: ((data: any) => any)[];
29
29
  headers: {
30
30
  common: {
31
31
  Accept: string;
@@ -108,6 +108,7 @@ export class HttpProvider {
108
108
  | ((
109
109
  $injector: ng.InjectorService,
110
110
  $sce: any,
111
+ $cookie: ng.CookieService,
111
112
  ) => {
112
113
  (requestConfig: any): Promise<any>;
113
114
  pendingRequests: any[];
@@ -119,7 +120,7 @@ export class HttpProvider {
119
120
  */
120
121
  defaults: {
121
122
  transformResponse: (typeof defaultHttpResponseTransform)[];
122
- transformRequest: ((d: any) => any)[];
123
+ transformRequest: ((data: any) => any)[];
123
124
  headers: {
124
125
  common: {
125
126
  Accept: string;
@@ -170,3 +171,10 @@ export function http(
170
171
  eventHandlers?: Record<string, EventListener>,
171
172
  uploadEventHandlers?: Record<string, EventListener>,
172
173
  ): void;
174
+ export const Http: Readonly<{
175
+ OK: 200;
176
+ MultipleChoices: 300;
177
+ BadRequest: 400;
178
+ NotFound: 404;
179
+ ErrorMax: 599;
180
+ }>;
@@ -94,10 +94,10 @@ export function parseAppUrl(url: string, html5Mode: boolean): void;
94
94
  * Returns `undefined` if `url` does not start with `base`.
95
95
  * @param {string} base
96
96
  * @param {string} url
97
- * @returns {string} returns text from `url` after `base` or `undefined` if it does not begin with
97
+ * @returns {string|undefined} returns text from `url` after `base` or `undefined` if it does not begin with
98
98
  * the expected string.
99
99
  */
100
- export function stripBaseUrl(base: string, url: string): string;
100
+ export function stripBaseUrl(base: string, url: string): string | undefined;
101
101
  /**
102
102
  * @ignore
103
103
  * Removes the hash fragment (including the '#') from the given URL string.
@@ -143,11 +143,11 @@ export function serverBase(url: string): string;
143
143
  * Determine if two URLs are equal despite potential differences in encoding,
144
144
  * trailing slashes, or empty hash fragments, such as between $location.absUrl() and $browser.url().
145
145
  *
146
- * @param {string} a - First URL to compare.
147
- * @param {string} b - Second URL to compare.
146
+ * @param {string} x - First URL to compare.
147
+ * @param {string} y - Second URL to compare.
148
148
  * @returns {boolean} True if URLs are equivalent after normalization.
149
149
  */
150
- export function urlsEqual(a: string, b: string): boolean;
150
+ export function urlsEqual(x: string, y: string): boolean;
151
151
  export class Location {
152
152
  /**
153
153
  * @param {string} appBase application base URL
@@ -321,7 +321,11 @@ export class LocationProvider {
321
321
  lastCachedState: any;
322
322
  $get: (
323
323
  | string
324
- | (($rootScope: ng.Scope, $rootElement: Element) => Location)
324
+ | ((
325
+ $rootScope: ng.Scope,
326
+ $rootElement: Element,
327
+ $exceptionHandler: ng.ExceptionHandlerService,
328
+ ) => Location)
325
329
  )[];
326
330
  #private;
327
331
  }
@@ -15,6 +15,7 @@ export class PubSubProvider {
15
15
  $get: () => PubSub;
16
16
  }
17
17
  export class PubSub {
18
+ static $nonscope: any;
18
19
  /**
19
20
  * Runs a function asynchronously.
20
21
  *
@@ -153,7 +154,7 @@ export class PubSub {
153
154
  * the order in which they were added, passing all arguments along.
154
155
  *
155
156
  * If this object was created with async=true, subscribed functions are called
156
- * via Promise.resolve(). Otherwise, the functions are called directly, and if
157
+ * via `queueMicrotask`. Otherwise, the functions are called directly, and if
157
158
  * any of them throw an uncaught error, publishing is aborted.
158
159
  *
159
160
  * @param {string} topic Topic to publish to.
@@ -0,0 +1,17 @@
1
+ export interface RestDefinition<T = any> {
2
+ name: string;
3
+ url: string;
4
+ /** Constructor for mapping JSON to class instance */
5
+ entityClass?: EntityClass<T>;
6
+ options?: Record<string, any>;
7
+ }
8
+ /**
9
+ * A constructor type for mapping JSON objects to entity instances
10
+ */
11
+ export interface EntityClass<T = any> {
12
+ /**
13
+ * Creates a new instance of the entity from a raw object
14
+ * @param data - Raw data (typically JSON) to map
15
+ */
16
+ new (data: any): T;
17
+ }