tempo-sdk 0.0.10 → 0.0.12
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/{chunk-GHPL4LGE.js → chunk-WGGLHHC5.js} +160 -28
- package/dist/chunk-WGGLHHC5.js.map +1 -0
- package/dist/expo/plugin.cjs +27 -584
- package/dist/expo/plugin.cjs.map +1 -1
- package/dist/expo/plugin.js +1 -1
- package/dist/expo-babel-plugin.cjs +27 -584
- package/dist/expo-babel-plugin.cjs.map +1 -1
- package/dist/expo-babel-plugin.d.cts +1 -6
- package/dist/expo-babel-plugin.d.ts +1 -6
- package/dist/expo-babel-plugin.js +1 -1
- package/dist/index.d.ts +1 -22
- package/dist/index.js +5 -569
- package/dist/index.js.map +1 -1
- package/dist/nextjs-loader.cjs +15 -586
- package/dist/nextjs-loader.cjs.map +1 -1
- package/package.json +4 -6
- package/dist/annotation-strategy-DCJHc--2.d.cts +0 -13
- package/dist/annotation-strategy-DCJHc--2.d.ts +0 -13
- package/dist/chunk-2LP5G6CD.js +0 -748
- package/dist/chunk-2LP5G6CD.js.map +0 -1
- package/dist/chunk-F64WRL4H.js +0 -884
- package/dist/chunk-F64WRL4H.js.map +0 -1
- package/dist/chunk-GHPL4LGE.js.map +0 -1
- package/dist/chunk-IG3JZVZI.js +0 -846
- package/dist/chunk-IG3JZVZI.js.map +0 -1
- package/dist/chunk-X3K7Z2BH.js +0 -900
- package/dist/chunk-X3K7Z2BH.js.map +0 -1
- package/dist/chunk-ZHORRCQG.js +0 -756
- package/dist/chunk-ZHORRCQG.js.map +0 -1
- package/dist/index.cjs +0 -1170
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -99
|
@@ -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
|
|
38
|
-
var
|
|
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);
|
|
@@ -116,16 +105,7 @@ function computeTempoAnnotatedProps(params) {
|
|
|
116
105
|
) ? void 0 : override.supportsChildren
|
|
117
106
|
};
|
|
118
107
|
}
|
|
119
|
-
|
|
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
|
-
};
|
|
108
|
+
return userProps;
|
|
129
109
|
}
|
|
130
110
|
function getFileAnnotationContext(params) {
|
|
131
111
|
const rawCleanFilename = cleanModuleId(params.filename);
|
|
@@ -144,553 +124,6 @@ function getFileAnnotationContext(params) {
|
|
|
144
124
|
};
|
|
145
125
|
}
|
|
146
126
|
|
|
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
127
|
// expo-babel-plugin.ts
|
|
695
128
|
var EXPO_DEFAULT_INCLUDE = ["**/*.tsx", "**/*.jsx", "**/*.js"];
|
|
696
129
|
var FRAGMENT_TAG_NAMES = /* @__PURE__ */ new Set(["Fragment", "React.Fragment"]);
|
|
@@ -820,18 +253,33 @@ function addAnnotations(api, tagName, openingElement, props) {
|
|
|
820
253
|
]);
|
|
821
254
|
}
|
|
822
255
|
}
|
|
256
|
+
var ROOT_META_NAME = "tempo-project-root";
|
|
257
|
+
function injectProjectRootMeta(api, programPath, root) {
|
|
258
|
+
const setter = api.template.statement(`
|
|
259
|
+
if (typeof document !== "undefined") {
|
|
260
|
+
var __tempoRootMeta = document.querySelector('meta[name="${ROOT_META_NAME}"]');
|
|
261
|
+
if (!__tempoRootMeta) {
|
|
262
|
+
__tempoRootMeta = document.createElement("meta");
|
|
263
|
+
__tempoRootMeta.setAttribute("name", "${ROOT_META_NAME}");
|
|
264
|
+
document.head.appendChild(__tempoRootMeta);
|
|
265
|
+
}
|
|
266
|
+
__tempoRootMeta.setAttribute("content", ${JSON.stringify(root)});
|
|
267
|
+
}
|
|
268
|
+
`)();
|
|
269
|
+
programPath.pushContainer("body", setter);
|
|
270
|
+
}
|
|
823
271
|
function resolveBabelRoot(state, options, filename) {
|
|
824
272
|
return resolveCanonicalRoot(
|
|
825
|
-
(0,
|
|
273
|
+
(0, import_node_path2.resolve)(
|
|
826
274
|
options.root ?? findNearestPackageRoot(filename) ?? state.cwd ?? state.file.opts.cwd ?? state.file.opts.root ?? process.cwd()
|
|
827
275
|
)
|
|
828
276
|
);
|
|
829
277
|
}
|
|
830
278
|
function findNearestPackageRoot(filename) {
|
|
831
|
-
let current = (0,
|
|
279
|
+
let current = (0, import_node_path2.dirname)(filename);
|
|
832
280
|
while (true) {
|
|
833
|
-
if ((0,
|
|
834
|
-
const parent = (0,
|
|
281
|
+
if ((0, import_node_fs2.existsSync)((0, import_node_path2.resolve)(current, "package.json"))) return current;
|
|
282
|
+
const parent = (0, import_node_path2.dirname)(current);
|
|
835
283
|
if (parent === current) return null;
|
|
836
284
|
current = parent;
|
|
837
285
|
}
|
|
@@ -839,7 +287,7 @@ function findNearestPackageRoot(filename) {
|
|
|
839
287
|
function resolveFilename(state) {
|
|
840
288
|
const filename = state.filename ?? state.file.opts.filename;
|
|
841
289
|
if (!filename) return null;
|
|
842
|
-
return (0,
|
|
290
|
+
return (0, import_node_path2.resolve)(cleanModuleId(filename));
|
|
843
291
|
}
|
|
844
292
|
function tempoExpoBabelPlugin(api, rawOptions = {}) {
|
|
845
293
|
api.assertVersion(7);
|
|
@@ -847,8 +295,6 @@ function tempoExpoBabelPlugin(api, rawOptions = {}) {
|
|
|
847
295
|
const include = rawOptions.include === void 0 ? EXPO_DEFAULT_INCLUDE : rawOptions.include;
|
|
848
296
|
const exclude = rawOptions.exclude === void 0 ? DEFAULT_EXCLUDE : rawOptions.exclude;
|
|
849
297
|
const filter = (0, import_pluginutils.createFilter)(include, exclude);
|
|
850
|
-
let typeAnalyzerRoot = null;
|
|
851
|
-
let typeAnalyzer = null;
|
|
852
298
|
return {
|
|
853
299
|
name: "tempo-expo-annotate",
|
|
854
300
|
manipulateOptions(opts, parserOpts) {
|
|
@@ -863,7 +309,7 @@ function tempoExpoBabelPlugin(api, rawOptions = {}) {
|
|
|
863
309
|
},
|
|
864
310
|
visitor: {
|
|
865
311
|
Program: {
|
|
866
|
-
enter(
|
|
312
|
+
enter(path, state) {
|
|
867
313
|
if (!enabled) return;
|
|
868
314
|
const options = { ...rawOptions, ...state.opts };
|
|
869
315
|
const filename = resolveFilename(state);
|
|
@@ -881,13 +327,11 @@ function tempoExpoBabelPlugin(api, rawOptions = {}) {
|
|
|
881
327
|
} catch {
|
|
882
328
|
return;
|
|
883
329
|
}
|
|
884
|
-
if (
|
|
885
|
-
|
|
886
|
-
typeAnalyzer = createTypeAnalyzer(root);
|
|
330
|
+
if (context.filepath === "index.js") {
|
|
331
|
+
injectProjectRootMeta(api, path, root);
|
|
887
332
|
}
|
|
888
|
-
const typeInfo = options.typeSupport === false ? null : typeAnalyzer?.analyzeFileTypes(context.cleanFilename, source);
|
|
889
333
|
const supportOverrides = getSupportOverrides(options);
|
|
890
|
-
|
|
334
|
+
path.traverse({
|
|
891
335
|
JSXElement(elementPath) {
|
|
892
336
|
const element = elementPath.node;
|
|
893
337
|
const tagName = getBabelTagName(element.openingElement.name);
|
|
@@ -901,7 +345,6 @@ function tempoExpoBabelPlugin(api, rawOptions = {}) {
|
|
|
901
345
|
filepath: context.filepath,
|
|
902
346
|
modifiedtsMs: context.modifiedtsMs,
|
|
903
347
|
computeAnnotatedProps: options.computeAnnotatedProps,
|
|
904
|
-
typeInfo,
|
|
905
348
|
elementSupportOverrides: supportOverrides
|
|
906
349
|
});
|
|
907
350
|
addAnnotations(api, tagName, element.openingElement, props);
|