solid-jsx-oxc 0.1.0-alpha.1
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 +56 -0
- package/index.d.ts +115 -0
- package/index.js +122 -0
- package/index.mjs +4 -0
- package/package.json +69 -0
- package/solid-jsx-oxc.darwin-arm64.node +0 -0
package/binding.d.ts
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
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
|
+
* @default "dom"
|
|
13
|
+
*/
|
|
14
|
+
generate?: string
|
|
15
|
+
/**
|
|
16
|
+
* Whether to enable hydration support
|
|
17
|
+
* @default false
|
|
18
|
+
*/
|
|
19
|
+
hydratable?: boolean
|
|
20
|
+
/**
|
|
21
|
+
* Whether to delegate events
|
|
22
|
+
* @default true
|
|
23
|
+
*/
|
|
24
|
+
delegateEvents?: boolean
|
|
25
|
+
/**
|
|
26
|
+
* Whether to wrap conditionals
|
|
27
|
+
* @default true
|
|
28
|
+
*/
|
|
29
|
+
wrapConditionals?: boolean
|
|
30
|
+
/**
|
|
31
|
+
* Whether to pass context to custom elements
|
|
32
|
+
* @default true
|
|
33
|
+
*/
|
|
34
|
+
contextToCustomElements?: boolean
|
|
35
|
+
/**
|
|
36
|
+
* Source filename
|
|
37
|
+
* @default "input.jsx"
|
|
38
|
+
*/
|
|
39
|
+
filename?: string
|
|
40
|
+
/**
|
|
41
|
+
* Whether to generate source maps
|
|
42
|
+
* @default false
|
|
43
|
+
*/
|
|
44
|
+
sourceMap?: boolean
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** Transform JSX source code */
|
|
48
|
+
export declare function transformJsx(source: string, options?: JsTransformOptions | undefined | null): TransformResult
|
|
49
|
+
|
|
50
|
+
/** Result of a transform operation */
|
|
51
|
+
export interface TransformResult {
|
|
52
|
+
/** The transformed code */
|
|
53
|
+
code: string
|
|
54
|
+
/** Source map (if enabled) */
|
|
55
|
+
map?: string
|
|
56
|
+
}
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
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
|
+
* Prefers snake_case option names.
|
|
78
|
+
*/
|
|
79
|
+
export function transformJsx(source: string, options?: {
|
|
80
|
+
module_name?: string;
|
|
81
|
+
generate?: string;
|
|
82
|
+
hydratable?: boolean;
|
|
83
|
+
delegate_events?: boolean;
|
|
84
|
+
wrap_conditionals?: boolean;
|
|
85
|
+
context_to_custom_elements?: boolean;
|
|
86
|
+
filename?: string;
|
|
87
|
+
source_map?: boolean;
|
|
88
|
+
} | null): TransformResult;
|
|
89
|
+
|
|
90
|
+
export interface PresetResult {
|
|
91
|
+
options: TransformOptions;
|
|
92
|
+
transform: (source: string) => TransformResult;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Create a preset configuration (for compatibility with babel-preset-solid interface)
|
|
97
|
+
* @param context - Babel context (ignored, for compatibility)
|
|
98
|
+
* @param options - User options
|
|
99
|
+
* @returns Preset configuration with options and transform function
|
|
100
|
+
*/
|
|
101
|
+
export function preset(context: unknown, options?: TransformOptions): PresetResult;
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Default options matching babel-preset-solid
|
|
105
|
+
*/
|
|
106
|
+
export const defaultOptions: Required<Omit<TransformOptions, 'filename'>>;
|
|
107
|
+
|
|
108
|
+
declare const _default: {
|
|
109
|
+
transform: typeof transform;
|
|
110
|
+
preset: typeof preset;
|
|
111
|
+
defaultOptions: typeof defaultOptions;
|
|
112
|
+
transformJsx: typeof transformJsx;
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
export default _default;
|
package/index.js
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* solid-jsx-oxc - OXC-based JSX compiler for SolidJS
|
|
3
|
+
*
|
|
4
|
+
* This is the JavaScript wrapper around the Rust NAPI bindings.
|
|
5
|
+
* It provides the same interface as babel-preset-solid.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
// Try to load the native module
|
|
9
|
+
let nativeBinding = null;
|
|
10
|
+
|
|
11
|
+
// Detect platform and architecture
|
|
12
|
+
const platform = process.platform;
|
|
13
|
+
const arch = process.arch;
|
|
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 {
|
|
29
|
+
if (nativeTarget) {
|
|
30
|
+
// Try platform-specific binary first
|
|
31
|
+
nativeBinding = require(`./solid-jsx-oxc.${nativeTarget}.node`);
|
|
32
|
+
} else {
|
|
33
|
+
// Fallback to generic name
|
|
34
|
+
nativeBinding = require('./solid-jsx-oxc.node');
|
|
35
|
+
}
|
|
36
|
+
} catch (e) {
|
|
37
|
+
// Fallback message if native module not found
|
|
38
|
+
console.warn(`solid-jsx-oxc: Native module not found for ${platformKey}. Run \`npm run build\` to compile.`);
|
|
39
|
+
console.warn(e.message);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Default options matching babel-preset-solid
|
|
44
|
+
*/
|
|
45
|
+
const defaultOptions = {
|
|
46
|
+
moduleName: 'solid-js/web',
|
|
47
|
+
builtIns: [
|
|
48
|
+
'For',
|
|
49
|
+
'Show',
|
|
50
|
+
'Switch',
|
|
51
|
+
'Match',
|
|
52
|
+
'Suspense',
|
|
53
|
+
'SuspenseList',
|
|
54
|
+
'Portal',
|
|
55
|
+
'Index',
|
|
56
|
+
'Dynamic',
|
|
57
|
+
'ErrorBoundary'
|
|
58
|
+
],
|
|
59
|
+
contextToCustomElements: true,
|
|
60
|
+
wrapConditionals: true,
|
|
61
|
+
generate: 'dom', // 'dom' | 'ssr' | 'universal'
|
|
62
|
+
hydratable: false,
|
|
63
|
+
delegateEvents: true,
|
|
64
|
+
sourceMap: false,
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Transform JSX source code
|
|
69
|
+
* @param {string} source - The source code to transform
|
|
70
|
+
* @param {object} options - Transform options
|
|
71
|
+
* @returns {{ code: string, map?: string }}
|
|
72
|
+
*/
|
|
73
|
+
function transform(source, options = {}) {
|
|
74
|
+
if (!nativeBinding) {
|
|
75
|
+
throw new Error('solid-jsx-oxc: Native module not loaded. Ensure it is built for your platform.');
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const mergedOptions = { ...defaultOptions, ...options };
|
|
79
|
+
|
|
80
|
+
// Map options to match Rust struct field names (snake_case)
|
|
81
|
+
const rustOptions = {
|
|
82
|
+
module_name: mergedOptions.moduleName,
|
|
83
|
+
generate: mergedOptions.generate,
|
|
84
|
+
hydratable: mergedOptions.hydratable,
|
|
85
|
+
delegate_events: mergedOptions.delegateEvents,
|
|
86
|
+
wrap_conditionals: mergedOptions.wrapConditionals,
|
|
87
|
+
context_to_custom_elements: mergedOptions.contextToCustomElements,
|
|
88
|
+
filename: mergedOptions.filename,
|
|
89
|
+
source_map: mergedOptions.sourceMap,
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
return nativeBinding.transformJsx(source, rustOptions);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Create a preset configuration (for compatibility with babel-preset-solid interface)
|
|
97
|
+
* @param {object} context - Babel context (ignored, for compatibility)
|
|
98
|
+
* @param {object} options - User options
|
|
99
|
+
* @returns {object}
|
|
100
|
+
*/
|
|
101
|
+
function preset(context, options = {}) {
|
|
102
|
+
const mergedOptions = { ...defaultOptions, ...options };
|
|
103
|
+
|
|
104
|
+
return {
|
|
105
|
+
// Return the options that would be passed to the transform
|
|
106
|
+
options: mergedOptions,
|
|
107
|
+
|
|
108
|
+
// The transform function
|
|
109
|
+
transform: (source) => transform(source, mergedOptions),
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
module.exports = {
|
|
114
|
+
transform,
|
|
115
|
+
preset,
|
|
116
|
+
defaultOptions,
|
|
117
|
+
// Also export the raw binding for advanced usage
|
|
118
|
+
transformJsx: nativeBinding ? nativeBinding.transformJsx : null,
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
// Also export as default for ESM compatibility
|
|
122
|
+
module.exports.default = module.exports;
|
package/index.mjs
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "solid-jsx-oxc",
|
|
3
|
+
"version": "0.1.0-alpha.1",
|
|
4
|
+
"description": "OXC-based JSX compiler for SolidJS",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"types": "index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./index.d.ts",
|
|
10
|
+
"require": "./index.js",
|
|
11
|
+
"import": "./index.mjs"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"index.js",
|
|
16
|
+
"index.mjs",
|
|
17
|
+
"index.d.ts",
|
|
18
|
+
"binding.d.ts",
|
|
19
|
+
"*.node"
|
|
20
|
+
],
|
|
21
|
+
"repository": {
|
|
22
|
+
"type": "git",
|
|
23
|
+
"url": "https://github.com/ryansolid/dom-expressions"
|
|
24
|
+
},
|
|
25
|
+
"keywords": [
|
|
26
|
+
"solid",
|
|
27
|
+
"solidjs",
|
|
28
|
+
"jsx",
|
|
29
|
+
"compiler",
|
|
30
|
+
"oxc",
|
|
31
|
+
"rust",
|
|
32
|
+
"napi",
|
|
33
|
+
"rolldown"
|
|
34
|
+
],
|
|
35
|
+
"author": "SolidJS Contributors",
|
|
36
|
+
"license": "MIT",
|
|
37
|
+
"napi": {
|
|
38
|
+
"binaryName": "solid-jsx-oxc",
|
|
39
|
+
"targets": [
|
|
40
|
+
"x86_64-apple-darwin",
|
|
41
|
+
"aarch64-apple-darwin",
|
|
42
|
+
"x86_64-unknown-linux-gnu",
|
|
43
|
+
"x86_64-pc-windows-msvc",
|
|
44
|
+
"aarch64-unknown-linux-gnu",
|
|
45
|
+
"aarch64-pc-windows-msvc"
|
|
46
|
+
]
|
|
47
|
+
},
|
|
48
|
+
"scripts": {
|
|
49
|
+
"artifacts": "napi artifacts",
|
|
50
|
+
"build": "napi build --platform --release --features napi --no-js --dts binding.d.ts",
|
|
51
|
+
"build:debug": "napi build --platform --features napi --no-js --dts binding.d.ts",
|
|
52
|
+
"clean": "rm -f *.node",
|
|
53
|
+
"rebuild": "bun run clean && bun run build",
|
|
54
|
+
"test": "cargo test",
|
|
55
|
+
"test:js": "bun run verify",
|
|
56
|
+
"verify": "bun scripts/verify.mjs",
|
|
57
|
+
"bench": "cargo bench",
|
|
58
|
+
"release": "bun scripts/release.mjs",
|
|
59
|
+
"release:alpha": "bun scripts/release.mjs alpha",
|
|
60
|
+
"release:beta": "bun scripts/release.mjs beta",
|
|
61
|
+
"release:next": "bun scripts/release.mjs next"
|
|
62
|
+
},
|
|
63
|
+
"devDependencies": {
|
|
64
|
+
"@napi-rs/cli": "^3.0.0-alpha.69"
|
|
65
|
+
},
|
|
66
|
+
"engines": {
|
|
67
|
+
"node": ">= 18"
|
|
68
|
+
}
|
|
69
|
+
}
|
|
Binary file
|