Page MenuHomePhabricator

D13702.diff
No OneTemporary

D13702.diff

diff --git a/native/.babelrc.cjs b/native/.babelrc.cjs
--- a/native/.babelrc.cjs
+++ b/native/.babelrc.cjs
@@ -5,6 +5,9 @@
'@babel/plugin-proposal-optional-chaining',
'@babel/plugin-proposal-nullish-coalescing-operator',
['@babel/plugin-transform-private-methods', { loose: true }],
+ '@babel/plugin-transform-numeric-separator',
+ 'babel-plugin-transform-bigint',
+ '@babel/plugin-transform-named-capturing-groups-regex',
// react-native-reanimated must be last
'react-native-reanimated/plugin',
],
diff --git a/native/package.json b/native/package.json
--- a/native/package.json
+++ b/native/package.json
@@ -26,12 +26,15 @@
"@babel/cli": "^7.23.4",
"@babel/core": "^7.23.7",
"@babel/node": "^7.22.19",
+ "@babel/plugin-transform-named-capturing-groups-regex": "^7.25.7",
"@babel/plugin-transform-nullish-coalescing-operator": "^7.23.4",
+ "@babel/plugin-transform-numeric-separator": "^7.25.8",
"@babel/plugin-transform-optional-chaining": "^7.23.4",
"@babel/plugin-transform-private-methods": "^7.24.1",
"@babel/preset-flow": "^7.23.3",
"@redux-devtools/cli": "^2.0.0",
"babel-jest": "^29.7.0",
+ "babel-plugin-transform-bigint": "^1.0.34",
"babel-plugin-transform-remove-console": "^6.9.4",
"babel-plugin-transform-remove-strict-mode": "0.0.2",
"flow-bin": "^0.202.1",
diff --git a/patches/babel-plugin-transform-bigint+1.0.34.patch b/patches/babel-plugin-transform-bigint+1.0.34.patch
new file mode 100644
--- /dev/null
+++ b/patches/babel-plugin-transform-bigint+1.0.34.patch
@@ -0,0 +1,738 @@
+diff --git a/node_modules/babel-plugin-transform-bigint/index.js b/node_modules/babel-plugin-transform-bigint/index.js
+index 14cfc85..2ab3bb0 100644
+--- a/node_modules/babel-plugin-transform-bigint/index.js
++++ b/node_modules/babel-plugin-transform-bigint/index.js
+@@ -4,731 +4,20 @@ const syntaxBigInt = require('@babel/plugin-syntax-bigint').default;
+
+ module.exports = function (babel) {
+ const types = babel.types;
+- const getFunctionName = function (operator) {
+- switch (operator) {
+- // Arithmetic operators
+- case '+': return 'add';
+- case '-': return 'subtract';
+- case '*': return 'multiply';
+- case '/': return 'divide';
+- case '%': return 'remainder';
+- case '**': return 'exponentiate';
+- // Bitwise shift operators
+- case '<<': return 'leftShift';
+- case '>>': return 'signedRightShift';
+- // Binary bitwise operators
+- case '&': return 'bitwiseAnd';
+- case '|': return 'bitwiseOr';
+- case '^': return 'bitwiseXor';
+- }
+- return null;
+- };
+- const getRelationalFunctionName = function (operator) {
+- // Relational operators
+- switch (operator) {
+- case '<': return 'lessThan';
+- case '>': return 'greaterThan';
+- case '<=': return 'lessThanOrEqual';
+- case '>=': return 'greaterThanOrEqual';
+- case '===': return 'equal';
+- case '!==': return 'notEqual';
+- }
+- return null;
+- };
+- const getUnaryFunctionName = function (operator) {
+- switch (operator) {
+- case '-': return 'unaryMinus';
+- case '~': return 'bitwiseNot';
+- }
+- return null;
+- };
+- const getUpdateFunctionName = function (operator) {
+- switch (operator) {
+- case '++': return 'add';
+- case '--': return 'subtract';
+- }
+- return null;
+- };
+-
+- let visited = new Map();
+- const canBeBigInt = function (path) {
+- if (visited.get(path) != null) {
+- return visited.get(path);
+- }
+- visited.set(path, maybeJSBI);
+- const result = canBeBigIntInternal(path);
+- //console.debug('canBeBigInt: ' + path.toString() + ', result: ' + result);
+- if (result === maybeJSBI) {
+- visited.delete(path);
+- } else {
+- visited.set(path, result);
+- }
+- return result;
+- };
+- const and = function (a, b) {
+- if (a === maybeJSBI) {
+- return b;
+- }
+- if (b === maybeJSBI) {
+- return a;
+- }
+- if (a === JSBI && b === JSBI) {
+- return JSBI;
+- }
+- return false;
+- };
+-
+- const tryType = function (X, binding, path) {
+- if ((X === false || X === JSBI) && binding.constant) {
+- return true;
+- }
+- if ((X === false || X === JSBI) && !binding.constant) {
+- let allAssignmentsHaveSameType = true;
+- for (const path of binding.constantViolations) {
+- allAssignmentsHaveSameType = allAssignmentsHaveSameType && canBeBigInt(path) === X;
+- }
+- if (allAssignmentsHaveSameType) {
+- return true;
+- }
+- if (visited.get(path) === maybeJSBI) { // assume that variable type is the same
+- const visitedOriginal = new Map(visited.entries());
+- visited.set(path, X);
+- for (const e of visited.entries()) {
+- if (e[1] === maybeJSBI) {
+- visited.delete(e[0]);
+- }
+- }
+- let allAssignmentsHaveSameType = true;
+- for (const path of binding.constantViolations) {
+- allAssignmentsHaveSameType = allAssignmentsHaveSameType && canBeBigInt(path) === X;
+- }
+- if (allAssignmentsHaveSameType) {
+- return true;
+- }
+- visited = visitedOriginal;
+- }
+- }
+- return false;
+- };
+-
+- const canBeBigIntInternal = function (path) {
+- if (path.node.type === 'BigIntLiteral') {
+- return JSBI;
+- }
+- if (path.node.type === 'NumericLiteral') {
+- return false;
+- }
+- if (path.node.type === 'StringLiteral') {
+- return false;
+- }
+- if (path.node.type === 'NullLiteral') {
+- return false;
+- }
+- if (path.node.type === 'RegExpLiteral') {
+- return false;
+- }
+- if (path.node.type === 'BooleanLiteral') {
+- return false;
+- }
+- if (path.node.type === 'TemplateLiteral') {
+- return false;
+- }
+- // Math.floor(a / b)
+- if (path.parentPath.node.type === 'CallExpression' &&
+- path.parentPath.node.arguments.length === 1 &&
+- path.parentPath.node.arguments[0] === path.node) {
+- const callee = path.parentPath.node.callee;
+- if (callee.type === 'MemberExpression' &&
+- callee.object.type === 'Identifier' &&
+- callee.object.name === 'Math') {
+- return false;
+- }
+- }
+- if (path.node.type === 'UnaryExpression') {
+- if (path.node.operator === '+') { // +0n is not allowed
+- return false;
+- }
+- return canBeBigInt(path.get('argument'));
+- }
+- if (path.node.type === 'BinaryExpression') {
+- if (getRelationalFunctionName(path.node.operator) != null) {
+- return false;
+- }
+- return and(canBeBigInt(path.get('left')), canBeBigInt(path.get('right')));
+- }
+- if (path.node.type === 'AssignmentExpression') {
+- if (path.node.left.type === 'ArrayPattern') {
+- return maybeJSBI;
+- }
+- if (path.node.operator === '=') {
+- return canBeBigInt(path.get('right'));
+- }
+- return and(canBeBigInt(path.get('left')), canBeBigInt(path.get('right')));
+- }
+-
+- if (path.node.type === 'Identifier') {
+- const binding = path.scope.getBinding(path.node.name);
+- if (binding != null) {
+- if (binding.path.node.type === 'VariableDeclarator') {
+- const x = binding.path.get('init');
+- if (x.node != null) {
+- let X = null;
+- if (x.node.type !== 'ArrayExpression') {
+- X = canBeBigInt(x);
+- if (tryType(X, binding, path)) {
+- return X;
+- }
+- }
+- }
+- }
+- for (const path of binding.referencePaths) {
+- //The next code causes infinite recursion, seems:
+- //if (path.parentPath.node.type === 'BinaryExpression' && getFunctionName(path.parentPath.node.operator) != null && canBeBigInt(path.parentPath) === false) {
+- // return false;
+- //}
+- }
+- if (binding.path.node.type === 'Identifier' && binding.path.parentPath.node.type === 'FunctionDeclaration') {
+- //console.log(binding.path.parentPath.node, '!!!');
+- const functionPath = binding.path.parentPath;
+- const id = functionPath.get('id');
+- const functionBinding = functionPath.scope.getBinding(id.node.name);
+- if (functionBinding != null) {
+- let argIsBigInt = undefined;
+- //TODO: check no exports
+- for (const path of functionBinding.referencePaths) {
+- //console.log('function call: ' + path.parentPath + '', path.parentPath);
+- const functionCall = path.parentPath;
+- if (types.isCallExpression(functionCall)) {
+- //TODO: check arguments
+- const args = functionCall.get('arguments');
+- for (let i = 0; i < args.length; i += 1) {
+- const a = args[i];
+- //console.log('arg', a);
+- const t = canBeBigInt(a);
+- if (t === false && (argIsBigInt == undefined || argIsBigInt === 'false')) {
+- argIsBigInt = 'false';
+- } else if (t === JSBI && (argIsBigInt == undefined || argIsBigInt === 'true')) {
+- argIsBigInt = 'true';
+- } else {
+- argIsBigInt = 'NO';
+- }
+- }
+- } else {
+- argIsBigInt = 'NO';
+- }
+- }
+- if (argIsBigInt === 'false') {
+- return false;
+- }
+- if (argIsBigInt === 'true') {
+- return JSBI;
+- }
+- }
+- }
+- } else {
+- if (path.node.name === 'undefined') {
+- return false;
+- }
+- }
+- const checkTypeOf = function (node, variableName, type, not) {
+- // typeof x === "bigint"
+- if (node.type === 'BinaryExpression' && (!not ? node.operator === '===' : node.operator === '!==')) {
+- if (node.left.type === 'UnaryExpression' && node.left.operator === 'typeof') {
+- if (node.left.argument.type === 'Identifier' && node.left.argument.name === variableName) {
+- if (node.right.type === 'StringLiteral' && node.right.value === type) {
+- return true;
+- }
+- }
+- }
+- }
+- if (type === 'bigint') {
+- // x instanceof JSBI
+- if (!not || node.type === 'UnaryExpression' && node.operator === '!') {
+- if (node.argument.type === 'BinaryExpression' && node.argument.operator === 'instanceof') {
+- if (node.argument.left.type === 'Identifier' && node.argument.left.name === variableName) {
+- if (node.argument.right.type === 'Identifier' && node.argument.right.name === 'JSBI') {
+- return true;
+- }
+- }
+- }
+- }
+- }
+- return false;
+- };
+- if (binding != null && binding.constant) {
+- const ifStatement = path.findParent(path => path.isIfStatement());
+- const variableName = path.node.name;
+- if (ifStatement != null) {
+- const tmp = ifStatement.get('test');
+- if (tmp.node.operator === '&&') {
+- if (checkTypeOf(tmp.node.left, variableName, 'number', false)) {
+- return false;
+- }
+- if (checkTypeOf(tmp.node.right, variableName, 'number', false)) {
+- return false;
+- }
+- }
+- }
+- }
+- if (binding != null) {
+- //console.debug(binding);
+- const functionDeclarationOrExpression = path.findParent(path => path.isFunctionDeclaration() || path.isFunctionExpression());
+- if (functionDeclarationOrExpression != null && functionDeclarationOrExpression.node.params.filter(param => !types.isIdentifier(param)).length == 0) {
+- const body = functionDeclarationOrExpression.get('body');
+- const x = body.get('body')[0];
+- if (types.isIfStatement(x)) {
+- const ifStatement = x;
+- const tmp = ifStatement.get('test');
+- const variableName = path.node.name;
+- const consequent = ifStatement.get('consequent').node;
+- let ok = false;
+- if (types.isBlockStatement(consequent)) {
+- if (consequent.body.length === 1) {
+- if (types.isThrowStatement(consequent.body[0])) {
+- ok = true;
+- }
+- }
+- }
+- const isNotTypeOfCheck = function (node, type, variableName) {
+- if (checkTypeOf(node, variableName, type, true)) {
+- return true;
+- }
+- if (node.type === 'LogicalExpression' && node.operator === '||') {
+- if (isNotTypeOfCheck(node.left, type, variableName)) {
+- return true;
+- }
+- if (isNotTypeOfCheck(node.right, type, variableName)) {
+- return true;
+- }
+- }
+- return false;
+- };
+- if (ok && isNotTypeOfCheck(tmp.node, 'bigint', variableName)) {
+- if (tryType(JSBI, binding, path)) {
+- return JSBI;
+- }
+- }
+- if (ok && isNotTypeOfCheck(tmp.node, 'number', variableName)) {
+- if (tryType(false, binding, path)) {
+- return false;
+- }
+- }
+- }
+- }
+- }
+- if (binding != null && !binding.constant) {
+- let hasFalse = false;
+- let hasJSBI= false;
+- for (const path of binding.constantViolations) {
+- if (canBeBigInt(path) === false) {
+- hasFalse = true;
+- } else if (canBeBigInt(path) === JSBI) {
+- hasJSBI = true;
+- }
+- }
+- if (hasFalse && !hasJSBI) {
+- if (tryType(false, binding, path)) {
+- return false;
+- }
+- }
+- if (!hasFalse && hasJSBI) {
+- if (tryType(JSBI, binding, path)) {
+- return JSBI;
+- }
+- }
+- }
+- return maybeJSBI;
+- }
+-
+- if (path.node.type === 'ConditionalExpression') {
+- const a = canBeBigInt(path.get('consequent'));
+- const b = canBeBigInt(path.get('alternate'));
+- return a === b ? a : maybeJSBI;
+- }
+- if (path.node.type === 'FunctionExpression') {
+- return false;
+- }
+- if (path.node.type === 'NewExpression') {
+- return false;
+- }
+- if (path.node.type === 'LogicalExpression') {
+- return false;//?
+- }
+- if (path.node.type === 'ObjectProperty') {
+- return false;//?
+- }
+- if (path.node.type === 'CallExpression') {
+- if (path.node.callee.type === 'MemberExpression' &&
+- path.node.callee.object.type === 'Identifier' &&
+- path.node.callee.object.name === 'Math') {
+- return false;
+- }
+- if (path.node.callee.type === 'Identifier') {
+- const name = path.node.callee.name;
+- if (name === 'Number') {
+- return false;
+- }
+- if (name === 'String') {
+- return false;
+- }
+- if (name === 'Boolean') {
+- return false;
+- }
+- if (name === 'BigInt') {
+- return JSBI;
+- }
+- }
+- if (path.node.callee.type === 'MemberExpression' &&
+- path.node.callee.object.type === 'Identifier' &&
+- (path.node.callee.object.name === 'JSBI' || path.node.callee.object.name === 'BigInt')) {
+- if (path.node.callee.object.name === 'JSBI') {
+- if (['lessThan', 'greateThan', 'equal', 'notEqual', 'lessThanOrEqual', 'greaterThanOrEqual', 'toNumber'].indexOf(path.node.callee.property.name) !== -1) {
+- return false;
+- }
+- }
+- return JSBI;
+- }
+- }
+- if (path.node.type === 'CallExpression') {
+- if (path.node.callee.type === 'Identifier') {
+- const binding = path.scope.getBinding(path.node.callee.name);
+- if (binding != null) {
+- if (binding.path.node.type === 'FunctionDeclaration' || binding.path.node.type === 'FunctionExpression') {
+- //console.log('binding.path', binding.path);
+- //const statements = binding.path.get('body').get('body');
+- const statements = [];
+- binding.path.getScope().traverse(binding.path.node, {ReturnStatement: function(path){ statements.push(path); }}, this);
+- let returnType = undefined;
+- for (const statement of statements) {
+- if (statement.type === 'ReturnStatement') {
+- const t = canBeBigInt(statement.get('argument'));
+- if (returnType === undefined) {
+- returnType = t;
+- }
+- if (returnType !== t) {
+- returnType = maybeJSBI;
+- }
+- }
+- }
+- if (returnType === false || returnType == JSBI) {
+- return returnType;
+- }
+- }
+- }
+- }
+- }
+- if (path.node.type === 'CallExpression') {
+- return maybeJSBI;
+- }
+- if (path.node.type === 'UpdateExpression') {
+- return canBeBigInt(path.get('argument'));
+- }
+- if (path.node.type === 'MemberExpression') {
+- return maybeJSBI;
+- }
+- if (path.node.type === 'ObjectExpression') {
+- return false;
+- }
+- if (path.node.type === 'ArrayExpression') {
+- return false;
+- }
+- if (path.node.type === 'ArrayPattern') {
+- return maybeJSBI;
+- }
+- console.warn('unknown path.node.type: ' + path.node.type);
+- //TODO:
+- return maybeJSBI;
+- };
+-
+- const JSBI = 'JSBI';
+- const maybeJSBI = 'maybeJSBI';
+- //const maybeJSBI = JSBI;
+- const IMPORT_PATH = './jsbi.mjs';
+-
+- const maybeJSBICode = `
+-
+-var maybeJSBI = {
+- toNumber: function toNumber(a) {
+- return typeof a === "object" ? JSBI.toNumber(a) : Number(a);
+- },
+- add: function add(a, b) {
+- return typeof a === "object" && typeof b === "object" ? JSBI.add(a, b) : a + b;
+- },
+- subtract: function subtract(a, b) {
+- return typeof a === "object" && typeof b === "object" ? JSBI.subtract(a, b) : a - b;
+- },
+- multiply: function multiply(a, b) {
+- return typeof a === "object" && typeof b === "object" ? JSBI.multiply(a, b) : a * b;
+- },
+- divide: function divide(a, b) {
+- return typeof a === "object" && typeof b === "object" ? JSBI.divide(a, b) : a / b;
+- },
+- remainder: function remainder(a, b) {
+- return typeof a === "object" && typeof b === "object" ? JSBI.remainder(a, b) : a % b;
+- },
+- exponentiate: function exponentiate(a, b) {
+- return typeof a === "object" && typeof b === "object" ? JSBI.exponentiate(a, b) : (typeof a === "bigint" && typeof b === "bigint" ? new Function("a", "b", "return a**b")(a, b) : Math.pow(a, b));
+- },
+- leftShift: function leftShift(a, b) {
+- return typeof a === "object" && typeof b === "object" ? JSBI.leftShift(a, b) : a << b;
+- },
+- signedRightShift: function signedRightShift(a, b) {
+- return typeof a === "object" && typeof b === "object" ? JSBI.signedRightShift(a, b) : a >> b;
+- },
+- bitwiseAnd: function bitwiseAnd(a, b) {
+- return typeof a === "object" && typeof b === "object" ? JSBI.bitwiseAnd(a, b) : a & b;
+- },
+- bitwiseOr: function bitwiseOr(a, b) {
+- return typeof a === "object" && typeof b === "object" ? JSBI.bitwiseOr(a, b) : a | b;
+- },
+- bitwiseXor: function bitwiseXor(a, b) {
+- return typeof a === "object" && typeof b === "object" ? JSBI.bitwiseXor(a, b) : a ^ b;
+- },
+- lessThan: function lessThan(a, b) {
+- return typeof a === "object" && typeof b === "object" ? JSBI.lessThan(a, b) : a < b;
+- },
+- greaterThan: function greaterThan(a, b) {
+- return typeof a === "object" && typeof b === "object" ? JSBI.greaterThan(a, b) : a > b;
+- },
+- lessThanOrEqual: function lessThanOrEqual(a, b) {
+- return typeof a === "object" && typeof b === "object" ? JSBI.lessThanOrEqual(a, b) : a <= b;
+- },
+- greaterThanOrEqual: function greaterThanOrEqual(a, b) {
+- return typeof a === "object" && typeof b === "object" ? JSBI.greaterThanOrEqual(a, b) : a >= b;
+- },
+- equal: function equal(a, b) {
+- return typeof a === "object" && typeof b === "object" ? JSBI.equal(a, b) : a === b;
+- },
+- notEqual: function notEqual(a, b) {
+- return typeof a === "object" && typeof b === "object" ? JSBI.notEqual(a, b) : a !== b;
+- },
+- unaryMinus: function unaryMinus(a) {
+- return typeof a === "object" ? JSBI.unaryMinus(a) : -a;
+- },
+- bitwiseNot: function bitwiseNot(a) {
+- return typeof a === "object" ? JSBI.bitwiseNot(a) : ~a;
+- }
+-};
+- `;
+- //const maybeJSBICode = '';
+-
+- const typeOfIgnore = new Set();
+-
+ return {
+ inherits: syntaxBigInt,
+ visitor: {
+- CallExpression: function (path, state) {
+- if (path.node.callee.name === 'Number') {
+- const JSBI = canBeBigInt(path.get('arguments')[0]);
+- if (JSBI !== false) {
+- path.replaceWith(types.callExpression(types.memberExpression(types.identifier(JSBI), types.identifier('toNumber')), path.node.arguments));
+- }
+- }
+- if (path.node.callee.name === 'BigInt') {
+- path.replaceWith(types.callExpression(types.memberExpression(types.identifier(JSBI), types.identifier('BigInt')), path.node.arguments));
+- }
+- if (path.node.callee.type === 'MemberExpression' &&
+- path.node.callee.object.type === 'Identifier' &&
+- path.node.callee.object.name === 'BigInt' &&
+- (path.node.callee.property.name === 'asUintN' || path.node.callee.property.name === 'asIntN')) {
+- path.replaceWith(types.callExpression(types.memberExpression(types.identifier(JSBI), types.identifier(path.node.callee.property.name)), path.node.arguments));
+- }
+- },
+ BigIntLiteral: function (path, state) {
+ const value = path.node.value;
+ const number = Number(value); //TODO:
+ if (number >= Number.MIN_SAFE_INTEGER && number <= Number.MAX_SAFE_INTEGER) {
+ // 1n -> JSBI.BigInt(1)
+- path.replaceWith(types.callExpression(types.memberExpression(types.identifier(JSBI), types.identifier('BigInt')), [types.numericLiteral(number)]));
++ path.replaceWith(types.callExpression(types.identifier('BigInt'), [types.numericLiteral(number)]));
+ } else {
+ // 9007199254740993n -> JSBI.BigInt('9007199254740993')
+- path.replaceWith(types.callExpression(types.memberExpression(types.identifier(JSBI), types.identifier('BigInt')), [types.StringLiteral(value)]));
++ path.replaceWith(types.callExpression(types.identifier('BigInt'), [types.StringLiteral(value)]));
+ }
+ },
+- BinaryExpression: function (path, state) {
+- const operator = path.node.operator;
+- const JSBI = getRelationalFunctionName(operator) != null ? and(canBeBigInt(path.get('left')), canBeBigInt(path.get('right'))) : canBeBigInt(path);
+- if (JSBI !== false) {
+- const functionName = getFunctionName(operator) || getRelationalFunctionName(operator);
+- if (functionName != null) {
+- // x * y -> JSBI.multiply(x, y)
+- path.replaceWith(types.callExpression(types.memberExpression(types.identifier(JSBI), types.identifier(functionName)), [path.node.left, path.node.right]));
+- }
+- }
+- // typeof x
+- if ((operator === '===' || operator === '!==') &&
+- types.isUnaryExpression(path.node.left) && path.node.left.operator === 'typeof' && types.isIdentifier(path.node.left.argument) &&
+- types.isStringLiteral(path.node.right)) {
+- // typeof x === 'bigint' -> x instanceof JSBI
+- const typeOfTest = path.node.left;
+- typeOfIgnore.add(typeOfTest);
+- if (path.node.right.value === 'bigint') {
+- const instanceOfNode = types.binaryExpression('instanceof', path.node.left.argument, types.identifier('JSBI'));
+- path.replaceWith(operator === '!==' ? types.unaryExpression('!', instanceOfNode) : instanceOfNode);
+- }
+- }
+- },
+- UnaryExpression: function (path, state) {
+- const JSBI = canBeBigInt(path);
+- if (JSBI !== false) {
+- const functionName = getUnaryFunctionName(path.node.operator);
+- if (functionName !== null) {
+- // -x -> JSBI.unaryMinus(x)
+- path.replaceWith(types.callExpression(types.memberExpression(types.identifier(JSBI), types.identifier(functionName)), [path.node.argument]));
+- }
+- }
+- // typeof x
+- if (path.node.operator === 'typeof' && !typeOfIgnore.has(path.node)) {
+- throw new RangeError('not supported');
+- }
+- },
+- UpdateExpression: function (path, state) {
+- throw new RangeError('UpdateExpressions are not supported because of the complexity: ' + path);
+- // The implementation below is buggy, as it converts ++x to x += 1n even for number x
+- /*
+- const JSBI = canBeBigInt(path);
+- if (JSBI !== false) {
+- const operator = path.node.operator;
+- const prefix = path.node.prefix;
+- const functionName = getUpdateFunctionName(operator);
+- if (functionName != null) {
+- const one = types.callExpression(types.memberExpression(types.identifier(JSBI), types.identifier('BigInt')), [types.numericLiteral(1)]);
+- const argument = path.node.argument;
+- if (types.isMemberExpression(argument)) {
+- if (prefix) {
+- const x = path.scope.generateUidIdentifier('x');
+- path.scope.push({id: x});
+- const y = path.scope.generateUidIdentifier('y');
+- path.scope.push({id: y});
+- // ++object[property] -> (x = object, y = property, x[y] = x[y] + 1)
+- path.replaceWith(types.sequenceExpression([
+- types.assignmentExpression('=', x, argument.object),
+- types.assignmentExpression('=', y, argument.computed ? argument.property : types.StringLiteral(argument.property.name)),
+- types.assignmentExpression('=', types.memberExpression(x, y, true), types.callExpression(types.memberExpression(types.identifier(JSBI), types.identifier(functionName)), [types.memberExpression(x, y, true), one]))
+- ]));
+- } else {
+- const x = path.scope.generateUidIdentifier('x');
+- path.scope.push({id: x});
+- const y = path.scope.generateUidIdentifier('y');
+- path.scope.push({id: y});
+- const z = path.scope.generateUidIdentifier('z');
+- path.scope.push({id: z});
+- // object[property]++ -> (x = object, y = property, z = x[y], x[y] = x[y] + 1, z)
+- path.replaceWith(types.sequenceExpression([
+- types.assignmentExpression('=', x, argument.object),
+- types.assignmentExpression('=', y, argument.computed ? argument.property : types.StringLiteral(argument.property.name)),
+- types.assignmentExpression('=', z, types.memberExpression(x, y, true)),
+- types.assignmentExpression('=', types.memberExpression(x, y, true), types.callExpression(types.memberExpression(types.identifier(JSBI), types.identifier(functionName)), [z, one])),
+- z
+- ]));
+- }
+- } else {
+- if (prefix) {
+- // ++argument -> (argument = argument + 1)
+- path.replaceWith(types.assignmentExpression('=', argument, types.callExpression(types.memberExpression(types.identifier(JSBI), types.identifier(functionName)), [argument, one])));
+- } else {
+- const x = path.scope.generateUidIdentifier('x');
+- path.scope.push({id: x});
+- // argument++ -> (x = argument, argument = argument + 1, x)
+- path.replaceWith(types.sequenceExpression([
+- types.assignmentExpression('=', x, argument),
+- types.assignmentExpression('=', argument, types.callExpression(types.memberExpression(types.identifier(JSBI), types.identifier(functionName)), [argument, one])),
+- x
+- ]));
+- }
+- }
+- }
+- }*/
+-
+- },
+- AssignmentExpression: function (path, state) {
+- const isConstant = function (path) {
+- if (types.isStringLiteral(path.node)) {
+- return true;
+- }
+- if (types.isNumericLiteral(path.node)) {
+- return true;
+- }
+- if (types.isIdentifier(path.node)) {
+- const binding = path.scope.getBinding(path.node.name);
+- if (binding == null) {
+- console.warn('unknown identifier: ' + path.node.name);
+- return false;
+- }
+- return binding.constant;
+- }
+- return false;
+- };
+- if (types.isMemberExpression(path.node.left) && types.isIdentifier(path.node.left.object) && path.node.left.object.name === 'arguments') {
+- throw new RangeError('arguments should not be used');
+- }
+- const JSBI = canBeBigInt(path);
+- if (JSBI !== false) {
+- const operator = path.node.operator;
+- if (operator.endsWith('=')) {
+- const functionName = getFunctionName(operator.slice(0, -'='.length));
+- if (functionName != null) {
+- const left = path.node.left;
+- const right = path.node.right;
+- if (types.isMemberExpression(left)) {
+- // object[property] += right -> (x = object, y = property, x[y] = x[y] + right)
+- const expressions = [];
+- let x = left.object;
+- if (!isConstant(path.get('left').get('object'))) {
+- x = path.scope.generateUidIdentifier('x');
+- path.scope.push({id: x});
+- expressions.push(types.assignmentExpression('=', x, left.object));
+- }
+- let y = left.property;
+- if (!isConstant(path.get('left').get('property'))) {
+- y = path.scope.generateUidIdentifier('y');
+- path.scope.push({id: y});
+- expressions.push(types.assignmentExpression('=', y, left.property));
+- }
+- const assignment = types.assignmentExpression('=',
+- types.memberExpression(x, y, left.computed),
+- types.callExpression(
+- types.memberExpression(types.identifier(JSBI), types.identifier(functionName)),
+- [types.memberExpression(x, y, left.computed), right]
+- )
+- );
+- expressions.push(assignment);
+- if (expressions.length === 1) {
+- path.replaceWith(expressions[0]);
+- } else {
+- path.replaceWith(types.sequenceExpression(expressions));
+- }
+- } else {
+- // left += right -> (left = left + right)
+- path.replaceWith(types.assignmentExpression('=', left, types.callExpression(types.memberExpression(types.identifier(JSBI), types.identifier(functionName)), [left, right])));
+- }
+- }
+- }
+- }
+- },
+- Program: function (path) {
+- // https://stackoverflow.com/a/35994497
+- const identifier = types.identifier(JSBI);
+- const importDefaultSpecifier = types.importDefaultSpecifier(identifier);
+- const importDeclaration = types.importDeclaration([importDefaultSpecifier], types.stringLiteral(IMPORT_PATH));
+- path.unshiftContainer('body', importDeclaration);
+- },
+- Identifier: function (path) {
+- if (path.node.name === 'eval') {
+- throw new RangeError('eval should not be used');
+- }
+- }
+- },
+- pre: function () {
+- visited.clear();
+- typeOfIgnore.clear();
+ },
+- post: function (state) {
+- //console.log(state);
+- const usesMaybeJSBI = state.path.toString().indexOf('maybeJSBI') !== -1;
+- if (usesMaybeJSBI) {
+- state.ast.program.body.unshift(babel.parse(maybeJSBICode).program.body[0]);
+- }
+- }
+ };
+ };
diff --git a/patches/metro-react-native-babel-preset+0.72.3.patch b/patches/metro-react-native-babel-preset+0.72.3.patch
new file mode 100644
--- /dev/null
+++ b/patches/metro-react-native-babel-preset+0.72.3.patch
@@ -0,0 +1,17 @@
+diff --git a/node_modules/metro-react-native-babel-preset/src/configs/main.js b/node_modules/metro-react-native-babel-preset/src/configs/main.js
+index 7ffbc92..912903d 100644
+--- a/node_modules/metro-react-native-babel-preset/src/configs/main.js
++++ b/node_modules/metro-react-native-babel-preset/src/configs/main.js
+@@ -136,12 +136,6 @@ const getPreset = (src, options) => {
+ extraPlugins.push([require("@babel/plugin-transform-async-to-generator")]);
+ }
+
+- if (!isHermes && (isNull || src.indexOf("**") !== -1)) {
+- extraPlugins.push([
+- require("@babel/plugin-transform-exponentiation-operator"),
+- ]);
+- }
+-
+ if (
+ isNull ||
+ src.indexOf("React.createClass") !== -1 ||
diff --git a/yarn.lock b/yarn.lock
--- a/yarn.lock
+++ b/yarn.lock
@@ -293,6 +293,13 @@
dependencies:
"@babel/types" "^7.22.5"
+"@babel/helper-annotate-as-pure@^7.25.7":
+ version "7.25.7"
+ resolved "https://registry.yarnpkg.com/@babel/helper-annotate-as-pure/-/helper-annotate-as-pure-7.25.7.tgz#63f02dbfa1f7cb75a9bdb832f300582f30bb8972"
+ integrity sha512-4xwU8StnqnlIhhioZf1tqnVWeQ9pvH/ujS8hRfw/WOza+/a+1qv69BWNy+oY231maTCWgKWhfBU7kDpsds6zAA==
+ dependencies:
+ "@babel/types" "^7.25.7"
+
"@babel/helper-builder-binary-assignment-operator-visitor@^7.22.15":
version "7.22.15"
resolved "https://registry.yarnpkg.com/@babel/helper-builder-binary-assignment-operator-visitor/-/helper-builder-binary-assignment-operator-visitor-7.22.15.tgz#5426b109cf3ad47b91120f8328d8ab1be8b0b956"
@@ -350,6 +357,15 @@
regexpu-core "^5.3.1"
semver "^6.3.1"
+"@babel/helper-create-regexp-features-plugin@^7.25.7":
+ version "7.25.7"
+ resolved "https://registry.yarnpkg.com/@babel/helper-create-regexp-features-plugin/-/helper-create-regexp-features-plugin-7.25.7.tgz#dcb464f0e2cdfe0c25cc2a0a59c37ab940ce894e"
+ integrity sha512-byHhumTj/X47wJ6C6eLpK7wW/WBEcnUeb7D0FNc/jFQnQVw7DOso3Zz5u9x/zLrFVkHa89ZGDbkAa1D54NdrCQ==
+ dependencies:
+ "@babel/helper-annotate-as-pure" "^7.25.7"
+ regexpu-core "^6.1.1"
+ semver "^6.3.1"
+
"@babel/helper-define-polyfill-provider@^0.4.4":
version "0.4.4"
resolved "https://registry.yarnpkg.com/@babel/helper-define-polyfill-provider/-/helper-define-polyfill-provider-0.4.4.tgz#64df615451cb30e94b59a9696022cffac9a10088"
@@ -423,6 +439,11 @@
resolved "https://registry.yarnpkg.com/@babel/helper-plugin-utils/-/helper-plugin-utils-7.24.0.tgz#945681931a52f15ce879fd5b86ce2dae6d3d7f2a"
integrity sha512-9cUznXMG0+FxRuJfvL82QlTqIzhVW9sL0KjMPHhAOOvpQGL8QtdxnBKILjBqxlHyliz0yCa1G903ZXI/FuHy2w==
+"@babel/helper-plugin-utils@^7.25.7":
+ version "7.25.7"
+ resolved "https://registry.yarnpkg.com/@babel/helper-plugin-utils/-/helper-plugin-utils-7.25.7.tgz#8ec5b21812d992e1ef88a9b068260537b6f0e36c"
+ integrity sha512-eaPZai0PiqCi09pPs3pAFfl/zYgGaE6IdXtYvmf0qlcDTd3WCtO7JWCcRd64e0EQrcYgiHibEZnOGsSY4QSgaw==
+
"@babel/helper-remap-async-to-generator@^7.18.9", "@babel/helper-remap-async-to-generator@^7.22.20":
version "7.22.20"
resolved "https://registry.yarnpkg.com/@babel/helper-remap-async-to-generator/-/helper-remap-async-to-generator-7.22.20.tgz#7b68e1cb4fa964d2996fd063723fb48eca8498e0"
@@ -476,11 +497,21 @@
resolved "https://registry.yarnpkg.com/@babel/helper-string-parser/-/helper-string-parser-7.23.4.tgz#9478c707febcbbe1ddb38a3d91a2e054ae622d83"
integrity sha512-803gmbQdqwdf4olxrX4AJyFBV/RTr3rSmOj0rKwesmzlfhYNDEs+/iOcznzpNWlJlIlTJC2QfPFcHB6DlzdVLQ==
+"@babel/helper-string-parser@^7.25.7":
+ version "7.25.7"
+ resolved "https://registry.yarnpkg.com/@babel/helper-string-parser/-/helper-string-parser-7.25.7.tgz#d50e8d37b1176207b4fe9acedec386c565a44a54"
+ integrity sha512-CbkjYdsJNHFk8uqpEkpCvRs3YRp9tY6FmFY7wLMSYuGYkrdUi7r2lc4/wqsvlHoMznX3WJ9IP8giGPq68T/Y6g==
+
"@babel/helper-validator-identifier@^7.22.20":
version "7.22.20"
resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.22.20.tgz#c4ae002c61d2879e724581d96665583dbc1dc0e0"
integrity sha512-Y4OZ+ytlatR8AI+8KZfKuL5urKp7qey08ha31L8b3BwewJAoJamTzyvxPR/5D+KkdJCGPq/+8TukHBlY10FX9A==
+"@babel/helper-validator-identifier@^7.25.7":
+ version "7.25.7"
+ resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.25.7.tgz#77b7f60c40b15c97df735b38a66ba1d7c3e93da5"
+ integrity sha512-AM6TzwYqGChO45oiuPqwL2t20/HdMC1rTPAesnBCgPCSF1x3oN9MVUwQV2iyz4xqWrctwK5RNC8LV22kaQCNYg==
+
"@babel/helper-validator-option@^7.18.6", "@babel/helper-validator-option@^7.22.15", "@babel/helper-validator-option@^7.23.5":
version "7.23.5"
resolved "https://registry.yarnpkg.com/@babel/helper-validator-option/-/helper-validator-option-7.23.5.tgz#907a3fbd4523426285365d1206c423c4c5520307"
@@ -1026,6 +1057,14 @@
"@babel/helper-create-regexp-features-plugin" "^7.22.5"
"@babel/helper-plugin-utils" "^7.22.5"
+"@babel/plugin-transform-named-capturing-groups-regex@^7.25.7":
+ version "7.25.7"
+ resolved "https://registry.yarnpkg.com/@babel/plugin-transform-named-capturing-groups-regex/-/plugin-transform-named-capturing-groups-regex-7.25.7.tgz#a2f3f6d7f38693b462542951748f0a72a34d196d"
+ integrity sha512-BtAT9LzCISKG3Dsdw5uso4oV1+v2NlVXIIomKJgQybotJY3OwCwJmkongjHgwGKoZXd0qG5UZ12JUlDQ07W6Ow==
+ dependencies:
+ "@babel/helper-create-regexp-features-plugin" "^7.25.7"
+ "@babel/helper-plugin-utils" "^7.25.7"
+
"@babel/plugin-transform-new-target@^7.23.3":
version "7.23.3"
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-new-target/-/plugin-transform-new-target-7.23.3.tgz#5491bb78ed6ac87e990957cea367eab781c4d980"
@@ -1049,6 +1088,13 @@
"@babel/helper-plugin-utils" "^7.22.5"
"@babel/plugin-syntax-numeric-separator" "^7.10.4"
+"@babel/plugin-transform-numeric-separator@^7.25.8":
+ version "7.25.8"
+ resolved "https://registry.yarnpkg.com/@babel/plugin-transform-numeric-separator/-/plugin-transform-numeric-separator-7.25.8.tgz#91e370486371637bd42161052f2602c701386891"
+ integrity sha512-rm9a5iEFPS4iMIy+/A/PiS0QN0UyjPIeVvbU5EMZFKJZHt8vQnasbpo3T3EFcxzCeYO0BHfc4RqooCZc51J86Q==
+ dependencies:
+ "@babel/helper-plugin-utils" "^7.25.7"
+
"@babel/plugin-transform-object-assign@^7.16.7":
version "7.18.6"
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-object-assign/-/plugin-transform-object-assign-7.18.6.tgz#7830b4b6f83e1374a5afb9f6111bcfaea872cdd2"
@@ -1479,6 +1525,15 @@
"@babel/helper-validator-identifier" "^7.22.20"
to-fast-properties "^2.0.0"
+"@babel/types@^7.25.7":
+ version "7.25.8"
+ resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.25.8.tgz#5cf6037258e8a9bcad533f4979025140cb9993e1"
+ integrity sha512-JWtuCu8VQsMladxVz/P4HzHUGCAwpuqacmowgXFs5XjxIgKuNjnLokQzuVjlTvIzODaDmpjT3oxcC48vyk9EWg==
+ dependencies:
+ "@babel/helper-string-parser" "^7.25.7"
+ "@babel/helper-validator-identifier" "^7.25.7"
+ to-fast-properties "^2.0.0"
+
"@bcoe/v8-coverage@^0.2.3":
version "0.2.3"
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
@@ -7056,6 +7111,13 @@
resolved "https://registry.yarnpkg.com/babel-plugin-syntax-trailing-function-commas/-/babel-plugin-syntax-trailing-function-commas-7.0.0-beta.0.tgz#aa213c1435e2bffeb6fca842287ef534ad05d5cf"
integrity sha512-Xj9XuRuz3nTSbaTXWv3itLOcxyF4oPD8douBBmj7U9BBC6nEBYfyOJYQMf/8PJAFotC62UY5dFfIGEPr7WswzQ==
+babel-plugin-transform-bigint@^1.0.34:
+ version "1.0.34"
+ resolved "https://registry.yarnpkg.com/babel-plugin-transform-bigint/-/babel-plugin-transform-bigint-1.0.34.tgz#0217c29d163138aea7f549703a8b0162c1b320e9"
+ integrity sha512-ZtKKbLosCmsdCGLdtDyf328PYOcM4hq9EW0jmUB0Y9MRTu+J2iO+uk3xt8x5TpYu8Wg8gD8yKnPL3b0lptq+Rw==
+ dependencies:
+ "@babel/plugin-syntax-bigint" "^7.8.3"
+
babel-plugin-transform-import-meta@2.2.1:
version "2.2.1"
resolved "https://registry.yarnpkg.com/babel-plugin-transform-import-meta/-/babel-plugin-transform-import-meta-2.2.1.tgz#eb5b79019ff0a9157b94d8280955121189a2964b"
@@ -15838,7 +15900,7 @@
resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-2.5.2.tgz#80564d2e483dacf6e8ef209650a67df3f0c283a4"
integrity sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA==
-jsesc@^3.0.2:
+jsesc@^3.0.2, jsesc@~3.0.2:
version "3.0.2"
resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-3.0.2.tgz#bb8b09a6597ba426425f2e4a07245c3d00b9343e"
integrity sha512-xKqzzWXDttJuOcawBt4KnKHHIf5oQ/Cxax+0PWFG+DFDgHNAdi+TXECADI+RYiFUMmx8792xsMbbgXj4CwnP4g==
@@ -20999,6 +21061,13 @@
dependencies:
regenerate "^1.4.2"
+regenerate-unicode-properties@^10.2.0:
+ version "10.2.0"
+ resolved "https://registry.yarnpkg.com/regenerate-unicode-properties/-/regenerate-unicode-properties-10.2.0.tgz#626e39df8c372338ea9b8028d1f99dc3fd9c3db0"
+ integrity sha512-DqHn3DwbmmPVzeKj9woBadqmXxLvQoQIwu7nopMc72ztvxVmVk2SBhSnx67zuye5TP+lJsb/TBQsjLKhnDf3MA==
+ dependencies:
+ regenerate "^1.4.2"
+
regenerate@^1.4.2:
version "1.4.2"
resolved "https://registry.yarnpkg.com/regenerate/-/regenerate-1.4.2.tgz#b9346d8827e8f5a32f7ba29637d398b69014848a"
@@ -21065,6 +21134,18 @@
unicode-match-property-ecmascript "^2.0.0"
unicode-match-property-value-ecmascript "^2.1.0"
+regexpu-core@^6.1.1:
+ version "6.1.1"
+ resolved "https://registry.yarnpkg.com/regexpu-core/-/regexpu-core-6.1.1.tgz#b469b245594cb2d088ceebc6369dceb8c00becac"
+ integrity sha512-k67Nb9jvwJcJmVpw0jPttR1/zVfnKf8Km0IPatrU/zJ5XeG3+Slx0xLXs9HByJSzXzrlz5EDvN6yLNMDc2qdnw==
+ dependencies:
+ regenerate "^1.4.2"
+ regenerate-unicode-properties "^10.2.0"
+ regjsgen "^0.8.0"
+ regjsparser "^0.11.0"
+ unicode-match-property-ecmascript "^2.0.0"
+ unicode-match-property-value-ecmascript "^2.1.0"
+
registry-auth-token@^3.0.1:
version "3.4.0"
resolved "https://registry.yarnpkg.com/registry-auth-token/-/registry-auth-token-3.4.0.tgz#d7446815433f5d5ed6431cd5dca21048f66b397e"
@@ -21094,6 +21175,11 @@
dependencies:
rc "^1.2.8"
+regjsgen@^0.8.0:
+ version "0.8.0"
+ resolved "https://registry.yarnpkg.com/regjsgen/-/regjsgen-0.8.0.tgz#df23ff26e0c5b300a6470cad160a9d090c3a37ab"
+ integrity sha512-RvwtGe3d7LvWiDQXeQw8p5asZUmfU1G/l6WbUXeHta7Y2PEIvBTwH6E2EfmYUK8pxcxEdEmaomqyp0vZZ7C+3Q==
+
regjsparser@^0.10.0:
version "0.10.0"
resolved "https://registry.yarnpkg.com/regjsparser/-/regjsparser-0.10.0.tgz#b1ed26051736b436f22fdec1c8f72635f9f44892"
@@ -21101,6 +21187,13 @@
dependencies:
jsesc "~0.5.0"
+regjsparser@^0.11.0:
+ version "0.11.1"
+ resolved "https://registry.yarnpkg.com/regjsparser/-/regjsparser-0.11.1.tgz#ae55c74f646db0c8fcb922d4da635e33da405149"
+ integrity sha512-1DHODs4B8p/mQHU9kr+jv8+wIC9mtG4eBHxWxIq5mhjE3D5oORhCc6deRKzTjs9DcfRFmj9BHSDguZklqCGFWQ==
+ dependencies:
+ jsesc "~3.0.2"
+
regjsparser@^0.9.1:
version "0.9.1"
resolved "https://registry.yarnpkg.com/regjsparser/-/regjsparser-0.9.1.tgz#272d05aa10c7c1f67095b1ff0addae8442fc5709"

File Metadata

Mime Type
text/plain
Expires
Thu, Oct 17, 10:30 PM (21 h, 59 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2313531
Default Alt Text
D13702.diff (44 KB)

Event Timeline