Website Structure

This commit is contained in:
supalerk-ar66 2026-01-13 10:46:40 +07:00
parent 62812f2090
commit 71f0676a62
22365 changed files with 4265753 additions and 791 deletions

22
Frontend-Learner/node_modules/oxc-transform/LICENSE generated vendored Normal file
View file

@ -0,0 +1,22 @@
MIT License
Copyright (c) 2024-present VoidZero Inc. & Contributors
Copyright (c) 2023 Boshen
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

88
Frontend-Learner/node_modules/oxc-transform/README.md generated vendored Normal file
View file

@ -0,0 +1,88 @@
# Oxc Transform
This is alpha software and may yield incorrect results, feel free to [submit a bug report](https://github.com/oxc-project/oxc/issues/new?assignees=&labels=C-bug&projects=&template=bug_report.md).
## TypeScript and React JSX Transform
```javascript
import assert from 'assert';
import { transformSync } from 'oxc-transform';
const { code, declaration, errors } = transformSync(
'test.ts',
'class A<T> {}',
{
typescript: {
declaration: true, // With isolated declarations in a single step.
},
},
);
// or `await transform(filename, code, options)`
assert.equal(code, 'class A {}\n');
assert.equal(declaration, 'declare class A<T> {}\n');
assert(errors.length == 0);
```
## [Isolated Declarations for Standalone DTS Emit](https://devblogs.microsoft.com/typescript/announcing-typescript-5-5/#isolated-declarations)
Conforms to TypeScript compiler's `--isolatedDeclarations` `.d.ts` emit.
### Usage
```javascript
import assert from 'assert';
import { isolatedDeclarationSync } from 'oxc-transform';
const { map, code, errors } = isolatedDeclarationSync('test.ts', 'class A {}');
// or `await isolatedDeclaration(filename, code, options)`
assert.equal(code, 'declare class A {}\n');
assert(errors.length == 0);
```
### API
#### Transform Functions
```typescript
// Synchronous transform
transformSync(
filename: string,
sourceText: string,
options?: TransformOptions,
): TransformResult
// Asynchronous transform
transform(
filename: string,
sourceText: string,
options?: TransformOptions,
): Promise<TransformResult>
```
#### Isolated Declaration Functions
```typescript
// Synchronous isolated declaration
isolatedDeclarationSync(
filename: string,
sourceText: string,
options?: IsolatedDeclarationsOptions,
): IsolatedDeclarationsResult
// Asynchronous isolated declaration
isolatedDeclaration(
filename: string,
sourceText: string,
options?: IsolatedDeclarationsOptions,
): Promise<IsolatedDeclarationsResult>
```
Use the `Sync` versions for synchronous operations. Use async versions for asynchronous operations, which can be beneficial in I/O-bound or concurrent scenarios, though they add async overhead.
See `index.d.ts` for complete type definitions.
### Supports WASM
See https://stackblitz.com/edit/oxc-transform for usage example.

View file

@ -0,0 +1 @@
export * from '@oxc-transform/binding-wasm32-wasi'

648
Frontend-Learner/node_modules/oxc-transform/index.d.ts generated vendored Normal file
View file

@ -0,0 +1,648 @@
/* auto-generated by NAPI-RS */
/* eslint-disable */
export interface Comment {
type: 'Line' | 'Block'
value: string
start: number
end: number
}
export interface ErrorLabel {
message: string | null
start: number
end: number
}
export interface OxcError {
severity: Severity
message: string
labels: Array<ErrorLabel>
helpMessage: string | null
codeframe: string | null
}
export declare const enum Severity {
Error = 'Error',
Warning = 'Warning',
Advice = 'Advice'
}
export interface SourceMap {
file?: string
mappings: string
names: Array<string>
sourceRoot?: string
sources: Array<string>
sourcesContent?: Array<string>
version: number
x_google_ignoreList?: Array<number>
}
export interface ArrowFunctionsOptions {
/**
* This option enables the following:
* * Wrap the generated function in .bind(this) and keeps uses of this inside the function as-is, instead of using a renamed this.
* * Add a runtime check to ensure the functions are not instantiated.
* * Add names to arrow functions.
*
* @default false
*/
spec?: boolean
}
export interface CompilerAssumptions {
ignoreFunctionLength?: boolean
noDocumentAll?: boolean
objectRestNoSymbols?: boolean
pureGetters?: boolean
/**
* When using public class fields, assume that they don't shadow any getter in the current class,
* in its subclasses or in its superclass. Thus, it's safe to assign them rather than using
* `Object.defineProperty`.
*
* For example:
*
* Input:
* ```js
* class Test {
* field = 2;
*
* static staticField = 3;
* }
* ```
*
* When `set_public_class_fields` is `true`, the output will be:
* ```js
* class Test {
* constructor() {
* this.field = 2;
* }
* }
* Test.staticField = 3;
* ```
*
* Otherwise, the output will be:
* ```js
* import _defineProperty from "@oxc-project/runtime/helpers/defineProperty";
* class Test {
* constructor() {
* _defineProperty(this, "field", 2);
* }
* }
* _defineProperty(Test, "staticField", 3);
* ```
*
* NOTE: For TypeScript, if you wanted behavior is equivalent to `useDefineForClassFields: false`, you should
* set both `set_public_class_fields` and [`crate::TypeScriptOptions::remove_class_fields_without_initializer`]
* to `true`.
*/
setPublicClassFields?: boolean
}
export interface DecoratorOptions {
/**
* Enables experimental support for decorators, which is a version of decorators that predates the TC39 standardization process.
*
* Decorators are a language feature which hasnt yet been fully ratified into the JavaScript specification.
* This means that the implementation version in TypeScript may differ from the implementation in JavaScript when it it decided by TC39.
*
* @see https://www.typescriptlang.org/tsconfig/#experimentalDecorators
* @default false
*/
legacy?: boolean
/**
* Enables emitting decorator metadata.
*
* This option the same as [emitDecoratorMetadata](https://www.typescriptlang.org/tsconfig/#emitDecoratorMetadata)
* in TypeScript, and it only works when `legacy` is true.
*
* @see https://www.typescriptlang.org/tsconfig/#emitDecoratorMetadata
* @default false
*/
emitDecoratorMetadata?: boolean
}
export interface Es2015Options {
/** Transform arrow functions into function expressions. */
arrowFunction?: ArrowFunctionsOptions
}
export declare const enum HelperMode {
/**
* Runtime mode (default): Helper functions are imported from a runtime package.
*
* Example:
*
* ```js
* import helperName from "@oxc-project/runtime/helpers/helperName";
* helperName(...arguments);
* ```
*/
Runtime = 'Runtime',
/**
* External mode: Helper functions are accessed from a global `babelHelpers` object.
*
* Example:
*
* ```js
* babelHelpers.helperName(...arguments);
* ```
*/
External = 'External'
}
export interface Helpers {
mode?: HelperMode
}
/**
* TypeScript Isolated Declarations for Standalone DTS Emit (async)
*
* Note: This function can be slower than `isolatedDeclarationSync` due to the overhead of spawning a thread.
*/
export declare function isolatedDeclaration(filename: string, sourceText: string, options?: IsolatedDeclarationsOptions | undefined | null): Promise<IsolatedDeclarationsResult>
export interface IsolatedDeclarationsOptions {
/**
* Do not emit declarations for code that has an @internal annotation in its JSDoc comment.
* This is an internal compiler option; use at your own risk, because the compiler does not check that the result is valid.
*
* Default: `false`
*
* See <https://www.typescriptlang.org/tsconfig/#stripInternal>
*/
stripInternal?: boolean
sourcemap?: boolean
}
export interface IsolatedDeclarationsResult {
code: string
map?: SourceMap
errors: Array<OxcError>
}
/** TypeScript Isolated Declarations for Standalone DTS Emit */
export declare function isolatedDeclarationSync(filename: string, sourceText: string, options?: IsolatedDeclarationsOptions | undefined | null): IsolatedDeclarationsResult
/**
* Configure how TSX and JSX are transformed.
*
* @see {@link https://babeljs.io/docs/babel-plugin-transform-react-jsx#options}
*/
export interface JsxOptions {
/**
* Decides which runtime to use.
*
* - 'automatic' - auto-import the correct JSX factories
* - 'classic' - no auto-import
*
* @default 'automatic'
*/
runtime?: 'classic' | 'automatic'
/**
* Emit development-specific information, such as `__source` and `__self`.
*
* @default false
*
* @see {@link https://babeljs.io/docs/babel-plugin-transform-react-jsx-development}
*/
development?: boolean
/**
* Toggles whether or not to throw an error if an XML namespaced tag name
* is used.
*
* Though the JSX spec allows this, it is disabled by default since React's
* JSX does not currently have support for it.
*
* @default true
*/
throwIfNamespace?: boolean
/**
* Enables `@babel/plugin-transform-react-pure-annotations`.
*
* It will mark JSX elements and top-level React method calls as pure for tree shaking.
*
* @see {@link https://babeljs.io/docs/en/babel-plugin-transform-react-pure-annotations}
*
* @default true
*/
pure?: boolean
/**
* Replaces the import source when importing functions.
*
* @default 'react'
*/
importSource?: string
/**
* Replace the function used when compiling JSX expressions. It should be a
* qualified name (e.g. `React.createElement`) or an identifier (e.g.
* `createElement`).
*
* Only used for `classic` {@link runtime}.
*
* @default 'React.createElement'
*/
pragma?: string
/**
* Replace the component used when compiling JSX fragments. It should be a
* valid JSX tag name.
*
* Only used for `classic` {@link runtime}.
*
* @default 'React.Fragment'
*/
pragmaFrag?: string
/**
* When spreading props, use `Object.assign` directly instead of an extend helper.
*
* Only used for `classic` {@link runtime}.
*
* @default false
*/
useBuiltIns?: boolean
/**
* When spreading props, use inline object with spread elements directly
* instead of an extend helper or Object.assign.
*
* Only used for `classic` {@link runtime}.
*
* @default false
*/
useSpread?: boolean
/**
* Enable React Fast Refresh .
*
* Conforms to the implementation in {@link https://github.com/facebook/react/tree/v18.3.1/packages/react-refresh}
*
* @default false
*/
refresh?: boolean | ReactRefreshOptions
}
/**
* Transform JavaScript code to a Vite Node runnable module.
*
* @param filename The name of the file being transformed.
* @param sourceText the source code itself
* @param options The options for the transformation. See {@link
* ModuleRunnerTransformOptions} for more information.
*
* @returns an object containing the transformed code, source maps, and any
* errors that occurred during parsing or transformation.
*
* Note: This function can be slower than `moduleRunnerTransformSync` due to the overhead of spawning a thread.
*
* @deprecated Only works for Vite.
*/
export declare function moduleRunnerTransform(filename: string, sourceText: string, options?: ModuleRunnerTransformOptions | undefined | null): Promise<ModuleRunnerTransformResult>
export interface ModuleRunnerTransformOptions {
/**
* Enable source map generation.
*
* When `true`, the `sourceMap` field of transform result objects will be populated.
*
* @default false
*
* @see {@link SourceMap}
*/
sourcemap?: boolean
}
export interface ModuleRunnerTransformResult {
/**
* The transformed code.
*
* If parsing failed, this will be an empty string.
*/
code: string
/**
* The source map for the transformed code.
*
* This will be set if {@link TransformOptions#sourcemap} is `true`.
*/
map?: SourceMap
deps: Array<string>
dynamicDeps: Array<string>
/**
* Parse and transformation errors.
*
* Oxc's parser recovers from common syntax errors, meaning that
* transformed code may still be available even if there are errors in this
* list.
*/
errors: Array<OxcError>
}
/** @deprecated Only works for Vite. */
export declare function moduleRunnerTransformSync(filename: string, sourceText: string, options?: ModuleRunnerTransformOptions | undefined | null): ModuleRunnerTransformResult
export interface PluginsOptions {
styledComponents?: StyledComponentsOptions
taggedTemplateEscape?: boolean
}
export interface ReactRefreshOptions {
/**
* Specify the identifier of the refresh registration variable.
*
* @default `$RefreshReg$`.
*/
refreshReg?: string
/**
* Specify the identifier of the refresh signature variable.
*
* @default `$RefreshSig$`.
*/
refreshSig?: string
emitFullSignatures?: boolean
}
/**
* Configure how styled-components are transformed.
*
* @see {@link https://styled-components.com/docs/tooling#babel-plugin}
*/
export interface StyledComponentsOptions {
/**
* Enhances the attached CSS class name on each component with richer output to help
* identify your components in the DOM without React DevTools.
*
* @default true
*/
displayName?: boolean
/**
* Controls whether the `displayName` of a component will be prefixed with the filename
* to make the component name as unique as possible.
*
* @default true
*/
fileName?: boolean
/**
* Adds a unique identifier to every styled component to avoid checksum mismatches
* due to different class generation on the client and server during server-side rendering.
*
* @default true
*/
ssr?: boolean
/**
* Transpiles styled-components tagged template literals to a smaller representation
* than what Babel normally creates, helping to reduce bundle size.
*
* @default true
*/
transpileTemplateLiterals?: boolean
/**
* Minifies CSS content by removing all whitespace and comments from your CSS,
* keeping valuable bytes out of your bundles.
*
* @default true
*/
minify?: boolean
/**
* Enables transformation of JSX `css` prop when using styled-components.
*
* **Note: This feature is not yet implemented in oxc.**
*
* @default true
*/
cssProp?: boolean
/**
* Enables "pure annotation" to aid dead code elimination by bundlers.
*
* @default false
*/
pure?: boolean
/**
* Adds a namespace prefix to component identifiers to ensure class names are unique.
*
* Example: With `namespace: "my-app"`, generates `componentId: "my-app__sc-3rfj0a-1"`
*/
namespace?: string
/**
* List of file names that are considered meaningless for component naming purposes.
*
* When the `fileName` option is enabled and a component is in a file with a name
* from this list, the directory name will be used instead of the file name for
* the component's display name.
*
* @default `["index"]`
*/
meaninglessFileNames?: Array<string>
/**
* Import paths to be considered as styled-components imports at the top level.
*
* **Note: This feature is not yet implemented in oxc.**
*/
topLevelImportPaths?: Array<string>
}
/**
* Transpile a JavaScript or TypeScript into a target ECMAScript version, asynchronously.
*
* Note: This function can be slower than `transform` due to the overhead of spawning a thread.
*
* @param filename The name of the file being transformed. If this is a
* relative path, consider setting the {@link TransformOptions#cwd} option.
* @param sourceText the source code itself
* @param options The options for the transformation. See {@link
* TransformOptions} for more information.
*
* @returns a promise that resolves to an object containing the transformed code,
* source maps, and any errors that occurred during parsing or transformation.
*/
export declare function transform(filename: string, sourceText: string, options?: TransformOptions | undefined | null): Promise<TransformResult>
/**
* Options for transforming a JavaScript or TypeScript file.
*
* @see {@link transform}
*/
export interface TransformOptions {
/** Treat the source text as `js`, `jsx`, `ts`, `tsx`, or `dts`. */
lang?: 'js' | 'jsx' | 'ts' | 'tsx' | 'dts'
/** Treat the source text as `script` or `module` code. */
sourceType?: 'script' | 'module' | 'unambiguous' | undefined
/**
* The current working directory. Used to resolve relative paths in other
* options.
*/
cwd?: string
/**
* Enable source map generation.
*
* When `true`, the `sourceMap` field of transform result objects will be populated.
*
* @default false
*
* @see {@link SourceMap}
*/
sourcemap?: boolean
/** Set assumptions in order to produce smaller output. */
assumptions?: CompilerAssumptions
/** Configure how TypeScript is transformed. */
typescript?: TypeScriptOptions
/** Configure how TSX and JSX are transformed. */
jsx?: 'preserve' | JsxOptions
/**
* Sets the target environment for the generated JavaScript.
*
* The lowest target is `es2015`.
*
* Example:
*
* * `'es2015'`
* * `['es2020', 'chrome58', 'edge16', 'firefox57', 'node12', 'safari11']`
*
* @default `esnext` (No transformation)
*
* @see [esbuild#target](https://esbuild.github.io/api/#target)
*/
target?: string | Array<string>
/** Behaviour for runtime helpers. */
helpers?: Helpers
/** Define Plugin */
define?: Record<string, string>
/** Inject Plugin */
inject?: Record<string, string | [string, string]>
/** Decorator plugin */
decorator?: DecoratorOptions
/** Third-party plugins to use. */
plugins?: PluginsOptions
}
export interface TransformResult {
/**
* The transformed code.
*
* If parsing failed, this will be an empty string.
*/
code: string
/**
* The source map for the transformed code.
*
* This will be set if {@link TransformOptions#sourcemap} is `true`.
*/
map?: SourceMap
/**
* The `.d.ts` declaration file for the transformed code. Declarations are
* only generated if `declaration` is set to `true` and a TypeScript file
* is provided.
*
* If parsing failed and `declaration` is set, this will be an empty string.
*
* @see {@link TypeScriptOptions#declaration}
* @see [declaration tsconfig option](https://www.typescriptlang.org/tsconfig/#declaration)
*/
declaration?: string
/**
* Declaration source map. Only generated if both
* {@link TypeScriptOptions#declaration declaration} and
* {@link TransformOptions#sourcemap sourcemap} are set to `true`.
*/
declarationMap?: SourceMap
/**
* Helpers used.
*
* @internal
*
* Example:
*
* ```text
* { "_objectSpread": "@oxc-project/runtime/helpers/objectSpread2" }
* ```
*/
helpersUsed: Record<string, string>
/**
* Parse and transformation errors.
*
* Oxc's parser recovers from common syntax errors, meaning that
* transformed code may still be available even if there are errors in this
* list.
*/
errors: Array<OxcError>
}
/**
* Transpile a JavaScript or TypeScript into a target ECMAScript version.
*
* @param filename The name of the file being transformed. If this is a
* relative path, consider setting the {@link TransformOptions#cwd} option..
* @param sourceText the source code itself
* @param options The options for the transformation. See {@link
* TransformOptions} for more information.
*
* @returns an object containing the transformed code, source maps, and any
* errors that occurred during parsing or transformation.
*/
export declare function transformSync(filename: string, sourceText: string, options?: TransformOptions | undefined | null): TransformResult
export interface TypeScriptOptions {
jsxPragma?: string
jsxPragmaFrag?: string
onlyRemoveTypeImports?: boolean
allowNamespaces?: boolean
/**
* When enabled, type-only class fields are only removed if they are prefixed with the declare modifier:
*
* @deprecated
*
* Allowing `declare` fields is built-in support in Oxc without any option. If you want to remove class fields
* without initializer, you can use `remove_class_fields_without_initializer: true` instead.
*/
allowDeclareFields?: boolean
/**
* When enabled, class fields without initializers are removed.
*
* For example:
* ```ts
* class Foo {
* x: number;
* y: number = 0;
* }
* ```
* // transform into
* ```js
* class Foo {
* x: number;
* }
* ```
*
* The option is used to align with the behavior of TypeScript's `useDefineForClassFields: false` option.
* When you want to enable this, you also need to set [`crate::CompilerAssumptions::set_public_class_fields`]
* to `true`. The `set_public_class_fields: true` + `remove_class_fields_without_initializer: true` is
* equivalent to `useDefineForClassFields: false` in TypeScript.
*
* When `set_public_class_fields` is true and class-properties plugin is enabled, the above example transforms into:
*
* ```js
* class Foo {
* constructor() {
* this.y = 0;
* }
* }
* ```
*
* Defaults to `false`.
*/
removeClassFieldsWithoutInitializer?: boolean
/**
* Also generate a `.d.ts` declaration file for TypeScript files.
*
* The source file must be compliant with all
* [`isolatedDeclarations`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-5.html#isolated-declarations)
* requirements.
*
* @default false
*/
declaration?: IsolatedDeclarationsOptions
/**
* Rewrite or remove TypeScript import/export declaration extensions.
*
* - When set to `rewrite`, it will change `.ts`, `.mts`, `.cts` extensions to `.js`, `.mjs`, `.cjs` respectively.
* - When set to `remove`, it will remove `.ts`/`.mts`/`.cts`/`.tsx` extension entirely.
* - When set to `true`, it's equivalent to `rewrite`.
* - When set to `false` or omitted, no changes will be made to the extensions.
*
* @default false
*/
rewriteImportExtensions?: 'rewrite' | 'remove' | boolean
}

594
Frontend-Learner/node_modules/oxc-transform/index.js generated vendored Normal file
View file

@ -0,0 +1,594 @@
// prettier-ignore
/* eslint-disable */
// @ts-nocheck
/* auto-generated by NAPI-RS */
import { createRequire } from 'node:module'
const require = createRequire(import.meta.url)
const __dirname = new URL('.', import.meta.url).pathname
const { readFileSync } = require('node:fs')
let nativeBinding = null
const loadErrors = []
const isMusl = () => {
let musl = false
if (process.platform === 'linux') {
musl = isMuslFromFilesystem()
if (musl === null) {
musl = isMuslFromReport()
}
if (musl === null) {
musl = isMuslFromChildProcess()
}
}
return musl
}
const isFileMusl = (f) => f.includes('libc.musl-') || f.includes('ld-musl-')
const isMuslFromFilesystem = () => {
try {
return readFileSync('/usr/bin/ldd', 'utf-8').includes('musl')
} catch {
return null
}
}
const isMuslFromReport = () => {
let report = null
if (typeof process.report?.getReport === 'function') {
process.report.excludeNetwork = true
report = process.report.getReport()
}
if (!report) {
return null
}
if (report.header && report.header.glibcVersionRuntime) {
return false
}
if (Array.isArray(report.sharedObjects)) {
if (report.sharedObjects.some(isFileMusl)) {
return true
}
}
return false
}
const isMuslFromChildProcess = () => {
try {
return require('child_process').execSync('ldd --version', { encoding: 'utf8' }).includes('musl')
} catch (e) {
// If we reach this case, we don't know if the system is musl or not, so is better to just fallback to false
return false
}
}
function requireNative() {
if (process.env.NAPI_RS_NATIVE_LIBRARY_PATH) {
try {
return require(process.env.NAPI_RS_NATIVE_LIBRARY_PATH);
} catch (err) {
loadErrors.push(err)
}
} else if (process.platform === 'android') {
if (process.arch === 'arm64') {
try {
return require('./transform.android-arm64.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('@oxc-transform/binding-android-arm64')
const bindingPackageVersion = require('@oxc-transform/binding-android-arm64/package.json').version
if (bindingPackageVersion !== '0.102.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.102.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
} else if (process.arch === 'arm') {
try {
return require('./transform.android-arm-eabi.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('@oxc-transform/binding-android-arm-eabi')
const bindingPackageVersion = require('@oxc-transform/binding-android-arm-eabi/package.json').version
if (bindingPackageVersion !== '0.102.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.102.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
} else {
loadErrors.push(new Error(`Unsupported architecture on Android ${process.arch}`))
}
} else if (process.platform === 'win32') {
if (process.arch === 'x64') {
if (process.config?.variables?.shlib_suffix === 'dll.a' || process.config?.variables?.node_target_type === 'shared_library') {
try {
return require('./transform.win32-x64-gnu.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('@oxc-transform/binding-win32-x64-gnu')
const bindingPackageVersion = require('@oxc-transform/binding-win32-x64-gnu/package.json').version
if (bindingPackageVersion !== '0.102.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.102.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
} else {
try {
return require('./transform.win32-x64-msvc.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('@oxc-transform/binding-win32-x64-msvc')
const bindingPackageVersion = require('@oxc-transform/binding-win32-x64-msvc/package.json').version
if (bindingPackageVersion !== '0.102.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.102.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
}
} else if (process.arch === 'ia32') {
try {
return require('./transform.win32-ia32-msvc.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('@oxc-transform/binding-win32-ia32-msvc')
const bindingPackageVersion = require('@oxc-transform/binding-win32-ia32-msvc/package.json').version
if (bindingPackageVersion !== '0.102.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.102.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
} else if (process.arch === 'arm64') {
try {
return require('./transform.win32-arm64-msvc.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('@oxc-transform/binding-win32-arm64-msvc')
const bindingPackageVersion = require('@oxc-transform/binding-win32-arm64-msvc/package.json').version
if (bindingPackageVersion !== '0.102.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.102.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
} else {
loadErrors.push(new Error(`Unsupported architecture on Windows: ${process.arch}`))
}
} else if (process.platform === 'darwin') {
try {
return require('./transform.darwin-universal.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('@oxc-transform/binding-darwin-universal')
const bindingPackageVersion = require('@oxc-transform/binding-darwin-universal/package.json').version
if (bindingPackageVersion !== '0.102.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.102.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
if (process.arch === 'x64') {
try {
return require('./transform.darwin-x64.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('@oxc-transform/binding-darwin-x64')
const bindingPackageVersion = require('@oxc-transform/binding-darwin-x64/package.json').version
if (bindingPackageVersion !== '0.102.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.102.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
} else if (process.arch === 'arm64') {
try {
return require('./transform.darwin-arm64.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('@oxc-transform/binding-darwin-arm64')
const bindingPackageVersion = require('@oxc-transform/binding-darwin-arm64/package.json').version
if (bindingPackageVersion !== '0.102.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.102.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
} else {
loadErrors.push(new Error(`Unsupported architecture on macOS: ${process.arch}`))
}
} else if (process.platform === 'freebsd') {
if (process.arch === 'x64') {
try {
return require('./transform.freebsd-x64.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('@oxc-transform/binding-freebsd-x64')
const bindingPackageVersion = require('@oxc-transform/binding-freebsd-x64/package.json').version
if (bindingPackageVersion !== '0.102.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.102.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
} else if (process.arch === 'arm64') {
try {
return require('./transform.freebsd-arm64.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('@oxc-transform/binding-freebsd-arm64')
const bindingPackageVersion = require('@oxc-transform/binding-freebsd-arm64/package.json').version
if (bindingPackageVersion !== '0.102.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.102.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
} else {
loadErrors.push(new Error(`Unsupported architecture on FreeBSD: ${process.arch}`))
}
} else if (process.platform === 'linux') {
if (process.arch === 'x64') {
if (isMusl()) {
try {
return require('./transform.linux-x64-musl.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('@oxc-transform/binding-linux-x64-musl')
const bindingPackageVersion = require('@oxc-transform/binding-linux-x64-musl/package.json').version
if (bindingPackageVersion !== '0.102.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.102.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
} else {
try {
return require('./transform.linux-x64-gnu.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('@oxc-transform/binding-linux-x64-gnu')
const bindingPackageVersion = require('@oxc-transform/binding-linux-x64-gnu/package.json').version
if (bindingPackageVersion !== '0.102.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.102.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
}
} else if (process.arch === 'arm64') {
if (isMusl()) {
try {
return require('./transform.linux-arm64-musl.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('@oxc-transform/binding-linux-arm64-musl')
const bindingPackageVersion = require('@oxc-transform/binding-linux-arm64-musl/package.json').version
if (bindingPackageVersion !== '0.102.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.102.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
} else {
try {
return require('./transform.linux-arm64-gnu.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('@oxc-transform/binding-linux-arm64-gnu')
const bindingPackageVersion = require('@oxc-transform/binding-linux-arm64-gnu/package.json').version
if (bindingPackageVersion !== '0.102.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.102.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
}
} else if (process.arch === 'arm') {
if (isMusl()) {
try {
return require('./transform.linux-arm-musleabihf.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('@oxc-transform/binding-linux-arm-musleabihf')
const bindingPackageVersion = require('@oxc-transform/binding-linux-arm-musleabihf/package.json').version
if (bindingPackageVersion !== '0.102.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.102.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
} else {
try {
return require('./transform.linux-arm-gnueabihf.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('@oxc-transform/binding-linux-arm-gnueabihf')
const bindingPackageVersion = require('@oxc-transform/binding-linux-arm-gnueabihf/package.json').version
if (bindingPackageVersion !== '0.102.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.102.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
}
} else if (process.arch === 'loong64') {
if (isMusl()) {
try {
return require('./transform.linux-loong64-musl.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('@oxc-transform/binding-linux-loong64-musl')
const bindingPackageVersion = require('@oxc-transform/binding-linux-loong64-musl/package.json').version
if (bindingPackageVersion !== '0.102.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.102.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
} else {
try {
return require('./transform.linux-loong64-gnu.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('@oxc-transform/binding-linux-loong64-gnu')
const bindingPackageVersion = require('@oxc-transform/binding-linux-loong64-gnu/package.json').version
if (bindingPackageVersion !== '0.102.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.102.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
}
} else if (process.arch === 'riscv64') {
if (isMusl()) {
try {
return require('./transform.linux-riscv64-musl.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('@oxc-transform/binding-linux-riscv64-musl')
const bindingPackageVersion = require('@oxc-transform/binding-linux-riscv64-musl/package.json').version
if (bindingPackageVersion !== '0.102.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.102.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
} else {
try {
return require('./transform.linux-riscv64-gnu.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('@oxc-transform/binding-linux-riscv64-gnu')
const bindingPackageVersion = require('@oxc-transform/binding-linux-riscv64-gnu/package.json').version
if (bindingPackageVersion !== '0.102.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.102.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
}
} else if (process.arch === 'ppc64') {
try {
return require('./transform.linux-ppc64-gnu.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('@oxc-transform/binding-linux-ppc64-gnu')
const bindingPackageVersion = require('@oxc-transform/binding-linux-ppc64-gnu/package.json').version
if (bindingPackageVersion !== '0.102.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.102.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
} else if (process.arch === 's390x') {
try {
return require('./transform.linux-s390x-gnu.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('@oxc-transform/binding-linux-s390x-gnu')
const bindingPackageVersion = require('@oxc-transform/binding-linux-s390x-gnu/package.json').version
if (bindingPackageVersion !== '0.102.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.102.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
} else {
loadErrors.push(new Error(`Unsupported architecture on Linux: ${process.arch}`))
}
} else if (process.platform === 'openharmony') {
if (process.arch === 'arm64') {
try {
return require('./transform.openharmony-arm64.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('@oxc-transform/binding-openharmony-arm64')
const bindingPackageVersion = require('@oxc-transform/binding-openharmony-arm64/package.json').version
if (bindingPackageVersion !== '0.102.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.102.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
} else if (process.arch === 'x64') {
try {
return require('./transform.openharmony-x64.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('@oxc-transform/binding-openharmony-x64')
const bindingPackageVersion = require('@oxc-transform/binding-openharmony-x64/package.json').version
if (bindingPackageVersion !== '0.102.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.102.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
} else if (process.arch === 'arm') {
try {
return require('./transform.openharmony-arm.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('@oxc-transform/binding-openharmony-arm')
const bindingPackageVersion = require('@oxc-transform/binding-openharmony-arm/package.json').version
if (bindingPackageVersion !== '0.102.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.102.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
} else {
loadErrors.push(new Error(`Unsupported architecture on OpenHarmony: ${process.arch}`))
}
} else {
loadErrors.push(new Error(`Unsupported OS: ${process.platform}, architecture: ${process.arch}`))
}
}
nativeBinding = requireNative()
if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
let wasiBinding = null
let wasiBindingError = null
try {
wasiBinding = require('./transform.wasi.cjs')
nativeBinding = wasiBinding
} catch (err) {
if (process.env.NAPI_RS_FORCE_WASI) {
wasiBindingError = err
}
}
if (!nativeBinding) {
try {
wasiBinding = require('@oxc-transform/binding-wasm32-wasi')
nativeBinding = wasiBinding
} catch (err) {
if (process.env.NAPI_RS_FORCE_WASI) {
wasiBindingError.cause = err
loadErrors.push(err)
}
}
}
if (process.env.NAPI_RS_FORCE_WASI === 'error' && !wasiBinding) {
const error = new Error('WASI binding not found and NAPI_RS_FORCE_WASI is set to error')
error.cause = wasiBindingError
throw error
}
}
if (!nativeBinding && globalThis.process?.versions?.["webcontainer"]) {
try {
nativeBinding = require('./webcontainer-fallback.cjs');
} catch (err) {
loadErrors.push(err)
}
}
if (!nativeBinding) {
if (loadErrors.length > 0) {
throw new Error(
`Cannot find native binding. ` +
`npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). ` +
'Please try `npm i` again after removing both package-lock.json and node_modules directory.',
{
cause: loadErrors.reduce((err, cur) => {
cur.cause = err
return cur
}),
},
)
}
throw new Error(`Failed to load native binding`)
}
const { Severity, HelperMode, isolatedDeclaration, isolatedDeclarationSync, moduleRunnerTransform, moduleRunnerTransformSync, transform, transformSync } = nativeBinding
export { Severity }
export { HelperMode }
export { isolatedDeclaration }
export { isolatedDeclarationSync }
export { moduleRunnerTransform }
export { moduleRunnerTransformSync }
export { transform }
export { transformSync }

View file

@ -0,0 +1,93 @@
{
"name": "oxc-transform",
"version": "0.102.0",
"type": "module",
"main": "index.js",
"browser": "browser.js",
"engines": {
"node": "^20.19.0 || >=22.12.0"
},
"description": "Oxc Transformer Node API",
"keywords": [
"oxc",
"transform"
],
"author": "Boshen and oxc contributors",
"license": "MIT",
"homepage": "https://oxc.rs",
"bugs": "https://github.com/oxc-project/oxc/issues",
"repository": {
"type": "git",
"url": "git+https://github.com/oxc-project/oxc.git",
"directory": "napi/transform"
},
"funding": {
"url": "https://github.com/sponsors/Boshen"
},
"files": [
"index.d.ts",
"index.js",
"browser.js",
"webcontainer-fallback.cjs"
],
"publishConfig": {
"registry": "https://registry.npmjs.org/",
"access": "public"
},
"devDependencies": {
"@types/node": "^24.0.0",
"typescript": "5.9.3",
"vitest": "4.0.10"
},
"napi": {
"binaryName": "transform",
"packageName": "@oxc-transform/binding",
"targets": [
"aarch64-apple-darwin",
"aarch64-linux-android",
"aarch64-pc-windows-msvc",
"aarch64-unknown-linux-gnu",
"aarch64-unknown-linux-musl",
"aarch64-unknown-linux-ohos",
"armv7-unknown-linux-gnueabihf",
"riscv64gc-unknown-linux-gnu",
"s390x-unknown-linux-gnu",
"wasm32-wasip1-threads",
"x86_64-apple-darwin",
"x86_64-pc-windows-msvc",
"x86_64-unknown-freebsd",
"x86_64-unknown-linux-gnu",
"x86_64-unknown-linux-musl"
],
"wasm": {
"browser": {
"fs": false
}
}
},
"optionalDependencies": {
"@oxc-transform/binding-darwin-arm64": "0.102.0",
"@oxc-transform/binding-android-arm64": "0.102.0",
"@oxc-transform/binding-win32-arm64-msvc": "0.102.0",
"@oxc-transform/binding-linux-arm64-gnu": "0.102.0",
"@oxc-transform/binding-linux-arm64-musl": "0.102.0",
"@oxc-transform/binding-openharmony-arm64": "0.102.0",
"@oxc-transform/binding-linux-arm-gnueabihf": "0.102.0",
"@oxc-transform/binding-linux-riscv64-gnu": "0.102.0",
"@oxc-transform/binding-linux-s390x-gnu": "0.102.0",
"@oxc-transform/binding-wasm32-wasi": "0.102.0",
"@oxc-transform/binding-darwin-x64": "0.102.0",
"@oxc-transform/binding-win32-x64-msvc": "0.102.0",
"@oxc-transform/binding-freebsd-x64": "0.102.0",
"@oxc-transform/binding-linux-x64-gnu": "0.102.0",
"@oxc-transform/binding-linux-x64-musl": "0.102.0"
},
"scripts": {
"build-dev": "napi build --esm --platform",
"build-test": "pnpm run build-dev",
"build": "pnpm run build-dev --features allocator --release",
"postbuild": "publint",
"postbuild-dev": "node scripts/patch.js",
"test": "tsc && vitest run --dir ./test"
}
}

View file

@ -0,0 +1,21 @@
const fs = require("node:fs");
const childProcess = require("node:child_process");
const pkg = JSON.parse(fs.readFileSync(require.resolve("oxc-transform/package.json"), "utf-8"));
const { version } = pkg;
const baseDir = `/tmp/oxc-transform-${version}`;
const bindingEntry = `${baseDir}/node_modules/@oxc-transform/binding-wasm32-wasi/transform.wasi.cjs`;
if (!fs.existsSync(bindingEntry)) {
fs.rmSync(baseDir, { recursive: true, force: true });
fs.mkdirSync(baseDir, { recursive: true });
const bindingPkg = `@oxc-transform/binding-wasm32-wasi@${version}`;
// oxlint-disable-next-line no-console
console.log(`[oxc-transform] Downloading ${bindingPkg} on WebContainer...`);
childProcess.execFileSync("pnpm", ["i", bindingPkg], {
cwd: baseDir,
stdio: "inherit",
});
}
module.exports = require(bindingEntry);