Skip to content

Commit a3641d2

Browse files
committed
fix(napi/parser): remove non-existent methods from TS type defs (#12054)
Fix #11950. Remove `parseSyncRaw`, `parseAsyncRaw`, and `getBufferOffset` from TS type defs. They're not actually exported from the package.
1 parent 735c0d3 commit a3641d2

File tree

5 files changed

+3
-80
lines changed

5 files changed

+3
-80
lines changed

napi/parser/bindings.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -388,10 +388,7 @@ module.exports.ParseResult = nativeBinding.ParseResult
388388
module.exports.ExportExportNameKind = nativeBinding.ExportExportNameKind
389389
module.exports.ExportImportNameKind = nativeBinding.ExportImportNameKind
390390
module.exports.ExportLocalNameKind = nativeBinding.ExportLocalNameKind
391-
module.exports.getBufferOffset = nativeBinding.getBufferOffset
392391
module.exports.ImportNameKind = nativeBinding.ImportNameKind
393392
module.exports.parseAsync = nativeBinding.parseAsync
394-
module.exports.parseAsyncRaw = nativeBinding.parseAsyncRaw
395393
module.exports.parseSync = nativeBinding.parseSync
396-
module.exports.parseSyncRaw = nativeBinding.parseSyncRaw
397394
module.exports.rawTransferSupported = nativeBinding.rawTransferSupported

napi/parser/index.d.ts

Lines changed: 0 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -113,14 +113,6 @@ export declare const enum ExportLocalNameKind {
113113
None = 'None'
114114
}
115115

116-
/**
117-
* Get offset within a `Uint8Array` which is aligned on 4 GiB.
118-
*
119-
* Does not check that the offset is within bounds of `buffer`.
120-
* To ensure it always is, provide a `Uint8Array` of at least 4 GiB size.
121-
*/
122-
export declare function getBufferOffset(buffer: Uint8Array): number
123-
124116
export interface ImportName {
125117
kind: ImportNameKind
126118
name?: string
@@ -144,38 +136,6 @@ export declare const enum ImportNameKind {
144136
*/
145137
export declare function parseAsync(filename: string, sourceText: string, options?: ParserOptions | undefined | null): Promise<ParseResult>
146138

147-
/**
148-
* Parse AST into provided `Uint8Array` buffer, asynchronously.
149-
*
150-
* Note: This function can be slower than `parseSyncRaw` due to the overhead of spawning a thread.
151-
*
152-
* Source text must be written into the start of the buffer, and its length (in UTF-8 bytes)
153-
* provided as `source_len`.
154-
*
155-
* This function will parse the source, and write the AST into the buffer, starting at the end.
156-
*
157-
* It also writes to the very end of the buffer the offset of `Program` within the buffer.
158-
*
159-
* Caller can deserialize data from the buffer on JS side.
160-
*
161-
* # SAFETY
162-
*
163-
* Caller must ensure:
164-
* * Source text is written into start of the buffer.
165-
* * Source text's UTF-8 byte length is `source_len`.
166-
* * The 1st `source_len` bytes of the buffer comprises a valid UTF-8 string.
167-
* * Contents of buffer must not be mutated by caller until the `AsyncTask` returned by this
168-
* function resolves.
169-
*
170-
* If source text is originally a JS string on JS side, and converted to a buffer with
171-
* `Buffer.from(str)` or `new TextEncoder().encode(str)`, this guarantees it's valid UTF-8.
172-
*
173-
* # Panics
174-
*
175-
* Panics if source text is too long, or AST takes more memory than is available in the buffer.
176-
*/
177-
export declare function parseAsyncRaw(filename: string, buffer: Uint8Array, sourceLen: number, options?: ParserOptions | undefined | null): Promise<unknown>
178-
179139
export interface ParserOptions {
180140
/** Treat the source text as `js`, `jsx`, `ts`, or `tsx`. */
181141
lang?: 'js' | 'jsx' | 'ts' | 'tsx'
@@ -220,34 +180,6 @@ export interface ParserOptions {
220180
/** Parse synchronously. */
221181
export declare function parseSync(filename: string, sourceText: string, options?: ParserOptions | undefined | null): ParseResult
222182

223-
/**
224-
* Parse AST into provided `Uint8Array` buffer, synchronously.
225-
*
226-
* Source text must be written into the start of the buffer, and its length (in UTF-8 bytes)
227-
* provided as `source_len`.
228-
*
229-
* This function will parse the source, and write the AST into the buffer, starting at the end.
230-
*
231-
* It also writes to the very end of the buffer the offset of `Program` within the buffer.
232-
*
233-
* Caller can deserialize data from the buffer on JS side.
234-
*
235-
* # SAFETY
236-
*
237-
* Caller must ensure:
238-
* * Source text is written into start of the buffer.
239-
* * Source text's UTF-8 byte length is `source_len`.
240-
* * The 1st `source_len` bytes of the buffer comprises a valid UTF-8 string.
241-
*
242-
* If source text is originally a JS string on JS side, and converted to a buffer with
243-
* `Buffer.from(str)` or `new TextEncoder().encode(str)`, this guarantees it's valid UTF-8.
244-
*
245-
* # Panics
246-
*
247-
* Panics if source text is too long, or AST takes more memory than is available in the buffer.
248-
*/
249-
export declare function parseSyncRaw(filename: string, buffer: Uint8Array, sourceLen: number, options?: ParserOptions | undefined | null): void
250-
251183
/** Returns `true` if raw transfer is supported on this platform. */
252184
export declare function rawTransferSupported(): boolean
253185

napi/parser/parser.wasi-browser.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,7 @@ export const ParseResult = __napiModule.exports.ParseResult
5959
export const ExportExportNameKind = __napiModule.exports.ExportExportNameKind
6060
export const ExportImportNameKind = __napiModule.exports.ExportImportNameKind
6161
export const ExportLocalNameKind = __napiModule.exports.ExportLocalNameKind
62-
export const getBufferOffset = __napiModule.exports.getBufferOffset
6362
export const ImportNameKind = __napiModule.exports.ImportNameKind
6463
export const parseAsync = __napiModule.exports.parseAsync
65-
export const parseAsyncRaw = __napiModule.exports.parseAsyncRaw
6664
export const parseSync = __napiModule.exports.parseSync
67-
export const parseSyncRaw = __napiModule.exports.parseSyncRaw
6865
export const rawTransferSupported = __napiModule.exports.rawTransferSupported

napi/parser/parser.wasi.cjs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,7 @@ module.exports.ParseResult = __napiModule.exports.ParseResult
9090
module.exports.ExportExportNameKind = __napiModule.exports.ExportExportNameKind
9191
module.exports.ExportImportNameKind = __napiModule.exports.ExportImportNameKind
9292
module.exports.ExportLocalNameKind = __napiModule.exports.ExportLocalNameKind
93-
module.exports.getBufferOffset = __napiModule.exports.getBufferOffset
9493
module.exports.ImportNameKind = __napiModule.exports.ImportNameKind
9594
module.exports.parseAsync = __napiModule.exports.parseAsync
96-
module.exports.parseAsyncRaw = __napiModule.exports.parseAsyncRaw
9795
module.exports.parseSync = __napiModule.exports.parseSync
98-
module.exports.parseSyncRaw = __napiModule.exports.parseSyncRaw
9996
module.exports.rawTransferSupported = __napiModule.exports.rawTransferSupported

napi/parser/src/raw_transfer.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ const BUMP_ALIGN: usize = 16;
4646
///
4747
/// Does not check that the offset is within bounds of `buffer`.
4848
/// To ensure it always is, provide a `Uint8Array` of at least 4 GiB size.
49-
#[napi]
49+
#[napi(skip_typescript)]
5050
pub fn get_buffer_offset(buffer: Uint8Array) -> u32 {
5151
let buffer = &*buffer;
5252
let buffer_addr32 = buffer.as_ptr() as u32;
@@ -77,7 +77,7 @@ pub fn get_buffer_offset(buffer: Uint8Array) -> u32 {
7777
/// # Panics
7878
///
7979
/// Panics if source text is too long, or AST takes more memory than is available in the buffer.
80-
#[napi]
80+
#[napi(skip_typescript)]
8181
pub unsafe fn parse_sync_raw(
8282
filename: String,
8383
mut buffer: Uint8Array,
@@ -120,7 +120,7 @@ pub unsafe fn parse_sync_raw(
120120
/// # Panics
121121
///
122122
/// Panics if source text is too long, or AST takes more memory than is available in the buffer.
123-
#[napi]
123+
#[napi(skip_typescript)]
124124
pub fn parse_async_raw(
125125
filename: String,
126126
buffer: Uint8Array,

0 commit comments

Comments
 (0)