@ngxs/store 3.8.1-dev.master-bd067dd → 3.8.1-dev.master-22a8ab1

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 (38) hide show
  1. package/package.json +1 -1
  2. package/schematics/src/ng-add/add-declaration.d.ts +4 -0
  3. package/schematics/src/ng-add/add-declaration.js +109 -0
  4. package/schematics/src/ng-add/add-declaration.js.map +1 -0
  5. package/schematics/src/ng-add/ng-add.factory.d.ts +6 -0
  6. package/schematics/src/ng-add/ng-add.factory.js +43 -41
  7. package/schematics/src/ng-add/ng-add.factory.js.map +1 -1
  8. package/schematics/src/utils/config.d.ts +1 -1
  9. package/schematics/src/utils/config.js +2 -2
  10. package/schematics/src/utils/config.js.map +1 -1
  11. package/schematics/src/utils/ng-utils/README.md +1 -0
  12. package/schematics/src/utils/ng-utils/ast-utils.d.ts +99 -0
  13. package/schematics/src/utils/ng-utils/ast-utils.js +517 -0
  14. package/schematics/src/utils/ng-utils/ast-utils.js.map +1 -0
  15. package/schematics/src/utils/ng-utils/ng-ast-utils.d.ts +5 -0
  16. package/schematics/src/utils/ng-utils/ng-ast-utils.js +67 -0
  17. package/schematics/src/utils/ng-utils/ng-ast-utils.js.map +1 -0
  18. package/schematics/src/utils/ng-utils/project.d.ts +2 -0
  19. package/schematics/src/utils/ng-utils/project.js +21 -0
  20. package/schematics/src/utils/ng-utils/project.js.map +1 -0
  21. package/schematics/src/utils/ng-utils/standalone/app_config.d.ts +16 -0
  22. package/schematics/src/utils/ng-utils/standalone/app_config.js +84 -0
  23. package/schematics/src/utils/ng-utils/standalone/app_config.js.map +1 -0
  24. package/schematics/src/utils/ng-utils/standalone/code_block.d.ts +46 -0
  25. package/schematics/src/utils/ng-utils/standalone/code_block.js +73 -0
  26. package/schematics/src/utils/ng-utils/standalone/code_block.js.map +1 -0
  27. package/schematics/src/utils/ng-utils/standalone/index.d.ts +1 -0
  28. package/schematics/src/utils/ng-utils/standalone/index.js +7 -0
  29. package/schematics/src/utils/ng-utils/standalone/index.js.map +1 -0
  30. package/schematics/src/utils/ng-utils/standalone/rules.d.ts +38 -0
  31. package/schematics/src/utils/ng-utils/standalone/rules.js +195 -0
  32. package/schematics/src/utils/ng-utils/standalone/rules.js.map +1 -0
  33. package/schematics/src/utils/ng-utils/standalone/util.d.ts +28 -0
  34. package/schematics/src/utils/ng-utils/standalone/util.js +138 -0
  35. package/schematics/src/utils/ng-utils/standalone/util.js.map +1 -0
  36. package/schematics/src/utils/project.d.ts +8 -9
  37. package/schematics/src/utils/project.js +16 -8
  38. package/schematics/src/utils/project.js.map +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ngxs/store",
3
- "version": "3.8.1-dev.master-bd067dd",
3
+ "version": "3.8.1-dev.master-22a8ab1",
4
4
  "license": "MIT",
5
5
  "sideEffects": false,
6
6
  "peerDependencies": {
@@ -0,0 +1,4 @@
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;
@@ -0,0 +1,109 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.addDeclarationToNonStandaloneApp = exports.addDeclarationToStandaloneApp = void 0;
13
+ const schematics_1 = require("@angular-devkit/schematics");
14
+ const rules_1 = require("../utils/ng-utils/standalone/rules");
15
+ const util_1 = require("../utils/ng-utils/standalone/util");
16
+ const ast_utils_1 = require("@schematics/angular/utility/ast-utils");
17
+ const app_config_1 = require("../utils/ng-utils/standalone/app_config");
18
+ const lib_config_1 = require("../utils/common/lib.config");
19
+ function addDeclarationToStandaloneApp(options) {
20
+ return (host) => __awaiter(this, void 0, void 0, function* () {
21
+ var _a;
22
+ const mainFilePath = yield (0, util_1.getMainFilePath)(host, options.project);
23
+ const bootstrapCall = (0, util_1.findBootstrapApplicationCall)(host, mainFilePath);
24
+ const appConfigFilePath = ((_a = (0, app_config_1.findAppConfig)(bootstrapCall, host, mainFilePath)) === null || _a === void 0 ? void 0 : _a.filePath) || mainFilePath;
25
+ const plugins = options.plugins
26
+ .filter(p => pluginData.has(p))
27
+ .map((p) => [p, pluginData.get(p).standalone]);
28
+ const importPluginRules = plugins.map(([plugin, standaloneDeclaration]) => {
29
+ return importTree => {
30
+ const change = (0, ast_utils_1.insertImport)((0, util_1.getSourceFile)(host, appConfigFilePath), appConfigFilePath, standaloneDeclaration, plugin);
31
+ (0, util_1.applyChangesToFile)(importTree, appConfigFilePath, [change]);
32
+ };
33
+ });
34
+ const pluginDeclarations = plugins
35
+ .map(([, standaloneDeclaration]) => `${standaloneDeclaration}()`)
36
+ .join(',\n');
37
+ return (0, schematics_1.chain)([
38
+ ...importPluginRules,
39
+ (0, rules_1.addRootProvider)(options.project, ({ code, external }) => code `${external('provideStore', '@ngxs/store')}(\n[],\n${pluginDeclarations})`)
40
+ ]);
41
+ });
42
+ }
43
+ exports.addDeclarationToStandaloneApp = addDeclarationToStandaloneApp;
44
+ function addDeclarationToNonStandaloneApp(options) {
45
+ const pluginRules = options.plugins
46
+ .map(p => { var _a; return [p, (_a = pluginData.get(p)) === null || _a === void 0 ? void 0 : _a.module]; })
47
+ .filter((v) => !!v[1])
48
+ .map(([plugin, moduleName]) => {
49
+ return (0, rules_1.addRootImport)(options.project, ({ code, external }) => code `${external(moduleName, plugin)}.forRoot()`);
50
+ });
51
+ const importPath = '@ngxs/store';
52
+ const moduleImportExtras = '.forRoot([], { developmentMode: /** !environment.production */ false, selectorOptions: { suppressErrors: false, injectContainerState: false } })';
53
+ return (0, schematics_1.chain)([
54
+ (0, rules_1.addRootImport)(options.project, ({ code, external }) => code `${external('NgxsModule', importPath)}${moduleImportExtras}`),
55
+ ...pluginRules
56
+ ]);
57
+ }
58
+ exports.addDeclarationToNonStandaloneApp = addDeclarationToNonStandaloneApp;
59
+ const pluginData = new Map([
60
+ [
61
+ lib_config_1.LIBRARIES.DEVTOOLS,
62
+ {
63
+ module: 'NgxsReduxDevtoolsPluginModule',
64
+ standalone: 'withNgxsReduxDevtoolsPlugin'
65
+ }
66
+ ],
67
+ [
68
+ lib_config_1.LIBRARIES.FORM,
69
+ {
70
+ module: 'NgxsFormPluginModule',
71
+ standalone: 'withNgxsFormPlugin'
72
+ }
73
+ ],
74
+ [
75
+ lib_config_1.LIBRARIES.LOGGER,
76
+ {
77
+ module: 'NgxsLoggerPluginModule',
78
+ standalone: 'withNgxsLoggerPlugin'
79
+ }
80
+ ],
81
+ [
82
+ lib_config_1.LIBRARIES.ROUTER,
83
+ {
84
+ module: 'NgxsRouterPluginModule',
85
+ standalone: 'withNgxsRouterPlugin'
86
+ }
87
+ ],
88
+ [
89
+ lib_config_1.LIBRARIES.STORAGE,
90
+ {
91
+ module: 'NgxsStoragePluginModule',
92
+ standalone: 'withNgxsStoragePlugin'
93
+ }
94
+ ],
95
+ [
96
+ lib_config_1.LIBRARIES.STORE,
97
+ {
98
+ standalone: 'provideStore'
99
+ }
100
+ ],
101
+ [
102
+ lib_config_1.LIBRARIES.WEBSOCKET,
103
+ {
104
+ module: 'NgxsWebsocketPluginModule',
105
+ standalone: 'withNgxsWebSocketPlugin'
106
+ }
107
+ ]
108
+ ]);
109
+ //# sourceMappingURL=add-declaration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"add-declaration.js","sourceRoot":"","sources":["../../../../../packages/store/schematics/src/ng-add/add-declaration.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2DAAyD;AACzD,8DAAoF;AACpF,4DAK2C;AAC3C,qEAAqE;AACrE,wEAAwE;AACxE,2DAAuD;AAGvD,SAAgB,6BAA6B,CAAC,OAAoC;IAChF,OAAO,CAAM,IAAI,EAAC,EAAE;;QAClB,MAAM,YAAY,GAAG,MAAM,IAAA,sBAAe,EAAC,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;QAClE,MAAM,aAAa,GAAG,IAAA,mCAA4B,EAAC,IAAI,EAAE,YAAY,CAAC,CAAC;QACvE,MAAM,iBAAiB,GACrB,CAAA,MAAA,IAAA,0BAAa,EAAC,aAAa,EAAE,IAAI,EAAE,YAAY,CAAC,0CAAE,QAAQ,KAAI,YAAY,CAAC;QAE7E,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO;aAC5B,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;aAC9B,GAAG,CAAC,CAAC,CAAC,EAAuB,EAAE,CAAC,CAAC,CAAC,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC,CAAE,CAAC,UAAU,CAAC,CAAC,CAAC;QAEvE,MAAM,iBAAiB,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,EAAE,qBAAqB,CAAC,EAAQ,EAAE;YAC9E,OAAO,UAAU,CAAC,EAAE;gBAClB,MAAM,MAAM,GAAG,IAAA,wBAAY,EACzB,IAAA,oBAAa,EAAC,IAAI,EAAE,iBAAiB,CAAC,EACtC,iBAAiB,EACjB,qBAAqB,EACrB,MAAM,CACP,CAAC;gBACF,IAAA,yBAAkB,EAAC,UAAU,EAAE,iBAAiB,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;YAC9D,CAAC,CAAC;QACJ,CAAC,CAAC,CAAC;QACH,M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Q,EAAE,EAAE,EAAE,CAAC,IAAI,CAAA,GAAG,QAAQ,CAAC,YAAY,EAAE,UAAU,CAAC,GAAG,kBAAkB,EAAE,CACzF;QACD,GAAG,WAAW;KACf,CAAC,CAAC;AACL,CAAC;AAvBD,4EAuBC;AAED,MAAM,UAAU,GAAoE,IAAI,GAAG,CAAC;IAC1F;QACE,sBAAS,CAAC,QAAQ;QAClB;YACE,MAAM,EAAE,+BAA+B;YACvC,UAAU,EAAE,6BAA6B;SAC1C;KACF;IACD;QACE,sBAAS,CAAC,IAAI;QACd;YACE,MAAM,EAAE,sBAAsB;YAC9B,UAAU,EAAE,oBAAoB;SACjC;KACF;IACD;QACE,sBAAS,CAAC,MAAM;QAChB;YACE,MAAM,EAAE,wBAAwB;YAChC,UAAU,EAAE,sBAAsB;SACnC;KACF;IACD;QACE,sBAAS,CAAC,MAAM;QAChB;YACE,MAAM,EAAE,wBAAwB;YAChC,UAAU,EAAE,sBAAsB;SACnC;KACF;IACD;QACE,sBAAS,CAAC,OAAO;QACjB;YACE,MAAM,EAAE,yBAAyB;YACjC,UAAU,EAAE,uBAAuB;SACpC;KACF;IACD;QACE,sBAAS,CAAC,KAAK;QACf;YACE,UAAU,EAAE,cAAc;SAC3B;KACF;IACD;QACE,sBAAS,CAAC,SAAS;QACnB;YACE,MAAM,EAAE,2BAA2B;YACnC,UAAU,EAAE,yBAAyB;SACtC;KACF;CACF,CAAC,CAAC"}
@@ -1,3 +1,9 @@
1
1
  import { Rule } from '@angular-devkit/schematics';
2
+ import { LIBRARIES } from '../utils/common/lib.config';
2
3
  import { NgxsPackageSchema } from './ng-add.schema';
4
+ export declare type NormalizedNgxsPackageSchema = {
5
+ skipInstall: boolean;
6
+ plugins: LIBRARIES[];
7
+ project: string;
8
+ };
3
9
  export declare function ngAdd(options: NgxsPackageSchema): Rule;
@@ -1,33 +1,42 @@
1
1
  "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
2
11
  Object.defineProperty(exports, "__esModule", { value: true });
3
12
  exports.ngAdd = void 0;
4
13
  const schematics_1 = require("@angular-devkit/schematics");
5
14
  const tasks_1 = require("@angular-devkit/schematics/tasks");
6
- const ts = require("@schematics/angular/third_party/github.com/Microsoft/TypeScript/lib/typescript");
7
- const ast_utils_1 = require("@schematics/angular/utility/ast-utils");
8
- const change_1 = require("@schematics/angular/utility/change");
9
15
  const dependencies_1 = require("@schematics/angular/utility/dependencies");
10
- const ng_ast_utils_1 = require("@schematics/angular/utility/ng-ast-utils");
11
16
  const lib_config_1 = require("../utils/common/lib.config");
12
- const project_1 = require("../utils/project");
17
+ const project_1 = require("../utils/ng-utils/project");
18
+ const ng_ast_utils_1 = require("../utils/ng-utils/ng-ast-utils");
19
+ const add_declaration_1 = require("./add-declaration");
20
+ const project_2 = require("../utils/project");
13
21
  const versions = require('./../utils/versions.json');
14
22
  function ngAdd(options) {
15
- return (0, schematics_1.chain)([
16
- addNgxsPackageToPackageJson(options),
17
- addDeclarationToNgModule(options),
18
- options.skipInstall ? (0, schematics_1.noop)() : runNpmPackageInstall()
19
- ]);
23
+ return (host) => {
24
+ const normalizedSchema = normalizeSchema(host, options);
25
+ return (0, schematics_1.chain)([
26
+ addNgxsPackageToPackageJson(normalizedSchema),
27
+ addDeclaration(normalizedSchema),
28
+ normalizedSchema.skipInstall ? (0, schematics_1.noop)() : runNpmPackageInstall()
29
+ ]);
30
+ };
20
31
  }
21
32
  exports.ngAdd = ngAdd;
22
- function addNgxsPackageToPackageJson(options) {
33
+ function addNgxsPackageToPackageJson(schema) {
23
34
  return (host, context) => {
24
35
  const ngxsStoreVersion = versions['@ngxs/store'];
25
36
  if (!ngxsStoreVersion) {
26
37
  throw new schematics_1.SchematicsException('Could not resolve the version of "@ngxs/store"');
27
38
  }
28
- Object.values(lib_config_1.LIBRARIES)
29
- .filter(lib => { var _a; return (_a = options.plugins) === null || _a === void 0 ? void 0 : _a.includes(lib); })
30
- .forEach(name => {
39
+ schema.plugins.forEach(name => {
31
40
  const packageExists = (0, dependencies_1.getPackageJsonDependency)(host, name);
32
41
  if (packageExists === null) {
33
42
  (0, dependencies_1.addPackageJsonDependency)(host, {
@@ -50,35 +59,28 @@ function runNpmPackageInstall() {
50
59
  context.logger.info(`🔍 Installing packages...`);
51
60
  };
52
61
  }
53
- function addDeclarationToNgModule(options) {
54
- return (host) => {
55
- const project = (0, project_1.getProject)(host, { project: options.project });
56
- if (typeof project === 'undefined' || project === null) {
57
- const message = options.project
58
- ? `Project "${options.project}" does not exist.`
59
- : 'Could not determine the project to update.';
60
- throw new schematics_1.SchematicsException(message);
62
+ function addDeclaration(schema) {
63
+ return (host) => __awaiter(this, void 0, void 0, function* () {
64
+ const mainFile = (0, project_1.getProjectMainFile)(host, schema.project);
65
+ const isStandalone = (0, ng_ast_utils_1.isStandaloneApp)(host, mainFile);
66
+ if (isStandalone) {
67
+ return (0, add_declaration_1.addDeclarationToStandaloneApp)(schema);
61
68
  }
62
- const modulePath = (0, ng_ast_utils_1.getAppModulePath)(host, `${project.root}/src/main.ts`);
63
- if (typeof modulePath === 'undefined') {
64
- throw new schematics_1.SchematicsException(`Module path for project "${options.project}" does not exist.`);
69
+ else {
70
+ return (0, add_declaration_1.addDeclarationToNonStandaloneApp)(schema);
65
71
  }
66
- const importPath = '@ngxs/store';
67
- const moduleImport = 'NgxsModule.forRoot([], { developmentMode: /** !environment.production */ false, selectorOptions: { suppressErrors: false, injectContainerState: false } })';
68
- const sourceBuffer = host.read(modulePath);
69
- if (sourceBuffer !== null) {
70
- const sourceText = sourceBuffer.toString();
71
- const source = ts.createSourceFile(modulePath, sourceText, ts.ScriptTarget.Latest, true);
72
- const changes = (0, ast_utils_1.addImportToModule)(source, modulePath, moduleImport, importPath);
73
- const recorder = host.beginUpdate(modulePath);
74
- for (const change of changes) {
75
- if (change instanceof change_1.InsertChange) {
76
- recorder.insertLeft(change.pos, change.toAdd);
77
- }
78
- }
79
- host.commitUpdate(recorder);
80
- }
81
- return host;
72
+ });
73
+ }
74
+ function normalizeSchema(host, schema) {
75
+ var _a, _b;
76
+ const projectName = (_a = (0, project_2.getProject)(host, schema.project)) === null || _a === void 0 ? void 0 : _a.name;
77
+ if (!projectName) {
78
+ throw new schematics_1.SchematicsException(`Project "${schema.project}" does not exist.`);
79
+ }
80
+ return {
81
+ skipInstall: !!schema.skipInstall,
82
+ plugins: (_b = Object.values(lib_config_1.LIBRARIES).filter(lib => { var _a; return (_a = schema.plugins) === null || _a === void 0 ? void 0 : _a.includes(lib); })) !== null && _b !== void 0 ? _b : [],
83
+ project: projectName
82
84
  };
83
85
  }
84
86
  //# sourceMappingURL=ng-add.factory.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ng-add.factory.js","sourceRoot":"","sources":["../../../../../packages/store/schematics/src/ng-add/ng-add.factory.ts"],"names":[],"mappings":";;;AAAA,2DAOoC;AACpC,4DAA0E;AAC1E,qGAAqG;AACrG,qEAA0E;AAC1E,+DAAkE;AAClE,2EAIkD;AAClD,2EAA4E;AAE5E,2DAAuD;AACvD,8CAA8C;AAI9C,MAAM,QAAQ,GAAG,OAAO,CAAC,0BAA0B,CAAC,CAAC;AAErD,SAAgB,KAAK,CAAC,OAA0B;IAC9C,OAAO,IAAA,kBAAK,EAAC;QACX,2BAA2B,CAAC,OAAO,CAAC;QACpC,wBAAwB,CAAC,OAAO,CAAC;QACjC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,IAAA,iBAAI,GAAE,CAAC,CAAC,CAAC,oBAAoB,EAAE;KACtD,CA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AAyB;;IAC5D,MAAM,WAAW,GAAG,MAAA,IAAA,oBAAU,EAAC,IAAI,EAAE,MAAM,CAAC,OAAO,CAAC,0CAAE,IAAI,CAAC;IAC3D,IAAI,CAAC,WAAW,EAAE;QAChB,MAAM,IAAI,gCAAmB,CAAC,YAAY,MAAM,CAAC,OAAO,mBAAmB,CAAC,CAAC;KAC9E;IACD,OAAO;QACL,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC,WAAW;QACjC,OAAO,EAAE,MAAA,MAAM,CAAC,MAAM,CAAC,sBAAS,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,WAAC,OAAA,MAAA,MAAM,CAAC,OAAO,0CAAE,QAAQ,CAAC,GAAG,CAAC,CAAA,EAAA,CAAC,mCAAI,EAAE;QACpF,OAAO,EAAE,WAAW;KACrB,CAAC;AACJ,CAAC"}
@@ -115,5 +115,5 @@ export interface AppConfig {
115
115
  route: string;
116
116
  };
117
117
  }
118
- export declare function getWorkspacePath(host: Tree): string;
118
+ export declare function getWorkspacePath(host: Tree): string | undefined;
119
119
  export declare function getWorkspace(host: Tree): any;
@@ -4,13 +4,13 @@ exports.getWorkspace = exports.getWorkspacePath = void 0;
4
4
  const schematics_1 = require("@angular-devkit/schematics");
5
5
  function getWorkspacePath(host) {
6
6
  const possibleFiles = ['/angular.json', '/.angular.json', '/workspace.json'];
7
- const path = possibleFiles.filter(path => host.exists(path))[0];
7
+ const path = possibleFiles.find(path => host.exists(path));
8
8
  return path;
9
9
  }
10
10
  exports.getWorkspacePath = getWorkspacePath;
11
11
  function getWorkspace(host) {
12
12
  const path = getWorkspacePath(host);
13
- const configBuffer = host.read(path);
13
+ const configBuffer = path ? host.read(path) : null;
14
14
  if (configBuffer === null) {
15
15
  throw new schematics_1.SchematicsException(`Could not find (${path})`);
16
16
  }
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../../../../../packages/store/schematics/src/utils/config.ts"],"names":[],"mappings":";;;AAAA,2DA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AI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACnD,IAAI,YAAY,KAAK,IAAI,EAAE;QACzB,MAAM,IAAI,gCAAmB,CAAC,mBAAmB,IAAI,GAAG,CAAC,CAAC;KAC3D;IACD,MAAM,MAAM,GAAG,YAAY,CAAC,QAAQ,EAAE,CAAC;IAEvC,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;AAC5B,CAAC;AATD,oCASC"}
@@ -0,0 +1 @@
1
+ The ng-utils folder represents a set of files copied from the @schematics/angular package's latest version. These utilities can be removed once @ngxs supports @angular >=16 as the minimum required version.
@@ -0,0 +1,99 @@
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;