@wq2/solid-jsx-oxc 0.1.0-alpha.15
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/binding.d.ts +57 -0
- package/index.d.ts +114 -0
- package/index.js +117 -0
- package/package.json +71 -0
- package/solid-jsx-oxc.linux-x64-gnu.node +0 -0
package/binding.d.ts
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/* auto-generated by NAPI-RS */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/** Transform options exposed to JavaScript */
|
|
4
|
+
export interface JsTransformOptions {
|
|
5
|
+
/**
|
|
6
|
+
* The module to import runtime helpers from
|
|
7
|
+
* @default "solid-js/web"
|
|
8
|
+
*/
|
|
9
|
+
moduleName?: string
|
|
10
|
+
/**
|
|
11
|
+
* Generate mode: "dom", "ssr", or "universal"
|
|
12
|
+
* Note: "universal" is currently treated as "dom" (not a separate universal renderer output).
|
|
13
|
+
* @default "dom"
|
|
14
|
+
*/
|
|
15
|
+
generate?: string
|
|
16
|
+
/**
|
|
17
|
+
* Whether to enable hydration support
|
|
18
|
+
* @default false
|
|
19
|
+
*/
|
|
20
|
+
hydratable?: boolean
|
|
21
|
+
/**
|
|
22
|
+
* Whether to delegate events
|
|
23
|
+
* @default true
|
|
24
|
+
*/
|
|
25
|
+
delegateEvents?: boolean
|
|
26
|
+
/**
|
|
27
|
+
* Whether to wrap conditionals
|
|
28
|
+
* @default true
|
|
29
|
+
*/
|
|
30
|
+
wrapConditionals?: boolean
|
|
31
|
+
/**
|
|
32
|
+
* Whether to pass context to custom elements
|
|
33
|
+
* @default true
|
|
34
|
+
*/
|
|
35
|
+
contextToCustomElements?: boolean
|
|
36
|
+
/**
|
|
37
|
+
* Source filename
|
|
38
|
+
* @default "input.jsx"
|
|
39
|
+
*/
|
|
40
|
+
filename?: string
|
|
41
|
+
/**
|
|
42
|
+
* Whether to generate source maps
|
|
43
|
+
* @default false
|
|
44
|
+
*/
|
|
45
|
+
sourceMap?: boolean
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** Transform JSX source code */
|
|
49
|
+
export declare function transformJsx(source: string, options?: JsTransformOptions | undefined | null): TransformResult
|
|
50
|
+
|
|
51
|
+
/** Result of a transform operation */
|
|
52
|
+
export interface TransformResult {
|
|
53
|
+
/** The transformed code */
|
|
54
|
+
code: string
|
|
55
|
+
/** Source map (if enabled) */
|
|
56
|
+
map?: string
|
|
57
|
+
}
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* solid-jsx-oxc - OXC-based JSX compiler for SolidJS
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
export interface TransformOptions {
|
|
6
|
+
/**
|
|
7
|
+
* The module to import runtime helpers from
|
|
8
|
+
* @default "solid-js/web"
|
|
9
|
+
*/
|
|
10
|
+
moduleName?: string;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Generate mode: "dom", "ssr", or "universal"
|
|
14
|
+
* @default "dom"
|
|
15
|
+
*/
|
|
16
|
+
generate?: 'dom' | 'ssr' | 'universal';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Whether to enable hydration support
|
|
20
|
+
* @default false
|
|
21
|
+
*/
|
|
22
|
+
hydratable?: boolean;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Whether to delegate events
|
|
26
|
+
* @default true
|
|
27
|
+
*/
|
|
28
|
+
delegateEvents?: boolean;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Whether to wrap conditionals
|
|
32
|
+
* @default true
|
|
33
|
+
*/
|
|
34
|
+
wrapConditionals?: boolean;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Whether to pass context to custom elements
|
|
38
|
+
* @default true
|
|
39
|
+
*/
|
|
40
|
+
contextToCustomElements?: boolean;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Source filename
|
|
44
|
+
* @default "input.jsx"
|
|
45
|
+
*/
|
|
46
|
+
filename?: string;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Whether to generate source maps
|
|
50
|
+
* @default false
|
|
51
|
+
*/
|
|
52
|
+
sourceMap?: boolean;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Built-in components that receive special handling
|
|
56
|
+
*/
|
|
57
|
+
builtIns?: string[];
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export interface TransformResult {
|
|
61
|
+
/** The transformed code */
|
|
62
|
+
code: string;
|
|
63
|
+
/** Source map (if enabled) */
|
|
64
|
+
map?: string;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Transform JSX source code
|
|
69
|
+
* @param source - The source code to transform
|
|
70
|
+
* @param options - Transform options
|
|
71
|
+
* @returns The transformed code and optional source map
|
|
72
|
+
*/
|
|
73
|
+
export function transform(source: string, options?: TransformOptions): TransformResult;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Low-level transform function from the native binding.
|
|
77
|
+
*/
|
|
78
|
+
export function transformJsx(source: string, options?: {
|
|
79
|
+
moduleName?: string;
|
|
80
|
+
generate?: 'dom' | 'ssr' | 'universal' | string;
|
|
81
|
+
hydratable?: boolean;
|
|
82
|
+
delegateEvents?: boolean;
|
|
83
|
+
wrapConditionals?: boolean;
|
|
84
|
+
contextToCustomElements?: boolean;
|
|
85
|
+
filename?: string;
|
|
86
|
+
sourceMap?: boolean;
|
|
87
|
+
} | null): TransformResult;
|
|
88
|
+
|
|
89
|
+
export interface PresetResult {
|
|
90
|
+
options: TransformOptions;
|
|
91
|
+
transform: (source: string) => TransformResult;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Create a preset configuration (for compatibility with babel-preset-solid interface)
|
|
96
|
+
* @param context - Babel context (ignored, for compatibility)
|
|
97
|
+
* @param options - User options
|
|
98
|
+
* @returns Preset configuration with options and transform function
|
|
99
|
+
*/
|
|
100
|
+
export function preset(context: unknown, options?: TransformOptions): PresetResult;
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Default options matching babel-preset-solid
|
|
104
|
+
*/
|
|
105
|
+
export const defaultOptions: Required<Omit<TransformOptions, 'filename'>>;
|
|
106
|
+
|
|
107
|
+
declare const _default: {
|
|
108
|
+
transform: typeof transform;
|
|
109
|
+
preset: typeof preset;
|
|
110
|
+
defaultOptions: typeof defaultOptions;
|
|
111
|
+
transformJsx: typeof transformJsx;
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
export default _default;
|
package/index.js
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* solid-jsx-oxc - OXC-based JSX compiler for SolidJS
|
|
3
|
+
*
|
|
4
|
+
* ESM entry point - provides the same interface as babel-preset-solid.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { createRequire } from 'node:module';
|
|
8
|
+
import { platform, arch } from 'node:process';
|
|
9
|
+
import { fileURLToPath } from 'node:url';
|
|
10
|
+
import { dirname, join } from 'node:path';
|
|
11
|
+
|
|
12
|
+
const require = createRequire(import.meta.url);
|
|
13
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
14
|
+
|
|
15
|
+
// Map Node.js platform/arch to binary file suffix
|
|
16
|
+
const platformMap = {
|
|
17
|
+
'darwin-arm64': 'darwin-arm64',
|
|
18
|
+
'darwin-x64': 'darwin-x64',
|
|
19
|
+
'linux-x64': 'linux-x64-gnu',
|
|
20
|
+
'linux-arm64': 'linux-arm64-gnu',
|
|
21
|
+
'win32-x64': 'win32-x64-msvc',
|
|
22
|
+
'win32-arm64': 'win32-arm64-msvc',
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const platformKey = `${platform}-${arch}`;
|
|
26
|
+
const nativeTarget = platformMap[platformKey];
|
|
27
|
+
|
|
28
|
+
// Try to load the native module
|
|
29
|
+
let nativeBinding = null;
|
|
30
|
+
|
|
31
|
+
try {
|
|
32
|
+
if (nativeTarget) {
|
|
33
|
+
// Try platform-specific binary first
|
|
34
|
+
nativeBinding = require(join(__dirname, `solid-jsx-oxc.${nativeTarget}.node`));
|
|
35
|
+
} else {
|
|
36
|
+
// Fallback to generic name
|
|
37
|
+
nativeBinding = require(join(__dirname, 'solid-jsx-oxc.node'));
|
|
38
|
+
}
|
|
39
|
+
} catch (e) {
|
|
40
|
+
// Fallback message if native module not found
|
|
41
|
+
console.warn(`solid-jsx-oxc: Native module not found for ${platformKey}. Run \`npm run build\` to compile.`);
|
|
42
|
+
console.warn(e instanceof Error ? e.message : String(e));
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Default options matching babel-preset-solid
|
|
47
|
+
*/
|
|
48
|
+
export const defaultOptions = {
|
|
49
|
+
moduleName: 'solid-js/web',
|
|
50
|
+
builtIns: [
|
|
51
|
+
'For',
|
|
52
|
+
'Show',
|
|
53
|
+
'Switch',
|
|
54
|
+
'Match',
|
|
55
|
+
'Suspense',
|
|
56
|
+
'SuspenseList',
|
|
57
|
+
'Portal',
|
|
58
|
+
'Index',
|
|
59
|
+
'Dynamic',
|
|
60
|
+
'ErrorBoundary'
|
|
61
|
+
],
|
|
62
|
+
contextToCustomElements: true,
|
|
63
|
+
wrapConditionals: true,
|
|
64
|
+
generate: 'dom', // 'dom' | 'ssr' | 'universal'
|
|
65
|
+
hydratable: false,
|
|
66
|
+
delegateEvents: true,
|
|
67
|
+
sourceMap: false,
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Transform JSX source code
|
|
72
|
+
* @param {string} source - The source code to transform
|
|
73
|
+
* @param {object} options - Transform options
|
|
74
|
+
* @returns {{ code: string, map?: string }}
|
|
75
|
+
*/
|
|
76
|
+
export function transform(source, options = {}) {
|
|
77
|
+
if (!nativeBinding) {
|
|
78
|
+
throw new Error('solid-jsx-oxc: Native module not loaded. Ensure it is built for your platform.');
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const mergedOptions = { ...defaultOptions, ...options };
|
|
82
|
+
|
|
83
|
+
// NAPI-RS automatically converts camelCase (JS) to snake_case (Rust)
|
|
84
|
+
// so we can pass options directly without manual conversion
|
|
85
|
+
return nativeBinding.transformJsx(source, mergedOptions);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Create a preset configuration (for compatibility with babel-preset-solid interface)
|
|
90
|
+
* @param {object} context - Babel context (ignored, for compatibility)
|
|
91
|
+
* @param {object} options - User options
|
|
92
|
+
* @returns {object}
|
|
93
|
+
*/
|
|
94
|
+
export function preset(context, options = {}) {
|
|
95
|
+
const mergedOptions = { ...defaultOptions, ...options };
|
|
96
|
+
|
|
97
|
+
return {
|
|
98
|
+
// Return the options that would be passed to the transform
|
|
99
|
+
options: mergedOptions,
|
|
100
|
+
|
|
101
|
+
// The transform function
|
|
102
|
+
transform: (source) => transform(source, mergedOptions),
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Low-level transform function from the native binding
|
|
108
|
+
*/
|
|
109
|
+
export const transformJsx = nativeBinding ? nativeBinding.transformJsx : null;
|
|
110
|
+
|
|
111
|
+
// Default export for convenience
|
|
112
|
+
export default {
|
|
113
|
+
transform,
|
|
114
|
+
preset,
|
|
115
|
+
defaultOptions,
|
|
116
|
+
transformJsx,
|
|
117
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@wq2/solid-jsx-oxc",
|
|
3
|
+
"version": "0.1.0-alpha.15",
|
|
4
|
+
"description": "OXC-based JSX compiler for SolidJS",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "index.js",
|
|
7
|
+
"types": "index.d.ts",
|
|
8
|
+
"private": false,
|
|
9
|
+
"publishConfig": {
|
|
10
|
+
"access": "public",
|
|
11
|
+
"provenance": true
|
|
12
|
+
},
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"types": "./index.d.ts",
|
|
16
|
+
"import": "./index.js"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"index.js",
|
|
21
|
+
"index.d.ts",
|
|
22
|
+
"binding.d.ts",
|
|
23
|
+
"*.node"
|
|
24
|
+
],
|
|
25
|
+
"repository": {
|
|
26
|
+
"type": "git",
|
|
27
|
+
"url": "https://github.com/MinibloxCheaters2/solid-jsx-oxc"
|
|
28
|
+
},
|
|
29
|
+
"keywords": [
|
|
30
|
+
"solid",
|
|
31
|
+
"solidjs",
|
|
32
|
+
"jsx",
|
|
33
|
+
"compiler",
|
|
34
|
+
"oxc",
|
|
35
|
+
"rust",
|
|
36
|
+
"napi",
|
|
37
|
+
"rolldown"
|
|
38
|
+
],
|
|
39
|
+
"author": "SolidJS Contributors",
|
|
40
|
+
"license": "MIT",
|
|
41
|
+
"napi": {
|
|
42
|
+
"binaryName": "solid-jsx-oxc",
|
|
43
|
+
"targets": [
|
|
44
|
+
"x86_64-unknown-linux-gnu",
|
|
45
|
+
"x86_64-pc-windows-msvc",
|
|
46
|
+
"aarch64-unknown-linux-gnu",
|
|
47
|
+
"aarch64-pc-windows-msvc"
|
|
48
|
+
]
|
|
49
|
+
},
|
|
50
|
+
"scripts": {
|
|
51
|
+
"artifacts": "napi artifacts",
|
|
52
|
+
"build": "napi build --platform --release --features napi --no-js --dts binding.d.ts",
|
|
53
|
+
"build:debug": "napi build --platform --features napi --no-js --dts binding.d.ts",
|
|
54
|
+
"clean": "rm -f *.node",
|
|
55
|
+
"rebuild": "bun run clean && bun run build",
|
|
56
|
+
"test": "cargo test",
|
|
57
|
+
"test:js": "bun run verify",
|
|
58
|
+
"verify": "bun scripts/verify.mjs",
|
|
59
|
+
"bench": "cargo bench",
|
|
60
|
+
"release": "bun scripts/release.mjs",
|
|
61
|
+
"release:alpha": "bun scripts/release.mjs alpha",
|
|
62
|
+
"release:beta": "bun scripts/release.mjs beta",
|
|
63
|
+
"release:next": "bun scripts/release.mjs next"
|
|
64
|
+
},
|
|
65
|
+
"devDependencies": {
|
|
66
|
+
"@napi-rs/cli": "^3.5.0"
|
|
67
|
+
},
|
|
68
|
+
"engines": {
|
|
69
|
+
"node": ">= 18"
|
|
70
|
+
}
|
|
71
|
+
}
|
|
Binary file
|