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/README.md
CHANGED
|
@@ -10,6 +10,7 @@ This package ships two plugins from one workspace:
|
|
|
10
10
|
- **`tempo-sdk`** — Vite plugin (`tempoVitePlugin`)
|
|
11
11
|
- **`tempo-sdk/nextjs`** — Next.js plugin (`tempoNextjsPlugin`)
|
|
12
12
|
- **`tempo-sdk/nextjs/plugin`** — default-exported Next.js plugin for ESM config files
|
|
13
|
+
- **`tempo-sdk/expo/plugin`** — Expo Babel plugin (`tempoExpoBabelPlugin`)
|
|
13
14
|
|
|
14
15
|
Both produce byte-identical `data-tempo-*` output, so downstream consumers
|
|
15
16
|
(`source-editor.ts`, `frame-preload.ts`) work the same regardless of which
|
|
@@ -193,6 +194,101 @@ design.
|
|
|
193
194
|
|
|
194
195
|
---
|
|
195
196
|
|
|
197
|
+
## Expo usage
|
|
198
|
+
|
|
199
|
+
Expo support is for Tempo's web canvas runtime. It annotates Expo web output for
|
|
200
|
+
selection and editing; it does not make native-device canvases editable.
|
|
201
|
+
|
|
202
|
+
Configure the Tempo-owned Expo sidecar app's Babel config:
|
|
203
|
+
|
|
204
|
+
```js
|
|
205
|
+
// tempo/babel.config.js
|
|
206
|
+
const path = require("node:path");
|
|
207
|
+
const { tempoExpoBabelPlugin } = require("tempo-sdk/expo/plugin");
|
|
208
|
+
|
|
209
|
+
module.exports = function (api) {
|
|
210
|
+
api.cache(true);
|
|
211
|
+
return {
|
|
212
|
+
presets: ["babel-preset-expo"],
|
|
213
|
+
plugins: [
|
|
214
|
+
[
|
|
215
|
+
tempoExpoBabelPlugin,
|
|
216
|
+
{
|
|
217
|
+
root: path.resolve(__dirname, ".."),
|
|
218
|
+
},
|
|
219
|
+
],
|
|
220
|
+
],
|
|
221
|
+
};
|
|
222
|
+
};
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
If the Expo app uses NativeWind-style `className`, pass
|
|
226
|
+
`reactNativeClassName: true` in the plugin options.
|
|
227
|
+
|
|
228
|
+
The sidecar Metro config must watch the parent project so `tempo/` can import
|
|
229
|
+
real app components:
|
|
230
|
+
|
|
231
|
+
```js
|
|
232
|
+
// tempo/metro.config.js
|
|
233
|
+
const path = require("node:path");
|
|
234
|
+
const { getDefaultConfig } = require("expo/metro-config");
|
|
235
|
+
|
|
236
|
+
const projectRoot = __dirname;
|
|
237
|
+
const workspaceRoot = path.resolve(projectRoot, "..");
|
|
238
|
+
const sidecarNodeModules = path.join(projectRoot, "node_modules");
|
|
239
|
+
|
|
240
|
+
const config = getDefaultConfig(projectRoot);
|
|
241
|
+
const sidecarModule = (moduleName) =>
|
|
242
|
+
path.join(sidecarNodeModules, ...moduleName.split("/"));
|
|
243
|
+
const singletonModules = {
|
|
244
|
+
react: sidecarModule("react"),
|
|
245
|
+
"react-dom": sidecarModule("react-dom"),
|
|
246
|
+
"react-native": sidecarModule("react-native"),
|
|
247
|
+
"react-native-web": sidecarModule("react-native-web"),
|
|
248
|
+
"react/jsx-runtime": sidecarModule("react/jsx-runtime.js"),
|
|
249
|
+
"react/jsx-dev-runtime": sidecarModule("react/jsx-dev-runtime.js"),
|
|
250
|
+
};
|
|
251
|
+
|
|
252
|
+
config.watchFolders = Array.from(
|
|
253
|
+
new Set([...(config.watchFolders ?? []), workspaceRoot]),
|
|
254
|
+
);
|
|
255
|
+
config.resolver.nodeModulesPaths = Array.from(
|
|
256
|
+
new Set([
|
|
257
|
+
sidecarNodeModules,
|
|
258
|
+
path.join(workspaceRoot, "node_modules"),
|
|
259
|
+
...(config.resolver.nodeModulesPaths ?? []),
|
|
260
|
+
]),
|
|
261
|
+
);
|
|
262
|
+
config.resolver.disableHierarchicalLookup = true;
|
|
263
|
+
config.resolver.extraNodeModules = {
|
|
264
|
+
...(config.resolver.extraNodeModules ?? {}),
|
|
265
|
+
...singletonModules,
|
|
266
|
+
};
|
|
267
|
+
config.resolver.alias = {
|
|
268
|
+
...(config.resolver.alias ?? {}),
|
|
269
|
+
...singletonModules,
|
|
270
|
+
};
|
|
271
|
+
|
|
272
|
+
module.exports = config;
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
Those singleton aliases are important for sidecar Expo projects. Without them,
|
|
276
|
+
Metro can resolve React Native files imported from the parent app against the
|
|
277
|
+
parent app's `node_modules` while the sidecar resolves its own runtime against
|
|
278
|
+
`tempo/node_modules`, which can produce duplicate React instances and invalid
|
|
279
|
+
hook-call failures.
|
|
280
|
+
|
|
281
|
+
Launch Expo web with `TEMPO=true`:
|
|
282
|
+
|
|
283
|
+
```bash
|
|
284
|
+
TEMPO=true npx expo start --web
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
Tempo discovers the printed local URL and probes `/tempo-host`; no fixed port is
|
|
288
|
+
required.
|
|
289
|
+
|
|
290
|
+
---
|
|
291
|
+
|
|
196
292
|
## How it works
|
|
197
293
|
|
|
198
294
|
The Next.js plugin is a webpack-compatible loader (`nextjs-loader.cjs`) plus a
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { JSXElement } from 'oxc-parser';
|
|
2
|
+
|
|
3
|
+
interface ElementInfo {
|
|
4
|
+
element: JSXElement;
|
|
5
|
+
/** e.g. "div", "Button", "Foo.Bar" */
|
|
6
|
+
tagName: string;
|
|
7
|
+
}
|
|
8
|
+
/** Supported prop value types. `undefined` values are skipped. */
|
|
9
|
+
type PropValue = string | number | boolean | null | undefined | ((...args: unknown[]) => unknown) | object;
|
|
10
|
+
|
|
11
|
+
type ComputeAnnotatedProps = (info: ElementInfo, filepath: string, modifiedtsMs: number) => Record<string, PropValue>;
|
|
12
|
+
|
|
13
|
+
export type { ComputeAnnotatedProps as C, ElementInfo as E, PropValue as P };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { JSXElement } from 'oxc-parser';
|
|
2
|
+
|
|
3
|
+
interface ElementInfo {
|
|
4
|
+
element: JSXElement;
|
|
5
|
+
/** e.g. "div", "Button", "Foo.Bar" */
|
|
6
|
+
tagName: string;
|
|
7
|
+
}
|
|
8
|
+
/** Supported prop value types. `undefined` values are skipped. */
|
|
9
|
+
type PropValue = string | number | boolean | null | undefined | ((...args: unknown[]) => unknown) | object;
|
|
10
|
+
|
|
11
|
+
type ComputeAnnotatedProps = (info: ElementInfo, filepath: string, modifiedtsMs: number) => Record<string, PropValue>;
|
|
12
|
+
|
|
13
|
+
export type { ComputeAnnotatedProps as C, ElementInfo as E, PropValue as P };
|