@ngxs/store 3.8.2-dev.master-09bece1 → 3.8.2-dev.master-b0e24dd

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 (113) hide show
  1. package/index.d.ts +609 -6
  2. package/internals/index.d.ts +196 -9
  3. package/internals/testing/index.d.ts +28 -4
  4. package/operators/index.d.ts +101 -13
  5. package/package.json +1 -1
  6. package/plugins/index.d.ts +62 -3
  7. package/internals/custom-rxjs-subjects.d.ts +0 -42
  8. package/internals/initial-state.d.ts +0 -8
  9. package/internals/internal-tokens.d.ts +0 -3
  10. package/internals/memoize.d.ts +0 -9
  11. package/internals/metadata.d.ts +0 -25
  12. package/internals/ngxs-app-bootstrapped-state.d.ts +0 -8
  13. package/internals/state-stream.d.ts +0 -15
  14. package/internals/state-token.d.ts +0 -7
  15. package/internals/symbols.d.ts +0 -80
  16. package/internals/testing/fresh-platform.d.ts +0 -1
  17. package/internals/testing/helpers/ngxs-test.component.d.ts +0 -8
  18. package/internals/testing/helpers/ngxs-test.module.d.ts +0 -10
  19. package/internals/testing/ngxs.setup.d.ts +0 -7
  20. package/internals/testing/skip-console-logging.d.ts +0 -1
  21. package/internals/testing/symbol.d.ts +0 -14
  22. package/operators/append.d.ts +0 -5
  23. package/operators/compose.d.ts +0 -2
  24. package/operators/iif.d.ts +0 -10
  25. package/operators/insert-item.d.ts +0 -6
  26. package/operators/patch.d.ts +0 -7
  27. package/operators/remove-item.d.ts +0 -6
  28. package/operators/types.d.ts +0 -56
  29. package/operators/update-item.d.ts +0 -9
  30. package/operators/utils.d.ts +0 -8
  31. package/plugins/actions.d.ts +0 -15
  32. package/plugins/symbols.d.ts +0 -13
  33. package/plugins/utils.d.ts +0 -29
  34. package/schematics/src/actions/actions.factory.d.ts +0 -3
  35. package/schematics/src/ng-add/add-declaration.d.ts +0 -4
  36. package/schematics/src/ng-add/ng-add.factory.d.ts +0 -9
  37. package/schematics/src/starter-kit/starter-kit.factory.d.ts +0 -3
  38. package/schematics/src/state/state.factory.d.ts +0 -3
  39. package/schematics/src/store/store.factory.d.ts +0 -3
  40. package/schematics/src/utils/common/lib.config.d.ts +0 -10
  41. package/schematics/src/utils/common/project-files.config.d.ts +0 -3
  42. package/schematics/src/utils/common/properties.d.ts +0 -1
  43. package/schematics/src/utils/config.d.ts +0 -119
  44. package/schematics/src/utils/generate-utils.d.ts +0 -4
  45. package/schematics/src/utils/interfaces/package.interface.d.ts +0 -7
  46. package/schematics/src/utils/ng-utils/ast-utils.d.ts +0 -99
  47. package/schematics/src/utils/ng-utils/ng-ast-utils.d.ts +0 -5
  48. package/schematics/src/utils/ng-utils/project.d.ts +0 -2
  49. package/schematics/src/utils/ng-utils/standalone/app_config.d.ts +0 -16
  50. package/schematics/src/utils/ng-utils/standalone/code_block.d.ts +0 -46
  51. package/schematics/src/utils/ng-utils/standalone/index.d.ts +0 -1
  52. package/schematics/src/utils/ng-utils/standalone/rules.d.ts +0 -38
  53. package/schematics/src/utils/ng-utils/standalone/util.d.ts +0 -28
  54. package/schematics/src/utils/normalize-options.d.ts +0 -9
  55. package/schematics/src/utils/project.d.ts +0 -16
  56. package/src/actions/symbols.d.ts +0 -7
  57. package/src/actions-stream.d.ts +0 -37
  58. package/src/configs/messages.config.d.ts +0 -13
  59. package/src/decorators/action.d.ts +0 -6
  60. package/src/decorators/select/select-factory.d.ts +0 -16
  61. package/src/decorators/select/select.d.ts +0 -4
  62. package/src/decorators/select/symbols.d.ts +0 -9
  63. package/src/decorators/selector/selector.d.ts +0 -10
  64. package/src/decorators/selector/symbols.d.ts +0 -3
  65. package/src/decorators/selector-options.d.ts +0 -5
  66. package/src/decorators/state.d.ts +0 -5
  67. package/src/dev-features/ngxs-development.module.d.ts +0 -10
  68. package/src/dev-features/ngxs-unhandled-actions-logger.d.ts +0 -17
  69. package/src/dev-features/symbols.d.ts +0 -8
  70. package/src/execution/dispatch-outside-zone-ngxs-execution-strategy.d.ts +0 -14
  71. package/src/execution/internal-ngxs-execution-strategy.d.ts +0 -10
  72. package/src/execution/noop-ngxs-execution-strategy.d.ts +0 -8
  73. package/src/execution/symbols.d.ts +0 -16
  74. package/src/internal/dispatcher.d.ts +0 -36
  75. package/src/internal/error-handler.d.ts +0 -26
  76. package/src/internal/internals.d.ts +0 -105
  77. package/src/internal/lifecycle-state-manager.d.ts +0 -26
  78. package/src/internal/state-context-factory.d.ts +0 -18
  79. package/src/internal/state-factory.d.ts +0 -60
  80. package/src/internal/state-operations.d.ts +0 -21
  81. package/src/internal/state-operators.d.ts +0 -2
  82. package/src/ivy/ivy-enabled-in-dev-mode.d.ts +0 -6
  83. package/src/module.d.ts +0 -13
  84. package/src/modules/ngxs-feature.module.d.ts +0 -10
  85. package/src/modules/ngxs-root.module.d.ts +0 -10
  86. package/src/operators/leave-ngxs.d.ts +0 -7
  87. package/src/operators/of-action.d.ts +0 -56
  88. package/src/plugin-manager.d.ts +0 -13
  89. package/src/plugin_api.d.ts +0 -1
  90. package/src/private_api.d.ts +0 -2
  91. package/src/public_api.d.ts +0 -21
  92. package/src/selectors/create-model-selector.d.ts +0 -10
  93. package/src/selectors/create-pick-selector.d.ts +0 -6
  94. package/src/selectors/create-property-selectors.d.ts +0 -5
  95. package/src/selectors/create-selector.d.ts +0 -19
  96. package/src/selectors/index.d.ts +0 -5
  97. package/src/selectors/selector-checks.util.d.ts +0 -9
  98. package/src/selectors/selector-metadata.d.ts +0 -7
  99. package/src/selectors/selector-models.d.ts +0 -10
  100. package/src/selectors/selector-types.util.d.ts +0 -6
  101. package/src/selectors/selector-utils.d.ts +0 -9
  102. package/src/standalone-features/feature-providers.d.ts +0 -7
  103. package/src/standalone-features/index.d.ts +0 -3
  104. package/src/standalone-features/initializers.d.ts +0 -29
  105. package/src/standalone-features/plugin.d.ts +0 -17
  106. package/src/standalone-features/provide-states.d.ts +0 -18
  107. package/src/standalone-features/provide-store.d.ts +0 -22
  108. package/src/standalone-features/root-providers.d.ts +0 -8
  109. package/src/store.d.ts +0 -60
  110. package/src/symbols.d.ts +0 -102
  111. package/src/utils/compose.d.ts +0 -23
  112. package/src/utils/freeze.d.ts +0 -5
  113. package/src/utils/store-validators.d.ts +0 -5
@@ -1,7 +0,0 @@
1
- import { NgxsOptionsTesting, NgxsTesting } from './symbol';
2
- export declare class NgxsTestBed {
3
- static configureTestingStates(options: NgxsOptionsTesting): NgxsTesting;
4
- private static ngxsBootstrap;
5
- private static resetTestBed;
6
- private static createRootNode;
7
- }
@@ -1 +0,0 @@
1
- export declare function skipConsoleLogging<T extends (...args: any[]) => any>(fn: T): ReturnType<T>;
@@ -1,14 +0,0 @@
1
- import { NgxsModuleOptions, Store } from '@ngxs/store';
2
- import { ModuleWithProviders } from '@angular/core';
3
- import { TestBedStatic } from '@angular/core/testing';
4
- import { ɵStateClass } from '@ngxs/store/internals';
5
- export interface NgxsOptionsTesting {
6
- states?: ɵStateClass[];
7
- ngxsOptions?: NgxsModuleOptions;
8
- imports?: ModuleWithProviders<any>[];
9
- before?: () => void;
10
- }
11
- export interface NgxsTesting {
12
- store: Store;
13
- getTestBed: TestBedStatic;
14
- }
@@ -1,5 +0,0 @@
1
- import { NoInfer, StateOperator } from './types';
2
- /**
3
- * @param items - Specific items to append to the end of an array
4
- */
5
- export declare function append<T>(items: NoInfer<T[]>): StateOperator<T[]>;
@@ -1,2 +0,0 @@
1
- import { NoInfer, StateOperator } from './types';
2
- export declare function compose<T>(...operators: NoInfer<StateOperator<T>[]>): StateOperator<T>;
@@ -1,10 +0,0 @@
1
- import { NoInfer, StateOperator } from './types';
2
- import { Predicate } from './utils';
3
- /**
4
- * @param condition - Condition can be a plain boolean value or a function,
5
- * that returns boolean, also this function can take a value as an argument
6
- * to which this state operator applies
7
- * @param trueOperatorOrValue - Any value or a state operator
8
- * @param elseOperatorOrValue - Any value or a state operator
9
- */
10
- export declare function iif<T>(condition: NoInfer<Predicate<T>> | boolean, trueOperatorOrValue: NoInfer<StateOperator<T> | T>, elseOperatorOrValue?: NoInfer<StateOperator<T> | T>): StateOperator<T>;
@@ -1,6 +0,0 @@
1
- import { NoInfer, StateOperator } from './types';
2
- /**
3
- * @param value - Value to insert
4
- * @param [beforePosition] - Specified index to insert value before, optional
5
- */
6
- export declare function insertItem<T>(value: NoInfer<T>, beforePosition?: number): StateOperator<T[]>;
@@ -1,7 +0,0 @@
1
- import { NoInfer, StateOperator } from './types';
2
- type NotUndefined<T> = T extends undefined ? never : T;
3
- export type ɵPatchSpec<T> = {
4
- [P in keyof T]?: T[P] | StateOperator<NotUndefined<T[P]>>;
5
- };
6
- export declare function patch<T extends Record<string, any>>(patchObject: NoInfer<ɵPatchSpec<T>>): StateOperator<T>;
7
- export {};
@@ -1,6 +0,0 @@
1
- import { NoInfer, StateOperator } from './types';
2
- import { Predicate } from './utils';
3
- /**
4
- * @param selector - index or predicate to remove an item from an array by
5
- */
6
- export declare function removeItem<T>(selector: number | NoInfer<Predicate<T>>): StateOperator<T[]>;
@@ -1,56 +0,0 @@
1
- type _NoInfer<T> = T extends infer S ? S : never;
2
- /**
3
- * Blocks the ability of the typescript inferrence engine to be able to use the provided type as part of
4
- * inferring any type parameters from this usage.
5
- * @example
6
- * Primarily used to wrap parameters of functions in order to prevent the TypeScript inferrence engine
7
- * from inferring a type parameter of the function from the value provided to this parameter.
8
- * This essentially blocks the Contravariance of the function (through its parameters) so that the
9
- * function type parameter is purely determined by the Covariant requirements of the function's return type.
10
- * This is key to creating `StateOperator`s that are typed based on their contextual usage and not on the arguments
11
- * provided to them. This is critical for type safety and intellisense for State Operators.
12
- * Here is an example of how this benefits a state operator:
13
- * ```ts
14
- * declare function append<T>(items: NoInfer<T[]>): StateOperator<T[]>;
15
- * declare function appendBad<T>(items: T[]): StateOperator<T[]>;
16
- *
17
- * interface AAA {
18
- * foo?: boolean;
19
- * bar?: boolean;
20
- * }
21
- *
22
- * // Works
23
- * // (T in append is correctly inferred as AAA)
24
- * patch<{ test: AAA[] }>({ test: append([{ foo: true }]) });
25
- *
26
- * // Incorrectly throws: Type 'AAA' is not assignable to type '{ foo: true; }'.ts(2322)
27
- * // (T in appendBad is incorrectly inferred as { foo: true; })
28
- * patch<{ test: AAA[] }>({ test: appendBad([{ foo: true }]) });
29
- * ```
30
- *
31
- */
32
- export type NoInfer<T> = T extends (infer O)[] ? _NoInfer<O>[] : _NoInfer<T>;
33
- /**
34
- * IMPORTANT NOTE: This should not be used externally to the library, rather
35
- * the exported type `ExistingState<T>` should be used instead.
36
- *
37
- * Used to convert a type to its readonly form. This can be given any type, from
38
- * primitives to objects or arrays that could already be readonly or not.
39
- * This does not apply the readonly construct to nested objects, but only to the top level type.
40
- */
41
- type ɵAsReadonly<T> = T extends Readonly<infer O> ? (O extends T ? Readonly<T> : T) : T;
42
- /**
43
- * Represents the existing state that is passed into a `StateOperator` which should
44
- * not be modified but will be used to build the new state returned by the `StateOperator`.
45
- */
46
- export type ExistingState<T> = T extends any ? ɵAsReadonly<T> : never;
47
- /**
48
- * This is a monotype unary function that is used to create a new state from an existing state.
49
- * A state operator is usually created by a function that is given some data
50
- * to integrate with the state and returns a state operator which integrates this data or instruction.
51
- *
52
- * In state management terminology this creator function is commonly referred to as a state operator
53
- * because it represents the operation to be performed. ie. `patch`, `append`, `insertItem`, `compose`, `iif`, etc.
54
- */
55
- export type StateOperator<T> = (existing: ExistingState<T>) => T;
56
- export {};
@@ -1,9 +0,0 @@
1
- import { NoInfer, StateOperator } from './types';
2
- import { Predicate } from './utils';
3
- /**
4
- * @param selector - Index of item in the array or a predicate function
5
- * that can be provided in `Array.prototype.findIndex`
6
- * @param operatorOrValue - New value under the `selector` index or a
7
- * function that can be applied to an existing value
8
- */
9
- export declare function updateItem<T>(selector: number | NoInfer<Predicate<T>>, operatorOrValue: NoInfer<T> | NoInfer<StateOperator<T>>): StateOperator<T[]>;
@@ -1,8 +0,0 @@
1
- import { StateOperator } from './types';
2
- export type Predicate<T = any> = (value: T | Readonly<T>) => boolean;
3
- export declare function isStateOperator<T>(value: T | StateOperator<T>): value is StateOperator<T>;
4
- export declare function isUndefined(value: any): value is undefined;
5
- export declare function isPredicate<T>(value: Predicate<T> | boolean | number): value is Predicate<T>;
6
- export declare function isNumber(value: any): value is number;
7
- export declare function invalidIndex(index: number): boolean;
8
- export declare function isNil<T>(value: T | null | undefined): value is null | undefined;
@@ -1,15 +0,0 @@
1
- import { ɵPlainObject } from '@ngxs/store/internals';
2
- /**
3
- * Init action
4
- */
5
- export declare class InitState {
6
- static readonly type = "@@INIT";
7
- }
8
- /**
9
- * Update action
10
- */
11
- export declare class UpdateState {
12
- readonly addedStates?: ɵPlainObject | undefined;
13
- static readonly type = "@@UPDATE_STATE";
14
- constructor(addedStates?: ɵPlainObject | undefined);
15
- }
@@ -1,13 +0,0 @@
1
- import { InjectionToken } from '@angular/core';
2
- export declare const NGXS_PLUGINS: InjectionToken<unknown>;
3
- export type NgxsPluginFn = (state: any, mutation: any, next: NgxsNextPluginFn) => any;
4
- export type NgxsNextPluginFn = (state: any, mutation: any) => any;
5
- /**
6
- * Plugin interface
7
- */
8
- export interface NgxsPlugin {
9
- /**
10
- * Handle the state/action before its submitted to the state handlers.
11
- */
12
- handle(state: any, action: any, next: NgxsNextPluginFn): any;
13
- }
@@ -1,29 +0,0 @@
1
- /**
2
- * Returns the type from an action instance/class.
3
- * @ignore
4
- */
5
- export declare function getActionTypeFromInstance(action: any): string | undefined;
6
- /**
7
- * Matches a action
8
- * @ignore
9
- */
10
- export declare function actionMatcher(action1: any): (action2: any) => boolean;
11
- /**
12
- * Set a deeply nested value. Example:
13
- *
14
- * setValue({ foo: { bar: { eat: false } } },
15
- * 'foo.bar.eat', true) //=> { foo: { bar: { eat: true } } }
16
- *
17
- * While it traverses it also creates new objects from top down.
18
- *
19
- * @ignore
20
- */
21
- export declare const setValue: (obj: any, prop: string, val: any) => any;
22
- /**
23
- * Get a deeply nested value. Example:
24
- *
25
- * getValue({ foo: bar: [] }, 'foo.bar') //=> []
26
- *
27
- * @ignore
28
- */
29
- export declare const getValue: (obj: any, prop: string) => any;
@@ -1,3 +0,0 @@
1
- import { Rule } from '@angular-devkit/schematics';
2
- import { ActionsSchema } from './actions.schema';
3
- export declare function actions(options: ActionsSchema): Rule;
@@ -1,4 +0,0 @@
1
- import { Rule } from '@angular-devkit/schematics';
2
- import { NormalizedNgxsPackageSchema } from './ng-add.factory';
3
- export declare function addDeclarationToStandaloneApp(options: NormalizedNgxsPackageSchema): Rule;
4
- export declare function addDeclarationToNonStandaloneApp(options: NormalizedNgxsPackageSchema): Rule;
@@ -1,9 +0,0 @@
1
- import { Rule } from '@angular-devkit/schematics';
2
- import { LIBRARIES } from '../utils/common/lib.config';
3
- import { NgxsPackageSchema } from './ng-add.schema';
4
- export type NormalizedNgxsPackageSchema = {
5
- skipInstall: boolean;
6
- plugins: LIBRARIES[];
7
- project: string;
8
- };
9
- export declare function ngAdd(options: NgxsPackageSchema): Rule;
@@ -1,3 +0,0 @@
1
- import { Rule } from '@angular-devkit/schematics';
2
- import { StarterKitSchema } from './starter-kit.schema';
3
- export declare function starterKit(options: StarterKitSchema): Rule;
@@ -1,3 +0,0 @@
1
- import { Rule } from '@angular-devkit/schematics';
2
- import { StateSchema } from './state.schema';
3
- export declare function state(options: StateSchema): Rule;
@@ -1,3 +0,0 @@
1
- import { Rule } from '@angular-devkit/schematics';
2
- import { StoreSchema } from './store.schema';
3
- export declare function store(options: StoreSchema): Rule;
@@ -1,10 +0,0 @@
1
- export declare enum LIBRARIES {
2
- DEVTOOLS = "@ngxs/devtools-plugin",
3
- FORM = "@ngxs/form-plugin",
4
- HMR = "@ngxs/hmr-plugin",
5
- LOGGER = "@ngxs/logger-plugin",
6
- ROUTER = "@ngxs/router-plugin",
7
- STORAGE = "@ngxs/storage-plugin",
8
- STORE = "@ngxs/store",
9
- WEBSOCKET = "@ngxs/websocket-plugin"
10
- }
@@ -1,3 +0,0 @@
1
- export declare const PACKAGE_JSON = "package.json";
2
- export declare const ANGULAR_JSON = "angular.json";
3
- export declare const TSCONFIG_SPEC_JSON = "src/tsconfig.spec.json";
@@ -1 +0,0 @@
1
- export declare function isEmpty(value: string | undefined): boolean;
@@ -1,119 +0,0 @@
1
- import { Tree } from '@angular-devkit/schematics';
2
- export interface AppConfig {
3
- /**
4
- * Name of the app.
5
- */
6
- name?: string;
7
- /**
8
- * Directory where app files are placed.
9
- */
10
- appRoot?: string;
11
- /**
12
- * The root directory of the app.
13
- */
14
- root?: string;
15
- /**
16
- * The output directory for build results.
17
- */
18
- outDir?: string;
19
- /**
20
- * List of application assets.
21
- */
22
- assets?: (string | {
23
- /**
24
- * The pattern to match.
25
- */
26
- glob?: string;
27
- /**
28
- * The dir to search within.
29
- */
30
- input?: string;
31
- /**
32
- * The output path (relative to the outDir).
33
- */
34
- output?: string;
35
- })[];
36
- /**
37
- * URL where files will be deployed.
38
- */
39
- deployUrl?: string;
40
- /**
41
- * Base url for the application being built.
42
- */
43
- baseHref?: string;
44
- /**
45
- * The runtime platform of the app.
46
- */
47
- platform?: 'browser' | 'server';
48
- /**
49
- * The name of the start HTML file.
50
- */
51
- index?: string;
52
- /**
53
- * The name of the main entry-point file.
54
- */
55
- main?: string;
56
- /**
57
- * The name of the polyfills file.
58
- */
59
- polyfills?: string;
60
- /**
61
- * The name of the test entry-point file.
62
- */
63
- test?: string;
64
- /**
65
- * The name of the TypeScript configuration file.
66
- */
67
- tsconfig?: string;
68
- /**
69
- * The name of the TypeScript configuration file for unit tests.
70
- */
71
- testTsconfig?: string;
72
- /**
73
- * The prefix to apply to generated selectors.
74
- */
75
- prefix?: string;
76
- /**
77
- * Experimental support for a service worker from @angular/service-worker.
78
- */
79
- serviceWorker?: boolean;
80
- /**
81
- * Global styles to be included in the build.
82
- */
83
- styles?: (string | {
84
- input?: string;
85
- [name: string]: any;
86
- })[];
87
- /**
88
- * Options to pass to style preprocessors
89
- */
90
- stylePreprocessorOptions?: {
91
- /**
92
- * Paths to include. Paths will be resolved to project root.
93
- */
94
- includePaths?: string[];
95
- };
96
- /**
97
- * Global scripts to be included in the build.
98
- */
99
- scripts?: (string | {
100
- input: string;
101
- [name: string]: any;
102
- })[];
103
- /**
104
- * Source file for environment config.
105
- */
106
- environmentSource?: string;
107
- /**
108
- * Name and corresponding file for environment config.
109
- */
110
- environments?: {
111
- [name: string]: any;
112
- };
113
- appShell?: {
114
- app: string;
115
- route: string;
116
- };
117
- }
118
- export declare function getWorkspacePath(host: Tree): string | undefined;
119
- export declare function getWorkspace(host: Tree): any;
@@ -1,4 +0,0 @@
1
- import { Rule, Source } from '@angular-devkit/schematics';
2
- export declare function generateFiles(srcFolder: Source, target: string, substitutions: {
3
- [k: string]: any;
4
- }, generateSpecs?: boolean): Rule;
@@ -1,7 +0,0 @@
1
- import { Tree } from '@angular-devkit/schematics';
2
- export interface PackageToJsonInterface {
3
- host: Tree;
4
- type: string;
5
- pkg: string;
6
- version: string;
7
- }
@@ -1,99 +0,0 @@
1
- import * as ts from '@schematics/angular/third_party/github.com/Microsoft/TypeScript/lib/typescript';
2
- import { Change } from '@schematics/angular/utility/change';
3
- /**
4
- * Add Import `import { symbolName } from fileName` if the import doesn't exit
5
- * already. Assumes fileToEdit can be resolved and accessed.
6
- * @param fileToEdit File we want to add import to.
7
- * @param symbolName Item to import.
8
- * @param fileName Path to the file.
9
- * @param isDefault If true, import follows style for importing default exports.
10
- * @param alias Alias that the symbol should be inserted under.
11
- * @return Change
12
- */
13
- export declare function insertImport(source: ts.SourceFile, fileToEdit: string, symbolName: string, fileName: string, isDefault?: boolean, alias?: string): Change;
14
- /**
15
- * Find all nodes from the AST in the subtree of node of SyntaxKind kind.
16
- * @param node
17
- * @param kind
18
- * @param max The maximum number of items to return.
19
- * @param recursive Continue looking for nodes of kind recursive until end
20
- * the last child even when node of kind has been found.
21
- * @return all nodes of kind, or [] if none is found
22
- */
23
- export declare function findNodes(node: ts.Node, kind: ts.SyntaxKind, max?: number, recursive?: boolean): ts.Node[];
24
- /**
25
- * Find all nodes from the AST in the subtree that satisfy a type guard.
26
- * @param node
27
- * @param guard
28
- * @param max The maximum number of items to return.
29
- * @param recursive Continue looking for nodes of kind recursive until end
30
- * the last child even when node of kind has been found.
31
- * @return all nodes that satisfy the type guard, or [] if none is found
32
- */
33
- export declare function findNodes<T extends ts.Node>(node: ts.Node, guard: (node: ts.Node) => node is T, max?: number, recursive?: boolean): T[];
34
- /**
35
- * Get all the nodes from a source.
36
- * @param sourceFile The source file object.
37
- * @returns {Array<ts.Node>} An array of all the nodes in the source.
38
- */
39
- export declare function getSourceNodes(sourceFile: ts.SourceFile): ts.Node[];
40
- export declare function findNode(node: ts.Node, kind: ts.SyntaxKind, text: string): ts.Node | null;
41
- /**
42
- * Insert `toInsert` after the last occurence of `ts.SyntaxKind[nodes[i].kind]`
43
- * or after the last of occurence of `syntaxKind` if the last occurence is a sub child
44
- * of ts.SyntaxKind[nodes[i].kind] and save the changes in file.
45
- *
46
- * @param nodes insert after the last occurence of nodes
47
- * @param toInsert string to insert
48
- * @param file file to insert changes into
49
- * @param fallbackPos position to insert if toInsert happens to be the first occurence
50
- * @param syntaxKind the ts.SyntaxKind of the subchildren to insert after
51
- * @return Change instance
52
- * @throw Error if toInsert is first occurence but fall back is not set
53
- */
54
- export declare function insertAfterLastOccurrence(nodes: ts.Node[] | ts.NodeArray<ts.Node>, toInsert: string, file: string, fallbackPos: number, syntaxKind?: ts.SyntaxKind): Change;
55
- export declare function getDecoratorMetadata(source: ts.SourceFile, identifier: string, module: string): ts.Node[];
56
- export declare function getMetadataField(node: ts.ObjectLiteralExpression, metadataField: string): ts.ObjectLiteralElement[];
57
- export declare function addSymbolToNgModuleMetadata(source: ts.SourceFile, ngModulePath: string, metadataField: string, symbolName: string, importPath?: string | null): Change[];
58
- /**
59
- * Custom function to insert a declaration (component, pipe, directive)
60
- * into NgModule declarations. It also imports the component.
61
- */
62
- export declare function addDeclarationToModule(source: ts.SourceFile, modulePath: string, classifiedName: string, importPath: string): Change[];
63
- /**
64
- * Custom function to insert an NgModule into NgModule imports. It also imports the module.
65
- */
66
- export declare function addImportToModule(source: ts.SourceFile, modulePath: string, classifiedName: string, importPath: string): Change[];
67
- /**
68
- * Custom function to insert a provider into NgModule. It also imports it.
69
- */
70
- export declare function addProviderToModule(source: ts.SourceFile, modulePath: string, classifiedName: string, importPath: string): Change[];
71
- /**
72
- * Custom function to insert an export into NgModule. It also imports it.
73
- */
74
- export declare function addExportToModule(source: ts.SourceFile, modulePath: string, classifiedName: string, importPath: string): Change[];
75
- /**
76
- * Custom function to insert an export into NgModule. It also imports it.
77
- */
78
- export declare function addBootstrapToModule(source: ts.SourceFile, modulePath: string, classifiedName: string, importPath: string): Change[];
79
- /**
80
- * Determine if an import already exists.
81
- */
82
- export declare function isImported(source: ts.SourceFile, classifiedName: string, importPath: string): boolean;
83
- /**
84
- * Returns the RouterModule declaration from NgModule metadata, if any.
85
- */
86
- export declare function getRouterModuleDeclaration(source: ts.SourceFile): ts.Expression | undefined;
87
- /**
88
- * Adds a new route declaration to a router module (i.e. has a RouterModule declaration)
89
- */
90
- export declare function addRouteDeclarationToModule(source: ts.SourceFile, fileToAdd: string, routeLiteral: string): Change;
91
- /**
92
- * Determines if a SourceFile has a top-level declaration whose name matches a specific symbol.
93
- * Can be used to avoid conflicts when inserting new imports into a file.
94
- * @param sourceFile File in which to search.
95
- * @param symbolName Name of the symbol to search for.
96
- * @param skipModule Path of the module that the symbol may have been imported from. Used to
97
- * avoid false positives where the same symbol we're looking for may have been imported.
98
- */
99
- export declare function hasTopLevelIdentifier(sourceFile: ts.SourceFile, symbolName: string, skipModule?: string | null): boolean;
@@ -1,5 +0,0 @@
1
- import { Tree } from '@angular-devkit/schematics';
2
- import * as ts from '@schematics/angular/third_party/github.com/Microsoft/TypeScript/lib/typescript';
3
- export declare function findBootstrapModuleCall(host: Tree, mainPath: string): ts.CallExpression | null;
4
- export declare function getAppModulePath(host: Tree, mainPath: string): string;
5
- export declare function isStandaloneApp(host: Tree, mainPath: string): boolean;
@@ -1,2 +0,0 @@
1
- import { Tree } from '@angular-devkit/schematics';
2
- export declare function getProjectMainFile(host: Tree, project?: string): string;
@@ -1,16 +0,0 @@
1
- import { Tree } from '@angular-devkit/schematics';
2
- import * as ts from '@schematics/angular/third_party/github.com/Microsoft/TypeScript/lib/typescript';
3
- /** App config that was resolved to its source node. */
4
- export interface ResolvedAppConfig {
5
- /** Tree-relative path of the file containing the app config. */
6
- filePath: string;
7
- /** Node defining the app config. */
8
- node: ts.ObjectLiteralExpression;
9
- }
10
- /**
11
- * Resolves the node that defines the app config from a bootstrap call.
12
- * @param bootstrapCall Call for which to resolve the config.
13
- * @param tree File tree of the project.
14
- * @param filePath File path of the bootstrap call.
15
- */
16
- export declare function findAppConfig(bootstrapCall: ts.CallExpression, tree: Tree, filePath: string): ResolvedAppConfig | null;
@@ -1,46 +0,0 @@
1
- import { Rule } from '@angular-devkit/schematics';
2
- /** Generated code that hasn't been interpolated yet. */
3
- export interface PendingCode {
4
- /** Code that will be inserted. */
5
- expression: string;
6
- /** Imports that need to be added to the file in which the code is inserted. */
7
- imports: PendingImports;
8
- }
9
- /** Map keeping track of imports and aliases under which they're referred to in an expresion. */
10
- type PendingImports = Map<string, Map<string, string>>;
11
- /**
12
- * Callback invoked by a Rule that produces the code
13
- * that needs to be inserted somewhere in the app.
14
- */
15
- export type CodeBlockCallback = (block: CodeBlock) => PendingCode;
16
- /**
17
- * Utility class used to generate blocks of code that
18
- * can be inserted by the devkit into a user's app.
19
- */
20
- export declare class CodeBlock {
21
- private _imports;
22
- /** Function used to tag a code block in order to produce a `PendingCode` object. */
23
- code: (strings: TemplateStringsArray, ...params: unknown[]) => PendingCode;
24
- /**
25
- * Used inside of a code block to mark external symbols and which module they should be imported
26
- * from. When the code is inserted, the required import statements will be produced automatically.
27
- * @param symbolName Name of the external symbol.
28
- * @param moduleName Module from which the symbol should be imported.
29
- */
30
- external: (symbolName: string, moduleName: string) => string;
31
- /**
32
- * Produces the necessary rules to transform a `PendingCode` object into valid code.
33
- * @param initialCode Code pending transformed.
34
- * @param filePath Path of the file in which the code will be inserted.
35
- */
36
- static transformPendingCode(initialCode: PendingCode, filePath: string): {
37
- code: {
38
- /** Code that will be inserted. */
39
- expression: string;
40
- /** Imports that need to be added to the file in which the code is inserted. */
41
- imports: PendingImports;
42
- };
43
- rules: Rule[];
44
- };
45
- }
46
- export {};
@@ -1 +0,0 @@
1
- export { addRootImport, addRootProvider } from './rules';
@@ -1,38 +0,0 @@
1
- import { Rule } from '@angular-devkit/schematics';
2
- import { CodeBlockCallback } from './code_block';
3
- /**
4
- * Adds an import to the root of the project.
5
- * @param project Name of the project to which to add the import.
6
- * @param callback Function that generates the code block which should be inserted.
7
- * @example
8
- *
9
- * ```ts
10
- * import { Rule } from '@angular-devkit/schematics';
11
- * import { addRootImport } from '@schematics/angular/utility';
12
- *
13
- * export default function(): Rule {
14
- * return addRootImport('default', ({code, external}) => {
15
- * return code`${external('MyModule', '@my/module')}.forRoot({})`;
16
- * });
17
- * }
18
- * ```
19
- */
20
- export declare function addRootImport(project: string, callback: CodeBlockCallback): Rule;
21
- /**
22
- * Adds a provider to the root of the project.
23
- * @param project Name of the project to which to add the import.
24
- * @param callback Function that generates the code block which should be inserted.
25
- * @example
26
- *
27
- * ```ts
28
- * import { Rule } from '@angular-devkit/schematics';
29
- * import { addRootProvider } from '@schematics/angular/utility';
30
- *
31
- * export default function(): Rule {
32
- * return addRootProvider('default', ({code, external}) => {
33
- * return code`${external('provideLibrary', '@my/library')}({})`;
34
- * });
35
- * }
36
- * ```
37
- */
38
- export declare function addRootProvider(project: string, callback: CodeBlockCallback): Rule;
@@ -1,28 +0,0 @@
1
- import { Tree } from '@angular-devkit/schematics';
2
- import * as ts from '@schematics/angular/third_party/github.com/Microsoft/TypeScript/lib/typescript';
3
- import { Change } from '@schematics/angular/utility/change';
4
- /**
5
- * Finds the main file of a project.
6
- * @param tree File tree for the project.
7
- * @param projectName Name of the project in which to search.
8
- */
9
- export declare function getMainFilePath(tree: Tree, projectName: string): Promise<string>;
10
- /**
11
- * Gets a TypeScript source file at a specific path.
12
- * @param tree File tree of a project.
13
- * @param path Path to the file.
14
- */
15
- export declare function getSourceFile(tree: Tree, path: string): ts.SourceFile;
16
- /** Finds the call to `bootstrapApplication` within a file. */
17
- export declare function findBootstrapApplicationCall(tree: Tree, mainFilePath: string): ts.CallExpression;
18
- /**
19
- * Applies a set of changes to a file.
20
- * @param tree File tree of the project.
21
- * @param path Path to the file that is being changed.
22
- * @param changes Changes that should be applied to the file.
23
- */
24
- export declare function applyChangesToFile(tree: Tree, path: string, changes: Change[]): void;
25
- /** Checks whether a node is a call to `mergeApplicationConfig`. */
26
- export declare function isMergeAppConfigCall(node: ts.Node): node is ts.CallExpression;
27
- /** Finds the `providers` array literal within an application config. */
28
- export declare function findProvidersLiteral(config: ts.ObjectLiteralExpression): ts.ArrayLiteralExpression | null;