@ktjs/babel-plugin-ktjsx 0.1.0 → 0.2.2
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/LICENSE +21 -0
- package/README.md +40 -13
- package/dist/index.d.ts +1 -6
- package/dist/index.mjs +2 -14986
- package/dist/index.mjs.map +1 -0
- package/package.json +9 -9
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 kasukabe tsumugi
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,25 +1,52 @@
|
|
|
1
|
-
# babel-plugin-ktjsx
|
|
1
|
+
# @ktjs/babel-plugin-ktjsx
|
|
2
2
|
|
|
3
|
-
`@ktjs/babel-plugin-ktjsx` is
|
|
3
|
+
`@ktjs/babel-plugin-ktjsx` is the Babel entry for KT.js JSX transforms, re-exported from `@ktjs/transformer`.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Current behavior:
|
|
6
|
+
|
|
7
|
+
- add KT.js internal SVG / MathML flags on JSX elements in SVG / MathML context
|
|
8
|
+
- validate directive combinations (`k-if` + `k-else`, and `k-for` mixed with conditional directives)
|
|
9
|
+
- transform `k-for` into `source.map(...)` and remove `k-for` / `k-key` attributes
|
|
10
|
+
- normalize sibling `k-if` / `k-else-if` / `k-else` chains into explicit `k-if` conditions
|
|
11
|
+
|
|
12
|
+
## Install
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
pnpm add -D @ktjs/babel-plugin-ktjsx @babel/core
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Usage (ESM Babel config)
|
|
6
19
|
|
|
7
20
|
```js
|
|
8
|
-
// babel.config.
|
|
21
|
+
// babel.config.mjs
|
|
22
|
+
import ktjsx from '@ktjs/babel-plugin-ktjsx';
|
|
23
|
+
|
|
24
|
+
export default {
|
|
25
|
+
plugins: [ktjsx],
|
|
26
|
+
};
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Usage (CommonJS Babel config)
|
|
30
|
+
|
|
31
|
+
```js
|
|
32
|
+
// babel.config.cjs
|
|
33
|
+
const { default: ktjsx } = require('@ktjs/babel-plugin-ktjsx');
|
|
34
|
+
|
|
9
35
|
module.exports = {
|
|
10
|
-
plugins: [
|
|
36
|
+
plugins: [ktjsx],
|
|
11
37
|
};
|
|
12
38
|
```
|
|
13
39
|
|
|
14
|
-
|
|
40
|
+
## Named exports
|
|
15
41
|
|
|
16
|
-
|
|
42
|
+
```ts
|
|
43
|
+
import { transformerKTjsx, transformWithKTjsx } from '@ktjs/babel-plugin-ktjsx';
|
|
44
|
+
```
|
|
17
45
|
|
|
18
|
-
- `
|
|
19
|
-
- `
|
|
20
|
-
- `createElementNames` - functions to consider as element factories (default `['createElement','h']`)
|
|
46
|
+
- `transformerKTjsx`: Babel plugin factory (same as default export)
|
|
47
|
+
- `transformWithKTjsx`: programmatic transform helper
|
|
21
48
|
|
|
22
|
-
Notes
|
|
49
|
+
## Notes
|
|
23
50
|
|
|
24
|
-
-
|
|
25
|
-
-
|
|
51
|
+
- This plugin works on JSX AST directly (not on `createElement(...)` output).
|
|
52
|
+
- There are no custom plugin options yet.
|
package/dist/index.d.ts
CHANGED