@angular/core 17.0.0-rc.3 → 17.0.1
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/esm2022/src/application_ref.mjs +1 -1
- package/esm2022/src/linker/view_ref.mjs +1 -1
- package/esm2022/src/render3/component_ref.mjs +3 -3
- package/esm2022/src/render3/instructions/change_detection.mjs +22 -19
- package/esm2022/src/render3/view_ref.mjs +5 -28
- package/esm2022/src/version.mjs +1 -1
- package/esm2022/testing/src/logger.mjs +3 -3
- package/fesm2022/core.mjs +28 -48
- package/fesm2022/core.mjs.map +1 -1
- package/fesm2022/primitives/signals.mjs +1 -1
- package/fesm2022/rxjs-interop.mjs +1 -1
- package/fesm2022/testing.mjs +1 -1
- package/index.d.ts +4 -8
- package/package.json +1 -1
- package/primitives/signals/index.d.ts +1 -1
- package/rxjs-interop/index.d.ts +1 -1
- package/schematics/migrations/block-template-entities/bundle.js +1 -1
- package/schematics/migrations/block-template-entities/bundle.js.map +1 -1
- package/schematics/ng-generate/control-flow-migration/bundle.js +331 -207
- package/schematics/ng-generate/control-flow-migration/bundle.js.map +4 -4
- package/schematics/ng-generate/standalone-migration/bundle.js +22 -16
- package/schematics/ng-generate/standalone-migration/bundle.js.map +3 -3
- package/testing/index.d.ts +1 -1
|
@@ -24761,7 +24761,7 @@ function publishFacade(global) {
|
|
|
24761
24761
|
}
|
|
24762
24762
|
|
|
24763
24763
|
// bazel-out/k8-fastbuild/bin/packages/compiler/src/version.mjs
|
|
24764
|
-
var VERSION2 = new Version("17.0.
|
|
24764
|
+
var VERSION2 = new Version("17.0.1");
|
|
24765
24765
|
|
|
24766
24766
|
// bazel-out/k8-fastbuild/bin/packages/compiler/src/i18n/extractor_merger.mjs
|
|
24767
24767
|
var _VisitorMode;
|
|
@@ -24805,42 +24805,8 @@ var FactoryTarget2;
|
|
|
24805
24805
|
// bazel-out/k8-fastbuild/bin/packages/compiler/src/compiler.mjs
|
|
24806
24806
|
publishFacade(_global);
|
|
24807
24807
|
|
|
24808
|
-
// bazel-out/k8-fastbuild/bin/packages/core/schematics/ng-generate/control-flow-migration/util.mjs
|
|
24809
|
-
var import_path2 = require("path");
|
|
24810
|
-
var import_typescript5 = __toESM(require("typescript"), 1);
|
|
24811
|
-
|
|
24812
24808
|
// bazel-out/k8-fastbuild/bin/packages/core/schematics/ng-generate/control-flow-migration/types.mjs
|
|
24813
|
-
var
|
|
24814
|
-
var boundngif = "[ngIf]";
|
|
24815
|
-
var nakedngif = "ngIf";
|
|
24816
|
-
var ngfor = "*ngFor";
|
|
24817
|
-
var ngswitch = "[ngSwitch]";
|
|
24818
|
-
var boundcase = "[ngSwitchCase]";
|
|
24819
|
-
var switchcase = "*ngSwitchCase";
|
|
24820
|
-
var nakedcase = "ngSwitchCase";
|
|
24821
|
-
var switchdefault = "*ngSwitchDefault";
|
|
24822
|
-
var nakeddefault = "ngSwitchDefault";
|
|
24823
|
-
var commaSeparatedSyntax = /* @__PURE__ */ new Map([
|
|
24824
|
-
["(", ")"],
|
|
24825
|
-
["{", "}"],
|
|
24826
|
-
["[", "]"]
|
|
24827
|
-
]);
|
|
24828
|
-
var stringPairs = /* @__PURE__ */ new Map([
|
|
24829
|
-
[`"`, `"`],
|
|
24830
|
-
[`'`, `'`]
|
|
24831
|
-
]);
|
|
24832
|
-
var attributesToMigrate = [
|
|
24833
|
-
ngif,
|
|
24834
|
-
nakedngif,
|
|
24835
|
-
boundngif,
|
|
24836
|
-
ngfor,
|
|
24837
|
-
ngswitch,
|
|
24838
|
-
boundcase,
|
|
24839
|
-
switchcase,
|
|
24840
|
-
nakedcase,
|
|
24841
|
-
switchdefault,
|
|
24842
|
-
nakeddefault
|
|
24843
|
-
];
|
|
24809
|
+
var ngtemplate = "ng-template";
|
|
24844
24810
|
var ElementToMigrate = class {
|
|
24845
24811
|
constructor(el, attr) {
|
|
24846
24812
|
__publicField(this, "el");
|
|
@@ -24876,13 +24842,14 @@ var ElementToMigrate = class {
|
|
|
24876
24842
|
}
|
|
24877
24843
|
};
|
|
24878
24844
|
var Template2 = class {
|
|
24879
|
-
constructor(el) {
|
|
24845
|
+
constructor(el, i18n2) {
|
|
24880
24846
|
__publicField(this, "el");
|
|
24881
24847
|
__publicField(this, "count", 0);
|
|
24882
24848
|
__publicField(this, "contents", "");
|
|
24883
24849
|
__publicField(this, "children", "");
|
|
24884
|
-
__publicField(this, "
|
|
24850
|
+
__publicField(this, "i18n", null);
|
|
24885
24851
|
this.el = el;
|
|
24852
|
+
this.i18n = i18n2;
|
|
24886
24853
|
}
|
|
24887
24854
|
generateContents(tmpl) {
|
|
24888
24855
|
this.contents = tmpl.slice(this.el.sourceSpan.start.offset, this.el.sourceSpan.end.offset + 1);
|
|
@@ -24912,32 +24879,53 @@ var AnalyzedFile = class {
|
|
|
24912
24879
|
}
|
|
24913
24880
|
};
|
|
24914
24881
|
var ElementCollector = class extends RecursiveVisitor {
|
|
24915
|
-
constructor() {
|
|
24916
|
-
super(
|
|
24882
|
+
constructor(_attributes = []) {
|
|
24883
|
+
super();
|
|
24884
|
+
__publicField(this, "_attributes");
|
|
24917
24885
|
__publicField(this, "elements", []);
|
|
24918
|
-
|
|
24886
|
+
this._attributes = _attributes;
|
|
24919
24887
|
}
|
|
24920
24888
|
visitElement(el) {
|
|
24921
24889
|
if (el.attrs.length > 0) {
|
|
24922
24890
|
for (const attr of el.attrs) {
|
|
24923
|
-
if (
|
|
24891
|
+
if (this._attributes.includes(attr.name)) {
|
|
24924
24892
|
this.elements.push(new ElementToMigrate(el, attr));
|
|
24925
24893
|
}
|
|
24926
24894
|
}
|
|
24927
24895
|
}
|
|
24928
|
-
|
|
24896
|
+
super.visitElement(el, null);
|
|
24897
|
+
}
|
|
24898
|
+
};
|
|
24899
|
+
var TemplateCollector = class extends RecursiveVisitor {
|
|
24900
|
+
constructor() {
|
|
24901
|
+
super(...arguments);
|
|
24902
|
+
__publicField(this, "elements", []);
|
|
24903
|
+
__publicField(this, "templates", /* @__PURE__ */ new Map());
|
|
24904
|
+
}
|
|
24905
|
+
visitElement(el) {
|
|
24906
|
+
if (el.name === ngtemplate) {
|
|
24907
|
+
let i18n2 = null;
|
|
24908
|
+
let templateAttr = null;
|
|
24929
24909
|
for (const attr of el.attrs) {
|
|
24910
|
+
if (attr.name === "i18n") {
|
|
24911
|
+
i18n2 = attr;
|
|
24912
|
+
}
|
|
24930
24913
|
if (attr.name.startsWith("#")) {
|
|
24931
|
-
|
|
24932
|
-
this.templates.set(attr.name, new Template2(el));
|
|
24914
|
+
templateAttr = attr;
|
|
24933
24915
|
}
|
|
24934
24916
|
}
|
|
24917
|
+
if (templateAttr !== null) {
|
|
24918
|
+
this.elements.push(new ElementToMigrate(el, templateAttr));
|
|
24919
|
+
this.templates.set(templateAttr.name, new Template2(el, i18n2));
|
|
24920
|
+
}
|
|
24935
24921
|
}
|
|
24936
24922
|
super.visitElement(el, null);
|
|
24937
24923
|
}
|
|
24938
24924
|
};
|
|
24939
24925
|
|
|
24940
24926
|
// bazel-out/k8-fastbuild/bin/packages/core/schematics/ng-generate/control-flow-migration/util.mjs
|
|
24927
|
+
var import_path2 = require("path");
|
|
24928
|
+
var import_typescript5 = __toESM(require("typescript"), 1);
|
|
24941
24929
|
function analyze(sourceFile, analyzedFiles) {
|
|
24942
24930
|
forEachClass(sourceFile, (node) => {
|
|
24943
24931
|
var _a2;
|
|
@@ -24976,11 +24964,8 @@ function getNestedCount(etm, aggregator) {
|
|
|
24976
24964
|
return getNestedCount(etm, aggregator);
|
|
24977
24965
|
}
|
|
24978
24966
|
}
|
|
24979
|
-
|
|
24980
|
-
function migrateTemplate(template2) {
|
|
24981
|
-
var _a2, _b2;
|
|
24967
|
+
function parseTemplate2(template2) {
|
|
24982
24968
|
let parsed;
|
|
24983
|
-
let errors = [];
|
|
24984
24969
|
try {
|
|
24985
24970
|
parsed = new HtmlParser().parse(template2, "", {
|
|
24986
24971
|
tokenizeExpansionForms: true,
|
|
@@ -24988,159 +24973,175 @@ function migrateTemplate(template2) {
|
|
|
24988
24973
|
preserveLineEndings: true
|
|
24989
24974
|
});
|
|
24990
24975
|
if (parsed.errors && parsed.errors.length > 0) {
|
|
24991
|
-
return
|
|
24976
|
+
return null;
|
|
24992
24977
|
}
|
|
24993
24978
|
} catch (e) {
|
|
24994
|
-
return
|
|
24995
|
-
}
|
|
24996
|
-
let result = template2;
|
|
24997
|
-
const lineBreaks = template2.match(/\r|\n/g);
|
|
24998
|
-
const hasLineBreaks = lineBreaks !== null;
|
|
24999
|
-
const visitor = new ElementCollector();
|
|
25000
|
-
visitAll2(visitor, parsed.rootNodes);
|
|
25001
|
-
for (let [key, tmpl] of visitor.templates) {
|
|
25002
|
-
const regex = new RegExp(`[^a-zA-Z0-9-<]+${key.slice(1)}\\W`, "gm");
|
|
25003
|
-
const matches = template2.match(regex);
|
|
25004
|
-
tmpl.count = (_a2 = matches == null ? void 0 : matches.length) != null ? _a2 : 0;
|
|
25005
|
-
tmpl.generateContents(template2);
|
|
24979
|
+
return null;
|
|
25006
24980
|
}
|
|
24981
|
+
return parsed;
|
|
24982
|
+
}
|
|
24983
|
+
function calculateNesting(visitor, hasLineBreaks2) {
|
|
25007
24984
|
let nestedQueue = [];
|
|
25008
24985
|
for (let i = 0; i < visitor.elements.length; i++) {
|
|
25009
24986
|
let currEl = visitor.elements[i];
|
|
25010
24987
|
if (i === 0) {
|
|
25011
24988
|
nestedQueue.push(currEl.el.sourceSpan.end.offset);
|
|
25012
|
-
currEl.hasLineBreaks =
|
|
24989
|
+
currEl.hasLineBreaks = hasLineBreaks2;
|
|
25013
24990
|
continue;
|
|
25014
24991
|
}
|
|
25015
|
-
currEl.hasLineBreaks =
|
|
24992
|
+
currEl.hasLineBreaks = hasLineBreaks2;
|
|
25016
24993
|
currEl.nestCount = getNestedCount(currEl, nestedQueue);
|
|
25017
24994
|
if (currEl.el.sourceSpan.end.offset !== nestedQueue[nestedQueue.length - 1]) {
|
|
25018
24995
|
nestedQueue.push(currEl.el.sourceSpan.end.offset);
|
|
25019
24996
|
}
|
|
25020
24997
|
}
|
|
24998
|
+
}
|
|
24999
|
+
function escapeRegExp(val) {
|
|
25000
|
+
return val.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
25001
|
+
}
|
|
25002
|
+
function hasLineBreaks(template2) {
|
|
25003
|
+
return /\r|\n/.test(template2);
|
|
25004
|
+
}
|
|
25005
|
+
function reduceNestingOffset(el, nestLevel, offset, postOffsets) {
|
|
25006
|
+
var _a2;
|
|
25007
|
+
if (el.nestCount <= nestLevel) {
|
|
25008
|
+
const count = nestLevel - el.nestCount;
|
|
25009
|
+
for (let i = 0; i <= count; i++) {
|
|
25010
|
+
offset += (_a2 = postOffsets.pop()) != null ? _a2 : 0;
|
|
25011
|
+
}
|
|
25012
|
+
}
|
|
25013
|
+
return offset;
|
|
25014
|
+
}
|
|
25015
|
+
function countTemplateUsage(template2) {
|
|
25016
|
+
var _a2;
|
|
25017
|
+
const parsed = parseTemplate2(template2);
|
|
25018
|
+
if (parsed !== null) {
|
|
25019
|
+
const visitor = new TemplateCollector();
|
|
25020
|
+
visitAll2(visitor, parsed.rootNodes);
|
|
25021
|
+
for (let [key, tmpl] of visitor.templates) {
|
|
25022
|
+
const escapeKey = escapeRegExp(key.slice(1));
|
|
25023
|
+
const regex = new RegExp(`[^a-zA-Z0-9-<]${escapeKey}\\W`, "gm");
|
|
25024
|
+
const matches = template2.match(regex);
|
|
25025
|
+
tmpl.count = (_a2 = matches == null ? void 0 : matches.length) != null ? _a2 : 0;
|
|
25026
|
+
tmpl.generateContents(template2);
|
|
25027
|
+
}
|
|
25028
|
+
return visitor.templates;
|
|
25029
|
+
}
|
|
25030
|
+
return /* @__PURE__ */ new Map();
|
|
25031
|
+
}
|
|
25032
|
+
function wrapIntoI18nContainer(i18nAttr, content) {
|
|
25033
|
+
const i18n2 = i18nAttr.value === "" ? "i18n" : `i18n="${i18nAttr.value}"`;
|
|
25034
|
+
return `<ng-container ${i18n2}>${content}</ng-container>`;
|
|
25035
|
+
}
|
|
25036
|
+
function processNgTemplates(template2) {
|
|
25037
|
+
const templates = countTemplateUsage(template2);
|
|
25038
|
+
for (const [name, t] of templates) {
|
|
25039
|
+
const placeholder = `${name}|`;
|
|
25040
|
+
if (template2.indexOf(placeholder) > -1) {
|
|
25041
|
+
if (t.i18n !== null) {
|
|
25042
|
+
const container = wrapIntoI18nContainer(t.i18n, t.children);
|
|
25043
|
+
template2 = template2.replace(placeholder, container);
|
|
25044
|
+
} else {
|
|
25045
|
+
template2 = template2.replace(placeholder, t.children);
|
|
25046
|
+
}
|
|
25047
|
+
if (t.count <= 2) {
|
|
25048
|
+
template2 = template2.replace(t.contents, "");
|
|
25049
|
+
}
|
|
25050
|
+
}
|
|
25051
|
+
}
|
|
25052
|
+
return template2;
|
|
25053
|
+
}
|
|
25054
|
+
function getOriginals(etm, tmpl, offset) {
|
|
25055
|
+
if (etm.el.children.length > 0) {
|
|
25056
|
+
const start2 = tmpl.slice(etm.el.sourceSpan.start.offset - offset, etm.el.children[0].sourceSpan.start.offset - offset);
|
|
25057
|
+
const end = tmpl.slice(etm.el.children[etm.el.children.length - 1].sourceSpan.end.offset - offset, etm.el.sourceSpan.end.offset - offset);
|
|
25058
|
+
return { start: start2, end };
|
|
25059
|
+
}
|
|
25060
|
+
const start = tmpl.slice(etm.el.sourceSpan.start.offset - offset, etm.el.sourceSpan.end.offset - offset);
|
|
25061
|
+
return { start, end: "" };
|
|
25062
|
+
}
|
|
25063
|
+
function getMainBlock(etm, tmpl, offset) {
|
|
25064
|
+
const i18nAttr = etm.el.attrs.find((x) => x.name === "i18n");
|
|
25065
|
+
if ((etm.el.name === "ng-container" || etm.el.name === "ng-template") && etm.el.attrs.length === 1) {
|
|
25066
|
+
const childStart2 = etm.el.children[0].sourceSpan.start.offset - offset;
|
|
25067
|
+
const childEnd2 = etm.el.children[etm.el.children.length - 1].sourceSpan.end.offset - offset;
|
|
25068
|
+
const middle2 = tmpl.slice(childStart2, childEnd2);
|
|
25069
|
+
return { start: "", middle: middle2, end: "" };
|
|
25070
|
+
} else if (etm.el.name === "ng-template" && etm.el.attrs.length === 2 && i18nAttr !== void 0) {
|
|
25071
|
+
const childStart2 = etm.el.children[0].sourceSpan.start.offset - offset;
|
|
25072
|
+
const childEnd2 = etm.el.children[etm.el.children.length - 1].sourceSpan.end.offset - offset;
|
|
25073
|
+
const middle2 = wrapIntoI18nContainer(i18nAttr, tmpl.slice(childStart2, childEnd2));
|
|
25074
|
+
return { start: "", middle: middle2, end: "" };
|
|
25075
|
+
}
|
|
25076
|
+
const attrStart = etm.attr.keySpan.start.offset - 1 - offset;
|
|
25077
|
+
const valEnd = (etm.attr.valueSpan ? etm.attr.valueSpan.end.offset + 1 : etm.attr.keySpan.end.offset) - offset;
|
|
25078
|
+
let childStart = valEnd;
|
|
25079
|
+
let childEnd = valEnd;
|
|
25080
|
+
if (etm.el.children.length > 0) {
|
|
25081
|
+
childStart = etm.el.children[0].sourceSpan.start.offset - offset;
|
|
25082
|
+
childEnd = etm.el.children[etm.el.children.length - 1].sourceSpan.end.offset - offset;
|
|
25083
|
+
}
|
|
25084
|
+
let start = tmpl.slice(etm.start(offset), attrStart);
|
|
25085
|
+
start += tmpl.slice(valEnd, childStart);
|
|
25086
|
+
const middle = tmpl.slice(childStart, childEnd);
|
|
25087
|
+
const end = tmpl.slice(childEnd, etm.end(offset));
|
|
25088
|
+
return { start, middle, end };
|
|
25089
|
+
}
|
|
25090
|
+
function forEachClass(sourceFile, callback) {
|
|
25091
|
+
sourceFile.forEachChild(function walk(node) {
|
|
25092
|
+
if (import_typescript5.default.isClassDeclaration(node)) {
|
|
25093
|
+
callback(node);
|
|
25094
|
+
}
|
|
25095
|
+
node.forEachChild(walk);
|
|
25096
|
+
});
|
|
25097
|
+
}
|
|
25098
|
+
|
|
25099
|
+
// bazel-out/k8-fastbuild/bin/packages/core/schematics/ng-generate/control-flow-migration/fors.mjs
|
|
25100
|
+
var ngfor = "*ngFor";
|
|
25101
|
+
var commaSeparatedSyntax = /* @__PURE__ */ new Map([
|
|
25102
|
+
["(", ")"],
|
|
25103
|
+
["{", "}"],
|
|
25104
|
+
["[", "]"]
|
|
25105
|
+
]);
|
|
25106
|
+
var stringPairs = /* @__PURE__ */ new Map([
|
|
25107
|
+
[`"`, `"`],
|
|
25108
|
+
[`'`, `'`]
|
|
25109
|
+
]);
|
|
25110
|
+
function migrateFor(template2) {
|
|
25111
|
+
let errors = [];
|
|
25112
|
+
let parsed = parseTemplate2(template2);
|
|
25113
|
+
if (parsed === null) {
|
|
25114
|
+
return { migrated: template2, errors };
|
|
25115
|
+
}
|
|
25116
|
+
let result = template2;
|
|
25117
|
+
const visitor = new ElementCollector([ngfor]);
|
|
25118
|
+
visitAll2(visitor, parsed.rootNodes);
|
|
25119
|
+
calculateNesting(visitor, hasLineBreaks(template2));
|
|
25021
25120
|
let offset = 0;
|
|
25022
25121
|
let nestLevel = -1;
|
|
25023
25122
|
let postOffsets = [];
|
|
25024
25123
|
for (const el of visitor.elements) {
|
|
25025
25124
|
let migrateResult = { tmpl: result, offsets: { pre: 0, post: 0 } };
|
|
25026
|
-
|
|
25027
|
-
|
|
25028
|
-
|
|
25029
|
-
|
|
25030
|
-
}
|
|
25031
|
-
}
|
|
25032
|
-
if (el.attr.name === ngif || el.attr.name === nakedngif || el.attr.name === boundngif) {
|
|
25033
|
-
try {
|
|
25034
|
-
migrateResult = migrateNgIf(el, visitor.templates, result, offset);
|
|
25035
|
-
} catch (error2) {
|
|
25036
|
-
errors.push({ type: ngif, error: error2 });
|
|
25037
|
-
}
|
|
25038
|
-
} else if (el.attr.name === ngfor) {
|
|
25039
|
-
try {
|
|
25040
|
-
migrateResult = migrateNgFor(el, result, offset);
|
|
25041
|
-
} catch (error2) {
|
|
25042
|
-
errors.push({ type: ngfor, error: error2 });
|
|
25043
|
-
}
|
|
25044
|
-
} else if (el.attr.name === ngswitch) {
|
|
25045
|
-
try {
|
|
25046
|
-
migrateResult = migrateNgSwitch(el, result, offset);
|
|
25047
|
-
} catch (error2) {
|
|
25048
|
-
errors.push({ type: ngswitch, error: error2 });
|
|
25049
|
-
}
|
|
25050
|
-
} else if (el.attr.name === switchcase || el.attr.name === nakedcase || el.attr.name === boundcase) {
|
|
25051
|
-
try {
|
|
25052
|
-
migrateResult = migrateNgSwitchCase(el, result, offset);
|
|
25053
|
-
} catch (error2) {
|
|
25054
|
-
errors.push({ type: ngswitch, error: error2 });
|
|
25055
|
-
}
|
|
25056
|
-
} else if (el.attr.name === switchdefault || el.attr.name === nakeddefault) {
|
|
25057
|
-
try {
|
|
25058
|
-
migrateResult = migrateNgSwitchDefault(el, result, offset);
|
|
25059
|
-
} catch (error2) {
|
|
25060
|
-
errors.push({ type: ngswitch, error: error2 });
|
|
25061
|
-
}
|
|
25125
|
+
offset = reduceNestingOffset(el, nestLevel, offset, postOffsets);
|
|
25126
|
+
try {
|
|
25127
|
+
migrateResult = migrateNgFor(el, result, offset);
|
|
25128
|
+
} catch (error2) {
|
|
25129
|
+
errors.push({ type: ngfor, error: error2 });
|
|
25062
25130
|
}
|
|
25063
25131
|
result = migrateResult.tmpl;
|
|
25064
25132
|
offset += migrateResult.offsets.pre;
|
|
25065
25133
|
postOffsets.push(migrateResult.offsets.post);
|
|
25066
25134
|
nestLevel = el.nestCount;
|
|
25067
25135
|
}
|
|
25068
|
-
for (const [_, t] of visitor.templates) {
|
|
25069
|
-
if (t.count < 2 && t.used) {
|
|
25070
|
-
result = result.replace(t.contents, "");
|
|
25071
|
-
}
|
|
25072
|
-
}
|
|
25073
25136
|
return { migrated: result, errors };
|
|
25074
25137
|
}
|
|
25075
|
-
function migrateNgIf(etm, ngTemplates, tmpl, offset) {
|
|
25076
|
-
const matchThen = etm.attr.value.match(/;\s*then/gm);
|
|
25077
|
-
const matchElse = etm.attr.value.match(/;\s*else/gm);
|
|
25078
|
-
if (matchThen && matchThen.length > 0) {
|
|
25079
|
-
return buildIfThenElseBlock(etm, ngTemplates, tmpl, matchThen[0], matchElse[0], offset);
|
|
25080
|
-
} else if (matchElse && matchElse.length > 0) {
|
|
25081
|
-
return buildIfElseBlock(etm, ngTemplates, tmpl, matchElse[0], offset);
|
|
25082
|
-
}
|
|
25083
|
-
return buildIfBlock(etm, tmpl, offset);
|
|
25084
|
-
}
|
|
25085
|
-
function buildIfBlock(etm, tmpl, offset) {
|
|
25086
|
-
const lbString = etm.hasLineBreaks ? lb : "";
|
|
25087
|
-
const condition = etm.attr.value.replace(" as ", "; as ");
|
|
25088
|
-
const originals = getOriginals(etm, tmpl, offset);
|
|
25089
|
-
const { start, middle, end } = getMainBlock(etm, tmpl, offset);
|
|
25090
|
-
const startBlock = `@if (${condition}) {${lbString}${start}`;
|
|
25091
|
-
const endBlock = `${end}${lbString}}`;
|
|
25092
|
-
const ifBlock = startBlock + middle + endBlock;
|
|
25093
|
-
const updatedTmpl = tmpl.slice(0, etm.start(offset)) + ifBlock + tmpl.slice(etm.end(offset));
|
|
25094
|
-
const pre = originals.start.length - startBlock.length;
|
|
25095
|
-
const post = originals.end.length - endBlock.length;
|
|
25096
|
-
return { tmpl: updatedTmpl, offsets: { pre, post } };
|
|
25097
|
-
}
|
|
25098
|
-
function buildIfElseBlock(etm, ngTemplates, tmpl, elseString, offset) {
|
|
25099
|
-
const lbString = etm.hasLineBreaks ? lb : "";
|
|
25100
|
-
const condition = etm.getCondition(elseString).replace(" as ", "; as ");
|
|
25101
|
-
const originals = getOriginals(etm, tmpl, offset);
|
|
25102
|
-
const elseTmpl = ngTemplates.get(`#${etm.getTemplateName(elseString)}`);
|
|
25103
|
-
const { start, middle, end } = getMainBlock(etm, tmpl, offset);
|
|
25104
|
-
const startBlock = `@if (${condition}) {${lbString}${start}`;
|
|
25105
|
-
const elseBlock = `${end}${lbString}} @else {${lbString}`;
|
|
25106
|
-
const postBlock = elseBlock + elseTmpl.children + `${lbString}}`;
|
|
25107
|
-
const ifElseBlock = startBlock + middle + postBlock;
|
|
25108
|
-
const tmplStart = tmpl.slice(0, etm.start(offset));
|
|
25109
|
-
const tmplEnd = tmpl.slice(etm.end(offset));
|
|
25110
|
-
const updatedTmpl = tmplStart + ifElseBlock + tmplEnd;
|
|
25111
|
-
elseTmpl.count--;
|
|
25112
|
-
elseTmpl.used = true;
|
|
25113
|
-
const pre = originals.start.length - startBlock.length;
|
|
25114
|
-
const post = originals.end.length - postBlock.length;
|
|
25115
|
-
return { tmpl: updatedTmpl, offsets: { pre, post } };
|
|
25116
|
-
}
|
|
25117
|
-
function buildIfThenElseBlock(etm, ngTemplates, tmpl, thenString, elseString, offset) {
|
|
25118
|
-
const condition = etm.getCondition(thenString).replace(" as ", "; as ");
|
|
25119
|
-
const lbString = etm.hasLineBreaks ? lb : "";
|
|
25120
|
-
const originals = getOriginals(etm, tmpl, offset);
|
|
25121
|
-
const startBlock = `@if (${condition}) {${lbString}`;
|
|
25122
|
-
const elseBlock = `${lbString}} @else {${lbString}`;
|
|
25123
|
-
const thenTmpl = ngTemplates.get(`#${etm.getTemplateName(thenString, elseString)}`);
|
|
25124
|
-
const elseTmpl = ngTemplates.get(`#${etm.getTemplateName(elseString)}`);
|
|
25125
|
-
const postBlock = thenTmpl.children + elseBlock + elseTmpl.children + `${lbString}}`;
|
|
25126
|
-
const ifThenElseBlock = startBlock + postBlock;
|
|
25127
|
-
const tmplStart = tmpl.slice(0, etm.start(offset));
|
|
25128
|
-
const tmplEnd = tmpl.slice(etm.end(offset));
|
|
25129
|
-
const updatedTmpl = tmplStart + ifThenElseBlock + tmplEnd;
|
|
25130
|
-
thenTmpl.count--;
|
|
25131
|
-
thenTmpl.used = true;
|
|
25132
|
-
elseTmpl.count--;
|
|
25133
|
-
elseTmpl.used = true;
|
|
25134
|
-
const pre = originals.start.length - startBlock.length;
|
|
25135
|
-
const post = originals.end.length - postBlock.length;
|
|
25136
|
-
return { tmpl: updatedTmpl, offsets: { pre, post } };
|
|
25137
|
-
}
|
|
25138
25138
|
function migrateNgFor(etm, tmpl, offset) {
|
|
25139
25139
|
const aliasWithEqualRegexp = /=\s*(count|index|first|last|even|odd)/gm;
|
|
25140
25140
|
const aliasWithAsRegexp = /(count|index|first|last|even|odd)\s+as/gm;
|
|
25141
25141
|
const aliases = [];
|
|
25142
|
-
const lbString = etm.hasLineBreaks ?
|
|
25143
|
-
const lbSpaces = etm.hasLineBreaks ?
|
|
25142
|
+
const lbString = etm.hasLineBreaks ? "\n" : "";
|
|
25143
|
+
const lbSpaces = etm.hasLineBreaks ? `
|
|
25144
|
+
` : "";
|
|
25144
25145
|
const parts = getNgForParts(etm.attr.value);
|
|
25145
25146
|
const originals = getOriginals(etm, tmpl, offset);
|
|
25146
25147
|
const condition = parts[0].replace("let ", "");
|
|
@@ -25212,38 +25213,161 @@ function getNgForParts(expression) {
|
|
|
25212
25213
|
}
|
|
25213
25214
|
return parts;
|
|
25214
25215
|
}
|
|
25215
|
-
|
|
25216
|
-
|
|
25217
|
-
|
|
25218
|
-
|
|
25219
|
-
|
|
25216
|
+
|
|
25217
|
+
// bazel-out/k8-fastbuild/bin/packages/core/schematics/ng-generate/control-flow-migration/ifs.mjs
|
|
25218
|
+
var ngif = "*ngIf";
|
|
25219
|
+
var boundngif = "[ngIf]";
|
|
25220
|
+
var nakedngif = "ngIf";
|
|
25221
|
+
var ifs = [
|
|
25222
|
+
ngif,
|
|
25223
|
+
nakedngif,
|
|
25224
|
+
boundngif
|
|
25225
|
+
];
|
|
25226
|
+
function migrateIf(template2) {
|
|
25227
|
+
let errors = [];
|
|
25228
|
+
let parsed = parseTemplate2(template2);
|
|
25229
|
+
if (parsed === null) {
|
|
25230
|
+
return { migrated: template2, errors };
|
|
25220
25231
|
}
|
|
25221
|
-
|
|
25222
|
-
|
|
25232
|
+
let result = template2;
|
|
25233
|
+
const visitor = new ElementCollector(ifs);
|
|
25234
|
+
visitAll2(visitor, parsed.rootNodes);
|
|
25235
|
+
calculateNesting(visitor, hasLineBreaks(template2));
|
|
25236
|
+
let offset = 0;
|
|
25237
|
+
let nestLevel = -1;
|
|
25238
|
+
let postOffsets = [];
|
|
25239
|
+
for (const el of visitor.elements) {
|
|
25240
|
+
let migrateResult = { tmpl: result, offsets: { pre: 0, post: 0 } };
|
|
25241
|
+
offset = reduceNestingOffset(el, nestLevel, offset, postOffsets);
|
|
25242
|
+
try {
|
|
25243
|
+
migrateResult = migrateNgIf(el, result, offset);
|
|
25244
|
+
} catch (error2) {
|
|
25245
|
+
errors.push({ type: ngif, error: error2 });
|
|
25246
|
+
}
|
|
25247
|
+
result = migrateResult.tmpl;
|
|
25248
|
+
offset += migrateResult.offsets.pre;
|
|
25249
|
+
postOffsets.push(migrateResult.offsets.post);
|
|
25250
|
+
nestLevel = el.nestCount;
|
|
25251
|
+
}
|
|
25252
|
+
return { migrated: result, errors };
|
|
25223
25253
|
}
|
|
25224
|
-
function
|
|
25225
|
-
|
|
25226
|
-
|
|
25227
|
-
|
|
25228
|
-
|
|
25229
|
-
|
|
25254
|
+
function migrateNgIf(etm, tmpl, offset) {
|
|
25255
|
+
const matchThen = etm.attr.value.match(/;\s*then/gm);
|
|
25256
|
+
const matchElse = etm.attr.value.match(/;\s*else/gm);
|
|
25257
|
+
if (matchThen && matchThen.length > 0) {
|
|
25258
|
+
return buildIfThenElseBlock(etm, tmpl, matchThen[0], matchElse[0], offset);
|
|
25259
|
+
} else if (matchElse && matchElse.length > 0) {
|
|
25260
|
+
return buildIfElseBlock(etm, tmpl, matchElse[0], offset);
|
|
25230
25261
|
}
|
|
25231
|
-
|
|
25232
|
-
|
|
25233
|
-
|
|
25234
|
-
|
|
25235
|
-
|
|
25236
|
-
|
|
25237
|
-
|
|
25262
|
+
return buildIfBlock(etm, tmpl, offset);
|
|
25263
|
+
}
|
|
25264
|
+
function buildIfBlock(etm, tmpl, offset) {
|
|
25265
|
+
const lbString = etm.hasLineBreaks ? "\n" : "";
|
|
25266
|
+
const condition = etm.attr.value.replace(" as ", "; as ");
|
|
25267
|
+
const originals = getOriginals(etm, tmpl, offset);
|
|
25268
|
+
const { start, middle, end } = getMainBlock(etm, tmpl, offset);
|
|
25269
|
+
const startBlock = `@if (${condition}) {${lbString}${start}`;
|
|
25270
|
+
const endBlock = `${end}${lbString}}`;
|
|
25271
|
+
const ifBlock = startBlock + middle + endBlock;
|
|
25272
|
+
const updatedTmpl = tmpl.slice(0, etm.start(offset)) + ifBlock + tmpl.slice(etm.end(offset));
|
|
25273
|
+
const pre = originals.start.length - startBlock.length;
|
|
25274
|
+
const post = originals.end.length - endBlock.length;
|
|
25275
|
+
return { tmpl: updatedTmpl, offsets: { pre, post } };
|
|
25276
|
+
}
|
|
25277
|
+
function buildIfElseBlock(etm, tmpl, elseString, offset) {
|
|
25278
|
+
const lbString = etm.hasLineBreaks ? "\n" : "";
|
|
25279
|
+
const condition = etm.getCondition(elseString).replace(" as ", "; as ");
|
|
25280
|
+
const originals = getOriginals(etm, tmpl, offset);
|
|
25281
|
+
const elsePlaceholder = `#${etm.getTemplateName(elseString)}|`;
|
|
25282
|
+
const { start, middle, end } = getMainBlock(etm, tmpl, offset);
|
|
25283
|
+
const startBlock = `@if (${condition}) {${lbString}${start}`;
|
|
25284
|
+
const elseBlock = `${end}${lbString}} @else {${lbString}`;
|
|
25285
|
+
const postBlock = elseBlock + elsePlaceholder + `${lbString}}`;
|
|
25286
|
+
const ifElseBlock = startBlock + middle + postBlock;
|
|
25287
|
+
const tmplStart = tmpl.slice(0, etm.start(offset));
|
|
25288
|
+
const tmplEnd = tmpl.slice(etm.end(offset));
|
|
25289
|
+
const updatedTmpl = tmplStart + ifElseBlock + tmplEnd;
|
|
25290
|
+
const pre = originals.start.length - startBlock.length;
|
|
25291
|
+
const post = originals.end.length - postBlock.length;
|
|
25292
|
+
return { tmpl: updatedTmpl, offsets: { pre, post } };
|
|
25293
|
+
}
|
|
25294
|
+
function buildIfThenElseBlock(etm, tmpl, thenString, elseString, offset) {
|
|
25295
|
+
const condition = etm.getCondition(thenString).replace(" as ", "; as ");
|
|
25296
|
+
const lbString = etm.hasLineBreaks ? "\n" : "";
|
|
25297
|
+
const originals = getOriginals(etm, tmpl, offset);
|
|
25298
|
+
const startBlock = `@if (${condition}) {${lbString}`;
|
|
25299
|
+
const elseBlock = `${lbString}} @else {${lbString}`;
|
|
25300
|
+
const thenPlaceholder = `#${etm.getTemplateName(thenString, elseString)}|`;
|
|
25301
|
+
const elsePlaceholder = `#${etm.getTemplateName(elseString)}|`;
|
|
25302
|
+
const postBlock = thenPlaceholder + elseBlock + elsePlaceholder + `${lbString}}`;
|
|
25303
|
+
const ifThenElseBlock = startBlock + postBlock;
|
|
25304
|
+
const tmplStart = tmpl.slice(0, etm.start(offset));
|
|
25305
|
+
const tmplEnd = tmpl.slice(etm.end(offset));
|
|
25306
|
+
const updatedTmpl = tmplStart + ifThenElseBlock + tmplEnd;
|
|
25307
|
+
const pre = originals.start.length - startBlock.length;
|
|
25308
|
+
const post = originals.end.length - postBlock.length;
|
|
25309
|
+
return { tmpl: updatedTmpl, offsets: { pre, post } };
|
|
25310
|
+
}
|
|
25311
|
+
|
|
25312
|
+
// bazel-out/k8-fastbuild/bin/packages/core/schematics/ng-generate/control-flow-migration/switches.mjs
|
|
25313
|
+
var ngswitch = "[ngSwitch]";
|
|
25314
|
+
var boundcase = "[ngSwitchCase]";
|
|
25315
|
+
var switchcase = "*ngSwitchCase";
|
|
25316
|
+
var nakedcase = "ngSwitchCase";
|
|
25317
|
+
var switchdefault = "*ngSwitchDefault";
|
|
25318
|
+
var nakeddefault = "ngSwitchDefault";
|
|
25319
|
+
var switches = [
|
|
25320
|
+
ngswitch,
|
|
25321
|
+
boundcase,
|
|
25322
|
+
switchcase,
|
|
25323
|
+
nakedcase,
|
|
25324
|
+
switchdefault,
|
|
25325
|
+
nakeddefault
|
|
25326
|
+
];
|
|
25327
|
+
function migrateSwitch(template2) {
|
|
25328
|
+
let errors = [];
|
|
25329
|
+
let parsed = parseTemplate2(template2);
|
|
25330
|
+
if (parsed === null) {
|
|
25331
|
+
return { migrated: template2, errors };
|
|
25238
25332
|
}
|
|
25239
|
-
let
|
|
25240
|
-
|
|
25241
|
-
|
|
25242
|
-
|
|
25243
|
-
|
|
25333
|
+
let result = template2;
|
|
25334
|
+
const visitor = new ElementCollector(switches);
|
|
25335
|
+
visitAll2(visitor, parsed.rootNodes);
|
|
25336
|
+
calculateNesting(visitor, hasLineBreaks(template2));
|
|
25337
|
+
let offset = 0;
|
|
25338
|
+
let nestLevel = -1;
|
|
25339
|
+
let postOffsets = [];
|
|
25340
|
+
for (const el of visitor.elements) {
|
|
25341
|
+
let migrateResult = { tmpl: result, offsets: { pre: 0, post: 0 } };
|
|
25342
|
+
offset = reduceNestingOffset(el, nestLevel, offset, postOffsets);
|
|
25343
|
+
if (el.attr.name === ngswitch) {
|
|
25344
|
+
try {
|
|
25345
|
+
migrateResult = migrateNgSwitch(el, result, offset);
|
|
25346
|
+
} catch (error2) {
|
|
25347
|
+
errors.push({ type: ngswitch, error: error2 });
|
|
25348
|
+
}
|
|
25349
|
+
} else if (el.attr.name === switchcase || el.attr.name === nakedcase || el.attr.name === boundcase) {
|
|
25350
|
+
try {
|
|
25351
|
+
migrateResult = migrateNgSwitchCase(el, result, offset);
|
|
25352
|
+
} catch (error2) {
|
|
25353
|
+
errors.push({ type: ngswitch, error: error2 });
|
|
25354
|
+
}
|
|
25355
|
+
} else if (el.attr.name === switchdefault || el.attr.name === nakeddefault) {
|
|
25356
|
+
try {
|
|
25357
|
+
migrateResult = migrateNgSwitchDefault(el, result, offset);
|
|
25358
|
+
} catch (error2) {
|
|
25359
|
+
errors.push({ type: ngswitch, error: error2 });
|
|
25360
|
+
}
|
|
25361
|
+
}
|
|
25362
|
+
result = migrateResult.tmpl;
|
|
25363
|
+
offset += migrateResult.offsets.pre;
|
|
25364
|
+
postOffsets.push(migrateResult.offsets.post);
|
|
25365
|
+
nestLevel = el.nestCount;
|
|
25366
|
+
}
|
|
25367
|
+
return { migrated: result, errors };
|
|
25244
25368
|
}
|
|
25245
25369
|
function migrateNgSwitch(etm, tmpl, offset) {
|
|
25246
|
-
const lbString = etm.hasLineBreaks ?
|
|
25370
|
+
const lbString = etm.hasLineBreaks ? "\n" : "";
|
|
25247
25371
|
const condition = etm.attr.value;
|
|
25248
25372
|
const originals = getOriginals(etm, tmpl, offset);
|
|
25249
25373
|
const { start, middle, end } = getMainBlock(etm, tmpl, offset);
|
|
@@ -25256,7 +25380,7 @@ function migrateNgSwitch(etm, tmpl, offset) {
|
|
|
25256
25380
|
return { tmpl: updatedTmpl, offsets: { pre, post } };
|
|
25257
25381
|
}
|
|
25258
25382
|
function migrateNgSwitchCase(etm, tmpl, offset) {
|
|
25259
|
-
const lbString = etm.hasLineBreaks ?
|
|
25383
|
+
const lbString = etm.hasLineBreaks ? "\n" : "";
|
|
25260
25384
|
const lbSpaces = etm.hasLineBreaks ? " " : "";
|
|
25261
25385
|
const leadingSpace = etm.hasLineBreaks ? "" : " ";
|
|
25262
25386
|
const condition = etm.attr.value;
|
|
@@ -25271,7 +25395,7 @@ function migrateNgSwitchCase(etm, tmpl, offset) {
|
|
|
25271
25395
|
return { tmpl: updatedTmpl, offsets: { pre, post } };
|
|
25272
25396
|
}
|
|
25273
25397
|
function migrateNgSwitchDefault(etm, tmpl, offset) {
|
|
25274
|
-
const lbString = etm.hasLineBreaks ?
|
|
25398
|
+
const lbString = etm.hasLineBreaks ? "\n" : "";
|
|
25275
25399
|
const lbSpaces = etm.hasLineBreaks ? " " : "";
|
|
25276
25400
|
const leadingSpace = etm.hasLineBreaks ? "" : " ";
|
|
25277
25401
|
const originals = getOriginals(etm, tmpl, offset);
|
|
@@ -25284,14 +25408,6 @@ function migrateNgSwitchDefault(etm, tmpl, offset) {
|
|
|
25284
25408
|
const post = originals.end.length - endBlock.length;
|
|
25285
25409
|
return { tmpl: updatedTmpl, offsets: { pre, post } };
|
|
25286
25410
|
}
|
|
25287
|
-
function forEachClass(sourceFile, callback) {
|
|
25288
|
-
sourceFile.forEachChild(function walk(node) {
|
|
25289
|
-
if (import_typescript5.default.isClassDeclaration(node)) {
|
|
25290
|
-
callback(node);
|
|
25291
|
-
}
|
|
25292
|
-
node.forEachChild(walk);
|
|
25293
|
-
});
|
|
25294
|
-
}
|
|
25295
25411
|
|
|
25296
25412
|
// bazel-out/k8-fastbuild/bin/packages/core/schematics/ng-generate/control-flow-migration/index.mjs
|
|
25297
25413
|
function control_flow_migration_default(options) {
|
|
@@ -25340,7 +25456,15 @@ function runControlFlowMigration(tree, tsconfigPath, basePath, pathToMigrate, sc
|
|
|
25340
25456
|
for (const [start, end] of ranges) {
|
|
25341
25457
|
const template2 = content.slice(start, end);
|
|
25342
25458
|
const length = (end != null ? end : content.length) - start;
|
|
25343
|
-
const
|
|
25459
|
+
const ifResult = migrateIf(template2);
|
|
25460
|
+
const forResult = migrateFor(ifResult.migrated);
|
|
25461
|
+
const switchResult = migrateSwitch(forResult.migrated);
|
|
25462
|
+
const errors = [
|
|
25463
|
+
...ifResult.errors,
|
|
25464
|
+
...forResult.errors,
|
|
25465
|
+
...switchResult.errors
|
|
25466
|
+
];
|
|
25467
|
+
const migrated = processNgTemplates(switchResult.migrated);
|
|
25344
25468
|
if (migrated !== null) {
|
|
25345
25469
|
update.remove(start, length);
|
|
25346
25470
|
update.insertLeft(start, migrated);
|