@vxrn/compiler 2.17.0 → 2.17.2

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.
@@ -67,12 +67,12 @@ function isCodegenNativeCommandsDeclaration(declaration) {
67
67
  function isReactNativeCodegenSpec(id, code) {
68
68
  return CODEGEN_FILE_RE.test(normalizePath(id.split("?")[0])) && CODEGEN_CALL_RE.test(code);
69
69
  }
70
- function transformReactNativeCodegen(code, id, projectRoot) {
70
+ function transformReactNativeCodegen(code, id) {
71
71
  const cleanId = normalizePath(id.split("?")[0]);
72
72
  if (!isReactNativeCodegenSpec(id, code)) {
73
73
  return;
74
74
  }
75
- const program = (0, import_reactNativeViewConfig.parseSpec)(code, cleanId, projectRoot);
75
+ const program = (0, import_reactNativeViewConfig.parseSpec)(code, cleanId);
76
76
  const body = program?.body;
77
77
  if (!body) {
78
78
  return;
@@ -41,17 +41,12 @@ const IMPORT_IGNORE = "const {ConditionallyIgnoredEventHandlers} = require('reac
41
41
  const IMPORT_DISPATCH = "const {dispatchCommand} = require(\"react-native/Libraries/ReactNative/RendererProxy\");";
42
42
  const IMPORT_UIMANAGER = "const {UIManager} = require(\"react-native-web\")";
43
43
  let hermesParser = void 0;
44
- function getHermesParser(projectRoot) {
44
+ function getHermesParser() {
45
45
  if (hermesParser === void 0) {
46
46
  try {
47
- const req = projectRoot ? (0, import_node_module.createRequire)((0, import_node_path.join)(projectRoot, "package.json")) : (0, import_node_module.createRequire)(SELF_URL);
48
- hermesParser = req("hermes-parser");
47
+ hermesParser = (0, import_node_module.createRequire)(SELF_URL)("hermes-parser");
49
48
  } catch {
50
- try {
51
- hermesParser = (0, import_node_module.createRequire)(SELF_URL)("hermes-parser");
52
- } catch {
53
- hermesParser = null;
54
- }
49
+ hermesParser = null;
55
50
  }
56
51
  }
57
52
  return hermesParser;
@@ -383,14 +378,14 @@ const FILE_HEADER = `/**
383
378
 
384
379
  'use strict';
385
380
  `;
386
- function parseSpec(code, filename, projectRoot) {
381
+ function parseSpec(code, filename) {
387
382
  const isTS = /\.[cm]?tsx?$/.test(filename);
388
383
  if (isTS) {
389
384
  const result = (0, import_oxc_parser.parseSync)(filename, code, { lang: filename.endsWith("x") ? "tsx" : "ts" });
390
385
  if (result.errors?.length) return null;
391
386
  return result.program;
392
387
  }
393
- const hermes = getHermesParser(projectRoot);
388
+ const hermes = getHermesParser();
394
389
  if (!hermes) return null;
395
390
  try {
396
391
  return hermes.parse(code, {
@@ -36,12 +36,12 @@ function isCodegenNativeCommandsDeclaration(declaration) {
36
36
  function isReactNativeCodegenSpec(id, code) {
37
37
  return CODEGEN_FILE_RE.test(normalizePath(id.split("?")[0])) && CODEGEN_CALL_RE.test(code);
38
38
  }
39
- function transformReactNativeCodegen(code, id, projectRoot) {
39
+ function transformReactNativeCodegen(code, id) {
40
40
  const cleanId = normalizePath(id.split("?")[0]);
41
41
  if (!isReactNativeCodegenSpec(id, code)) {
42
42
  return;
43
43
  }
44
- const program = parseSpec(code, cleanId, projectRoot);
44
+ const program = parseSpec(code, cleanId);
45
45
  const body = program?.body;
46
46
  if (!body) {
47
47
  return;
@@ -1 +1 @@
1
- {"version":3,"file":"reactNativeCodegen.js","names":[],"sources":["esm/reactNativeCodegen.js"],"sourcesContent":["import MagicString from \"magic-string\";\nimport {\n generateViewConfig,\n parseSpec,\n renderViewConfigModule\n} from \"./reactNativeViewConfig\";\nfunction normalizePath(id) {\n return id.replace(/\\\\/g, \"/\");\n}\nconst CODEGEN_FILE_RE = /(?:NativeComponent\\.[cm]?[jt]sx?$|[/\\\\]specs?[/\\\\])/;\nconst CODEGEN_CALL_RE = /codegenNativeComponent\\s*[<(]/;\nconst startOf = (node) => node.start ?? node.range[0];\nconst endOf = (node) => node.end ?? node.range[1];\nfunction unwrapExpression(node) {\n while (node) {\n if (node.type === \"TSAsExpression\" || node.type === \"TSSatisfiesExpression\" || node.type === \"TSTypeAssertion\" || node.type === \"TypeCastExpression\" || node.type === \"AsExpression\" || node.type === \"ParenthesizedExpression\") {\n node = node.expression;\n } else if (node.type === \"SequenceExpression\" && Array.isArray(node.expressions) && node.expressions.length > 0) {\n node = node.expressions[node.expressions.length - 1];\n } else {\n break;\n }\n }\n return node;\n}\nfunction isCodegenDeclaration(declaration) {\n if (!declaration) return false;\n if (declaration.left && declaration.left.left && declaration.left.left.name === \"codegenNativeComponent\") {\n return true;\n }\n const unwrapped = unwrapExpression(declaration);\n return unwrapped?.type === \"CallExpression\" && unwrapped.callee?.type === \"Identifier\" && unwrapped.callee.name === \"codegenNativeComponent\";\n}\nfunction isCodegenNativeCommandsDeclaration(declaration) {\n if (!declaration) return false;\n const unwrapped = unwrapExpression(declaration);\n return unwrapped?.type === \"CallExpression\" && unwrapped.callee?.type === \"Identifier\" && unwrapped.callee.name === \"codegenNativeCommands\";\n}\nfunction isReactNativeCodegenSpec(id, code) {\n return CODEGEN_FILE_RE.test(normalizePath(id.split(\"?\")[0])) && CODEGEN_CALL_RE.test(code);\n}\nfunction transformReactNativeCodegen(code, id, projectRoot) {\n const cleanId = normalizePath(id.split(\"?\")[0]);\n if (!isReactNativeCodegenSpec(id, code)) {\n return;\n }\n const program = parseSpec(code, cleanId, projectRoot);\n const body = program?.body;\n if (!body) {\n return;\n }\n let defaultExport = null;\n let commandsExport = null;\n for (const node of body) {\n if (node.type === \"ExportDefaultDeclaration\") {\n if (isCodegenDeclaration(node.declaration)) {\n defaultExport = node;\n }\n } else if (node.type === \"ExportNamedDeclaration\") {\n if (node.declaration && node.declaration.declarations) {\n const firstDeclaration = node.declaration.declarations[0];\n if (firstDeclaration?.type === \"VariableDeclarator\") {\n const isValidCommandsExport = isCodegenNativeCommandsDeclaration(\n firstDeclaration.init\n );\n if (isValidCommandsExport) {\n if (firstDeclaration.id?.type === \"Identifier\" && firstDeclaration.id.name !== \"Commands\") {\n throw new Error(\"Native commands must be exported with the name 'Commands'\");\n }\n commandsExport = node;\n } else {\n if (firstDeclaration.id?.type === \"Identifier\" && firstDeclaration.id.name === \"Commands\") {\n throw new Error(\n \"'Commands' is a reserved export and may only be used to export the result of codegenNativeCommands.\"\n );\n }\n }\n }\n } else if (node.specifiers && node.specifiers.length > 0) {\n for (const specifier of node.specifiers) {\n if (specifier.type === \"ExportSpecifier\" && (specifier.local?.type === \"Identifier\" && specifier.local.name === \"Commands\" || specifier.exported?.type === \"Identifier\" && specifier.exported.name === \"Commands\")) {\n throw new Error(\n \"'Commands' is a reserved export and may only be used to export the result of codegenNativeCommands.\"\n );\n }\n }\n }\n }\n }\n if (!defaultExport) {\n return;\n }\n const generated = generateViewConfig(program);\n if (!generated) {\n return;\n }\n const s = new MagicString(code);\n if (commandsExport) {\n let removeEnd = endOf(commandsExport);\n if (code[removeEnd] === \"\\r\") removeEnd++;\n if (code[removeEnd] === \"\\n\") removeEnd++;\n s.remove(startOf(commandsExport), removeEnd);\n }\n s.overwrite(\n startOf(defaultExport),\n endOf(defaultExport),\n renderViewConfigModule(generated)\n );\n return {\n code: s.toString(),\n map: s.generateMap({ hires: true, source: cleanId })\n };\n}\nexport {\n isReactNativeCodegenSpec,\n transformReactNativeCodegen\n};\n//# sourceMappingURL=reactNativeCodegen.js.map\n"],"mappings":";;;;AAMA,SAAS,cAAc,IAAI;CACzB,OAAO,GAAG,QAAQ,OAAO,GAAG;AAC9B;AACA,MAAM,kBAAkB;AACxB,MAAM,kBAAkB;AACxB,MAAM,WAAW,SAAS,KAAK,SAAS,KAAK,MAAM;AACnD,MAAM,SAAS,SAAS,KAAK,OAAO,KAAK,MAAM;AAC/C,SAAS,iBAAiB,MAAM;CAC9B,OAAO,MAAM;EACX,IAAI,KAAK,SAAS,oBAAoB,KAAK,SAAS,2BAA2B,KAAK,SAAS,qBAAqB,KAAK,SAAS,wBAAwB,KAAK,SAAS,kBAAkB,KAAK,SAAS,2BAA2B;GAC/N,OAAO,KAAK;EACd,OAAO,IAAI,KAAK,SAAS,wBAAwB,MAAM,QAAQ,KAAK,WAAW,KAAK,KAAK,YAAY,SAAS,GAAG;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AsB;KACnD,MAAM,wBAAwB,mCAC5B,iBAAiB,IACnB;KACA,IAAI,uBAAuB;MACzB,IAAI,iBAAiB,IAAI,SAAS,gBAAgB,iBAAiB,GAAG,SAAS,YAAY;OACzF,MAAM,IAAI,MAAM,2DAA2D;MAC7E;MACA,iBAAiB;KACnB,OAAO;MACL,IAAI,iBAAiB,IAAI,SAAS,gBAAgB,iBAAiB,GAAG,SAAS,YAAY;OACzF,MAAM,IAAI,MACR,qGACF;MACF;KACF;IACF;GACF,OAAO,IAAI,KAAK,cAAc,KAAK,WAAW,SAAS,GAAG;IACxD,KAAK,MAAM,aAAa,KAAK,YAAY;KACvC,IAAI,UAAU,SAAS,sBAAsB,UAAU,OAAO,SAAS,gBAAgB,UAAU,MAAM,SAAS,cAAc,UAAU,UAAU,SAAS,gBAAgB,UAAU,SAAS,SAAS,aAAa;MAClN,MAAM,IAAI,MACR,qGACF;KACF;IACF;GACF;EACF;CACF;CACA,IAAI,CAAC,eAAe;EAClB;CACF;CACA,MAAM,YAAY,mBAAmB,OAAO;CAC5C,IAAI,CAAC,WAAW;EACd;CACF;CACA,MAAM,IAAI,IAAI,YAAY,IAAI;CAC9B,IAAI,gBAAgB;EAClB,IAAI,YAAY,MAAM,cAAc;EACpC,IAAI,KAAK,eAAe,MAAM;EAC9B,IAAI,KAAK,eAAe,MAAM;EAC9B,EAAE,OAAO,QAAQ,cAAc,GAAG,SAAS;CAC7C;CACA,EAAE,UACA,QAAQ,aAAa,GACrB,MAAM,aAAa,GACnB,uBAAuB,SAAS,CAClC;CACA,OAAO;EACL,MAAM,EAAE,SAAS;EACjB,KAAK,EAAE,YAAY;GAAE,OAAO;GAAM,QAAQ;EAAQ,CAAC;CACrD;AACF"}
1
+ {"version":3,"file":"reactNativeCodegen.js","names":[],"sources":["esm/reactNativeCodegen.js"],"sourcesContent":["import MagicString from \"magic-string\";\nimport {\n generateViewConfig,\n parseSpec,\n renderViewConfigModule\n} from \"./reactNativeViewConfig\";\nfunction normalizePath(id) {\n return id.replace(/\\\\/g, \"/\");\n}\nconst CODEGEN_FILE_RE = /(?:NativeComponent\\.[cm]?[jt]sx?$|[/\\\\]specs?[/\\\\])/;\nconst CODEGEN_CALL_RE = /codegenNativeComponent\\s*[<(]/;\nconst startOf = (node) => node.start ?? node.range[0];\nconst endOf = (node) => node.end ?? node.range[1];\nfunction unwrapExpression(node) {\n while (node) {\n if (node.type === \"TSAsExpression\" || node.type === \"TSSatisfiesExpression\" || node.type === \"TSTypeAssertion\" || node.type === \"TypeCastExpression\" || node.type === \"AsExpression\" || node.type === \"ParenthesizedExpression\") {\n node = node.expression;\n } else if (node.type === \"SequenceExpression\" && Array.isArray(node.expressions) && node.expressions.length > 0) {\n node = node.expressions[node.expressions.length - 1];\n } else {\n break;\n }\n }\n return node;\n}\nfunction isCodegenDeclaration(declaration) {\n if (!declaration) return false;\n if (declaration.left && declaration.left.left && declaration.left.left.name === \"codegenNativeComponent\") {\n return true;\n }\n const unwrapped = unwrapExpression(declaration);\n return unwrapped?.type === \"CallExpression\" && unwrapped.callee?.type === \"Identifier\" && unwrapped.callee.name === \"codegenNativeComponent\";\n}\nfunction isCodegenNativeCommandsDeclaration(declaration) {\n if (!declaration) return false;\n const unwrapped = unwrapExpression(declaration);\n return unwrapped?.type === \"CallExpression\" && unwrapped.callee?.type === \"Identifier\" && unwrapped.callee.name === \"codegenNativeCommands\";\n}\nfunction isReactNativeCodegenSpec(id, code) {\n return CODEGEN_FILE_RE.test(normalizePath(id.split(\"?\")[0])) && CODEGEN_CALL_RE.test(code);\n}\nfunction transformReactNativeCodegen(code, id) {\n const cleanId = normalizePath(id.split(\"?\")[0]);\n if (!isReactNativeCodegenSpec(id, code)) {\n return;\n }\n const program = parseSpec(code, cleanId);\n const body = program?.body;\n if (!body) {\n return;\n }\n let defaultExport = null;\n let commandsExport = null;\n for (const node of body) {\n if (node.type === \"ExportDefaultDeclaration\") {\n if (isCodegenDeclaration(node.declaration)) {\n defaultExport = node;\n }\n } else if (node.type === \"ExportNamedDeclaration\") {\n if (node.declaration && node.declaration.declarations) {\n const firstDeclaration = node.declaration.declarations[0];\n if (firstDeclaration?.type === \"VariableDeclarator\") {\n const isValidCommandsExport = isCodegenNativeCommandsDeclaration(\n firstDeclaration.init\n );\n if (isValidCommandsExport) {\n if (firstDeclaration.id?.type === \"Identifier\" && firstDeclaration.id.name !== \"Commands\") {\n throw new Error(\"Native commands must be exported with the name 'Commands'\");\n }\n commandsExport = node;\n } else {\n if (firstDeclaration.id?.type === \"Identifier\" && firstDeclaration.id.name === \"Commands\") {\n throw new Error(\n \"'Commands' is a reserved export and may only be used to export the result of codegenNativeCommands.\"\n );\n }\n }\n }\n } else if (node.specifiers && node.specifiers.length > 0) {\n for (const specifier of node.specifiers) {\n if (specifier.type === \"ExportSpecifier\" && (specifier.local?.type === \"Identifier\" && specifier.local.name === \"Commands\" || specifier.exported?.type === \"Identifier\" && specifier.exported.name === \"Commands\")) {\n throw new Error(\n \"'Commands' is a reserved export and may only be used to export the result of codegenNativeCommands.\"\n );\n }\n }\n }\n }\n }\n if (!defaultExport) {\n return;\n }\n const generated = generateViewConfig(program);\n if (!generated) {\n return;\n }\n const s = new MagicString(code);\n if (commandsExport) {\n let removeEnd = endOf(commandsExport);\n if (code[removeEnd] === \"\\r\") removeEnd++;\n if (code[removeEnd] === \"\\n\") removeEnd++;\n s.remove(startOf(commandsExport), removeEnd);\n }\n s.overwrite(\n startOf(defaultExport),\n endOf(defaultExport),\n renderViewConfigModule(generated)\n );\n return {\n code: s.toString(),\n map: s.generateMap({ hires: true, source: cleanId })\n };\n}\nexport {\n isReactNativeCodegenSpec,\n transformReactNativeCodegen\n};\n//# sourceMappingURL=reactNativeCodegen.js.map\n"],"mappings":";;;;AAMA,SAAS,cAAc,IAAI;CACzB,OAAO,GAAG,QAAQ,OAAO,GAAG;AAC9B;AACA,MAAM,kBAAkB;AACxB,MAAM,kBAAkB;AACxB,MAAM,WAAW,SAAS,KAAK,SAAS,KAAK,MAAM;A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,aAAa,GACrB,MAAM,aAAa,GACnB,uBAAuB,SAAS,CAClC;CACA,OAAO;EACL,MAAM,EAAE,SAAS;EACjB,KAAK,EAAE,YAAY;GAAE,OAAO;GAAM,QAAQ;EAAQ,CAAC;CACrD;AACF"}
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from "node:module";
2
- import { basename, join } from "node:path";
2
+ import { basename } from "node:path";
3
3
  import { parseSync } from "oxc-parser";
4
4
 
5
5
  const SELF_URL = typeof __filename !== "undefined" ? __filename : import.meta.url;
@@ -13,17 +13,12 @@ const IMPORT_IGNORE = "const {ConditionallyIgnoredEventHandlers} = require('reac
13
13
  const IMPORT_DISPATCH = "const {dispatchCommand} = require(\"react-native/Libraries/ReactNative/RendererProxy\");";
14
14
  const IMPORT_UIMANAGER = "const {UIManager} = require(\"react-native\")";
15
15
  let hermesParser = void 0;
16
- function getHermesParser(projectRoot) {
16
+ function getHermesParser() {
17
17
  if (hermesParser === void 0) {
18
18
  try {
19
- const req = projectRoot ? createRequire(join(projectRoot, "package.json")) : createRequire(SELF_URL);
20
- hermesParser = req("hermes-parser");
19
+ hermesParser = createRequire(SELF_URL)("hermes-parser");
21
20
  } catch {
22
- try {
23
- hermesParser = createRequire(SELF_URL)("hermes-parser");
24
- } catch {
25
- hermesParser = null;
26
- }
21
+ hermesParser = null;
27
22
  }
28
23
  }
29
24
  return hermesParser;
@@ -355,14 +350,14 @@ const FILE_HEADER = `/**
355
350
 
356
351
  'use strict';
357
352
  `;
358
- function parseSpec(code, filename, projectRoot) {
353
+ function parseSpec(code, filename) {
359
354
  const isTS = /\.[cm]?tsx?$/.test(filename);
360
355
  if (isTS) {
361
356
  const result = parseSync(filename, code, { lang: filename.endsWith("x") ? "tsx" : "ts" });
362
357
  if (result.errors?.length) return null;
363
358
  return result.program;
364
359
  }
365
- const hermes = getHermesParser(projectRoot);
360
+ const hermes = getHermesParser();
366
361
  if (!hermes) return null;
367
362
  try {
368
363
  return hermes.parse(code, {
@@ -1 +1 @@
1
- {"version":3,"file":"reactNativeViewConfig.js","names":[],"sources":["esm/reactNativeViewConfig.js"],"sourcesContent":["import { createRequire } from \"node:module\";\nimport { basename, join } from \"node:path\";\nimport { parseSync } from \"oxc-parser\";\nconst SELF_URL = typeof __filename !== \"undefined\" ? __filename : import.meta.url;\nconst COLOR_ATTRIBUTE = \"require('react-native/Libraries/Components/View/ReactNativeStyleAttributes').colorAttribute\";\nconst COLOR_ARRAY_ATTRIBUTE = \"{\\n process: (req => 'default' in req ? req.default : req)(require('react-native/Libraries/StyleSheet/processColorArray'))\\n }\";\nconst IMAGE_ATTRIBUTE = \"{\\n process: (req => 'default' in req ? req.default : req)(require('react-native/Libraries/Image/resolveAssetSource'))\\n }\";\nconst POINT_ATTRIBUTE = \"{\\n diff: (req => 'default' in req ? req.default : req)(require('react-native/Libraries/Utilities/differ/pointsDiffer'))\\n }\";\nconst EDGE_INSETS_ATTRIBUTE = \"{\\n diff: (req => 'default' in req ? req.default : req)(require('react-native/Libraries/Utilities/differ/insetsDiffer'))\\n }\";\nconst IMPORT_REGISTRY = \"const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');\";\nconst IMPORT_IGNORE = \"const {ConditionallyIgnoredEventHandlers} = require('react-native/Libraries/NativeComponent/ViewConfigIgnore');\";\nconst IMPORT_DISPATCH = 'const {dispatchCommand} = require(\"react-native/Libraries/ReactNative/RendererProxy\");';\nconst IMPORT_UIMANAGER = 'const {UIManager} = require(\"react-native\")';\nlet hermesParser = void 0;\nfunction getHermesParser(projectRoot) {\n if (hermesParser === void 0) {\n try {\n const req = projectRoot ? createRequire(join(projectRoot, \"package.json\")) : createRequire(SELF_URL);\n hermesParser = req(\"hermes-parser\");\n } catch {\n try {\n hermesParser = createRequire(SELF_URL)(\"hermes-parser\");\n } catch {\n hermesParser = null;\n }\n }\n }\n return hermesParser;\n}\nfunction readType(node) {\n if (!node) return { name: \"\", args: [] };\n switch (node.type) {\n // flow\n case \"NullableTypeAnnotation\":\n case \"TypeAnnotation\":\n return readType(node.typeAnnotation);\n case \"GenericTypeAnnotation\":\n return {\n name: readTypeName(node.id),\n args: (node.typeParameters?.params ?? []).map(readType)\n };\n case \"ObjectTypeAnnotation\":\n return { name: \"__object\", args: [] };\n case \"StringTypeAnnotation\":\n return { name: \"string\", args: [] };\n case \"BooleanTypeAnnotation\":\n return { name: \"boolean\", args: [] };\n case \"NumberTypeAnnotation\":\n return { name: \"number\", args: [] };\n case \"UnionTypeAnnotation\":\n return readUnion(node);\n case \"FunctionTypeAnnotation\":\n return { name: \"__function\", args: [] };\n // typescript\n case \"TSTypeAnnotation\":\n return readType(node.typeAnnotation);\n case \"TSTypeReference\":\n return {\n name: readTypeName(node.typeName),\n args: (node.typeArguments ?? node.typeParameters)?.params?.map(readType) ?? []\n };\n case \"TSTypeLiteral\":\n return { name: \"__object\", args: [] };\n case \"TSStringKeyword\":\n return { name: \"string\", args: [] };\n case \"TSBooleanKeyword\":\n return { name: \"boolean\", args: [] };\n case \"TSNumberKeyword\":\n return { name: \"number\", args: [] };\n case \"TSUnionType\":\n return readUnion(node);\n case \"TSFunctionType\":\n return { name: \"__function\", args: [] };\n case \"TSArrayType\":\n return { name: \"Array\", args: [readType(node.elementType)] };\n }\n return { name: \"__unknown\", args: [] };\n}\nconst NULLISH_TYPES = /* @__PURE__ */ new Set([\n \"TSUndefinedKeyword\",\n \"TSNullKeyword\",\n \"TSVoidKeyword\",\n \"NullLiteralTypeAnnotation\",\n \"VoidTypeAnnotation\"\n]);\nfunction readUnion(node) {\n const real = (node.types ?? []).filter((t) => !NULLISH_TYPES.has(t.type));\n if (real.length === 1) return readType(real[0]);\n return { name: \"__union\", args: [] };\n}\nfunction readTypeName(id) {\n if (!id) return \"\";\n if (id.type === \"Identifier\") return id.name;\n if (id.type === \"QualifiedTypeIdentifier\") return readTypeName(id.id);\n if (id.type === \"TSQualifiedName\") return readTypeName(id.right);\n return \"\";\n}\nconst READONLY_ARRAYS = /* @__PURE__ */ new Set([\"ReadonlyArray\", \"$ReadOnlyArray\", \"Array\"]);\nconst TRANSPARENT = /* @__PURE__ */ new Set([\"WithDefault\", \"UnsafeMixed\", \"Readonly\", \"$ReadOnly\"]);\nfunction unwrap(type) {\n let cur = type;\n while (TRANSPARENT.has(cur.name) && cur.args.length > 0) {\n cur = cur.args[0];\n }\n return cur;\n}\nfunction attributeValue(type) {\n const t = unwrap(type);\n switch (t.name) {\n case \"ColorValue\":\n case \"ProcessedColorValue\":\n return COLOR_ATTRIBUTE;\n case \"ImageSource\":\n return IMAGE_ATTRIBUTE;\n case \"PointValue\":\n return POINT_ATTRIBUTE;\n case \"EdgeInsetsValue\":\n return EDGE_INSETS_ATTRIBUTE;\n }\n if (READONLY_ARRAYS.has(t.name) && t.args.length === 1) {\n const el = unwrap(t.args[0]);\n if (el.name === \"ColorValue\" || el.name === \"ProcessedColorValue\") {\n return COLOR_ARRAY_ATTRIBUTE;\n }\n }\n return \"true\";\n}\nfunction eventOf(name, type) {\n const t = unwrap(type);\n if (t.name !== \"DirectEventHandler\" && t.name !== \"BubblingEventHandler\") return null;\n const override = t.args[1]?.name;\n return {\n name,\n bubbling: t.name === \"BubblingEventHandler\",\n topName: normalizeInputEventName(\n override && override !== \"__unknown\" ? override : name\n )\n };\n}\nfunction normalizeInputEventName(name) {\n if (name.startsWith(\"on\")) return name.replace(/^on/, \"top\");\n if (!name.startsWith(\"top\")) return `top${name[0].toUpperCase()}${name.slice(1)}`;\n return name;\n}\nfunction collectDeclarations(body) {\n const out = /* @__PURE__ */ new Map();\n for (const raw of body) {\n const node = raw?.type === \"ExportNamedDeclaration\" ? raw.declaration : raw;\n if (!node) continue;\n switch (node.type) {\n case \"TSTypeAliasDeclaration\":\n case \"TypeAlias\":\n case \"TSInterfaceDeclaration\":\n case \"InterfaceDeclaration\":\n if (node.id?.name) out.set(node.id.name, node);\n break;\n }\n }\n return out;\n}\nfunction flattenMembers(typeName, decls, seen = /* @__PURE__ */ new Set()) {\n if (typeName === \"ViewProps\" || seen.has(typeName)) return [];\n seen.add(typeName);\n const decl = decls.get(typeName);\n if (!decl) return [];\n const out = [];\n const heritage = decl.extends ?? decl.heritage ?? [];\n for (const h of heritage) {\n const name = readTypeName(h.id ?? h.expression ?? h.typeName);\n if (name) out.push(...flattenMembers(name, decls, seen));\n }\n const bodyNode = decl.body ?? // interface\n decl.right ?? // type alias\n decl.typeAnnotation;\n out.push(...readObjectMembers(bodyNode, decls, seen));\n return out;\n}\nfunction readObjectMembers(node, decls, seen) {\n if (!node) return [];\n if (node.type === \"TSTypeReference\" || node.type === \"GenericTypeAnnotation\") {\n const name = readTypeName(node.typeName ?? node.id);\n const args = (node.typeArguments ?? node.typeParameters)?.params ?? [];\n if (TRANSPARENT.has(name) && args.length) {\n return readObjectMembers(args[0], decls, seen);\n }\n return flattenMembers(name, decls, seen);\n }\n if (node.type === \"TSIntersectionType\" || node.type === \"IntersectionTypeAnnotation\") {\n const out2 = [];\n for (const t of node.types ?? []) out2.push(...readObjectMembers(t, decls, seen));\n return out2;\n }\n const members = node.members ?? node.body ?? node.properties ?? [];\n const out = [];\n for (const m of members) {\n switch (m.type) {\n case \"TSPropertySignature\":\n case \"ObjectTypeProperty\": {\n const name = m.key?.name ?? m.key?.value;\n if (!name) break;\n out.push({ name, type: readType(m.typeAnnotation ?? m.value) });\n break;\n }\n // flow's `...OtherProps` inside an object type\n case \"ObjectTypeSpreadProperty\": {\n const name = readTypeName(m.argument?.id ?? m.argument);\n if (name) out.push(...flattenMembers(name, decls, seen));\n break;\n }\n }\n }\n return out;\n}\nfunction findComponentCall(body) {\n for (const node of body) {\n if (node.type !== \"ExportDefaultDeclaration\") continue;\n let expr = node.declaration;\n while (expr) {\n if (expr.type === \"CallExpression\") break;\n expr = expr.expression ?? (expr.type === \"SequenceExpression\" ? expr.expressions[expr.expressions.length - 1] : null);\n }\n if (expr?.type === \"CallExpression\" && expr.callee?.name === \"codegenNativeComponent\") {\n return expr;\n }\n }\n return null;\n}\nfunction findCommandsCall(body) {\n for (const raw of body) {\n const node = raw?.type === \"ExportNamedDeclaration\" ? raw.declaration : raw;\n const decl = node?.declarations?.[0];\n let init = decl?.init;\n while (init && init.type !== \"CallExpression\") init = init.expression;\n if (init?.type === \"CallExpression\" && init.callee?.name === \"codegenNativeCommands\") {\n return init;\n }\n }\n return null;\n}\nfunction readStringOption(objectExpression, key) {\n for (const p of objectExpression?.properties ?? []) {\n if ((p.key?.name ?? p.key?.value) === key && typeof p.value?.value === \"string\") {\n return p.value.value;\n }\n }\n return null;\n}\nfunction readCommands(call, decls) {\n const typeName = readTypeName(\n (call.typeArguments ?? call.typeParameters)?.params?.[0]?.typeName ?? (call.typeArguments ?? call.typeParameters)?.params?.[0]?.id\n );\n const supported = [];\n for (const p of call.arguments?.[0]?.properties ?? []) {\n if ((p.key?.name ?? p.key?.value) !== \"supportedCommands\") continue;\n for (const el of p.value?.elements ?? []) {\n if (typeof el?.value === \"string\") supported.push(el.value);\n }\n }\n if (!supported.length) return [];\n const decl = decls.get(typeName);\n const byName = /* @__PURE__ */ new Map();\n const commandMembers = decl?.body?.body ?? decl?.body?.members ?? decl?.body?.properties ?? [];\n for (const m of commandMembers) {\n const name = m.key?.name ?? m.key?.value;\n if (!name) continue;\n const fn = m.type === \"TSMethodSignature\" ? m : m.typeAnnotation?.typeAnnotation ?? m.value ?? m.typeAnnotation;\n const params = (fn?.params ?? fn?.parameters ?? []).slice(1);\n byName.set(\n name,\n params.map((p, i) => p.name?.name ?? p.name ?? `arg${i}`)\n );\n }\n return supported.map((name) => ({ name, params: byName.get(name) ?? [] }));\n}\nfunction indent(text, spaces) {\n const pad = \" \".repeat(spaces);\n return text.split(\"\\n\").map((line, i) => i === 0 || line === \"\" ? line : pad + line).join(\"\\n\");\n}\nfunction printViewConfig(componentName, attributes, events) {\n const lines = [` uiViewClassName: ${JSON.stringify(componentName)}`];\n const bubbling = events.filter((e) => e.bubbling);\n if (bubbling.length) {\n lines.push(\n ` bubblingEventTypes: {\n${bubbling.map(\n (e) => ` ${e.topName}: {\n phasedRegistrationNames: {\n captured: ${JSON.stringify(\n `${e.name}Capture`\n )},\n bubbled: ${JSON.stringify(e.name)}\n }\n }`\n ).join(\",\\n\")}\n }`\n );\n }\n const direct = events.filter((e) => !e.bubbling);\n if (direct.length) {\n lines.push(\n ` directEventTypes: {\n${direct.map(\n (e) => ` ${e.topName}: {\n registrationName: ${JSON.stringify(e.name)}\n }`\n ).join(\",\\n\")}\n }`\n );\n }\n const attrLines = attributes.map((a) => ` ${a.name}: ${indent(a.value, 4)}`);\n if (events.length) {\n attrLines.push(\n ` ...ConditionallyIgnoredEventHandlers({\n${events.map((e) => ` ${e.name}: true`).join(\",\\n\")}\n })`\n );\n }\n lines.push(\n attrLines.length ? ` validAttributes: {\n${attrLines.join(\",\\n\")}\n }` : \" validAttributes: {}\"\n );\n return `{\n${lines.join(\",\\n\")}\n}`;\n}\nfunction printCommands(commands) {\n return `export const Commands = {\n${commands.map(\n (c) => ` ${c.name}(ref${c.params.map((p) => `, ${p}`).join(\"\")}) {\n dispatchCommand(ref, ${JSON.stringify(\n c.name\n )}, [${c.params.join(\", \")}]);\n }`\n ).join(\",\\n\")}\n};`;\n}\nconst FILE_HEADER = `/**\n * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).\n *\n * Do not edit this file as changes may cause incorrect behavior and will be lost\n * once the code is regenerated.\n *\n * @flow\n *\n * @generated by codegen project: GenerateViewConfigJs.js\n */\n\n'use strict';\n`;\nfunction parseSpec(code, filename, projectRoot) {\n const isTS = /\\.[cm]?tsx?$/.test(filename);\n if (isTS) {\n const result = parseSync(filename, code, {\n lang: filename.endsWith(\"x\") ? \"tsx\" : \"ts\"\n });\n if (result.errors?.length) return null;\n return result.program;\n }\n const hermes = getHermesParser(projectRoot);\n if (!hermes) return null;\n try {\n return hermes.parse(code, {\n babel: false,\n flow: \"all\",\n sourceFilename: filename\n });\n } catch {\n return null;\n }\n}\nfunction generateViewConfig(program) {\n const body = program?.body;\n if (!body) return null;\n const call = findComponentCall(body);\n if (!call) return null;\n const componentNameArg = call.arguments?.[0];\n if (typeof componentNameArg?.value !== \"string\") return null;\n const componentName = componentNameArg.value;\n const options = call.arguments?.[1];\n const paperComponentName = readStringOption(options, \"paperComponentName\");\n const paperComponentNameDeprecated = readStringOption(\n options,\n \"paperComponentNameDeprecated\"\n );\n const propsTypeName = readTypeName(\n (call.typeArguments ?? call.typeParameters)?.params?.[0]?.typeName ?? (call.typeArguments ?? call.typeParameters)?.params?.[0]?.id\n );\n if (!propsTypeName) return null;\n const decls = collectDeclarations(body);\n const members = flattenMembers(propsTypeName, decls);\n const attributes = [];\n const events = [];\n for (const m of members) {\n const event = eventOf(m.name, m.type);\n if (event) {\n events.push(event);\n continue;\n }\n attributes.push({ name: m.name, value: attributeValue(m.type) });\n }\n const commandsCall = findCommandsCall(body);\n const commands = commandsCall ? readCommands(commandsCall, decls) : [];\n const imports = /* @__PURE__ */ new Set([IMPORT_REGISTRY]);\n if (events.length) imports.add(IMPORT_IGNORE);\n if (commands.length) imports.add(IMPORT_DISPATCH);\n if (paperComponentNameDeprecated) imports.add(IMPORT_UIMANAGER);\n const nativeName = paperComponentName ?? componentName;\n const parts = [`let nativeComponentName = '${nativeName}';`];\n if (paperComponentNameDeprecated) {\n parts.push(\n `if (UIManager.hasViewManagerConfig('${componentName}')) {\n nativeComponentName = '${componentName}';\n} else if (UIManager.hasViewManagerConfig('${paperComponentNameDeprecated}')) {\n nativeComponentName = '${paperComponentNameDeprecated}';\n} else {\n throw new Error('Failed to find native component for either \"${componentName}\" or \"${paperComponentNameDeprecated}\"');\n}`\n );\n }\n parts.push(\n `export const __INTERNAL_VIEW_CONFIG = ${printViewConfig(nativeName, attributes, events)};`\n );\n parts.push(\n \"export default NativeComponentRegistry.get(nativeComponentName, () => __INTERNAL_VIEW_CONFIG);\"\n );\n if (commands.length) parts.push(printCommands(commands));\n return { imports: [...imports].sort(), body: parts.join(\"\\n\") };\n}\nfunction renderViewConfigModule(result) {\n return `\n${FILE_HEADER}\n${result.imports.join(\"\\n\")}\n\n${result.body}\n`;\n}\nfunction getLibraryName(filename) {\n const base = basename(filename);\n const replaced = base.replace(/NativeComponent\\.[cm]?[jt]sx?$/, \"\");\n return replaced === base ? base.replace(/\\.[cm]?[jt]sx?$/, \"\") : replaced;\n}\nexport {\n generateViewConfig,\n getLibraryName,\n parseSpec,\n renderViewConfigModule\n};\n//# sourceMappingURL=reactNativeViewConfig.js.map\n"],"mappings":";;;;;AAGA,MAAM,WAAW,OAAO,eAAe,cAAc,aAAa,YAAY;AAC9E,MAAM,kBAAkB;AACxB,MAAM,wBAAwB;AAC9B,MAAM,kBAAkB;AACxB,MAAM,kBAAkB;AACxB,MAAM,wBAAwB;AAC9B,MAAM,kBAAkB;AACxB,MAAM,gBAAgB;AACtB,MAAM,kBAAkB;AACxB,MAAM,mBAAmB;AACzB,IAAI,eAAe,KAAK;AACxB,SAAS,gBAAgB,aAAa;CACpC,IAAI,iBAAiB,KAAK,GAAG;EAC3B,IAAI;GACF,MAAM,MAAM,cAAc,cAAc,KAAK,aAAa,cAAc,CAAC,IAAI,cAAc,QAAQ;GACnG,eAAe,IAAI,eAAe;EACpC,QAAQ;GACN,IAAI;IACF,eAAe,cAAc,QAAQ,CAAC,CAAC,eAAe;GACxD,QAAQ;IACN,eAAe;GACjB;EACF;CACF;CACA,OAAO;AACT;AACA,SAAS,SAAS,MAAM;CACtB,IAAI,CAAC,MAAM,OAAO;EAAE,MAAM;EAAI,MAAM,CAAC;CAAE;CACvC,QAAQ,KAAK,MAAb;EAEE,KAAK;EACL,KAAK,kBACH,OAAO,SAAS,KAAK,cAAc;EACrC,KAAK,yBACH,OAAO;GACL,MAAM,aAAa,KAAK,EAAE;GAC1B,OAAO,KAAK,gBAAgB,UAAU,CAAC,EAAC,CAAE,IAAI,QAAQ;EACxD;EACF,KAAK,wBACH,OAAO;GAAE,MAAM;GAAY,MAAM,CAAC;EAAE;EACtC,KAAK,wBACH,OAAO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A,IAAI,SAAS,QAAQ,MAAM,KAAK,cAAc,QAAQ,CAAC;CACvD,OAAO;EAAE,SAAS,CAAC,GAAG,OAAO,CAAC,CAAC,KAAK;EAAG,MAAM,MAAM,KAAK,IAAI;CAAE;AAChE;AACA,SAAS,uBAAuB,QAAQ;CACtC,OAAO;EACP,YAAY;EACZ,OAAO,QAAQ,KAAK,IAAI,EAAE;;EAE1B,OAAO,KAAK;;AAEd;AACA,SAAS,eAAe,UAAU;CAChC,MAAM,OAAO,SAAS,QAAQ;CAC9B,MAAM,WAAW,KAAK,QAAQ,kCAAkC,EAAE;CAClE,OAAO,aAAa,OAAO,KAAK,QAAQ,mBAAmB,EAAE,IAAI;AACnE"}
1
+ {"version":3,"file":"reactNativeViewConfig.js","names":[],"sources":["esm/reactNativeViewConfig.js"],"sourcesContent":["import { createRequire } from \"node:module\";\nimport { basename } from \"node:path\";\nimport { parseSync } from \"oxc-parser\";\nconst SELF_URL = typeof __filename !== \"undefined\" ? __filename : import.meta.url;\nconst COLOR_ATTRIBUTE = \"require('react-native/Libraries/Components/View/ReactNativeStyleAttributes').colorAttribute\";\nconst COLOR_ARRAY_ATTRIBUTE = \"{\\n process: (req => 'default' in req ? req.default : req)(require('react-native/Libraries/StyleSheet/processColorArray'))\\n }\";\nconst IMAGE_ATTRIBUTE = \"{\\n process: (req => 'default' in req ? req.default : req)(require('react-native/Libraries/Image/resolveAssetSource'))\\n }\";\nconst POINT_ATTRIBUTE = \"{\\n diff: (req => 'default' in req ? req.default : req)(require('react-native/Libraries/Utilities/differ/pointsDiffer'))\\n }\";\nconst EDGE_INSETS_ATTRIBUTE = \"{\\n diff: (req => 'default' in req ? req.default : req)(require('react-native/Libraries/Utilities/differ/insetsDiffer'))\\n }\";\nconst IMPORT_REGISTRY = \"const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');\";\nconst IMPORT_IGNORE = \"const {ConditionallyIgnoredEventHandlers} = require('react-native/Libraries/NativeComponent/ViewConfigIgnore');\";\nconst IMPORT_DISPATCH = 'const {dispatchCommand} = require(\"react-native/Libraries/ReactNative/RendererProxy\");';\nconst IMPORT_UIMANAGER = 'const {UIManager} = require(\"react-native\")';\nlet hermesParser = void 0;\nfunction getHermesParser() {\n if (hermesParser === void 0) {\n try {\n hermesParser = createRequire(SELF_URL)(\"hermes-parser\");\n } catch {\n hermesParser = null;\n }\n }\n return hermesParser;\n}\nfunction readType(node) {\n if (!node) return { name: \"\", args: [] };\n switch (node.type) {\n // flow\n case \"NullableTypeAnnotation\":\n case \"TypeAnnotation\":\n return readType(node.typeAnnotation);\n case \"GenericTypeAnnotation\":\n return {\n name: readTypeName(node.id),\n args: (node.typeParameters?.params ?? []).map(readType)\n };\n case \"ObjectTypeAnnotation\":\n return { name: \"__object\", args: [] };\n case \"StringTypeAnnotation\":\n return { name: \"string\", args: [] };\n case \"BooleanTypeAnnotation\":\n return { name: \"boolean\", args: [] };\n case \"NumberTypeAnnotation\":\n return { name: \"number\", args: [] };\n case \"UnionTypeAnnotation\":\n return readUnion(node);\n case \"FunctionTypeAnnotation\":\n return { name: \"__function\", args: [] };\n // typescript\n case \"TSTypeAnnotation\":\n return readType(node.typeAnnotation);\n case \"TSTypeReference\":\n return {\n name: readTypeName(node.typeName),\n args: (node.typeArguments ?? node.typeParameters)?.params?.map(readType) ?? []\n };\n case \"TSTypeLiteral\":\n return { name: \"__object\", args: [] };\n case \"TSStringKeyword\":\n return { name: \"string\", args: [] };\n case \"TSBooleanKeyword\":\n return { name: \"boolean\", args: [] };\n case \"TSNumberKeyword\":\n return { name: \"number\", args: [] };\n case \"TSUnionType\":\n return readUnion(node);\n case \"TSFunctionType\":\n return { name: \"__function\", args: [] };\n case \"TSArrayType\":\n return { name: \"Array\", args: [readType(node.elementType)] };\n }\n return { name: \"__unknown\", args: [] };\n}\nconst NULLISH_TYPES = /* @__PURE__ */ new Set([\n \"TSUndefinedKeyword\",\n \"TSNullKeyword\",\n \"TSVoidKeyword\",\n \"NullLiteralTypeAnnotation\",\n \"VoidTypeAnnotation\"\n]);\nfunction readUnion(node) {\n const real = (node.types ?? []).filter((t) => !NULLISH_TYPES.has(t.type));\n if (real.length === 1) return readType(real[0]);\n return { name: \"__union\", args: [] };\n}\nfunction readTypeName(id) {\n if (!id) return \"\";\n if (id.type === \"Identifier\") return id.name;\n if (id.type === \"QualifiedTypeIdentifier\") return readTypeName(id.id);\n if (id.type === \"TSQualifiedName\") return readTypeName(id.right);\n return \"\";\n}\nconst READONLY_ARRAYS = /* @__PURE__ */ new Set([\"ReadonlyArray\", \"$ReadOnlyArray\", \"Array\"]);\nconst TRANSPARENT = /* @__PURE__ */ new Set([\"WithDefault\", \"UnsafeMixed\", \"Readonly\", \"$ReadOnly\"]);\nfunction unwrap(type) {\n let cur = type;\n while (TRANSPARENT.has(cur.name) && cur.args.length > 0) {\n cur = cur.args[0];\n }\n return cur;\n}\nfunction attributeValue(type) {\n const t = unwrap(type);\n switch (t.name) {\n case \"ColorValue\":\n case \"ProcessedColorValue\":\n return COLOR_ATTRIBUTE;\n case \"ImageSource\":\n return IMAGE_ATTRIBUTE;\n case \"PointValue\":\n return POINT_ATTRIBUTE;\n case \"EdgeInsetsValue\":\n return EDGE_INSETS_ATTRIBUTE;\n }\n if (READONLY_ARRAYS.has(t.name) && t.args.length === 1) {\n const el = unwrap(t.args[0]);\n if (el.name === \"ColorValue\" || el.name === \"ProcessedColorValue\") {\n return COLOR_ARRAY_ATTRIBUTE;\n }\n }\n return \"true\";\n}\nfunction eventOf(name, type) {\n const t = unwrap(type);\n if (t.name !== \"DirectEventHandler\" && t.name !== \"BubblingEventHandler\") return null;\n const override = t.args[1]?.name;\n return {\n name,\n bubbling: t.name === \"BubblingEventHandler\",\n topName: normalizeInputEventName(\n override && override !== \"__unknown\" ? override : name\n )\n };\n}\nfunction normalizeInputEventName(name) {\n if (name.startsWith(\"on\")) return name.replace(/^on/, \"top\");\n if (!name.startsWith(\"top\")) return `top${name[0].toUpperCase()}${name.slice(1)}`;\n return name;\n}\nfunction collectDeclarations(body) {\n const out = /* @__PURE__ */ new Map();\n for (const raw of body) {\n const node = raw?.type === \"ExportNamedDeclaration\" ? raw.declaration : raw;\n if (!node) continue;\n switch (node.type) {\n case \"TSTypeAliasDeclaration\":\n case \"TypeAlias\":\n case \"TSInterfaceDeclaration\":\n case \"InterfaceDeclaration\":\n if (node.id?.name) out.set(node.id.name, node);\n break;\n }\n }\n return out;\n}\nfunction flattenMembers(typeName, decls, seen = /* @__PURE__ */ new Set()) {\n if (typeName === \"ViewProps\" || seen.has(typeName)) return [];\n seen.add(typeName);\n const decl = decls.get(typeName);\n if (!decl) return [];\n const out = [];\n const heritage = decl.extends ?? decl.heritage ?? [];\n for (const h of heritage) {\n const name = readTypeName(h.id ?? h.expression ?? h.typeName);\n if (name) out.push(...flattenMembers(name, decls, seen));\n }\n const bodyNode = decl.body ?? // interface\n decl.right ?? // type alias\n decl.typeAnnotation;\n out.push(...readObjectMembers(bodyNode, decls, seen));\n return out;\n}\nfunction readObjectMembers(node, decls, seen) {\n if (!node) return [];\n if (node.type === \"TSTypeReference\" || node.type === \"GenericTypeAnnotation\") {\n const name = readTypeName(node.typeName ?? node.id);\n const args = (node.typeArguments ?? node.typeParameters)?.params ?? [];\n if (TRANSPARENT.has(name) && args.length) {\n return readObjectMembers(args[0], decls, seen);\n }\n return flattenMembers(name, decls, seen);\n }\n if (node.type === \"TSIntersectionType\" || node.type === \"IntersectionTypeAnnotation\") {\n const out2 = [];\n for (const t of node.types ?? []) out2.push(...readObjectMembers(t, decls, seen));\n return out2;\n }\n const members = node.members ?? node.body ?? node.properties ?? [];\n const out = [];\n for (const m of members) {\n switch (m.type) {\n case \"TSPropertySignature\":\n case \"ObjectTypeProperty\": {\n const name = m.key?.name ?? m.key?.value;\n if (!name) break;\n out.push({ name, type: readType(m.typeAnnotation ?? m.value) });\n break;\n }\n // flow's `...OtherProps` inside an object type\n case \"ObjectTypeSpreadProperty\": {\n const name = readTypeName(m.argument?.id ?? m.argument);\n if (name) out.push(...flattenMembers(name, decls, seen));\n break;\n }\n }\n }\n return out;\n}\nfunction findComponentCall(body) {\n for (const node of body) {\n if (node.type !== \"ExportDefaultDeclaration\") continue;\n let expr = node.declaration;\n while (expr) {\n if (expr.type === \"CallExpression\") break;\n expr = expr.expression ?? (expr.type === \"SequenceExpression\" ? expr.expressions[expr.expressions.length - 1] : null);\n }\n if (expr?.type === \"CallExpression\" && expr.callee?.name === \"codegenNativeComponent\") {\n return expr;\n }\n }\n return null;\n}\nfunction findCommandsCall(body) {\n for (const raw of body) {\n const node = raw?.type === \"ExportNamedDeclaration\" ? raw.declaration : raw;\n const decl = node?.declarations?.[0];\n let init = decl?.init;\n while (init && init.type !== \"CallExpression\") init = init.expression;\n if (init?.type === \"CallExpression\" && init.callee?.name === \"codegenNativeCommands\") {\n return init;\n }\n }\n return null;\n}\nfunction readStringOption(objectExpression, key) {\n for (const p of objectExpression?.properties ?? []) {\n if ((p.key?.name ?? p.key?.value) === key && typeof p.value?.value === \"string\") {\n return p.value.value;\n }\n }\n return null;\n}\nfunction readCommands(call, decls) {\n const typeName = readTypeName(\n (call.typeArguments ?? call.typeParameters)?.params?.[0]?.typeName ?? (call.typeArguments ?? call.typeParameters)?.params?.[0]?.id\n );\n const supported = [];\n for (const p of call.arguments?.[0]?.properties ?? []) {\n if ((p.key?.name ?? p.key?.value) !== \"supportedCommands\") continue;\n for (const el of p.value?.elements ?? []) {\n if (typeof el?.value === \"string\") supported.push(el.value);\n }\n }\n if (!supported.length) return [];\n const decl = decls.get(typeName);\n const byName = /* @__PURE__ */ new Map();\n const commandMembers = decl?.body?.body ?? decl?.body?.members ?? decl?.body?.properties ?? [];\n for (const m of commandMembers) {\n const name = m.key?.name ?? m.key?.value;\n if (!name) continue;\n const fn = m.type === \"TSMethodSignature\" ? m : m.typeAnnotation?.typeAnnotation ?? m.value ?? m.typeAnnotation;\n const params = (fn?.params ?? fn?.parameters ?? []).slice(1);\n byName.set(\n name,\n params.map((p, i) => p.name?.name ?? p.name ?? `arg${i}`)\n );\n }\n return supported.map((name) => ({ name, params: byName.get(name) ?? [] }));\n}\nfunction indent(text, spaces) {\n const pad = \" \".repeat(spaces);\n return text.split(\"\\n\").map((line, i) => i === 0 || line === \"\" ? line : pad + line).join(\"\\n\");\n}\nfunction printViewConfig(componentName, attributes, events) {\n const lines = [` uiViewClassName: ${JSON.stringify(componentName)}`];\n const bubbling = events.filter((e) => e.bubbling);\n if (bubbling.length) {\n lines.push(\n ` bubblingEventTypes: {\n${bubbling.map(\n (e) => ` ${e.topName}: {\n phasedRegistrationNames: {\n captured: ${JSON.stringify(\n `${e.name}Capture`\n )},\n bubbled: ${JSON.stringify(e.name)}\n }\n }`\n ).join(\",\\n\")}\n }`\n );\n }\n const direct = events.filter((e) => !e.bubbling);\n if (direct.length) {\n lines.push(\n ` directEventTypes: {\n${direct.map(\n (e) => ` ${e.topName}: {\n registrationName: ${JSON.stringify(e.name)}\n }`\n ).join(\",\\n\")}\n }`\n );\n }\n const attrLines = attributes.map((a) => ` ${a.name}: ${indent(a.value, 4)}`);\n if (events.length) {\n attrLines.push(\n ` ...ConditionallyIgnoredEventHandlers({\n${events.map((e) => ` ${e.name}: true`).join(\",\\n\")}\n })`\n );\n }\n lines.push(\n attrLines.length ? ` validAttributes: {\n${attrLines.join(\",\\n\")}\n }` : \" validAttributes: {}\"\n );\n return `{\n${lines.join(\",\\n\")}\n}`;\n}\nfunction printCommands(commands) {\n return `export const Commands = {\n${commands.map(\n (c) => ` ${c.name}(ref${c.params.map((p) => `, ${p}`).join(\"\")}) {\n dispatchCommand(ref, ${JSON.stringify(\n c.name\n )}, [${c.params.join(\", \")}]);\n }`\n ).join(\",\\n\")}\n};`;\n}\nconst FILE_HEADER = `/**\n * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).\n *\n * Do not edit this file as changes may cause incorrect behavior and will be lost\n * once the code is regenerated.\n *\n * @flow\n *\n * @generated by codegen project: GenerateViewConfigJs.js\n */\n\n'use strict';\n`;\nfunction parseSpec(code, filename) {\n const isTS = /\\.[cm]?tsx?$/.test(filename);\n if (isTS) {\n const result = parseSync(filename, code, {\n lang: filename.endsWith(\"x\") ? \"tsx\" : \"ts\"\n });\n if (result.errors?.length) return null;\n return result.program;\n }\n const hermes = getHermesParser();\n if (!hermes) return null;\n try {\n return hermes.parse(code, {\n babel: false,\n flow: \"all\",\n sourceFilename: filename\n });\n } catch {\n return null;\n }\n}\nfunction generateViewConfig(program) {\n const body = program?.body;\n if (!body) return null;\n const call = findComponentCall(body);\n if (!call) return null;\n const componentNameArg = call.arguments?.[0];\n if (typeof componentNameArg?.value !== \"string\") return null;\n const componentName = componentNameArg.value;\n const options = call.arguments?.[1];\n const paperComponentName = readStringOption(options, \"paperComponentName\");\n const paperComponentNameDeprecated = readStringOption(\n options,\n \"paperComponentNameDeprecated\"\n );\n const propsTypeName = readTypeName(\n (call.typeArguments ?? call.typeParameters)?.params?.[0]?.typeName ?? (call.typeArguments ?? call.typeParameters)?.params?.[0]?.id\n );\n if (!propsTypeName) return null;\n const decls = collectDeclarations(body);\n const members = flattenMembers(propsTypeName, decls);\n const attributes = [];\n const events = [];\n for (const m of members) {\n const event = eventOf(m.name, m.type);\n if (event) {\n events.push(event);\n continue;\n }\n attributes.push({ name: m.name, value: attributeValue(m.type) });\n }\n const commandsCall = findCommandsCall(body);\n const commands = commandsCall ? readCommands(commandsCall, decls) : [];\n const imports = /* @__PURE__ */ new Set([IMPORT_REGISTRY]);\n if (events.length) imports.add(IMPORT_IGNORE);\n if (commands.length) imports.add(IMPORT_DISPATCH);\n if (paperComponentNameDeprecated) imports.add(IMPORT_UIMANAGER);\n const nativeName = paperComponentName ?? componentName;\n const parts = [`let nativeComponentName = '${nativeName}';`];\n if (paperComponentNameDeprecated) {\n parts.push(\n `if (UIManager.hasViewManagerConfig('${componentName}')) {\n nativeComponentName = '${componentName}';\n} else if (UIManager.hasViewManagerConfig('${paperComponentNameDeprecated}')) {\n nativeComponentName = '${paperComponentNameDeprecated}';\n} else {\n throw new Error('Failed to find native component for either \"${componentName}\" or \"${paperComponentNameDeprecated}\"');\n}`\n );\n }\n parts.push(\n `export const __INTERNAL_VIEW_CONFIG = ${printViewConfig(nativeName, attributes, events)};`\n );\n parts.push(\n \"export default NativeComponentRegistry.get(nativeComponentName, () => __INTERNAL_VIEW_CONFIG);\"\n );\n if (commands.length) parts.push(printCommands(commands));\n return { imports: [...imports].sort(), body: parts.join(\"\\n\") };\n}\nfunction renderViewConfigModule(result) {\n return `\n${FILE_HEADER}\n${result.imports.join(\"\\n\")}\n\n${result.body}\n`;\n}\nfunction getLibraryName(filename) {\n const base = basename(filename);\n const replaced = base.replace(/NativeComponent\\.[cm]?[jt]sx?$/, \"\");\n return replaced === base ? base.replace(/\\.[cm]?[jt]sx?$/, \"\") : replaced;\n}\nexport {\n generateViewConfig,\n getLibraryName,\n parseSpec,\n renderViewConfigModule\n};\n//# sourceMappingURL=reactNativeViewConfig.js.map\n"],"mappings":";;;;;AAGA,MAAM,WAAW,OAAO,eAAe,cAAc,aAAa,YAAY;AAC9E,MAAM,kBAAkB;AACxB,MAAM,wBAAwB;AAC9B,MAAM,kBAAkB;AACxB,MAAM,kBAAkB;AACxB,MAAM,wBAAwB;AAC9B,MAAM,kBAAkB;AACxB,MAAM,gBAAgB;AACtB,MAAM,kBAAkB;AACxB,MAAM,mBAAmB;AACzB,IAAI,eAAe,KAAK;AACxB,SAAS,kBAAkB;CACzB,IAAI,iBAAiB,KAAK,GAAG;EAC3B,IAAI;GACF,eAAe,cAAc,QAAQ,CAAC,CAAC,eAAe;EACxD,QAAQ;GACN,eAAe;EACjB;CACF;CACA,OAAO;AACT;AACA,SAAS,SAAS,MAAM;CACtB,IAAI,CAAC,MAAM,OAAO;EAAE,MAAM;EAAI,MAAM,CAAC;CAAE;CACvC,QAAQ,KAAK,MAAb;EAEE,KAAK;EACL,KAAK,kBACH,OAAO,SAAS,KAAK,cAAc;EACrC,KAAK,yBACH,OA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ChC,cAAc;6CACI,6BAA6B;2BAC/C,6BAA6B;;iEAES,cAAc,QAAQ,6BAA6B;EAEhH;CACF;CACA,MAAM,KACJ,yCAAyC,gBAAgB,YAAY,YAAY,MAAM,EAAE,EAC3F;CACA,MAAM,KACJ,gGACF;CACA,IAAI,SAAS,QAAQ,MAAM,KAAK,cAAc,QAAQ,CAAC;CACvD,OAAO;EAAE,SAAS,CAAC,GAAG,OAAO,CAAC,CAAC,KAAK;EAAG,MAAM,MAAM,KAAK,IAAI;CAAE;AAChE;AACA,SAAS,uBAAuB,QAAQ;CACtC,OAAO;EACP,YAAY;EACZ,OAAO,QAAQ,KAAK,IAAI,EAAE;;EAE1B,OAAO,KAAK;;AAEd;AACA,SAAS,eAAe,UAAU;CAChC,MAAM,OAAO,SAAS,QAAQ;CAC9B,MAAM,WAAW,KAAK,QAAQ,kCAAkC,EAAE;CAClE,OAAO,aAAa,OAAO,KAAK,QAAQ,mBAAmB,EAAE,IAAI;AACnE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vxrn/compiler",
3
- "version": "2.17.0",
3
+ "version": "2.17.2",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  "./package.json": "./package.json",
@@ -42,8 +42,8 @@
42
42
  "@babel/plugin-transform-regenerator": "^7.28.4",
43
43
  "@jridgewell/remapping": "^2.3.0",
44
44
  "@swc/core": "1.16.18",
45
- "@vxrn/utils": "2.17.0",
46
- "@vxrn/vite-native-client": "2.17.0",
45
+ "@vxrn/utils": "2.17.2",
46
+ "@vxrn/vite-native-client": "2.17.2",
47
47
  "astring": "1.9.0",
48
48
  "babel-plugin-react-compiler": "^1.0.0",
49
49
  "babel-plugin-syntax-hermes-parser": "^0.37.0",
@@ -80,7 +80,7 @@
80
80
  "publishConfig": {
81
81
  "access": "public"
82
82
  },
83
- "releaseSourceCommit": "3b9704636a5a718fd58951d0e3bf5007cb6137fa",
83
+ "releaseSourceCommit": "0f6102eec6ca3a2dbc4bb5efa6a2fbcf6f9871b8",
84
84
  "repository": {
85
85
  "type": "git",
86
86
  "url": "git+https://github.com/onejs/one.git",
@@ -78,8 +78,7 @@ export function isReactNativeCodegenSpec(id: string, code: string) {
78
78
 
79
79
  export function transformReactNativeCodegen(
80
80
  code: string,
81
- id: string,
82
- projectRoot?: string
81
+ id: string
83
82
  ): { code: string; map: any } | null | undefined {
84
83
  const cleanId = normalizePath(id.split('?')[0])
85
84
 
@@ -92,7 +91,7 @@ export function transformReactNativeCodegen(
92
91
  return
93
92
  }
94
93
 
95
- const program = parseSpec(code, cleanId, projectRoot)
94
+ const program = parseSpec(code, cleanId)
96
95
  const body = program?.body
97
96
  if (!body) {
98
97
  return
@@ -18,7 +18,7 @@
18
18
  */
19
19
 
20
20
  import { createRequire } from 'node:module'
21
- import { basename, join } from 'node:path'
21
+ import { basename } from 'node:path'
22
22
  import { parseSync } from 'oxc-parser'
23
23
 
24
24
  const SELF_URL: string = typeof __filename !== 'undefined' ? __filename : import.meta.url
@@ -55,19 +55,12 @@ type TypeRef = { name: string; args: TypeRef[] }
55
55
 
56
56
  let hermesParser: any = undefined
57
57
 
58
- function getHermesParser(projectRoot?: string) {
58
+ function getHermesParser() {
59
59
  if (hermesParser === undefined) {
60
60
  try {
61
- const req = projectRoot
62
- ? createRequire(join(projectRoot, 'package.json'))
63
- : createRequire(SELF_URL)
64
- hermesParser = req('hermes-parser')
61
+ hermesParser = createRequire(SELF_URL)('hermes-parser')
65
62
  } catch {
66
- try {
67
- hermesParser = createRequire(SELF_URL)('hermes-parser')
68
- } catch {
69
- hermesParser = null
70
- }
63
+ hermesParser = null
71
64
  }
72
65
  }
73
66
  return hermesParser
@@ -496,7 +489,7 @@ const FILE_HEADER = `/**
496
489
  // entry
497
490
  // ---------------------------------------------------------------------------
498
491
 
499
- export function parseSpec(code: string, filename: string, projectRoot?: string): any {
492
+ export function parseSpec(code: string, filename: string): any {
500
493
  const isTS = /\.[cm]?tsx?$/.test(filename)
501
494
  if (isTS) {
502
495
  const result = parseSync(filename, code, {
@@ -506,7 +499,7 @@ export function parseSpec(code: string, filename: string, projectRoot?: string):
506
499
  return result.program
507
500
  }
508
501
 
509
- const hermes = getHermesParser(projectRoot)
502
+ const hermes = getHermesParser()
510
503
  if (!hermes) return null
511
504
  try {
512
505
  // `babel: false` keeps this on hermes' own ESTree output, which is what
@@ -1,5 +1,5 @@
1
1
  export declare function isReactNativeCodegenSpec(id: string, code: string): boolean;
2
- export declare function transformReactNativeCodegen(code: string, id: string, projectRoot?: string): {
2
+ export declare function transformReactNativeCodegen(code: string, id: string): {
3
3
  code: string;
4
4
  map: any;
5
5
  } | null | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"reactNativeCodegen.d.ts","sourceRoot":"","sources":["../src/reactNativeCodegen.ts"],"names":[],"mappings":"AA0EA,wBAAgB,wBAAwB,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,WAEhE;AAED,wBAAgB,2BAA2B,CACzC,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,MAAM,EACV,WAAW,CAAC,EAAE,MAAM,GACnB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,GAAG,CAAA;CAAE,GAAG,IAAI,GAAG,SAAS,CAmG/C"}
1
+ {"version":3,"file":"reactNativeCodegen.d.ts","sourceRoot":"","sources":["../src/reactNativeCodegen.ts"],"names":[],"mappings":"AA0EA,wBAAgB,wBAAwB,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,WAEhE;AAED,wBAAgB,2BAA2B,CACzC,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,MAAM,GACT;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,GAAG,CAAA;CAAE,GAAG,IAAI,GAAG,SAAS,CAmG/C"}
@@ -16,7 +16,7 @@
16
16
  * TypeScript specs are parsed with oxc. React Native's own specs are Flow, which
17
17
  * oxc cannot parse, so those go through hermes-parser (which is not babel).
18
18
  */
19
- export declare function parseSpec(code: string, filename: string, projectRoot?: string): any;
19
+ export declare function parseSpec(code: string, filename: string): any;
20
20
  /**
21
21
  * Generate the replacement for a spec's default export, plus the `Commands`
22
22
  * export when the spec declares one. Returns null when the file is not a spec
@@ -1 +1 @@
1
- {"version":3,"file":"reactNativeViewConfig.d.ts","sourceRoot":"","sources":["../src/reactNativeViewConfig.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAieH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,GAAG,CAuBnF;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,GAAG,GACX;IAAE,OAAO,EAAE,MAAM,EAAE,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAsE5C;AAED,kFAAkF;AAClF,wBAAgB,sBAAsB,CAAC,MAAM,EAAE;IAAE,OAAO,EAAE,MAAM,EAAE,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,UAEjF;AAED,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAIvD"}
1
+ {"version":3,"file":"reactNativeViewConfig.d.ts","sourceRoot":"","sources":["../src/reactNativeViewConfig.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AA0dH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,GAAG,CAuB7D;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,GAAG,GACX;IAAE,OAAO,EAAE,MAAM,EAAE,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAsE5C;AAED,kFAAkF;AAClF,wBAAgB,sBAAsB,CAAC,MAAM,EAAE;IAAE,OAAO,EAAE,MAAM,EAAE,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,UAEjF;AAED,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAIvD"}