shallok 0.1.2 → 0.1.4
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/README.md +141 -27
- package/dist/index.js +877 -794
- package/dist/index.js.map +1 -1
- package/package.json +61 -62
- package/skills/astro-localization-and-translation-i18n/SKILL.md +4 -0
- package/skills/expo-localization-and-translation-i18n/SKILL.md +4 -0
- package/skills/localization-and-translation-i18n/SKILL.md +4 -0
- package/skills/nextjs-localization-and-translation-i18n/SKILL.md +4 -0
- package/skills/react-localization-and-translation-i18n/SKILL.md +4 -0
package/dist/index.js
CHANGED
|
@@ -109,7 +109,7 @@ var require_path = __commonJS({
|
|
|
109
109
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
110
110
|
exports.convertPosixPathToPattern = exports.convertWindowsPathToPattern = exports.convertPathToPattern = exports.escapePosixPath = exports.escapeWindowsPath = exports.escape = exports.removeLeadingDotSegment = exports.makeAbsolute = exports.unixify = void 0;
|
|
111
111
|
var os = __require("os");
|
|
112
|
-
var
|
|
112
|
+
var path14 = __require("path");
|
|
113
113
|
var IS_WINDOWS_PLATFORM = os.platform() === "win32";
|
|
114
114
|
var LEADING_DOT_SEGMENT_CHARACTERS_COUNT = 2;
|
|
115
115
|
var POSIX_UNESCAPED_GLOB_SYMBOLS_RE = /(\\?)([()*?[\]{|}]|^!|[!+@](?=\()|\\(?![!()*+?@[\]{|}]))/g;
|
|
@@ -121,7 +121,7 @@ var require_path = __commonJS({
|
|
|
121
121
|
}
|
|
122
122
|
exports.unixify = unixify;
|
|
123
123
|
function makeAbsolute(cwd, filepath) {
|
|
124
|
-
return
|
|
124
|
+
return path14.resolve(cwd, filepath);
|
|
125
125
|
}
|
|
126
126
|
exports.makeAbsolute = makeAbsolute;
|
|
127
127
|
function removeLeadingDotSegment(entry) {
|
|
@@ -1420,7 +1420,7 @@ var require_braces = __commonJS({
|
|
|
1420
1420
|
var require_constants2 = __commonJS({
|
|
1421
1421
|
"../../node_modules/.pnpm/picomatch@2.3.2/node_modules/picomatch/lib/constants.js"(exports, module) {
|
|
1422
1422
|
"use strict";
|
|
1423
|
-
var
|
|
1423
|
+
var path14 = __require("path");
|
|
1424
1424
|
var WIN_SLASH = "\\\\/";
|
|
1425
1425
|
var WIN_NO_SLASH = `[^${WIN_SLASH}]`;
|
|
1426
1426
|
var DEFAULT_MAX_EXTGLOB_RECURSION = 0;
|
|
@@ -1594,7 +1594,7 @@ var require_constants2 = __commonJS({
|
|
|
1594
1594
|
/* | */
|
|
1595
1595
|
CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279,
|
|
1596
1596
|
/* \uFEFF */
|
|
1597
|
-
SEP:
|
|
1597
|
+
SEP: path14.sep,
|
|
1598
1598
|
/**
|
|
1599
1599
|
* Create EXTGLOB_CHARS
|
|
1600
1600
|
*/
|
|
@@ -1621,7 +1621,7 @@ var require_constants2 = __commonJS({
|
|
|
1621
1621
|
var require_utils2 = __commonJS({
|
|
1622
1622
|
"../../node_modules/.pnpm/picomatch@2.3.2/node_modules/picomatch/lib/utils.js"(exports) {
|
|
1623
1623
|
"use strict";
|
|
1624
|
-
var
|
|
1624
|
+
var path14 = __require("path");
|
|
1625
1625
|
var win32 = process.platform === "win32";
|
|
1626
1626
|
var {
|
|
1627
1627
|
REGEX_BACKSLASH,
|
|
@@ -1650,7 +1650,7 @@ var require_utils2 = __commonJS({
|
|
|
1650
1650
|
if (options && typeof options.windows === "boolean") {
|
|
1651
1651
|
return options.windows;
|
|
1652
1652
|
}
|
|
1653
|
-
return win32 === true ||
|
|
1653
|
+
return win32 === true || path14.sep === "\\";
|
|
1654
1654
|
};
|
|
1655
1655
|
exports.escapeLast = (input, char, lastIdx) => {
|
|
1656
1656
|
const idx = input.lastIndexOf(char, lastIdx);
|
|
@@ -3014,7 +3014,7 @@ var require_parse2 = __commonJS({
|
|
|
3014
3014
|
var require_picomatch = __commonJS({
|
|
3015
3015
|
"../../node_modules/.pnpm/picomatch@2.3.2/node_modules/picomatch/lib/picomatch.js"(exports, module) {
|
|
3016
3016
|
"use strict";
|
|
3017
|
-
var
|
|
3017
|
+
var path14 = __require("path");
|
|
3018
3018
|
var scan = require_scan();
|
|
3019
3019
|
var parse3 = require_parse2();
|
|
3020
3020
|
var utils = require_utils2();
|
|
@@ -3099,7 +3099,7 @@ var require_picomatch = __commonJS({
|
|
|
3099
3099
|
};
|
|
3100
3100
|
picomatch.matchBase = (input, glob, options, posix = utils.isWindows(options)) => {
|
|
3101
3101
|
const regex = glob instanceof RegExp ? glob : picomatch.makeRe(glob, options);
|
|
3102
|
-
return regex.test(
|
|
3102
|
+
return regex.test(path14.basename(input));
|
|
3103
3103
|
};
|
|
3104
3104
|
picomatch.isMatch = (str, patterns, options) => picomatch(patterns, options)(str);
|
|
3105
3105
|
picomatch.parse = (pattern, options) => {
|
|
@@ -3326,7 +3326,7 @@ var require_pattern = __commonJS({
|
|
|
3326
3326
|
"use strict";
|
|
3327
3327
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3328
3328
|
exports.isAbsolute = exports.partitionAbsoluteAndRelative = exports.removeDuplicateSlashes = exports.matchAny = exports.convertPatternsToRe = exports.makeRe = exports.getPatternParts = exports.expandBraceExpansion = exports.expandPatternsWithBraceExpansion = exports.isAffectDepthOfReadingPattern = exports.endsWithSlashGlobStar = exports.hasGlobStar = exports.getBaseDirectory = exports.isPatternRelatedToParentDirectory = exports.getPatternsOutsideCurrentDirectory = exports.getPatternsInsideCurrentDirectory = exports.getPositivePatterns = exports.getNegativePatterns = exports.isPositivePattern = exports.isNegativePattern = exports.convertToNegativePattern = exports.convertToPositivePattern = exports.isDynamicPattern = exports.isStaticPattern = void 0;
|
|
3329
|
-
var
|
|
3329
|
+
var path14 = __require("path");
|
|
3330
3330
|
var globParent = require_glob_parent();
|
|
3331
3331
|
var micromatch = require_micromatch();
|
|
3332
3332
|
var GLOBSTAR = "**";
|
|
@@ -3421,7 +3421,7 @@ var require_pattern = __commonJS({
|
|
|
3421
3421
|
}
|
|
3422
3422
|
exports.endsWithSlashGlobStar = endsWithSlashGlobStar;
|
|
3423
3423
|
function isAffectDepthOfReadingPattern(pattern) {
|
|
3424
|
-
const basename =
|
|
3424
|
+
const basename = path14.basename(pattern);
|
|
3425
3425
|
return endsWithSlashGlobStar(pattern) || isStaticPattern(basename);
|
|
3426
3426
|
}
|
|
3427
3427
|
exports.isAffectDepthOfReadingPattern = isAffectDepthOfReadingPattern;
|
|
@@ -3479,7 +3479,7 @@ var require_pattern = __commonJS({
|
|
|
3479
3479
|
}
|
|
3480
3480
|
exports.partitionAbsoluteAndRelative = partitionAbsoluteAndRelative;
|
|
3481
3481
|
function isAbsolute(pattern) {
|
|
3482
|
-
return
|
|
3482
|
+
return path14.isAbsolute(pattern);
|
|
3483
3483
|
}
|
|
3484
3484
|
exports.isAbsolute = isAbsolute;
|
|
3485
3485
|
}
|
|
@@ -3656,8 +3656,8 @@ var require_utils3 = __commonJS({
|
|
|
3656
3656
|
exports.errno = errno;
|
|
3657
3657
|
var fs12 = require_fs();
|
|
3658
3658
|
exports.fs = fs12;
|
|
3659
|
-
var
|
|
3660
|
-
exports.path =
|
|
3659
|
+
var path14 = require_path();
|
|
3660
|
+
exports.path = path14;
|
|
3661
3661
|
var pattern = require_pattern();
|
|
3662
3662
|
exports.pattern = pattern;
|
|
3663
3663
|
var stream = require_stream();
|
|
@@ -3769,8 +3769,8 @@ var require_async = __commonJS({
|
|
|
3769
3769
|
"use strict";
|
|
3770
3770
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3771
3771
|
exports.read = void 0;
|
|
3772
|
-
function read(
|
|
3773
|
-
settings.fs.lstat(
|
|
3772
|
+
function read(path14, settings, callback) {
|
|
3773
|
+
settings.fs.lstat(path14, (lstatError, lstat) => {
|
|
3774
3774
|
if (lstatError !== null) {
|
|
3775
3775
|
callFailureCallback(callback, lstatError);
|
|
3776
3776
|
return;
|
|
@@ -3779,7 +3779,7 @@ var require_async = __commonJS({
|
|
|
3779
3779
|
callSuccessCallback(callback, lstat);
|
|
3780
3780
|
return;
|
|
3781
3781
|
}
|
|
3782
|
-
settings.fs.stat(
|
|
3782
|
+
settings.fs.stat(path14, (statError, stat) => {
|
|
3783
3783
|
if (statError !== null) {
|
|
3784
3784
|
if (settings.throwErrorOnBrokenSymbolicLink) {
|
|
3785
3785
|
callFailureCallback(callback, statError);
|
|
@@ -3811,13 +3811,13 @@ var require_sync = __commonJS({
|
|
|
3811
3811
|
"use strict";
|
|
3812
3812
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3813
3813
|
exports.read = void 0;
|
|
3814
|
-
function read(
|
|
3815
|
-
const lstat = settings.fs.lstatSync(
|
|
3814
|
+
function read(path14, settings) {
|
|
3815
|
+
const lstat = settings.fs.lstatSync(path14);
|
|
3816
3816
|
if (!lstat.isSymbolicLink() || !settings.followSymbolicLink) {
|
|
3817
3817
|
return lstat;
|
|
3818
3818
|
}
|
|
3819
3819
|
try {
|
|
3820
|
-
const stat = settings.fs.statSync(
|
|
3820
|
+
const stat = settings.fs.statSync(path14);
|
|
3821
3821
|
if (settings.markSymbolicLink) {
|
|
3822
3822
|
stat.isSymbolicLink = () => true;
|
|
3823
3823
|
}
|
|
@@ -3888,17 +3888,17 @@ var require_out = __commonJS({
|
|
|
3888
3888
|
var sync = require_sync();
|
|
3889
3889
|
var settings_1 = require_settings();
|
|
3890
3890
|
exports.Settings = settings_1.default;
|
|
3891
|
-
function stat(
|
|
3891
|
+
function stat(path14, optionsOrSettingsOrCallback, callback) {
|
|
3892
3892
|
if (typeof optionsOrSettingsOrCallback === "function") {
|
|
3893
|
-
async.read(
|
|
3893
|
+
async.read(path14, getSettings(), optionsOrSettingsOrCallback);
|
|
3894
3894
|
return;
|
|
3895
3895
|
}
|
|
3896
|
-
async.read(
|
|
3896
|
+
async.read(path14, getSettings(optionsOrSettingsOrCallback), callback);
|
|
3897
3897
|
}
|
|
3898
3898
|
exports.stat = stat;
|
|
3899
|
-
function statSync(
|
|
3899
|
+
function statSync(path14, optionsOrSettings) {
|
|
3900
3900
|
const settings = getSettings(optionsOrSettings);
|
|
3901
|
-
return sync.read(
|
|
3901
|
+
return sync.read(path14, settings);
|
|
3902
3902
|
}
|
|
3903
3903
|
exports.statSync = statSync;
|
|
3904
3904
|
function getSettings(settingsOrOptions = {}) {
|
|
@@ -4116,16 +4116,16 @@ var require_async2 = __commonJS({
|
|
|
4116
4116
|
return;
|
|
4117
4117
|
}
|
|
4118
4118
|
const tasks = names.map((name) => {
|
|
4119
|
-
const
|
|
4119
|
+
const path14 = common.joinPathSegments(directory, name, settings.pathSegmentSeparator);
|
|
4120
4120
|
return (done) => {
|
|
4121
|
-
fsStat.stat(
|
|
4121
|
+
fsStat.stat(path14, settings.fsStatSettings, (error, stats) => {
|
|
4122
4122
|
if (error !== null) {
|
|
4123
4123
|
done(error);
|
|
4124
4124
|
return;
|
|
4125
4125
|
}
|
|
4126
4126
|
const entry = {
|
|
4127
4127
|
name,
|
|
4128
|
-
path:
|
|
4128
|
+
path: path14,
|
|
4129
4129
|
dirent: utils.fs.createDirentFromStats(name, stats)
|
|
4130
4130
|
};
|
|
4131
4131
|
if (settings.stats) {
|
|
@@ -4243,7 +4243,7 @@ var require_settings2 = __commonJS({
|
|
|
4243
4243
|
"../../node_modules/.pnpm/@nodelib+fs.scandir@2.1.5/node_modules/@nodelib/fs.scandir/out/settings.js"(exports) {
|
|
4244
4244
|
"use strict";
|
|
4245
4245
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4246
|
-
var
|
|
4246
|
+
var path14 = __require("path");
|
|
4247
4247
|
var fsStat = require_out();
|
|
4248
4248
|
var fs12 = require_fs4();
|
|
4249
4249
|
var Settings = class {
|
|
@@ -4251,7 +4251,7 @@ var require_settings2 = __commonJS({
|
|
|
4251
4251
|
this._options = _options;
|
|
4252
4252
|
this.followSymbolicLinks = this._getValue(this._options.followSymbolicLinks, false);
|
|
4253
4253
|
this.fs = fs12.createFileSystemAdapter(this._options.fs);
|
|
4254
|
-
this.pathSegmentSeparator = this._getValue(this._options.pathSegmentSeparator,
|
|
4254
|
+
this.pathSegmentSeparator = this._getValue(this._options.pathSegmentSeparator, path14.sep);
|
|
4255
4255
|
this.stats = this._getValue(this._options.stats, false);
|
|
4256
4256
|
this.throwErrorOnBrokenSymbolicLink = this._getValue(this._options.throwErrorOnBrokenSymbolicLink, true);
|
|
4257
4257
|
this.fsStatSettings = new fsStat.Settings({
|
|
@@ -4278,17 +4278,17 @@ var require_out2 = __commonJS({
|
|
|
4278
4278
|
var sync = require_sync2();
|
|
4279
4279
|
var settings_1 = require_settings2();
|
|
4280
4280
|
exports.Settings = settings_1.default;
|
|
4281
|
-
function scandir(
|
|
4281
|
+
function scandir(path14, optionsOrSettingsOrCallback, callback) {
|
|
4282
4282
|
if (typeof optionsOrSettingsOrCallback === "function") {
|
|
4283
|
-
async.read(
|
|
4283
|
+
async.read(path14, getSettings(), optionsOrSettingsOrCallback);
|
|
4284
4284
|
return;
|
|
4285
4285
|
}
|
|
4286
|
-
async.read(
|
|
4286
|
+
async.read(path14, getSettings(optionsOrSettingsOrCallback), callback);
|
|
4287
4287
|
}
|
|
4288
4288
|
exports.scandir = scandir;
|
|
4289
|
-
function scandirSync(
|
|
4289
|
+
function scandirSync(path14, optionsOrSettings) {
|
|
4290
4290
|
const settings = getSettings(optionsOrSettings);
|
|
4291
|
-
return sync.read(
|
|
4291
|
+
return sync.read(path14, settings);
|
|
4292
4292
|
}
|
|
4293
4293
|
exports.scandirSync = scandirSync;
|
|
4294
4294
|
function getSettings(settingsOrOptions = {}) {
|
|
@@ -4936,7 +4936,7 @@ var require_settings3 = __commonJS({
|
|
|
4936
4936
|
"../../node_modules/.pnpm/@nodelib+fs.walk@1.2.8/node_modules/@nodelib/fs.walk/out/settings.js"(exports) {
|
|
4937
4937
|
"use strict";
|
|
4938
4938
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4939
|
-
var
|
|
4939
|
+
var path14 = __require("path");
|
|
4940
4940
|
var fsScandir = require_out2();
|
|
4941
4941
|
var Settings = class {
|
|
4942
4942
|
constructor(_options = {}) {
|
|
@@ -4946,7 +4946,7 @@ var require_settings3 = __commonJS({
|
|
|
4946
4946
|
this.deepFilter = this._getValue(this._options.deepFilter, null);
|
|
4947
4947
|
this.entryFilter = this._getValue(this._options.entryFilter, null);
|
|
4948
4948
|
this.errorFilter = this._getValue(this._options.errorFilter, null);
|
|
4949
|
-
this.pathSegmentSeparator = this._getValue(this._options.pathSegmentSeparator,
|
|
4949
|
+
this.pathSegmentSeparator = this._getValue(this._options.pathSegmentSeparator, path14.sep);
|
|
4950
4950
|
this.fsScandirSettings = new fsScandir.Settings({
|
|
4951
4951
|
followSymbolicLinks: this._options.followSymbolicLinks,
|
|
4952
4952
|
fs: this._options.fs,
|
|
@@ -5008,7 +5008,7 @@ var require_reader2 = __commonJS({
|
|
|
5008
5008
|
"../../node_modules/.pnpm/fast-glob@3.3.3/node_modules/fast-glob/out/readers/reader.js"(exports) {
|
|
5009
5009
|
"use strict";
|
|
5010
5010
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5011
|
-
var
|
|
5011
|
+
var path14 = __require("path");
|
|
5012
5012
|
var fsStat = require_out();
|
|
5013
5013
|
var utils = require_utils3();
|
|
5014
5014
|
var Reader = class {
|
|
@@ -5021,7 +5021,7 @@ var require_reader2 = __commonJS({
|
|
|
5021
5021
|
});
|
|
5022
5022
|
}
|
|
5023
5023
|
_getFullEntryPath(filepath) {
|
|
5024
|
-
return
|
|
5024
|
+
return path14.resolve(this._settings.cwd, filepath);
|
|
5025
5025
|
}
|
|
5026
5026
|
_makeEntry(stats, pattern) {
|
|
5027
5027
|
const entry = {
|
|
@@ -5437,7 +5437,7 @@ var require_provider = __commonJS({
|
|
|
5437
5437
|
"../../node_modules/.pnpm/fast-glob@3.3.3/node_modules/fast-glob/out/providers/provider.js"(exports) {
|
|
5438
5438
|
"use strict";
|
|
5439
5439
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5440
|
-
var
|
|
5440
|
+
var path14 = __require("path");
|
|
5441
5441
|
var deep_1 = require_deep();
|
|
5442
5442
|
var entry_1 = require_entry();
|
|
5443
5443
|
var error_1 = require_error();
|
|
@@ -5451,7 +5451,7 @@ var require_provider = __commonJS({
|
|
|
5451
5451
|
this.entryTransformer = new entry_2.default(this._settings);
|
|
5452
5452
|
}
|
|
5453
5453
|
_getRootDirectory(task) {
|
|
5454
|
-
return
|
|
5454
|
+
return path14.resolve(this._settings.cwd, task.base);
|
|
5455
5455
|
}
|
|
5456
5456
|
_getReaderOptions(task) {
|
|
5457
5457
|
const basePath = task.base === "." ? "" : task.base;
|
|
@@ -20831,11 +20831,11 @@ var require_visitors = __commonJS({
|
|
|
20831
20831
|
}
|
|
20832
20832
|
visitor._verified = true;
|
|
20833
20833
|
}
|
|
20834
|
-
function validateVisitorMethods(
|
|
20834
|
+
function validateVisitorMethods(path14, val) {
|
|
20835
20835
|
const fns = [].concat(val);
|
|
20836
20836
|
for (const fn of fns) {
|
|
20837
20837
|
if (typeof fn !== "function") {
|
|
20838
|
-
throw new TypeError(`Non-function found defined in ${
|
|
20838
|
+
throw new TypeError(`Non-function found defined in ${path14} with type ${typeof fn}`);
|
|
20839
20839
|
}
|
|
20840
20840
|
}
|
|
20841
20841
|
}
|
|
@@ -20878,8 +20878,8 @@ var require_visitors = __commonJS({
|
|
|
20878
20878
|
fns = fns.map(function(fn) {
|
|
20879
20879
|
let newFn = fn;
|
|
20880
20880
|
if (state) {
|
|
20881
|
-
newFn = function(
|
|
20882
|
-
fn.call(state,
|
|
20881
|
+
newFn = function(path14) {
|
|
20882
|
+
fn.call(state, path14, state);
|
|
20883
20883
|
};
|
|
20884
20884
|
}
|
|
20885
20885
|
if (wrapper) {
|
|
@@ -20912,8 +20912,8 @@ var require_visitors = __commonJS({
|
|
|
20912
20912
|
function wrapCheck(nodeType, fn) {
|
|
20913
20913
|
const fnKey = `is${nodeType}`;
|
|
20914
20914
|
const validator = virtualTypesValidators[fnKey];
|
|
20915
|
-
const newFn = function(
|
|
20916
|
-
if (validator.call(
|
|
20915
|
+
const newFn = function(path14) {
|
|
20916
|
+
if (validator.call(path14)) {
|
|
20917
20917
|
return fn.apply(this, arguments);
|
|
20918
20918
|
}
|
|
20919
20919
|
};
|
|
@@ -20938,24 +20938,24 @@ var require_visitors = __commonJS({
|
|
|
20938
20938
|
}
|
|
20939
20939
|
}
|
|
20940
20940
|
var _environmentVisitor = {
|
|
20941
|
-
FunctionParent(
|
|
20942
|
-
if (
|
|
20943
|
-
|
|
20944
|
-
if (
|
|
20945
|
-
if (!
|
|
20946
|
-
_context.requeueComputedKeyAndDecorators.call(
|
|
20941
|
+
FunctionParent(path14) {
|
|
20942
|
+
if (path14.isArrowFunctionExpression()) return;
|
|
20943
|
+
path14.skip();
|
|
20944
|
+
if (path14.isMethod()) {
|
|
20945
|
+
if (!path14.requeueComputedKeyAndDecorators) {
|
|
20946
|
+
_context.requeueComputedKeyAndDecorators.call(path14);
|
|
20947
20947
|
} else {
|
|
20948
|
-
|
|
20948
|
+
path14.requeueComputedKeyAndDecorators();
|
|
20949
20949
|
}
|
|
20950
20950
|
}
|
|
20951
20951
|
},
|
|
20952
|
-
Property(
|
|
20953
|
-
if (
|
|
20954
|
-
|
|
20955
|
-
if (!
|
|
20956
|
-
_context.requeueComputedKeyAndDecorators.call(
|
|
20952
|
+
Property(path14) {
|
|
20953
|
+
if (path14.isObjectProperty()) return;
|
|
20954
|
+
path14.skip();
|
|
20955
|
+
if (!path14.requeueComputedKeyAndDecorators) {
|
|
20956
|
+
_context.requeueComputedKeyAndDecorators.call(path14);
|
|
20957
20957
|
} else {
|
|
20958
|
-
|
|
20958
|
+
path14.requeueComputedKeyAndDecorators();
|
|
20959
20959
|
}
|
|
20960
20960
|
}
|
|
20961
20961
|
};
|
|
@@ -20989,18 +20989,18 @@ var require_renamer = __commonJS({
|
|
|
20989
20989
|
node.name = state.newName;
|
|
20990
20990
|
}
|
|
20991
20991
|
},
|
|
20992
|
-
Scope(
|
|
20993
|
-
if (!
|
|
20994
|
-
|
|
20995
|
-
if (
|
|
20996
|
-
if (!
|
|
20997
|
-
_context.requeueComputedKeyAndDecorators.call(
|
|
20992
|
+
Scope(path14, state) {
|
|
20993
|
+
if (!path14.scope.bindingIdentifierEquals(state.oldName, state.binding.identifier)) {
|
|
20994
|
+
path14.skip();
|
|
20995
|
+
if (path14.isMethod()) {
|
|
20996
|
+
if (!path14.requeueComputedKeyAndDecorators) {
|
|
20997
|
+
_context.requeueComputedKeyAndDecorators.call(path14);
|
|
20998
20998
|
} else {
|
|
20999
|
-
|
|
20999
|
+
path14.requeueComputedKeyAndDecorators();
|
|
21000
21000
|
}
|
|
21001
21001
|
}
|
|
21002
|
-
if (
|
|
21003
|
-
|
|
21002
|
+
if (path14.isSwitchStatement()) {
|
|
21003
|
+
path14.context.maybeQueue(path14.get("discriminant"));
|
|
21004
21004
|
}
|
|
21005
21005
|
}
|
|
21006
21006
|
},
|
|
@@ -21017,9 +21017,9 @@ var require_renamer = __commonJS({
|
|
|
21017
21017
|
if ((_node$extra = node.extra) != null && _node$extra.shorthand) node.extra.shorthand = false;
|
|
21018
21018
|
}
|
|
21019
21019
|
},
|
|
21020
|
-
"AssignmentExpression|Declaration|VariableDeclarator"(
|
|
21021
|
-
if (
|
|
21022
|
-
const ids =
|
|
21020
|
+
"AssignmentExpression|Declaration|VariableDeclarator"(path14, state) {
|
|
21021
|
+
if (path14.isVariableDeclaration()) return;
|
|
21022
|
+
const ids = path14.isAssignmentExpression() ? getAssignmentIdentifiers(path14.node) : path14.getOuterBindingIdentifiers();
|
|
21023
21023
|
for (const name in ids) {
|
|
21024
21024
|
if (name === state.oldName) ids[name].name = state.newName;
|
|
21025
21025
|
}
|
|
@@ -21049,11 +21049,11 @@ var require_renamer = __commonJS({
|
|
|
21049
21049
|
}
|
|
21050
21050
|
maybeExportDeclar.splitExportDeclaration();
|
|
21051
21051
|
}
|
|
21052
|
-
maybeConvertFromClassFunctionDeclaration(
|
|
21053
|
-
return
|
|
21052
|
+
maybeConvertFromClassFunctionDeclaration(path14) {
|
|
21053
|
+
return path14;
|
|
21054
21054
|
}
|
|
21055
|
-
maybeConvertFromClassFunctionExpression(
|
|
21056
|
-
return
|
|
21055
|
+
maybeConvertFromClassFunctionExpression(path14) {
|
|
21056
|
+
return path14;
|
|
21057
21057
|
}
|
|
21058
21058
|
rename() {
|
|
21059
21059
|
const {
|
|
@@ -21063,9 +21063,9 @@ var require_renamer = __commonJS({
|
|
|
21063
21063
|
} = this;
|
|
21064
21064
|
const {
|
|
21065
21065
|
scope,
|
|
21066
|
-
path:
|
|
21066
|
+
path: path14
|
|
21067
21067
|
} = binding;
|
|
21068
|
-
const parentDeclar =
|
|
21068
|
+
const parentDeclar = path14.find((path15) => path15.isDeclaration() || path15.isFunctionExpression() || path15.isClassExpression());
|
|
21069
21069
|
if (parentDeclar) {
|
|
21070
21070
|
const bindingIds = parentDeclar.getOuterBindingIdentifiers();
|
|
21071
21071
|
if (bindingIds[oldName] === binding.identifier) {
|
|
@@ -21091,8 +21091,8 @@ var require_renamer = __commonJS({
|
|
|
21091
21091
|
this.binding.identifier.name = newName;
|
|
21092
21092
|
}
|
|
21093
21093
|
if (parentDeclar) {
|
|
21094
|
-
this.maybeConvertFromClassFunctionDeclaration(
|
|
21095
|
-
this.maybeConvertFromClassFunctionExpression(
|
|
21094
|
+
this.maybeConvertFromClassFunctionDeclaration(path14);
|
|
21095
|
+
this.maybeConvertFromClassFunctionExpression(path14);
|
|
21096
21096
|
}
|
|
21097
21097
|
}
|
|
21098
21098
|
};
|
|
@@ -21115,17 +21115,17 @@ var require_traverseForScope = __commonJS({
|
|
|
21115
21115
|
var {
|
|
21116
21116
|
VISITOR_KEYS
|
|
21117
21117
|
} = _t;
|
|
21118
|
-
function traverseForScope(
|
|
21118
|
+
function traverseForScope(path14, visitors, state) {
|
|
21119
21119
|
const exploded = (0, _visitors.explode)(visitors);
|
|
21120
21120
|
if (exploded.enter || exploded.exit) {
|
|
21121
21121
|
throw new Error("Should not be used with enter/exit visitors.");
|
|
21122
21122
|
}
|
|
21123
|
-
_traverse(
|
|
21123
|
+
_traverse(path14.parentPath, path14.parent, path14.node, path14.container, path14.key, path14.listKey, path14.hub, path14);
|
|
21124
21124
|
function _traverse(parentPath, parent, node, container, key, listKey, hub, inPath) {
|
|
21125
21125
|
if (!node) {
|
|
21126
21126
|
return;
|
|
21127
21127
|
}
|
|
21128
|
-
const
|
|
21128
|
+
const path15 = inPath || _index.NodePath.get({
|
|
21129
21129
|
hub,
|
|
21130
21130
|
parentPath,
|
|
21131
21131
|
parent,
|
|
@@ -21133,14 +21133,14 @@ var require_traverseForScope = __commonJS({
|
|
|
21133
21133
|
listKey,
|
|
21134
21134
|
key
|
|
21135
21135
|
});
|
|
21136
|
-
_context._forceSetScope.call(
|
|
21136
|
+
_context._forceSetScope.call(path15);
|
|
21137
21137
|
const visitor = exploded[node.type];
|
|
21138
21138
|
if (visitor != null && visitor.enter) {
|
|
21139
21139
|
for (const visit of visitor.enter) {
|
|
21140
|
-
visit.call(state,
|
|
21140
|
+
visit.call(state, path15, state);
|
|
21141
21141
|
}
|
|
21142
21142
|
}
|
|
21143
|
-
if (
|
|
21143
|
+
if (path15.shouldSkip) {
|
|
21144
21144
|
return;
|
|
21145
21145
|
}
|
|
21146
21146
|
const keys = VISITOR_KEYS[node.type];
|
|
@@ -21153,15 +21153,15 @@ var require_traverseForScope = __commonJS({
|
|
|
21153
21153
|
if (Array.isArray(prop)) {
|
|
21154
21154
|
for (let i = 0; i < prop.length; i++) {
|
|
21155
21155
|
const value = prop[i];
|
|
21156
|
-
_traverse(
|
|
21156
|
+
_traverse(path15, node, value, prop, i, key2);
|
|
21157
21157
|
}
|
|
21158
21158
|
} else {
|
|
21159
|
-
_traverse(
|
|
21159
|
+
_traverse(path15, node, prop, node, key2, null);
|
|
21160
21160
|
}
|
|
21161
21161
|
}
|
|
21162
21162
|
if (visitor != null && visitor.exit) {
|
|
21163
21163
|
for (const visit of visitor.exit) {
|
|
21164
|
-
visit.call(state,
|
|
21164
|
+
visit.call(state, path15, state);
|
|
21165
21165
|
}
|
|
21166
21166
|
}
|
|
21167
21167
|
}
|
|
@@ -21181,7 +21181,7 @@ var require_binding = __commonJS({
|
|
|
21181
21181
|
constructor({
|
|
21182
21182
|
identifier,
|
|
21183
21183
|
scope,
|
|
21184
|
-
path:
|
|
21184
|
+
path: path14,
|
|
21185
21185
|
kind
|
|
21186
21186
|
}) {
|
|
21187
21187
|
this.identifier = void 0;
|
|
@@ -21195,10 +21195,10 @@ var require_binding = __commonJS({
|
|
|
21195
21195
|
this.references = 0;
|
|
21196
21196
|
this.identifier = identifier;
|
|
21197
21197
|
this.scope = scope;
|
|
21198
|
-
this.path =
|
|
21198
|
+
this.path = path14;
|
|
21199
21199
|
this.kind = kind;
|
|
21200
|
-
if ((kind === "var" || kind === "hoisted") && isInitInLoop(
|
|
21201
|
-
this.reassign(
|
|
21200
|
+
if ((kind === "var" || kind === "hoisted") && isInitInLoop(path14)) {
|
|
21201
|
+
this.reassign(path14);
|
|
21202
21202
|
}
|
|
21203
21203
|
this.clearValue();
|
|
21204
21204
|
}
|
|
@@ -21216,20 +21216,20 @@ var require_binding = __commonJS({
|
|
|
21216
21216
|
this.hasValue = false;
|
|
21217
21217
|
this.value = null;
|
|
21218
21218
|
}
|
|
21219
|
-
reassign(
|
|
21219
|
+
reassign(path14) {
|
|
21220
21220
|
this.constant = false;
|
|
21221
|
-
if (this.constantViolations.includes(
|
|
21221
|
+
if (this.constantViolations.includes(path14)) {
|
|
21222
21222
|
return;
|
|
21223
21223
|
}
|
|
21224
|
-
this.constantViolations.push(
|
|
21224
|
+
this.constantViolations.push(path14);
|
|
21225
21225
|
}
|
|
21226
|
-
reference(
|
|
21227
|
-
if (this.referencePaths.includes(
|
|
21226
|
+
reference(path14) {
|
|
21227
|
+
if (this.referencePaths.includes(path14)) {
|
|
21228
21228
|
return;
|
|
21229
21229
|
}
|
|
21230
21230
|
this.referenced = true;
|
|
21231
21231
|
this.references++;
|
|
21232
|
-
this.referencePaths.push(
|
|
21232
|
+
this.referencePaths.push(path14);
|
|
21233
21233
|
}
|
|
21234
21234
|
dereference() {
|
|
21235
21235
|
this.references--;
|
|
@@ -21237,12 +21237,12 @@ var require_binding = __commonJS({
|
|
|
21237
21237
|
}
|
|
21238
21238
|
};
|
|
21239
21239
|
exports.default = Binding;
|
|
21240
|
-
function isInitInLoop(
|
|
21241
|
-
const isFunctionDeclarationOrHasInit = !
|
|
21240
|
+
function isInitInLoop(path14) {
|
|
21241
|
+
const isFunctionDeclarationOrHasInit = !path14.isVariableDeclarator() || path14.node.init;
|
|
21242
21242
|
for (let {
|
|
21243
21243
|
parentPath,
|
|
21244
21244
|
key
|
|
21245
|
-
} =
|
|
21245
|
+
} = path14; parentPath; {
|
|
21246
21246
|
parentPath,
|
|
21247
21247
|
key
|
|
21248
21248
|
} = parentPath) {
|
|
@@ -21281,11 +21281,11 @@ var require_cache = __commonJS({
|
|
|
21281
21281
|
function clearScope() {
|
|
21282
21282
|
exports.scope = scope = /* @__PURE__ */ new WeakMap();
|
|
21283
21283
|
}
|
|
21284
|
-
function getCachedPaths(
|
|
21284
|
+
function getCachedPaths(path14) {
|
|
21285
21285
|
const {
|
|
21286
21286
|
parent,
|
|
21287
21287
|
parentPath
|
|
21288
|
-
} =
|
|
21288
|
+
} = path14;
|
|
21289
21289
|
return pathsCache.get(parent);
|
|
21290
21290
|
}
|
|
21291
21291
|
function getOrCreateCachedPaths(node, parentPath) {
|
|
@@ -21561,128 +21561,128 @@ var require_scope = __commonJS({
|
|
|
21561
21561
|
scope.bindings = /* @__PURE__ */ Object.create(null);
|
|
21562
21562
|
scope.globals = /* @__PURE__ */ Object.create(null);
|
|
21563
21563
|
}
|
|
21564
|
-
function isAnonymousFunctionExpression(
|
|
21565
|
-
return
|
|
21564
|
+
function isAnonymousFunctionExpression(path14) {
|
|
21565
|
+
return path14.isFunctionExpression() && !path14.node.id || path14.isArrowFunctionExpression();
|
|
21566
21566
|
}
|
|
21567
21567
|
var NOT_LOCAL_BINDING = /* @__PURE__ */ Symbol.for("should not be considered a local binding");
|
|
21568
21568
|
var collectorVisitor = {
|
|
21569
|
-
ForStatement(
|
|
21570
|
-
const declar =
|
|
21569
|
+
ForStatement(path14) {
|
|
21570
|
+
const declar = path14.get("init");
|
|
21571
21571
|
if (declar.isVar()) {
|
|
21572
21572
|
const {
|
|
21573
21573
|
scope
|
|
21574
|
-
} =
|
|
21574
|
+
} = path14;
|
|
21575
21575
|
const parentScope = scope.getFunctionParent() || scope.getProgramParent();
|
|
21576
21576
|
parentScope.registerBinding("var", declar);
|
|
21577
21577
|
}
|
|
21578
21578
|
},
|
|
21579
|
-
Declaration(
|
|
21580
|
-
if (
|
|
21581
|
-
if (
|
|
21582
|
-
if (
|
|
21583
|
-
const parent =
|
|
21584
|
-
parent.registerDeclaration(
|
|
21579
|
+
Declaration(path14) {
|
|
21580
|
+
if (path14.isBlockScoped()) return;
|
|
21581
|
+
if (path14.isImportDeclaration()) return;
|
|
21582
|
+
if (path14.isExportDeclaration()) return;
|
|
21583
|
+
const parent = path14.scope.getFunctionParent() || path14.scope.getProgramParent();
|
|
21584
|
+
parent.registerDeclaration(path14);
|
|
21585
21585
|
},
|
|
21586
|
-
ImportDeclaration(
|
|
21587
|
-
const parent =
|
|
21588
|
-
parent.registerDeclaration(
|
|
21586
|
+
ImportDeclaration(path14) {
|
|
21587
|
+
const parent = path14.scope.getBlockParent();
|
|
21588
|
+
parent.registerDeclaration(path14);
|
|
21589
21589
|
},
|
|
21590
|
-
TSImportEqualsDeclaration(
|
|
21591
|
-
const parent =
|
|
21592
|
-
parent.registerDeclaration(
|
|
21590
|
+
TSImportEqualsDeclaration(path14) {
|
|
21591
|
+
const parent = path14.scope.getBlockParent();
|
|
21592
|
+
parent.registerDeclaration(path14);
|
|
21593
21593
|
},
|
|
21594
|
-
ReferencedIdentifier(
|
|
21595
|
-
if (t2.isTSQualifiedName(
|
|
21594
|
+
ReferencedIdentifier(path14, state) {
|
|
21595
|
+
if (t2.isTSQualifiedName(path14.parent) && path14.parent.right === path14.node) {
|
|
21596
21596
|
return;
|
|
21597
21597
|
}
|
|
21598
|
-
if (
|
|
21599
|
-
state.references.push(
|
|
21598
|
+
if (path14.parentPath.isTSImportEqualsDeclaration()) return;
|
|
21599
|
+
state.references.push(path14);
|
|
21600
21600
|
},
|
|
21601
|
-
ForXStatement(
|
|
21602
|
-
const left =
|
|
21601
|
+
ForXStatement(path14, state) {
|
|
21602
|
+
const left = path14.get("left");
|
|
21603
21603
|
if (left.isPattern() || left.isIdentifier()) {
|
|
21604
|
-
state.constantViolations.push(
|
|
21604
|
+
state.constantViolations.push(path14);
|
|
21605
21605
|
} else if (left.isVar()) {
|
|
21606
21606
|
const {
|
|
21607
21607
|
scope
|
|
21608
|
-
} =
|
|
21608
|
+
} = path14;
|
|
21609
21609
|
const parentScope = scope.getFunctionParent() || scope.getProgramParent();
|
|
21610
21610
|
parentScope.registerBinding("var", left);
|
|
21611
21611
|
}
|
|
21612
21612
|
},
|
|
21613
21613
|
ExportDeclaration: {
|
|
21614
|
-
exit(
|
|
21614
|
+
exit(path14) {
|
|
21615
21615
|
const {
|
|
21616
21616
|
node,
|
|
21617
21617
|
scope
|
|
21618
|
-
} =
|
|
21618
|
+
} = path14;
|
|
21619
21619
|
if (isExportAllDeclaration(node)) return;
|
|
21620
21620
|
const declar = node.declaration;
|
|
21621
21621
|
if (isClassDeclaration(declar) || isFunctionDeclaration(declar)) {
|
|
21622
21622
|
const id = declar.id;
|
|
21623
21623
|
if (!id) return;
|
|
21624
21624
|
const binding = scope.getBinding(id.name);
|
|
21625
|
-
binding == null || binding.reference(
|
|
21625
|
+
binding == null || binding.reference(path14);
|
|
21626
21626
|
} else if (isVariableDeclaration(declar)) {
|
|
21627
21627
|
for (const decl of declar.declarations) {
|
|
21628
21628
|
for (const name of Object.keys(getBindingIdentifiers(decl))) {
|
|
21629
21629
|
const binding = scope.getBinding(name);
|
|
21630
|
-
binding == null || binding.reference(
|
|
21630
|
+
binding == null || binding.reference(path14);
|
|
21631
21631
|
}
|
|
21632
21632
|
}
|
|
21633
21633
|
}
|
|
21634
21634
|
}
|
|
21635
21635
|
},
|
|
21636
|
-
LabeledStatement(
|
|
21637
|
-
|
|
21636
|
+
LabeledStatement(path14) {
|
|
21637
|
+
path14.scope.getBlockParent().registerDeclaration(path14);
|
|
21638
21638
|
},
|
|
21639
|
-
AssignmentExpression(
|
|
21640
|
-
state.assignments.push(
|
|
21639
|
+
AssignmentExpression(path14, state) {
|
|
21640
|
+
state.assignments.push(path14);
|
|
21641
21641
|
},
|
|
21642
|
-
UpdateExpression(
|
|
21643
|
-
state.constantViolations.push(
|
|
21642
|
+
UpdateExpression(path14, state) {
|
|
21643
|
+
state.constantViolations.push(path14);
|
|
21644
21644
|
},
|
|
21645
|
-
UnaryExpression(
|
|
21646
|
-
if (
|
|
21647
|
-
state.constantViolations.push(
|
|
21645
|
+
UnaryExpression(path14, state) {
|
|
21646
|
+
if (path14.node.operator === "delete") {
|
|
21647
|
+
state.constantViolations.push(path14);
|
|
21648
21648
|
}
|
|
21649
21649
|
},
|
|
21650
|
-
BlockScoped(
|
|
21651
|
-
let scope =
|
|
21652
|
-
if (scope.path ===
|
|
21650
|
+
BlockScoped(path14) {
|
|
21651
|
+
let scope = path14.scope;
|
|
21652
|
+
if (scope.path === path14) scope = scope.parent;
|
|
21653
21653
|
const parent = scope.getBlockParent();
|
|
21654
|
-
parent.registerDeclaration(
|
|
21655
|
-
if (
|
|
21656
|
-
const id =
|
|
21654
|
+
parent.registerDeclaration(path14);
|
|
21655
|
+
if (path14.isClassDeclaration() && path14.node.id) {
|
|
21656
|
+
const id = path14.node.id;
|
|
21657
21657
|
const name = id.name;
|
|
21658
|
-
|
|
21658
|
+
path14.scope.bindings[name] = path14.scope.parent.getBinding(name);
|
|
21659
21659
|
}
|
|
21660
21660
|
},
|
|
21661
|
-
CatchClause(
|
|
21662
|
-
|
|
21661
|
+
CatchClause(path14) {
|
|
21662
|
+
path14.scope.registerBinding("let", path14);
|
|
21663
21663
|
},
|
|
21664
|
-
Function(
|
|
21665
|
-
const params =
|
|
21664
|
+
Function(path14) {
|
|
21665
|
+
const params = path14.get("params");
|
|
21666
21666
|
for (const param of params) {
|
|
21667
|
-
|
|
21667
|
+
path14.scope.registerBinding("param", param);
|
|
21668
21668
|
}
|
|
21669
|
-
if (
|
|
21670
|
-
|
|
21669
|
+
if (path14.isFunctionExpression() && path14.node.id && !path14.node.id[NOT_LOCAL_BINDING]) {
|
|
21670
|
+
path14.scope.registerBinding("local", path14.get("id"), path14);
|
|
21671
21671
|
}
|
|
21672
21672
|
},
|
|
21673
|
-
ClassExpression(
|
|
21674
|
-
if (
|
|
21675
|
-
|
|
21673
|
+
ClassExpression(path14) {
|
|
21674
|
+
if (path14.node.id && !path14.node.id[NOT_LOCAL_BINDING]) {
|
|
21675
|
+
path14.scope.registerBinding("local", path14.get("id"), path14);
|
|
21676
21676
|
}
|
|
21677
21677
|
},
|
|
21678
|
-
TSTypeAnnotation(
|
|
21679
|
-
|
|
21678
|
+
TSTypeAnnotation(path14) {
|
|
21679
|
+
path14.skip();
|
|
21680
21680
|
}
|
|
21681
21681
|
};
|
|
21682
21682
|
var scopeVisitor;
|
|
21683
21683
|
var uid = 0;
|
|
21684
21684
|
var Scope = class _Scope {
|
|
21685
|
-
constructor(
|
|
21685
|
+
constructor(path14) {
|
|
21686
21686
|
this.uid = void 0;
|
|
21687
21687
|
this.path = void 0;
|
|
21688
21688
|
this.block = void 0;
|
|
@@ -21696,15 +21696,15 @@ var require_scope = __commonJS({
|
|
|
21696
21696
|
this.crawling = void 0;
|
|
21697
21697
|
const {
|
|
21698
21698
|
node
|
|
21699
|
-
} =
|
|
21699
|
+
} = path14;
|
|
21700
21700
|
const cached = _cache.scope.get(node);
|
|
21701
|
-
if ((cached == null ? void 0 : cached.path) ===
|
|
21701
|
+
if ((cached == null ? void 0 : cached.path) === path14) {
|
|
21702
21702
|
return cached;
|
|
21703
21703
|
}
|
|
21704
21704
|
_cache.scope.set(node, this);
|
|
21705
21705
|
this.uid = uid++;
|
|
21706
21706
|
this.block = node;
|
|
21707
|
-
this.path =
|
|
21707
|
+
this.path = path14;
|
|
21708
21708
|
this.labels = /* @__PURE__ */ new Map();
|
|
21709
21709
|
this.inited = false;
|
|
21710
21710
|
Object.defineProperties(this, {
|
|
@@ -21724,14 +21724,14 @@ var require_scope = __commonJS({
|
|
|
21724
21724
|
}
|
|
21725
21725
|
get parent() {
|
|
21726
21726
|
var _parent;
|
|
21727
|
-
let parent,
|
|
21727
|
+
let parent, path14 = this.path;
|
|
21728
21728
|
do {
|
|
21729
21729
|
var _path;
|
|
21730
|
-
const shouldSkip =
|
|
21731
|
-
|
|
21732
|
-
if (shouldSkip &&
|
|
21733
|
-
if ((_path =
|
|
21734
|
-
} while (
|
|
21730
|
+
const shouldSkip = path14.key === "key" || path14.listKey === "decorators";
|
|
21731
|
+
path14 = path14.parentPath;
|
|
21732
|
+
if (shouldSkip && path14.isMethod()) path14 = path14.parentPath;
|
|
21733
|
+
if ((_path = path14) != null && _path.isScope()) parent = path14;
|
|
21734
|
+
} while (path14 && !parent);
|
|
21735
21735
|
return (_parent = parent) == null ? void 0 : _parent.scope;
|
|
21736
21736
|
}
|
|
21737
21737
|
get references() {
|
|
@@ -21844,62 +21844,62 @@ var require_scope = __commonJS({
|
|
|
21844
21844
|
getLabel(name) {
|
|
21845
21845
|
return this.labels.get(name);
|
|
21846
21846
|
}
|
|
21847
|
-
registerLabel(
|
|
21848
|
-
this.labels.set(
|
|
21847
|
+
registerLabel(path14) {
|
|
21848
|
+
this.labels.set(path14.node.label.name, path14);
|
|
21849
21849
|
}
|
|
21850
|
-
registerDeclaration(
|
|
21851
|
-
if (
|
|
21852
|
-
this.registerLabel(
|
|
21853
|
-
} else if (
|
|
21854
|
-
this.registerBinding("hoisted",
|
|
21855
|
-
} else if (
|
|
21856
|
-
const declarations =
|
|
21850
|
+
registerDeclaration(path14) {
|
|
21851
|
+
if (path14.isLabeledStatement()) {
|
|
21852
|
+
this.registerLabel(path14);
|
|
21853
|
+
} else if (path14.isFunctionDeclaration()) {
|
|
21854
|
+
this.registerBinding("hoisted", path14.get("id"), path14);
|
|
21855
|
+
} else if (path14.isVariableDeclaration()) {
|
|
21856
|
+
const declarations = path14.get("declarations");
|
|
21857
21857
|
const {
|
|
21858
21858
|
kind
|
|
21859
|
-
} =
|
|
21859
|
+
} = path14.node;
|
|
21860
21860
|
for (const declar of declarations) {
|
|
21861
21861
|
this.registerBinding(kind === "using" || kind === "await using" ? "const" : kind, declar);
|
|
21862
21862
|
}
|
|
21863
|
-
} else if (
|
|
21864
|
-
if (
|
|
21865
|
-
this.registerBinding("let",
|
|
21866
|
-
} else if (
|
|
21867
|
-
const isTypeDeclaration =
|
|
21868
|
-
const specifiers =
|
|
21863
|
+
} else if (path14.isClassDeclaration()) {
|
|
21864
|
+
if (path14.node.declare) return;
|
|
21865
|
+
this.registerBinding("let", path14);
|
|
21866
|
+
} else if (path14.isImportDeclaration()) {
|
|
21867
|
+
const isTypeDeclaration = path14.node.importKind === "type" || path14.node.importKind === "typeof";
|
|
21868
|
+
const specifiers = path14.get("specifiers");
|
|
21869
21869
|
for (const specifier of specifiers) {
|
|
21870
21870
|
const isTypeSpecifier = isTypeDeclaration || specifier.isImportSpecifier() && (specifier.node.importKind === "type" || specifier.node.importKind === "typeof");
|
|
21871
21871
|
this.registerBinding(isTypeSpecifier ? "unknown" : "module", specifier);
|
|
21872
21872
|
}
|
|
21873
|
-
} else if (
|
|
21874
|
-
const declar =
|
|
21873
|
+
} else if (path14.isExportDeclaration()) {
|
|
21874
|
+
const declar = path14.get("declaration");
|
|
21875
21875
|
if (declar.isClassDeclaration() || declar.isFunctionDeclaration() || declar.isVariableDeclaration()) {
|
|
21876
21876
|
this.registerDeclaration(declar);
|
|
21877
21877
|
}
|
|
21878
21878
|
} else {
|
|
21879
|
-
this.registerBinding("unknown",
|
|
21879
|
+
this.registerBinding("unknown", path14);
|
|
21880
21880
|
}
|
|
21881
21881
|
}
|
|
21882
21882
|
buildUndefinedNode() {
|
|
21883
21883
|
return buildUndefinedNode();
|
|
21884
21884
|
}
|
|
21885
|
-
registerConstantViolation(
|
|
21886
|
-
const ids =
|
|
21885
|
+
registerConstantViolation(path14) {
|
|
21886
|
+
const ids = path14.getAssignmentIdentifiers();
|
|
21887
21887
|
for (const name of Object.keys(ids)) {
|
|
21888
21888
|
var _this$getBinding;
|
|
21889
|
-
(_this$getBinding = this.getBinding(name)) == null || _this$getBinding.reassign(
|
|
21889
|
+
(_this$getBinding = this.getBinding(name)) == null || _this$getBinding.reassign(path14);
|
|
21890
21890
|
}
|
|
21891
21891
|
}
|
|
21892
|
-
registerBinding(kind,
|
|
21892
|
+
registerBinding(kind, path14, bindingPath = path14) {
|
|
21893
21893
|
if (!kind) throw new ReferenceError("no `kind`");
|
|
21894
|
-
if (
|
|
21895
|
-
const declarators =
|
|
21894
|
+
if (path14.isVariableDeclaration()) {
|
|
21895
|
+
const declarators = path14.get("declarations");
|
|
21896
21896
|
for (const declar of declarators) {
|
|
21897
21897
|
this.registerBinding(kind, declar);
|
|
21898
21898
|
}
|
|
21899
21899
|
return;
|
|
21900
21900
|
}
|
|
21901
21901
|
const parent = this.getProgramParent();
|
|
21902
|
-
const ids =
|
|
21902
|
+
const ids = path14.getOuterBindingIdentifiers(true);
|
|
21903
21903
|
for (const name of Object.keys(ids)) {
|
|
21904
21904
|
parent.references[name] = true;
|
|
21905
21905
|
for (const id of ids[name]) {
|
|
@@ -22041,7 +22041,7 @@ var require_scope = __commonJS({
|
|
|
22041
22041
|
}
|
|
22042
22042
|
}
|
|
22043
22043
|
crawl() {
|
|
22044
|
-
const
|
|
22044
|
+
const path14 = this.path;
|
|
22045
22045
|
resetScope(this);
|
|
22046
22046
|
this.data = /* @__PURE__ */ Object.create(null);
|
|
22047
22047
|
let scope = this;
|
|
@@ -22059,27 +22059,27 @@ var require_scope = __commonJS({
|
|
|
22059
22059
|
};
|
|
22060
22060
|
this.crawling = true;
|
|
22061
22061
|
scopeVisitor || (scopeVisitor = _index.default.visitors.merge([{
|
|
22062
|
-
Scope(
|
|
22063
|
-
resetScope(
|
|
22062
|
+
Scope(path15) {
|
|
22063
|
+
resetScope(path15.scope);
|
|
22064
22064
|
}
|
|
22065
22065
|
}, collectorVisitor]));
|
|
22066
|
-
if (
|
|
22067
|
-
const typeVisitors = scopeVisitor[
|
|
22066
|
+
if (path14.type !== "Program") {
|
|
22067
|
+
const typeVisitors = scopeVisitor[path14.type];
|
|
22068
22068
|
if (typeVisitors) {
|
|
22069
22069
|
for (const visit of typeVisitors.enter) {
|
|
22070
|
-
visit.call(state,
|
|
22070
|
+
visit.call(state, path14, state);
|
|
22071
22071
|
}
|
|
22072
22072
|
}
|
|
22073
22073
|
}
|
|
22074
|
-
|
|
22074
|
+
path14.traverse(scopeVisitor, state);
|
|
22075
22075
|
this.crawling = false;
|
|
22076
|
-
for (const
|
|
22077
|
-
const ids =
|
|
22076
|
+
for (const path15 of state.assignments) {
|
|
22077
|
+
const ids = path15.getAssignmentIdentifiers();
|
|
22078
22078
|
for (const name of Object.keys(ids)) {
|
|
22079
|
-
if (
|
|
22079
|
+
if (path15.scope.getBinding(name)) continue;
|
|
22080
22080
|
programParent.addGlobal(ids[name]);
|
|
22081
22081
|
}
|
|
22082
|
-
|
|
22082
|
+
path15.scope.registerConstantViolation(path15);
|
|
22083
22083
|
}
|
|
22084
22084
|
for (const ref of state.references) {
|
|
22085
22085
|
const binding = ref.scope.getBinding(ref.node.name);
|
|
@@ -22089,19 +22089,19 @@ var require_scope = __commonJS({
|
|
|
22089
22089
|
programParent.addGlobal(ref.node);
|
|
22090
22090
|
}
|
|
22091
22091
|
}
|
|
22092
|
-
for (const
|
|
22093
|
-
|
|
22092
|
+
for (const path15 of state.constantViolations) {
|
|
22093
|
+
path15.scope.registerConstantViolation(path15);
|
|
22094
22094
|
}
|
|
22095
22095
|
}
|
|
22096
22096
|
push(opts) {
|
|
22097
|
-
let
|
|
22098
|
-
if (
|
|
22099
|
-
|
|
22100
|
-
} else if (!
|
|
22101
|
-
|
|
22097
|
+
let path14 = this.path;
|
|
22098
|
+
if (path14.isPattern()) {
|
|
22099
|
+
path14 = this.getPatternParent().path;
|
|
22100
|
+
} else if (!path14.isBlockStatement() && !path14.isProgram()) {
|
|
22101
|
+
path14 = this.getBlockParent().path;
|
|
22102
22102
|
}
|
|
22103
|
-
if (
|
|
22104
|
-
|
|
22103
|
+
if (path14.isSwitchStatement()) {
|
|
22104
|
+
path14 = (this.getFunctionParent() || this.getProgramParent()).path;
|
|
22105
22105
|
}
|
|
22106
22106
|
const {
|
|
22107
22107
|
init,
|
|
@@ -22109,29 +22109,29 @@ var require_scope = __commonJS({
|
|
|
22109
22109
|
kind = "var",
|
|
22110
22110
|
id
|
|
22111
22111
|
} = opts;
|
|
22112
|
-
if (!init && !unique && (kind === "var" || kind === "let") && isAnonymousFunctionExpression(
|
|
22113
|
-
callee:
|
|
22114
|
-
}) &&
|
|
22115
|
-
|
|
22116
|
-
|
|
22112
|
+
if (!init && !unique && (kind === "var" || kind === "let") && isAnonymousFunctionExpression(path14) && isCallExpression(path14.parent, {
|
|
22113
|
+
callee: path14.node
|
|
22114
|
+
}) && path14.parent.arguments.length <= path14.node.params.length && isIdentifier(id)) {
|
|
22115
|
+
path14.pushContainer("params", id);
|
|
22116
|
+
path14.scope.registerBinding("param", path14.get("params")[path14.node.params.length - 1]);
|
|
22117
22117
|
return;
|
|
22118
22118
|
}
|
|
22119
|
-
if (
|
|
22120
|
-
|
|
22121
|
-
|
|
22119
|
+
if (path14.isLoop() || path14.isCatchClause() || path14.isFunction()) {
|
|
22120
|
+
path14.ensureBlock();
|
|
22121
|
+
path14 = path14.get("body");
|
|
22122
22122
|
}
|
|
22123
22123
|
const blockHoist = opts._blockHoist == null ? 2 : opts._blockHoist;
|
|
22124
22124
|
const dataKey = `declaration:${kind}:${blockHoist}`;
|
|
22125
|
-
let declarPath = !unique &&
|
|
22125
|
+
let declarPath = !unique && path14.getData(dataKey);
|
|
22126
22126
|
if (!declarPath) {
|
|
22127
22127
|
const declar = variableDeclaration(kind, []);
|
|
22128
22128
|
declar._blockHoist = blockHoist;
|
|
22129
|
-
[declarPath] =
|
|
22130
|
-
if (!unique)
|
|
22129
|
+
[declarPath] = path14.unshiftContainer("body", [declar]);
|
|
22130
|
+
if (!unique) path14.setData(dataKey, declarPath);
|
|
22131
22131
|
}
|
|
22132
22132
|
const declarator = variableDeclarator(id, init);
|
|
22133
22133
|
const len = declarPath.node.declarations.push(declarator);
|
|
22134
|
-
|
|
22134
|
+
path14.scope.registerBinding(kind, declarPath.get("declarations")[len - 1]);
|
|
22135
22135
|
}
|
|
22136
22136
|
getProgramParent() {
|
|
22137
22137
|
let scope = this;
|
|
@@ -22276,15 +22276,15 @@ var require_scope = __commonJS({
|
|
|
22276
22276
|
const binding = this.bindings[name];
|
|
22277
22277
|
if (!binding) continue;
|
|
22278
22278
|
const {
|
|
22279
|
-
path:
|
|
22279
|
+
path: path14
|
|
22280
22280
|
} = binding;
|
|
22281
|
-
if (!
|
|
22281
|
+
if (!path14.isVariableDeclarator()) continue;
|
|
22282
22282
|
const {
|
|
22283
22283
|
parent,
|
|
22284
22284
|
parentPath
|
|
22285
|
-
} =
|
|
22285
|
+
} = path14;
|
|
22286
22286
|
if (parent.kind !== "var" || seen.has(parent)) continue;
|
|
22287
|
-
seen.add(
|
|
22287
|
+
seen.add(path14.parent);
|
|
22288
22288
|
let firstId;
|
|
22289
22289
|
const init = [];
|
|
22290
22290
|
for (const decl of parent.declarations) {
|
|
@@ -22933,16 +22933,16 @@ var require_resolve_uri_umd = __commonJS({
|
|
|
22933
22933
|
}
|
|
22934
22934
|
function parseFileUrl(input) {
|
|
22935
22935
|
const match = fileRegex.exec(input);
|
|
22936
|
-
const
|
|
22937
|
-
return makeUrl("file:", "", match[1] || "", "", isAbsolutePath(
|
|
22936
|
+
const path14 = match[2];
|
|
22937
|
+
return makeUrl("file:", "", match[1] || "", "", isAbsolutePath(path14) ? path14 : "/" + path14, match[3] || "", match[4] || "");
|
|
22938
22938
|
}
|
|
22939
|
-
function makeUrl(scheme, user, host, port,
|
|
22939
|
+
function makeUrl(scheme, user, host, port, path14, query, hash) {
|
|
22940
22940
|
return {
|
|
22941
22941
|
scheme,
|
|
22942
22942
|
user,
|
|
22943
22943
|
host,
|
|
22944
22944
|
port,
|
|
22945
|
-
path:
|
|
22945
|
+
path: path14,
|
|
22946
22946
|
query,
|
|
22947
22947
|
hash,
|
|
22948
22948
|
type: 7
|
|
@@ -22972,11 +22972,11 @@ var require_resolve_uri_umd = __commonJS({
|
|
|
22972
22972
|
url.type = input ? input.startsWith("?") ? 3 : input.startsWith("#") ? 2 : 4 : 1;
|
|
22973
22973
|
return url;
|
|
22974
22974
|
}
|
|
22975
|
-
function stripPathFilename(
|
|
22976
|
-
if (
|
|
22977
|
-
return
|
|
22978
|
-
const index =
|
|
22979
|
-
return
|
|
22975
|
+
function stripPathFilename(path14) {
|
|
22976
|
+
if (path14.endsWith("/.."))
|
|
22977
|
+
return path14;
|
|
22978
|
+
const index = path14.lastIndexOf("/");
|
|
22979
|
+
return path14.slice(0, index + 1);
|
|
22980
22980
|
}
|
|
22981
22981
|
function mergePaths(url, base) {
|
|
22982
22982
|
normalizePath(base, base.type);
|
|
@@ -23014,14 +23014,14 @@ var require_resolve_uri_umd = __commonJS({
|
|
|
23014
23014
|
pieces[pointer++] = piece;
|
|
23015
23015
|
positive++;
|
|
23016
23016
|
}
|
|
23017
|
-
let
|
|
23017
|
+
let path14 = "";
|
|
23018
23018
|
for (let i = 1; i < pointer; i++) {
|
|
23019
|
-
|
|
23019
|
+
path14 += "/" + pieces[i];
|
|
23020
23020
|
}
|
|
23021
|
-
if (!
|
|
23022
|
-
|
|
23021
|
+
if (!path14 || addTrailingSlash && !path14.endsWith("/..")) {
|
|
23022
|
+
path14 += "/";
|
|
23023
23023
|
}
|
|
23024
|
-
url.path =
|
|
23024
|
+
url.path = path14;
|
|
23025
23025
|
}
|
|
23026
23026
|
function resolve(input, base) {
|
|
23027
23027
|
if (!input && !base)
|
|
@@ -23062,13 +23062,13 @@ var require_resolve_uri_umd = __commonJS({
|
|
|
23062
23062
|
case 3:
|
|
23063
23063
|
return queryHash;
|
|
23064
23064
|
case 4: {
|
|
23065
|
-
const
|
|
23066
|
-
if (!
|
|
23065
|
+
const path14 = url.path.slice(1);
|
|
23066
|
+
if (!path14)
|
|
23067
23067
|
return queryHash || ".";
|
|
23068
|
-
if (isRelative(base || input) && !isRelative(
|
|
23069
|
-
return "./" +
|
|
23068
|
+
if (isRelative(base || input) && !isRelative(path14)) {
|
|
23069
|
+
return "./" + path14 + queryHash;
|
|
23070
23070
|
}
|
|
23071
|
-
return
|
|
23071
|
+
return path14 + queryHash;
|
|
23072
23072
|
}
|
|
23073
23073
|
case 5:
|
|
23074
23074
|
return url.path + queryHash;
|
|
@@ -23168,10 +23168,10 @@ var require_trace_mapping_umd = __commonJS({
|
|
|
23168
23168
|
module2.exports = __toCommonJS(trace_mapping_exports);
|
|
23169
23169
|
var import_sourcemap_codec = __toESM2(require_sourcemap_codec());
|
|
23170
23170
|
var import_resolve_uri = __toESM2(require_resolve_uri());
|
|
23171
|
-
function stripFilename(
|
|
23172
|
-
if (!
|
|
23173
|
-
const index =
|
|
23174
|
-
return
|
|
23171
|
+
function stripFilename(path14) {
|
|
23172
|
+
if (!path14) return "";
|
|
23173
|
+
const index = path14.lastIndexOf("/");
|
|
23174
|
+
return path14.slice(0, index + 1);
|
|
23175
23175
|
}
|
|
23176
23176
|
function resolver(mapUrl, sourceRoot) {
|
|
23177
23177
|
const from = stripFilename(mapUrl);
|
|
@@ -29503,56 +29503,56 @@ var require_ancestry = __commonJS({
|
|
|
29503
29503
|
VISITOR_KEYS
|
|
29504
29504
|
} = _t;
|
|
29505
29505
|
function findParent(callback) {
|
|
29506
|
-
let
|
|
29507
|
-
while (
|
|
29508
|
-
if (callback(
|
|
29506
|
+
let path14 = this;
|
|
29507
|
+
while (path14 = path14.parentPath) {
|
|
29508
|
+
if (callback(path14)) return path14;
|
|
29509
29509
|
}
|
|
29510
29510
|
return null;
|
|
29511
29511
|
}
|
|
29512
29512
|
function find(callback) {
|
|
29513
|
-
let
|
|
29513
|
+
let path14 = this;
|
|
29514
29514
|
do {
|
|
29515
|
-
if (callback(
|
|
29516
|
-
} while (
|
|
29515
|
+
if (callback(path14)) return path14;
|
|
29516
|
+
} while (path14 = path14.parentPath);
|
|
29517
29517
|
return null;
|
|
29518
29518
|
}
|
|
29519
29519
|
function getFunctionParent() {
|
|
29520
29520
|
return this.findParent((p) => p.isFunction());
|
|
29521
29521
|
}
|
|
29522
29522
|
function getStatementParent() {
|
|
29523
|
-
let
|
|
29523
|
+
let path14 = this;
|
|
29524
29524
|
do {
|
|
29525
|
-
if (!
|
|
29525
|
+
if (!path14.parentPath || Array.isArray(path14.container) && path14.isStatement()) {
|
|
29526
29526
|
break;
|
|
29527
29527
|
} else {
|
|
29528
|
-
|
|
29528
|
+
path14 = path14.parentPath;
|
|
29529
29529
|
}
|
|
29530
|
-
} while (
|
|
29531
|
-
if (
|
|
29530
|
+
} while (path14);
|
|
29531
|
+
if (path14 && (path14.isProgram() || path14.isFile())) {
|
|
29532
29532
|
throw new Error("File/Program node, we can't possibly find a statement parent to this");
|
|
29533
29533
|
}
|
|
29534
|
-
return
|
|
29534
|
+
return path14;
|
|
29535
29535
|
}
|
|
29536
29536
|
function getEarliestCommonAncestorFrom(paths) {
|
|
29537
29537
|
return this.getDeepestCommonAncestorFrom(paths, function(deepest, i, ancestries) {
|
|
29538
29538
|
let earliest;
|
|
29539
29539
|
const keys = VISITOR_KEYS[deepest.type];
|
|
29540
29540
|
for (const ancestry of ancestries) {
|
|
29541
|
-
const
|
|
29541
|
+
const path14 = ancestry[i + 1];
|
|
29542
29542
|
if (!earliest) {
|
|
29543
|
-
earliest =
|
|
29543
|
+
earliest = path14;
|
|
29544
29544
|
continue;
|
|
29545
29545
|
}
|
|
29546
|
-
if (
|
|
29547
|
-
if (
|
|
29548
|
-
earliest =
|
|
29546
|
+
if (path14.listKey && earliest.listKey === path14.listKey) {
|
|
29547
|
+
if (path14.key < earliest.key) {
|
|
29548
|
+
earliest = path14;
|
|
29549
29549
|
continue;
|
|
29550
29550
|
}
|
|
29551
29551
|
}
|
|
29552
29552
|
const earliestKeyIndex = keys.indexOf(earliest.parentKey);
|
|
29553
|
-
const currentKeyIndex = keys.indexOf(
|
|
29553
|
+
const currentKeyIndex = keys.indexOf(path14.parentKey);
|
|
29554
29554
|
if (earliestKeyIndex > currentKeyIndex) {
|
|
29555
|
-
earliest =
|
|
29555
|
+
earliest = path14;
|
|
29556
29556
|
}
|
|
29557
29557
|
}
|
|
29558
29558
|
return earliest;
|
|
@@ -29567,11 +29567,11 @@ var require_ancestry = __commonJS({
|
|
|
29567
29567
|
}
|
|
29568
29568
|
let minDepth = Infinity;
|
|
29569
29569
|
let lastCommonIndex, lastCommon;
|
|
29570
|
-
const ancestries = paths.map((
|
|
29570
|
+
const ancestries = paths.map((path14) => {
|
|
29571
29571
|
const ancestry = [];
|
|
29572
29572
|
do {
|
|
29573
|
-
ancestry.unshift(
|
|
29574
|
-
} while ((
|
|
29573
|
+
ancestry.unshift(path14);
|
|
29574
|
+
} while ((path14 = path14.parentPath) && path14 !== this);
|
|
29575
29575
|
if (ancestry.length < minDepth) {
|
|
29576
29576
|
minDepth = ancestry.length;
|
|
29577
29577
|
}
|
|
@@ -29599,11 +29599,11 @@ var require_ancestry = __commonJS({
|
|
|
29599
29599
|
}
|
|
29600
29600
|
}
|
|
29601
29601
|
function getAncestry() {
|
|
29602
|
-
let
|
|
29602
|
+
let path14 = this;
|
|
29603
29603
|
const paths = [];
|
|
29604
29604
|
do {
|
|
29605
|
-
paths.push(
|
|
29606
|
-
} while (
|
|
29605
|
+
paths.push(path14);
|
|
29606
|
+
} while (path14 = path14.parentPath);
|
|
29607
29607
|
return paths;
|
|
29608
29608
|
}
|
|
29609
29609
|
function isAncestor(maybeDescendant) {
|
|
@@ -29613,10 +29613,10 @@ var require_ancestry = __commonJS({
|
|
|
29613
29613
|
return !!this.findParent((parent) => parent === maybeAncestor);
|
|
29614
29614
|
}
|
|
29615
29615
|
function inType(...candidateTypes) {
|
|
29616
|
-
let
|
|
29617
|
-
while (
|
|
29618
|
-
if (candidateTypes.includes(
|
|
29619
|
-
|
|
29616
|
+
let path14 = this;
|
|
29617
|
+
while (path14) {
|
|
29618
|
+
if (candidateTypes.includes(path14.node.type)) return true;
|
|
29619
|
+
path14 = path14.parentPath;
|
|
29620
29620
|
}
|
|
29621
29621
|
return false;
|
|
29622
29622
|
}
|
|
@@ -29687,14 +29687,14 @@ var require_inferer_reference = __commonJS({
|
|
|
29687
29687
|
} else if (node.name === "arguments") {
|
|
29688
29688
|
}
|
|
29689
29689
|
}
|
|
29690
|
-
function getTypeAnnotationBindingConstantViolations(binding,
|
|
29690
|
+
function getTypeAnnotationBindingConstantViolations(binding, path14, name) {
|
|
29691
29691
|
const types = [];
|
|
29692
29692
|
const functionConstantViolations = [];
|
|
29693
|
-
let constantViolations = getConstantViolationsBefore(binding,
|
|
29694
|
-
const testType = getConditionalAnnotation(binding,
|
|
29693
|
+
let constantViolations = getConstantViolationsBefore(binding, path14, functionConstantViolations);
|
|
29694
|
+
const testType = getConditionalAnnotation(binding, path14, name);
|
|
29695
29695
|
if (testType) {
|
|
29696
29696
|
const testConstantViolations = getConstantViolationsBefore(binding, testType.ifStatement);
|
|
29697
|
-
constantViolations = constantViolations.filter((
|
|
29697
|
+
constantViolations = constantViolations.filter((path15) => !testConstantViolations.includes(path15));
|
|
29698
29698
|
types.push(testType.typeAnnotation);
|
|
29699
29699
|
}
|
|
29700
29700
|
if (constantViolations.length) {
|
|
@@ -29708,20 +29708,20 @@ var require_inferer_reference = __commonJS({
|
|
|
29708
29708
|
}
|
|
29709
29709
|
return (0, _util.createUnionType)(types);
|
|
29710
29710
|
}
|
|
29711
|
-
function getConstantViolationsBefore(binding,
|
|
29711
|
+
function getConstantViolationsBefore(binding, path14, functions) {
|
|
29712
29712
|
const violations = binding.constantViolations.slice();
|
|
29713
29713
|
violations.unshift(binding.path);
|
|
29714
29714
|
return violations.filter((violation) => {
|
|
29715
29715
|
violation = violation.resolve();
|
|
29716
|
-
const status = violation._guessExecutionStatusRelativeTo(
|
|
29716
|
+
const status = violation._guessExecutionStatusRelativeTo(path14);
|
|
29717
29717
|
if (functions && status === "unknown") functions.push(violation);
|
|
29718
29718
|
return status === "before";
|
|
29719
29719
|
});
|
|
29720
29720
|
}
|
|
29721
|
-
function inferAnnotationFromBinaryExpression(name,
|
|
29722
|
-
const operator =
|
|
29723
|
-
const right =
|
|
29724
|
-
const left =
|
|
29721
|
+
function inferAnnotationFromBinaryExpression(name, path14) {
|
|
29722
|
+
const operator = path14.node.operator;
|
|
29723
|
+
const right = path14.get("right").resolve();
|
|
29724
|
+
const left = path14.get("left").resolve();
|
|
29725
29725
|
let target;
|
|
29726
29726
|
if (left.isIdentifier({
|
|
29727
29727
|
name
|
|
@@ -29765,11 +29765,11 @@ var require_inferer_reference = __commonJS({
|
|
|
29765
29765
|
if (typeof typeValue !== "string") return;
|
|
29766
29766
|
return createTypeAnnotationBasedOnTypeof(typeValue);
|
|
29767
29767
|
}
|
|
29768
|
-
function getParentConditionalPath(binding,
|
|
29768
|
+
function getParentConditionalPath(binding, path14, name) {
|
|
29769
29769
|
let parentPath;
|
|
29770
|
-
while (parentPath =
|
|
29770
|
+
while (parentPath = path14.parentPath) {
|
|
29771
29771
|
if (parentPath.isIfStatement() || parentPath.isConditionalExpression()) {
|
|
29772
|
-
if (
|
|
29772
|
+
if (path14.key === "test") {
|
|
29773
29773
|
return;
|
|
29774
29774
|
}
|
|
29775
29775
|
return parentPath;
|
|
@@ -29777,24 +29777,24 @@ var require_inferer_reference = __commonJS({
|
|
|
29777
29777
|
if (parentPath.isFunction()) {
|
|
29778
29778
|
if (name == null || parentPath.parentPath.scope.getBinding(name) !== binding) return;
|
|
29779
29779
|
}
|
|
29780
|
-
|
|
29780
|
+
path14 = parentPath;
|
|
29781
29781
|
}
|
|
29782
29782
|
}
|
|
29783
|
-
function getConditionalAnnotation(binding,
|
|
29784
|
-
const ifStatement = getParentConditionalPath(binding,
|
|
29783
|
+
function getConditionalAnnotation(binding, path14, name) {
|
|
29784
|
+
const ifStatement = getParentConditionalPath(binding, path14, name);
|
|
29785
29785
|
if (!ifStatement) return;
|
|
29786
29786
|
const test = ifStatement.get("test");
|
|
29787
29787
|
const paths = [test];
|
|
29788
29788
|
const types = [];
|
|
29789
29789
|
for (let i = 0; i < paths.length; i++) {
|
|
29790
|
-
const
|
|
29791
|
-
if (
|
|
29792
|
-
if (
|
|
29793
|
-
paths.push(
|
|
29794
|
-
paths.push(
|
|
29795
|
-
}
|
|
29796
|
-
} else if (
|
|
29797
|
-
const type = inferAnnotationFromBinaryExpression(name,
|
|
29790
|
+
const path15 = paths[i];
|
|
29791
|
+
if (path15.isLogicalExpression()) {
|
|
29792
|
+
if (path15.node.operator === "&&") {
|
|
29793
|
+
paths.push(path15.get("left"));
|
|
29794
|
+
paths.push(path15.get("right"));
|
|
29795
|
+
}
|
|
29796
|
+
} else if (path15.isBinaryExpression()) {
|
|
29797
|
+
const type = inferAnnotationFromBinaryExpression(name, path15);
|
|
29798
29798
|
if (type) types.push(type);
|
|
29799
29799
|
}
|
|
29800
29800
|
}
|
|
@@ -30615,12 +30615,12 @@ var require_hoister = __commonJS({
|
|
|
30615
30615
|
variableDeclarator
|
|
30616
30616
|
} = _t2;
|
|
30617
30617
|
var referenceVisitor = {
|
|
30618
|
-
ReferencedIdentifier(
|
|
30619
|
-
if (
|
|
30618
|
+
ReferencedIdentifier(path14, state) {
|
|
30619
|
+
if (path14.isJSXIdentifier() && react.isCompatTag(path14.node.name) && !path14.parentPath.isJSXMemberExpression()) {
|
|
30620
30620
|
return;
|
|
30621
30621
|
}
|
|
30622
|
-
if (
|
|
30623
|
-
let scope =
|
|
30622
|
+
if (path14.node.name === "this") {
|
|
30623
|
+
let scope = path14.scope;
|
|
30624
30624
|
do {
|
|
30625
30625
|
if (scope.path.isFunction() && !scope.path.isArrowFunctionExpression()) {
|
|
30626
30626
|
break;
|
|
@@ -30628,21 +30628,21 @@ var require_hoister = __commonJS({
|
|
|
30628
30628
|
} while (scope = scope.parent);
|
|
30629
30629
|
if (scope) state.breakOnScopePaths.push(scope.path);
|
|
30630
30630
|
}
|
|
30631
|
-
const binding =
|
|
30631
|
+
const binding = path14.scope.getBinding(path14.node.name);
|
|
30632
30632
|
if (!binding) return;
|
|
30633
30633
|
for (const violation of binding.constantViolations) {
|
|
30634
30634
|
if (violation.scope !== binding.path.scope) {
|
|
30635
30635
|
state.mutableBinding = true;
|
|
30636
|
-
|
|
30636
|
+
path14.stop();
|
|
30637
30637
|
return;
|
|
30638
30638
|
}
|
|
30639
30639
|
}
|
|
30640
|
-
if (binding !== state.scope.getBinding(
|
|
30641
|
-
state.bindings[
|
|
30640
|
+
if (binding !== state.scope.getBinding(path14.node.name)) return;
|
|
30641
|
+
state.bindings[path14.node.name] = binding;
|
|
30642
30642
|
}
|
|
30643
30643
|
};
|
|
30644
30644
|
var PathHoister = class {
|
|
30645
|
-
constructor(
|
|
30645
|
+
constructor(path14, scope) {
|
|
30646
30646
|
this.breakOnScopePaths = void 0;
|
|
30647
30647
|
this.bindings = void 0;
|
|
30648
30648
|
this.mutableBinding = void 0;
|
|
@@ -30655,7 +30655,7 @@ var require_hoister = __commonJS({
|
|
|
30655
30655
|
this.mutableBinding = false;
|
|
30656
30656
|
this.scopes = [];
|
|
30657
30657
|
this.scope = scope;
|
|
30658
|
-
this.path =
|
|
30658
|
+
this.path = path14;
|
|
30659
30659
|
this.attachAfter = false;
|
|
30660
30660
|
}
|
|
30661
30661
|
isCompatibleScope(scope) {
|
|
@@ -30681,11 +30681,11 @@ var require_hoister = __commonJS({
|
|
|
30681
30681
|
} while (scope = scope.parent);
|
|
30682
30682
|
}
|
|
30683
30683
|
getAttachmentPath() {
|
|
30684
|
-
let
|
|
30685
|
-
if (!
|
|
30686
|
-
let targetScope =
|
|
30687
|
-
if (targetScope.path ===
|
|
30688
|
-
targetScope =
|
|
30684
|
+
let path14 = this._getAttachmentPath();
|
|
30685
|
+
if (!path14) return;
|
|
30686
|
+
let targetScope = path14.scope;
|
|
30687
|
+
if (targetScope.path === path14) {
|
|
30688
|
+
targetScope = path14.scope.parent;
|
|
30689
30689
|
}
|
|
30690
30690
|
if (targetScope.path.isProgram() || targetScope.path.isFunction()) {
|
|
30691
30691
|
for (const name of Object.keys(this.bindings)) {
|
|
@@ -30695,18 +30695,18 @@ var require_hoister = __commonJS({
|
|
|
30695
30695
|
continue;
|
|
30696
30696
|
}
|
|
30697
30697
|
const bindingParentPath = this.getAttachmentParentForPath(binding.path);
|
|
30698
|
-
if (bindingParentPath.key >=
|
|
30698
|
+
if (bindingParentPath.key >= path14.key) {
|
|
30699
30699
|
this.attachAfter = true;
|
|
30700
|
-
|
|
30700
|
+
path14 = binding.path;
|
|
30701
30701
|
for (const violationPath of binding.constantViolations) {
|
|
30702
|
-
if (this.getAttachmentParentForPath(violationPath).key >
|
|
30703
|
-
|
|
30702
|
+
if (this.getAttachmentParentForPath(violationPath).key > path14.key) {
|
|
30703
|
+
path14 = violationPath;
|
|
30704
30704
|
}
|
|
30705
30705
|
}
|
|
30706
30706
|
}
|
|
30707
30707
|
}
|
|
30708
30708
|
}
|
|
30709
|
-
return
|
|
30709
|
+
return path14;
|
|
30710
30710
|
}
|
|
30711
30711
|
_getAttachmentPath() {
|
|
30712
30712
|
const scopes = this.scopes;
|
|
@@ -30731,13 +30731,13 @@ var require_hoister = __commonJS({
|
|
|
30731
30731
|
const scope = this.scopes.pop();
|
|
30732
30732
|
if (scope) return this.getAttachmentParentForPath(scope.path);
|
|
30733
30733
|
}
|
|
30734
|
-
getAttachmentParentForPath(
|
|
30734
|
+
getAttachmentParentForPath(path14) {
|
|
30735
30735
|
do {
|
|
30736
|
-
if (!
|
|
30737
|
-
return
|
|
30736
|
+
if (!path14.parentPath || Array.isArray(path14.container) && path14.isStatement()) {
|
|
30737
|
+
return path14;
|
|
30738
30738
|
}
|
|
30739
|
-
} while (
|
|
30740
|
-
return
|
|
30739
|
+
} while (path14 = path14.parentPath);
|
|
30740
|
+
return path14;
|
|
30741
30741
|
}
|
|
30742
30742
|
hasOwnParamBindings(scope) {
|
|
30743
30743
|
for (const name of Object.keys(this.bindings)) {
|
|
@@ -30839,18 +30839,18 @@ var require_modification = __commonJS({
|
|
|
30839
30839
|
for (let i = 0; i < nodes.length; i++) {
|
|
30840
30840
|
var _this$context;
|
|
30841
30841
|
const to = from + i;
|
|
30842
|
-
const
|
|
30843
|
-
paths.push(
|
|
30842
|
+
const path14 = this.getSibling(to);
|
|
30843
|
+
paths.push(path14);
|
|
30844
30844
|
if ((_this$context = this.context) != null && _this$context.queue) {
|
|
30845
|
-
_context.pushContext.call(
|
|
30845
|
+
_context.pushContext.call(path14, this.context);
|
|
30846
30846
|
}
|
|
30847
30847
|
}
|
|
30848
30848
|
const contexts = _context._getQueueContexts.call(this);
|
|
30849
|
-
for (const
|
|
30850
|
-
_context.setScope.call(
|
|
30851
|
-
|
|
30849
|
+
for (const path14 of paths) {
|
|
30850
|
+
_context.setScope.call(path14);
|
|
30851
|
+
path14.debug("Inserted.");
|
|
30852
30852
|
for (const context of contexts) {
|
|
30853
|
-
context.maybeQueue(
|
|
30853
|
+
context.maybeQueue(path14, true);
|
|
30854
30854
|
}
|
|
30855
30855
|
}
|
|
30856
30856
|
return paths;
|
|
@@ -30862,8 +30862,8 @@ var require_modification = __commonJS({
|
|
|
30862
30862
|
return _containerInsert.call(this, this.key + 1, nodes);
|
|
30863
30863
|
}
|
|
30864
30864
|
var last = (arr) => arr[arr.length - 1];
|
|
30865
|
-
function isHiddenInSequenceExpression(
|
|
30866
|
-
return isSequenceExpression(
|
|
30865
|
+
function isHiddenInSequenceExpression(path14) {
|
|
30866
|
+
return isSequenceExpression(path14.parent) && (last(path14.parent.expressions) !== path14.node || isHiddenInSequenceExpression(path14.parentPath));
|
|
30867
30867
|
}
|
|
30868
30868
|
function isAlmostConstantAssignment(node, scope) {
|
|
30869
30869
|
if (!isAssignmentExpression(node) || !isIdentifier(node.left)) {
|
|
@@ -30937,9 +30937,9 @@ var require_modification = __commonJS({
|
|
|
30937
30937
|
if (!this.parent) return;
|
|
30938
30938
|
const paths = (0, _cache.getCachedPaths)(this);
|
|
30939
30939
|
if (!paths) return;
|
|
30940
|
-
for (const [,
|
|
30941
|
-
if (typeof
|
|
30942
|
-
|
|
30940
|
+
for (const [, path14] of paths) {
|
|
30941
|
+
if (typeof path14.key === "number" && path14.container === this.container && path14.key >= fromIndex) {
|
|
30942
|
+
path14.key += incrementBy;
|
|
30943
30943
|
}
|
|
30944
30944
|
}
|
|
30945
30945
|
}
|
|
@@ -30973,27 +30973,27 @@ var require_modification = __commonJS({
|
|
|
30973
30973
|
_removal._assertUnremoved.call(this);
|
|
30974
30974
|
const verifiedNodes = _verifyNodeList.call(this, nodes);
|
|
30975
30975
|
const container = this.node[listKey];
|
|
30976
|
-
const
|
|
30976
|
+
const path14 = _index.default.get({
|
|
30977
30977
|
parentPath: this,
|
|
30978
30978
|
parent: this.node,
|
|
30979
30979
|
container,
|
|
30980
30980
|
listKey,
|
|
30981
30981
|
key: 0
|
|
30982
30982
|
}).setContext(this.context);
|
|
30983
|
-
return _containerInsertBefore.call(
|
|
30983
|
+
return _containerInsertBefore.call(path14, verifiedNodes);
|
|
30984
30984
|
}
|
|
30985
30985
|
function pushContainer(listKey, nodes) {
|
|
30986
30986
|
_removal._assertUnremoved.call(this);
|
|
30987
30987
|
const verifiedNodes = _verifyNodeList.call(this, nodes);
|
|
30988
30988
|
const container = this.node[listKey];
|
|
30989
|
-
const
|
|
30989
|
+
const path14 = _index.default.get({
|
|
30990
30990
|
parentPath: this,
|
|
30991
30991
|
parent: this.node,
|
|
30992
30992
|
container,
|
|
30993
30993
|
listKey,
|
|
30994
30994
|
key: container.length
|
|
30995
30995
|
}).setContext(this.context);
|
|
30996
|
-
return
|
|
30996
|
+
return path14.replaceWithMultiple(verifiedNodes);
|
|
30997
30997
|
}
|
|
30998
30998
|
exports.hoist = function hoist(scope = this.scope) {
|
|
30999
30999
|
const hoister = new _hoister.default(this, scope);
|
|
@@ -45763,9 +45763,9 @@ var require_replacement = __commonJS({
|
|
|
45763
45763
|
id
|
|
45764
45764
|
}));
|
|
45765
45765
|
const completionRecords = callee.getCompletionRecords();
|
|
45766
|
-
for (const
|
|
45767
|
-
if (!
|
|
45768
|
-
const loop =
|
|
45766
|
+
for (const path14 of completionRecords) {
|
|
45767
|
+
if (!path14.isExpressionStatement()) continue;
|
|
45768
|
+
const loop = path14.findParent((path15) => path15.isLoop());
|
|
45769
45769
|
if (loop) {
|
|
45770
45770
|
let uid = loop.getData("expressionReplacementReturnUid");
|
|
45771
45771
|
if (!uid) {
|
|
@@ -45775,9 +45775,9 @@ var require_replacement = __commonJS({
|
|
|
45775
45775
|
} else {
|
|
45776
45776
|
uid = identifier(uid.name);
|
|
45777
45777
|
}
|
|
45778
|
-
|
|
45778
|
+
path14.get("expression").replaceWith(assignmentExpression("=", cloneNode(uid), path14.node.expression));
|
|
45779
45779
|
} else {
|
|
45780
|
-
|
|
45780
|
+
path14.replaceWith(returnStatement(path14.node.expression));
|
|
45781
45781
|
}
|
|
45782
45782
|
}
|
|
45783
45783
|
callee.arrowFunctionToExpression();
|
|
@@ -45886,16 +45886,16 @@ var require_evaluation = __commonJS({
|
|
|
45886
45886
|
const res = this.evaluate();
|
|
45887
45887
|
if (res.confident) return !!res.value;
|
|
45888
45888
|
}
|
|
45889
|
-
function deopt(
|
|
45889
|
+
function deopt(path14, state) {
|
|
45890
45890
|
if (!state.confident) return;
|
|
45891
|
-
state.deoptPath =
|
|
45891
|
+
state.deoptPath = path14;
|
|
45892
45892
|
state.confident = false;
|
|
45893
45893
|
}
|
|
45894
45894
|
var Globals = /* @__PURE__ */ new Map([["undefined", void 0], ["Infinity", Infinity], ["NaN", NaN]]);
|
|
45895
|
-
function evaluateCached(
|
|
45895
|
+
function evaluateCached(path14, state) {
|
|
45896
45896
|
const {
|
|
45897
45897
|
node
|
|
45898
|
-
} =
|
|
45898
|
+
} = path14;
|
|
45899
45899
|
const {
|
|
45900
45900
|
seen
|
|
45901
45901
|
} = state;
|
|
@@ -45904,7 +45904,7 @@ var require_evaluation = __commonJS({
|
|
|
45904
45904
|
if (existing.resolved) {
|
|
45905
45905
|
return existing.value;
|
|
45906
45906
|
} else {
|
|
45907
|
-
deopt(
|
|
45907
|
+
deopt(path14, state);
|
|
45908
45908
|
return;
|
|
45909
45909
|
}
|
|
45910
45910
|
} else {
|
|
@@ -45912,7 +45912,7 @@ var require_evaluation = __commonJS({
|
|
|
45912
45912
|
resolved: false
|
|
45913
45913
|
};
|
|
45914
45914
|
seen.set(node, item);
|
|
45915
|
-
const val = _evaluate(
|
|
45915
|
+
const val = _evaluate(path14, state);
|
|
45916
45916
|
if (state.confident) {
|
|
45917
45917
|
item.resolved = true;
|
|
45918
45918
|
item.value = val;
|
|
@@ -45920,55 +45920,55 @@ var require_evaluation = __commonJS({
|
|
|
45920
45920
|
return val;
|
|
45921
45921
|
}
|
|
45922
45922
|
}
|
|
45923
|
-
function _evaluate(
|
|
45923
|
+
function _evaluate(path14, state) {
|
|
45924
45924
|
if (!state.confident) return;
|
|
45925
|
-
if (
|
|
45926
|
-
const exprs =
|
|
45925
|
+
if (path14.isSequenceExpression()) {
|
|
45926
|
+
const exprs = path14.get("expressions");
|
|
45927
45927
|
return evaluateCached(exprs[exprs.length - 1], state);
|
|
45928
45928
|
}
|
|
45929
|
-
if (
|
|
45930
|
-
return
|
|
45929
|
+
if (path14.isStringLiteral() || path14.isNumericLiteral() || path14.isBooleanLiteral()) {
|
|
45930
|
+
return path14.node.value;
|
|
45931
45931
|
}
|
|
45932
|
-
if (
|
|
45932
|
+
if (path14.isNullLiteral()) {
|
|
45933
45933
|
return null;
|
|
45934
45934
|
}
|
|
45935
|
-
if (
|
|
45936
|
-
return evaluateQuasis(
|
|
45935
|
+
if (path14.isTemplateLiteral()) {
|
|
45936
|
+
return evaluateQuasis(path14, path14.node.quasis, state);
|
|
45937
45937
|
}
|
|
45938
|
-
if (
|
|
45939
|
-
const object =
|
|
45938
|
+
if (path14.isTaggedTemplateExpression() && path14.get("tag").isMemberExpression()) {
|
|
45939
|
+
const object = path14.get("tag.object");
|
|
45940
45940
|
const {
|
|
45941
45941
|
node: {
|
|
45942
45942
|
name
|
|
45943
45943
|
}
|
|
45944
45944
|
} = object;
|
|
45945
|
-
const property =
|
|
45946
|
-
if (object.isIdentifier() && name === "String" && !
|
|
45947
|
-
return evaluateQuasis(
|
|
45945
|
+
const property = path14.get("tag.property");
|
|
45946
|
+
if (object.isIdentifier() && name === "String" && !path14.scope.getBinding(name) && property.isIdentifier() && property.node.name === "raw") {
|
|
45947
|
+
return evaluateQuasis(path14, path14.node.quasi.quasis, state, true);
|
|
45948
45948
|
}
|
|
45949
45949
|
}
|
|
45950
|
-
if (
|
|
45951
|
-
const testResult = evaluateCached(
|
|
45950
|
+
if (path14.isConditionalExpression()) {
|
|
45951
|
+
const testResult = evaluateCached(path14.get("test"), state);
|
|
45952
45952
|
if (!state.confident) return;
|
|
45953
45953
|
if (testResult) {
|
|
45954
|
-
return evaluateCached(
|
|
45954
|
+
return evaluateCached(path14.get("consequent"), state);
|
|
45955
45955
|
} else {
|
|
45956
|
-
return evaluateCached(
|
|
45956
|
+
return evaluateCached(path14.get("alternate"), state);
|
|
45957
45957
|
}
|
|
45958
45958
|
}
|
|
45959
|
-
if (
|
|
45960
|
-
return evaluateCached(
|
|
45959
|
+
if (path14.isExpressionWrapper()) {
|
|
45960
|
+
return evaluateCached(path14.get("expression"), state);
|
|
45961
45961
|
}
|
|
45962
|
-
if (
|
|
45963
|
-
callee:
|
|
45962
|
+
if (path14.isMemberExpression() && !path14.parentPath.isCallExpression({
|
|
45963
|
+
callee: path14.node
|
|
45964
45964
|
})) {
|
|
45965
|
-
const property =
|
|
45966
|
-
const object =
|
|
45965
|
+
const property = path14.get("property");
|
|
45966
|
+
const object = path14.get("object");
|
|
45967
45967
|
if (object.isLiteral()) {
|
|
45968
45968
|
const value = object.node.value;
|
|
45969
45969
|
const type = typeof value;
|
|
45970
45970
|
let key = null;
|
|
45971
|
-
if (
|
|
45971
|
+
if (path14.node.computed) {
|
|
45972
45972
|
key = evaluateCached(property, state);
|
|
45973
45973
|
if (!state.confident) return;
|
|
45974
45974
|
} else if (property.isIdentifier()) {
|
|
@@ -45979,10 +45979,10 @@ var require_evaluation = __commonJS({
|
|
|
45979
45979
|
}
|
|
45980
45980
|
}
|
|
45981
45981
|
}
|
|
45982
|
-
if (
|
|
45983
|
-
const binding =
|
|
45982
|
+
if (path14.isReferencedIdentifier()) {
|
|
45983
|
+
const binding = path14.scope.getBinding(path14.node.name);
|
|
45984
45984
|
if (binding) {
|
|
45985
|
-
if (binding.constantViolations.length > 0 ||
|
|
45985
|
+
if (binding.constantViolations.length > 0 || path14.node.start < binding.path.node.end) {
|
|
45986
45986
|
deopt(binding.path, state);
|
|
45987
45987
|
return;
|
|
45988
45988
|
}
|
|
@@ -45991,7 +45991,7 @@ var require_evaluation = __commonJS({
|
|
|
45991
45991
|
let hasUnsafeBlock = !bindingPathScope.path.parentPath.isBlockStatement();
|
|
45992
45992
|
for (let scope = bindingPathScope.parent; scope; scope = scope.parent) {
|
|
45993
45993
|
var _scope$path$parentPat;
|
|
45994
|
-
if (scope ===
|
|
45994
|
+
if (scope === path14.scope) {
|
|
45995
45995
|
if (hasUnsafeBlock) {
|
|
45996
45996
|
deopt(binding.path, state);
|
|
45997
45997
|
return;
|
|
@@ -46007,7 +46007,7 @@ var require_evaluation = __commonJS({
|
|
|
46007
46007
|
return binding.value;
|
|
46008
46008
|
}
|
|
46009
46009
|
}
|
|
46010
|
-
const name =
|
|
46010
|
+
const name = path14.node.name;
|
|
46011
46011
|
if (Globals.has(name)) {
|
|
46012
46012
|
if (!binding) {
|
|
46013
46013
|
return Globals.get(name);
|
|
@@ -46016,7 +46016,7 @@ var require_evaluation = __commonJS({
|
|
|
46016
46016
|
return;
|
|
46017
46017
|
}
|
|
46018
46018
|
if (!binding) {
|
|
46019
|
-
deopt(
|
|
46019
|
+
deopt(path14, state);
|
|
46020
46020
|
return;
|
|
46021
46021
|
}
|
|
46022
46022
|
const bindingPath = binding.path;
|
|
@@ -46037,19 +46037,19 @@ var require_evaluation = __commonJS({
|
|
|
46037
46037
|
}
|
|
46038
46038
|
return value;
|
|
46039
46039
|
}
|
|
46040
|
-
if (
|
|
46040
|
+
if (path14.isUnaryExpression({
|
|
46041
46041
|
prefix: true
|
|
46042
46042
|
})) {
|
|
46043
|
-
if (
|
|
46043
|
+
if (path14.node.operator === "void") {
|
|
46044
46044
|
return void 0;
|
|
46045
46045
|
}
|
|
46046
|
-
const argument =
|
|
46047
|
-
if (
|
|
46046
|
+
const argument = path14.get("argument");
|
|
46047
|
+
if (path14.node.operator === "typeof" && (argument.isFunction() || argument.isClass())) {
|
|
46048
46048
|
return "function";
|
|
46049
46049
|
}
|
|
46050
46050
|
const arg = evaluateCached(argument, state);
|
|
46051
46051
|
if (!state.confident) return;
|
|
46052
|
-
switch (
|
|
46052
|
+
switch (path14.node.operator) {
|
|
46053
46053
|
case "!":
|
|
46054
46054
|
return !arg;
|
|
46055
46055
|
case "+":
|
|
@@ -46062,9 +46062,9 @@ var require_evaluation = __commonJS({
|
|
|
46062
46062
|
return typeof arg;
|
|
46063
46063
|
}
|
|
46064
46064
|
}
|
|
46065
|
-
if (
|
|
46065
|
+
if (path14.isArrayExpression()) {
|
|
46066
46066
|
const arr = [];
|
|
46067
|
-
const elems =
|
|
46067
|
+
const elems = path14.get("elements");
|
|
46068
46068
|
for (const elem of elems) {
|
|
46069
46069
|
const elemValue = elem.evaluate();
|
|
46070
46070
|
if (elemValue.confident) {
|
|
@@ -46076,9 +46076,9 @@ var require_evaluation = __commonJS({
|
|
|
46076
46076
|
}
|
|
46077
46077
|
return arr;
|
|
46078
46078
|
}
|
|
46079
|
-
if (
|
|
46079
|
+
if (path14.isObjectExpression()) {
|
|
46080
46080
|
const obj = {};
|
|
46081
|
-
const props =
|
|
46081
|
+
const props = path14.get("properties");
|
|
46082
46082
|
for (const prop of props) {
|
|
46083
46083
|
if (prop.isObjectMethod() || prop.isSpreadElement()) {
|
|
46084
46084
|
deopt(prop, state);
|
|
@@ -46109,14 +46109,14 @@ var require_evaluation = __commonJS({
|
|
|
46109
46109
|
}
|
|
46110
46110
|
return obj;
|
|
46111
46111
|
}
|
|
46112
|
-
if (
|
|
46112
|
+
if (path14.isLogicalExpression()) {
|
|
46113
46113
|
const wasConfident = state.confident;
|
|
46114
|
-
const left = evaluateCached(
|
|
46114
|
+
const left = evaluateCached(path14.get("left"), state);
|
|
46115
46115
|
const leftConfident = state.confident;
|
|
46116
46116
|
state.confident = wasConfident;
|
|
46117
|
-
const right = evaluateCached(
|
|
46117
|
+
const right = evaluateCached(path14.get("right"), state);
|
|
46118
46118
|
const rightConfident = state.confident;
|
|
46119
|
-
switch (
|
|
46119
|
+
switch (path14.node.operator) {
|
|
46120
46120
|
case "||":
|
|
46121
46121
|
state.confident = leftConfident && (!!left || rightConfident);
|
|
46122
46122
|
if (!state.confident) return;
|
|
@@ -46131,12 +46131,12 @@ var require_evaluation = __commonJS({
|
|
|
46131
46131
|
return left != null ? left : right;
|
|
46132
46132
|
}
|
|
46133
46133
|
}
|
|
46134
|
-
if (
|
|
46135
|
-
const left = evaluateCached(
|
|
46134
|
+
if (path14.isBinaryExpression()) {
|
|
46135
|
+
const left = evaluateCached(path14.get("left"), state);
|
|
46136
46136
|
if (!state.confident) return;
|
|
46137
|
-
const right = evaluateCached(
|
|
46137
|
+
const right = evaluateCached(path14.get("right"), state);
|
|
46138
46138
|
if (!state.confident) return;
|
|
46139
|
-
switch (
|
|
46139
|
+
switch (path14.node.operator) {
|
|
46140
46140
|
case "-":
|
|
46141
46141
|
return left - right;
|
|
46142
46142
|
case "+":
|
|
@@ -46179,11 +46179,11 @@ var require_evaluation = __commonJS({
|
|
|
46179
46179
|
return left >>> right;
|
|
46180
46180
|
}
|
|
46181
46181
|
}
|
|
46182
|
-
if (
|
|
46183
|
-
const callee =
|
|
46182
|
+
if (path14.isCallExpression()) {
|
|
46183
|
+
const callee = path14.get("callee");
|
|
46184
46184
|
let context;
|
|
46185
46185
|
let func;
|
|
46186
|
-
if (callee.isIdentifier() && !
|
|
46186
|
+
if (callee.isIdentifier() && !path14.scope.getBinding(callee.node.name) && (isValidObjectCallee(callee.node.name) || isValidIdentifierCallee(callee.node.name))) {
|
|
46187
46187
|
func = global[callee.node.name];
|
|
46188
46188
|
}
|
|
46189
46189
|
if (callee.isMemberExpression()) {
|
|
@@ -46205,17 +46205,17 @@ var require_evaluation = __commonJS({
|
|
|
46205
46205
|
}
|
|
46206
46206
|
}
|
|
46207
46207
|
if (func) {
|
|
46208
|
-
const args =
|
|
46208
|
+
const args = path14.get("arguments").map((arg) => evaluateCached(arg, state));
|
|
46209
46209
|
if (!state.confident) return;
|
|
46210
46210
|
return func.apply(context, args);
|
|
46211
46211
|
}
|
|
46212
46212
|
}
|
|
46213
|
-
deopt(
|
|
46213
|
+
deopt(path14, state);
|
|
46214
46214
|
}
|
|
46215
|
-
function evaluateQuasis(
|
|
46215
|
+
function evaluateQuasis(path14, quasis, state, raw = false) {
|
|
46216
46216
|
let str = "";
|
|
46217
46217
|
let i = 0;
|
|
46218
|
-
const exprs =
|
|
46218
|
+
const exprs = path14.isTemplateLiteral() ? path14.get("expressions") : path14.get("quasi.expressions");
|
|
46219
46219
|
for (const elem of quasis) {
|
|
46220
46220
|
if (!state.confident) break;
|
|
46221
46221
|
str += raw ? elem.value.raw : elem.value.cooked;
|
|
@@ -47009,8 +47009,8 @@ var require_conversion = __commonJS({
|
|
|
47009
47009
|
}
|
|
47010
47010
|
hoistFunctionEnvironment(this);
|
|
47011
47011
|
}
|
|
47012
|
-
function setType(
|
|
47013
|
-
|
|
47012
|
+
function setType(path14, type) {
|
|
47013
|
+
path14.node.type = type;
|
|
47014
47014
|
}
|
|
47015
47015
|
function arrowFunctionToExpression({
|
|
47016
47016
|
allowInsertArrow = true,
|
|
@@ -47425,14 +47425,14 @@ var require_conversion = __commonJS({
|
|
|
47425
47425
|
return this;
|
|
47426
47426
|
}
|
|
47427
47427
|
var refersOuterBindingVisitor = {
|
|
47428
|
-
"ReferencedIdentifier|BindingIdentifier"(
|
|
47429
|
-
if (
|
|
47428
|
+
"ReferencedIdentifier|BindingIdentifier"(path14, state) {
|
|
47429
|
+
if (path14.node.name !== state.name) return;
|
|
47430
47430
|
state.needsRename = true;
|
|
47431
|
-
|
|
47431
|
+
path14.stop();
|
|
47432
47432
|
},
|
|
47433
|
-
Scope(
|
|
47434
|
-
if (
|
|
47435
|
-
|
|
47433
|
+
Scope(path14, state) {
|
|
47434
|
+
if (path14.scope.hasOwnBinding(state.name)) {
|
|
47435
|
+
path14.skip();
|
|
47436
47436
|
}
|
|
47437
47437
|
}
|
|
47438
47438
|
};
|
|
@@ -47581,21 +47581,21 @@ var require_introspection = __commonJS({
|
|
|
47581
47581
|
return false;
|
|
47582
47582
|
}
|
|
47583
47583
|
function isCompletionRecord(allowInsideFunction) {
|
|
47584
|
-
let
|
|
47584
|
+
let path14 = this;
|
|
47585
47585
|
let first = true;
|
|
47586
47586
|
do {
|
|
47587
47587
|
const {
|
|
47588
47588
|
type,
|
|
47589
47589
|
container
|
|
47590
|
-
} =
|
|
47591
|
-
if (!first && (
|
|
47590
|
+
} = path14;
|
|
47591
|
+
if (!first && (path14.isFunction() || type === "StaticBlock")) {
|
|
47592
47592
|
return !!allowInsideFunction;
|
|
47593
47593
|
}
|
|
47594
47594
|
first = false;
|
|
47595
|
-
if (Array.isArray(container) &&
|
|
47595
|
+
if (Array.isArray(container) && path14.key !== container.length - 1) {
|
|
47596
47596
|
return false;
|
|
47597
47597
|
}
|
|
47598
|
-
} while ((
|
|
47598
|
+
} while ((path14 = path14.parentPath) && !path14.isProgram() && !path14.isDoExpression());
|
|
47599
47599
|
return true;
|
|
47600
47600
|
}
|
|
47601
47601
|
function isStatementOrBlock() {
|
|
@@ -47617,21 +47617,21 @@ var require_introspection = __commonJS({
|
|
|
47617
47617
|
}
|
|
47618
47618
|
const binding = this.scope.getBinding(this.node.name);
|
|
47619
47619
|
if ((binding == null ? void 0 : binding.kind) !== "module") return false;
|
|
47620
|
-
const
|
|
47621
|
-
const parent =
|
|
47620
|
+
const path14 = binding.path;
|
|
47621
|
+
const parent = path14.parentPath;
|
|
47622
47622
|
if (!parent.isImportDeclaration()) return false;
|
|
47623
47623
|
if (parent.node.source.value === moduleSource) {
|
|
47624
47624
|
if (!importName) return true;
|
|
47625
47625
|
} else {
|
|
47626
47626
|
return false;
|
|
47627
47627
|
}
|
|
47628
|
-
if (
|
|
47628
|
+
if (path14.isImportDefaultSpecifier() && importName === "default") {
|
|
47629
47629
|
return true;
|
|
47630
47630
|
}
|
|
47631
|
-
if (
|
|
47631
|
+
if (path14.isImportNamespaceSpecifier() && importName === "*") {
|
|
47632
47632
|
return true;
|
|
47633
47633
|
}
|
|
47634
|
-
if (
|
|
47634
|
+
if (path14.isImportSpecifier() && isIdentifier(path14.node.imported, {
|
|
47635
47635
|
name: importName
|
|
47636
47636
|
})) {
|
|
47637
47637
|
return true;
|
|
@@ -47649,8 +47649,8 @@ var require_introspection = __commonJS({
|
|
|
47649
47649
|
function willIMaybeExecuteBefore(target) {
|
|
47650
47650
|
return this._guessExecutionStatusRelativeTo(target) !== "after";
|
|
47651
47651
|
}
|
|
47652
|
-
function getOuterFunction(
|
|
47653
|
-
return
|
|
47652
|
+
function getOuterFunction(path14) {
|
|
47653
|
+
return path14.isProgram() ? path14 : (path14.parentPath.scope.getFunctionParent() || path14.parentPath.scope.getProgramParent()).path;
|
|
47654
47654
|
}
|
|
47655
47655
|
function isExecutionUncertain(type, key) {
|
|
47656
47656
|
switch (type) {
|
|
@@ -47682,8 +47682,8 @@ var require_introspection = __commonJS({
|
|
|
47682
47682
|
}
|
|
47683
47683
|
function isExecutionUncertainInList(paths, maxIndex) {
|
|
47684
47684
|
for (let i = 0; i < maxIndex; i++) {
|
|
47685
|
-
const
|
|
47686
|
-
if (isExecutionUncertain(
|
|
47685
|
+
const path14 = paths[i];
|
|
47686
|
+
if (isExecutionUncertain(path14.parent.type, path14.parentKey)) {
|
|
47687
47687
|
return true;
|
|
47688
47688
|
}
|
|
47689
47689
|
}
|
|
@@ -47713,10 +47713,10 @@ var require_introspection = __commonJS({
|
|
|
47713
47713
|
this: 0
|
|
47714
47714
|
};
|
|
47715
47715
|
while (!commonPath && commonIndex.this < paths.this.length) {
|
|
47716
|
-
const
|
|
47717
|
-
commonIndex.target = paths.target.indexOf(
|
|
47716
|
+
const path14 = paths.this[commonIndex.this];
|
|
47717
|
+
commonIndex.target = paths.target.indexOf(path14);
|
|
47718
47718
|
if (commonIndex.target >= 0) {
|
|
47719
|
-
commonPath =
|
|
47719
|
+
commonPath = path14;
|
|
47720
47720
|
} else {
|
|
47721
47721
|
commonIndex.this++;
|
|
47722
47722
|
}
|
|
@@ -47754,13 +47754,13 @@ var require_introspection = __commonJS({
|
|
|
47754
47754
|
if (!binding.references) return "before";
|
|
47755
47755
|
const referencePaths = binding.referencePaths;
|
|
47756
47756
|
let allStatus;
|
|
47757
|
-
for (const
|
|
47758
|
-
const childOfFunction = !!
|
|
47757
|
+
for (const path14 of referencePaths) {
|
|
47758
|
+
const childOfFunction = !!path14.find((path15) => path15.node === target.node);
|
|
47759
47759
|
if (childOfFunction) continue;
|
|
47760
|
-
if (
|
|
47760
|
+
if (path14.key !== "callee" || !path14.parentPath.isCallExpression()) {
|
|
47761
47761
|
return "unknown";
|
|
47762
47762
|
}
|
|
47763
|
-
const status = _guessExecutionStatusRelativeToCached(base,
|
|
47763
|
+
const status = _guessExecutionStatusRelativeToCached(base, path14, cache);
|
|
47764
47764
|
if (allStatus && allStatus !== status) {
|
|
47765
47765
|
return "unknown";
|
|
47766
47766
|
} else {
|
|
@@ -47878,19 +47878,19 @@ var require_introspection = __commonJS({
|
|
|
47878
47878
|
}
|
|
47879
47879
|
function isInStrictMode() {
|
|
47880
47880
|
const start = this.isProgram() ? this : this.parentPath;
|
|
47881
|
-
const strictParent = start.find((
|
|
47882
|
-
if (
|
|
47881
|
+
const strictParent = start.find((path14) => {
|
|
47882
|
+
if (path14.isProgram({
|
|
47883
47883
|
sourceType: "module"
|
|
47884
47884
|
})) return true;
|
|
47885
|
-
if (
|
|
47886
|
-
if (
|
|
47885
|
+
if (path14.isClass()) return true;
|
|
47886
|
+
if (path14.isArrowFunctionExpression() && !path14.get("body").isBlockStatement()) {
|
|
47887
47887
|
return false;
|
|
47888
47888
|
}
|
|
47889
47889
|
let body;
|
|
47890
|
-
if (
|
|
47891
|
-
body =
|
|
47892
|
-
} else if (
|
|
47893
|
-
body =
|
|
47890
|
+
if (path14.isFunction()) {
|
|
47891
|
+
body = path14.node.body;
|
|
47892
|
+
} else if (path14.isProgram()) {
|
|
47893
|
+
body = path14.node;
|
|
47894
47894
|
} else {
|
|
47895
47895
|
return false;
|
|
47896
47896
|
}
|
|
@@ -47939,16 +47939,16 @@ var require_family = __commonJS({
|
|
|
47939
47939
|
} = _t;
|
|
47940
47940
|
var NORMAL_COMPLETION = 0;
|
|
47941
47941
|
var BREAK_COMPLETION = 1;
|
|
47942
|
-
function NormalCompletion(
|
|
47942
|
+
function NormalCompletion(path14) {
|
|
47943
47943
|
return {
|
|
47944
47944
|
type: NORMAL_COMPLETION,
|
|
47945
|
-
path:
|
|
47945
|
+
path: path14
|
|
47946
47946
|
};
|
|
47947
47947
|
}
|
|
47948
|
-
function BreakCompletion(
|
|
47948
|
+
function BreakCompletion(path14) {
|
|
47949
47949
|
return {
|
|
47950
47950
|
type: BREAK_COMPLETION,
|
|
47951
|
-
path:
|
|
47951
|
+
path: path14
|
|
47952
47952
|
};
|
|
47953
47953
|
}
|
|
47954
47954
|
function getOpposite() {
|
|
@@ -47959,9 +47959,9 @@ var require_family = __commonJS({
|
|
|
47959
47959
|
}
|
|
47960
47960
|
return null;
|
|
47961
47961
|
}
|
|
47962
|
-
function addCompletionRecords(
|
|
47963
|
-
if (
|
|
47964
|
-
records.push(..._getCompletionRecords(
|
|
47962
|
+
function addCompletionRecords(path14, records, context) {
|
|
47963
|
+
if (path14) {
|
|
47964
|
+
records.push(..._getCompletionRecords(path14, context));
|
|
47965
47965
|
}
|
|
47966
47966
|
return records;
|
|
47967
47967
|
}
|
|
@@ -48011,16 +48011,16 @@ var require_family = __commonJS({
|
|
|
48011
48011
|
if (context.canHaveBreak) {
|
|
48012
48012
|
let lastNormalCompletions = [];
|
|
48013
48013
|
for (let i = 0; i < paths.length; i++) {
|
|
48014
|
-
const
|
|
48014
|
+
const path14 = paths[i];
|
|
48015
48015
|
const newContext = Object.assign({}, context, {
|
|
48016
48016
|
inCaseClause: false
|
|
48017
48017
|
});
|
|
48018
|
-
if (
|
|
48018
|
+
if (path14.isBlockStatement() && (context.inCaseClause || context.shouldPopulateBreak)) {
|
|
48019
48019
|
newContext.shouldPopulateBreak = true;
|
|
48020
48020
|
} else {
|
|
48021
48021
|
newContext.shouldPopulateBreak = false;
|
|
48022
48022
|
}
|
|
48023
|
-
const statementCompletions = _getCompletionRecords(
|
|
48023
|
+
const statementCompletions = _getCompletionRecords(path14, newContext);
|
|
48024
48024
|
if (statementCompletions.length > 0 && statementCompletions.every((c) => c.type === BREAK_COMPLETION)) {
|
|
48025
48025
|
if (lastNormalCompletions.length > 0 && statementCompletions.every((c) => c.path.isBreakStatement({
|
|
48026
48026
|
label: null
|
|
@@ -48070,35 +48070,35 @@ var require_family = __commonJS({
|
|
|
48070
48070
|
}
|
|
48071
48071
|
return completions;
|
|
48072
48072
|
}
|
|
48073
|
-
function _getCompletionRecords(
|
|
48073
|
+
function _getCompletionRecords(path14, context) {
|
|
48074
48074
|
let records = [];
|
|
48075
|
-
if (
|
|
48076
|
-
records = addCompletionRecords(
|
|
48077
|
-
records = addCompletionRecords(
|
|
48078
|
-
} else if (
|
|
48079
|
-
return addCompletionRecords(
|
|
48080
|
-
} else if (
|
|
48081
|
-
return getStatementListCompletion(
|
|
48082
|
-
} else if (
|
|
48083
|
-
return _getCompletionRecords(
|
|
48084
|
-
} else if (
|
|
48085
|
-
records = addCompletionRecords(
|
|
48086
|
-
records = addCompletionRecords(
|
|
48087
|
-
} else if (
|
|
48088
|
-
return addCompletionRecords(
|
|
48089
|
-
} else if (
|
|
48090
|
-
return completionRecordForSwitch(
|
|
48091
|
-
} else if (
|
|
48092
|
-
return getStatementListCompletion(
|
|
48075
|
+
if (path14.isIfStatement()) {
|
|
48076
|
+
records = addCompletionRecords(path14.get("consequent"), records, context);
|
|
48077
|
+
records = addCompletionRecords(path14.get("alternate"), records, context);
|
|
48078
|
+
} else if (path14.isDoExpression() || path14.isFor() || path14.isWhile() || path14.isLabeledStatement()) {
|
|
48079
|
+
return addCompletionRecords(path14.get("body"), records, context);
|
|
48080
|
+
} else if (path14.isProgram() || path14.isBlockStatement()) {
|
|
48081
|
+
return getStatementListCompletion(path14.get("body"), context);
|
|
48082
|
+
} else if (path14.isFunction()) {
|
|
48083
|
+
return _getCompletionRecords(path14.get("body"), context);
|
|
48084
|
+
} else if (path14.isTryStatement()) {
|
|
48085
|
+
records = addCompletionRecords(path14.get("block"), records, context);
|
|
48086
|
+
records = addCompletionRecords(path14.get("handler"), records, context);
|
|
48087
|
+
} else if (path14.isCatchClause()) {
|
|
48088
|
+
return addCompletionRecords(path14.get("body"), records, context);
|
|
48089
|
+
} else if (path14.isSwitchStatement()) {
|
|
48090
|
+
return completionRecordForSwitch(path14.get("cases"), records, context);
|
|
48091
|
+
} else if (path14.isSwitchCase()) {
|
|
48092
|
+
return getStatementListCompletion(path14.get("consequent"), {
|
|
48093
48093
|
canHaveBreak: true,
|
|
48094
48094
|
shouldPopulateBreak: false,
|
|
48095
48095
|
inCaseClause: true,
|
|
48096
48096
|
shouldPreserveBreak: context.shouldPreserveBreak
|
|
48097
48097
|
});
|
|
48098
|
-
} else if (
|
|
48099
|
-
records.push(BreakCompletion(
|
|
48098
|
+
} else if (path14.isBreakStatement()) {
|
|
48099
|
+
records.push(BreakCompletion(path14));
|
|
48100
48100
|
} else {
|
|
48101
|
-
records.push(NormalCompletion(
|
|
48101
|
+
records.push(NormalCompletion(path14));
|
|
48102
48102
|
}
|
|
48103
48103
|
return records;
|
|
48104
48104
|
}
|
|
@@ -48178,19 +48178,19 @@ var require_family = __commonJS({
|
|
|
48178
48178
|
}
|
|
48179
48179
|
}
|
|
48180
48180
|
function _getPattern(parts, context) {
|
|
48181
|
-
let
|
|
48181
|
+
let path14 = this;
|
|
48182
48182
|
for (const part of parts) {
|
|
48183
48183
|
if (part === ".") {
|
|
48184
|
-
|
|
48184
|
+
path14 = path14.parentPath;
|
|
48185
48185
|
} else {
|
|
48186
|
-
if (Array.isArray(
|
|
48187
|
-
|
|
48186
|
+
if (Array.isArray(path14)) {
|
|
48187
|
+
path14 = path14[part];
|
|
48188
48188
|
} else {
|
|
48189
|
-
|
|
48189
|
+
path14 = path14.get(part, context);
|
|
48190
48190
|
}
|
|
48191
48191
|
}
|
|
48192
48192
|
}
|
|
48193
|
-
return
|
|
48193
|
+
return path14;
|
|
48194
48194
|
}
|
|
48195
48195
|
function getAssignmentIdentifiers() {
|
|
48196
48196
|
return _getAssignmentIdentifiers(this.node);
|
|
@@ -48202,8 +48202,8 @@ var require_family = __commonJS({
|
|
|
48202
48202
|
return _getOuterBindingIdentifiers(this.node, duplicates);
|
|
48203
48203
|
}
|
|
48204
48204
|
function getBindingIdentifierPaths(duplicates = false, outerOnly = false) {
|
|
48205
|
-
const
|
|
48206
|
-
const search = [
|
|
48205
|
+
const path14 = this;
|
|
48206
|
+
const search = [path14];
|
|
48207
48207
|
const ids = /* @__PURE__ */ Object.create(null);
|
|
48208
48208
|
while (search.length) {
|
|
48209
48209
|
const id = search.shift();
|
|
@@ -48402,13 +48402,13 @@ var require_path2 = __commonJS({
|
|
|
48402
48402
|
}
|
|
48403
48403
|
const targetNode = container[key];
|
|
48404
48404
|
const paths = cache.getOrCreateCachedPaths(parent, parentPath);
|
|
48405
|
-
let
|
|
48406
|
-
if (!
|
|
48407
|
-
|
|
48408
|
-
if (targetNode) paths.set(targetNode,
|
|
48405
|
+
let path14 = paths.get(targetNode);
|
|
48406
|
+
if (!path14) {
|
|
48407
|
+
path14 = new NodePath(hub, parent);
|
|
48408
|
+
if (targetNode) paths.set(targetNode, path14);
|
|
48409
48409
|
}
|
|
48410
|
-
_context.setup.call(
|
|
48411
|
-
return
|
|
48410
|
+
_context.setup.call(path14, parentPath, container, listKey, key);
|
|
48411
|
+
return path14;
|
|
48412
48412
|
}
|
|
48413
48413
|
getScope(scope) {
|
|
48414
48414
|
return this.isScope() ? new _index2.default(this) : scope;
|
|
@@ -48442,12 +48442,12 @@ var require_path2 = __commonJS({
|
|
|
48442
48442
|
}
|
|
48443
48443
|
getPathLocation() {
|
|
48444
48444
|
const parts = [];
|
|
48445
|
-
let
|
|
48445
|
+
let path14 = this;
|
|
48446
48446
|
do {
|
|
48447
|
-
let key =
|
|
48448
|
-
if (
|
|
48447
|
+
let key = path14.key;
|
|
48448
|
+
if (path14.inList) key = `${path14.listKey}[${key}]`;
|
|
48449
48449
|
parts.unshift(key);
|
|
48450
|
-
} while (
|
|
48450
|
+
} while (path14 = path14.parentPath);
|
|
48451
48451
|
return parts.join(".");
|
|
48452
48452
|
}
|
|
48453
48453
|
debug(message) {
|
|
@@ -48679,12 +48679,12 @@ var require_context = __commonJS({
|
|
|
48679
48679
|
hub
|
|
48680
48680
|
});
|
|
48681
48681
|
}
|
|
48682
|
-
maybeQueue(
|
|
48682
|
+
maybeQueue(path14, notPriority) {
|
|
48683
48683
|
if (this.queue) {
|
|
48684
48684
|
if (notPriority) {
|
|
48685
|
-
this.queue.push(
|
|
48685
|
+
this.queue.push(path14);
|
|
48686
48686
|
} else {
|
|
48687
|
-
this.priorityQueue.push(
|
|
48687
|
+
this.priorityQueue.push(path14);
|
|
48688
48688
|
}
|
|
48689
48689
|
}
|
|
48690
48690
|
}
|
|
@@ -48713,19 +48713,19 @@ var require_context = __commonJS({
|
|
|
48713
48713
|
let stop = false;
|
|
48714
48714
|
let visitIndex = 0;
|
|
48715
48715
|
for (; visitIndex < queue.length; ) {
|
|
48716
|
-
const
|
|
48716
|
+
const path14 = queue[visitIndex];
|
|
48717
48717
|
visitIndex++;
|
|
48718
|
-
_context.resync.call(
|
|
48719
|
-
if (
|
|
48720
|
-
_context.pushContext.call(
|
|
48718
|
+
_context.resync.call(path14);
|
|
48719
|
+
if (path14.contexts.length === 0 || path14.contexts[path14.contexts.length - 1] !== this) {
|
|
48720
|
+
_context.pushContext.call(path14, this);
|
|
48721
48721
|
}
|
|
48722
|
-
if (
|
|
48722
|
+
if (path14.key === null) continue;
|
|
48723
48723
|
const {
|
|
48724
48724
|
node
|
|
48725
|
-
} =
|
|
48725
|
+
} = path14;
|
|
48726
48726
|
if (visited.has(node)) continue;
|
|
48727
48727
|
if (node) visited.add(node);
|
|
48728
|
-
if (
|
|
48728
|
+
if (path14.visit()) {
|
|
48729
48729
|
stop = true;
|
|
48730
48730
|
break;
|
|
48731
48731
|
}
|
|
@@ -48771,13 +48771,13 @@ var require_traverse_node = __commonJS({
|
|
|
48771
48771
|
var {
|
|
48772
48772
|
VISITOR_KEYS
|
|
48773
48773
|
} = _t;
|
|
48774
|
-
function traverseNode(node, opts, scope, state,
|
|
48774
|
+
function traverseNode(node, opts, scope, state, path14, skipKeys, visitSelf) {
|
|
48775
48775
|
const keys = VISITOR_KEYS[node.type];
|
|
48776
48776
|
if (!keys) return false;
|
|
48777
|
-
const context = new _context.default(scope, opts, state,
|
|
48777
|
+
const context = new _context.default(scope, opts, state, path14);
|
|
48778
48778
|
if (visitSelf) {
|
|
48779
|
-
if (skipKeys != null && skipKeys[
|
|
48780
|
-
return context.visitQueue([
|
|
48779
|
+
if (skipKeys != null && skipKeys[path14.parentKey]) return false;
|
|
48780
|
+
return context.visitQueue([path14]);
|
|
48781
48781
|
}
|
|
48782
48782
|
for (const key of keys) {
|
|
48783
48783
|
if (skipKeys != null && skipKeys[key]) continue;
|
|
@@ -48859,11 +48859,11 @@ var require_context2 = __commonJS({
|
|
|
48859
48859
|
return denylist == null ? void 0 : denylist.includes(this.node.type);
|
|
48860
48860
|
}
|
|
48861
48861
|
exports.isBlacklisted = isDenylisted;
|
|
48862
|
-
function restoreContext(
|
|
48863
|
-
if (
|
|
48864
|
-
|
|
48865
|
-
|
|
48866
|
-
|
|
48862
|
+
function restoreContext(path14, context) {
|
|
48863
|
+
if (path14.context !== context) {
|
|
48864
|
+
path14.context = context;
|
|
48865
|
+
path14.state = context.state;
|
|
48866
|
+
path14.opts = context.opts;
|
|
48867
48867
|
}
|
|
48868
48868
|
}
|
|
48869
48869
|
function visit() {
|
|
@@ -48903,14 +48903,14 @@ var require_context2 = __commonJS({
|
|
|
48903
48903
|
}
|
|
48904
48904
|
function _forceSetScope() {
|
|
48905
48905
|
var _this$scope;
|
|
48906
|
-
let
|
|
48907
|
-
if ((this.key === "key" || this.listKey === "decorators") &&
|
|
48908
|
-
|
|
48906
|
+
let path14 = this.parentPath;
|
|
48907
|
+
if ((this.key === "key" || this.listKey === "decorators") && path14.isMethod() || this.key === "discriminant" && path14.isSwitchStatement()) {
|
|
48908
|
+
path14 = path14.parentPath;
|
|
48909
48909
|
}
|
|
48910
48910
|
let target;
|
|
48911
|
-
while (
|
|
48912
|
-
target =
|
|
48913
|
-
|
|
48911
|
+
while (path14 && !target) {
|
|
48912
|
+
target = path14.scope;
|
|
48913
|
+
path14 = path14.parentPath;
|
|
48914
48914
|
}
|
|
48915
48915
|
this.scope = this.getScope(target);
|
|
48916
48916
|
(_this$scope = this.scope) == null || _this$scope.init();
|
|
@@ -48918,16 +48918,16 @@ var require_context2 = __commonJS({
|
|
|
48918
48918
|
function setScope() {
|
|
48919
48919
|
var _this$opts2, _this$scope2;
|
|
48920
48920
|
if ((_this$opts2 = this.opts) != null && _this$opts2.noScope) return;
|
|
48921
|
-
let
|
|
48922
|
-
if ((this.key === "key" || this.listKey === "decorators") &&
|
|
48923
|
-
|
|
48921
|
+
let path14 = this.parentPath;
|
|
48922
|
+
if ((this.key === "key" || this.listKey === "decorators") && path14.isMethod() || this.key === "discriminant" && path14.isSwitchStatement()) {
|
|
48923
|
+
path14 = path14.parentPath;
|
|
48924
48924
|
}
|
|
48925
48925
|
let target;
|
|
48926
|
-
while (
|
|
48926
|
+
while (path14 && !target) {
|
|
48927
48927
|
var _path$opts;
|
|
48928
|
-
if ((_path$opts =
|
|
48929
|
-
target =
|
|
48930
|
-
|
|
48928
|
+
if ((_path$opts = path14.opts) != null && _path$opts.noScope) return;
|
|
48929
|
+
target = path14.scope;
|
|
48930
|
+
path14 = path14.parentPath;
|
|
48931
48931
|
}
|
|
48932
48932
|
this.scope = this.getScope(target);
|
|
48933
48933
|
(_this$scope2 = this.scope) == null || _this$scope2.init();
|
|
@@ -49035,12 +49035,12 @@ var require_context2 = __commonJS({
|
|
|
49035
49035
|
}
|
|
49036
49036
|
}
|
|
49037
49037
|
function _getQueueContexts() {
|
|
49038
|
-
let
|
|
49038
|
+
let path14 = this;
|
|
49039
49039
|
let contexts = this.contexts;
|
|
49040
49040
|
while (!contexts.length) {
|
|
49041
|
-
|
|
49042
|
-
if (!
|
|
49043
|
-
contexts =
|
|
49041
|
+
path14 = path14.parentPath;
|
|
49042
|
+
if (!path14) break;
|
|
49043
|
+
contexts = path14.contexts;
|
|
49044
49044
|
}
|
|
49045
49045
|
return contexts;
|
|
49046
49046
|
}
|
|
@@ -49111,8 +49111,8 @@ var require_lib8 = __commonJS({
|
|
|
49111
49111
|
traverseFast(node, enter);
|
|
49112
49112
|
return;
|
|
49113
49113
|
};
|
|
49114
|
-
traverse2.node = function(node, opts, scope, state,
|
|
49115
|
-
(0, _traverseNode.traverseNode)(node, opts, scope, state,
|
|
49114
|
+
traverse2.node = function(node, opts, scope, state, path14, skipKeys) {
|
|
49115
|
+
(0, _traverseNode.traverseNode)(node, opts, scope, state, path14, skipKeys);
|
|
49116
49116
|
};
|
|
49117
49117
|
traverse2.clearNode = function(node, opts) {
|
|
49118
49118
|
removeProperties(node, opts);
|
|
@@ -50031,32 +50031,32 @@ function extractStringsFromSource(options) {
|
|
|
50031
50031
|
}
|
|
50032
50032
|
traverse(ast, {
|
|
50033
50033
|
// 1. Skip imports
|
|
50034
|
-
ImportDeclaration(
|
|
50035
|
-
|
|
50034
|
+
ImportDeclaration(path14) {
|
|
50035
|
+
path14.skip();
|
|
50036
50036
|
},
|
|
50037
50037
|
// 2. Skip console and logger calls
|
|
50038
|
-
CallExpression(
|
|
50039
|
-
const callee =
|
|
50038
|
+
CallExpression(path14) {
|
|
50039
|
+
const callee = path14.node.callee;
|
|
50040
50040
|
if (t.isMemberExpression(callee) && t.isIdentifier(callee.object) && (callee.object.name === "console" || callee.object.name === "logger")) {
|
|
50041
|
-
|
|
50041
|
+
path14.skip();
|
|
50042
50042
|
return;
|
|
50043
50043
|
}
|
|
50044
50044
|
if (t.isIdentifier(callee, { name: "t" }) || t.isMemberExpression(callee) && t.isIdentifier(callee.object, { name: "i18n" }) && t.isIdentifier(callee.property, { name: "t" })) {
|
|
50045
|
-
|
|
50045
|
+
path14.skip();
|
|
50046
50046
|
return;
|
|
50047
50047
|
}
|
|
50048
50048
|
},
|
|
50049
50049
|
// 3. Extract JSXText
|
|
50050
|
-
JSXText(
|
|
50051
|
-
const text =
|
|
50050
|
+
JSXText(path14) {
|
|
50051
|
+
const text = path14.node.value;
|
|
50052
50052
|
const trimmed = text.trim();
|
|
50053
50053
|
if (!isLikelyUserFacingText(trimmed)) {
|
|
50054
50054
|
return;
|
|
50055
50055
|
}
|
|
50056
|
-
const line =
|
|
50057
|
-
const column =
|
|
50058
|
-
const tagName =
|
|
50059
|
-
const { context: richContext, hasExplicitComment } = deriveEnclosingContext(
|
|
50056
|
+
const line = path14.node.loc?.start.line || 1;
|
|
50057
|
+
const column = path14.node.loc?.start.column || 0;
|
|
50058
|
+
const tagName = path14.parent?.openingElement?.name?.name || "element";
|
|
50059
|
+
const { context: richContext, hasExplicitComment } = deriveEnclosingContext(path14, `JSX text in <${tagName}>`);
|
|
50060
50060
|
const suggestedKey = generateSemanticKey({
|
|
50061
50061
|
filePath,
|
|
50062
50062
|
content: trimmed,
|
|
@@ -50077,15 +50077,15 @@ function extractStringsFromSource(options) {
|
|
|
50077
50077
|
});
|
|
50078
50078
|
},
|
|
50079
50079
|
// 4. Extract JSXAttribute (e.g. placeholder, aria-label, title)
|
|
50080
|
-
JSXAttribute(
|
|
50081
|
-
const attrName =
|
|
50080
|
+
JSXAttribute(path14) {
|
|
50081
|
+
const attrName = path14.node.name.name;
|
|
50082
50082
|
if (typeof attrName !== "string" || isIgnoredAttribute(attrName)) {
|
|
50083
50083
|
return;
|
|
50084
50084
|
}
|
|
50085
50085
|
if (!isUserFacingAttribute(attrName)) {
|
|
50086
50086
|
return;
|
|
50087
50087
|
}
|
|
50088
|
-
const val =
|
|
50088
|
+
const val = path14.node.value;
|
|
50089
50089
|
if (t.isStringLiteral(val)) {
|
|
50090
50090
|
const trimmed = val.value.trim();
|
|
50091
50091
|
if (!isLikelyUserFacingText(trimmed)) {
|
|
@@ -50093,7 +50093,7 @@ function extractStringsFromSource(options) {
|
|
|
50093
50093
|
}
|
|
50094
50094
|
const line = val.loc?.start.line || 1;
|
|
50095
50095
|
const column = val.loc?.start.column || 0;
|
|
50096
|
-
const { context: richContext, hasExplicitComment } = deriveEnclosingContext(
|
|
50096
|
+
const { context: richContext, hasExplicitComment } = deriveEnclosingContext(path14, `${attrName} attribute`);
|
|
50097
50097
|
const suggestedKey = generateSemanticKey({
|
|
50098
50098
|
filePath,
|
|
50099
50099
|
content: trimmed,
|
|
@@ -50115,8 +50115,8 @@ function extractStringsFromSource(options) {
|
|
|
50115
50115
|
}
|
|
50116
50116
|
},
|
|
50117
50117
|
// 5. Extract string literals inside JSXExpressionContainer conditional or logical expressions
|
|
50118
|
-
JSXExpressionContainer(
|
|
50119
|
-
|
|
50118
|
+
JSXExpressionContainer(path14) {
|
|
50119
|
+
path14.traverse({
|
|
50120
50120
|
StringLiteral(subPath) {
|
|
50121
50121
|
if (t.isConditionalExpression(subPath.parent) || t.isLogicalExpression(subPath.parent)) {
|
|
50122
50122
|
const trimmed = subPath.node.value.trim();
|
|
@@ -50174,22 +50174,22 @@ function transformSourceFile(options) {
|
|
|
50174
50174
|
const extractedKeys = [];
|
|
50175
50175
|
let modified = false;
|
|
50176
50176
|
traverse(ast, {
|
|
50177
|
-
ImportDeclaration(
|
|
50178
|
-
|
|
50177
|
+
ImportDeclaration(path14) {
|
|
50178
|
+
path14.skip();
|
|
50179
50179
|
},
|
|
50180
|
-
CallExpression(
|
|
50181
|
-
const callee =
|
|
50180
|
+
CallExpression(path14) {
|
|
50181
|
+
const callee = path14.node.callee;
|
|
50182
50182
|
if (t.isMemberExpression(callee) && t.isIdentifier(callee.object) && (callee.object.name === "console" || callee.object.name === "logger")) {
|
|
50183
|
-
|
|
50183
|
+
path14.skip();
|
|
50184
50184
|
return;
|
|
50185
50185
|
}
|
|
50186
50186
|
if (t.isIdentifier(callee, { name: "t" }) || t.isMemberExpression(callee) && t.isIdentifier(callee.object, { name: "i18n" }) && t.isIdentifier(callee.property, { name: "t" })) {
|
|
50187
|
-
|
|
50187
|
+
path14.skip();
|
|
50188
50188
|
return;
|
|
50189
50189
|
}
|
|
50190
50190
|
},
|
|
50191
|
-
JSXText(
|
|
50192
|
-
const text =
|
|
50191
|
+
JSXText(path14) {
|
|
50192
|
+
const text = path14.node.value;
|
|
50193
50193
|
const trimmed = text.trim();
|
|
50194
50194
|
if (!isLikelyUserFacingText(trimmed)) {
|
|
50195
50195
|
return;
|
|
@@ -50202,15 +50202,15 @@ function transformSourceFile(options) {
|
|
|
50202
50202
|
existingKeys.set(key, trimmed);
|
|
50203
50203
|
extractedKeys.push(key);
|
|
50204
50204
|
const replacement = t.jsxExpressionContainer(t.callExpression(t.identifier("t"), [t.stringLiteral(key)]));
|
|
50205
|
-
|
|
50205
|
+
path14.replaceWith(replacement);
|
|
50206
50206
|
modified = true;
|
|
50207
50207
|
},
|
|
50208
|
-
JSXAttribute(
|
|
50209
|
-
const attrName =
|
|
50208
|
+
JSXAttribute(path14) {
|
|
50209
|
+
const attrName = path14.node.name.name;
|
|
50210
50210
|
if (typeof attrName !== "string" || isIgnoredAttribute(attrName) || !isUserFacingAttribute(attrName)) {
|
|
50211
50211
|
return;
|
|
50212
50212
|
}
|
|
50213
|
-
const val =
|
|
50213
|
+
const val = path14.node.value;
|
|
50214
50214
|
if (t.isStringLiteral(val)) {
|
|
50215
50215
|
const trimmed = val.value.trim();
|
|
50216
50216
|
if (!isLikelyUserFacingText(trimmed)) {
|
|
@@ -50225,12 +50225,12 @@ function transformSourceFile(options) {
|
|
|
50225
50225
|
existingKeys.set(key, trimmed);
|
|
50226
50226
|
extractedKeys.push(key);
|
|
50227
50227
|
const replacement = t.jsxExpressionContainer(t.callExpression(t.identifier("t"), [t.stringLiteral(key)]));
|
|
50228
|
-
|
|
50228
|
+
path14.node.value = replacement;
|
|
50229
50229
|
modified = true;
|
|
50230
50230
|
}
|
|
50231
50231
|
},
|
|
50232
|
-
JSXExpressionContainer(
|
|
50233
|
-
|
|
50232
|
+
JSXExpressionContainer(path14) {
|
|
50233
|
+
path14.traverse({
|
|
50234
50234
|
StringLiteral(subPath) {
|
|
50235
50235
|
if (t.isConditionalExpression(subPath.parent) || t.isLogicalExpression(subPath.parent)) {
|
|
50236
50236
|
const trimmed = subPath.node.value.trim();
|
|
@@ -50281,9 +50281,9 @@ function injectHookAndImport(options) {
|
|
|
50281
50281
|
const { ast, hookName, packageName } = options;
|
|
50282
50282
|
let hasImport = false;
|
|
50283
50283
|
traverse(ast, {
|
|
50284
|
-
ImportDeclaration(
|
|
50285
|
-
if (
|
|
50286
|
-
for (const spec of
|
|
50284
|
+
ImportDeclaration(path14) {
|
|
50285
|
+
if (path14.node.source.value === packageName) {
|
|
50286
|
+
for (const spec of path14.node.specifiers) {
|
|
50287
50287
|
if (t.isImportSpecifier(spec) && spec.imported.name === hookName) {
|
|
50288
50288
|
hasImport = true;
|
|
50289
50289
|
}
|
|
@@ -50297,17 +50297,17 @@ function injectHookAndImport(options) {
|
|
|
50297
50297
|
ast.program.body.unshift(importDecl);
|
|
50298
50298
|
}
|
|
50299
50299
|
traverse(ast, {
|
|
50300
|
-
FunctionDeclaration(
|
|
50301
|
-
injectHookIntoBody(
|
|
50300
|
+
FunctionDeclaration(path14) {
|
|
50301
|
+
injectHookIntoBody(path14.node.body, hookName);
|
|
50302
50302
|
},
|
|
50303
|
-
FunctionExpression(
|
|
50304
|
-
if (t.isBlockStatement(
|
|
50305
|
-
injectHookIntoBody(
|
|
50303
|
+
FunctionExpression(path14) {
|
|
50304
|
+
if (t.isBlockStatement(path14.node.body)) {
|
|
50305
|
+
injectHookIntoBody(path14.node.body, hookName);
|
|
50306
50306
|
}
|
|
50307
50307
|
},
|
|
50308
|
-
ArrowFunctionExpression(
|
|
50309
|
-
if (t.isBlockStatement(
|
|
50310
|
-
injectHookIntoBody(
|
|
50308
|
+
ArrowFunctionExpression(path14) {
|
|
50309
|
+
if (t.isBlockStatement(path14.node.body)) {
|
|
50310
|
+
injectHookIntoBody(path14.node.body, hookName);
|
|
50311
50311
|
}
|
|
50312
50312
|
}
|
|
50313
50313
|
});
|
|
@@ -50341,8 +50341,8 @@ function injectHookIntoBody(body, hookName) {
|
|
|
50341
50341
|
body.body.unshift(hookStatement);
|
|
50342
50342
|
}
|
|
50343
50343
|
}
|
|
50344
|
-
function deriveEnclosingContext(
|
|
50345
|
-
const comments =
|
|
50344
|
+
function deriveEnclosingContext(path14, fallback) {
|
|
50345
|
+
const comments = path14.node.leadingComments || path14.parent?.leadingComments || [];
|
|
50346
50346
|
for (const c of comments) {
|
|
50347
50347
|
const val = (c.value || "").trim();
|
|
50348
50348
|
if (/^(context|i18n-context|desc|description):/i.test(val)) {
|
|
@@ -50351,7 +50351,7 @@ function deriveEnclosingContext(path13, fallback) {
|
|
|
50351
50351
|
}
|
|
50352
50352
|
}
|
|
50353
50353
|
let componentName = "";
|
|
50354
|
-
let curr =
|
|
50354
|
+
let curr = path14.parentPath;
|
|
50355
50355
|
while (curr) {
|
|
50356
50356
|
if (curr.isFunctionDeclaration && curr.isFunctionDeclaration()) {
|
|
50357
50357
|
componentName = curr.node.id?.name || "";
|
|
@@ -50364,7 +50364,7 @@ function deriveEnclosingContext(path13, fallback) {
|
|
|
50364
50364
|
curr = curr.parentPath;
|
|
50365
50365
|
}
|
|
50366
50366
|
let tagInfo = "";
|
|
50367
|
-
let parentEl =
|
|
50367
|
+
let parentEl = path14.findParent ? path14.findParent((p) => p.isJSXElement && p.isJSXElement()) : null;
|
|
50368
50368
|
if (parentEl && parentEl.node?.openingElement) {
|
|
50369
50369
|
const opening = parentEl.node.openingElement;
|
|
50370
50370
|
const tagName = opening.name?.name || "element";
|
|
@@ -50500,8 +50500,215 @@ async function analyzeCommand(options) {
|
|
|
50500
50500
|
}
|
|
50501
50501
|
}
|
|
50502
50502
|
|
|
50503
|
+
// src/commands/setup.ts
|
|
50504
|
+
import chalk2 from "chalk";
|
|
50505
|
+
|
|
50506
|
+
// src/installer/skills-installer.ts
|
|
50507
|
+
import fs4 from "fs/promises";
|
|
50508
|
+
import fsSync2 from "fs";
|
|
50509
|
+
import path6 from "path";
|
|
50510
|
+
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
50511
|
+
import { exec } from "child_process";
|
|
50512
|
+
import { promisify } from "util";
|
|
50513
|
+
|
|
50514
|
+
// src/version.ts
|
|
50515
|
+
import fsSync from "fs";
|
|
50516
|
+
import path5 from "path";
|
|
50517
|
+
import { fileURLToPath } from "url";
|
|
50518
|
+
function resolveCliVersion() {
|
|
50519
|
+
try {
|
|
50520
|
+
const __filename2 = fileURLToPath(import.meta.url);
|
|
50521
|
+
const __dirname2 = path5.dirname(__filename2);
|
|
50522
|
+
const candidates = [
|
|
50523
|
+
path5.resolve(__dirname2, "../package.json"),
|
|
50524
|
+
path5.resolve(__dirname2, "../../package.json"),
|
|
50525
|
+
path5.resolve(__dirname2, "../../../package.json")
|
|
50526
|
+
];
|
|
50527
|
+
for (const candidate of candidates) {
|
|
50528
|
+
if (fsSync.existsSync(candidate)) {
|
|
50529
|
+
const pkg = JSON.parse(fsSync.readFileSync(candidate, "utf8"));
|
|
50530
|
+
if (pkg && pkg.name === "shallok" && pkg.version) {
|
|
50531
|
+
return pkg.version;
|
|
50532
|
+
}
|
|
50533
|
+
}
|
|
50534
|
+
}
|
|
50535
|
+
} catch {
|
|
50536
|
+
}
|
|
50537
|
+
return "0.1.3";
|
|
50538
|
+
}
|
|
50539
|
+
var CLI_VERSION = resolveCliVersion();
|
|
50540
|
+
|
|
50541
|
+
// src/installer/skills-installer.ts
|
|
50542
|
+
var execAsync = promisify(exec);
|
|
50543
|
+
var __filename = fileURLToPath2(import.meta.url);
|
|
50544
|
+
var __dirname = path6.dirname(__filename);
|
|
50545
|
+
async function detectPackageManager(projectRoot) {
|
|
50546
|
+
if (fsSync2.existsSync(path6.resolve(projectRoot, "pnpm-lock.yaml"))) return "pnpm";
|
|
50547
|
+
if (fsSync2.existsSync(path6.resolve(projectRoot, "yarn.lock"))) return "yarn";
|
|
50548
|
+
if (fsSync2.existsSync(path6.resolve(projectRoot, "bun.lockb")) || fsSync2.existsSync(path6.resolve(projectRoot, "bun.lock"))) {
|
|
50549
|
+
return "bun";
|
|
50550
|
+
}
|
|
50551
|
+
return "npm";
|
|
50552
|
+
}
|
|
50553
|
+
function resolveSkillsDir() {
|
|
50554
|
+
const candidates = [
|
|
50555
|
+
path6.resolve(__dirname, "../skills"),
|
|
50556
|
+
path6.resolve(__dirname, "../../skills"),
|
|
50557
|
+
path6.resolve(__dirname, "../../../skills"),
|
|
50558
|
+
path6.resolve(__dirname, "../../../../skills")
|
|
50559
|
+
];
|
|
50560
|
+
for (const candidate of candidates) {
|
|
50561
|
+
if (fsSync2.existsSync(candidate) && fsSync2.statSync(candidate).isDirectory() && fsSync2.existsSync(path6.resolve(candidate, "localization-and-translation-i18n"))) {
|
|
50562
|
+
return candidate;
|
|
50563
|
+
}
|
|
50564
|
+
}
|
|
50565
|
+
return null;
|
|
50566
|
+
}
|
|
50567
|
+
async function ensureShallokDependency(projectRoot) {
|
|
50568
|
+
const pkgPath = path6.resolve(projectRoot, "package.json");
|
|
50569
|
+
if (!fsSync2.existsSync(pkgPath)) return false;
|
|
50570
|
+
try {
|
|
50571
|
+
const raw = await fs4.readFile(pkgPath, "utf8");
|
|
50572
|
+
const pkg = JSON.parse(raw);
|
|
50573
|
+
if (pkg.name === "shallok-monorepo") return false;
|
|
50574
|
+
const hasShallok = Boolean(pkg.dependencies?.shallok || pkg.dependencies?.["@shallok/cli"]) || Boolean(pkg.devDependencies?.shallok || pkg.devDependencies?.["@shallok/cli"]);
|
|
50575
|
+
if (hasShallok) return false;
|
|
50576
|
+
const pm = await detectPackageManager(projectRoot);
|
|
50577
|
+
const installCmd = pm === "pnpm" ? "pnpm add -D shallok" : pm === "yarn" ? "yarn add -D shallok" : pm === "bun" ? "bun add -d shallok" : "npm install -D shallok";
|
|
50578
|
+
try {
|
|
50579
|
+
await execAsync(installCmd, { cwd: projectRoot });
|
|
50580
|
+
return true;
|
|
50581
|
+
} catch {
|
|
50582
|
+
pkg.devDependencies = pkg.devDependencies || {};
|
|
50583
|
+
pkg.devDependencies["shallok"] = `^${CLI_VERSION}`;
|
|
50584
|
+
await fs4.writeFile(pkgPath, JSON.stringify(pkg, null, 2) + "\n", "utf8");
|
|
50585
|
+
return true;
|
|
50586
|
+
}
|
|
50587
|
+
} catch {
|
|
50588
|
+
return false;
|
|
50589
|
+
}
|
|
50590
|
+
}
|
|
50591
|
+
async function installSkillsForProject(projectRoot, framework) {
|
|
50592
|
+
const pm = await detectPackageManager(projectRoot);
|
|
50593
|
+
const dependencyInstalled = await ensureShallokDependency(projectRoot);
|
|
50594
|
+
const skillsDir = resolveSkillsDir();
|
|
50595
|
+
const copiedSkills = [];
|
|
50596
|
+
const destinations = [];
|
|
50597
|
+
if (!skillsDir) {
|
|
50598
|
+
return {
|
|
50599
|
+
packageManager: pm,
|
|
50600
|
+
dependencyInstalled,
|
|
50601
|
+
copiedSkills,
|
|
50602
|
+
destinations
|
|
50603
|
+
};
|
|
50604
|
+
}
|
|
50605
|
+
const frameworkSkillMap = {
|
|
50606
|
+
react: "react-localization-and-translation-i18n",
|
|
50607
|
+
nextjs: "nextjs-localization-and-translation-i18n",
|
|
50608
|
+
expo: "expo-localization-and-translation-i18n",
|
|
50609
|
+
astro: "astro-localization-and-translation-i18n"
|
|
50610
|
+
};
|
|
50611
|
+
const fwSkill = framework ? frameworkSkillMap[framework.toLowerCase()] : void 0;
|
|
50612
|
+
const selectedSkills = fwSkill ? [fwSkill] : ["localization-and-translation-i18n"];
|
|
50613
|
+
const targetRoots = [
|
|
50614
|
+
path6.resolve(projectRoot, ".agents", "skills"),
|
|
50615
|
+
path6.resolve(projectRoot, "skills")
|
|
50616
|
+
];
|
|
50617
|
+
for (const targetRoot of targetRoots) {
|
|
50618
|
+
for (const skillName of selectedSkills) {
|
|
50619
|
+
const srcSkillPath = path6.resolve(skillsDir, skillName);
|
|
50620
|
+
if (fsSync2.existsSync(srcSkillPath)) {
|
|
50621
|
+
const destSkillPath = path6.resolve(targetRoot, skillName);
|
|
50622
|
+
await fs4.mkdir(destSkillPath, { recursive: true });
|
|
50623
|
+
await copyDirRecursive(srcSkillPath, destSkillPath);
|
|
50624
|
+
if (!copiedSkills.includes(skillName)) {
|
|
50625
|
+
copiedSkills.push(skillName);
|
|
50626
|
+
}
|
|
50627
|
+
}
|
|
50628
|
+
}
|
|
50629
|
+
destinations.push(path6.relative(projectRoot, targetRoot));
|
|
50630
|
+
}
|
|
50631
|
+
return {
|
|
50632
|
+
packageManager: pm,
|
|
50633
|
+
dependencyInstalled,
|
|
50634
|
+
copiedSkills,
|
|
50635
|
+
destinations
|
|
50636
|
+
};
|
|
50637
|
+
}
|
|
50638
|
+
async function copyDirRecursive(src, dest) {
|
|
50639
|
+
await fs4.mkdir(dest, { recursive: true });
|
|
50640
|
+
const entries = await fs4.readdir(src, { withFileTypes: true });
|
|
50641
|
+
for (const entry of entries) {
|
|
50642
|
+
const srcPath = path6.resolve(src, entry.name);
|
|
50643
|
+
const destPath = path6.resolve(dest, entry.name);
|
|
50644
|
+
if (entry.isDirectory()) {
|
|
50645
|
+
await copyDirRecursive(srcPath, destPath);
|
|
50646
|
+
} else {
|
|
50647
|
+
await fs4.copyFile(srcPath, destPath);
|
|
50648
|
+
}
|
|
50649
|
+
}
|
|
50650
|
+
}
|
|
50651
|
+
|
|
50652
|
+
// src/commands/setup.ts
|
|
50653
|
+
async function setupCommand(options) {
|
|
50654
|
+
const cwd = process.cwd();
|
|
50655
|
+
const printer = new Printer(options.json);
|
|
50656
|
+
try {
|
|
50657
|
+
printer.log("Setting up Shallok in your project...");
|
|
50658
|
+
let detectedFramework = "unknown";
|
|
50659
|
+
try {
|
|
50660
|
+
const analysis = await analyzeProject(cwd);
|
|
50661
|
+
detectedFramework = analysis.framework.name;
|
|
50662
|
+
} catch {
|
|
50663
|
+
}
|
|
50664
|
+
const framework = options.framework || detectedFramework;
|
|
50665
|
+
const result = await installSkillsForProject(cwd, framework);
|
|
50666
|
+
if (options.json) {
|
|
50667
|
+
printer.json({
|
|
50668
|
+
success: true,
|
|
50669
|
+
packageManager: result.packageManager,
|
|
50670
|
+
dependencyInstalled: result.dependencyInstalled,
|
|
50671
|
+
framework,
|
|
50672
|
+
copiedSkills: result.copiedSkills,
|
|
50673
|
+
destinations: result.destinations,
|
|
50674
|
+
instructionForAiAgent: 'Ask your AI coding agent: "Add localization and translations for a, b, c, d languages" (e.g. en, es, hi, kn)'
|
|
50675
|
+
});
|
|
50676
|
+
return;
|
|
50677
|
+
}
|
|
50678
|
+
printer.success("Shallok setup completed successfully!");
|
|
50679
|
+
printer.info(`Detected framework: ${framework}`);
|
|
50680
|
+
if (result.dependencyInstalled) {
|
|
50681
|
+
printer.info(`Installed shallok in devDependencies (${result.packageManager})`);
|
|
50682
|
+
} else {
|
|
50683
|
+
printer.info(`shallok dependency verified in package.json`);
|
|
50684
|
+
}
|
|
50685
|
+
for (const skill of result.copiedSkills) {
|
|
50686
|
+
printer.info(`Added AI agent skill: ${skill} (.agents/skills/ & skills/)`);
|
|
50687
|
+
}
|
|
50688
|
+
console.log("");
|
|
50689
|
+
console.log(chalk2.bold.cyan("======================================================================"));
|
|
50690
|
+
console.log(chalk2.bold(" Next Step: Ask your AI agent to localize your app!"));
|
|
50691
|
+
console.log(chalk2.bold.cyan("======================================================================"));
|
|
50692
|
+
console.log("Now open your AI coding agent (Antigravity, Cursor, Claude Code, Copilot, etc.)");
|
|
50693
|
+
console.log("and tell it:");
|
|
50694
|
+
console.log("");
|
|
50695
|
+
console.log(chalk2.green.bold(' "Add localization and translations for a, b, c, d languages"'));
|
|
50696
|
+
console.log(chalk2.dim(' (e.g., "Add localization and translations for en, es, hi, kn")'));
|
|
50697
|
+
console.log("");
|
|
50698
|
+
console.log("Your AI agent will use the installed skill to:");
|
|
50699
|
+
console.log(" 1. Initialize configuration and catalogs (shallok init)");
|
|
50700
|
+
console.log(" 2. Extract hardcoded UI strings into canonical catalog (shallok extract)");
|
|
50701
|
+
console.log(" 3. Generate translations without external API keys (shallok translate)");
|
|
50702
|
+
console.log(" 4. Wire up framework runtime provider and compile message bundles");
|
|
50703
|
+
console.log(chalk2.bold.cyan("======================================================================"));
|
|
50704
|
+
} catch (err) {
|
|
50705
|
+
printer.error(`Setup failed: ${err.message}`);
|
|
50706
|
+
process.exit(1);
|
|
50707
|
+
}
|
|
50708
|
+
}
|
|
50709
|
+
|
|
50503
50710
|
// src/commands/init.ts
|
|
50504
|
-
import
|
|
50711
|
+
import path12 from "path";
|
|
50505
50712
|
import fs10 from "fs/promises";
|
|
50506
50713
|
|
|
50507
50714
|
// ../../packages/framework-adapters/dist/common/compile.js
|
|
@@ -50535,23 +50742,23 @@ function compileCatalogToRuntime(localeCatalog, canonicalCatalog, format = "flat
|
|
|
50535
50742
|
}
|
|
50536
50743
|
|
|
50537
50744
|
// ../../packages/framework-adapters/dist/react/adapter.js
|
|
50538
|
-
import
|
|
50539
|
-
import
|
|
50745
|
+
import fs5 from "fs/promises";
|
|
50746
|
+
import path7 from "path";
|
|
50540
50747
|
var ReactAdapter = class {
|
|
50541
50748
|
name = "react";
|
|
50542
50749
|
framework = "react";
|
|
50543
50750
|
library = "react-i18next";
|
|
50544
50751
|
async detect(projectRoot) {
|
|
50545
|
-
const pkg = await readJsonIfExists(
|
|
50752
|
+
const pkg = await readJsonIfExists(path7.resolve(projectRoot, "package.json"));
|
|
50546
50753
|
if (!pkg?.dependencies)
|
|
50547
50754
|
return false;
|
|
50548
50755
|
return Boolean(pkg.dependencies["react"] && !pkg.dependencies["next"]);
|
|
50549
50756
|
}
|
|
50550
50757
|
async initialize(projectRoot, options) {
|
|
50551
50758
|
const createdFiles = [];
|
|
50552
|
-
const srcDir =
|
|
50553
|
-
await
|
|
50554
|
-
const i18nConfigPath =
|
|
50759
|
+
const srcDir = path7.resolve(projectRoot, "src");
|
|
50760
|
+
await fs5.mkdir(srcDir, { recursive: true });
|
|
50761
|
+
const i18nConfigPath = path7.resolve(srcDir, "i18n.ts");
|
|
50555
50762
|
const configContent = `import i18n from 'i18next';
|
|
50556
50763
|
import { initReactI18next } from 'react-i18next';
|
|
50557
50764
|
|
|
@@ -50574,7 +50781,7 @@ i18n
|
|
|
50574
50781
|
|
|
50575
50782
|
export default i18n;
|
|
50576
50783
|
`;
|
|
50577
|
-
await
|
|
50784
|
+
await fs5.writeFile(i18nConfigPath, configContent, "utf8");
|
|
50578
50785
|
createdFiles.push("src/i18n.ts");
|
|
50579
50786
|
return {
|
|
50580
50787
|
createdFiles,
|
|
@@ -50593,39 +50800,39 @@ export default i18n;
|
|
|
50593
50800
|
async writeRuntimeMessages(projectRoot, options) {
|
|
50594
50801
|
const compiled = this.compileRuntimeMessages(options);
|
|
50595
50802
|
const writtenFiles = [];
|
|
50596
|
-
const outDir =
|
|
50597
|
-
await
|
|
50803
|
+
const outDir = path7.resolve(projectRoot, options.manifest.paths.translations_directory, "runtime");
|
|
50804
|
+
await fs5.mkdir(outDir, { recursive: true });
|
|
50598
50805
|
for (const [locale, messages] of Object.entries(compiled)) {
|
|
50599
|
-
const filePath =
|
|
50806
|
+
const filePath = path7.resolve(outDir, `${locale}.json`);
|
|
50600
50807
|
await writeJsonAtomic(filePath, messages);
|
|
50601
|
-
writtenFiles.push(
|
|
50808
|
+
writtenFiles.push(path7.relative(projectRoot, filePath));
|
|
50602
50809
|
}
|
|
50603
50810
|
return writtenFiles;
|
|
50604
50811
|
}
|
|
50605
50812
|
};
|
|
50606
50813
|
|
|
50607
50814
|
// ../../packages/framework-adapters/dist/nextjs/adapter.js
|
|
50608
|
-
import
|
|
50609
|
-
import
|
|
50815
|
+
import fs6 from "fs/promises";
|
|
50816
|
+
import path8 from "path";
|
|
50610
50817
|
var NextjsAdapter = class {
|
|
50611
50818
|
name = "nextjs";
|
|
50612
50819
|
framework = "nextjs";
|
|
50613
50820
|
library = "next-intl";
|
|
50614
50821
|
async detect(projectRoot) {
|
|
50615
|
-
const pkg = await readJsonIfExists(
|
|
50822
|
+
const pkg = await readJsonIfExists(path8.resolve(projectRoot, "package.json"));
|
|
50616
50823
|
return Boolean(pkg?.dependencies?.["next"]);
|
|
50617
50824
|
}
|
|
50618
50825
|
async initialize(projectRoot, options) {
|
|
50619
50826
|
const createdFiles = [];
|
|
50620
50827
|
let baseDir = "src";
|
|
50621
50828
|
try {
|
|
50622
|
-
await
|
|
50829
|
+
await fs6.access(path8.resolve(projectRoot, "src"));
|
|
50623
50830
|
} catch {
|
|
50624
50831
|
baseDir = ".";
|
|
50625
50832
|
}
|
|
50626
|
-
const i18nDir =
|
|
50627
|
-
await
|
|
50628
|
-
const routingPath =
|
|
50833
|
+
const i18nDir = path8.resolve(projectRoot, baseDir, "i18n");
|
|
50834
|
+
await fs6.mkdir(i18nDir, { recursive: true });
|
|
50835
|
+
const routingPath = path8.resolve(i18nDir, "routing.ts");
|
|
50629
50836
|
const routingContent = `import { defineRouting } from 'next-intl/routing';
|
|
50630
50837
|
|
|
50631
50838
|
export const routing = defineRouting({
|
|
@@ -50633,9 +50840,9 @@ export const routing = defineRouting({
|
|
|
50633
50840
|
defaultLocale: '${options.sourceLocale}',
|
|
50634
50841
|
});
|
|
50635
50842
|
`;
|
|
50636
|
-
await
|
|
50637
|
-
createdFiles.push(
|
|
50638
|
-
const requestPath =
|
|
50843
|
+
await fs6.writeFile(routingPath, routingContent, "utf8");
|
|
50844
|
+
createdFiles.push(path8.relative(projectRoot, routingPath));
|
|
50845
|
+
const requestPath = path8.resolve(i18nDir, "request.ts");
|
|
50639
50846
|
const requestContent = `import { getRequestConfig } from 'next-intl/server';
|
|
50640
50847
|
import { routing } from './routing';
|
|
50641
50848
|
|
|
@@ -50652,8 +50859,8 @@ export default getRequestConfig(async ({ requestLocale }) => {
|
|
|
50652
50859
|
};
|
|
50653
50860
|
});
|
|
50654
50861
|
`;
|
|
50655
|
-
await
|
|
50656
|
-
createdFiles.push(
|
|
50862
|
+
await fs6.writeFile(requestPath, requestContent, "utf8");
|
|
50863
|
+
createdFiles.push(path8.relative(projectRoot, requestPath));
|
|
50657
50864
|
return {
|
|
50658
50865
|
createdFiles,
|
|
50659
50866
|
modifiedFiles: [],
|
|
@@ -50671,33 +50878,33 @@ export default getRequestConfig(async ({ requestLocale }) => {
|
|
|
50671
50878
|
async writeRuntimeMessages(projectRoot, options) {
|
|
50672
50879
|
const compiled = this.compileRuntimeMessages(options);
|
|
50673
50880
|
const writtenFiles = [];
|
|
50674
|
-
const outDir =
|
|
50675
|
-
await
|
|
50881
|
+
const outDir = path8.resolve(projectRoot, options.manifest.paths.translations_directory, "runtime");
|
|
50882
|
+
await fs6.mkdir(outDir, { recursive: true });
|
|
50676
50883
|
for (const [locale, messages] of Object.entries(compiled)) {
|
|
50677
|
-
const filePath =
|
|
50884
|
+
const filePath = path8.resolve(outDir, `${locale}.json`);
|
|
50678
50885
|
await writeJsonAtomic(filePath, messages);
|
|
50679
|
-
writtenFiles.push(
|
|
50886
|
+
writtenFiles.push(path8.relative(projectRoot, filePath));
|
|
50680
50887
|
}
|
|
50681
50888
|
return writtenFiles;
|
|
50682
50889
|
}
|
|
50683
50890
|
};
|
|
50684
50891
|
|
|
50685
50892
|
// ../../packages/framework-adapters/dist/vue/adapter.js
|
|
50686
|
-
import
|
|
50687
|
-
import
|
|
50893
|
+
import fs7 from "fs/promises";
|
|
50894
|
+
import path9 from "path";
|
|
50688
50895
|
var VueAdapter = class {
|
|
50689
50896
|
name = "vue";
|
|
50690
50897
|
framework = "vue";
|
|
50691
50898
|
library = "vue-i18n";
|
|
50692
50899
|
async detect(projectRoot) {
|
|
50693
|
-
const pkg = await readJsonIfExists(
|
|
50900
|
+
const pkg = await readJsonIfExists(path9.resolve(projectRoot, "package.json"));
|
|
50694
50901
|
return Boolean(pkg?.dependencies?.["vue"]);
|
|
50695
50902
|
}
|
|
50696
50903
|
async initialize(projectRoot, options) {
|
|
50697
50904
|
const createdFiles = [];
|
|
50698
|
-
const srcDir =
|
|
50699
|
-
await
|
|
50700
|
-
const i18nConfigPath =
|
|
50905
|
+
const srcDir = path9.resolve(projectRoot, "src");
|
|
50906
|
+
await fs7.mkdir(srcDir, { recursive: true });
|
|
50907
|
+
const i18nConfigPath = path9.resolve(srcDir, "i18n.ts");
|
|
50701
50908
|
const configContent = `import { createI18n } from 'vue-i18n';
|
|
50702
50909
|
|
|
50703
50910
|
${options.supportedLocales.map((loc) => `import ${loc}Messages from '../messages/${loc}.json';`).join("\n")}
|
|
@@ -50713,7 +50920,7 @@ export const i18n = createI18n({
|
|
|
50713
50920
|
messages,
|
|
50714
50921
|
});
|
|
50715
50922
|
`;
|
|
50716
|
-
await
|
|
50923
|
+
await fs7.writeFile(i18nConfigPath, configContent, "utf8");
|
|
50717
50924
|
createdFiles.push("src/i18n.ts");
|
|
50718
50925
|
return {
|
|
50719
50926
|
createdFiles,
|
|
@@ -50732,32 +50939,32 @@ export const i18n = createI18n({
|
|
|
50732
50939
|
async writeRuntimeMessages(projectRoot, options) {
|
|
50733
50940
|
const compiled = this.compileRuntimeMessages(options);
|
|
50734
50941
|
const writtenFiles = [];
|
|
50735
|
-
const outDir =
|
|
50736
|
-
await
|
|
50942
|
+
const outDir = path9.resolve(projectRoot, options.manifest.paths.translations_directory);
|
|
50943
|
+
await fs7.mkdir(outDir, { recursive: true });
|
|
50737
50944
|
for (const [locale, messages] of Object.entries(compiled)) {
|
|
50738
|
-
const filePath =
|
|
50945
|
+
const filePath = path9.resolve(outDir, `${locale}.json`);
|
|
50739
50946
|
await writeJsonAtomic(filePath, messages);
|
|
50740
|
-
writtenFiles.push(
|
|
50947
|
+
writtenFiles.push(path9.relative(projectRoot, filePath));
|
|
50741
50948
|
}
|
|
50742
50949
|
return writtenFiles;
|
|
50743
50950
|
}
|
|
50744
50951
|
};
|
|
50745
50952
|
|
|
50746
50953
|
// ../../packages/framework-adapters/dist/expo/adapter.js
|
|
50747
|
-
import
|
|
50748
|
-
import
|
|
50954
|
+
import fs8 from "fs/promises";
|
|
50955
|
+
import path10 from "path";
|
|
50749
50956
|
var ExpoAdapter = class {
|
|
50750
50957
|
name = "expo";
|
|
50751
50958
|
framework = "expo";
|
|
50752
50959
|
library = "expo-localization";
|
|
50753
50960
|
async detect(projectRoot) {
|
|
50754
|
-
const pkg = await readJsonIfExists(
|
|
50961
|
+
const pkg = await readJsonIfExists(path10.resolve(projectRoot, "package.json"));
|
|
50755
50962
|
return Boolean(pkg?.dependencies?.["expo"] || pkg?.dependencies?.["react-native"]);
|
|
50756
50963
|
}
|
|
50757
50964
|
async initialize(projectRoot, options) {
|
|
50758
50965
|
const createdFiles = [];
|
|
50759
50966
|
const rootDir = projectRoot;
|
|
50760
|
-
const i18nConfigPath =
|
|
50967
|
+
const i18nConfigPath = path10.resolve(rootDir, "i18n.ts");
|
|
50761
50968
|
const configContent = `import i18n from 'i18next';
|
|
50762
50969
|
import { initReactI18next } from 'react-i18next';
|
|
50763
50970
|
import { getLocales } from 'expo-localization';
|
|
@@ -50783,7 +50990,7 @@ i18n
|
|
|
50783
50990
|
|
|
50784
50991
|
export default i18n;
|
|
50785
50992
|
`;
|
|
50786
|
-
await
|
|
50993
|
+
await fs8.writeFile(i18nConfigPath, configContent, "utf8");
|
|
50787
50994
|
createdFiles.push("i18n.ts");
|
|
50788
50995
|
return {
|
|
50789
50996
|
createdFiles,
|
|
@@ -50802,33 +51009,33 @@ export default i18n;
|
|
|
50802
51009
|
async writeRuntimeMessages(projectRoot, options) {
|
|
50803
51010
|
const compiled = this.compileRuntimeMessages(options);
|
|
50804
51011
|
const writtenFiles = [];
|
|
50805
|
-
const outDir =
|
|
50806
|
-
await
|
|
51012
|
+
const outDir = path10.resolve(projectRoot, options.manifest.paths.translations_directory, "runtime");
|
|
51013
|
+
await fs8.mkdir(outDir, { recursive: true });
|
|
50807
51014
|
for (const [locale, messages] of Object.entries(compiled)) {
|
|
50808
|
-
const filePath =
|
|
51015
|
+
const filePath = path10.resolve(outDir, `${locale}.json`);
|
|
50809
51016
|
await writeJsonAtomic(filePath, messages);
|
|
50810
|
-
writtenFiles.push(
|
|
51017
|
+
writtenFiles.push(path10.relative(projectRoot, filePath));
|
|
50811
51018
|
}
|
|
50812
51019
|
return writtenFiles;
|
|
50813
51020
|
}
|
|
50814
51021
|
};
|
|
50815
51022
|
|
|
50816
51023
|
// ../../packages/framework-adapters/dist/astro/adapter.js
|
|
50817
|
-
import
|
|
50818
|
-
import
|
|
51024
|
+
import fs9 from "fs/promises";
|
|
51025
|
+
import path11 from "path";
|
|
50819
51026
|
var AstroAdapter = class {
|
|
50820
51027
|
name = "astro";
|
|
50821
51028
|
framework = "astro";
|
|
50822
51029
|
library = "astro-i18n";
|
|
50823
51030
|
async detect(projectRoot) {
|
|
50824
|
-
const pkg = await readJsonIfExists(
|
|
51031
|
+
const pkg = await readJsonIfExists(path11.resolve(projectRoot, "package.json"));
|
|
50825
51032
|
return Boolean(pkg?.dependencies?.["astro"]);
|
|
50826
51033
|
}
|
|
50827
51034
|
async initialize(projectRoot, options) {
|
|
50828
51035
|
const createdFiles = [];
|
|
50829
|
-
const srcDir =
|
|
50830
|
-
await
|
|
50831
|
-
const utilsPath =
|
|
51036
|
+
const srcDir = path11.resolve(projectRoot, "src", "i18n");
|
|
51037
|
+
await fs9.mkdir(srcDir, { recursive: true });
|
|
51038
|
+
const utilsPath = path11.resolve(srcDir, "utils.ts");
|
|
50832
51039
|
const utilsContent = `export const defaultLocale = '${options.sourceLocale}';
|
|
50833
51040
|
export const locales = ${JSON.stringify(options.supportedLocales)} as const;
|
|
50834
51041
|
|
|
@@ -50842,7 +51049,7 @@ export async function useTranslations(locale: Locale) {
|
|
|
50842
51049
|
};
|
|
50843
51050
|
}
|
|
50844
51051
|
`;
|
|
50845
|
-
await
|
|
51052
|
+
await fs9.writeFile(utilsPath, utilsContent, "utf8");
|
|
50846
51053
|
createdFiles.push("src/i18n/utils.ts");
|
|
50847
51054
|
return {
|
|
50848
51055
|
createdFiles,
|
|
@@ -50861,12 +51068,12 @@ export async function useTranslations(locale: Locale) {
|
|
|
50861
51068
|
async writeRuntimeMessages(projectRoot, options) {
|
|
50862
51069
|
const compiled = this.compileRuntimeMessages(options);
|
|
50863
51070
|
const writtenFiles = [];
|
|
50864
|
-
const outDir =
|
|
50865
|
-
await
|
|
51071
|
+
const outDir = path11.resolve(projectRoot, options.manifest.paths.translations_directory, "runtime");
|
|
51072
|
+
await fs9.mkdir(outDir, { recursive: true });
|
|
50866
51073
|
for (const [locale, messages] of Object.entries(compiled)) {
|
|
50867
|
-
const filePath =
|
|
51074
|
+
const filePath = path11.resolve(outDir, `${locale}.json`);
|
|
50868
51075
|
await writeJsonAtomic(filePath, messages);
|
|
50869
|
-
writtenFiles.push(
|
|
51076
|
+
writtenFiles.push(path11.relative(projectRoot, filePath));
|
|
50870
51077
|
}
|
|
50871
51078
|
return writtenFiles;
|
|
50872
51079
|
}
|
|
@@ -50892,126 +51099,6 @@ function getAdapter(frameworkName) {
|
|
|
50892
51099
|
}
|
|
50893
51100
|
}
|
|
50894
51101
|
|
|
50895
|
-
// src/installer/skills-installer.ts
|
|
50896
|
-
import fs9 from "fs/promises";
|
|
50897
|
-
import fsSync from "fs";
|
|
50898
|
-
import path10 from "path";
|
|
50899
|
-
import { fileURLToPath } from "url";
|
|
50900
|
-
import { exec } from "child_process";
|
|
50901
|
-
import { promisify } from "util";
|
|
50902
|
-
var execAsync = promisify(exec);
|
|
50903
|
-
var __filename = fileURLToPath(import.meta.url);
|
|
50904
|
-
var __dirname = path10.dirname(__filename);
|
|
50905
|
-
async function detectPackageManager(projectRoot) {
|
|
50906
|
-
if (fsSync.existsSync(path10.resolve(projectRoot, "pnpm-lock.yaml"))) return "pnpm";
|
|
50907
|
-
if (fsSync.existsSync(path10.resolve(projectRoot, "yarn.lock"))) return "yarn";
|
|
50908
|
-
if (fsSync.existsSync(path10.resolve(projectRoot, "bun.lockb")) || fsSync.existsSync(path10.resolve(projectRoot, "bun.lock"))) {
|
|
50909
|
-
return "bun";
|
|
50910
|
-
}
|
|
50911
|
-
return "npm";
|
|
50912
|
-
}
|
|
50913
|
-
function resolveSkillsDir() {
|
|
50914
|
-
const candidates = [
|
|
50915
|
-
path10.resolve(__dirname, "../../skills"),
|
|
50916
|
-
path10.resolve(__dirname, "../skills"),
|
|
50917
|
-
path10.resolve(__dirname, "../../../skills"),
|
|
50918
|
-
path10.resolve(process.cwd(), "skills")
|
|
50919
|
-
];
|
|
50920
|
-
for (const candidate of candidates) {
|
|
50921
|
-
if (fsSync.existsSync(candidate) && fsSync.statSync(candidate).isDirectory()) {
|
|
50922
|
-
return candidate;
|
|
50923
|
-
}
|
|
50924
|
-
}
|
|
50925
|
-
return null;
|
|
50926
|
-
}
|
|
50927
|
-
async function ensureShallokDependency(projectRoot) {
|
|
50928
|
-
const pkgPath = path10.resolve(projectRoot, "package.json");
|
|
50929
|
-
if (!fsSync.existsSync(pkgPath)) return false;
|
|
50930
|
-
try {
|
|
50931
|
-
const raw = await fs9.readFile(pkgPath, "utf8");
|
|
50932
|
-
const pkg = JSON.parse(raw);
|
|
50933
|
-
if (pkg.name === "shallok-monorepo") return false;
|
|
50934
|
-
const hasShallok = Boolean(pkg.dependencies?.shallok || pkg.dependencies?.["@shallok/cli"]) || Boolean(pkg.devDependencies?.shallok || pkg.devDependencies?.["@shallok/cli"]);
|
|
50935
|
-
if (hasShallok) return false;
|
|
50936
|
-
const pm = await detectPackageManager(projectRoot);
|
|
50937
|
-
const installCmd = pm === "pnpm" ? "pnpm add -D shallok" : pm === "yarn" ? "yarn add -D shallok" : pm === "bun" ? "bun add -d shallok" : "npm install -D shallok";
|
|
50938
|
-
try {
|
|
50939
|
-
await execAsync(installCmd, { cwd: projectRoot });
|
|
50940
|
-
return true;
|
|
50941
|
-
} catch {
|
|
50942
|
-
pkg.devDependencies = pkg.devDependencies || {};
|
|
50943
|
-
pkg.devDependencies["shallok"] = "^0.1.0";
|
|
50944
|
-
await fs9.writeFile(pkgPath, JSON.stringify(pkg, null, 2) + "\n", "utf8");
|
|
50945
|
-
return true;
|
|
50946
|
-
}
|
|
50947
|
-
} catch {
|
|
50948
|
-
return false;
|
|
50949
|
-
}
|
|
50950
|
-
}
|
|
50951
|
-
async function installSkillsForProject(projectRoot, framework) {
|
|
50952
|
-
const pm = await detectPackageManager(projectRoot);
|
|
50953
|
-
const dependencyInstalled = await ensureShallokDependency(projectRoot);
|
|
50954
|
-
const skillsDir = resolveSkillsDir();
|
|
50955
|
-
const copiedSkills = [];
|
|
50956
|
-
const destinations = [];
|
|
50957
|
-
if (!skillsDir) {
|
|
50958
|
-
return {
|
|
50959
|
-
packageManager: pm,
|
|
50960
|
-
dependencyInstalled,
|
|
50961
|
-
copiedSkills,
|
|
50962
|
-
destinations
|
|
50963
|
-
};
|
|
50964
|
-
}
|
|
50965
|
-
const frameworkSkillMap = {
|
|
50966
|
-
react: "react-localization-and-translation-i18n",
|
|
50967
|
-
nextjs: "nextjs-localization-and-translation-i18n",
|
|
50968
|
-
expo: "expo-localization-and-translation-i18n",
|
|
50969
|
-
astro: "astro-localization-and-translation-i18n"
|
|
50970
|
-
};
|
|
50971
|
-
const selectedSkills = ["localization-and-translation-i18n"];
|
|
50972
|
-
const fwSkill = frameworkSkillMap[framework.toLowerCase()];
|
|
50973
|
-
if (fwSkill) {
|
|
50974
|
-
selectedSkills.push(fwSkill);
|
|
50975
|
-
}
|
|
50976
|
-
const targetRoots = [
|
|
50977
|
-
path10.resolve(projectRoot, ".agents", "skills"),
|
|
50978
|
-
path10.resolve(projectRoot, "skills")
|
|
50979
|
-
];
|
|
50980
|
-
for (const targetRoot of targetRoots) {
|
|
50981
|
-
for (const skillName of selectedSkills) {
|
|
50982
|
-
const srcSkillPath = path10.resolve(skillsDir, skillName);
|
|
50983
|
-
if (fsSync.existsSync(srcSkillPath)) {
|
|
50984
|
-
const destSkillPath = path10.resolve(targetRoot, skillName);
|
|
50985
|
-
await fs9.mkdir(destSkillPath, { recursive: true });
|
|
50986
|
-
await copyDirRecursive(srcSkillPath, destSkillPath);
|
|
50987
|
-
if (!copiedSkills.includes(skillName)) {
|
|
50988
|
-
copiedSkills.push(skillName);
|
|
50989
|
-
}
|
|
50990
|
-
}
|
|
50991
|
-
}
|
|
50992
|
-
destinations.push(path10.relative(projectRoot, targetRoot));
|
|
50993
|
-
}
|
|
50994
|
-
return {
|
|
50995
|
-
packageManager: pm,
|
|
50996
|
-
dependencyInstalled,
|
|
50997
|
-
copiedSkills,
|
|
50998
|
-
destinations
|
|
50999
|
-
};
|
|
51000
|
-
}
|
|
51001
|
-
async function copyDirRecursive(src, dest) {
|
|
51002
|
-
await fs9.mkdir(dest, { recursive: true });
|
|
51003
|
-
const entries = await fs9.readdir(src, { withFileTypes: true });
|
|
51004
|
-
for (const entry of entries) {
|
|
51005
|
-
const srcPath = path10.resolve(src, entry.name);
|
|
51006
|
-
const destPath = path10.resolve(dest, entry.name);
|
|
51007
|
-
if (entry.isDirectory()) {
|
|
51008
|
-
await copyDirRecursive(srcPath, destPath);
|
|
51009
|
-
} else {
|
|
51010
|
-
await fs9.copyFile(srcPath, destPath);
|
|
51011
|
-
}
|
|
51012
|
-
}
|
|
51013
|
-
}
|
|
51014
|
-
|
|
51015
51102
|
// src/commands/init.ts
|
|
51016
51103
|
async function initCommand(options) {
|
|
51017
51104
|
const cwd = process.cwd();
|
|
@@ -51055,7 +51142,7 @@ async function initCommand(options) {
|
|
|
51055
51142
|
}
|
|
51056
51143
|
};
|
|
51057
51144
|
await storage.writeManifest(manifest);
|
|
51058
|
-
const baseDir =
|
|
51145
|
+
const baseDir = path12.resolve(cwd, manifest.paths.base_directory);
|
|
51059
51146
|
await fs10.mkdir(baseDir, { recursive: true });
|
|
51060
51147
|
const existingCanonical = await storage.readCanonicalCatalog(
|
|
51061
51148
|
manifest.paths.base_directory,
|
|
@@ -51070,7 +51157,7 @@ async function initCommand(options) {
|
|
|
51070
51157
|
await storage.writeMetadata(
|
|
51071
51158
|
{
|
|
51072
51159
|
tool_name: "shallok",
|
|
51073
|
-
tool_version:
|
|
51160
|
+
tool_version: CLI_VERSION,
|
|
51074
51161
|
schema_version: 1,
|
|
51075
51162
|
last_extraction_at: now,
|
|
51076
51163
|
total_keys: Object.keys(existingCanonical).length,
|
|
@@ -51079,7 +51166,7 @@ async function initCommand(options) {
|
|
|
51079
51166
|
},
|
|
51080
51167
|
manifest.paths.base_directory
|
|
51081
51168
|
);
|
|
51082
|
-
const messagesDir =
|
|
51169
|
+
const messagesDir = path12.resolve(cwd, manifest.paths.translations_directory);
|
|
51083
51170
|
await fs10.mkdir(messagesDir, { recursive: true });
|
|
51084
51171
|
for (const loc of supportedLocales) {
|
|
51085
51172
|
const existingLocCatalog = await storage.readLocaleCatalog(loc, manifest.paths.translations_directory);
|
|
@@ -51090,13 +51177,11 @@ async function initCommand(options) {
|
|
|
51090
51177
|
supportedLocales,
|
|
51091
51178
|
router: analysis.framework.router
|
|
51092
51179
|
});
|
|
51093
|
-
const skillsResult = await installSkillsForProject(cwd, frameworkName);
|
|
51094
51180
|
if (options.json) {
|
|
51095
51181
|
printer.json({
|
|
51096
51182
|
success: true,
|
|
51097
51183
|
manifest,
|
|
51098
|
-
adapterResult
|
|
51099
|
-
skillsResult
|
|
51184
|
+
adapterResult
|
|
51100
51185
|
});
|
|
51101
51186
|
return;
|
|
51102
51187
|
}
|
|
@@ -51107,12 +51192,6 @@ async function initCommand(options) {
|
|
|
51107
51192
|
for (const f of adapterResult.createdFiles) {
|
|
51108
51193
|
printer.info(`Generated adapter file: ${f}`);
|
|
51109
51194
|
}
|
|
51110
|
-
if (skillsResult.dependencyInstalled) {
|
|
51111
|
-
printer.info(`Installed shallok in devDependencies (${skillsResult.packageManager})`);
|
|
51112
|
-
}
|
|
51113
|
-
for (const skill of skillsResult.copiedSkills) {
|
|
51114
|
-
printer.info(`Added AI agent skill: ${skill} (.agents/skills/ & skills/)`);
|
|
51115
|
-
}
|
|
51116
51195
|
} catch (err) {
|
|
51117
51196
|
printer.error(`Initialization failed: ${err.message}`);
|
|
51118
51197
|
process.exit(1);
|
|
@@ -51121,7 +51200,7 @@ async function initCommand(options) {
|
|
|
51121
51200
|
|
|
51122
51201
|
// src/commands/extract.ts
|
|
51123
51202
|
import fs11 from "fs/promises";
|
|
51124
|
-
import
|
|
51203
|
+
import path13 from "path";
|
|
51125
51204
|
import React2 from "react";
|
|
51126
51205
|
import { render as render2 } from "ink";
|
|
51127
51206
|
|
|
@@ -51189,7 +51268,7 @@ async function extractCommand(options) {
|
|
|
51189
51268
|
const storage = new CatalogStorage(cwd);
|
|
51190
51269
|
const manifest = await storage.readManifest();
|
|
51191
51270
|
if (!manifest) {
|
|
51192
|
-
printer.error('No localization.json found. Run "
|
|
51271
|
+
printer.error('No localization.json found. Run "shallok init" first.');
|
|
51193
51272
|
process.exit(1);
|
|
51194
51273
|
}
|
|
51195
51274
|
const isDryRun = options.dryRun ?? false;
|
|
@@ -51206,7 +51285,7 @@ async function extractCommand(options) {
|
|
|
51206
51285
|
const allExtractedStrings = [];
|
|
51207
51286
|
const modifiedFiles = [];
|
|
51208
51287
|
for (const relPath of filePaths) {
|
|
51209
|
-
const fullPath =
|
|
51288
|
+
const fullPath = path13.resolve(cwd, relPath);
|
|
51210
51289
|
const code = await fs11.readFile(fullPath, "utf8");
|
|
51211
51290
|
if (shouldApplyCodeTransform && !isDryRun) {
|
|
51212
51291
|
const transformRes = transformSourceFile({
|
|
@@ -51248,7 +51327,7 @@ async function extractCommand(options) {
|
|
|
51248
51327
|
await storage.writeMetadata(
|
|
51249
51328
|
{
|
|
51250
51329
|
tool_name: "shallok",
|
|
51251
|
-
tool_version:
|
|
51330
|
+
tool_version: CLI_VERSION,
|
|
51252
51331
|
schema_version: 1,
|
|
51253
51332
|
last_extraction_at: now,
|
|
51254
51333
|
total_keys: Object.keys(reconciliation.catalog).length,
|
|
@@ -51647,7 +51726,7 @@ async function translateCommand(options) {
|
|
|
51647
51726
|
const storage = new CatalogStorage(cwd);
|
|
51648
51727
|
const manifest = await storage.readManifest();
|
|
51649
51728
|
if (!manifest) {
|
|
51650
|
-
printer.error('No localization.json found. Run "
|
|
51729
|
+
printer.error('No localization.json found. Run "shallok init" first.');
|
|
51651
51730
|
process.exit(1);
|
|
51652
51731
|
}
|
|
51653
51732
|
const canonical = await storage.readCanonicalCatalog(
|
|
@@ -51772,7 +51851,7 @@ async function statusCommand(options) {
|
|
|
51772
51851
|
const storage = new CatalogStorage(cwd);
|
|
51773
51852
|
const manifest = await storage.readManifest();
|
|
51774
51853
|
if (!manifest) {
|
|
51775
|
-
printer.error('No localization.json found. Run "
|
|
51854
|
+
printer.error('No localization.json found. Run "shallok init" first.');
|
|
51776
51855
|
process.exit(1);
|
|
51777
51856
|
}
|
|
51778
51857
|
const canonical = await storage.readCanonicalCatalog(
|
|
@@ -51816,7 +51895,7 @@ async function validateCommand(options) {
|
|
|
51816
51895
|
const storage = new CatalogStorage(cwd);
|
|
51817
51896
|
const manifest = await storage.readManifest();
|
|
51818
51897
|
if (!manifest) {
|
|
51819
|
-
printer.error('No localization.json found. Run "
|
|
51898
|
+
printer.error('No localization.json found. Run "shallok init" first.');
|
|
51820
51899
|
process.exit(1);
|
|
51821
51900
|
}
|
|
51822
51901
|
const canonical = await storage.readCanonicalCatalog(
|
|
@@ -51864,7 +51943,7 @@ async function buildCommand(options) {
|
|
|
51864
51943
|
const storage = new CatalogStorage(cwd);
|
|
51865
51944
|
const manifest = await storage.readManifest();
|
|
51866
51945
|
if (!manifest) {
|
|
51867
|
-
printer.error('No localization.json found. Run "
|
|
51946
|
+
printer.error('No localization.json found. Run "shallok init" first.');
|
|
51868
51947
|
process.exit(1);
|
|
51869
51948
|
}
|
|
51870
51949
|
const canonical = await storage.readCanonicalCatalog(
|
|
@@ -51908,7 +51987,7 @@ async function reportCommand(options) {
|
|
|
51908
51987
|
const storage = new CatalogStorage(cwd);
|
|
51909
51988
|
const manifest = await storage.readManifest();
|
|
51910
51989
|
if (!manifest) {
|
|
51911
|
-
printer.error('No localization.json found. Run "
|
|
51990
|
+
printer.error('No localization.json found. Run "shallok init" first.');
|
|
51912
51991
|
process.exit(1);
|
|
51913
51992
|
}
|
|
51914
51993
|
const canonical = await storage.readCanonicalCatalog(
|
|
@@ -51968,7 +52047,7 @@ async function localeAddCommand(locale, options) {
|
|
|
51968
52047
|
const storage = new CatalogStorage(cwd);
|
|
51969
52048
|
const manifest = await storage.readManifest();
|
|
51970
52049
|
if (!manifest) {
|
|
51971
|
-
printer.error('No localization.json found. Run "
|
|
52050
|
+
printer.error('No localization.json found. Run "shallok init" first.');
|
|
51972
52051
|
process.exit(1);
|
|
51973
52052
|
}
|
|
51974
52053
|
const cleanLocale = locale.trim().toLowerCase();
|
|
@@ -51997,7 +52076,7 @@ async function localeAddCommand(locale, options) {
|
|
|
51997
52076
|
return;
|
|
51998
52077
|
}
|
|
51999
52078
|
printer.success(`Added locale "${cleanLocale}" to supported_locales.`);
|
|
52000
|
-
printer.info(`Run "
|
|
52079
|
+
printer.info(`Run "shallok translate --locale ${cleanLocale}" to generate translations for this locale.`);
|
|
52001
52080
|
}
|
|
52002
52081
|
async function localeRemoveCommand(locale, options) {
|
|
52003
52082
|
const cwd = process.cwd();
|
|
@@ -52005,7 +52084,7 @@ async function localeRemoveCommand(locale, options) {
|
|
|
52005
52084
|
const storage = new CatalogStorage(cwd);
|
|
52006
52085
|
const manifest = await storage.readManifest();
|
|
52007
52086
|
if (!manifest) {
|
|
52008
|
-
printer.error('No localization.json found. Run "
|
|
52087
|
+
printer.error('No localization.json found. Run "shallok init" first.');
|
|
52009
52088
|
process.exit(1);
|
|
52010
52089
|
}
|
|
52011
52090
|
const cleanLocale = locale.trim().toLowerCase();
|
|
@@ -52060,7 +52139,7 @@ async function renameCommand(oldKey, newKey, options) {
|
|
|
52060
52139
|
const storage = new CatalogStorage(cwd);
|
|
52061
52140
|
const manifest = await storage.readManifest();
|
|
52062
52141
|
if (!manifest) {
|
|
52063
|
-
printer.error('No localization.json found. Run "
|
|
52142
|
+
printer.error('No localization.json found. Run "shallok init" first.');
|
|
52064
52143
|
process.exit(1);
|
|
52065
52144
|
}
|
|
52066
52145
|
const canonical = await storage.readCanonicalCatalog(
|
|
@@ -52120,7 +52199,7 @@ async function contextSetCommand(key, newContext, options) {
|
|
|
52120
52199
|
const storage = new CatalogStorage(cwd);
|
|
52121
52200
|
const manifest = await storage.readManifest();
|
|
52122
52201
|
if (!manifest) {
|
|
52123
|
-
printer.error('No localization.json found. Run "
|
|
52202
|
+
printer.error('No localization.json found. Run "shallok init" first.');
|
|
52124
52203
|
process.exit(1);
|
|
52125
52204
|
}
|
|
52126
52205
|
const canonical = await storage.readCanonicalCatalog(
|
|
@@ -52162,7 +52241,7 @@ async function entrySetCommand(locale, key, translatedValue, options) {
|
|
|
52162
52241
|
const storage = new CatalogStorage(cwd);
|
|
52163
52242
|
const manifest = await storage.readManifest();
|
|
52164
52243
|
if (!manifest) {
|
|
52165
|
-
printer.error('No localization.json found. Run "
|
|
52244
|
+
printer.error('No localization.json found. Run "shallok init" first.');
|
|
52166
52245
|
process.exit(1);
|
|
52167
52246
|
}
|
|
52168
52247
|
const cleanLocale = locale.trim().toLowerCase();
|
|
@@ -52208,7 +52287,11 @@ async function entrySetCommand(locale, key, translatedValue, options) {
|
|
|
52208
52287
|
|
|
52209
52288
|
// src/index.ts
|
|
52210
52289
|
var program = new Command();
|
|
52211
|
-
program.name("shallok").description("Shallok: AI-Powered, Versioned Localization Tool").version(
|
|
52290
|
+
program.name("shallok").description("Shallok: AI-Powered, Versioned Localization Tool").version(CLI_VERSION).option("--json", "Output machine-readable JSON for AI agent orchestration");
|
|
52291
|
+
program.command("setup").description("Set up Shallok in project: install devDependency and copy agent skill (For developers only)").option("--framework <name>", "Override framework detection (react, nextjs, expo, astro)").option("--json", "Output machine-readable JSON").action(async (options) => {
|
|
52292
|
+
const isJson = options.json || program.opts().json;
|
|
52293
|
+
await setupCommand({ ...options, json: isJson });
|
|
52294
|
+
});
|
|
52212
52295
|
program.command("analyze").description("Analyze the repository without modifying it").option("--json", "Output machine-readable JSON").action(async (options) => {
|
|
52213
52296
|
const isJson = options.json || program.opts().json;
|
|
52214
52297
|
await analyzeCommand({ json: isJson });
|