tempo-sdk 0.0.13 → 0.0.15

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.
@@ -1,9 +1,7 @@
1
1
  "use strict";
2
- var __create = Object.create;
3
2
  var __defProp = Object.defineProperty;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
6
  var __export = (target, all) => {
9
7
  for (var name in all)
@@ -17,14 +15,6 @@ var __copyProps = (to, from, except, desc) => {
17
15
  }
18
16
  return to;
19
17
  };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
19
 
30
20
  // expo-babel-plugin.ts
@@ -34,8 +24,8 @@ __export(expo_babel_plugin_exports, {
34
24
  tempoExpoBabelPlugin: () => tempoExpoBabelPlugin
35
25
  });
36
26
  module.exports = __toCommonJS(expo_babel_plugin_exports);
37
- var import_node_fs4 = require("fs");
38
- var import_node_path4 = require("path");
27
+ var import_node_fs2 = require("fs");
28
+ var import_node_path2 = require("path");
39
29
  var import_pluginutils = require("@rollup/pluginutils");
40
30
 
41
31
  // annotation-strategy.ts
@@ -91,7 +81,6 @@ function computeTempoAnnotatedProps(params) {
91
81
  filepath,
92
82
  modifiedtsMs,
93
83
  computeAnnotatedProps,
94
- typeInfo,
95
84
  elementSupportOverrides
96
85
  } = params;
97
86
  const userProps = computeAnnotatedProps ? computeAnnotatedProps(info, filepath, modifiedtsMs) : defaultComputeAnnotatedProps(info, filepath, modifiedtsMs);
@@ -108,24 +97,13 @@ function computeTempoAnnotatedProps(params) {
108
97
  if (override) {
109
98
  return {
110
99
  ...userProps,
111
- "data-tempo-supports-style": override.supportsStyle,
112
- "data-tempo-supports-classname": override.supportsClassName,
113
100
  "data-tempo-supports-children": hasJsxAttribute(
114
101
  info,
115
102
  "data-tempo-supports-children"
116
103
  ) ? void 0 : override.supportsChildren
117
104
  };
118
105
  }
119
- const support = typeInfo?.get(info.element.openingElement.start);
120
- return {
121
- ...userProps,
122
- "data-tempo-supports-style": support?.supportsStyle ?? false,
123
- "data-tempo-supports-classname": support?.supportsClassName ?? false,
124
- "data-tempo-supports-children": hasJsxAttribute(
125
- info,
126
- "data-tempo-supports-children"
127
- ) ? void 0 : support?.supportsChildren ?? false
128
- };
106
+ return userProps;
129
107
  }
130
108
  function getFileAnnotationContext(params) {
131
109
  const rawCleanFilename = cleanModuleId(params.filename);
@@ -144,557 +122,10 @@ function getFileAnnotationContext(params) {
144
122
  };
145
123
  }
146
124
 
147
- // type-analyzer.ts
148
- var import_typescript2 = __toESM(require("typescript"), 1);
149
- var import_node_path3 = __toESM(require("path"), 1);
150
- var import_node_fs3 = require("fs");
151
-
152
- // ../../modules/typescript/workspace-service.ts
153
- var import_node_fs2 = require("fs");
154
- var import_node_path2 = __toESM(require("path"), 1);
155
- var import_typescript = __toESM(require("typescript"), 1);
156
- function canonicalPath(input) {
157
- const resolved = import_node_path2.default.resolve(input);
158
- try {
159
- return import_node_fs2.realpathSync.native(resolved);
160
- } catch {
161
- return resolved;
162
- }
163
- }
164
- function compareProjectPriority(left, right) {
165
- const depthDelta = right.rootDir.length - left.rootDir.length;
166
- if (depthDelta !== 0) {
167
- return depthDelta;
168
- }
169
- const priorityDelta = right.priority - left.priority;
170
- if (priorityDelta !== 0) {
171
- return priorityDelta;
172
- }
173
- return left.id.localeCompare(right.id);
174
- }
175
- function isWithinRoot(filePath, rootDir) {
176
- return filePath === rootDir || filePath.startsWith(`${rootDir}${import_node_path2.default.sep}`);
177
- }
178
- function loadProject(descriptor) {
179
- const id = descriptor.id.trim();
180
- if (!id) {
181
- throw new Error("Project id must be a non-empty string");
182
- }
183
- const tsconfigPath = canonicalPath(descriptor.tsconfigPath);
184
- const rootDir = canonicalPath(descriptor.rootDir);
185
- const readResult = import_typescript.default.readConfigFile(tsconfigPath, import_typescript.default.sys.readFile);
186
- if (readResult.error) {
187
- throw new Error(
188
- `Failed to read tsconfig at ${tsconfigPath}: ${import_typescript.default.flattenDiagnosticMessageText(
189
- readResult.error.messageText,
190
- "\n"
191
- )}`
192
- );
193
- }
194
- const parsed = import_typescript.default.parseJsonConfigFileContent(
195
- readResult.config,
196
- import_typescript.default.sys,
197
- import_node_path2.default.dirname(tsconfigPath)
198
- );
199
- if (parsed.errors.length > 0) {
200
- const message = parsed.errors.map(
201
- (diagnostic) => import_typescript.default.flattenDiagnosticMessageText(diagnostic.messageText, "\n")
202
- ).join("; ");
203
- throw new Error(`Failed to parse tsconfig at ${tsconfigPath}: ${message}`);
204
- }
205
- const normalizedFiles = parsed.fileNames.map(
206
- (fileName) => canonicalPath(fileName)
207
- );
208
- return {
209
- id,
210
- rootDir,
211
- tsconfigPath,
212
- priority: descriptor.priority ?? 0,
213
- options: parsed.options,
214
- fileNames: normalizedFiles,
215
- moduleResolutionCache: import_typescript.default.createModuleResolutionCache(
216
- rootDir,
217
- (value) => value,
218
- parsed.options
219
- )
220
- };
221
- }
222
- function getFileMtimeVersion(filePath) {
223
- try {
224
- const stats = (0, import_node_fs2.statSync)(filePath);
225
- return String(stats.mtimeMs);
226
- } catch {
227
- return "0";
228
- }
229
- }
230
- function createTsWorkspaceService(descriptor) {
231
- if (descriptor.projects.length === 0) {
232
- throw new Error(
233
- "TsWorkspaceDescriptor.projects must include at least one project"
234
- );
235
- }
236
- const workspaceRoot = canonicalPath(descriptor.workspaceRoot);
237
- const loadedProjects = descriptor.projects.map(
238
- (project) => loadProject(project)
239
- );
240
- const projectsById = /* @__PURE__ */ new Map();
241
- for (const project of loadedProjects) {
242
- if (projectsById.has(project.id)) {
243
- throw new Error(`Duplicate project id: ${project.id}`);
244
- }
245
- projectsById.set(project.id, project);
246
- }
247
- const primaryProject = (descriptor.primaryProjectId ? projectsById.get(descriptor.primaryProjectId) : null) ?? loadedProjects[0];
248
- if (descriptor.primaryProjectId && !projectsById.has(descriptor.primaryProjectId)) {
249
- throw new Error(
250
- `Primary project id not found: ${descriptor.primaryProjectId}`
251
- );
252
- }
253
- const orderedProjects = [...loadedProjects].sort(compareProjectPriority);
254
- const rootFileNames = /* @__PURE__ */ new Set();
255
- for (const project of loadedProjects) {
256
- for (const fileName of project.fileNames) {
257
- rootFileNames.add(fileName);
258
- }
259
- }
260
- const inMemoryFiles = /* @__PURE__ */ new Map();
261
- let projectVersion = 0;
262
- function getOwningProject(filePath) {
263
- const canonicalFilePath = canonicalPath(filePath);
264
- for (const project of orderedProjects) {
265
- if (isWithinRoot(canonicalFilePath, project.rootDir)) {
266
- return project;
267
- }
268
- }
269
- return primaryProject;
270
- }
271
- const moduleResolutionHost = {
272
- fileExists: import_typescript.default.sys.fileExists,
273
- readFile: import_typescript.default.sys.readFile,
274
- realpath: import_typescript.default.sys.realpath,
275
- directoryExists: import_typescript.default.sys.directoryExists,
276
- getCurrentDirectory: () => workspaceRoot,
277
- getDirectories: import_typescript.default.sys.getDirectories
278
- };
279
- const host = {
280
- getScriptFileNames: () => Array.from(rootFileNames),
281
- getScriptVersion: (filePath) => {
282
- const canonicalFilePath = canonicalPath(filePath);
283
- const inMemory = inMemoryFiles.get(canonicalFilePath);
284
- if (inMemory) {
285
- return String(inMemory.version);
286
- }
287
- return getFileMtimeVersion(canonicalFilePath);
288
- },
289
- getScriptSnapshot: (filePath) => {
290
- const canonicalFilePath = canonicalPath(filePath);
291
- const inMemory = inMemoryFiles.get(canonicalFilePath);
292
- if (inMemory) {
293
- return import_typescript.default.ScriptSnapshot.fromString(inMemory.content);
294
- }
295
- const diskContent = import_typescript.default.sys.readFile(canonicalFilePath);
296
- if (diskContent === void 0) {
297
- return void 0;
298
- }
299
- return import_typescript.default.ScriptSnapshot.fromString(diskContent);
300
- },
301
- getCurrentDirectory: () => workspaceRoot,
302
- getCompilationSettings: () => primaryProject.options,
303
- getDefaultLibFileName: (options) => import_typescript.default.getDefaultLibFilePath(options),
304
- fileExists: import_typescript.default.sys.fileExists,
305
- readFile: import_typescript.default.sys.readFile,
306
- readDirectory: import_typescript.default.sys.readDirectory,
307
- directoryExists: import_typescript.default.sys.directoryExists,
308
- getDirectories: import_typescript.default.sys.getDirectories,
309
- useCaseSensitiveFileNames: () => import_typescript.default.sys.useCaseSensitiveFileNames,
310
- getProjectVersion: () => String(projectVersion),
311
- resolveModuleNames: (moduleNames, containingFile) => {
312
- const owningProject = getOwningProject(containingFile);
313
- return moduleNames.map((moduleName) => {
314
- const ownerResolution = import_typescript.default.resolveModuleName(
315
- moduleName,
316
- containingFile,
317
- owningProject.options,
318
- moduleResolutionHost,
319
- owningProject.moduleResolutionCache
320
- ).resolvedModule;
321
- if (ownerResolution) {
322
- return ownerResolution;
323
- }
324
- if (owningProject.id === primaryProject.id) {
325
- return void 0;
326
- }
327
- return import_typescript.default.resolveModuleName(
328
- moduleName,
329
- containingFile,
330
- primaryProject.options,
331
- moduleResolutionHost,
332
- primaryProject.moduleResolutionCache
333
- ).resolvedModule;
334
- });
335
- }
336
- };
337
- const languageService = import_typescript.default.createLanguageService(
338
- host,
339
- import_typescript.default.createDocumentRegistry()
340
- );
341
- return {
342
- updateFile(filePath, content) {
343
- const canonicalFilePath = canonicalPath(filePath);
344
- const currentVersion = inMemoryFiles.get(canonicalFilePath)?.version ?? 0;
345
- inMemoryFiles.set(canonicalFilePath, {
346
- version: currentVersion + 1,
347
- content
348
- });
349
- if (!rootFileNames.has(canonicalFilePath)) {
350
- rootFileNames.add(canonicalFilePath);
351
- }
352
- projectVersion += 1;
353
- },
354
- closeFile(filePath) {
355
- const canonicalFilePath = canonicalPath(filePath);
356
- inMemoryFiles.delete(canonicalFilePath);
357
- projectVersion += 1;
358
- },
359
- getProgram() {
360
- return languageService.getProgram() ?? null;
361
- },
362
- getSemanticDiagnostics(filePath) {
363
- const canonicalFilePath = canonicalPath(filePath);
364
- return languageService.getSemanticDiagnostics(canonicalFilePath);
365
- },
366
- getDefinition(filePath, position) {
367
- const canonicalFilePath = canonicalPath(filePath);
368
- return languageService.getDefinitionAtPosition(
369
- canonicalFilePath,
370
- position
371
- );
372
- },
373
- dispose() {
374
- languageService.dispose();
375
- }
376
- };
377
- }
378
-
379
- // type-analyzer.ts
380
- function isCustomComponent(node) {
381
- const text = node.getText();
382
- return text.length > 0 && text[0] !== text[0].toLowerCase();
383
- }
384
- function canonicalPath2(value) {
385
- const resolved = import_node_path3.default.resolve(value);
386
- try {
387
- return import_node_fs3.realpathSync.native(resolved);
388
- } catch {
389
- return resolved;
390
- }
391
- }
392
- function parseManagedTsconfigPaths(rawConfig) {
393
- if (!rawConfig || typeof rawConfig !== "object" || Array.isArray(rawConfig)) {
394
- return [];
395
- }
396
- const metadata = rawConfig.tempobook;
397
- if (!metadata || typeof metadata !== "object" || Array.isArray(metadata)) {
398
- return [];
399
- }
400
- const managedPaths = metadata.managedTsconfigPaths;
401
- if (!Array.isArray(managedPaths)) {
402
- return [];
403
- }
404
- return managedPaths.filter(
405
- (entry) => typeof entry === "string" && entry.trim().length > 0
406
- );
407
- }
408
- function parseProjectReferenceTsconfigPaths(references, configDir) {
409
- if (!references || references.length === 0) {
410
- return [];
411
- }
412
- const entries = [];
413
- for (const reference of references) {
414
- const referencePath = reference.path;
415
- if (!referencePath) {
416
- continue;
417
- }
418
- const resolvedPath = import_node_path3.default.resolve(configDir, referencePath);
419
- const tsconfigPath = resolvedPath.endsWith(".json") ? resolvedPath : import_node_path3.default.join(resolvedPath, "tsconfig.json");
420
- entries.push(tsconfigPath);
421
- }
422
- return entries;
423
- }
424
- function buildWorkspaceProjects(root, configPath, parsedConfig, rawConfig) {
425
- const configDir = import_node_path3.default.dirname(configPath);
426
- const projects = [
427
- {
428
- id: "root",
429
- rootDir: root,
430
- tsconfigPath: configPath,
431
- priority: 0
432
- }
433
- ];
434
- const seenTsconfigPaths = /* @__PURE__ */ new Set([canonicalPath2(configPath)]);
435
- const referencedTsconfigPaths = parseProjectReferenceTsconfigPaths(
436
- parsedConfig.projectReferences,
437
- configDir
438
- );
439
- const managedTsconfigPaths = parseManagedTsconfigPaths(rawConfig).map(
440
- (entry) => import_node_path3.default.resolve(configDir, entry)
441
- );
442
- const candidateTsconfigPaths = [
443
- ...managedTsconfigPaths,
444
- ...referencedTsconfigPaths
445
- ];
446
- for (const candidatePath of candidateTsconfigPaths) {
447
- const normalizedPath = canonicalPath2(candidatePath);
448
- if (seenTsconfigPaths.has(normalizedPath)) {
449
- continue;
450
- }
451
- if (!import_typescript2.default.sys.fileExists(normalizedPath)) {
452
- continue;
453
- }
454
- seenTsconfigPaths.add(normalizedPath);
455
- projects.push({
456
- id: `external-${projects.length}`,
457
- rootDir: import_node_path3.default.dirname(normalizedPath),
458
- tsconfigPath: normalizedPath,
459
- priority: 0
460
- });
461
- }
462
- return projects;
463
- }
464
- function createTypeAnalyzer(root) {
465
- const configPath = import_typescript2.default.findConfigFile(
466
- root,
467
- import_typescript2.default.sys.fileExists,
468
- "tsconfig.json"
469
- );
470
- if (!configPath) return null;
471
- const configFile = import_typescript2.default.readConfigFile(configPath, import_typescript2.default.sys.readFile);
472
- if (configFile.error) return null;
473
- const parsedConfig = import_typescript2.default.parseJsonConfigFileContent(
474
- configFile.config,
475
- import_typescript2.default.sys,
476
- root
477
- );
478
- const workspaceProjects = buildWorkspaceProjects(
479
- root,
480
- configPath,
481
- parsedConfig,
482
- configFile.config
483
- );
484
- const workspaceProjectRoots = workspaceProjects.map(
485
- (project) => canonicalPath2(project.rootDir)
486
- );
487
- const workspaceService = createTsWorkspaceService({
488
- workspaceRoot: root,
489
- primaryProjectId: "root",
490
- projects: workspaceProjects
491
- });
492
- let cssPropertiesType;
493
- function resolveCSSPropertiesType(checker, sourceFile) {
494
- if (cssPropertiesType !== void 0) return cssPropertiesType;
495
- try {
496
- let jsxNs = checker.resolveName(
497
- "JSX",
498
- sourceFile,
499
- import_typescript2.default.SymbolFlags.Namespace,
500
- false
501
- );
502
- if (!jsxNs) {
503
- const program = workspaceService.getProgram();
504
- const compilerOptions = program?.getCompilerOptions();
505
- const jsxImportSource = compilerOptions?.jsxImportSource ?? "react";
506
- const resolved = import_typescript2.default.resolveModuleName(
507
- `${jsxImportSource}/jsx-runtime`,
508
- sourceFile.fileName,
509
- compilerOptions,
510
- import_typescript2.default.sys
511
- );
512
- if (resolved.resolvedModule) {
513
- const runtimeFile = program?.getSourceFile(
514
- resolved.resolvedModule.resolvedFileName
515
- );
516
- if (runtimeFile) {
517
- const runtimeSymbol = checker.getSymbolAtLocation(runtimeFile);
518
- if (runtimeSymbol) {
519
- const exports2 = checker.getExportsOfModule(runtimeSymbol);
520
- jsxNs = exports2.find((s) => s.name === "JSX");
521
- }
522
- }
523
- }
524
- }
525
- if (!jsxNs) {
526
- cssPropertiesType = null;
527
- return null;
528
- }
529
- const intrinsicSym = checker.getExportsOfModule(jsxNs).find((s) => s.name === "IntrinsicElements") ?? checker.getDeclaredTypeOfSymbol(jsxNs).getProperty("IntrinsicElements");
530
- if (!intrinsicSym) {
531
- cssPropertiesType = null;
532
- return null;
533
- }
534
- const divSym = checker.getDeclaredTypeOfSymbol(intrinsicSym).getProperty("div");
535
- if (!divSym) {
536
- cssPropertiesType = null;
537
- return null;
538
- }
539
- const styleSym = checker.getTypeOfSymbol(divSym).getProperty("style");
540
- if (!styleSym) {
541
- cssPropertiesType = null;
542
- return null;
543
- }
544
- const styleType = checker.getTypeOfSymbol(styleSym);
545
- if (styleType.isUnion()) {
546
- const nonUndefined = styleType.types.find(
547
- (t) => !(t.flags & import_typescript2.default.TypeFlags.Undefined)
548
- );
549
- cssPropertiesType = nonUndefined ?? null;
550
- } else {
551
- cssPropertiesType = styleType;
552
- }
553
- } catch {
554
- cssPropertiesType = null;
555
- }
556
- return cssPropertiesType;
557
- }
558
- let reactNodeType;
559
- function resolveReactNodeType(checker, sourceFile) {
560
- if (reactNodeType !== void 0) return reactNodeType;
561
- try {
562
- let jsxNs = checker.resolveName(
563
- "JSX",
564
- sourceFile,
565
- import_typescript2.default.SymbolFlags.Namespace,
566
- false
567
- );
568
- if (!jsxNs) {
569
- const program = workspaceService.getProgram();
570
- const compilerOptions = program?.getCompilerOptions();
571
- const jsxImportSource = compilerOptions?.jsxImportSource ?? "react";
572
- const resolved = import_typescript2.default.resolveModuleName(
573
- `${jsxImportSource}/jsx-runtime`,
574
- sourceFile.fileName,
575
- compilerOptions,
576
- import_typescript2.default.sys
577
- );
578
- if (resolved.resolvedModule) {
579
- const runtimeFile = program?.getSourceFile(
580
- resolved.resolvedModule.resolvedFileName
581
- );
582
- if (runtimeFile) {
583
- const runtimeSymbol = checker.getSymbolAtLocation(runtimeFile);
584
- if (runtimeSymbol) {
585
- const exports2 = checker.getExportsOfModule(runtimeSymbol);
586
- jsxNs = exports2.find((s) => s.name === "JSX");
587
- }
588
- }
589
- }
590
- }
591
- if (!jsxNs) {
592
- reactNodeType = null;
593
- return null;
594
- }
595
- const intrinsicSym = checker.getExportsOfModule(jsxNs).find((s) => s.name === "IntrinsicElements") ?? checker.getDeclaredTypeOfSymbol(jsxNs).getProperty("IntrinsicElements");
596
- if (!intrinsicSym) {
597
- reactNodeType = null;
598
- return null;
599
- }
600
- const divSym = checker.getDeclaredTypeOfSymbol(intrinsicSym).getProperty("div");
601
- if (!divSym) {
602
- reactNodeType = null;
603
- return null;
604
- }
605
- const childrenSym = checker.getTypeOfSymbol(divSym).getProperty("children");
606
- if (!childrenSym) {
607
- reactNodeType = null;
608
- return null;
609
- }
610
- const childrenType = checker.getTypeOfSymbol(childrenSym);
611
- if (childrenType.isUnion()) {
612
- const nonUndefined = childrenType.types.find(
613
- (t) => !(t.flags & import_typescript2.default.TypeFlags.Undefined)
614
- );
615
- reactNodeType = nonUndefined ?? null;
616
- } else {
617
- reactNodeType = childrenType;
618
- }
619
- } catch {
620
- reactNodeType = null;
621
- }
622
- return reactNodeType;
623
- }
624
- return {
625
- analyzeFileTypes(filePath, source) {
626
- const canonicalFilePath = canonicalPath2(filePath);
627
- const belongsToWorkspace = workspaceProjectRoots.some(
628
- (projectRoot) => canonicalFilePath === projectRoot || canonicalFilePath.startsWith(`${projectRoot}${import_node_path3.default.sep}`)
629
- );
630
- if (!belongsToWorkspace) {
631
- return null;
632
- }
633
- workspaceService.updateFile(filePath, source);
634
- const program = workspaceService.getProgram();
635
- if (!program) return null;
636
- const sourceFile = program.getSourceFile(filePath);
637
- if (!sourceFile) return null;
638
- const checker = program.getTypeChecker();
639
- const cssProps = resolveCSSPropertiesType(checker, sourceFile);
640
- const result = /* @__PURE__ */ new Map();
641
- function visit(node) {
642
- if ((import_typescript2.default.isJsxOpeningElement(node) || import_typescript2.default.isJsxSelfClosingElement(node)) && isCustomComponent(node.tagName)) {
643
- const position = node.getStart(sourceFile);
644
- const attrsType = checker.getContextualType(node.attributes);
645
- let supportsStyle = false;
646
- let supportsClassName = false;
647
- let supportsChildren = false;
648
- if (attrsType) {
649
- const classNameProp = attrsType.getProperty("className");
650
- if (classNameProp) {
651
- const propType = checker.getTypeOfSymbol(classNameProp);
652
- supportsClassName = checker.isTypeAssignableTo(
653
- checker.getStringType(),
654
- propType
655
- );
656
- }
657
- const styleProp = attrsType.getProperty("style");
658
- if (styleProp && cssProps) {
659
- let propType = checker.getTypeOfSymbol(styleProp);
660
- if (propType.isUnion()) {
661
- const nonUndefined = propType.types.find(
662
- (t) => !(t.flags & import_typescript2.default.TypeFlags.Undefined)
663
- );
664
- if (nonUndefined) propType = nonUndefined;
665
- }
666
- supportsStyle = checker.isTypeAssignableTo(cssProps, propType);
667
- }
668
- const reactNode = resolveReactNodeType(checker, sourceFile);
669
- const childrenProp = attrsType.getProperty("children");
670
- if (childrenProp && reactNode) {
671
- let propType = checker.getTypeOfSymbol(childrenProp);
672
- if (propType.isUnion()) {
673
- const nonUndefined = propType.types.find(
674
- (t) => !(t.flags & import_typescript2.default.TypeFlags.Undefined)
675
- );
676
- if (nonUndefined) propType = nonUndefined;
677
- }
678
- supportsChildren = checker.isTypeAssignableTo(
679
- reactNode,
680
- propType
681
- );
682
- }
683
- }
684
- result.set(position, { supportsStyle, supportsClassName, supportsChildren });
685
- }
686
- import_typescript2.default.forEachChild(node, visit);
687
- }
688
- visit(sourceFile);
689
- return result;
690
- }
691
- };
692
- }
693
-
694
125
  // expo-babel-plugin.ts
695
126
  var EXPO_DEFAULT_INCLUDE = ["**/*.tsx", "**/*.jsx", "**/*.js"];
696
127
  var FRAGMENT_TAG_NAMES = /* @__PURE__ */ new Set(["Fragment", "React.Fragment"]);
697
- var REACT_NATIVE_STYLE_COMPONENTS = /* @__PURE__ */ new Set([
128
+ var REACT_NATIVE_HOST_COMPONENTS = /* @__PURE__ */ new Set([
698
129
  "ActivityIndicator",
699
130
  "Button",
700
131
  "FlatList",
@@ -724,13 +155,9 @@ var REACT_NATIVE_NO_CHILDREN_COMPONENTS = /* @__PURE__ */ new Set([
724
155
  "Switch"
725
156
  ]);
726
157
  var REACT_NATIVE_SUPPORT_OVERRIDES = new Map(
727
- [...REACT_NATIVE_STYLE_COMPONENTS].map((tagName) => [
158
+ [...REACT_NATIVE_HOST_COMPONENTS].map((tagName) => [
728
159
  tagName,
729
- {
730
- supportsStyle: true,
731
- supportsClassName: false,
732
- supportsChildren: !REACT_NATIVE_NO_CHILDREN_COMPONENTS.has(tagName)
733
- }
160
+ { supportsChildren: !REACT_NATIVE_NO_CHILDREN_COMPONENTS.has(tagName) }
734
161
  ])
735
162
  );
736
163
  function hasParserPlugin(plugins, name) {
@@ -759,17 +186,6 @@ function propValueToExpression(api, value) {
759
186
  }
760
187
  return api.types.valueToNode(value);
761
188
  }
762
- function getSupportOverrides(options) {
763
- if (!options.reactNativeClassName) {
764
- return REACT_NATIVE_SUPPORT_OVERRIDES;
765
- }
766
- return new Map(
767
- [...REACT_NATIVE_SUPPORT_OVERRIDES].map(([tagName, support]) => [
768
- tagName,
769
- { ...support, supportsClassName: true }
770
- ])
771
- );
772
- }
773
189
  function dataAttrToDataSetKey(attrName) {
774
190
  return attrName.replace(/^data-/, "").replace(/-([a-z])/g, (_, char) => char.toUpperCase());
775
191
  }
@@ -837,16 +253,16 @@ function injectProjectRootMeta(api, programPath, root) {
837
253
  }
838
254
  function resolveBabelRoot(state, options, filename) {
839
255
  return resolveCanonicalRoot(
840
- (0, import_node_path4.resolve)(
256
+ (0, import_node_path2.resolve)(
841
257
  options.root ?? findNearestPackageRoot(filename) ?? state.cwd ?? state.file.opts.cwd ?? state.file.opts.root ?? process.cwd()
842
258
  )
843
259
  );
844
260
  }
845
261
  function findNearestPackageRoot(filename) {
846
- let current = (0, import_node_path4.dirname)(filename);
262
+ let current = (0, import_node_path2.dirname)(filename);
847
263
  while (true) {
848
- if ((0, import_node_fs4.existsSync)((0, import_node_path4.resolve)(current, "package.json"))) return current;
849
- const parent = (0, import_node_path4.dirname)(current);
264
+ if ((0, import_node_fs2.existsSync)((0, import_node_path2.resolve)(current, "package.json"))) return current;
265
+ const parent = (0, import_node_path2.dirname)(current);
850
266
  if (parent === current) return null;
851
267
  current = parent;
852
268
  }
@@ -854,7 +270,7 @@ function findNearestPackageRoot(filename) {
854
270
  function resolveFilename(state) {
855
271
  const filename = state.filename ?? state.file.opts.filename;
856
272
  if (!filename) return null;
857
- return (0, import_node_path4.resolve)(cleanModuleId(filename));
273
+ return (0, import_node_path2.resolve)(cleanModuleId(filename));
858
274
  }
859
275
  function tempoExpoBabelPlugin(api, rawOptions = {}) {
860
276
  api.assertVersion(7);
@@ -862,8 +278,6 @@ function tempoExpoBabelPlugin(api, rawOptions = {}) {
862
278
  const include = rawOptions.include === void 0 ? EXPO_DEFAULT_INCLUDE : rawOptions.include;
863
279
  const exclude = rawOptions.exclude === void 0 ? DEFAULT_EXCLUDE : rawOptions.exclude;
864
280
  const filter = (0, import_pluginutils.createFilter)(include, exclude);
865
- let typeAnalyzerRoot = null;
866
- let typeAnalyzer = null;
867
281
  return {
868
282
  name: "tempo-expo-annotate",
869
283
  manipulateOptions(opts, parserOpts) {
@@ -878,7 +292,7 @@ function tempoExpoBabelPlugin(api, rawOptions = {}) {
878
292
  },
879
293
  visitor: {
880
294
  Program: {
881
- enter(path3, state) {
295
+ enter(path, state) {
882
296
  if (!enabled) return;
883
297
  const options = { ...rawOptions, ...state.opts };
884
298
  const filename = resolveFilename(state);
@@ -897,15 +311,9 @@ function tempoExpoBabelPlugin(api, rawOptions = {}) {
897
311
  return;
898
312
  }
899
313
  if (context.filepath === "index.js") {
900
- injectProjectRootMeta(api, path3, root);
901
- }
902
- if (options.typeSupport !== false && typeAnalyzerRoot !== root) {
903
- typeAnalyzerRoot = root;
904
- typeAnalyzer = createTypeAnalyzer(root);
314
+ injectProjectRootMeta(api, path, root);
905
315
  }
906
- const typeInfo = options.typeSupport === false ? null : typeAnalyzer?.analyzeFileTypes(context.cleanFilename, source);
907
- const supportOverrides = getSupportOverrides(options);
908
- path3.traverse({
316
+ path.traverse({
909
317
  JSXElement(elementPath) {
910
318
  const element = elementPath.node;
911
319
  const tagName = getBabelTagName(element.openingElement.name);
@@ -919,8 +327,7 @@ function tempoExpoBabelPlugin(api, rawOptions = {}) {
919
327
  filepath: context.filepath,
920
328
  modifiedtsMs: context.modifiedtsMs,
921
329
  computeAnnotatedProps: options.computeAnnotatedProps,
922
- typeInfo,
923
- elementSupportOverrides: supportOverrides
330
+ elementSupportOverrides: REACT_NATIVE_SUPPORT_OVERRIDES
924
331
  });
925
332
  addAnnotations(api, tagName, element.openingElement, props);
926
333
  }