barrelize 1.6.4 → 1.6.6
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/lib/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as actualFS from "node:fs";
|
|
2
|
+
import { statSync, existsSync, readFileSync } from "node:fs";
|
|
2
3
|
import { fileURLToPath } from "node:url";
|
|
3
4
|
import { resolve, dirname, extname, join, win32, posix, relative, sep as sep$1 } from "node:path";
|
|
4
5
|
import { realpathSync as realpathSync$1, readlinkSync, readdirSync, readdir as readdir$1, lstatSync, unwatchFile, watchFile, watch as watch$1, stat as stat$2 } from "fs";
|
|
5
|
-
import
|
|
6
|
-
import { existsSync } from "node:fs";
|
|
6
|
+
import { writeFile, readFile, realpath, readlink, readdir, lstat, stat } from "node:fs/promises";
|
|
7
7
|
import { EventEmitter as EventEmitter$1 } from "node:events";
|
|
8
8
|
import Stream, { Readable } from "node:stream";
|
|
9
9
|
import { StringDecoder } from "node:string_decoder";
|
|
@@ -594,11 +594,11 @@ class CAC extends EventEmitter {
|
|
|
594
594
|
}
|
|
595
595
|
const cac = (name2 = "") => new CAC(name2);
|
|
596
596
|
const name = "barrelize";
|
|
597
|
-
const version = "1.6.
|
|
597
|
+
const version = "1.6.6";
|
|
598
598
|
function cliInit() {
|
|
599
599
|
const cli = cac(name);
|
|
600
|
-
cli.command("[config path]", `Generate barrel files`).option("-w, --watch", "Watch for changes and regenerate barrel files automatically").action(
|
|
601
|
-
|
|
600
|
+
cli.command("[config path]", `Generate barrel files`).option("-w, --watch", "Watch for changes and regenerate barrel files automatically").action((configPath, options) => {
|
|
601
|
+
runGenerateCommand({ configPath: configPath || ".barrelize", watch: !!options.watch });
|
|
602
602
|
});
|
|
603
603
|
cli.command("init [config path]", "Create .barrelize config file if does not exist").example("barrelize init").example("barrelize init .barrelize").example("barrelize init root/.barrelize").action(async (path2 = ".barrelize") => {
|
|
604
604
|
await runInitCommand(path2);
|
|
@@ -879,17 +879,18 @@ const validateGenerateOptions = (() => {
|
|
|
879
879
|
};
|
|
880
880
|
});
|
|
881
881
|
})();
|
|
882
|
-
|
|
882
|
+
function runGenerateCommand(options) {
|
|
883
883
|
const validatedOptions = validateGenerateOptions(options);
|
|
884
884
|
if (!validatedOptions.success) {
|
|
885
885
|
logValidationError(`Invalid 'generate' command options`, validatedOptions);
|
|
886
886
|
return;
|
|
887
887
|
}
|
|
888
|
-
|
|
888
|
+
const configPathStat = statSync(options.configPath);
|
|
889
|
+
if (!configPathStat.isFile()) {
|
|
889
890
|
logError(`Couldn't find barrelize config file with path '${options.configPath}'`);
|
|
890
891
|
return;
|
|
891
892
|
}
|
|
892
|
-
const config =
|
|
893
|
+
const config = parseConfig(options.configPath);
|
|
893
894
|
const validatedConfig = validateConfig(config);
|
|
894
895
|
if (!validatedConfig.success) {
|
|
895
896
|
logValidationError(`Invalid barrelize config`, validatedConfig);
|
|
@@ -899,7 +900,7 @@ async function runGenerateCommand(options) {
|
|
|
899
900
|
if (options.watch) {
|
|
900
901
|
watchBarrels(configDir, options.configPath, validatedConfig.data);
|
|
901
902
|
} else {
|
|
902
|
-
|
|
903
|
+
generateBarrels(configDir, options.configPath, validatedConfig.data);
|
|
903
904
|
}
|
|
904
905
|
}
|
|
905
906
|
async function runInitCommand(baseConfigFilePath) {
|
|
@@ -2310,8 +2311,8 @@ const JSON5 = {
|
|
|
2310
2311
|
stringify
|
|
2311
2312
|
};
|
|
2312
2313
|
var lib$1 = JSON5;
|
|
2313
|
-
|
|
2314
|
-
const configJson = (
|
|
2314
|
+
function parseConfig(configPath) {
|
|
2315
|
+
const configJson = readFileSync(configPath).toString();
|
|
2315
2316
|
try {
|
|
2316
2317
|
return lib$1.parse(configJson);
|
|
2317
2318
|
} catch (error) {
|
|
@@ -2777,7 +2778,7 @@ function requireLib() {
|
|
|
2777
2778
|
allowUndeclaredExports: false,
|
|
2778
2779
|
allowYieldOutsideFunction: false,
|
|
2779
2780
|
plugins: [],
|
|
2780
|
-
strictMode:
|
|
2781
|
+
strictMode: void 0,
|
|
2781
2782
|
ranges: false,
|
|
2782
2783
|
tokens: false,
|
|
2783
2784
|
createImportExpressions: false,
|
|
@@ -2967,7 +2968,6 @@ function requireLib() {
|
|
|
2967
2968
|
}
|
|
2968
2969
|
convertPrivateNameToPrivateIdentifier(node) {
|
|
2969
2970
|
const name2 = super.getPrivateNameSV(node);
|
|
2970
|
-
node = node;
|
|
2971
2971
|
delete node.id;
|
|
2972
2972
|
node.name = name2;
|
|
2973
2973
|
return this.castNodeTo(node, "PrivateIdentifier");
|
|
@@ -3082,8 +3082,8 @@ function requireLib() {
|
|
|
3082
3082
|
node.kind = "init";
|
|
3083
3083
|
return this.finishNode(node, "Property");
|
|
3084
3084
|
}
|
|
3085
|
-
isValidLVal(type2, isUnparenthesizedInAssign, binding) {
|
|
3086
|
-
return type2 === "Property" ? "value" : super.isValidLVal(type2, isUnparenthesizedInAssign, binding);
|
|
3085
|
+
isValidLVal(type2, disallowCallExpression, isUnparenthesizedInAssign, binding) {
|
|
3086
|
+
return type2 === "Property" ? "value" : super.isValidLVal(type2, disallowCallExpression, isUnparenthesizedInAssign, binding);
|
|
3087
3087
|
}
|
|
3088
3088
|
isAssignable(node, isBinding) {
|
|
3089
3089
|
if (node != null && this.isObjectProperty(node)) {
|
|
@@ -3800,13 +3800,13 @@ function requireLib() {
|
|
|
3800
3800
|
context.push(types2.j_expr, types2.j_oTag);
|
|
3801
3801
|
};
|
|
3802
3802
|
}
|
|
3803
|
-
let nonASCIIidentifierStartChars = "
|
|
3804
|
-
let nonASCIIidentifierChars = "
|
|
3803
|
+
let nonASCIIidentifierStartChars = "ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽͿΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԯԱ-Ֆՙՠ-ֈא-תׯ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࡠ-ࡪࡰ-ࢇࢉ-ࢠ-ࣉऄ-हऽॐक़-ॡॱ-ঀঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱৼਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡૹଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-హఽౘ-ౚౝౠౡಀಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽ-ೞೠೡೱೲഄ-ഌഎ-ഐഒ-ഺഽൎൔ-ൖൟ-ൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄຆ-ຊຌ-ຣລວ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏽᏸ-ᏽᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛸᜀ-ᜑᜟ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡸᢀ-ᢨᢪᢰ-ᣵᤀ-ᤞᥐ-ᥭᥰ-ᥴᦀ-ᦫᦰ-ᧉᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭌᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᲀ-Ა-ᲺᲽ-Ჿᳩ-ᳬᳮ-ᳳᳵᳶᳺᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₜℂℇℊ-ℓℕ℘-ℝℤΩℨK-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞ々-〇〡-〩〱-〵〸-〼ぁ-ゖ゛-ゟァ-ヺー-ヿㄅ-ㄯㄱ-ㆎㆠ-ㆿㇰ-ㇿ㐀-䶿一-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚝꚠ-ꛯꜗ-ꜟꜢ-ꞈꞋ--ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꣽꣾꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꧠ-ꧤꧦ-ꧯꧺ-ꧾꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꩾ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꬰ-ꭚꭜ-ꭩꭰ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ";
|
|
3804
|
+
let nonASCIIidentifierChars = "·̀-ͯ·҃-֑҇-ׇֽֿׁׂׅׄؐ-ًؚ-٩ٰۖ-ۜ۟-۪ۤۧۨ-ۭ۰-۹ܑܰ-݊ަ-ް߀-߉߫-߽߳ࠖ-࠙ࠛ-ࠣࠥ-ࠧࠩ-࡙࠭-࡛-࢟࣊-ࣣ࣡-ःऺ-़ा-ॏ॑-ॗॢॣ०-९ঁ-ঃ়া-ৄেৈো-্ৗৢৣ০-৯৾ਁ-ਃ਼ਾ-ੂੇੈੋ-੍ੑ੦-ੱੵઁ-ઃ઼ા-ૅે-ૉો-્ૢૣ૦-૯ૺ-૿ଁ-ଃ଼ା-ୄେୈୋ-୍୕-ୗୢୣ୦-୯ஂா-ூெ-ைொ-்ௗ௦-௯ఀ-ఄ఼ా-ౄె-ైొ-్ౕౖౢౣ౦-౯ಁ-ಃ಼ಾ-ೄೆ-ೈೊ-್ೕೖೢೣ೦-೯ೳഀ-ഃ഻഼ാ-ൄെ-ൈൊ-്ൗൢൣ൦-൯ඁ-ඃ්ා-ුූෘ-ෟ෦-෯ෲෳัิ-ฺ็-๎๐-๙ັິ-ຼ່-໎໐-໙༘༙༠-༩༹༵༷༾༿ཱ-྄྆྇ྍ-ྗྙ-ྼ࿆ါ-ှ၀-၉ၖ-ၙၞ-ၠၢ-ၤၧ-ၭၱ-ၴႂ-ႍႏ-ႝ፝-፟፩-፱ᜒ-᜕ᜲ-᜴ᝒᝓᝲᝳ឴-៓៝០-៩᠋-᠍᠏-᠙ᢩᤠ-ᤫᤰ-᤻᥆-᥏᧐-᧚ᨗ-ᨛᩕ-ᩞ᩠-᩿᩼-᪉᪐-᪙᪰-᪽ᪿ--ᬀ-ᬄ᬴-᭄᭐-᭙᭫-᭳ᮀ-ᮂᮡ-ᮭ᮰-᮹᯦-᯳ᰤ-᰷᱀-᱉᱐-᱙᳐-᳔᳒-᳨᳭᳴᳷-᳹᷀-᷿‿⁀⁔⃐-⃥⃜⃡-⃰⳯-⵿⳱ⷠ-〪ⷿ-゙゚〯・꘠-꘩꙯ꙴ-꙽ꚞꚟ꛰꛱ꠂ꠆ꠋꠣ-ꠧ꠬ꢀꢁꢴ-ꣅ꣐-꣙꣠-꣱ꣿ-꤉ꤦ-꤭ꥇ-꥓ꦀ-ꦃ꦳-꧀꧐-꧙ꧥ꧰-꧹ꨩ-ꨶꩃꩌꩍ꩐-꩙ꩻ-ꩽꪰꪲ-ꪴꪷꪸꪾ꪿꫁ꫫ-ꫯꫵ꫶ꯣ-ꯪ꯬꯭꯰-꯹ﬞ︀-️︠-︯︳︴﹍-﹏0-9_・";
|
|
3805
3805
|
const nonASCIIidentifierStart = new RegExp("[" + nonASCIIidentifierStartChars + "]");
|
|
3806
3806
|
const nonASCIIidentifier = new RegExp("[" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "]");
|
|
3807
3807
|
nonASCIIidentifierStartChars = nonASCIIidentifierChars = null;
|
|
3808
|
-
const astralIdentifierStartCodes = [0, 11, 2, 25, 2, 18, 2, 1, 2, 14, 3, 13, 35, 122, 70, 52, 268, 28, 4, 48, 48, 31, 14, 29, 6, 37, 11, 29, 3, 35, 5, 7, 2, 4, 43, 157, 19, 35, 5, 35, 5, 39, 9, 51, 13, 10, 2, 14, 2, 6, 2, 1, 2, 10, 2, 14, 2, 6, 2, 1, 4, 51, 13, 310, 10, 21, 11, 7, 25, 5, 2, 41, 2, 8, 70, 5, 3, 0, 2, 43, 2, 1, 4, 0, 3, 22, 11, 22, 10, 30, 66, 18, 2, 1, 11, 21, 11, 25,
|
|
3809
|
-
const astralIdentifierCodes = [509, 0, 227, 0, 150, 4, 294, 9, 1368, 2, 2, 1, 6, 3, 41, 2, 5, 0, 166, 1, 574, 3, 9, 9, 7, 9, 32, 4, 318, 1,
|
|
3808
|
+
const astralIdentifierStartCodes = [0, 11, 2, 25, 2, 18, 2, 1, 2, 14, 3, 13, 35, 122, 70, 52, 268, 28, 4, 48, 48, 31, 14, 29, 6, 37, 11, 29, 3, 35, 5, 7, 2, 4, 43, 157, 19, 35, 5, 35, 5, 39, 9, 51, 13, 10, 2, 14, 2, 6, 2, 1, 2, 10, 2, 14, 2, 6, 2, 1, 4, 51, 13, 310, 10, 21, 11, 7, 25, 5, 2, 41, 2, 8, 70, 5, 3, 0, 2, 43, 2, 1, 4, 0, 3, 22, 11, 22, 10, 30, 66, 18, 2, 1, 11, 21, 11, 25, 7, 25, 39, 55, 7, 1, 65, 0, 16, 3, 2, 2, 2, 28, 43, 28, 4, 28, 36, 7, 2, 27, 28, 53, 11, 21, 11, 18, 14, 17, 111, 72, 56, 50, 14, 50, 14, 35, 39, 27, 10, 22, 251, 41, 7, 1, 17, 5, 57, 28, 11, 0, 9, 21, 43, 17, 47, 20, 28, 22, 13, 52, 58, 1, 3, 0, 14, 44, 33, 24, 27, 35, 30, 0, 3, 0, 9, 34, 4, 0, 13, 47, 15, 3, 22, 0, 2, 0, 36, 17, 2, 24, 20, 1, 64, 6, 2, 0, 2, 3, 2, 14, 2, 9, 8, 46, 39, 7, 3, 1, 3, 21, 2, 6, 2, 1, 2, 4, 4, 0, 19, 0, 13, 4, 31, 9, 2, 0, 3, 0, 2, 37, 2, 0, 26, 0, 2, 0, 45, 52, 19, 3, 21, 2, 31, 47, 21, 1, 2, 0, 185, 46, 42, 3, 37, 47, 21, 0, 60, 42, 14, 0, 72, 26, 38, 6, 186, 43, 117, 63, 32, 7, 3, 0, 3, 7, 2, 1, 2, 23, 16, 0, 2, 0, 95, 7, 3, 38, 17, 0, 2, 0, 29, 0, 11, 39, 8, 0, 22, 0, 12, 45, 20, 0, 19, 72, 200, 32, 32, 8, 2, 36, 18, 0, 50, 29, 113, 6, 2, 1, 2, 37, 22, 0, 26, 5, 2, 1, 2, 31, 15, 0, 24, 43, 261, 18, 16, 0, 2, 12, 2, 33, 125, 0, 80, 921, 103, 110, 18, 195, 2637, 96, 16, 1071, 18, 5, 26, 3994, 6, 582, 6842, 29, 1763, 568, 8, 30, 18, 78, 18, 29, 19, 47, 17, 3, 32, 20, 6, 18, 433, 44, 212, 63, 33, 24, 3, 24, 45, 74, 6, 0, 67, 12, 65, 1, 2, 0, 15, 4, 10, 7381, 42, 31, 98, 114, 8702, 3, 2, 6, 2, 1, 2, 290, 16, 0, 30, 2, 3, 0, 15, 3, 9, 395, 2309, 106, 6, 12, 4, 8, 8, 9, 5991, 84, 2, 70, 2, 1, 3, 0, 3, 1, 3, 3, 2, 11, 2, 0, 2, 6, 2, 64, 2, 3, 3, 7, 2, 6, 2, 27, 2, 3, 2, 4, 2, 0, 4, 6, 2, 339, 3, 24, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 7, 1845, 30, 7, 5, 262, 61, 147, 44, 11, 6, 17, 0, 322, 29, 19, 43, 485, 27, 229, 29, 3, 0, 208, 30, 2, 2, 2, 1, 2, 6, 3, 4, 10, 1, 225, 6, 2, 3, 2, 1, 2, 14, 2, 196, 60, 67, 8, 0, 1205, 3, 2, 26, 2, 1, 2, 0, 3, 0, 2, 9, 2, 3, 2, 0, 2, 0, 7, 0, 5, 0, 2, 0, 2, 0, 2, 2, 2, 1, 2, 0, 3, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 1, 2, 0, 3, 3, 2, 6, 2, 3, 2, 3, 2, 0, 2, 9, 2, 16, 6, 2, 2, 4, 2, 16, 4421, 42719, 33, 4381, 3, 5773, 3, 7472, 16, 621, 2467, 541, 1507, 4938, 6, 8489];
|
|
3809
|
+
const astralIdentifierCodes = [509, 0, 227, 0, 150, 4, 294, 9, 1368, 2, 2, 1, 6, 3, 41, 2, 5, 0, 166, 1, 574, 3, 9, 9, 7, 9, 32, 4, 318, 1, 78, 5, 71, 10, 50, 3, 123, 2, 54, 14, 32, 10, 3, 1, 11, 3, 46, 10, 8, 0, 46, 9, 7, 2, 37, 13, 2, 9, 6, 1, 45, 0, 13, 2, 49, 13, 9, 3, 2, 11, 83, 11, 7, 0, 3, 0, 158, 11, 6, 9, 7, 3, 56, 1, 2, 6, 3, 1, 3, 2, 10, 0, 11, 1, 3, 6, 4, 4, 68, 8, 2, 0, 3, 0, 2, 3, 2, 4, 2, 0, 15, 1, 83, 17, 10, 9, 5, 0, 82, 19, 13, 9, 214, 6, 3, 8, 28, 1, 83, 16, 16, 9, 82, 12, 9, 9, 7, 19, 58, 14, 5, 9, 243, 14, 166, 9, 71, 5, 2, 1, 3, 3, 2, 0, 2, 1, 13, 9, 120, 6, 3, 6, 4, 0, 29, 9, 41, 6, 2, 3, 9, 0, 10, 10, 47, 15, 199, 7, 137, 9, 54, 7, 2, 7, 17, 9, 57, 21, 2, 13, 123, 5, 4, 0, 2, 1, 2, 6, 2, 0, 9, 9, 49, 4, 2, 1, 2, 4, 9, 9, 55, 9, 266, 3, 10, 1, 2, 0, 49, 6, 4, 4, 14, 10, 5350, 0, 7, 14, 11465, 27, 2343, 9, 87, 9, 39, 4, 60, 6, 26, 9, 535, 9, 470, 0, 2, 54, 8, 3, 82, 0, 12, 1, 19628, 1, 4178, 9, 519, 45, 3, 22, 543, 4, 4, 5, 9, 7, 3, 6, 31, 3, 149, 2, 1418, 49, 513, 54, 5, 49, 9, 0, 15, 0, 23, 4, 2, 14, 1361, 6, 2, 16, 3, 6, 2, 1, 2, 4, 101, 0, 161, 6, 10, 9, 357, 0, 62, 13, 499, 13, 245, 1, 2, 9, 233, 0, 3, 0, 8, 1, 6, 0, 475, 6, 110, 6, 6, 9, 4759, 9, 787719, 239];
|
|
3810
3810
|
function isInAstralSet(code2, set) {
|
|
3811
3811
|
let pos2 = 65536;
|
|
3812
3812
|
for (let i = 0, length = set.length; i < length; i += 2) {
|
|
@@ -3990,7 +3990,7 @@ function requireLib() {
|
|
|
3990
3990
|
if (bindingType & 8) {
|
|
3991
3991
|
return scope.names.has(name2);
|
|
3992
3992
|
}
|
|
3993
|
-
const type2 = scope.names.get(name2);
|
|
3993
|
+
const type2 = scope.names.get(name2) || 0;
|
|
3994
3994
|
if (bindingType & 16) {
|
|
3995
3995
|
return (type2 & 2) > 0 || !this.treatFunctionsAsVarInScope(scope) && (type2 & 1) > 0;
|
|
3996
3996
|
}
|
|
@@ -4306,9 +4306,8 @@ function requireLib() {
|
|
|
4306
4306
|
return this.flowParseDeclareInterface(node);
|
|
4307
4307
|
} else if (this.match(82)) {
|
|
4308
4308
|
return this.flowParseDeclareExportDeclaration(node, insideModule);
|
|
4309
|
-
} else {
|
|
4310
|
-
this.unexpected();
|
|
4311
4309
|
}
|
|
4310
|
+
throw this.unexpected();
|
|
4312
4311
|
}
|
|
4313
4312
|
flowParseDeclareVariable(node) {
|
|
4314
4313
|
this.next();
|
|
@@ -4328,18 +4327,17 @@ function requireLib() {
|
|
|
4328
4327
|
const body = bodyNode.body = [];
|
|
4329
4328
|
this.expect(5);
|
|
4330
4329
|
while (!this.match(8)) {
|
|
4331
|
-
|
|
4330
|
+
const bodyNode2 = this.startNode();
|
|
4332
4331
|
if (this.match(83)) {
|
|
4333
4332
|
this.next();
|
|
4334
4333
|
if (!this.isContextual(130) && !this.match(87)) {
|
|
4335
4334
|
this.raise(FlowErrors.InvalidNonTypeImportInDeclareModule, this.state.lastTokStartLoc);
|
|
4336
4335
|
}
|
|
4337
|
-
super.parseImport(bodyNode2);
|
|
4336
|
+
body.push(super.parseImport(bodyNode2));
|
|
4338
4337
|
} else {
|
|
4339
4338
|
this.expectContextual(125, FlowErrors.UnsupportedStatementInDeclareModule);
|
|
4340
|
-
|
|
4339
|
+
body.push(this.flowParseDeclare(bodyNode2, true));
|
|
4341
4340
|
}
|
|
4342
|
-
body.push(bodyNode2);
|
|
4343
4341
|
}
|
|
4344
4342
|
this.scope.exit();
|
|
4345
4343
|
this.expect(8);
|
|
@@ -4400,7 +4398,7 @@ function requireLib() {
|
|
|
4400
4398
|
}
|
|
4401
4399
|
}
|
|
4402
4400
|
}
|
|
4403
|
-
this.unexpected();
|
|
4401
|
+
throw this.unexpected();
|
|
4404
4402
|
}
|
|
4405
4403
|
flowParseDeclareModuleExports(node) {
|
|
4406
4404
|
this.next();
|
|
@@ -4608,7 +4606,7 @@ function requireLib() {
|
|
|
4608
4606
|
return this.finishNode(node, "TypeParameterInstantiation");
|
|
4609
4607
|
}
|
|
4610
4608
|
flowParseTypeParameterInstantiationCallOrNew() {
|
|
4611
|
-
if (this.reScan_lt() !== 47) return;
|
|
4609
|
+
if (this.reScan_lt() !== 47) return null;
|
|
4612
4610
|
const node = this.startNode();
|
|
4613
4611
|
const oldInType = this.state.inType;
|
|
4614
4612
|
node.params = [];
|
|
@@ -5102,8 +5100,7 @@ function requireLib() {
|
|
|
5102
5100
|
}
|
|
5103
5101
|
throw this.raise(FlowErrors.UnexpectedSubtractionOperand, this.state.startLoc);
|
|
5104
5102
|
}
|
|
5105
|
-
this.unexpected();
|
|
5106
|
-
return;
|
|
5103
|
+
throw this.unexpected();
|
|
5107
5104
|
case 135:
|
|
5108
5105
|
return this.parseLiteral(this.state.value, "NumberLiteralTypeAnnotation");
|
|
5109
5106
|
case 136:
|
|
@@ -5134,7 +5131,7 @@ function requireLib() {
|
|
|
5134
5131
|
return this.flowIdentToTypeAnnotation(startLoc, node, this.parseIdentifier());
|
|
5135
5132
|
}
|
|
5136
5133
|
}
|
|
5137
|
-
this.unexpected();
|
|
5134
|
+
throw this.unexpected();
|
|
5138
5135
|
}
|
|
5139
5136
|
flowParsePostfixType() {
|
|
5140
5137
|
const startLoc = this.state.startLoc;
|
|
@@ -5595,15 +5592,15 @@ function requireLib() {
|
|
|
5595
5592
|
}
|
|
5596
5593
|
return exprList;
|
|
5597
5594
|
}
|
|
5598
|
-
parseArrayLike(close,
|
|
5599
|
-
const node = super.parseArrayLike(close,
|
|
5600
|
-
if (
|
|
5595
|
+
parseArrayLike(close, isTuple, refExpressionErrors) {
|
|
5596
|
+
const node = super.parseArrayLike(close, isTuple, refExpressionErrors);
|
|
5597
|
+
if (refExpressionErrors != null && !this.state.maybeInArrowParameters) {
|
|
5601
5598
|
this.toReferencedList(node.elements);
|
|
5602
5599
|
}
|
|
5603
5600
|
return node;
|
|
5604
5601
|
}
|
|
5605
|
-
isValidLVal(type2, isParenthesized, binding) {
|
|
5606
|
-
return type2 === "TypeCastExpression" || super.isValidLVal(type2, isParenthesized, binding);
|
|
5602
|
+
isValidLVal(type2, disallowCallExpression, isParenthesized, binding) {
|
|
5603
|
+
return type2 === "TypeCastExpression" || super.isValidLVal(type2, disallowCallExpression, isParenthesized, binding);
|
|
5607
5604
|
}
|
|
5608
5605
|
parseClassProperty(node) {
|
|
5609
5606
|
if (this.match(14)) {
|
|
@@ -7442,10 +7439,8 @@ function requireLib() {
|
|
|
7442
7439
|
setLeadingComments(commentWS.trailingNode, comments);
|
|
7443
7440
|
}
|
|
7444
7441
|
} else {
|
|
7445
|
-
const
|
|
7446
|
-
|
|
7447
|
-
start: commentStart
|
|
7448
|
-
} = commentWS;
|
|
7442
|
+
const node = commentWS.containingNode;
|
|
7443
|
+
const commentStart = commentWS.start;
|
|
7449
7444
|
if (this.input.charCodeAt(this.offsetToSourcePos(commentStart) - 1) === 44) {
|
|
7450
7445
|
switch (node.type) {
|
|
7451
7446
|
case "ObjectExpression":
|
|
@@ -9541,7 +9536,7 @@ function requireLib() {
|
|
|
9541
9536
|
if (isLHS) {
|
|
9542
9537
|
if (parenthesized.type === "Identifier") {
|
|
9543
9538
|
this.expressionScope.recordArrowParameterBindingError(Errors.InvalidParenthesizedAssignment, node);
|
|
9544
|
-
} else if (parenthesized.type !== "MemberExpression" && !this.isOptionalMemberExpression(parenthesized)) {
|
|
9539
|
+
} else if (parenthesized.type !== "CallExpression" && parenthesized.type !== "MemberExpression" && !this.isOptionalMemberExpression(parenthesized)) {
|
|
9545
9540
|
this.raise(Errors.InvalidParenthesizedAssignment, node);
|
|
9546
9541
|
}
|
|
9547
9542
|
} else {
|
|
@@ -9813,7 +9808,7 @@ function requireLib() {
|
|
|
9813
9808
|
node.right = this.parseMaybeAssignAllowIn();
|
|
9814
9809
|
return this.finishNode(node, "AssignmentPattern");
|
|
9815
9810
|
}
|
|
9816
|
-
isValidLVal(type2, isUnparenthesizedInAssign, binding) {
|
|
9811
|
+
isValidLVal(type2, disallowCallExpression, isUnparenthesizedInAssign, binding) {
|
|
9817
9812
|
switch (type2) {
|
|
9818
9813
|
case "AssignmentPattern":
|
|
9819
9814
|
return "left";
|
|
@@ -9829,13 +9824,17 @@ function requireLib() {
|
|
|
9829
9824
|
return "properties";
|
|
9830
9825
|
case "VoidPattern":
|
|
9831
9826
|
return true;
|
|
9827
|
+
case "CallExpression":
|
|
9828
|
+
if (!disallowCallExpression && !this.state.strict && this.optionFlags & 8192) {
|
|
9829
|
+
return true;
|
|
9830
|
+
}
|
|
9832
9831
|
}
|
|
9833
9832
|
return false;
|
|
9834
9833
|
}
|
|
9835
9834
|
isOptionalMemberExpression(expression) {
|
|
9836
9835
|
return expression.type === "OptionalMemberExpression";
|
|
9837
9836
|
}
|
|
9838
|
-
checkLVal(expression, ancestor, binding = 64, checkClashes = false, strictModeChanged = false, hasParenthesizedAncestor = false) {
|
|
9837
|
+
checkLVal(expression, ancestor, binding = 64, checkClashes = false, strictModeChanged = false, hasParenthesizedAncestor = false, disallowCallExpression = false) {
|
|
9839
9838
|
var _expression$extra;
|
|
9840
9839
|
const type2 = expression.type;
|
|
9841
9840
|
if (this.isObjectMethod(expression)) return;
|
|
@@ -9870,7 +9869,9 @@ function requireLib() {
|
|
|
9870
9869
|
} else if (type2 === "VoidPattern" && ancestor.type === "CatchClause") {
|
|
9871
9870
|
this.raise(Errors.VoidPatternCatchClauseParam, expression);
|
|
9872
9871
|
}
|
|
9873
|
-
const
|
|
9872
|
+
const unwrappedExpression = unwrapParenthesizedExpression(expression);
|
|
9873
|
+
disallowCallExpression || (disallowCallExpression = unwrappedExpression.type === "CallExpression" && (unwrappedExpression.callee.type === "Import" || unwrappedExpression.callee.type === "Super"));
|
|
9874
|
+
const validity = this.isValidLVal(type2, disallowCallExpression, !(hasParenthesizedAncestor || (_expression$extra = expression.extra) != null && _expression$extra.parenthesized) && ancestor.type === "AssignmentExpression", binding);
|
|
9874
9875
|
if (validity === true) return;
|
|
9875
9876
|
if (validity === false) {
|
|
9876
9877
|
const ParseErrorClass = binding === 64 ? Errors.InvalidLhs : Errors.InvalidLhsBinding;
|
|
@@ -9893,11 +9894,11 @@ function requireLib() {
|
|
|
9893
9894
|
if (Array.isArray(val)) {
|
|
9894
9895
|
for (const child of val) {
|
|
9895
9896
|
if (child) {
|
|
9896
|
-
this.checkLVal(child, nextAncestor, binding, checkClashes, strictModeChanged, isParenthesizedExpression);
|
|
9897
|
+
this.checkLVal(child, nextAncestor, binding, checkClashes, strictModeChanged, isParenthesizedExpression, true);
|
|
9897
9898
|
}
|
|
9898
9899
|
}
|
|
9899
9900
|
} else if (val) {
|
|
9900
|
-
this.checkLVal(val, nextAncestor, binding, checkClashes, strictModeChanged, isParenthesizedExpression);
|
|
9901
|
+
this.checkLVal(val, nextAncestor, binding, checkClashes, strictModeChanged, isParenthesizedExpression, disallowCallExpression);
|
|
9901
9902
|
}
|
|
9902
9903
|
}
|
|
9903
9904
|
checkIdentifier(at, bindingType, strictModeChanged = false) {
|
|
@@ -9945,6 +9946,7 @@ function requireLib() {
|
|
|
9945
9946
|
return true;
|
|
9946
9947
|
}
|
|
9947
9948
|
}
|
|
9949
|
+
const keywordAndTSRelationalOperator = /in(?:stanceof)?|as|satisfies/y;
|
|
9948
9950
|
function nonNull(x) {
|
|
9949
9951
|
if (x == null) {
|
|
9950
9952
|
throw new Error(`Unexpected ${x} value.`);
|
|
@@ -10831,7 +10833,7 @@ function requireLib() {
|
|
|
10831
10833
|
}
|
|
10832
10834
|
}
|
|
10833
10835
|
}
|
|
10834
|
-
this.unexpected();
|
|
10836
|
+
throw this.unexpected();
|
|
10835
10837
|
}
|
|
10836
10838
|
tsParseArrayTypeOrHigher() {
|
|
10837
10839
|
const {
|
|
@@ -11394,51 +11396,22 @@ function requireLib() {
|
|
|
11394
11396
|
}
|
|
11395
11397
|
default:
|
|
11396
11398
|
if (tokenIsIdentifier(startType)) {
|
|
11397
|
-
return this.tsParseDeclaration(node, this.state.
|
|
11399
|
+
return this.tsParseDeclaration(node, this.state.type, true, null);
|
|
11398
11400
|
}
|
|
11399
11401
|
}
|
|
11400
11402
|
});
|
|
11401
11403
|
}
|
|
11402
11404
|
tsTryParseExportDeclaration() {
|
|
11403
|
-
return this.tsParseDeclaration(this.startNode(), this.state.
|
|
11404
|
-
}
|
|
11405
|
-
tsParseExpressionStatement(node, expr, decorators) {
|
|
11406
|
-
switch (expr.name) {
|
|
11407
|
-
case "declare": {
|
|
11408
|
-
const declaration = this.tsTryParseDeclare(node);
|
|
11409
|
-
if (declaration) {
|
|
11410
|
-
declaration.declare = true;
|
|
11411
|
-
}
|
|
11412
|
-
return declaration;
|
|
11413
|
-
}
|
|
11414
|
-
case "global":
|
|
11415
|
-
if (this.match(5)) {
|
|
11416
|
-
this.scope.enter(1024);
|
|
11417
|
-
this.prodParam.enter(0);
|
|
11418
|
-
const mod = node;
|
|
11419
|
-
mod.kind = "global";
|
|
11420
|
-
{
|
|
11421
|
-
node.global = true;
|
|
11422
|
-
}
|
|
11423
|
-
mod.id = expr;
|
|
11424
|
-
mod.body = this.tsParseModuleBlock();
|
|
11425
|
-
this.scope.exit();
|
|
11426
|
-
this.prodParam.exit();
|
|
11427
|
-
return this.finishNode(mod, "TSModuleDeclaration");
|
|
11428
|
-
}
|
|
11429
|
-
break;
|
|
11430
|
-
default:
|
|
11431
|
-
return this.tsParseDeclaration(node, expr.name, false, decorators);
|
|
11432
|
-
}
|
|
11405
|
+
return this.tsParseDeclaration(this.startNode(), this.state.type, true, null);
|
|
11433
11406
|
}
|
|
11434
|
-
tsParseDeclaration(node,
|
|
11435
|
-
switch (
|
|
11436
|
-
case
|
|
11407
|
+
tsParseDeclaration(node, type2, next, decorators) {
|
|
11408
|
+
switch (type2) {
|
|
11409
|
+
case 124:
|
|
11437
11410
|
if (this.tsCheckLineTerminator(next) && (this.match(80) || tokenIsIdentifier(this.state.type))) {
|
|
11438
11411
|
return this.tsParseAbstractDeclaration(node, decorators);
|
|
11439
11412
|
}
|
|
11440
11413
|
break;
|
|
11441
|
-
case
|
|
11414
|
+
case 127:
|
|
11442
11415
|
if (this.tsCheckLineTerminator(next)) {
|
|
11443
11416
|
if (this.match(134)) {
|
|
11444
11417
|
return this.tsParseAmbientExternalModuleDeclaration(node);
|
|
@@ -11448,13 +11421,13 @@ function requireLib() {
|
|
|
11448
11421
|
}
|
|
11449
11422
|
}
|
|
11450
11423
|
break;
|
|
11451
|
-
case
|
|
11424
|
+
case 128:
|
|
11452
11425
|
if (this.tsCheckLineTerminator(next) && tokenIsIdentifier(this.state.type)) {
|
|
11453
11426
|
node.kind = "namespace";
|
|
11454
11427
|
return this.tsParseModuleOrNamespaceDeclaration(node);
|
|
11455
11428
|
}
|
|
11456
11429
|
break;
|
|
11457
|
-
case
|
|
11430
|
+
case 130:
|
|
11458
11431
|
if (this.tsCheckLineTerminator(next) && tokenIsIdentifier(this.state.type)) {
|
|
11459
11432
|
return this.tsParseTypeAliasDeclaration(node);
|
|
11460
11433
|
}
|
|
@@ -11595,8 +11568,8 @@ function requireLib() {
|
|
|
11595
11568
|
this.tsCheckForInvalidTypeCasts(exprList);
|
|
11596
11569
|
return exprList;
|
|
11597
11570
|
}
|
|
11598
|
-
parseArrayLike(close,
|
|
11599
|
-
const node = super.parseArrayLike(close,
|
|
11571
|
+
parseArrayLike(close, isTuple, refExpressionErrors) {
|
|
11572
|
+
const node = super.parseArrayLike(close, isTuple, refExpressionErrors);
|
|
11600
11573
|
if (node.type === "ArrayExpression") {
|
|
11601
11574
|
this.tsCheckForInvalidTypeCasts(node.elements);
|
|
11602
11575
|
}
|
|
@@ -11842,19 +11815,78 @@ function requireLib() {
|
|
|
11842
11815
|
return declaration;
|
|
11843
11816
|
}
|
|
11844
11817
|
parseStatementContent(flags, decorators) {
|
|
11845
|
-
if (this.
|
|
11846
|
-
|
|
11847
|
-
|
|
11848
|
-
|
|
11849
|
-
|
|
11850
|
-
|
|
11851
|
-
|
|
11852
|
-
|
|
11853
|
-
|
|
11854
|
-
|
|
11855
|
-
|
|
11856
|
-
|
|
11857
|
-
|
|
11818
|
+
if (!this.state.containsEsc) {
|
|
11819
|
+
switch (this.state.type) {
|
|
11820
|
+
case 75: {
|
|
11821
|
+
if (this.isLookaheadContextual("enum")) {
|
|
11822
|
+
const node = this.startNode();
|
|
11823
|
+
this.expect(75);
|
|
11824
|
+
return this.tsParseEnumDeclaration(node, {
|
|
11825
|
+
const: true
|
|
11826
|
+
});
|
|
11827
|
+
}
|
|
11828
|
+
break;
|
|
11829
|
+
}
|
|
11830
|
+
case 124:
|
|
11831
|
+
case 125: {
|
|
11832
|
+
if (this.nextTokenIsIdentifierAndNotTSRelationalOperatorOnSameLine()) {
|
|
11833
|
+
const token2 = this.state.type;
|
|
11834
|
+
const node = this.startNode();
|
|
11835
|
+
this.next();
|
|
11836
|
+
const declaration = token2 === 125 ? this.tsTryParseDeclare(node) : this.tsParseAbstractDeclaration(node, decorators);
|
|
11837
|
+
if (declaration) {
|
|
11838
|
+
if (token2 === 125) {
|
|
11839
|
+
declaration.declare = true;
|
|
11840
|
+
}
|
|
11841
|
+
return declaration;
|
|
11842
|
+
} else {
|
|
11843
|
+
node.expression = this.createIdentifier(this.startNodeAt(node.loc.start), token2 === 125 ? "declare" : "abstract");
|
|
11844
|
+
this.semicolon(false);
|
|
11845
|
+
return this.finishNode(node, "ExpressionStatement");
|
|
11846
|
+
}
|
|
11847
|
+
}
|
|
11848
|
+
break;
|
|
11849
|
+
}
|
|
11850
|
+
case 126:
|
|
11851
|
+
return this.tsParseEnumDeclaration(this.startNode());
|
|
11852
|
+
case 112: {
|
|
11853
|
+
const nextCh = this.lookaheadCharCode();
|
|
11854
|
+
if (nextCh === 123) {
|
|
11855
|
+
const node = this.startNode();
|
|
11856
|
+
return this.tsParseAmbientExternalModuleDeclaration(node);
|
|
11857
|
+
}
|
|
11858
|
+
break;
|
|
11859
|
+
}
|
|
11860
|
+
case 129: {
|
|
11861
|
+
const result = this.tsParseInterfaceDeclaration(this.startNode());
|
|
11862
|
+
if (result) return result;
|
|
11863
|
+
break;
|
|
11864
|
+
}
|
|
11865
|
+
case 127: {
|
|
11866
|
+
if (this.nextTokenIsIdentifierOrStringLiteralOnSameLine()) {
|
|
11867
|
+
const node = this.startNode();
|
|
11868
|
+
this.next();
|
|
11869
|
+
return this.tsParseDeclaration(node, 127, false, decorators);
|
|
11870
|
+
}
|
|
11871
|
+
break;
|
|
11872
|
+
}
|
|
11873
|
+
case 128: {
|
|
11874
|
+
if (this.nextTokenIsIdentifierOnSameLine()) {
|
|
11875
|
+
const node = this.startNode();
|
|
11876
|
+
this.next();
|
|
11877
|
+
return this.tsParseDeclaration(node, 128, false, decorators);
|
|
11878
|
+
}
|
|
11879
|
+
break;
|
|
11880
|
+
}
|
|
11881
|
+
case 130: {
|
|
11882
|
+
if (this.nextTokenIsIdentifierOnSameLine()) {
|
|
11883
|
+
const node = this.startNode();
|
|
11884
|
+
this.next();
|
|
11885
|
+
return this.tsParseTypeAliasDeclaration(node);
|
|
11886
|
+
}
|
|
11887
|
+
break;
|
|
11888
|
+
}
|
|
11889
|
+
}
|
|
11858
11890
|
}
|
|
11859
11891
|
return super.parseStatementContent(flags, decorators);
|
|
11860
11892
|
}
|
|
@@ -11938,10 +11970,6 @@ function requireLib() {
|
|
|
11938
11970
|
this.raise(TSErrors.ClassMethodHasDeclare, methodOrProp);
|
|
11939
11971
|
}
|
|
11940
11972
|
}
|
|
11941
|
-
parseExpressionStatement(node, expr, decorators) {
|
|
11942
|
-
const decl = expr.type === "Identifier" ? this.tsParseExpressionStatement(node, expr, decorators) : void 0;
|
|
11943
|
-
return decl || super.parseExpressionStatement(node, expr, decorators);
|
|
11944
|
-
}
|
|
11945
11973
|
shouldParseExportDeclaration() {
|
|
11946
11974
|
if (this.tsIsDeclarationStart()) return true;
|
|
11947
11975
|
return super.shouldParseExportDeclaration();
|
|
@@ -12266,7 +12294,7 @@ function requireLib() {
|
|
|
12266
12294
|
super.checkToRestConversion(node, allowPattern);
|
|
12267
12295
|
}
|
|
12268
12296
|
}
|
|
12269
|
-
isValidLVal(type2, isUnparenthesizedInAssign, binding) {
|
|
12297
|
+
isValidLVal(type2, disallowCallExpression, isUnparenthesizedInAssign, binding) {
|
|
12270
12298
|
switch (type2) {
|
|
12271
12299
|
case "TSTypeCastExpression":
|
|
12272
12300
|
return true;
|
|
@@ -12279,7 +12307,7 @@ function requireLib() {
|
|
|
12279
12307
|
case "TSTypeAssertion":
|
|
12280
12308
|
return (binding !== 64 || !isUnparenthesizedInAssign) && ["expression", true];
|
|
12281
12309
|
default:
|
|
12282
|
-
return super.isValidLVal(type2, isUnparenthesizedInAssign, binding);
|
|
12310
|
+
return super.isValidLVal(type2, disallowCallExpression, isUnparenthesizedInAssign, binding);
|
|
12283
12311
|
}
|
|
12284
12312
|
}
|
|
12285
12313
|
parseBindingAtom() {
|
|
@@ -12441,10 +12469,11 @@ function requireLib() {
|
|
|
12441
12469
|
node.abstract = true;
|
|
12442
12470
|
this.raise(TSErrors.NonClassMethodPropertyHasAbstractModifier, node);
|
|
12443
12471
|
return this.tsParseInterfaceDeclaration(node);
|
|
12472
|
+
} else {
|
|
12473
|
+
return null;
|
|
12444
12474
|
}
|
|
12445
|
-
} else {
|
|
12446
|
-
this.unexpected(null, 80);
|
|
12447
12475
|
}
|
|
12476
|
+
throw this.unexpected(null, 80);
|
|
12448
12477
|
}
|
|
12449
12478
|
parseMethod(node, isGenerator, isAsync, isConstructor, allowDirectSuper, type2, inClassScope) {
|
|
12450
12479
|
const method = super.parseMethod(node, isGenerator, isAsync, isConstructor, allowDirectSuper, type2, inClassScope);
|
|
@@ -12660,6 +12689,32 @@ function requireLib() {
|
|
|
12660
12689
|
return;
|
|
12661
12690
|
}
|
|
12662
12691
|
}
|
|
12692
|
+
chStartsBindingIdentifierAndNotRelationalOperator(ch, pos2) {
|
|
12693
|
+
if (isIdentifierStart(ch)) {
|
|
12694
|
+
keywordAndTSRelationalOperator.lastIndex = pos2;
|
|
12695
|
+
if (keywordAndTSRelationalOperator.test(this.input)) {
|
|
12696
|
+
const endCh = this.codePointAtPos(keywordAndTSRelationalOperator.lastIndex);
|
|
12697
|
+
if (!isIdentifierChar(endCh) && endCh !== 92) {
|
|
12698
|
+
return false;
|
|
12699
|
+
}
|
|
12700
|
+
}
|
|
12701
|
+
return true;
|
|
12702
|
+
} else if (ch === 92) {
|
|
12703
|
+
return true;
|
|
12704
|
+
} else {
|
|
12705
|
+
return false;
|
|
12706
|
+
}
|
|
12707
|
+
}
|
|
12708
|
+
nextTokenIsIdentifierAndNotTSRelationalOperatorOnSameLine() {
|
|
12709
|
+
const next = this.nextTokenInLineStart();
|
|
12710
|
+
const nextCh = this.codePointAtPos(next);
|
|
12711
|
+
return this.chStartsBindingIdentifierAndNotRelationalOperator(nextCh, next);
|
|
12712
|
+
}
|
|
12713
|
+
nextTokenIsIdentifierOrStringLiteralOnSameLine() {
|
|
12714
|
+
const next = this.nextTokenInLineStart();
|
|
12715
|
+
const nextCh = this.codePointAtPos(next);
|
|
12716
|
+
return this.chStartsBindingIdentifier(nextCh, next) || nextCh === 34 || nextCh === 39;
|
|
12717
|
+
}
|
|
12663
12718
|
};
|
|
12664
12719
|
function isPossiblyLiteralEnum(expression) {
|
|
12665
12720
|
if (expression.type !== "MemberExpression") return false;
|
|
@@ -12788,8 +12843,8 @@ function requireLib() {
|
|
|
12788
12843
|
parseBindingAtom() {
|
|
12789
12844
|
return this.parsePlaceholder("Pattern") || super.parseBindingAtom();
|
|
12790
12845
|
}
|
|
12791
|
-
isValidLVal(type2, isParenthesized, binding) {
|
|
12792
|
-
return type2 === "Placeholder" || super.isValidLVal(type2, isParenthesized, binding);
|
|
12846
|
+
isValidLVal(type2, disallowCallExpression, isParenthesized, binding) {
|
|
12847
|
+
return type2 === "Placeholder" || super.isValidLVal(type2, disallowCallExpression, isParenthesized, binding);
|
|
12793
12848
|
}
|
|
12794
12849
|
toAssignable(node, isLHS) {
|
|
12795
12850
|
if (node && node.type === "Placeholder" && node.expectedNode === "Expression") {
|
|
@@ -13189,7 +13244,7 @@ function requireLib() {
|
|
|
13189
13244
|
}
|
|
13190
13245
|
this.next();
|
|
13191
13246
|
node.right = this.parseMaybeAssign();
|
|
13192
|
-
this.checkLVal(left, this.finishNode(node, "AssignmentExpression"));
|
|
13247
|
+
this.checkLVal(left, this.finishNode(node, "AssignmentExpression"), void 0, void 0, void 0, void 0, operator === "||=" || operator === "&&=" || operator === "??=");
|
|
13193
13248
|
return node;
|
|
13194
13249
|
} else if (ownExpressionErrors) {
|
|
13195
13250
|
this.checkExpressionErrors(refExpressionErrors, true);
|
|
@@ -13659,7 +13714,7 @@ function requireLib() {
|
|
|
13659
13714
|
return this.parseParenAndDistinguishExpression(canBeArrow);
|
|
13660
13715
|
}
|
|
13661
13716
|
case 0: {
|
|
13662
|
-
return this.parseArrayLike(3,
|
|
13717
|
+
return this.parseArrayLike(3, false, refExpressionErrors);
|
|
13663
13718
|
}
|
|
13664
13719
|
case 5: {
|
|
13665
13720
|
return this.parseObjectLike(8, false, false, refExpressionErrors);
|
|
@@ -13709,24 +13764,21 @@ function requireLib() {
|
|
|
13709
13764
|
if (pipeProposal) {
|
|
13710
13765
|
return this.parseTopicReference(pipeProposal);
|
|
13711
13766
|
}
|
|
13712
|
-
this.unexpected();
|
|
13713
|
-
break;
|
|
13767
|
+
throw this.unexpected();
|
|
13714
13768
|
}
|
|
13715
13769
|
case 47: {
|
|
13716
13770
|
const lookaheadCh = this.input.codePointAt(this.nextTokenStart());
|
|
13717
13771
|
if (isIdentifierStart(lookaheadCh) || lookaheadCh === 62) {
|
|
13718
|
-
this.expectOnePlugin(["jsx", "flow", "typescript"]);
|
|
13719
|
-
} else {
|
|
13720
|
-
this.unexpected();
|
|
13772
|
+
throw this.expectOnePlugin(["jsx", "flow", "typescript"]);
|
|
13721
13773
|
}
|
|
13722
|
-
|
|
13774
|
+
throw this.unexpected();
|
|
13723
13775
|
}
|
|
13724
13776
|
default:
|
|
13725
13777
|
{
|
|
13726
13778
|
if (type2 === 137) {
|
|
13727
13779
|
return this.parseDecimalLiteral(this.state.value);
|
|
13728
13780
|
} else if (type2 === 2 || type2 === 1) {
|
|
13729
|
-
return this.parseArrayLike(this.state.type === 2 ? 4 : 3,
|
|
13781
|
+
return this.parseArrayLike(this.state.type === 2 ? 4 : 3, true);
|
|
13730
13782
|
} else if (type2 === 6 || type2 === 7) {
|
|
13731
13783
|
return this.parseObjectLike(this.state.type === 6 ? 9 : 8, false, true);
|
|
13732
13784
|
}
|
|
@@ -13763,7 +13815,7 @@ function requireLib() {
|
|
|
13763
13815
|
}
|
|
13764
13816
|
return id;
|
|
13765
13817
|
} else {
|
|
13766
|
-
this.unexpected();
|
|
13818
|
+
throw this.unexpected();
|
|
13767
13819
|
}
|
|
13768
13820
|
}
|
|
13769
13821
|
}
|
|
@@ -13776,9 +13828,8 @@ function requireLib() {
|
|
|
13776
13828
|
this.state.end--;
|
|
13777
13829
|
this.state.endLoc = createPositionWithColumnOffset(this.state.endLoc, -1);
|
|
13778
13830
|
return this.parseTopicReference(pipeProposal);
|
|
13779
|
-
} else {
|
|
13780
|
-
this.unexpected();
|
|
13781
13831
|
}
|
|
13832
|
+
throw this.unexpected();
|
|
13782
13833
|
}
|
|
13783
13834
|
parseTopicReference(pipeProposal) {
|
|
13784
13835
|
const node = this.startNode();
|
|
@@ -13853,10 +13904,18 @@ function requireLib() {
|
|
|
13853
13904
|
parseSuper() {
|
|
13854
13905
|
const node = this.startNode();
|
|
13855
13906
|
this.next();
|
|
13856
|
-
if (this.match(10) && !this.scope.allowDirectSuper
|
|
13857
|
-
|
|
13858
|
-
|
|
13859
|
-
|
|
13907
|
+
if (this.match(10) && !this.scope.allowDirectSuper) {
|
|
13908
|
+
{
|
|
13909
|
+
if (!(this.optionFlags & 16)) {
|
|
13910
|
+
this.raise(Errors.SuperNotAllowed, node);
|
|
13911
|
+
}
|
|
13912
|
+
}
|
|
13913
|
+
} else if (!this.scope.allowSuper) {
|
|
13914
|
+
{
|
|
13915
|
+
if (!(this.optionFlags & 16)) {
|
|
13916
|
+
this.raise(Errors.UnexpectedSuper, node);
|
|
13917
|
+
}
|
|
13918
|
+
}
|
|
13860
13919
|
}
|
|
13861
13920
|
if (!this.match(10) && !this.match(0) && !this.match(16)) {
|
|
13862
13921
|
this.raise(Errors.UnsupportedSuper, node);
|
|
@@ -14369,7 +14428,7 @@ function requireLib() {
|
|
|
14369
14428
|
this.scope.exit();
|
|
14370
14429
|
return finishedNode;
|
|
14371
14430
|
}
|
|
14372
|
-
parseArrayLike(close,
|
|
14431
|
+
parseArrayLike(close, isTuple, refExpressionErrors) {
|
|
14373
14432
|
if (isTuple) {
|
|
14374
14433
|
this.expectPlugin("recordAndTuple");
|
|
14375
14434
|
}
|
|
@@ -14995,9 +15054,7 @@ function requireLib() {
|
|
|
14995
15054
|
if (!this.isContextual(107)) {
|
|
14996
15055
|
return false;
|
|
14997
15056
|
}
|
|
14998
|
-
|
|
14999
|
-
const nextCh = this.codePointAtPos(next);
|
|
15000
|
-
return this.chStartsBindingIdentifier(nextCh, next);
|
|
15057
|
+
return this.nextTokenIsIdentifierOnSameLine();
|
|
15001
15058
|
}
|
|
15002
15059
|
isForUsing() {
|
|
15003
15060
|
if (!this.isContextual(107)) {
|
|
@@ -15016,6 +15073,11 @@ function requireLib() {
|
|
|
15016
15073
|
}
|
|
15017
15074
|
return false;
|
|
15018
15075
|
}
|
|
15076
|
+
nextTokenIsIdentifierOnSameLine() {
|
|
15077
|
+
const next = this.nextTokenInLineStart();
|
|
15078
|
+
const nextCh = this.codePointAtPos(next);
|
|
15079
|
+
return this.chStartsBindingIdentifier(nextCh, next);
|
|
15080
|
+
}
|
|
15019
15081
|
isAwaitUsing() {
|
|
15020
15082
|
if (!this.isContextual(96)) {
|
|
15021
15083
|
return false;
|
|
@@ -16153,7 +16215,7 @@ function requireLib() {
|
|
|
16153
16215
|
this.sawUnambiguousESM = true;
|
|
16154
16216
|
return this.finishNode(node2, "ExportDefaultDeclaration");
|
|
16155
16217
|
}
|
|
16156
|
-
this.unexpected(null, 5);
|
|
16218
|
+
throw this.unexpected(null, 5);
|
|
16157
16219
|
}
|
|
16158
16220
|
eatExportStar(node) {
|
|
16159
16221
|
return this.eat(55);
|
|
@@ -16745,54 +16807,54 @@ function requireLib() {
|
|
|
16745
16807
|
}
|
|
16746
16808
|
class Parser extends StatementParser {
|
|
16747
16809
|
constructor(options, input, pluginsMap) {
|
|
16748
|
-
|
|
16749
|
-
super(
|
|
16750
|
-
this.options =
|
|
16810
|
+
const normalizedOptions = getOptions(options);
|
|
16811
|
+
super(normalizedOptions, input);
|
|
16812
|
+
this.options = normalizedOptions;
|
|
16751
16813
|
this.initializeScopes();
|
|
16752
16814
|
this.plugins = pluginsMap;
|
|
16753
|
-
this.filename =
|
|
16754
|
-
this.startIndex =
|
|
16815
|
+
this.filename = normalizedOptions.sourceFilename;
|
|
16816
|
+
this.startIndex = normalizedOptions.startIndex;
|
|
16755
16817
|
let optionFlags = 0;
|
|
16756
|
-
if (
|
|
16818
|
+
if (normalizedOptions.allowAwaitOutsideFunction) {
|
|
16757
16819
|
optionFlags |= 1;
|
|
16758
16820
|
}
|
|
16759
|
-
if (
|
|
16821
|
+
if (normalizedOptions.allowReturnOutsideFunction) {
|
|
16760
16822
|
optionFlags |= 2;
|
|
16761
16823
|
}
|
|
16762
|
-
if (
|
|
16824
|
+
if (normalizedOptions.allowImportExportEverywhere) {
|
|
16763
16825
|
optionFlags |= 8;
|
|
16764
16826
|
}
|
|
16765
|
-
if (
|
|
16827
|
+
if (normalizedOptions.allowSuperOutsideMethod) {
|
|
16766
16828
|
optionFlags |= 16;
|
|
16767
16829
|
}
|
|
16768
|
-
if (
|
|
16830
|
+
if (normalizedOptions.allowUndeclaredExports) {
|
|
16769
16831
|
optionFlags |= 64;
|
|
16770
16832
|
}
|
|
16771
|
-
if (
|
|
16833
|
+
if (normalizedOptions.allowNewTargetOutsideFunction) {
|
|
16772
16834
|
optionFlags |= 4;
|
|
16773
16835
|
}
|
|
16774
|
-
if (
|
|
16836
|
+
if (normalizedOptions.allowYieldOutsideFunction) {
|
|
16775
16837
|
optionFlags |= 32;
|
|
16776
16838
|
}
|
|
16777
|
-
if (
|
|
16839
|
+
if (normalizedOptions.ranges) {
|
|
16778
16840
|
optionFlags |= 128;
|
|
16779
16841
|
}
|
|
16780
|
-
if (
|
|
16842
|
+
if (normalizedOptions.tokens) {
|
|
16781
16843
|
optionFlags |= 256;
|
|
16782
16844
|
}
|
|
16783
|
-
if (
|
|
16845
|
+
if (normalizedOptions.createImportExpressions) {
|
|
16784
16846
|
optionFlags |= 512;
|
|
16785
16847
|
}
|
|
16786
|
-
if (
|
|
16848
|
+
if (normalizedOptions.createParenthesizedExpressions) {
|
|
16787
16849
|
optionFlags |= 1024;
|
|
16788
16850
|
}
|
|
16789
|
-
if (
|
|
16851
|
+
if (normalizedOptions.errorRecovery) {
|
|
16790
16852
|
optionFlags |= 2048;
|
|
16791
16853
|
}
|
|
16792
|
-
if (
|
|
16854
|
+
if (normalizedOptions.attachComment) {
|
|
16793
16855
|
optionFlags |= 4096;
|
|
16794
16856
|
}
|
|
16795
|
-
if (
|
|
16857
|
+
if (normalizedOptions.annexB) {
|
|
16796
16858
|
optionFlags |= 8192;
|
|
16797
16859
|
}
|
|
16798
16860
|
this.optionFlags = optionFlags;
|
|
@@ -16806,10 +16868,10 @@ function requireLib() {
|
|
|
16806
16868
|
const program = this.startNode();
|
|
16807
16869
|
this.nextToken();
|
|
16808
16870
|
file.errors = null;
|
|
16809
|
-
this.parseTopLevel(file, program);
|
|
16810
|
-
|
|
16811
|
-
|
|
16812
|
-
return
|
|
16871
|
+
const result = this.parseTopLevel(file, program);
|
|
16872
|
+
result.errors = this.state.errors;
|
|
16873
|
+
result.comments.length = this.state.commentsLen;
|
|
16874
|
+
return result;
|
|
16813
16875
|
}
|
|
16814
16876
|
}
|
|
16815
16877
|
function parse3(input, options) {
|
|
@@ -17009,8 +17071,8 @@ async function generateBarrels(configDir, configPath, config, silentIgnore = fal
|
|
|
17009
17071
|
const indexFileAbsolutePath = resolve(configDir, indexFileRelativePath);
|
|
17010
17072
|
const indexDirectory = dirname(indexFileAbsolutePath);
|
|
17011
17073
|
if (!existsSync(indexDirectory)) {
|
|
17012
|
-
|
|
17013
|
-
|
|
17074
|
+
logWarning(`Index directory '${indexDirectory}' does not exist - skipping`);
|
|
17075
|
+
logWarning(` Please verify the 'root' path in your '${configPath}' configuration`);
|
|
17014
17076
|
continue;
|
|
17015
17077
|
}
|
|
17016
17078
|
const newExportPaths = await handlePaths(configDir, barrelConfig);
|
|
@@ -25315,12 +25377,13 @@ function watch(paths, options = {}) {
|
|
|
25315
25377
|
watcher.add(paths);
|
|
25316
25378
|
return watcher;
|
|
25317
25379
|
}
|
|
25318
|
-
function watchBarrels(configDir, configPath, config) {
|
|
25380
|
+
async function watchBarrels(configDir, configPath, config) {
|
|
25319
25381
|
console.log(colorize("Watch mode enabled.", TerminalColor.GREEN));
|
|
25382
|
+
await generateBarrels(configDir, configPath, config, true);
|
|
25320
25383
|
const watchDirectories = getWatchDirectories(configDir, config.barrels);
|
|
25321
|
-
const
|
|
25322
|
-
for (const eventName of
|
|
25323
|
-
watch(watchDirectories).on(eventName, async () => {
|
|
25384
|
+
const watchEvents = ["add", "unlink", "addDir", "unlinkDir"];
|
|
25385
|
+
for (const eventName of watchEvents) {
|
|
25386
|
+
watch(watchDirectories, { ignoreInitial: true }).on(eventName, async () => {
|
|
25324
25387
|
await generateBarrels(configDir, configPath, config, true);
|
|
25325
25388
|
});
|
|
25326
25389
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { GenerateCommandOptions } from '../../index.ts';
|
|
2
|
-
export declare function runGenerateCommand(options: GenerateCommandOptions):
|
|
2
|
+
export declare function runGenerateCommand(options: GenerateCommandOptions): void;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { Config } from '../index.ts';
|
|
2
|
-
export declare function parseConfig(configPath: string):
|
|
2
|
+
export declare function parseConfig(configPath: string): Config | null;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { Config } from '../index.ts';
|
|
2
|
-
export declare function watchBarrels(configDir: string, configPath: string, config: Config): void
|
|
2
|
+
export declare function watchBarrels(configDir: string, configPath: string, config: Config): Promise<void>;
|
package/package.json
CHANGED
|
@@ -1,56 +1,56 @@
|
|
|
1
1
|
{
|
|
2
|
-
"name": "barrelize",
|
|
3
|
-
"version": "1.6.4",
|
|
4
|
-
"description": "Automatically generating index (barrel) files",
|
|
5
|
-
"scripts": {
|
|
6
|
-
"build": "npm run schema && vite build",
|
|
7
|
-
"schema": "ts-json-schema-generator -p src/config/config.ts -t 'Config' -o schema.json --unstable --markdown-description",
|
|
8
|
-
"prepare": "ts-patch install",
|
|
9
|
-
"test": "vitest run"
|
|
10
|
-
},
|
|
11
|
-
"repository": {
|
|
12
|
-
"type": "git",
|
|
13
|
-
"url": "git@github.com/nizami/barrelize"
|
|
14
|
-
},
|
|
15
|
-
"keywords": [
|
|
16
|
-
"barrels",
|
|
17
|
-
"typescript",
|
|
18
|
-
"index",
|
|
19
|
-
"file"
|
|
20
|
-
],
|
|
21
2
|
"author": "Nizami",
|
|
22
|
-
"
|
|
3
|
+
"bin": {
|
|
4
|
+
"barrelize": "./bin/cli.js"
|
|
5
|
+
},
|
|
6
|
+
"description": "Automatically generating index (barrel) files",
|
|
23
7
|
"devDependencies": {
|
|
24
|
-
"@babel/parser": "^7.28.
|
|
8
|
+
"@babel/parser": "^7.28.5",
|
|
25
9
|
"@ryoppippi/unplugin-typia": "^2.6.5",
|
|
26
|
-
"@types/node": "^24.
|
|
10
|
+
"@types/node": "^24.9.2",
|
|
27
11
|
"cac": "^6.7.14",
|
|
28
12
|
"chokidar": "^4.0.3",
|
|
29
13
|
"glob": "^11.0.3",
|
|
30
14
|
"json5": "^2.2.3",
|
|
31
15
|
"ts-json-schema-generator": "^2.4.0",
|
|
32
16
|
"ts-patch": "^3.3.0",
|
|
33
|
-
"typescript": "~5.9.
|
|
17
|
+
"typescript": "~5.9.3",
|
|
34
18
|
"typia": "^9.7.2",
|
|
35
|
-
"vite": "^7.1.
|
|
19
|
+
"vite": "^7.1.12",
|
|
36
20
|
"vite-plugin-dts": "^4.5.4",
|
|
37
|
-
"vitest": "^
|
|
21
|
+
"vitest": "^4.0.6"
|
|
38
22
|
},
|
|
39
|
-
"
|
|
40
|
-
"
|
|
23
|
+
"exports": {
|
|
24
|
+
".": {
|
|
25
|
+
"import": "./lib/index.js",
|
|
26
|
+
"types": "./lib/src/index.d.ts"
|
|
27
|
+
}
|
|
41
28
|
},
|
|
42
|
-
"type": "module",
|
|
43
|
-
"sideEffects": false,
|
|
44
29
|
"files": [
|
|
45
30
|
"bin",
|
|
46
31
|
"lib",
|
|
47
32
|
"schema.json"
|
|
48
33
|
],
|
|
34
|
+
"keywords": [
|
|
35
|
+
"barrels",
|
|
36
|
+
"typescript",
|
|
37
|
+
"index.ts",
|
|
38
|
+
"index.js"
|
|
39
|
+
],
|
|
40
|
+
"license": "MIT",
|
|
41
|
+
"name": "barrelize",
|
|
42
|
+
"repository": {
|
|
43
|
+
"type": "git",
|
|
44
|
+
"url": "git@github.com/nizami/barrelize"
|
|
45
|
+
},
|
|
46
|
+
"scripts": {
|
|
47
|
+
"build": "npm run schema && vite build",
|
|
48
|
+
"prepare": "ts-patch install",
|
|
49
|
+
"schema": "ts-json-schema-generator -p src/config/config.ts -t 'Config' -o schema.json --unstable --markdown-description",
|
|
50
|
+
"test": "vitest run"
|
|
51
|
+
},
|
|
52
|
+
"sideEffects": false,
|
|
53
|
+
"type": "module",
|
|
49
54
|
"types": "./lib/src/index.d.ts",
|
|
50
|
-
"
|
|
51
|
-
".": {
|
|
52
|
-
"types": "./lib/src/index.d.ts",
|
|
53
|
-
"import": "./lib/index.js"
|
|
54
|
-
}
|
|
55
|
-
}
|
|
55
|
+
"version": "1.6.6"
|
|
56
56
|
}
|