@assistant-ui/metro 0.0.12 → 0.0.14

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.
@@ -14,8 +14,7 @@ type BabelTransformer = {
14
14
  getCacheKey?: (() => string) | undefined;
15
15
  [key: string]: unknown;
16
16
  };
17
- declare function transform(props: Parameters<BabelTransformer["transform"]>[0]): unknown;
18
- declare function getCacheKey(): string;
17
+ export declare function transform(props: Parameters<BabelTransformer["transform"]>[0]): unknown;
18
+ export declare function getCacheKey(): string;
19
19
  //#endregion
20
- export { getCacheKey, transform };
21
20
  //# sourceMappingURL=transformer.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"transformer.d.cts","names":[],"sources":["../src/transformer.ts"],"mappings":";;KAYK;EACH,YAAY;IACV;IACA;IACA;MACM;QAA2B;;;KAEhC;;EAEH;GACC;;iBA2Ca,UACd,OAAO,WAAW;iBA2CJ"}
1
+ {"version":3,"file":"transformer.d.cts","names":[],"sources":["../src/transformer.ts"],"mappings":";;KAYK;EACH,YAAY;IACV;IACA;IACA;MACM;QAA2B;;;KAEhC;;EAEH;GACC;;wBA2Ca,UACd,OAAO,WAAW;wBA2CJ"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@assistant-ui/metro",
3
- "version": "0.0.12",
3
+ "version": "0.0.14",
4
4
  "description": "Metro / Expo integration for assistant-ui: the \"use generative\" directive compiler that colocates a tool's schema, server execute, and client render in one file. Works with Expo and bare React Native.",
5
5
  "keywords": [
6
6
  "assistant-ui",
@@ -31,18 +31,18 @@
31
31
  "README.md"
32
32
  ],
33
33
  "dependencies": {
34
- "@babel/generator": "^8.0.0",
35
- "@babel/parser": "^8.0.4",
36
- "@babel/traverse": "^8.0.4",
37
- "@babel/types": "^8.0.4"
34
+ "@babel/generator": "^8.0.5",
35
+ "@babel/parser": "^8.0.5",
36
+ "@babel/traverse": "^8.0.5",
37
+ "@babel/types": "^8.0.5"
38
38
  },
39
39
  "devDependencies": {
40
- "@assistant-ui/x-buildutils": "0.0.25",
41
- "@assistant-ui/x-generative-compiler": "^0.0.16",
42
- "@types/node": "^26.4.0",
40
+ "@assistant-ui/x-buildutils": "0.0.28",
41
+ "@assistant-ui/x-generative-compiler": "^0.0.18",
42
+ "@types/node": "^26.5.1",
43
43
  "typescript": "npm:@typescript/typescript6@^6.0.2",
44
44
  "typescript-7": "npm:typescript@^7.0.2",
45
- "vitest": "^4.1.11"
45
+ "vitest": "^5.0.1"
46
46
  },
47
47
  "publishConfig": {
48
48
  "access": "public",
@@ -60,6 +60,7 @@
60
60
  "scripts": {
61
61
  "build": "aui-build",
62
62
  "test": "vitest run",
63
+ "typecheck": "tsc --noEmit",
63
64
  "test:watch": "vitest"
64
65
  }
65
66
  }
package/src/index.ts CHANGED
@@ -73,14 +73,19 @@ export function withAui<T extends MetroConfigLike>(config: T): T {
73
73
  const { aui, ...baseConfig } = config;
74
74
  const upstream = config.transformer?.babelTransformerPath;
75
75
 
76
- if (aui?.backendless) process.env[BACKENDLESS_ENV] = "1";
76
+ // A double-wrap is a re-entry: the first call already captured the real
77
+ // upstream, and replacing it with our transformer would cause recursion.
78
+ // An explicit `aui` on a rewrap still replaces the backendless setting.
79
+ const isRewrap = upstream === self;
77
80
 
78
- // Guard against a double-wrap (`withAui(withAui(config))`, or a shared config
79
- // already wrapped): if it already points at our transformer, keep the real
80
- // upstream captured earlier rather than overwriting it with our own path,
81
- // which would make `resolveUpstream()` return this transformer and recurse.
82
- if (upstream && upstream !== self) {
83
- process.env[UPSTREAM_TRANSFORMER_ENV] = upstream;
81
+ if (aui !== undefined || !isRewrap) {
82
+ if (aui?.backendless) process.env[BACKENDLESS_ENV] = "1";
83
+ else delete process.env[BACKENDLESS_ENV];
84
+ }
85
+
86
+ if (!isRewrap) {
87
+ if (upstream) process.env[UPSTREAM_TRANSFORMER_ENV] = upstream;
88
+ else delete process.env[UPSTREAM_TRANSFORMER_ENV];
84
89
  }
85
90
 
86
91
  return {
@@ -1,7 +1,7 @@
1
- import { describe, it, expect, beforeAll } from "vitest";
1
+ import { describe, it, expect, beforeAll, beforeEach, afterEach } from "vitest";
2
2
  import { fileURLToPath } from "node:url";
3
3
  import { dirname, join } from "node:path";
4
- import { withAui, UPSTREAM_TRANSFORMER_ENV } from "./index";
4
+ import { BACKENDLESS_ENV, withAui, UPSTREAM_TRANSFORMER_ENV } from "./index";
5
5
 
6
6
  const here = dirname(fileURLToPath(import.meta.url));
7
7
  const mockUpstream = join(here, "__fixtures__/mock-upstream.cjs");
@@ -21,6 +21,16 @@ export default defineToolkit({
21
21
  `;
22
22
 
23
23
  describe("withAui", () => {
24
+ beforeEach(() => {
25
+ delete process.env[BACKENDLESS_ENV];
26
+ delete process.env[UPSTREAM_TRANSFORMER_ENV];
27
+ });
28
+
29
+ afterEach(() => {
30
+ delete process.env[BACKENDLESS_ENV];
31
+ delete process.env[UPSTREAM_TRANSFORMER_ENV];
32
+ });
33
+
24
34
  it("points babelTransformerPath at our transformer, preserving the rest", () => {
25
35
  const config = withAui({
26
36
  projectRoot: "/app",
@@ -42,6 +52,7 @@ describe("withAui", () => {
42
52
 
43
53
  it("is idempotent: a double-wrap keeps the real upstream, not the wrapper", () => {
44
54
  const once = withAui({
55
+ aui: { backendless: true },
45
56
  transformer: { babelTransformerPath: "/up/stream.js" },
46
57
  });
47
58
  const self = once.transformer?.babelTransformerPath;
@@ -50,6 +61,19 @@ describe("withAui", () => {
50
61
  // still points at our transformer, and the env still names the real upstream
51
62
  expect(twice.transformer?.babelTransformerPath).toBe(self);
52
63
  expect(process.env[UPSTREAM_TRANSFORMER_ENV]).toBe("/up/stream.js");
64
+ expect(process.env[BACKENDLESS_ENV]).toBe("1");
65
+ });
66
+
67
+ it("clears settings left by an independently loaded config", () => {
68
+ withAui({
69
+ aui: { backendless: true },
70
+ transformer: { babelTransformerPath: "/workspace-a/transformer.js" },
71
+ });
72
+
73
+ withAui({});
74
+
75
+ expect(process.env[BACKENDLESS_ENV]).toBeUndefined();
76
+ expect(process.env[UPSTREAM_TRANSFORMER_ENV]).toBeUndefined();
53
77
  });
54
78
  });
55
79