Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions napi/parser/bindings.js
Original file line number Diff line number Diff line change
Expand Up @@ -388,10 +388,7 @@ module.exports.ParseResult = nativeBinding.ParseResult
module.exports.ExportExportNameKind = nativeBinding.ExportExportNameKind
module.exports.ExportImportNameKind = nativeBinding.ExportImportNameKind
module.exports.ExportLocalNameKind = nativeBinding.ExportLocalNameKind
module.exports.getBufferOffset = nativeBinding.getBufferOffset
module.exports.ImportNameKind = nativeBinding.ImportNameKind
module.exports.parseAsync = nativeBinding.parseAsync
module.exports.parseAsyncRaw = nativeBinding.parseAsyncRaw
module.exports.parseSync = nativeBinding.parseSync
module.exports.parseSyncRaw = nativeBinding.parseSyncRaw
module.exports.rawTransferSupported = nativeBinding.rawTransferSupported
68 changes: 0 additions & 68 deletions napi/parser/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,6 @@ export declare const enum ExportLocalNameKind {
None = 'None'
}

/**
* Get offset within a `Uint8Array` which is aligned on 4 GiB.
*
* Does not check that the offset is within bounds of `buffer`.
* To ensure it always is, provide a `Uint8Array` of at least 4 GiB size.
*/
export declare function getBufferOffset(buffer: Uint8Array): number

export interface ImportName {
kind: ImportNameKind
name?: string
Expand All @@ -144,38 +136,6 @@ export declare const enum ImportNameKind {
*/
export declare function parseAsync(filename: string, sourceText: string, options?: ParserOptions | undefined | null): Promise<ParseResult>

/**
* Parse AST into provided `Uint8Array` buffer, asynchronously.
*
* Note: This function can be slower than `parseSyncRaw` due to the overhead of spawning a thread.
*
* Source text must be written into the start of the buffer, and its length (in UTF-8 bytes)
* provided as `source_len`.
*
* This function will parse the source, and write the AST into the buffer, starting at the end.
*
* It also writes to the very end of the buffer the offset of `Program` within the buffer.
*
* Caller can deserialize data from the buffer on JS side.
*
* # SAFETY
*
* Caller must ensure:
* * Source text is written into start of the buffer.
* * Source text's UTF-8 byte length is `source_len`.
* * The 1st `source_len` bytes of the buffer comprises a valid UTF-8 string.
* * Contents of buffer must not be mutated by caller until the `AsyncTask` returned by this
* function resolves.
*
* If source text is originally a JS string on JS side, and converted to a buffer with
* `Buffer.from(str)` or `new TextEncoder().encode(str)`, this guarantees it's valid UTF-8.
*
* # Panics
*
* Panics if source text is too long, or AST takes more memory than is available in the buffer.
*/
export declare function parseAsyncRaw(filename: string, buffer: Uint8Array, sourceLen: number, options?: ParserOptions | undefined | null): Promise<unknown>

export interface ParserOptions {
/** Treat the source text as `js`, `jsx`, `ts`, or `tsx`. */
lang?: 'js' | 'jsx' | 'ts' | 'tsx'
Expand Down Expand Up @@ -220,34 +180,6 @@ export interface ParserOptions {
/** Parse synchronously. */
export declare function parseSync(filename: string, sourceText: string, options?: ParserOptions | undefined | null): ParseResult

/**
* Parse AST into provided `Uint8Array` buffer, synchronously.
*
* Source text must be written into the start of the buffer, and its length (in UTF-8 bytes)
* provided as `source_len`.
*
* This function will parse the source, and write the AST into the buffer, starting at the end.
*
* It also writes to the very end of the buffer the offset of `Program` within the buffer.
*
* Caller can deserialize data from the buffer on JS side.
*
* # SAFETY
*
* Caller must ensure:
* * Source text is written into start of the buffer.
* * Source text's UTF-8 byte length is `source_len`.
* * The 1st `source_len` bytes of the buffer comprises a valid UTF-8 string.
*
* If source text is originally a JS string on JS side, and converted to a buffer with
* `Buffer.from(str)` or `new TextEncoder().encode(str)`, this guarantees it's valid UTF-8.
*
* # Panics
*
* Panics if source text is too long, or AST takes more memory than is available in the buffer.
*/
export declare function parseSyncRaw(filename: string, buffer: Uint8Array, sourceLen: number, options?: ParserOptions | undefined | null): void

/** Returns `true` if raw transfer is supported on this platform. */
export declare function rawTransferSupported(): boolean

Expand Down
3 changes: 0 additions & 3 deletions napi/parser/parser.wasi-browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,7 @@ export const ParseResult = __napiModule.exports.ParseResult
export const ExportExportNameKind = __napiModule.exports.ExportExportNameKind
export const ExportImportNameKind = __napiModule.exports.ExportImportNameKind
export const ExportLocalNameKind = __napiModule.exports.ExportLocalNameKind
export const getBufferOffset = __napiModule.exports.getBufferOffset
export const ImportNameKind = __napiModule.exports.ImportNameKind
export const parseAsync = __napiModule.exports.parseAsync
export const parseAsyncRaw = __napiModule.exports.parseAsyncRaw
export const parseSync = __napiModule.exports.parseSync
export const parseSyncRaw = __napiModule.exports.parseSyncRaw
export const rawTransferSupported = __napiModule.exports.rawTransferSupported
3 changes: 0 additions & 3 deletions napi/parser/parser.wasi.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,7 @@ module.exports.ParseResult = __napiModule.exports.ParseResult
module.exports.ExportExportNameKind = __napiModule.exports.ExportExportNameKind
module.exports.ExportImportNameKind = __napiModule.exports.ExportImportNameKind
module.exports.ExportLocalNameKind = __napiModule.exports.ExportLocalNameKind
module.exports.getBufferOffset = __napiModule.exports.getBufferOffset
module.exports.ImportNameKind = __napiModule.exports.ImportNameKind
module.exports.parseAsync = __napiModule.exports.parseAsync
module.exports.parseAsyncRaw = __napiModule.exports.parseAsyncRaw
module.exports.parseSync = __napiModule.exports.parseSync
module.exports.parseSyncRaw = __napiModule.exports.parseSyncRaw
module.exports.rawTransferSupported = __napiModule.exports.rawTransferSupported
6 changes: 3 additions & 3 deletions napi/parser/src/raw_transfer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const BUMP_ALIGN: usize = 16;
///
/// Does not check that the offset is within bounds of `buffer`.
/// To ensure it always is, provide a `Uint8Array` of at least 4 GiB size.
#[napi]
#[napi(skip_typescript)]
pub fn get_buffer_offset(buffer: Uint8Array) -> u32 {
let buffer = &*buffer;
let buffer_addr32 = buffer.as_ptr() as u32;
Expand Down Expand Up @@ -77,7 +77,7 @@ pub fn get_buffer_offset(buffer: Uint8Array) -> u32 {
/// # Panics
///
/// Panics if source text is too long, or AST takes more memory than is available in the buffer.
#[napi]
#[napi(skip_typescript)]
pub unsafe fn parse_sync_raw(
filename: String,
mut buffer: Uint8Array,
Expand Down Expand Up @@ -120,7 +120,7 @@ pub unsafe fn parse_sync_raw(
/// # Panics
///
/// Panics if source text is too long, or AST takes more memory than is available in the buffer.
#[napi]
#[napi(skip_typescript)]
pub fn parse_async_raw(
filename: String,
buffer: Uint8Array,
Expand Down
Loading