hackmud-script-manager 0.19.0 → 0.19.1-07fc9cb

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. package/README.md +0 -2
  2. package/bin/hsm.js +435 -1
  3. package/constants.js +3 -1
  4. package/generateTypeDeclaration.js +68 -1
  5. package/index.js +51 -1
  6. package/package.json +38 -39
  7. package/processScript/index.js +333 -1
  8. package/processScript/minify.js +444 -1
  9. package/processScript/postprocess.js +20 -1
  10. package/processScript/preprocess.js +105 -1
  11. package/processScript/shared.js +32 -1
  12. package/processScript/transform.js +668 -1
  13. package/pull.js +11 -1
  14. package/push.js +269 -1
  15. package/{bin → src/bin}/hsm.d.ts +0 -0
  16. package/src/generateTypeDeclaration.d.ts +2 -0
  17. package/src/processScript/index.d.ts +31 -0
  18. package/src/processScript/minify.d.ts +18 -0
  19. package/src/processScript/preprocess.d.ts +9 -0
  20. package/{processScript → src/processScript}/shared.d.ts +1 -1
  21. package/src/processScript/transform.d.ts +18 -0
  22. package/src/pull.d.ts +6 -0
  23. package/src/push.d.ts +29 -0
  24. package/{syncMacros.d.ts → src/syncMacros.d.ts} +1 -1
  25. package/src/watch.d.ts +15 -0
  26. package/syncMacros.js +43 -1
  27. package/watch.js +208 -1
  28. package/generateTypeDeclaration.d.ts +0 -2
  29. package/processScript/index.d.ts +0 -40
  30. package/processScript/minify.d.ts +0 -24
  31. package/processScript/preprocess.d.ts +0 -12
  32. package/processScript/transform.d.ts +0 -24
  33. package/pull.d.ts +0 -9
  34. package/push.d.ts +0 -37
  35. package/tsconfig.tsbuildinfo +0 -1
  36. package/watch.d.ts +0 -20
  37. /package/{constants.d.ts → src/constants.d.ts} +0 -0
  38. /package/{index.d.ts → src/index.d.ts} +0 -0
  39. /package/{processScript → src/processScript}/postprocess.d.ts +0 -0
@@ -1 +1,668 @@
1
- import e from"@babel/traverse";import i from"@babel/types";import{assert as t}from"@samual/lib/assert";import{clearObject as r}from"@samual/lib/clearObject";import{validDBMethods as n}from"../constants.js";import{getReferencePathsToGlobal as o}from"./shared.js";const{default:a}=e,s=["Map","Set","Date","JSON","Math","Array","Error","isNaN","Number","Object","RegExp","String","Symbol","BigInt"],transform=(e,p,{uniqueID:l="00000000000",scriptUser:c="UNKNOWN",scriptName:d="UNKNOWN",seclevel:f=4}={})=>{const b=`_${l}_SCRIPT_`,y=new Map,m=new Map;let $;if(a(e,{Program(e){$=e,e.skip()}}),$.scope.hasGlobal("_SOURCE"))for(const e of o("_SOURCE",$))e.replaceWith(i.stringLiteral(p));if($.scope.hasGlobal("_BUILD_DATE"))for(const e of o("_BUILD_DATE",$))e.replaceWith(i.numericLiteral(Date.now()));if($.scope.hasGlobal("_SCRIPT_USER"))for(const e of o("_SCRIPT_USER",$))1==c?e.replaceWith(i.stringLiteral(`$${l}$SCRIPT_USER$`)):e.replaceWith(i.stringLiteral(c));if($.scope.hasGlobal("_SCRIPT_NAME"))for(const e of o("_SCRIPT_NAME",$))1==d?e.replaceWith(i.stringLiteral(`$${l}$SCRIPT_NAME$`)):e.replaceWith(i.stringLiteral(d));if($.scope.hasGlobal("_FULL_SCRIPT_NAME"))for(const e of o("_FULL_SCRIPT_NAME",$))1==c||1==d?e.replaceWith(i.stringLiteral(`$${l}$FULL_SCRIPT_NAME$`)):e.replaceWith(i.stringLiteral(`${c}.${d}`));let h=!1;const createGetFunctionPrototypeNode=()=>{for(const e of s)if(!$.scope.hasOwnBinding(e))return i.memberExpression(i.memberExpression(i.identifier(e),i.identifier("constructor")),i.identifier("prototype"));return i.memberExpression(i.memberExpression(i.arrowFunctionExpression([i.identifier("_")],i.identifier("_")),i.identifier("constructor")),i.identifier("prototype"))};if($.scope.hasGlobal("Function")){const e=o("Function",$);if(1==e.length){const i=e[0];t("MemberExpression"==i.parent.type,"`Function` isn't available in hackmud, only `Function.prototype` is accessible"),t("Identifier"==i.parent.property.type,"`Function` isn't available in hackmud, only `Function.prototype` is accessible"),t("prototype"==i.parent.property.name,"`Function` isn't available in hackmud, only `Function.prototype` is accessible"),i.parentPath.replaceWith(createGetFunctionPrototypeNode())}else{for(const r of e)t("MemberExpression"==r.parent.type,"`Function` isn't available in hackmud, only `Function.prototype` is accessible"),t("Identifier"==r.parent.property.type,"`Function` isn't available in hackmud, only `Function.prototype` is accessible"),t("prototype"==r.parent.property.name,"`Function` isn't available in hackmud, only `Function.prototype` is accessible"),h=!0,r.parentPath.replaceWith(i.identifier(`_${l}_FUNCTION_DOT_PROTOTYPE_`));h=!0}}let E=4;const processFakeSubscriptObject=e=>{for(const r of o(e,$))t("MemberExpression"==r.parent.type),t("Identifier"==r.parent.property.type),t("MemberExpression"==r.parentPath.parentPath?.node.type),t("Identifier"==r.parentPath.parentPath.node.property.type),t(/^[_a-z][\d_a-z]{0,24}$/.test(r.parent.property.name),`invalid user "${r.parent.property.name}" in subscript`),t(/^[_a-z][\d_a-z]{0,24}$/.test(r.parentPath.parentPath.node.property.name),`invalid script name "${r.parentPath.parentPath.node.property.name}" in subscript`),"CallExpression"==r.parentPath.parentPath.parentPath?.type?r.parentPath.parentPath.replaceWith(i.identifier(`$${l}$SUBSCRIPT$${r.parent.property.name}$${r.parentPath.parentPath.node.property.name}$`)):r.parentPath.parentPath.replaceWith(i.arrowFunctionExpression([i.restElement(i.identifier("args"))],i.callExpression(i.identifier(`$${l}$SUBSCRIPT$${r.parent.property.name}$${r.parentPath.parentPath.node.property.name}$`),[i.spreadElement(i.identifier("args"))])))};for(const e of["$fs","$4s","$s"])$.scope.hasGlobal(e)&&processFakeSubscriptObject(e);for(const e of["$hs","$3s"])$.scope.hasGlobal(e)&&(E=3,processFakeSubscriptObject(e));for(const e of["$ms","$2s"])$.scope.hasGlobal(e)&&(E=2,processFakeSubscriptObject(e));for(const e of["$ls","$1s"])$.scope.hasGlobal(e)&&(E=1,processFakeSubscriptObject(e));for(const e of["$ns","$0s"])$.scope.hasGlobal(e)&&(E=0,processFakeSubscriptObject(e));if(f=Math.min(f,E),$.scope.hasGlobal("$db"))for(const e of o("$db",$)){t("MemberExpression"==e.parentPath.node.type),t("Identifier"==e.parentPath.node.property.type);const r=e.parentPath.node.property.name;t(n.includes(r),`invalid db method "${r}", valid db methods are "${n.join('", "')}"`),"CallExpression"==e.parentPath.parentPath?.type?e.parentPath.replaceWith(i.identifier(`$${l}$DB$${r}$`)):"ObjectId"==r?e.parentPath.replaceWith(i.arrowFunctionExpression([],i.callExpression(i.identifier(`$${l}$DB$${r}$`),[]))):"i"==r||"r"==r?e.parentPath.replaceWith(i.arrowFunctionExpression([i.identifier("a")],i.callExpression(i.identifier(`$${l}$DB$${r}$`),[i.identifier("a")]))):e.parentPath.replaceWith(i.arrowFunctionExpression([i.identifier("a"),i.identifier("b")],i.callExpression(i.identifier(`$${l}$DB$${r}$`),[i.identifier("a"),i.identifier("b")])))}if($.scope.hasGlobal("$D"))for(const e of o("$D",$))"CallExpression"==e.parentPath.type?e.replaceWith(i.identifier(`$${l}$DEBUG$`)):e.replaceWith(i.arrowFunctionExpression([i.identifier("a")],i.callExpression(i.identifier(`$${l}$DEBUG$`),[i.identifier("a")])));if($.scope.hasGlobal("$FMCL"))for(const e of o("$FMCL",$))e.replaceWith(i.identifier(`$${l}$FMCL$`));if($.scope.hasGlobal("$G"))for(const e of o("$G",$))e.replaceWith(i.identifier(`$${l}$GLOBAL$`));if($.scope.hasGlobal("_SECLEVEL"))for(const e of o("_SECLEVEL",$))e.replaceWith(i.numericLiteral(f));let _=!1,u=!1;if($.scope.hasGlobal("Object"))for(const e of o("Object",$))"MemberExpression"!=e.parent.type||e.parent.computed||(t("Identifier"==e.parent.property.type),"getPrototypeOf"==e.parent.property.name?(e.parentPath.replaceWith(i.identifier(`_${l}_GET_PROTOTYPE_OF_`)),_=!0):"setPrototypeOf"==e.parent.property.name&&(e.parentPath.replaceWith(i.identifier(`_${l}_SET_PROTOTYPE_OF_`)),u=!0));const P=$.node.body.at(-1);let x;if(t(P,"program is empty"),"ExportNamedDeclaration"==P.type){$.node.body.pop();for(const e of P.specifiers){t("ExportSpecifier"==e.type,`${e.type} is currently unsupported`);const i="Identifier"==e.exported.type?e.exported.name:e.exported.value;"default"==i?x=e.local.name:y.set(e.local.name,i)}}const O=i.blockStatement([]);let D;for(const e of $.node.body)if("VariableDeclaration"==e.type)for(const t of e.declarations)if("Identifier"!=t.id.type||t.id.name!=x||!t.init||"FunctionExpression"!=t.init.type&&"ArrowFunctionExpression"!=t.init.type||t.init.async||t.init.generator){for(const r in i.getBindingIdentifiers(t.id))r==x&&(D=i.functionDeclaration(i.identifier(b),[i.identifier("context"),i.identifier("args")],i.blockStatement([i.returnStatement(i.callExpression(i.identifier(x),[]))]))),"const"!=e.kind&&y.has(r)&&(m.set(r,y.get(r)),y.delete(r)),O.body.push(i.variableDeclaration("let",[i.variableDeclarator(i.identifier(r))]));t.init&&O.body.push(i.expressionStatement(i.assignmentExpression("=",t.id,t.init)))}else D=i.functionDeclaration(i.identifier(b),t.init.params,"BlockStatement"==t.init.body.type?t.init.body:i.blockStatement([i.returnStatement(t.init.body)]));else"FunctionDeclaration"==e.type?e.id.name==x?D=e:O.body.push(i.variableDeclaration("let",[i.variableDeclarator(e.id,i.functionExpression(void 0,e.params,e.body,e.generator,e.async))])):O.body.push(e);if(D||=i.functionDeclaration(i.identifier(b),[i.identifier("context"),i.identifier("args")],i.blockStatement([])),$.node.body=[D],O.body.length){(y.size||m.size)&&D.body.body.push(i.returnStatement(i.objectExpression([...[...y].map((([e,t])=>i.objectProperty(i.identifier(t),i.identifier(e)))),...[...m].map((([e,t])=>i.objectMethod("get",i.identifier(t),[],i.blockStatement([i.returnStatement(i.identifier(e))]))))]))),$.scope.crawl();const e=new Set;let n=0;for(const[o,a]of[...O.body.entries()].reverse())if("VariableDeclaration"==a.type){t(1==a.declarations.length);const s=a.declarations[0];if(t("Identifier"==s.id.type,`declarator.id.type was "${s.id.type}"`),$.scope.crawl(),$.scope.hasGlobal(s.id.name)){O.body.splice(o,1);const[p]=$.unshiftContainer("body",O),[c]=$.unshiftContainer("body",a);if($.scope.crawl(),!s.init||"FunctionExpression"!=s.init.type&&"ArrowFunctionExpression"!=s.init.type||Object.keys($.scope.globals).some((i=>e.has(i)))){const e=$.scope.getBinding(s.id.name);t(e);for(const r of e.referencePaths)t("Identifier"==r.node.type),r.replaceWith(i.memberExpression(i.identifier(`$${l}$GLOBAL$`),i.identifier(r.node.name)));for(const t of e.constantViolations)if("AssignmentExpression"==t.node.type)for(const[e,n]of Object.entries(i.getBindingIdentifiers(t.node)))e==s.id.name&&(r(n),Object.assign(n,i.memberExpression(i.identifier(`$${l}$GLOBAL$`),i.identifier(e))));p.remove(),c.remove(),s.init&&O.body.splice(o,0,i.expressionStatement(i.assignmentExpression("=",i.memberExpression(i.identifier(`$${l}$GLOBAL$`),i.identifier(s.id.name)),s.init)))}else p.remove(),c.remove(),D.body.body.unshift(a),n++}else e.add(s.id.name)}else if("ClassDeclaration"==a.type&&($.scope.crawl(),t(a.id,"src/processScript/transform.ts:564:37"),$.scope.hasGlobal(a.id.name))){O.body.splice(o,1);const[e]=$.unshiftContainer("body",O),[r]=$.unshiftContainer("body",a);$.scope.crawl();const n=$.scope.getBinding(a.id.name);t(n);for(const e of n.referencePaths)t("Identifier"==e.node.type),e.replaceWith(i.memberExpression(i.identifier(`$${l}$GLOBAL$`),i.identifier(e.node.name)));e.remove(),r.remove(),O.body.splice(o,0,i.expressionStatement(i.assignmentExpression("=",i.memberExpression(i.identifier(`$${l}$GLOBAL$`),i.identifier(a.id.name)),i.classExpression(void 0,a.superClass,a.body,a.decorators))))}if($.scope.hasGlobal("_EXPORTS"))for(const e of o("_EXPORTS",$))e.replaceWith(i.arrayExpression([...y.keys(),...m.keys()].map((e=>i.stringLiteral(e)))));O.body.length&&D.body.body.splice(n,0,i.ifStatement(i.unaryExpression("!",i.identifier(`$${l}$FMCL$`)),O))}return h&&D.body.body.unshift(i.variableDeclaration("let",[i.variableDeclarator(i.identifier(`_${l}_FUNCTION_DOT_PROTOTYPE_`),createGetFunctionPrototypeNode())])),u&&D.body.body.unshift(i.variableDeclaration("let",[i.variableDeclarator(i.identifier(`_${l}_SET_PROTOTYPE_OF_`),i.callExpression(i.memberExpression(i.memberExpression(i.identifier("Object"),i.identifier("call")),i.identifier("bind")),[i.identifier(`_${l}_DUNDER_PROTO_SETTER_`)]))])),_&&D.body.body.unshift(i.variableDeclaration("let",[i.variableDeclarator(i.identifier(`_${l}_GET_PROTOTYPE_OF_`),i.callExpression(i.memberExpression(i.memberExpression(i.identifier("Object"),i.identifier("call")),i.identifier("bind")),[i.identifier(`_${l}_DUNDER_PROTO_GETTER_`)]))])),(_||u)&&D.body.body.unshift(i.variableDeclaration("let",[i.variableDeclarator(i.objectPattern(_?u?[i.objectProperty(i.identifier("get"),i.identifier(`_${l}_DUNDER_PROTO_GETTER_`)),i.objectProperty(i.identifier("set"),i.identifier(`_${l}_DUNDER_PROTO_SETTER_`))]:[i.objectProperty(i.identifier("get"),i.identifier(`_${l}_DUNDER_PROTO_GETTER_`))]:[i.objectProperty(i.identifier("set"),i.identifier(`_${l}_DUNDER_PROTO_SETTER_`))]),i.callExpression(i.memberExpression(i.identifier("Object"),i.identifier("getOwnPropertyDescriptor")),[i.memberExpression(i.identifier("Object"),i.identifier("prototype")),i.stringLiteral("__proto__")]))])),a(e,{BlockStatement({node:e}){for(const[t,r]of e.body.entries())"FunctionDeclaration"!=r.type||r.generator||(e.body.splice(t,1),e.body.unshift(i.variableDeclaration("let",[i.variableDeclarator(r.id,i.arrowFunctionExpression(r.params,r.body,r.async))])))},ClassBody({node:e,scope:r,parent:n}){t(i.isClass(n));let o=!1;for(const t of e.body){if("ClassMethod"!=t.type)continue;let e=!1;if(a(t.body,{ThisExpression(t){e=!0,o=!0,t.replaceWith(i.identifier(`_${l}_THIS_`))},Function(e){e.skip()}},r),e)if("constructor"!=t.kind)t.body.body.unshift(i.variableDeclaration("let",[i.variableDeclarator(i.identifier(`_${l}_THIS_`),i.callExpression(i.memberExpression(i.super(),i.identifier("valueOf")),[]))]));else{const e=[];if(a(t.body,{CallExpression(i){"Super"==i.node.callee.type&&e.push(i)}},r),e.length)if(1==e.length&&"ExpressionStatement"==e[0].parent.type&&e[0].parentPath.parentPath.parent==t)e[0].parentPath.replaceWith(i.variableDeclaration("let",[i.variableDeclarator(i.identifier(`_${l}_THIS_`),e[0].node)]));else{for(const t of e)t.replaceWith(i.assignmentExpression("=",i.identifier(`_${l}_THIS_`),t.node));t.body.body.unshift(i.variableDeclaration("let",[i.variableDeclarator(i.identifier(`_${l}_THIS_`))]))}else t.body.body.unshift(i.variableDeclaration("let",[i.variableDeclarator(i.identifier(`_${l}_THIS_`),i.callExpression(i.super(),[]))]))}}!n.superClass&&o&&(n.superClass=i.identifier("Object"))},VariableDeclaration({node:e}){"const"==e.kind&&(e.kind="let")},ThisExpression(e){e.replaceWith(i.identifier("undefined"))},BigIntLiteral(e){const t=Number(e.node.value);BigInt(t)==BigInt(e.node.value)?e.replaceWith(i.callExpression(i.identifier("BigInt"),[i.numericLiteral(t)])):e.replaceWith(i.callExpression(i.identifier("BigInt"),[i.stringLiteral(e.node.value)]))}}),{file:e,seclevel:f}};export{transform as default,transform};
1
+ import babelTraverse from "@babel/traverse"
2
+ import t from "@babel/types"
3
+ import { assert } from "@samual/lib/assert"
4
+ import { clearObject } from "@samual/lib/clearObject"
5
+ import { validDBMethods } from "../constants.js"
6
+ import { getReferencePathsToGlobal } from "./shared.js"
7
+ const { default: traverse } = babelTraverse,
8
+ globalFunctionsUnder7Characters = [
9
+ "Map",
10
+ "Set",
11
+ "Date",
12
+ "JSON",
13
+ "Math",
14
+ "Array",
15
+ "Error",
16
+ "isNaN",
17
+ "Number",
18
+ "Object",
19
+ "RegExp",
20
+ "String",
21
+ "Symbol",
22
+ "BigInt"
23
+ ]
24
+ function transform(
25
+ file,
26
+ sourceCode,
27
+ { uniqueID = "00000000000", scriptUser = "UNKNOWN", scriptName = "UNKNOWN", seclevel = 4 } = {}
28
+ ) {
29
+ const topFunctionName = `_${uniqueID}_SCRIPT_`,
30
+ exports = new Map(),
31
+ liveExports = new Map()
32
+ let program
33
+ traverse(file, {
34
+ Program(path) {
35
+ program = path
36
+ path.skip()
37
+ }
38
+ })
39
+ if (program.scope.hasGlobal("_SOURCE"))
40
+ for (const referencePath of getReferencePathsToGlobal("_SOURCE", program))
41
+ referencePath.replaceWith(t.stringLiteral(sourceCode))
42
+ if (program.scope.hasGlobal("_BUILD_DATE"))
43
+ for (const referencePath of getReferencePathsToGlobal("_BUILD_DATE", program))
44
+ referencePath.replaceWith(t.numericLiteral(Date.now()))
45
+ if (program.scope.hasGlobal("_SCRIPT_USER"))
46
+ for (const referencePath of getReferencePathsToGlobal("_SCRIPT_USER", program))
47
+ referencePath.replaceWith(t.stringLiteral(1 == scriptUser ? `$${uniqueID}$SCRIPT_USER$` : scriptUser))
48
+ if (program.scope.hasGlobal("_SCRIPT_NAME"))
49
+ for (const referencePath of getReferencePathsToGlobal("_SCRIPT_NAME", program))
50
+ referencePath.replaceWith(t.stringLiteral(1 == scriptName ? `$${uniqueID}$SCRIPT_NAME$` : scriptName))
51
+ if (program.scope.hasGlobal("_FULL_SCRIPT_NAME"))
52
+ for (const referencePath of getReferencePathsToGlobal("_FULL_SCRIPT_NAME", program))
53
+ referencePath.replaceWith(
54
+ t.stringLiteral(
55
+ 1 == scriptUser || 1 == scriptName ?
56
+ `$${uniqueID}$FULL_SCRIPT_NAME$`
57
+ : `${scriptUser}.${scriptName}`
58
+ )
59
+ )
60
+ let functionDotPrototypeIsReferencedMultipleTimes = !1
61
+ if (program.scope.hasGlobal("Function")) {
62
+ const FunctionReferencePaths = getReferencePathsToGlobal("Function", program)
63
+ if (1 == FunctionReferencePaths.length) {
64
+ const referencePath = FunctionReferencePaths[0]
65
+ assert(
66
+ "MemberExpression" == referencePath.parent.type,
67
+ "src/processScript/transform.ts:89:8 `Function` isn't available in hackmud, only `Function.prototype` is accessible"
68
+ )
69
+ assert(
70
+ "Identifier" == referencePath.parent.property.type,
71
+ "src/processScript/transform.ts:94:8 `Function` isn't available in hackmud, only `Function.prototype` is accessible"
72
+ )
73
+ assert(
74
+ "prototype" == referencePath.parent.property.name,
75
+ "src/processScript/transform.ts:99:8 `Function` isn't available in hackmud, only `Function.prototype` is accessible"
76
+ )
77
+ referencePath.parentPath.replaceWith(createGetFunctionPrototypeNode())
78
+ } else {
79
+ for (const referencePath of FunctionReferencePaths) {
80
+ assert(
81
+ "MemberExpression" == referencePath.parent.type,
82
+ "src/processScript/transform.ts:107:9 `Function` isn't available in hackmud, only `Function.prototype` is accessible"
83
+ )
84
+ assert(
85
+ "Identifier" == referencePath.parent.property.type,
86
+ "src/processScript/transform.ts:112:9 `Function` isn't available in hackmud, only `Function.prototype` is accessible"
87
+ )
88
+ assert(
89
+ "prototype" == referencePath.parent.property.name,
90
+ "src/processScript/transform.ts:117:9 `Function` isn't available in hackmud, only `Function.prototype` is accessible"
91
+ )
92
+ functionDotPrototypeIsReferencedMultipleTimes = !0
93
+ referencePath.parentPath.replaceWith(t.identifier(`_${uniqueID}_FUNCTION_DOT_PROTOTYPE_`))
94
+ }
95
+ functionDotPrototypeIsReferencedMultipleTimes = !0
96
+ }
97
+ }
98
+ const neededSubscriptLets = new Set()
99
+ let detectedSeclevel = 4
100
+ for (const fakeSubscriptObjectName of ["$fs", "$4s", "$s"])
101
+ program.scope.hasGlobal(fakeSubscriptObjectName) && processFakeSubscriptObject(fakeSubscriptObjectName)
102
+ for (const fakeSubscriptObjectName of ["$hs", "$3s"])
103
+ if (program.scope.hasGlobal(fakeSubscriptObjectName)) {
104
+ detectedSeclevel = 3
105
+ processFakeSubscriptObject(fakeSubscriptObjectName)
106
+ }
107
+ for (const fakeSubscriptObjectName of ["$ms", "$2s"])
108
+ if (program.scope.hasGlobal(fakeSubscriptObjectName)) {
109
+ detectedSeclevel = 2
110
+ processFakeSubscriptObject(fakeSubscriptObjectName)
111
+ }
112
+ for (const fakeSubscriptObjectName of ["$ls", "$1s"])
113
+ if (program.scope.hasGlobal(fakeSubscriptObjectName)) {
114
+ detectedSeclevel = 1
115
+ processFakeSubscriptObject(fakeSubscriptObjectName)
116
+ }
117
+ for (const fakeSubscriptObjectName of ["$ns", "$0s"])
118
+ if (program.scope.hasGlobal(fakeSubscriptObjectName)) {
119
+ detectedSeclevel = 0
120
+ processFakeSubscriptObject(fakeSubscriptObjectName)
121
+ }
122
+ seclevel = Math.min(seclevel, detectedSeclevel)
123
+ const neededDbMethodLets = new Set()
124
+ if (program.scope.hasGlobal("$db"))
125
+ for (const referencePath of getReferencePathsToGlobal("$db", program)) {
126
+ assert("MemberExpression" == referencePath.parentPath.node.type, "src/processScript/transform.ts:171:69")
127
+ assert("Identifier" == referencePath.parentPath.node.property.type, "src/processScript/transform.ts:172:72")
128
+ const databaseOpMethodName = referencePath.parentPath.node.property.name
129
+ assert(
130
+ validDBMethods.includes(databaseOpMethodName),
131
+ `src/processScript/transform.ts:178:8 invalid db method "${databaseOpMethodName}", valid db methods are "${validDBMethods.join('", "')}"`
132
+ )
133
+ if ("CallExpression" == referencePath.parentPath.parentPath?.type)
134
+ referencePath.parentPath.replaceWith(t.identifier(`$${uniqueID}$DB$${databaseOpMethodName}$`))
135
+ else {
136
+ referencePath.parentPath.replaceWith(
137
+ t.identifier(`_${uniqueID}_CONSOLE_METHOD_${databaseOpMethodName}_`)
138
+ )
139
+ neededDbMethodLets.add(databaseOpMethodName)
140
+ }
141
+ }
142
+ let needDebugLet = !1
143
+ if (program.scope.hasGlobal("$D"))
144
+ for (const referencePath of getReferencePathsToGlobal("$D", program))
145
+ if ("CallExpression" == referencePath.parentPath.type)
146
+ referencePath.replaceWith(t.identifier(`$${uniqueID}$DEBUG$`))
147
+ else {
148
+ referencePath.replaceWith(t.identifier(`_${uniqueID}_DEBUG_`))
149
+ needDebugLet = !0
150
+ }
151
+ if (program.scope.hasGlobal("$FMCL"))
152
+ for (const referencePath of getReferencePathsToGlobal("$FMCL", program))
153
+ referencePath.replaceWith(t.identifier(`$${uniqueID}$FMCL$`))
154
+ if (program.scope.hasGlobal("$G"))
155
+ for (const referencePath of getReferencePathsToGlobal("$G", program))
156
+ referencePath.replaceWith(t.identifier(`$${uniqueID}$GLOBAL$`))
157
+ if (program.scope.hasGlobal("_SECLEVEL"))
158
+ for (const referencePath of getReferencePathsToGlobal("_SECLEVEL", program))
159
+ referencePath.replaceWith(t.numericLiteral(seclevel))
160
+ let needGetPrototypeOf = !1
161
+ if (program.scope.hasGlobal("Object"))
162
+ for (const referencePath of getReferencePathsToGlobal("Object", program))
163
+ if ("MemberExpression" == referencePath.parent.type && !referencePath.parent.computed) {
164
+ assert("Identifier" == referencePath.parent.property.type, "src/processScript/transform.ts:225:64")
165
+ if ("getPrototypeOf" == referencePath.parent.property.name) {
166
+ referencePath.parentPath.replaceWith(t.identifier(`_${uniqueID}_GET_PROTOTYPE_OF_`))
167
+ needGetPrototypeOf = !0
168
+ }
169
+ }
170
+ const consoleMethodsReferenced = new Set()
171
+ if (program.scope.hasGlobal("console"))
172
+ for (const referencePath of getReferencePathsToGlobal("console", program))
173
+ if ("MemberExpression" == referencePath.parent.type && !referencePath.parent.computed) {
174
+ assert("Identifier" == referencePath.parent.property.type, "src/processScript/transform.ts:240:64")
175
+ referencePath.parentPath.replaceWith(
176
+ t.identifier(`_${uniqueID}_CONSOLE_METHOD_${referencePath.parent.property.name}_`)
177
+ )
178
+ consoleMethodsReferenced.add(referencePath.parent.property.name)
179
+ }
180
+ const lastStatement = program.node.body.at(-1)
181
+ let exportDefaultName
182
+ assert(lastStatement, "src/processScript/transform.ts:254:27 program is empty")
183
+ if ("ExportNamedDeclaration" == lastStatement.type) {
184
+ program.node.body.pop()
185
+ for (const specifier of lastStatement.specifiers) {
186
+ assert(
187
+ "ExportSpecifier" == specifier.type,
188
+ `src/processScript/transform.ts:260:51 ${specifier.type} is currently unsupported`
189
+ )
190
+ const exportedName =
191
+ "Identifier" == specifier.exported.type ? specifier.exported.name : specifier.exported.value
192
+ "default" == exportedName ?
193
+ (exportDefaultName = specifier.local.name)
194
+ : exports.set(specifier.local.name, exportedName)
195
+ }
196
+ }
197
+ const globalBlock = t.blockStatement([])
198
+ let mainFunction
199
+ for (const statement of program.node.body)
200
+ if ("VariableDeclaration" == statement.type)
201
+ for (const declarator of statement.declarations)
202
+ if (
203
+ "Identifier" != declarator.id.type ||
204
+ declarator.id.name != exportDefaultName ||
205
+ !declarator.init ||
206
+ ("FunctionExpression" != declarator.init.type &&
207
+ "ArrowFunctionExpression" != declarator.init.type) ||
208
+ declarator.init.async ||
209
+ declarator.init.generator
210
+ ) {
211
+ for (const identifierName in t.getBindingIdentifiers(declarator.id)) {
212
+ identifierName == exportDefaultName &&
213
+ (mainFunction = t.functionDeclaration(
214
+ t.identifier(topFunctionName),
215
+ [t.identifier("context"), t.identifier("args")],
216
+ t.blockStatement([
217
+ t.returnStatement(t.callExpression(t.identifier(exportDefaultName), []))
218
+ ])
219
+ ))
220
+ if ("const" != statement.kind && exports.has(identifierName)) {
221
+ liveExports.set(identifierName, exports.get(identifierName))
222
+ exports.delete(identifierName)
223
+ }
224
+ globalBlock.body.push(
225
+ t.variableDeclaration("let", [t.variableDeclarator(t.identifier(identifierName))])
226
+ )
227
+ }
228
+ declarator.init &&
229
+ globalBlock.body.push(
230
+ t.expressionStatement(t.assignmentExpression("=", declarator.id, declarator.init))
231
+ )
232
+ } else
233
+ mainFunction = t.functionDeclaration(
234
+ t.identifier(topFunctionName),
235
+ declarator.init.params,
236
+ "BlockStatement" == declarator.init.body.type ?
237
+ declarator.init.body
238
+ : t.blockStatement([t.returnStatement(declarator.init.body)])
239
+ )
240
+ else
241
+ "FunctionDeclaration" == statement.type ?
242
+ statement.id.name == exportDefaultName ?
243
+ (mainFunction = statement)
244
+ : globalBlock.body.push(
245
+ t.variableDeclaration("let", [
246
+ t.variableDeclarator(
247
+ statement.id,
248
+ t.functionExpression(
249
+ void 0,
250
+ statement.params,
251
+ statement.body,
252
+ statement.generator,
253
+ statement.async
254
+ )
255
+ )
256
+ ])
257
+ )
258
+ : globalBlock.body.push(statement)
259
+ mainFunction ||= t.functionDeclaration(
260
+ t.identifier(topFunctionName),
261
+ [t.identifier("context"), t.identifier("args")],
262
+ t.blockStatement([])
263
+ )
264
+ program.node.body = [mainFunction]
265
+ if (globalBlock.body.length) {
266
+ ;(exports.size || liveExports.size) &&
267
+ mainFunction.body.body.push(
268
+ t.returnStatement(
269
+ t.objectExpression([
270
+ ...[...exports].map(([local, exported]) =>
271
+ t.objectProperty(t.identifier(exported), t.identifier(local))
272
+ ),
273
+ ...[...liveExports].map(([local, exported]) =>
274
+ t.objectMethod(
275
+ "get",
276
+ t.identifier(exported),
277
+ [],
278
+ t.blockStatement([t.returnStatement(t.identifier(local))])
279
+ )
280
+ )
281
+ ])
282
+ )
283
+ )
284
+ program.scope.crawl()
285
+ const globalBlockVariables = new Set()
286
+ let hoistedGlobalBlockFunctions = 0
287
+ for (const [globalBlockIndex, globalBlockStatement] of [...globalBlock.body.entries()].reverse())
288
+ if ("VariableDeclaration" == globalBlockStatement.type) {
289
+ assert(1 == globalBlockStatement.declarations.length, "src/processScript/transform.ts:370:59")
290
+ const declarator = globalBlockStatement.declarations[0]
291
+ assert(
292
+ "Identifier" == declarator.id.type,
293
+ `src/processScript/transform.ts:374:51 declarator.id.type was "${declarator.id.type}"`
294
+ )
295
+ program.scope.crawl()
296
+ if (program.scope.hasGlobal(declarator.id.name)) {
297
+ globalBlock.body.splice(globalBlockIndex, 1)
298
+ const [globalBlockPath] = program.unshiftContainer("body", globalBlock),
299
+ [globalBlockStatementPath] = program.unshiftContainer("body", globalBlockStatement)
300
+ program.scope.crawl()
301
+ if (
302
+ !declarator.init ||
303
+ ("FunctionExpression" != declarator.init.type &&
304
+ "ArrowFunctionExpression" != declarator.init.type) ||
305
+ Object.keys(program.scope.globals).some(global => globalBlockVariables.has(global))
306
+ ) {
307
+ const binding = program.scope.getBinding(declarator.id.name)
308
+ assert(binding, "src/processScript/transform.ts:393:23")
309
+ for (const referencePath of binding.referencePaths) {
310
+ assert("Identifier" == referencePath.node.type, "src/processScript/transform.ts:396:56")
311
+ referencePath.replaceWith(
312
+ t.memberExpression(
313
+ t.identifier(`$${uniqueID}$GLOBAL$`),
314
+ t.identifier(referencePath.node.name)
315
+ )
316
+ )
317
+ }
318
+ for (const referencePath of binding.constantViolations)
319
+ if ("AssignmentExpression" == referencePath.node.type)
320
+ for (const [name, node] of Object.entries(t.getBindingIdentifiers(referencePath.node)))
321
+ if (name == declarator.id.name) {
322
+ clearObject(node)
323
+ Object.assign(
324
+ node,
325
+ t.memberExpression(t.identifier(`$${uniqueID}$GLOBAL$`), t.identifier(name))
326
+ )
327
+ }
328
+ globalBlockPath.remove()
329
+ globalBlockStatementPath.remove()
330
+ declarator.init &&
331
+ globalBlock.body.splice(
332
+ globalBlockIndex,
333
+ 0,
334
+ t.expressionStatement(
335
+ t.assignmentExpression(
336
+ "=",
337
+ t.memberExpression(
338
+ t.identifier(`$${uniqueID}$GLOBAL$`),
339
+ t.identifier(declarator.id.name)
340
+ ),
341
+ declarator.init
342
+ )
343
+ )
344
+ )
345
+ } else {
346
+ globalBlockPath.remove()
347
+ globalBlockStatementPath.remove()
348
+ mainFunction.body.body.unshift(globalBlockStatement)
349
+ hoistedGlobalBlockFunctions++
350
+ }
351
+ } else globalBlockVariables.add(declarator.id.name)
352
+ } else if ("ClassDeclaration" == globalBlockStatement.type) {
353
+ program.scope.crawl()
354
+ assert(globalBlockStatement.id, "src/processScript/transform.ts:447:37")
355
+ if (program.scope.hasGlobal(globalBlockStatement.id.name)) {
356
+ globalBlock.body.splice(globalBlockIndex, 1)
357
+ const [globalBlockPath] = program.unshiftContainer("body", globalBlock),
358
+ [globalBlockStatementPath] = program.unshiftContainer("body", globalBlockStatement)
359
+ program.scope.crawl()
360
+ const binding = program.scope.getBinding(globalBlockStatement.id.name)
361
+ assert(binding, "src/processScript/transform.ts:459:22")
362
+ for (const referencePath of binding.referencePaths) {
363
+ assert("Identifier" == referencePath.node.type, "src/processScript/transform.ts:462:55")
364
+ referencePath.replaceWith(
365
+ t.memberExpression(
366
+ t.identifier(`$${uniqueID}$GLOBAL$`),
367
+ t.identifier(referencePath.node.name)
368
+ )
369
+ )
370
+ }
371
+ globalBlockPath.remove()
372
+ globalBlockStatementPath.remove()
373
+ globalBlock.body.splice(
374
+ globalBlockIndex,
375
+ 0,
376
+ t.expressionStatement(
377
+ t.assignmentExpression(
378
+ "=",
379
+ t.memberExpression(
380
+ t.identifier(`$${uniqueID}$GLOBAL$`),
381
+ t.identifier(globalBlockStatement.id.name)
382
+ ),
383
+ t.classExpression(
384
+ void 0,
385
+ globalBlockStatement.superClass,
386
+ globalBlockStatement.body,
387
+ globalBlockStatement.decorators
388
+ )
389
+ )
390
+ )
391
+ )
392
+ }
393
+ }
394
+ if (program.scope.hasGlobal("_EXPORTS"))
395
+ for (const referencePath of getReferencePathsToGlobal("_EXPORTS", program))
396
+ referencePath.replaceWith(
397
+ t.arrayExpression([...exports.keys(), ...liveExports.keys()].map(name => t.stringLiteral(name)))
398
+ )
399
+ globalBlock.body.length &&
400
+ mainFunction.body.body.splice(
401
+ hoistedGlobalBlockFunctions,
402
+ 0,
403
+ t.ifStatement(t.unaryExpression("!", t.identifier(`$${uniqueID}$FMCL$`)), globalBlock)
404
+ )
405
+ }
406
+ functionDotPrototypeIsReferencedMultipleTimes &&
407
+ mainFunction.body.body.unshift(
408
+ t.variableDeclaration("let", [
409
+ t.variableDeclarator(
410
+ t.identifier(`_${uniqueID}_FUNCTION_DOT_PROTOTYPE_`),
411
+ createGetFunctionPrototypeNode()
412
+ )
413
+ ])
414
+ )
415
+ needGetPrototypeOf &&
416
+ mainFunction.body.body.unshift(
417
+ t.variableDeclaration("let", [
418
+ t.variableDeclarator(
419
+ t.objectPattern([
420
+ t.objectProperty(t.identifier("get"), t.identifier(`_${uniqueID}_DUNDER_PROTO_GETTER_`))
421
+ ]),
422
+ t.callExpression(
423
+ t.memberExpression(t.identifier("Object"), t.identifier("getOwnPropertyDescriptor")),
424
+ [
425
+ t.memberExpression(t.identifier("Object"), t.identifier("prototype")),
426
+ t.stringLiteral("__proto__")
427
+ ]
428
+ )
429
+ ),
430
+ t.variableDeclarator(
431
+ t.identifier(`_${uniqueID}_GET_PROTOTYPE_OF_`),
432
+ t.callExpression(
433
+ t.memberExpression(
434
+ t.memberExpression(
435
+ t.identifier(
436
+ globalFunctionsUnder7Characters.find(name => !program.scope.hasOwnBinding(name))
437
+ ),
438
+ t.identifier("call")
439
+ ),
440
+ t.identifier("bind")
441
+ ),
442
+ [t.identifier(`_${uniqueID}_DUNDER_PROTO_GETTER_`)]
443
+ )
444
+ )
445
+ ])
446
+ )
447
+ consoleMethodsReferenced.size &&
448
+ mainFunction.body.body.unshift(
449
+ t.variableDeclaration(
450
+ "let",
451
+ [...consoleMethodsReferenced].map(name =>
452
+ t.variableDeclarator(
453
+ t.identifier(`_${uniqueID}_CONSOLE_METHOD_${name}_`),
454
+ t.arrowFunctionExpression(
455
+ [t.restElement(t.identifier("args"))],
456
+ t.unaryExpression(
457
+ "void",
458
+ t.callExpression(t.identifier(`$${uniqueID}$DEBUG$`), [t.identifier("args")])
459
+ )
460
+ )
461
+ )
462
+ )
463
+ )
464
+ )
465
+ neededDbMethodLets.size &&
466
+ mainFunction.body.body.unshift(
467
+ t.variableDeclaration(
468
+ "let",
469
+ [...neededDbMethodLets].map(name => {
470
+ const getArgs = () =>
471
+ "ObjectId" == name ? []
472
+ : "i" == name || "r" == name ? [t.identifier("a")]
473
+ : [t.identifier("a"), t.identifier("b")]
474
+ return t.variableDeclarator(
475
+ t.identifier(`_${uniqueID}_CONSOLE_METHOD_${name}_`),
476
+ t.arrowFunctionExpression(
477
+ getArgs(),
478
+ t.callExpression(t.identifier(`$${uniqueID}$DB$${name}$`), getArgs())
479
+ )
480
+ )
481
+ })
482
+ )
483
+ )
484
+ needDebugLet &&
485
+ mainFunction.body.body.unshift(
486
+ t.variableDeclaration("let", [
487
+ t.variableDeclarator(
488
+ t.identifier(`_${uniqueID}_DEBUG_`),
489
+ t.callExpression(t.identifier(`$${uniqueID}$DEBUG$`), [t.identifier("a")])
490
+ )
491
+ ])
492
+ )
493
+ neededSubscriptLets.size &&
494
+ mainFunction.body.body.unshift(
495
+ t.variableDeclaration(
496
+ "let",
497
+ [...neededSubscriptLets].map(name =>
498
+ t.variableDeclarator(
499
+ t.identifier(`_${uniqueID}_SUBSCRIPT_${name}_`),
500
+ t.arrowFunctionExpression(
501
+ [t.restElement(t.identifier("args"))],
502
+ t.callExpression(t.identifier(`$${uniqueID}$SUBSCRIPT$${name}$`), [
503
+ t.spreadElement(t.identifier("args"))
504
+ ])
505
+ )
506
+ )
507
+ )
508
+ )
509
+ )
510
+ traverse(file, {
511
+ BlockStatement({ node: blockStatement }) {
512
+ for (const [index, functionDeclaration] of blockStatement.body.entries())
513
+ if ("FunctionDeclaration" == functionDeclaration.type && !functionDeclaration.generator) {
514
+ blockStatement.body.splice(index, 1)
515
+ blockStatement.body.unshift(
516
+ t.variableDeclaration("let", [
517
+ t.variableDeclarator(
518
+ functionDeclaration.id,
519
+ t.arrowFunctionExpression(
520
+ functionDeclaration.params,
521
+ functionDeclaration.body,
522
+ functionDeclaration.async
523
+ )
524
+ )
525
+ ])
526
+ )
527
+ }
528
+ },
529
+ ClassBody({ node: classBody, scope, parent }) {
530
+ assert(t.isClass(parent), "src/processScript/transform.ts:629:30")
531
+ let thisIsReferenced = !1
532
+ for (const classMethod of classBody.body) {
533
+ if ("ClassMethod" != classMethod.type) continue
534
+ let methodReferencesThis = !1
535
+ traverse(
536
+ classMethod.body,
537
+ {
538
+ ThisExpression(path) {
539
+ methodReferencesThis = !0
540
+ thisIsReferenced = !0
541
+ path.replaceWith(t.identifier(`_${uniqueID}_THIS_`))
542
+ },
543
+ Function: path => path.skip()
544
+ },
545
+ scope
546
+ )
547
+ if (methodReferencesThis)
548
+ if ("constructor" != classMethod.kind)
549
+ classMethod.body.body.unshift(
550
+ t.variableDeclaration("let", [
551
+ t.variableDeclarator(
552
+ t.identifier(`_${uniqueID}_THIS_`),
553
+ t.callExpression(t.memberExpression(t.super(), t.identifier("valueOf")), [])
554
+ )
555
+ ])
556
+ )
557
+ else {
558
+ const superCalls = []
559
+ traverse(
560
+ classMethod.body,
561
+ {
562
+ CallExpression(path) {
563
+ "Super" == path.node.callee.type && superCalls.push(path)
564
+ }
565
+ },
566
+ scope
567
+ )
568
+ if (superCalls.length)
569
+ if (
570
+ 1 == superCalls.length &&
571
+ "ExpressionStatement" == superCalls[0].parent.type &&
572
+ superCalls[0].parentPath.parentPath.parent == classMethod
573
+ )
574
+ superCalls[0].parentPath.replaceWith(
575
+ t.variableDeclaration("let", [
576
+ t.variableDeclarator(t.identifier(`_${uniqueID}_THIS_`), superCalls[0].node)
577
+ ])
578
+ )
579
+ else {
580
+ for (const path of superCalls)
581
+ path.replaceWith(
582
+ t.assignmentExpression("=", t.identifier(`_${uniqueID}_THIS_`), path.node)
583
+ )
584
+ classMethod.body.body.unshift(
585
+ t.variableDeclaration("let", [
586
+ t.variableDeclarator(t.identifier(`_${uniqueID}_THIS_`))
587
+ ])
588
+ )
589
+ }
590
+ else
591
+ classMethod.body.body.unshift(
592
+ t.variableDeclaration("let", [
593
+ t.variableDeclarator(
594
+ t.identifier(`_${uniqueID}_THIS_`),
595
+ t.callExpression(t.super(), [])
596
+ )
597
+ ])
598
+ )
599
+ }
600
+ }
601
+ !parent.superClass && thisIsReferenced && (parent.superClass = t.identifier("Object"))
602
+ },
603
+ VariableDeclaration({ node: variableDeclaration }) {
604
+ "const" == variableDeclaration.kind && (variableDeclaration.kind = "let")
605
+ },
606
+ ThisExpression: path => path.replaceWith(t.identifier("undefined")),
607
+ BigIntLiteral(path) {
608
+ const bigIntAsNumber = Number(path.node.value)
609
+ path.replaceWith(
610
+ t.callExpression(t.identifier("BigInt"), [
611
+ BigInt(bigIntAsNumber) == BigInt(path.node.value) ?
612
+ t.numericLiteral(bigIntAsNumber)
613
+ : t.stringLiteral(path.node.value)
614
+ ])
615
+ )
616
+ }
617
+ })
618
+ return { file, seclevel }
619
+ function createGetFunctionPrototypeNode() {
620
+ for (const globalFunction of globalFunctionsUnder7Characters)
621
+ if (!program.scope.hasOwnBinding(globalFunction))
622
+ return t.memberExpression(
623
+ t.memberExpression(t.identifier(globalFunction), t.identifier("constructor")),
624
+ t.identifier("prototype")
625
+ )
626
+ return t.memberExpression(
627
+ t.memberExpression(
628
+ t.arrowFunctionExpression([t.identifier("_")], t.identifier("_")),
629
+ t.identifier("constructor")
630
+ ),
631
+ t.identifier("prototype")
632
+ )
633
+ }
634
+ function processFakeSubscriptObject(fakeSubscriptObjectName) {
635
+ for (const referencePath of getReferencePathsToGlobal(fakeSubscriptObjectName, program)) {
636
+ assert("MemberExpression" == referencePath.parent.type, "src/processScript/transform.ts:743:60")
637
+ assert("Identifier" == referencePath.parent.property.type)
638
+ assert(
639
+ "MemberExpression" == referencePath.parentPath.parentPath?.node.type,
640
+ "src/processScript/transform.ts:745:81"
641
+ )
642
+ assert(
643
+ "Identifier" == referencePath.parentPath.parentPath.node.property.type,
644
+ "src/processScript/transform.ts:746:83"
645
+ )
646
+ assert(
647
+ /^[_a-z][\d_a-z]{0,24}$/.test(referencePath.parent.property.name),
648
+ `src/processScript/transform.ts:750:8 invalid user "${referencePath.parent.property.name}" in subscript`
649
+ )
650
+ assert(
651
+ /^[_a-z][\d_a-z]{0,24}$/.test(referencePath.parentPath.parentPath.node.property.name),
652
+ `src/processScript/transform.ts:755:8 invalid script name "${referencePath.parentPath.parentPath.node.property.name}" in subscript`
653
+ )
654
+ if ("CallExpression" == referencePath.parentPath.parentPath.parentPath?.type)
655
+ referencePath.parentPath.parentPath.replaceWith(
656
+ t.identifier(
657
+ `$${uniqueID}$SUBSCRIPT$${referencePath.parent.property.name}$${referencePath.parentPath.parentPath.node.property.name}$`
658
+ )
659
+ )
660
+ else {
661
+ const name = `${referencePath.parent.property.name}$${referencePath.parentPath.parentPath.node.property.name}`
662
+ referencePath.parentPath.parentPath.replaceWith(t.identifier(`_${uniqueID}_SUBSCRIPT_${name}_`))
663
+ neededSubscriptLets.add(name)
664
+ }
665
+ }
666
+ }
667
+ }
668
+ export { transform as default, transform }