@formatjs/cli 5.0.0 → 5.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/formatjs CHANGED
@@ -148054,1081 +148054,1082 @@ var require_console_utils = __commonJS({
148054
148054
  }
148055
148055
  });
148056
148056
 
148057
- // bazel-out/darwin-fastbuild/bin/packages/ts-transformer/src/transform.js
148058
- var require_transform = __commonJS({
148059
- "bazel-out/darwin-fastbuild/bin/packages/ts-transformer/src/transform.js"(exports) {
148060
- "use strict";
148061
- Object.defineProperty(exports, "__esModule", { value: true });
148062
- exports.transform = exports.transformWithTs = void 0;
148063
- var tslib_1 = require_tslib();
148064
- var typescript = (0, tslib_1.__importStar)(require_typescript());
148065
- var interpolate_name_1 = require_interpolate_name();
148066
- var icu_messageformat_parser_1 = require_icu_messageformat_parser();
148067
- var console_utils_1 = require_console_utils();
148068
- var MESSAGE_DESC_KEYS = [
148069
- "id",
148070
- "defaultMessage",
148071
- "description"
148072
- ];
148073
- function primitiveToTSNode(factory, v) {
148074
- return typeof v === "string" ? factory.createStringLiteral(v) : typeof v === "number" ? factory.createNumericLiteral(v + "") : typeof v === "boolean" ? v ? factory.createTrue() : factory.createFalse() : void 0;
148075
- }
148076
- function isValidIdentifier(k) {
148077
- try {
148078
- new Function("return {".concat(k, ":1}"));
148079
- return true;
148080
- } catch (e) {
148081
- return false;
148057
+ // bazel-out/darwin-fastbuild/bin/external/npm/node_modules/jsonify/lib/parse.js
148058
+ var require_parse = __commonJS({
148059
+ "bazel-out/darwin-fastbuild/bin/external/npm/node_modules/jsonify/lib/parse.js"(exports, module2) {
148060
+ var at;
148061
+ var ch;
148062
+ var escapee = {
148063
+ '"': '"',
148064
+ "\\": "\\",
148065
+ "/": "/",
148066
+ b: "\b",
148067
+ f: "\f",
148068
+ n: "\n",
148069
+ r: "\r",
148070
+ t: " "
148071
+ };
148072
+ var text;
148073
+ var error = function(m) {
148074
+ throw {
148075
+ name: "SyntaxError",
148076
+ message: m,
148077
+ at,
148078
+ text
148079
+ };
148080
+ };
148081
+ var next = function(c) {
148082
+ if (c && c !== ch) {
148083
+ error("Expected '" + c + "' instead of '" + ch + "'");
148082
148084
  }
148083
- }
148084
- function objToTSNode(factory, obj) {
148085
- if (typeof obj === "object" && !obj) {
148086
- return factory.createNull();
148085
+ ch = text.charAt(at);
148086
+ at += 1;
148087
+ return ch;
148088
+ };
148089
+ var number = function() {
148090
+ var number2, string2 = "";
148091
+ if (ch === "-") {
148092
+ string2 = "-";
148093
+ next("-");
148087
148094
  }
148088
- var props = Object.entries(obj).filter(function(_a) {
148089
- var _ = _a[0], v = _a[1];
148090
- return typeof v !== "undefined";
148091
- }).map(function(_a) {
148092
- var k = _a[0], v = _a[1];
148093
- return factory.createPropertyAssignment(isValidIdentifier(k) ? k : factory.createStringLiteral(k), primitiveToTSNode(factory, v) || (Array.isArray(v) ? factory.createArrayLiteralExpression(v.filter(function(n) {
148094
- return typeof n !== "undefined";
148095
- }).map(function(n) {
148096
- return objToTSNode(factory, n);
148097
- })) : objToTSNode(factory, v)));
148098
- });
148099
- return factory.createObjectLiteralExpression(props);
148100
- }
148101
- function messageASTToTSNode(factory, ast) {
148102
- return factory.createArrayLiteralExpression(ast.map(function(el) {
148103
- return objToTSNode(factory, el);
148104
- }));
148105
- }
148106
- function literalToObj(ts2, n) {
148107
- if (ts2.isNumericLiteral(n)) {
148108
- return +n.text;
148095
+ while (ch >= "0" && ch <= "9") {
148096
+ string2 += ch;
148097
+ next();
148109
148098
  }
148110
- if (ts2.isStringLiteral(n)) {
148111
- return n.text;
148099
+ if (ch === ".") {
148100
+ string2 += ".";
148101
+ while (next() && ch >= "0" && ch <= "9") {
148102
+ string2 += ch;
148103
+ }
148112
148104
  }
148113
- if (n.kind === ts2.SyntaxKind.TrueKeyword) {
148114
- return true;
148105
+ if (ch === "e" || ch === "E") {
148106
+ string2 += ch;
148107
+ next();
148108
+ if (ch === "-" || ch === "+") {
148109
+ string2 += ch;
148110
+ next();
148111
+ }
148112
+ while (ch >= "0" && ch <= "9") {
148113
+ string2 += ch;
148114
+ next();
148115
+ }
148115
148116
  }
148116
- if (n.kind === ts2.SyntaxKind.FalseKeyword) {
148117
- return false;
148117
+ number2 = +string2;
148118
+ if (!isFinite(number2)) {
148119
+ error("Bad number");
148120
+ } else {
148121
+ return number2;
148118
148122
  }
148119
- }
148120
- function objectLiteralExpressionToObj(ts2, obj) {
148121
- return obj.properties.reduce(function(all, prop) {
148122
- if (ts2.isPropertyAssignment(prop) && prop.name) {
148123
- if (ts2.isIdentifier(prop.name)) {
148124
- all[prop.name.escapedText.toString()] = literalToObj(ts2, prop.initializer);
148125
- } else if (ts2.isStringLiteral(prop.name)) {
148126
- all[prop.name.text] = literalToObj(ts2, prop.initializer);
148123
+ };
148124
+ var string = function() {
148125
+ var hex, i, string2 = "", uffff;
148126
+ if (ch === '"') {
148127
+ while (next()) {
148128
+ if (ch === '"') {
148129
+ next();
148130
+ return string2;
148131
+ } else if (ch === "\\") {
148132
+ next();
148133
+ if (ch === "u") {
148134
+ uffff = 0;
148135
+ for (i = 0; i < 4; i += 1) {
148136
+ hex = parseInt(next(), 16);
148137
+ if (!isFinite(hex)) {
148138
+ break;
148139
+ }
148140
+ uffff = uffff * 16 + hex;
148141
+ }
148142
+ string2 += String.fromCharCode(uffff);
148143
+ } else if (typeof escapee[ch] === "string") {
148144
+ string2 += escapee[ch];
148145
+ } else {
148146
+ break;
148147
+ }
148148
+ } else {
148149
+ string2 += ch;
148127
148150
  }
148128
148151
  }
148129
- return all;
148130
- }, {});
148131
- }
148132
- var DEFAULT_OPTS = {
148133
- onMsgExtracted: function() {
148134
- return void 0;
148135
- },
148136
- onMetaExtracted: function() {
148137
- return void 0;
148138
148152
  }
148153
+ error("Bad string");
148139
148154
  };
148140
- function isMultipleMessageDecl(ts2, node) {
148141
- return ts2.isIdentifier(node.expression) && node.expression.text === "defineMessages";
148142
- }
148143
- function isSingularMessageDecl(ts2, node, additionalComponentNames) {
148144
- var compNames = new Set((0, tslib_1.__spreadArray)([
148145
- "FormattedMessage",
148146
- "defineMessage",
148147
- "formatMessage",
148148
- "$formatMessage"
148149
- ], additionalComponentNames, true));
148150
- var fnName = "";
148151
- if (ts2.isCallExpression(node) && ts2.isIdentifier(node.expression)) {
148152
- fnName = node.expression.text;
148153
- } else if (ts2.isJsxOpeningElement(node) && ts2.isIdentifier(node.tagName)) {
148154
- fnName = node.tagName.text;
148155
- } else if (ts2.isJsxSelfClosingElement(node) && ts2.isIdentifier(node.tagName)) {
148156
- fnName = node.tagName.text;
148157
- }
148158
- return compNames.has(fnName);
148159
- }
148160
- function evaluateStringConcat(ts2, node) {
148161
- var right = node.right, left = node.left;
148162
- if (!ts2.isStringLiteral(right)) {
148163
- return ["", false];
148164
- }
148165
- if (ts2.isStringLiteral(left)) {
148166
- return [left.text + right.text, true];
148167
- }
148168
- if (ts2.isBinaryExpression(left)) {
148169
- var _a = evaluateStringConcat(ts2, left), result = _a[0], isStatic = _a[1];
148170
- return [result + right.text, isStatic];
148155
+ var white = function() {
148156
+ while (ch && ch <= " ") {
148157
+ next();
148171
148158
  }
148172
- return ["", false];
148173
- }
148174
- function extractMessageDescriptor(ts2, node, _a, sf) {
148175
- var overrideIdFn = _a.overrideIdFn, extractSourceLocation = _a.extractSourceLocation, preserveWhitespace = _a.preserveWhitespace;
148176
- var properties = void 0;
148177
- if (ts2.isObjectLiteralExpression(node)) {
148178
- properties = node.properties;
148179
- } else if (ts2.isJsxOpeningElement(node) || ts2.isJsxSelfClosingElement(node)) {
148180
- properties = node.attributes.properties;
148159
+ };
148160
+ var word = function() {
148161
+ switch (ch) {
148162
+ case "t":
148163
+ next("t");
148164
+ next("r");
148165
+ next("u");
148166
+ next("e");
148167
+ return true;
148168
+ case "f":
148169
+ next("f");
148170
+ next("a");
148171
+ next("l");
148172
+ next("s");
148173
+ next("e");
148174
+ return false;
148175
+ case "n":
148176
+ next("n");
148177
+ next("u");
148178
+ next("l");
148179
+ next("l");
148180
+ return null;
148181
148181
  }
148182
- var msg = { id: "" };
148183
- if (!properties) {
148184
- return;
148182
+ error("Unexpected '" + ch + "'");
148183
+ };
148184
+ var value;
148185
+ var array = function() {
148186
+ var array2 = [];
148187
+ if (ch === "[") {
148188
+ next("[");
148189
+ white();
148190
+ if (ch === "]") {
148191
+ next("]");
148192
+ return array2;
148193
+ }
148194
+ while (ch) {
148195
+ array2.push(value());
148196
+ white();
148197
+ if (ch === "]") {
148198
+ next("]");
148199
+ return array2;
148200
+ }
148201
+ next(",");
148202
+ white();
148203
+ }
148185
148204
  }
148186
- properties.forEach(function(prop) {
148187
- var name = prop.name;
148188
- var initializer = ts2.isPropertyAssignment(prop) || ts2.isJsxAttribute(prop) ? prop.initializer : void 0;
148189
- if (name && ts2.isIdentifier(name) && initializer) {
148190
- if (ts2.isStringLiteral(initializer)) {
148191
- switch (name.text) {
148192
- case "id":
148193
- msg.id = initializer.text;
148194
- break;
148195
- case "defaultMessage":
148196
- msg.defaultMessage = initializer.text;
148197
- break;
148198
- case "description":
148199
- msg.description = initializer.text;
148200
- break;
148201
- }
148202
- } else if (ts2.isNoSubstitutionTemplateLiteral(initializer)) {
148203
- switch (name.text) {
148204
- case "id":
148205
- msg.id = initializer.text;
148206
- break;
148207
- case "defaultMessage":
148208
- msg.defaultMessage = initializer.text;
148209
- break;
148210
- case "description":
148211
- msg.description = initializer.text;
148212
- break;
148213
- }
148214
- } else if (ts2.isJsxExpression(initializer) && initializer.expression) {
148215
- if (ts2.isStringLiteral(initializer.expression)) {
148216
- switch (name.text) {
148217
- case "id":
148218
- msg.id = initializer.expression.text;
148219
- break;
148220
- case "defaultMessage":
148221
- msg.defaultMessage = initializer.expression.text;
148222
- break;
148223
- case "description":
148224
- msg.description = initializer.expression.text;
148225
- break;
148226
- }
148227
- } else if (ts2.isObjectLiteralExpression(initializer.expression) && name.text === "description") {
148228
- msg.description = objectLiteralExpressionToObj(ts2, initializer.expression);
148229
- } else if (ts2.isNoSubstitutionTemplateLiteral(initializer.expression)) {
148230
- var expression = initializer.expression;
148231
- switch (name.text) {
148232
- case "id":
148233
- msg.id = expression.text;
148234
- break;
148235
- case "defaultMessage":
148236
- msg.defaultMessage = expression.text;
148237
- break;
148238
- case "description":
148239
- msg.description = expression.text;
148240
- break;
148241
- }
148242
- } else if (ts2.isBinaryExpression(initializer.expression)) {
148243
- var expression = initializer.expression;
148244
- var _a2 = evaluateStringConcat(ts2, expression), result = _a2[0], isStatic = _a2[1];
148245
- if (isStatic) {
148246
- switch (name.text) {
148247
- case "id":
148248
- msg.id = result;
148249
- break;
148250
- case "defaultMessage":
148251
- msg.defaultMessage = result;
148252
- break;
148253
- case "description":
148254
- msg.description = result;
148255
- break;
148256
- }
148257
- }
148258
- }
148259
- } else if (ts2.isBinaryExpression(initializer)) {
148260
- var _b = evaluateStringConcat(ts2, initializer), result = _b[0], isStatic = _b[1];
148261
- if (isStatic) {
148262
- switch (name.text) {
148263
- case "id":
148264
- msg.id = result;
148265
- break;
148266
- case "defaultMessage":
148267
- msg.defaultMessage = result;
148268
- break;
148269
- case "description":
148270
- msg.description = result;
148271
- break;
148272
- }
148273
- }
148274
- } else if (ts2.isObjectLiteralExpression(initializer) && name.text === "description") {
148275
- msg.description = objectLiteralExpressionToObj(ts2, initializer);
148276
- }
148277
- }
148278
- });
148279
- if (!msg.defaultMessage && !msg.id) {
148280
- return;
148281
- }
148282
- if (msg.defaultMessage && !preserveWhitespace) {
148283
- msg.defaultMessage = msg.defaultMessage.trim().replace(/\s+/gm, " ");
148284
- }
148285
- if (msg.defaultMessage && overrideIdFn) {
148286
- switch (typeof overrideIdFn) {
148287
- case "string":
148288
- if (!msg.id) {
148289
- msg.id = (0, interpolate_name_1.interpolateName)({ resourcePath: sf.fileName }, overrideIdFn, {
148290
- content: msg.description ? "".concat(msg.defaultMessage, "#").concat(msg.description) : msg.defaultMessage
148291
- });
148292
- }
148293
- break;
148294
- case "function":
148295
- msg.id = overrideIdFn(msg.id, msg.defaultMessage, msg.description, sf.fileName);
148296
- break;
148297
- }
148298
- }
148299
- if (extractSourceLocation) {
148300
- return (0, tslib_1.__assign)((0, tslib_1.__assign)({}, msg), { file: sf.fileName, start: node.pos, end: node.end });
148301
- }
148302
- return msg;
148303
- }
148304
- function isMemberMethodFormatMessageCall(ts2, node, additionalFunctionNames) {
148305
- var fnNames = new Set((0, tslib_1.__spreadArray)([
148306
- "formatMessage",
148307
- "$formatMessage"
148308
- ], additionalFunctionNames, true));
148309
- var method = node.expression;
148310
- if (ts2.isPropertyAccessExpression(method)) {
148311
- return fnNames.has(method.name.text);
148312
- }
148313
- return ts2.isIdentifier(method) && fnNames.has(method.text);
148314
- }
148315
- function extractMessageFromJsxComponent(ts2, factory, node, opts, sf) {
148316
- var onMsgExtracted = opts.onMsgExtracted;
148317
- if (!isSingularMessageDecl(ts2, node, opts.additionalComponentNames || [])) {
148318
- return node;
148319
- }
148320
- var msg = extractMessageDescriptor(ts2, node, opts, sf);
148321
- if (!msg) {
148322
- return node;
148323
- }
148324
- if (typeof onMsgExtracted === "function") {
148325
- onMsgExtracted(sf.fileName, [msg]);
148326
- }
148327
- var newProps = generateNewProperties(ts2, factory, node.attributes, {
148328
- defaultMessage: opts.removeDefaultMessage ? void 0 : msg.defaultMessage,
148329
- id: msg.id
148330
- }, opts.ast);
148331
- if (ts2.isJsxOpeningElement(node)) {
148332
- return factory.updateJsxOpeningElement(node, node.tagName, node.typeArguments, factory.createJsxAttributes(newProps));
148333
- }
148334
- return factory.updateJsxSelfClosingElement(node, node.tagName, node.typeArguments, factory.createJsxAttributes(newProps));
148335
- }
148336
- function setAttributesInObject(ts2, factory, node, msg, ast) {
148337
- var newProps = (0, tslib_1.__spreadArray)([
148338
- factory.createPropertyAssignment("id", factory.createStringLiteral(msg.id))
148339
- ], msg.defaultMessage ? [
148340
- factory.createPropertyAssignment("defaultMessage", ast ? messageASTToTSNode(factory, (0, icu_messageformat_parser_1.parse)(msg.defaultMessage)) : factory.createStringLiteral(msg.defaultMessage))
148341
- ] : [], true);
148342
- for (var _i = 0, _a = node.properties; _i < _a.length; _i++) {
148343
- var prop = _a[_i];
148344
- if (ts2.isPropertyAssignment(prop) && ts2.isIdentifier(prop.name) && MESSAGE_DESC_KEYS.includes(prop.name.text)) {
148345
- continue;
148346
- }
148347
- if (ts2.isPropertyAssignment(prop)) {
148348
- newProps.push(prop);
148349
- }
148350
- }
148351
- return factory.createObjectLiteralExpression(factory.createNodeArray(newProps));
148352
- }
148353
- function generateNewProperties(ts2, factory, node, msg, ast) {
148354
- var newProps = (0, tslib_1.__spreadArray)([
148355
- factory.createJsxAttribute(factory.createIdentifier("id"), factory.createStringLiteral(msg.id))
148356
- ], msg.defaultMessage ? [
148357
- factory.createJsxAttribute(factory.createIdentifier("defaultMessage"), ast ? factory.createJsxExpression(void 0, messageASTToTSNode(factory, (0, icu_messageformat_parser_1.parse)(msg.defaultMessage))) : factory.createStringLiteral(msg.defaultMessage))
148358
- ] : [], true);
148359
- for (var _i = 0, _a = node.properties; _i < _a.length; _i++) {
148360
- var prop = _a[_i];
148361
- if (ts2.isJsxAttribute(prop) && ts2.isIdentifier(prop.name) && MESSAGE_DESC_KEYS.includes(prop.name.text)) {
148362
- continue;
148363
- }
148364
- if (ts2.isJsxAttribute(prop)) {
148365
- newProps.push(prop);
148366
- }
148367
- }
148368
- return newProps;
148369
- }
148370
- function extractMessagesFromCallExpression(ts2, factory, node, opts, sf) {
148371
- var onMsgExtracted = opts.onMsgExtracted, additionalFunctionNames = opts.additionalFunctionNames;
148372
- if (isMultipleMessageDecl(ts2, node)) {
148373
- var _a = node.arguments, arg = _a[0], restArgs = _a.slice(1);
148374
- var descriptorsObj = void 0;
148375
- if (ts2.isObjectLiteralExpression(arg)) {
148376
- descriptorsObj = arg;
148377
- } else if (ts2.isAsExpression(arg) && ts2.isObjectLiteralExpression(arg.expression)) {
148378
- descriptorsObj = arg.expression;
148379
- }
148380
- if (descriptorsObj) {
148381
- var properties = descriptorsObj.properties;
148382
- var msgs_1 = properties.filter(function(prop) {
148383
- return ts2.isPropertyAssignment(prop);
148384
- }).map(function(prop) {
148385
- return ts2.isObjectLiteralExpression(prop.initializer) && extractMessageDescriptor(ts2, prop.initializer, opts, sf);
148386
- }).filter(function(msg2) {
148387
- return !!msg2;
148388
- });
148389
- if (!msgs_1.length) {
148390
- return node;
148391
- }
148392
- (0, console_utils_1.debug)('Multiple messages extracted from "%s": %s', sf.fileName, msgs_1);
148393
- if (typeof onMsgExtracted === "function") {
148394
- onMsgExtracted(sf.fileName, msgs_1);
148395
- }
148396
- var clonedProperties = factory.createNodeArray(properties.map(function(prop, i) {
148397
- if (!ts2.isPropertyAssignment(prop) || !ts2.isObjectLiteralExpression(prop.initializer)) {
148398
- return prop;
148399
- }
148400
- return factory.createPropertyAssignment(prop.name, setAttributesInObject(ts2, factory, prop.initializer, {
148401
- defaultMessage: opts.removeDefaultMessage ? void 0 : msgs_1[i].defaultMessage,
148402
- id: msgs_1[i] ? msgs_1[i].id : ""
148403
- }, opts.ast));
148404
- }));
148405
- var clonedDescriptorsObj = factory.createObjectLiteralExpression(clonedProperties);
148406
- return factory.updateCallExpression(node, node.expression, node.typeArguments, (0, tslib_1.__spreadArray)([clonedDescriptorsObj], restArgs, true));
148205
+ error("Bad array");
148206
+ };
148207
+ var object = function() {
148208
+ var key, object2 = {};
148209
+ if (ch === "{") {
148210
+ next("{");
148211
+ white();
148212
+ if (ch === "}") {
148213
+ next("}");
148214
+ return object2;
148407
148215
  }
148408
- } else if (isSingularMessageDecl(ts2, node, opts.additionalComponentNames || []) || isMemberMethodFormatMessageCall(ts2, node, additionalFunctionNames || [])) {
148409
- var _b = node.arguments, descriptorsObj = _b[0], restArgs = _b.slice(1);
148410
- if (ts2.isObjectLiteralExpression(descriptorsObj)) {
148411
- var msg = extractMessageDescriptor(ts2, descriptorsObj, opts, sf);
148412
- if (!msg) {
148413
- return node;
148216
+ while (ch) {
148217
+ key = string();
148218
+ white();
148219
+ next(":");
148220
+ if (Object.hasOwnProperty.call(object2, key)) {
148221
+ error('Duplicate key "' + key + '"');
148414
148222
  }
148415
- (0, console_utils_1.debug)('Message extracted from "%s": %s', sf.fileName, msg);
148416
- if (typeof onMsgExtracted === "function") {
148417
- onMsgExtracted(sf.fileName, [msg]);
148223
+ object2[key] = value();
148224
+ white();
148225
+ if (ch === "}") {
148226
+ next("}");
148227
+ return object2;
148418
148228
  }
148419
- return factory.updateCallExpression(node, node.expression, node.typeArguments, (0, tslib_1.__spreadArray)([
148420
- setAttributesInObject(ts2, factory, descriptorsObj, {
148421
- defaultMessage: opts.removeDefaultMessage ? void 0 : msg.defaultMessage,
148422
- id: msg.id
148423
- }, opts.ast)
148424
- ], restArgs, true));
148229
+ next(",");
148230
+ white();
148425
148231
  }
148426
148232
  }
148427
- return node;
148428
- }
148429
- var PRAGMA_REGEX = /^\/\/ @([^\s]*) (.*)$/m;
148430
- function getVisitor(ts2, ctx, sf, opts) {
148431
- var visitor = function(node) {
148432
- var newNode = ts2.isCallExpression(node) ? extractMessagesFromCallExpression(ts2, ctx.factory, node, opts, sf) : ts2.isJsxOpeningElement(node) || ts2.isJsxSelfClosingElement(node) ? extractMessageFromJsxComponent(ts2, ctx.factory, node, opts, sf) : node;
148433
- return ts2.visitEachChild(newNode, visitor, ctx);
148434
- };
148435
- return visitor;
148436
- }
148437
- function transformWithTs2(ts2, opts) {
148438
- opts = (0, tslib_1.__assign)((0, tslib_1.__assign)({}, DEFAULT_OPTS), opts);
148439
- (0, console_utils_1.debug)("Transforming options", opts);
148440
- var transformFn = function(ctx) {
148441
- return function(sf) {
148442
- var pragmaResult = PRAGMA_REGEX.exec(sf.text);
148443
- if (pragmaResult) {
148444
- (0, console_utils_1.debug)("Pragma found", pragmaResult);
148445
- var pragma = pragmaResult[1], kvString = pragmaResult[2];
148446
- if (pragma === opts.pragma) {
148447
- var kvs = kvString.split(" ");
148448
- var result = {};
148449
- for (var _i = 0, kvs_1 = kvs; _i < kvs_1.length; _i++) {
148450
- var kv = kvs_1[_i];
148451
- var _a = kv.split(":"), k = _a[0], v = _a[1];
148452
- result[k] = v;
148453
- }
148454
- (0, console_utils_1.debug)("Pragma extracted", result);
148455
- if (typeof opts.onMetaExtracted === "function") {
148456
- opts.onMetaExtracted(sf.fileName, result);
148457
- }
148458
- }
148459
- }
148460
- return ts2.visitNode(sf, getVisitor(ts2, ctx, sf, opts));
148461
- };
148462
- };
148463
- return transformFn;
148464
- }
148465
- exports.transformWithTs = transformWithTs2;
148466
- function transform(opts) {
148467
- return transformWithTs2(typescript, opts);
148468
- }
148469
- exports.transform = transform;
148470
- }
148471
- });
148472
-
148473
- // bazel-out/darwin-fastbuild/bin/packages/ts-transformer/src/types.js
148474
- var require_types2 = __commonJS({
148475
- "bazel-out/darwin-fastbuild/bin/packages/ts-transformer/src/types.js"(exports) {
148476
- "use strict";
148477
- Object.defineProperty(exports, "__esModule", { value: true });
148478
- }
148479
- });
148480
-
148481
- // bazel-out/darwin-fastbuild/bin/packages/ts-transformer/index.js
148482
- var require_ts_transformer = __commonJS({
148483
- "bazel-out/darwin-fastbuild/bin/packages/ts-transformer/index.js"(exports) {
148484
- "use strict";
148485
- Object.defineProperty(exports, "__esModule", { value: true });
148486
- var tslib_1 = require_tslib();
148487
- (0, tslib_1.__exportStar)(require_transform(), exports);
148488
- (0, tslib_1.__exportStar)(require_types2(), exports);
148489
- (0, tslib_1.__exportStar)(require_interpolate_name(), exports);
148490
- }
148491
- });
148492
-
148493
- // bazel-out/darwin-fastbuild/bin/packages/cli/lib_esnext/src/formatters/default.js
148494
- var default_exports = {};
148495
- __export(default_exports, {
148496
- compile: () => compile,
148497
- format: () => format2
148498
- });
148499
- var format2, compile;
148500
- var init_default = __esm({
148501
- "bazel-out/darwin-fastbuild/bin/packages/cli/lib_esnext/src/formatters/default.js"() {
148502
- format2 = (msgs) => msgs;
148503
- compile = (msgs) => {
148504
- const results = {};
148505
- for (const k in msgs) {
148506
- results[k] = msgs[k].defaultMessage;
148507
- }
148508
- return results;
148509
- };
148510
- }
148511
- });
148512
-
148513
- // bazel-out/darwin-fastbuild/bin/packages/cli/lib_esnext/src/formatters/transifex.js
148514
- var transifex_exports = {};
148515
- __export(transifex_exports, {
148516
- compile: () => compile2,
148517
- format: () => format3
148518
- });
148519
- var format3, compile2;
148520
- var init_transifex = __esm({
148521
- "bazel-out/darwin-fastbuild/bin/packages/cli/lib_esnext/src/formatters/transifex.js"() {
148522
- format3 = (msgs) => {
148523
- const results = {};
148524
- for (const [id, msg] of Object.entries(msgs)) {
148525
- results[id] = {
148526
- string: msg.defaultMessage,
148527
- developer_comment: typeof msg.description === "string" ? msg.description : JSON.stringify(msg.description)
148528
- };
148529
- }
148530
- return results;
148531
- };
148532
- compile2 = (msgs) => {
148533
- const results = {};
148534
- for (const [id, msg] of Object.entries(msgs)) {
148535
- results[id] = msg.string;
148536
- }
148537
- return results;
148233
+ error("Bad object");
148538
148234
  };
148539
- }
148540
- });
148541
-
148542
- // bazel-out/darwin-fastbuild/bin/packages/cli/lib_esnext/src/formatters/smartling.js
148543
- var smartling_exports = {};
148544
- __export(smartling_exports, {
148545
- compareMessages: () => compareMessages,
148546
- compile: () => compile3,
148547
- format: () => format4
148548
- });
148549
- var format4, compareMessages, compile3;
148550
- var init_smartling = __esm({
148551
- "bazel-out/darwin-fastbuild/bin/packages/cli/lib_esnext/src/formatters/smartling.js"() {
148552
- format4 = (msgs) => {
148553
- const results = {
148554
- smartling: {
148555
- translate_paths: [
148556
- {
148557
- path: "*/message",
148558
- key: "{*}/message",
148559
- instruction: "*/description"
148560
- }
148561
- ],
148562
- variants_enabled: true,
148563
- string_format: "icu"
148564
- }
148565
- };
148566
- for (const [id, msg] of Object.entries(msgs)) {
148567
- results[id] = {
148568
- message: msg.defaultMessage,
148569
- description: typeof msg.description === "string" ? msg.description : JSON.stringify(msg.description)
148570
- };
148235
+ value = function() {
148236
+ white();
148237
+ switch (ch) {
148238
+ case "{":
148239
+ return object();
148240
+ case "[":
148241
+ return array();
148242
+ case '"':
148243
+ return string();
148244
+ case "-":
148245
+ return number();
148246
+ default:
148247
+ return ch >= "0" && ch <= "9" ? number() : word();
148571
148248
  }
148572
- return results;
148573
148249
  };
148574
- compareMessages = (el1, el2) => {
148575
- if (el1.key === "smartling") {
148576
- return -1;
148577
- }
148578
- if (el2.key === "smartling") {
148579
- return 1;
148250
+ module2.exports = function(source, reviver) {
148251
+ var result;
148252
+ text = source;
148253
+ at = 0;
148254
+ ch = " ";
148255
+ result = value();
148256
+ white();
148257
+ if (ch) {
148258
+ error("Syntax error");
148580
148259
  }
148581
- return el1.key < el2.key ? -1 : el1.key === el2.key ? 0 : 1;
148582
- };
148583
- compile3 = (msgs) => {
148584
- const results = {};
148585
- for (const [id, msg] of Object.entries(msgs)) {
148586
- if (id === "smartling") {
148587
- continue;
148260
+ return typeof reviver === "function" ? function walk2(holder, key) {
148261
+ var k, v, value2 = holder[key];
148262
+ if (value2 && typeof value2 === "object") {
148263
+ for (k in value2) {
148264
+ if (Object.prototype.hasOwnProperty.call(value2, k)) {
148265
+ v = walk2(value2, k);
148266
+ if (v !== void 0) {
148267
+ value2[k] = v;
148268
+ } else {
148269
+ delete value2[k];
148270
+ }
148271
+ }
148272
+ }
148588
148273
  }
148589
- results[id] = msg.message;
148590
- }
148591
- return results;
148274
+ return reviver.call(holder, key, value2);
148275
+ }({ "": result }, "") : result;
148592
148276
  };
148593
148277
  }
148594
148278
  });
148595
148279
 
148596
- // bazel-out/darwin-fastbuild/bin/packages/cli/lib_esnext/src/formatters/simple.js
148597
- var simple_exports = {};
148598
- __export(simple_exports, {
148599
- compile: () => compile4,
148600
- format: () => format5
148601
- });
148602
- var format5, compile4;
148603
- var init_simple = __esm({
148604
- "bazel-out/darwin-fastbuild/bin/packages/cli/lib_esnext/src/formatters/simple.js"() {
148605
- format5 = (msgs) => {
148606
- return Object.keys(msgs).reduce((all, k) => {
148607
- all[k] = msgs[k].defaultMessage;
148608
- return all;
148609
- }, {});
148280
+ // bazel-out/darwin-fastbuild/bin/external/npm/node_modules/jsonify/lib/stringify.js
148281
+ var require_stringify = __commonJS({
148282
+ "bazel-out/darwin-fastbuild/bin/external/npm/node_modules/jsonify/lib/stringify.js"(exports, module2) {
148283
+ var escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;
148284
+ var gap;
148285
+ var indent;
148286
+ var meta = {
148287
+ "\b": "\\b",
148288
+ " ": "\\t",
148289
+ "\n": "\\n",
148290
+ "\f": "\\f",
148291
+ "\r": "\\r",
148292
+ '"': '\\"',
148293
+ "\\": "\\\\"
148610
148294
  };
148611
- compile4 = (msgs) => msgs;
148612
- }
148613
- });
148614
-
148615
- // bazel-out/darwin-fastbuild/bin/packages/cli/lib_esnext/src/formatters/lokalise.js
148616
- var lokalise_exports = {};
148617
- __export(lokalise_exports, {
148618
- compile: () => compile5,
148619
- format: () => format6
148620
- });
148621
- var format6, compile5;
148622
- var init_lokalise = __esm({
148623
- "bazel-out/darwin-fastbuild/bin/packages/cli/lib_esnext/src/formatters/lokalise.js"() {
148624
- format6 = (msgs) => {
148625
- const results = {};
148626
- for (const [id, msg] of Object.entries(msgs)) {
148627
- results[id] = {
148628
- translation: msg.defaultMessage,
148629
- notes: typeof msg.description === "string" ? msg.description : JSON.stringify(msg.description)
148630
- };
148295
+ var rep;
148296
+ function quote(string) {
148297
+ escapable.lastIndex = 0;
148298
+ return escapable.test(string) ? '"' + string.replace(escapable, function(a) {
148299
+ var c = meta[a];
148300
+ return typeof c === "string" ? c : "\\u" + ("0000" + a.charCodeAt(0).toString(16)).slice(-4);
148301
+ }) + '"' : '"' + string + '"';
148302
+ }
148303
+ function str(key, holder) {
148304
+ var i, k, v, length, mind = gap, partial, value = holder[key];
148305
+ if (value && typeof value === "object" && typeof value.toJSON === "function") {
148306
+ value = value.toJSON(key);
148631
148307
  }
148632
- return results;
148633
- };
148634
- compile5 = (msgs) => {
148635
- const results = {};
148636
- for (const [id, msg] of Object.entries(msgs)) {
148637
- results[id] = msg.translation;
148308
+ if (typeof rep === "function") {
148309
+ value = rep.call(holder, key, value);
148638
148310
  }
148639
- return results;
148311
+ switch (typeof value) {
148312
+ case "string":
148313
+ return quote(value);
148314
+ case "number":
148315
+ return isFinite(value) ? String(value) : "null";
148316
+ case "boolean":
148317
+ case "null":
148318
+ return String(value);
148319
+ case "object":
148320
+ if (!value)
148321
+ return "null";
148322
+ gap += indent;
148323
+ partial = [];
148324
+ if (Object.prototype.toString.apply(value) === "[object Array]") {
148325
+ length = value.length;
148326
+ for (i = 0; i < length; i += 1) {
148327
+ partial[i] = str(i, value) || "null";
148328
+ }
148329
+ v = partial.length === 0 ? "[]" : gap ? "[\n" + gap + partial.join(",\n" + gap) + "\n" + mind + "]" : "[" + partial.join(",") + "]";
148330
+ gap = mind;
148331
+ return v;
148332
+ }
148333
+ if (rep && typeof rep === "object") {
148334
+ length = rep.length;
148335
+ for (i = 0; i < length; i += 1) {
148336
+ k = rep[i];
148337
+ if (typeof k === "string") {
148338
+ v = str(k, value);
148339
+ if (v) {
148340
+ partial.push(quote(k) + (gap ? ": " : ":") + v);
148341
+ }
148342
+ }
148343
+ }
148344
+ } else {
148345
+ for (k in value) {
148346
+ if (Object.prototype.hasOwnProperty.call(value, k)) {
148347
+ v = str(k, value);
148348
+ if (v) {
148349
+ partial.push(quote(k) + (gap ? ": " : ":") + v);
148350
+ }
148351
+ }
148352
+ }
148353
+ }
148354
+ v = partial.length === 0 ? "{}" : gap ? "{\n" + gap + partial.join(",\n" + gap) + "\n" + mind + "}" : "{" + partial.join(",") + "}";
148355
+ gap = mind;
148356
+ return v;
148357
+ }
148358
+ }
148359
+ module2.exports = function(value, replacer, space) {
148360
+ var i;
148361
+ gap = "";
148362
+ indent = "";
148363
+ if (typeof space === "number") {
148364
+ for (i = 0; i < space; i += 1) {
148365
+ indent += " ";
148366
+ }
148367
+ } else if (typeof space === "string") {
148368
+ indent = space;
148369
+ }
148370
+ rep = replacer;
148371
+ if (replacer && typeof replacer !== "function" && (typeof replacer !== "object" || typeof replacer.length !== "number")) {
148372
+ throw new Error("JSON.stringify");
148373
+ }
148374
+ return str("", { "": value });
148640
148375
  };
148641
148376
  }
148642
148377
  });
148643
148378
 
148644
- // bazel-out/darwin-fastbuild/bin/packages/cli/lib_esnext/src/formatters/crowdin.js
148645
- var crowdin_exports = {};
148646
- __export(crowdin_exports, {
148647
- compile: () => compile6,
148648
- format: () => format7
148379
+ // bazel-out/darwin-fastbuild/bin/external/npm/node_modules/jsonify/index.js
148380
+ var require_jsonify = __commonJS({
148381
+ "bazel-out/darwin-fastbuild/bin/external/npm/node_modules/jsonify/index.js"(exports) {
148382
+ exports.parse = require_parse();
148383
+ exports.stringify = require_stringify();
148384
+ }
148649
148385
  });
148650
- var format7, compile6;
148651
- var init_crowdin = __esm({
148652
- "bazel-out/darwin-fastbuild/bin/packages/cli/lib_esnext/src/formatters/crowdin.js"() {
148653
- format7 = (msgs) => {
148654
- const results = {};
148655
- for (const [id, msg] of Object.entries(msgs)) {
148656
- results[id] = {
148657
- message: msg.defaultMessage,
148658
- description: typeof msg.description === "string" ? msg.description : JSON.stringify(msg.description)
148386
+
148387
+ // bazel-out/darwin-fastbuild/bin/external/npm/node_modules/json-stable-stringify/index.js
148388
+ var require_json_stable_stringify = __commonJS({
148389
+ "bazel-out/darwin-fastbuild/bin/external/npm/node_modules/json-stable-stringify/index.js"(exports, module2) {
148390
+ var json = typeof JSON !== "undefined" ? JSON : require_jsonify();
148391
+ module2.exports = function(obj, opts) {
148392
+ if (!opts)
148393
+ opts = {};
148394
+ if (typeof opts === "function")
148395
+ opts = { cmp: opts };
148396
+ var space = opts.space || "";
148397
+ if (typeof space === "number")
148398
+ space = Array(space + 1).join(" ");
148399
+ var cycles = typeof opts.cycles === "boolean" ? opts.cycles : false;
148400
+ var replacer = opts.replacer || function(key, value) {
148401
+ return value;
148402
+ };
148403
+ var cmp = opts.cmp && function(f) {
148404
+ return function(node) {
148405
+ return function(a, b) {
148406
+ var aobj = { key: a, value: node[a] };
148407
+ var bobj = { key: b, value: node[b] };
148408
+ return f(aobj, bobj);
148409
+ };
148659
148410
  };
148660
- }
148661
- return results;
148662
- };
148663
- compile6 = (msgs) => {
148664
- const results = {};
148665
- for (const [id, msg] of Object.entries(msgs)) {
148666
- if (id === "smartling") {
148667
- continue;
148411
+ }(opts.cmp);
148412
+ var seen = [];
148413
+ return function stringify3(parent, key, node, level) {
148414
+ var indent = space ? "\n" + new Array(level + 1).join(space) : "";
148415
+ var colonSeparator = space ? ": " : ":";
148416
+ if (node && node.toJSON && typeof node.toJSON === "function") {
148417
+ node = node.toJSON();
148668
148418
  }
148669
- results[id] = msg.message;
148419
+ node = replacer.call(parent, key, node);
148420
+ if (node === void 0) {
148421
+ return;
148422
+ }
148423
+ if (typeof node !== "object" || node === null) {
148424
+ return json.stringify(node);
148425
+ }
148426
+ if (isArray(node)) {
148427
+ var out = [];
148428
+ for (var i = 0; i < node.length; i++) {
148429
+ var item = stringify3(node, i, node[i], level + 1) || json.stringify(null);
148430
+ out.push(indent + space + item);
148431
+ }
148432
+ return "[" + out.join(",") + indent + "]";
148433
+ } else {
148434
+ if (seen.indexOf(node) !== -1) {
148435
+ if (cycles)
148436
+ return json.stringify("__cycle__");
148437
+ throw new TypeError("Converting circular structure to JSON");
148438
+ } else
148439
+ seen.push(node);
148440
+ var keys = objectKeys(node).sort(cmp && cmp(node));
148441
+ var out = [];
148442
+ for (var i = 0; i < keys.length; i++) {
148443
+ var key = keys[i];
148444
+ var value = stringify3(node, key, node[key], level + 1);
148445
+ if (!value)
148446
+ continue;
148447
+ var keyValue = json.stringify(key) + colonSeparator + value;
148448
+ ;
148449
+ out.push(indent + space + keyValue);
148450
+ }
148451
+ seen.splice(seen.indexOf(node), 1);
148452
+ return "{" + out.join(",") + indent + "}";
148453
+ }
148454
+ }({ "": obj }, "", obj, 0);
148455
+ };
148456
+ var isArray = Array.isArray || function(x) {
148457
+ return {}.toString.call(x) === "[object Array]";
148458
+ };
148459
+ var objectKeys = Object.keys || function(obj) {
148460
+ var has = Object.prototype.hasOwnProperty || function() {
148461
+ return true;
148462
+ };
148463
+ var keys = [];
148464
+ for (var key in obj) {
148465
+ if (has.call(obj, key))
148466
+ keys.push(key);
148670
148467
  }
148671
- return results;
148468
+ return keys;
148672
148469
  };
148673
148470
  }
148674
148471
  });
148675
148472
 
148676
- // bazel-out/darwin-fastbuild/bin/packages/cli/lib_esnext/src/formatters/index.js
148677
- async function resolveBuiltinFormatter(format8) {
148678
- if (!format8) {
148679
- return default_exports;
148680
- }
148681
- if (typeof format8 !== "string") {
148682
- return format8;
148683
- }
148684
- switch (format8) {
148685
- case "transifex":
148686
- return transifex_exports;
148687
- case "smartling":
148688
- return smartling_exports;
148689
- case "simple":
148690
- return simple_exports;
148691
- case "lokalise":
148692
- return lokalise_exports;
148693
- case "crowdin":
148694
- return crowdin_exports;
148695
- }
148696
- try {
148697
- return import((0, import_path.resolve)(process.cwd(), format8));
148698
- } catch (e) {
148699
- console.error(`Cannot resolve formatter ${format8}`);
148700
- throw e;
148701
- }
148702
- }
148703
- var import_path;
148704
- var init_formatters = __esm({
148705
- "bazel-out/darwin-fastbuild/bin/packages/cli/lib_esnext/src/formatters/index.js"() {
148706
- init_default();
148707
- init_transifex();
148708
- init_smartling();
148709
- init_simple();
148710
- init_lokalise();
148711
- init_crowdin();
148712
- import_path = require("path");
148713
- }
148714
- });
148715
-
148716
- // bazel-out/darwin-fastbuild/bin/external/npm/node_modules/jsonify/lib/parse.js
148717
- var require_parse = __commonJS({
148718
- "bazel-out/darwin-fastbuild/bin/external/npm/node_modules/jsonify/lib/parse.js"(exports, module2) {
148719
- var at;
148720
- var ch;
148721
- var escapee = {
148722
- '"': '"',
148723
- "\\": "\\",
148724
- "/": "/",
148725
- b: "\b",
148726
- f: "\f",
148727
- n: "\n",
148728
- r: "\r",
148729
- t: " "
148730
- };
148731
- var text;
148732
- var error = function(m) {
148733
- throw {
148734
- name: "SyntaxError",
148735
- message: m,
148736
- at,
148737
- text
148738
- };
148739
- };
148740
- var next = function(c) {
148741
- if (c && c !== ch) {
148742
- error("Expected '" + c + "' instead of '" + ch + "'");
148473
+ // bazel-out/darwin-fastbuild/bin/packages/ts-transformer/src/transform.js
148474
+ var require_transform = __commonJS({
148475
+ "bazel-out/darwin-fastbuild/bin/packages/ts-transformer/src/transform.js"(exports) {
148476
+ "use strict";
148477
+ Object.defineProperty(exports, "__esModule", { value: true });
148478
+ exports.transform = exports.transformWithTs = void 0;
148479
+ var tslib_1 = require_tslib();
148480
+ var typescript = (0, tslib_1.__importStar)(require_typescript());
148481
+ var interpolate_name_1 = require_interpolate_name();
148482
+ var icu_messageformat_parser_1 = require_icu_messageformat_parser();
148483
+ var console_utils_1 = require_console_utils();
148484
+ var json_stable_stringify_1 = (0, tslib_1.__importDefault)(require_json_stable_stringify());
148485
+ var MESSAGE_DESC_KEYS = [
148486
+ "id",
148487
+ "defaultMessage",
148488
+ "description"
148489
+ ];
148490
+ function primitiveToTSNode(factory, v) {
148491
+ return typeof v === "string" ? factory.createStringLiteral(v) : typeof v === "number" ? factory.createNumericLiteral(v + "") : typeof v === "boolean" ? v ? factory.createTrue() : factory.createFalse() : void 0;
148492
+ }
148493
+ function isValidIdentifier(k) {
148494
+ try {
148495
+ new Function("return {".concat(k, ":1}"));
148496
+ return true;
148497
+ } catch (e) {
148498
+ return false;
148743
148499
  }
148744
- ch = text.charAt(at);
148745
- at += 1;
148746
- return ch;
148747
- };
148748
- var number = function() {
148749
- var number2, string2 = "";
148750
- if (ch === "-") {
148751
- string2 = "-";
148752
- next("-");
148500
+ }
148501
+ function objToTSNode(factory, obj) {
148502
+ if (typeof obj === "object" && !obj) {
148503
+ return factory.createNull();
148753
148504
  }
148754
- while (ch >= "0" && ch <= "9") {
148755
- string2 += ch;
148756
- next();
148505
+ var props = Object.entries(obj).filter(function(_a) {
148506
+ var _ = _a[0], v = _a[1];
148507
+ return typeof v !== "undefined";
148508
+ }).map(function(_a) {
148509
+ var k = _a[0], v = _a[1];
148510
+ return factory.createPropertyAssignment(isValidIdentifier(k) ? k : factory.createStringLiteral(k), primitiveToTSNode(factory, v) || (Array.isArray(v) ? factory.createArrayLiteralExpression(v.filter(function(n) {
148511
+ return typeof n !== "undefined";
148512
+ }).map(function(n) {
148513
+ return objToTSNode(factory, n);
148514
+ })) : objToTSNode(factory, v)));
148515
+ });
148516
+ return factory.createObjectLiteralExpression(props);
148517
+ }
148518
+ function messageASTToTSNode(factory, ast) {
148519
+ return factory.createArrayLiteralExpression(ast.map(function(el) {
148520
+ return objToTSNode(factory, el);
148521
+ }));
148522
+ }
148523
+ function literalToObj(ts2, n) {
148524
+ if (ts2.isNumericLiteral(n)) {
148525
+ return +n.text;
148757
148526
  }
148758
- if (ch === ".") {
148759
- string2 += ".";
148760
- while (next() && ch >= "0" && ch <= "9") {
148761
- string2 += ch;
148762
- }
148527
+ if (ts2.isStringLiteral(n)) {
148528
+ return n.text;
148763
148529
  }
148764
- if (ch === "e" || ch === "E") {
148765
- string2 += ch;
148766
- next();
148767
- if (ch === "-" || ch === "+") {
148768
- string2 += ch;
148769
- next();
148770
- }
148771
- while (ch >= "0" && ch <= "9") {
148772
- string2 += ch;
148773
- next();
148774
- }
148530
+ if (n.kind === ts2.SyntaxKind.TrueKeyword) {
148531
+ return true;
148775
148532
  }
148776
- number2 = +string2;
148777
- if (!isFinite(number2)) {
148778
- error("Bad number");
148779
- } else {
148780
- return number2;
148533
+ if (n.kind === ts2.SyntaxKind.FalseKeyword) {
148534
+ return false;
148535
+ }
148536
+ }
148537
+ function objectLiteralExpressionToObj(ts2, obj) {
148538
+ return obj.properties.reduce(function(all, prop) {
148539
+ if (ts2.isPropertyAssignment(prop) && prop.name) {
148540
+ if (ts2.isIdentifier(prop.name)) {
148541
+ all[prop.name.escapedText.toString()] = literalToObj(ts2, prop.initializer);
148542
+ } else if (ts2.isStringLiteral(prop.name)) {
148543
+ all[prop.name.text] = literalToObj(ts2, prop.initializer);
148544
+ }
148545
+ }
148546
+ return all;
148547
+ }, {});
148548
+ }
148549
+ var DEFAULT_OPTS = {
148550
+ onMsgExtracted: function() {
148551
+ return void 0;
148552
+ },
148553
+ onMetaExtracted: function() {
148554
+ return void 0;
148781
148555
  }
148782
148556
  };
148783
- var string = function() {
148784
- var hex, i, string2 = "", uffff;
148785
- if (ch === '"') {
148786
- while (next()) {
148787
- if (ch === '"') {
148788
- next();
148789
- return string2;
148790
- } else if (ch === "\\") {
148791
- next();
148792
- if (ch === "u") {
148793
- uffff = 0;
148794
- for (i = 0; i < 4; i += 1) {
148795
- hex = parseInt(next(), 16);
148796
- if (!isFinite(hex)) {
148557
+ function isMultipleMessageDecl(ts2, node) {
148558
+ return ts2.isIdentifier(node.expression) && node.expression.text === "defineMessages";
148559
+ }
148560
+ function isSingularMessageDecl(ts2, node, additionalComponentNames) {
148561
+ var compNames = new Set((0, tslib_1.__spreadArray)([
148562
+ "FormattedMessage",
148563
+ "defineMessage",
148564
+ "formatMessage",
148565
+ "$formatMessage"
148566
+ ], additionalComponentNames, true));
148567
+ var fnName = "";
148568
+ if (ts2.isCallExpression(node) && ts2.isIdentifier(node.expression)) {
148569
+ fnName = node.expression.text;
148570
+ } else if (ts2.isJsxOpeningElement(node) && ts2.isIdentifier(node.tagName)) {
148571
+ fnName = node.tagName.text;
148572
+ } else if (ts2.isJsxSelfClosingElement(node) && ts2.isIdentifier(node.tagName)) {
148573
+ fnName = node.tagName.text;
148574
+ }
148575
+ return compNames.has(fnName);
148576
+ }
148577
+ function evaluateStringConcat(ts2, node) {
148578
+ var right = node.right, left = node.left;
148579
+ if (!ts2.isStringLiteral(right)) {
148580
+ return ["", false];
148581
+ }
148582
+ if (ts2.isStringLiteral(left)) {
148583
+ return [left.text + right.text, true];
148584
+ }
148585
+ if (ts2.isBinaryExpression(left)) {
148586
+ var _a = evaluateStringConcat(ts2, left), result = _a[0], isStatic = _a[1];
148587
+ return [result + right.text, isStatic];
148588
+ }
148589
+ return ["", false];
148590
+ }
148591
+ function extractMessageDescriptor(ts2, node, _a, sf) {
148592
+ var overrideIdFn = _a.overrideIdFn, extractSourceLocation = _a.extractSourceLocation, preserveWhitespace = _a.preserveWhitespace;
148593
+ var properties = void 0;
148594
+ if (ts2.isObjectLiteralExpression(node)) {
148595
+ properties = node.properties;
148596
+ } else if (ts2.isJsxOpeningElement(node) || ts2.isJsxSelfClosingElement(node)) {
148597
+ properties = node.attributes.properties;
148598
+ }
148599
+ var msg = { id: "" };
148600
+ if (!properties) {
148601
+ return;
148602
+ }
148603
+ properties.forEach(function(prop) {
148604
+ var name = prop.name;
148605
+ var initializer = ts2.isPropertyAssignment(prop) || ts2.isJsxAttribute(prop) ? prop.initializer : void 0;
148606
+ if (name && ts2.isIdentifier(name) && initializer) {
148607
+ if (ts2.isStringLiteral(initializer)) {
148608
+ switch (name.text) {
148609
+ case "id":
148610
+ msg.id = initializer.text;
148611
+ break;
148612
+ case "defaultMessage":
148613
+ msg.defaultMessage = initializer.text;
148614
+ break;
148615
+ case "description":
148616
+ msg.description = initializer.text;
148617
+ break;
148618
+ }
148619
+ } else if (ts2.isNoSubstitutionTemplateLiteral(initializer)) {
148620
+ switch (name.text) {
148621
+ case "id":
148622
+ msg.id = initializer.text;
148623
+ break;
148624
+ case "defaultMessage":
148625
+ msg.defaultMessage = initializer.text;
148626
+ break;
148627
+ case "description":
148628
+ msg.description = initializer.text;
148629
+ break;
148630
+ }
148631
+ } else if (ts2.isJsxExpression(initializer) && initializer.expression) {
148632
+ if (ts2.isStringLiteral(initializer.expression)) {
148633
+ switch (name.text) {
148634
+ case "id":
148635
+ msg.id = initializer.expression.text;
148636
+ break;
148637
+ case "defaultMessage":
148638
+ msg.defaultMessage = initializer.expression.text;
148639
+ break;
148640
+ case "description":
148641
+ msg.description = initializer.expression.text;
148642
+ break;
148643
+ }
148644
+ } else if (ts2.isObjectLiteralExpression(initializer.expression) && name.text === "description") {
148645
+ msg.description = objectLiteralExpressionToObj(ts2, initializer.expression);
148646
+ } else if (ts2.isNoSubstitutionTemplateLiteral(initializer.expression)) {
148647
+ var expression = initializer.expression;
148648
+ switch (name.text) {
148649
+ case "id":
148650
+ msg.id = expression.text;
148651
+ break;
148652
+ case "defaultMessage":
148653
+ msg.defaultMessage = expression.text;
148654
+ break;
148655
+ case "description":
148656
+ msg.description = expression.text;
148797
148657
  break;
148658
+ }
148659
+ } else if (ts2.isBinaryExpression(initializer.expression)) {
148660
+ var expression = initializer.expression;
148661
+ var _a2 = evaluateStringConcat(ts2, expression), result = _a2[0], isStatic = _a2[1];
148662
+ if (isStatic) {
148663
+ switch (name.text) {
148664
+ case "id":
148665
+ msg.id = result;
148666
+ break;
148667
+ case "defaultMessage":
148668
+ msg.defaultMessage = result;
148669
+ break;
148670
+ case "description":
148671
+ msg.description = result;
148672
+ break;
148798
148673
  }
148799
- uffff = uffff * 16 + hex;
148800
148674
  }
148801
- string2 += String.fromCharCode(uffff);
148802
- } else if (typeof escapee[ch] === "string") {
148803
- string2 += escapee[ch];
148804
- } else {
148805
- break;
148806
148675
  }
148807
- } else {
148808
- string2 += ch;
148676
+ } else if (ts2.isBinaryExpression(initializer)) {
148677
+ var _b = evaluateStringConcat(ts2, initializer), result = _b[0], isStatic = _b[1];
148678
+ if (isStatic) {
148679
+ switch (name.text) {
148680
+ case "id":
148681
+ msg.id = result;
148682
+ break;
148683
+ case "defaultMessage":
148684
+ msg.defaultMessage = result;
148685
+ break;
148686
+ case "description":
148687
+ msg.description = result;
148688
+ break;
148689
+ }
148690
+ }
148691
+ } else if (ts2.isObjectLiteralExpression(initializer) && name.text === "description") {
148692
+ msg.description = objectLiteralExpressionToObj(ts2, initializer);
148809
148693
  }
148810
148694
  }
148695
+ });
148696
+ if (!msg.defaultMessage && !msg.id) {
148697
+ return;
148811
148698
  }
148812
- error("Bad string");
148813
- };
148814
- var white = function() {
148815
- while (ch && ch <= " ") {
148816
- next();
148699
+ if (msg.defaultMessage && !preserveWhitespace) {
148700
+ msg.defaultMessage = msg.defaultMessage.trim().replace(/\s+/gm, " ");
148817
148701
  }
148818
- };
148819
- var word = function() {
148820
- switch (ch) {
148821
- case "t":
148822
- next("t");
148823
- next("r");
148824
- next("u");
148825
- next("e");
148826
- return true;
148827
- case "f":
148828
- next("f");
148829
- next("a");
148830
- next("l");
148831
- next("s");
148832
- next("e");
148833
- return false;
148834
- case "n":
148835
- next("n");
148836
- next("u");
148837
- next("l");
148838
- next("l");
148839
- return null;
148702
+ if (msg.defaultMessage && overrideIdFn) {
148703
+ switch (typeof overrideIdFn) {
148704
+ case "string":
148705
+ if (!msg.id) {
148706
+ msg.id = (0, interpolate_name_1.interpolateName)({ resourcePath: sf.fileName }, overrideIdFn, {
148707
+ content: msg.description ? "".concat(msg.defaultMessage, "#").concat(typeof msg.description === "string" ? msg.description : (0, json_stable_stringify_1.default)(msg.description)) : msg.defaultMessage
148708
+ });
148709
+ }
148710
+ break;
148711
+ case "function":
148712
+ msg.id = overrideIdFn(msg.id, msg.defaultMessage, msg.description, sf.fileName);
148713
+ break;
148714
+ }
148840
148715
  }
148841
- error("Unexpected '" + ch + "'");
148842
- };
148843
- var value;
148844
- var array = function() {
148845
- var array2 = [];
148846
- if (ch === "[") {
148847
- next("[");
148848
- white();
148849
- if (ch === "]") {
148850
- next("]");
148851
- return array2;
148716
+ if (extractSourceLocation) {
148717
+ return (0, tslib_1.__assign)((0, tslib_1.__assign)({}, msg), { file: sf.fileName, start: node.pos, end: node.end });
148718
+ }
148719
+ return msg;
148720
+ }
148721
+ function isMemberMethodFormatMessageCall(ts2, node, additionalFunctionNames) {
148722
+ var fnNames = new Set((0, tslib_1.__spreadArray)([
148723
+ "formatMessage",
148724
+ "$formatMessage"
148725
+ ], additionalFunctionNames, true));
148726
+ var method = node.expression;
148727
+ if (ts2.isPropertyAccessExpression(method)) {
148728
+ return fnNames.has(method.name.text);
148729
+ }
148730
+ return ts2.isIdentifier(method) && fnNames.has(method.text);
148731
+ }
148732
+ function extractMessageFromJsxComponent(ts2, factory, node, opts, sf) {
148733
+ var onMsgExtracted = opts.onMsgExtracted;
148734
+ if (!isSingularMessageDecl(ts2, node, opts.additionalComponentNames || [])) {
148735
+ return node;
148736
+ }
148737
+ var msg = extractMessageDescriptor(ts2, node, opts, sf);
148738
+ if (!msg) {
148739
+ return node;
148740
+ }
148741
+ if (typeof onMsgExtracted === "function") {
148742
+ onMsgExtracted(sf.fileName, [msg]);
148743
+ }
148744
+ var newProps = generateNewProperties(ts2, factory, node.attributes, {
148745
+ defaultMessage: opts.removeDefaultMessage ? void 0 : msg.defaultMessage,
148746
+ id: msg.id
148747
+ }, opts.ast);
148748
+ if (ts2.isJsxOpeningElement(node)) {
148749
+ return factory.updateJsxOpeningElement(node, node.tagName, node.typeArguments, factory.createJsxAttributes(newProps));
148750
+ }
148751
+ return factory.updateJsxSelfClosingElement(node, node.tagName, node.typeArguments, factory.createJsxAttributes(newProps));
148752
+ }
148753
+ function setAttributesInObject(ts2, factory, node, msg, ast) {
148754
+ var newProps = (0, tslib_1.__spreadArray)([
148755
+ factory.createPropertyAssignment("id", factory.createStringLiteral(msg.id))
148756
+ ], msg.defaultMessage ? [
148757
+ factory.createPropertyAssignment("defaultMessage", ast ? messageASTToTSNode(factory, (0, icu_messageformat_parser_1.parse)(msg.defaultMessage)) : factory.createStringLiteral(msg.defaultMessage))
148758
+ ] : [], true);
148759
+ for (var _i = 0, _a = node.properties; _i < _a.length; _i++) {
148760
+ var prop = _a[_i];
148761
+ if (ts2.isPropertyAssignment(prop) && ts2.isIdentifier(prop.name) && MESSAGE_DESC_KEYS.includes(prop.name.text)) {
148762
+ continue;
148852
148763
  }
148853
- while (ch) {
148854
- array2.push(value());
148855
- white();
148856
- if (ch === "]") {
148857
- next("]");
148858
- return array2;
148859
- }
148860
- next(",");
148861
- white();
148764
+ if (ts2.isPropertyAssignment(prop)) {
148765
+ newProps.push(prop);
148862
148766
  }
148863
148767
  }
148864
- error("Bad array");
148865
- };
148866
- var object = function() {
148867
- var key, object2 = {};
148868
- if (ch === "{") {
148869
- next("{");
148870
- white();
148871
- if (ch === "}") {
148872
- next("}");
148873
- return object2;
148768
+ return factory.createObjectLiteralExpression(factory.createNodeArray(newProps));
148769
+ }
148770
+ function generateNewProperties(ts2, factory, node, msg, ast) {
148771
+ var newProps = (0, tslib_1.__spreadArray)([
148772
+ factory.createJsxAttribute(factory.createIdentifier("id"), factory.createStringLiteral(msg.id))
148773
+ ], msg.defaultMessage ? [
148774
+ factory.createJsxAttribute(factory.createIdentifier("defaultMessage"), ast ? factory.createJsxExpression(void 0, messageASTToTSNode(factory, (0, icu_messageformat_parser_1.parse)(msg.defaultMessage))) : factory.createStringLiteral(msg.defaultMessage))
148775
+ ] : [], true);
148776
+ for (var _i = 0, _a = node.properties; _i < _a.length; _i++) {
148777
+ var prop = _a[_i];
148778
+ if (ts2.isJsxAttribute(prop) && ts2.isIdentifier(prop.name) && MESSAGE_DESC_KEYS.includes(prop.name.text)) {
148779
+ continue;
148780
+ }
148781
+ if (ts2.isJsxAttribute(prop)) {
148782
+ newProps.push(prop);
148783
+ }
148784
+ }
148785
+ return newProps;
148786
+ }
148787
+ function extractMessagesFromCallExpression(ts2, factory, node, opts, sf) {
148788
+ var onMsgExtracted = opts.onMsgExtracted, additionalFunctionNames = opts.additionalFunctionNames;
148789
+ if (isMultipleMessageDecl(ts2, node)) {
148790
+ var _a = node.arguments, arg = _a[0], restArgs = _a.slice(1);
148791
+ var descriptorsObj = void 0;
148792
+ if (ts2.isObjectLiteralExpression(arg)) {
148793
+ descriptorsObj = arg;
148794
+ } else if (ts2.isAsExpression(arg) && ts2.isObjectLiteralExpression(arg.expression)) {
148795
+ descriptorsObj = arg.expression;
148796
+ }
148797
+ if (descriptorsObj) {
148798
+ var properties = descriptorsObj.properties;
148799
+ var msgs_1 = properties.filter(function(prop) {
148800
+ return ts2.isPropertyAssignment(prop);
148801
+ }).map(function(prop) {
148802
+ return ts2.isObjectLiteralExpression(prop.initializer) && extractMessageDescriptor(ts2, prop.initializer, opts, sf);
148803
+ }).filter(function(msg2) {
148804
+ return !!msg2;
148805
+ });
148806
+ if (!msgs_1.length) {
148807
+ return node;
148808
+ }
148809
+ (0, console_utils_1.debug)('Multiple messages extracted from "%s": %s', sf.fileName, msgs_1);
148810
+ if (typeof onMsgExtracted === "function") {
148811
+ onMsgExtracted(sf.fileName, msgs_1);
148812
+ }
148813
+ var clonedProperties = factory.createNodeArray(properties.map(function(prop, i) {
148814
+ if (!ts2.isPropertyAssignment(prop) || !ts2.isObjectLiteralExpression(prop.initializer)) {
148815
+ return prop;
148816
+ }
148817
+ return factory.createPropertyAssignment(prop.name, setAttributesInObject(ts2, factory, prop.initializer, {
148818
+ defaultMessage: opts.removeDefaultMessage ? void 0 : msgs_1[i].defaultMessage,
148819
+ id: msgs_1[i] ? msgs_1[i].id : ""
148820
+ }, opts.ast));
148821
+ }));
148822
+ var clonedDescriptorsObj = factory.createObjectLiteralExpression(clonedProperties);
148823
+ return factory.updateCallExpression(node, node.expression, node.typeArguments, (0, tslib_1.__spreadArray)([clonedDescriptorsObj], restArgs, true));
148874
148824
  }
148875
- while (ch) {
148876
- key = string();
148877
- white();
148878
- next(":");
148879
- if (Object.hasOwnProperty.call(object2, key)) {
148880
- error('Duplicate key "' + key + '"');
148825
+ } else if (isSingularMessageDecl(ts2, node, opts.additionalComponentNames || []) || isMemberMethodFormatMessageCall(ts2, node, additionalFunctionNames || [])) {
148826
+ var _b = node.arguments, descriptorsObj = _b[0], restArgs = _b.slice(1);
148827
+ if (ts2.isObjectLiteralExpression(descriptorsObj)) {
148828
+ var msg = extractMessageDescriptor(ts2, descriptorsObj, opts, sf);
148829
+ if (!msg) {
148830
+ return node;
148881
148831
  }
148882
- object2[key] = value();
148883
- white();
148884
- if (ch === "}") {
148885
- next("}");
148886
- return object2;
148832
+ (0, console_utils_1.debug)('Message extracted from "%s": %s', sf.fileName, msg);
148833
+ if (typeof onMsgExtracted === "function") {
148834
+ onMsgExtracted(sf.fileName, [msg]);
148887
148835
  }
148888
- next(",");
148889
- white();
148836
+ return factory.updateCallExpression(node, node.expression, node.typeArguments, (0, tslib_1.__spreadArray)([
148837
+ setAttributesInObject(ts2, factory, descriptorsObj, {
148838
+ defaultMessage: opts.removeDefaultMessage ? void 0 : msg.defaultMessage,
148839
+ id: msg.id
148840
+ }, opts.ast)
148841
+ ], restArgs, true));
148890
148842
  }
148891
148843
  }
148892
- error("Bad object");
148893
- };
148894
- value = function() {
148895
- white();
148896
- switch (ch) {
148897
- case "{":
148898
- return object();
148899
- case "[":
148900
- return array();
148901
- case '"':
148902
- return string();
148903
- case "-":
148904
- return number();
148905
- default:
148906
- return ch >= "0" && ch <= "9" ? number() : word();
148907
- }
148908
- };
148909
- module2.exports = function(source, reviver) {
148910
- var result;
148911
- text = source;
148912
- at = 0;
148913
- ch = " ";
148914
- result = value();
148915
- white();
148916
- if (ch) {
148917
- error("Syntax error");
148918
- }
148919
- return typeof reviver === "function" ? function walk2(holder, key) {
148920
- var k, v, value2 = holder[key];
148921
- if (value2 && typeof value2 === "object") {
148922
- for (k in value2) {
148923
- if (Object.prototype.hasOwnProperty.call(value2, k)) {
148924
- v = walk2(value2, k);
148925
- if (v !== void 0) {
148926
- value2[k] = v;
148927
- } else {
148928
- delete value2[k];
148844
+ return node;
148845
+ }
148846
+ var PRAGMA_REGEX = /^\/\/ @([^\s]*) (.*)$/m;
148847
+ function getVisitor(ts2, ctx, sf, opts) {
148848
+ var visitor = function(node) {
148849
+ var newNode = ts2.isCallExpression(node) ? extractMessagesFromCallExpression(ts2, ctx.factory, node, opts, sf) : ts2.isJsxOpeningElement(node) || ts2.isJsxSelfClosingElement(node) ? extractMessageFromJsxComponent(ts2, ctx.factory, node, opts, sf) : node;
148850
+ return ts2.visitEachChild(newNode, visitor, ctx);
148851
+ };
148852
+ return visitor;
148853
+ }
148854
+ function transformWithTs2(ts2, opts) {
148855
+ opts = (0, tslib_1.__assign)((0, tslib_1.__assign)({}, DEFAULT_OPTS), opts);
148856
+ (0, console_utils_1.debug)("Transforming options", opts);
148857
+ var transformFn = function(ctx) {
148858
+ return function(sf) {
148859
+ var pragmaResult = PRAGMA_REGEX.exec(sf.text);
148860
+ if (pragmaResult) {
148861
+ (0, console_utils_1.debug)("Pragma found", pragmaResult);
148862
+ var pragma = pragmaResult[1], kvString = pragmaResult[2];
148863
+ if (pragma === opts.pragma) {
148864
+ var kvs = kvString.split(" ");
148865
+ var result = {};
148866
+ for (var _i = 0, kvs_1 = kvs; _i < kvs_1.length; _i++) {
148867
+ var kv = kvs_1[_i];
148868
+ var _a = kv.split(":"), k = _a[0], v = _a[1];
148869
+ result[k] = v;
148870
+ }
148871
+ (0, console_utils_1.debug)("Pragma extracted", result);
148872
+ if (typeof opts.onMetaExtracted === "function") {
148873
+ opts.onMetaExtracted(sf.fileName, result);
148929
148874
  }
148930
148875
  }
148931
148876
  }
148932
- }
148933
- return reviver.call(holder, key, value2);
148934
- }({ "": result }, "") : result;
148935
- };
148877
+ return ts2.visitNode(sf, getVisitor(ts2, ctx, sf, opts));
148878
+ };
148879
+ };
148880
+ return transformFn;
148881
+ }
148882
+ exports.transformWithTs = transformWithTs2;
148883
+ function transform(opts) {
148884
+ return transformWithTs2(typescript, opts);
148885
+ }
148886
+ exports.transform = transform;
148936
148887
  }
148937
148888
  });
148938
148889
 
148939
- // bazel-out/darwin-fastbuild/bin/external/npm/node_modules/jsonify/lib/stringify.js
148940
- var require_stringify = __commonJS({
148941
- "bazel-out/darwin-fastbuild/bin/external/npm/node_modules/jsonify/lib/stringify.js"(exports, module2) {
148942
- var escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;
148943
- var gap;
148944
- var indent;
148945
- var meta = {
148946
- "\b": "\\b",
148947
- " ": "\\t",
148948
- "\n": "\\n",
148949
- "\f": "\\f",
148950
- "\r": "\\r",
148951
- '"': '\\"',
148952
- "\\": "\\\\"
148890
+ // bazel-out/darwin-fastbuild/bin/packages/ts-transformer/src/types.js
148891
+ var require_types2 = __commonJS({
148892
+ "bazel-out/darwin-fastbuild/bin/packages/ts-transformer/src/types.js"(exports) {
148893
+ "use strict";
148894
+ Object.defineProperty(exports, "__esModule", { value: true });
148895
+ }
148896
+ });
148897
+
148898
+ // bazel-out/darwin-fastbuild/bin/packages/ts-transformer/index.js
148899
+ var require_ts_transformer = __commonJS({
148900
+ "bazel-out/darwin-fastbuild/bin/packages/ts-transformer/index.js"(exports) {
148901
+ "use strict";
148902
+ Object.defineProperty(exports, "__esModule", { value: true });
148903
+ var tslib_1 = require_tslib();
148904
+ (0, tslib_1.__exportStar)(require_transform(), exports);
148905
+ (0, tslib_1.__exportStar)(require_types2(), exports);
148906
+ (0, tslib_1.__exportStar)(require_interpolate_name(), exports);
148907
+ }
148908
+ });
148909
+
148910
+ // bazel-out/darwin-fastbuild/bin/packages/cli/lib_esnext/src/formatters/default.js
148911
+ var default_exports = {};
148912
+ __export(default_exports, {
148913
+ compile: () => compile,
148914
+ format: () => format2
148915
+ });
148916
+ var format2, compile;
148917
+ var init_default = __esm({
148918
+ "bazel-out/darwin-fastbuild/bin/packages/cli/lib_esnext/src/formatters/default.js"() {
148919
+ format2 = (msgs) => msgs;
148920
+ compile = (msgs) => {
148921
+ const results = {};
148922
+ for (const k in msgs) {
148923
+ results[k] = msgs[k].defaultMessage;
148924
+ }
148925
+ return results;
148953
148926
  };
148954
- var rep;
148955
- function quote(string) {
148956
- escapable.lastIndex = 0;
148957
- return escapable.test(string) ? '"' + string.replace(escapable, function(a) {
148958
- var c = meta[a];
148959
- return typeof c === "string" ? c : "\\u" + ("0000" + a.charCodeAt(0).toString(16)).slice(-4);
148960
- }) + '"' : '"' + string + '"';
148961
- }
148962
- function str(key, holder) {
148963
- var i, k, v, length, mind = gap, partial, value = holder[key];
148964
- if (value && typeof value === "object" && typeof value.toJSON === "function") {
148965
- value = value.toJSON(key);
148927
+ }
148928
+ });
148929
+
148930
+ // bazel-out/darwin-fastbuild/bin/packages/cli/lib_esnext/src/formatters/transifex.js
148931
+ var transifex_exports = {};
148932
+ __export(transifex_exports, {
148933
+ compile: () => compile2,
148934
+ format: () => format3
148935
+ });
148936
+ var format3, compile2;
148937
+ var init_transifex = __esm({
148938
+ "bazel-out/darwin-fastbuild/bin/packages/cli/lib_esnext/src/formatters/transifex.js"() {
148939
+ format3 = (msgs) => {
148940
+ const results = {};
148941
+ for (const [id, msg] of Object.entries(msgs)) {
148942
+ results[id] = {
148943
+ string: msg.defaultMessage,
148944
+ developer_comment: typeof msg.description === "string" ? msg.description : JSON.stringify(msg.description)
148945
+ };
148966
148946
  }
148967
- if (typeof rep === "function") {
148968
- value = rep.call(holder, key, value);
148947
+ return results;
148948
+ };
148949
+ compile2 = (msgs) => {
148950
+ const results = {};
148951
+ for (const [id, msg] of Object.entries(msgs)) {
148952
+ results[id] = msg.string;
148969
148953
  }
148970
- switch (typeof value) {
148971
- case "string":
148972
- return quote(value);
148973
- case "number":
148974
- return isFinite(value) ? String(value) : "null";
148975
- case "boolean":
148976
- case "null":
148977
- return String(value);
148978
- case "object":
148979
- if (!value)
148980
- return "null";
148981
- gap += indent;
148982
- partial = [];
148983
- if (Object.prototype.toString.apply(value) === "[object Array]") {
148984
- length = value.length;
148985
- for (i = 0; i < length; i += 1) {
148986
- partial[i] = str(i, value) || "null";
148987
- }
148988
- v = partial.length === 0 ? "[]" : gap ? "[\n" + gap + partial.join(",\n" + gap) + "\n" + mind + "]" : "[" + partial.join(",") + "]";
148989
- gap = mind;
148990
- return v;
148991
- }
148992
- if (rep && typeof rep === "object") {
148993
- length = rep.length;
148994
- for (i = 0; i < length; i += 1) {
148995
- k = rep[i];
148996
- if (typeof k === "string") {
148997
- v = str(k, value);
148998
- if (v) {
148999
- partial.push(quote(k) + (gap ? ": " : ":") + v);
149000
- }
149001
- }
149002
- }
149003
- } else {
149004
- for (k in value) {
149005
- if (Object.prototype.hasOwnProperty.call(value, k)) {
149006
- v = str(k, value);
149007
- if (v) {
149008
- partial.push(quote(k) + (gap ? ": " : ":") + v);
149009
- }
149010
- }
148954
+ return results;
148955
+ };
148956
+ }
148957
+ });
148958
+
148959
+ // bazel-out/darwin-fastbuild/bin/packages/cli/lib_esnext/src/formatters/smartling.js
148960
+ var smartling_exports = {};
148961
+ __export(smartling_exports, {
148962
+ compareMessages: () => compareMessages,
148963
+ compile: () => compile3,
148964
+ format: () => format4
148965
+ });
148966
+ var format4, compareMessages, compile3;
148967
+ var init_smartling = __esm({
148968
+ "bazel-out/darwin-fastbuild/bin/packages/cli/lib_esnext/src/formatters/smartling.js"() {
148969
+ format4 = (msgs) => {
148970
+ const results = {
148971
+ smartling: {
148972
+ translate_paths: [
148973
+ {
148974
+ path: "*/message",
148975
+ key: "{*}/message",
148976
+ instruction: "*/description"
149011
148977
  }
149012
- }
149013
- v = partial.length === 0 ? "{}" : gap ? "{\n" + gap + partial.join(",\n" + gap) + "\n" + mind + "}" : "{" + partial.join(",") + "}";
149014
- gap = mind;
149015
- return v;
149016
- }
149017
- }
149018
- module2.exports = function(value, replacer, space) {
149019
- var i;
149020
- gap = "";
149021
- indent = "";
149022
- if (typeof space === "number") {
149023
- for (i = 0; i < space; i += 1) {
149024
- indent += " ";
148978
+ ],
148979
+ variants_enabled: true,
148980
+ string_format: "icu"
149025
148981
  }
149026
- } else if (typeof space === "string") {
149027
- indent = space;
148982
+ };
148983
+ for (const [id, msg] of Object.entries(msgs)) {
148984
+ results[id] = {
148985
+ message: msg.defaultMessage,
148986
+ description: typeof msg.description === "string" ? msg.description : JSON.stringify(msg.description)
148987
+ };
149028
148988
  }
149029
- rep = replacer;
149030
- if (replacer && typeof replacer !== "function" && (typeof replacer !== "object" || typeof replacer.length !== "number")) {
149031
- throw new Error("JSON.stringify");
148989
+ return results;
148990
+ };
148991
+ compareMessages = (el1, el2) => {
148992
+ if (el1.key === "smartling") {
148993
+ return -1;
149032
148994
  }
149033
- return str("", { "": value });
148995
+ if (el2.key === "smartling") {
148996
+ return 1;
148997
+ }
148998
+ return el1.key < el2.key ? -1 : el1.key === el2.key ? 0 : 1;
148999
+ };
149000
+ compile3 = (msgs) => {
149001
+ const results = {};
149002
+ for (const [id, msg] of Object.entries(msgs)) {
149003
+ if (id === "smartling") {
149004
+ continue;
149005
+ }
149006
+ results[id] = msg.message;
149007
+ }
149008
+ return results;
149034
149009
  };
149035
149010
  }
149036
149011
  });
149037
149012
 
149038
- // bazel-out/darwin-fastbuild/bin/external/npm/node_modules/jsonify/index.js
149039
- var require_jsonify = __commonJS({
149040
- "bazel-out/darwin-fastbuild/bin/external/npm/node_modules/jsonify/index.js"(exports) {
149041
- exports.parse = require_parse();
149042
- exports.stringify = require_stringify();
149013
+ // bazel-out/darwin-fastbuild/bin/packages/cli/lib_esnext/src/formatters/simple.js
149014
+ var simple_exports = {};
149015
+ __export(simple_exports, {
149016
+ compile: () => compile4,
149017
+ format: () => format5
149018
+ });
149019
+ var format5, compile4;
149020
+ var init_simple = __esm({
149021
+ "bazel-out/darwin-fastbuild/bin/packages/cli/lib_esnext/src/formatters/simple.js"() {
149022
+ format5 = (msgs) => {
149023
+ return Object.keys(msgs).reduce((all, k) => {
149024
+ all[k] = msgs[k].defaultMessage;
149025
+ return all;
149026
+ }, {});
149027
+ };
149028
+ compile4 = (msgs) => msgs;
149043
149029
  }
149044
149030
  });
149045
149031
 
149046
- // bazel-out/darwin-fastbuild/bin/external/npm/node_modules/json-stable-stringify/index.js
149047
- var require_json_stable_stringify = __commonJS({
149048
- "bazel-out/darwin-fastbuild/bin/external/npm/node_modules/json-stable-stringify/index.js"(exports, module2) {
149049
- var json = typeof JSON !== "undefined" ? JSON : require_jsonify();
149050
- module2.exports = function(obj, opts) {
149051
- if (!opts)
149052
- opts = {};
149053
- if (typeof opts === "function")
149054
- opts = { cmp: opts };
149055
- var space = opts.space || "";
149056
- if (typeof space === "number")
149057
- space = Array(space + 1).join(" ");
149058
- var cycles = typeof opts.cycles === "boolean" ? opts.cycles : false;
149059
- var replacer = opts.replacer || function(key, value) {
149060
- return value;
149061
- };
149062
- var cmp = opts.cmp && function(f) {
149063
- return function(node) {
149064
- return function(a, b) {
149065
- var aobj = { key: a, value: node[a] };
149066
- var bobj = { key: b, value: node[b] };
149067
- return f(aobj, bobj);
149068
- };
149032
+ // bazel-out/darwin-fastbuild/bin/packages/cli/lib_esnext/src/formatters/lokalise.js
149033
+ var lokalise_exports = {};
149034
+ __export(lokalise_exports, {
149035
+ compile: () => compile5,
149036
+ format: () => format6
149037
+ });
149038
+ var format6, compile5;
149039
+ var init_lokalise = __esm({
149040
+ "bazel-out/darwin-fastbuild/bin/packages/cli/lib_esnext/src/formatters/lokalise.js"() {
149041
+ format6 = (msgs) => {
149042
+ const results = {};
149043
+ for (const [id, msg] of Object.entries(msgs)) {
149044
+ results[id] = {
149045
+ translation: msg.defaultMessage,
149046
+ notes: typeof msg.description === "string" ? msg.description : JSON.stringify(msg.description)
149069
149047
  };
149070
- }(opts.cmp);
149071
- var seen = [];
149072
- return function stringify3(parent, key, node, level) {
149073
- var indent = space ? "\n" + new Array(level + 1).join(space) : "";
149074
- var colonSeparator = space ? ": " : ":";
149075
- if (node && node.toJSON && typeof node.toJSON === "function") {
149076
- node = node.toJSON();
149077
- }
149078
- node = replacer.call(parent, key, node);
149079
- if (node === void 0) {
149080
- return;
149081
- }
149082
- if (typeof node !== "object" || node === null) {
149083
- return json.stringify(node);
149084
- }
149085
- if (isArray(node)) {
149086
- var out = [];
149087
- for (var i = 0; i < node.length; i++) {
149088
- var item = stringify3(node, i, node[i], level + 1) || json.stringify(null);
149089
- out.push(indent + space + item);
149090
- }
149091
- return "[" + out.join(",") + indent + "]";
149092
- } else {
149093
- if (seen.indexOf(node) !== -1) {
149094
- if (cycles)
149095
- return json.stringify("__cycle__");
149096
- throw new TypeError("Converting circular structure to JSON");
149097
- } else
149098
- seen.push(node);
149099
- var keys = objectKeys(node).sort(cmp && cmp(node));
149100
- var out = [];
149101
- for (var i = 0; i < keys.length; i++) {
149102
- var key = keys[i];
149103
- var value = stringify3(node, key, node[key], level + 1);
149104
- if (!value)
149105
- continue;
149106
- var keyValue = json.stringify(key) + colonSeparator + value;
149107
- ;
149108
- out.push(indent + space + keyValue);
149109
- }
149110
- seen.splice(seen.indexOf(node), 1);
149111
- return "{" + out.join(",") + indent + "}";
149112
- }
149113
- }({ "": obj }, "", obj, 0);
149048
+ }
149049
+ return results;
149114
149050
  };
149115
- var isArray = Array.isArray || function(x) {
149116
- return {}.toString.call(x) === "[object Array]";
149051
+ compile5 = (msgs) => {
149052
+ const results = {};
149053
+ for (const [id, msg] of Object.entries(msgs)) {
149054
+ results[id] = msg.translation;
149055
+ }
149056
+ return results;
149117
149057
  };
149118
- var objectKeys = Object.keys || function(obj) {
149119
- var has = Object.prototype.hasOwnProperty || function() {
149120
- return true;
149121
- };
149122
- var keys = [];
149123
- for (var key in obj) {
149124
- if (has.call(obj, key))
149125
- keys.push(key);
149058
+ }
149059
+ });
149060
+
149061
+ // bazel-out/darwin-fastbuild/bin/packages/cli/lib_esnext/src/formatters/crowdin.js
149062
+ var crowdin_exports = {};
149063
+ __export(crowdin_exports, {
149064
+ compile: () => compile6,
149065
+ format: () => format7
149066
+ });
149067
+ var format7, compile6;
149068
+ var init_crowdin = __esm({
149069
+ "bazel-out/darwin-fastbuild/bin/packages/cli/lib_esnext/src/formatters/crowdin.js"() {
149070
+ format7 = (msgs) => {
149071
+ const results = {};
149072
+ for (const [id, msg] of Object.entries(msgs)) {
149073
+ results[id] = {
149074
+ message: msg.defaultMessage,
149075
+ description: typeof msg.description === "string" ? msg.description : JSON.stringify(msg.description)
149076
+ };
149126
149077
  }
149127
- return keys;
149078
+ return results;
149079
+ };
149080
+ compile6 = (msgs) => {
149081
+ const results = {};
149082
+ for (const [id, msg] of Object.entries(msgs)) {
149083
+ if (id === "smartling") {
149084
+ continue;
149085
+ }
149086
+ results[id] = msg.message;
149087
+ }
149088
+ return results;
149128
149089
  };
149129
149090
  }
149130
149091
  });
149131
149092
 
149093
+ // bazel-out/darwin-fastbuild/bin/packages/cli/lib_esnext/src/formatters/index.js
149094
+ async function resolveBuiltinFormatter(format8) {
149095
+ if (!format8) {
149096
+ return default_exports;
149097
+ }
149098
+ if (typeof format8 !== "string") {
149099
+ return format8;
149100
+ }
149101
+ switch (format8) {
149102
+ case "transifex":
149103
+ return transifex_exports;
149104
+ case "smartling":
149105
+ return smartling_exports;
149106
+ case "simple":
149107
+ return simple_exports;
149108
+ case "lokalise":
149109
+ return lokalise_exports;
149110
+ case "crowdin":
149111
+ return crowdin_exports;
149112
+ }
149113
+ try {
149114
+ return import((0, import_path.resolve)(process.cwd(), format8));
149115
+ } catch (e) {
149116
+ console.error(`Cannot resolve formatter ${format8}`);
149117
+ throw e;
149118
+ }
149119
+ }
149120
+ var import_path;
149121
+ var init_formatters = __esm({
149122
+ "bazel-out/darwin-fastbuild/bin/packages/cli/lib_esnext/src/formatters/index.js"() {
149123
+ init_default();
149124
+ init_transifex();
149125
+ init_smartling();
149126
+ init_simple();
149127
+ init_lokalise();
149128
+ init_crowdin();
149129
+ import_path = require("path");
149130
+ }
149131
+ });
149132
+
149132
149133
  // bazel-out/darwin-fastbuild/bin/packages/cli/lib_esnext/src/parse_script.js
149133
149134
  function parseScript(opts, fn) {
149134
149135
  return (source) => {
@@ -149418,7 +149419,7 @@ async function processFile(source, fn, _a) {
149418
149419
  overrideIdFn: (id, defaultMessage, description, fileName) => id || (0, import_ts_transformer2.interpolateName)({
149419
149420
  resourcePath: fileName
149420
149421
  }, idInterpolationPattern, {
149421
- content: description ? `${defaultMessage}#${description}` : defaultMessage
149422
+ content: description ? `${defaultMessage}#${typeof description === "string" ? description : (0, import_json_stable_stringify.default)(description)}` : defaultMessage
149422
149423
  })
149423
149424
  });
149424
149425
  }
@@ -154913,7 +154914,7 @@ var require_out4 = __commonJS({
154913
154914
  var version;
154914
154915
  var init_package = __esm({
154915
154916
  "bazel-out/darwin-fastbuild/bin/packages/cli/lib_esnext/package.json"() {
154916
- version = "5.0.0";
154917
+ version = "5.0.1";
154917
154918
  }
154918
154919
  });
154919
154920