@vxrn/compiler 2.0.0-beta.98.1 → 2.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/dist/cjs/index.cjs +10 -1
  2. package/dist/cjs/reactNativeViewConfig.cjs +1 -1
  3. package/dist/cjs/transformBabel.cjs +15 -57
  4. package/dist/cjs/transformFlow.cjs +87 -0
  5. package/dist/cjs/transformHermesClasses.cjs +58 -0
  6. package/dist/cjs/transformSWC.cjs +3 -4
  7. package/dist/cjs/workletUtils.cjs +30 -0
  8. package/dist/cjs/worklets/autoworklet.cjs +2 -2
  9. package/dist/cjs/worklets/globals.cjs +22 -1
  10. package/dist/esm/index.js +12 -1
  11. package/dist/esm/index.js.map +1 -1
  12. package/dist/esm/index.mjs +12 -1
  13. package/dist/esm/index.mjs.map +1 -1
  14. package/dist/esm/reactNativeViewConfig.mjs +1 -1
  15. package/dist/esm/reactNativeViewConfig.mjs.map +1 -1
  16. package/dist/esm/transformBabel.mjs +17 -58
  17. package/dist/esm/transformBabel.mjs.map +1 -1
  18. package/dist/esm/transformFlow.mjs +62 -0
  19. package/dist/esm/transformFlow.mjs.map +1 -0
  20. package/dist/esm/transformHermesClasses.mjs +32 -0
  21. package/dist/esm/transformHermesClasses.mjs.map +1 -0
  22. package/dist/esm/transformSWC.mjs +3 -4
  23. package/dist/esm/transformSWC.mjs.map +1 -1
  24. package/dist/esm/workletUtils.mjs +5 -0
  25. package/dist/esm/worklets/autoworklet.mjs +2 -2
  26. package/dist/esm/worklets/autoworklet.mjs.map +1 -1
  27. package/dist/esm/worklets/globals.mjs +22 -1
  28. package/dist/esm/worklets/globals.mjs.map +1 -1
  29. package/package.json +12 -4
  30. package/src/index.ts +12 -1
  31. package/src/reactNativeViewConfig.ts +7 -2
  32. package/src/transformBabel.test.ts +61 -37
  33. package/src/transformBabel.ts +28 -92
  34. package/src/transformFlow.test.ts +134 -0
  35. package/src/transformFlow.ts +68 -0
  36. package/src/transformHermesClasses.ts +34 -0
  37. package/src/transformSWC.test.ts +33 -1
  38. package/src/transformSWC.ts +14 -4
  39. package/src/transformWorklets.test.ts +64 -0
  40. package/src/workletUtils.ts +4 -0
  41. package/src/worklets/autoworklet.ts +5 -2
  42. package/src/worklets/globals.ts +23 -0
  43. package/types/index.d.ts +2 -0
  44. package/types/index.d.ts.map +1 -1
  45. package/types/reactNativeViewConfig.d.ts +1 -1
  46. package/types/reactNativeViewConfig.d.ts.map +1 -1
  47. package/types/transformBabel.d.ts +0 -12
  48. package/types/transformBabel.d.ts.map +1 -1
  49. package/types/transformFlow.d.ts +5 -0
  50. package/types/transformFlow.d.ts.map +1 -0
  51. package/types/transformHermesClasses.d.ts +5 -0
  52. package/types/transformHermesClasses.d.ts.map +1 -0
  53. package/types/transformSWC.d.ts.map +1 -1
  54. package/types/workletUtils.d.ts +4 -0
  55. package/types/workletUtils.d.ts.map +1 -0
  56. package/types/worklets/autoworklet.d.ts.map +1 -1
  57. package/types/worklets/globals.d.ts.map +1 -1
@@ -1,4 +1,5 @@
1
1
  import { extname } from "node:path";
2
+ import { parseSync } from "oxc-parser";
2
3
  import { normalizePath } from "vite";
3
4
  import { configuration } from "./configure.mjs";
4
5
  import { asyncGeneratorRegex, debug, runtimePublicPath } from "./constants.mjs";
@@ -7,11 +8,9 @@ const ignoreId = /node_modules\/(\.vite|vite)\//;
7
8
  function shouldStripFlow(id, code) {
8
9
  const filename = id.split("?")[0];
9
10
  if (!/\.jsx?$/.test(filename)) return false;
10
- if (/node_modules[\\/](?:react-native|@react-native)[\\/].*\.js$/.test(filename)) {
11
- return true;
12
- }
13
11
  const header = code.match(/^(?:#![^\r\n]*(?:\r?\n|$))?(?:\s|\/\*[\s\S]*?\*\/|\/\/[^\r\n]*)*/)?.[0] || "";
14
- return /@flow\b/.test(header) || /\b(?:import|export)\s+type\b/.test(code);
12
+ const candidate = /node_modules[\\/](?:react-native|@react-native)[\\/].*\.js$/.test(filename) || /@flow\b/.test(header) || /\b(?:import|export)\s+type\b/.test(code) || /\(\s*(?:\.\.\.)?[\w$]+\??\s*:\s*/.test(code) || /\)\s*:\s*(?:[\w$]+(?:<[^;{}]*>)?(?:\[\])?\s*)(?:=>|\{)/.test(code) || /^\s*[\w$]+\??\s*:\s*(?:string|number|boolean|any|mixed|void|[A-Z][\w$]*)(?:[^;\r\n=]*)(?:=[^;\r\n]*)?;/m.test(code) || /\b(?:opaque\s+)?type\s+[\w$]+(?:\s*<[^;{}]*>)?\s*=/.test(code);
13
+ return candidate && parseSync(filename, code, { lang: "jsx" }).errors.length > 0;
15
14
  }
16
15
  async function transformSWC(id, code, options, swcOptions) {
17
16
  id = normalizePath(id.split("?")[0]).replace(normalizePath(process.cwd()), "");
@@ -1 +1 @@
1
- {"version":3,"file":"transformSWC.js","names":[],"sources":["esm/transformSWC.js"],"sourcesContent":["import { extname } from \"node:path\";\nimport { normalizePath } from \"vite\";\nimport { configuration } from \"./configure\";\nimport { asyncGeneratorRegex, debug, runtimePublicPath } from \"./constants\";\nconst ignoreId = /node_modules\\/(\\.vite|vite)\\//;\nfunction shouldStripFlow(id, code) {\n const filename = id.split(\"?\")[0];\n if (!/\\.jsx?$/.test(filename)) return false;\n if (/node_modules[\\\\/](?:react-native|@react-native)[\\\\/].*\\.js$/.test(filename)) {\n return true;\n }\n const header = code.match(/^(?:#![^\\r\\n]*(?:\\r?\\n|$))?(?:\\s|\\/\\*[\\s\\S]*?\\*\\/|\\/\\/[^\\r\\n]*)*/)?.[0] || \"\";\n return /@flow\\b/.test(header) || /\\b(?:import|export)\\s+type\\b/.test(code);\n}\nasync function transformSWC(id, code, options, swcOptions) {\n id = normalizePath(id.split(\"?\")[0]).replace(normalizePath(process.cwd()), \"\");\n if (ignoreId.test(id)) {\n return;\n }\n if (id === runtimePublicPath) {\n return;\n }\n const lang = getLang(id, options.forceJSX);\n if (!lang) {\n return;\n }\n const refresh = options.environment !== \"ssr\" && !options.production && !options.noHMR && !options.forceJSX && !id.includes(\"node_modules\");\n const importSource = configuration.enableNativewind && !id.includes(\"node_modules\") ? \"nativewind\" : \"react\";\n const shouldEs5Transform = options.es5 || !process.env.VXRN_USE_BABEL_FOR_GENERATORS && asyncGeneratorRegex.test(code);\n const target = shouldEs5Transform ? \"es2015\" : \"es2020\";\n const sourceMaps = swcOptions?.sourceMaps !== void 0 ? Boolean(swcOptions.sourceMaps) : shouldSourceMap();\n const oxcOptions = {\n lang,\n target,\n assumptions: {\n setPublicClassFields: true,\n ...swcOptions?.assumptions || {}\n },\n sourcemap: sourceMaps,\n jsx: {\n runtime: \"automatic\",\n development: !options.forceJSX && !options.production,\n refresh: Boolean(refresh),\n importSource\n }\n };\n const { transformSync } = await import(\"oxc-transform\");\n const result = (() => {\n try {\n debug?.(\n `transformSWC (oxc) ${id} using options:\n${JSON.stringify(oxcOptions, null, 2)}`\n );\n const res = transformSync(id, code, oxcOptions);\n if (res.errors?.length) {\n const err = res.errors[0];\n const error = new Error(\n err.message + (err.codeframe ? `\n${err.codeframe}` : \"\")\n );\n if (err.labels?.[0]) {\n error.start = err.labels[0].start;\n error.end = err.labels[0].end;\n }\n throw error;\n }\n return {\n code: res.code,\n map: res.map\n };\n } catch (e) {\n throw e;\n }\n })();\n if (configuration.enableNativeCSS) {\n if (result.code.includes(`createInteropElement(`)) {\n result.code = `import { createInteropElement, Fragment as _InteropFragment } from 'react-native-css-interop/jsx-dev-runtime'\n${result.code}`;\n }\n }\n const hasRefreshRuntime = refresh && refreshContentRE.test(result.code);\n if (options.fixNonTypeSpecificImports || id.includes(\"node_modules\") && (lang === \"ts\" || lang === \"tsx\")) {\n const typeExportsMatch = code.match(/^\\s*export\\s+type\\s+([^\\s]+)/gi);\n if (typeExportsMatch) {\n for (const typeExport of Array.from(typeExportsMatch)) {\n const [_export, _type, name] = typeExport.split(/\\s+/);\n if (name.startsWith(\"{\")) continue;\n if (name.includes(\"<\")) continue;\n const alreadyExported = new RegExp(\n `export (const|let|class|function) ${name}\\\\s+`\n ).test(result.code);\n if (!alreadyExported) {\n const fakeExport = `export let ${name} = {};`;\n console.info(\n ` \\u26A0\\uFE0F Fixing non-type-specific import in node_module, this should be fixed upstream: ${fakeExport} in ${id}`\n );\n result.code += `\n${fakeExport}\n`;\n }\n }\n }\n }\n if (result && !options.production && !options.noHMR) {\n return wrapSourceInRefreshRuntime(id, result, options, hasRefreshRuntime);\n }\n return result;\n}\nconst transformOxc = transformSWC;\nfunction wrapSourceInRefreshRuntime(id, result, options, hasRefreshRuntime) {\n if (options.environment === \"ssr\") {\n return result;\n }\n if (options.environment === \"client\") {\n return wrapSourceInRefreshRuntimeWeb(id, result, hasRefreshRuntime);\n }\n return wrapSourceInRefreshRuntimeNative(id, result, options, hasRefreshRuntime);\n}\nfunction wrapSourceInRefreshRuntimeWeb(id, result, hasRefreshRuntime) {\n const sourceMap = result.map ? typeof result.map === \"string\" ? JSON.parse(result.map) : { ...result.map } : void 0;\n if (sourceMap) {\n sourceMap.mappings = \";;\" + sourceMap.mappings;\n }\n result.code = `import * as RefreshRuntime from \"${runtimePublicPath}\";\n\n${result.code}`;\n if (hasRefreshRuntime) {\n if (sourceMap) {\n sourceMap.mappings = \";;;;;;\" + sourceMap.mappings;\n }\n result.code = `if (!window.$RefreshReg$) throw new Error(\"React refresh preamble was not loaded. Something is wrong.\");\nconst prevRefreshReg = window.$RefreshReg$;\nconst prevRefreshSig = window.$RefreshSig$;\nwindow.$RefreshReg$ = RefreshRuntime.getRefreshReg(\"${id}\");\nwindow.$RefreshSig$ = RefreshRuntime.createSignatureFunctionForTransform;\n\n${result.code}\n\nwindow.$RefreshReg$ = prevRefreshReg;\nwindow.$RefreshSig$ = prevRefreshSig;\n`;\n }\n result.code += `\nRefreshRuntime.__hmr_import(import.meta.url).then((currentExports) => {\n RefreshRuntime.registerExportsForReactRefresh(\"${id}\", currentExports);\n import.meta.hot.accept((nextExports) => {\n if (!nextExports) return;\n const invalidateMessage = RefreshRuntime.validateRefreshBoundaryAndEnqueueUpdate(\"${id}\", currentExports, nextExports);\n if (invalidateMessage) import.meta.hot.invalidate(invalidateMessage);\n });\n});\n`;\n return { code: result.code, map: sourceMap };\n}\nfunction wrapSourceInRefreshRuntimeNative(id, result, options, hasRefreshRuntime) {\n const postfixCode = `if (module.hot) {\n if (module.hot.accept) {\n module.hot.accept((nextExports) => {\n RefreshRuntime.performReactRefresh()\n });\n }\n}`;\n if (hasRefreshRuntime) {\n const prefixCode = `const RefreshRuntime = __cachedModules[\"react-refresh/cjs/react-refresh-runtime.development\"];\nconst prevRefreshReg = globalThis.$RefreshReg$;\nconst prevRefreshSig = globalThis.$RefreshSig$ || (() => {\n console.info(\"no react refresh setup!\")\n return (x) => x\n});\nglobalThis.$RefreshReg$ = (type, id) => RefreshRuntime.register(type, \"${id}\" + \" \" + id);\nglobalThis.$RefreshSig$ = RefreshRuntime.createSignatureFunctionForTransform;\nmodule.url = '${id}'\nmodule.hot = createHotContext(module.url)`;\n const sourceMap = result.map ? typeof result.map === \"string\" ? JSON.parse(result.map) : { ...result.map } : void 0;\n if (sourceMap) {\n const prefixLen = prefixCode.split(\"\\n\").length + 1;\n sourceMap.mappings = new Array(prefixLen).fill(\";\").join(\"\") + sourceMap.mappings;\n }\n return {\n code: `${prefixCode}\n${result.code}\n\nif (module.hot) {\n globalThis.$RefreshReg$ = prevRefreshReg;\n globalThis.$RefreshSig$ = prevRefreshSig;\n globalThis['lastHmrExports'] = JSON.stringify(Object.keys(exports))\n}\n\n${postfixCode}\n`,\n map: sourceMap\n };\n }\n result.code += postfixCode;\n return result;\n}\nconst refreshContentRE = /\\$Refresh(?:Reg|Sig)\\$\\(/;\nfunction shouldSourceMap() {\n return process.env.VXRN_ENABLE_SOURCE_MAP === \"1\";\n}\nfunction getLang(id, forceJSX = false) {\n if (id.endsWith(\"one-entry-native\")) {\n return \"tsx\";\n }\n const extension = extname(id);\n if (extension === \".tsx\") return \"tsx\";\n if (extension === \".ts\") return \"ts\";\n if (extension === \".jsx\" || extension === \".mdx\") return \"jsx\";\n if (extension === \".js\" || extension === \".mjs\" || extension === \".cjs\") {\n return \"jsx\";\n }\n if (!extension) {\n return forceJSX ? \"jsx\" : \"js\";\n }\n return void 0;\n}\nconst transformSWCStripJSX = async (id, code) => {\n const lang = getLang(id);\n if (!lang) return;\n const { transformSync } = await import(\"oxc-transform\");\n const res = transformSync(id, code, {\n lang,\n target: \"es2020\",\n assumptions: {\n setPublicClassFields: true\n },\n sourcemap: shouldSourceMap(),\n jsx: {\n runtime: \"automatic\",\n development: true,\n refresh: false\n }\n });\n if (res.errors?.length) {\n const err = res.errors[0];\n throw new Error(err.message + (err.codeframe ? `\n${err.codeframe}` : \"\"));\n }\n return { code: res.code, map: res.map };\n};\nconst transformOxcStripJSX = transformSWCStripJSX;\nexport {\n shouldSourceMap,\n shouldStripFlow,\n transformOxc,\n transformOxcStripJSX,\n transformSWC,\n transformSWCStripJSX\n};\n//# sourceMappingURL=transformSWC.js.map\n"],"mappings":";;;;;;AAIA,MAAM,WAAW;AACjB,SAAS,gBAAgB,IAAI,MAAM;CACjC,MAAM,WAAW,GAAG,MAAM,GAAG,CAAC,CAAC;CAC/B,IAAI,CAAC,UAAU,KAAK,QAAQ,GAAG,OAAO;CACtC,IAAI,8DAA8D,KAAK,QAAQ,GAAG;EAChF,OAAO;CACT;CACA,MAAM,SAAS,KAAK,MAAM,kEAAkE,CAAC,GAAG,MAAM;CACtG,OAAO,UAAU,KAAK,MAAM,KAAK,+BAA+B,KAAK,IAAI;AAC3E;AACA,eAAe,aAAa,IAAI,MAAM,SAAS,YAAY;CACzD,KAAK,cAAc,GAAG,MAAM,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,QAAQ,cAAc,QAAQ,IAAI,CAAC,GAAG,EAAE;CAC7E,IAAI,SAAS,KAAK,EAAE,GAAG;EACrB;CACF;CACA,IAAI,OAAO,mBAAmB;EAC5B;CACF;CACA,MAAM,OAAO,QAAQ,IAAI,QAAQ,QAAQ;CACzC,IAAI,CAAC,MAAM;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;EACvE,OAAO;CACT;CACA,IAAI,CAAC,WAAW;EACd,OAAO,WAAW,QAAQ;CAC5B;CACA,OAAO,KAAK;AACd;AACA,MAAM,uBAAuB,OAAO,IAAI,SAAS;CAC/C,MAAM,OAAO,QAAQ,EAAE;CACvB,IAAI,CAAC,MAAM;CACX,MAAM,EAAE,kBAAkB,MAAM,OAAO;CACvC,MAAM,MAAM,cAAc,IAAI,MAAM;EAClC;EACA,QAAQ;EACR,aAAa,EACX,sBAAsB,KACxB;EACA,WAAW,gBAAgB;EAC3B,KAAK;GACH,SAAS;GACT,aAAa;GACb,SAAS;EACX;CACF,CAAC;CACD,IAAI,IAAI,QAAQ,QAAQ;EACtB,MAAM,MAAM,IAAI,OAAO;EACvB,MAAM,IAAI,MAAM,IAAI,WAAW,IAAI,YAAY;EACjD,IAAI,cAAc,GAAG;CACrB;CACA,OAAO;EAAE,MAAM,IAAI;EAAM,KAAK,IAAI;CAAI;AACxC;AACA,MAAM,uBAAuB"}
1
+ {"version":3,"file":"transformSWC.js","names":[],"sources":["esm/transformSWC.js"],"sourcesContent":["import { extname } from \"node:path\";\nimport { parseSync } from \"oxc-parser\";\nimport { normalizePath } from \"vite\";\nimport { configuration } from \"./configure\";\nimport { asyncGeneratorRegex, debug, runtimePublicPath } from \"./constants\";\nconst ignoreId = /node_modules\\/(\\.vite|vite)\\//;\nfunction shouldStripFlow(id, code) {\n const filename = id.split(\"?\")[0];\n if (!/\\.jsx?$/.test(filename)) return false;\n const header = code.match(/^(?:#![^\\r\\n]*(?:\\r?\\n|$))?(?:\\s|\\/\\*[\\s\\S]*?\\*\\/|\\/\\/[^\\r\\n]*)*/)?.[0] || \"\";\n const candidate = /node_modules[\\\\/](?:react-native|@react-native)[\\\\/].*\\.js$/.test(filename) || /@flow\\b/.test(header) || /\\b(?:import|export)\\s+type\\b/.test(code) || // Some published Flow sources omit the pragma and use ordinary imports.\n // Typed function returns, declarations, and class fields still need stripping.\n /\\(\\s*(?:\\.\\.\\.)?[\\w$]+\\??\\s*:\\s*/.test(code) || /\\)\\s*:\\s*(?:[\\w$]+(?:<[^;{}]*>)?(?:\\[\\])?\\s*)(?:=>|\\{)/.test(code) || /^\\s*[\\w$]+\\??\\s*:\\s*(?:string|number|boolean|any|mixed|void|[A-Z][\\w$]*)(?:[^;\\r\\n=]*)(?:=[^;\\r\\n]*)?;/m.test(\n code\n ) || /\\b(?:opaque\\s+)?type\\s+[\\w$]+(?:\\s*<[^;{}]*>)?\\s*=/.test(code);\n return candidate && parseSync(filename, code, { lang: \"jsx\" }).errors.length > 0;\n}\nasync function transformSWC(id, code, options, swcOptions) {\n id = normalizePath(id.split(\"?\")[0]).replace(normalizePath(process.cwd()), \"\");\n if (ignoreId.test(id)) {\n return;\n }\n if (id === runtimePublicPath) {\n return;\n }\n const lang = getLang(id, options.forceJSX);\n if (!lang) {\n return;\n }\n const refresh = options.environment !== \"ssr\" && !options.production && !options.noHMR && !options.forceJSX && !id.includes(\"node_modules\");\n const importSource = configuration.enableNativewind && !id.includes(\"node_modules\") ? \"nativewind\" : \"react\";\n const shouldEs5Transform = options.es5 || !process.env.VXRN_USE_BABEL_FOR_GENERATORS && asyncGeneratorRegex.test(code);\n const target = shouldEs5Transform ? \"es2015\" : \"es2020\";\n const sourceMaps = swcOptions?.sourceMaps !== void 0 ? Boolean(swcOptions.sourceMaps) : shouldSourceMap();\n const oxcOptions = {\n lang,\n target,\n assumptions: {\n setPublicClassFields: true,\n ...swcOptions?.assumptions || {}\n },\n sourcemap: sourceMaps,\n jsx: {\n runtime: \"automatic\",\n development: !options.forceJSX && !options.production,\n refresh: Boolean(refresh),\n importSource\n }\n };\n const { transformSync } = await import(\"oxc-transform\");\n const result = (() => {\n try {\n debug?.(\n `transformSWC (oxc) ${id} using options:\n${JSON.stringify(oxcOptions, null, 2)}`\n );\n const res = transformSync(id, code, oxcOptions);\n if (res.errors?.length) {\n const err = res.errors[0];\n const error = new Error(\n err.message + (err.codeframe ? `\n${err.codeframe}` : \"\")\n );\n if (err.labels?.[0]) {\n error.start = err.labels[0].start;\n error.end = err.labels[0].end;\n }\n throw error;\n }\n return {\n code: res.code,\n map: res.map\n };\n } catch (e) {\n throw e;\n }\n })();\n if (configuration.enableNativeCSS) {\n if (result.code.includes(`createInteropElement(`)) {\n result.code = `import { createInteropElement, Fragment as _InteropFragment } from 'react-native-css-interop/jsx-dev-runtime'\n${result.code}`;\n }\n }\n const hasRefreshRuntime = refresh && refreshContentRE.test(result.code);\n if (options.fixNonTypeSpecificImports || id.includes(\"node_modules\") && (lang === \"ts\" || lang === \"tsx\")) {\n const typeExportsMatch = code.match(/^\\s*export\\s+type\\s+([^\\s]+)/gi);\n if (typeExportsMatch) {\n for (const typeExport of Array.from(typeExportsMatch)) {\n const [_export, _type, name] = typeExport.split(/\\s+/);\n if (name.startsWith(\"{\")) continue;\n if (name.includes(\"<\")) continue;\n const alreadyExported = new RegExp(\n `export (const|let|class|function) ${name}\\\\s+`\n ).test(result.code);\n if (!alreadyExported) {\n const fakeExport = `export let ${name} = {};`;\n console.info(\n ` \\u26A0\\uFE0F Fixing non-type-specific import in node_module, this should be fixed upstream: ${fakeExport} in ${id}`\n );\n result.code += `\n${fakeExport}\n`;\n }\n }\n }\n }\n if (result && !options.production && !options.noHMR) {\n return wrapSourceInRefreshRuntime(id, result, options, hasRefreshRuntime);\n }\n return result;\n}\nconst transformOxc = transformSWC;\nfunction wrapSourceInRefreshRuntime(id, result, options, hasRefreshRuntime) {\n if (options.environment === \"ssr\") {\n return result;\n }\n if (options.environment === \"client\") {\n return wrapSourceInRefreshRuntimeWeb(id, result, hasRefreshRuntime);\n }\n return wrapSourceInRefreshRuntimeNative(id, result, options, hasRefreshRuntime);\n}\nfunction wrapSourceInRefreshRuntimeWeb(id, result, hasRefreshRuntime) {\n const sourceMap = result.map ? typeof result.map === \"string\" ? JSON.parse(result.map) : { ...result.map } : void 0;\n if (sourceMap) {\n sourceMap.mappings = \";;\" + sourceMap.mappings;\n }\n result.code = `import * as RefreshRuntime from \"${runtimePublicPath}\";\n\n${result.code}`;\n if (hasRefreshRuntime) {\n if (sourceMap) {\n sourceMap.mappings = \";;;;;;\" + sourceMap.mappings;\n }\n result.code = `if (!window.$RefreshReg$) throw new Error(\"React refresh preamble was not loaded. Something is wrong.\");\nconst prevRefreshReg = window.$RefreshReg$;\nconst prevRefreshSig = window.$RefreshSig$;\nwindow.$RefreshReg$ = RefreshRuntime.getRefreshReg(\"${id}\");\nwindow.$RefreshSig$ = RefreshRuntime.createSignatureFunctionForTransform;\n\n${result.code}\n\nwindow.$RefreshReg$ = prevRefreshReg;\nwindow.$RefreshSig$ = prevRefreshSig;\n`;\n }\n result.code += `\nRefreshRuntime.__hmr_import(import.meta.url).then((currentExports) => {\n RefreshRuntime.registerExportsForReactRefresh(\"${id}\", currentExports);\n import.meta.hot.accept((nextExports) => {\n if (!nextExports) return;\n const invalidateMessage = RefreshRuntime.validateRefreshBoundaryAndEnqueueUpdate(\"${id}\", currentExports, nextExports);\n if (invalidateMessage) import.meta.hot.invalidate(invalidateMessage);\n });\n});\n`;\n return { code: result.code, map: sourceMap };\n}\nfunction wrapSourceInRefreshRuntimeNative(id, result, options, hasRefreshRuntime) {\n const postfixCode = `if (module.hot) {\n if (module.hot.accept) {\n module.hot.accept((nextExports) => {\n RefreshRuntime.performReactRefresh()\n });\n }\n}`;\n if (hasRefreshRuntime) {\n const prefixCode = `const RefreshRuntime = __cachedModules[\"react-refresh/cjs/react-refresh-runtime.development\"];\nconst prevRefreshReg = globalThis.$RefreshReg$;\nconst prevRefreshSig = globalThis.$RefreshSig$ || (() => {\n console.info(\"no react refresh setup!\")\n return (x) => x\n});\nglobalThis.$RefreshReg$ = (type, id) => RefreshRuntime.register(type, \"${id}\" + \" \" + id);\nglobalThis.$RefreshSig$ = RefreshRuntime.createSignatureFunctionForTransform;\nmodule.url = '${id}'\nmodule.hot = createHotContext(module.url)`;\n const sourceMap = result.map ? typeof result.map === \"string\" ? JSON.parse(result.map) : { ...result.map } : void 0;\n if (sourceMap) {\n const prefixLen = prefixCode.split(\"\\n\").length + 1;\n sourceMap.mappings = new Array(prefixLen).fill(\";\").join(\"\") + sourceMap.mappings;\n }\n return {\n code: `${prefixCode}\n${result.code}\n\nif (module.hot) {\n globalThis.$RefreshReg$ = prevRefreshReg;\n globalThis.$RefreshSig$ = prevRefreshSig;\n globalThis['lastHmrExports'] = JSON.stringify(Object.keys(exports))\n}\n\n${postfixCode}\n`,\n map: sourceMap\n };\n }\n result.code += postfixCode;\n return result;\n}\nconst refreshContentRE = /\\$Refresh(?:Reg|Sig)\\$\\(/;\nfunction shouldSourceMap() {\n return process.env.VXRN_ENABLE_SOURCE_MAP === \"1\";\n}\nfunction getLang(id, forceJSX = false) {\n if (id.endsWith(\"one-entry-native\")) {\n return \"tsx\";\n }\n const extension = extname(id);\n if (extension === \".tsx\") return \"tsx\";\n if (extension === \".ts\") return \"ts\";\n if (extension === \".jsx\" || extension === \".mdx\") return \"jsx\";\n if (extension === \".js\" || extension === \".mjs\" || extension === \".cjs\") {\n return \"jsx\";\n }\n if (!extension) {\n return forceJSX ? \"jsx\" : \"js\";\n }\n return void 0;\n}\nconst transformSWCStripJSX = async (id, code) => {\n const lang = getLang(id);\n if (!lang) return;\n const { transformSync } = await import(\"oxc-transform\");\n const res = transformSync(id, code, {\n lang,\n target: \"es2020\",\n assumptions: {\n setPublicClassFields: true\n },\n sourcemap: shouldSourceMap(),\n jsx: {\n runtime: \"automatic\",\n development: true,\n refresh: false\n }\n });\n if (res.errors?.length) {\n const err = res.errors[0];\n throw new Error(err.message + (err.codeframe ? `\n${err.codeframe}` : \"\"));\n }\n return { code: res.code, map: res.map };\n};\nconst transformOxcStripJSX = transformSWCStripJSX;\nexport {\n shouldSourceMap,\n shouldStripFlow,\n transformOxc,\n transformOxcStripJSX,\n transformSWC,\n transformSWCStripJSX\n};\n//# sourceMappingURL=transformSWC.js.map\n"],"mappings":";;;;;;;AAKA,MAAM,WAAW;AACjB,SAAS,gBAAgB,I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M,IAAI,WAAW,IAAI,YAAY;EACjD,IAAI,cAAc,GAAG;CACrB;CACA,OAAO;EAAE,MAAM,IAAI;EAAM,KAAK,IAAI;CAAI;AACxC;AACA,MAAM,uBAAuB"}
@@ -0,0 +1,5 @@
1
+ import { getClosureVariables } from "./worklets/scope.mjs";
2
+ import { JS_GLOBALS } from "./worklets/globals.mjs";
3
+ import { transformHermesLoops } from "./transformHermesLoops.mjs";
4
+
5
+ export { JS_GLOBALS, getClosureVariables, transformHermesLoops };
@@ -216,7 +216,7 @@ function findWorkletCandidates(program) {
216
216
  node: node.method ? node : fn,
217
217
  fnNode: fn,
218
218
  kind: node.method ? "object_method" : fn.type === "ArrowFunctionExpression" ? "arrow_function" : "function_expression",
219
- name: node.key?.name,
219
+ name: node.method ? node.key?.name : fn.id?.name,
220
220
  parent,
221
221
  isAutoWorklet: false
222
222
  });
@@ -261,7 +261,7 @@ function findWorkletCandidates(program) {
261
261
  node: prop.value,
262
262
  fnNode: prop.value,
263
263
  kind: prop.value.type === "ArrowFunctionExpression" ? "arrow_function" : "function_expression",
264
- name: prop.key?.name,
264
+ name: prop.value.id?.name,
265
265
  parent: prop,
266
266
  isAutoWorklet: true
267
267
  });
@@ -1 +1 @@
1
- {"version":3,"file":"autoworklet.js","names":[],"sources":["esm/worklets/autoworklet.js"],"sourcesContent":["const AUTOWORKLET_FUNCTION_ARGS = Object.assign(\n /* @__PURE__ */ Object.create(null),\n {\n useFrameCallback: [0],\n useAnimatedStyle: [0],\n useAnimatedProps: [0],\n createAnimatedPropAdapter: [0],\n useDerivedValue: [0],\n useAnimatedScrollHandler: [0],\n useAnimatedGestureHandler: [0],\n useAnimatedReaction: [0, 1],\n withTiming: [2],\n withSpring: [2],\n withDecay: [1],\n withRepeat: [3],\n runOnUI: [0],\n executeOnUIRuntimeSync: [0],\n scheduleOnUI: [0],\n runOnUISync: [0],\n runOnUIAsync: [0],\n runOnRuntime: [1],\n runOnRuntimeSync: [1],\n runOnRuntimeAsync: [1],\n scheduleOnRuntime: [1],\n runOnRuntimeSyncWithId: [1],\n scheduleOnRuntimeWithId: [1],\n useTapGesture: [0],\n usePanGesture: [0],\n usePinchGesture: [0],\n useRotationGesture: [0],\n useFlingGesture: [0],\n useLongPressGesture: [0],\n useNativeGesture: [0],\n useManualGesture: [0],\n useHoverGesture: [0]\n }\n);\nconst GESTURE_BUILDER_METHODS = /* @__PURE__ */ new Set([\n \"onBegin\",\n \"onStart\",\n \"onEnd\",\n \"onFinalize\",\n \"onUpdate\",\n \"onChange\",\n \"onTouchesDown\",\n \"onTouchesMove\",\n \"onTouchesUp\",\n \"onTouchesCancelled\"\n]);\nconst GESTURE_KINDS = /* @__PURE__ */ new Set([\n \"Tap\",\n \"Pan\",\n \"Pinch\",\n \"Rotation\",\n \"Fling\",\n \"LongPress\",\n \"ForceTouch\",\n \"Native\",\n \"Manual\",\n \"Race\",\n \"Simultaneous\",\n \"Exclusive\",\n \"Hover\"\n]);\nconst LAYOUT_ANIMATIONS = new Set(\n `BounceIn BounceInDown BounceInLeft BounceInRight BounceInUp BounceOut BounceOutDown\n BounceOutLeft BounceOutRight BounceOutUp FadeIn FadeInDown FadeInLeft FadeInRight FadeInUp\n FadeOut FadeOutDown FadeOutLeft FadeOutRight FadeOutUp FlipInEasyX FlipInEasyY FlipInXDown\n FlipInXUp FlipInYLeft FlipInYRight FlipOutEasyX FlipOutEasyY FlipOutXDown FlipOutXUp\n FlipOutYLeft FlipOutYRight LightSpeedInLeft LightSpeedInRight LightSpeedOutLeft\n LightSpeedOutRight PinwheelIn PinwheelOut RollInLeft RollInRight RollOutLeft RollOutRight\n RotateInDownLeft RotateInDownRight RotateInUpLeft RotateInUpRight RotateOutDownLeft\n RotateOutDownRight RotateOutUpLeft RotateOutUpRight SlideInDown SlideInLeft SlideInRight\n SlideInUp SlideOutDown SlideOutLeft SlideOutRight SlideOutUp StretchInX StretchInY\n StretchOutX StretchOutY ZoomIn ZoomInDown ZoomInEasyDown ZoomInEasyUp ZoomInLeft ZoomInRight\n ZoomInRotate ZoomInUp ZoomOut ZoomOutDown ZoomOutEasyDown ZoomOutEasyUp ZoomOutLeft\n ZoomOutRight ZoomOutRotate ZoomOutUp Layout LinearTransition SequencedTransition\n FadingTransition JumpingTransition CurvedTransition EntryExitTransition`.split(/\\s+/)\n);\nconst LAYOUT_ANIMATION_CHAIN_METHODS = /* @__PURE__ */ new Set([\n \"build\",\n \"duration\",\n \"delay\",\n \"getDuration\",\n \"randomDelay\",\n \"getDelay\",\n \"getDelayFunction\",\n \"easing\",\n \"rotate\",\n \"springify\",\n \"damping\",\n \"mass\",\n \"stiffness\",\n \"overshootClamping\",\n \"energyThreshold\",\n \"restDisplacementThreshold\",\n \"restSpeedThreshold\",\n \"withInitialValues\",\n \"getAnimationAndConfig\",\n \"easingX\",\n \"easingY\",\n \"easingWidth\",\n \"easingHeight\",\n \"entering\",\n \"exiting\",\n \"reverse\"\n]);\nfunction isGestureObject(exp) {\n return exp?.type === \"CallExpression\" && exp.callee?.type === \"MemberExpression\" && exp.callee.object?.type === \"Identifier\" && exp.callee.object.name === \"Gesture\" && exp.callee.property?.type === \"Identifier\" && GESTURE_KINDS.has(exp.callee.property.name);\n}\nfunction containsGestureObject(exp) {\n if (isGestureObject(exp)) return true;\n return exp?.type === \"CallExpression\" && exp.callee?.type === \"MemberExpression\" && containsGestureObject(exp.callee.object);\n}\nfunction isLayoutAnimationChain(exp) {\n if (exp?.type === \"Identifier\" && LAYOUT_ANIMATIONS.has(exp.name)) return true;\n if (exp?.type === \"NewExpression\" && exp.callee?.type === \"Identifier\" && LAYOUT_ANIMATIONS.has(exp.callee.name)) {\n return true;\n }\n return exp?.type === \"CallExpression\" && exp.callee?.type === \"MemberExpression\" && exp.callee.property?.type === \"Identifier\" && LAYOUT_ANIMATION_CHAIN_METHODS.has(exp.callee.property.name) && isLayoutAnimationChain(exp.callee.object);\n}\nfunction isChainedCallback(callee) {\n if (callee?.type !== \"MemberExpression\" || callee.property?.type !== \"Identifier\") {\n return false;\n }\n const name = callee.property.name;\n if (GESTURE_BUILDER_METHODS.has(name)) return containsGestureObject(callee.object);\n if (name === \"withCallback\") return isLayoutAnimationChain(callee.object);\n return false;\n}\nconst WORKLET_DIRECTIVES = [\n \"worklet\",\n \"no-worklet-closure\",\n \"limit-init-data-hoisting\"\n];\nfunction statementDirective(stmt) {\n if (!stmt || stmt.type !== \"ExpressionStatement\") return void 0;\n if (typeof stmt.directive === \"string\") return stmt.directive;\n if (stmt.expression?.type === \"Literal\" && typeof stmt.expression.value === \"string\") {\n return stmt.expression.value;\n }\n return void 0;\n}\nfunction hasDirective(fnNode, directive) {\n if (!fnNode || !fnNode.body) return false;\n if (Array.isArray(fnNode.body.directives)) {\n for (const d of fnNode.body.directives) {\n if (d.directive === directive || d.value === directive) {\n return true;\n }\n }\n }\n if (fnNode.body.type === \"BlockStatement\" && Array.isArray(fnNode.body.body)) {\n for (const stmt of fnNode.body.body) {\n const found = statementDirective(stmt);\n if (found === void 0) break;\n if (found === directive) return true;\n }\n }\n return false;\n}\nfunction hasWorkletDirective(fnNode) {\n return hasDirective(fnNode, \"worklet\");\n}\nfunction bodyStartAfterDirectives(fnNode, code) {\n let start = fnNode.body.start + 1;\n if (fnNode.body.type !== \"BlockStatement\" || !Array.isArray(fnNode.body.body))\n return start;\n for (const stmt of fnNode.body.body) {\n const found = statementDirective(stmt);\n if (found === void 0 || !WORKLET_DIRECTIVES.includes(found)) break;\n start = stmt.end;\n while (start < fnNode.body.end && (code[start] === \";\" || /\\s/.test(code[start]))) {\n start++;\n }\n }\n return start;\n}\nfunction findWorkletCandidates(program) {\n const candidates = [];\n const seenStarts = /* @__PURE__ */ new Set();\n function addCandidate(candidate) {\n const fnStart = candidate.fnNode.start;\n if (seenStarts.has(fnStart)) return;\n seenStarts.add(fnStart);\n candidates.push(candidate);\n }\n function getCalleeName(callee) {\n if (!callee) return null;\n if (callee.type === \"Identifier\") {\n return callee.name;\n }\n if (callee.type === \"MemberExpression\" && !callee.computed && callee.property?.type === \"Identifier\") {\n return callee.property.name;\n }\n return null;\n }\n function walk(node, parent) {\n if (!node || typeof node !== \"object\") return;\n if (node.type === \"FunctionDeclaration\" || node.type === \"FunctionExpression\" || node.type === \"ArrowFunctionExpression\") {\n if (hasWorkletDirective(node)) {\n let kind = \"function_expression\";\n if (node.type === \"FunctionDeclaration\") kind = \"function_declaration\";\n else if (node.type === \"ArrowFunctionExpression\") kind = \"arrow_function\";\n let name = node.id?.name;\n if (!name && parent?.type === \"VariableDeclarator\" && parent.id?.name) {\n name = parent.id.name;\n }\n addCandidate({\n node,\n fnNode: node,\n kind,\n name,\n parent,\n isAutoWorklet: false\n });\n }\n } else if (node.type === \"Property\" && (node.method || node.value?.type === \"FunctionExpression\" || node.value?.type === \"ArrowFunctionExpression\")) {\n const fn = node.value;\n if (hasWorkletDirective(fn)) {\n addCandidate({\n node: node.method ? node : fn,\n fnNode: fn,\n kind: node.method ? \"object_method\" : fn.type === \"ArrowFunctionExpression\" ? \"arrow_function\" : \"function_expression\",\n name: node.key?.name,\n parent,\n isAutoWorklet: false\n });\n }\n }\n if (node.type === \"CallExpression\") {\n const calleeName = getCalleeName(node.callee);\n const argIndices = calleeName ? AUTOWORKLET_FUNCTION_ARGS[calleeName] : void 0;\n const chained = !argIndices && isChainedCallback(node.callee);\n const indices = argIndices ?? (chained ? node.arguments.map((_, i) => i) : void 0);\n if (indices) {\n for (const idx of indices) {\n const arg = node.arguments[idx];\n if (!arg) continue;\n if (arg.type === \"ArrowFunctionExpression\" || arg.type === \"FunctionExpression\") {\n let name = arg.id?.name;\n if (!name && parent?.type === \"VariableDeclarator\" && parent.id?.name) {\n name = parent.id.name;\n }\n addCandidate({\n node: arg,\n fnNode: arg,\n kind: arg.type === \"ArrowFunctionExpression\" ? \"arrow_function\" : \"function_expression\",\n name,\n parent: node,\n isAutoWorklet: true\n });\n } else if (arg.type === \"ObjectExpression\" && Array.isArray(arg.properties)) {\n for (const prop of arg.properties) {\n if (prop.type === \"Property\") {\n if (prop.method) {\n addCandidate({\n node: prop,\n fnNode: prop.value,\n kind: \"object_method\",\n name: prop.key?.name,\n parent: arg,\n isAutoWorklet: true\n });\n } else if (prop.value?.type === \"ArrowFunctionExpression\" || prop.value?.type === \"FunctionExpression\") {\n addCandidate({\n node: prop.value,\n fnNode: prop.value,\n kind: prop.value.type === \"ArrowFunctionExpression\" ? \"arrow_function\" : \"function_expression\",\n name: prop.key?.name,\n parent: prop,\n isAutoWorklet: true\n });\n }\n }\n }\n }\n }\n }\n }\n for (const key of Object.keys(node)) {\n if (key === \"start\" || key === \"end\" || key === \"loc\" || key === \"range\") continue;\n const child = node[key];\n if (Array.isArray(child)) {\n for (const item of child) {\n walk(item, node);\n }\n } else if (child && typeof child === \"object\") {\n walk(child, node);\n }\n }\n }\n walk(program, null);\n return candidates;\n}\nexport {\n AUTOWORKLET_FUNCTION_ARGS,\n GESTURE_BUILDER_METHODS,\n WORKLET_DIRECTIVES,\n bodyStartAfterDirectives,\n findWorkletCandidates,\n hasDirective,\n hasWorkletDirective\n};\n//# sourceMappingURL=autoworklet.js.map\n"],"mappings":";AAAA,MAAM,4BAA4B,OAAO,OACvB,uBAAO,OAAO,IAAI,GAClC;CACE,kBAAkB,CAAC,CAAC;CACpB,kBAAkB,CAAC,CAAC;CACpB,kBAAkB,CAAC,CAAC;CACpB,2BAA2B,CAAC,CAAC;CAC7B,iBAAiB,CAAC,CAAC;CACnB,0BAA0B,CAAC,CAAC;CAC5B,2BAA2B,CAAC,CAAC;CAC7B,qBAAqB,CAAC,GAAG,CAAC;CAC1B,YAAY,CAAC,CAAC;CACd,YAAY,CAAC,CAAC;CACd,WAAW,CAAC,CAAC;CACb,YAAY,CAAC,CAAC;CACd,SAAS,CAAC,CAAC;CACX,wBAAwB,CAAC,CAAC;CAC1B,cAAc,CAAC,CAAC;CAChB,aAAa,CAAC,CAAC;CACf,cAAc,CAAC,CAAC;CAChB,cAAc,CAAC,CAAC;CAChB,kBAAkB,CAAC,CAAC;CAC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,MAAM,IAAI,SAAS,4BAA4B,mBAAmB;OAClE;OACA,QAAQ;OACR,eAAe;MACjB,CAAC;KACH,OAAO,IAAI,IAAI,SAAS,sBAAsB,MAAM,QAAQ,IAAI,UAAU,GAAG;MAC3E,KAAK,MAAM,QAAQ,IAAI,YAAY;OACjC,IAAI,KAAK,SAAS,YAAY;QAC5B,IAAI,KAAK,QAAQ;SACf,aAAa;UACX,MAAM;UACN,QAAQ,KAAK;UACb,MAAM;UACN,MAAM,KAAK,KAAK;UAChB,QAAQ;UACR,eAAe;SACjB,CAAC;QACH,OAAO,IAAI,KAAK,OAAO,SAAS,6BAA6B,KAAK,OAAO,SAAS,sBAAsB;SACtG,aAAa;UACX,MAAM,KAAK;UACX,QAAQ,KAAK;UACb,MAAM,KAAK,MAAM,SAAS,4BAA4B,mBAAmB;UACzE,MAAM,KAAK,KAAK;UAChB,QAAQ;UACR,eAAe;SACjB,CAAC;QACH;OACF;MACF;KACF;IACF;GACF;EACF;EACA,KAAK,MAAM,OAAO,OAAO,KAAK,IAAI,GAAG;GACnC,IAAI,QAAQ,WAAW,QAAQ,SAAS,QAAQ,SAAS,QAAQ,SAAS;GAC1E,MAAM,QAAQ,KAAK;GACnB,IAAI,MAAM,QAAQ,KAAK,GAAG;IACxB,KAAK,MAAM,QAAQ,OAAO;KACxB,KAAK,MAAM,IAAI;IACjB;GACF,OAAO,IAAI,SAAS,OAAO,UAAU,UAAU;IAC7C,KAAK,OAAO,IAAI;GAClB;EACF;CACF;CACA,KAAK,SAAS,IAAI;CAClB,OAAO;AACT"}
1
+ {"version":3,"file":"autoworklet.js","names":[],"sources":["esm/worklets/autoworklet.js"],"sourcesContent":["const AUTOWORKLET_FUNCTION_ARGS = Object.assign(\n /* @__PURE__ */ Object.create(null),\n {\n useFrameCallback: [0],\n useAnimatedStyle: [0],\n useAnimatedProps: [0],\n createAnimatedPropAdapter: [0],\n useDerivedValue: [0],\n useAnimatedScrollHandler: [0],\n useAnimatedGestureHandler: [0],\n useAnimatedReaction: [0, 1],\n withTiming: [2],\n withSpring: [2],\n withDecay: [1],\n withRepeat: [3],\n runOnUI: [0],\n executeOnUIRuntimeSync: [0],\n scheduleOnUI: [0],\n runOnUISync: [0],\n runOnUIAsync: [0],\n runOnRuntime: [1],\n runOnRuntimeSync: [1],\n runOnRuntimeAsync: [1],\n scheduleOnRuntime: [1],\n runOnRuntimeSyncWithId: [1],\n scheduleOnRuntimeWithId: [1],\n useTapGesture: [0],\n usePanGesture: [0],\n usePinchGesture: [0],\n useRotationGesture: [0],\n useFlingGesture: [0],\n useLongPressGesture: [0],\n useNativeGesture: [0],\n useManualGesture: [0],\n useHoverGesture: [0]\n }\n);\nconst GESTURE_BUILDER_METHODS = /* @__PURE__ */ new Set([\n \"onBegin\",\n \"onStart\",\n \"onEnd\",\n \"onFinalize\",\n \"onUpdate\",\n \"onChange\",\n \"onTouchesDown\",\n \"onTouchesMove\",\n \"onTouchesUp\",\n \"onTouchesCancelled\"\n]);\nconst GESTURE_KINDS = /* @__PURE__ */ new Set([\n \"Tap\",\n \"Pan\",\n \"Pinch\",\n \"Rotation\",\n \"Fling\",\n \"LongPress\",\n \"ForceTouch\",\n \"Native\",\n \"Manual\",\n \"Race\",\n \"Simultaneous\",\n \"Exclusive\",\n \"Hover\"\n]);\nconst LAYOUT_ANIMATIONS = new Set(\n `BounceIn BounceInDown BounceInLeft BounceInRight BounceInUp BounceOut BounceOutDown\n BounceOutLeft BounceOutRight BounceOutUp FadeIn FadeInDown FadeInLeft FadeInRight FadeInUp\n FadeOut FadeOutDown FadeOutLeft FadeOutRight FadeOutUp FlipInEasyX FlipInEasyY FlipInXDown\n FlipInXUp FlipInYLeft FlipInYRight FlipOutEasyX FlipOutEasyY FlipOutXDown FlipOutXUp\n FlipOutYLeft FlipOutYRight LightSpeedInLeft LightSpeedInRight LightSpeedOutLeft\n LightSpeedOutRight PinwheelIn PinwheelOut RollInLeft RollInRight RollOutLeft RollOutRight\n RotateInDownLeft RotateInDownRight RotateInUpLeft RotateInUpRight RotateOutDownLeft\n RotateOutDownRight RotateOutUpLeft RotateOutUpRight SlideInDown SlideInLeft SlideInRight\n SlideInUp SlideOutDown SlideOutLeft SlideOutRight SlideOutUp StretchInX StretchInY\n StretchOutX StretchOutY ZoomIn ZoomInDown ZoomInEasyDown ZoomInEasyUp ZoomInLeft ZoomInRight\n ZoomInRotate ZoomInUp ZoomOut ZoomOutDown ZoomOutEasyDown ZoomOutEasyUp ZoomOutLeft\n ZoomOutRight ZoomOutRotate ZoomOutUp Layout LinearTransition SequencedTransition\n FadingTransition JumpingTransition CurvedTransition EntryExitTransition`.split(/\\s+/)\n);\nconst LAYOUT_ANIMATION_CHAIN_METHODS = /* @__PURE__ */ new Set([\n \"build\",\n \"duration\",\n \"delay\",\n \"getDuration\",\n \"randomDelay\",\n \"getDelay\",\n \"getDelayFunction\",\n \"easing\",\n \"rotate\",\n \"springify\",\n \"damping\",\n \"mass\",\n \"stiffness\",\n \"overshootClamping\",\n \"energyThreshold\",\n \"restDisplacementThreshold\",\n \"restSpeedThreshold\",\n \"withInitialValues\",\n \"getAnimationAndConfig\",\n \"easingX\",\n \"easingY\",\n \"easingWidth\",\n \"easingHeight\",\n \"entering\",\n \"exiting\",\n \"reverse\"\n]);\nfunction isGestureObject(exp) {\n return exp?.type === \"CallExpression\" && exp.callee?.type === \"MemberExpression\" && exp.callee.object?.type === \"Identifier\" && exp.callee.object.name === \"Gesture\" && exp.callee.property?.type === \"Identifier\" && GESTURE_KINDS.has(exp.callee.property.name);\n}\nfunction containsGestureObject(exp) {\n if (isGestureObject(exp)) return true;\n return exp?.type === \"CallExpression\" && exp.callee?.type === \"MemberExpression\" && containsGestureObject(exp.callee.object);\n}\nfunction isLayoutAnimationChain(exp) {\n if (exp?.type === \"Identifier\" && LAYOUT_ANIMATIONS.has(exp.name)) return true;\n if (exp?.type === \"NewExpression\" && exp.callee?.type === \"Identifier\" && LAYOUT_ANIMATIONS.has(exp.callee.name)) {\n return true;\n }\n return exp?.type === \"CallExpression\" && exp.callee?.type === \"MemberExpression\" && exp.callee.property?.type === \"Identifier\" && LAYOUT_ANIMATION_CHAIN_METHODS.has(exp.callee.property.name) && isLayoutAnimationChain(exp.callee.object);\n}\nfunction isChainedCallback(callee) {\n if (callee?.type !== \"MemberExpression\" || callee.property?.type !== \"Identifier\") {\n return false;\n }\n const name = callee.property.name;\n if (GESTURE_BUILDER_METHODS.has(name)) return containsGestureObject(callee.object);\n if (name === \"withCallback\") return isLayoutAnimationChain(callee.object);\n return false;\n}\nconst WORKLET_DIRECTIVES = [\n \"worklet\",\n \"no-worklet-closure\",\n \"limit-init-data-hoisting\"\n];\nfunction statementDirective(stmt) {\n if (!stmt || stmt.type !== \"ExpressionStatement\") return void 0;\n if (typeof stmt.directive === \"string\") return stmt.directive;\n if (stmt.expression?.type === \"Literal\" && typeof stmt.expression.value === \"string\") {\n return stmt.expression.value;\n }\n return void 0;\n}\nfunction hasDirective(fnNode, directive) {\n if (!fnNode || !fnNode.body) return false;\n if (Array.isArray(fnNode.body.directives)) {\n for (const d of fnNode.body.directives) {\n if (d.directive === directive || d.value === directive) {\n return true;\n }\n }\n }\n if (fnNode.body.type === \"BlockStatement\" && Array.isArray(fnNode.body.body)) {\n for (const stmt of fnNode.body.body) {\n const found = statementDirective(stmt);\n if (found === void 0) break;\n if (found === directive) return true;\n }\n }\n return false;\n}\nfunction hasWorkletDirective(fnNode) {\n return hasDirective(fnNode, \"worklet\");\n}\nfunction bodyStartAfterDirectives(fnNode, code) {\n let start = fnNode.body.start + 1;\n if (fnNode.body.type !== \"BlockStatement\" || !Array.isArray(fnNode.body.body))\n return start;\n for (const stmt of fnNode.body.body) {\n const found = statementDirective(stmt);\n if (found === void 0 || !WORKLET_DIRECTIVES.includes(found)) break;\n start = stmt.end;\n while (start < fnNode.body.end && (code[start] === \";\" || /\\s/.test(code[start]))) {\n start++;\n }\n }\n return start;\n}\nfunction findWorkletCandidates(program) {\n const candidates = [];\n const seenStarts = /* @__PURE__ */ new Set();\n function addCandidate(candidate) {\n const fnStart = candidate.fnNode.start;\n if (seenStarts.has(fnStart)) return;\n seenStarts.add(fnStart);\n candidates.push(candidate);\n }\n function getCalleeName(callee) {\n if (!callee) return null;\n if (callee.type === \"Identifier\") {\n return callee.name;\n }\n if (callee.type === \"MemberExpression\" && !callee.computed && callee.property?.type === \"Identifier\") {\n return callee.property.name;\n }\n return null;\n }\n function walk(node, parent) {\n if (!node || typeof node !== \"object\") return;\n if (node.type === \"FunctionDeclaration\" || node.type === \"FunctionExpression\" || node.type === \"ArrowFunctionExpression\") {\n if (hasWorkletDirective(node)) {\n let kind = \"function_expression\";\n if (node.type === \"FunctionDeclaration\") kind = \"function_declaration\";\n else if (node.type === \"ArrowFunctionExpression\") kind = \"arrow_function\";\n let name = node.id?.name;\n if (!name && parent?.type === \"VariableDeclarator\" && parent.id?.name) {\n name = parent.id.name;\n }\n addCandidate({\n node,\n fnNode: node,\n kind,\n name,\n parent,\n isAutoWorklet: false\n });\n }\n } else if (node.type === \"Property\" && (node.method || node.value?.type === \"FunctionExpression\" || node.value?.type === \"ArrowFunctionExpression\")) {\n const fn = node.value;\n if (hasWorkletDirective(fn)) {\n addCandidate({\n node: node.method ? node : fn,\n fnNode: fn,\n kind: node.method ? \"object_method\" : fn.type === \"ArrowFunctionExpression\" ? \"arrow_function\" : \"function_expression\",\n // only a method is named by its key, as upstream's plugin does: a\n // property's function has no binding of that name, so naming it would\n // shadow an outer binding it closes over with the worklet itself.\n name: node.method ? node.key?.name : fn.id?.name,\n parent,\n isAutoWorklet: false\n });\n }\n }\n if (node.type === \"CallExpression\") {\n const calleeName = getCalleeName(node.callee);\n const argIndices = calleeName ? AUTOWORKLET_FUNCTION_ARGS[calleeName] : void 0;\n const chained = !argIndices && isChainedCallback(node.callee);\n const indices = argIndices ?? (chained ? node.arguments.map((_, i) => i) : void 0);\n if (indices) {\n for (const idx of indices) {\n const arg = node.arguments[idx];\n if (!arg) continue;\n if (arg.type === \"ArrowFunctionExpression\" || arg.type === \"FunctionExpression\") {\n let name = arg.id?.name;\n if (!name && parent?.type === \"VariableDeclarator\" && parent.id?.name) {\n name = parent.id.name;\n }\n addCandidate({\n node: arg,\n fnNode: arg,\n kind: arg.type === \"ArrowFunctionExpression\" ? \"arrow_function\" : \"function_expression\",\n name,\n parent: node,\n isAutoWorklet: true\n });\n } else if (arg.type === \"ObjectExpression\" && Array.isArray(arg.properties)) {\n for (const prop of arg.properties) {\n if (prop.type === \"Property\") {\n if (prop.method) {\n addCandidate({\n node: prop,\n fnNode: prop.value,\n kind: \"object_method\",\n name: prop.key?.name,\n parent: arg,\n isAutoWorklet: true\n });\n } else if (prop.value?.type === \"ArrowFunctionExpression\" || prop.value?.type === \"FunctionExpression\") {\n addCandidate({\n node: prop.value,\n fnNode: prop.value,\n kind: prop.value.type === \"ArrowFunctionExpression\" ? \"arrow_function\" : \"function_expression\",\n name: prop.value.id?.name,\n parent: prop,\n isAutoWorklet: true\n });\n }\n }\n }\n }\n }\n }\n }\n for (const key of Object.keys(node)) {\n if (key === \"start\" || key === \"end\" || key === \"loc\" || key === \"range\") continue;\n const child = node[key];\n if (Array.isArray(child)) {\n for (const item of child) {\n walk(item, node);\n }\n } else if (child && typeof child === \"object\") {\n walk(child, node);\n }\n }\n }\n walk(program, null);\n return candidates;\n}\nexport {\n AUTOWORKLET_FUNCTION_ARGS,\n GESTURE_BUILDER_METHODS,\n WORKLET_DIRECTIVES,\n bodyStartAfterDirectives,\n findWorkletCandidates,\n hasDirective,\n hasWorkletDirective\n};\n//# sourceMappingURL=autoworklet.js.map\n"],"mappings":";AAAA,MAAM,4BAA4B,OAAO,OACvB,uBAAO,OAAO,IAAI,GAClC;CACE,kBAAkB,CAAC,CAAC;CACpB,kBAAkB,CAAC,CAAC;CACpB,kBAAkB,CAAC,CAAC;CACpB,2BAA2B,CAAC,CAAC;CAC7B,iBAAiB,CAAC,CAAC;CACnB,0BAA0B,CAAC,CAAC;CAC5B,2BAA2B,CAAC,CA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C,KAAK,OAAO,IAAI;GAClB;EACF;CACF;CACA,KAAK,SAAS,IAAI;CAClB,OAAO;AACT"}
@@ -92,7 +92,28 @@ const DEFAULT_GLOBALS = /* @__PURE__ */ new Set([
92
92
  "setInterval",
93
93
  "clearInterval",
94
94
  "HermesInternal",
95
- "_WORKLET"
95
+ "_WORKLET",
96
+ "ReanimatedError",
97
+ "__reanimatedLoggerConfig",
98
+ "_IS_FABRIC",
99
+ "_log",
100
+ "_toString",
101
+ "_scheduleHostFunctionOnJS",
102
+ "_scheduleRemoteFunctionOnJS",
103
+ "_scheduleOnRuntime",
104
+ "_makeShareableClone",
105
+ "_updatePropsPaper",
106
+ "_updatePropsFabric",
107
+ "_measurePaper",
108
+ "_measureFabric",
109
+ "_scrollToPaper",
110
+ "_dispatchCommandPaper",
111
+ "_dispatchCommandFabric",
112
+ "_setGestureState",
113
+ "_notifyAboutProgress",
114
+ "_notifyAboutEnd",
115
+ "_runOnUIQueue",
116
+ "_getAnimationTimestamp"
96
117
  ]);
97
118
  function createGlobalsSet(customGlobals, strictGlobal) {
98
119
  const set = /* @__PURE__ */ new Set();
@@ -1 +1 @@
1
- {"version":3,"file":"globals.js","names":[],"sources":["esm/worklets/globals.js"],"sourcesContent":["const JS_GLOBALS = /* @__PURE__ */ new Set([\n // Value properties\n \"globalThis\",\n \"Infinity\",\n \"NaN\",\n \"undefined\",\n // Function properties\n \"eval\",\n \"isFinite\",\n \"isNaN\",\n \"parseFloat\",\n \"parseInt\",\n \"decodeURI\",\n \"decodeURIComponent\",\n \"encodeURI\",\n \"encodeURIComponent\",\n \"escape\",\n \"unescape\",\n // Fundamental objects\n \"Object\",\n \"Function\",\n \"Boolean\",\n \"Symbol\",\n // Error objects\n \"Error\",\n \"AggregateError\",\n \"EvalError\",\n \"RangeError\",\n \"ReferenceError\",\n \"SyntaxError\",\n \"TypeError\",\n \"URIError\",\n \"InternalError\",\n // Numbers and dates\n \"Number\",\n \"BigInt\",\n \"Math\",\n \"Date\",\n // Text processing\n \"String\",\n \"RegExp\",\n // Indexed collections\n \"Array\",\n \"Int8Array\",\n \"Uint8Array\",\n \"Uint8ClampedArray\",\n \"Int16Array\",\n \"Uint16Array\",\n \"Int32Array\",\n \"Uint32Array\",\n \"BigInt64Array\",\n \"BigUint64Array\",\n \"Float32Array\",\n \"Float64Array\",\n // Keyed collections\n \"Map\",\n \"Set\",\n \"WeakMap\",\n \"WeakSet\",\n // Structured data\n \"ArrayBuffer\",\n \"SharedArrayBuffer\",\n \"DataView\",\n \"Atomics\",\n \"JSON\",\n // Managing memory\n \"WeakRef\",\n \"FinalizationRegistry\",\n // Control abstraction objects\n \"Iterator\",\n \"AsyncIterator\",\n \"Promise\",\n \"GeneratorFunction\",\n \"AsyncGeneratorFunction\",\n \"Generator\",\n \"AsyncGenerator\",\n \"AsyncFunction\",\n // Reflection\n \"Reflect\",\n \"Proxy\",\n // Internationalization\n \"Intl\"\n]);\nconst DEFAULT_GLOBALS = /* @__PURE__ */ new Set([\n ...JS_GLOBALS,\n // Environment / Runtime\n \"null\",\n \"this\",\n \"global\",\n \"window\",\n \"self\",\n \"console\",\n \"performance\",\n \"arguments\",\n \"require\",\n \"fetch\",\n \"XMLHttpRequest\",\n \"WebSocket\",\n \"queueMicrotask\",\n \"requestAnimationFrame\",\n \"cancelAnimationFrame\",\n \"setTimeout\",\n \"clearTimeout\",\n \"setImmediate\",\n \"clearImmediate\",\n \"setInterval\",\n \"clearInterval\",\n \"HermesInternal\",\n \"_WORKLET\"\n]);\nfunction createGlobalsSet(customGlobals, strictGlobal) {\n const set = /* @__PURE__ */ new Set();\n if (!strictGlobal) {\n for (const g of DEFAULT_GLOBALS) {\n set.add(g);\n }\n }\n if (customGlobals) {\n for (const g of customGlobals) {\n set.add(g);\n }\n }\n return set;\n}\nexport {\n DEFAULT_GLOBALS,\n JS_GLOBALS,\n createGlobalsSet\n};\n//# sourceMappingURL=globals.js.map\n"],"mappings":";AAAA,MAAM,6BAA6B,IAAI,IAAI;CAEzC;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CAEA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CAEA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CAEA;AACF,CAAC;AACD,MAAM,kCAAkC,IAAI,IAAI;CAC9C,GAAG;CAEH;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AACD,SAAS,iBAAiB,eAAe,cAAc;CACrD,MAAM,sBAAsB,IAAI,IAAI;CACpC,IAAI,CAAC,cAAc;EACjB,KAAK,MAAM,KAAK,iBAAiB;GAC/B,IAAI,IAAI,CAAC;EACX;CACF;CACA,IAAI,eAAe;EACjB,KAAK,MAAM,KAAK,eAAe;GAC7B,IAAI,IAAI,CAAC;EACX;CACF;CACA,OAAO;AACT"}
1
+ {"version":3,"file":"globals.js","names":[],"sources":["esm/worklets/globals.js"],"sourcesContent":["const JS_GLOBALS = /* @__PURE__ */ new Set([\n // Value properties\n \"globalThis\",\n \"Infinity\",\n \"NaN\",\n \"undefined\",\n // Function properties\n \"eval\",\n \"isFinite\",\n \"isNaN\",\n \"parseFloat\",\n \"parseInt\",\n \"decodeURI\",\n \"decodeURIComponent\",\n \"encodeURI\",\n \"encodeURIComponent\",\n \"escape\",\n \"unescape\",\n // Fundamental objects\n \"Object\",\n \"Function\",\n \"Boolean\",\n \"Symbol\",\n // Error objects\n \"Error\",\n \"AggregateError\",\n \"EvalError\",\n \"RangeError\",\n \"ReferenceError\",\n \"SyntaxError\",\n \"TypeError\",\n \"URIError\",\n \"InternalError\",\n // Numbers and dates\n \"Number\",\n \"BigInt\",\n \"Math\",\n \"Date\",\n // Text processing\n \"String\",\n \"RegExp\",\n // Indexed collections\n \"Array\",\n \"Int8Array\",\n \"Uint8Array\",\n \"Uint8ClampedArray\",\n \"Int16Array\",\n \"Uint16Array\",\n \"Int32Array\",\n \"Uint32Array\",\n \"BigInt64Array\",\n \"BigUint64Array\",\n \"Float32Array\",\n \"Float64Array\",\n // Keyed collections\n \"Map\",\n \"Set\",\n \"WeakMap\",\n \"WeakSet\",\n // Structured data\n \"ArrayBuffer\",\n \"SharedArrayBuffer\",\n \"DataView\",\n \"Atomics\",\n \"JSON\",\n // Managing memory\n \"WeakRef\",\n \"FinalizationRegistry\",\n // Control abstraction objects\n \"Iterator\",\n \"AsyncIterator\",\n \"Promise\",\n \"GeneratorFunction\",\n \"AsyncGeneratorFunction\",\n \"Generator\",\n \"AsyncGenerator\",\n \"AsyncFunction\",\n // Reflection\n \"Reflect\",\n \"Proxy\",\n // Internationalization\n \"Intl\"\n]);\nconst DEFAULT_GLOBALS = /* @__PURE__ */ new Set([\n ...JS_GLOBALS,\n // Environment / Runtime\n \"null\",\n \"this\",\n \"global\",\n \"window\",\n \"self\",\n \"console\",\n \"performance\",\n \"arguments\",\n \"require\",\n \"fetch\",\n \"XMLHttpRequest\",\n \"WebSocket\",\n \"queueMicrotask\",\n \"requestAnimationFrame\",\n \"cancelAnimationFrame\",\n \"setTimeout\",\n \"clearTimeout\",\n \"setImmediate\",\n \"clearImmediate\",\n \"setInterval\",\n \"clearInterval\",\n \"HermesInternal\",\n \"_WORKLET\",\n // Reanimated installs these in the UI runtime. Capturing them on the JS\n // thread fails before its value unpacker can initialize (Reanimated 3).\n \"ReanimatedError\",\n \"__reanimatedLoggerConfig\",\n \"_IS_FABRIC\",\n \"_log\",\n \"_toString\",\n \"_scheduleHostFunctionOnJS\",\n \"_scheduleRemoteFunctionOnJS\",\n \"_scheduleOnRuntime\",\n \"_makeShareableClone\",\n \"_updatePropsPaper\",\n \"_updatePropsFabric\",\n \"_measurePaper\",\n \"_measureFabric\",\n \"_scrollToPaper\",\n \"_dispatchCommandPaper\",\n \"_dispatchCommandFabric\",\n \"_setGestureState\",\n \"_notifyAboutProgress\",\n \"_notifyAboutEnd\",\n \"_runOnUIQueue\",\n \"_getAnimationTimestamp\"\n]);\nfunction createGlobalsSet(customGlobals, strictGlobal) {\n const set = /* @__PURE__ */ new Set();\n if (!strictGlobal) {\n for (const g of DEFAULT_GLOBALS) {\n set.add(g);\n }\n }\n if (customGlobals) {\n for (const g of customGlobals) {\n set.add(g);\n }\n }\n return set;\n}\nexport {\n DEFAULT_GLOBALS,\n JS_GLOBALS,\n createGlobalsSet\n};\n//# sourceMappingURL=globals.js.map\n"],"mappings":";AAAA,MAAM,6BAA6B,IAAI,IAAI;CAEzC;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CAEA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CAEA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CAEA;AACF,CAAC;AACD,MAAM,kCAAkC,IAAI,IAAI;CAC9C,GAAG;CAEH;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAGA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AACD,SAAS,iBAAiB,eAAe,cAAc;CACrD,MAAM,sBAAsB,IAAI,IAAI;CACpC,IAAI,CAAC,cAAc;EACjB,KAAK,MAAM,KAAK,iBAAiB;GAC/B,IAAI,IAAI,CAAC;EACX;CACF;CACA,IAAI,eAAe;EACjB,KAAK,MAAM,KAAK,eAAe;GAC7B,IAAI,IAAI,CAAC;EACX;CACF;CACA,OAAO;AACT"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vxrn/compiler",
3
- "version": "2.0.0-beta.98.1",
3
+ "version": "2.6.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  "./package.json": "./package.json",
@@ -8,6 +8,11 @@
8
8
  "types": "./types/index.d.ts",
9
9
  "import": "./dist/esm/index.mjs",
10
10
  "require": "./dist/cjs/index.cjs"
11
+ },
12
+ "./worklet-utils": {
13
+ "types": "./types/workletUtils.d.ts",
14
+ "import": "./dist/esm/workletUtils.mjs",
15
+ "require": "./dist/cjs/workletUtils.cjs"
11
16
  }
12
17
  },
13
18
  "main": "dist/cjs",
@@ -36,8 +41,10 @@
36
41
  "@babel/plugin-transform-react-jsx": "^7.27.1",
37
42
  "@babel/plugin-transform-regenerator": "^7.28.4",
38
43
  "@jridgewell/remapping": "^2.3.0",
39
- "@vxrn/utils": "2.0.0-beta.98.1",
40
- "@vxrn/vite-native-client": "2.0.0-beta.98.1",
44
+ "@swc/core": "1.16.18",
45
+ "@vxrn/utils": "2.6.0",
46
+ "@vxrn/vite-native-client": "2.6.0",
47
+ "astring": "1.9.0",
41
48
  "babel-plugin-react-compiler": "^1.0.0",
42
49
  "babel-plugin-syntax-hermes-parser": "^0.36.1",
43
50
  "babel-plugin-transform-flow-enums": "^0.0.2",
@@ -51,7 +58,7 @@
51
58
  },
52
59
  "devDependencies": {
53
60
  "@jridgewell/trace-mapping": "^0.3.25",
54
- "@tamagui/build": "3.0.0-beta.1432.1",
61
+ "@tamagui/build": "3.0.3",
55
62
  "depcheck": "^1.4.7",
56
63
  "rolldown": "^1.2.8",
57
64
  "vite": "^8.2.2",
@@ -68,6 +75,7 @@
68
75
  "publishConfig": {
69
76
  "access": "public"
70
77
  },
78
+ "releaseSourceCommit": "9822993504bd9422425d1d6ee9bfbe96f84c909c",
71
79
  "repository": {
72
80
  "type": "git",
73
81
  "url": "git+https://github.com/onejs/one.git",
package/src/index.ts CHANGED
@@ -30,11 +30,13 @@ import { getCachedTransform, logCacheStats, setCachedTransform } from './cache'
30
30
 
31
31
  export * from './configure'
32
32
  export * from './transformBabel'
33
+ export * from './transformFlow'
33
34
  export * from './transformSWC'
34
35
  export * from './transformWorklets'
35
36
  export * from './reactNativeCodegen'
36
37
  export * from './transformHermesLoops'
37
38
  export * from './transformHermesAsync'
39
+ export * from './transformHermesClasses'
38
40
  export { clearTransformCache } from './cache'
39
41
  export { JS_GLOBALS } from './worklets/globals'
40
42
  export { getClosureVariables } from './worklets/scope'
@@ -162,10 +164,14 @@ async function performBabelTransform({
162
164
  }
163
165
 
164
166
  if (userTransform !== 'swc' && userTransform !== 'oxc') {
165
- const babelOptions = getBabelOptions({
167
+ let babelOptions = getBabelOptions({
166
168
  ...transformProps,
167
169
  userSetting: userTransform,
168
170
  })
171
+ // worklets run without requesting a babel pass.
172
+ if (!babelOptions && shouldTransformWorklets({ id, code })) {
173
+ babelOptions = { plugins: [] }
174
+ }
169
175
 
170
176
  if (babelOptions) {
171
177
  const hasCompilerPlugin = babelOptions.plugins?.some(
@@ -643,6 +649,11 @@ ${rootJS.code}
643
649
  transform(code, _id) {
644
650
  if (this.environment.name !== 'client') return
645
651
  if (code.includes(runtimePublicPath)) return // already wrapped
652
+ // vite's special queries (the same pattern as its SPECIAL_QUERY_RE) make
653
+ // a string, url, or worker wrapper module, never the component source.
654
+ // wrapping one imports the refresh runtime, which writes to `window` and
655
+ // so throws when a worker imports `Foo.tsx?raw`.
656
+ if (/[?&](?:worker|sharedworker|raw|url)\b/.test(_id)) return
646
657
 
647
658
  const id = _id.split('?')[0]
648
659
  if (id.includes('node_modules')) return
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * `@react-native/codegen` builds a full CodegenSchema with @babel/parser and
5
5
  * emits the module with @babel/generator, which is the last thing in the native
6
- * pipeline that runs babel at all: 11,774 babel calls per bundle of the soot
6
+ * pipeline that runs babel at all: 11,774 babel calls per bundle of the contrast
7
7
  * app, every one of them from codegen. The view config itself is a plain object
8
8
  * literal, so it can be read off the spec's own AST and printed as text.
9
9
  *
@@ -389,7 +389,12 @@ function readCommands(call: any, decls: Declarations): Command[] {
389
389
  for (const m of commandMembers) {
390
390
  const name = m.key?.name ?? m.key?.value
391
391
  if (!name) continue
392
- const fn = m.typeAnnotation?.typeAnnotation ?? m.value ?? m.typeAnnotation
392
+ // `setPage(ref, index): void` carries its params on the member itself;
393
+ // `setPage: (ref, index) => void` and flow members carry a function type
394
+ const fn =
395
+ m.type === 'TSMethodSignature'
396
+ ? m
397
+ : (m.typeAnnotation?.typeAnnotation ?? m.value ?? m.typeAnnotation)
393
398
  const params = (fn?.params ?? fn?.parameters ?? []).slice(1)
394
399
  byName.set(
395
400
  name,
@@ -9,12 +9,13 @@ import {
9
9
  transformBabel,
10
10
  transformOxcReactCompiler,
11
11
  } from './transformBabel'
12
+ import { stripFlowTypes } from './transformFlow'
12
13
 
13
14
  afterEach(() => {
14
15
  configureVXRNCompilerPlugin({ enableReanimated: false })
15
16
  })
16
- describe('getBabelOptions Worklets resolution', () => {
17
- it('uses the app-installed Worklets Babel plugin', () => {
17
+ describe('getBabelOptions worklets ownership', () => {
18
+ it('does not add an automatic Worklets Babel pass', () => {
18
19
  const projectRoot = fs.realpathSync(
19
20
  fs.mkdtempSync(path.join(os.tmpdir(), 'vxrn-worklets-'))
20
21
  )
@@ -40,7 +41,7 @@ describe('getBabelOptions Worklets resolution', () => {
40
41
  projectRoot,
41
42
  })
42
43
 
43
- expect(options?.plugins).toContain(pluginPath)
44
+ expect(options).toBeNull()
44
45
  } finally {
45
46
  fs.rmSync(projectRoot, { recursive: true, force: true })
46
47
  }
@@ -247,7 +248,7 @@ export async function* generatorProbe() {
247
248
  })
248
249
 
249
250
  describe('shared compiler worklets backend selection', () => {
250
- it('retains Babel for worklets by default when enableNativeWorklets is false', async () => {
251
+ it('does not fall back to Babel when worklet compilation is disabled', async () => {
251
252
  const { vi } = await import('vitest')
252
253
  const { createVXRNCompilerPlugin } = await import('./index')
253
254
  const workletsModule = await import('./transformWorklets')
@@ -269,8 +270,8 @@ describe('shared compiler worklets backend selection', () => {
269
270
  const hook = plugin.transform.handler || plugin.transform
270
271
  const context = { environment: { name: 'ios' } }
271
272
  const result = await hook.call(context, inputCode, tempFile)
272
- expect(result).toBeDefined()
273
- // With enableNativeWorklets: false, transformWorklets (SWC) is NOT called
273
+ expect(result).toBeNull()
274
+ // disabling the transform does not select a second backend.
274
275
  expect(workletSpy).not.toHaveBeenCalled()
275
276
  } finally {
276
277
  workletSpy.mockRestore()
@@ -282,7 +283,7 @@ describe('shared compiler worklets backend selection', () => {
282
283
  }
283
284
  })
284
285
 
285
- it('uses native SWC for worklets when enableNativeWorklets is true', async () => {
286
+ it('compiles worklets with One when no Babel pass is requested', async () => {
286
287
  const compiler = await import('./index')
287
288
  const { vi } = await import('vitest')
288
289
  const workletsModule = await import('./transformWorklets')
@@ -305,7 +306,8 @@ describe('shared compiler worklets backend selection', () => {
305
306
  const context = { environment: { name: 'ios' } }
306
307
  const result = await hook.call(context, inputCode, tempFile)
307
308
  expect(result).toBeDefined()
308
- // With enableNativeWorklets: true, transformWorklets (SWC) IS called
309
+ expect(result.code).toContain('__workletHash')
310
+ // the worklet-only file still reaches the One transform.
309
311
  expect(workletSpy).toHaveBeenCalled()
310
312
  } finally {
311
313
  workletSpy.mockRestore()
@@ -328,7 +330,7 @@ describe('shared compiler worklets backend selection', () => {
328
330
  fs.writeFileSync(tempFile, inputCode)
329
331
 
330
332
  try {
331
- // Step 1: Run with Babel backend (enableNativeWorklets: false)
333
+ // begin with worklet compilation disabled.
332
334
  configureVXRNCompilerPlugin({
333
335
  enableReanimated: true,
334
336
  enableNativeWorklets: false,
@@ -341,10 +343,10 @@ describe('shared compiler worklets backend selection', () => {
341
343
  const context = { environment: { name: 'ios' } }
342
344
 
343
345
  const res1 = await hook1.call(context, inputCode, tempFile)
344
- expect(res1).toBeDefined()
346
+ expect(res1).toBeNull()
345
347
  expect(workletSpy).toHaveBeenCalledTimes(0)
346
348
 
347
- // Step 2: Toggle to native SWC backend on the SAME file without changes
349
+ // enable the transform on the same unchanged file.
348
350
  configureVXRNCompilerPlugin({
349
351
  enableReanimated: true,
350
352
  enableNativeWorklets: true,
@@ -357,15 +359,16 @@ describe('shared compiler worklets backend selection', () => {
357
359
 
358
360
  const res2 = await hook2.call(context, inputCode, tempFile)
359
361
  expect(res2).toBeDefined()
360
- // Cache must NOT serve the Babel entry; native transformWorklets must be invoked
362
+ expect(res2.code).toContain('__workletHash')
363
+ // the cache must not serve the untransformed entry.
361
364
  expect(workletSpy).toHaveBeenCalledTimes(1)
362
365
 
363
- // Step 3: Call again with native SWC to verify caching works for the native backend
366
+ // reuse the transformed cache entry.
364
367
  const res3 = await hook2.call(context, inputCode, tempFile)
365
368
  expect(res3).toBeDefined()
366
369
  expect(workletSpy).toHaveBeenCalledTimes(1)
367
370
 
368
- // Step 4: Toggle back to Babel backend; cache must not serve SWC entry
371
+ // disable the transform; the cache must not serve a transformed entry.
369
372
  configureVXRNCompilerPlugin({
370
373
  enableReanimated: true,
371
374
  enableNativeWorklets: false,
@@ -377,8 +380,8 @@ describe('shared compiler worklets backend selection', () => {
377
380
  const hook3 = plugin3.transform.handler || plugin3.transform
378
381
 
379
382
  const res4 = await hook3.call(context, inputCode, tempFile)
380
- expect(res4).toBeDefined()
381
- // workletSpy should still have only been called once
383
+ expect(res4).toBeNull()
384
+ // no second transform was requested.
382
385
  expect(workletSpy).toHaveBeenCalledTimes(1)
383
386
  } finally {
384
387
  workletSpy.mockRestore()
@@ -474,30 +477,40 @@ describe('findUserBabelConfig and user Babel config respect', () => {
474
477
  }
475
478
  })
476
479
 
477
- it('tells user babel config it runs in a bundler that keeps static esm', async () => {
478
- const projectRoot = fs.realpathSync(
479
- fs.mkdtempSync(path.join(os.tmpdir(), 'vxrn-babel-conf-'))
480
- )
481
- const userConfig = path.join(projectRoot, 'babel.config.js')
482
- // presets such as babel-preset-expo read this caller to decide whether to
483
- // rewrite esm to commonjs and import.meta to a metro runtime global
484
- fs.writeFileSync(
485
- userConfig,
486
- `module.exports = (api) => ({
487
- comments: !api.caller((c) => c?.name === 'vxrn' && c?.supportsStaticESM === true),
480
+ it.each(['ios', 'android', 'client', 'ssr'] as const)(
481
+ 'tells user babel config the %s platform and that the bundler keeps static esm',
482
+ async (environment) => {
483
+ const projectRoot = fs.realpathSync(
484
+ fs.mkdtempSync(path.join(os.tmpdir(), 'vxrn-babel-conf-'))
485
+ )
486
+ const userConfig = path.join(projectRoot, 'babel.config.js')
487
+ // presets such as babel-preset-expo read this caller to decide whether to
488
+ // rewrite esm to commonjs and import.meta to a metro runtime global
489
+ fs.writeFileSync(
490
+ userConfig,
491
+ `module.exports = (api) => ({
492
+ comments: !api.caller((c) => c?.name === 'vxrn' && c?.supportsStaticESM === true && c?.platform === '${environment === 'ios' || environment === 'android' ? environment : 'web'}'),
488
493
  })`
489
- )
490
- try {
491
- const res = await transformBabel(
492
- path.join(projectRoot, 'src', 'index.ts'),
493
- '/* remove me */ export const x = 1',
494
- { configFile: userConfig, babelrc: true }
495
494
  )
496
- expect(res.code).not.toContain('remove me')
497
- } finally {
498
- fs.rmSync(projectRoot, { recursive: true, force: true })
495
+ try {
496
+ const id = path.join(projectRoot, 'src', 'index.ts')
497
+ const code = '/* remove me */ export const x = 1'
498
+ const options = getBabelOptions({
499
+ id,
500
+ code,
501
+ projectRoot,
502
+ environment,
503
+ development: false,
504
+ reactForRNVersion: '19',
505
+ })
506
+ expect(options).not.toBeNull()
507
+ const res = await transformBabel(id, code, options!)
508
+ expect(res.code).not.toContain('remove me')
509
+ } finally {
510
+ fs.rmSync(projectRoot, { recursive: true, force: true })
511
+ }
499
512
  }
500
- })
513
+ )
501
514
  })
502
515
  describe('explicit swc/oxc per-file choice with a user babel config', () => {
503
516
  it('returns null for swc/oxc string and object forms', () => {
@@ -656,3 +669,14 @@ describe('user babel config end-to-end through the compiler plugin', () => {
656
669
  }
657
670
  })
658
671
  })
672
+
673
+ describe('Flow and JSX parsing', () => {
674
+ it('strips Flow types while retaining JSX in published JavaScript', async () => {
675
+ const result = await stripFlowTypes(
676
+ '/app/VideoView.js',
677
+ `export function View(props: {value: string}) { return <NativeView {...props} /> }`
678
+ )
679
+ expect(result.code).not.toContain('value: string')
680
+ expect(result.code).toContain('<NativeView')
681
+ })
682
+ })