@ngrx/store-devtools 20.0.1 → 21.0.0-beta.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.
- package/fesm2022/ngrx-store-devtools.mjs +13 -13
- package/fesm2022/ngrx-store-devtools.mjs.map +1 -1
- package/migrations/17_0_0-beta/index.js +11 -14
- package/migrations/17_0_0-beta/index.js.map +1 -1
- package/migrations/6_0_0/index.js +3 -6
- package/migrations/6_0_0/index.js.map +1 -1
- package/package.json +5 -5
- package/schematics/ng-add/index.js +30 -33
- package/schematics/ng-add/index.js.map +1 -1
- package/schematics/ng-add/schema.js +0 -2
- package/schematics-core/index.js +24 -75
- package/schematics-core/index.js.map +1 -1
- package/schematics-core/utility/ast-utils.js +28 -44
- package/schematics-core/utility/ast-utils.js.map +1 -1
- package/schematics-core/utility/change.js +8 -15
- package/schematics-core/utility/change.js.map +1 -1
- package/schematics-core/utility/config.js +4 -8
- package/schematics-core/utility/config.js.map +1 -1
- package/schematics-core/utility/find-component.js +17 -22
- package/schematics-core/utility/find-component.js.map +1 -1
- package/schematics-core/utility/find-module.js +19 -24
- package/schematics-core/utility/find-module.js.map +1 -1
- package/schematics-core/utility/json-utilts.js +1 -4
- package/schematics-core/utility/json-utilts.js.map +1 -1
- package/schematics-core/utility/libs-version.js +1 -4
- package/schematics-core/utility/libs-version.js.map +1 -1
- package/schematics-core/utility/ngrx-utils.js +28 -36
- package/schematics-core/utility/ngrx-utils.js.map +1 -1
- package/schematics-core/utility/package.js +1 -4
- package/schematics-core/utility/package.js.map +1 -1
- package/schematics-core/utility/parse-name.js +5 -8
- package/schematics-core/utility/parse-name.js.map +1 -1
- package/schematics-core/utility/project.js +9 -15
- package/schematics-core/utility/project.js.map +1 -1
- package/schematics-core/utility/standalone.js +13 -18
- package/schematics-core/utility/standalone.js.map +1 -1
- package/schematics-core/utility/strings.js +9 -20
- package/schematics-core/utility/strings.js.map +1 -1
- package/schematics-core/utility/update.js +4 -7
- package/schematics-core/utility/update.js.map +1 -1
- package/schematics-core/utility/visitors.js +16 -30
- package/schematics-core/utility/visitors.js.map +1 -1
- package/types/ngrx-store-devtools.d.ts +252 -0
- package/index.d.ts +0 -6
- package/public_api.d.ts +0 -1
- package/src/actions.d.ts +0 -79
- package/src/config.d.ts +0 -126
- package/src/devtools-dispatcher.d.ts +0 -6
- package/src/devtools.d.ts +0 -35
- package/src/extension.d.ts +0 -52
- package/src/index.d.ts +0 -6
- package/src/instrument.d.ts +0 -9
- package/src/provide-store-devtools.d.ts +0 -26
- package/src/reducer.d.ts +0 -47
- package/src/utils.d.ts +0 -42
- package/src/zone-config.d.ts +0 -9
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ngrx/store-devtools",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "21.0.0-beta.0",
|
|
4
4
|
"description": "Developer tools for @ngrx/store",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
},
|
|
21
21
|
"homepage": "https://github.com/ngrx/platform#readme",
|
|
22
22
|
"peerDependencies": {
|
|
23
|
-
"@angular/core": "^
|
|
24
|
-
"@ngrx/store": "
|
|
23
|
+
"@angular/core": "^21.0.0",
|
|
24
|
+
"@ngrx/store": "21.0.0-beta.0",
|
|
25
25
|
"rxjs": "^6.5.3 || ^7.5.0"
|
|
26
26
|
},
|
|
27
27
|
"schematics": "./schematics/collection.json",
|
|
@@ -48,13 +48,13 @@
|
|
|
48
48
|
"tslib": "^2.0.0"
|
|
49
49
|
},
|
|
50
50
|
"module": "fesm2022/ngrx-store-devtools.mjs",
|
|
51
|
-
"typings": "
|
|
51
|
+
"typings": "types/ngrx-store-devtools.d.ts",
|
|
52
52
|
"exports": {
|
|
53
53
|
"./package.json": {
|
|
54
54
|
"default": "./package.json"
|
|
55
55
|
},
|
|
56
56
|
".": {
|
|
57
|
-
"types": "./
|
|
57
|
+
"types": "./types/ngrx-store-devtools.d.ts",
|
|
58
58
|
"default": "./fesm2022/ngrx-store-devtools.mjs"
|
|
59
59
|
}
|
|
60
60
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __read = (this && this.__read) || function (o, n) {
|
|
3
2
|
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
4
3
|
if (!m) return o;
|
|
@@ -26,15 +25,13 @@ var __values = (this && this.__values) || function(o) {
|
|
|
26
25
|
};
|
|
27
26
|
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
28
27
|
};
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
var project_1 = require("../../schematics-core/utility/project");
|
|
37
|
-
var ng_ast_utils_1 = require("@schematics/angular/utility/ng-ast-utils");
|
|
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';
|
|
38
35
|
function addImportToNgModule(options) {
|
|
39
36
|
return function (host) {
|
|
40
37
|
var e_1, _a;
|
|
@@ -47,21 +44,21 @@ function addImportToNgModule(options) {
|
|
|
47
44
|
}
|
|
48
45
|
var text = host.read(modulePath);
|
|
49
46
|
if (text === null) {
|
|
50
|
-
throw new
|
|
47
|
+
throw new SchematicsException("File ".concat(modulePath, " does not exist."));
|
|
51
48
|
}
|
|
52
49
|
var sourceText = text.toString('utf-8');
|
|
53
50
|
var source = ts.createSourceFile(modulePath, sourceText, ts.ScriptTarget.Latest, true);
|
|
54
|
-
var _b = __read(
|
|
51
|
+
var _b = __read(addImportToModule(source, modulePath, "StoreDevtoolsModule.instrument({ maxAge: ".concat(options.maxAge, ", logOnly: !isDevMode() })"), modulePath), 1), instrumentNgModuleImport = _b[0];
|
|
55
52
|
var changes = [
|
|
56
|
-
|
|
57
|
-
|
|
53
|
+
insertImport(source, modulePath, 'StoreDevtoolsModule', '@ngrx/store-devtools'),
|
|
54
|
+
insertImport(source, modulePath, 'isDevMode', '@angular/core'),
|
|
58
55
|
instrumentNgModuleImport,
|
|
59
56
|
];
|
|
60
57
|
var recorder = host.beginUpdate(modulePath);
|
|
61
58
|
try {
|
|
62
59
|
for (var changes_1 = __values(changes), changes_1_1 = changes_1.next(); !changes_1_1.done; changes_1_1 = changes_1.next()) {
|
|
63
60
|
var change = changes_1_1.value;
|
|
64
|
-
if (change instanceof
|
|
61
|
+
if (change instanceof InsertChange) {
|
|
65
62
|
recorder.insertLeft(change.pos, change.toAdd);
|
|
66
63
|
}
|
|
67
64
|
}
|
|
@@ -79,36 +76,36 @@ function addImportToNgModule(options) {
|
|
|
79
76
|
}
|
|
80
77
|
function addNgRxStoreDevToolsToPackageJson() {
|
|
81
78
|
return function (host, context) {
|
|
82
|
-
|
|
83
|
-
context.addTask(new
|
|
79
|
+
addPackageToPackageJson(host, 'dependencies', '@ngrx/store-devtools', platformVersion);
|
|
80
|
+
context.addTask(new NodePackageInstallTask());
|
|
84
81
|
return host;
|
|
85
82
|
};
|
|
86
83
|
}
|
|
87
84
|
function addStandaloneConfig(options) {
|
|
88
85
|
return function (host) {
|
|
89
86
|
var e_2, _a;
|
|
90
|
-
var mainFile =
|
|
87
|
+
var mainFile = getProjectMainFile(host, options);
|
|
91
88
|
if (host.exists(mainFile)) {
|
|
92
89
|
var providerFn = 'provideStoreDevtools';
|
|
93
|
-
if (
|
|
90
|
+
if (callsProvidersFunction(host, mainFile, providerFn)) {
|
|
94
91
|
// exit because the store config is already provided
|
|
95
92
|
return host;
|
|
96
93
|
}
|
|
97
94
|
var providerOptions = [
|
|
98
95
|
ts.factory.createIdentifier("{ maxAge: ".concat(options.maxAge, ", logOnly: !isDevMode() }")),
|
|
99
96
|
];
|
|
100
|
-
var patchedConfigFile =
|
|
97
|
+
var patchedConfigFile = addFunctionalProvidersToStandaloneBootstrap(host, mainFile, providerFn, '@ngrx/store-devtools', providerOptions);
|
|
101
98
|
// insert reducers import into the patched file
|
|
102
99
|
var configFileContent = host.read(patchedConfigFile);
|
|
103
100
|
var source = ts.createSourceFile(patchedConfigFile, (configFileContent === null || configFileContent === void 0 ? void 0 : configFileContent.toString('utf-8')) || '', ts.ScriptTarget.Latest, true);
|
|
104
101
|
var recorder = host.beginUpdate(patchedConfigFile);
|
|
105
102
|
var changes = [
|
|
106
|
-
|
|
103
|
+
insertImport(source, patchedConfigFile, 'isDevMode', '@angular/core'),
|
|
107
104
|
];
|
|
108
105
|
try {
|
|
109
106
|
for (var changes_2 = __values(changes), changes_2_1 = changes_2.next(); !changes_2_1.done; changes_2_1 = changes_2.next()) {
|
|
110
107
|
var change = changes_2_1.value;
|
|
111
|
-
if (change instanceof
|
|
108
|
+
if (change instanceof InsertChange) {
|
|
112
109
|
recorder.insertLeft(change.pos, change.toAdd);
|
|
113
110
|
}
|
|
114
111
|
}
|
|
@@ -123,33 +120,33 @@ function addStandaloneConfig(options) {
|
|
|
123
120
|
host.commitUpdate(recorder);
|
|
124
121
|
return host;
|
|
125
122
|
}
|
|
126
|
-
throw new
|
|
123
|
+
throw new SchematicsException("Main file not found for a project ".concat(options.project));
|
|
127
124
|
};
|
|
128
125
|
}
|
|
129
|
-
function
|
|
126
|
+
export default function (options) {
|
|
130
127
|
return function (host, context) {
|
|
131
|
-
var mainFile =
|
|
132
|
-
var isStandalone =
|
|
133
|
-
options.path =
|
|
128
|
+
var mainFile = getProjectMainFile(host, options);
|
|
129
|
+
var isStandalone = isStandaloneApp(host, mainFile);
|
|
130
|
+
options.path = getProjectPath(host, options);
|
|
134
131
|
if (options.module && !isStandalone) {
|
|
135
|
-
options.module =
|
|
132
|
+
options.module = findModuleFromOptions(host, {
|
|
136
133
|
name: '',
|
|
137
134
|
module: options.module,
|
|
138
135
|
path: options.path,
|
|
139
136
|
});
|
|
140
137
|
}
|
|
141
|
-
var parsedPath =
|
|
138
|
+
var parsedPath = parseName(options.path, '');
|
|
142
139
|
options.path = parsedPath.path;
|
|
143
140
|
if (options.maxAge && (options.maxAge < 0 || options.maxAge === 1)) {
|
|
144
|
-
throw new
|
|
141
|
+
throw new SchematicsException("maxAge should be an integer greater than 1.");
|
|
145
142
|
}
|
|
146
143
|
var configOrModuleUpdate = isStandalone
|
|
147
144
|
? addStandaloneConfig(options)
|
|
148
145
|
: addImportToNgModule(options);
|
|
149
|
-
return
|
|
150
|
-
|
|
146
|
+
return chain([
|
|
147
|
+
branchAndMerge(chain([configOrModuleUpdate])),
|
|
151
148
|
options && options.skipPackageJson
|
|
152
|
-
?
|
|
149
|
+
? noop()
|
|
153
150
|
: addNgRxStoreDevToolsToPackageJson(),
|
|
154
151
|
])(host, context);
|
|
155
152
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../modules/store-devtools/schematics/ng-add/index.ts"],"names":[],"mappings":"
|
|
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,q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AAI,GAAG,cAAc,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAE7C,IAAI,OAAO,CAAC,MAAM,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"]}
|
package/schematics-core/index.js
CHANGED
|
@@ -1,77 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
var change_1 = require("./utility/change");
|
|
21
|
-
Object.defineProperty(exports, "NoopChange", { enumerable: true, get: function () { return change_1.NoopChange; } });
|
|
22
|
-
Object.defineProperty(exports, "InsertChange", { enumerable: true, get: function () { return change_1.InsertChange; } });
|
|
23
|
-
Object.defineProperty(exports, "RemoveChange", { enumerable: true, get: function () { return change_1.RemoveChange; } });
|
|
24
|
-
Object.defineProperty(exports, "ReplaceChange", { enumerable: true, get: function () { return change_1.ReplaceChange; } });
|
|
25
|
-
Object.defineProperty(exports, "createReplaceChange", { enumerable: true, get: function () { return change_1.createReplaceChange; } });
|
|
26
|
-
Object.defineProperty(exports, "createChangeRecorder", { enumerable: true, get: function () { return change_1.createChangeRecorder; } });
|
|
27
|
-
Object.defineProperty(exports, "commitChanges", { enumerable: true, get: function () { return change_1.commitChanges; } });
|
|
28
|
-
var config_1 = require("./utility/config");
|
|
29
|
-
Object.defineProperty(exports, "getWorkspace", { enumerable: true, get: function () { return config_1.getWorkspace; } });
|
|
30
|
-
Object.defineProperty(exports, "getWorkspacePath", { enumerable: true, get: function () { return config_1.getWorkspacePath; } });
|
|
31
|
-
var find_component_1 = require("./utility/find-component");
|
|
32
|
-
Object.defineProperty(exports, "findComponentFromOptions", { enumerable: true, get: function () { return find_component_1.findComponentFromOptions; } });
|
|
33
|
-
var find_module_1 = require("./utility/find-module");
|
|
34
|
-
Object.defineProperty(exports, "findModule", { enumerable: true, get: function () { return find_module_1.findModule; } });
|
|
35
|
-
Object.defineProperty(exports, "findModuleFromOptions", { enumerable: true, get: function () { return find_module_1.findModuleFromOptions; } });
|
|
36
|
-
Object.defineProperty(exports, "buildRelativePath", { enumerable: true, get: function () { return find_module_1.buildRelativePath; } });
|
|
37
|
-
var json_utilts_1 = require("./utility/json-utilts");
|
|
38
|
-
Object.defineProperty(exports, "findPropertyInAstObject", { enumerable: true, get: function () { return json_utilts_1.findPropertyInAstObject; } });
|
|
39
|
-
var ngrx_utils_1 = require("./utility/ngrx-utils");
|
|
40
|
-
Object.defineProperty(exports, "addReducerToState", { enumerable: true, get: function () { return ngrx_utils_1.addReducerToState; } });
|
|
41
|
-
Object.defineProperty(exports, "addReducerToStateInterface", { enumerable: true, get: function () { return ngrx_utils_1.addReducerToStateInterface; } });
|
|
42
|
-
Object.defineProperty(exports, "addReducerImportToNgModule", { enumerable: true, get: function () { return ngrx_utils_1.addReducerImportToNgModule; } });
|
|
43
|
-
Object.defineProperty(exports, "addReducerToActionReducerMap", { enumerable: true, get: function () { return ngrx_utils_1.addReducerToActionReducerMap; } });
|
|
44
|
-
Object.defineProperty(exports, "omit", { enumerable: true, get: function () { return ngrx_utils_1.omit; } });
|
|
45
|
-
Object.defineProperty(exports, "getPrefix", { enumerable: true, get: function () { return ngrx_utils_1.getPrefix; } });
|
|
46
|
-
var project_1 = require("./utility/project");
|
|
47
|
-
Object.defineProperty(exports, "getProjectPath", { enumerable: true, get: function () { return project_1.getProjectPath; } });
|
|
48
|
-
Object.defineProperty(exports, "getProject", { enumerable: true, get: function () { return project_1.getProject; } });
|
|
49
|
-
Object.defineProperty(exports, "isLib", { enumerable: true, get: function () { return project_1.isLib; } });
|
|
50
|
-
exports.stringUtils = {
|
|
51
|
-
dasherize: strings_1.dasherize,
|
|
52
|
-
decamelize: strings_1.decamelize,
|
|
53
|
-
camelize: strings_1.camelize,
|
|
54
|
-
classify: strings_1.classify,
|
|
55
|
-
underscore: strings_1.underscore,
|
|
56
|
-
group: strings_1.group,
|
|
57
|
-
capitalize: strings_1.capitalize,
|
|
58
|
-
featurePath: strings_1.featurePath,
|
|
59
|
-
pluralize: strings_1.pluralize,
|
|
1
|
+
import { dasherize, decamelize, camelize, classify, underscore, group, capitalize, featurePath, pluralize, } from './utility/strings';
|
|
2
|
+
export { findNodes, getSourceNodes, getDecoratorMetadata, getContentOfKeyLiteral, insertAfterLastOccurrence, insertImport, addBootstrapToModule, addDeclarationToModule, addExportToModule, addImportToModule, addProviderToComponent, addProviderToModule, replaceImport, containsProperty, } from './utility/ast-utils';
|
|
3
|
+
export { NoopChange, InsertChange, RemoveChange, ReplaceChange, createReplaceChange, createChangeRecorder, commitChanges, } from './utility/change';
|
|
4
|
+
export { getWorkspace, getWorkspacePath } from './utility/config';
|
|
5
|
+
export { findComponentFromOptions } from './utility/find-component';
|
|
6
|
+
export { findModule, findModuleFromOptions, buildRelativePath, } from './utility/find-module';
|
|
7
|
+
export { findPropertyInAstObject } from './utility/json-utilts';
|
|
8
|
+
export { addReducerToState, addReducerToStateInterface, addReducerImportToNgModule, addReducerToActionReducerMap, omit, getPrefix, } from './utility/ngrx-utils';
|
|
9
|
+
export { getProjectPath, getProject, isLib } from './utility/project';
|
|
10
|
+
export var stringUtils = {
|
|
11
|
+
dasherize: dasherize,
|
|
12
|
+
decamelize: decamelize,
|
|
13
|
+
camelize: camelize,
|
|
14
|
+
classify: classify,
|
|
15
|
+
underscore: underscore,
|
|
16
|
+
group: group,
|
|
17
|
+
capitalize: capitalize,
|
|
18
|
+
featurePath: featurePath,
|
|
19
|
+
pluralize: pluralize,
|
|
60
20
|
};
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
Object.defineProperty(exports, "addPackageToPackageJson", { enumerable: true, get: function () { return package_1.addPackageToPackageJson; } });
|
|
67
|
-
var libs_version_1 = require("./utility/libs-version");
|
|
68
|
-
Object.defineProperty(exports, "platformVersion", { enumerable: true, get: function () { return libs_version_1.platformVersion; } });
|
|
69
|
-
var visitors_1 = require("./utility/visitors");
|
|
70
|
-
Object.defineProperty(exports, "visitTSSourceFiles", { enumerable: true, get: function () { return visitors_1.visitTSSourceFiles; } });
|
|
71
|
-
Object.defineProperty(exports, "visitNgModuleImports", { enumerable: true, get: function () { return visitors_1.visitNgModuleImports; } });
|
|
72
|
-
Object.defineProperty(exports, "visitNgModuleExports", { enumerable: true, get: function () { return visitors_1.visitNgModuleExports; } });
|
|
73
|
-
Object.defineProperty(exports, "visitComponents", { enumerable: true, get: function () { return visitors_1.visitComponents; } });
|
|
74
|
-
Object.defineProperty(exports, "visitDecorator", { enumerable: true, get: function () { return visitors_1.visitDecorator; } });
|
|
75
|
-
Object.defineProperty(exports, "visitNgModules", { enumerable: true, get: function () { return visitors_1.visitNgModules; } });
|
|
76
|
-
Object.defineProperty(exports, "visitTemplates", { enumerable: true, get: function () { return visitors_1.visitTemplates; } });
|
|
21
|
+
export { updatePackage } from './utility/update';
|
|
22
|
+
export { parseName } from './utility/parse-name';
|
|
23
|
+
export { addPackageToPackageJson } from './utility/package';
|
|
24
|
+
export { platformVersion } from './utility/libs-version';
|
|
25
|
+
export { visitTSSourceFiles, visitNgModuleImports, visitNgModuleExports, visitComponents, visitDecorator, visitNgModules, visitTemplates, } from './utility/visitors';
|
|
77
26
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../modules/store-devtools/schematics-core/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../modules/store-devtools/schematics-core/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,UAAU,EACV,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,KAAK,EACL,UAAU,EACV,WAAW,EACX,SAAS,GACV,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,SAAS,EACT,cAAc,EACd,oBAAoB,EACpB,sBAAsB,EACtB,yBAAyB,EACzB,YAAY,EACZ,oBAAoB,EACpB,sBAAsB,EACtB,iBAAiB,EACjB,iBAAiB,EACjB,sBAAsB,EACtB,mBAAmB,EACnB,aAAa,EACb,gBAAgB,GACjB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAGL,UAAU,EACV,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,mBAAmB,EACnB,oBAAoB,EACpB,aAAa,GACd,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAa,YAAY,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAE7E,OAAO,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAC;AAEpE,OAAO,EACL,UAAU,EACV,qBAAqB,EACrB,iBAAiB,GAElB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAEhE,OAAO,EACL,iBAAiB,EACjB,0BAA0B,EAC1B,0BAA0B,EAC1B,4BAA4B,EAC5B,IAAI,EACJ,SAAS,GACV,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAEtE,MAAM,CAAC,IAAM,WAAW,GAAG;IACzB,SAAS,WAAA;IACT,UAAU,YAAA;IACV,QAAQ,UAAA;IACR,QAAQ,UAAA;IACR,UAAU,YAAA;IACV,KAAK,OAAA;IACL,UAAU,YAAA;IACV,WAAW,aAAA;IACX,SAAS,WAAA;CACV,CAAC;AAEF,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEjD,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAE5D,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,oBAAoB,EACpB,eAAe,EACf,cAAc,EACd,cAAc,EACd,cAAc,GACf,MAAM,oBAAoB,CAAC","sourcesContent":["import {\n dasherize,\n decamelize,\n camelize,\n classify,\n underscore,\n group,\n capitalize,\n featurePath,\n pluralize,\n} from './utility/strings';\n\nexport {\n findNodes,\n getSourceNodes,\n getDecoratorMetadata,\n getContentOfKeyLiteral,\n insertAfterLastOccurrence,\n insertImport,\n addBootstrapToModule,\n addDeclarationToModule,\n addExportToModule,\n addImportToModule,\n addProviderToComponent,\n addProviderToModule,\n replaceImport,\n containsProperty,\n} from './utility/ast-utils';\n\nexport {\n Host,\n Change,\n NoopChange,\n InsertChange,\n RemoveChange,\n ReplaceChange,\n createReplaceChange,\n createChangeRecorder,\n commitChanges,\n} from './utility/change';\n\nexport { AppConfig, getWorkspace, getWorkspacePath } from './utility/config';\n\nexport { findComponentFromOptions } from './utility/find-component';\n\nexport {\n findModule,\n findModuleFromOptions,\n buildRelativePath,\n ModuleOptions,\n} from './utility/find-module';\n\nexport { findPropertyInAstObject } from './utility/json-utilts';\n\nexport {\n addReducerToState,\n addReducerToStateInterface,\n addReducerImportToNgModule,\n addReducerToActionReducerMap,\n omit,\n getPrefix,\n} from './utility/ngrx-utils';\n\nexport { getProjectPath, getProject, isLib } from './utility/project';\n\nexport const stringUtils = {\n dasherize,\n decamelize,\n camelize,\n classify,\n underscore,\n group,\n capitalize,\n featurePath,\n pluralize,\n};\n\nexport { updatePackage } from './utility/update';\n\nexport { parseName } from './utility/parse-name';\n\nexport { addPackageToPackageJson } from './utility/package';\n\nexport { platformVersion } from './utility/libs-version';\n\nexport {\n visitTSSourceFiles,\n visitNgModuleImports,\n visitNgModuleExports,\n visitComponents,\n visitDecorator,\n visitNgModules,\n visitTemplates,\n} from './utility/visitors';\n"]}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __values = (this && this.__values) || function(o) {
|
|
3
2
|
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
4
3
|
if (m) return m.call(o);
|
|
@@ -35,21 +34,6 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
35
34
|
}
|
|
36
35
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
37
36
|
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.findNodes = findNodes;
|
|
40
|
-
exports.getSourceNodes = getSourceNodes;
|
|
41
|
-
exports.insertAfterLastOccurrence = insertAfterLastOccurrence;
|
|
42
|
-
exports.getContentOfKeyLiteral = getContentOfKeyLiteral;
|
|
43
|
-
exports.getDecoratorMetadata = getDecoratorMetadata;
|
|
44
|
-
exports.addDeclarationToModule = addDeclarationToModule;
|
|
45
|
-
exports.addImportToModule = addImportToModule;
|
|
46
|
-
exports.addProviderToModule = addProviderToModule;
|
|
47
|
-
exports.addProviderToComponent = addProviderToComponent;
|
|
48
|
-
exports.addExportToModule = addExportToModule;
|
|
49
|
-
exports.addBootstrapToModule = addBootstrapToModule;
|
|
50
|
-
exports.insertImport = insertImport;
|
|
51
|
-
exports.replaceImport = replaceImport;
|
|
52
|
-
exports.containsProperty = containsProperty;
|
|
53
37
|
/* istanbul ignore file */
|
|
54
38
|
/**
|
|
55
39
|
* @license
|
|
@@ -58,8 +42,8 @@ exports.containsProperty = containsProperty;
|
|
|
58
42
|
* Use of this source code is governed by an MIT-style license that can be
|
|
59
43
|
* found in the LICENSE file at https://angular.io/license
|
|
60
44
|
*/
|
|
61
|
-
|
|
62
|
-
|
|
45
|
+
import * as ts from 'typescript';
|
|
46
|
+
import { InsertChange, NoopChange, createReplaceChange, createRemoveChange, } from './change';
|
|
63
47
|
/**
|
|
64
48
|
* Find all nodes from the AST in the subtree of node of SyntaxKind kind.
|
|
65
49
|
* @param node
|
|
@@ -67,7 +51,7 @@ var change_1 = require("./change");
|
|
|
67
51
|
* @param max The maximum number of items to return.
|
|
68
52
|
* @return all nodes of kind, or [] if none is found
|
|
69
53
|
*/
|
|
70
|
-
function findNodes(node, kind, max) {
|
|
54
|
+
export function findNodes(node, kind, max) {
|
|
71
55
|
var e_1, _a;
|
|
72
56
|
if (max === void 0) { max = Infinity; }
|
|
73
57
|
if (!node || max == 0) {
|
|
@@ -108,7 +92,7 @@ function findNodes(node, kind, max) {
|
|
|
108
92
|
* @param sourceFile The source file object.
|
|
109
93
|
* @returns {Observable<ts.Node>} An observable of all the nodes in the source.
|
|
110
94
|
*/
|
|
111
|
-
function getSourceNodes(sourceFile) {
|
|
95
|
+
export function getSourceNodes(sourceFile) {
|
|
112
96
|
var nodes = [sourceFile];
|
|
113
97
|
var result = [];
|
|
114
98
|
while (nodes.length > 0) {
|
|
@@ -142,7 +126,7 @@ function nodesByPosition(first, second) {
|
|
|
142
126
|
* @return Change instance
|
|
143
127
|
* @throw Error if toInsert is first occurence but fall back is not set
|
|
144
128
|
*/
|
|
145
|
-
function insertAfterLastOccurrence(nodes, toInsert, file, fallbackPos, syntaxKind) {
|
|
129
|
+
export function insertAfterLastOccurrence(nodes, toInsert, file, fallbackPos, syntaxKind) {
|
|
146
130
|
var lastItem = nodes.sort(nodesByPosition).pop();
|
|
147
131
|
if (!lastItem) {
|
|
148
132
|
throw new Error();
|
|
@@ -154,9 +138,9 @@ function insertAfterLastOccurrence(nodes, toInsert, file, fallbackPos, syntaxKin
|
|
|
154
138
|
throw new Error("tried to insert ".concat(toInsert, " as first occurence with no fallback position"));
|
|
155
139
|
}
|
|
156
140
|
var lastItemPosition = lastItem ? lastItem.end : fallbackPos;
|
|
157
|
-
return new
|
|
141
|
+
return new InsertChange(file, lastItemPosition, toInsert);
|
|
158
142
|
}
|
|
159
|
-
function getContentOfKeyLiteral(_source, node) {
|
|
143
|
+
export function getContentOfKeyLiteral(_source, node) {
|
|
160
144
|
if (node.kind == ts.SyntaxKind.Identifier) {
|
|
161
145
|
return node.text;
|
|
162
146
|
}
|
|
@@ -214,7 +198,7 @@ function _angularImportsFromNode(node, _sourceFile) {
|
|
|
214
198
|
return {};
|
|
215
199
|
}
|
|
216
200
|
}
|
|
217
|
-
function getDecoratorMetadata(source, identifier, module) {
|
|
201
|
+
export function getDecoratorMetadata(source, identifier, module) {
|
|
218
202
|
var angularImports = findNodes(source, ts.SyntaxKind.ImportDeclaration)
|
|
219
203
|
.map(function (node) {
|
|
220
204
|
return _angularImportsFromNode(node, source);
|
|
@@ -315,7 +299,7 @@ function _addSymbolToNgModuleMetadata(source, ngModulePath, metadataField, symbo
|
|
|
315
299
|
toInsert_1 = ", ".concat(metadataField, ": [").concat(symbolName, "]");
|
|
316
300
|
}
|
|
317
301
|
}
|
|
318
|
-
var newMetadataProperty = new
|
|
302
|
+
var newMetadataProperty = new InsertChange(ngModulePath, position_1, toInsert_1);
|
|
319
303
|
var newMetadataImport = insertImport(source, ngModulePath, symbolName.replace(/\..*$/, ''), importPath);
|
|
320
304
|
return [newMetadataProperty, newMetadataImport];
|
|
321
305
|
}
|
|
@@ -359,7 +343,7 @@ function _addSymbolToNgModuleMetadata(source, ngModulePath, metadataField, symbo
|
|
|
359
343
|
var epos = void 0;
|
|
360
344
|
if (effectsElements.length === 0) {
|
|
361
345
|
epos = effectsArgs.getStart() + 1;
|
|
362
|
-
return [new
|
|
346
|
+
return [new InsertChange(ngModulePath, epos, effectsSymbol)];
|
|
363
347
|
}
|
|
364
348
|
else {
|
|
365
349
|
var lastEffect = effectsElements[effectsElements.length - 1];
|
|
@@ -373,7 +357,7 @@ function _addSymbolToNgModuleMetadata(source, ngModulePath, metadataField, symbo
|
|
|
373
357
|
else {
|
|
374
358
|
effectInsert = ", ".concat(effectsSymbol);
|
|
375
359
|
}
|
|
376
|
-
return [new
|
|
360
|
+
return [new InsertChange(ngModulePath, epos, effectInsert)];
|
|
377
361
|
}
|
|
378
362
|
}
|
|
379
363
|
else {
|
|
@@ -419,7 +403,7 @@ function _addSymbolToNgModuleMetadata(source, ngModulePath, metadataField, symbo
|
|
|
419
403
|
toInsert = ", ".concat(symbolName);
|
|
420
404
|
}
|
|
421
405
|
}
|
|
422
|
-
var insert = new
|
|
406
|
+
var insert = new InsertChange(ngModulePath, position, toInsert);
|
|
423
407
|
var importInsert = insertImport(source, ngModulePath, symbolName.replace(/\..*$/, ''), importPath);
|
|
424
408
|
return [insert, importInsert];
|
|
425
409
|
}
|
|
@@ -471,7 +455,7 @@ function _addSymbolToComponentMetadata(source, componentPath, metadataField, sym
|
|
|
471
455
|
toInsert_2 = ", ".concat(metadataField, ": [").concat(symbolName, "]");
|
|
472
456
|
}
|
|
473
457
|
}
|
|
474
|
-
var newMetadataProperty = new
|
|
458
|
+
var newMetadataProperty = new InsertChange(componentPath, position_2, toInsert_2);
|
|
475
459
|
var newMetadataImport = insertImport(source, componentPath, symbolName.replace(/\..*$/, ''), importPath);
|
|
476
460
|
return [newMetadataProperty, newMetadataImport];
|
|
477
461
|
}
|
|
@@ -538,7 +522,7 @@ function _addSymbolToComponentMetadata(source, componentPath, metadataField, sym
|
|
|
538
522
|
toInsert = ", ".concat(symbolName);
|
|
539
523
|
}
|
|
540
524
|
}
|
|
541
|
-
var insert = new
|
|
525
|
+
var insert = new InsertChange(componentPath, position, toInsert);
|
|
542
526
|
var importInsert = insertImport(source, componentPath, symbolName.replace(/\..*$/, ''), importPath);
|
|
543
527
|
return [insert, importInsert];
|
|
544
528
|
}
|
|
@@ -546,38 +530,38 @@ function _addSymbolToComponentMetadata(source, componentPath, metadataField, sym
|
|
|
546
530
|
* Custom function to insert a declaration (component, pipe, directive)
|
|
547
531
|
* into NgModule declarations. It also imports the component.
|
|
548
532
|
*/
|
|
549
|
-
function addDeclarationToModule(source, modulePath, classifiedName, importPath) {
|
|
533
|
+
export function addDeclarationToModule(source, modulePath, classifiedName, importPath) {
|
|
550
534
|
return _addSymbolToNgModuleMetadata(source, modulePath, 'declarations', classifiedName, importPath);
|
|
551
535
|
}
|
|
552
536
|
/**
|
|
553
537
|
* Custom function to insert a declaration (component, pipe, directive)
|
|
554
538
|
* into NgModule declarations. It also imports the component.
|
|
555
539
|
*/
|
|
556
|
-
function addImportToModule(source, modulePath, classifiedName, importPath) {
|
|
540
|
+
export function addImportToModule(source, modulePath, classifiedName, importPath) {
|
|
557
541
|
return _addSymbolToNgModuleMetadata(source, modulePath, 'imports', classifiedName, importPath);
|
|
558
542
|
}
|
|
559
543
|
/**
|
|
560
544
|
* Custom function to insert a provider into NgModule. It also imports it.
|
|
561
545
|
*/
|
|
562
|
-
function addProviderToModule(source, modulePath, classifiedName, importPath) {
|
|
546
|
+
export function addProviderToModule(source, modulePath, classifiedName, importPath) {
|
|
563
547
|
return _addSymbolToNgModuleMetadata(source, modulePath, 'providers', classifiedName, importPath);
|
|
564
548
|
}
|
|
565
549
|
/**
|
|
566
550
|
* Custom function to insert a provider into Component. It also imports it.
|
|
567
551
|
*/
|
|
568
|
-
function addProviderToComponent(source, componentPath, classifiedName, importPath) {
|
|
552
|
+
export function addProviderToComponent(source, componentPath, classifiedName, importPath) {
|
|
569
553
|
return _addSymbolToComponentMetadata(source, componentPath, 'providers', classifiedName, importPath);
|
|
570
554
|
}
|
|
571
555
|
/**
|
|
572
556
|
* Custom function to insert an export into NgModule. It also imports it.
|
|
573
557
|
*/
|
|
574
|
-
function addExportToModule(source, modulePath, classifiedName, importPath) {
|
|
558
|
+
export function addExportToModule(source, modulePath, classifiedName, importPath) {
|
|
575
559
|
return _addSymbolToNgModuleMetadata(source, modulePath, 'exports', classifiedName, importPath);
|
|
576
560
|
}
|
|
577
561
|
/**
|
|
578
562
|
* Custom function to insert an export into NgModule. It also imports it.
|
|
579
563
|
*/
|
|
580
|
-
function addBootstrapToModule(source, modulePath, classifiedName, importPath) {
|
|
564
|
+
export function addBootstrapToModule(source, modulePath, classifiedName, importPath) {
|
|
581
565
|
return _addSymbolToNgModuleMetadata(source, modulePath, 'bootstrap', classifiedName, importPath);
|
|
582
566
|
}
|
|
583
567
|
/**
|
|
@@ -589,7 +573,7 @@ function addBootstrapToModule(source, modulePath, classifiedName, importPath) {
|
|
|
589
573
|
* @param isDefault (if true, import follows style for importing default exports)
|
|
590
574
|
* @return Change
|
|
591
575
|
*/
|
|
592
|
-
function insertImport(source, fileToEdit, symbolName, fileName, isDefault) {
|
|
576
|
+
export function insertImport(source, fileToEdit, symbolName, fileName, isDefault) {
|
|
593
577
|
if (isDefault === void 0) { isDefault = false; }
|
|
594
578
|
var rootNode = source;
|
|
595
579
|
var allImports = findNodes(rootNode, ts.SyntaxKind.ImportDeclaration);
|
|
@@ -614,7 +598,7 @@ function insertImport(source, fileToEdit, symbolName, fileName, isDefault) {
|
|
|
614
598
|
});
|
|
615
599
|
// if imports * from fileName, don't add symbolName
|
|
616
600
|
if (importsAsterisk_1) {
|
|
617
|
-
return new
|
|
601
|
+
return new NoopChange();
|
|
618
602
|
}
|
|
619
603
|
var importTextNodes = imports_1.filter(function (n) { return n.text === symbolName; });
|
|
620
604
|
// insert import if it's not there
|
|
@@ -623,7 +607,7 @@ function insertImport(source, fileToEdit, symbolName, fileName, isDefault) {
|
|
|
623
607
|
findNodes(relevantImports[0], ts.SyntaxKind.FromKeyword)[0].getStart();
|
|
624
608
|
return insertAfterLastOccurrence(imports_1, ", ".concat(symbolName), fileToEdit, fallbackPos_1);
|
|
625
609
|
}
|
|
626
|
-
return new
|
|
610
|
+
return new NoopChange();
|
|
627
611
|
}
|
|
628
612
|
// no such import declaration exists
|
|
629
613
|
var useStrict = findNodes(rootNode, ts.SyntaxKind.StringLiteral).filter(function (n) { return n.getText() === 'use strict'; });
|
|
@@ -640,7 +624,7 @@ function insertImport(source, fileToEdit, symbolName, fileName, isDefault) {
|
|
|
640
624
|
" from '".concat(fileName, "'").concat(insertAtBeginning ? ';\n' : '');
|
|
641
625
|
return insertAfterLastOccurrence(allImports, toInsert, fileToEdit, fallbackPos, ts.SyntaxKind.StringLiteral);
|
|
642
626
|
}
|
|
643
|
-
function replaceImport(sourceFile, path, importFrom, importAsIs, importToBe) {
|
|
627
|
+
export function replaceImport(sourceFile, path, importFrom, importAsIs, importToBe) {
|
|
644
628
|
var imports = sourceFile.statements
|
|
645
629
|
.filter(ts.isImportDeclaration)
|
|
646
630
|
.filter(function (_a) {
|
|
@@ -679,21 +663,21 @@ function replaceImport(sourceFile, path, importFrom, importAsIs, importToBe) {
|
|
|
679
663
|
}
|
|
680
664
|
// identifier has not been imported, simply replace the old text with the new text
|
|
681
665
|
if (!isAlreadyImported) {
|
|
682
|
-
return
|
|
666
|
+
return createReplaceChange(sourceFile, specifier, importAsIs, importToBe);
|
|
683
667
|
}
|
|
684
668
|
var nextIdentifier = importSpecifiers[index + 1];
|
|
685
669
|
// identifer is not the last, also clean up the comma
|
|
686
670
|
if (nextIdentifier) {
|
|
687
|
-
return
|
|
671
|
+
return createRemoveChange(sourceFile, specifier, specifier.getStart(sourceFile), nextIdentifier.getStart(sourceFile));
|
|
688
672
|
}
|
|
689
673
|
// there are no imports following, just remove it
|
|
690
|
-
return
|
|
674
|
+
return createRemoveChange(sourceFile, specifier, specifier.getStart(sourceFile), specifier.getEnd());
|
|
691
675
|
});
|
|
692
676
|
return importChanges.filter(Boolean);
|
|
693
677
|
});
|
|
694
678
|
return changes.reduce(function (imports, curr) { return imports.concat(curr); }, []);
|
|
695
679
|
}
|
|
696
|
-
function containsProperty(objectLiteral, propertyName) {
|
|
680
|
+
export function containsProperty(objectLiteral, propertyName) {
|
|
697
681
|
return (objectLiteral &&
|
|
698
682
|
objectLiteral.properties.some(function (prop) {
|
|
699
683
|
return ts.isPropertyAssignment(prop) &&
|