@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.
- package/dist/index.cjs +9 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -6
- package/dist/index.d.cts.map +1 -1
- package/dist/transformer.cjs +66 -18
- package/dist/transformer.cjs.map +1 -1
- package/dist/transformer.d.cts +2 -3
- package/dist/transformer.d.cts.map +1 -1
- package/package.json +10 -9
- package/src/index.ts +12 -7
- package/src/transformer.test.ts +26 -2
package/dist/transformer.d.cts
CHANGED
|
@@ -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;;
|
|
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.
|
|
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.
|
|
35
|
-
"@babel/parser": "^8.0.
|
|
36
|
-
"@babel/traverse": "^8.0.
|
|
37
|
-
"@babel/types": "^8.0.
|
|
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.
|
|
41
|
-
"@assistant-ui/x-generative-compiler": "^0.0.
|
|
42
|
-
"@types/node": "^26.
|
|
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": "^
|
|
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
|
-
|
|
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
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
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 {
|
package/src/transformer.test.ts
CHANGED
|
@@ -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
|
|