paseo-plugin-genui 0.1.1 → 0.1.3
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/client/components/content.tsx +48 -14
- package/client/components/image-lightbox.tsx +110 -0
- package/client/components/inputs.tsx +1 -1
- package/client/components/media.tsx +2 -2
- package/client/live-ui.tsx +2 -2
- package/client/node-renderer.tsx +37 -19
- package/client/web.ts +22 -0
- package/package.json +1 -1
- package/shared/core/data.ts +9 -1
- package/shared/core/define-class.ts +36 -0
- package/shared/core/diagnostics.ts +24 -13
- package/shared/core/evaluate.ts +561 -525
- package/shared/core/junit.ts +9 -1
- package/shared/core/lexer.ts +187 -177
- package/shared/core/parser.ts +280 -263
- package/shared/core/validate.ts +366 -356
- package/shared/hermes-syntax.test.ts +41 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { readdirSync, readFileSync, statSync } from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import ts from "typescript";
|
|
4
|
+
import { describe, expect, it } from "vitest";
|
|
5
|
+
|
|
6
|
+
const root = path.resolve(__dirname, "..");
|
|
7
|
+
|
|
8
|
+
function sourceFiles(dir: string): string[] {
|
|
9
|
+
return readdirSync(dir).flatMap((name) => {
|
|
10
|
+
const full = path.join(dir, name);
|
|
11
|
+
if (statSync(full).isDirectory()) return sourceFiles(full);
|
|
12
|
+
return /\.[cm]?tsx?$/.test(name) && !/\.test\.tsx?$/.test(name) && !name.endsWith(".d.ts") ? [full] : [];
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function classesIn(file: string): string[] {
|
|
17
|
+
const sf = ts.createSourceFile(file, readFileSync(file, "utf8"), ts.ScriptTarget.ES2022, true);
|
|
18
|
+
const found: string[] = [];
|
|
19
|
+
const visit = (node: ts.Node): void => {
|
|
20
|
+
if (ts.isClassDeclaration(node) || ts.isClassExpression(node)) {
|
|
21
|
+
const { line } = sf.getLineAndCharacterOfPosition(node.getStart(sf));
|
|
22
|
+
found.push(`${path.relative(root, file)}:${line + 1}`);
|
|
23
|
+
}
|
|
24
|
+
ts.forEachChild(node, visit);
|
|
25
|
+
};
|
|
26
|
+
visit(sf);
|
|
27
|
+
return found;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
describe("Hermes compatibility", () => {
|
|
31
|
+
// Hermes (React Native) has no `class` syntax, and Paseo compiles plugin client
|
|
32
|
+
// bundles for es2020, so `class` would reach it. server/ runs in Node and may use it.
|
|
33
|
+
it("keeps `class` out of client and shared code; use defineClass", () => {
|
|
34
|
+
const files = [
|
|
35
|
+
...sourceFiles(path.join(root, "client")),
|
|
36
|
+
...sourceFiles(path.join(root, "shared")),
|
|
37
|
+
path.join(root, "index.client.tsx"),
|
|
38
|
+
];
|
|
39
|
+
expect(files.flatMap(classesIn)).toEqual([]);
|
|
40
|
+
});
|
|
41
|
+
});
|