@nifrajs/web-solid 1.13.0 → 2.1.0
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/svg.d.ts +5 -0
- package/dist/svg.d.ts.map +1 -0
- package/dist/svg.js +40 -0
- package/dist/svg.js.map +1 -0
- package/package.json +9 -4
- package/src/svg.ts +41 -0
package/dist/svg.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { BunPlugin } from "bun";
|
|
2
|
+
/** The Solid SVG-component plugin. `generate` selects the Solid `"dom"`/`"ssr"` output, matching
|
|
3
|
+
* `solidBunPlugin`. A plain `import "./icon.svg"` (asset URL) is untouched - only `?component` matches. */
|
|
4
|
+
export declare function solidSvgComponentBunPlugin(generate: "dom" | "ssr"): BunPlugin;
|
|
5
|
+
//# sourceMappingURL=svg.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"svg.d.ts","sourceRoot":"","sources":["../src/svg.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,KAAK,CAAA;AAEpC;2GAC2G;AAC3G,wBAAgB,0BAA0B,CAAC,QAAQ,EAAE,KAAK,GAAG,KAAK,GAAG,SAAS,CAoB7E"}
|
package/dist/svg.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@nifrajs/web-solid/svg` - the Solid build of the SVG-as-component plugin. `import Icon from
|
|
3
|
+
* "./icon.svg?component"`, then `<Icon class="w-6 h-6" />`, props spread onto the root `<svg>`.
|
|
4
|
+
*
|
|
5
|
+
* Solid JSX is not standard JSX (it compiles through `babel-preset-solid`) and uses `class`, not
|
|
6
|
+
* `className` - so this can't reuse the React/Preact plugin from `@nifrajs/web/plugins/svg`. It shares
|
|
7
|
+
* that package's `svgToJsx` transform (with `classProp: "class"`) to produce a Solid component, then
|
|
8
|
+
* runs the same Solid + TypeScript babel passes `solidBunPlugin` applies to `.tsx`. Pass `"dom"` for the
|
|
9
|
+
* client bundle and preload `"ssr"` for the server.
|
|
10
|
+
*/
|
|
11
|
+
import { transformAsync } from "@babel/core";
|
|
12
|
+
// @ts-expect-error - no type declarations published
|
|
13
|
+
import presetTypeScript from "@babel/preset-typescript";
|
|
14
|
+
import { SVG_COMPONENT_FILTER, svgComponentSource } from "@nifrajs/web/plugins/svg";
|
|
15
|
+
// @ts-expect-error - no type declarations published
|
|
16
|
+
import presetSolid from "babel-preset-solid";
|
|
17
|
+
/** The Solid SVG-component plugin. `generate` selects the Solid `"dom"`/`"ssr"` output, matching
|
|
18
|
+
* `solidBunPlugin`. A plain `import "./icon.svg"` (asset URL) is untouched - only `?component` matches. */
|
|
19
|
+
export function solidSvgComponentBunPlugin(generate) {
|
|
20
|
+
return {
|
|
21
|
+
name: `nifra-solid-svg-${generate}`,
|
|
22
|
+
setup(build) {
|
|
23
|
+
build.onLoad({ filter: SVG_COMPONENT_FILTER }, async (args) => {
|
|
24
|
+
const path = args.path.split("?")[0] ?? args.path;
|
|
25
|
+
const xml = await Bun.file(path).text();
|
|
26
|
+
// Solid uses `class`; emit the component JSX, then run the Solid + TS babel passes.
|
|
27
|
+
const source = svgComponentSource(xml, { classProp: "class" });
|
|
28
|
+
const result = await transformAsync(source, {
|
|
29
|
+
filename: `${path}.tsx`, // ensure presetTypeScript treats it as TSX-eligible
|
|
30
|
+
presets: [
|
|
31
|
+
[presetSolid, { generate, hydratable: true }],
|
|
32
|
+
[presetTypeScript, { onlyRemoveTypeImports: true }],
|
|
33
|
+
],
|
|
34
|
+
});
|
|
35
|
+
return { contents: result?.code ?? "", loader: "js" };
|
|
36
|
+
});
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=svg.js.map
|
package/dist/svg.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"svg.js","sourceRoot":"","sources":["../src/svg.ts"],"names":[],"mappings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F,CAAA;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nifrajs/web-solid",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "Solid render adapter for @nifrajs/web — SSR + hydration + the Solid Babel build plugin.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bun",
|
|
@@ -61,6 +61,11 @@
|
|
|
61
61
|
"types": "./dist/mdx.d.ts",
|
|
62
62
|
"default": "./dist/mdx.js"
|
|
63
63
|
},
|
|
64
|
+
"./svg": {
|
|
65
|
+
"bun": "./src/svg.ts",
|
|
66
|
+
"types": "./dist/svg.d.ts",
|
|
67
|
+
"default": "./dist/svg.js"
|
|
68
|
+
},
|
|
64
69
|
"./mdx-runtime": {
|
|
65
70
|
"bun": "./src/mdx-runtime.ts",
|
|
66
71
|
"types": "./dist/mdx-runtime.d.ts",
|
|
@@ -82,9 +87,9 @@
|
|
|
82
87
|
"dependencies": {
|
|
83
88
|
"@babel/core": "^7.26.0",
|
|
84
89
|
"@babel/preset-typescript": "^7.26.0",
|
|
85
|
-
"@nifrajs/i18n": "1.
|
|
86
|
-
"@nifrajs/image": "1.
|
|
87
|
-
"@nifrajs/web": "1.
|
|
90
|
+
"@nifrajs/i18n": "2.1.0",
|
|
91
|
+
"@nifrajs/image": "2.1.0",
|
|
92
|
+
"@nifrajs/web": "2.1.0",
|
|
88
93
|
"babel-preset-solid": "^1.9.3"
|
|
89
94
|
},
|
|
90
95
|
"peerDependencies": {
|
package/src/svg.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@nifrajs/web-solid/svg` - the Solid build of the SVG-as-component plugin. `import Icon from
|
|
3
|
+
* "./icon.svg?component"`, then `<Icon class="w-6 h-6" />`, props spread onto the root `<svg>`.
|
|
4
|
+
*
|
|
5
|
+
* Solid JSX is not standard JSX (it compiles through `babel-preset-solid`) and uses `class`, not
|
|
6
|
+
* `className` - so this can't reuse the React/Preact plugin from `@nifrajs/web/plugins/svg`. It shares
|
|
7
|
+
* that package's `svgToJsx` transform (with `classProp: "class"`) to produce a Solid component, then
|
|
8
|
+
* runs the same Solid + TypeScript babel passes `solidBunPlugin` applies to `.tsx`. Pass `"dom"` for the
|
|
9
|
+
* client bundle and preload `"ssr"` for the server.
|
|
10
|
+
*/
|
|
11
|
+
import { transformAsync } from "@babel/core"
|
|
12
|
+
// @ts-expect-error - no type declarations published
|
|
13
|
+
import presetTypeScript from "@babel/preset-typescript"
|
|
14
|
+
import { SVG_COMPONENT_FILTER, svgComponentSource } from "@nifrajs/web/plugins/svg"
|
|
15
|
+
// @ts-expect-error - no type declarations published
|
|
16
|
+
import presetSolid from "babel-preset-solid"
|
|
17
|
+
import type { BunPlugin } from "bun"
|
|
18
|
+
|
|
19
|
+
/** The Solid SVG-component plugin. `generate` selects the Solid `"dom"`/`"ssr"` output, matching
|
|
20
|
+
* `solidBunPlugin`. A plain `import "./icon.svg"` (asset URL) is untouched - only `?component` matches. */
|
|
21
|
+
export function solidSvgComponentBunPlugin(generate: "dom" | "ssr"): BunPlugin {
|
|
22
|
+
return {
|
|
23
|
+
name: `nifra-solid-svg-${generate}`,
|
|
24
|
+
setup(build) {
|
|
25
|
+
build.onLoad({ filter: SVG_COMPONENT_FILTER }, async (args) => {
|
|
26
|
+
const path = args.path.split("?")[0] ?? args.path
|
|
27
|
+
const xml = await Bun.file(path).text()
|
|
28
|
+
// Solid uses `class`; emit the component JSX, then run the Solid + TS babel passes.
|
|
29
|
+
const source = svgComponentSource(xml, { classProp: "class" })
|
|
30
|
+
const result = await transformAsync(source, {
|
|
31
|
+
filename: `${path}.tsx`, // ensure presetTypeScript treats it as TSX-eligible
|
|
32
|
+
presets: [
|
|
33
|
+
[presetSolid, { generate, hydratable: true }],
|
|
34
|
+
[presetTypeScript, { onlyRemoveTypeImports: true }],
|
|
35
|
+
],
|
|
36
|
+
})
|
|
37
|
+
return { contents: result?.code ?? "", loader: "js" }
|
|
38
|
+
})
|
|
39
|
+
},
|
|
40
|
+
}
|
|
41
|
+
}
|