tempo-sdk 0.0.8 → 0.0.9
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/README.md +96 -0
- 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-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 +883 -0
- package/dist/expo/plugin.cjs.map +1 -0
- package/dist/expo/plugin.d.cts +5 -0
- package/dist/expo/plugin.d.ts +5 -0
- package/dist/expo/plugin.js +8 -0
- package/dist/expo/plugin.js.map +1 -0
- package/dist/expo-babel-plugin.cjs +881 -0
- package/dist/expo-babel-plugin.cjs.map +1 -0
- package/dist/expo-babel-plugin.d.cts +71 -0
- package/dist/expo-babel-plugin.d.ts +71 -0
- package/dist/expo-babel-plugin.js +8 -0
- package/dist/expo-babel-plugin.js.map +1 -0
- package/dist/index.cjs +1170 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +99 -0
- package/dist/index.js +100 -53
- package/dist/index.js.map +1 -1
- package/dist/nextjs-loader.cjs +114 -67
- package/dist/nextjs-loader.cjs.map +1 -1
- package/package.json +23 -6
package/dist/nextjs-loader.cjs
CHANGED
|
@@ -37,9 +37,9 @@ __export(nextjs_loader_exports, {
|
|
|
37
37
|
nextjsLoader: () => nextjsLoader
|
|
38
38
|
});
|
|
39
39
|
module.exports = __toCommonJS(nextjs_loader_exports);
|
|
40
|
-
var
|
|
40
|
+
var import_node_fs4 = require("fs");
|
|
41
41
|
var import_node_module = require("module");
|
|
42
|
-
var
|
|
42
|
+
var import_node_path4 = require("path");
|
|
43
43
|
|
|
44
44
|
// ../../modules/annotation/annotate-file.ts
|
|
45
45
|
var import_oxc_parser2 = require("oxc-parser");
|
|
@@ -169,19 +169,98 @@ function annotateFile(source, filename, computeAnnotatedProps) {
|
|
|
169
169
|
// nextjs-loader.ts
|
|
170
170
|
var import_oxc_parser3 = require("oxc-parser");
|
|
171
171
|
|
|
172
|
+
// annotation-strategy.ts
|
|
173
|
+
var import_node_fs = require("fs");
|
|
174
|
+
var import_node_path = require("path");
|
|
175
|
+
var HTML_VOID_ELEMENTS = /* @__PURE__ */ new Set([
|
|
176
|
+
"area",
|
|
177
|
+
"base",
|
|
178
|
+
"br",
|
|
179
|
+
"col",
|
|
180
|
+
"embed",
|
|
181
|
+
"hr",
|
|
182
|
+
"img",
|
|
183
|
+
"input",
|
|
184
|
+
"link",
|
|
185
|
+
"meta",
|
|
186
|
+
"param",
|
|
187
|
+
"source",
|
|
188
|
+
"track",
|
|
189
|
+
"wbr"
|
|
190
|
+
]);
|
|
191
|
+
function isIntrinsicElement(tagName) {
|
|
192
|
+
return tagName.length > 0 && tagName[0] === tagName[0].toLowerCase();
|
|
193
|
+
}
|
|
194
|
+
function hasJsxAttribute(info, attrName) {
|
|
195
|
+
for (const attr of info.element.openingElement.attributes) {
|
|
196
|
+
const name = attr.name;
|
|
197
|
+
if (name?.name === attrName) return true;
|
|
198
|
+
}
|
|
199
|
+
return false;
|
|
200
|
+
}
|
|
201
|
+
function defaultComputeAnnotatedProps(info, filepath, modifiedtsMs) {
|
|
202
|
+
return {
|
|
203
|
+
"data-tempo-filepath": filepath,
|
|
204
|
+
"data-tempo-position": info.element.openingElement.start,
|
|
205
|
+
"data-tempo-modifiedts": modifiedtsMs
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
function computeTempoAnnotatedProps(params) {
|
|
209
|
+
const {
|
|
210
|
+
info,
|
|
211
|
+
filepath,
|
|
212
|
+
modifiedtsMs,
|
|
213
|
+
computeAnnotatedProps,
|
|
214
|
+
typeInfo,
|
|
215
|
+
elementSupportOverrides
|
|
216
|
+
} = params;
|
|
217
|
+
const userProps = computeAnnotatedProps ? computeAnnotatedProps(info, filepath, modifiedtsMs) : defaultComputeAnnotatedProps(info, filepath, modifiedtsMs);
|
|
218
|
+
if (isIntrinsicElement(info.tagName)) {
|
|
219
|
+
return {
|
|
220
|
+
...userProps,
|
|
221
|
+
"data-tempo-supports-children": hasJsxAttribute(
|
|
222
|
+
info,
|
|
223
|
+
"data-tempo-supports-children"
|
|
224
|
+
) ? void 0 : !HTML_VOID_ELEMENTS.has(info.tagName)
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
const override = elementSupportOverrides?.get(info.tagName);
|
|
228
|
+
if (override) {
|
|
229
|
+
return {
|
|
230
|
+
...userProps,
|
|
231
|
+
"data-tempo-supports-style": override.supportsStyle,
|
|
232
|
+
"data-tempo-supports-classname": override.supportsClassName,
|
|
233
|
+
"data-tempo-supports-children": hasJsxAttribute(
|
|
234
|
+
info,
|
|
235
|
+
"data-tempo-supports-children"
|
|
236
|
+
) ? void 0 : override.supportsChildren
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
const support = typeInfo?.get(info.element.openingElement.start);
|
|
240
|
+
return {
|
|
241
|
+
...userProps,
|
|
242
|
+
"data-tempo-supports-style": support?.supportsStyle ?? false,
|
|
243
|
+
"data-tempo-supports-classname": support?.supportsClassName ?? false,
|
|
244
|
+
"data-tempo-supports-children": hasJsxAttribute(
|
|
245
|
+
info,
|
|
246
|
+
"data-tempo-supports-children"
|
|
247
|
+
) ? void 0 : support?.supportsChildren ?? false
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
|
|
172
251
|
// type-analyzer.ts
|
|
173
252
|
var import_typescript2 = __toESM(require("typescript"), 1);
|
|
174
|
-
var
|
|
175
|
-
var
|
|
253
|
+
var import_node_path3 = __toESM(require("path"), 1);
|
|
254
|
+
var import_node_fs3 = require("fs");
|
|
176
255
|
|
|
177
256
|
// ../../modules/typescript/workspace-service.ts
|
|
178
|
-
var
|
|
179
|
-
var
|
|
257
|
+
var import_node_fs2 = require("fs");
|
|
258
|
+
var import_node_path2 = __toESM(require("path"), 1);
|
|
180
259
|
var import_typescript = __toESM(require("typescript"), 1);
|
|
181
260
|
function canonicalPath(input) {
|
|
182
|
-
const resolved =
|
|
261
|
+
const resolved = import_node_path2.default.resolve(input);
|
|
183
262
|
try {
|
|
184
|
-
return
|
|
263
|
+
return import_node_fs2.realpathSync.native(resolved);
|
|
185
264
|
} catch {
|
|
186
265
|
return resolved;
|
|
187
266
|
}
|
|
@@ -198,7 +277,7 @@ function compareProjectPriority(left, right) {
|
|
|
198
277
|
return left.id.localeCompare(right.id);
|
|
199
278
|
}
|
|
200
279
|
function isWithinRoot(filePath, rootDir) {
|
|
201
|
-
return filePath === rootDir || filePath.startsWith(`${rootDir}${
|
|
280
|
+
return filePath === rootDir || filePath.startsWith(`${rootDir}${import_node_path2.default.sep}`);
|
|
202
281
|
}
|
|
203
282
|
function loadProject(descriptor) {
|
|
204
283
|
const id = descriptor.id.trim();
|
|
@@ -219,7 +298,7 @@ function loadProject(descriptor) {
|
|
|
219
298
|
const parsed = import_typescript.default.parseJsonConfigFileContent(
|
|
220
299
|
readResult.config,
|
|
221
300
|
import_typescript.default.sys,
|
|
222
|
-
|
|
301
|
+
import_node_path2.default.dirname(tsconfigPath)
|
|
223
302
|
);
|
|
224
303
|
if (parsed.errors.length > 0) {
|
|
225
304
|
const message = parsed.errors.map(
|
|
@@ -246,7 +325,7 @@ function loadProject(descriptor) {
|
|
|
246
325
|
}
|
|
247
326
|
function getFileMtimeVersion(filePath) {
|
|
248
327
|
try {
|
|
249
|
-
const stats = (0,
|
|
328
|
+
const stats = (0, import_node_fs2.statSync)(filePath);
|
|
250
329
|
return String(stats.mtimeMs);
|
|
251
330
|
} catch {
|
|
252
331
|
return "0";
|
|
@@ -407,9 +486,9 @@ function isCustomComponent(node) {
|
|
|
407
486
|
return text.length > 0 && text[0] !== text[0].toLowerCase();
|
|
408
487
|
}
|
|
409
488
|
function canonicalPath2(value) {
|
|
410
|
-
const resolved =
|
|
489
|
+
const resolved = import_node_path3.default.resolve(value);
|
|
411
490
|
try {
|
|
412
|
-
return
|
|
491
|
+
return import_node_fs3.realpathSync.native(resolved);
|
|
413
492
|
} catch {
|
|
414
493
|
return resolved;
|
|
415
494
|
}
|
|
@@ -440,14 +519,14 @@ function parseProjectReferenceTsconfigPaths(references, configDir) {
|
|
|
440
519
|
if (!referencePath) {
|
|
441
520
|
continue;
|
|
442
521
|
}
|
|
443
|
-
const resolvedPath =
|
|
444
|
-
const tsconfigPath = resolvedPath.endsWith(".json") ? resolvedPath :
|
|
522
|
+
const resolvedPath = import_node_path3.default.resolve(configDir, referencePath);
|
|
523
|
+
const tsconfigPath = resolvedPath.endsWith(".json") ? resolvedPath : import_node_path3.default.join(resolvedPath, "tsconfig.json");
|
|
445
524
|
entries.push(tsconfigPath);
|
|
446
525
|
}
|
|
447
526
|
return entries;
|
|
448
527
|
}
|
|
449
528
|
function buildWorkspaceProjects(root, configPath, parsedConfig, rawConfig) {
|
|
450
|
-
const configDir =
|
|
529
|
+
const configDir = import_node_path3.default.dirname(configPath);
|
|
451
530
|
const projects = [
|
|
452
531
|
{
|
|
453
532
|
id: "root",
|
|
@@ -462,7 +541,7 @@ function buildWorkspaceProjects(root, configPath, parsedConfig, rawConfig) {
|
|
|
462
541
|
configDir
|
|
463
542
|
);
|
|
464
543
|
const managedTsconfigPaths = parseManagedTsconfigPaths(rawConfig).map(
|
|
465
|
-
(entry) =>
|
|
544
|
+
(entry) => import_node_path3.default.resolve(configDir, entry)
|
|
466
545
|
);
|
|
467
546
|
const candidateTsconfigPaths = [
|
|
468
547
|
...managedTsconfigPaths,
|
|
@@ -479,7 +558,7 @@ function buildWorkspaceProjects(root, configPath, parsedConfig, rawConfig) {
|
|
|
479
558
|
seenTsconfigPaths.add(normalizedPath);
|
|
480
559
|
projects.push({
|
|
481
560
|
id: `external-${projects.length}`,
|
|
482
|
-
rootDir:
|
|
561
|
+
rootDir: import_node_path3.default.dirname(normalizedPath),
|
|
483
562
|
tsconfigPath: normalizedPath,
|
|
484
563
|
priority: 0
|
|
485
564
|
});
|
|
@@ -650,7 +729,7 @@ function createTypeAnalyzer(root) {
|
|
|
650
729
|
analyzeFileTypes(filePath, source) {
|
|
651
730
|
const canonicalFilePath = canonicalPath2(filePath);
|
|
652
731
|
const belongsToWorkspace = workspaceProjectRoots.some(
|
|
653
|
-
(projectRoot) => canonicalFilePath === projectRoot || canonicalFilePath.startsWith(`${projectRoot}${
|
|
732
|
+
(projectRoot) => canonicalFilePath === projectRoot || canonicalFilePath.startsWith(`${projectRoot}${import_node_path3.default.sep}`)
|
|
654
733
|
);
|
|
655
734
|
if (!belongsToWorkspace) {
|
|
656
735
|
return null;
|
|
@@ -718,22 +797,6 @@ function createTypeAnalyzer(root) {
|
|
|
718
797
|
|
|
719
798
|
// nextjs-loader.ts
|
|
720
799
|
var ROOT_META_NAME = "tempo-project-root";
|
|
721
|
-
var HTML_VOID_ELEMENTS = /* @__PURE__ */ new Set([
|
|
722
|
-
"area",
|
|
723
|
-
"base",
|
|
724
|
-
"br",
|
|
725
|
-
"col",
|
|
726
|
-
"embed",
|
|
727
|
-
"hr",
|
|
728
|
-
"img",
|
|
729
|
-
"input",
|
|
730
|
-
"link",
|
|
731
|
-
"meta",
|
|
732
|
-
"param",
|
|
733
|
-
"source",
|
|
734
|
-
"track",
|
|
735
|
-
"wbr"
|
|
736
|
-
]);
|
|
737
800
|
var cachedCanonicalRoot = null;
|
|
738
801
|
var cachedTypeAnalyzer = null;
|
|
739
802
|
var cachedUserComputeProps;
|
|
@@ -744,16 +807,6 @@ function _resetLoaderState() {
|
|
|
744
807
|
cachedUserComputeProps = void 0;
|
|
745
808
|
cachedComputeModulePath = null;
|
|
746
809
|
}
|
|
747
|
-
function isIntrinsicElement(tagName) {
|
|
748
|
-
return tagName.length > 0 && tagName[0] === tagName[0].toLowerCase();
|
|
749
|
-
}
|
|
750
|
-
function defaultComputeAnnotatedProps(info, filepath, modifiedtsMs) {
|
|
751
|
-
return {
|
|
752
|
-
"data-tempo-filepath": filepath,
|
|
753
|
-
"data-tempo-position": info.element.openingElement.start,
|
|
754
|
-
"data-tempo-modifiedts": modifiedtsMs
|
|
755
|
-
};
|
|
756
|
-
}
|
|
757
810
|
function stripQueryAndHash(path3) {
|
|
758
811
|
const queryIdx = path3.indexOf("?");
|
|
759
812
|
const hashIdx = path3.indexOf("#");
|
|
@@ -764,13 +817,13 @@ function stripQueryAndHash(path3) {
|
|
|
764
817
|
}
|
|
765
818
|
function resolveCanonicalRoot(rootContext) {
|
|
766
819
|
try {
|
|
767
|
-
return
|
|
820
|
+
return import_node_fs4.realpathSync.native(rootContext);
|
|
768
821
|
} catch {
|
|
769
822
|
return rootContext;
|
|
770
823
|
}
|
|
771
824
|
}
|
|
772
825
|
function isInNodeModules(path3) {
|
|
773
|
-
return path3.includes(`${
|
|
826
|
+
return path3.includes(`${import_node_path4.sep}node_modules${import_node_path4.sep}`);
|
|
774
827
|
}
|
|
775
828
|
function findFirstJSXElement(program, tagName) {
|
|
776
829
|
let result = null;
|
|
@@ -838,7 +891,7 @@ function injectRootMetaIntoAnnotatedSource(annotatedSource, filename, root) {
|
|
|
838
891
|
return injectRootMetaIntoSource(annotatedSource, filename, root);
|
|
839
892
|
}
|
|
840
893
|
function loadUserComputeProps(modulePath, canonicalRoot) {
|
|
841
|
-
const resolved = (0,
|
|
894
|
+
const resolved = (0, import_node_path4.resolve)(canonicalRoot, modulePath);
|
|
842
895
|
const requireFromRoot = (0, import_node_module.createRequire)(`${canonicalRoot}/__tempo_loader__.js`);
|
|
843
896
|
const mod = requireFromRoot(resolved);
|
|
844
897
|
const fn = mod && (mod.default ?? mod);
|
|
@@ -887,29 +940,23 @@ function nextjsLoader(source) {
|
|
|
887
940
|
cachedUserComputeProps = null;
|
|
888
941
|
}
|
|
889
942
|
const userComputeProps = cachedUserComputeProps;
|
|
890
|
-
const filepath = (0,
|
|
891
|
-
const modifiedtsMs = Math.trunc((0,
|
|
943
|
+
const filepath = (0, import_node_path4.relative)(canonicalRoot, cleanPath);
|
|
944
|
+
const modifiedtsMs = Math.trunc((0, import_node_fs4.statSync)(cleanPath).mtimeMs);
|
|
892
945
|
const typeInfo = cachedTypeAnalyzer?.analyzeFileTypes(
|
|
893
946
|
cleanPath,
|
|
894
947
|
source
|
|
895
948
|
) ?? null;
|
|
896
|
-
const annotated = annotateFile(
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
...userProps,
|
|
908
|
-
"data-tempo-supports-style": support?.supportsStyle ?? false,
|
|
909
|
-
"data-tempo-supports-classname": support?.supportsClassName ?? false,
|
|
910
|
-
"data-tempo-supports-children": support?.supportsChildren ?? false
|
|
911
|
-
};
|
|
912
|
-
});
|
|
949
|
+
const annotated = annotateFile(
|
|
950
|
+
source,
|
|
951
|
+
cleanPath,
|
|
952
|
+
(info) => computeTempoAnnotatedProps({
|
|
953
|
+
info,
|
|
954
|
+
filepath,
|
|
955
|
+
modifiedtsMs,
|
|
956
|
+
computeAnnotatedProps: userComputeProps ?? void 0,
|
|
957
|
+
typeInfo
|
|
958
|
+
})
|
|
959
|
+
);
|
|
913
960
|
let finalSource = annotated.annotatedSource;
|
|
914
961
|
if (options.autoInjectRootMeta !== false) {
|
|
915
962
|
finalSource = injectRootMetaIntoAnnotatedSource(
|