{"version":3,"file":"transformMixedNativeModule.js","names":[],"sources":["esm/transformMixedNativeModule.js"],"sourcesContent":["import { parseSync } from \"oxc-parser\";\nimport MagicString from \"magic-string\";\nimport remapping from \"@jridgewell/remapping\";\nfunction analyze(program) {\n  const scopes = /* @__PURE__ */ new WeakMap();\n  const bindings = /* @__PURE__ */ new WeakSet();\n  const root = { bindings: /* @__PURE__ */ new Set(), function: true };\n  function bind(pattern, scope) {\n    if (!pattern) return;\n    if (pattern.type === \"Identifier\") {\n      scope.bindings.add(pattern.name);\n      bindings.add(pattern);\n    } else if (pattern.type === \"RestElement\") bind(pattern.argument, scope);\n    else if (pattern.type === \"AssignmentPattern\") bind(pattern.left, scope);\n    else if (pattern.type === \"ArrayPattern\") {\n      for (const item of pattern.elements) bind(item, scope);\n    } else if (pattern.type === \"ObjectPattern\") {\n      for (const item of pattern.properties)\n        bind(item.type === \"RestElement\" ? item.argument : item.value, scope);\n    }\n  }\n  function visit(node, parentScope) {\n    let scope = parentScope;\n    const fn = /^(?:FunctionDeclaration|FunctionExpression|ArrowFunctionExpression)$/.test(\n      node.type\n    );\n    if (node.type === \"FunctionDeclaration\" || node.type === \"ClassDeclaration\")\n      bind(node.id, parentScope);\n    if (fn || /^(?:BlockStatement|CatchClause|ForStatement|ForInStatement|ForOfStatement|SwitchStatement|ClassExpression|ClassDeclaration|StaticBlock)$/.test(\n      node.type\n    )) {\n      scope = {\n        parent: parentScope,\n        bindings: /* @__PURE__ */ new Set(),\n        function: fn || node.type === \"StaticBlock\"\n      };\n    }\n    scopes.set(node, scope);\n    if (fn) {\n      if (node.type === \"FunctionExpression\") bind(node.id, scope);\n      for (const param of node.params) bind(param, scope);\n    }\n    if (node.type === \"ClassExpression\" || node.type === \"ClassDeclaration\")\n      bind(node.id, scope);\n    if (node.type === \"CatchClause\") bind(node.param, scope);\n    if (node.type === \"VariableDeclaration\") {\n      let target = scope;\n      if (node.kind === \"var\") while (!target.function) target = target.parent;\n      for (const declaration of node.declarations) bind(declaration.id, target);\n    }\n    if (node.type === \"ImportDeclaration\")\n      for (const specifier of node.specifiers) bind(specifier.local, scope);\n    children(node, (child) => visit(child, scope));\n    if ((node.type === \"FunctionDeclaration\" || node.type === \"ClassDeclaration\") && node.id)\n      scopes.set(node.id, parentScope);\n  }\n  visit(program, root);\n  function binding(node) {\n    let scope = scopes.get(node);\n    while (scope && !scope.bindings.has(node.name)) scope = scope.parent;\n    return scope;\n  }\n  return { bindings, binding, rootBindings: root.bindings };\n}\nfunction children(node, visit) {\n  for (const key of Object.keys(node)) {\n    if (key === \"parent\") continue;\n    const value = node[key];\n    if (Array.isArray(value)) {\n      for (const child of value) if (child?.type) visit(child, key);\n    } else if (value?.type) visit(value, key);\n  }\n}\nfunction isReference(node, parent, key, bindings) {\n  if (bindings.has(node)) return false;\n  if ((parent.type === \"MemberExpression\" || parent.type === \"OptionalMemberExpression\") && key === \"property\" && !parent.computed)\n    return false;\n  if (/^(?:Property|MethodDefinition|PropertyDefinition)$/.test(parent.type) && key === \"key\" && !parent.computed)\n    return false;\n  if (/^(?:Import.*Specifier|ExportSpecifier|LabeledStatement|BreakStatement|ContinueStatement|MetaProperty)$/.test(\n    parent.type\n  ))\n    return false;\n  return true;\n}\nfunction lowerLocalExports(program, code, analysis) {\n  const edited = new MagicString(code);\n  let exportAccess = \"__mixedExports\";\n  while (code.includes(exportAccess)) exportAccess += \"_\";\n  const exportBinding = analysis.rootBindings.has(\"exports\") ? `const ${exportAccess} = module.exports;` : `const ${exportAccess} = () => exports;`;\n  const exportObject = analysis.rootBindings.has(\"exports\") ? exportAccess : `${exportAccess}()`;\n  const exported = /* @__PURE__ */ new Map();\n  const imported = /* @__PURE__ */ new Set();\n  for (const node of program.body)\n    if (node.type === \"ImportDeclaration\")\n      for (const specifier of node.specifiers) imported.add(specifier.local.name);\n  const hoisted = [];\n  const defaultFunctions = [];\n  function names(pattern) {\n    if (!pattern) return [];\n    if (pattern.type === \"Identifier\") return [pattern];\n    if (pattern.type === \"RestElement\") return names(pattern.argument);\n    if (pattern.type === \"AssignmentPattern\") return names(pattern.left);\n    if (pattern.type === \"ArrayPattern\") return pattern.elements.flatMap(names);\n    if (pattern.type === \"ObjectPattern\")\n      return pattern.properties.flatMap(\n        (item) => names(item.type === \"RestElement\" ? item.argument : item.value)\n      );\n    return [];\n  }\n  function add(id, name) {\n    const entry = exported.get(id.name) || {\n      scope: analysis.binding(id),\n      names: []\n    };\n    entry.names.push(name);\n    exported.set(id.name, entry);\n  }\n  const assignments = (id) => exported.get(id).names.map((name) => `${exportObject}[${JSON.stringify(name)}] = `).join(\"\") + id;\n  for (const node of program.body) {\n    if (node.type === \"ExportDefaultDeclaration\") {\n      const declaration = node.declaration;\n      if (declaration.type === \"FunctionDeclaration\" || declaration.type === \"ClassDeclaration\" && declaration.id) {\n        edited.remove(node.start, declaration.start);\n        if (declaration.id) {\n          add(declaration.id, \"default\");\n          if (declaration.type === \"FunctionDeclaration\")\n            hoisted.push(declaration.id.name);\n          else\n            edited.appendLeft(\n              node.end,\n              `;${exportObject}.default = ${declaration.id.name};`\n            );\n        } else {\n          let name = \"__mixedDefault\";\n          while (code.includes(name)) name += \"_\";\n          const prefix = code.slice(declaration.start, declaration.body.start).match(/^(?:async\\s+)?function\\s*\\*?/)[0];\n          edited.prependRight(declaration.start + prefix.length, ` ${name}`);\n          defaultFunctions.push(`${exportObject}.default = ${name};`);\n        }\n      } else if (declaration.type !== \"TSInterfaceDeclaration\") {\n        edited.overwrite(node.start, declaration.start, `${exportObject}.default = (`);\n        edited.appendLeft(declaration.end, \")\");\n      }\n    }\n    if (node.type === \"ExportNamedDeclaration\" && !node.source && node.exportKind !== \"type\") {\n      const declaration = node.declaration;\n      if (declaration) {\n        if (/^(?:TS|Interface|Type)/.test(declaration.type)) continue;\n        const ids = declaration.type === \"VariableDeclaration\" ? declaration.declarations.flatMap((item) => names(item.id)) : names(declaration.id);\n        for (const id of ids) add(id, id.name);\n        edited.remove(node.start, declaration.start);\n        if (declaration.type === \"FunctionDeclaration\")\n          hoisted.push(...ids.map((id) => id.name));\n      } else {\n        const locals = node.specifiers.filter(\n          (item) => item.exportKind !== \"type\" && !imported.has(item.local.name)\n        );\n        for (const item of locals)\n          add(item.local, item.exported.name ?? item.exported.value);\n        if (locals.length === node.specifiers.length) edited.remove(node.start, node.end);\n        else if (locals.length) {\n          const retained = node.specifiers.filter(\n            (other) => !locals.includes(other)\n          );\n          edited.overwrite(\n            node.start,\n            node.end,\n            `export { ${retained.map((other) => code.slice(other.start, other.end)).join(\", \")} };`\n          );\n        }\n      }\n    }\n  }\n  for (const node of program.body) {\n    const declaration = node.type === \"ExportNamedDeclaration\" ? node.declaration : node;\n    if (!declaration) continue;\n    if (declaration.type === \"VariableDeclaration\") {\n      for (const item of declaration.declarations)\n        for (const id of names(item.id)) {\n          if (exported.has(id.name)) {\n            if (item.id.type === \"Identifier\" && item.init) {\n              const prefix = exported.get(id.name).names.map((name) => `${exportObject}[${JSON.stringify(name)}] = `).join(\"\");\n              edited.prependRight(item.init.start, prefix + \"(\");\n              edited.appendLeft(item.init.end, \")\");\n            } else if (item.id.type !== \"Identifier\")\n              edited.appendLeft(node.end, `;${assignments(id.name)};`);\n          }\n        }\n    } else if (declaration.type === \"FunctionDeclaration\" && exported.has(declaration.id?.name)) {\n      if (!hoisted.includes(declaration.id.name)) hoisted.push(declaration.id.name);\n    } else if (declaration.type === \"ClassDeclaration\" && exported.has(declaration.id?.name)) {\n      edited.appendLeft(node.end, `;${assignments(declaration.id.name)};`);\n    }\n  }\n  let temporary = \"__mixedExportResult\";\n  while (code.includes(temporary)) temporary += \"_\";\n  function mutations(node) {\n    if (node.type === \"ForOfStatement\" || node.type === \"ForInStatement\") {\n      const ids = (node.left.type === \"VariableDeclaration\" ? node.left.declarations.flatMap((item) => names(item.id)) : names(node.left)).filter(\n        (id) => exported.has(id.name) && analysis.binding(id) === exported.get(id.name).scope\n      );\n      if (ids.length) {\n        const publish = ids.map((id) => assignments(id.name) + \";\").join(\"\");\n        if (node.body.type === \"BlockStatement\")\n          edited.prependRight(node.body.start + 1, publish);\n        else {\n          edited.prependRight(node.body.start, \"{\" + publish);\n          edited.appendLeft(node.body.end, \"}\");\n        }\n      }\n    }\n    if (node.type === \"AssignmentExpression\" || node.type === \"UpdateExpression\") {\n      const ids = names(\n        node.type === \"AssignmentExpression\" ? node.left : node.argument\n      ).filter(\n        (id) => exported.has(id.name) && analysis.binding(id) === exported.get(id.name).scope\n      );\n      if (ids.length) {\n        edited.prependRight(\n          node.start,\n          `((${temporary}) => (${ids.map((id) => assignments(id.name)).join(\", \")}, ${temporary}))(`\n        );\n        edited.appendLeft(node.end, \")\");\n      }\n    }\n    children(node, (child) => mutations(child));\n  }\n  mutations(program);\n  const first = program.body.find(\n    (node) => !(node.type === \"ExpressionStatement\" && node.directive)\n  );\n  const initialization = [...exported.values()].flatMap((entry) => entry.names).map((name) => `${exportObject}[${JSON.stringify(name)}] = void 0;`).join(\"\");\n  edited.prependRight(\n    first?.start ?? code.length,\n    `export {};${exportBinding}${initialization}${hoisted.map((id) => assignments(id) + \";\").join(\"\")}${defaultFunctions.join(\"\")}`\n  );\n  return edited;\n}\nasync function transformMixedNativeModule(code, filename, sourceMaps = false) {\n  if (!/\\b(?:module|exports)\\b/.test(code) || !/\\b(?:import|export)\\b/.test(code)) return;\n  const typescript = /\\.[cm]?tsx?$/.test(filename);\n  const parsed = parseSync(filename, code, {\n    lang: typescript ? filename.endsWith(\"tsx\") ? \"tsx\" : \"ts\" : \"jsx\"\n  });\n  if (parsed.errors.length) throw new Error(parsed.errors[0].message);\n  let program = parsed.program;\n  if (!program.body.some((node) => /^(?:Import|Export)/.test(node.type))) return;\n  let analysis = analyze(program);\n  let mixed = false;\n  function inspect(node, parent, key) {\n    if (node.type === \"Identifier\" && /^(?:module|exports)$/.test(node.name) && isReference(node, parent, key, analysis.bindings) && !analysis.binding(node))\n      mixed = true;\n    children(node, (child, key2) => inspect(child, node, key2));\n  }\n  inspect(program, program, \"\");\n  if (!mixed) return;\n  const { transform } = await import(\"@swc/core\");\n  let typeMap;\n  if (typescript) {\n    const stripped = await transform(code, {\n      filename,\n      swcrc: false,\n      configFile: false,\n      sourceMaps,\n      jsc: {\n        target: \"esnext\",\n        parser: { syntax: \"typescript\", tsx: filename.endsWith(\".tsx\") },\n        transform: { react: { runtime: \"preserve\" } }\n      },\n      module: { type: \"es6\" }\n    });\n    code = stripped.code;\n    typeMap = stripped.map ? JSON.parse(stripped.map) : void 0;\n    const javascript = parseSync(filename, code, { lang: \"jsx\" });\n    if (javascript.errors.length) throw new Error(javascript.errors[0].message);\n    program = javascript.program;\n    analysis = analyze(program);\n  }\n  const edited = lowerLocalExports(program, code, analysis);\n  const result = await transform(edited.toString(), {\n    filename,\n    swcrc: false,\n    configFile: false,\n    sourceMaps,\n    jsc: {\n      target: \"esnext\",\n      parser: { syntax: \"ecmascript\", jsx: true },\n      transform: { react: { runtime: \"preserve\" } }\n    },\n    module: { type: \"commonjs\", strictMode: false, allowTopLevelThis: true }\n  });\n  return {\n    code: result.code,\n    map: result.map ? remapping(\n      [\n        JSON.parse(result.map),\n        edited.generateMap({\n          source: filename,\n          includeContent: true,\n          hires: true\n        }),\n        ...typeMap ? [typeMap] : []\n      ],\n      () => null\n    ) : void 0\n  };\n}\nexport {\n  transformMixedNativeModule\n};\n//# sourceMappingURL=transformMixedNativeModule.js.map\n"],"mappings":";;;;;AAGA,SAAS,QAAQ,SAAS;CACxB,MAAM,yBAAyB,IAAI,QAAQ;CAC3C,MAAM,2BAA2B,IAAI,QAAQ;CAC7C,MAAM,OAAO;EAAE,0BAA0B,IAAI,IAAI;EAAG,UAAU;CAAK;CACnE,SAAS,KAAK,SAAS,OAAO;EAC5B,IAAI,CAAC,SAAS;EACd,IAAI,QAAQ,SAAS,cAAc;GACjC,MAAM,SAAS,IAAI,QAAQ,IAAI;GAC/B,SAAS,IAAI,OAAO;EACtB,OAAO,IAAI,QAAQ,SAAS,eAAe,KAAK,QAAQ,UAAU,KAAK;O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