@angular-wave/angular.ts 0.11.0 → 0.13.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.
- package/@types/angular.d.ts +66 -53
- package/@types/animations/animate.d.ts +1 -351
- package/@types/animations/animation.d.ts +2 -2
- package/@types/animations/interface.d.ts +72 -0
- package/@types/animations/{animate-queue.d.ts → queue/animate-queue.d.ts} +2 -7
- package/@types/animations/queue/interface.d.ts +50 -0
- package/@types/animations/raf-scheduler.d.ts +1 -3
- package/@types/core/compile/attributes.d.ts +6 -6
- package/@types/core/compile/compile.d.ts +6 -6
- package/@types/core/controller/controller.d.ts +1 -1
- package/@types/core/di/di.d.ts +26 -0
- package/@types/core/di/injector.d.ts +0 -11
- package/@types/core/di/internal-injector.d.ts +2 -2
- package/@types/core/di/ng-module/ng-module.d.ts +209 -0
- package/@types/core/sanitize/interface.d.ts +8 -0
- package/@types/core/sanitize/sanitize-uri.d.ts +5 -2
- package/@types/core/scope/interface.d.ts +2 -2
- package/@types/core/scope/scope.d.ts +5 -2
- package/@types/directive/bind/bind.d.ts +2 -2
- package/@types/directive/form/form.d.ts +7 -7
- package/@types/directive/if/if.d.ts +2 -2
- package/@types/directive/include/include.d.ts +8 -8
- package/@types/directive/messages/messages.d.ts +18 -22
- package/@types/directive/model/model.d.ts +17 -17
- package/@types/directive/options/options.d.ts +4 -4
- package/@types/directive/scope/scope.d.ts +4 -0
- package/@types/directive/show-hide/show-hide.d.ts +3 -4
- package/@types/directive/switch/switch.d.ts +3 -5
- package/@types/directive/wasm/wasm.d.ts +4 -0
- package/@types/{services → directive}/worker/interface.d.ts +1 -0
- package/@types/directive/worker/worker.d.ts +18 -8
- package/@types/interface.d.ts +76 -15
- package/@types/namespace.d.ts +49 -6
- package/@types/router/url/url-service.d.ts +1 -4
- package/@types/services/cookie/cookie.d.ts +78 -0
- package/@types/services/cookie/interface.d.ts +12 -0
- package/@types/services/exception/exception.d.ts +56 -0
- package/@types/services/exception/interface.d.ts +2 -3
- package/@types/services/log/log.d.ts +2 -2
- package/@types/services/rest/interface.d.ts +17 -0
- package/@types/services/rest/rest.d.ts +110 -0
- package/@types/services/rest/rfc.d.ts +40 -0
- package/@types/services/sce/sce.d.ts +4 -82
- package/@types/services/sse/sse.d.ts +1 -5
- package/@types/services/storage/interface.d.ts +6 -0
- package/@types/services/storage/storage.d.ts +19 -0
- package/@types/services/stream/interface.d.ts +18 -0
- package/@types/shared/dom.d.ts +27 -14
- package/@types/shared/strings.d.ts +0 -6
- package/@types/shared/utils.d.ts +27 -14
- package/README.md +3 -90
- package/dist/angular-ts.esm.js +2539 -1542
- package/dist/angular-ts.umd.js +2539 -1542
- package/dist/angular-ts.umd.min.js +1 -1
- package/package.json +1 -1
- package/@types/core/di/ng-module.d.ts +0 -156
- package/@types/services/exception/exception-handler.d.ts +0 -58
- package/@types/services/worker/worker.d.ts +0 -31
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @param {
|
|
3
|
-
* @returns {
|
|
2
|
+
* @param {ng.AnimateService} $animate
|
|
3
|
+
* @returns {ng.Directive}
|
|
4
4
|
*/
|
|
5
|
-
export function ngSwitchDirective(
|
|
6
|
-
$animate: any,
|
|
7
|
-
): import("../../interface.ts").Directive;
|
|
5
|
+
export function ngSwitchDirective($animate: ng.AnimateService): ng.Directive;
|
|
8
6
|
export namespace ngSwitchDirective {
|
|
9
7
|
let $inject: string[];
|
|
10
8
|
}
|
|
@@ -1,15 +1,25 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* ngWorker directive factory
|
|
3
2
|
* Usage: <div ng-worker="workerName" data-params="{{ expression }}" data-on-result="callback($result)"></div>
|
|
3
|
+
*
|
|
4
|
+
* @param {ng.ParseService} $parse
|
|
5
|
+
* @param {ng.LogService} $log
|
|
6
|
+
* @returns {ng.Directive}
|
|
4
7
|
*/
|
|
5
8
|
export function ngWorkerDirective(
|
|
6
|
-
$
|
|
7
|
-
$
|
|
8
|
-
|
|
9
|
-
): {
|
|
10
|
-
restrict: string;
|
|
11
|
-
link(scope: any, element: any, attrs: any): void;
|
|
12
|
-
};
|
|
9
|
+
$parse: ng.ParseService,
|
|
10
|
+
$log: ng.LogService,
|
|
11
|
+
): ng.Directive;
|
|
13
12
|
export namespace ngWorkerDirective {
|
|
14
13
|
let $inject: string[];
|
|
15
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* Creates a managed Web Worker connection.
|
|
17
|
+
*
|
|
18
|
+
* @param {string | URL} scriptPath
|
|
19
|
+
* @param {ng.WorkerConfig} [config]
|
|
20
|
+
* @returns {ng.WorkerConnection}
|
|
21
|
+
*/
|
|
22
|
+
export function createWorkerConnection(
|
|
23
|
+
scriptPath: string | URL,
|
|
24
|
+
config?: ng.WorkerConfig,
|
|
25
|
+
): ng.WorkerConnection;
|
package/@types/interface.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export * from "./animations/interface.ts";
|
|
1
2
|
export * from "./services/http/interface.ts";
|
|
2
3
|
export * from "./services/log/interface.ts";
|
|
3
4
|
export * from "./services/log/log.js";
|
|
@@ -9,6 +10,11 @@ export * from "./index.js";
|
|
|
9
10
|
export * from "./angular.js";
|
|
10
11
|
export * from "./core/di/internal-injector.js";
|
|
11
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";
|
|
12
18
|
import { Attributes } from "./core/compile/attributes.js";
|
|
13
19
|
import { Scope } from "./core/scope/scope.js";
|
|
14
20
|
/**
|
|
@@ -63,18 +69,23 @@ export type InjectableClass<TInstance = any> = new (...args: any) => TInstance;
|
|
|
63
69
|
*
|
|
64
70
|
* Parentheses are required around constructor types when used in unions.
|
|
65
71
|
*/
|
|
72
|
+
export type FactoryFunction<T> = T extends abstract new (...args: any[]) => any
|
|
73
|
+
? (...args: ConstructorParameters<T>) => InstanceType<T>
|
|
74
|
+
: T;
|
|
66
75
|
export type Injectable<
|
|
67
76
|
T extends ((...args: any[]) => any) | (abstract new (...args: any[]) => any),
|
|
68
77
|
> =
|
|
69
|
-
| AnnotatedFactory<
|
|
70
|
-
T extends abstract new (...args: any[]) => any
|
|
71
|
-
? (...args: ConstructorParameters<T>) => InstanceType<T>
|
|
72
|
-
: T
|
|
73
|
-
>
|
|
78
|
+
| AnnotatedFactory<FactoryFunction<T>>
|
|
74
79
|
| (T extends abstract new (...args: any[]) => any
|
|
75
80
|
? InjectableClass<InstanceType<T>>
|
|
76
81
|
: never)
|
|
77
82
|
| T;
|
|
83
|
+
export interface ServiceProviderClass {
|
|
84
|
+
new (...args: any[]): ServiceProvider;
|
|
85
|
+
}
|
|
86
|
+
export interface ServiceProviderFactory {
|
|
87
|
+
(...args: any[]): ServiceProvider;
|
|
88
|
+
}
|
|
78
89
|
/**
|
|
79
90
|
* An object that defines how a service is constructed.
|
|
80
91
|
*
|
|
@@ -163,6 +174,57 @@ export interface ChangesObject<T = any> {
|
|
|
163
174
|
* Mapping of binding property names to their change metadata.
|
|
164
175
|
*/
|
|
165
176
|
export type OnChangesObject = Record<string, ChangesObject>;
|
|
177
|
+
/**
|
|
178
|
+
* Interface for the $onInit lifecycle hook
|
|
179
|
+
* https://docs.angularjs.org/api/ng/service/$compile#life-cycle-hooks
|
|
180
|
+
*/
|
|
181
|
+
export interface OnInit {
|
|
182
|
+
/**
|
|
183
|
+
* Called on each controller after all the controllers on an element have been constructed and had their bindings
|
|
184
|
+
* initialized (and before the pre & post linking functions for the directives on this element). This is a good
|
|
185
|
+
* place to put initialization code for your controller.
|
|
186
|
+
*/
|
|
187
|
+
$onInit(): void;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Interface for the $onChanges lifecycle hook
|
|
191
|
+
* https://docs.angularjs.org/api/ng/service/$compile#life-cycle-hooks
|
|
192
|
+
*/
|
|
193
|
+
export interface OnChanges {
|
|
194
|
+
/**
|
|
195
|
+
* Called whenever one-way bindings are updated. The onChangesObj is a hash whose keys are the names of the bound
|
|
196
|
+
* properties that have changed, and the values are an {@link IChangesObject} object of the form
|
|
197
|
+
* { currentValue, previousValue, isFirstChange() }. Use this hook to trigger updates within a component such as
|
|
198
|
+
* cloning the bound value to prevent accidental mutation of the outer value.
|
|
199
|
+
*/
|
|
200
|
+
$onChanges(onChangesObj: OnChangesObject): void;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Interface for the $onDestroy lifecycle hook
|
|
204
|
+
* https://docs.angularjs.org/api/ng/service/$compile#life-cycle-hooks
|
|
205
|
+
*/
|
|
206
|
+
export interface OnDestroy {
|
|
207
|
+
/**
|
|
208
|
+
* Called on a controller when its containing scope is destroyed. Use this hook for releasing external resources,
|
|
209
|
+
* watches and event handlers.
|
|
210
|
+
*/
|
|
211
|
+
$onDestroy(): void;
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Interface for the $postLink lifecycle hook
|
|
215
|
+
* https://docs.angularjs.org/api/ng/service/$compile#life-cycle-hooks
|
|
216
|
+
*/
|
|
217
|
+
export interface PostLink {
|
|
218
|
+
/**
|
|
219
|
+
* Called after this controller's element and its children have been linked. Similar to the post-link function this
|
|
220
|
+
* hook can be used to set up DOM event handlers and do direct DOM manipulation. Note that child elements that contain
|
|
221
|
+
* templateUrl directives will not have been compiled and linked since they are waiting for their template to load
|
|
222
|
+
* asynchronously and their own compilation and linking has been suspended until that occurs. This hook can be considered
|
|
223
|
+
* analogous to the ngAfterViewInit and ngAfterContentInit hooks in Angular 2. Since the compilation process is rather
|
|
224
|
+
* different in Angular 1 there is no direct mapping and care should be taken when upgrading.
|
|
225
|
+
*/
|
|
226
|
+
$postLink(): void;
|
|
227
|
+
}
|
|
166
228
|
/**
|
|
167
229
|
* AngularTS component lifecycle interface.
|
|
168
230
|
* Directive controllers have a well-defined lifecycle. Each controller can implement "lifecycle hooks". These are methods that
|
|
@@ -271,22 +333,22 @@ export type DirectiveController =
|
|
|
271
333
|
/**
|
|
272
334
|
* Represents a controller used within directive link functions.
|
|
273
335
|
*/
|
|
274
|
-
export type TController = DirectiveController | NgModelController;
|
|
336
|
+
export type TController<T> = DirectiveController | NgModelController | T;
|
|
275
337
|
/**
|
|
276
338
|
* Defines optional pre/post link functions in directive compile phase.
|
|
277
339
|
*/
|
|
278
340
|
export interface DirectivePrePost {
|
|
279
|
-
pre?: DirectiveLinkFn
|
|
280
|
-
post?: DirectiveLinkFn
|
|
341
|
+
pre?: DirectiveLinkFn<any>;
|
|
342
|
+
post?: DirectiveLinkFn<any>;
|
|
281
343
|
}
|
|
282
344
|
/**
|
|
283
345
|
* A link function executed during directive linking.
|
|
284
346
|
*/
|
|
285
|
-
export type DirectiveLinkFn = (
|
|
347
|
+
export type DirectiveLinkFn<T> = (
|
|
286
348
|
scope: Scope,
|
|
287
349
|
element: HTMLElement,
|
|
288
350
|
attrs: Attributes & Record<string, any>,
|
|
289
|
-
controller?: TController
|
|
351
|
+
controller?: TController<T>,
|
|
290
352
|
transclude?: (...args: any[]) => any,
|
|
291
353
|
) => void;
|
|
292
354
|
/**
|
|
@@ -296,12 +358,11 @@ export type DirectiveCompileFn = (
|
|
|
296
358
|
templateElement?: HTMLElement,
|
|
297
359
|
templateAttributes?: Attributes & Record<string, any>,
|
|
298
360
|
transclude?: (...args: any[]) => any,
|
|
299
|
-
) => void | DirectiveLinkFn | DirectivePrePost;
|
|
361
|
+
) => void | DirectiveLinkFn<any> | DirectivePrePost;
|
|
300
362
|
/**
|
|
301
363
|
* Defines the structure of an AngularTS directive.
|
|
302
|
-
* @typedef {Object} Directive
|
|
303
364
|
*/
|
|
304
|
-
export interface Directive {
|
|
365
|
+
export interface Directive<TController = any> {
|
|
305
366
|
/** Optional name (usually inferred) */
|
|
306
367
|
name?: string;
|
|
307
368
|
/** Restrict option: 'A' and/or 'E'. Defaults to 'EA' if not defined */
|
|
@@ -315,7 +376,7 @@ export interface Directive {
|
|
|
315
376
|
/** Whether to bind scope to controller */
|
|
316
377
|
bindToController?: boolean | Record<string, string>;
|
|
317
378
|
/** Link function(s) executed during linking */
|
|
318
|
-
link?: DirectiveLinkFn | DirectivePrePost;
|
|
379
|
+
link?: DirectiveLinkFn<TController> | DirectivePrePost;
|
|
319
380
|
/** Priority of the directive */
|
|
320
381
|
priority?: number;
|
|
321
382
|
/** Stops further directive processing if true */
|
|
@@ -340,7 +401,7 @@ export interface Directive {
|
|
|
340
401
|
}
|
|
341
402
|
export type DirectiveFactoryFn = (
|
|
342
403
|
...args: any[]
|
|
343
|
-
) => Directive | DirectiveLinkFn
|
|
404
|
+
) => Directive | DirectiveLinkFn<any>;
|
|
344
405
|
export type AnnotatedDirectiveFactory = Array<string | DirectiveFactoryFn>;
|
|
345
406
|
export type DirectiveFactory = DirectiveFactoryFn | AnnotatedDirectiveFactory;
|
|
346
407
|
/**
|
package/@types/namespace.d.ts
CHANGED
|
@@ -2,14 +2,18 @@ export { angular } from "./index.js";
|
|
|
2
2
|
import { Angular as TAngular } from "./angular.js";
|
|
3
3
|
import { Attributes as TAttributes } from "./core/compile/attributes.js";
|
|
4
4
|
import { Scope as TScope } from "./core/scope/scope.js";
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
ListenerFn as TListenerFn,
|
|
7
|
+
Listener as TListener,
|
|
8
|
+
} from "./core/scope/interface.ts";
|
|
9
|
+
import { NgModule as TNgModule } from "./core/di/ng-module/ng-module.js";
|
|
6
10
|
import { InjectorService as TInjectorService } from "./core/di/internal-injector.js";
|
|
7
11
|
import {
|
|
8
12
|
AnchorScrollProvider as TAnchorScrollProvider,
|
|
9
13
|
AnchorScrollService as TAnchorScrollService,
|
|
10
14
|
} from "./services/anchor-scroll/anchor-scroll.js";
|
|
11
15
|
import { ControllerService as TControllerService } from "./core/controller/interface.ts";
|
|
12
|
-
import {
|
|
16
|
+
import { ExceptionHandler as TExceptionHandler } from "./services/exception/interface.ts";
|
|
13
17
|
import { ParseService as TParseService } from "./core/parse/interface.ts";
|
|
14
18
|
import { TemplateRequestService as TTemplateRequestService } from "./services/template-request/interface.ts";
|
|
15
19
|
import { HttpParamSerializer as THttpParamSerializer } from "./services/http/interface.ts";
|
|
@@ -36,6 +40,7 @@ import {
|
|
|
36
40
|
DirectiveFactory as TDirectiveFactory,
|
|
37
41
|
Component as TComponent,
|
|
38
42
|
Controller as TController,
|
|
43
|
+
Injectable as TInjectable,
|
|
39
44
|
} from "./interface.ts";
|
|
40
45
|
import {
|
|
41
46
|
SseService as TSseService,
|
|
@@ -55,17 +60,37 @@ import {
|
|
|
55
60
|
import {
|
|
56
61
|
WorkerConnection as TWorkerConnection,
|
|
57
62
|
WorkerConfig as TWorkerConfig,
|
|
58
|
-
} from "./
|
|
63
|
+
} from "./directive/worker/interface.ts";
|
|
59
64
|
import { Provider as TProvideService } from "./interface.ts";
|
|
60
65
|
import { Location as TLocationService } from "./services/location/location.js";
|
|
66
|
+
import { AnimateService as TAnimateService } from "./animations/interface.ts";
|
|
67
|
+
import {
|
|
68
|
+
StorageBackend as TStorageBackend,
|
|
69
|
+
StorageType as TStorageType,
|
|
70
|
+
} from "./services/storage/interface.ts";
|
|
71
|
+
import { StreamConnectionConfig as TStreamConnectionConfig } from "./services/stream/interface.ts";
|
|
72
|
+
import { CookieService as TCookieService } from "./services/cookie/cookie.js";
|
|
73
|
+
import {
|
|
74
|
+
CookieStoreOptions as TCookieStoreOptions,
|
|
75
|
+
CookieOptions as TCookieOptions,
|
|
76
|
+
} from "./services/cookie/interface.ts";
|
|
77
|
+
import {
|
|
78
|
+
RestDefinition as TRestDefinition,
|
|
79
|
+
EntityClass as TEntityClass,
|
|
80
|
+
} from "./services/rest/interface.ts";
|
|
81
|
+
import { RestService as TRestService } from "./services/rest/rest.js";
|
|
82
|
+
import { ServiceProvider as TServiceProvider } from "./interface.ts";
|
|
61
83
|
declare global {
|
|
62
84
|
interface Function {
|
|
63
85
|
$inject?: readonly string[] | undefined;
|
|
64
86
|
}
|
|
87
|
+
interface Window {
|
|
88
|
+
angular: TAngular;
|
|
89
|
+
}
|
|
65
90
|
export namespace ng {
|
|
66
91
|
type Angular = TAngular;
|
|
67
92
|
type Attributes = TAttributes & Record<string, any>;
|
|
68
|
-
type Directive = TDirective
|
|
93
|
+
type Directive<TController = any> = TDirective<TController>;
|
|
69
94
|
type DirectiveFactory = TDirectiveFactory;
|
|
70
95
|
type Component = TComponent;
|
|
71
96
|
type Controller = TController;
|
|
@@ -86,9 +111,11 @@ declare global {
|
|
|
86
111
|
type SceProvider = TSceProvider;
|
|
87
112
|
type SceDelegateProvider = TSceDelegateProvider;
|
|
88
113
|
type AnchorScrollService = TAnchorScrollService;
|
|
114
|
+
type AnimateService = TAnimateService;
|
|
89
115
|
type CompileService = TCompileFn;
|
|
90
116
|
type ControllerService = TControllerService;
|
|
91
|
-
type
|
|
117
|
+
type CookieService = TCookieService;
|
|
118
|
+
type ExceptionHandlerService = TExceptionHandler;
|
|
92
119
|
type FilterService = TFilterFactory;
|
|
93
120
|
type HttpParamSerializerSerService = THttpParamSerializer;
|
|
94
121
|
type HttpService = THttpService;
|
|
@@ -107,9 +134,25 @@ declare global {
|
|
|
107
134
|
type TemplateCacheService = Map<string, string>;
|
|
108
135
|
type TemplateRequestService = TTemplateRequestService;
|
|
109
136
|
type ErrorHandlingConfig = TErrorHandlingConfig;
|
|
110
|
-
type
|
|
137
|
+
type ListenerFn = TListenerFn;
|
|
138
|
+
type Listener = TListener;
|
|
111
139
|
type DocumentService = Document;
|
|
140
|
+
type WindowService = Window;
|
|
112
141
|
type WorkerConfig = TWorkerConfig;
|
|
113
142
|
type WorkerConnection = TWorkerConnection;
|
|
143
|
+
type Injectable<
|
|
144
|
+
T extends
|
|
145
|
+
| ((...args: any[]) => any)
|
|
146
|
+
| (abstract new (...args: any[]) => any),
|
|
147
|
+
> = TInjectable<T>;
|
|
148
|
+
type StorageBackend = TStorageBackend;
|
|
149
|
+
type StorageType = TStorageType;
|
|
150
|
+
type StreamConnectionConfig = TStreamConnectionConfig;
|
|
151
|
+
type CookieOptions = TCookieOptions;
|
|
152
|
+
type CookieStoreOptions = TCookieStoreOptions;
|
|
153
|
+
type RestService<T, ID> = TRestService<T, ID>;
|
|
154
|
+
type RestDefinition<T> = TRestDefinition<T>;
|
|
155
|
+
type EntityClass<T> = TEntityClass<T>;
|
|
156
|
+
type ServiceProvider = TServiceProvider;
|
|
114
157
|
}
|
|
115
158
|
}
|
|
@@ -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}
|
|
@@ -0,0 +1,78 @@
|
|
|
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
|
+
*/
|
|
38
|
+
get(key: string): string | null;
|
|
39
|
+
/**
|
|
40
|
+
* Retrieves a cookie and deserializes its JSON content.
|
|
41
|
+
*
|
|
42
|
+
* @template T
|
|
43
|
+
* @param {string} key
|
|
44
|
+
* @returns {T|null}
|
|
45
|
+
* @throws {SyntaxError} if cookie JSON is invalid
|
|
46
|
+
*/
|
|
47
|
+
getObject<T>(key: string): T | null;
|
|
48
|
+
/**
|
|
49
|
+
* Returns an object containing all raw cookies.
|
|
50
|
+
*
|
|
51
|
+
* @returns {Record<string, string>}
|
|
52
|
+
*/
|
|
53
|
+
getAll(): Record<string, string>;
|
|
54
|
+
/**
|
|
55
|
+
* Sets a raw cookie value.
|
|
56
|
+
*
|
|
57
|
+
* @param {string} key
|
|
58
|
+
* @param {string} value
|
|
59
|
+
* @param {ng.CookieOptions} [options]
|
|
60
|
+
*/
|
|
61
|
+
put(key: string, value: string, options?: ng.CookieOptions): void;
|
|
62
|
+
/**
|
|
63
|
+
* Serializes an object as JSON and stores it as a cookie.
|
|
64
|
+
*
|
|
65
|
+
* @param {string} key
|
|
66
|
+
* @param {any} value
|
|
67
|
+
* @param {ng.CookieOptions} [options]
|
|
68
|
+
* @throws {TypeError} if Object cannot be converted to JSON
|
|
69
|
+
*/
|
|
70
|
+
putObject(key: string, value: any, options?: ng.CookieOptions): void;
|
|
71
|
+
/**
|
|
72
|
+
* Removes a cookie by setting an expired date.
|
|
73
|
+
*
|
|
74
|
+
* @param {string} key
|
|
75
|
+
* @param {ng.CookieOptions} [options]
|
|
76
|
+
*/
|
|
77
|
+
remove(key: string, options?: ng.CookieOptions): void;
|
|
78
|
+
}
|
|
@@ -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,6 @@
|
|
|
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.
|
|
6
5
|
*/
|
|
7
|
-
export type
|
|
6
|
+
export type ExceptionHandler = (exception: Error) => void;
|
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @template T, ID
|
|
3
|
+
*/
|
|
4
|
+
export class RestService<T, ID> {
|
|
5
|
+
static $nonscope: boolean;
|
|
6
|
+
/**
|
|
7
|
+
* Core REST service for CRUD operations.
|
|
8
|
+
* Safe, predictable, and optionally maps raw JSON to entity class instances.
|
|
9
|
+
*
|
|
10
|
+
* @param {ng.HttpService} $http Angular-like $http service
|
|
11
|
+
* @param {string} baseUrl Base URL or URI template
|
|
12
|
+
* @param {{new(data: any): T}=} entityClass Optional constructor to map JSON to objects
|
|
13
|
+
* @param {Object=} options Optional settings (interceptors, headers, etc.)
|
|
14
|
+
*/
|
|
15
|
+
constructor(
|
|
16
|
+
$http: ng.HttpService,
|
|
17
|
+
baseUrl: string,
|
|
18
|
+
entityClass?:
|
|
19
|
+
| {
|
|
20
|
+
new (data: any): T;
|
|
21
|
+
}
|
|
22
|
+
| undefined,
|
|
23
|
+
options?: any | undefined,
|
|
24
|
+
);
|
|
25
|
+
/** @private */
|
|
26
|
+
private $http;
|
|
27
|
+
/** @private */
|
|
28
|
+
private baseUrl;
|
|
29
|
+
/** @private */
|
|
30
|
+
private entityClass;
|
|
31
|
+
/** @private */
|
|
32
|
+
private options;
|
|
33
|
+
/**
|
|
34
|
+
* Build full URL from template and parameters
|
|
35
|
+
* @param {string} template
|
|
36
|
+
* @param {Record<string, any>} params
|
|
37
|
+
* @returns {string}
|
|
38
|
+
*/
|
|
39
|
+
buildUrl(template: string, params: Record<string, any>): string;
|
|
40
|
+
/**
|
|
41
|
+
* List entities
|
|
42
|
+
* @param {Record<string, any>=} params
|
|
43
|
+
* @returns {Promise<T[]>}
|
|
44
|
+
*/
|
|
45
|
+
list(params?: Record<string, any> | undefined): Promise<T[]>;
|
|
46
|
+
/**
|
|
47
|
+
* Read single entity by ID
|
|
48
|
+
* @param {ID} id
|
|
49
|
+
* @param {Record<string, any>=} params
|
|
50
|
+
* @returns {Promise<T|null>}
|
|
51
|
+
*/
|
|
52
|
+
read(id: ID, params?: Record<string, any> | undefined): Promise<T | null>;
|
|
53
|
+
/**
|
|
54
|
+
* Create a new entity
|
|
55
|
+
* @param {T} item
|
|
56
|
+
* @returns {Promise<T>}
|
|
57
|
+
*/
|
|
58
|
+
create(item: T): Promise<T>;
|
|
59
|
+
/**
|
|
60
|
+
* Update entity by ID
|
|
61
|
+
* @param {ID} id
|
|
62
|
+
* @param {Partial<T>} item
|
|
63
|
+
* @returns {Promise<T|null>}
|
|
64
|
+
*/
|
|
65
|
+
update(id: ID, item: Partial<T>): Promise<T | null>;
|
|
66
|
+
/**
|
|
67
|
+
* Delete entity by ID
|
|
68
|
+
* @param {ID} id
|
|
69
|
+
* @returns {Promise<boolean>}
|
|
70
|
+
*/
|
|
71
|
+
delete(id: ID): Promise<boolean>;
|
|
72
|
+
#private;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Provider for registering REST endpoints during module configuration.
|
|
76
|
+
*/
|
|
77
|
+
export class RestProvider {
|
|
78
|
+
/** @private @type {ng.RestDefinition<any>[]} */
|
|
79
|
+
private definitions;
|
|
80
|
+
/**
|
|
81
|
+
* Register a REST resource at config phase
|
|
82
|
+
* @template T
|
|
83
|
+
* @param {string} name Service name
|
|
84
|
+
* @param {string} url Base URL or URI template
|
|
85
|
+
* @param {{new(data:any):T}=} entityClass Optional entity constructor
|
|
86
|
+
* @param {Object=} options Optional service options
|
|
87
|
+
*/
|
|
88
|
+
rest<T>(
|
|
89
|
+
name: string,
|
|
90
|
+
url: string,
|
|
91
|
+
entityClass?:
|
|
92
|
+
| {
|
|
93
|
+
new (data: any): T;
|
|
94
|
+
}
|
|
95
|
+
| undefined,
|
|
96
|
+
options?: any | undefined,
|
|
97
|
+
): void;
|
|
98
|
+
/**
|
|
99
|
+
* $get factory: returns a factory function and allows access to named services
|
|
100
|
+
* @returns {(baseUrl:string, entityClass?:Function, options?:object) => RestService & { get(name:string): RestService, listNames(): string[] }}
|
|
101
|
+
*/
|
|
102
|
+
$get: (
|
|
103
|
+
| string
|
|
104
|
+
| (($http: any) => {
|
|
105
|
+
(baseUrl: any, entityClass: any, options?: {}): RestService<any, any>;
|
|
106
|
+
get(name: any): any;
|
|
107
|
+
listNames(): any[];
|
|
108
|
+
})
|
|
109
|
+
)[];
|
|
110
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RFC 6570 Level 4 URI Template expander
|
|
3
|
+
*
|
|
4
|
+
* Supports operators: (none), +, #, ., /, ;, ?, &
|
|
5
|
+
* Supports varspec modifiers: explode (*) and prefix (:len)
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* expandUriTemplate("/users/{id}", { id: 10 }) === "/users/10"
|
|
9
|
+
* expandUriTemplate("/search{?q,lang}", { q: "a b", lang: "en" }) === "/search?q=a%20b&lang=en"
|
|
10
|
+
* expandUriTemplate("/repos/{owner}/{repo}/issues{?labels*}", { labels: ["bug","ui"] }) === "/repos/x/y/issues?labels=bug&labels=ui"
|
|
11
|
+
*
|
|
12
|
+
* @param {string} template
|
|
13
|
+
* @param {Object<string, any>} vars
|
|
14
|
+
* @returns {string}
|
|
15
|
+
*/
|
|
16
|
+
export function expandUriTemplate(
|
|
17
|
+
template: string,
|
|
18
|
+
vars?: {
|
|
19
|
+
[x: string]: any;
|
|
20
|
+
},
|
|
21
|
+
): string;
|
|
22
|
+
/**
|
|
23
|
+
* Helper: percent-encode a string. If allowReserved true, reserved chars are NOT encoded.
|
|
24
|
+
* @param {string} str
|
|
25
|
+
* @param {boolean} allowReserved
|
|
26
|
+
* @returns {string}
|
|
27
|
+
*/
|
|
28
|
+
export function pctEncode(str: string, allowReserved: boolean): string;
|
|
29
|
+
/**
|
|
30
|
+
* Parse and expand a single expression (content between { and }).
|
|
31
|
+
* @param {string} expression
|
|
32
|
+
* @param {Object<string, any>} vars
|
|
33
|
+
* @returns {string}
|
|
34
|
+
*/
|
|
35
|
+
export function expandExpression(
|
|
36
|
+
expression: string,
|
|
37
|
+
vars: {
|
|
38
|
+
[x: string]: any;
|
|
39
|
+
},
|
|
40
|
+
): string;
|