@ngrx/store-devtools 21.0.0-beta.0 → 21.0.0-rc.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 (40) hide show
  1. package/migrations/17_0_0-beta/index.js +66 -68
  2. package/migrations/17_0_0-beta/index.js.map +1 -1
  3. package/migrations/6_0_0/index.js +6 -3
  4. package/migrations/6_0_0/index.js.map +1 -1
  5. package/package.json +2 -2
  6. package/schematics/ng-add/index.js +86 -99
  7. package/schematics/ng-add/index.js.map +1 -1
  8. package/schematics/ng-add/schema.js +2 -0
  9. package/schematics-core/index.js +75 -24
  10. package/schematics-core/index.js.map +1 -1
  11. package/schematics-core/utility/ast-utils.js +234 -260
  12. package/schematics-core/utility/ast-utils.js.map +1 -1
  13. package/schematics-core/utility/change.js +82 -92
  14. package/schematics-core/utility/change.js.map +1 -1
  15. package/schematics-core/utility/config.js +13 -9
  16. package/schematics-core/utility/config.js.map +1 -1
  17. package/schematics-core/utility/find-component.js +35 -30
  18. package/schematics-core/utility/find-component.js.map +1 -1
  19. package/schematics-core/utility/find-module.js +38 -33
  20. package/schematics-core/utility/find-module.js.map +1 -1
  21. package/schematics-core/utility/json-utilts.js +8 -27
  22. package/schematics-core/utility/json-utilts.js.map +1 -1
  23. package/schematics-core/utility/libs-version.js +4 -1
  24. package/schematics-core/utility/libs-version.js.map +1 -1
  25. package/schematics-core/utility/ngrx-utils.js +129 -152
  26. package/schematics-core/utility/ngrx-utils.js.map +1 -1
  27. package/schematics-core/utility/package.js +6 -4
  28. package/schematics-core/utility/package.js.map +1 -1
  29. package/schematics-core/utility/parse-name.js +8 -5
  30. package/schematics-core/utility/parse-name.js.map +1 -1
  31. package/schematics-core/utility/project.js +23 -17
  32. package/schematics-core/utility/project.js.map +1 -1
  33. package/schematics-core/utility/standalone.js +141 -214
  34. package/schematics-core/utility/standalone.js.map +1 -1
  35. package/schematics-core/utility/strings.js +32 -21
  36. package/schematics-core/utility/strings.js.map +1 -1
  37. package/schematics-core/utility/update.js +18 -15
  38. package/schematics-core/utility/update.js.map +1 -1
  39. package/schematics-core/utility/visitors.js +104 -192
  40. package/schematics-core/utility/visitors.js.map +1 -1
@@ -1,51 +1,59 @@
1
- var __read = (this && this.__read) || function (o, n) {
2
- var m = typeof Symbol === "function" && o[Symbol.iterator];
3
- if (!m) return o;
4
- var i = m.call(o), r, ar = [], e;
5
- try {
6
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
7
  }
8
- catch (error) { e = { error: error }; }
9
- finally {
10
- try {
11
- if (r && !r.done && (m = i["return"])) m.call(i);
12
- }
13
- finally { if (e) throw e.error; }
14
- }
15
- return ar;
16
- };
17
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
18
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
19
- if (ar || !(i in from)) {
20
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
21
- ar[i] = from[i];
22
- }
23
- }
24
- return to.concat(ar || Array.prototype.slice.call(from));
25
- };
26
- import * as ts from 'typescript';
27
- import { chain } from '@angular-devkit/schematics';
28
- import { visitTSSourceFiles, commitChanges, InsertChange, createReplaceChange, } from '../..//schematics-core';
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.default = default_1;
37
+ const ts = __importStar(require("typescript"));
38
+ const schematics_1 = require("@angular-devkit/schematics");
39
+ const schematics_core_1 = require("../..//schematics-core");
29
40
  function migrate() {
30
- return function (tree) {
31
- visitTSSourceFiles(tree, function (sourceFile) {
32
- var devtoolsImports = sourceFile.statements
41
+ return (tree) => {
42
+ (0, schematics_core_1.visitTSSourceFiles)(tree, (sourceFile) => {
43
+ const devtoolsImports = sourceFile.statements
33
44
  .filter(ts.isImportDeclaration)
34
- .filter(function (_a) {
35
- var moduleSpecifier = _a.moduleSpecifier;
36
- return moduleSpecifier.getText(sourceFile).includes('@ngrx/store-devtools');
37
- });
45
+ .filter(({ moduleSpecifier }) => moduleSpecifier.getText(sourceFile).includes('@ngrx/store-devtools'));
38
46
  if (devtoolsImports.length === 0) {
39
47
  return;
40
48
  }
41
- var changes = __spreadArray([], __read(findAndUpdateConfigs(sourceFile)), false);
42
- commitChanges(tree, sourceFile.fileName, changes);
49
+ const changes = [...findAndUpdateConfigs(sourceFile)];
50
+ (0, schematics_core_1.commitChanges)(tree, sourceFile.fileName, changes);
43
51
  });
44
52
  };
45
53
  }
46
54
  function findAndUpdateConfigs(sourceFile) {
47
- var changes = [];
48
- ts.forEachChild(sourceFile, function (node) { return find(node, changes); });
55
+ const changes = [];
56
+ ts.forEachChild(sourceFile, (node) => find(node, changes));
49
57
  return changes;
50
58
  function find(node, changes) {
51
59
  if (ts.isPropertyAccessExpression(node) &&
@@ -54,45 +62,35 @@ function findAndUpdateConfigs(sourceFile) {
54
62
  node.expression.text === 'StoreDevtoolsModule' &&
55
63
  ts.isCallExpression(node.parent)) {
56
64
  if (node.parent.arguments.length) {
57
- var _a = __read(node.parent.arguments, 1), devtoolsConfig = _a[0];
65
+ const [devtoolsConfig] = node.parent.arguments;
58
66
  if (ts.isObjectLiteralExpression(devtoolsConfig)) {
59
- updateConfig(sourceFile, devtoolsConfig, function (change) {
60
- return changes.push(change);
61
- });
67
+ updateConfig(sourceFile, devtoolsConfig, (change) => changes.push(change));
62
68
  }
63
69
  }
64
70
  else {
65
- createDevtoolsConfig(sourceFile, node.parent, function (change) {
66
- return changes.push(change);
67
- });
71
+ createDevtoolsConfig(sourceFile, node.parent, (change) => changes.push(change));
68
72
  }
69
73
  }
70
74
  if (ts.isCallExpression(node) &&
71
75
  ts.isIdentifier(node.expression) &&
72
76
  node.expression.text === 'provideStoreDevtools') {
73
77
  if (node.arguments.length) {
74
- var _b = __read(node.arguments, 1), devtoolsConfig = _b[0];
78
+ const [devtoolsConfig] = node.arguments;
75
79
  if (ts.isObjectLiteralExpression(devtoolsConfig)) {
76
- updateConfig(sourceFile, devtoolsConfig, function (change) {
77
- return changes.push(change);
78
- });
80
+ updateConfig(sourceFile, devtoolsConfig, (change) => changes.push(change));
79
81
  }
80
82
  }
81
83
  else {
82
- createDevtoolsConfig(sourceFile, node, function (change) {
83
- return changes.push(change);
84
- });
84
+ createDevtoolsConfig(sourceFile, node, (change) => changes.push(change));
85
85
  }
86
86
  }
87
- ts.forEachChild(node, function (childNode) { return find(childNode, changes); });
87
+ ts.forEachChild(node, (childNode) => find(childNode, changes));
88
88
  }
89
89
  }
90
90
  function updateConfig(sourceFile, devtoolsConfig, addChange) {
91
- var connectOutsideZoneProperty = devtoolsConfig.properties.find(function (p) {
92
- return ts.isPropertyAssignment(p) &&
93
- ts.isIdentifier(p.name) &&
94
- p.name.text === 'connectOutsideZone';
95
- });
91
+ const connectOutsideZoneProperty = devtoolsConfig.properties.find((p) => ts.isPropertyAssignment(p) &&
92
+ ts.isIdentifier(p.name) &&
93
+ p.name.text === 'connectOutsideZone');
96
94
  if (!connectOutsideZoneProperty) {
97
95
  addConnectInZoneProperty();
98
96
  }
@@ -100,32 +98,32 @@ function updateConfig(sourceFile, devtoolsConfig, addChange) {
100
98
  replaceConnectOutsideZoneConfig(connectOutsideZoneProperty);
101
99
  }
102
100
  function addConnectInZoneProperty() {
103
- var configText = devtoolsConfig.getText(sourceFile);
104
- var comma = !devtoolsConfig.properties.length ||
101
+ const configText = devtoolsConfig.getText(sourceFile);
102
+ const comma = !devtoolsConfig.properties.length ||
105
103
  configText
106
104
  .substring(0, configText.length - 1)
107
105
  .trim()
108
106
  .endsWith(',')
109
107
  ? ''
110
108
  : ',';
111
- addChange(new InsertChange(sourceFile.fileName, devtoolsConfig.getEnd() - 1, "".concat(comma, " connectInZone: true").trim()));
109
+ addChange(new schematics_core_1.InsertChange(sourceFile.fileName, devtoolsConfig.getEnd() - 1, `${comma} connectInZone: true`.trim()));
112
110
  }
113
111
  function replaceConnectOutsideZoneConfig(connectOutsideZone) {
114
- var currentValue = connectOutsideZone.initializer
112
+ const currentValue = connectOutsideZone.initializer
115
113
  .getText(sourceFile)
116
114
  .trim();
117
- addChange(createReplaceChange(sourceFile, connectOutsideZone.name, 'connectOutsideZone', 'connectInZone'));
118
- addChange(createReplaceChange(sourceFile, connectOutsideZone.initializer, currentValue, currentValue === 'true'
115
+ addChange((0, schematics_core_1.createReplaceChange)(sourceFile, connectOutsideZone.name, 'connectOutsideZone', 'connectInZone'));
116
+ addChange((0, schematics_core_1.createReplaceChange)(sourceFile, connectOutsideZone.initializer, currentValue, currentValue === 'true'
119
117
  ? 'false'
120
118
  : currentValue === 'false'
121
119
  ? 'true'
122
- : "!".concat(currentValue)));
120
+ : `!${currentValue}`));
123
121
  }
124
122
  }
125
123
  function createDevtoolsConfig(sourceFile, callExpression, addChange) {
126
- addChange(new InsertChange(sourceFile.fileName, callExpression.getEnd() - 1, "{connectInZone: true}"));
124
+ addChange(new schematics_core_1.InsertChange(sourceFile.fileName, callExpression.getEnd() - 1, `{connectInZone: true}`));
127
125
  }
128
- export default function () {
129
- return chain([migrate()]);
126
+ function default_1() {
127
+ return (0, schematics_1.chain)([migrate()]);
130
128
  }
131
129
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../modules/store-devtools/migrations/17_0_0-beta/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AACjC,OAAO,EAAQ,KAAK,EAAQ,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EACL,kBAAkB,EAClB,aAAa,EACb,YAAY,EAEZ,mBAAmB,GACpB,MAAM,wBAAwB,CAAC;AAEhC,SAAS,OAAO;IACd,OAAO,UAAC,IAAU;QAChB,kBAAkB,CAAC,IAAI,EAAE,UAAC,UAAU;YAClC,IAAM,eAAe,GAAG,UAAU,CAAC,UAAU;iBAC1C,MAAM,CAAC,EAAE,CAAC,mBAAmB,CAAC;iBAC9B,MAAM,CAAC,UAAC,EAAmB;oBAAjB,eAAe,qBAAA;gBACxB,OAAA,eAAe,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,QAAQ,CAAC,sBAAsB,CAAC;YAApE,CAAoE,CACrE,CAAC;YAEJ,IAAI,eAAe,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBACjC,OAAO;YACT,CAAC;YAED,IAAM,OAAO,4BAAO,oBAAoB,CAAC,UAAU,CAAC,SAAC,CAAC;YAEtD,aAAa,CAAC,IAAI,EAAE,UAAU,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QACpD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC;AAED,SAAS,oBA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AAC,CAAC,CAAC;AAC5B,CAAC","sourcesContent":["import * as ts from 'typescript';\nimport { Rule, chain, Tree } from '@angular-devkit/schematics';\nimport {\n visitTSSourceFiles,\n commitChanges,\n InsertChange,\n Change,\n createReplaceChange,\n} from '../..//schematics-core';\n\nfunction migrate() {\n return (tree: Tree) => {\n visitTSSourceFiles(tree, (sourceFile) => {\n const devtoolsImports = sourceFile.statements\n .filter(ts.isImportDeclaration)\n .filter(({ moduleSpecifier }) =>\n moduleSpecifier.getText(sourceFile).includes('@ngrx/store-devtools')\n );\n\n if (devtoolsImports.length === 0) {\n return;\n }\n\n const changes = [...findAndUpdateConfigs(sourceFile)];\n\n commitChanges(tree, sourceFile.fileName, changes);\n });\n };\n}\n\nfunction findAndUpdateConfigs(sourceFile: ts.SourceFile) {\n const changes: Change[] = [];\n ts.forEachChild(sourceFile, (node) => find(node, changes));\n return changes;\n\n function find(node: ts.Node, changes: Change[]) {\n if (\n ts.isPropertyAccessExpression(node) &&\n node.name.text === 'instrument' &&\n ts.isIdentifier(node.expression) &&\n node.expression.text === 'StoreDevtoolsModule' &&\n ts.isCallExpression(node.parent)\n ) {\n if (node.parent.arguments.length) {\n const [devtoolsConfig] = node.parent.arguments;\n\n if (ts.isObjectLiteralExpression(devtoolsConfig)) {\n updateConfig(sourceFile, devtoolsConfig, (change) =>\n changes.push(change)\n );\n }\n } else {\n createDevtoolsConfig(sourceFile, node.parent, (change) =>\n changes.push(change)\n );\n }\n }\n\n if (\n ts.isCallExpression(node) &&\n ts.isIdentifier(node.expression) &&\n node.expression.text === 'provideStoreDevtools'\n ) {\n if (node.arguments.length) {\n const [devtoolsConfig] = node.arguments;\n\n if (ts.isObjectLiteralExpression(devtoolsConfig)) {\n updateConfig(sourceFile, devtoolsConfig, (change) =>\n changes.push(change)\n );\n }\n } else {\n createDevtoolsConfig(sourceFile, node, (change) =>\n changes.push(change)\n );\n }\n }\n\n ts.forEachChild(node, (childNode) => find(childNode, changes));\n }\n}\n\nfunction updateConfig(\n sourceFile: ts.SourceFile,\n devtoolsConfig: ts.ObjectLiteralExpression,\n addChange: (changes: Change) => number\n) {\n const connectOutsideZoneProperty = devtoolsConfig.properties.find(\n (p) =>\n ts.isPropertyAssignment(p) &&\n ts.isIdentifier(p.name) &&\n p.name.text === 'connectOutsideZone'\n );\n\n if (!connectOutsideZoneProperty) {\n addConnectInZoneProperty();\n } else if (ts.isPropertyAssignment(connectOutsideZoneProperty)) {\n replaceConnectOutsideZoneConfig(connectOutsideZoneProperty);\n }\n\n function addConnectInZoneProperty() {\n const configText = devtoolsConfig.getText(sourceFile);\n const comma =\n !devtoolsConfig.properties.length ||\n configText\n .substring(0, configText.length - 1)\n .trim()\n .endsWith(',')\n ? ''\n : ',';\n\n addChange(\n new InsertChange(\n sourceFile.fileName,\n devtoolsConfig.getEnd() - 1,\n `${comma} connectInZone: true`.trim()\n )\n );\n }\n\n function replaceConnectOutsideZoneConfig(\n connectOutsideZone: ts.PropertyAssignment\n ) {\n const currentValue = connectOutsideZone.initializer\n .getText(sourceFile)\n .trim();\n addChange(\n createReplaceChange(\n sourceFile,\n connectOutsideZone.name,\n 'connectOutsideZone',\n 'connectInZone'\n )\n );\n addChange(\n createReplaceChange(\n sourceFile,\n connectOutsideZone.initializer,\n currentValue,\n currentValue === 'true'\n ? 'false'\n : currentValue === 'false'\n ? 'true'\n : `!${currentValue}`\n )\n );\n }\n}\n\nfunction createDevtoolsConfig(\n sourceFile: ts.SourceFile,\n callExpression: ts.CallExpression,\n addChange: (...items: Change[]) => number\n) {\n addChange(\n new InsertChange(\n sourceFile.fileName,\n callExpression.getEnd() - 1,\n `{connectInZone: true}`\n )\n );\n}\n\nexport default function (): Rule {\n return chain([migrate()]);\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../modules/store-devtools/migrations/17_0_0-beta/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmKA,4BAEC;AArKD,+CAAiC;AAC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,kBAAkB,CAAC,IAAI,EACvB,oBAAoB,EACpB,eAAe,CAChB,CACF,CAAC;QACF,SAAS,CACP,IAAA,qCAAmB,EACjB,UAAU,EACV,kBAAkB,CAAC,WAAW,EAC9B,YAAY,EACZ,YAAY,KAAK,MAAM;YACrB,CAAC,CAAC,OAAO;YACT,CAAC,CAAC,YAAY,KAAK,OAAO;gBACxB,CAAC,CAAC,MAAM;gBACR,CAAC,CAAC,IAAI,YAAY,EAAE,CACzB,CACF,CAAC;IACJ,CAAC;AACH,CAAC;AAED,SAAS,oBAAoB,CAC3B,UAAyB,EACzB,cAAiC,EACjC,SAAyC;IAEzC,SAAS,CACP,IAAI,8BAAY,CACd,UAAU,CAAC,QAAQ,EACnB,cAAc,CAAC,MAAM,EAAE,GAAG,CAAC,EAC3B,uBAAuB,CACxB,CACF,CAAC;AACJ,CAAC;AAED;IACE,OAAO,IAAA,kBAAK,EAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;AAC5B,CAAC","sourcesContent":["import * as ts from 'typescript';\nimport { Rule, chain, Tree } from '@angular-devkit/schematics';\nimport {\n visitTSSourceFiles,\n commitChanges,\n InsertChange,\n Change,\n createReplaceChange,\n} from '../..//schematics-core';\n\nfunction migrate() {\n return (tree: Tree) => {\n visitTSSourceFiles(tree, (sourceFile) => {\n const devtoolsImports = sourceFile.statements\n .filter(ts.isImportDeclaration)\n .filter(({ moduleSpecifier }) =>\n moduleSpecifier.getText(sourceFile).includes('@ngrx/store-devtools')\n );\n\n if (devtoolsImports.length === 0) {\n return;\n }\n\n const changes = [...findAndUpdateConfigs(sourceFile)];\n\n commitChanges(tree, sourceFile.fileName, changes);\n });\n };\n}\n\nfunction findAndUpdateConfigs(sourceFile: ts.SourceFile) {\n const changes: Change[] = [];\n ts.forEachChild(sourceFile, (node) => find(node, changes));\n return changes;\n\n function find(node: ts.Node, changes: Change[]) {\n if (\n ts.isPropertyAccessExpression(node) &&\n node.name.text === 'instrument' &&\n ts.isIdentifier(node.expression) &&\n node.expression.text === 'StoreDevtoolsModule' &&\n ts.isCallExpression(node.parent)\n ) {\n if (node.parent.arguments.length) {\n const [devtoolsConfig] = node.parent.arguments;\n\n if (ts.isObjectLiteralExpression(devtoolsConfig)) {\n updateConfig(sourceFile, devtoolsConfig, (change) =>\n changes.push(change)\n );\n }\n } else {\n createDevtoolsConfig(sourceFile, node.parent, (change) =>\n changes.push(change)\n );\n }\n }\n\n if (\n ts.isCallExpression(node) &&\n ts.isIdentifier(node.expression) &&\n node.expression.text === 'provideStoreDevtools'\n ) {\n if (node.arguments.length) {\n const [devtoolsConfig] = node.arguments;\n\n if (ts.isObjectLiteralExpression(devtoolsConfig)) {\n updateConfig(sourceFile, devtoolsConfig, (change) =>\n changes.push(change)\n );\n }\n } else {\n createDevtoolsConfig(sourceFile, node, (change) =>\n changes.push(change)\n );\n }\n }\n\n ts.forEachChild(node, (childNode) => find(childNode, changes));\n }\n}\n\nfunction updateConfig(\n sourceFile: ts.SourceFile,\n devtoolsConfig: ts.ObjectLiteralExpression,\n addChange: (changes: Change) => number\n) {\n const connectOutsideZoneProperty = devtoolsConfig.properties.find(\n (p) =>\n ts.isPropertyAssignment(p) &&\n ts.isIdentifier(p.name) &&\n p.name.text === 'connectOutsideZone'\n );\n\n if (!connectOutsideZoneProperty) {\n addConnectInZoneProperty();\n } else if (ts.isPropertyAssignment(connectOutsideZoneProperty)) {\n replaceConnectOutsideZoneConfig(connectOutsideZoneProperty);\n }\n\n function addConnectInZoneProperty() {\n const configText = devtoolsConfig.getText(sourceFile);\n const comma =\n !devtoolsConfig.properties.length ||\n configText\n .substring(0, configText.length - 1)\n .trim()\n .endsWith(',')\n ? ''\n : ',';\n\n addChange(\n new InsertChange(\n sourceFile.fileName,\n devtoolsConfig.getEnd() - 1,\n `${comma} connectInZone: true`.trim()\n )\n );\n }\n\n function replaceConnectOutsideZoneConfig(\n connectOutsideZone: ts.PropertyAssignment\n ) {\n const currentValue = connectOutsideZone.initializer\n .getText(sourceFile)\n .trim();\n addChange(\n createReplaceChange(\n sourceFile,\n connectOutsideZone.name,\n 'connectOutsideZone',\n 'connectInZone'\n )\n );\n addChange(\n createReplaceChange(\n sourceFile,\n connectOutsideZone.initializer,\n currentValue,\n currentValue === 'true'\n ? 'false'\n : currentValue === 'false'\n ? 'true'\n : `!${currentValue}`\n )\n );\n }\n}\n\nfunction createDevtoolsConfig(\n sourceFile: ts.SourceFile,\n callExpression: ts.CallExpression,\n addChange: (...items: Change[]) => number\n) {\n addChange(\n new InsertChange(\n sourceFile.fileName,\n callExpression.getEnd() - 1,\n `{connectInZone: true}`\n )\n );\n}\n\nexport default function (): Rule {\n return chain([migrate()]);\n}\n"]}
@@ -1,5 +1,8 @@
1
- import { updatePackage } from '../../schematics-core';
2
- export default function () {
3
- return updatePackage('store-devtools');
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = default_1;
4
+ const schematics_core_1 = require("../../schematics-core");
5
+ function default_1() {
6
+ return (0, schematics_core_1.updatePackage)('store-devtools');
4
7
  }
5
8
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../modules/store-devtools/migrations/6_0_0/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAEtD,MAAM,CAAC,OAAO;IACZ,OAAO,aAAa,CAAC,gBAAgB,CAAC,CAAC;AACzC,CAAC","sourcesContent":["import { Rule } from '@angular-devkit/schematics';\nimport { updatePackage } from '../../schematics-core';\n\nexport default function (): Rule {\n return updatePackage('store-devtools');\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../modules/store-devtools/migrations/6_0_0/index.ts"],"names":[],"mappings":";;AAGA,4BAEC;AAJD,2DAAsD;AAEtD;IACE,OAAO,IAAA,+BAAa,EAAC,gBAAgB,CAAC,CAAC;AACzC,CAAC","sourcesContent":["import { Rule } from '@angular-devkit/schematics';\nimport { updatePackage } from '../../schematics-core';\n\nexport default function (): Rule {\n return updatePackage('store-devtools');\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ngrx/store-devtools",
3
- "version": "21.0.0-beta.0",
3
+ "version": "21.0.0-rc.0",
4
4
  "description": "Developer tools for @ngrx/store",
5
5
  "repository": {
6
6
  "type": "git",
@@ -21,7 +21,7 @@
21
21
  "homepage": "https://github.com/ngrx/platform#readme",
22
22
  "peerDependencies": {
23
23
  "@angular/core": "^21.0.0",
24
- "@ngrx/store": "21.0.0-beta.0",
24
+ "@ngrx/store": "21.0.0-rc.0",
25
25
  "rxjs": "^6.5.3 || ^7.5.0"
26
26
  },
27
27
  "schematics": "./schematics/collection.json",
@@ -1,152 +1,139 @@
1
- var __read = (this && this.__read) || function (o, n) {
2
- var m = typeof Symbol === "function" && o[Symbol.iterator];
3
- if (!m) return o;
4
- var i = m.call(o), r, ar = [], e;
5
- try {
6
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
7
  }
8
- catch (error) { e = { error: error }; }
9
- finally {
10
- try {
11
- if (r && !r.done && (m = i["return"])) m.call(i);
12
- }
13
- finally { if (e) throw e.error; }
14
- }
15
- return ar;
16
- };
17
- var __values = (this && this.__values) || function(o) {
18
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
19
- if (m) return m.call(o);
20
- if (o && typeof o.length === "number") return {
21
- next: function () {
22
- if (o && i >= o.length) o = void 0;
23
- return { value: o && o[i++], done: !o };
24
- }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
25
26
  };
26
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
27
- };
28
- import * as ts from 'typescript';
29
- import { SchematicsException, branchAndMerge, chain, noop, } from '@angular-devkit/schematics';
30
- import { NodePackageInstallTask } from '@angular-devkit/schematics/tasks';
31
- import { InsertChange, addImportToModule, findModuleFromOptions, getProjectPath, insertImport, addPackageToPackageJson, platformVersion, parseName, } from '../../schematics-core';
32
- import { addFunctionalProvidersToStandaloneBootstrap, callsProvidersFunction, } from '../../schematics-core/utility/standalone';
33
- import { getProjectMainFile } from '../../schematics-core/utility/project';
34
- import { isStandaloneApp } from '@schematics/angular/utility/ng-ast-utils';
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.default = default_1;
37
+ const ts = __importStar(require("typescript"));
38
+ const schematics_1 = require("@angular-devkit/schematics");
39
+ const tasks_1 = require("@angular-devkit/schematics/tasks");
40
+ const schematics_core_1 = require("../../schematics-core");
41
+ const standalone_1 = require("../../schematics-core/utility/standalone");
42
+ const project_1 = require("../../schematics-core/utility/project");
43
+ const ng_ast_utils_1 = require("@schematics/angular/utility/ng-ast-utils");
35
44
  function addImportToNgModule(options) {
36
- return function (host) {
37
- var e_1, _a;
38
- var modulePath = options.module;
45
+ return (host) => {
46
+ const modulePath = options.module;
39
47
  if (!modulePath) {
40
48
  return host;
41
49
  }
42
50
  if (!host.exists(modulePath)) {
43
51
  throw new Error('Specified module does not exist');
44
52
  }
45
- var text = host.read(modulePath);
53
+ const text = host.read(modulePath);
46
54
  if (text === null) {
47
- throw new SchematicsException("File ".concat(modulePath, " does not exist."));
55
+ throw new schematics_1.SchematicsException(`File ${modulePath} does not exist.`);
48
56
  }
49
- var sourceText = text.toString('utf-8');
50
- var source = ts.createSourceFile(modulePath, sourceText, ts.ScriptTarget.Latest, true);
51
- var _b = __read(addImportToModule(source, modulePath, "StoreDevtoolsModule.instrument({ maxAge: ".concat(options.maxAge, ", logOnly: !isDevMode() })"), modulePath), 1), instrumentNgModuleImport = _b[0];
52
- var changes = [
53
- insertImport(source, modulePath, 'StoreDevtoolsModule', '@ngrx/store-devtools'),
54
- insertImport(source, modulePath, 'isDevMode', '@angular/core'),
57
+ const sourceText = text.toString('utf-8');
58
+ const source = ts.createSourceFile(modulePath, sourceText, ts.ScriptTarget.Latest, true);
59
+ const [instrumentNgModuleImport] = (0, schematics_core_1.addImportToModule)(source, modulePath, `StoreDevtoolsModule.instrument({ maxAge: ${options.maxAge}, logOnly: !isDevMode() })`, modulePath);
60
+ const changes = [
61
+ (0, schematics_core_1.insertImport)(source, modulePath, 'StoreDevtoolsModule', '@ngrx/store-devtools'),
62
+ (0, schematics_core_1.insertImport)(source, modulePath, 'isDevMode', '@angular/core'),
55
63
  instrumentNgModuleImport,
56
64
  ];
57
- var recorder = host.beginUpdate(modulePath);
58
- try {
59
- for (var changes_1 = __values(changes), changes_1_1 = changes_1.next(); !changes_1_1.done; changes_1_1 = changes_1.next()) {
60
- var change = changes_1_1.value;
61
- if (change instanceof InsertChange) {
62
- recorder.insertLeft(change.pos, change.toAdd);
63
- }
65
+ const recorder = host.beginUpdate(modulePath);
66
+ for (const change of changes) {
67
+ if (change instanceof schematics_core_1.InsertChange) {
68
+ recorder.insertLeft(change.pos, change.toAdd);
64
69
  }
65
70
  }
66
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
67
- finally {
68
- try {
69
- if (changes_1_1 && !changes_1_1.done && (_a = changes_1.return)) _a.call(changes_1);
70
- }
71
- finally { if (e_1) throw e_1.error; }
72
- }
73
71
  host.commitUpdate(recorder);
74
72
  return host;
75
73
  };
76
74
  }
77
75
  function addNgRxStoreDevToolsToPackageJson() {
78
- return function (host, context) {
79
- addPackageToPackageJson(host, 'dependencies', '@ngrx/store-devtools', platformVersion);
80
- context.addTask(new NodePackageInstallTask());
76
+ return (host, context) => {
77
+ (0, schematics_core_1.addPackageToPackageJson)(host, 'dependencies', '@ngrx/store-devtools', schematics_core_1.platformVersion);
78
+ context.addTask(new tasks_1.NodePackageInstallTask());
81
79
  return host;
82
80
  };
83
81
  }
84
82
  function addStandaloneConfig(options) {
85
- return function (host) {
86
- var e_2, _a;
87
- var mainFile = getProjectMainFile(host, options);
83
+ return (host) => {
84
+ const mainFile = (0, project_1.getProjectMainFile)(host, options);
88
85
  if (host.exists(mainFile)) {
89
- var providerFn = 'provideStoreDevtools';
90
- if (callsProvidersFunction(host, mainFile, providerFn)) {
86
+ const providerFn = 'provideStoreDevtools';
87
+ if ((0, standalone_1.callsProvidersFunction)(host, mainFile, providerFn)) {
91
88
  // exit because the store config is already provided
92
89
  return host;
93
90
  }
94
- var providerOptions = [
95
- ts.factory.createIdentifier("{ maxAge: ".concat(options.maxAge, ", logOnly: !isDevMode() }")),
91
+ const providerOptions = [
92
+ ts.factory.createIdentifier(`{ maxAge: ${options.maxAge}, logOnly: !isDevMode() }`),
96
93
  ];
97
- var patchedConfigFile = addFunctionalProvidersToStandaloneBootstrap(host, mainFile, providerFn, '@ngrx/store-devtools', providerOptions);
94
+ const patchedConfigFile = (0, standalone_1.addFunctionalProvidersToStandaloneBootstrap)(host, mainFile, providerFn, '@ngrx/store-devtools', providerOptions);
98
95
  // insert reducers import into the patched file
99
- var configFileContent = host.read(patchedConfigFile);
100
- var source = ts.createSourceFile(patchedConfigFile, (configFileContent === null || configFileContent === void 0 ? void 0 : configFileContent.toString('utf-8')) || '', ts.ScriptTarget.Latest, true);
101
- var recorder = host.beginUpdate(patchedConfigFile);
102
- var changes = [
103
- insertImport(source, patchedConfigFile, 'isDevMode', '@angular/core'),
96
+ const configFileContent = host.read(patchedConfigFile);
97
+ const source = ts.createSourceFile(patchedConfigFile, configFileContent?.toString('utf-8') || '', ts.ScriptTarget.Latest, true);
98
+ const recorder = host.beginUpdate(patchedConfigFile);
99
+ const changes = [
100
+ (0, schematics_core_1.insertImport)(source, patchedConfigFile, 'isDevMode', '@angular/core'),
104
101
  ];
105
- try {
106
- for (var changes_2 = __values(changes), changes_2_1 = changes_2.next(); !changes_2_1.done; changes_2_1 = changes_2.next()) {
107
- var change = changes_2_1.value;
108
- if (change instanceof InsertChange) {
109
- recorder.insertLeft(change.pos, change.toAdd);
110
- }
111
- }
112
- }
113
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
114
- finally {
115
- try {
116
- if (changes_2_1 && !changes_2_1.done && (_a = changes_2.return)) _a.call(changes_2);
102
+ for (const change of changes) {
103
+ if (change instanceof schematics_core_1.InsertChange) {
104
+ recorder.insertLeft(change.pos, change.toAdd);
117
105
  }
118
- finally { if (e_2) throw e_2.error; }
119
106
  }
120
107
  host.commitUpdate(recorder);
121
108
  return host;
122
109
  }
123
- throw new SchematicsException("Main file not found for a project ".concat(options.project));
110
+ throw new schematics_1.SchematicsException(`Main file not found for a project ${options.project}`);
124
111
  };
125
112
  }
126
- export default function (options) {
127
- return function (host, context) {
128
- var mainFile = getProjectMainFile(host, options);
129
- var isStandalone = isStandaloneApp(host, mainFile);
130
- options.path = getProjectPath(host, options);
113
+ function default_1(options) {
114
+ return (host, context) => {
115
+ const mainFile = (0, project_1.getProjectMainFile)(host, options);
116
+ const isStandalone = (0, ng_ast_utils_1.isStandaloneApp)(host, mainFile);
117
+ options.path = (0, schematics_core_1.getProjectPath)(host, options);
131
118
  if (options.module && !isStandalone) {
132
- options.module = findModuleFromOptions(host, {
119
+ options.module = (0, schematics_core_1.findModuleFromOptions)(host, {
133
120
  name: '',
134
121
  module: options.module,
135
122
  path: options.path,
136
123
  });
137
124
  }
138
- var parsedPath = parseName(options.path, '');
125
+ const parsedPath = (0, schematics_core_1.parseName)(options.path, '');
139
126
  options.path = parsedPath.path;
140
127
  if (options.maxAge && (options.maxAge < 0 || options.maxAge === 1)) {
141
- throw new SchematicsException("maxAge should be an integer greater than 1.");
128
+ throw new schematics_1.SchematicsException(`maxAge should be an integer greater than 1.`);
142
129
  }
143
- var configOrModuleUpdate = isStandalone
130
+ const configOrModuleUpdate = isStandalone
144
131
  ? addStandaloneConfig(options)
145
132
  : addImportToNgModule(options);
146
- return chain([
147
- branchAndMerge(chain([configOrModuleUpdate])),
133
+ return (0, schematics_1.chain)([
134
+ (0, schematics_1.branchAndMerge)((0, schematics_1.chain)([configOrModuleUpdate])),
148
135
  options && options.skipPackageJson
149
- ? noop()
136
+ ? (0, schematics_1.noop)()
150
137
  : addNgRxStoreDevToolsToPackageJson(),
151
138
  ])(host, context);
152
139
  };
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../modules/store-devtools/schematics/ng-add/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AACjC,OAAO,EAGL,mBAAmB,EAEnB,cAAc,EACd,KAAK,EACL,IAAI,GACL,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;AAC1E,OAAO,EACL,YAAY,EACZ,iBAAiB,EACjB,qBAAqB,EACrB,cAAc,EACd,YAAY,EACZ,uBAAuB,EACvB,eAAe,EACf,SAAS,GACV,MAAM,uBAA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,IAAI,CAAC,YAAY,EAAE,CAAC;YACpC,OAAO,CAAC,MAAM,GAAG,qBAAqB,CAAC,IAAI,EAAE;gBAC3C,IAAI,EAAE,EAAE;gBACR,MAAM,EAAE,OAAO,CAAC,MAAM;gBACtB,IAAI,EAAE,OAAO,CAAC,IAAI;aACnB,CAAC,CAAC;QACL,CAAC;QAED,IAAM,UAAU,GAAG,SAAS,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QAC/C,OAAO,CAAC,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC;QAE/B,IAAI,OAAO,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,CAAC,EAAE,CAAC;YACnE,MAAM,IAAI,mBAAmB,CAC3B,6CAA6C,CAC9C,CAAC;QACJ,CAAC;QAED,IAAM,oBAAoB,GAAG,YAAY;YACvC,CAAC,CAAC,mBAAmB,CAAC,OAAO,CAAC;YAC9B,CAAC,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAC;QAEjC,OAAO,KAAK,CAAC;YACX,cAAc,CAAC,KAAK,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC;YAC7C,OAAO,IAAI,OAAO,CAAC,eAAe;gBAChC,CAAC,CAAC,IAAI,EAAE;gBACR,CAAC,CAAC,iCAAiC,EAAE;SACxC,CAAC,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACpB,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import * as ts from 'typescript';\nimport {\n Rule,\n SchematicContext,\n SchematicsException,\n Tree,\n branchAndMerge,\n chain,\n noop,\n} from '@angular-devkit/schematics';\nimport { NodePackageInstallTask } from '@angular-devkit/schematics/tasks';\nimport {\n InsertChange,\n addImportToModule,\n findModuleFromOptions,\n getProjectPath,\n insertImport,\n addPackageToPackageJson,\n platformVersion,\n parseName,\n} from '../../schematics-core';\nimport { Schema as StoreDevtoolsOptions } from './schema';\nimport {\n addFunctionalProvidersToStandaloneBootstrap,\n callsProvidersFunction,\n} from '../../schematics-core/utility/standalone';\nimport { getProjectMainFile } from '../../schematics-core/utility/project';\nimport { isStandaloneApp } from '@schematics/angular/utility/ng-ast-utils';\n\nfunction addImportToNgModule(options: StoreDevtoolsOptions): Rule {\n return (host: Tree) => {\n const modulePath = options.module;\n\n if (!modulePath) {\n return host;\n }\n\n if (!host.exists(modulePath)) {\n throw new Error('Specified module does not exist');\n }\n\n const text = host.read(modulePath);\n if (text === null) {\n throw new SchematicsException(`File ${modulePath} does not exist.`);\n }\n const sourceText = text.toString('utf-8');\n\n const source = ts.createSourceFile(\n modulePath,\n sourceText,\n ts.ScriptTarget.Latest,\n true\n );\n\n const [instrumentNgModuleImport] = addImportToModule(\n source,\n modulePath,\n `StoreDevtoolsModule.instrument({ maxAge: ${options.maxAge}, logOnly: !isDevMode() })`,\n modulePath\n );\n\n const changes = [\n insertImport(\n source,\n modulePath,\n 'StoreDevtoolsModule',\n '@ngrx/store-devtools'\n ),\n insertImport(source, modulePath, 'isDevMode', '@angular/core'),\n instrumentNgModuleImport,\n ];\n const recorder = host.beginUpdate(modulePath);\n\n for (const change of changes) {\n if (change instanceof InsertChange) {\n recorder.insertLeft(change.pos, change.toAdd);\n }\n }\n host.commitUpdate(recorder);\n\n return host;\n };\n}\n\nfunction addNgRxStoreDevToolsToPackageJson() {\n return (host: Tree, context: SchematicContext) => {\n addPackageToPackageJson(\n host,\n 'dependencies',\n '@ngrx/store-devtools',\n platformVersion\n );\n context.addTask(new NodePackageInstallTask());\n return host;\n };\n}\n\nfunction addStandaloneConfig(options: StoreDevtoolsOptions): Rule {\n return (host: Tree) => {\n const mainFile = getProjectMainFile(host, options);\n\n if (host.exists(mainFile)) {\n const providerFn = 'provideStoreDevtools';\n\n if (callsProvidersFunction(host, mainFile, providerFn)) {\n // exit because the store config is already provided\n return host;\n }\n\n const providerOptions = [\n ts.factory.createIdentifier(\n `{ maxAge: ${options.maxAge}, logOnly: !isDevMode() }`\n ),\n ];\n\n const patchedConfigFile = addFunctionalProvidersToStandaloneBootstrap(\n host,\n mainFile,\n providerFn,\n '@ngrx/store-devtools',\n providerOptions\n );\n\n // insert reducers import into the patched file\n const configFileContent = host.read(patchedConfigFile);\n const source = ts.createSourceFile(\n patchedConfigFile,\n configFileContent?.toString('utf-8') || '',\n ts.ScriptTarget.Latest,\n true\n );\n\n const recorder = host.beginUpdate(patchedConfigFile);\n\n const changes = [\n insertImport(source, patchedConfigFile, 'isDevMode', '@angular/core'),\n ];\n\n for (const change of changes) {\n if (change instanceof InsertChange) {\n recorder.insertLeft(change.pos, change.toAdd);\n }\n }\n\n host.commitUpdate(recorder);\n\n return host;\n }\n\n throw new SchematicsException(\n `Main file not found for a project ${options.project}`\n );\n };\n}\n\nexport default function (options: StoreDevtoolsOptions): Rule {\n return (host: Tree, context: SchematicContext) => {\n const mainFile = getProjectMainFile(host, options);\n const isStandalone = isStandaloneApp(host, mainFile);\n\n options.path = getProjectPath(host, options);\n\n if (options.module && !isStandalone) {\n options.module = findModuleFromOptions(host, {\n name: '',\n module: options.module,\n path: options.path,\n });\n }\n\n const parsedPath = parseName(options.path, '');\n options.path = parsedPath.path;\n\n if (options.maxAge && (options.maxAge < 0 || options.maxAge === 1)) {\n throw new SchematicsException(\n `maxAge should be an integer greater than 1.`\n );\n }\n\n const configOrModuleUpdate = isStandalone\n ? addStandaloneConfig(options)\n : addImportToNgModule(options);\n\n return chain([\n branchAndMerge(chain([configOrModuleUpdate])),\n options && options.skipPackageJson\n ? noop()\n : addNgRxStoreDevToolsToPackageJson(),\n ])(host, context);\n };\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../modules/store-devtools/schematics/ng-add/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2JA,4BAmCC;AA9LD,+CAAiC;AACjC,2DAQoC;AACpC,4DAA0E;AAC1E,2DAS+B;AAE/B,yEAGkD;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AC;QACL,CAAC;QAED,MAAM,UAAU,GAAG,IAAA,2BAAS,EAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QAC/C,OAAO,CAAC,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC;QAE/B,IAAI,OAAO,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,CAAC,EAAE,CAAC;YACnE,MAAM,IAAI,gCAAmB,CAC3B,6CAA6C,CAC9C,CAAC;QACJ,CAAC;QAED,MAAM,oBAAoB,GAAG,YAAY;YACvC,CAAC,CAAC,mBAAmB,CAAC,OAAO,CAAC;YAC9B,CAAC,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAC;QAEjC,OAAO,IAAA,kBAAK,EAAC;YACX,IAAA,2BAAc,EAAC,IAAA,kBAAK,EAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC;YAC7C,OAAO,IAAI,OAAO,CAAC,eAAe;gBAChC,CAAC,CAAC,IAAA,iBAAI,GAAE;gBACR,CAAC,CAAC,iCAAiC,EAAE;SACxC,CAAC,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACpB,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import * as ts from 'typescript';\nimport {\n Rule,\n SchematicContext,\n SchematicsException,\n Tree,\n branchAndMerge,\n chain,\n noop,\n} from '@angular-devkit/schematics';\nimport { NodePackageInstallTask } from '@angular-devkit/schematics/tasks';\nimport {\n InsertChange,\n addImportToModule,\n findModuleFromOptions,\n getProjectPath,\n insertImport,\n addPackageToPackageJson,\n platformVersion,\n parseName,\n} from '../../schematics-core';\nimport { Schema as StoreDevtoolsOptions } from './schema';\nimport {\n addFunctionalProvidersToStandaloneBootstrap,\n callsProvidersFunction,\n} from '../../schematics-core/utility/standalone';\nimport { getProjectMainFile } from '../../schematics-core/utility/project';\nimport { isStandaloneApp } from '@schematics/angular/utility/ng-ast-utils';\n\nfunction addImportToNgModule(options: StoreDevtoolsOptions): Rule {\n return (host: Tree) => {\n const modulePath = options.module;\n\n if (!modulePath) {\n return host;\n }\n\n if (!host.exists(modulePath)) {\n throw new Error('Specified module does not exist');\n }\n\n const text = host.read(modulePath);\n if (text === null) {\n throw new SchematicsException(`File ${modulePath} does not exist.`);\n }\n const sourceText = text.toString('utf-8');\n\n const source = ts.createSourceFile(\n modulePath,\n sourceText,\n ts.ScriptTarget.Latest,\n true\n );\n\n const [instrumentNgModuleImport] = addImportToModule(\n source,\n modulePath,\n `StoreDevtoolsModule.instrument({ maxAge: ${options.maxAge}, logOnly: !isDevMode() })`,\n modulePath\n );\n\n const changes = [\n insertImport(\n source,\n modulePath,\n 'StoreDevtoolsModule',\n '@ngrx/store-devtools'\n ),\n insertImport(source, modulePath, 'isDevMode', '@angular/core'),\n instrumentNgModuleImport,\n ];\n const recorder = host.beginUpdate(modulePath);\n\n for (const change of changes) {\n if (change instanceof InsertChange) {\n recorder.insertLeft(change.pos, change.toAdd);\n }\n }\n host.commitUpdate(recorder);\n\n return host;\n };\n}\n\nfunction addNgRxStoreDevToolsToPackageJson() {\n return (host: Tree, context: SchematicContext) => {\n addPackageToPackageJson(\n host,\n 'dependencies',\n '@ngrx/store-devtools',\n platformVersion\n );\n context.addTask(new NodePackageInstallTask());\n return host;\n };\n}\n\nfunction addStandaloneConfig(options: StoreDevtoolsOptions): Rule {\n return (host: Tree) => {\n const mainFile = getProjectMainFile(host, options);\n\n if (host.exists(mainFile)) {\n const providerFn = 'provideStoreDevtools';\n\n if (callsProvidersFunction(host, mainFile, providerFn)) {\n // exit because the store config is already provided\n return host;\n }\n\n const providerOptions = [\n ts.factory.createIdentifier(\n `{ maxAge: ${options.maxAge}, logOnly: !isDevMode() }`\n ),\n ];\n\n const patchedConfigFile = addFunctionalProvidersToStandaloneBootstrap(\n host,\n mainFile,\n providerFn,\n '@ngrx/store-devtools',\n providerOptions\n );\n\n // insert reducers import into the patched file\n const configFileContent = host.read(patchedConfigFile);\n const source = ts.createSourceFile(\n patchedConfigFile,\n configFileContent?.toString('utf-8') || '',\n ts.ScriptTarget.Latest,\n true\n );\n\n const recorder = host.beginUpdate(patchedConfigFile);\n\n const changes = [\n insertImport(source, patchedConfigFile, 'isDevMode', '@angular/core'),\n ];\n\n for (const change of changes) {\n if (change instanceof InsertChange) {\n recorder.insertLeft(change.pos, change.toAdd);\n }\n }\n\n host.commitUpdate(recorder);\n\n return host;\n }\n\n throw new SchematicsException(\n `Main file not found for a project ${options.project}`\n );\n };\n}\n\nexport default function (options: StoreDevtoolsOptions): Rule {\n return (host: Tree, context: SchematicContext) => {\n const mainFile = getProjectMainFile(host, options);\n const isStandalone = isStandaloneApp(host, mainFile);\n\n options.path = getProjectPath(host, options);\n\n if (options.module && !isStandalone) {\n options.module = findModuleFromOptions(host, {\n name: '',\n module: options.module,\n path: options.path,\n });\n }\n\n const parsedPath = parseName(options.path, '');\n options.path = parsedPath.path;\n\n if (options.maxAge && (options.maxAge < 0 || options.maxAge === 1)) {\n throw new SchematicsException(\n `maxAge should be an integer greater than 1.`\n );\n }\n\n const configOrModuleUpdate = isStandalone\n ? addStandaloneConfig(options)\n : addImportToNgModule(options);\n\n return chain([\n branchAndMerge(chain([configOrModuleUpdate])),\n options && options.skipPackageJson\n ? noop()\n : addNgRxStoreDevToolsToPackageJson(),\n ])(host, context);\n };\n}\n"]}
@@ -1 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
1
3
  //# sourceMappingURL=schema.js.map