@mongosh/async-rewriter2
Advanced tools
Comparing version 1.1.9 to 1.2.1
import * as babel from '@babel/core'; | ||
export default class AsyncWriter { | ||
step(code: string, plugins: babel.PluginItem[]): string; | ||
step(ast: babel.types.Node | null | undefined, originalSource: string, plugins?: babel.PluginItem[], opts?: babel.TransformOptions): babel.BabelFileResult | null; | ||
process(code: string): string; | ||
runtimeSupportCode(): string; | ||
} |
@@ -32,24 +32,30 @@ "use strict"; | ||
class AsyncWriter { | ||
step(code, plugins) { | ||
var _a; | ||
return (_a = babel.transformSync(code, { | ||
step(ast, originalSource, plugins = [], opts = {}) { | ||
const transform = (opts) => ast ? | ||
babel.transformFromAstSync(ast, originalSource, opts) : | ||
babel.transformSync(originalSource, opts); | ||
return transform({ | ||
plugins, | ||
code: true, | ||
code: false, | ||
ast: true, | ||
cloneInputAst: false, | ||
configFile: false, | ||
babelrc: false, | ||
browserslistConfigFile: false, | ||
compact: code.length > 10000, | ||
sourceType: 'script' | ||
})) === null || _a === void 0 ? void 0 : _a.code; | ||
compact: originalSource.length > 10000, | ||
sourceType: 'script', | ||
...opts | ||
}); | ||
} | ||
process(code) { | ||
var _a, _b, _c, _d; | ||
try { | ||
code = this.step(code, [ | ||
let ast = (_a = this.step(undefined, code, [ | ||
require('@babel/plugin-transform-shorthand-properties').default, | ||
require('@babel/plugin-transform-parameters').default, | ||
require('@babel/plugin-transform-destructuring').default | ||
]); | ||
code = this.step(code, [wrap_as_iife_1.default]); | ||
code = this.step(code, [uncatchable_exceptions_1.default]); | ||
code = this.step(code, [ | ||
])) === null || _a === void 0 ? void 0 : _a.ast; | ||
ast = (_b = this.step(ast, code, [wrap_as_iife_1.default])) === null || _b === void 0 ? void 0 : _b.ast; | ||
ast = (_c = this.step(ast, code, [uncatchable_exceptions_1.default])) === null || _c === void 0 ? void 0 : _c.ast; | ||
return (_d = this.step(ast, code, [ | ||
[ | ||
@@ -59,4 +65,3 @@ transform_maybe_await_1.default, | ||
] | ||
]); | ||
return code; | ||
], { code: true, ast: false })) === null || _d === void 0 ? void 0 : _d.code; | ||
} | ||
@@ -63,0 +68,0 @@ catch (e) { |
@@ -293,5 +293,5 @@ 'use strict'; | ||
const source = origFptS.call(this, arguments); | ||
const match = source.match(/^[^"]*"<async_rewriter>(?<encoded>[a-z0-9]+)<\/>";/); | ||
const match = source.match(/^[^"]*"<async_rewriter>(?<encoded>[^<]*)<\/>";/); | ||
if (match) { | ||
return String.fromCharCode(...match.groups.encoded.match(/.{4}/g).map(hex => parseInt(hex, 16))); | ||
return decodeURIComponent(match.groups.encoded); | ||
} | ||
@@ -298,0 +298,0 @@ return source; |
@@ -133,3 +133,3 @@ "use strict"; | ||
'function () { [unknown code] }'; | ||
const encodedOriginalSource = [...originalSource].map(char => char.charCodeAt(0).toString(16).padStart(4, '0')).join(''); | ||
const encodedOriginalSource = encodeURIComponent(originalSource); | ||
const originalSourceNode = t.expressionStatement(t.stringLiteral(`<async_rewriter>${encodedOriginalSource}</>`)); | ||
@@ -136,0 +136,0 @@ const existingIdentifiers = (_c = path.findParent(path => !!path.getData(identifierGroupKey))) === null || _c === void 0 ? void 0 : _c.getData(identifierGroupKey); |
{ | ||
"name": "@mongosh/async-rewriter2", | ||
"version": "1.1.9", | ||
"version": "1.2.1", | ||
"description": "MongoDB Shell Async Rewriter Package", | ||
@@ -8,2 +8,3 @@ "main": "./lib/index.js", | ||
"pretest": "npm run compile-ts", | ||
"benchmark": "node -r ts-node/register benchmark/index.ts", | ||
"test": "mocha --experimental-vm-modules -r \"../../scripts/import-expansions.js\" --timeout 60000 -r ts-node/register \"./{src,lib}/**/*.spec.ts\"", | ||
@@ -34,10 +35,10 @@ "test-ci": "node ../../scripts/run-if-package-requested.js npm test", | ||
"dependencies": { | ||
"@babel/core": "^7.14.8", | ||
"@babel/plugin-transform-destructuring": "^7.14.7", | ||
"@babel/plugin-transform-parameters": "^7.14.5", | ||
"@babel/plugin-transform-shorthand-properties": "^7.14.5", | ||
"@babel/types": "^7.14.9", | ||
"@types/babel__core": "^7.1.15" | ||
"@babel/core": "^7.16.12", | ||
"@babel/plugin-transform-destructuring": "^7.16.7", | ||
"@babel/plugin-transform-parameters": "^7.16.7", | ||
"@babel/plugin-transform-shorthand-properties": "^7.16.7", | ||
"@babel/types": "^7.16.8", | ||
"@types/babel__core": "^7.1.18" | ||
}, | ||
"gitHead": "1a200600554f6aa59ec10aaedb915f67771eb7fd" | ||
"gitHead": "62b1dff4ce48f4dd3706d4fd9ccd4582df403ee3" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
96563
30
1013