@angular-wave/angular.ts 0.11.0 → 0.12.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 (45) hide show
  1. package/@types/angular.d.ts +64 -51
  2. package/@types/animations/animate.d.ts +1 -351
  3. package/@types/animations/animation.d.ts +2 -2
  4. package/@types/animations/interface.d.ts +72 -0
  5. package/@types/animations/{animate-queue.d.ts → queue/animate-queue.d.ts} +2 -7
  6. package/@types/animations/queue/interface.d.ts +50 -0
  7. package/@types/core/compile/attributes.d.ts +5 -5
  8. package/@types/core/compile/compile.d.ts +4 -4
  9. package/@types/core/controller/controller.d.ts +1 -1
  10. package/@types/core/di/di.d.ts +26 -0
  11. package/@types/core/di/injector.d.ts +0 -11
  12. package/@types/core/di/internal-injector.d.ts +2 -2
  13. package/@types/core/di/ng-module/ng-module.d.ts +197 -0
  14. package/@types/core/sanitize/interface.d.ts +8 -0
  15. package/@types/core/sanitize/sanitize-uri.d.ts +5 -2
  16. package/@types/core/scope/interface.d.ts +2 -2
  17. package/@types/core/scope/scope.d.ts +5 -2
  18. package/@types/directive/form/form.d.ts +7 -7
  19. package/@types/directive/if/if.d.ts +2 -2
  20. package/@types/directive/include/include.d.ts +4 -4
  21. package/@types/directive/messages/messages.d.ts +18 -22
  22. package/@types/directive/model/model.d.ts +3 -3
  23. package/@types/directive/scope/scope.d.ts +4 -0
  24. package/@types/directive/show-hide/show-hide.d.ts +3 -4
  25. package/@types/directive/switch/switch.d.ts +3 -5
  26. package/@types/directive/wasm/wasm.d.ts +4 -0
  27. package/@types/{services → directive}/worker/interface.d.ts +1 -0
  28. package/@types/directive/worker/worker.d.ts +18 -8
  29. package/@types/interface.d.ts +14 -15
  30. package/@types/namespace.d.ts +25 -4
  31. package/@types/services/log/log.d.ts +2 -2
  32. package/@types/services/sce/sce.d.ts +4 -82
  33. package/@types/services/sse/sse.d.ts +1 -5
  34. package/@types/services/storage/interface.d.ts +5 -0
  35. package/@types/services/storage/storage.d.ts +19 -0
  36. package/@types/services/stream/interface.d.ts +18 -0
  37. package/@types/shared/dom.d.ts +21 -5
  38. package/@types/shared/strings.d.ts +0 -6
  39. package/@types/shared/utils.d.ts +24 -14
  40. package/dist/angular-ts.esm.js +1448 -1194
  41. package/dist/angular-ts.umd.js +1448 -1194
  42. package/dist/angular-ts.umd.min.js +1 -1
  43. package/package.json +1 -1
  44. package/@types/core/di/ng-module.d.ts +0 -156
  45. package/@types/services/worker/worker.d.ts +0 -31
@@ -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";
@@ -63,14 +64,13 @@ export type InjectableClass<TInstance = any> = new (...args: any) => TInstance;
63
64
  *
64
65
  * Parentheses are required around constructor types when used in unions.
65
66
  */
67
+ type FactoryFunction<T> = T extends abstract new (...args: any[]) => any
68
+ ? (...args: ConstructorParameters<T>) => InstanceType<T>
69
+ : T;
66
70
  export type Injectable<
67
71
  T extends ((...args: any[]) => any) | (abstract new (...args: any[]) => any),
68
72
  > =
69
- | AnnotatedFactory<
70
- T extends abstract new (...args: any[]) => any
71
- ? (...args: ConstructorParameters<T>) => InstanceType<T>
72
- : T
73
- >
73
+ | AnnotatedFactory<FactoryFunction<T>>
74
74
  | (T extends abstract new (...args: any[]) => any
75
75
  ? InjectableClass<InstanceType<T>>
76
76
  : never)
@@ -271,22 +271,22 @@ export type DirectiveController =
271
271
  /**
272
272
  * Represents a controller used within directive link functions.
273
273
  */
274
- export type TController = DirectiveController | NgModelController;
274
+ export type TController<T> = DirectiveController | NgModelController | T;
275
275
  /**
276
276
  * Defines optional pre/post link functions in directive compile phase.
277
277
  */
278
278
  export interface DirectivePrePost {
279
- pre?: DirectiveLinkFn;
280
- post?: DirectiveLinkFn;
279
+ pre?: DirectiveLinkFn<any>;
280
+ post?: DirectiveLinkFn<any>;
281
281
  }
282
282
  /**
283
283
  * A link function executed during directive linking.
284
284
  */
285
- export type DirectiveLinkFn = (
285
+ export type DirectiveLinkFn<T> = (
286
286
  scope: Scope,
287
287
  element: HTMLElement,
288
288
  attrs: Attributes & Record<string, any>,
289
- controller?: TController,
289
+ controller?: TController<T>,
290
290
  transclude?: (...args: any[]) => any,
291
291
  ) => void;
292
292
  /**
@@ -296,12 +296,11 @@ export type DirectiveCompileFn = (
296
296
  templateElement?: HTMLElement,
297
297
  templateAttributes?: Attributes & Record<string, any>,
298
298
  transclude?: (...args: any[]) => any,
299
- ) => void | DirectiveLinkFn | DirectivePrePost;
299
+ ) => void | DirectiveLinkFn<any> | DirectivePrePost;
300
300
  /**
301
301
  * Defines the structure of an AngularTS directive.
302
- * @typedef {Object} Directive
303
302
  */
304
- export interface Directive {
303
+ export interface Directive<TController = any> {
305
304
  /** Optional name (usually inferred) */
306
305
  name?: string;
307
306
  /** Restrict option: 'A' and/or 'E'. Defaults to 'EA' if not defined */
@@ -315,7 +314,7 @@ export interface Directive {
315
314
  /** Whether to bind scope to controller */
316
315
  bindToController?: boolean | Record<string, string>;
317
316
  /** Link function(s) executed during linking */
318
- link?: DirectiveLinkFn | DirectivePrePost;
317
+ link?: DirectiveLinkFn<TController> | DirectivePrePost;
319
318
  /** Priority of the directive */
320
319
  priority?: number;
321
320
  /** Stops further directive processing if true */
@@ -340,7 +339,7 @@ export interface Directive {
340
339
  }
341
340
  export type DirectiveFactoryFn = (
342
341
  ...args: any[]
343
- ) => Directive | DirectiveLinkFn;
342
+ ) => Directive | DirectiveLinkFn<any>;
344
343
  export type AnnotatedDirectiveFactory = Array<string | DirectiveFactoryFn>;
345
344
  export type DirectiveFactory = DirectiveFactoryFn | AnnotatedDirectiveFactory;
346
345
  /**
@@ -2,7 +2,11 @@ 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 { NgModule as TNgModule } from "./core/di/ng-module.js";
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,
@@ -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,23 @@ import {
55
60
  import {
56
61
  WorkerConnection as TWorkerConnection,
57
62
  WorkerConfig as TWorkerConfig,
58
- } from "./services/worker/interface.ts";
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 { StorageBackend as TStorageBackend } from "./services/storage/interface.ts";
68
+ import { StreamConnectionConfig as TStreamConnectionConfig } from "./services/stream/interface.ts";
61
69
  declare global {
62
70
  interface Function {
63
71
  $inject?: readonly string[] | undefined;
64
72
  }
73
+ interface Window {
74
+ angular: TAngular;
75
+ }
65
76
  export namespace ng {
66
77
  type Angular = TAngular;
67
78
  type Attributes = TAttributes & Record<string, any>;
68
- type Directive = TDirective;
79
+ type Directive<TController = any> = TDirective<TController>;
69
80
  type DirectiveFactory = TDirectiveFactory;
70
81
  type Component = TComponent;
71
82
  type Controller = TController;
@@ -86,6 +97,7 @@ declare global {
86
97
  type SceProvider = TSceProvider;
87
98
  type SceDelegateProvider = TSceDelegateProvider;
88
99
  type AnchorScrollService = TAnchorScrollService;
100
+ type AnimateService = TAnimateService;
89
101
  type CompileService = TCompileFn;
90
102
  type ControllerService = TControllerService;
91
103
  type ExceptionHandlerService = TErrorHandler;
@@ -107,9 +119,18 @@ declare global {
107
119
  type TemplateCacheService = Map<string, string>;
108
120
  type TemplateRequestService = TTemplateRequestService;
109
121
  type ErrorHandlingConfig = TErrorHandlingConfig;
110
- type WindowService = Window;
122
+ type ListenerFn = TListenerFn;
123
+ type Listener = TListener;
111
124
  type DocumentService = Document;
125
+ type WindowService = Window;
112
126
  type WorkerConfig = TWorkerConfig;
113
127
  type WorkerConnection = TWorkerConnection;
128
+ type Injectable<
129
+ T extends
130
+ | ((...args: any[]) => any)
131
+ | (abstract new (...args: any[]) => any),
132
+ > = TInjectable<T>;
133
+ type StorageBackend = TStorageBackend;
134
+ type StreamConnectionConfig = TStreamConnectionConfig;
114
135
  }
115
136
  }
@@ -19,7 +19,7 @@ export class LogProvider {
19
19
  */
20
20
  private consoleLog;
21
21
  /**
22
- * @returns {import("./interface.ts").LogService}
22
+ * @returns {ng.LogService}
23
23
  */
24
- $get(): import("./interface.ts").LogService;
24
+ $get(): ng.LogService;
25
25
  }
@@ -24,85 +24,7 @@ export namespace SCE_CONTEXTS {
24
24
  * `$sceDelegate` is a service that is used by the `$sce` service to provide {@link ng.$sce Strict
25
25
  * Contextual Escaping (SCE)} services to AngularTS.
26
26
  *
27
- * For an overview of this service and the functionnality it provides in AngularTS, see the main
28
- * page for {@link ng.$sce SCE}. The current page is targeted for developers who need to alter how
29
- * SCE works in their application, which shouldn't be needed in most cases.
30
- *
31
- * <div class="alert alert-danger">
32
- * AngularTS strongly relies on contextual escaping for the security of bindings: disabling or
33
- * modifying this might cause cross site scripting (XSS) vulnerabilities. For libraries owners,
34
- * changes to this service will also influence users, so be extra careful and document your changes.
35
- * </div>
36
- *
37
- * Typically, you would configure or override the {@link ng.$sceDelegate $sceDelegate} instead of
38
- * the `$sce` service to customize the way Strict Contextual Escaping works in AngularTS. This is
39
- * because, while the `$sce` provides numerous shorthand methods, etc., you really only need to
40
- * override 3 core functions (`trustAs`, `getTrusted` and `valueOf`) to replace the way things
41
- * work because `$sce` delegates to `$sceDelegate` for these operations.
42
- *
43
- * Refer {@link ng.$sceDelegateProvider $sceDelegateProvider} to configure this service.
44
- *
45
- * The default instance of `$sceDelegate` should work out of the box with little pain. While you
46
- * can override it completely to change the behavior of `$sce`, the common case would
47
- * involve configuring the {@link ng.$sceDelegateProvider $sceDelegateProvider} instead by setting
48
- * your own trusted and banned resource lists for trusting URLs used for loading AngularTS resources
49
- * such as templates. Refer {@link ng.$sceDelegateProvider#trustedResourceUrlList
50
- * $sceDelegateProvider.trustedResourceUrlList} and {@link
51
- * ng.$sceDelegateProvider#bannedResourceUrlList $sceDelegateProvider.bannedResourceUrlList}
52
- */
53
- /**
54
- *
55
- * The `$sceDelegateProvider` provider allows developers to configure the {@link ng.$sceDelegate
56
- * $sceDelegate service}, used as a delegate for {@link ng.$sce Strict Contextual Escaping (SCE)}.
57
- *
58
- * The `$sceDelegateProvider` allows one to get/set the `trustedResourceUrlList` and
59
- * `bannedResourceUrlList` used to ensure that the URLs used for sourcing AngularTS templates and
60
- * other script-running URLs are safe (all places that use the `$sce.RESOURCE_URL` context). See
61
- * {@link ng.$sceDelegateProvider#trustedResourceUrlList
62
- * $sceDelegateProvider.trustedResourceUrlList} and
63
- * {@link ng.$sceDelegateProvider#bannedResourceUrlList $sceDelegateProvider.bannedResourceUrlList},
64
- *
65
- * For the general details about this service in AngularTS, read the main page for {@link ng.$sce
66
- * Strict Contextual Escaping (SCE)}.
67
- *
68
- * **Example**: Consider the following case. <a name="example"></a>
69
- *
70
- * - your app is hosted at url `http://myapp.example.com/`
71
- * - but some of your templates are hosted on other domains you control such as
72
- * `http://srv01.assets.example.com/`, `http://srv02.assets.example.com/`, etc.
73
- * - and you have an open redirect at `http://myapp.example.com/clickThru?...`.
74
- *
75
- * Here is what a secure configuration for this scenario might look like:
76
- *
77
- * ```
78
- * angular.module('myApp', []).config(function($sceDelegateProvider) {
79
- * $sceDelegateProvider.trustedResourceUrlList([
80
- * // Allow same origin resource loads.
81
- * 'self',
82
- * // Allow loading from our assets domain. Notice the difference between * and **.
83
- * 'http://srv*.assets.example.com/**'
84
- * ]);
85
- *
86
- * // The banned resource URL list overrides the trusted resource URL list so the open redirect
87
- * // here is blocked.
88
- * $sceDelegateProvider.bannedResourceUrlList([
89
- * 'http://myapp.example.com/clickThru**'
90
- * ]);
91
- * });
92
- * ```
93
- * Note that an empty trusted resource URL list will block every resource URL from being loaded, and will require
94
- * you to manually mark each one as trusted with `$sce.trustAsResourceUrl`. However, templates
95
- * requested by {@link ng.$templateRequest $templateRequest} that are present in
96
- * {@link ng.$templateCache $templateCache} will not go through this check. If you have a mechanism
97
- * to populate your templates in that cache at config time, then it is a good idea to remove 'self'
98
- * from the trusted resource URL lsit. This helps to mitigate the security impact of certain types
99
- * of issues, like for instance attacker-controlled `ng-includes`.
100
- */
101
- /**
102
- * `$sceDelegate` is a service that is used by the `$sce` service to provide {@link ng.$sce Strict
103
- * Contextual Escaping (SCE)} services to AngularTS.
104
- *
105
- * For an overview of this service and the functionnality it provides in AngularTS, see the main
27
+ * For an overview of this service and the functionality it provides in AngularTS, see the main
106
28
  * page for {@link ng.$sce SCE}. The current page is targeted for developers who need to alter how
107
29
  * SCE works in their application, which shouldn't be needed in most cases.
108
30
  *
@@ -179,7 +101,7 @@ export namespace SCE_CONTEXTS {
179
101
  export class SceDelegateProvider {
180
102
  /**
181
103
  *
182
- * @param {Array=} trustedResourceUrlList When provided, replaces the trustedResourceUrlList with
104
+ * @param {Array=} value When provided, replaces the trustedResourceUrlList with
183
105
  * the value provided. This must be an array or null. A snapshot of this array is used so
184
106
  * further changes to the array are ignored.
185
107
  * Follow {@link ng.$sce#resourceUrlPatternItem this link} for a description of the items
@@ -198,7 +120,7 @@ export class SceDelegateProvider {
198
120
  * its origin with other apps! It is a good idea to limit it to only your application's directory.
199
121
  * </div>
200
122
  */
201
- trustedResourceUrlList: (value: any, ...args: any[]) => any[];
123
+ trustedResourceUrlList: (value?: any[] | undefined, ...args: any[]) => any[];
202
124
  /**
203
125
  *
204
126
  * @param {Array=} bannedResourceUrlList When provided, replaces the `bannedResourceUrlList` with
@@ -226,7 +148,7 @@ export class SceDelegateProvider {
226
148
  | string
227
149
  | ((
228
150
  $injector: ng.InjectorService,
229
- $$sanitizeUri: any,
151
+ $$sanitizeUri: import("../../core/sanitize/interface.ts").SanitizerFn,
230
152
  $exceptionHandler: ng.ExceptionHandlerService,
231
153
  ) => {
232
154
  trustAs: (type: string, trustedValue: any) => any;
@@ -17,11 +17,7 @@ export class SseProvider {
17
17
  * @type {ng.SseConfig}
18
18
  */
19
19
  defaults: ng.SseConfig;
20
- /**
21
- * Returns the $sse service function
22
- * @returns {ng.SseService}
23
- */
24
- $get: any[];
20
+ $get: (string | ((log: ng.LogService) => ng.SseService))[];
25
21
  $log: import("../log/interface.ts").LogService;
26
22
  #private;
27
23
  }
@@ -0,0 +1,5 @@
1
+ export interface StorageBackend {
2
+ get(key: string): string | undefined;
3
+ set(key: string, value: string): void;
4
+ remove(key: string): void;
5
+ }
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Creates a proxy that automatically persists an object's state
3
+ * into a storage backend whenever a property is set.
4
+ *
5
+ * @param {object} target - The object to wrap
6
+ * @param {string} key - The storage key
7
+ * @param {object} storage - Any storage-like object with getItem/setItem/removeItem
8
+ * @param {{serialize?: function, deserialize?: function}} [options] - Optional custom (de)serialization
9
+ * @returns {Proxy}
10
+ */
11
+ export function createPersistentProxy(
12
+ target: object,
13
+ key: string,
14
+ storage: object,
15
+ options?: {
16
+ serialize?: Function;
17
+ deserialize?: Function;
18
+ },
19
+ ): ProxyConstructor;
@@ -0,0 +1,18 @@
1
+ export interface StreamConnectionConfig {
2
+ /** Called when the connection opens */
3
+ onOpen?: (event: Event) => void;
4
+ /** Called when a message is received */
5
+ onMessage?: (data: any, event: Event) => void;
6
+ /** Called when an error occurs */
7
+ onError?: (err: any) => void;
8
+ /** Called when a reconnect attempt happens */
9
+ onReconnect?: (attempt: number) => void;
10
+ /** Delay between reconnect attempts in milliseconds */
11
+ retryDelay?: number;
12
+ /** Maximum number of reconnect attempts */
13
+ maxRetries?: number;
14
+ /** Timeout in milliseconds to detect heartbeat inactivity */
15
+ heartbeatTimeout?: number;
16
+ /** Function to transform incoming messages */
17
+ transformMessage?: (data: any) => any;
18
+ }
@@ -99,9 +99,9 @@ export function deleteCacheData(element: Element, key: string): void;
99
99
  * Gets scope for a given element.
100
100
  *
101
101
  * @param {Element} element - The DOM element to get data from.
102
- * @returns {*} - The retrieved data for the given key or all data if no key is provided.
102
+ * @returns {ng.Scope} - The retrieved data for the given key or all data if no key is provided.
103
103
  */
104
- export function getScope(element: Element): any;
104
+ export function getScope(element: Element): ng.Scope;
105
105
  /**
106
106
  * Set scope for a given element.
107
107
  *
@@ -233,10 +233,26 @@ export function emptyElement(element: Element): void;
233
233
  * @returns {boolean}
234
234
  */
235
235
  export function isRoot(element: Element): boolean;
236
+ /**
237
+ * Inserts a DOM element before or at the beginning of a parent element.
238
+ *
239
+ * @param {HTMLElement | Element} element
240
+ * The element to insert into the DOM.
241
+ *
242
+ * @param {HTMLElement | Element} parentElement
243
+ * The parent element that will receive the inserted element.
244
+ *
245
+ * @param {HTMLElement | Element | null} [afterElement]
246
+ * An optional sibling element — if present and valid, `element`
247
+ * will be inserted after it. If omitted or invalid, `element`
248
+ * is prepended to `parentElement`.
249
+ *
250
+ * @returns {void}
251
+ */
236
252
  export function domInsert(
237
- element: any,
238
- parentElement: any,
239
- afterElement: any,
253
+ element: HTMLElement | Element,
254
+ parentElement: HTMLElement | Element,
255
+ afterElement?: HTMLElement | Element | null,
240
256
  ): void;
241
257
  export function animatedomInsert(element: any, parent: any, after: any): void;
242
258
  /**
@@ -49,10 +49,4 @@ export function splitOnDelim(delim: any): (str: any) => any;
49
49
  * ```
50
50
  */
51
51
  export function joinNeighborsR(acc: any, x: any): any;
52
- export function beforeAfterSubstr(char: any): (str: any) => any[];
53
- export const hostRegex: RegExp;
54
52
  export function stripLastPathElement(str: any): any;
55
- export function splitHash(str: any): any[];
56
- export function splitQuery(str: any): any[];
57
- export function splitEqual(str: any): any[];
58
- export function trimHashVal(str: any): any;
@@ -208,19 +208,6 @@ export function isNumberNaN(num: any): boolean;
208
208
  */
209
209
  export function inherit(parent: any, extra: any): any;
210
210
  export function hasCustomToString(obj: any): boolean;
211
- /**
212
- * @module angular
213
- * @function isElement
214
-
215
- * @function
216
- *
217
- * @description
218
- * Determines if a reference is a DOM element (or wrapped jQuery element).
219
- *
220
- * @param {*} node Reference to check.
221
- * @returns {boolean} True if `value` is a DOM element (or wrapped jQuery element).
222
- */
223
- export function isElement(node: any): boolean;
224
211
  /**
225
212
  * Returns a string appropriate for the type of node.
226
213
  *
@@ -488,7 +475,18 @@ export function toDebugString(obj: any): any;
488
475
  * The resulting string key is in 'type:hashKey' format.
489
476
  */
490
477
  export function hashKey(obj: any): string;
491
- export function mergeClasses(a: any, b: any): any;
478
+ /**
479
+ * Merges two class name values into a single space-separated string.
480
+ * Accepts strings, arrays of strings, or null/undefined values.
481
+ *
482
+ * @param {string | string[] | null | undefined} a - The first class name(s).
483
+ * @param {string | string[] | null | undefined} b - The second class name(s).
484
+ * @returns {string} A single string containing all class names separated by spaces.
485
+ */
486
+ export function mergeClasses(
487
+ a: string | string[] | null | undefined,
488
+ b: string | string[] | null | undefined,
489
+ ): string;
492
490
  /**
493
491
  * Converts all accepted directives format into proper directive name.
494
492
  * @param {string} name Name to normalize
@@ -571,5 +569,17 @@ export function wait(t?: number): Promise<void>;
571
569
  * // returns false
572
570
  */
573
571
  export function startsWith(str: string, search: string): boolean;
572
+ /**
573
+ * Loads and instantiates a WebAssembly module.
574
+ * Tries streaming first, then falls back.
575
+ */
576
+ export function instantiateWasm(
577
+ src: any,
578
+ imports?: {},
579
+ ): Promise<{
580
+ instance: WebAssembly.Instance;
581
+ exports: WebAssembly.Exports;
582
+ module: WebAssembly.Module;
583
+ }>;
574
584
  export const isProxySymbol: unique symbol;
575
585
  export const ngAttrPrefixes: string[];