@angular-wave/angular.ts 0.9.9 → 0.10.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 (44) hide show
  1. package/@types/angular.d.ts +2 -2
  2. package/@types/animations/animate-js.d.ts +1 -1
  3. package/@types/animations/animate-queue.d.ts +0 -1
  4. package/@types/animations/animate-swap.d.ts +2 -4
  5. package/@types/animations/animate.d.ts +2 -2
  6. package/@types/animations/raf-scheduler.d.ts +4 -4
  7. package/@types/animations/shared.d.ts +30 -2
  8. package/@types/core/compile/attributes.d.ts +5 -8
  9. package/@types/core/compile/compile.d.ts +4 -4
  10. package/@types/core/controller/controller.d.ts +1 -1
  11. package/@types/core/di/ng-module.d.ts +14 -14
  12. package/@types/core/scope/interface.d.ts +18 -0
  13. package/@types/core/scope/scope.d.ts +16 -97
  14. package/@types/directive/aria/aria.d.ts +11 -13
  15. package/@types/directive/attrs/attrs.d.ts +2 -2
  16. package/@types/directive/events/events.d.ts +0 -2
  17. package/@types/directive/http/http.d.ts +4 -22
  18. package/@types/directive/if/if.d.ts +2 -4
  19. package/@types/directive/include/include.d.ts +2 -2
  20. package/@types/directive/messages/messages.d.ts +3 -3
  21. package/@types/directive/observe/observe.d.ts +2 -5
  22. package/@types/directive/worker/worker.d.ts +15 -0
  23. package/@types/interface.d.ts +5 -5
  24. package/@types/namespace.d.ts +7 -1
  25. package/@types/router/directives/view-directive.d.ts +2 -2
  26. package/@types/router/path/path-utils.d.ts +2 -2
  27. package/@types/router/state/state-object.d.ts +6 -6
  28. package/@types/router/state/state-service.d.ts +3 -3
  29. package/@types/router/transition/hook-builder.d.ts +1 -1
  30. package/@types/router/transition/interface.d.ts +1 -12
  31. package/@types/router/transition/transition-hook.d.ts +31 -0
  32. package/@types/router/transition/transition-service.d.ts +1 -1
  33. package/@types/router/transition/transition.d.ts +2 -2
  34. package/@types/services/pubsub/pubsub.d.ts +2 -2
  35. package/@types/services/sse/interface.d.ts +27 -1
  36. package/@types/services/sse/sse.d.ts +4 -3
  37. package/@types/services/worker/interface.d.ts +12 -0
  38. package/@types/services/worker/worker.d.ts +31 -0
  39. package/@types/shared/url-utils/url-utils.d.ts +14 -14
  40. package/README.md +1 -1
  41. package/dist/angular-ts.esm.js +1317 -1032
  42. package/dist/angular-ts.umd.js +1317 -1032
  43. package/dist/angular-ts.umd.min.js +1 -1
  44. package/package.json +1 -1
@@ -0,0 +1,15 @@
1
+ /**
2
+ * ngWorker directive factory
3
+ * Usage: <div ng-worker="workerName" data-params="{{ expression }}" data-on-result="callback($result)"></div>
4
+ */
5
+ export function ngWorkerDirective(
6
+ $worker: any,
7
+ $parse: any,
8
+ $log: any,
9
+ ): {
10
+ restrict: string;
11
+ link(scope: any, element: any, attrs: any): void;
12
+ };
13
+ export namespace ngWorkerDirective {
14
+ let $inject: string[];
15
+ }
@@ -256,7 +256,7 @@ export interface DirectivePrePost {
256
256
  export type DirectiveLinkFn = (
257
257
  scope: Scope,
258
258
  element: HTMLElement,
259
- attrs: Attributes,
259
+ attrs: Attributes & Record<string, any>,
260
260
  controller?: TController,
261
261
  transclude?: (...args: any[]) => any,
262
262
  ) => void;
@@ -264,9 +264,9 @@ export type DirectiveLinkFn = (
264
264
  * A compile function used to prepare directives before linking.
265
265
  */
266
266
  export type DirectiveCompileFn = (
267
- templateElement: HTMLElement,
268
- templateAttributes: Attributes,
269
- transclude: (...args: any[]) => any,
267
+ templateElement?: HTMLElement,
268
+ templateAttributes?: Attributes & Record<string, any>,
269
+ transclude?: (...args: any[]) => any,
270
270
  ) => void | DirectiveLinkFn | DirectivePrePost;
271
271
  /**
272
272
  * Defines the structure of an AngularTS directive.
@@ -275,7 +275,7 @@ export type DirectiveCompileFn = (
275
275
  export interface Directive {
276
276
  /** Optional name (usually inferred) */
277
277
  name?: string;
278
- /** Restrict option: 'A' and/or 'E'. Defaults to 'EA' */
278
+ /** Restrict option: 'A' and/or 'E'. Defaults to 'EA' if not defined */
279
279
  restrict?: string;
280
280
  /** Compile function for the directive */
281
281
  compile?: DirectiveCompileFn;
@@ -52,13 +52,17 @@ import {
52
52
  LinkFnMapping as TLinkFnMapping,
53
53
  CompositeLinkFn as TCompositeLinkFn,
54
54
  } from "./core/compile/inteface.ts";
55
+ import {
56
+ WorkerConnection as TWorkerConnection,
57
+ WorkerConfig as TWorkerConfig,
58
+ } from "./services/worker/interface.ts";
55
59
  declare global {
56
60
  interface Function {
57
61
  $inject?: readonly string[] | undefined;
58
62
  }
59
63
  export namespace ng {
60
64
  type Angular = TAngular;
61
- type Attributes = TAttributes;
65
+ type Attributes = TAttributes & Record<string, any>;
62
66
  type Directive = TDirective;
63
67
  type DirectiveFactory = TDirectiveFactory;
64
68
  type Component = TComponent;
@@ -101,5 +105,7 @@ declare global {
101
105
  type ErrorHandlingConfig = TErrorHandlingConfig;
102
106
  type WindowService = Window;
103
107
  type DocumentService = Document;
108
+ type WorkerConfig = TWorkerConfig;
109
+ type WorkerConnection = TWorkerConnection;
104
110
  }
105
111
  }
@@ -134,5 +134,5 @@ export namespace $ViewDirectiveFill {
134
134
  * });
135
135
  * ```
136
136
  */
137
- /** @type {import("../../interface.js").AnnotatedDirectiveFactory} */
138
- export let ngView: import("../../interface.js").AnnotatedDirectiveFactory;
137
+ /** @type {import("../../interface.ts").AnnotatedDirectiveFactory} */
138
+ export let ngView: import("../../interface.ts").AnnotatedDirectiveFactory;
@@ -37,13 +37,13 @@ export class PathUtils {
37
37
  * @param {PathNode[]} fromPath
38
38
  * @param {PathNode[]} toPath
39
39
  * @param {boolean} [reloadState]
40
- * @returns {import("../transition/interface.js").TreeChanges}
40
+ * @returns {import("../transition/interface.ts").TreeChanges}
41
41
  */
42
42
  static treeChanges(
43
43
  fromPath: PathNode[],
44
44
  toPath: PathNode[],
45
45
  reloadState?: boolean,
46
- ): import("../transition/interface.js").TreeChanges;
46
+ ): import("../transition/interface.ts").TreeChanges;
47
47
  /**
48
48
  * Returns a new path which is: the subpath of the first path which matches the second path.
49
49
  *
@@ -1,4 +1,4 @@
1
- /** @typedef {import('./interface.js').StateDeclaration} StateDeclaration */
1
+ /** @typedef {import('./interface.ts').StateDeclaration} StateDeclaration */
2
2
  /**
3
3
  * Internal representation of a ng-router state.
4
4
  *
@@ -12,9 +12,9 @@
12
12
  */
13
13
  export class StateObject implements StateDeclaration {
14
14
  /**
15
- * @param {import('./interface.js').StateDeclaration} config
15
+ * @param {import('./interface.ts').StateDeclaration} config
16
16
  */
17
- constructor(config: import("./interface.js").StateDeclaration);
17
+ constructor(config: import("./interface.ts").StateDeclaration);
18
18
  name: any;
19
19
  navigable: any;
20
20
  /** @type {?StateObject} */
@@ -24,9 +24,9 @@ export class StateObject implements StateDeclaration {
24
24
  includes: any;
25
25
  $$state: () => this;
26
26
  /**
27
- * @type {import('./interface.js').StateDeclaration}
27
+ * @type {import('./interface.ts').StateDeclaration}
28
28
  */
29
- self: import("./interface.js").StateDeclaration;
29
+ self: import("./interface.ts").StateDeclaration;
30
30
  __stateObjectCache: {
31
31
  nameGlob: Glob;
32
32
  };
@@ -79,5 +79,5 @@ export namespace StateObject {
79
79
  /** Predicate which returns true if the object is an internal [[StateObject]] object */
80
80
  function isState(obj: any): boolean;
81
81
  }
82
- export type StateDeclaration = import("./interface.js").StateDeclaration;
82
+ export type StateDeclaration = import("./interface.ts").StateDeclaration;
83
83
  import { Glob } from "../glob/glob.js";
@@ -27,7 +27,7 @@ export class StateProvider {
27
27
  *
28
28
  * @deprecated This is a passthrough through to [[Router.current]]
29
29
  */
30
- get current(): import("./interface.js").StateDeclaration;
30
+ get current(): import("./interface.ts").StateDeclaration;
31
31
  /**
32
32
  * The current [[StateObject]] (an internal API)
33
33
  *
@@ -134,9 +134,9 @@ export class StateProvider {
134
134
  decorator(name: string, func: object): object;
135
135
  /**
136
136
  *
137
- * @param {import("./interface.js").StateDeclaration} definition
137
+ * @param {import("./interface.ts").StateDeclaration} definition
138
138
  */
139
- state(definition: import("./interface.js").StateDeclaration): this;
139
+ state(definition: import("./interface.ts").StateDeclaration): this;
140
140
  /**
141
141
  * Handler for when [[transitionTo]] is called with an invalid state.
142
142
  *
@@ -45,4 +45,4 @@ export class HookBuilder {
45
45
  */
46
46
  getMatchingHooks(hookType: any, treeChanges: any, transition: any): any;
47
47
  }
48
- import { TransitionHookPhase } from "./interface.js";
48
+ import { TransitionHookPhase } from "./transition-hook.js";
@@ -5,6 +5,7 @@ import { StateObject } from "../state/state-object.js";
5
5
  import { PathNode } from "../path/path-node.js";
6
6
  import { TargetState } from "../state/target-state.js";
7
7
  import { RegisteredHook } from "./hook-registry.js";
8
+ import { TransitionHookScope } from "./transition-hook.js";
8
9
  /**
9
10
  * The TransitionOptions object can be used to change the behavior of a transition.
10
11
  *
@@ -866,15 +867,3 @@ export interface PathType {
866
867
  * Or, `true` to always match
867
868
  */
868
869
  export type HookMatchCriterion = string | IStateMatch | boolean;
869
- declare enum TransitionHookPhase {
870
- CREATE = 0,
871
- BEFORE = 1,
872
- RUN = 2,
873
- SUCCESS = 3,
874
- ERROR = 4,
875
- }
876
- declare enum TransitionHookScope {
877
- TRANSITION = 0,
878
- STATE = 1,
879
- }
880
- export { TransitionHookPhase, TransitionHookScope };
@@ -1,3 +1,34 @@
1
+ /**
2
+ * Enum representing the different phases of a transition hook.
3
+ */
4
+ export type TransitionHookPhase = number;
5
+ /**
6
+ * Enum representing the different phases of a transition hook.
7
+ *
8
+ * @readonly
9
+ * @enum {number}
10
+ */
11
+ export const TransitionHookPhase: Readonly<{
12
+ CREATE: 0;
13
+ BEFORE: 1;
14
+ RUN: 2;
15
+ SUCCESS: 3;
16
+ ERROR: 4;
17
+ }>;
18
+ /**
19
+ * Enum representing the scope in which a transition hook operates.
20
+ */
21
+ export type TransitionHookScope = number;
22
+ /**
23
+ * Enum representing the scope in which a transition hook operates.
24
+ *
25
+ * @readonly
26
+ * @enum {number}
27
+ */
28
+ export const TransitionHookScope: Readonly<{
29
+ TRANSITION: 0;
30
+ STATE: 1;
31
+ }>;
1
32
  export class TransitionHook {
2
33
  /**
3
34
  * Chains together an array of TransitionHooks.
@@ -117,4 +117,4 @@ export class TransitionProvider {
117
117
  _registerCoreTransitionHooks(): void;
118
118
  }
119
119
  import { Transition } from "./transition.js";
120
- import { TransitionHookPhase } from "./interface.js";
120
+ import { TransitionHookPhase } from "./transition-hook.js";
@@ -47,7 +47,7 @@ export class Transition implements IHookRegistry {
47
47
  _targetState: import("../state/target-state.js").TargetState;
48
48
  _options: any;
49
49
  $id: number;
50
- _treeChanges: import("./interface.js").TreeChanges;
50
+ _treeChanges: import("./interface.ts").TreeChanges;
51
51
  onStart: any;
52
52
  onBefore: any;
53
53
  onSuccess: any;
@@ -251,7 +251,7 @@ export class Transition implements IHookRegistry {
251
251
  pathname: any,
252
252
  ):
253
253
  | import("../path/path-node.js").PathNode[]
254
- | import("./interface.js").TreeChanges;
254
+ | import("./interface.ts").TreeChanges;
255
255
  /**
256
256
  * Creates a new transition that is a redirection of the current one.
257
257
  *
@@ -1,4 +1,4 @@
1
- /** @typedef {import('../../interface.js').ServiceProvider} ServiceProvider
1
+ /** @typedef {import('../../interface.ts').ServiceProvider} ServiceProvider
2
2
 
3
3
  /**
4
4
  * Configurable provider for an injectable event bus
@@ -182,4 +182,4 @@ export const EventBus: PubSub;
182
182
  * /**
183
183
  * Configurable provider for an injectable event bus
184
184
  */
185
- export type ServiceProvider = import("../../interface.js").ServiceProvider;
185
+ export type ServiceProvider = import("../../interface.ts").ServiceProvider;
@@ -2,15 +2,41 @@
2
2
  * Configuration object for SSE
3
3
  */
4
4
  export interface SseConfig {
5
+ /** Include cookies/credentials when connecting */
5
6
  withCredentials?: boolean;
7
+ /** Custom headers (Note: EventSource doesn't natively support headers; handled at app level if needed) */
6
8
  headers?: Record<string, string>;
9
+ /** Called when the connection is successfully opened */
7
10
  onOpen?: (event: Event) => void;
11
+ /** Called when a message event is received */
8
12
  onMessage?: (data: any, event: MessageEvent) => void;
13
+ /** Called on connection error */
9
14
  onError?: (err: Event) => void;
15
+ /** Transform raw SSE message data (default: JSON.parse if possible) */
10
16
  transformMessage?: (data: string) => any;
17
+ /** Optional query parameters appended to the URL */
11
18
  params?: Record<string, any>;
19
+ /** Called when the connection is being re-established */
20
+ onReconnect?: (attempt: number) => void;
21
+ /** Delay in milliseconds before attempting to reconnect (default: 1000ms) */
22
+ retryDelay?: number;
23
+ /** Maximum number of reconnect attempts (default: Infinity) */
24
+ maxRetries?: number;
25
+ /** Heartbeat timeout in milliseconds; reconnect if no message within this time */
26
+ heartbeatTimeout?: number;
27
+ }
28
+ /**
29
+ * Managed SSE connection object returned by $sse.
30
+ * Provides a safe way to close the connection and stop reconnection attempts.
31
+ */
32
+ export interface SseConnection {
33
+ /** Manually close the SSE connection and stop all reconnect attempts */
34
+ close(): void;
35
+ /** Manually restart the SSE connection */
36
+ connect(): void;
12
37
  }
13
38
  /**
14
39
  * $sse service type
40
+ * Returns a managed SSE connection that automatically reconnects when needed.
15
41
  */
16
- export type SseService = (url: string, config?: SseConfig) => EventSource;
42
+ export type SseService = (url: string, config?: SseConfig) => SseConnection;
@@ -5,10 +5,10 @@
5
5
  * const source = $sse('/events', {
6
6
  * onMessage: (data) => console.log(data),
7
7
  * onError: (err) => console.error(err),
8
- * withCredentials: true
8
+ * retryDelay: 2000,
9
+ * heartbeatTimeout: 10000,
9
10
  * });
10
11
  *
11
- * // later:
12
12
  * source.close();
13
13
  */
14
14
  export class SseProvider {
@@ -21,6 +21,7 @@ export class SseProvider {
21
21
  * Returns the $sse service function
22
22
  * @returns {ng.SseService}
23
23
  */
24
- $get: () => ng.SseService;
24
+ $get: any[];
25
+ $log: import("../log/interface.ts").LogService;
25
26
  #private;
26
27
  }
@@ -0,0 +1,12 @@
1
+ export interface WorkerConfig {
2
+ onMessage?: (data: any, event: MessageEvent) => void;
3
+ onError?: (err: ErrorEvent) => void;
4
+ autoRestart?: boolean;
5
+ autoTerminate?: boolean;
6
+ transformMessage?: (data: any) => any;
7
+ }
8
+ export interface WorkerConnection {
9
+ post(data: any): void;
10
+ terminate(): void;
11
+ restart(): void;
12
+ }
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Worker Provider
3
+ *
4
+ * Usage:
5
+ * const worker = $worker('./math.worker.js', {
6
+ * onMessage: (data) => console.log('Result:', data),
7
+ * onError: (err) => console.error('Worker error:', err),
8
+ * autoTerminate: false,
9
+ * transformMessage: (d) => d,
10
+ * });
11
+ *
12
+ * worker.post({ action: 'fib', n: 20 });
13
+ * worker.terminate();
14
+ */
15
+ export class WorkerProvider {
16
+ /**
17
+ * @type {ng.LogService}
18
+ */
19
+ $log: ng.LogService;
20
+ /**
21
+ * Optional provider-level defaults
22
+ * @type {ng.WorkerConfig}
23
+ */
24
+ defaults: ng.WorkerConfig;
25
+ /**
26
+ * Returns the $worker service function
27
+ * @returns {ng.WorkerService}
28
+ */
29
+ $get: any[];
30
+ #private;
31
+ }
@@ -1,20 +1,20 @@
1
1
  /**
2
- * @param {import("./interface.js").ResolvableUrl} url
3
- * @return {import("./interface.js").ParsedUrl}
2
+ * @param {import("./interface.ts").ResolvableUrl} url
3
+ * @return {import("./interface.ts").ParsedUrl}
4
4
  */
5
5
  export function urlResolve(
6
- url: import("./interface.js").ResolvableUrl,
7
- ): import("./interface.js").ParsedUrl;
6
+ url: import("./interface.ts").ResolvableUrl,
7
+ ): import("./interface.ts").ParsedUrl;
8
8
  /**
9
9
  * Parse a request URL and determine whether this is a same-origin request as the application
10
10
  * document.
11
11
  *
12
- * @param {import("./interface.js").ResolvableUrl} requestUrl The url of the request as a string that will be resolved
12
+ * @param {import("./interface.ts").ResolvableUrl} requestUrl The url of the request as a string that will be resolved
13
13
  * or a parsed URL object.
14
14
  * @returns {boolean} Whether the request is for the same origin as the application document.
15
15
  */
16
16
  export function urlIsSameOrigin(
17
- requestUrl: import("./interface.js").ResolvableUrl,
17
+ requestUrl: import("./interface.ts").ResolvableUrl,
18
18
  ): boolean;
19
19
  /**
20
20
  * Parse a request URL and determine whether it is same-origin as the current document base URL.
@@ -22,12 +22,12 @@ export function urlIsSameOrigin(
22
22
  * Note: The base URL is usually the same as the document location (`location.href`) but can
23
23
  * be overriden by using the `<base>` tag.
24
24
  *
25
- * @param {import("./interface.js").ResolvableUrl} requestUrl The url of the request as a string that will be resolved
25
+ * @param {import("./interface.ts").ResolvableUrl} requestUrl The url of the request as a string that will be resolved
26
26
  * or a parsed URL object.
27
27
  * @returns {boolean} Whether the URL is same-origin as the document base URL.
28
28
  */
29
29
  export function urlIsSameOriginAsBaseUrl(
30
- requestUrl: import("./interface.js").ResolvableUrl,
30
+ requestUrl: import("./interface.ts").ResolvableUrl,
31
31
  ): boolean;
32
32
  /**
33
33
  * Create a function that can check a URL's origin against a list of allowed/trusted origins.
@@ -35,25 +35,25 @@ export function urlIsSameOriginAsBaseUrl(
35
35
  *
36
36
  * @param {string[]} trustedOriginUrls - A list of URLs (strings), whose origins are trusted.
37
37
  *
38
- * @returns {(url: import("./interface.js").ResolvableUrl) => boolean } - A function that receives a URL (string or parsed URL object) and returns
38
+ * @returns {(url: import("./interface.ts").ResolvableUrl) => boolean } - A function that receives a URL (string or parsed URL object) and returns
39
39
  * whether it is of an allowed origin.
40
40
  */
41
41
  export function urlIsAllowedOriginFactory(
42
42
  trustedOriginUrls: string[],
43
- ): (url: import("./interface.js").ResolvableUrl) => boolean;
43
+ ): (url: import("./interface.ts").ResolvableUrl) => boolean;
44
44
  /**
45
45
  * Determine if two URLs share the same origin.
46
46
  *
47
- * @param {import("./interface.js").ResolvableUrl} url1 - First URL to compare as a string or a normalized URL in the form of
47
+ * @param {import("./interface.ts").ResolvableUrl} url1 - First URL to compare as a string or a normalized URL in the form of
48
48
  * a dictionary object returned by `urlResolve()`.
49
- * @param {import("./interface.js").ResolvableUrl} url2 - Second URL to compare as a string or a normalized URL in the form
49
+ * @param {import("./interface.ts").ResolvableUrl} url2 - Second URL to compare as a string or a normalized URL in the form
50
50
  * of a dictionary object returned by `urlResolve()`.
51
51
  *
52
52
  * @returns {boolean} - True if both URLs have the same origin, and false otherwise.
53
53
  */
54
54
  export function urlsAreSameOrigin(
55
- url1: import("./interface.js").ResolvableUrl,
56
- url2: import("./interface.js").ResolvableUrl,
55
+ url1: import("./interface.ts").ResolvableUrl,
56
+ url2: import("./interface.ts").ResolvableUrl,
57
57
  ): boolean;
58
58
  /**
59
59
  * Removes a trailing hash ('#') from the given URL if it exists.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  ## AngularTS
2
2
 
3
- ![Build status](https://github.com/angular-qave/angular.ts/actions/workflows/ci.yml/badge.svg)
3
+ ![Build status](https://github.com/angular-wave/angular.ts/actions/workflows/ci.yml/badge.svg)
4
4
  [![stats](https://data.jsdelivr.com/v1/package/npm/@angular-wave/angular.ts/badge?style=rounded)](https://www.jsdelivr.com/package/npm/@angular-wave/angular.ts)
5
5
 
6
6
  This project preserves, modernises and expands the original [AngularJS](https://angularjs.org/)