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