@homebound/truss 2.0.0-next.1 → 2.0.0-next.13
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/build/index.js +39 -1
- package/build/index.js.map +1 -1
- package/build/plugin/index.d.ts +4 -3
- package/build/plugin/index.js +767 -105
- package/build/plugin/index.js.map +1 -1
- package/build/runtime.d.ts +6 -0
- package/build/runtime.js +19 -0
- package/build/runtime.js.map +1 -0
- package/cli.js +6 -19
- package/package.json +8 -3
- package/tsup.config.ts +1 -0
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import * as stylex from '@stylexjs/stylex';
|
|
2
|
+
|
|
3
|
+
declare function mergeProps(stylexNs: typeof stylex, explicitClassName: string, ...styles: Array<Parameters<typeof stylex.props>[number]>): Record<string, unknown>;
|
|
4
|
+
declare function asStyleArray(styles: unknown): ReadonlyArray<unknown>;
|
|
5
|
+
|
|
6
|
+
export { asStyleArray, mergeProps };
|
package/build/runtime.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// src/runtime.ts
|
|
2
|
+
function mergeProps(stylexNs, explicitClassName, ...styles) {
|
|
3
|
+
const sx = stylexNs.props(...styles);
|
|
4
|
+
return {
|
|
5
|
+
...sx,
|
|
6
|
+
className: `${explicitClassName} ${sx.className ?? ""}`.trim()
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
function asStyleArray(styles) {
|
|
10
|
+
if (Array.isArray(styles)) {
|
|
11
|
+
return styles;
|
|
12
|
+
}
|
|
13
|
+
return styles ? [styles] : [];
|
|
14
|
+
}
|
|
15
|
+
export {
|
|
16
|
+
asStyleArray,
|
|
17
|
+
mergeProps
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=runtime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/runtime.ts"],"sourcesContent":["import type * as stylex from \"@stylexjs/stylex\";\n\nexport function mergeProps(\n stylexNs: typeof stylex,\n explicitClassName: string,\n ...styles: Array<Parameters<typeof stylex.props>[number]>\n): Record<string, unknown> {\n const sx = stylexNs.props(...styles);\n return {\n ...sx,\n className: `${explicitClassName} ${sx.className ?? \"\"}`.trim(),\n };\n}\n\nexport function asStyleArray(styles: unknown): ReadonlyArray<unknown> {\n if (Array.isArray(styles)) {\n return styles;\n }\n return styles ? [styles] : [];\n}\n"],"mappings":";AAEO,SAAS,WACd,UACA,sBACG,QACsB;AACzB,QAAM,KAAK,SAAS,MAAM,GAAG,MAAM;AACnC,SAAO;AAAA,IACL,GAAG;AAAA,IACH,WAAW,GAAG,iBAAiB,IAAI,GAAG,aAAa,EAAE,GAAG,KAAK;AAAA,EAC/D;AACF;AAEO,SAAS,aAAa,QAAyC;AACpE,MAAI,MAAM,QAAQ,MAAM,GAAG;AACzB,WAAO;AAAA,EACT;AACA,SAAO,SAAS,CAAC,MAAM,IAAI,CAAC;AAC9B;","names":[]}
|
package/cli.js
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import { createRequire } from "node:module";
|
|
4
3
|
import { join } from "node:path";
|
|
5
4
|
import { pathToFileURL } from "node:url";
|
|
6
|
-
import { register } from "
|
|
5
|
+
import { register } from "tsx/esm/api";
|
|
7
6
|
import { generate } from "./build/index.js";
|
|
8
7
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
// Pass `module: commonjs` to handle vite projects that use `module: esnext`.
|
|
13
|
-
register({ transpileOnly: true, compilerOptions: { module: "commonjs" } });
|
|
8
|
+
// Register tsx loader so we can import TypeScript config files
|
|
9
|
+
// (handles both CJS and ESM projects, with extensionless .ts imports).
|
|
10
|
+
const unregister = register();
|
|
14
11
|
|
|
15
12
|
const filename = process.argv[2] ?? "./truss-config.ts";
|
|
16
13
|
const configPath = join(process.cwd(), filename);
|
|
@@ -21,18 +18,8 @@ main().catch((err) => {
|
|
|
21
18
|
});
|
|
22
19
|
|
|
23
20
|
async function main() {
|
|
24
|
-
const config = await
|
|
21
|
+
const config = (await import(pathToFileURL(configPath).href)).default;
|
|
22
|
+
unregister();
|
|
25
23
|
await generate(config);
|
|
26
24
|
console.log(`Generated ${config.outputPath}`);
|
|
27
25
|
}
|
|
28
|
-
|
|
29
|
-
async function loadConfig(configPath) {
|
|
30
|
-
try {
|
|
31
|
-
return require(configPath).default;
|
|
32
|
-
} catch (err) {
|
|
33
|
-
if (err && typeof err === "object" && "code" in err && err.code === "ERR_REQUIRE_ESM") {
|
|
34
|
-
return (await import(pathToFileURL(configPath).href)).default;
|
|
35
|
-
}
|
|
36
|
-
throw err;
|
|
37
|
-
}
|
|
38
|
-
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@homebound/truss",
|
|
3
|
-
"version": "2.0.0-next.
|
|
3
|
+
"version": "2.0.0-next.13",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"bin": "cli.js",
|
|
@@ -14,6 +14,11 @@
|
|
|
14
14
|
"types": "./build/plugin/index.d.ts",
|
|
15
15
|
"import": "./build/plugin/index.js",
|
|
16
16
|
"default": "./build/plugin/index.js"
|
|
17
|
+
},
|
|
18
|
+
"./runtime": {
|
|
19
|
+
"types": "./build/runtime.d.ts",
|
|
20
|
+
"import": "./build/runtime.js",
|
|
21
|
+
"default": "./build/runtime.js"
|
|
17
22
|
}
|
|
18
23
|
},
|
|
19
24
|
"scripts": {
|
|
@@ -24,8 +29,8 @@
|
|
|
24
29
|
"dependencies": {
|
|
25
30
|
"change-case": "^5.4.4",
|
|
26
31
|
"csstype": "^3.2.3",
|
|
27
|
-
"ts-
|
|
28
|
-
"
|
|
32
|
+
"ts-poet": "^6.12.0",
|
|
33
|
+
"tsx": "^4.19.0"
|
|
29
34
|
},
|
|
30
35
|
"devDependencies": {
|
|
31
36
|
"@homebound/tsconfig": "^1.1.1",
|