tempo-sdk 0.0.8 → 0.0.10
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-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 +921 -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 +919 -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/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// index.ts
|
|
2
|
-
import { realpathSync as
|
|
3
|
-
import { relative } from "path";
|
|
2
|
+
import { realpathSync as realpathSync4, statSync as statSync3 } from "fs";
|
|
3
|
+
import { relative as relative2 } from "path";
|
|
4
4
|
|
|
5
5
|
// ../../modules/annotation/annotate-file.ts
|
|
6
6
|
import { parseSync as parseSync2 } from "oxc-parser";
|
|
@@ -130,19 +130,98 @@ function annotateFile(source, filename, computeAnnotatedProps) {
|
|
|
130
130
|
// index.ts
|
|
131
131
|
import { createFilter } from "@rollup/pluginutils";
|
|
132
132
|
|
|
133
|
+
// annotation-strategy.ts
|
|
134
|
+
import { realpathSync, statSync } from "fs";
|
|
135
|
+
import { relative } from "path";
|
|
136
|
+
var HTML_VOID_ELEMENTS = /* @__PURE__ */ new Set([
|
|
137
|
+
"area",
|
|
138
|
+
"base",
|
|
139
|
+
"br",
|
|
140
|
+
"col",
|
|
141
|
+
"embed",
|
|
142
|
+
"hr",
|
|
143
|
+
"img",
|
|
144
|
+
"input",
|
|
145
|
+
"link",
|
|
146
|
+
"meta",
|
|
147
|
+
"param",
|
|
148
|
+
"source",
|
|
149
|
+
"track",
|
|
150
|
+
"wbr"
|
|
151
|
+
]);
|
|
152
|
+
function isIntrinsicElement(tagName) {
|
|
153
|
+
return tagName.length > 0 && tagName[0] === tagName[0].toLowerCase();
|
|
154
|
+
}
|
|
155
|
+
function hasJsxAttribute(info, attrName) {
|
|
156
|
+
for (const attr of info.element.openingElement.attributes) {
|
|
157
|
+
const name = attr.name;
|
|
158
|
+
if (name?.name === attrName) return true;
|
|
159
|
+
}
|
|
160
|
+
return false;
|
|
161
|
+
}
|
|
162
|
+
function defaultComputeAnnotatedProps(info, filepath, modifiedtsMs) {
|
|
163
|
+
return {
|
|
164
|
+
"data-tempo-filepath": filepath,
|
|
165
|
+
"data-tempo-position": info.element.openingElement.start,
|
|
166
|
+
"data-tempo-modifiedts": modifiedtsMs
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
function computeTempoAnnotatedProps(params) {
|
|
170
|
+
const {
|
|
171
|
+
info,
|
|
172
|
+
filepath,
|
|
173
|
+
modifiedtsMs,
|
|
174
|
+
computeAnnotatedProps,
|
|
175
|
+
typeInfo,
|
|
176
|
+
elementSupportOverrides
|
|
177
|
+
} = params;
|
|
178
|
+
const userProps = computeAnnotatedProps ? computeAnnotatedProps(info, filepath, modifiedtsMs) : defaultComputeAnnotatedProps(info, filepath, modifiedtsMs);
|
|
179
|
+
if (isIntrinsicElement(info.tagName)) {
|
|
180
|
+
return {
|
|
181
|
+
...userProps,
|
|
182
|
+
"data-tempo-supports-children": hasJsxAttribute(
|
|
183
|
+
info,
|
|
184
|
+
"data-tempo-supports-children"
|
|
185
|
+
) ? void 0 : !HTML_VOID_ELEMENTS.has(info.tagName)
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
const override = elementSupportOverrides?.get(info.tagName);
|
|
189
|
+
if (override) {
|
|
190
|
+
return {
|
|
191
|
+
...userProps,
|
|
192
|
+
"data-tempo-supports-style": override.supportsStyle,
|
|
193
|
+
"data-tempo-supports-classname": override.supportsClassName,
|
|
194
|
+
"data-tempo-supports-children": hasJsxAttribute(
|
|
195
|
+
info,
|
|
196
|
+
"data-tempo-supports-children"
|
|
197
|
+
) ? void 0 : override.supportsChildren
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
const support = typeInfo?.get(info.element.openingElement.start);
|
|
201
|
+
return {
|
|
202
|
+
...userProps,
|
|
203
|
+
"data-tempo-supports-style": support?.supportsStyle ?? false,
|
|
204
|
+
"data-tempo-supports-classname": support?.supportsClassName ?? false,
|
|
205
|
+
"data-tempo-supports-children": hasJsxAttribute(
|
|
206
|
+
info,
|
|
207
|
+
"data-tempo-supports-children"
|
|
208
|
+
) ? void 0 : support?.supportsChildren ?? false
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
|
|
133
212
|
// type-analyzer.ts
|
|
134
213
|
import ts2 from "typescript";
|
|
135
214
|
import path2 from "path";
|
|
136
|
-
import { realpathSync as
|
|
215
|
+
import { realpathSync as realpathSync3 } from "fs";
|
|
137
216
|
|
|
138
217
|
// ../../modules/typescript/workspace-service.ts
|
|
139
|
-
import { realpathSync, statSync } from "fs";
|
|
218
|
+
import { realpathSync as realpathSync2, statSync as statSync2 } from "fs";
|
|
140
219
|
import path from "path";
|
|
141
220
|
import ts from "typescript";
|
|
142
221
|
function canonicalPath(input) {
|
|
143
222
|
const resolved = path.resolve(input);
|
|
144
223
|
try {
|
|
145
|
-
return
|
|
224
|
+
return realpathSync2.native(resolved);
|
|
146
225
|
} catch {
|
|
147
226
|
return resolved;
|
|
148
227
|
}
|
|
@@ -207,7 +286,7 @@ function loadProject(descriptor) {
|
|
|
207
286
|
}
|
|
208
287
|
function getFileMtimeVersion(filePath) {
|
|
209
288
|
try {
|
|
210
|
-
const stats =
|
|
289
|
+
const stats = statSync2(filePath);
|
|
211
290
|
return String(stats.mtimeMs);
|
|
212
291
|
} catch {
|
|
213
292
|
return "0";
|
|
@@ -370,7 +449,7 @@ function isCustomComponent(node) {
|
|
|
370
449
|
function canonicalPath2(value) {
|
|
371
450
|
const resolved = path2.resolve(value);
|
|
372
451
|
try {
|
|
373
|
-
return
|
|
452
|
+
return realpathSync3.native(resolved);
|
|
374
453
|
} catch {
|
|
375
454
|
return resolved;
|
|
376
455
|
}
|
|
@@ -686,7 +765,7 @@ function cleanModuleId(id) {
|
|
|
686
765
|
}
|
|
687
766
|
function resolveCanonicalRoot(root) {
|
|
688
767
|
try {
|
|
689
|
-
return
|
|
768
|
+
return realpathSync4.native(root);
|
|
690
769
|
} catch {
|
|
691
770
|
return root;
|
|
692
771
|
}
|
|
@@ -694,32 +773,6 @@ function resolveCanonicalRoot(root) {
|
|
|
694
773
|
function hasRootMetaTag(html) {
|
|
695
774
|
return /<meta[^>]+name=["']tempo-project-root["'][^>]*>/i.test(html);
|
|
696
775
|
}
|
|
697
|
-
function isIntrinsicElement(tagName) {
|
|
698
|
-
return tagName.length > 0 && tagName[0] === tagName[0].toLowerCase();
|
|
699
|
-
}
|
|
700
|
-
var HTML_VOID_ELEMENTS = /* @__PURE__ */ new Set([
|
|
701
|
-
"area",
|
|
702
|
-
"base",
|
|
703
|
-
"br",
|
|
704
|
-
"col",
|
|
705
|
-
"embed",
|
|
706
|
-
"hr",
|
|
707
|
-
"img",
|
|
708
|
-
"input",
|
|
709
|
-
"link",
|
|
710
|
-
"meta",
|
|
711
|
-
"param",
|
|
712
|
-
"source",
|
|
713
|
-
"track",
|
|
714
|
-
"wbr"
|
|
715
|
-
]);
|
|
716
|
-
function defaultComputeAnnotatedProps(info, filepath, modifiedtsMs) {
|
|
717
|
-
return {
|
|
718
|
-
"data-tempo-filepath": filepath,
|
|
719
|
-
"data-tempo-position": info.element.openingElement.start,
|
|
720
|
-
"data-tempo-modifiedts": modifiedtsMs
|
|
721
|
-
};
|
|
722
|
-
}
|
|
723
776
|
function createErrorServer() {
|
|
724
777
|
const errorsByFile = /* @__PURE__ */ new Map();
|
|
725
778
|
function getMostRecentError() {
|
|
@@ -827,7 +880,6 @@ function tempoVitePlugin(options = {}) {
|
|
|
827
880
|
const include = options.include === void 0 ? DEFAULT_INCLUDE : options.include;
|
|
828
881
|
const exclude = options.exclude === void 0 ? DEFAULT_EXCLUDE : options.exclude;
|
|
829
882
|
const filter = createFilter(include, exclude);
|
|
830
|
-
const computeAnnotatedProps = options.computeAnnotatedProps ?? defaultComputeAnnotatedProps;
|
|
831
883
|
let canonicalRoot = process.cwd();
|
|
832
884
|
let command = "serve";
|
|
833
885
|
let typeAnalyzer = null;
|
|
@@ -912,25 +964,20 @@ function tempoVitePlugin(options = {}) {
|
|
|
912
964
|
return null;
|
|
913
965
|
}
|
|
914
966
|
try {
|
|
915
|
-
const filepath =
|
|
916
|
-
const modifiedtsMs = Math.trunc(
|
|
967
|
+
const filepath = relative2(canonicalRoot, cleanId);
|
|
968
|
+
const modifiedtsMs = Math.trunc(statSync3(cleanId).mtimeMs);
|
|
917
969
|
const typeInfo = typeAnalyzer?.analyzeFileTypes(cleanId, source);
|
|
918
|
-
const result = annotateFile(
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
"data-tempo-supports-style": support?.supportsStyle ?? false,
|
|
930
|
-
"data-tempo-supports-classname": support?.supportsClassName ?? false,
|
|
931
|
-
"data-tempo-supports-children": support?.supportsChildren ?? false
|
|
932
|
-
};
|
|
933
|
-
});
|
|
970
|
+
const result = annotateFile(
|
|
971
|
+
source,
|
|
972
|
+
cleanId,
|
|
973
|
+
(info) => computeTempoAnnotatedProps({
|
|
974
|
+
info,
|
|
975
|
+
filepath,
|
|
976
|
+
modifiedtsMs,
|
|
977
|
+
computeAnnotatedProps: options.computeAnnotatedProps,
|
|
978
|
+
typeInfo
|
|
979
|
+
})
|
|
980
|
+
);
|
|
934
981
|
if (result.elementsAnnotated === 0) {
|
|
935
982
|
return null;
|
|
936
983
|
}
|