first commit
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 382 KiB |
BIN
Binary file not shown.
|
After Width: | Height: | Size: 361 KiB |
Binary file not shown.
+1
@@ -0,0 +1 @@
|
|||||||
|
../semver/bin/semver.js
|
||||||
+1311
File diff suppressed because it is too large
Load Diff
+21
@@ -0,0 +1,21 @@
|
|||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2021-present Toyobayashi
|
||||||
|
|
||||||
|
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.
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
See [https://github.com/toyobayashi/emnapi](https://github.com/toyobayashi/emnapi)
|
||||||
+1398
File diff suppressed because it is too large
Load Diff
+671
@@ -0,0 +1,671 @@
|
|||||||
|
export declare type Ptr = number | bigint
|
||||||
|
|
||||||
|
export declare interface IBuffer extends Uint8Array {}
|
||||||
|
export declare interface BufferCtor {
|
||||||
|
readonly prototype: IBuffer
|
||||||
|
/** @deprecated */
|
||||||
|
new (...args: any[]): IBuffer
|
||||||
|
from: {
|
||||||
|
(buffer: ArrayBufferLike): IBuffer
|
||||||
|
(buffer: ArrayBufferLike, byteOffset: number, length: number): IBuffer
|
||||||
|
}
|
||||||
|
alloc: (size: number) => IBuffer
|
||||||
|
isBuffer: (obj: unknown) => obj is IBuffer
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare const enum GlobalHandle {
|
||||||
|
UNDEFINED = 1,
|
||||||
|
NULL,
|
||||||
|
FALSE,
|
||||||
|
TRUE,
|
||||||
|
GLOBAL
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare const enum Version {
|
||||||
|
NODE_API_SUPPORTED_VERSION_MIN = 1,
|
||||||
|
NODE_API_DEFAULT_MODULE_API_VERSION = 8,
|
||||||
|
NODE_API_SUPPORTED_VERSION_MAX = 10,
|
||||||
|
NAPI_VERSION_EXPERIMENTAL = 2147483647 // INT_MAX
|
||||||
|
}
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
|
export declare type Pointer<T> = number
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
|
export declare type PointerPointer<T> = number
|
||||||
|
export declare type FunctionPointer<T extends (...args: any[]) => any> = Pointer<T>
|
||||||
|
export declare type Const<T> = T
|
||||||
|
|
||||||
|
export declare type void_p = Pointer<void>
|
||||||
|
export declare type void_pp = Pointer<void_p>
|
||||||
|
export declare type bool = number
|
||||||
|
export declare type char = number
|
||||||
|
export declare type char_p = Pointer<char>
|
||||||
|
export declare type unsigned_char = number
|
||||||
|
export declare type const_char = Const<char>
|
||||||
|
export declare type const_char_p = Pointer<const_char>
|
||||||
|
export declare type char16_t_p = number
|
||||||
|
export declare type const_char16_t_p = number
|
||||||
|
|
||||||
|
export declare type short = number
|
||||||
|
export declare type unsigned_short = number
|
||||||
|
export declare type int = number
|
||||||
|
export declare type unsigned_int = number
|
||||||
|
export declare type long = number
|
||||||
|
export declare type unsigned_long = number
|
||||||
|
export declare type long_long = bigint
|
||||||
|
export declare type unsigned_long_long = bigint
|
||||||
|
export declare type float = number
|
||||||
|
export declare type double = number
|
||||||
|
export declare type long_double = number
|
||||||
|
export declare type size_t = number
|
||||||
|
|
||||||
|
export declare type int8_t = number
|
||||||
|
export declare type uint8_t = number
|
||||||
|
export declare type int16_t = number
|
||||||
|
export declare type uint16_t = number
|
||||||
|
export declare type int32_t = number
|
||||||
|
export declare type uint32_t = number
|
||||||
|
export declare type int64_t = bigint
|
||||||
|
export declare type uint64_t = bigint
|
||||||
|
export declare type napi_env = Pointer<unknown>
|
||||||
|
|
||||||
|
export declare type napi_value = Pointer<unknown>
|
||||||
|
export declare type napi_ref = Pointer<unknown>
|
||||||
|
export declare type napi_deferred = Pointer<unknown>
|
||||||
|
export declare type napi_handle_scope = Pointer<unknown>
|
||||||
|
export declare type napi_escapable_handle_scope = Pointer<unknown>
|
||||||
|
|
||||||
|
export declare type napi_addon_register_func = FunctionPointer<(env: napi_env, exports: napi_value) => napi_value>
|
||||||
|
|
||||||
|
export declare type napi_callback_info = Pointer<unknown>
|
||||||
|
export declare type napi_callback = FunctionPointer<(env: napi_env, info: napi_callback_info) => napi_value>
|
||||||
|
|
||||||
|
export declare interface napi_extended_error_info {
|
||||||
|
error_message: const_char_p
|
||||||
|
engine_reserved: void_p
|
||||||
|
engine_error_code: uint32_t
|
||||||
|
error_code: napi_status
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare interface napi_property_descriptor {
|
||||||
|
// One of utf8name or name should be NULL.
|
||||||
|
utf8name: const_char_p
|
||||||
|
name: napi_value
|
||||||
|
|
||||||
|
method: napi_callback
|
||||||
|
getter: napi_callback
|
||||||
|
setter: napi_callback
|
||||||
|
value: napi_value
|
||||||
|
/* napi_property_attributes */
|
||||||
|
attributes: number
|
||||||
|
data: void_p
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare type napi_finalize = FunctionPointer<(
|
||||||
|
env: napi_env,
|
||||||
|
finalize_data: void_p,
|
||||||
|
finalize_hint: void_p
|
||||||
|
) => void>
|
||||||
|
|
||||||
|
export declare interface node_module {
|
||||||
|
nm_version: int32_t
|
||||||
|
nm_flags: uint32_t
|
||||||
|
nm_filename: Pointer<const_char>
|
||||||
|
nm_register_func: napi_addon_register_func
|
||||||
|
nm_modname: Pointer<const_char>
|
||||||
|
nm_priv: Pointer<void>
|
||||||
|
reserved: PointerPointer<void>
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare interface napi_node_version {
|
||||||
|
major: uint32_t
|
||||||
|
minor: uint32_t
|
||||||
|
patch: uint32_t
|
||||||
|
release: const_char_p
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare interface emnapi_emscripten_version {
|
||||||
|
major: uint32_t
|
||||||
|
minor: uint32_t
|
||||||
|
patch: uint32_t
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare const enum napi_status {
|
||||||
|
napi_ok,
|
||||||
|
napi_invalid_arg,
|
||||||
|
napi_object_expected,
|
||||||
|
napi_string_expected,
|
||||||
|
napi_name_expected,
|
||||||
|
napi_function_expected,
|
||||||
|
napi_number_expected,
|
||||||
|
napi_boolean_expected,
|
||||||
|
napi_array_expected,
|
||||||
|
napi_generic_failure,
|
||||||
|
napi_pending_exception,
|
||||||
|
napi_cancelled,
|
||||||
|
napi_escape_called_twice,
|
||||||
|
napi_handle_scope_mismatch,
|
||||||
|
napi_callback_scope_mismatch,
|
||||||
|
napi_queue_full,
|
||||||
|
napi_closing,
|
||||||
|
napi_bigint_expected,
|
||||||
|
napi_date_expected,
|
||||||
|
napi_arraybuffer_expected,
|
||||||
|
napi_detachable_arraybuffer_expected,
|
||||||
|
napi_would_deadlock, // unused
|
||||||
|
napi_no_external_buffers_allowed,
|
||||||
|
napi_cannot_run_js
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare const enum napi_property_attributes {
|
||||||
|
napi_default = 0,
|
||||||
|
napi_writable = 1 << 0,
|
||||||
|
napi_enumerable = 1 << 1,
|
||||||
|
napi_configurable = 1 << 2,
|
||||||
|
|
||||||
|
// Used with napi_define_class to distinguish static properties
|
||||||
|
// from instance properties. Ignored by napi_define_properties.
|
||||||
|
napi_static = 1 << 10,
|
||||||
|
|
||||||
|
/// #ifdef NAPI_EXPERIMENTAL
|
||||||
|
// Default for class methods.
|
||||||
|
napi_default_method = napi_writable | napi_configurable,
|
||||||
|
|
||||||
|
// Default for object properties, like in JS obj[prop].
|
||||||
|
napi_default_jsproperty = napi_writable | napi_enumerable | napi_configurable
|
||||||
|
/// #endif // NAPI_EXPERIMENTAL
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare const enum napi_valuetype {
|
||||||
|
napi_undefined,
|
||||||
|
napi_null,
|
||||||
|
napi_boolean,
|
||||||
|
napi_number,
|
||||||
|
napi_string,
|
||||||
|
napi_symbol,
|
||||||
|
napi_object,
|
||||||
|
napi_function,
|
||||||
|
napi_external,
|
||||||
|
napi_bigint
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare const enum napi_typedarray_type {
|
||||||
|
napi_int8_array,
|
||||||
|
napi_uint8_array,
|
||||||
|
napi_uint8_clamped_array,
|
||||||
|
napi_int16_array,
|
||||||
|
napi_uint16_array,
|
||||||
|
napi_int32_array,
|
||||||
|
napi_uint32_array,
|
||||||
|
napi_float32_array,
|
||||||
|
napi_float64_array,
|
||||||
|
napi_bigint64_array,
|
||||||
|
napi_biguint64_array,
|
||||||
|
napi_float16_array,
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare const enum napi_key_collection_mode {
|
||||||
|
napi_key_include_prototypes,
|
||||||
|
napi_key_own_only
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare const enum napi_key_filter {
|
||||||
|
napi_key_all_properties = 0,
|
||||||
|
napi_key_writable = 1,
|
||||||
|
napi_key_enumerable = 1 << 1,
|
||||||
|
napi_key_configurable = 1 << 2,
|
||||||
|
napi_key_skip_strings = 1 << 3,
|
||||||
|
napi_key_skip_symbols = 1 << 4
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare const enum napi_key_conversion {
|
||||||
|
napi_key_keep_numbers,
|
||||||
|
napi_key_numbers_to_strings
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare const enum emnapi_memory_view_type {
|
||||||
|
emnapi_int8_array,
|
||||||
|
emnapi_uint8_array,
|
||||||
|
emnapi_uint8_clamped_array,
|
||||||
|
emnapi_int16_array,
|
||||||
|
emnapi_uint16_array,
|
||||||
|
emnapi_int32_array,
|
||||||
|
emnapi_uint32_array,
|
||||||
|
emnapi_float32_array,
|
||||||
|
emnapi_float64_array,
|
||||||
|
emnapi_bigint64_array,
|
||||||
|
emnapi_biguint64_array,
|
||||||
|
emnapi_float16_array,
|
||||||
|
emnapi_data_view = -1,
|
||||||
|
emnapi_buffer = -2
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare const enum napi_threadsafe_function_call_mode {
|
||||||
|
napi_tsfn_nonblocking,
|
||||||
|
napi_tsfn_blocking
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare const enum napi_threadsafe_function_release_mode {
|
||||||
|
napi_tsfn_release,
|
||||||
|
napi_tsfn_abort
|
||||||
|
}
|
||||||
|
export declare type CleanupHookCallbackFunction = number | ((arg: number) => void);
|
||||||
|
|
||||||
|
export declare class ConstHandle<S extends undefined | null | boolean | typeof globalThis> extends Handle<S> {
|
||||||
|
constructor(id: number, value: S);
|
||||||
|
dispose(): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare class Context {
|
||||||
|
private _isStopping;
|
||||||
|
private _canCallIntoJs;
|
||||||
|
private _suppressDestroy;
|
||||||
|
envStore: Store<Env>;
|
||||||
|
scopeStore: ScopeStore;
|
||||||
|
refStore: Store<Reference>;
|
||||||
|
deferredStore: Store<Deferred<any>>;
|
||||||
|
handleStore: HandleStore;
|
||||||
|
private readonly refCounter?;
|
||||||
|
private readonly cleanupQueue;
|
||||||
|
private readonly _externalMemory;
|
||||||
|
feature: {
|
||||||
|
supportReflect: boolean;
|
||||||
|
supportFinalizer: boolean;
|
||||||
|
supportWeakSymbol: boolean;
|
||||||
|
supportBigInt: boolean;
|
||||||
|
supportNewFunction: boolean;
|
||||||
|
canSetFunctionName: boolean;
|
||||||
|
setImmediate: (callback: () => void) => void;
|
||||||
|
Buffer: BufferCtor | undefined;
|
||||||
|
MessageChannel: {
|
||||||
|
new (): MessageChannel;
|
||||||
|
prototype: MessageChannel;
|
||||||
|
} | undefined;
|
||||||
|
};
|
||||||
|
constructor(options?: ContextOptions);
|
||||||
|
/**
|
||||||
|
* Suppress the destroy on `beforeExit` event in Node.js.
|
||||||
|
* Call this method if you want to keep the context and
|
||||||
|
* all associated {@link Env | Env} alive,
|
||||||
|
* this also means that cleanup hooks will not be called.
|
||||||
|
* After call this method, you should call
|
||||||
|
* {@link Context.destroy | `Context.prototype.destroy`} method manually.
|
||||||
|
*/
|
||||||
|
suppressDestroy(): void;
|
||||||
|
getRuntimeVersions(): {
|
||||||
|
version: string;
|
||||||
|
NODE_API_SUPPORTED_VERSION_MAX: Version;
|
||||||
|
NAPI_VERSION_EXPERIMENTAL: Version;
|
||||||
|
NODE_API_DEFAULT_MODULE_API_VERSION: Version;
|
||||||
|
};
|
||||||
|
createNotSupportWeakRefError(api: string, message: string): NotSupportWeakRefError;
|
||||||
|
createNotSupportBufferError(api: string, message: string): NotSupportBufferError;
|
||||||
|
createReference(envObject: Env, handle_id: napi_value, initialRefcount: uint32_t, ownership: ReferenceOwnership): Reference;
|
||||||
|
createReferenceWithData(envObject: Env, handle_id: napi_value, initialRefcount: uint32_t, ownership: ReferenceOwnership, data: void_p): Reference;
|
||||||
|
createReferenceWithFinalizer(envObject: Env, handle_id: napi_value, initialRefcount: uint32_t, ownership: ReferenceOwnership, finalize_callback?: napi_finalize, finalize_data?: void_p, finalize_hint?: void_p): Reference;
|
||||||
|
createDeferred<T = any>(value: IDeferrdValue<T>): Deferred<T>;
|
||||||
|
adjustAmountOfExternalAllocatedMemory(changeInBytes: number | bigint): bigint;
|
||||||
|
createEnv(filename: string, moduleApiVersion: number, makeDynCall_vppp: (cb: Ptr) => (a: Ptr, b: Ptr, c: Ptr) => void, makeDynCall_vp: (cb: Ptr) => (a: Ptr) => void, abort: (msg?: string) => never, nodeBinding?: any): Env;
|
||||||
|
createTrackedFinalizer(envObject: Env, finalize_callback: napi_finalize, finalize_data: void_p, finalize_hint: void_p): TrackedFinalizer;
|
||||||
|
getCurrentScope(): HandleScope | null;
|
||||||
|
addToCurrentScope<V>(value: V): Handle<V>;
|
||||||
|
openScope(envObject?: Env): HandleScope;
|
||||||
|
closeScope(envObject?: Env, _scope?: HandleScope): void;
|
||||||
|
ensureHandle<S>(value: S): Handle<S>;
|
||||||
|
addCleanupHook(envObject: Env, fn: CleanupHookCallbackFunction, arg: number): void;
|
||||||
|
removeCleanupHook(envObject: Env, fn: CleanupHookCallbackFunction, arg: number): void;
|
||||||
|
runCleanup(): void;
|
||||||
|
increaseWaitingRequestCounter(): void;
|
||||||
|
decreaseWaitingRequestCounter(): void;
|
||||||
|
setCanCallIntoJs(value: boolean): void;
|
||||||
|
setStopping(value: boolean): void;
|
||||||
|
canCallIntoJs(): boolean;
|
||||||
|
/**
|
||||||
|
* Destroy the context and call cleanup hooks.
|
||||||
|
* Associated {@link Env | Env} will be destroyed.
|
||||||
|
*/
|
||||||
|
destroy(): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare interface ContextOptions {
|
||||||
|
onExternalMemoryChange?: (current: bigint, old: bigint, delta: bigint) => any;
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare function createContext(options?: ContextOptions): Context;
|
||||||
|
|
||||||
|
export declare class Deferred<T = any> implements IStoreValue {
|
||||||
|
static create<T = any>(ctx: Context, value: IDeferrdValue<T>): Deferred;
|
||||||
|
id: number;
|
||||||
|
ctx: Context;
|
||||||
|
value: IDeferrdValue<T>;
|
||||||
|
constructor(ctx: Context, value: IDeferrdValue<T>);
|
||||||
|
resolve(value: T): void;
|
||||||
|
reject(reason?: any): void;
|
||||||
|
dispose(): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare class EmnapiError extends Error {
|
||||||
|
constructor(message?: string);
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare abstract class Env implements IStoreValue {
|
||||||
|
readonly ctx: Context;
|
||||||
|
moduleApiVersion: number;
|
||||||
|
makeDynCall_vppp: (cb: Ptr) => (a: Ptr, b: Ptr, c: Ptr) => void;
|
||||||
|
makeDynCall_vp: (cb: Ptr) => (a: Ptr) => void;
|
||||||
|
abort: (msg?: string) => never;
|
||||||
|
id: number;
|
||||||
|
openHandleScopes: number;
|
||||||
|
instanceData: TrackedFinalizer | null;
|
||||||
|
tryCatch: TryCatch;
|
||||||
|
refs: number;
|
||||||
|
reflist: RefTracker;
|
||||||
|
finalizing_reflist: RefTracker;
|
||||||
|
pendingFinalizers: RefTracker[];
|
||||||
|
lastError: {
|
||||||
|
errorCode: napi_status;
|
||||||
|
engineErrorCode: number;
|
||||||
|
engineReserved: Ptr;
|
||||||
|
};
|
||||||
|
inGcFinalizer: boolean;
|
||||||
|
constructor(ctx: Context, moduleApiVersion: number, makeDynCall_vppp: (cb: Ptr) => (a: Ptr, b: Ptr, c: Ptr) => void, makeDynCall_vp: (cb: Ptr) => (a: Ptr) => void, abort: (msg?: string) => never);
|
||||||
|
/** @virtual */
|
||||||
|
canCallIntoJs(): boolean;
|
||||||
|
terminatedOrTerminating(): boolean;
|
||||||
|
ref(): void;
|
||||||
|
unref(): void;
|
||||||
|
ensureHandle<S>(value: S): Handle<S>;
|
||||||
|
ensureHandleId(value: any): napi_value;
|
||||||
|
clearLastError(): napi_status;
|
||||||
|
setLastError(error_code: napi_status, engine_error_code?: uint32_t, engine_reserved?: void_p): napi_status;
|
||||||
|
getReturnStatus(): napi_status;
|
||||||
|
callIntoModule<T>(fn: (env: Env) => T, handleException?: (envObject: Env, value: any) => void): T;
|
||||||
|
/** @virtual */
|
||||||
|
abstract callFinalizer(cb: napi_finalize, data: void_p, hint: void_p): void;
|
||||||
|
invokeFinalizerFromGC(finalizer: RefTracker): void;
|
||||||
|
checkGCAccess(): void;
|
||||||
|
/** @virtual */
|
||||||
|
enqueueFinalizer(finalizer: RefTracker): void;
|
||||||
|
/** @virtual */
|
||||||
|
dequeueFinalizer(finalizer: RefTracker): void;
|
||||||
|
/** @virtual */
|
||||||
|
deleteMe(): void;
|
||||||
|
dispose(): void;
|
||||||
|
private readonly _bindingMap;
|
||||||
|
initObjectBinding<S extends object>(value: S): IReferenceBinding;
|
||||||
|
getObjectBinding<S extends object>(value: S): IReferenceBinding;
|
||||||
|
setInstanceData(data: number, finalize_cb: number, finalize_hint: number): void;
|
||||||
|
getInstanceData(): number;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @public */
|
||||||
|
declare interface External_2 extends Record<any, any> {
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @public */
|
||||||
|
declare const External_2: {
|
||||||
|
new (value: number | bigint): External_2;
|
||||||
|
prototype: null;
|
||||||
|
};
|
||||||
|
export { External_2 as External }
|
||||||
|
|
||||||
|
export declare class Finalizer {
|
||||||
|
envObject: Env;
|
||||||
|
private _finalizeCallback;
|
||||||
|
private _finalizeData;
|
||||||
|
private _finalizeHint;
|
||||||
|
private _makeDynCall_vppp;
|
||||||
|
constructor(envObject: Env, _finalizeCallback?: napi_finalize, _finalizeData?: void_p, _finalizeHint?: void_p);
|
||||||
|
callback(): napi_finalize;
|
||||||
|
data(): void_p;
|
||||||
|
hint(): void_p;
|
||||||
|
resetEnv(): void;
|
||||||
|
resetFinalizer(): void;
|
||||||
|
callFinalizer(): void;
|
||||||
|
dispose(): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare function getDefaultContext(): Context;
|
||||||
|
|
||||||
|
/** @public */
|
||||||
|
export declare function getExternalValue(external: External_2): number | bigint;
|
||||||
|
|
||||||
|
export declare class Handle<S> {
|
||||||
|
id: number;
|
||||||
|
value: S;
|
||||||
|
constructor(id: number, value: S);
|
||||||
|
data(): void_p;
|
||||||
|
isNumber(): boolean;
|
||||||
|
isBigInt(): boolean;
|
||||||
|
isString(): boolean;
|
||||||
|
isFunction(): boolean;
|
||||||
|
isExternal(): boolean;
|
||||||
|
isObject(): boolean;
|
||||||
|
isArray(): boolean;
|
||||||
|
isArrayBuffer(): boolean;
|
||||||
|
isTypedArray(): boolean;
|
||||||
|
isBuffer(BufferConstructor?: BufferCtor): boolean;
|
||||||
|
isDataView(): boolean;
|
||||||
|
isDate(): boolean;
|
||||||
|
isPromise(): boolean;
|
||||||
|
isBoolean(): boolean;
|
||||||
|
isUndefined(): boolean;
|
||||||
|
isSymbol(): boolean;
|
||||||
|
isNull(): boolean;
|
||||||
|
dispose(): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare class HandleScope {
|
||||||
|
handleStore: HandleStore;
|
||||||
|
id: number;
|
||||||
|
parent: HandleScope | null;
|
||||||
|
child: HandleScope | null;
|
||||||
|
start: number;
|
||||||
|
end: number;
|
||||||
|
private _escapeCalled;
|
||||||
|
callbackInfo: ICallbackInfo;
|
||||||
|
constructor(handleStore: HandleStore, id: number, parentScope: HandleScope | null, start: number, end?: number);
|
||||||
|
add<V>(value: V): Handle<V>;
|
||||||
|
addExternal(data: void_p): Handle<object>;
|
||||||
|
dispose(): void;
|
||||||
|
escape(handle: number): Handle<any> | null;
|
||||||
|
escapeCalled(): boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare class HandleStore {
|
||||||
|
static UNDEFINED: ConstHandle<undefined>;
|
||||||
|
static NULL: ConstHandle<null>;
|
||||||
|
static FALSE: ConstHandle<false>;
|
||||||
|
static TRUE: ConstHandle<true>;
|
||||||
|
static GLOBAL: ConstHandle<typeof globalThis>;
|
||||||
|
static MIN_ID: 6;
|
||||||
|
private readonly _values;
|
||||||
|
private _next;
|
||||||
|
push<S>(value: S): Handle<S>;
|
||||||
|
erase(start: number, end: number): void;
|
||||||
|
get(id: Ptr): Handle<any> | undefined;
|
||||||
|
swap(a: number, b: number): void;
|
||||||
|
dispose(): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare interface ICallbackInfo {
|
||||||
|
thiz: any;
|
||||||
|
data: void_p;
|
||||||
|
args: ArrayLike<any>;
|
||||||
|
fn: Function;
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare interface IDeferrdValue<T = any> {
|
||||||
|
resolve: (value: T) => void;
|
||||||
|
reject: (reason?: any) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare interface IReferenceBinding {
|
||||||
|
wrapped: number;
|
||||||
|
tag: Uint32Array | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @public */
|
||||||
|
export declare function isExternal(object: unknown): object is External_2;
|
||||||
|
|
||||||
|
export declare function isReferenceType(v: any): v is object;
|
||||||
|
|
||||||
|
export declare interface IStoreValue {
|
||||||
|
id: number;
|
||||||
|
dispose(): void;
|
||||||
|
[x: string]: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare const NAPI_VERSION_EXPERIMENTAL = Version.NAPI_VERSION_EXPERIMENTAL;
|
||||||
|
|
||||||
|
export declare const NODE_API_DEFAULT_MODULE_API_VERSION = Version.NODE_API_DEFAULT_MODULE_API_VERSION;
|
||||||
|
|
||||||
|
export declare const NODE_API_SUPPORTED_VERSION_MAX = Version.NODE_API_SUPPORTED_VERSION_MAX;
|
||||||
|
|
||||||
|
export declare const NODE_API_SUPPORTED_VERSION_MIN = Version.NODE_API_SUPPORTED_VERSION_MIN;
|
||||||
|
|
||||||
|
export declare class NodeEnv extends Env {
|
||||||
|
filename: string;
|
||||||
|
private readonly nodeBinding?;
|
||||||
|
destructing: boolean;
|
||||||
|
finalizationScheduled: boolean;
|
||||||
|
constructor(ctx: Context, filename: string, moduleApiVersion: number, makeDynCall_vppp: (cb: Ptr) => (a: Ptr, b: Ptr, c: Ptr) => void, makeDynCall_vp: (cb: Ptr) => (a: Ptr) => void, abort: (msg?: string) => never, nodeBinding?: any);
|
||||||
|
deleteMe(): void;
|
||||||
|
canCallIntoJs(): boolean;
|
||||||
|
triggerFatalException(err: any): void;
|
||||||
|
callbackIntoModule<T>(enforceUncaughtExceptionPolicy: boolean, fn: (env: Env) => T): T;
|
||||||
|
callFinalizer(cb: napi_finalize, data: void_p, hint: void_p): void;
|
||||||
|
callFinalizerInternal(forceUncaught: int, cb: napi_finalize, data: void_p, hint: void_p): void;
|
||||||
|
enqueueFinalizer(finalizer: RefTracker): void;
|
||||||
|
drainFinalizerQueue(): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare class NotSupportBufferError extends EmnapiError {
|
||||||
|
constructor(api: string, message: string);
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare class NotSupportWeakRefError extends EmnapiError {
|
||||||
|
constructor(api: string, message: string);
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare class Persistent<T> {
|
||||||
|
private _ref;
|
||||||
|
private _param;
|
||||||
|
private _callback;
|
||||||
|
private static readonly _registry;
|
||||||
|
constructor(value: T);
|
||||||
|
setWeak<P>(param: P, callback: (param: P) => void): void;
|
||||||
|
clearWeak(): void;
|
||||||
|
reset(): void;
|
||||||
|
isEmpty(): boolean;
|
||||||
|
deref(): T | undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare class Reference extends RefTracker implements IStoreValue {
|
||||||
|
private static weakCallback;
|
||||||
|
id: number;
|
||||||
|
envObject: Env;
|
||||||
|
private readonly canBeWeak;
|
||||||
|
private _refcount;
|
||||||
|
private readonly _ownership;
|
||||||
|
persistent: Persistent<object>;
|
||||||
|
static create(envObject: Env, handle_id: napi_value, initialRefcount: uint32_t, ownership: ReferenceOwnership, _unused1?: void_p, _unused2?: void_p, _unused3?: void_p): Reference;
|
||||||
|
protected constructor(envObject: Env, handle_id: napi_value, initialRefcount: uint32_t, ownership: ReferenceOwnership);
|
||||||
|
ref(): number;
|
||||||
|
unref(): number;
|
||||||
|
get(envObject?: Env): napi_value;
|
||||||
|
/** @virtual */
|
||||||
|
resetFinalizer(): void;
|
||||||
|
/** @virtual */
|
||||||
|
data(): void_p;
|
||||||
|
refcount(): number;
|
||||||
|
ownership(): ReferenceOwnership;
|
||||||
|
/** @virtual */
|
||||||
|
protected callUserFinalizer(): void;
|
||||||
|
/** @virtual */
|
||||||
|
protected invokeFinalizerFromGC(): void;
|
||||||
|
private _setWeak;
|
||||||
|
finalize(): void;
|
||||||
|
dispose(): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare enum ReferenceOwnership {
|
||||||
|
kRuntime = 0,
|
||||||
|
kUserland = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare class ReferenceWithData extends Reference {
|
||||||
|
private readonly _data;
|
||||||
|
static create(envObject: Env, value: napi_value, initialRefcount: uint32_t, ownership: ReferenceOwnership, data: void_p): ReferenceWithData;
|
||||||
|
private constructor();
|
||||||
|
data(): void_p;
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare class ReferenceWithFinalizer extends Reference {
|
||||||
|
private _finalizer;
|
||||||
|
static create(envObject: Env, value: napi_value, initialRefcount: uint32_t, ownership: ReferenceOwnership, finalize_callback: napi_finalize, finalize_data: void_p, finalize_hint: void_p): ReferenceWithFinalizer;
|
||||||
|
private constructor();
|
||||||
|
resetFinalizer(): void;
|
||||||
|
data(): void_p;
|
||||||
|
protected callUserFinalizer(): void;
|
||||||
|
protected invokeFinalizerFromGC(): void;
|
||||||
|
dispose(): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare class RefTracker {
|
||||||
|
/** @virtual */
|
||||||
|
dispose(): void;
|
||||||
|
/** @virtual */
|
||||||
|
finalize(): void;
|
||||||
|
private _next;
|
||||||
|
private _prev;
|
||||||
|
link(list: RefTracker): void;
|
||||||
|
unlink(): void;
|
||||||
|
static finalizeAll(list: RefTracker): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare class ScopeStore {
|
||||||
|
private readonly _rootScope;
|
||||||
|
currentScope: HandleScope;
|
||||||
|
private readonly _values;
|
||||||
|
constructor();
|
||||||
|
get(id: number): HandleScope | undefined;
|
||||||
|
openScope(handleStore: HandleStore): HandleScope;
|
||||||
|
closeScope(): void;
|
||||||
|
dispose(): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare class Store<V extends IStoreValue> {
|
||||||
|
protected _values: Array<V | undefined>;
|
||||||
|
private _freeList;
|
||||||
|
private _size;
|
||||||
|
constructor();
|
||||||
|
add(value: V): void;
|
||||||
|
get(id: Ptr): V | undefined;
|
||||||
|
has(id: Ptr): boolean;
|
||||||
|
remove(id: Ptr): void;
|
||||||
|
dispose(): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare class TrackedFinalizer extends RefTracker {
|
||||||
|
private _finalizer;
|
||||||
|
static create(envObject: Env, finalize_callback: napi_finalize, finalize_data: void_p, finalize_hint: void_p): TrackedFinalizer;
|
||||||
|
private constructor();
|
||||||
|
data(): void_p;
|
||||||
|
dispose(): void;
|
||||||
|
finalize(): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare class TryCatch {
|
||||||
|
private _exception;
|
||||||
|
private _caught;
|
||||||
|
isEmpty(): boolean;
|
||||||
|
hasCaught(): boolean;
|
||||||
|
exception(): any;
|
||||||
|
setError(err: any): void;
|
||||||
|
reset(): void;
|
||||||
|
extractException(): any;
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare const version: string;
|
||||||
|
|
||||||
|
export { }
|
||||||
+1
File diff suppressed because one or more lines are too long
+671
@@ -0,0 +1,671 @@
|
|||||||
|
export declare type Ptr = number | bigint
|
||||||
|
|
||||||
|
export declare interface IBuffer extends Uint8Array {}
|
||||||
|
export declare interface BufferCtor {
|
||||||
|
readonly prototype: IBuffer
|
||||||
|
/** @deprecated */
|
||||||
|
new (...args: any[]): IBuffer
|
||||||
|
from: {
|
||||||
|
(buffer: ArrayBufferLike): IBuffer
|
||||||
|
(buffer: ArrayBufferLike, byteOffset: number, length: number): IBuffer
|
||||||
|
}
|
||||||
|
alloc: (size: number) => IBuffer
|
||||||
|
isBuffer: (obj: unknown) => obj is IBuffer
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare const enum GlobalHandle {
|
||||||
|
UNDEFINED = 1,
|
||||||
|
NULL,
|
||||||
|
FALSE,
|
||||||
|
TRUE,
|
||||||
|
GLOBAL
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare const enum Version {
|
||||||
|
NODE_API_SUPPORTED_VERSION_MIN = 1,
|
||||||
|
NODE_API_DEFAULT_MODULE_API_VERSION = 8,
|
||||||
|
NODE_API_SUPPORTED_VERSION_MAX = 10,
|
||||||
|
NAPI_VERSION_EXPERIMENTAL = 2147483647 // INT_MAX
|
||||||
|
}
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
|
export declare type Pointer<T> = number
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
|
export declare type PointerPointer<T> = number
|
||||||
|
export declare type FunctionPointer<T extends (...args: any[]) => any> = Pointer<T>
|
||||||
|
export declare type Const<T> = T
|
||||||
|
|
||||||
|
export declare type void_p = Pointer<void>
|
||||||
|
export declare type void_pp = Pointer<void_p>
|
||||||
|
export declare type bool = number
|
||||||
|
export declare type char = number
|
||||||
|
export declare type char_p = Pointer<char>
|
||||||
|
export declare type unsigned_char = number
|
||||||
|
export declare type const_char = Const<char>
|
||||||
|
export declare type const_char_p = Pointer<const_char>
|
||||||
|
export declare type char16_t_p = number
|
||||||
|
export declare type const_char16_t_p = number
|
||||||
|
|
||||||
|
export declare type short = number
|
||||||
|
export declare type unsigned_short = number
|
||||||
|
export declare type int = number
|
||||||
|
export declare type unsigned_int = number
|
||||||
|
export declare type long = number
|
||||||
|
export declare type unsigned_long = number
|
||||||
|
export declare type long_long = bigint
|
||||||
|
export declare type unsigned_long_long = bigint
|
||||||
|
export declare type float = number
|
||||||
|
export declare type double = number
|
||||||
|
export declare type long_double = number
|
||||||
|
export declare type size_t = number
|
||||||
|
|
||||||
|
export declare type int8_t = number
|
||||||
|
export declare type uint8_t = number
|
||||||
|
export declare type int16_t = number
|
||||||
|
export declare type uint16_t = number
|
||||||
|
export declare type int32_t = number
|
||||||
|
export declare type uint32_t = number
|
||||||
|
export declare type int64_t = bigint
|
||||||
|
export declare type uint64_t = bigint
|
||||||
|
export declare type napi_env = Pointer<unknown>
|
||||||
|
|
||||||
|
export declare type napi_value = Pointer<unknown>
|
||||||
|
export declare type napi_ref = Pointer<unknown>
|
||||||
|
export declare type napi_deferred = Pointer<unknown>
|
||||||
|
export declare type napi_handle_scope = Pointer<unknown>
|
||||||
|
export declare type napi_escapable_handle_scope = Pointer<unknown>
|
||||||
|
|
||||||
|
export declare type napi_addon_register_func = FunctionPointer<(env: napi_env, exports: napi_value) => napi_value>
|
||||||
|
|
||||||
|
export declare type napi_callback_info = Pointer<unknown>
|
||||||
|
export declare type napi_callback = FunctionPointer<(env: napi_env, info: napi_callback_info) => napi_value>
|
||||||
|
|
||||||
|
export declare interface napi_extended_error_info {
|
||||||
|
error_message: const_char_p
|
||||||
|
engine_reserved: void_p
|
||||||
|
engine_error_code: uint32_t
|
||||||
|
error_code: napi_status
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare interface napi_property_descriptor {
|
||||||
|
// One of utf8name or name should be NULL.
|
||||||
|
utf8name: const_char_p
|
||||||
|
name: napi_value
|
||||||
|
|
||||||
|
method: napi_callback
|
||||||
|
getter: napi_callback
|
||||||
|
setter: napi_callback
|
||||||
|
value: napi_value
|
||||||
|
/* napi_property_attributes */
|
||||||
|
attributes: number
|
||||||
|
data: void_p
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare type napi_finalize = FunctionPointer<(
|
||||||
|
env: napi_env,
|
||||||
|
finalize_data: void_p,
|
||||||
|
finalize_hint: void_p
|
||||||
|
) => void>
|
||||||
|
|
||||||
|
export declare interface node_module {
|
||||||
|
nm_version: int32_t
|
||||||
|
nm_flags: uint32_t
|
||||||
|
nm_filename: Pointer<const_char>
|
||||||
|
nm_register_func: napi_addon_register_func
|
||||||
|
nm_modname: Pointer<const_char>
|
||||||
|
nm_priv: Pointer<void>
|
||||||
|
reserved: PointerPointer<void>
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare interface napi_node_version {
|
||||||
|
major: uint32_t
|
||||||
|
minor: uint32_t
|
||||||
|
patch: uint32_t
|
||||||
|
release: const_char_p
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare interface emnapi_emscripten_version {
|
||||||
|
major: uint32_t
|
||||||
|
minor: uint32_t
|
||||||
|
patch: uint32_t
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare const enum napi_status {
|
||||||
|
napi_ok,
|
||||||
|
napi_invalid_arg,
|
||||||
|
napi_object_expected,
|
||||||
|
napi_string_expected,
|
||||||
|
napi_name_expected,
|
||||||
|
napi_function_expected,
|
||||||
|
napi_number_expected,
|
||||||
|
napi_boolean_expected,
|
||||||
|
napi_array_expected,
|
||||||
|
napi_generic_failure,
|
||||||
|
napi_pending_exception,
|
||||||
|
napi_cancelled,
|
||||||
|
napi_escape_called_twice,
|
||||||
|
napi_handle_scope_mismatch,
|
||||||
|
napi_callback_scope_mismatch,
|
||||||
|
napi_queue_full,
|
||||||
|
napi_closing,
|
||||||
|
napi_bigint_expected,
|
||||||
|
napi_date_expected,
|
||||||
|
napi_arraybuffer_expected,
|
||||||
|
napi_detachable_arraybuffer_expected,
|
||||||
|
napi_would_deadlock, // unused
|
||||||
|
napi_no_external_buffers_allowed,
|
||||||
|
napi_cannot_run_js
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare const enum napi_property_attributes {
|
||||||
|
napi_default = 0,
|
||||||
|
napi_writable = 1 << 0,
|
||||||
|
napi_enumerable = 1 << 1,
|
||||||
|
napi_configurable = 1 << 2,
|
||||||
|
|
||||||
|
// Used with napi_define_class to distinguish static properties
|
||||||
|
// from instance properties. Ignored by napi_define_properties.
|
||||||
|
napi_static = 1 << 10,
|
||||||
|
|
||||||
|
/// #ifdef NAPI_EXPERIMENTAL
|
||||||
|
// Default for class methods.
|
||||||
|
napi_default_method = napi_writable | napi_configurable,
|
||||||
|
|
||||||
|
// Default for object properties, like in JS obj[prop].
|
||||||
|
napi_default_jsproperty = napi_writable | napi_enumerable | napi_configurable
|
||||||
|
/// #endif // NAPI_EXPERIMENTAL
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare const enum napi_valuetype {
|
||||||
|
napi_undefined,
|
||||||
|
napi_null,
|
||||||
|
napi_boolean,
|
||||||
|
napi_number,
|
||||||
|
napi_string,
|
||||||
|
napi_symbol,
|
||||||
|
napi_object,
|
||||||
|
napi_function,
|
||||||
|
napi_external,
|
||||||
|
napi_bigint
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare const enum napi_typedarray_type {
|
||||||
|
napi_int8_array,
|
||||||
|
napi_uint8_array,
|
||||||
|
napi_uint8_clamped_array,
|
||||||
|
napi_int16_array,
|
||||||
|
napi_uint16_array,
|
||||||
|
napi_int32_array,
|
||||||
|
napi_uint32_array,
|
||||||
|
napi_float32_array,
|
||||||
|
napi_float64_array,
|
||||||
|
napi_bigint64_array,
|
||||||
|
napi_biguint64_array,
|
||||||
|
napi_float16_array,
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare const enum napi_key_collection_mode {
|
||||||
|
napi_key_include_prototypes,
|
||||||
|
napi_key_own_only
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare const enum napi_key_filter {
|
||||||
|
napi_key_all_properties = 0,
|
||||||
|
napi_key_writable = 1,
|
||||||
|
napi_key_enumerable = 1 << 1,
|
||||||
|
napi_key_configurable = 1 << 2,
|
||||||
|
napi_key_skip_strings = 1 << 3,
|
||||||
|
napi_key_skip_symbols = 1 << 4
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare const enum napi_key_conversion {
|
||||||
|
napi_key_keep_numbers,
|
||||||
|
napi_key_numbers_to_strings
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare const enum emnapi_memory_view_type {
|
||||||
|
emnapi_int8_array,
|
||||||
|
emnapi_uint8_array,
|
||||||
|
emnapi_uint8_clamped_array,
|
||||||
|
emnapi_int16_array,
|
||||||
|
emnapi_uint16_array,
|
||||||
|
emnapi_int32_array,
|
||||||
|
emnapi_uint32_array,
|
||||||
|
emnapi_float32_array,
|
||||||
|
emnapi_float64_array,
|
||||||
|
emnapi_bigint64_array,
|
||||||
|
emnapi_biguint64_array,
|
||||||
|
emnapi_float16_array,
|
||||||
|
emnapi_data_view = -1,
|
||||||
|
emnapi_buffer = -2
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare const enum napi_threadsafe_function_call_mode {
|
||||||
|
napi_tsfn_nonblocking,
|
||||||
|
napi_tsfn_blocking
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare const enum napi_threadsafe_function_release_mode {
|
||||||
|
napi_tsfn_release,
|
||||||
|
napi_tsfn_abort
|
||||||
|
}
|
||||||
|
export declare type CleanupHookCallbackFunction = number | ((arg: number) => void);
|
||||||
|
|
||||||
|
export declare class ConstHandle<S extends undefined | null | boolean | typeof globalThis> extends Handle<S> {
|
||||||
|
constructor(id: number, value: S);
|
||||||
|
dispose(): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare class Context {
|
||||||
|
private _isStopping;
|
||||||
|
private _canCallIntoJs;
|
||||||
|
private _suppressDestroy;
|
||||||
|
envStore: Store<Env>;
|
||||||
|
scopeStore: ScopeStore;
|
||||||
|
refStore: Store<Reference>;
|
||||||
|
deferredStore: Store<Deferred<any>>;
|
||||||
|
handleStore: HandleStore;
|
||||||
|
private readonly refCounter?;
|
||||||
|
private readonly cleanupQueue;
|
||||||
|
private readonly _externalMemory;
|
||||||
|
feature: {
|
||||||
|
supportReflect: boolean;
|
||||||
|
supportFinalizer: boolean;
|
||||||
|
supportWeakSymbol: boolean;
|
||||||
|
supportBigInt: boolean;
|
||||||
|
supportNewFunction: boolean;
|
||||||
|
canSetFunctionName: boolean;
|
||||||
|
setImmediate: (callback: () => void) => void;
|
||||||
|
Buffer: BufferCtor | undefined;
|
||||||
|
MessageChannel: {
|
||||||
|
new (): MessageChannel;
|
||||||
|
prototype: MessageChannel;
|
||||||
|
} | undefined;
|
||||||
|
};
|
||||||
|
constructor(options?: ContextOptions);
|
||||||
|
/**
|
||||||
|
* Suppress the destroy on `beforeExit` event in Node.js.
|
||||||
|
* Call this method if you want to keep the context and
|
||||||
|
* all associated {@link Env | Env} alive,
|
||||||
|
* this also means that cleanup hooks will not be called.
|
||||||
|
* After call this method, you should call
|
||||||
|
* {@link Context.destroy | `Context.prototype.destroy`} method manually.
|
||||||
|
*/
|
||||||
|
suppressDestroy(): void;
|
||||||
|
getRuntimeVersions(): {
|
||||||
|
version: string;
|
||||||
|
NODE_API_SUPPORTED_VERSION_MAX: Version;
|
||||||
|
NAPI_VERSION_EXPERIMENTAL: Version;
|
||||||
|
NODE_API_DEFAULT_MODULE_API_VERSION: Version;
|
||||||
|
};
|
||||||
|
createNotSupportWeakRefError(api: string, message: string): NotSupportWeakRefError;
|
||||||
|
createNotSupportBufferError(api: string, message: string): NotSupportBufferError;
|
||||||
|
createReference(envObject: Env, handle_id: napi_value, initialRefcount: uint32_t, ownership: ReferenceOwnership): Reference;
|
||||||
|
createReferenceWithData(envObject: Env, handle_id: napi_value, initialRefcount: uint32_t, ownership: ReferenceOwnership, data: void_p): Reference;
|
||||||
|
createReferenceWithFinalizer(envObject: Env, handle_id: napi_value, initialRefcount: uint32_t, ownership: ReferenceOwnership, finalize_callback?: napi_finalize, finalize_data?: void_p, finalize_hint?: void_p): Reference;
|
||||||
|
createDeferred<T = any>(value: IDeferrdValue<T>): Deferred<T>;
|
||||||
|
adjustAmountOfExternalAllocatedMemory(changeInBytes: number | bigint): bigint;
|
||||||
|
createEnv(filename: string, moduleApiVersion: number, makeDynCall_vppp: (cb: Ptr) => (a: Ptr, b: Ptr, c: Ptr) => void, makeDynCall_vp: (cb: Ptr) => (a: Ptr) => void, abort: (msg?: string) => never, nodeBinding?: any): Env;
|
||||||
|
createTrackedFinalizer(envObject: Env, finalize_callback: napi_finalize, finalize_data: void_p, finalize_hint: void_p): TrackedFinalizer;
|
||||||
|
getCurrentScope(): HandleScope | null;
|
||||||
|
addToCurrentScope<V>(value: V): Handle<V>;
|
||||||
|
openScope(envObject?: Env): HandleScope;
|
||||||
|
closeScope(envObject?: Env, _scope?: HandleScope): void;
|
||||||
|
ensureHandle<S>(value: S): Handle<S>;
|
||||||
|
addCleanupHook(envObject: Env, fn: CleanupHookCallbackFunction, arg: number): void;
|
||||||
|
removeCleanupHook(envObject: Env, fn: CleanupHookCallbackFunction, arg: number): void;
|
||||||
|
runCleanup(): void;
|
||||||
|
increaseWaitingRequestCounter(): void;
|
||||||
|
decreaseWaitingRequestCounter(): void;
|
||||||
|
setCanCallIntoJs(value: boolean): void;
|
||||||
|
setStopping(value: boolean): void;
|
||||||
|
canCallIntoJs(): boolean;
|
||||||
|
/**
|
||||||
|
* Destroy the context and call cleanup hooks.
|
||||||
|
* Associated {@link Env | Env} will be destroyed.
|
||||||
|
*/
|
||||||
|
destroy(): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare interface ContextOptions {
|
||||||
|
onExternalMemoryChange?: (current: bigint, old: bigint, delta: bigint) => any;
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare function createContext(options?: ContextOptions): Context;
|
||||||
|
|
||||||
|
export declare class Deferred<T = any> implements IStoreValue {
|
||||||
|
static create<T = any>(ctx: Context, value: IDeferrdValue<T>): Deferred;
|
||||||
|
id: number;
|
||||||
|
ctx: Context;
|
||||||
|
value: IDeferrdValue<T>;
|
||||||
|
constructor(ctx: Context, value: IDeferrdValue<T>);
|
||||||
|
resolve(value: T): void;
|
||||||
|
reject(reason?: any): void;
|
||||||
|
dispose(): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare class EmnapiError extends Error {
|
||||||
|
constructor(message?: string);
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare abstract class Env implements IStoreValue {
|
||||||
|
readonly ctx: Context;
|
||||||
|
moduleApiVersion: number;
|
||||||
|
makeDynCall_vppp: (cb: Ptr) => (a: Ptr, b: Ptr, c: Ptr) => void;
|
||||||
|
makeDynCall_vp: (cb: Ptr) => (a: Ptr) => void;
|
||||||
|
abort: (msg?: string) => never;
|
||||||
|
id: number;
|
||||||
|
openHandleScopes: number;
|
||||||
|
instanceData: TrackedFinalizer | null;
|
||||||
|
tryCatch: TryCatch;
|
||||||
|
refs: number;
|
||||||
|
reflist: RefTracker;
|
||||||
|
finalizing_reflist: RefTracker;
|
||||||
|
pendingFinalizers: RefTracker[];
|
||||||
|
lastError: {
|
||||||
|
errorCode: napi_status;
|
||||||
|
engineErrorCode: number;
|
||||||
|
engineReserved: Ptr;
|
||||||
|
};
|
||||||
|
inGcFinalizer: boolean;
|
||||||
|
constructor(ctx: Context, moduleApiVersion: number, makeDynCall_vppp: (cb: Ptr) => (a: Ptr, b: Ptr, c: Ptr) => void, makeDynCall_vp: (cb: Ptr) => (a: Ptr) => void, abort: (msg?: string) => never);
|
||||||
|
/** @virtual */
|
||||||
|
canCallIntoJs(): boolean;
|
||||||
|
terminatedOrTerminating(): boolean;
|
||||||
|
ref(): void;
|
||||||
|
unref(): void;
|
||||||
|
ensureHandle<S>(value: S): Handle<S>;
|
||||||
|
ensureHandleId(value: any): napi_value;
|
||||||
|
clearLastError(): napi_status;
|
||||||
|
setLastError(error_code: napi_status, engine_error_code?: uint32_t, engine_reserved?: void_p): napi_status;
|
||||||
|
getReturnStatus(): napi_status;
|
||||||
|
callIntoModule<T>(fn: (env: Env) => T, handleException?: (envObject: Env, value: any) => void): T;
|
||||||
|
/** @virtual */
|
||||||
|
abstract callFinalizer(cb: napi_finalize, data: void_p, hint: void_p): void;
|
||||||
|
invokeFinalizerFromGC(finalizer: RefTracker): void;
|
||||||
|
checkGCAccess(): void;
|
||||||
|
/** @virtual */
|
||||||
|
enqueueFinalizer(finalizer: RefTracker): void;
|
||||||
|
/** @virtual */
|
||||||
|
dequeueFinalizer(finalizer: RefTracker): void;
|
||||||
|
/** @virtual */
|
||||||
|
deleteMe(): void;
|
||||||
|
dispose(): void;
|
||||||
|
private readonly _bindingMap;
|
||||||
|
initObjectBinding<S extends object>(value: S): IReferenceBinding;
|
||||||
|
getObjectBinding<S extends object>(value: S): IReferenceBinding;
|
||||||
|
setInstanceData(data: number, finalize_cb: number, finalize_hint: number): void;
|
||||||
|
getInstanceData(): number;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @public */
|
||||||
|
declare interface External_2 extends Record<any, any> {
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @public */
|
||||||
|
declare const External_2: {
|
||||||
|
new (value: number | bigint): External_2;
|
||||||
|
prototype: null;
|
||||||
|
};
|
||||||
|
export { External_2 as External }
|
||||||
|
|
||||||
|
export declare class Finalizer {
|
||||||
|
envObject: Env;
|
||||||
|
private _finalizeCallback;
|
||||||
|
private _finalizeData;
|
||||||
|
private _finalizeHint;
|
||||||
|
private _makeDynCall_vppp;
|
||||||
|
constructor(envObject: Env, _finalizeCallback?: napi_finalize, _finalizeData?: void_p, _finalizeHint?: void_p);
|
||||||
|
callback(): napi_finalize;
|
||||||
|
data(): void_p;
|
||||||
|
hint(): void_p;
|
||||||
|
resetEnv(): void;
|
||||||
|
resetFinalizer(): void;
|
||||||
|
callFinalizer(): void;
|
||||||
|
dispose(): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare function getDefaultContext(): Context;
|
||||||
|
|
||||||
|
/** @public */
|
||||||
|
export declare function getExternalValue(external: External_2): number | bigint;
|
||||||
|
|
||||||
|
export declare class Handle<S> {
|
||||||
|
id: number;
|
||||||
|
value: S;
|
||||||
|
constructor(id: number, value: S);
|
||||||
|
data(): void_p;
|
||||||
|
isNumber(): boolean;
|
||||||
|
isBigInt(): boolean;
|
||||||
|
isString(): boolean;
|
||||||
|
isFunction(): boolean;
|
||||||
|
isExternal(): boolean;
|
||||||
|
isObject(): boolean;
|
||||||
|
isArray(): boolean;
|
||||||
|
isArrayBuffer(): boolean;
|
||||||
|
isTypedArray(): boolean;
|
||||||
|
isBuffer(BufferConstructor?: BufferCtor): boolean;
|
||||||
|
isDataView(): boolean;
|
||||||
|
isDate(): boolean;
|
||||||
|
isPromise(): boolean;
|
||||||
|
isBoolean(): boolean;
|
||||||
|
isUndefined(): boolean;
|
||||||
|
isSymbol(): boolean;
|
||||||
|
isNull(): boolean;
|
||||||
|
dispose(): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare class HandleScope {
|
||||||
|
handleStore: HandleStore;
|
||||||
|
id: number;
|
||||||
|
parent: HandleScope | null;
|
||||||
|
child: HandleScope | null;
|
||||||
|
start: number;
|
||||||
|
end: number;
|
||||||
|
private _escapeCalled;
|
||||||
|
callbackInfo: ICallbackInfo;
|
||||||
|
constructor(handleStore: HandleStore, id: number, parentScope: HandleScope | null, start: number, end?: number);
|
||||||
|
add<V>(value: V): Handle<V>;
|
||||||
|
addExternal(data: void_p): Handle<object>;
|
||||||
|
dispose(): void;
|
||||||
|
escape(handle: number): Handle<any> | null;
|
||||||
|
escapeCalled(): boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare class HandleStore {
|
||||||
|
static UNDEFINED: ConstHandle<undefined>;
|
||||||
|
static NULL: ConstHandle<null>;
|
||||||
|
static FALSE: ConstHandle<false>;
|
||||||
|
static TRUE: ConstHandle<true>;
|
||||||
|
static GLOBAL: ConstHandle<typeof globalThis>;
|
||||||
|
static MIN_ID: 6;
|
||||||
|
private readonly _values;
|
||||||
|
private _next;
|
||||||
|
push<S>(value: S): Handle<S>;
|
||||||
|
erase(start: number, end: number): void;
|
||||||
|
get(id: Ptr): Handle<any> | undefined;
|
||||||
|
swap(a: number, b: number): void;
|
||||||
|
dispose(): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare interface ICallbackInfo {
|
||||||
|
thiz: any;
|
||||||
|
data: void_p;
|
||||||
|
args: ArrayLike<any>;
|
||||||
|
fn: Function;
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare interface IDeferrdValue<T = any> {
|
||||||
|
resolve: (value: T) => void;
|
||||||
|
reject: (reason?: any) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare interface IReferenceBinding {
|
||||||
|
wrapped: number;
|
||||||
|
tag: Uint32Array | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @public */
|
||||||
|
export declare function isExternal(object: unknown): object is External_2;
|
||||||
|
|
||||||
|
export declare function isReferenceType(v: any): v is object;
|
||||||
|
|
||||||
|
export declare interface IStoreValue {
|
||||||
|
id: number;
|
||||||
|
dispose(): void;
|
||||||
|
[x: string]: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare const NAPI_VERSION_EXPERIMENTAL = Version.NAPI_VERSION_EXPERIMENTAL;
|
||||||
|
|
||||||
|
export declare const NODE_API_DEFAULT_MODULE_API_VERSION = Version.NODE_API_DEFAULT_MODULE_API_VERSION;
|
||||||
|
|
||||||
|
export declare const NODE_API_SUPPORTED_VERSION_MAX = Version.NODE_API_SUPPORTED_VERSION_MAX;
|
||||||
|
|
||||||
|
export declare const NODE_API_SUPPORTED_VERSION_MIN = Version.NODE_API_SUPPORTED_VERSION_MIN;
|
||||||
|
|
||||||
|
export declare class NodeEnv extends Env {
|
||||||
|
filename: string;
|
||||||
|
private readonly nodeBinding?;
|
||||||
|
destructing: boolean;
|
||||||
|
finalizationScheduled: boolean;
|
||||||
|
constructor(ctx: Context, filename: string, moduleApiVersion: number, makeDynCall_vppp: (cb: Ptr) => (a: Ptr, b: Ptr, c: Ptr) => void, makeDynCall_vp: (cb: Ptr) => (a: Ptr) => void, abort: (msg?: string) => never, nodeBinding?: any);
|
||||||
|
deleteMe(): void;
|
||||||
|
canCallIntoJs(): boolean;
|
||||||
|
triggerFatalException(err: any): void;
|
||||||
|
callbackIntoModule<T>(enforceUncaughtExceptionPolicy: boolean, fn: (env: Env) => T): T;
|
||||||
|
callFinalizer(cb: napi_finalize, data: void_p, hint: void_p): void;
|
||||||
|
callFinalizerInternal(forceUncaught: int, cb: napi_finalize, data: void_p, hint: void_p): void;
|
||||||
|
enqueueFinalizer(finalizer: RefTracker): void;
|
||||||
|
drainFinalizerQueue(): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare class NotSupportBufferError extends EmnapiError {
|
||||||
|
constructor(api: string, message: string);
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare class NotSupportWeakRefError extends EmnapiError {
|
||||||
|
constructor(api: string, message: string);
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare class Persistent<T> {
|
||||||
|
private _ref;
|
||||||
|
private _param;
|
||||||
|
private _callback;
|
||||||
|
private static readonly _registry;
|
||||||
|
constructor(value: T);
|
||||||
|
setWeak<P>(param: P, callback: (param: P) => void): void;
|
||||||
|
clearWeak(): void;
|
||||||
|
reset(): void;
|
||||||
|
isEmpty(): boolean;
|
||||||
|
deref(): T | undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare class Reference extends RefTracker implements IStoreValue {
|
||||||
|
private static weakCallback;
|
||||||
|
id: number;
|
||||||
|
envObject: Env;
|
||||||
|
private readonly canBeWeak;
|
||||||
|
private _refcount;
|
||||||
|
private readonly _ownership;
|
||||||
|
persistent: Persistent<object>;
|
||||||
|
static create(envObject: Env, handle_id: napi_value, initialRefcount: uint32_t, ownership: ReferenceOwnership, _unused1?: void_p, _unused2?: void_p, _unused3?: void_p): Reference;
|
||||||
|
protected constructor(envObject: Env, handle_id: napi_value, initialRefcount: uint32_t, ownership: ReferenceOwnership);
|
||||||
|
ref(): number;
|
||||||
|
unref(): number;
|
||||||
|
get(envObject?: Env): napi_value;
|
||||||
|
/** @virtual */
|
||||||
|
resetFinalizer(): void;
|
||||||
|
/** @virtual */
|
||||||
|
data(): void_p;
|
||||||
|
refcount(): number;
|
||||||
|
ownership(): ReferenceOwnership;
|
||||||
|
/** @virtual */
|
||||||
|
protected callUserFinalizer(): void;
|
||||||
|
/** @virtual */
|
||||||
|
protected invokeFinalizerFromGC(): void;
|
||||||
|
private _setWeak;
|
||||||
|
finalize(): void;
|
||||||
|
dispose(): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare enum ReferenceOwnership {
|
||||||
|
kRuntime = 0,
|
||||||
|
kUserland = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare class ReferenceWithData extends Reference {
|
||||||
|
private readonly _data;
|
||||||
|
static create(envObject: Env, value: napi_value, initialRefcount: uint32_t, ownership: ReferenceOwnership, data: void_p): ReferenceWithData;
|
||||||
|
private constructor();
|
||||||
|
data(): void_p;
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare class ReferenceWithFinalizer extends Reference {
|
||||||
|
private _finalizer;
|
||||||
|
static create(envObject: Env, value: napi_value, initialRefcount: uint32_t, ownership: ReferenceOwnership, finalize_callback: napi_finalize, finalize_data: void_p, finalize_hint: void_p): ReferenceWithFinalizer;
|
||||||
|
private constructor();
|
||||||
|
resetFinalizer(): void;
|
||||||
|
data(): void_p;
|
||||||
|
protected callUserFinalizer(): void;
|
||||||
|
protected invokeFinalizerFromGC(): void;
|
||||||
|
dispose(): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare class RefTracker {
|
||||||
|
/** @virtual */
|
||||||
|
dispose(): void;
|
||||||
|
/** @virtual */
|
||||||
|
finalize(): void;
|
||||||
|
private _next;
|
||||||
|
private _prev;
|
||||||
|
link(list: RefTracker): void;
|
||||||
|
unlink(): void;
|
||||||
|
static finalizeAll(list: RefTracker): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare class ScopeStore {
|
||||||
|
private readonly _rootScope;
|
||||||
|
currentScope: HandleScope;
|
||||||
|
private readonly _values;
|
||||||
|
constructor();
|
||||||
|
get(id: number): HandleScope | undefined;
|
||||||
|
openScope(handleStore: HandleStore): HandleScope;
|
||||||
|
closeScope(): void;
|
||||||
|
dispose(): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare class Store<V extends IStoreValue> {
|
||||||
|
protected _values: Array<V | undefined>;
|
||||||
|
private _freeList;
|
||||||
|
private _size;
|
||||||
|
constructor();
|
||||||
|
add(value: V): void;
|
||||||
|
get(id: Ptr): V | undefined;
|
||||||
|
has(id: Ptr): boolean;
|
||||||
|
remove(id: Ptr): void;
|
||||||
|
dispose(): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare class TrackedFinalizer extends RefTracker {
|
||||||
|
private _finalizer;
|
||||||
|
static create(envObject: Env, finalize_callback: napi_finalize, finalize_data: void_p, finalize_hint: void_p): TrackedFinalizer;
|
||||||
|
private constructor();
|
||||||
|
data(): void_p;
|
||||||
|
dispose(): void;
|
||||||
|
finalize(): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare class TryCatch {
|
||||||
|
private _exception;
|
||||||
|
private _caught;
|
||||||
|
isEmpty(): boolean;
|
||||||
|
hasCaught(): boolean;
|
||||||
|
exception(): any;
|
||||||
|
setError(err: any): void;
|
||||||
|
reset(): void;
|
||||||
|
extractException(): any;
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare const version: string;
|
||||||
|
|
||||||
|
export { }
|
||||||
+673
@@ -0,0 +1,673 @@
|
|||||||
|
export declare type Ptr = number | bigint
|
||||||
|
|
||||||
|
export declare interface IBuffer extends Uint8Array {}
|
||||||
|
export declare interface BufferCtor {
|
||||||
|
readonly prototype: IBuffer
|
||||||
|
/** @deprecated */
|
||||||
|
new (...args: any[]): IBuffer
|
||||||
|
from: {
|
||||||
|
(buffer: ArrayBufferLike): IBuffer
|
||||||
|
(buffer: ArrayBufferLike, byteOffset: number, length: number): IBuffer
|
||||||
|
}
|
||||||
|
alloc: (size: number) => IBuffer
|
||||||
|
isBuffer: (obj: unknown) => obj is IBuffer
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare const enum GlobalHandle {
|
||||||
|
UNDEFINED = 1,
|
||||||
|
NULL,
|
||||||
|
FALSE,
|
||||||
|
TRUE,
|
||||||
|
GLOBAL
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare const enum Version {
|
||||||
|
NODE_API_SUPPORTED_VERSION_MIN = 1,
|
||||||
|
NODE_API_DEFAULT_MODULE_API_VERSION = 8,
|
||||||
|
NODE_API_SUPPORTED_VERSION_MAX = 10,
|
||||||
|
NAPI_VERSION_EXPERIMENTAL = 2147483647 // INT_MAX
|
||||||
|
}
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
|
export declare type Pointer<T> = number
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
|
export declare type PointerPointer<T> = number
|
||||||
|
export declare type FunctionPointer<T extends (...args: any[]) => any> = Pointer<T>
|
||||||
|
export declare type Const<T> = T
|
||||||
|
|
||||||
|
export declare type void_p = Pointer<void>
|
||||||
|
export declare type void_pp = Pointer<void_p>
|
||||||
|
export declare type bool = number
|
||||||
|
export declare type char = number
|
||||||
|
export declare type char_p = Pointer<char>
|
||||||
|
export declare type unsigned_char = number
|
||||||
|
export declare type const_char = Const<char>
|
||||||
|
export declare type const_char_p = Pointer<const_char>
|
||||||
|
export declare type char16_t_p = number
|
||||||
|
export declare type const_char16_t_p = number
|
||||||
|
|
||||||
|
export declare type short = number
|
||||||
|
export declare type unsigned_short = number
|
||||||
|
export declare type int = number
|
||||||
|
export declare type unsigned_int = number
|
||||||
|
export declare type long = number
|
||||||
|
export declare type unsigned_long = number
|
||||||
|
export declare type long_long = bigint
|
||||||
|
export declare type unsigned_long_long = bigint
|
||||||
|
export declare type float = number
|
||||||
|
export declare type double = number
|
||||||
|
export declare type long_double = number
|
||||||
|
export declare type size_t = number
|
||||||
|
|
||||||
|
export declare type int8_t = number
|
||||||
|
export declare type uint8_t = number
|
||||||
|
export declare type int16_t = number
|
||||||
|
export declare type uint16_t = number
|
||||||
|
export declare type int32_t = number
|
||||||
|
export declare type uint32_t = number
|
||||||
|
export declare type int64_t = bigint
|
||||||
|
export declare type uint64_t = bigint
|
||||||
|
export declare type napi_env = Pointer<unknown>
|
||||||
|
|
||||||
|
export declare type napi_value = Pointer<unknown>
|
||||||
|
export declare type napi_ref = Pointer<unknown>
|
||||||
|
export declare type napi_deferred = Pointer<unknown>
|
||||||
|
export declare type napi_handle_scope = Pointer<unknown>
|
||||||
|
export declare type napi_escapable_handle_scope = Pointer<unknown>
|
||||||
|
|
||||||
|
export declare type napi_addon_register_func = FunctionPointer<(env: napi_env, exports: napi_value) => napi_value>
|
||||||
|
|
||||||
|
export declare type napi_callback_info = Pointer<unknown>
|
||||||
|
export declare type napi_callback = FunctionPointer<(env: napi_env, info: napi_callback_info) => napi_value>
|
||||||
|
|
||||||
|
export declare interface napi_extended_error_info {
|
||||||
|
error_message: const_char_p
|
||||||
|
engine_reserved: void_p
|
||||||
|
engine_error_code: uint32_t
|
||||||
|
error_code: napi_status
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare interface napi_property_descriptor {
|
||||||
|
// One of utf8name or name should be NULL.
|
||||||
|
utf8name: const_char_p
|
||||||
|
name: napi_value
|
||||||
|
|
||||||
|
method: napi_callback
|
||||||
|
getter: napi_callback
|
||||||
|
setter: napi_callback
|
||||||
|
value: napi_value
|
||||||
|
/* napi_property_attributes */
|
||||||
|
attributes: number
|
||||||
|
data: void_p
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare type napi_finalize = FunctionPointer<(
|
||||||
|
env: napi_env,
|
||||||
|
finalize_data: void_p,
|
||||||
|
finalize_hint: void_p
|
||||||
|
) => void>
|
||||||
|
|
||||||
|
export declare interface node_module {
|
||||||
|
nm_version: int32_t
|
||||||
|
nm_flags: uint32_t
|
||||||
|
nm_filename: Pointer<const_char>
|
||||||
|
nm_register_func: napi_addon_register_func
|
||||||
|
nm_modname: Pointer<const_char>
|
||||||
|
nm_priv: Pointer<void>
|
||||||
|
reserved: PointerPointer<void>
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare interface napi_node_version {
|
||||||
|
major: uint32_t
|
||||||
|
minor: uint32_t
|
||||||
|
patch: uint32_t
|
||||||
|
release: const_char_p
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare interface emnapi_emscripten_version {
|
||||||
|
major: uint32_t
|
||||||
|
minor: uint32_t
|
||||||
|
patch: uint32_t
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare const enum napi_status {
|
||||||
|
napi_ok,
|
||||||
|
napi_invalid_arg,
|
||||||
|
napi_object_expected,
|
||||||
|
napi_string_expected,
|
||||||
|
napi_name_expected,
|
||||||
|
napi_function_expected,
|
||||||
|
napi_number_expected,
|
||||||
|
napi_boolean_expected,
|
||||||
|
napi_array_expected,
|
||||||
|
napi_generic_failure,
|
||||||
|
napi_pending_exception,
|
||||||
|
napi_cancelled,
|
||||||
|
napi_escape_called_twice,
|
||||||
|
napi_handle_scope_mismatch,
|
||||||
|
napi_callback_scope_mismatch,
|
||||||
|
napi_queue_full,
|
||||||
|
napi_closing,
|
||||||
|
napi_bigint_expected,
|
||||||
|
napi_date_expected,
|
||||||
|
napi_arraybuffer_expected,
|
||||||
|
napi_detachable_arraybuffer_expected,
|
||||||
|
napi_would_deadlock, // unused
|
||||||
|
napi_no_external_buffers_allowed,
|
||||||
|
napi_cannot_run_js
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare const enum napi_property_attributes {
|
||||||
|
napi_default = 0,
|
||||||
|
napi_writable = 1 << 0,
|
||||||
|
napi_enumerable = 1 << 1,
|
||||||
|
napi_configurable = 1 << 2,
|
||||||
|
|
||||||
|
// Used with napi_define_class to distinguish static properties
|
||||||
|
// from instance properties. Ignored by napi_define_properties.
|
||||||
|
napi_static = 1 << 10,
|
||||||
|
|
||||||
|
/// #ifdef NAPI_EXPERIMENTAL
|
||||||
|
// Default for class methods.
|
||||||
|
napi_default_method = napi_writable | napi_configurable,
|
||||||
|
|
||||||
|
// Default for object properties, like in JS obj[prop].
|
||||||
|
napi_default_jsproperty = napi_writable | napi_enumerable | napi_configurable
|
||||||
|
/// #endif // NAPI_EXPERIMENTAL
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare const enum napi_valuetype {
|
||||||
|
napi_undefined,
|
||||||
|
napi_null,
|
||||||
|
napi_boolean,
|
||||||
|
napi_number,
|
||||||
|
napi_string,
|
||||||
|
napi_symbol,
|
||||||
|
napi_object,
|
||||||
|
napi_function,
|
||||||
|
napi_external,
|
||||||
|
napi_bigint
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare const enum napi_typedarray_type {
|
||||||
|
napi_int8_array,
|
||||||
|
napi_uint8_array,
|
||||||
|
napi_uint8_clamped_array,
|
||||||
|
napi_int16_array,
|
||||||
|
napi_uint16_array,
|
||||||
|
napi_int32_array,
|
||||||
|
napi_uint32_array,
|
||||||
|
napi_float32_array,
|
||||||
|
napi_float64_array,
|
||||||
|
napi_bigint64_array,
|
||||||
|
napi_biguint64_array,
|
||||||
|
napi_float16_array,
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare const enum napi_key_collection_mode {
|
||||||
|
napi_key_include_prototypes,
|
||||||
|
napi_key_own_only
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare const enum napi_key_filter {
|
||||||
|
napi_key_all_properties = 0,
|
||||||
|
napi_key_writable = 1,
|
||||||
|
napi_key_enumerable = 1 << 1,
|
||||||
|
napi_key_configurable = 1 << 2,
|
||||||
|
napi_key_skip_strings = 1 << 3,
|
||||||
|
napi_key_skip_symbols = 1 << 4
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare const enum napi_key_conversion {
|
||||||
|
napi_key_keep_numbers,
|
||||||
|
napi_key_numbers_to_strings
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare const enum emnapi_memory_view_type {
|
||||||
|
emnapi_int8_array,
|
||||||
|
emnapi_uint8_array,
|
||||||
|
emnapi_uint8_clamped_array,
|
||||||
|
emnapi_int16_array,
|
||||||
|
emnapi_uint16_array,
|
||||||
|
emnapi_int32_array,
|
||||||
|
emnapi_uint32_array,
|
||||||
|
emnapi_float32_array,
|
||||||
|
emnapi_float64_array,
|
||||||
|
emnapi_bigint64_array,
|
||||||
|
emnapi_biguint64_array,
|
||||||
|
emnapi_float16_array,
|
||||||
|
emnapi_data_view = -1,
|
||||||
|
emnapi_buffer = -2
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare const enum napi_threadsafe_function_call_mode {
|
||||||
|
napi_tsfn_nonblocking,
|
||||||
|
napi_tsfn_blocking
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare const enum napi_threadsafe_function_release_mode {
|
||||||
|
napi_tsfn_release,
|
||||||
|
napi_tsfn_abort
|
||||||
|
}
|
||||||
|
export declare type CleanupHookCallbackFunction = number | ((arg: number) => void);
|
||||||
|
|
||||||
|
export declare class ConstHandle<S extends undefined | null | boolean | typeof globalThis> extends Handle<S> {
|
||||||
|
constructor(id: number, value: S);
|
||||||
|
dispose(): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare class Context {
|
||||||
|
private _isStopping;
|
||||||
|
private _canCallIntoJs;
|
||||||
|
private _suppressDestroy;
|
||||||
|
envStore: Store<Env>;
|
||||||
|
scopeStore: ScopeStore;
|
||||||
|
refStore: Store<Reference>;
|
||||||
|
deferredStore: Store<Deferred<any>>;
|
||||||
|
handleStore: HandleStore;
|
||||||
|
private readonly refCounter?;
|
||||||
|
private readonly cleanupQueue;
|
||||||
|
private readonly _externalMemory;
|
||||||
|
feature: {
|
||||||
|
supportReflect: boolean;
|
||||||
|
supportFinalizer: boolean;
|
||||||
|
supportWeakSymbol: boolean;
|
||||||
|
supportBigInt: boolean;
|
||||||
|
supportNewFunction: boolean;
|
||||||
|
canSetFunctionName: boolean;
|
||||||
|
setImmediate: (callback: () => void) => void;
|
||||||
|
Buffer: BufferCtor | undefined;
|
||||||
|
MessageChannel: {
|
||||||
|
new (): MessageChannel;
|
||||||
|
prototype: MessageChannel;
|
||||||
|
} | undefined;
|
||||||
|
};
|
||||||
|
constructor(options?: ContextOptions);
|
||||||
|
/**
|
||||||
|
* Suppress the destroy on `beforeExit` event in Node.js.
|
||||||
|
* Call this method if you want to keep the context and
|
||||||
|
* all associated {@link Env | Env} alive,
|
||||||
|
* this also means that cleanup hooks will not be called.
|
||||||
|
* After call this method, you should call
|
||||||
|
* {@link Context.destroy | `Context.prototype.destroy`} method manually.
|
||||||
|
*/
|
||||||
|
suppressDestroy(): void;
|
||||||
|
getRuntimeVersions(): {
|
||||||
|
version: string;
|
||||||
|
NODE_API_SUPPORTED_VERSION_MAX: Version;
|
||||||
|
NAPI_VERSION_EXPERIMENTAL: Version;
|
||||||
|
NODE_API_DEFAULT_MODULE_API_VERSION: Version;
|
||||||
|
};
|
||||||
|
createNotSupportWeakRefError(api: string, message: string): NotSupportWeakRefError;
|
||||||
|
createNotSupportBufferError(api: string, message: string): NotSupportBufferError;
|
||||||
|
createReference(envObject: Env, handle_id: napi_value, initialRefcount: uint32_t, ownership: ReferenceOwnership): Reference;
|
||||||
|
createReferenceWithData(envObject: Env, handle_id: napi_value, initialRefcount: uint32_t, ownership: ReferenceOwnership, data: void_p): Reference;
|
||||||
|
createReferenceWithFinalizer(envObject: Env, handle_id: napi_value, initialRefcount: uint32_t, ownership: ReferenceOwnership, finalize_callback?: napi_finalize, finalize_data?: void_p, finalize_hint?: void_p): Reference;
|
||||||
|
createDeferred<T = any>(value: IDeferrdValue<T>): Deferred<T>;
|
||||||
|
adjustAmountOfExternalAllocatedMemory(changeInBytes: number | bigint): bigint;
|
||||||
|
createEnv(filename: string, moduleApiVersion: number, makeDynCall_vppp: (cb: Ptr) => (a: Ptr, b: Ptr, c: Ptr) => void, makeDynCall_vp: (cb: Ptr) => (a: Ptr) => void, abort: (msg?: string) => never, nodeBinding?: any): Env;
|
||||||
|
createTrackedFinalizer(envObject: Env, finalize_callback: napi_finalize, finalize_data: void_p, finalize_hint: void_p): TrackedFinalizer;
|
||||||
|
getCurrentScope(): HandleScope | null;
|
||||||
|
addToCurrentScope<V>(value: V): Handle<V>;
|
||||||
|
openScope(envObject?: Env): HandleScope;
|
||||||
|
closeScope(envObject?: Env, _scope?: HandleScope): void;
|
||||||
|
ensureHandle<S>(value: S): Handle<S>;
|
||||||
|
addCleanupHook(envObject: Env, fn: CleanupHookCallbackFunction, arg: number): void;
|
||||||
|
removeCleanupHook(envObject: Env, fn: CleanupHookCallbackFunction, arg: number): void;
|
||||||
|
runCleanup(): void;
|
||||||
|
increaseWaitingRequestCounter(): void;
|
||||||
|
decreaseWaitingRequestCounter(): void;
|
||||||
|
setCanCallIntoJs(value: boolean): void;
|
||||||
|
setStopping(value: boolean): void;
|
||||||
|
canCallIntoJs(): boolean;
|
||||||
|
/**
|
||||||
|
* Destroy the context and call cleanup hooks.
|
||||||
|
* Associated {@link Env | Env} will be destroyed.
|
||||||
|
*/
|
||||||
|
destroy(): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare interface ContextOptions {
|
||||||
|
onExternalMemoryChange?: (current: bigint, old: bigint, delta: bigint) => any;
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare function createContext(options?: ContextOptions): Context;
|
||||||
|
|
||||||
|
export declare class Deferred<T = any> implements IStoreValue {
|
||||||
|
static create<T = any>(ctx: Context, value: IDeferrdValue<T>): Deferred;
|
||||||
|
id: number;
|
||||||
|
ctx: Context;
|
||||||
|
value: IDeferrdValue<T>;
|
||||||
|
constructor(ctx: Context, value: IDeferrdValue<T>);
|
||||||
|
resolve(value: T): void;
|
||||||
|
reject(reason?: any): void;
|
||||||
|
dispose(): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare class EmnapiError extends Error {
|
||||||
|
constructor(message?: string);
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare abstract class Env implements IStoreValue {
|
||||||
|
readonly ctx: Context;
|
||||||
|
moduleApiVersion: number;
|
||||||
|
makeDynCall_vppp: (cb: Ptr) => (a: Ptr, b: Ptr, c: Ptr) => void;
|
||||||
|
makeDynCall_vp: (cb: Ptr) => (a: Ptr) => void;
|
||||||
|
abort: (msg?: string) => never;
|
||||||
|
id: number;
|
||||||
|
openHandleScopes: number;
|
||||||
|
instanceData: TrackedFinalizer | null;
|
||||||
|
tryCatch: TryCatch;
|
||||||
|
refs: number;
|
||||||
|
reflist: RefTracker;
|
||||||
|
finalizing_reflist: RefTracker;
|
||||||
|
pendingFinalizers: RefTracker[];
|
||||||
|
lastError: {
|
||||||
|
errorCode: napi_status;
|
||||||
|
engineErrorCode: number;
|
||||||
|
engineReserved: Ptr;
|
||||||
|
};
|
||||||
|
inGcFinalizer: boolean;
|
||||||
|
constructor(ctx: Context, moduleApiVersion: number, makeDynCall_vppp: (cb: Ptr) => (a: Ptr, b: Ptr, c: Ptr) => void, makeDynCall_vp: (cb: Ptr) => (a: Ptr) => void, abort: (msg?: string) => never);
|
||||||
|
/** @virtual */
|
||||||
|
canCallIntoJs(): boolean;
|
||||||
|
terminatedOrTerminating(): boolean;
|
||||||
|
ref(): void;
|
||||||
|
unref(): void;
|
||||||
|
ensureHandle<S>(value: S): Handle<S>;
|
||||||
|
ensureHandleId(value: any): napi_value;
|
||||||
|
clearLastError(): napi_status;
|
||||||
|
setLastError(error_code: napi_status, engine_error_code?: uint32_t, engine_reserved?: void_p): napi_status;
|
||||||
|
getReturnStatus(): napi_status;
|
||||||
|
callIntoModule<T>(fn: (env: Env) => T, handleException?: (envObject: Env, value: any) => void): T;
|
||||||
|
/** @virtual */
|
||||||
|
abstract callFinalizer(cb: napi_finalize, data: void_p, hint: void_p): void;
|
||||||
|
invokeFinalizerFromGC(finalizer: RefTracker): void;
|
||||||
|
checkGCAccess(): void;
|
||||||
|
/** @virtual */
|
||||||
|
enqueueFinalizer(finalizer: RefTracker): void;
|
||||||
|
/** @virtual */
|
||||||
|
dequeueFinalizer(finalizer: RefTracker): void;
|
||||||
|
/** @virtual */
|
||||||
|
deleteMe(): void;
|
||||||
|
dispose(): void;
|
||||||
|
private readonly _bindingMap;
|
||||||
|
initObjectBinding<S extends object>(value: S): IReferenceBinding;
|
||||||
|
getObjectBinding<S extends object>(value: S): IReferenceBinding;
|
||||||
|
setInstanceData(data: number, finalize_cb: number, finalize_hint: number): void;
|
||||||
|
getInstanceData(): number;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @public */
|
||||||
|
declare interface External_2 extends Record<any, any> {
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @public */
|
||||||
|
declare const External_2: {
|
||||||
|
new (value: number | bigint): External_2;
|
||||||
|
prototype: null;
|
||||||
|
};
|
||||||
|
export { External_2 as External }
|
||||||
|
|
||||||
|
export declare class Finalizer {
|
||||||
|
envObject: Env;
|
||||||
|
private _finalizeCallback;
|
||||||
|
private _finalizeData;
|
||||||
|
private _finalizeHint;
|
||||||
|
private _makeDynCall_vppp;
|
||||||
|
constructor(envObject: Env, _finalizeCallback?: napi_finalize, _finalizeData?: void_p, _finalizeHint?: void_p);
|
||||||
|
callback(): napi_finalize;
|
||||||
|
data(): void_p;
|
||||||
|
hint(): void_p;
|
||||||
|
resetEnv(): void;
|
||||||
|
resetFinalizer(): void;
|
||||||
|
callFinalizer(): void;
|
||||||
|
dispose(): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare function getDefaultContext(): Context;
|
||||||
|
|
||||||
|
/** @public */
|
||||||
|
export declare function getExternalValue(external: External_2): number | bigint;
|
||||||
|
|
||||||
|
export declare class Handle<S> {
|
||||||
|
id: number;
|
||||||
|
value: S;
|
||||||
|
constructor(id: number, value: S);
|
||||||
|
data(): void_p;
|
||||||
|
isNumber(): boolean;
|
||||||
|
isBigInt(): boolean;
|
||||||
|
isString(): boolean;
|
||||||
|
isFunction(): boolean;
|
||||||
|
isExternal(): boolean;
|
||||||
|
isObject(): boolean;
|
||||||
|
isArray(): boolean;
|
||||||
|
isArrayBuffer(): boolean;
|
||||||
|
isTypedArray(): boolean;
|
||||||
|
isBuffer(BufferConstructor?: BufferCtor): boolean;
|
||||||
|
isDataView(): boolean;
|
||||||
|
isDate(): boolean;
|
||||||
|
isPromise(): boolean;
|
||||||
|
isBoolean(): boolean;
|
||||||
|
isUndefined(): boolean;
|
||||||
|
isSymbol(): boolean;
|
||||||
|
isNull(): boolean;
|
||||||
|
dispose(): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare class HandleScope {
|
||||||
|
handleStore: HandleStore;
|
||||||
|
id: number;
|
||||||
|
parent: HandleScope | null;
|
||||||
|
child: HandleScope | null;
|
||||||
|
start: number;
|
||||||
|
end: number;
|
||||||
|
private _escapeCalled;
|
||||||
|
callbackInfo: ICallbackInfo;
|
||||||
|
constructor(handleStore: HandleStore, id: number, parentScope: HandleScope | null, start: number, end?: number);
|
||||||
|
add<V>(value: V): Handle<V>;
|
||||||
|
addExternal(data: void_p): Handle<object>;
|
||||||
|
dispose(): void;
|
||||||
|
escape(handle: number): Handle<any> | null;
|
||||||
|
escapeCalled(): boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare class HandleStore {
|
||||||
|
static UNDEFINED: ConstHandle<undefined>;
|
||||||
|
static NULL: ConstHandle<null>;
|
||||||
|
static FALSE: ConstHandle<false>;
|
||||||
|
static TRUE: ConstHandle<true>;
|
||||||
|
static GLOBAL: ConstHandle<typeof globalThis>;
|
||||||
|
static MIN_ID: 6;
|
||||||
|
private readonly _values;
|
||||||
|
private _next;
|
||||||
|
push<S>(value: S): Handle<S>;
|
||||||
|
erase(start: number, end: number): void;
|
||||||
|
get(id: Ptr): Handle<any> | undefined;
|
||||||
|
swap(a: number, b: number): void;
|
||||||
|
dispose(): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare interface ICallbackInfo {
|
||||||
|
thiz: any;
|
||||||
|
data: void_p;
|
||||||
|
args: ArrayLike<any>;
|
||||||
|
fn: Function;
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare interface IDeferrdValue<T = any> {
|
||||||
|
resolve: (value: T) => void;
|
||||||
|
reject: (reason?: any) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare interface IReferenceBinding {
|
||||||
|
wrapped: number;
|
||||||
|
tag: Uint32Array | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @public */
|
||||||
|
export declare function isExternal(object: unknown): object is External_2;
|
||||||
|
|
||||||
|
export declare function isReferenceType(v: any): v is object;
|
||||||
|
|
||||||
|
export declare interface IStoreValue {
|
||||||
|
id: number;
|
||||||
|
dispose(): void;
|
||||||
|
[x: string]: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare const NAPI_VERSION_EXPERIMENTAL = Version.NAPI_VERSION_EXPERIMENTAL;
|
||||||
|
|
||||||
|
export declare const NODE_API_DEFAULT_MODULE_API_VERSION = Version.NODE_API_DEFAULT_MODULE_API_VERSION;
|
||||||
|
|
||||||
|
export declare const NODE_API_SUPPORTED_VERSION_MAX = Version.NODE_API_SUPPORTED_VERSION_MAX;
|
||||||
|
|
||||||
|
export declare const NODE_API_SUPPORTED_VERSION_MIN = Version.NODE_API_SUPPORTED_VERSION_MIN;
|
||||||
|
|
||||||
|
export declare class NodeEnv extends Env {
|
||||||
|
filename: string;
|
||||||
|
private readonly nodeBinding?;
|
||||||
|
destructing: boolean;
|
||||||
|
finalizationScheduled: boolean;
|
||||||
|
constructor(ctx: Context, filename: string, moduleApiVersion: number, makeDynCall_vppp: (cb: Ptr) => (a: Ptr, b: Ptr, c: Ptr) => void, makeDynCall_vp: (cb: Ptr) => (a: Ptr) => void, abort: (msg?: string) => never, nodeBinding?: any);
|
||||||
|
deleteMe(): void;
|
||||||
|
canCallIntoJs(): boolean;
|
||||||
|
triggerFatalException(err: any): void;
|
||||||
|
callbackIntoModule<T>(enforceUncaughtExceptionPolicy: boolean, fn: (env: Env) => T): T;
|
||||||
|
callFinalizer(cb: napi_finalize, data: void_p, hint: void_p): void;
|
||||||
|
callFinalizerInternal(forceUncaught: int, cb: napi_finalize, data: void_p, hint: void_p): void;
|
||||||
|
enqueueFinalizer(finalizer: RefTracker): void;
|
||||||
|
drainFinalizerQueue(): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare class NotSupportBufferError extends EmnapiError {
|
||||||
|
constructor(api: string, message: string);
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare class NotSupportWeakRefError extends EmnapiError {
|
||||||
|
constructor(api: string, message: string);
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare class Persistent<T> {
|
||||||
|
private _ref;
|
||||||
|
private _param;
|
||||||
|
private _callback;
|
||||||
|
private static readonly _registry;
|
||||||
|
constructor(value: T);
|
||||||
|
setWeak<P>(param: P, callback: (param: P) => void): void;
|
||||||
|
clearWeak(): void;
|
||||||
|
reset(): void;
|
||||||
|
isEmpty(): boolean;
|
||||||
|
deref(): T | undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare class Reference extends RefTracker implements IStoreValue {
|
||||||
|
private static weakCallback;
|
||||||
|
id: number;
|
||||||
|
envObject: Env;
|
||||||
|
private readonly canBeWeak;
|
||||||
|
private _refcount;
|
||||||
|
private readonly _ownership;
|
||||||
|
persistent: Persistent<object>;
|
||||||
|
static create(envObject: Env, handle_id: napi_value, initialRefcount: uint32_t, ownership: ReferenceOwnership, _unused1?: void_p, _unused2?: void_p, _unused3?: void_p): Reference;
|
||||||
|
protected constructor(envObject: Env, handle_id: napi_value, initialRefcount: uint32_t, ownership: ReferenceOwnership);
|
||||||
|
ref(): number;
|
||||||
|
unref(): number;
|
||||||
|
get(envObject?: Env): napi_value;
|
||||||
|
/** @virtual */
|
||||||
|
resetFinalizer(): void;
|
||||||
|
/** @virtual */
|
||||||
|
data(): void_p;
|
||||||
|
refcount(): number;
|
||||||
|
ownership(): ReferenceOwnership;
|
||||||
|
/** @virtual */
|
||||||
|
protected callUserFinalizer(): void;
|
||||||
|
/** @virtual */
|
||||||
|
protected invokeFinalizerFromGC(): void;
|
||||||
|
private _setWeak;
|
||||||
|
finalize(): void;
|
||||||
|
dispose(): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare enum ReferenceOwnership {
|
||||||
|
kRuntime = 0,
|
||||||
|
kUserland = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare class ReferenceWithData extends Reference {
|
||||||
|
private readonly _data;
|
||||||
|
static create(envObject: Env, value: napi_value, initialRefcount: uint32_t, ownership: ReferenceOwnership, data: void_p): ReferenceWithData;
|
||||||
|
private constructor();
|
||||||
|
data(): void_p;
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare class ReferenceWithFinalizer extends Reference {
|
||||||
|
private _finalizer;
|
||||||
|
static create(envObject: Env, value: napi_value, initialRefcount: uint32_t, ownership: ReferenceOwnership, finalize_callback: napi_finalize, finalize_data: void_p, finalize_hint: void_p): ReferenceWithFinalizer;
|
||||||
|
private constructor();
|
||||||
|
resetFinalizer(): void;
|
||||||
|
data(): void_p;
|
||||||
|
protected callUserFinalizer(): void;
|
||||||
|
protected invokeFinalizerFromGC(): void;
|
||||||
|
dispose(): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare class RefTracker {
|
||||||
|
/** @virtual */
|
||||||
|
dispose(): void;
|
||||||
|
/** @virtual */
|
||||||
|
finalize(): void;
|
||||||
|
private _next;
|
||||||
|
private _prev;
|
||||||
|
link(list: RefTracker): void;
|
||||||
|
unlink(): void;
|
||||||
|
static finalizeAll(list: RefTracker): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare class ScopeStore {
|
||||||
|
private readonly _rootScope;
|
||||||
|
currentScope: HandleScope;
|
||||||
|
private readonly _values;
|
||||||
|
constructor();
|
||||||
|
get(id: number): HandleScope | undefined;
|
||||||
|
openScope(handleStore: HandleStore): HandleScope;
|
||||||
|
closeScope(): void;
|
||||||
|
dispose(): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare class Store<V extends IStoreValue> {
|
||||||
|
protected _values: Array<V | undefined>;
|
||||||
|
private _freeList;
|
||||||
|
private _size;
|
||||||
|
constructor();
|
||||||
|
add(value: V): void;
|
||||||
|
get(id: Ptr): V | undefined;
|
||||||
|
has(id: Ptr): boolean;
|
||||||
|
remove(id: Ptr): void;
|
||||||
|
dispose(): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare class TrackedFinalizer extends RefTracker {
|
||||||
|
private _finalizer;
|
||||||
|
static create(envObject: Env, finalize_callback: napi_finalize, finalize_data: void_p, finalize_hint: void_p): TrackedFinalizer;
|
||||||
|
private constructor();
|
||||||
|
data(): void_p;
|
||||||
|
dispose(): void;
|
||||||
|
finalize(): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare class TryCatch {
|
||||||
|
private _exception;
|
||||||
|
private _caught;
|
||||||
|
isEmpty(): boolean;
|
||||||
|
hasCaught(): boolean;
|
||||||
|
exception(): any;
|
||||||
|
setError(err: any): void;
|
||||||
|
reset(): void;
|
||||||
|
extractException(): any;
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare const version: string;
|
||||||
|
|
||||||
|
export { }
|
||||||
|
|
||||||
|
export as namespace emnapi;
|
||||||
+1457
File diff suppressed because it is too large
Load Diff
+426
@@ -0,0 +1,426 @@
|
|||||||
|
declare namespace emnapi {
|
||||||
|
|
||||||
|
export type CleanupHookCallbackFunction = number | ((arg: number) => void);
|
||||||
|
|
||||||
|
export class ConstHandle<S extends undefined | null | boolean | typeof globalThis> extends Handle<S> {
|
||||||
|
constructor(id: number, value: S);
|
||||||
|
dispose(): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class Context {
|
||||||
|
private _isStopping;
|
||||||
|
private _canCallIntoJs;
|
||||||
|
private _suppressDestroy;
|
||||||
|
envStore: Store<Env>;
|
||||||
|
scopeStore: ScopeStore;
|
||||||
|
refStore: Store<Reference>;
|
||||||
|
deferredStore: Store<Deferred<any>>;
|
||||||
|
handleStore: HandleStore;
|
||||||
|
private readonly refCounter?;
|
||||||
|
private readonly cleanupQueue;
|
||||||
|
private readonly _externalMemory;
|
||||||
|
feature: {
|
||||||
|
supportReflect: boolean;
|
||||||
|
supportFinalizer: boolean;
|
||||||
|
supportWeakSymbol: boolean;
|
||||||
|
supportBigInt: boolean;
|
||||||
|
supportNewFunction: boolean;
|
||||||
|
canSetFunctionName: boolean;
|
||||||
|
setImmediate: (callback: () => void) => void;
|
||||||
|
Buffer: BufferCtor | undefined;
|
||||||
|
MessageChannel: {
|
||||||
|
new (): MessageChannel;
|
||||||
|
prototype: MessageChannel;
|
||||||
|
} | undefined;
|
||||||
|
};
|
||||||
|
constructor(options?: ContextOptions);
|
||||||
|
/**
|
||||||
|
* Suppress the destroy on `beforeExit` event in Node.js.
|
||||||
|
* Call this method if you want to keep the context and
|
||||||
|
* all associated {@link Env | Env} alive,
|
||||||
|
* this also means that cleanup hooks will not be called.
|
||||||
|
* After call this method, you should call
|
||||||
|
* {@link Context.destroy | `Context.prototype.destroy`} method manually.
|
||||||
|
*/
|
||||||
|
suppressDestroy(): void;
|
||||||
|
getRuntimeVersions(): {
|
||||||
|
version: string;
|
||||||
|
NODE_API_SUPPORTED_VERSION_MAX: Version;
|
||||||
|
NAPI_VERSION_EXPERIMENTAL: Version;
|
||||||
|
NODE_API_DEFAULT_MODULE_API_VERSION: Version;
|
||||||
|
};
|
||||||
|
createNotSupportWeakRefError(api: string, message: string): NotSupportWeakRefError;
|
||||||
|
createNotSupportBufferError(api: string, message: string): NotSupportBufferError;
|
||||||
|
createReference(envObject: Env, handle_id: napi_value, initialRefcount: uint32_t, ownership: ReferenceOwnership): Reference;
|
||||||
|
createReferenceWithData(envObject: Env, handle_id: napi_value, initialRefcount: uint32_t, ownership: ReferenceOwnership, data: void_p): Reference;
|
||||||
|
createReferenceWithFinalizer(envObject: Env, handle_id: napi_value, initialRefcount: uint32_t, ownership: ReferenceOwnership, finalize_callback?: napi_finalize, finalize_data?: void_p, finalize_hint?: void_p): Reference;
|
||||||
|
createDeferred<T = any>(value: IDeferrdValue<T>): Deferred<T>;
|
||||||
|
adjustAmountOfExternalAllocatedMemory(changeInBytes: number | bigint): bigint;
|
||||||
|
createEnv(filename: string, moduleApiVersion: number, makeDynCall_vppp: (cb: Ptr) => (a: Ptr, b: Ptr, c: Ptr) => void, makeDynCall_vp: (cb: Ptr) => (a: Ptr) => void, abort: (msg?: string) => never, nodeBinding?: any): Env;
|
||||||
|
createTrackedFinalizer(envObject: Env, finalize_callback: napi_finalize, finalize_data: void_p, finalize_hint: void_p): TrackedFinalizer;
|
||||||
|
getCurrentScope(): HandleScope | null;
|
||||||
|
addToCurrentScope<V>(value: V): Handle<V>;
|
||||||
|
openScope(envObject?: Env): HandleScope;
|
||||||
|
closeScope(envObject?: Env, _scope?: HandleScope): void;
|
||||||
|
ensureHandle<S>(value: S): Handle<S>;
|
||||||
|
addCleanupHook(envObject: Env, fn: CleanupHookCallbackFunction, arg: number): void;
|
||||||
|
removeCleanupHook(envObject: Env, fn: CleanupHookCallbackFunction, arg: number): void;
|
||||||
|
runCleanup(): void;
|
||||||
|
increaseWaitingRequestCounter(): void;
|
||||||
|
decreaseWaitingRequestCounter(): void;
|
||||||
|
setCanCallIntoJs(value: boolean): void;
|
||||||
|
setStopping(value: boolean): void;
|
||||||
|
canCallIntoJs(): boolean;
|
||||||
|
/**
|
||||||
|
* Destroy the context and call cleanup hooks.
|
||||||
|
* Associated {@link Env | Env} will be destroyed.
|
||||||
|
*/
|
||||||
|
destroy(): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ContextOptions {
|
||||||
|
onExternalMemoryChange?: (current: bigint, old: bigint, delta: bigint) => any;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function createContext(options?: ContextOptions): Context;
|
||||||
|
|
||||||
|
export class Deferred<T = any> implements IStoreValue {
|
||||||
|
static create<T = any>(ctx: Context, value: IDeferrdValue<T>): Deferred;
|
||||||
|
id: number;
|
||||||
|
ctx: Context;
|
||||||
|
value: IDeferrdValue<T>;
|
||||||
|
constructor(ctx: Context, value: IDeferrdValue<T>);
|
||||||
|
resolve(value: T): void;
|
||||||
|
reject(reason?: any): void;
|
||||||
|
dispose(): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class EmnapiError extends Error {
|
||||||
|
constructor(message?: string);
|
||||||
|
}
|
||||||
|
|
||||||
|
export abstract class Env implements IStoreValue {
|
||||||
|
readonly ctx: Context;
|
||||||
|
moduleApiVersion: number;
|
||||||
|
makeDynCall_vppp: (cb: Ptr) => (a: Ptr, b: Ptr, c: Ptr) => void;
|
||||||
|
makeDynCall_vp: (cb: Ptr) => (a: Ptr) => void;
|
||||||
|
abort: (msg?: string) => never;
|
||||||
|
id: number;
|
||||||
|
openHandleScopes: number;
|
||||||
|
instanceData: TrackedFinalizer | null;
|
||||||
|
tryCatch: TryCatch;
|
||||||
|
refs: number;
|
||||||
|
reflist: RefTracker;
|
||||||
|
finalizing_reflist: RefTracker;
|
||||||
|
pendingFinalizers: RefTracker[];
|
||||||
|
lastError: {
|
||||||
|
errorCode: napi_status;
|
||||||
|
engineErrorCode: number;
|
||||||
|
engineReserved: Ptr;
|
||||||
|
};
|
||||||
|
inGcFinalizer: boolean;
|
||||||
|
constructor(ctx: Context, moduleApiVersion: number, makeDynCall_vppp: (cb: Ptr) => (a: Ptr, b: Ptr, c: Ptr) => void, makeDynCall_vp: (cb: Ptr) => (a: Ptr) => void, abort: (msg?: string) => never);
|
||||||
|
/** @virtual */
|
||||||
|
canCallIntoJs(): boolean;
|
||||||
|
terminatedOrTerminating(): boolean;
|
||||||
|
ref(): void;
|
||||||
|
unref(): void;
|
||||||
|
ensureHandle<S>(value: S): Handle<S>;
|
||||||
|
ensureHandleId(value: any): napi_value;
|
||||||
|
clearLastError(): napi_status;
|
||||||
|
setLastError(error_code: napi_status, engine_error_code?: uint32_t, engine_reserved?: void_p): napi_status;
|
||||||
|
getReturnStatus(): napi_status;
|
||||||
|
callIntoModule<T>(fn: (env: Env) => T, handleException?: (envObject: Env, value: any) => void): T;
|
||||||
|
/** @virtual */
|
||||||
|
abstract callFinalizer(cb: napi_finalize, data: void_p, hint: void_p): void;
|
||||||
|
invokeFinalizerFromGC(finalizer: RefTracker): void;
|
||||||
|
checkGCAccess(): void;
|
||||||
|
/** @virtual */
|
||||||
|
enqueueFinalizer(finalizer: RefTracker): void;
|
||||||
|
/** @virtual */
|
||||||
|
dequeueFinalizer(finalizer: RefTracker): void;
|
||||||
|
/** @virtual */
|
||||||
|
deleteMe(): void;
|
||||||
|
dispose(): void;
|
||||||
|
private readonly _bindingMap;
|
||||||
|
initObjectBinding<S extends object>(value: S): IReferenceBinding;
|
||||||
|
getObjectBinding<S extends object>(value: S): IReferenceBinding;
|
||||||
|
setInstanceData(data: number, finalize_cb: number, finalize_hint: number): void;
|
||||||
|
getInstanceData(): number;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @public */
|
||||||
|
interface External_2 extends Record<any, any> {
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @public */
|
||||||
|
const External_2: {
|
||||||
|
new (value: number | bigint): External_2;
|
||||||
|
prototype: null;
|
||||||
|
};
|
||||||
|
export { External_2 as External }
|
||||||
|
|
||||||
|
export class Finalizer {
|
||||||
|
envObject: Env;
|
||||||
|
private _finalizeCallback;
|
||||||
|
private _finalizeData;
|
||||||
|
private _finalizeHint;
|
||||||
|
private _makeDynCall_vppp;
|
||||||
|
constructor(envObject: Env, _finalizeCallback?: napi_finalize, _finalizeData?: void_p, _finalizeHint?: void_p);
|
||||||
|
callback(): napi_finalize;
|
||||||
|
data(): void_p;
|
||||||
|
hint(): void_p;
|
||||||
|
resetEnv(): void;
|
||||||
|
resetFinalizer(): void;
|
||||||
|
callFinalizer(): void;
|
||||||
|
dispose(): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getDefaultContext(): Context;
|
||||||
|
|
||||||
|
/** @public */
|
||||||
|
export function getExternalValue(external: External_2): number | bigint;
|
||||||
|
|
||||||
|
export class Handle<S> {
|
||||||
|
id: number;
|
||||||
|
value: S;
|
||||||
|
constructor(id: number, value: S);
|
||||||
|
data(): void_p;
|
||||||
|
isNumber(): boolean;
|
||||||
|
isBigInt(): boolean;
|
||||||
|
isString(): boolean;
|
||||||
|
isFunction(): boolean;
|
||||||
|
isExternal(): boolean;
|
||||||
|
isObject(): boolean;
|
||||||
|
isArray(): boolean;
|
||||||
|
isArrayBuffer(): boolean;
|
||||||
|
isTypedArray(): boolean;
|
||||||
|
isBuffer(BufferConstructor?: BufferCtor): boolean;
|
||||||
|
isDataView(): boolean;
|
||||||
|
isDate(): boolean;
|
||||||
|
isPromise(): boolean;
|
||||||
|
isBoolean(): boolean;
|
||||||
|
isUndefined(): boolean;
|
||||||
|
isSymbol(): boolean;
|
||||||
|
isNull(): boolean;
|
||||||
|
dispose(): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class HandleScope {
|
||||||
|
handleStore: HandleStore;
|
||||||
|
id: number;
|
||||||
|
parent: HandleScope | null;
|
||||||
|
child: HandleScope | null;
|
||||||
|
start: number;
|
||||||
|
end: number;
|
||||||
|
private _escapeCalled;
|
||||||
|
callbackInfo: ICallbackInfo;
|
||||||
|
constructor(handleStore: HandleStore, id: number, parentScope: HandleScope | null, start: number, end?: number);
|
||||||
|
add<V>(value: V): Handle<V>;
|
||||||
|
addExternal(data: void_p): Handle<object>;
|
||||||
|
dispose(): void;
|
||||||
|
escape(handle: number): Handle<any> | null;
|
||||||
|
escapeCalled(): boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class HandleStore {
|
||||||
|
static UNDEFINED: ConstHandle<undefined>;
|
||||||
|
static NULL: ConstHandle<null>;
|
||||||
|
static FALSE: ConstHandle<false>;
|
||||||
|
static TRUE: ConstHandle<true>;
|
||||||
|
static GLOBAL: ConstHandle<typeof globalThis>;
|
||||||
|
static MIN_ID: 6;
|
||||||
|
private readonly _values;
|
||||||
|
private _next;
|
||||||
|
push<S>(value: S): Handle<S>;
|
||||||
|
erase(start: number, end: number): void;
|
||||||
|
get(id: Ptr): Handle<any> | undefined;
|
||||||
|
swap(a: number, b: number): void;
|
||||||
|
dispose(): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ICallbackInfo {
|
||||||
|
thiz: any;
|
||||||
|
data: void_p;
|
||||||
|
args: ArrayLike<any>;
|
||||||
|
fn: Function;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IDeferrdValue<T = any> {
|
||||||
|
resolve: (value: T) => void;
|
||||||
|
reject: (reason?: any) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IReferenceBinding {
|
||||||
|
wrapped: number;
|
||||||
|
tag: Uint32Array | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @public */
|
||||||
|
export function isExternal(object: unknown): object is External_2;
|
||||||
|
|
||||||
|
export function isReferenceType(v: any): v is object;
|
||||||
|
|
||||||
|
export interface IStoreValue {
|
||||||
|
id: number;
|
||||||
|
dispose(): void;
|
||||||
|
[x: string]: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const NAPI_VERSION_EXPERIMENTAL = Version.NAPI_VERSION_EXPERIMENTAL;
|
||||||
|
|
||||||
|
export const NODE_API_DEFAULT_MODULE_API_VERSION = Version.NODE_API_DEFAULT_MODULE_API_VERSION;
|
||||||
|
|
||||||
|
export const NODE_API_SUPPORTED_VERSION_MAX = Version.NODE_API_SUPPORTED_VERSION_MAX;
|
||||||
|
|
||||||
|
export const NODE_API_SUPPORTED_VERSION_MIN = Version.NODE_API_SUPPORTED_VERSION_MIN;
|
||||||
|
|
||||||
|
export class NodeEnv extends Env {
|
||||||
|
filename: string;
|
||||||
|
private readonly nodeBinding?;
|
||||||
|
destructing: boolean;
|
||||||
|
finalizationScheduled: boolean;
|
||||||
|
constructor(ctx: Context, filename: string, moduleApiVersion: number, makeDynCall_vppp: (cb: Ptr) => (a: Ptr, b: Ptr, c: Ptr) => void, makeDynCall_vp: (cb: Ptr) => (a: Ptr) => void, abort: (msg?: string) => never, nodeBinding?: any);
|
||||||
|
deleteMe(): void;
|
||||||
|
canCallIntoJs(): boolean;
|
||||||
|
triggerFatalException(err: any): void;
|
||||||
|
callbackIntoModule<T>(enforceUncaughtExceptionPolicy: boolean, fn: (env: Env) => T): T;
|
||||||
|
callFinalizer(cb: napi_finalize, data: void_p, hint: void_p): void;
|
||||||
|
callFinalizerInternal(forceUncaught: int, cb: napi_finalize, data: void_p, hint: void_p): void;
|
||||||
|
enqueueFinalizer(finalizer: RefTracker): void;
|
||||||
|
drainFinalizerQueue(): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class NotSupportBufferError extends EmnapiError {
|
||||||
|
constructor(api: string, message: string);
|
||||||
|
}
|
||||||
|
|
||||||
|
export class NotSupportWeakRefError extends EmnapiError {
|
||||||
|
constructor(api: string, message: string);
|
||||||
|
}
|
||||||
|
|
||||||
|
export class Persistent<T> {
|
||||||
|
private _ref;
|
||||||
|
private _param;
|
||||||
|
private _callback;
|
||||||
|
private static readonly _registry;
|
||||||
|
constructor(value: T);
|
||||||
|
setWeak<P>(param: P, callback: (param: P) => void): void;
|
||||||
|
clearWeak(): void;
|
||||||
|
reset(): void;
|
||||||
|
isEmpty(): boolean;
|
||||||
|
deref(): T | undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class Reference extends RefTracker implements IStoreValue {
|
||||||
|
private static weakCallback;
|
||||||
|
id: number;
|
||||||
|
envObject: Env;
|
||||||
|
private readonly canBeWeak;
|
||||||
|
private _refcount;
|
||||||
|
private readonly _ownership;
|
||||||
|
persistent: Persistent<object>;
|
||||||
|
static create(envObject: Env, handle_id: napi_value, initialRefcount: uint32_t, ownership: ReferenceOwnership, _unused1?: void_p, _unused2?: void_p, _unused3?: void_p): Reference;
|
||||||
|
protected constructor(envObject: Env, handle_id: napi_value, initialRefcount: uint32_t, ownership: ReferenceOwnership);
|
||||||
|
ref(): number;
|
||||||
|
unref(): number;
|
||||||
|
get(envObject?: Env): napi_value;
|
||||||
|
/** @virtual */
|
||||||
|
resetFinalizer(): void;
|
||||||
|
/** @virtual */
|
||||||
|
data(): void_p;
|
||||||
|
refcount(): number;
|
||||||
|
ownership(): ReferenceOwnership;
|
||||||
|
/** @virtual */
|
||||||
|
protected callUserFinalizer(): void;
|
||||||
|
/** @virtual */
|
||||||
|
protected invokeFinalizerFromGC(): void;
|
||||||
|
private _setWeak;
|
||||||
|
finalize(): void;
|
||||||
|
dispose(): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export enum ReferenceOwnership {
|
||||||
|
kRuntime = 0,
|
||||||
|
kUserland = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
export class ReferenceWithData extends Reference {
|
||||||
|
private readonly _data;
|
||||||
|
static create(envObject: Env, value: napi_value, initialRefcount: uint32_t, ownership: ReferenceOwnership, data: void_p): ReferenceWithData;
|
||||||
|
private constructor();
|
||||||
|
data(): void_p;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class ReferenceWithFinalizer extends Reference {
|
||||||
|
private _finalizer;
|
||||||
|
static create(envObject: Env, value: napi_value, initialRefcount: uint32_t, ownership: ReferenceOwnership, finalize_callback: napi_finalize, finalize_data: void_p, finalize_hint: void_p): ReferenceWithFinalizer;
|
||||||
|
private constructor();
|
||||||
|
resetFinalizer(): void;
|
||||||
|
data(): void_p;
|
||||||
|
protected callUserFinalizer(): void;
|
||||||
|
protected invokeFinalizerFromGC(): void;
|
||||||
|
dispose(): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class RefTracker {
|
||||||
|
/** @virtual */
|
||||||
|
dispose(): void;
|
||||||
|
/** @virtual */
|
||||||
|
finalize(): void;
|
||||||
|
private _next;
|
||||||
|
private _prev;
|
||||||
|
link(list: RefTracker): void;
|
||||||
|
unlink(): void;
|
||||||
|
static finalizeAll(list: RefTracker): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class ScopeStore {
|
||||||
|
private readonly _rootScope;
|
||||||
|
currentScope: HandleScope;
|
||||||
|
private readonly _values;
|
||||||
|
constructor();
|
||||||
|
get(id: number): HandleScope | undefined;
|
||||||
|
openScope(handleStore: HandleStore): HandleScope;
|
||||||
|
closeScope(): void;
|
||||||
|
dispose(): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class Store<V extends IStoreValue> {
|
||||||
|
protected _values: Array<V | undefined>;
|
||||||
|
private _freeList;
|
||||||
|
private _size;
|
||||||
|
constructor();
|
||||||
|
add(value: V): void;
|
||||||
|
get(id: Ptr): V | undefined;
|
||||||
|
has(id: Ptr): boolean;
|
||||||
|
remove(id: Ptr): void;
|
||||||
|
dispose(): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class TrackedFinalizer extends RefTracker {
|
||||||
|
private _finalizer;
|
||||||
|
static create(envObject: Env, finalize_callback: napi_finalize, finalize_data: void_p, finalize_hint: void_p): TrackedFinalizer;
|
||||||
|
private constructor();
|
||||||
|
data(): void_p;
|
||||||
|
dispose(): void;
|
||||||
|
finalize(): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class TryCatch {
|
||||||
|
private _exception;
|
||||||
|
private _caught;
|
||||||
|
isEmpty(): boolean;
|
||||||
|
hasCaught(): boolean;
|
||||||
|
exception(): any;
|
||||||
|
setError(err: any): void;
|
||||||
|
reset(): void;
|
||||||
|
extractException(): any;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const version: string;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
+1528
File diff suppressed because it is too large
Load Diff
+1529
File diff suppressed because it is too large
Load Diff
+671
@@ -0,0 +1,671 @@
|
|||||||
|
export declare type Ptr = number | bigint
|
||||||
|
|
||||||
|
export declare interface IBuffer extends Uint8Array {}
|
||||||
|
export declare interface BufferCtor {
|
||||||
|
readonly prototype: IBuffer
|
||||||
|
/** @deprecated */
|
||||||
|
new (...args: any[]): IBuffer
|
||||||
|
from: {
|
||||||
|
(buffer: ArrayBufferLike): IBuffer
|
||||||
|
(buffer: ArrayBufferLike, byteOffset: number, length: number): IBuffer
|
||||||
|
}
|
||||||
|
alloc: (size: number) => IBuffer
|
||||||
|
isBuffer: (obj: unknown) => obj is IBuffer
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare const enum GlobalHandle {
|
||||||
|
UNDEFINED = 1,
|
||||||
|
NULL,
|
||||||
|
FALSE,
|
||||||
|
TRUE,
|
||||||
|
GLOBAL
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare const enum Version {
|
||||||
|
NODE_API_SUPPORTED_VERSION_MIN = 1,
|
||||||
|
NODE_API_DEFAULT_MODULE_API_VERSION = 8,
|
||||||
|
NODE_API_SUPPORTED_VERSION_MAX = 10,
|
||||||
|
NAPI_VERSION_EXPERIMENTAL = 2147483647 // INT_MAX
|
||||||
|
}
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
|
export declare type Pointer<T> = number
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
|
export declare type PointerPointer<T> = number
|
||||||
|
export declare type FunctionPointer<T extends (...args: any[]) => any> = Pointer<T>
|
||||||
|
export declare type Const<T> = T
|
||||||
|
|
||||||
|
export declare type void_p = Pointer<void>
|
||||||
|
export declare type void_pp = Pointer<void_p>
|
||||||
|
export declare type bool = number
|
||||||
|
export declare type char = number
|
||||||
|
export declare type char_p = Pointer<char>
|
||||||
|
export declare type unsigned_char = number
|
||||||
|
export declare type const_char = Const<char>
|
||||||
|
export declare type const_char_p = Pointer<const_char>
|
||||||
|
export declare type char16_t_p = number
|
||||||
|
export declare type const_char16_t_p = number
|
||||||
|
|
||||||
|
export declare type short = number
|
||||||
|
export declare type unsigned_short = number
|
||||||
|
export declare type int = number
|
||||||
|
export declare type unsigned_int = number
|
||||||
|
export declare type long = number
|
||||||
|
export declare type unsigned_long = number
|
||||||
|
export declare type long_long = bigint
|
||||||
|
export declare type unsigned_long_long = bigint
|
||||||
|
export declare type float = number
|
||||||
|
export declare type double = number
|
||||||
|
export declare type long_double = number
|
||||||
|
export declare type size_t = number
|
||||||
|
|
||||||
|
export declare type int8_t = number
|
||||||
|
export declare type uint8_t = number
|
||||||
|
export declare type int16_t = number
|
||||||
|
export declare type uint16_t = number
|
||||||
|
export declare type int32_t = number
|
||||||
|
export declare type uint32_t = number
|
||||||
|
export declare type int64_t = bigint
|
||||||
|
export declare type uint64_t = bigint
|
||||||
|
export declare type napi_env = Pointer<unknown>
|
||||||
|
|
||||||
|
export declare type napi_value = Pointer<unknown>
|
||||||
|
export declare type napi_ref = Pointer<unknown>
|
||||||
|
export declare type napi_deferred = Pointer<unknown>
|
||||||
|
export declare type napi_handle_scope = Pointer<unknown>
|
||||||
|
export declare type napi_escapable_handle_scope = Pointer<unknown>
|
||||||
|
|
||||||
|
export declare type napi_addon_register_func = FunctionPointer<(env: napi_env, exports: napi_value) => napi_value>
|
||||||
|
|
||||||
|
export declare type napi_callback_info = Pointer<unknown>
|
||||||
|
export declare type napi_callback = FunctionPointer<(env: napi_env, info: napi_callback_info) => napi_value>
|
||||||
|
|
||||||
|
export declare interface napi_extended_error_info {
|
||||||
|
error_message: const_char_p
|
||||||
|
engine_reserved: void_p
|
||||||
|
engine_error_code: uint32_t
|
||||||
|
error_code: napi_status
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare interface napi_property_descriptor {
|
||||||
|
// One of utf8name or name should be NULL.
|
||||||
|
utf8name: const_char_p
|
||||||
|
name: napi_value
|
||||||
|
|
||||||
|
method: napi_callback
|
||||||
|
getter: napi_callback
|
||||||
|
setter: napi_callback
|
||||||
|
value: napi_value
|
||||||
|
/* napi_property_attributes */
|
||||||
|
attributes: number
|
||||||
|
data: void_p
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare type napi_finalize = FunctionPointer<(
|
||||||
|
env: napi_env,
|
||||||
|
finalize_data: void_p,
|
||||||
|
finalize_hint: void_p
|
||||||
|
) => void>
|
||||||
|
|
||||||
|
export declare interface node_module {
|
||||||
|
nm_version: int32_t
|
||||||
|
nm_flags: uint32_t
|
||||||
|
nm_filename: Pointer<const_char>
|
||||||
|
nm_register_func: napi_addon_register_func
|
||||||
|
nm_modname: Pointer<const_char>
|
||||||
|
nm_priv: Pointer<void>
|
||||||
|
reserved: PointerPointer<void>
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare interface napi_node_version {
|
||||||
|
major: uint32_t
|
||||||
|
minor: uint32_t
|
||||||
|
patch: uint32_t
|
||||||
|
release: const_char_p
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare interface emnapi_emscripten_version {
|
||||||
|
major: uint32_t
|
||||||
|
minor: uint32_t
|
||||||
|
patch: uint32_t
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare const enum napi_status {
|
||||||
|
napi_ok,
|
||||||
|
napi_invalid_arg,
|
||||||
|
napi_object_expected,
|
||||||
|
napi_string_expected,
|
||||||
|
napi_name_expected,
|
||||||
|
napi_function_expected,
|
||||||
|
napi_number_expected,
|
||||||
|
napi_boolean_expected,
|
||||||
|
napi_array_expected,
|
||||||
|
napi_generic_failure,
|
||||||
|
napi_pending_exception,
|
||||||
|
napi_cancelled,
|
||||||
|
napi_escape_called_twice,
|
||||||
|
napi_handle_scope_mismatch,
|
||||||
|
napi_callback_scope_mismatch,
|
||||||
|
napi_queue_full,
|
||||||
|
napi_closing,
|
||||||
|
napi_bigint_expected,
|
||||||
|
napi_date_expected,
|
||||||
|
napi_arraybuffer_expected,
|
||||||
|
napi_detachable_arraybuffer_expected,
|
||||||
|
napi_would_deadlock, // unused
|
||||||
|
napi_no_external_buffers_allowed,
|
||||||
|
napi_cannot_run_js
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare const enum napi_property_attributes {
|
||||||
|
napi_default = 0,
|
||||||
|
napi_writable = 1 << 0,
|
||||||
|
napi_enumerable = 1 << 1,
|
||||||
|
napi_configurable = 1 << 2,
|
||||||
|
|
||||||
|
// Used with napi_define_class to distinguish static properties
|
||||||
|
// from instance properties. Ignored by napi_define_properties.
|
||||||
|
napi_static = 1 << 10,
|
||||||
|
|
||||||
|
/// #ifdef NAPI_EXPERIMENTAL
|
||||||
|
// Default for class methods.
|
||||||
|
napi_default_method = napi_writable | napi_configurable,
|
||||||
|
|
||||||
|
// Default for object properties, like in JS obj[prop].
|
||||||
|
napi_default_jsproperty = napi_writable | napi_enumerable | napi_configurable
|
||||||
|
/// #endif // NAPI_EXPERIMENTAL
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare const enum napi_valuetype {
|
||||||
|
napi_undefined,
|
||||||
|
napi_null,
|
||||||
|
napi_boolean,
|
||||||
|
napi_number,
|
||||||
|
napi_string,
|
||||||
|
napi_symbol,
|
||||||
|
napi_object,
|
||||||
|
napi_function,
|
||||||
|
napi_external,
|
||||||
|
napi_bigint
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare const enum napi_typedarray_type {
|
||||||
|
napi_int8_array,
|
||||||
|
napi_uint8_array,
|
||||||
|
napi_uint8_clamped_array,
|
||||||
|
napi_int16_array,
|
||||||
|
napi_uint16_array,
|
||||||
|
napi_int32_array,
|
||||||
|
napi_uint32_array,
|
||||||
|
napi_float32_array,
|
||||||
|
napi_float64_array,
|
||||||
|
napi_bigint64_array,
|
||||||
|
napi_biguint64_array,
|
||||||
|
napi_float16_array,
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare const enum napi_key_collection_mode {
|
||||||
|
napi_key_include_prototypes,
|
||||||
|
napi_key_own_only
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare const enum napi_key_filter {
|
||||||
|
napi_key_all_properties = 0,
|
||||||
|
napi_key_writable = 1,
|
||||||
|
napi_key_enumerable = 1 << 1,
|
||||||
|
napi_key_configurable = 1 << 2,
|
||||||
|
napi_key_skip_strings = 1 << 3,
|
||||||
|
napi_key_skip_symbols = 1 << 4
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare const enum napi_key_conversion {
|
||||||
|
napi_key_keep_numbers,
|
||||||
|
napi_key_numbers_to_strings
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare const enum emnapi_memory_view_type {
|
||||||
|
emnapi_int8_array,
|
||||||
|
emnapi_uint8_array,
|
||||||
|
emnapi_uint8_clamped_array,
|
||||||
|
emnapi_int16_array,
|
||||||
|
emnapi_uint16_array,
|
||||||
|
emnapi_int32_array,
|
||||||
|
emnapi_uint32_array,
|
||||||
|
emnapi_float32_array,
|
||||||
|
emnapi_float64_array,
|
||||||
|
emnapi_bigint64_array,
|
||||||
|
emnapi_biguint64_array,
|
||||||
|
emnapi_float16_array,
|
||||||
|
emnapi_data_view = -1,
|
||||||
|
emnapi_buffer = -2
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare const enum napi_threadsafe_function_call_mode {
|
||||||
|
napi_tsfn_nonblocking,
|
||||||
|
napi_tsfn_blocking
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare const enum napi_threadsafe_function_release_mode {
|
||||||
|
napi_tsfn_release,
|
||||||
|
napi_tsfn_abort
|
||||||
|
}
|
||||||
|
export declare type CleanupHookCallbackFunction = number | ((arg: number) => void);
|
||||||
|
|
||||||
|
export declare class ConstHandle<S extends undefined | null | boolean | typeof globalThis> extends Handle<S> {
|
||||||
|
constructor(id: number, value: S);
|
||||||
|
dispose(): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare class Context {
|
||||||
|
private _isStopping;
|
||||||
|
private _canCallIntoJs;
|
||||||
|
private _suppressDestroy;
|
||||||
|
envStore: Store<Env>;
|
||||||
|
scopeStore: ScopeStore;
|
||||||
|
refStore: Store<Reference>;
|
||||||
|
deferredStore: Store<Deferred<any>>;
|
||||||
|
handleStore: HandleStore;
|
||||||
|
private readonly refCounter?;
|
||||||
|
private readonly cleanupQueue;
|
||||||
|
private readonly _externalMemory;
|
||||||
|
feature: {
|
||||||
|
supportReflect: boolean;
|
||||||
|
supportFinalizer: boolean;
|
||||||
|
supportWeakSymbol: boolean;
|
||||||
|
supportBigInt: boolean;
|
||||||
|
supportNewFunction: boolean;
|
||||||
|
canSetFunctionName: boolean;
|
||||||
|
setImmediate: (callback: () => void) => void;
|
||||||
|
Buffer: BufferCtor | undefined;
|
||||||
|
MessageChannel: {
|
||||||
|
new (): MessageChannel;
|
||||||
|
prototype: MessageChannel;
|
||||||
|
} | undefined;
|
||||||
|
};
|
||||||
|
constructor(options?: ContextOptions);
|
||||||
|
/**
|
||||||
|
* Suppress the destroy on `beforeExit` event in Node.js.
|
||||||
|
* Call this method if you want to keep the context and
|
||||||
|
* all associated {@link Env | Env} alive,
|
||||||
|
* this also means that cleanup hooks will not be called.
|
||||||
|
* After call this method, you should call
|
||||||
|
* {@link Context.destroy | `Context.prototype.destroy`} method manually.
|
||||||
|
*/
|
||||||
|
suppressDestroy(): void;
|
||||||
|
getRuntimeVersions(): {
|
||||||
|
version: string;
|
||||||
|
NODE_API_SUPPORTED_VERSION_MAX: Version;
|
||||||
|
NAPI_VERSION_EXPERIMENTAL: Version;
|
||||||
|
NODE_API_DEFAULT_MODULE_API_VERSION: Version;
|
||||||
|
};
|
||||||
|
createNotSupportWeakRefError(api: string, message: string): NotSupportWeakRefError;
|
||||||
|
createNotSupportBufferError(api: string, message: string): NotSupportBufferError;
|
||||||
|
createReference(envObject: Env, handle_id: napi_value, initialRefcount: uint32_t, ownership: ReferenceOwnership): Reference;
|
||||||
|
createReferenceWithData(envObject: Env, handle_id: napi_value, initialRefcount: uint32_t, ownership: ReferenceOwnership, data: void_p): Reference;
|
||||||
|
createReferenceWithFinalizer(envObject: Env, handle_id: napi_value, initialRefcount: uint32_t, ownership: ReferenceOwnership, finalize_callback?: napi_finalize, finalize_data?: void_p, finalize_hint?: void_p): Reference;
|
||||||
|
createDeferred<T = any>(value: IDeferrdValue<T>): Deferred<T>;
|
||||||
|
adjustAmountOfExternalAllocatedMemory(changeInBytes: number | bigint): bigint;
|
||||||
|
createEnv(filename: string, moduleApiVersion: number, makeDynCall_vppp: (cb: Ptr) => (a: Ptr, b: Ptr, c: Ptr) => void, makeDynCall_vp: (cb: Ptr) => (a: Ptr) => void, abort: (msg?: string) => never, nodeBinding?: any): Env;
|
||||||
|
createTrackedFinalizer(envObject: Env, finalize_callback: napi_finalize, finalize_data: void_p, finalize_hint: void_p): TrackedFinalizer;
|
||||||
|
getCurrentScope(): HandleScope | null;
|
||||||
|
addToCurrentScope<V>(value: V): Handle<V>;
|
||||||
|
openScope(envObject?: Env): HandleScope;
|
||||||
|
closeScope(envObject?: Env, _scope?: HandleScope): void;
|
||||||
|
ensureHandle<S>(value: S): Handle<S>;
|
||||||
|
addCleanupHook(envObject: Env, fn: CleanupHookCallbackFunction, arg: number): void;
|
||||||
|
removeCleanupHook(envObject: Env, fn: CleanupHookCallbackFunction, arg: number): void;
|
||||||
|
runCleanup(): void;
|
||||||
|
increaseWaitingRequestCounter(): void;
|
||||||
|
decreaseWaitingRequestCounter(): void;
|
||||||
|
setCanCallIntoJs(value: boolean): void;
|
||||||
|
setStopping(value: boolean): void;
|
||||||
|
canCallIntoJs(): boolean;
|
||||||
|
/**
|
||||||
|
* Destroy the context and call cleanup hooks.
|
||||||
|
* Associated {@link Env | Env} will be destroyed.
|
||||||
|
*/
|
||||||
|
destroy(): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare interface ContextOptions {
|
||||||
|
onExternalMemoryChange?: (current: bigint, old: bigint, delta: bigint) => any;
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare function createContext(options?: ContextOptions): Context;
|
||||||
|
|
||||||
|
export declare class Deferred<T = any> implements IStoreValue {
|
||||||
|
static create<T = any>(ctx: Context, value: IDeferrdValue<T>): Deferred;
|
||||||
|
id: number;
|
||||||
|
ctx: Context;
|
||||||
|
value: IDeferrdValue<T>;
|
||||||
|
constructor(ctx: Context, value: IDeferrdValue<T>);
|
||||||
|
resolve(value: T): void;
|
||||||
|
reject(reason?: any): void;
|
||||||
|
dispose(): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare class EmnapiError extends Error {
|
||||||
|
constructor(message?: string);
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare abstract class Env implements IStoreValue {
|
||||||
|
readonly ctx: Context;
|
||||||
|
moduleApiVersion: number;
|
||||||
|
makeDynCall_vppp: (cb: Ptr) => (a: Ptr, b: Ptr, c: Ptr) => void;
|
||||||
|
makeDynCall_vp: (cb: Ptr) => (a: Ptr) => void;
|
||||||
|
abort: (msg?: string) => never;
|
||||||
|
id: number;
|
||||||
|
openHandleScopes: number;
|
||||||
|
instanceData: TrackedFinalizer | null;
|
||||||
|
tryCatch: TryCatch;
|
||||||
|
refs: number;
|
||||||
|
reflist: RefTracker;
|
||||||
|
finalizing_reflist: RefTracker;
|
||||||
|
pendingFinalizers: RefTracker[];
|
||||||
|
lastError: {
|
||||||
|
errorCode: napi_status;
|
||||||
|
engineErrorCode: number;
|
||||||
|
engineReserved: Ptr;
|
||||||
|
};
|
||||||
|
inGcFinalizer: boolean;
|
||||||
|
constructor(ctx: Context, moduleApiVersion: number, makeDynCall_vppp: (cb: Ptr) => (a: Ptr, b: Ptr, c: Ptr) => void, makeDynCall_vp: (cb: Ptr) => (a: Ptr) => void, abort: (msg?: string) => never);
|
||||||
|
/** @virtual */
|
||||||
|
canCallIntoJs(): boolean;
|
||||||
|
terminatedOrTerminating(): boolean;
|
||||||
|
ref(): void;
|
||||||
|
unref(): void;
|
||||||
|
ensureHandle<S>(value: S): Handle<S>;
|
||||||
|
ensureHandleId(value: any): napi_value;
|
||||||
|
clearLastError(): napi_status;
|
||||||
|
setLastError(error_code: napi_status, engine_error_code?: uint32_t, engine_reserved?: void_p): napi_status;
|
||||||
|
getReturnStatus(): napi_status;
|
||||||
|
callIntoModule<T>(fn: (env: Env) => T, handleException?: (envObject: Env, value: any) => void): T;
|
||||||
|
/** @virtual */
|
||||||
|
abstract callFinalizer(cb: napi_finalize, data: void_p, hint: void_p): void;
|
||||||
|
invokeFinalizerFromGC(finalizer: RefTracker): void;
|
||||||
|
checkGCAccess(): void;
|
||||||
|
/** @virtual */
|
||||||
|
enqueueFinalizer(finalizer: RefTracker): void;
|
||||||
|
/** @virtual */
|
||||||
|
dequeueFinalizer(finalizer: RefTracker): void;
|
||||||
|
/** @virtual */
|
||||||
|
deleteMe(): void;
|
||||||
|
dispose(): void;
|
||||||
|
private readonly _bindingMap;
|
||||||
|
initObjectBinding<S extends object>(value: S): IReferenceBinding;
|
||||||
|
getObjectBinding<S extends object>(value: S): IReferenceBinding;
|
||||||
|
setInstanceData(data: number, finalize_cb: number, finalize_hint: number): void;
|
||||||
|
getInstanceData(): number;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @public */
|
||||||
|
declare interface External_2 extends Record<any, any> {
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @public */
|
||||||
|
declare const External_2: {
|
||||||
|
new (value: number | bigint): External_2;
|
||||||
|
prototype: null;
|
||||||
|
};
|
||||||
|
export { External_2 as External }
|
||||||
|
|
||||||
|
export declare class Finalizer {
|
||||||
|
envObject: Env;
|
||||||
|
private _finalizeCallback;
|
||||||
|
private _finalizeData;
|
||||||
|
private _finalizeHint;
|
||||||
|
private _makeDynCall_vppp;
|
||||||
|
constructor(envObject: Env, _finalizeCallback?: napi_finalize, _finalizeData?: void_p, _finalizeHint?: void_p);
|
||||||
|
callback(): napi_finalize;
|
||||||
|
data(): void_p;
|
||||||
|
hint(): void_p;
|
||||||
|
resetEnv(): void;
|
||||||
|
resetFinalizer(): void;
|
||||||
|
callFinalizer(): void;
|
||||||
|
dispose(): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare function getDefaultContext(): Context;
|
||||||
|
|
||||||
|
/** @public */
|
||||||
|
export declare function getExternalValue(external: External_2): number | bigint;
|
||||||
|
|
||||||
|
export declare class Handle<S> {
|
||||||
|
id: number;
|
||||||
|
value: S;
|
||||||
|
constructor(id: number, value: S);
|
||||||
|
data(): void_p;
|
||||||
|
isNumber(): boolean;
|
||||||
|
isBigInt(): boolean;
|
||||||
|
isString(): boolean;
|
||||||
|
isFunction(): boolean;
|
||||||
|
isExternal(): boolean;
|
||||||
|
isObject(): boolean;
|
||||||
|
isArray(): boolean;
|
||||||
|
isArrayBuffer(): boolean;
|
||||||
|
isTypedArray(): boolean;
|
||||||
|
isBuffer(BufferConstructor?: BufferCtor): boolean;
|
||||||
|
isDataView(): boolean;
|
||||||
|
isDate(): boolean;
|
||||||
|
isPromise(): boolean;
|
||||||
|
isBoolean(): boolean;
|
||||||
|
isUndefined(): boolean;
|
||||||
|
isSymbol(): boolean;
|
||||||
|
isNull(): boolean;
|
||||||
|
dispose(): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare class HandleScope {
|
||||||
|
handleStore: HandleStore;
|
||||||
|
id: number;
|
||||||
|
parent: HandleScope | null;
|
||||||
|
child: HandleScope | null;
|
||||||
|
start: number;
|
||||||
|
end: number;
|
||||||
|
private _escapeCalled;
|
||||||
|
callbackInfo: ICallbackInfo;
|
||||||
|
constructor(handleStore: HandleStore, id: number, parentScope: HandleScope | null, start: number, end?: number);
|
||||||
|
add<V>(value: V): Handle<V>;
|
||||||
|
addExternal(data: void_p): Handle<object>;
|
||||||
|
dispose(): void;
|
||||||
|
escape(handle: number): Handle<any> | null;
|
||||||
|
escapeCalled(): boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare class HandleStore {
|
||||||
|
static UNDEFINED: ConstHandle<undefined>;
|
||||||
|
static NULL: ConstHandle<null>;
|
||||||
|
static FALSE: ConstHandle<false>;
|
||||||
|
static TRUE: ConstHandle<true>;
|
||||||
|
static GLOBAL: ConstHandle<typeof globalThis>;
|
||||||
|
static MIN_ID: 6;
|
||||||
|
private readonly _values;
|
||||||
|
private _next;
|
||||||
|
push<S>(value: S): Handle<S>;
|
||||||
|
erase(start: number, end: number): void;
|
||||||
|
get(id: Ptr): Handle<any> | undefined;
|
||||||
|
swap(a: number, b: number): void;
|
||||||
|
dispose(): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare interface ICallbackInfo {
|
||||||
|
thiz: any;
|
||||||
|
data: void_p;
|
||||||
|
args: ArrayLike<any>;
|
||||||
|
fn: Function;
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare interface IDeferrdValue<T = any> {
|
||||||
|
resolve: (value: T) => void;
|
||||||
|
reject: (reason?: any) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare interface IReferenceBinding {
|
||||||
|
wrapped: number;
|
||||||
|
tag: Uint32Array | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @public */
|
||||||
|
export declare function isExternal(object: unknown): object is External_2;
|
||||||
|
|
||||||
|
export declare function isReferenceType(v: any): v is object;
|
||||||
|
|
||||||
|
export declare interface IStoreValue {
|
||||||
|
id: number;
|
||||||
|
dispose(): void;
|
||||||
|
[x: string]: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare const NAPI_VERSION_EXPERIMENTAL = Version.NAPI_VERSION_EXPERIMENTAL;
|
||||||
|
|
||||||
|
export declare const NODE_API_DEFAULT_MODULE_API_VERSION = Version.NODE_API_DEFAULT_MODULE_API_VERSION;
|
||||||
|
|
||||||
|
export declare const NODE_API_SUPPORTED_VERSION_MAX = Version.NODE_API_SUPPORTED_VERSION_MAX;
|
||||||
|
|
||||||
|
export declare const NODE_API_SUPPORTED_VERSION_MIN = Version.NODE_API_SUPPORTED_VERSION_MIN;
|
||||||
|
|
||||||
|
export declare class NodeEnv extends Env {
|
||||||
|
filename: string;
|
||||||
|
private readonly nodeBinding?;
|
||||||
|
destructing: boolean;
|
||||||
|
finalizationScheduled: boolean;
|
||||||
|
constructor(ctx: Context, filename: string, moduleApiVersion: number, makeDynCall_vppp: (cb: Ptr) => (a: Ptr, b: Ptr, c: Ptr) => void, makeDynCall_vp: (cb: Ptr) => (a: Ptr) => void, abort: (msg?: string) => never, nodeBinding?: any);
|
||||||
|
deleteMe(): void;
|
||||||
|
canCallIntoJs(): boolean;
|
||||||
|
triggerFatalException(err: any): void;
|
||||||
|
callbackIntoModule<T>(enforceUncaughtExceptionPolicy: boolean, fn: (env: Env) => T): T;
|
||||||
|
callFinalizer(cb: napi_finalize, data: void_p, hint: void_p): void;
|
||||||
|
callFinalizerInternal(forceUncaught: int, cb: napi_finalize, data: void_p, hint: void_p): void;
|
||||||
|
enqueueFinalizer(finalizer: RefTracker): void;
|
||||||
|
drainFinalizerQueue(): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare class NotSupportBufferError extends EmnapiError {
|
||||||
|
constructor(api: string, message: string);
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare class NotSupportWeakRefError extends EmnapiError {
|
||||||
|
constructor(api: string, message: string);
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare class Persistent<T> {
|
||||||
|
private _ref;
|
||||||
|
private _param;
|
||||||
|
private _callback;
|
||||||
|
private static readonly _registry;
|
||||||
|
constructor(value: T);
|
||||||
|
setWeak<P>(param: P, callback: (param: P) => void): void;
|
||||||
|
clearWeak(): void;
|
||||||
|
reset(): void;
|
||||||
|
isEmpty(): boolean;
|
||||||
|
deref(): T | undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare class Reference extends RefTracker implements IStoreValue {
|
||||||
|
private static weakCallback;
|
||||||
|
id: number;
|
||||||
|
envObject: Env;
|
||||||
|
private readonly canBeWeak;
|
||||||
|
private _refcount;
|
||||||
|
private readonly _ownership;
|
||||||
|
persistent: Persistent<object>;
|
||||||
|
static create(envObject: Env, handle_id: napi_value, initialRefcount: uint32_t, ownership: ReferenceOwnership, _unused1?: void_p, _unused2?: void_p, _unused3?: void_p): Reference;
|
||||||
|
protected constructor(envObject: Env, handle_id: napi_value, initialRefcount: uint32_t, ownership: ReferenceOwnership);
|
||||||
|
ref(): number;
|
||||||
|
unref(): number;
|
||||||
|
get(envObject?: Env): napi_value;
|
||||||
|
/** @virtual */
|
||||||
|
resetFinalizer(): void;
|
||||||
|
/** @virtual */
|
||||||
|
data(): void_p;
|
||||||
|
refcount(): number;
|
||||||
|
ownership(): ReferenceOwnership;
|
||||||
|
/** @virtual */
|
||||||
|
protected callUserFinalizer(): void;
|
||||||
|
/** @virtual */
|
||||||
|
protected invokeFinalizerFromGC(): void;
|
||||||
|
private _setWeak;
|
||||||
|
finalize(): void;
|
||||||
|
dispose(): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare enum ReferenceOwnership {
|
||||||
|
kRuntime = 0,
|
||||||
|
kUserland = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare class ReferenceWithData extends Reference {
|
||||||
|
private readonly _data;
|
||||||
|
static create(envObject: Env, value: napi_value, initialRefcount: uint32_t, ownership: ReferenceOwnership, data: void_p): ReferenceWithData;
|
||||||
|
private constructor();
|
||||||
|
data(): void_p;
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare class ReferenceWithFinalizer extends Reference {
|
||||||
|
private _finalizer;
|
||||||
|
static create(envObject: Env, value: napi_value, initialRefcount: uint32_t, ownership: ReferenceOwnership, finalize_callback: napi_finalize, finalize_data: void_p, finalize_hint: void_p): ReferenceWithFinalizer;
|
||||||
|
private constructor();
|
||||||
|
resetFinalizer(): void;
|
||||||
|
data(): void_p;
|
||||||
|
protected callUserFinalizer(): void;
|
||||||
|
protected invokeFinalizerFromGC(): void;
|
||||||
|
dispose(): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare class RefTracker {
|
||||||
|
/** @virtual */
|
||||||
|
dispose(): void;
|
||||||
|
/** @virtual */
|
||||||
|
finalize(): void;
|
||||||
|
private _next;
|
||||||
|
private _prev;
|
||||||
|
link(list: RefTracker): void;
|
||||||
|
unlink(): void;
|
||||||
|
static finalizeAll(list: RefTracker): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare class ScopeStore {
|
||||||
|
private readonly _rootScope;
|
||||||
|
currentScope: HandleScope;
|
||||||
|
private readonly _values;
|
||||||
|
constructor();
|
||||||
|
get(id: number): HandleScope | undefined;
|
||||||
|
openScope(handleStore: HandleStore): HandleScope;
|
||||||
|
closeScope(): void;
|
||||||
|
dispose(): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare class Store<V extends IStoreValue> {
|
||||||
|
protected _values: Array<V | undefined>;
|
||||||
|
private _freeList;
|
||||||
|
private _size;
|
||||||
|
constructor();
|
||||||
|
add(value: V): void;
|
||||||
|
get(id: Ptr): V | undefined;
|
||||||
|
has(id: Ptr): boolean;
|
||||||
|
remove(id: Ptr): void;
|
||||||
|
dispose(): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare class TrackedFinalizer extends RefTracker {
|
||||||
|
private _finalizer;
|
||||||
|
static create(envObject: Env, finalize_callback: napi_finalize, finalize_data: void_p, finalize_hint: void_p): TrackedFinalizer;
|
||||||
|
private constructor();
|
||||||
|
data(): void_p;
|
||||||
|
dispose(): void;
|
||||||
|
finalize(): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare class TryCatch {
|
||||||
|
private _exception;
|
||||||
|
private _caught;
|
||||||
|
isEmpty(): boolean;
|
||||||
|
hasCaught(): boolean;
|
||||||
|
exception(): any;
|
||||||
|
setError(err: any): void;
|
||||||
|
reset(): void;
|
||||||
|
extractException(): any;
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare const version: string;
|
||||||
|
|
||||||
|
export { }
|
||||||
+1
File diff suppressed because one or more lines are too long
+1
File diff suppressed because one or more lines are too long
+1367
File diff suppressed because it is too large
Load Diff
+5
@@ -0,0 +1,5 @@
|
|||||||
|
if (typeof process !== 'undefined' && process.env.NODE_ENV === 'production') {
|
||||||
|
module.exports = require('./dist/emnapi.cjs.min.js')
|
||||||
|
} else {
|
||||||
|
module.exports = require('./dist/emnapi.cjs.js')
|
||||||
|
}
|
||||||
+48
@@ -0,0 +1,48 @@
|
|||||||
|
{
|
||||||
|
"name": "@emnapi/runtime",
|
||||||
|
"version": "1.11.3",
|
||||||
|
"description": "emnapi runtime",
|
||||||
|
"main": "index.js",
|
||||||
|
"module": "./dist/emnapi.esm-bundler.js",
|
||||||
|
"types": "./dist/emnapi.d.ts",
|
||||||
|
"sideEffects": false,
|
||||||
|
"exports": {
|
||||||
|
".": {
|
||||||
|
"types": {
|
||||||
|
"module": "./dist/emnapi.d.ts",
|
||||||
|
"import": "./dist/emnapi.d.mts",
|
||||||
|
"default": "./dist/emnapi.d.ts"
|
||||||
|
},
|
||||||
|
"module": "./dist/emnapi.esm-bundler.js",
|
||||||
|
"import": "./dist/emnapi.mjs",
|
||||||
|
"default": "./index.js"
|
||||||
|
},
|
||||||
|
"./dist/emnapi.cjs.min": {
|
||||||
|
"types": "./dist/emnapi.d.ts",
|
||||||
|
"default": "./dist/emnapi.cjs.min.js"
|
||||||
|
},
|
||||||
|
"./dist/emnapi.min.mjs": {
|
||||||
|
"types": "./dist/emnapi.d.mts",
|
||||||
|
"default": "./dist/emnapi.min.mjs"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"tslib": "^2.4.0"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"build": "node ./script/build.js"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git+https://github.com/toyobayashi/emnapi.git"
|
||||||
|
},
|
||||||
|
"author": "toyobayashi",
|
||||||
|
"license": "MIT",
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/toyobayashi/emnapi/issues"
|
||||||
|
},
|
||||||
|
"homepage": "https://github.com/toyobayashi/emnapi#readme",
|
||||||
|
"publishConfig": {
|
||||||
|
"access": "public"
|
||||||
|
}
|
||||||
|
}
|
||||||
+82
@@ -0,0 +1,82 @@
|
|||||||
|
# Licensing
|
||||||
|
|
||||||
|
## color
|
||||||
|
|
||||||
|
Copyright (c) 2012 Heather Arthur
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
## color-convert
|
||||||
|
|
||||||
|
Copyright (c) 2011-2016 Heather Arthur <fayearthur@gmail.com>.
|
||||||
|
Copyright (c) 2016-2021 Josh Junon <josh@junon.me>.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
## color-string
|
||||||
|
|
||||||
|
Copyright (c) 2011 Heather Arthur <fayearthur@gmail.com>
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
## color-name
|
||||||
|
|
||||||
|
The MIT License (MIT)
|
||||||
|
Copyright (c) 2015 Dmitry Ivanov
|
||||||
|
|
||||||
|
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.
|
||||||
+15
@@ -0,0 +1,15 @@
|
|||||||
|
# `@img/colour`
|
||||||
|
|
||||||
|
The latest version of the
|
||||||
|
[color](https://www.npmjs.com/package/color)
|
||||||
|
package is now ESM-only,
|
||||||
|
however some JavaScript runtimes do not yet support this,
|
||||||
|
which includes versions of Node.js prior to 20.19.0.
|
||||||
|
|
||||||
|
This package converts the `color` package and its dependencies,
|
||||||
|
all of which are MIT-licensed, to CommonJS.
|
||||||
|
|
||||||
|
- [color](https://www.npmjs.com/package/color)
|
||||||
|
- [color-convert](https://www.npmjs.com/package/color-convert)
|
||||||
|
- [color-string](https://www.npmjs.com/package/color-string)
|
||||||
|
- [color-name](https://www.npmjs.com/package/color-name)
|
||||||
+1596
File diff suppressed because it is too large
Load Diff
+1
@@ -0,0 +1 @@
|
|||||||
|
module.exports = require("./color.cjs").default;
|
||||||
+929
@@ -0,0 +1,929 @@
|
|||||||
|
// Generated by dts-bundle-generator v9.5.1
|
||||||
|
|
||||||
|
type Channels = number;
|
||||||
|
type RGB = [
|
||||||
|
r: number,
|
||||||
|
g: number,
|
||||||
|
b: number
|
||||||
|
];
|
||||||
|
type HSL = [
|
||||||
|
h: number,
|
||||||
|
s: number,
|
||||||
|
l: number
|
||||||
|
];
|
||||||
|
type HSV = [
|
||||||
|
h: number,
|
||||||
|
s: number,
|
||||||
|
v: number
|
||||||
|
];
|
||||||
|
type CMYK = [
|
||||||
|
c: number,
|
||||||
|
m: number,
|
||||||
|
y: number,
|
||||||
|
k: number
|
||||||
|
];
|
||||||
|
type LAB = [
|
||||||
|
l: number,
|
||||||
|
a: number,
|
||||||
|
b: number
|
||||||
|
];
|
||||||
|
type LCH = [
|
||||||
|
l: number,
|
||||||
|
c: number,
|
||||||
|
h: number
|
||||||
|
];
|
||||||
|
type HCG = [
|
||||||
|
h: number,
|
||||||
|
c: number,
|
||||||
|
g: number
|
||||||
|
];
|
||||||
|
type HWB = [
|
||||||
|
h: number,
|
||||||
|
w: number,
|
||||||
|
b: number
|
||||||
|
];
|
||||||
|
type XYZ = [
|
||||||
|
x: number,
|
||||||
|
y: number,
|
||||||
|
z: number
|
||||||
|
];
|
||||||
|
type Apple = [
|
||||||
|
r16: number,
|
||||||
|
g16: number,
|
||||||
|
b16: number
|
||||||
|
];
|
||||||
|
type Gray = [
|
||||||
|
gray: number
|
||||||
|
];
|
||||||
|
type ANSI16 = number;
|
||||||
|
type ANSI256 = number;
|
||||||
|
type Keyword = string;
|
||||||
|
type HEX = string;
|
||||||
|
declare namespace route {
|
||||||
|
type rgb = {
|
||||||
|
hsl(from: RGB): HSL;
|
||||||
|
hsl(...from: RGB): HSL;
|
||||||
|
hsl(from: RGB): HSL;
|
||||||
|
hsl(...from: RGB): HSL;
|
||||||
|
hsv(from: RGB): HSV;
|
||||||
|
hsv(...from: RGB): HSV;
|
||||||
|
hwb(from: RGB): HWB;
|
||||||
|
hwb(...from: RGB): HWB;
|
||||||
|
cmyk(from: RGB): CMYK;
|
||||||
|
cmyk(...from: RGB): CMYK;
|
||||||
|
xyz(from: RGB): XYZ;
|
||||||
|
xyz(...from: RGB): XYZ;
|
||||||
|
lab(from: RGB): LAB;
|
||||||
|
lab(...from: RGB): LAB;
|
||||||
|
lch(from: RGB): LCH;
|
||||||
|
lch(...from: RGB): LCH;
|
||||||
|
hex(from: RGB): HEX;
|
||||||
|
hex(...from: RGB): HEX;
|
||||||
|
keyword(from: RGB): Keyword;
|
||||||
|
keyword(...from: RGB): Keyword;
|
||||||
|
ansi16(from: RGB): ANSI16;
|
||||||
|
ansi16(...from: RGB): ANSI16;
|
||||||
|
ansi256(from: RGB): ANSI256;
|
||||||
|
ansi256(...from: RGB): ANSI256;
|
||||||
|
hcg(from: RGB): HCG;
|
||||||
|
hcg(...from: RGB): HCG;
|
||||||
|
apple(from: RGB): Apple;
|
||||||
|
apple(...from: RGB): Apple;
|
||||||
|
gray(from: RGB): Gray;
|
||||||
|
gray(...from: RGB): Gray;
|
||||||
|
};
|
||||||
|
type hsl = {
|
||||||
|
rgb(from: HSL): RGB;
|
||||||
|
rgb(...from: HSL): RGB;
|
||||||
|
hsv(from: HSL): HSV;
|
||||||
|
hsv(...from: HSL): HSV;
|
||||||
|
hwb(from: HSL): HWB;
|
||||||
|
hwb(...from: HSL): HWB;
|
||||||
|
cmyk(from: HSL): CMYK;
|
||||||
|
cmyk(...from: HSL): CMYK;
|
||||||
|
xyz(from: HSL): XYZ;
|
||||||
|
xyz(...from: HSL): XYZ;
|
||||||
|
lab(from: HSL): LAB;
|
||||||
|
lab(...from: HSL): LAB;
|
||||||
|
lch(from: HSL): LCH;
|
||||||
|
lch(...from: HSL): LCH;
|
||||||
|
hex(from: HSL): HEX;
|
||||||
|
hex(...from: HSL): HEX;
|
||||||
|
keyword(from: HSL): Keyword;
|
||||||
|
keyword(...from: HSL): Keyword;
|
||||||
|
ansi16(from: HSL): ANSI16;
|
||||||
|
ansi16(...from: HSL): ANSI16;
|
||||||
|
ansi256(from: HSL): ANSI256;
|
||||||
|
ansi256(...from: HSL): ANSI256;
|
||||||
|
hcg(from: HSL): HCG;
|
||||||
|
hcg(...from: HSL): HCG;
|
||||||
|
apple(from: HSL): Apple;
|
||||||
|
apple(...from: HSL): Apple;
|
||||||
|
gray(from: HSL): Gray;
|
||||||
|
gray(...from: HSL): Gray;
|
||||||
|
};
|
||||||
|
type hsv = {
|
||||||
|
rgb(from: HSV): RGB;
|
||||||
|
rgb(...from: HSV): RGB;
|
||||||
|
hsl(from: HSV): HSL;
|
||||||
|
hsl(...from: HSV): HSL;
|
||||||
|
hwb(from: HSV): HWB;
|
||||||
|
hwb(...from: HSV): HWB;
|
||||||
|
cmyk(from: HSV): CMYK;
|
||||||
|
cmyk(...from: HSV): CMYK;
|
||||||
|
xyz(from: HSV): XYZ;
|
||||||
|
xyz(...from: HSV): XYZ;
|
||||||
|
lab(from: HSV): LAB;
|
||||||
|
lab(...from: HSV): LAB;
|
||||||
|
lch(from: HSV): LCH;
|
||||||
|
lch(...from: HSV): LCH;
|
||||||
|
hex(from: HSV): HEX;
|
||||||
|
hex(...from: HSV): HEX;
|
||||||
|
keyword(from: HSV): Keyword;
|
||||||
|
keyword(...from: HSV): Keyword;
|
||||||
|
ansi16(from: HSV): ANSI16;
|
||||||
|
ansi16(...from: HSV): ANSI16;
|
||||||
|
ansi256(from: HSV): ANSI256;
|
||||||
|
ansi256(...from: HSV): ANSI256;
|
||||||
|
hcg(from: HSV): HCG;
|
||||||
|
hcg(...from: HSV): HCG;
|
||||||
|
apple(from: HSV): Apple;
|
||||||
|
apple(...from: HSV): Apple;
|
||||||
|
gray(from: HSV): Gray;
|
||||||
|
gray(...from: HSV): Gray;
|
||||||
|
};
|
||||||
|
type hwb = {
|
||||||
|
rgb(from: HWB): RGB;
|
||||||
|
rgb(...from: HWB): RGB;
|
||||||
|
hsl(from: HWB): HSL;
|
||||||
|
hsl(...from: HWB): HSL;
|
||||||
|
hsv(from: HWB): HSV;
|
||||||
|
hsv(...from: HWB): HSV;
|
||||||
|
cmyk(from: HWB): CMYK;
|
||||||
|
cmyk(...from: HWB): CMYK;
|
||||||
|
xyz(from: HWB): XYZ;
|
||||||
|
xyz(...from: HWB): XYZ;
|
||||||
|
lab(from: HWB): LAB;
|
||||||
|
lab(...from: HWB): LAB;
|
||||||
|
lch(from: HWB): LCH;
|
||||||
|
lch(...from: HWB): LCH;
|
||||||
|
hex(from: HWB): HEX;
|
||||||
|
hex(...from: HWB): HEX;
|
||||||
|
keyword(from: HWB): Keyword;
|
||||||
|
keyword(...from: HWB): Keyword;
|
||||||
|
ansi16(from: HWB): ANSI16;
|
||||||
|
ansi16(...from: HWB): ANSI16;
|
||||||
|
ansi256(from: HWB): ANSI256;
|
||||||
|
ansi256(...from: HWB): ANSI256;
|
||||||
|
hcg(from: HWB): HCG;
|
||||||
|
hcg(...from: HWB): HCG;
|
||||||
|
apple(from: HWB): Apple;
|
||||||
|
apple(...from: HWB): Apple;
|
||||||
|
gray(from: HWB): Gray;
|
||||||
|
gray(...from: HWB): Gray;
|
||||||
|
};
|
||||||
|
type cmyk = {
|
||||||
|
rgb(from: CMYK): RGB;
|
||||||
|
rgb(...from: CMYK): RGB;
|
||||||
|
hsl(from: CMYK): HSL;
|
||||||
|
hsl(...from: CMYK): HSL;
|
||||||
|
hsv(from: CMYK): HSV;
|
||||||
|
hsv(...from: CMYK): HSV;
|
||||||
|
hwb(from: CMYK): HWB;
|
||||||
|
hwb(...from: CMYK): HWB;
|
||||||
|
xyz(from: CMYK): XYZ;
|
||||||
|
xyz(...from: CMYK): XYZ;
|
||||||
|
lab(from: CMYK): LAB;
|
||||||
|
lab(...from: CMYK): LAB;
|
||||||
|
lch(from: CMYK): LCH;
|
||||||
|
lch(...from: CMYK): LCH;
|
||||||
|
hex(from: CMYK): HEX;
|
||||||
|
hex(...from: CMYK): HEX;
|
||||||
|
keyword(from: CMYK): Keyword;
|
||||||
|
keyword(...from: CMYK): Keyword;
|
||||||
|
ansi16(from: CMYK): ANSI16;
|
||||||
|
ansi16(...from: CMYK): ANSI16;
|
||||||
|
ansi256(from: CMYK): ANSI256;
|
||||||
|
ansi256(...from: CMYK): ANSI256;
|
||||||
|
hcg(from: CMYK): HCG;
|
||||||
|
hcg(...from: CMYK): HCG;
|
||||||
|
apple(from: CMYK): Apple;
|
||||||
|
apple(...from: CMYK): Apple;
|
||||||
|
gray(from: CMYK): Gray;
|
||||||
|
gray(...from: CMYK): Gray;
|
||||||
|
};
|
||||||
|
type xyz = {
|
||||||
|
rgb(from: XYZ): RGB;
|
||||||
|
rgb(...from: XYZ): RGB;
|
||||||
|
hsl(from: XYZ): HSL;
|
||||||
|
hsl(...from: XYZ): HSL;
|
||||||
|
hsv(from: XYZ): HSV;
|
||||||
|
hsv(...from: XYZ): HSV;
|
||||||
|
hwb(from: XYZ): HWB;
|
||||||
|
hwb(...from: XYZ): HWB;
|
||||||
|
cmyk(from: XYZ): CMYK;
|
||||||
|
cmyk(...from: XYZ): CMYK;
|
||||||
|
lab(from: XYZ): LAB;
|
||||||
|
lab(...from: XYZ): LAB;
|
||||||
|
lch(from: XYZ): LCH;
|
||||||
|
lch(...from: XYZ): LCH;
|
||||||
|
hex(from: XYZ): HEX;
|
||||||
|
hex(...from: XYZ): HEX;
|
||||||
|
keyword(from: XYZ): Keyword;
|
||||||
|
keyword(...from: XYZ): Keyword;
|
||||||
|
ansi16(from: XYZ): ANSI16;
|
||||||
|
ansi16(...from: XYZ): ANSI16;
|
||||||
|
ansi256(from: XYZ): ANSI256;
|
||||||
|
ansi256(...from: XYZ): ANSI256;
|
||||||
|
hcg(from: XYZ): HCG;
|
||||||
|
hcg(...from: XYZ): HCG;
|
||||||
|
apple(from: XYZ): Apple;
|
||||||
|
apple(...from: XYZ): Apple;
|
||||||
|
gray(from: XYZ): Gray;
|
||||||
|
gray(...from: XYZ): Gray;
|
||||||
|
};
|
||||||
|
type lab = {
|
||||||
|
rgb(from: LAB): RGB;
|
||||||
|
rgb(...from: LAB): RGB;
|
||||||
|
hsl(from: LAB): HSL;
|
||||||
|
hsl(...from: LAB): HSL;
|
||||||
|
hsv(from: LAB): HSV;
|
||||||
|
hsv(...from: LAB): HSV;
|
||||||
|
hwb(from: LAB): HWB;
|
||||||
|
hwb(...from: LAB): HWB;
|
||||||
|
cmyk(from: LAB): CMYK;
|
||||||
|
cmyk(...from: LAB): CMYK;
|
||||||
|
xyz(from: LAB): XYZ;
|
||||||
|
xyz(...from: LAB): XYZ;
|
||||||
|
lch(from: LAB): LCH;
|
||||||
|
lch(...from: LAB): LCH;
|
||||||
|
hex(from: LAB): HEX;
|
||||||
|
hex(...from: LAB): HEX;
|
||||||
|
keyword(from: LAB): Keyword;
|
||||||
|
keyword(...from: LAB): Keyword;
|
||||||
|
ansi16(from: LAB): ANSI16;
|
||||||
|
ansi16(...from: LAB): ANSI16;
|
||||||
|
ansi256(from: LAB): ANSI256;
|
||||||
|
ansi256(...from: LAB): ANSI256;
|
||||||
|
hcg(from: LAB): HCG;
|
||||||
|
hcg(...from: LAB): HCG;
|
||||||
|
apple(from: LAB): Apple;
|
||||||
|
apple(...from: LAB): Apple;
|
||||||
|
gray(from: LAB): Gray;
|
||||||
|
gray(...from: LAB): Gray;
|
||||||
|
};
|
||||||
|
type lch = {
|
||||||
|
rgb(from: LCH): RGB;
|
||||||
|
rgb(...from: LCH): RGB;
|
||||||
|
hsl(from: LCH): HSL;
|
||||||
|
hsl(...from: LCH): HSL;
|
||||||
|
hsv(from: LCH): HSV;
|
||||||
|
hsv(...from: LCH): HSV;
|
||||||
|
hwb(from: LCH): HWB;
|
||||||
|
hwb(...from: LCH): HWB;
|
||||||
|
cmyk(from: LCH): CMYK;
|
||||||
|
cmyk(...from: LCH): CMYK;
|
||||||
|
xyz(from: LCH): XYZ;
|
||||||
|
xyz(...from: LCH): XYZ;
|
||||||
|
lab(from: LCH): LAB;
|
||||||
|
lab(...from: LCH): LAB;
|
||||||
|
hex(from: LCH): HEX;
|
||||||
|
hex(...from: LCH): HEX;
|
||||||
|
keyword(from: LCH): Keyword;
|
||||||
|
keyword(...from: LCH): Keyword;
|
||||||
|
ansi16(from: LCH): ANSI16;
|
||||||
|
ansi16(...from: LCH): ANSI16;
|
||||||
|
ansi256(from: LCH): ANSI256;
|
||||||
|
ansi256(...from: LCH): ANSI256;
|
||||||
|
hcg(from: LCH): HCG;
|
||||||
|
hcg(...from: LCH): HCG;
|
||||||
|
apple(from: LCH): Apple;
|
||||||
|
apple(...from: LCH): Apple;
|
||||||
|
gray(from: LCH): Gray;
|
||||||
|
gray(...from: LCH): Gray;
|
||||||
|
};
|
||||||
|
type hex = {
|
||||||
|
rgb(from: HEX): RGB;
|
||||||
|
hsl(from: HEX): HSL;
|
||||||
|
hsv(from: HEX): HSV;
|
||||||
|
hwb(from: HEX): HWB;
|
||||||
|
cmyk(from: HEX): CMYK;
|
||||||
|
xyz(from: HEX): XYZ;
|
||||||
|
lab(from: HEX): LAB;
|
||||||
|
lch(from: HEX): LCH;
|
||||||
|
keyword(from: HEX): Keyword;
|
||||||
|
ansi16(from: HEX): ANSI16;
|
||||||
|
ansi256(from: HEX): ANSI256;
|
||||||
|
hcg(from: HEX): HCG;
|
||||||
|
apple(from: HEX): Apple;
|
||||||
|
gray(from: HEX): Gray;
|
||||||
|
};
|
||||||
|
type keyword = {
|
||||||
|
rgb(from: Keyword): RGB;
|
||||||
|
hsl(from: Keyword): HSL;
|
||||||
|
hsv(from: Keyword): HSV;
|
||||||
|
hwb(from: Keyword): HWB;
|
||||||
|
cmyk(from: Keyword): CMYK;
|
||||||
|
xyz(from: Keyword): XYZ;
|
||||||
|
lab(from: Keyword): LAB;
|
||||||
|
lch(from: Keyword): LCH;
|
||||||
|
hex(from: Keyword): HEX;
|
||||||
|
ansi16(from: Keyword): ANSI16;
|
||||||
|
ansi256(from: Keyword): ANSI256;
|
||||||
|
hcg(from: Keyword): HCG;
|
||||||
|
apple(from: Keyword): Apple;
|
||||||
|
gray(from: Keyword): Gray;
|
||||||
|
};
|
||||||
|
type ansi16 = {
|
||||||
|
rgb(from: ANSI16): RGB;
|
||||||
|
hsl(from: ANSI16): HSL;
|
||||||
|
hsv(from: ANSI16): HSV;
|
||||||
|
hwb(from: ANSI16): HWB;
|
||||||
|
cmyk(from: ANSI16): CMYK;
|
||||||
|
xyz(from: ANSI16): XYZ;
|
||||||
|
lab(from: ANSI16): LAB;
|
||||||
|
lch(from: ANSI16): LCH;
|
||||||
|
hex(from: ANSI16): HEX;
|
||||||
|
keyword(from: ANSI16): Keyword;
|
||||||
|
ansi256(from: ANSI16): ANSI256;
|
||||||
|
hcg(from: ANSI16): HCG;
|
||||||
|
apple(from: ANSI16): Apple;
|
||||||
|
gray(from: ANSI16): Gray;
|
||||||
|
};
|
||||||
|
type ansi256 = {
|
||||||
|
rgb(from: ANSI256): RGB;
|
||||||
|
hsl(from: ANSI256): HSL;
|
||||||
|
hsv(from: ANSI256): HSV;
|
||||||
|
hwb(from: ANSI256): HWB;
|
||||||
|
cmyk(from: ANSI256): CMYK;
|
||||||
|
xyz(from: ANSI256): XYZ;
|
||||||
|
lab(from: ANSI256): LAB;
|
||||||
|
lch(from: ANSI256): LCH;
|
||||||
|
hex(from: ANSI256): HEX;
|
||||||
|
keyword(from: ANSI256): Keyword;
|
||||||
|
ansi16(from: ANSI256): ANSI16;
|
||||||
|
hcg(from: ANSI256): HCG;
|
||||||
|
apple(from: ANSI256): Apple;
|
||||||
|
gray(from: ANSI256): Gray;
|
||||||
|
};
|
||||||
|
type hcg = {
|
||||||
|
rgb(from: HCG): RGB;
|
||||||
|
rgb(...from: HCG): RGB;
|
||||||
|
hsl(from: HCG): HSL;
|
||||||
|
hsl(...from: HCG): HSL;
|
||||||
|
hsv(from: HCG): HSV;
|
||||||
|
hsv(...from: HCG): HSV;
|
||||||
|
hwb(from: HCG): HWB;
|
||||||
|
hwb(...from: HCG): HWB;
|
||||||
|
cmyk(from: HCG): CMYK;
|
||||||
|
cmyk(...from: HCG): CMYK;
|
||||||
|
xyz(from: HCG): XYZ;
|
||||||
|
xyz(...from: HCG): XYZ;
|
||||||
|
lab(from: HCG): LAB;
|
||||||
|
lab(...from: HCG): LAB;
|
||||||
|
lch(from: HCG): LCH;
|
||||||
|
lch(...from: HCG): LCH;
|
||||||
|
hex(from: HCG): HEX;
|
||||||
|
hex(...from: HCG): HEX;
|
||||||
|
keyword(from: HCG): Keyword;
|
||||||
|
keyword(...from: HCG): Keyword;
|
||||||
|
ansi16(from: HCG): ANSI16;
|
||||||
|
ansi16(...from: HCG): ANSI16;
|
||||||
|
ansi256(from: HCG): ANSI256;
|
||||||
|
ansi256(...from: HCG): ANSI256;
|
||||||
|
apple(from: HCG): Apple;
|
||||||
|
apple(...from: HCG): Apple;
|
||||||
|
gray(from: HCG): Gray;
|
||||||
|
gray(...from: HCG): Gray;
|
||||||
|
};
|
||||||
|
type apple = {
|
||||||
|
rgb(from: Apple): RGB;
|
||||||
|
rgb(...from: Apple): RGB;
|
||||||
|
hsl(from: Apple): HSL;
|
||||||
|
hsl(...from: Apple): HSL;
|
||||||
|
hsv(from: Apple): HSV;
|
||||||
|
hsv(...from: Apple): HSV;
|
||||||
|
hwb(from: Apple): HWB;
|
||||||
|
hwb(...from: Apple): HWB;
|
||||||
|
cmyk(from: Apple): CMYK;
|
||||||
|
cmyk(...from: Apple): CMYK;
|
||||||
|
xyz(from: Apple): XYZ;
|
||||||
|
xyz(...from: Apple): XYZ;
|
||||||
|
lab(from: Apple): LAB;
|
||||||
|
lab(...from: Apple): LAB;
|
||||||
|
lch(from: Apple): LCH;
|
||||||
|
lch(...from: Apple): LCH;
|
||||||
|
hex(from: Apple): HEX;
|
||||||
|
hex(...from: Apple): HEX;
|
||||||
|
keyword(from: Apple): Keyword;
|
||||||
|
keyword(...from: Apple): Keyword;
|
||||||
|
ansi16(from: Apple): ANSI16;
|
||||||
|
ansi16(...from: Apple): ANSI16;
|
||||||
|
ansi256(from: Apple): ANSI256;
|
||||||
|
ansi256(...from: Apple): ANSI256;
|
||||||
|
hcg(from: Apple): HCG;
|
||||||
|
hcg(...from: Apple): HCG;
|
||||||
|
gray(from: Apple): Gray;
|
||||||
|
gray(...from: Apple): Gray;
|
||||||
|
};
|
||||||
|
type gray = {
|
||||||
|
rgb(from: Gray): RGB;
|
||||||
|
rgb(...from: Gray): RGB;
|
||||||
|
hsl(from: Gray): HSL;
|
||||||
|
hsl(...from: Gray): HSL;
|
||||||
|
hsv(from: Gray): HSV;
|
||||||
|
hsv(...from: Gray): HSV;
|
||||||
|
hwb(from: Gray): HWB;
|
||||||
|
hwb(...from: Gray): HWB;
|
||||||
|
cmyk(from: Gray): CMYK;
|
||||||
|
cmyk(...from: Gray): CMYK;
|
||||||
|
xyz(from: Gray): XYZ;
|
||||||
|
xyz(...from: Gray): XYZ;
|
||||||
|
lab(from: Gray): LAB;
|
||||||
|
lab(...from: Gray): LAB;
|
||||||
|
lch(from: Gray): LCH;
|
||||||
|
lch(...from: Gray): LCH;
|
||||||
|
hex(from: Gray): HEX;
|
||||||
|
hex(...from: Gray): HEX;
|
||||||
|
keyword(from: Gray): Keyword;
|
||||||
|
keyword(...from: Gray): Keyword;
|
||||||
|
ansi16(from: Gray): ANSI16;
|
||||||
|
ansi16(...from: Gray): ANSI16;
|
||||||
|
ansi256(from: Gray): ANSI256;
|
||||||
|
ansi256(...from: Gray): ANSI256;
|
||||||
|
hcg(from: Gray): HCG;
|
||||||
|
hcg(...from: Gray): HCG;
|
||||||
|
apple(from: Gray): Apple;
|
||||||
|
apple(...from: Gray): Apple;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
declare function route(fromModel: "rgb"): route.rgb;
|
||||||
|
declare function route(fromModel: "hsl"): route.hsl;
|
||||||
|
declare function route(fromModel: "hsv"): route.hsv;
|
||||||
|
declare function route(fromModel: "hwb"): route.hwb;
|
||||||
|
declare function route(fromModel: "cmyk"): route.cmyk;
|
||||||
|
declare function route(fromModel: "xyz"): route.xyz;
|
||||||
|
declare function route(fromModel: "lab"): route.lab;
|
||||||
|
declare function route(fromModel: "lch"): route.lch;
|
||||||
|
declare function route(fromModel: "hex"): route.hex;
|
||||||
|
declare function route(fromModel: "keyword"): route.keyword;
|
||||||
|
declare function route(fromModel: "ansi16"): route.ansi16;
|
||||||
|
declare function route(fromModel: "ansi256"): route.ansi256;
|
||||||
|
declare function route(fromModel: "hcg"): route.hcg;
|
||||||
|
declare function route(fromModel: "apple"): route.apple;
|
||||||
|
declare function route(fromModel: "gray"): route.gray;
|
||||||
|
type Convert = {
|
||||||
|
rgb: {
|
||||||
|
channels: Channels;
|
||||||
|
labels: "rgb";
|
||||||
|
hsl: {
|
||||||
|
(...rgb: RGB): HSL;
|
||||||
|
raw: (...rgb: RGB) => HSL;
|
||||||
|
};
|
||||||
|
hsv: {
|
||||||
|
(...rgb: RGB): HSV;
|
||||||
|
raw: (...rgb: RGB) => HSV;
|
||||||
|
};
|
||||||
|
hwb: {
|
||||||
|
(...rgb: RGB): HWB;
|
||||||
|
raw: (...rgb: RGB) => HWB;
|
||||||
|
};
|
||||||
|
hcg: {
|
||||||
|
(...rgb: RGB): HCG;
|
||||||
|
raw: (...rgb: RGB) => HCG;
|
||||||
|
};
|
||||||
|
cmyk: {
|
||||||
|
(...rgb: RGB): CMYK;
|
||||||
|
raw: (...rgb: RGB) => CMYK;
|
||||||
|
};
|
||||||
|
keyword: {
|
||||||
|
(...rgb: RGB): Keyword;
|
||||||
|
raw: (...rgb: RGB) => Keyword;
|
||||||
|
};
|
||||||
|
ansi16: {
|
||||||
|
(...rgb: RGB): ANSI16;
|
||||||
|
raw: (...rgb: RGB) => ANSI16;
|
||||||
|
};
|
||||||
|
ansi256: {
|
||||||
|
(...rgb: RGB): ANSI256;
|
||||||
|
raw: (...rgb: RGB) => ANSI256;
|
||||||
|
};
|
||||||
|
apple: {
|
||||||
|
(...rgb: RGB): Apple;
|
||||||
|
raw: (...rgb: RGB) => Apple;
|
||||||
|
};
|
||||||
|
hex: {
|
||||||
|
(...rgb: RGB): HEX;
|
||||||
|
raw: (...rgb: RGB) => HEX;
|
||||||
|
};
|
||||||
|
gray: {
|
||||||
|
(...rgb: RGB): Gray;
|
||||||
|
raw: (...rgb: RGB) => Gray;
|
||||||
|
};
|
||||||
|
} & route.rgb & {
|
||||||
|
[F in keyof route.rgb]: {
|
||||||
|
raw: route.rgb[F];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
keyword: {
|
||||||
|
channels: Channels;
|
||||||
|
rgb: {
|
||||||
|
(keyword: Keyword): RGB;
|
||||||
|
raw: (keyword: Keyword) => RGB;
|
||||||
|
};
|
||||||
|
} & route.keyword & {
|
||||||
|
[F in keyof route.keyword]: {
|
||||||
|
raw: route.keyword[F];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
hsl: {
|
||||||
|
channels: Channels;
|
||||||
|
labels: "hsl";
|
||||||
|
rgb: {
|
||||||
|
(...hsl: HSL): RGB;
|
||||||
|
raw: (...hsl: HSL) => RGB;
|
||||||
|
};
|
||||||
|
hsv: {
|
||||||
|
(...hsl: HSL): HSV;
|
||||||
|
raw: (...hsl: HSL) => HSV;
|
||||||
|
};
|
||||||
|
hcg: {
|
||||||
|
(...hsl: HSL): HCG;
|
||||||
|
raw: (...hsl: HSL) => HCG;
|
||||||
|
};
|
||||||
|
} & route.hsl & {
|
||||||
|
[F in keyof route.hsl]: {
|
||||||
|
raw: route.hsl[F];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
hsv: {
|
||||||
|
channels: Channels;
|
||||||
|
labels: "hsv";
|
||||||
|
hcg: {
|
||||||
|
(...hsv: HSV): HCG;
|
||||||
|
raw: (...hsv: HSV) => HCG;
|
||||||
|
};
|
||||||
|
rgb: {
|
||||||
|
(...hsv: HSV): RGB;
|
||||||
|
raw: (...hsv: HSV) => RGB;
|
||||||
|
};
|
||||||
|
hsv: {
|
||||||
|
(...hsv: HSV): HSV;
|
||||||
|
raw: (...hsv: HSV) => HSV;
|
||||||
|
};
|
||||||
|
hsl: {
|
||||||
|
(...hsv: HSV): HSL;
|
||||||
|
raw: (...hsv: HSV) => HSL;
|
||||||
|
};
|
||||||
|
hwb: {
|
||||||
|
(...hsv: HSV): HWB;
|
||||||
|
raw: (...hsv: HSV) => HWB;
|
||||||
|
};
|
||||||
|
ansi16: {
|
||||||
|
(...hsv: HSV): ANSI16;
|
||||||
|
raw: (...hsv: HSV) => ANSI16;
|
||||||
|
};
|
||||||
|
} & route.hsv & {
|
||||||
|
[F in keyof route.hsv]: {
|
||||||
|
raw: route.hsv[F];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
hwb: {
|
||||||
|
channels: Channels;
|
||||||
|
labels: "hwb";
|
||||||
|
hcg: {
|
||||||
|
(...hwb: HWB): HCG;
|
||||||
|
raw: (...hwb: HWB) => HCG;
|
||||||
|
};
|
||||||
|
rgb: {
|
||||||
|
(...hwb: HWB): RGB;
|
||||||
|
raw: (...hwb: HWB) => RGB;
|
||||||
|
};
|
||||||
|
} & route.hwb & {
|
||||||
|
[F in keyof route.hwb]: {
|
||||||
|
raw: route.hwb[F];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
cmyk: {
|
||||||
|
channels: Channels;
|
||||||
|
labels: "cmyk";
|
||||||
|
rgb: {
|
||||||
|
(...cmyk: CMYK): RGB;
|
||||||
|
raw: (...cmyk: CMYK) => RGB;
|
||||||
|
};
|
||||||
|
} & route.cmyk & {
|
||||||
|
[F in keyof route.cmyk]: {
|
||||||
|
raw: route.cmyk[F];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
xyz: {
|
||||||
|
channels: Channels;
|
||||||
|
labels: "xyz";
|
||||||
|
rgb: {
|
||||||
|
(...xyz: XYZ): RGB;
|
||||||
|
raw: (...xyz: XYZ) => RGB;
|
||||||
|
};
|
||||||
|
lab: {
|
||||||
|
(...xyz: XYZ): LAB;
|
||||||
|
raw: (...xyz: XYZ) => LAB;
|
||||||
|
};
|
||||||
|
} & route.xyz & {
|
||||||
|
[F in keyof route.xyz]: {
|
||||||
|
raw: route.xyz[F];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
lab: {
|
||||||
|
channels: Channels;
|
||||||
|
labels: "lab";
|
||||||
|
xyz: {
|
||||||
|
(...lab: LAB): XYZ;
|
||||||
|
raw: (...lab: LAB) => XYZ;
|
||||||
|
};
|
||||||
|
lch: {
|
||||||
|
(...lab: LAB): LCH;
|
||||||
|
raw: (...lab: LAB) => LCH;
|
||||||
|
};
|
||||||
|
} & route.lab & {
|
||||||
|
[F in keyof route.lab]: {
|
||||||
|
raw: route.lab[F];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
lch: {
|
||||||
|
channels: Channels;
|
||||||
|
labels: "lch";
|
||||||
|
lab: {
|
||||||
|
(...lch: LCH): LAB;
|
||||||
|
raw: (...lch: LCH) => LAB;
|
||||||
|
};
|
||||||
|
} & route.lch & {
|
||||||
|
[F in keyof route.lch]: {
|
||||||
|
raw: route.lch[F];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
hex: {
|
||||||
|
channels: Channels;
|
||||||
|
labels: [
|
||||||
|
"hex"
|
||||||
|
];
|
||||||
|
rgb: {
|
||||||
|
(hex: HEX): RGB;
|
||||||
|
raw: (hex: HEX) => RGB;
|
||||||
|
};
|
||||||
|
} & route.hex & {
|
||||||
|
[F in keyof route.hex]: {
|
||||||
|
raw: route.hex[F];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
ansi16: {
|
||||||
|
channels: Channels;
|
||||||
|
labels: [
|
||||||
|
"ansi16"
|
||||||
|
];
|
||||||
|
rgb: {
|
||||||
|
(ansi16: ANSI16): RGB;
|
||||||
|
raw: (ansi16: ANSI16) => RGB;
|
||||||
|
};
|
||||||
|
} & route.ansi16 & {
|
||||||
|
[F in keyof route.ansi16]: {
|
||||||
|
raw: route.ansi16[F];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
ansi256: {
|
||||||
|
channels: Channels;
|
||||||
|
labels: [
|
||||||
|
"ansi256"
|
||||||
|
];
|
||||||
|
rgb: {
|
||||||
|
(ansi256: ANSI256): RGB;
|
||||||
|
raw: (ansi256: ANSI256) => RGB;
|
||||||
|
};
|
||||||
|
} & route.ansi256 & {
|
||||||
|
[F in keyof route.ansi256]: {
|
||||||
|
raw: route.ansi256[F];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
hcg: {
|
||||||
|
channels: Channels;
|
||||||
|
labels: [
|
||||||
|
"h",
|
||||||
|
"c",
|
||||||
|
"g"
|
||||||
|
];
|
||||||
|
rgb: {
|
||||||
|
(...hcg: HCG): RGB;
|
||||||
|
raw: (...hcg: HCG) => RGB;
|
||||||
|
};
|
||||||
|
hsv: {
|
||||||
|
(...hcg: HCG): HSV;
|
||||||
|
raw: (...hcg: HCG) => HSV;
|
||||||
|
};
|
||||||
|
hwb: {
|
||||||
|
(...hcg: HCG): HWB;
|
||||||
|
raw: (...hcg: HCG) => HWB;
|
||||||
|
};
|
||||||
|
} & route.hcg & {
|
||||||
|
[F in keyof route.hcg]: {
|
||||||
|
raw: route.hcg[F];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
apple: {
|
||||||
|
channels: Channels;
|
||||||
|
labels: [
|
||||||
|
"r16",
|
||||||
|
"g16",
|
||||||
|
"b16"
|
||||||
|
];
|
||||||
|
rgb: {
|
||||||
|
(...apple: Apple): RGB;
|
||||||
|
raw: (...apple: Apple) => RGB;
|
||||||
|
};
|
||||||
|
} & route.apple & {
|
||||||
|
[F in keyof route.apple]: {
|
||||||
|
raw: route.apple[F];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
gray: {
|
||||||
|
channels: Channels;
|
||||||
|
labels: [
|
||||||
|
"gray"
|
||||||
|
];
|
||||||
|
rgb: {
|
||||||
|
(...gray: Gray): RGB;
|
||||||
|
raw: (...gray: Gray) => RGB;
|
||||||
|
};
|
||||||
|
hsl: {
|
||||||
|
(...gray: Gray): HSL;
|
||||||
|
raw: (...gray: Gray) => HSL;
|
||||||
|
};
|
||||||
|
hsv: {
|
||||||
|
(...gray: Gray): HSV;
|
||||||
|
raw: (...gray: Gray) => HSV;
|
||||||
|
};
|
||||||
|
hwb: {
|
||||||
|
(...gray: Gray): HWB;
|
||||||
|
raw: (...gray: Gray) => HWB;
|
||||||
|
};
|
||||||
|
cmyk: {
|
||||||
|
(...gray: Gray): CMYK;
|
||||||
|
raw: (...gray: Gray) => CMYK;
|
||||||
|
};
|
||||||
|
lab: {
|
||||||
|
(...gray: Gray): LAB;
|
||||||
|
raw: (...gray: Gray) => LAB;
|
||||||
|
};
|
||||||
|
hex: {
|
||||||
|
(...gray: Gray): HEX;
|
||||||
|
raw: (...gray: Gray) => HEX;
|
||||||
|
};
|
||||||
|
} & route.gray & {
|
||||||
|
[F in keyof route.gray]: {
|
||||||
|
raw: route.gray[F];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
declare const convert: Convert;
|
||||||
|
export type ColorLike = ColorInstance | string | ArrayLike<number> | number | Record<string, any>;
|
||||||
|
export type ColorJson = {
|
||||||
|
model: string;
|
||||||
|
color: number[];
|
||||||
|
valpha: number;
|
||||||
|
};
|
||||||
|
export type ColorObject = {
|
||||||
|
alpha?: number | undefined;
|
||||||
|
} & Record<string, number>;
|
||||||
|
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
|
||||||
|
export interface ColorInstance {
|
||||||
|
toString(): string;
|
||||||
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||||
|
toJSON(): ColorJson;
|
||||||
|
string(places?: number): string;
|
||||||
|
percentString(places?: number): string;
|
||||||
|
array(): number[];
|
||||||
|
object(): ColorObject;
|
||||||
|
unitArray(): number[];
|
||||||
|
unitObject(): {
|
||||||
|
r: number;
|
||||||
|
g: number;
|
||||||
|
b: number;
|
||||||
|
alpha?: number | undefined;
|
||||||
|
};
|
||||||
|
round(places?: number): ColorInstance;
|
||||||
|
alpha(): number;
|
||||||
|
alpha(value: number): ColorInstance;
|
||||||
|
red(): number;
|
||||||
|
red(value: number): ColorInstance;
|
||||||
|
green(): number;
|
||||||
|
green(value: number): ColorInstance;
|
||||||
|
blue(): number;
|
||||||
|
blue(value: number): ColorInstance;
|
||||||
|
hue(): number;
|
||||||
|
hue(value: number): ColorInstance;
|
||||||
|
saturationl(): number;
|
||||||
|
saturationl(value: number): ColorInstance;
|
||||||
|
lightness(): number;
|
||||||
|
lightness(value: number): ColorInstance;
|
||||||
|
saturationv(): number;
|
||||||
|
saturationv(value: number): ColorInstance;
|
||||||
|
value(): number;
|
||||||
|
value(value: number): ColorInstance;
|
||||||
|
chroma(): number;
|
||||||
|
chroma(value: number): ColorInstance;
|
||||||
|
gray(): number;
|
||||||
|
gray(value: number): ColorInstance;
|
||||||
|
white(): number;
|
||||||
|
white(value: number): ColorInstance;
|
||||||
|
wblack(): number;
|
||||||
|
wblack(value: number): ColorInstance;
|
||||||
|
cyan(): number;
|
||||||
|
cyan(value: number): ColorInstance;
|
||||||
|
magenta(): number;
|
||||||
|
magenta(value: number): ColorInstance;
|
||||||
|
yellow(): number;
|
||||||
|
yellow(value: number): ColorInstance;
|
||||||
|
black(): number;
|
||||||
|
black(value: number): ColorInstance;
|
||||||
|
x(): number;
|
||||||
|
x(value: number): ColorInstance;
|
||||||
|
y(): number;
|
||||||
|
y(value: number): ColorInstance;
|
||||||
|
z(): number;
|
||||||
|
z(value: number): ColorInstance;
|
||||||
|
l(): number;
|
||||||
|
l(value: number): ColorInstance;
|
||||||
|
a(): number;
|
||||||
|
a(value: number): ColorInstance;
|
||||||
|
b(): number;
|
||||||
|
b(value: number): ColorInstance;
|
||||||
|
keyword(): string;
|
||||||
|
keyword<V extends string>(value: V): ColorInstance;
|
||||||
|
hex(): string;
|
||||||
|
hex<V extends string>(value: V): ColorInstance;
|
||||||
|
hexa(): string;
|
||||||
|
hexa<V extends string>(value: V): ColorInstance;
|
||||||
|
rgbNumber(): number;
|
||||||
|
luminosity(): number;
|
||||||
|
contrast(color2: ColorInstance): number;
|
||||||
|
level(color2: ColorInstance): "AAA" | "AA" | "";
|
||||||
|
isDark(): boolean;
|
||||||
|
isLight(): boolean;
|
||||||
|
negate(): ColorInstance;
|
||||||
|
lighten(ratio: number): ColorInstance;
|
||||||
|
darken(ratio: number): ColorInstance;
|
||||||
|
saturate(ratio: number): ColorInstance;
|
||||||
|
desaturate(ratio: number): ColorInstance;
|
||||||
|
whiten(ratio: number): ColorInstance;
|
||||||
|
blacken(ratio: number): ColorInstance;
|
||||||
|
grayscale(): ColorInstance;
|
||||||
|
fade(ratio: number): ColorInstance;
|
||||||
|
opaquer(ratio: number): ColorInstance;
|
||||||
|
rotate(degrees: number): ColorInstance;
|
||||||
|
mix(mixinColor: ColorInstance, weight?: number): ColorInstance;
|
||||||
|
rgb(...arguments_: number[]): ColorInstance;
|
||||||
|
hsl(...arguments_: number[]): ColorInstance;
|
||||||
|
hsv(...arguments_: number[]): ColorInstance;
|
||||||
|
hwb(...arguments_: number[]): ColorInstance;
|
||||||
|
cmyk(...arguments_: number[]): ColorInstance;
|
||||||
|
xyz(...arguments_: number[]): ColorInstance;
|
||||||
|
lab(...arguments_: number[]): ColorInstance;
|
||||||
|
lch(...arguments_: number[]): ColorInstance;
|
||||||
|
ansi16(...arguments_: number[]): ColorInstance;
|
||||||
|
ansi256(...arguments_: number[]): ColorInstance;
|
||||||
|
hcg(...arguments_: number[]): ColorInstance;
|
||||||
|
apple(...arguments_: number[]): ColorInstance;
|
||||||
|
}
|
||||||
|
export type ColorConstructor = {
|
||||||
|
(object?: ColorLike, model?: keyof (typeof convert)): ColorInstance;
|
||||||
|
new (object?: ColorLike, model?: keyof (typeof convert)): ColorInstance;
|
||||||
|
rgb(...value: number[]): ColorInstance;
|
||||||
|
rgb(color: ColorLike): ColorInstance;
|
||||||
|
hsl(...value: number[]): ColorInstance;
|
||||||
|
hsl(color: ColorLike): ColorInstance;
|
||||||
|
hsv(...value: number[]): ColorInstance;
|
||||||
|
hsv(color: ColorLike): ColorInstance;
|
||||||
|
hwb(...value: number[]): ColorInstance;
|
||||||
|
hwb(color: ColorLike): ColorInstance;
|
||||||
|
cmyk(...value: number[]): ColorInstance;
|
||||||
|
cmyk(color: ColorLike): ColorInstance;
|
||||||
|
xyz(...value: number[]): ColorInstance;
|
||||||
|
xyz(color: ColorLike): ColorInstance;
|
||||||
|
lab(...value: number[]): ColorInstance;
|
||||||
|
lab(color: ColorLike): ColorInstance;
|
||||||
|
lch(...value: number[]): ColorInstance;
|
||||||
|
lch(color: ColorLike): ColorInstance;
|
||||||
|
ansi16(...value: number[]): ColorInstance;
|
||||||
|
ansi16(color: ColorLike): ColorInstance;
|
||||||
|
ansi256(...value: number[]): ColorInstance;
|
||||||
|
ansi256(color: ColorLike): ColorInstance;
|
||||||
|
hcg(...value: number[]): ColorInstance;
|
||||||
|
hcg(color: ColorLike): ColorInstance;
|
||||||
|
apple(...value: number[]): ColorInstance;
|
||||||
|
apple(color: ColorLike): ColorInstance;
|
||||||
|
};
|
||||||
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||||
|
declare const Color: ColorConstructor;
|
||||||
|
|
||||||
|
export {
|
||||||
|
Color as default,
|
||||||
|
};
|
||||||
|
|
||||||
|
export {};
|
||||||
+58
@@ -0,0 +1,58 @@
|
|||||||
|
{
|
||||||
|
"name": "@img/colour",
|
||||||
|
"version": "1.1.0",
|
||||||
|
"description": "The ESM-only 'color' package made compatible for use with CommonJS runtimes",
|
||||||
|
"license": "MIT",
|
||||||
|
"main": "index.cjs",
|
||||||
|
"types": "index.d.ts",
|
||||||
|
"exports": {
|
||||||
|
".": {
|
||||||
|
"types": "./index.d.ts",
|
||||||
|
"require": "./index.cjs",
|
||||||
|
"default": "./index.cjs"
|
||||||
|
},
|
||||||
|
"./package.json": "./package.json"
|
||||||
|
},
|
||||||
|
"authors": [
|
||||||
|
"Heather Arthur <fayearthur@gmail.com>",
|
||||||
|
"Josh Junon <josh@junon.me>",
|
||||||
|
"Maxime Thirouin",
|
||||||
|
"Dyma Ywanov <dfcreative@gmail.com>",
|
||||||
|
"LitoMore (https://github.com/LitoMore)"
|
||||||
|
],
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"color.cjs",
|
||||||
|
"index.d.ts"
|
||||||
|
],
|
||||||
|
"publishConfig": {
|
||||||
|
"access": "public"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git+https://github.com/lovell/colour.git"
|
||||||
|
},
|
||||||
|
"type": "commonjs",
|
||||||
|
"keywords": [
|
||||||
|
"color",
|
||||||
|
"colour",
|
||||||
|
"cjs",
|
||||||
|
"commonjs"
|
||||||
|
],
|
||||||
|
"scripts": {
|
||||||
|
"build:cjs": "esbuild node_modules/color/index.js --bundle --platform=node --outfile=color.cjs",
|
||||||
|
"build:dts": "dts-bundle-generator ./dts-src.ts -o index.d.ts --project tsconfig.build.json --external-inlines color --external-inlines color-convert --export-referenced-types=false",
|
||||||
|
"build": "npm run build:cjs && npm run build:dts",
|
||||||
|
"test": "node --test"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"color": "5.0.3",
|
||||||
|
"color-convert": "3.1.3",
|
||||||
|
"color-name": "2.1.0",
|
||||||
|
"color-string": "2.1.4",
|
||||||
|
"dts-bundle-generator": "^9.5.1",
|
||||||
|
"esbuild": "^0.27.3"
|
||||||
|
}
|
||||||
|
}
|
||||||
+46
@@ -0,0 +1,46 @@
|
|||||||
|
# `@img/sharp-libvips-linux-x64`
|
||||||
|
|
||||||
|
Prebuilt libvips and dependencies for use with sharp on Linux (glibc) x64.
|
||||||
|
|
||||||
|
## Licensing
|
||||||
|
|
||||||
|
This software contains third-party libraries
|
||||||
|
used under the terms of the following licenses:
|
||||||
|
|
||||||
|
| Library | Used under the terms of |
|
||||||
|
|---------------|-----------------------------------------------------------------------------------------------------------|
|
||||||
|
| aom | BSD 2-Clause + [Alliance for Open Media Patent License 1.0](https://aomedia.org/license/patent-license/) |
|
||||||
|
| cairo | Mozilla Public License 2.0 |
|
||||||
|
| cgif | MIT License |
|
||||||
|
| expat | MIT License |
|
||||||
|
| fontconfig | [fontconfig License](https://gitlab.freedesktop.org/fontconfig/fontconfig/blob/main/COPYING) (BSD-like) |
|
||||||
|
| freetype | [freetype License](https://git.savannah.gnu.org/cgit/freetype/freetype2.git/tree/docs/FTL.TXT) (BSD-like) |
|
||||||
|
| fribidi | LGPLv3 |
|
||||||
|
| glib | LGPLv3 |
|
||||||
|
| harfbuzz | MIT License |
|
||||||
|
| highway | BSD 3-Clause |
|
||||||
|
| lcms | MIT License |
|
||||||
|
| libarchive | BSD 2-Clause |
|
||||||
|
| libexif | LGPLv3 |
|
||||||
|
| libffi | MIT License |
|
||||||
|
| libheif | LGPLv3 |
|
||||||
|
| libimagequant | [BSD 2-Clause](https://github.com/lovell/libimagequant/blob/main/COPYRIGHT) |
|
||||||
|
| libnsgif | MIT License |
|
||||||
|
| libpng | [libpng License](https://github.com/pnggroup/libpng/blob/master/LICENSE) |
|
||||||
|
| librsvg | LGPLv3 |
|
||||||
|
| libtiff | [libtiff License](https://gitlab.com/libtiff/libtiff/blob/master/LICENSE.md) (BSD-like) |
|
||||||
|
| libultrahdr | MIT License |
|
||||||
|
| libvips | LGPLv3 |
|
||||||
|
| libwebp | New BSD License |
|
||||||
|
| libxml2 | MIT License |
|
||||||
|
| mozjpeg | [zlib License, IJG License, BSD 3-Clause](https://github.com/mozilla/mozjpeg/blob/master/LICENSE.md) |
|
||||||
|
| pango | LGPLv3 |
|
||||||
|
| pixman | MIT License |
|
||||||
|
| proxy-libintl | LGPLv3 |
|
||||||
|
| zlib-ng | [zlib License](https://github.com/zlib-ng/zlib-ng/blob/develop/LICENSE.md) |
|
||||||
|
|
||||||
|
Use of libraries under the terms of the LGPLv3 is via the
|
||||||
|
"any later version" clause of the LGPLv2 or LGPLv2.1.
|
||||||
|
|
||||||
|
Please report any errors or omissions via
|
||||||
|
https://github.com/lovell/sharp-libvips/issues/new
|
||||||
+219
@@ -0,0 +1,219 @@
|
|||||||
|
/* glibconfig.h
|
||||||
|
*
|
||||||
|
* This is a generated file. Please modify 'glibconfig.h.in'
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __GLIBCONFIG_H__
|
||||||
|
#define __GLIBCONFIG_H__
|
||||||
|
|
||||||
|
#include <glib/gmacros.h>
|
||||||
|
|
||||||
|
#include <limits.h>
|
||||||
|
#include <float.h>
|
||||||
|
#define GLIB_HAVE_ALLOCA_H
|
||||||
|
|
||||||
|
#define GLIB_STATIC_COMPILATION 1
|
||||||
|
#define GOBJECT_STATIC_COMPILATION 1
|
||||||
|
#define GIO_STATIC_COMPILATION 1
|
||||||
|
#define GMODULE_STATIC_COMPILATION 1
|
||||||
|
#define GI_STATIC_COMPILATION 1
|
||||||
|
|
||||||
|
/* Specifies that GLib's g_print*() functions wrap the
|
||||||
|
* system printf functions. This is useful to know, for example,
|
||||||
|
* when using glibc's register_printf_function().
|
||||||
|
*/
|
||||||
|
#define GLIB_USING_SYSTEM_PRINTF
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
#define G_MINFLOAT FLT_MIN
|
||||||
|
#define G_MAXFLOAT FLT_MAX
|
||||||
|
#define G_MINDOUBLE DBL_MIN
|
||||||
|
#define G_MAXDOUBLE DBL_MAX
|
||||||
|
#define G_MINSHORT SHRT_MIN
|
||||||
|
#define G_MAXSHORT SHRT_MAX
|
||||||
|
#define G_MAXUSHORT USHRT_MAX
|
||||||
|
#define G_MININT INT_MIN
|
||||||
|
#define G_MAXINT INT_MAX
|
||||||
|
#define G_MAXUINT UINT_MAX
|
||||||
|
#define G_MINLONG LONG_MIN
|
||||||
|
#define G_MAXLONG LONG_MAX
|
||||||
|
#define G_MAXULONG ULONG_MAX
|
||||||
|
|
||||||
|
typedef signed char gint8;
|
||||||
|
typedef unsigned char guint8;
|
||||||
|
|
||||||
|
typedef signed short gint16;
|
||||||
|
typedef unsigned short guint16;
|
||||||
|
|
||||||
|
#define G_GINT16_MODIFIER "h"
|
||||||
|
#define G_GINT16_FORMAT "hi"
|
||||||
|
#define G_GUINT16_FORMAT "hu"
|
||||||
|
|
||||||
|
|
||||||
|
typedef signed int gint32;
|
||||||
|
typedef unsigned int guint32;
|
||||||
|
|
||||||
|
#define G_GINT32_MODIFIER ""
|
||||||
|
#define G_GINT32_FORMAT "i"
|
||||||
|
#define G_GUINT32_FORMAT "u"
|
||||||
|
|
||||||
|
|
||||||
|
#define G_HAVE_GINT64 1 /* deprecated, always true */
|
||||||
|
|
||||||
|
typedef signed long gint64;
|
||||||
|
typedef unsigned long guint64;
|
||||||
|
|
||||||
|
#define G_GINT64_CONSTANT(val) (val##L)
|
||||||
|
#define G_GUINT64_CONSTANT(val) (val##UL)
|
||||||
|
|
||||||
|
#define G_GINT64_MODIFIER "l"
|
||||||
|
#define G_GINT64_FORMAT "li"
|
||||||
|
#define G_GUINT64_FORMAT "lu"
|
||||||
|
|
||||||
|
|
||||||
|
#define GLIB_SIZEOF_VOID_P 8
|
||||||
|
#define GLIB_SIZEOF_LONG 8
|
||||||
|
#define GLIB_SIZEOF_SIZE_T 8
|
||||||
|
#define GLIB_SIZEOF_SSIZE_T 8
|
||||||
|
|
||||||
|
typedef signed long gssize;
|
||||||
|
typedef unsigned long gsize;
|
||||||
|
#define G_GSIZE_MODIFIER "l"
|
||||||
|
#define G_GSSIZE_MODIFIER "l"
|
||||||
|
#define G_GSIZE_FORMAT "lu"
|
||||||
|
#define G_GSSIZE_FORMAT "li"
|
||||||
|
|
||||||
|
#define G_MAXSIZE G_MAXULONG
|
||||||
|
#define G_MINSSIZE G_MINLONG
|
||||||
|
#define G_MAXSSIZE G_MAXLONG
|
||||||
|
|
||||||
|
typedef gint64 goffset;
|
||||||
|
#define G_MINOFFSET G_MININT64
|
||||||
|
#define G_MAXOFFSET G_MAXINT64
|
||||||
|
|
||||||
|
#define G_GOFFSET_MODIFIER G_GINT64_MODIFIER
|
||||||
|
#define G_GOFFSET_FORMAT G_GINT64_FORMAT
|
||||||
|
#define G_GOFFSET_CONSTANT(val) G_GINT64_CONSTANT(val)
|
||||||
|
|
||||||
|
#define G_POLLFD_FORMAT "%d"
|
||||||
|
|
||||||
|
#define GPOINTER_TO_INT(p) ((gint) (glong) (p))
|
||||||
|
#define GPOINTER_TO_UINT(p) ((guint) (gulong) (p))
|
||||||
|
|
||||||
|
#define GINT_TO_POINTER(i) ((gpointer) (glong) (i))
|
||||||
|
#define GUINT_TO_POINTER(u) ((gpointer) (gulong) (u))
|
||||||
|
|
||||||
|
typedef signed long gintptr;
|
||||||
|
typedef unsigned long guintptr;
|
||||||
|
|
||||||
|
#define G_GINTPTR_MODIFIER "l"
|
||||||
|
#define G_GINTPTR_FORMAT "li"
|
||||||
|
#define G_GUINTPTR_FORMAT "lu"
|
||||||
|
|
||||||
|
#define GLIB_MAJOR_VERSION 2
|
||||||
|
#define GLIB_MINOR_VERSION 89
|
||||||
|
#define GLIB_MICRO_VERSION 1
|
||||||
|
|
||||||
|
#define G_OS_UNIX
|
||||||
|
|
||||||
|
#define G_VA_COPY va_copy
|
||||||
|
|
||||||
|
#define G_VA_COPY_AS_ARRAY 1
|
||||||
|
|
||||||
|
#define G_HAVE_ISO_VARARGS 1
|
||||||
|
|
||||||
|
/* gcc-2.95.x supports both gnu style and ISO varargs, but if -ansi
|
||||||
|
* is passed ISO vararg support is turned off, and there is no work
|
||||||
|
* around to turn it on, so we unconditionally turn it off.
|
||||||
|
*/
|
||||||
|
#if __GNUC__ == 2 && __GNUC_MINOR__ == 95
|
||||||
|
# undef G_HAVE_ISO_VARARGS
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define G_HAVE_GROWING_STACK 0
|
||||||
|
|
||||||
|
#ifndef _MSC_VER
|
||||||
|
# define G_HAVE_GNUC_VARARGS 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)
|
||||||
|
#define G_GNUC_INTERNAL __attribute__((visibility("hidden")))
|
||||||
|
#elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x550)
|
||||||
|
#define G_GNUC_INTERNAL __hidden
|
||||||
|
#elif defined (__GNUC__) && defined (G_HAVE_GNUC_VISIBILITY)
|
||||||
|
#define G_GNUC_INTERNAL __attribute__((visibility("hidden")))
|
||||||
|
#else
|
||||||
|
#define G_GNUC_INTERNAL
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define G_THREADS_ENABLED
|
||||||
|
#define G_THREADS_IMPL_POSIX
|
||||||
|
|
||||||
|
#define G_ATOMIC_LOCK_FREE
|
||||||
|
|
||||||
|
#define GINT16_TO_LE(val) ((gint16) (val))
|
||||||
|
#define GUINT16_TO_LE(val) ((guint16) (val))
|
||||||
|
#define GINT16_TO_BE(val) ((gint16) GUINT16_SWAP_LE_BE (val))
|
||||||
|
#define GUINT16_TO_BE(val) (GUINT16_SWAP_LE_BE (val))
|
||||||
|
|
||||||
|
#define GINT32_TO_LE(val) ((gint32) (val))
|
||||||
|
#define GUINT32_TO_LE(val) ((guint32) (val))
|
||||||
|
#define GINT32_TO_BE(val) ((gint32) GUINT32_SWAP_LE_BE (val))
|
||||||
|
#define GUINT32_TO_BE(val) (GUINT32_SWAP_LE_BE (val))
|
||||||
|
|
||||||
|
#define GINT64_TO_LE(val) ((gint64) (val))
|
||||||
|
#define GUINT64_TO_LE(val) ((guint64) (val))
|
||||||
|
#define GINT64_TO_BE(val) ((gint64) GUINT64_SWAP_LE_BE (val))
|
||||||
|
#define GUINT64_TO_BE(val) (GUINT64_SWAP_LE_BE (val))
|
||||||
|
|
||||||
|
#define GLONG_TO_LE(val) ((glong) GINT64_TO_LE (val))
|
||||||
|
#define GULONG_TO_LE(val) ((gulong) GUINT64_TO_LE (val))
|
||||||
|
#define GLONG_TO_BE(val) ((glong) GINT64_TO_BE (val))
|
||||||
|
#define GULONG_TO_BE(val) ((gulong) GUINT64_TO_BE (val))
|
||||||
|
#define GINT_TO_LE(val) ((gint) GINT32_TO_LE (val))
|
||||||
|
#define GUINT_TO_LE(val) ((guint) GUINT32_TO_LE (val))
|
||||||
|
#define GINT_TO_BE(val) ((gint) GINT32_TO_BE (val))
|
||||||
|
#define GUINT_TO_BE(val) ((guint) GUINT32_TO_BE (val))
|
||||||
|
#define GSIZE_TO_LE(val) ((gsize) GUINT64_TO_LE (val))
|
||||||
|
#define GSSIZE_TO_LE(val) ((gssize) GINT64_TO_LE (val))
|
||||||
|
#define GSIZE_TO_BE(val) ((gsize) GUINT64_TO_BE (val))
|
||||||
|
#define GSSIZE_TO_BE(val) ((gssize) GINT64_TO_BE (val))
|
||||||
|
#define G_BYTE_ORDER G_LITTLE_ENDIAN
|
||||||
|
|
||||||
|
#define GLIB_SYSDEF_POLLIN =1
|
||||||
|
#define GLIB_SYSDEF_POLLOUT =4
|
||||||
|
#define GLIB_SYSDEF_POLLPRI =2
|
||||||
|
#define GLIB_SYSDEF_POLLHUP =16
|
||||||
|
#define GLIB_SYSDEF_POLLERR =8
|
||||||
|
#define GLIB_SYSDEF_POLLNVAL =32
|
||||||
|
|
||||||
|
/* No way to disable deprecation warnings for macros, so only emit deprecation
|
||||||
|
* warnings on platforms where usage of this macro is broken */
|
||||||
|
#if defined(__APPLE__) || defined(_MSC_VER) || defined(__CYGWIN__)
|
||||||
|
#define G_MODULE_SUFFIX "so" GLIB_DEPRECATED_MACRO_IN_2_76
|
||||||
|
#else
|
||||||
|
#define G_MODULE_SUFFIX "so"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef int GPid;
|
||||||
|
#define G_PID_FORMAT "i"
|
||||||
|
|
||||||
|
#define GLIB_SYSDEF_AF_UNIX 1
|
||||||
|
#define GLIB_SYSDEF_AF_INET 2
|
||||||
|
#define GLIB_SYSDEF_AF_INET6 10
|
||||||
|
|
||||||
|
#define GLIB_SYSDEF_MSG_OOB 1
|
||||||
|
#define GLIB_SYSDEF_MSG_PEEK 2
|
||||||
|
#define GLIB_SYSDEF_MSG_DONTROUTE 4
|
||||||
|
|
||||||
|
#define G_DIR_SEPARATOR '/'
|
||||||
|
#define G_DIR_SEPARATOR_S "/"
|
||||||
|
#define G_SEARCHPATH_SEPARATOR ':'
|
||||||
|
#define G_SEARCHPATH_SEPARATOR_S ":"
|
||||||
|
|
||||||
|
#undef G_HAVE_FREE_SIZED
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif /* __GLIBCONFIG_H__ */
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
module.exports = __dirname;
|
||||||
BIN
Binary file not shown.
+43
@@ -0,0 +1,43 @@
|
|||||||
|
{
|
||||||
|
"name": "@img/sharp-libvips-linux-x64",
|
||||||
|
"version": "1.3.2",
|
||||||
|
"description": "Prebuilt libvips and dependencies for use with sharp on Linux (glibc) x64",
|
||||||
|
"author": "Lovell Fuller <npm@lovell.info>",
|
||||||
|
"homepage": "https://sharp.pixelplumbing.com",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git+https://github.com/lovell/sharp-libvips.git",
|
||||||
|
"directory": "npm/linux-x64"
|
||||||
|
},
|
||||||
|
"license": "LGPL-3.0-or-later",
|
||||||
|
"funding": {
|
||||||
|
"url": "https://opencollective.com/libvips"
|
||||||
|
},
|
||||||
|
"preferUnplugged": true,
|
||||||
|
"publishConfig": {
|
||||||
|
"access": "public"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"lib",
|
||||||
|
"versions.json"
|
||||||
|
],
|
||||||
|
"type": "commonjs",
|
||||||
|
"exports": {
|
||||||
|
"./lib": "./lib/index.js",
|
||||||
|
"./package": "./package.json",
|
||||||
|
"./versions": "./versions.json",
|
||||||
|
"./binary": "./lib/libvips-cpp.so.8.18.3"
|
||||||
|
},
|
||||||
|
"config": {
|
||||||
|
"glibc": ">=2.28"
|
||||||
|
},
|
||||||
|
"os": [
|
||||||
|
"linux"
|
||||||
|
],
|
||||||
|
"libc": [
|
||||||
|
"glibc"
|
||||||
|
],
|
||||||
|
"cpu": [
|
||||||
|
"x64"
|
||||||
|
]
|
||||||
|
}
|
||||||
+30
@@ -0,0 +1,30 @@
|
|||||||
|
{
|
||||||
|
"aom": "3.14.1",
|
||||||
|
"archive": "3.8.8",
|
||||||
|
"cairo": "1.18.4",
|
||||||
|
"cgif": "0.5.3",
|
||||||
|
"exif": "0.6.26",
|
||||||
|
"expat": "2.8.2",
|
||||||
|
"ffi": "3.6.0",
|
||||||
|
"fontconfig": "2.18.1",
|
||||||
|
"freetype": "2.14.3",
|
||||||
|
"fribidi": "1.0.16",
|
||||||
|
"glib": "2.89.1",
|
||||||
|
"harfbuzz": "14.2.1",
|
||||||
|
"heif": "1.23.1",
|
||||||
|
"highway": "1.4.0",
|
||||||
|
"imagequant": "2.4.1",
|
||||||
|
"lcms": "2.19.1",
|
||||||
|
"mozjpeg": "0826579",
|
||||||
|
"pango": "1.58.0",
|
||||||
|
"pixman": "0.46.4",
|
||||||
|
"png": "1.6.58",
|
||||||
|
"proxy-libintl": "0.5",
|
||||||
|
"rsvg": "2.62.90",
|
||||||
|
"tiff": "d01a94b",
|
||||||
|
"uhdr": "1acdbed",
|
||||||
|
"vips": "8.18.3",
|
||||||
|
"webp": "1.6.0",
|
||||||
|
"xml2": "2.15.3",
|
||||||
|
"zlib-ng": "2.3.3"
|
||||||
|
}
|
||||||
+46
@@ -0,0 +1,46 @@
|
|||||||
|
# `@img/sharp-libvips-linuxmusl-x64`
|
||||||
|
|
||||||
|
Prebuilt libvips and dependencies for use with sharp on Linux (musl) x64.
|
||||||
|
|
||||||
|
## Licensing
|
||||||
|
|
||||||
|
This software contains third-party libraries
|
||||||
|
used under the terms of the following licenses:
|
||||||
|
|
||||||
|
| Library | Used under the terms of |
|
||||||
|
|---------------|-----------------------------------------------------------------------------------------------------------|
|
||||||
|
| aom | BSD 2-Clause + [Alliance for Open Media Patent License 1.0](https://aomedia.org/license/patent-license/) |
|
||||||
|
| cairo | Mozilla Public License 2.0 |
|
||||||
|
| cgif | MIT License |
|
||||||
|
| expat | MIT License |
|
||||||
|
| fontconfig | [fontconfig License](https://gitlab.freedesktop.org/fontconfig/fontconfig/blob/main/COPYING) (BSD-like) |
|
||||||
|
| freetype | [freetype License](https://git.savannah.gnu.org/cgit/freetype/freetype2.git/tree/docs/FTL.TXT) (BSD-like) |
|
||||||
|
| fribidi | LGPLv3 |
|
||||||
|
| glib | LGPLv3 |
|
||||||
|
| harfbuzz | MIT License |
|
||||||
|
| highway | BSD 3-Clause |
|
||||||
|
| lcms | MIT License |
|
||||||
|
| libarchive | BSD 2-Clause |
|
||||||
|
| libexif | LGPLv3 |
|
||||||
|
| libffi | MIT License |
|
||||||
|
| libheif | LGPLv3 |
|
||||||
|
| libimagequant | [BSD 2-Clause](https://github.com/lovell/libimagequant/blob/main/COPYRIGHT) |
|
||||||
|
| libnsgif | MIT License |
|
||||||
|
| libpng | [libpng License](https://github.com/pnggroup/libpng/blob/master/LICENSE) |
|
||||||
|
| librsvg | LGPLv3 |
|
||||||
|
| libtiff | [libtiff License](https://gitlab.com/libtiff/libtiff/blob/master/LICENSE.md) (BSD-like) |
|
||||||
|
| libultrahdr | MIT License |
|
||||||
|
| libvips | LGPLv3 |
|
||||||
|
| libwebp | New BSD License |
|
||||||
|
| libxml2 | MIT License |
|
||||||
|
| mozjpeg | [zlib License, IJG License, BSD 3-Clause](https://github.com/mozilla/mozjpeg/blob/master/LICENSE.md) |
|
||||||
|
| pango | LGPLv3 |
|
||||||
|
| pixman | MIT License |
|
||||||
|
| proxy-libintl | LGPLv3 |
|
||||||
|
| zlib-ng | [zlib License](https://github.com/zlib-ng/zlib-ng/blob/develop/LICENSE.md) |
|
||||||
|
|
||||||
|
Use of libraries under the terms of the LGPLv3 is via the
|
||||||
|
"any later version" clause of the LGPLv2 or LGPLv2.1.
|
||||||
|
|
||||||
|
Please report any errors or omissions via
|
||||||
|
https://github.com/lovell/sharp-libvips/issues/new
|
||||||
+219
@@ -0,0 +1,219 @@
|
|||||||
|
/* glibconfig.h
|
||||||
|
*
|
||||||
|
* This is a generated file. Please modify 'glibconfig.h.in'
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __GLIBCONFIG_H__
|
||||||
|
#define __GLIBCONFIG_H__
|
||||||
|
|
||||||
|
#include <glib/gmacros.h>
|
||||||
|
|
||||||
|
#include <limits.h>
|
||||||
|
#include <float.h>
|
||||||
|
#define GLIB_HAVE_ALLOCA_H
|
||||||
|
|
||||||
|
#define GLIB_STATIC_COMPILATION 1
|
||||||
|
#define GOBJECT_STATIC_COMPILATION 1
|
||||||
|
#define GIO_STATIC_COMPILATION 1
|
||||||
|
#define GMODULE_STATIC_COMPILATION 1
|
||||||
|
#define GI_STATIC_COMPILATION 1
|
||||||
|
|
||||||
|
/* Specifies that GLib's g_print*() functions wrap the
|
||||||
|
* system printf functions. This is useful to know, for example,
|
||||||
|
* when using glibc's register_printf_function().
|
||||||
|
*/
|
||||||
|
#define GLIB_USING_SYSTEM_PRINTF
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
#define G_MINFLOAT FLT_MIN
|
||||||
|
#define G_MAXFLOAT FLT_MAX
|
||||||
|
#define G_MINDOUBLE DBL_MIN
|
||||||
|
#define G_MAXDOUBLE DBL_MAX
|
||||||
|
#define G_MINSHORT SHRT_MIN
|
||||||
|
#define G_MAXSHORT SHRT_MAX
|
||||||
|
#define G_MAXUSHORT USHRT_MAX
|
||||||
|
#define G_MININT INT_MIN
|
||||||
|
#define G_MAXINT INT_MAX
|
||||||
|
#define G_MAXUINT UINT_MAX
|
||||||
|
#define G_MINLONG LONG_MIN
|
||||||
|
#define G_MAXLONG LONG_MAX
|
||||||
|
#define G_MAXULONG ULONG_MAX
|
||||||
|
|
||||||
|
typedef signed char gint8;
|
||||||
|
typedef unsigned char guint8;
|
||||||
|
|
||||||
|
typedef signed short gint16;
|
||||||
|
typedef unsigned short guint16;
|
||||||
|
|
||||||
|
#define G_GINT16_MODIFIER "h"
|
||||||
|
#define G_GINT16_FORMAT "hi"
|
||||||
|
#define G_GUINT16_FORMAT "hu"
|
||||||
|
|
||||||
|
|
||||||
|
typedef signed int gint32;
|
||||||
|
typedef unsigned int guint32;
|
||||||
|
|
||||||
|
#define G_GINT32_MODIFIER ""
|
||||||
|
#define G_GINT32_FORMAT "i"
|
||||||
|
#define G_GUINT32_FORMAT "u"
|
||||||
|
|
||||||
|
|
||||||
|
#define G_HAVE_GINT64 1 /* deprecated, always true */
|
||||||
|
|
||||||
|
typedef signed long gint64;
|
||||||
|
typedef unsigned long guint64;
|
||||||
|
|
||||||
|
#define G_GINT64_CONSTANT(val) (val##L)
|
||||||
|
#define G_GUINT64_CONSTANT(val) (val##UL)
|
||||||
|
|
||||||
|
#define G_GINT64_MODIFIER "l"
|
||||||
|
#define G_GINT64_FORMAT "li"
|
||||||
|
#define G_GUINT64_FORMAT "lu"
|
||||||
|
|
||||||
|
|
||||||
|
#define GLIB_SIZEOF_VOID_P 8
|
||||||
|
#define GLIB_SIZEOF_LONG 8
|
||||||
|
#define GLIB_SIZEOF_SIZE_T 8
|
||||||
|
#define GLIB_SIZEOF_SSIZE_T 8
|
||||||
|
|
||||||
|
typedef signed long gssize;
|
||||||
|
typedef unsigned long gsize;
|
||||||
|
#define G_GSIZE_MODIFIER "l"
|
||||||
|
#define G_GSSIZE_MODIFIER "l"
|
||||||
|
#define G_GSIZE_FORMAT "lu"
|
||||||
|
#define G_GSSIZE_FORMAT "li"
|
||||||
|
|
||||||
|
#define G_MAXSIZE G_MAXULONG
|
||||||
|
#define G_MINSSIZE G_MINLONG
|
||||||
|
#define G_MAXSSIZE G_MAXLONG
|
||||||
|
|
||||||
|
typedef gint64 goffset;
|
||||||
|
#define G_MINOFFSET G_MININT64
|
||||||
|
#define G_MAXOFFSET G_MAXINT64
|
||||||
|
|
||||||
|
#define G_GOFFSET_MODIFIER G_GINT64_MODIFIER
|
||||||
|
#define G_GOFFSET_FORMAT G_GINT64_FORMAT
|
||||||
|
#define G_GOFFSET_CONSTANT(val) G_GINT64_CONSTANT(val)
|
||||||
|
|
||||||
|
#define G_POLLFD_FORMAT "%d"
|
||||||
|
|
||||||
|
#define GPOINTER_TO_INT(p) ((gint) (glong) (p))
|
||||||
|
#define GPOINTER_TO_UINT(p) ((guint) (gulong) (p))
|
||||||
|
|
||||||
|
#define GINT_TO_POINTER(i) ((gpointer) (glong) (i))
|
||||||
|
#define GUINT_TO_POINTER(u) ((gpointer) (gulong) (u))
|
||||||
|
|
||||||
|
typedef signed long gintptr;
|
||||||
|
typedef unsigned long guintptr;
|
||||||
|
|
||||||
|
#define G_GINTPTR_MODIFIER "l"
|
||||||
|
#define G_GINTPTR_FORMAT "li"
|
||||||
|
#define G_GUINTPTR_FORMAT "lu"
|
||||||
|
|
||||||
|
#define GLIB_MAJOR_VERSION 2
|
||||||
|
#define GLIB_MINOR_VERSION 89
|
||||||
|
#define GLIB_MICRO_VERSION 1
|
||||||
|
|
||||||
|
#define G_OS_UNIX
|
||||||
|
|
||||||
|
#define G_VA_COPY va_copy
|
||||||
|
|
||||||
|
#define G_VA_COPY_AS_ARRAY 1
|
||||||
|
|
||||||
|
#define G_HAVE_ISO_VARARGS 1
|
||||||
|
|
||||||
|
/* gcc-2.95.x supports both gnu style and ISO varargs, but if -ansi
|
||||||
|
* is passed ISO vararg support is turned off, and there is no work
|
||||||
|
* around to turn it on, so we unconditionally turn it off.
|
||||||
|
*/
|
||||||
|
#if __GNUC__ == 2 && __GNUC_MINOR__ == 95
|
||||||
|
# undef G_HAVE_ISO_VARARGS
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define G_HAVE_GROWING_STACK 0
|
||||||
|
|
||||||
|
#ifndef _MSC_VER
|
||||||
|
# define G_HAVE_GNUC_VARARGS 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)
|
||||||
|
#define G_GNUC_INTERNAL __attribute__((visibility("hidden")))
|
||||||
|
#elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x550)
|
||||||
|
#define G_GNUC_INTERNAL __hidden
|
||||||
|
#elif defined (__GNUC__) && defined (G_HAVE_GNUC_VISIBILITY)
|
||||||
|
#define G_GNUC_INTERNAL __attribute__((visibility("hidden")))
|
||||||
|
#else
|
||||||
|
#define G_GNUC_INTERNAL
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define G_THREADS_ENABLED
|
||||||
|
#define G_THREADS_IMPL_POSIX
|
||||||
|
|
||||||
|
#define G_ATOMIC_LOCK_FREE
|
||||||
|
|
||||||
|
#define GINT16_TO_LE(val) ((gint16) (val))
|
||||||
|
#define GUINT16_TO_LE(val) ((guint16) (val))
|
||||||
|
#define GINT16_TO_BE(val) ((gint16) GUINT16_SWAP_LE_BE (val))
|
||||||
|
#define GUINT16_TO_BE(val) (GUINT16_SWAP_LE_BE (val))
|
||||||
|
|
||||||
|
#define GINT32_TO_LE(val) ((gint32) (val))
|
||||||
|
#define GUINT32_TO_LE(val) ((guint32) (val))
|
||||||
|
#define GINT32_TO_BE(val) ((gint32) GUINT32_SWAP_LE_BE (val))
|
||||||
|
#define GUINT32_TO_BE(val) (GUINT32_SWAP_LE_BE (val))
|
||||||
|
|
||||||
|
#define GINT64_TO_LE(val) ((gint64) (val))
|
||||||
|
#define GUINT64_TO_LE(val) ((guint64) (val))
|
||||||
|
#define GINT64_TO_BE(val) ((gint64) GUINT64_SWAP_LE_BE (val))
|
||||||
|
#define GUINT64_TO_BE(val) (GUINT64_SWAP_LE_BE (val))
|
||||||
|
|
||||||
|
#define GLONG_TO_LE(val) ((glong) GINT64_TO_LE (val))
|
||||||
|
#define GULONG_TO_LE(val) ((gulong) GUINT64_TO_LE (val))
|
||||||
|
#define GLONG_TO_BE(val) ((glong) GINT64_TO_BE (val))
|
||||||
|
#define GULONG_TO_BE(val) ((gulong) GUINT64_TO_BE (val))
|
||||||
|
#define GINT_TO_LE(val) ((gint) GINT32_TO_LE (val))
|
||||||
|
#define GUINT_TO_LE(val) ((guint) GUINT32_TO_LE (val))
|
||||||
|
#define GINT_TO_BE(val) ((gint) GINT32_TO_BE (val))
|
||||||
|
#define GUINT_TO_BE(val) ((guint) GUINT32_TO_BE (val))
|
||||||
|
#define GSIZE_TO_LE(val) ((gsize) GUINT64_TO_LE (val))
|
||||||
|
#define GSSIZE_TO_LE(val) ((gssize) GINT64_TO_LE (val))
|
||||||
|
#define GSIZE_TO_BE(val) ((gsize) GUINT64_TO_BE (val))
|
||||||
|
#define GSSIZE_TO_BE(val) ((gssize) GINT64_TO_BE (val))
|
||||||
|
#define G_BYTE_ORDER G_LITTLE_ENDIAN
|
||||||
|
|
||||||
|
#define GLIB_SYSDEF_POLLIN =1
|
||||||
|
#define GLIB_SYSDEF_POLLOUT =4
|
||||||
|
#define GLIB_SYSDEF_POLLPRI =2
|
||||||
|
#define GLIB_SYSDEF_POLLHUP =16
|
||||||
|
#define GLIB_SYSDEF_POLLERR =8
|
||||||
|
#define GLIB_SYSDEF_POLLNVAL =32
|
||||||
|
|
||||||
|
/* No way to disable deprecation warnings for macros, so only emit deprecation
|
||||||
|
* warnings on platforms where usage of this macro is broken */
|
||||||
|
#if defined(__APPLE__) || defined(_MSC_VER) || defined(__CYGWIN__)
|
||||||
|
#define G_MODULE_SUFFIX "so" GLIB_DEPRECATED_MACRO_IN_2_76
|
||||||
|
#else
|
||||||
|
#define G_MODULE_SUFFIX "so"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef int GPid;
|
||||||
|
#define G_PID_FORMAT "i"
|
||||||
|
|
||||||
|
#define GLIB_SYSDEF_AF_UNIX 1
|
||||||
|
#define GLIB_SYSDEF_AF_INET 2
|
||||||
|
#define GLIB_SYSDEF_AF_INET6 10
|
||||||
|
|
||||||
|
#define GLIB_SYSDEF_MSG_OOB 1
|
||||||
|
#define GLIB_SYSDEF_MSG_PEEK 2
|
||||||
|
#define GLIB_SYSDEF_MSG_DONTROUTE 4
|
||||||
|
|
||||||
|
#define G_DIR_SEPARATOR '/'
|
||||||
|
#define G_DIR_SEPARATOR_S "/"
|
||||||
|
#define G_SEARCHPATH_SEPARATOR ':'
|
||||||
|
#define G_SEARCHPATH_SEPARATOR_S ":"
|
||||||
|
|
||||||
|
#undef G_HAVE_FREE_SIZED
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif /* __GLIBCONFIG_H__ */
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
module.exports = __dirname;
|
||||||
BIN
Binary file not shown.
+43
@@ -0,0 +1,43 @@
|
|||||||
|
{
|
||||||
|
"name": "@img/sharp-libvips-linuxmusl-x64",
|
||||||
|
"version": "1.3.2",
|
||||||
|
"description": "Prebuilt libvips and dependencies for use with sharp on Linux (musl) x64",
|
||||||
|
"author": "Lovell Fuller <npm@lovell.info>",
|
||||||
|
"homepage": "https://sharp.pixelplumbing.com",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git+https://github.com/lovell/sharp-libvips.git",
|
||||||
|
"directory": "npm/linuxmusl-x64"
|
||||||
|
},
|
||||||
|
"license": "LGPL-3.0-or-later",
|
||||||
|
"funding": {
|
||||||
|
"url": "https://opencollective.com/libvips"
|
||||||
|
},
|
||||||
|
"preferUnplugged": true,
|
||||||
|
"publishConfig": {
|
||||||
|
"access": "public"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"lib",
|
||||||
|
"versions.json"
|
||||||
|
],
|
||||||
|
"type": "commonjs",
|
||||||
|
"exports": {
|
||||||
|
"./lib": "./lib/index.js",
|
||||||
|
"./package": "./package.json",
|
||||||
|
"./versions": "./versions.json",
|
||||||
|
"./binary": "./lib/libvips-cpp.so.8.18.3"
|
||||||
|
},
|
||||||
|
"config": {
|
||||||
|
"musl": ">=1.2.5"
|
||||||
|
},
|
||||||
|
"os": [
|
||||||
|
"linux"
|
||||||
|
],
|
||||||
|
"libc": [
|
||||||
|
"musl"
|
||||||
|
],
|
||||||
|
"cpu": [
|
||||||
|
"x64"
|
||||||
|
]
|
||||||
|
}
|
||||||
+30
@@ -0,0 +1,30 @@
|
|||||||
|
{
|
||||||
|
"aom": "3.14.1",
|
||||||
|
"archive": "3.8.8",
|
||||||
|
"cairo": "1.18.4",
|
||||||
|
"cgif": "0.5.3",
|
||||||
|
"exif": "0.6.26",
|
||||||
|
"expat": "2.8.2",
|
||||||
|
"ffi": "3.6.0",
|
||||||
|
"fontconfig": "2.18.1",
|
||||||
|
"freetype": "2.14.3",
|
||||||
|
"fribidi": "1.0.16",
|
||||||
|
"glib": "2.89.1",
|
||||||
|
"harfbuzz": "14.2.1",
|
||||||
|
"heif": "1.23.1",
|
||||||
|
"highway": "1.4.0",
|
||||||
|
"imagequant": "2.4.1",
|
||||||
|
"lcms": "2.19.1",
|
||||||
|
"mozjpeg": "0826579",
|
||||||
|
"pango": "1.58.0",
|
||||||
|
"pixman": "0.46.4",
|
||||||
|
"png": "1.6.58",
|
||||||
|
"proxy-libintl": "0.5",
|
||||||
|
"rsvg": "2.62.90",
|
||||||
|
"tiff": "d01a94b",
|
||||||
|
"uhdr": "1acdbed",
|
||||||
|
"vips": "8.18.3",
|
||||||
|
"webp": "1.6.0",
|
||||||
|
"xml2": "2.15.3",
|
||||||
|
"zlib-ng": "2.3.3"
|
||||||
|
}
|
||||||
+191
@@ -0,0 +1,191 @@
|
|||||||
|
Apache License
|
||||||
|
Version 2.0, January 2004
|
||||||
|
http://www.apache.org/licenses/
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||||
|
|
||||||
|
1. Definitions.
|
||||||
|
|
||||||
|
"License" shall mean the terms and conditions for use, reproduction, and
|
||||||
|
distribution as defined by Sections 1 through 9 of this document.
|
||||||
|
|
||||||
|
"Licensor" shall mean the copyright owner or entity authorized by the copyright
|
||||||
|
owner that is granting the License.
|
||||||
|
|
||||||
|
"Legal Entity" shall mean the union of the acting entity and all other entities
|
||||||
|
that control, are controlled by, or are under common control with that entity.
|
||||||
|
For the purposes of this definition, "control" means (i) the power, direct or
|
||||||
|
indirect, to cause the direction or management of such entity, whether by
|
||||||
|
contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||||
|
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||||
|
|
||||||
|
"You" (or "Your") shall mean an individual or Legal Entity exercising
|
||||||
|
permissions granted by this License.
|
||||||
|
|
||||||
|
"Source" form shall mean the preferred form for making modifications, including
|
||||||
|
but not limited to software source code, documentation source, and configuration
|
||||||
|
files.
|
||||||
|
|
||||||
|
"Object" form shall mean any form resulting from mechanical transformation or
|
||||||
|
translation of a Source form, including but not limited to compiled object code,
|
||||||
|
generated documentation, and conversions to other media types.
|
||||||
|
|
||||||
|
"Work" shall mean the work of authorship, whether in Source or Object form, made
|
||||||
|
available under the License, as indicated by a copyright notice that is included
|
||||||
|
in or attached to the work (an example is provided in the Appendix below).
|
||||||
|
|
||||||
|
"Derivative Works" shall mean any work, whether in Source or Object form, that
|
||||||
|
is based on (or derived from) the Work and for which the editorial revisions,
|
||||||
|
annotations, elaborations, or other modifications represent, as a whole, an
|
||||||
|
original work of authorship. For the purposes of this License, Derivative Works
|
||||||
|
shall not include works that remain separable from, or merely link (or bind by
|
||||||
|
name) to the interfaces of, the Work and Derivative Works thereof.
|
||||||
|
|
||||||
|
"Contribution" shall mean any work of authorship, including the original version
|
||||||
|
of the Work and any modifications or additions to that Work or Derivative Works
|
||||||
|
thereof, that is intentionally submitted to Licensor for inclusion in the Work
|
||||||
|
by the copyright owner or by an individual or Legal Entity authorized to submit
|
||||||
|
on behalf of the copyright owner. For the purposes of this definition,
|
||||||
|
"submitted" means any form of electronic, verbal, or written communication sent
|
||||||
|
to the Licensor or its representatives, including but not limited to
|
||||||
|
communication on electronic mailing lists, source code control systems, and
|
||||||
|
issue tracking systems that are managed by, or on behalf of, the Licensor for
|
||||||
|
the purpose of discussing and improving the Work, but excluding communication
|
||||||
|
that is conspicuously marked or otherwise designated in writing by the copyright
|
||||||
|
owner as "Not a Contribution."
|
||||||
|
|
||||||
|
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf
|
||||||
|
of whom a Contribution has been received by Licensor and subsequently
|
||||||
|
incorporated within the Work.
|
||||||
|
|
||||||
|
2. Grant of Copyright License.
|
||||||
|
|
||||||
|
Subject to the terms and conditions of this License, each Contributor hereby
|
||||||
|
grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
|
||||||
|
irrevocable copyright license to reproduce, prepare Derivative Works of,
|
||||||
|
publicly display, publicly perform, sublicense, and distribute the Work and such
|
||||||
|
Derivative Works in Source or Object form.
|
||||||
|
|
||||||
|
3. Grant of Patent License.
|
||||||
|
|
||||||
|
Subject to the terms and conditions of this License, each Contributor hereby
|
||||||
|
grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
|
||||||
|
irrevocable (except as stated in this section) patent license to make, have
|
||||||
|
made, use, offer to sell, sell, import, and otherwise transfer the Work, where
|
||||||
|
such license applies only to those patent claims licensable by such Contributor
|
||||||
|
that are necessarily infringed by their Contribution(s) alone or by combination
|
||||||
|
of their Contribution(s) with the Work to which such Contribution(s) was
|
||||||
|
submitted. If You institute patent litigation against any entity (including a
|
||||||
|
cross-claim or counterclaim in a lawsuit) alleging that the Work or a
|
||||||
|
Contribution incorporated within the Work constitutes direct or contributory
|
||||||
|
patent infringement, then any patent licenses granted to You under this License
|
||||||
|
for that Work shall terminate as of the date such litigation is filed.
|
||||||
|
|
||||||
|
4. Redistribution.
|
||||||
|
|
||||||
|
You may reproduce and distribute copies of the Work or Derivative Works thereof
|
||||||
|
in any medium, with or without modifications, and in Source or Object form,
|
||||||
|
provided that You meet the following conditions:
|
||||||
|
|
||||||
|
You must give any other recipients of the Work or Derivative Works a copy of
|
||||||
|
this License; and
|
||||||
|
You must cause any modified files to carry prominent notices stating that You
|
||||||
|
changed the files; and
|
||||||
|
You must retain, in the Source form of any Derivative Works that You distribute,
|
||||||
|
all copyright, patent, trademark, and attribution notices from the Source form
|
||||||
|
of the Work, excluding those notices that do not pertain to any part of the
|
||||||
|
Derivative Works; and
|
||||||
|
If the Work includes a "NOTICE" text file as part of its distribution, then any
|
||||||
|
Derivative Works that You distribute must include a readable copy of the
|
||||||
|
attribution notices contained within such NOTICE file, excluding those notices
|
||||||
|
that do not pertain to any part of the Derivative Works, in at least one of the
|
||||||
|
following places: within a NOTICE text file distributed as part of the
|
||||||
|
Derivative Works; within the Source form or documentation, if provided along
|
||||||
|
with the Derivative Works; or, within a display generated by the Derivative
|
||||||
|
Works, if and wherever such third-party notices normally appear. The contents of
|
||||||
|
the NOTICE file are for informational purposes only and do not modify the
|
||||||
|
License. You may add Your own attribution notices within Derivative Works that
|
||||||
|
You distribute, alongside or as an addendum to the NOTICE text from the Work,
|
||||||
|
provided that such additional attribution notices cannot be construed as
|
||||||
|
modifying the License.
|
||||||
|
You may add Your own copyright statement to Your modifications and may provide
|
||||||
|
additional or different license terms and conditions for use, reproduction, or
|
||||||
|
distribution of Your modifications, or for any such Derivative Works as a whole,
|
||||||
|
provided Your use, reproduction, and distribution of the Work otherwise complies
|
||||||
|
with the conditions stated in this License.
|
||||||
|
|
||||||
|
5. Submission of Contributions.
|
||||||
|
|
||||||
|
Unless You explicitly state otherwise, any Contribution intentionally submitted
|
||||||
|
for inclusion in the Work by You to the Licensor shall be under the terms and
|
||||||
|
conditions of this License, without any additional terms or conditions.
|
||||||
|
Notwithstanding the above, nothing herein shall supersede or modify the terms of
|
||||||
|
any separate license agreement you may have executed with Licensor regarding
|
||||||
|
such Contributions.
|
||||||
|
|
||||||
|
6. Trademarks.
|
||||||
|
|
||||||
|
This License does not grant permission to use the trade names, trademarks,
|
||||||
|
service marks, or product names of the Licensor, except as required for
|
||||||
|
reasonable and customary use in describing the origin of the Work and
|
||||||
|
reproducing the content of the NOTICE file.
|
||||||
|
|
||||||
|
7. Disclaimer of Warranty.
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, Licensor provides the
|
||||||
|
Work (and each Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
|
||||||
|
including, without limitation, any warranties or conditions of TITLE,
|
||||||
|
NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are
|
||||||
|
solely responsible for determining the appropriateness of using or
|
||||||
|
redistributing the Work and assume any risks associated with Your exercise of
|
||||||
|
permissions under this License.
|
||||||
|
|
||||||
|
8. Limitation of Liability.
|
||||||
|
|
||||||
|
In no event and under no legal theory, whether in tort (including negligence),
|
||||||
|
contract, or otherwise, unless required by applicable law (such as deliberate
|
||||||
|
and grossly negligent acts) or agreed to in writing, shall any Contributor be
|
||||||
|
liable to You for damages, including any direct, indirect, special, incidental,
|
||||||
|
or consequential damages of any character arising as a result of this License or
|
||||||
|
out of the use or inability to use the Work (including but not limited to
|
||||||
|
damages for loss of goodwill, work stoppage, computer failure or malfunction, or
|
||||||
|
any and all other commercial damages or losses), even if such Contributor has
|
||||||
|
been advised of the possibility of such damages.
|
||||||
|
|
||||||
|
9. Accepting Warranty or Additional Liability.
|
||||||
|
|
||||||
|
While redistributing the Work or Derivative Works thereof, You may choose to
|
||||||
|
offer, and charge a fee for, acceptance of support, warranty, indemnity, or
|
||||||
|
other liability obligations and/or rights consistent with this License. However,
|
||||||
|
in accepting such obligations, You may act only on Your own behalf and on Your
|
||||||
|
sole responsibility, not on behalf of any other Contributor, and only if You
|
||||||
|
agree to indemnify, defend, and hold each Contributor harmless for any liability
|
||||||
|
incurred by, or claims asserted against, such Contributor by reason of your
|
||||||
|
accepting any such warranty or additional liability.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
APPENDIX: How to apply the Apache License to your work
|
||||||
|
|
||||||
|
To apply the Apache License to your work, attach the following boilerplate
|
||||||
|
notice, with the fields enclosed by brackets "[]" replaced with your own
|
||||||
|
identifying information. (Don't include the brackets!) The text should be
|
||||||
|
enclosed in the appropriate comment syntax for the file format. We also
|
||||||
|
recommend that a file or class name and description of purpose be included on
|
||||||
|
the same "printed page" as the copyright notice for easier identification within
|
||||||
|
third-party archives.
|
||||||
|
|
||||||
|
Copyright [yyyy] [name of copyright owner]
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
+18
@@ -0,0 +1,18 @@
|
|||||||
|
# `@img/sharp-linux-x64`
|
||||||
|
|
||||||
|
Prebuilt sharp for use with Linux (glibc) x64.
|
||||||
|
|
||||||
|
## Licensing
|
||||||
|
|
||||||
|
Copyright 2013 Lovell Fuller and others.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
[https://www.apache.org/licenses/LICENSE-2.0](https://www.apache.org/licenses/LICENSE-2.0)
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
+2
@@ -0,0 +1,2 @@
|
|||||||
|
try { require.resolve('@img/sharp-libvips-linux-x64/binary'); } catch {}
|
||||||
|
module.exports = require('./lib/sharp-linux-x64-0.35.3.node');
|
||||||
BIN
Binary file not shown.
+47
@@ -0,0 +1,47 @@
|
|||||||
|
{
|
||||||
|
"name": "@img/sharp-linux-x64",
|
||||||
|
"version": "0.35.3",
|
||||||
|
"description": "Prebuilt sharp for use with Linux (glibc) x64",
|
||||||
|
"author": "Lovell Fuller <npm@lovell.info>",
|
||||||
|
"homepage": "https://sharp.pixelplumbing.com",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git+https://github.com/lovell/sharp.git",
|
||||||
|
"directory": "npm/linux-x64"
|
||||||
|
},
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"funding": {
|
||||||
|
"url": "https://opencollective.com/libvips"
|
||||||
|
},
|
||||||
|
"preferUnplugged": true,
|
||||||
|
"optionalDependencies": {
|
||||||
|
"@img/sharp-libvips-linux-x64": "1.3.2"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"index.cjs",
|
||||||
|
"lib"
|
||||||
|
],
|
||||||
|
"publishConfig": {
|
||||||
|
"access": "public"
|
||||||
|
},
|
||||||
|
"type": "commonjs",
|
||||||
|
"exports": {
|
||||||
|
"./sharp.node": "./index.cjs",
|
||||||
|
"./package": "./package.json"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=20.9.0"
|
||||||
|
},
|
||||||
|
"config": {
|
||||||
|
"glibc": ">=2.28"
|
||||||
|
},
|
||||||
|
"os": [
|
||||||
|
"linux"
|
||||||
|
],
|
||||||
|
"libc": [
|
||||||
|
"glibc"
|
||||||
|
],
|
||||||
|
"cpu": [
|
||||||
|
"x64"
|
||||||
|
]
|
||||||
|
}
|
||||||
+191
@@ -0,0 +1,191 @@
|
|||||||
|
Apache License
|
||||||
|
Version 2.0, January 2004
|
||||||
|
http://www.apache.org/licenses/
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||||
|
|
||||||
|
1. Definitions.
|
||||||
|
|
||||||
|
"License" shall mean the terms and conditions for use, reproduction, and
|
||||||
|
distribution as defined by Sections 1 through 9 of this document.
|
||||||
|
|
||||||
|
"Licensor" shall mean the copyright owner or entity authorized by the copyright
|
||||||
|
owner that is granting the License.
|
||||||
|
|
||||||
|
"Legal Entity" shall mean the union of the acting entity and all other entities
|
||||||
|
that control, are controlled by, or are under common control with that entity.
|
||||||
|
For the purposes of this definition, "control" means (i) the power, direct or
|
||||||
|
indirect, to cause the direction or management of such entity, whether by
|
||||||
|
contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||||
|
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||||
|
|
||||||
|
"You" (or "Your") shall mean an individual or Legal Entity exercising
|
||||||
|
permissions granted by this License.
|
||||||
|
|
||||||
|
"Source" form shall mean the preferred form for making modifications, including
|
||||||
|
but not limited to software source code, documentation source, and configuration
|
||||||
|
files.
|
||||||
|
|
||||||
|
"Object" form shall mean any form resulting from mechanical transformation or
|
||||||
|
translation of a Source form, including but not limited to compiled object code,
|
||||||
|
generated documentation, and conversions to other media types.
|
||||||
|
|
||||||
|
"Work" shall mean the work of authorship, whether in Source or Object form, made
|
||||||
|
available under the License, as indicated by a copyright notice that is included
|
||||||
|
in or attached to the work (an example is provided in the Appendix below).
|
||||||
|
|
||||||
|
"Derivative Works" shall mean any work, whether in Source or Object form, that
|
||||||
|
is based on (or derived from) the Work and for which the editorial revisions,
|
||||||
|
annotations, elaborations, or other modifications represent, as a whole, an
|
||||||
|
original work of authorship. For the purposes of this License, Derivative Works
|
||||||
|
shall not include works that remain separable from, or merely link (or bind by
|
||||||
|
name) to the interfaces of, the Work and Derivative Works thereof.
|
||||||
|
|
||||||
|
"Contribution" shall mean any work of authorship, including the original version
|
||||||
|
of the Work and any modifications or additions to that Work or Derivative Works
|
||||||
|
thereof, that is intentionally submitted to Licensor for inclusion in the Work
|
||||||
|
by the copyright owner or by an individual or Legal Entity authorized to submit
|
||||||
|
on behalf of the copyright owner. For the purposes of this definition,
|
||||||
|
"submitted" means any form of electronic, verbal, or written communication sent
|
||||||
|
to the Licensor or its representatives, including but not limited to
|
||||||
|
communication on electronic mailing lists, source code control systems, and
|
||||||
|
issue tracking systems that are managed by, or on behalf of, the Licensor for
|
||||||
|
the purpose of discussing and improving the Work, but excluding communication
|
||||||
|
that is conspicuously marked or otherwise designated in writing by the copyright
|
||||||
|
owner as "Not a Contribution."
|
||||||
|
|
||||||
|
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf
|
||||||
|
of whom a Contribution has been received by Licensor and subsequently
|
||||||
|
incorporated within the Work.
|
||||||
|
|
||||||
|
2. Grant of Copyright License.
|
||||||
|
|
||||||
|
Subject to the terms and conditions of this License, each Contributor hereby
|
||||||
|
grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
|
||||||
|
irrevocable copyright license to reproduce, prepare Derivative Works of,
|
||||||
|
publicly display, publicly perform, sublicense, and distribute the Work and such
|
||||||
|
Derivative Works in Source or Object form.
|
||||||
|
|
||||||
|
3. Grant of Patent License.
|
||||||
|
|
||||||
|
Subject to the terms and conditions of this License, each Contributor hereby
|
||||||
|
grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
|
||||||
|
irrevocable (except as stated in this section) patent license to make, have
|
||||||
|
made, use, offer to sell, sell, import, and otherwise transfer the Work, where
|
||||||
|
such license applies only to those patent claims licensable by such Contributor
|
||||||
|
that are necessarily infringed by their Contribution(s) alone or by combination
|
||||||
|
of their Contribution(s) with the Work to which such Contribution(s) was
|
||||||
|
submitted. If You institute patent litigation against any entity (including a
|
||||||
|
cross-claim or counterclaim in a lawsuit) alleging that the Work or a
|
||||||
|
Contribution incorporated within the Work constitutes direct or contributory
|
||||||
|
patent infringement, then any patent licenses granted to You under this License
|
||||||
|
for that Work shall terminate as of the date such litigation is filed.
|
||||||
|
|
||||||
|
4. Redistribution.
|
||||||
|
|
||||||
|
You may reproduce and distribute copies of the Work or Derivative Works thereof
|
||||||
|
in any medium, with or without modifications, and in Source or Object form,
|
||||||
|
provided that You meet the following conditions:
|
||||||
|
|
||||||
|
You must give any other recipients of the Work or Derivative Works a copy of
|
||||||
|
this License; and
|
||||||
|
You must cause any modified files to carry prominent notices stating that You
|
||||||
|
changed the files; and
|
||||||
|
You must retain, in the Source form of any Derivative Works that You distribute,
|
||||||
|
all copyright, patent, trademark, and attribution notices from the Source form
|
||||||
|
of the Work, excluding those notices that do not pertain to any part of the
|
||||||
|
Derivative Works; and
|
||||||
|
If the Work includes a "NOTICE" text file as part of its distribution, then any
|
||||||
|
Derivative Works that You distribute must include a readable copy of the
|
||||||
|
attribution notices contained within such NOTICE file, excluding those notices
|
||||||
|
that do not pertain to any part of the Derivative Works, in at least one of the
|
||||||
|
following places: within a NOTICE text file distributed as part of the
|
||||||
|
Derivative Works; within the Source form or documentation, if provided along
|
||||||
|
with the Derivative Works; or, within a display generated by the Derivative
|
||||||
|
Works, if and wherever such third-party notices normally appear. The contents of
|
||||||
|
the NOTICE file are for informational purposes only and do not modify the
|
||||||
|
License. You may add Your own attribution notices within Derivative Works that
|
||||||
|
You distribute, alongside or as an addendum to the NOTICE text from the Work,
|
||||||
|
provided that such additional attribution notices cannot be construed as
|
||||||
|
modifying the License.
|
||||||
|
You may add Your own copyright statement to Your modifications and may provide
|
||||||
|
additional or different license terms and conditions for use, reproduction, or
|
||||||
|
distribution of Your modifications, or for any such Derivative Works as a whole,
|
||||||
|
provided Your use, reproduction, and distribution of the Work otherwise complies
|
||||||
|
with the conditions stated in this License.
|
||||||
|
|
||||||
|
5. Submission of Contributions.
|
||||||
|
|
||||||
|
Unless You explicitly state otherwise, any Contribution intentionally submitted
|
||||||
|
for inclusion in the Work by You to the Licensor shall be under the terms and
|
||||||
|
conditions of this License, without any additional terms or conditions.
|
||||||
|
Notwithstanding the above, nothing herein shall supersede or modify the terms of
|
||||||
|
any separate license agreement you may have executed with Licensor regarding
|
||||||
|
such Contributions.
|
||||||
|
|
||||||
|
6. Trademarks.
|
||||||
|
|
||||||
|
This License does not grant permission to use the trade names, trademarks,
|
||||||
|
service marks, or product names of the Licensor, except as required for
|
||||||
|
reasonable and customary use in describing the origin of the Work and
|
||||||
|
reproducing the content of the NOTICE file.
|
||||||
|
|
||||||
|
7. Disclaimer of Warranty.
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, Licensor provides the
|
||||||
|
Work (and each Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
|
||||||
|
including, without limitation, any warranties or conditions of TITLE,
|
||||||
|
NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are
|
||||||
|
solely responsible for determining the appropriateness of using or
|
||||||
|
redistributing the Work and assume any risks associated with Your exercise of
|
||||||
|
permissions under this License.
|
||||||
|
|
||||||
|
8. Limitation of Liability.
|
||||||
|
|
||||||
|
In no event and under no legal theory, whether in tort (including negligence),
|
||||||
|
contract, or otherwise, unless required by applicable law (such as deliberate
|
||||||
|
and grossly negligent acts) or agreed to in writing, shall any Contributor be
|
||||||
|
liable to You for damages, including any direct, indirect, special, incidental,
|
||||||
|
or consequential damages of any character arising as a result of this License or
|
||||||
|
out of the use or inability to use the Work (including but not limited to
|
||||||
|
damages for loss of goodwill, work stoppage, computer failure or malfunction, or
|
||||||
|
any and all other commercial damages or losses), even if such Contributor has
|
||||||
|
been advised of the possibility of such damages.
|
||||||
|
|
||||||
|
9. Accepting Warranty or Additional Liability.
|
||||||
|
|
||||||
|
While redistributing the Work or Derivative Works thereof, You may choose to
|
||||||
|
offer, and charge a fee for, acceptance of support, warranty, indemnity, or
|
||||||
|
other liability obligations and/or rights consistent with this License. However,
|
||||||
|
in accepting such obligations, You may act only on Your own behalf and on Your
|
||||||
|
sole responsibility, not on behalf of any other Contributor, and only if You
|
||||||
|
agree to indemnify, defend, and hold each Contributor harmless for any liability
|
||||||
|
incurred by, or claims asserted against, such Contributor by reason of your
|
||||||
|
accepting any such warranty or additional liability.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
APPENDIX: How to apply the Apache License to your work
|
||||||
|
|
||||||
|
To apply the Apache License to your work, attach the following boilerplate
|
||||||
|
notice, with the fields enclosed by brackets "[]" replaced with your own
|
||||||
|
identifying information. (Don't include the brackets!) The text should be
|
||||||
|
enclosed in the appropriate comment syntax for the file format. We also
|
||||||
|
recommend that a file or class name and description of purpose be included on
|
||||||
|
the same "printed page" as the copyright notice for easier identification within
|
||||||
|
third-party archives.
|
||||||
|
|
||||||
|
Copyright [yyyy] [name of copyright owner]
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
+18
@@ -0,0 +1,18 @@
|
|||||||
|
# `@img/sharp-linuxmusl-x64`
|
||||||
|
|
||||||
|
Prebuilt sharp for use with Linux (musl) x64.
|
||||||
|
|
||||||
|
## Licensing
|
||||||
|
|
||||||
|
Copyright 2013 Lovell Fuller and others.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
[https://www.apache.org/licenses/LICENSE-2.0](https://www.apache.org/licenses/LICENSE-2.0)
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
+2
@@ -0,0 +1,2 @@
|
|||||||
|
try { require.resolve('@img/sharp-libvips-linuxmusl-x64/binary'); } catch {}
|
||||||
|
module.exports = require('./lib/sharp-linuxmusl-x64-0.35.3.node');
|
||||||
BIN
Binary file not shown.
+47
@@ -0,0 +1,47 @@
|
|||||||
|
{
|
||||||
|
"name": "@img/sharp-linuxmusl-x64",
|
||||||
|
"version": "0.35.3",
|
||||||
|
"description": "Prebuilt sharp for use with Linux (musl) x64",
|
||||||
|
"author": "Lovell Fuller <npm@lovell.info>",
|
||||||
|
"homepage": "https://sharp.pixelplumbing.com",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git+https://github.com/lovell/sharp.git",
|
||||||
|
"directory": "npm/linuxmusl-x64"
|
||||||
|
},
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"funding": {
|
||||||
|
"url": "https://opencollective.com/libvips"
|
||||||
|
},
|
||||||
|
"preferUnplugged": true,
|
||||||
|
"optionalDependencies": {
|
||||||
|
"@img/sharp-libvips-linuxmusl-x64": "1.3.2"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"index.cjs",
|
||||||
|
"lib"
|
||||||
|
],
|
||||||
|
"publishConfig": {
|
||||||
|
"access": "public"
|
||||||
|
},
|
||||||
|
"type": "commonjs",
|
||||||
|
"exports": {
|
||||||
|
"./sharp.node": "./index.cjs",
|
||||||
|
"./package": "./package.json"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=20.9.0"
|
||||||
|
},
|
||||||
|
"config": {
|
||||||
|
"musl": ">=1.2.5"
|
||||||
|
},
|
||||||
|
"os": [
|
||||||
|
"linux"
|
||||||
|
],
|
||||||
|
"libc": [
|
||||||
|
"musl"
|
||||||
|
],
|
||||||
|
"cpu": [
|
||||||
|
"x64"
|
||||||
|
]
|
||||||
|
}
|
||||||
+191
@@ -0,0 +1,191 @@
|
|||||||
|
Apache License
|
||||||
|
Version 2.0, January 2004
|
||||||
|
http://www.apache.org/licenses/
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||||
|
|
||||||
|
1. Definitions.
|
||||||
|
|
||||||
|
"License" shall mean the terms and conditions for use, reproduction, and
|
||||||
|
distribution as defined by Sections 1 through 9 of this document.
|
||||||
|
|
||||||
|
"Licensor" shall mean the copyright owner or entity authorized by the copyright
|
||||||
|
owner that is granting the License.
|
||||||
|
|
||||||
|
"Legal Entity" shall mean the union of the acting entity and all other entities
|
||||||
|
that control, are controlled by, or are under common control with that entity.
|
||||||
|
For the purposes of this definition, "control" means (i) the power, direct or
|
||||||
|
indirect, to cause the direction or management of such entity, whether by
|
||||||
|
contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||||
|
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||||
|
|
||||||
|
"You" (or "Your") shall mean an individual or Legal Entity exercising
|
||||||
|
permissions granted by this License.
|
||||||
|
|
||||||
|
"Source" form shall mean the preferred form for making modifications, including
|
||||||
|
but not limited to software source code, documentation source, and configuration
|
||||||
|
files.
|
||||||
|
|
||||||
|
"Object" form shall mean any form resulting from mechanical transformation or
|
||||||
|
translation of a Source form, including but not limited to compiled object code,
|
||||||
|
generated documentation, and conversions to other media types.
|
||||||
|
|
||||||
|
"Work" shall mean the work of authorship, whether in Source or Object form, made
|
||||||
|
available under the License, as indicated by a copyright notice that is included
|
||||||
|
in or attached to the work (an example is provided in the Appendix below).
|
||||||
|
|
||||||
|
"Derivative Works" shall mean any work, whether in Source or Object form, that
|
||||||
|
is based on (or derived from) the Work and for which the editorial revisions,
|
||||||
|
annotations, elaborations, or other modifications represent, as a whole, an
|
||||||
|
original work of authorship. For the purposes of this License, Derivative Works
|
||||||
|
shall not include works that remain separable from, or merely link (or bind by
|
||||||
|
name) to the interfaces of, the Work and Derivative Works thereof.
|
||||||
|
|
||||||
|
"Contribution" shall mean any work of authorship, including the original version
|
||||||
|
of the Work and any modifications or additions to that Work or Derivative Works
|
||||||
|
thereof, that is intentionally submitted to Licensor for inclusion in the Work
|
||||||
|
by the copyright owner or by an individual or Legal Entity authorized to submit
|
||||||
|
on behalf of the copyright owner. For the purposes of this definition,
|
||||||
|
"submitted" means any form of electronic, verbal, or written communication sent
|
||||||
|
to the Licensor or its representatives, including but not limited to
|
||||||
|
communication on electronic mailing lists, source code control systems, and
|
||||||
|
issue tracking systems that are managed by, or on behalf of, the Licensor for
|
||||||
|
the purpose of discussing and improving the Work, but excluding communication
|
||||||
|
that is conspicuously marked or otherwise designated in writing by the copyright
|
||||||
|
owner as "Not a Contribution."
|
||||||
|
|
||||||
|
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf
|
||||||
|
of whom a Contribution has been received by Licensor and subsequently
|
||||||
|
incorporated within the Work.
|
||||||
|
|
||||||
|
2. Grant of Copyright License.
|
||||||
|
|
||||||
|
Subject to the terms and conditions of this License, each Contributor hereby
|
||||||
|
grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
|
||||||
|
irrevocable copyright license to reproduce, prepare Derivative Works of,
|
||||||
|
publicly display, publicly perform, sublicense, and distribute the Work and such
|
||||||
|
Derivative Works in Source or Object form.
|
||||||
|
|
||||||
|
3. Grant of Patent License.
|
||||||
|
|
||||||
|
Subject to the terms and conditions of this License, each Contributor hereby
|
||||||
|
grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
|
||||||
|
irrevocable (except as stated in this section) patent license to make, have
|
||||||
|
made, use, offer to sell, sell, import, and otherwise transfer the Work, where
|
||||||
|
such license applies only to those patent claims licensable by such Contributor
|
||||||
|
that are necessarily infringed by their Contribution(s) alone or by combination
|
||||||
|
of their Contribution(s) with the Work to which such Contribution(s) was
|
||||||
|
submitted. If You institute patent litigation against any entity (including a
|
||||||
|
cross-claim or counterclaim in a lawsuit) alleging that the Work or a
|
||||||
|
Contribution incorporated within the Work constitutes direct or contributory
|
||||||
|
patent infringement, then any patent licenses granted to You under this License
|
||||||
|
for that Work shall terminate as of the date such litigation is filed.
|
||||||
|
|
||||||
|
4. Redistribution.
|
||||||
|
|
||||||
|
You may reproduce and distribute copies of the Work or Derivative Works thereof
|
||||||
|
in any medium, with or without modifications, and in Source or Object form,
|
||||||
|
provided that You meet the following conditions:
|
||||||
|
|
||||||
|
You must give any other recipients of the Work or Derivative Works a copy of
|
||||||
|
this License; and
|
||||||
|
You must cause any modified files to carry prominent notices stating that You
|
||||||
|
changed the files; and
|
||||||
|
You must retain, in the Source form of any Derivative Works that You distribute,
|
||||||
|
all copyright, patent, trademark, and attribution notices from the Source form
|
||||||
|
of the Work, excluding those notices that do not pertain to any part of the
|
||||||
|
Derivative Works; and
|
||||||
|
If the Work includes a "NOTICE" text file as part of its distribution, then any
|
||||||
|
Derivative Works that You distribute must include a readable copy of the
|
||||||
|
attribution notices contained within such NOTICE file, excluding those notices
|
||||||
|
that do not pertain to any part of the Derivative Works, in at least one of the
|
||||||
|
following places: within a NOTICE text file distributed as part of the
|
||||||
|
Derivative Works; within the Source form or documentation, if provided along
|
||||||
|
with the Derivative Works; or, within a display generated by the Derivative
|
||||||
|
Works, if and wherever such third-party notices normally appear. The contents of
|
||||||
|
the NOTICE file are for informational purposes only and do not modify the
|
||||||
|
License. You may add Your own attribution notices within Derivative Works that
|
||||||
|
You distribute, alongside or as an addendum to the NOTICE text from the Work,
|
||||||
|
provided that such additional attribution notices cannot be construed as
|
||||||
|
modifying the License.
|
||||||
|
You may add Your own copyright statement to Your modifications and may provide
|
||||||
|
additional or different license terms and conditions for use, reproduction, or
|
||||||
|
distribution of Your modifications, or for any such Derivative Works as a whole,
|
||||||
|
provided Your use, reproduction, and distribution of the Work otherwise complies
|
||||||
|
with the conditions stated in this License.
|
||||||
|
|
||||||
|
5. Submission of Contributions.
|
||||||
|
|
||||||
|
Unless You explicitly state otherwise, any Contribution intentionally submitted
|
||||||
|
for inclusion in the Work by You to the Licensor shall be under the terms and
|
||||||
|
conditions of this License, without any additional terms or conditions.
|
||||||
|
Notwithstanding the above, nothing herein shall supersede or modify the terms of
|
||||||
|
any separate license agreement you may have executed with Licensor regarding
|
||||||
|
such Contributions.
|
||||||
|
|
||||||
|
6. Trademarks.
|
||||||
|
|
||||||
|
This License does not grant permission to use the trade names, trademarks,
|
||||||
|
service marks, or product names of the Licensor, except as required for
|
||||||
|
reasonable and customary use in describing the origin of the Work and
|
||||||
|
reproducing the content of the NOTICE file.
|
||||||
|
|
||||||
|
7. Disclaimer of Warranty.
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, Licensor provides the
|
||||||
|
Work (and each Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
|
||||||
|
including, without limitation, any warranties or conditions of TITLE,
|
||||||
|
NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are
|
||||||
|
solely responsible for determining the appropriateness of using or
|
||||||
|
redistributing the Work and assume any risks associated with Your exercise of
|
||||||
|
permissions under this License.
|
||||||
|
|
||||||
|
8. Limitation of Liability.
|
||||||
|
|
||||||
|
In no event and under no legal theory, whether in tort (including negligence),
|
||||||
|
contract, or otherwise, unless required by applicable law (such as deliberate
|
||||||
|
and grossly negligent acts) or agreed to in writing, shall any Contributor be
|
||||||
|
liable to You for damages, including any direct, indirect, special, incidental,
|
||||||
|
or consequential damages of any character arising as a result of this License or
|
||||||
|
out of the use or inability to use the Work (including but not limited to
|
||||||
|
damages for loss of goodwill, work stoppage, computer failure or malfunction, or
|
||||||
|
any and all other commercial damages or losses), even if such Contributor has
|
||||||
|
been advised of the possibility of such damages.
|
||||||
|
|
||||||
|
9. Accepting Warranty or Additional Liability.
|
||||||
|
|
||||||
|
While redistributing the Work or Derivative Works thereof, You may choose to
|
||||||
|
offer, and charge a fee for, acceptance of support, warranty, indemnity, or
|
||||||
|
other liability obligations and/or rights consistent with this License. However,
|
||||||
|
in accepting such obligations, You may act only on Your own behalf and on Your
|
||||||
|
sole responsibility, not on behalf of any other Contributor, and only if You
|
||||||
|
agree to indemnify, defend, and hold each Contributor harmless for any liability
|
||||||
|
incurred by, or claims asserted against, such Contributor by reason of your
|
||||||
|
accepting any such warranty or additional liability.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
APPENDIX: How to apply the Apache License to your work
|
||||||
|
|
||||||
|
To apply the Apache License to your work, attach the following boilerplate
|
||||||
|
notice, with the fields enclosed by brackets "[]" replaced with your own
|
||||||
|
identifying information. (Don't include the brackets!) The text should be
|
||||||
|
enclosed in the appropriate comment syntax for the file format. We also
|
||||||
|
recommend that a file or class name and description of purpose be included on
|
||||||
|
the same "printed page" as the copyright notice for easier identification within
|
||||||
|
third-party archives.
|
||||||
|
|
||||||
|
Copyright [yyyy] [name of copyright owner]
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
+50
@@ -0,0 +1,50 @@
|
|||||||
|
# `@img/sharp-wasm32`
|
||||||
|
|
||||||
|
Prebuilt sharp for use with WebAssembly.
|
||||||
|
|
||||||
|
## Licensing
|
||||||
|
|
||||||
|
Copyright 2013 Lovell Fuller and others.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
[https://www.apache.org/licenses/LICENSE-2.0](https://www.apache.org/licenses/LICENSE-2.0)
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
This software contains third-party libraries
|
||||||
|
used under the terms of the following licenses:
|
||||||
|
|
||||||
|
| Library | Used under the terms of |
|
||||||
|
|---------------|----------------------------------------------------------------------------------------------------------|
|
||||||
|
| aom | BSD 2-Clause + [Alliance for Open Media Patent License 1.0](https://aomedia.org/license/patent-license/) |
|
||||||
|
| cgif | MIT License |
|
||||||
|
| emscripten | [MIT License](https://github.com/emscripten-core/emscripten/blob/main/LICENSE) |
|
||||||
|
| expat | MIT License |
|
||||||
|
| glib | LGPLv3 |
|
||||||
|
| highway | BSD 3-Clause |
|
||||||
|
| lcms | MIT License |
|
||||||
|
| libexif | LGPLv3 |
|
||||||
|
| libffi | MIT License |
|
||||||
|
| libheif | LGPLv3 |
|
||||||
|
| libimagequant | [BSD 2-Clause](https://github.com/lovell/libimagequant/blob/main/COPYRIGHT) |
|
||||||
|
| libnsgif | MIT License |
|
||||||
|
| libpng | [libpng License](https://github.com/pnggroup/libpng/blob/master/LICENSE) |
|
||||||
|
| libtiff | [libtiff License](https://gitlab.com/libtiff/libtiff/blob/master/LICENSE.md) (BSD-like) |
|
||||||
|
| libultrahdr | MIT License |
|
||||||
|
| libvips | LGPLv3 |
|
||||||
|
| libwebp | New BSD License |
|
||||||
|
| mozjpeg | [zlib License, IJG License, BSD 3-Clause](https://github.com/mozilla/mozjpeg/blob/master/LICENSE.md) |
|
||||||
|
| resvg | MIT License |
|
||||||
|
| zlib-ng | [zlib License](https://github.com/zlib-ng/zlib-ng/blob/develop/LICENSE.md) |
|
||||||
|
|
||||||
|
Use of libraries under the terms of the LGPLv3 is via the
|
||||||
|
"any later version" clause of the LGPLv2 or LGPLv2.1.
|
||||||
|
|
||||||
|
Please report any errors or omissions via
|
||||||
|
https://github.com/lovell/sharp-libvips/issues/new
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
module.exports = require('./lib/sharp-wasm32-0.35.3.node');
|
||||||
+1
File diff suppressed because one or more lines are too long
BIN
Binary file not shown.
+37
@@ -0,0 +1,37 @@
|
|||||||
|
{
|
||||||
|
"name": "@img/sharp-wasm32",
|
||||||
|
"version": "0.35.3",
|
||||||
|
"description": "Prebuilt sharp for use with WebAssembly",
|
||||||
|
"author": "Lovell Fuller <npm@lovell.info>",
|
||||||
|
"homepage": "https://sharp.pixelplumbing.com",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git+https://github.com/lovell/sharp.git",
|
||||||
|
"directory": "npm/wasm32"
|
||||||
|
},
|
||||||
|
"license": "Apache-2.0 AND LGPL-3.0-or-later AND MIT",
|
||||||
|
"funding": {
|
||||||
|
"url": "https://opencollective.com/libvips"
|
||||||
|
},
|
||||||
|
"preferUnplugged": true,
|
||||||
|
"files": [
|
||||||
|
"index.cjs",
|
||||||
|
"lib",
|
||||||
|
"versions.json"
|
||||||
|
],
|
||||||
|
"publishConfig": {
|
||||||
|
"access": "public"
|
||||||
|
},
|
||||||
|
"type": "commonjs",
|
||||||
|
"exports": {
|
||||||
|
"./sharp.node": "./index.cjs",
|
||||||
|
"./package": "./package.json",
|
||||||
|
"./versions": "./versions.json"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=20.9.0"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@emnapi/runtime": "^1.11.1"
|
||||||
|
}
|
||||||
|
}
|
||||||
+21
@@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
"aom": "3.14.1",
|
||||||
|
"cgif": "0.5.3",
|
||||||
|
"emscripten": "6.0.1",
|
||||||
|
"exif": "0.6.26",
|
||||||
|
"expat": "2.8.2",
|
||||||
|
"ffi": "3.6.0",
|
||||||
|
"glib": "2.89.1",
|
||||||
|
"heif": "1.23.1",
|
||||||
|
"highway": "1.4.0",
|
||||||
|
"imagequant": "2.4.1",
|
||||||
|
"lcms": "2.19.1",
|
||||||
|
"mozjpeg": "0826579",
|
||||||
|
"png": "1.6.58",
|
||||||
|
"resvg": "0.47.0",
|
||||||
|
"tiff": "4.7.2rc2",
|
||||||
|
"uhdr": "1acdbed",
|
||||||
|
"vips": "8.18.3",
|
||||||
|
"webp": "1.6.0",
|
||||||
|
"zlib-ng": "2.3.3"
|
||||||
|
}
|
||||||
+250
@@ -0,0 +1,250 @@
|
|||||||
|
2.0.0 / 2024-08-31
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Drop node <18 support
|
||||||
|
* deps: mime-types@^3.0.0
|
||||||
|
* deps: negotiator@^1.0.0
|
||||||
|
|
||||||
|
1.3.8 / 2022-02-02
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: mime-types@~2.1.34
|
||||||
|
- deps: mime-db@~1.51.0
|
||||||
|
* deps: negotiator@0.6.3
|
||||||
|
|
||||||
|
1.3.7 / 2019-04-29
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: negotiator@0.6.2
|
||||||
|
- Fix sorting charset, encoding, and language with extra parameters
|
||||||
|
|
||||||
|
1.3.6 / 2019-04-28
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: mime-types@~2.1.24
|
||||||
|
- deps: mime-db@~1.40.0
|
||||||
|
|
||||||
|
1.3.5 / 2018-02-28
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: mime-types@~2.1.18
|
||||||
|
- deps: mime-db@~1.33.0
|
||||||
|
|
||||||
|
1.3.4 / 2017-08-22
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: mime-types@~2.1.16
|
||||||
|
- deps: mime-db@~1.29.0
|
||||||
|
|
||||||
|
1.3.3 / 2016-05-02
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: mime-types@~2.1.11
|
||||||
|
- deps: mime-db@~1.23.0
|
||||||
|
* deps: negotiator@0.6.1
|
||||||
|
- perf: improve `Accept` parsing speed
|
||||||
|
- perf: improve `Accept-Charset` parsing speed
|
||||||
|
- perf: improve `Accept-Encoding` parsing speed
|
||||||
|
- perf: improve `Accept-Language` parsing speed
|
||||||
|
|
||||||
|
1.3.2 / 2016-03-08
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: mime-types@~2.1.10
|
||||||
|
- Fix extension of `application/dash+xml`
|
||||||
|
- Update primary extension for `audio/mp4`
|
||||||
|
- deps: mime-db@~1.22.0
|
||||||
|
|
||||||
|
1.3.1 / 2016-01-19
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: mime-types@~2.1.9
|
||||||
|
- deps: mime-db@~1.21.0
|
||||||
|
|
||||||
|
1.3.0 / 2015-09-29
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: mime-types@~2.1.7
|
||||||
|
- deps: mime-db@~1.19.0
|
||||||
|
* deps: negotiator@0.6.0
|
||||||
|
- Fix including type extensions in parameters in `Accept` parsing
|
||||||
|
- Fix parsing `Accept` parameters with quoted equals
|
||||||
|
- Fix parsing `Accept` parameters with quoted semicolons
|
||||||
|
- Lazy-load modules from main entry point
|
||||||
|
- perf: delay type concatenation until needed
|
||||||
|
- perf: enable strict mode
|
||||||
|
- perf: hoist regular expressions
|
||||||
|
- perf: remove closures getting spec properties
|
||||||
|
- perf: remove a closure from media type parsing
|
||||||
|
- perf: remove property delete from media type parsing
|
||||||
|
|
||||||
|
1.2.13 / 2015-09-06
|
||||||
|
===================
|
||||||
|
|
||||||
|
* deps: mime-types@~2.1.6
|
||||||
|
- deps: mime-db@~1.18.0
|
||||||
|
|
||||||
|
1.2.12 / 2015-07-30
|
||||||
|
===================
|
||||||
|
|
||||||
|
* deps: mime-types@~2.1.4
|
||||||
|
- deps: mime-db@~1.16.0
|
||||||
|
|
||||||
|
1.2.11 / 2015-07-16
|
||||||
|
===================
|
||||||
|
|
||||||
|
* deps: mime-types@~2.1.3
|
||||||
|
- deps: mime-db@~1.15.0
|
||||||
|
|
||||||
|
1.2.10 / 2015-07-01
|
||||||
|
===================
|
||||||
|
|
||||||
|
* deps: mime-types@~2.1.2
|
||||||
|
- deps: mime-db@~1.14.0
|
||||||
|
|
||||||
|
1.2.9 / 2015-06-08
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: mime-types@~2.1.1
|
||||||
|
- perf: fix deopt during mapping
|
||||||
|
|
||||||
|
1.2.8 / 2015-06-07
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: mime-types@~2.1.0
|
||||||
|
- deps: mime-db@~1.13.0
|
||||||
|
* perf: avoid argument reassignment & argument slice
|
||||||
|
* perf: avoid negotiator recursive construction
|
||||||
|
* perf: enable strict mode
|
||||||
|
* perf: remove unnecessary bitwise operator
|
||||||
|
|
||||||
|
1.2.7 / 2015-05-10
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: negotiator@0.5.3
|
||||||
|
- Fix media type parameter matching to be case-insensitive
|
||||||
|
|
||||||
|
1.2.6 / 2015-05-07
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: mime-types@~2.0.11
|
||||||
|
- deps: mime-db@~1.9.1
|
||||||
|
* deps: negotiator@0.5.2
|
||||||
|
- Fix comparing media types with quoted values
|
||||||
|
- Fix splitting media types with quoted commas
|
||||||
|
|
||||||
|
1.2.5 / 2015-03-13
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: mime-types@~2.0.10
|
||||||
|
- deps: mime-db@~1.8.0
|
||||||
|
|
||||||
|
1.2.4 / 2015-02-14
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Support Node.js 0.6
|
||||||
|
* deps: mime-types@~2.0.9
|
||||||
|
- deps: mime-db@~1.7.0
|
||||||
|
* deps: negotiator@0.5.1
|
||||||
|
- Fix preference sorting to be stable for long acceptable lists
|
||||||
|
|
||||||
|
1.2.3 / 2015-01-31
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: mime-types@~2.0.8
|
||||||
|
- deps: mime-db@~1.6.0
|
||||||
|
|
||||||
|
1.2.2 / 2014-12-30
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: mime-types@~2.0.7
|
||||||
|
- deps: mime-db@~1.5.0
|
||||||
|
|
||||||
|
1.2.1 / 2014-12-30
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: mime-types@~2.0.5
|
||||||
|
- deps: mime-db@~1.3.1
|
||||||
|
|
||||||
|
1.2.0 / 2014-12-19
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: negotiator@0.5.0
|
||||||
|
- Fix list return order when large accepted list
|
||||||
|
- Fix missing identity encoding when q=0 exists
|
||||||
|
- Remove dynamic building of Negotiator class
|
||||||
|
|
||||||
|
1.1.4 / 2014-12-10
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: mime-types@~2.0.4
|
||||||
|
- deps: mime-db@~1.3.0
|
||||||
|
|
||||||
|
1.1.3 / 2014-11-09
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: mime-types@~2.0.3
|
||||||
|
- deps: mime-db@~1.2.0
|
||||||
|
|
||||||
|
1.1.2 / 2014-10-14
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: negotiator@0.4.9
|
||||||
|
- Fix error when media type has invalid parameter
|
||||||
|
|
||||||
|
1.1.1 / 2014-09-28
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: mime-types@~2.0.2
|
||||||
|
- deps: mime-db@~1.1.0
|
||||||
|
* deps: negotiator@0.4.8
|
||||||
|
- Fix all negotiations to be case-insensitive
|
||||||
|
- Stable sort preferences of same quality according to client order
|
||||||
|
|
||||||
|
1.1.0 / 2014-09-02
|
||||||
|
==================
|
||||||
|
|
||||||
|
* update `mime-types`
|
||||||
|
|
||||||
|
1.0.7 / 2014-07-04
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Fix wrong type returned from `type` when match after unknown extension
|
||||||
|
|
||||||
|
1.0.6 / 2014-06-24
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: negotiator@0.4.7
|
||||||
|
|
||||||
|
1.0.5 / 2014-06-20
|
||||||
|
==================
|
||||||
|
|
||||||
|
* fix crash when unknown extension given
|
||||||
|
|
||||||
|
1.0.4 / 2014-06-19
|
||||||
|
==================
|
||||||
|
|
||||||
|
* use `mime-types`
|
||||||
|
|
||||||
|
1.0.3 / 2014-06-11
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: negotiator@0.4.6
|
||||||
|
- Order by specificity when quality is the same
|
||||||
|
|
||||||
|
1.0.2 / 2014-05-29
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Fix interpretation when header not in request
|
||||||
|
* deps: pin negotiator@0.4.5
|
||||||
|
|
||||||
|
1.0.1 / 2014-01-18
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Identity encoding isn't always acceptable
|
||||||
|
* deps: negotiator@~0.4.0
|
||||||
|
|
||||||
|
1.0.0 / 2013-12-27
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Genesis
|
||||||
+23
@@ -0,0 +1,23 @@
|
|||||||
|
(The MIT License)
|
||||||
|
|
||||||
|
Copyright (c) 2014 Jonathan Ong <me@jongleberry.com>
|
||||||
|
Copyright (c) 2015 Douglas Christopher Wilson <doug@somethingdoug.com>
|
||||||
|
|
||||||
|
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.
|
||||||
+140
@@ -0,0 +1,140 @@
|
|||||||
|
# accepts
|
||||||
|
|
||||||
|
[![NPM Version][npm-version-image]][npm-url]
|
||||||
|
[![NPM Downloads][npm-downloads-image]][npm-url]
|
||||||
|
[![Node.js Version][node-version-image]][node-version-url]
|
||||||
|
[![Build Status][github-actions-ci-image]][github-actions-ci-url]
|
||||||
|
[![Test Coverage][coveralls-image]][coveralls-url]
|
||||||
|
|
||||||
|
Higher level content negotiation based on [negotiator](https://www.npmjs.com/package/negotiator).
|
||||||
|
Extracted from [koa](https://www.npmjs.com/package/koa) for general use.
|
||||||
|
|
||||||
|
In addition to negotiator, it allows:
|
||||||
|
|
||||||
|
- Allows types as an array or arguments list, ie `(['text/html', 'application/json'])`
|
||||||
|
as well as `('text/html', 'application/json')`.
|
||||||
|
- Allows type shorthands such as `json`.
|
||||||
|
- Returns `false` when no types match
|
||||||
|
- Treats non-existent headers as `*`
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
This is a [Node.js](https://nodejs.org/en/) module available through the
|
||||||
|
[npm registry](https://www.npmjs.com/). Installation is done using the
|
||||||
|
[`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally):
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ npm install accepts
|
||||||
|
```
|
||||||
|
|
||||||
|
## API
|
||||||
|
|
||||||
|
```js
|
||||||
|
var accepts = require('accepts')
|
||||||
|
```
|
||||||
|
|
||||||
|
### accepts(req)
|
||||||
|
|
||||||
|
Create a new `Accepts` object for the given `req`.
|
||||||
|
|
||||||
|
#### .charset(charsets)
|
||||||
|
|
||||||
|
Return the first accepted charset. If nothing in `charsets` is accepted,
|
||||||
|
then `false` is returned.
|
||||||
|
|
||||||
|
#### .charsets()
|
||||||
|
|
||||||
|
Return the charsets that the request accepts, in the order of the client's
|
||||||
|
preference (most preferred first).
|
||||||
|
|
||||||
|
#### .encoding(encodings)
|
||||||
|
|
||||||
|
Return the first accepted encoding. If nothing in `encodings` is accepted,
|
||||||
|
then `false` is returned.
|
||||||
|
|
||||||
|
#### .encodings()
|
||||||
|
|
||||||
|
Return the encodings that the request accepts, in the order of the client's
|
||||||
|
preference (most preferred first).
|
||||||
|
|
||||||
|
#### .language(languages)
|
||||||
|
|
||||||
|
Return the first accepted language. If nothing in `languages` is accepted,
|
||||||
|
then `false` is returned.
|
||||||
|
|
||||||
|
#### .languages()
|
||||||
|
|
||||||
|
Return the languages that the request accepts, in the order of the client's
|
||||||
|
preference (most preferred first).
|
||||||
|
|
||||||
|
#### .type(types)
|
||||||
|
|
||||||
|
Return the first accepted type (and it is returned as the same text as what
|
||||||
|
appears in the `types` array). If nothing in `types` is accepted, then `false`
|
||||||
|
is returned.
|
||||||
|
|
||||||
|
The `types` array can contain full MIME types or file extensions. Any value
|
||||||
|
that is not a full MIME type is passed to `require('mime-types').lookup`.
|
||||||
|
|
||||||
|
#### .types()
|
||||||
|
|
||||||
|
Return the types that the request accepts, in the order of the client's
|
||||||
|
preference (most preferred first).
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
### Simple type negotiation
|
||||||
|
|
||||||
|
This simple example shows how to use `accepts` to return a different typed
|
||||||
|
respond body based on what the client wants to accept. The server lists it's
|
||||||
|
preferences in order and will get back the best match between the client and
|
||||||
|
server.
|
||||||
|
|
||||||
|
```js
|
||||||
|
var accepts = require('accepts')
|
||||||
|
var http = require('http')
|
||||||
|
|
||||||
|
function app (req, res) {
|
||||||
|
var accept = accepts(req)
|
||||||
|
|
||||||
|
// the order of this list is significant; should be server preferred order
|
||||||
|
switch (accept.type(['json', 'html'])) {
|
||||||
|
case 'json':
|
||||||
|
res.setHeader('Content-Type', 'application/json')
|
||||||
|
res.write('{"hello":"world!"}')
|
||||||
|
break
|
||||||
|
case 'html':
|
||||||
|
res.setHeader('Content-Type', 'text/html')
|
||||||
|
res.write('<b>hello, world!</b>')
|
||||||
|
break
|
||||||
|
default:
|
||||||
|
// the fallback is text/plain, so no need to specify it above
|
||||||
|
res.setHeader('Content-Type', 'text/plain')
|
||||||
|
res.write('hello, world!')
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
res.end()
|
||||||
|
}
|
||||||
|
|
||||||
|
http.createServer(app).listen(3000)
|
||||||
|
```
|
||||||
|
|
||||||
|
You can test this out with the cURL program:
|
||||||
|
```sh
|
||||||
|
curl -I -H'Accept: text/html' http://localhost:3000/
|
||||||
|
```
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
[MIT](LICENSE)
|
||||||
|
|
||||||
|
[coveralls-image]: https://badgen.net/coveralls/c/github/jshttp/accepts/master
|
||||||
|
[coveralls-url]: https://coveralls.io/r/jshttp/accepts?branch=master
|
||||||
|
[github-actions-ci-image]: https://badgen.net/github/checks/jshttp/accepts/master?label=ci
|
||||||
|
[github-actions-ci-url]: https://github.com/jshttp/accepts/actions/workflows/ci.yml
|
||||||
|
[node-version-image]: https://badgen.net/npm/node/accepts
|
||||||
|
[node-version-url]: https://nodejs.org/en/download
|
||||||
|
[npm-downloads-image]: https://badgen.net/npm/dm/accepts
|
||||||
|
[npm-url]: https://npmjs.org/package/accepts
|
||||||
|
[npm-version-image]: https://badgen.net/npm/v/accepts
|
||||||
+238
@@ -0,0 +1,238 @@
|
|||||||
|
/*!
|
||||||
|
* accepts
|
||||||
|
* Copyright(c) 2014 Jonathan Ong
|
||||||
|
* Copyright(c) 2015 Douglas Christopher Wilson
|
||||||
|
* MIT Licensed
|
||||||
|
*/
|
||||||
|
|
||||||
|
'use strict'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Module dependencies.
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
|
||||||
|
var Negotiator = require('negotiator')
|
||||||
|
var mime = require('mime-types')
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Module exports.
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
|
|
||||||
|
module.exports = Accepts
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new Accepts object for the given req.
|
||||||
|
*
|
||||||
|
* @param {object} req
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
|
|
||||||
|
function Accepts (req) {
|
||||||
|
if (!(this instanceof Accepts)) {
|
||||||
|
return new Accepts(req)
|
||||||
|
}
|
||||||
|
|
||||||
|
this.headers = req.headers
|
||||||
|
this.negotiator = new Negotiator(req)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the given `type(s)` is acceptable, returning
|
||||||
|
* the best match when true, otherwise `undefined`, in which
|
||||||
|
* case you should respond with 406 "Not Acceptable".
|
||||||
|
*
|
||||||
|
* The `type` value may be a single mime type string
|
||||||
|
* such as "application/json", the extension name
|
||||||
|
* such as "json" or an array `["json", "html", "text/plain"]`. When a list
|
||||||
|
* or array is given the _best_ match, if any is returned.
|
||||||
|
*
|
||||||
|
* Examples:
|
||||||
|
*
|
||||||
|
* // Accept: text/html
|
||||||
|
* this.types('html');
|
||||||
|
* // => "html"
|
||||||
|
*
|
||||||
|
* // Accept: text/*, application/json
|
||||||
|
* this.types('html');
|
||||||
|
* // => "html"
|
||||||
|
* this.types('text/html');
|
||||||
|
* // => "text/html"
|
||||||
|
* this.types('json', 'text');
|
||||||
|
* // => "json"
|
||||||
|
* this.types('application/json');
|
||||||
|
* // => "application/json"
|
||||||
|
*
|
||||||
|
* // Accept: text/*, application/json
|
||||||
|
* this.types('image/png');
|
||||||
|
* this.types('png');
|
||||||
|
* // => undefined
|
||||||
|
*
|
||||||
|
* // Accept: text/*;q=.5, application/json
|
||||||
|
* this.types(['html', 'json']);
|
||||||
|
* this.types('html', 'json');
|
||||||
|
* // => "json"
|
||||||
|
*
|
||||||
|
* @param {String|Array} types...
|
||||||
|
* @return {String|Array|Boolean}
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
|
|
||||||
|
Accepts.prototype.type =
|
||||||
|
Accepts.prototype.types = function (types_) {
|
||||||
|
var types = types_
|
||||||
|
|
||||||
|
// support flattened arguments
|
||||||
|
if (types && !Array.isArray(types)) {
|
||||||
|
types = new Array(arguments.length)
|
||||||
|
for (var i = 0; i < types.length; i++) {
|
||||||
|
types[i] = arguments[i]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// no types, return all requested types
|
||||||
|
if (!types || types.length === 0) {
|
||||||
|
return this.negotiator.mediaTypes()
|
||||||
|
}
|
||||||
|
|
||||||
|
// no accept header, return first given type
|
||||||
|
if (!this.headers.accept) {
|
||||||
|
return types[0]
|
||||||
|
}
|
||||||
|
|
||||||
|
var mimes = types.map(extToMime)
|
||||||
|
var accepts = this.negotiator.mediaTypes(mimes.filter(validMime))
|
||||||
|
var first = accepts[0]
|
||||||
|
|
||||||
|
return first
|
||||||
|
? types[mimes.indexOf(first)]
|
||||||
|
: false
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return accepted encodings or best fit based on `encodings`.
|
||||||
|
*
|
||||||
|
* Given `Accept-Encoding: gzip, deflate`
|
||||||
|
* an array sorted by quality is returned:
|
||||||
|
*
|
||||||
|
* ['gzip', 'deflate']
|
||||||
|
*
|
||||||
|
* @param {String|Array} encodings...
|
||||||
|
* @return {String|Array}
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
|
|
||||||
|
Accepts.prototype.encoding =
|
||||||
|
Accepts.prototype.encodings = function (encodings_) {
|
||||||
|
var encodings = encodings_
|
||||||
|
|
||||||
|
// support flattened arguments
|
||||||
|
if (encodings && !Array.isArray(encodings)) {
|
||||||
|
encodings = new Array(arguments.length)
|
||||||
|
for (var i = 0; i < encodings.length; i++) {
|
||||||
|
encodings[i] = arguments[i]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// no encodings, return all requested encodings
|
||||||
|
if (!encodings || encodings.length === 0) {
|
||||||
|
return this.negotiator.encodings()
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.negotiator.encodings(encodings)[0] || false
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return accepted charsets or best fit based on `charsets`.
|
||||||
|
*
|
||||||
|
* Given `Accept-Charset: utf-8, iso-8859-1;q=0.2, utf-7;q=0.5`
|
||||||
|
* an array sorted by quality is returned:
|
||||||
|
*
|
||||||
|
* ['utf-8', 'utf-7', 'iso-8859-1']
|
||||||
|
*
|
||||||
|
* @param {String|Array} charsets...
|
||||||
|
* @return {String|Array}
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
|
|
||||||
|
Accepts.prototype.charset =
|
||||||
|
Accepts.prototype.charsets = function (charsets_) {
|
||||||
|
var charsets = charsets_
|
||||||
|
|
||||||
|
// support flattened arguments
|
||||||
|
if (charsets && !Array.isArray(charsets)) {
|
||||||
|
charsets = new Array(arguments.length)
|
||||||
|
for (var i = 0; i < charsets.length; i++) {
|
||||||
|
charsets[i] = arguments[i]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// no charsets, return all requested charsets
|
||||||
|
if (!charsets || charsets.length === 0) {
|
||||||
|
return this.negotiator.charsets()
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.negotiator.charsets(charsets)[0] || false
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return accepted languages or best fit based on `langs`.
|
||||||
|
*
|
||||||
|
* Given `Accept-Language: en;q=0.8, es, pt`
|
||||||
|
* an array sorted by quality is returned:
|
||||||
|
*
|
||||||
|
* ['es', 'pt', 'en']
|
||||||
|
*
|
||||||
|
* @param {String|Array} langs...
|
||||||
|
* @return {Array|String}
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
|
|
||||||
|
Accepts.prototype.lang =
|
||||||
|
Accepts.prototype.langs =
|
||||||
|
Accepts.prototype.language =
|
||||||
|
Accepts.prototype.languages = function (languages_) {
|
||||||
|
var languages = languages_
|
||||||
|
|
||||||
|
// support flattened arguments
|
||||||
|
if (languages && !Array.isArray(languages)) {
|
||||||
|
languages = new Array(arguments.length)
|
||||||
|
for (var i = 0; i < languages.length; i++) {
|
||||||
|
languages[i] = arguments[i]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// no languages, return all requested languages
|
||||||
|
if (!languages || languages.length === 0) {
|
||||||
|
return this.negotiator.languages()
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.negotiator.languages(languages)[0] || false
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert extnames to mime.
|
||||||
|
*
|
||||||
|
* @param {String} type
|
||||||
|
* @return {String}
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
|
||||||
|
function extToMime (type) {
|
||||||
|
return type.indexOf('/') === -1
|
||||||
|
? mime.lookup(type)
|
||||||
|
: type
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if mime is valid.
|
||||||
|
*
|
||||||
|
* @param {String} type
|
||||||
|
* @return {Boolean}
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
|
||||||
|
function validMime (type) {
|
||||||
|
return typeof type === 'string'
|
||||||
|
}
|
||||||
+47
@@ -0,0 +1,47 @@
|
|||||||
|
{
|
||||||
|
"name": "accepts",
|
||||||
|
"description": "Higher-level content negotiation",
|
||||||
|
"version": "2.0.0",
|
||||||
|
"contributors": [
|
||||||
|
"Douglas Christopher Wilson <doug@somethingdoug.com>",
|
||||||
|
"Jonathan Ong <me@jongleberry.com> (http://jongleberry.com)"
|
||||||
|
],
|
||||||
|
"license": "MIT",
|
||||||
|
"repository": "jshttp/accepts",
|
||||||
|
"dependencies": {
|
||||||
|
"mime-types": "^3.0.0",
|
||||||
|
"negotiator": "^1.0.0"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"deep-equal": "1.0.1",
|
||||||
|
"eslint": "7.32.0",
|
||||||
|
"eslint-config-standard": "14.1.1",
|
||||||
|
"eslint-plugin-import": "2.25.4",
|
||||||
|
"eslint-plugin-markdown": "2.2.1",
|
||||||
|
"eslint-plugin-node": "11.1.0",
|
||||||
|
"eslint-plugin-promise": "4.3.1",
|
||||||
|
"eslint-plugin-standard": "4.1.0",
|
||||||
|
"mocha": "9.2.0",
|
||||||
|
"nyc": "15.1.0"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"LICENSE",
|
||||||
|
"HISTORY.md",
|
||||||
|
"index.js"
|
||||||
|
],
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 0.6"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"lint": "eslint .",
|
||||||
|
"test": "mocha --reporter spec --check-leaks --bail test/",
|
||||||
|
"test-ci": "nyc --reporter=lcov --reporter=text npm test",
|
||||||
|
"test-cov": "nyc --reporter=html --reporter=text npm test"
|
||||||
|
},
|
||||||
|
"keywords": [
|
||||||
|
"content",
|
||||||
|
"negotiation",
|
||||||
|
"accept",
|
||||||
|
"accepts"
|
||||||
|
]
|
||||||
|
}
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
node_modules/
|
||||||
+21
@@ -0,0 +1,21 @@
|
|||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2015 Linus Unnebäck
|
||||||
|
|
||||||
|
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.
|
||||||
+44
@@ -0,0 +1,44 @@
|
|||||||
|
# `append-field`
|
||||||
|
|
||||||
|
A [W3C HTML JSON forms spec](http://www.w3.org/TR/html-json-forms/) compliant
|
||||||
|
field appender (for lack of a better name). Useful for people implementing
|
||||||
|
`application/x-www-form-urlencoded` and `multipart/form-data` parsers.
|
||||||
|
|
||||||
|
It works best on objects created with `Object.create(null)`. Otherwise it might
|
||||||
|
conflict with variables from the prototype (e.g. `hasOwnProperty`).
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm install --save append-field
|
||||||
|
```
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
var appendField = require('append-field')
|
||||||
|
var obj = Object.create(null)
|
||||||
|
|
||||||
|
appendField(obj, 'pets[0][species]', 'Dahut')
|
||||||
|
appendField(obj, 'pets[0][name]', 'Hypatia')
|
||||||
|
appendField(obj, 'pets[1][species]', 'Felis Stultus')
|
||||||
|
appendField(obj, 'pets[1][name]', 'Billie')
|
||||||
|
|
||||||
|
console.log(obj)
|
||||||
|
```
|
||||||
|
|
||||||
|
```text
|
||||||
|
{ pets:
|
||||||
|
[ { species: 'Dahut', name: 'Hypatia' },
|
||||||
|
{ species: 'Felis Stultus', name: 'Billie' } ] }
|
||||||
|
```
|
||||||
|
|
||||||
|
## API
|
||||||
|
|
||||||
|
### `appendField(store, key, value)`
|
||||||
|
|
||||||
|
Adds the field named `key` with the value `value` to the object `store`.
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
MIT
|
||||||
+12
@@ -0,0 +1,12 @@
|
|||||||
|
var parsePath = require('./lib/parse-path')
|
||||||
|
var setValue = require('./lib/set-value')
|
||||||
|
|
||||||
|
function appendField (store, key, value) {
|
||||||
|
var steps = parsePath(key)
|
||||||
|
|
||||||
|
steps.reduce(function (context, step) {
|
||||||
|
return setValue(context, step, context[step.key], value)
|
||||||
|
}, store)
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = appendField
|
||||||
+53
@@ -0,0 +1,53 @@
|
|||||||
|
var reFirstKey = /^[^\[]*/
|
||||||
|
var reDigitPath = /^\[(\d+)\]/
|
||||||
|
var reNormalPath = /^\[([^\]]+)\]/
|
||||||
|
|
||||||
|
function parsePath (key) {
|
||||||
|
function failure () {
|
||||||
|
return [{ type: 'object', key: key, last: true }]
|
||||||
|
}
|
||||||
|
|
||||||
|
var firstKey = reFirstKey.exec(key)[0]
|
||||||
|
if (!firstKey) return failure()
|
||||||
|
|
||||||
|
var len = key.length
|
||||||
|
var pos = firstKey.length
|
||||||
|
var tail = { type: 'object', key: firstKey }
|
||||||
|
var steps = [tail]
|
||||||
|
|
||||||
|
while (pos < len) {
|
||||||
|
var m
|
||||||
|
|
||||||
|
if (key[pos] === '[' && key[pos + 1] === ']') {
|
||||||
|
pos += 2
|
||||||
|
tail.append = true
|
||||||
|
if (pos !== len) return failure()
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
m = reDigitPath.exec(key.substring(pos))
|
||||||
|
if (m !== null) {
|
||||||
|
pos += m[0].length
|
||||||
|
tail.nextType = 'array'
|
||||||
|
tail = { type: 'array', key: parseInt(m[1], 10) }
|
||||||
|
steps.push(tail)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
m = reNormalPath.exec(key.substring(pos))
|
||||||
|
if (m !== null) {
|
||||||
|
pos += m[0].length
|
||||||
|
tail.nextType = 'object'
|
||||||
|
tail = { type: 'object', key: m[1] }
|
||||||
|
steps.push(tail)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
return failure()
|
||||||
|
}
|
||||||
|
|
||||||
|
tail.last = true
|
||||||
|
return steps
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = parsePath
|
||||||
+64
@@ -0,0 +1,64 @@
|
|||||||
|
function valueType (value) {
|
||||||
|
if (value === undefined) return 'undefined'
|
||||||
|
if (Array.isArray(value)) return 'array'
|
||||||
|
if (typeof value === 'object') return 'object'
|
||||||
|
return 'scalar'
|
||||||
|
}
|
||||||
|
|
||||||
|
function setLastValue (context, step, currentValue, entryValue) {
|
||||||
|
switch (valueType(currentValue)) {
|
||||||
|
case 'undefined':
|
||||||
|
if (step.append) {
|
||||||
|
context[step.key] = [entryValue]
|
||||||
|
} else {
|
||||||
|
context[step.key] = entryValue
|
||||||
|
}
|
||||||
|
break
|
||||||
|
case 'array':
|
||||||
|
context[step.key].push(entryValue)
|
||||||
|
break
|
||||||
|
case 'object':
|
||||||
|
return setLastValue(currentValue, { type: 'object', key: '', last: true }, currentValue[''], entryValue)
|
||||||
|
case 'scalar':
|
||||||
|
context[step.key] = [context[step.key], entryValue]
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
return context
|
||||||
|
}
|
||||||
|
|
||||||
|
function setValue (context, step, currentValue, entryValue) {
|
||||||
|
if (step.last) return setLastValue(context, step, currentValue, entryValue)
|
||||||
|
|
||||||
|
var obj
|
||||||
|
switch (valueType(currentValue)) {
|
||||||
|
case 'undefined':
|
||||||
|
if (step.nextType === 'array') {
|
||||||
|
context[step.key] = []
|
||||||
|
} else {
|
||||||
|
context[step.key] = Object.create(null)
|
||||||
|
}
|
||||||
|
return context[step.key]
|
||||||
|
case 'object':
|
||||||
|
return context[step.key]
|
||||||
|
case 'array':
|
||||||
|
if (step.nextType === 'array') {
|
||||||
|
return currentValue
|
||||||
|
}
|
||||||
|
|
||||||
|
obj = Object.create(null)
|
||||||
|
context[step.key] = obj
|
||||||
|
currentValue.forEach(function (item, i) {
|
||||||
|
if (item !== undefined) obj['' + i] = item
|
||||||
|
})
|
||||||
|
|
||||||
|
return obj
|
||||||
|
case 'scalar':
|
||||||
|
obj = Object.create(null)
|
||||||
|
obj[''] = currentValue
|
||||||
|
context[step.key] = obj
|
||||||
|
return obj
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = setValue
|
||||||
+19
@@ -0,0 +1,19 @@
|
|||||||
|
{
|
||||||
|
"name": "append-field",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"license": "MIT",
|
||||||
|
"author": "Linus Unnebäck <linus@folkdatorn.se>",
|
||||||
|
"main": "index.js",
|
||||||
|
"devDependencies": {
|
||||||
|
"mocha": "^2.2.4",
|
||||||
|
"standard": "^6.0.5",
|
||||||
|
"testdata-w3c-json-form": "^0.2.0"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"test": "standard && mocha"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "http://github.com/LinusU/node-append-field.git"
|
||||||
|
}
|
||||||
|
}
|
||||||
+19
@@ -0,0 +1,19 @@
|
|||||||
|
/* eslint-env mocha */
|
||||||
|
|
||||||
|
var assert = require('assert')
|
||||||
|
var appendField = require('../')
|
||||||
|
var testData = require('testdata-w3c-json-form')
|
||||||
|
|
||||||
|
describe('Append Field', function () {
|
||||||
|
for (var test of testData) {
|
||||||
|
it('handles ' + test.name, function () {
|
||||||
|
var store = Object.create(null)
|
||||||
|
|
||||||
|
for (var field of test.fields) {
|
||||||
|
appendField(store, field.key, field.value)
|
||||||
|
}
|
||||||
|
|
||||||
|
assert.deepEqual(store, test.expected)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
+21
@@ -0,0 +1,21 @@
|
|||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2016 Alex Indigo
|
||||||
|
|
||||||
|
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.
|
||||||
+233
@@ -0,0 +1,233 @@
|
|||||||
|
# asynckit [](https://www.npmjs.com/package/asynckit)
|
||||||
|
|
||||||
|
Minimal async jobs utility library, with streams support.
|
||||||
|
|
||||||
|
[](https://travis-ci.org/alexindigo/asynckit)
|
||||||
|
[](https://travis-ci.org/alexindigo/asynckit)
|
||||||
|
[](https://ci.appveyor.com/project/alexindigo/asynckit)
|
||||||
|
|
||||||
|
[](https://coveralls.io/github/alexindigo/asynckit?branch=master)
|
||||||
|
[](https://david-dm.org/alexindigo/asynckit)
|
||||||
|
[](https://www.bithound.io/github/alexindigo/asynckit)
|
||||||
|
|
||||||
|
<!-- [](https://www.npmjs.com/package/reamde) -->
|
||||||
|
|
||||||
|
AsyncKit provides harness for `parallel` and `serial` iterators over list of items represented by arrays or objects.
|
||||||
|
Optionally it accepts abort function (should be synchronously return by iterator for each item), and terminates left over jobs upon an error event. For specific iteration order built-in (`ascending` and `descending`) and custom sort helpers also supported, via `asynckit.serialOrdered` method.
|
||||||
|
|
||||||
|
It ensures async operations to keep behavior more stable and prevent `Maximum call stack size exceeded` errors, from sync iterators.
|
||||||
|
|
||||||
|
| compression | size |
|
||||||
|
| :----------------- | -------: |
|
||||||
|
| asynckit.js | 12.34 kB |
|
||||||
|
| asynckit.min.js | 4.11 kB |
|
||||||
|
| asynckit.min.js.gz | 1.47 kB |
|
||||||
|
|
||||||
|
|
||||||
|
## Install
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ npm install --save asynckit
|
||||||
|
```
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
### Parallel Jobs
|
||||||
|
|
||||||
|
Runs iterator over provided array in parallel. Stores output in the `result` array,
|
||||||
|
on the matching positions. In unlikely event of an error from one of the jobs,
|
||||||
|
will terminate rest of the active jobs (if abort function is provided)
|
||||||
|
and return error along with salvaged data to the main callback function.
|
||||||
|
|
||||||
|
#### Input Array
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
var parallel = require('asynckit').parallel
|
||||||
|
, assert = require('assert')
|
||||||
|
;
|
||||||
|
|
||||||
|
var source = [ 1, 1, 4, 16, 64, 32, 8, 2 ]
|
||||||
|
, expectedResult = [ 2, 2, 8, 32, 128, 64, 16, 4 ]
|
||||||
|
, expectedTarget = [ 1, 1, 2, 4, 8, 16, 32, 64 ]
|
||||||
|
, target = []
|
||||||
|
;
|
||||||
|
|
||||||
|
parallel(source, asyncJob, function(err, result)
|
||||||
|
{
|
||||||
|
assert.deepEqual(result, expectedResult);
|
||||||
|
assert.deepEqual(target, expectedTarget);
|
||||||
|
});
|
||||||
|
|
||||||
|
// async job accepts one element from the array
|
||||||
|
// and a callback function
|
||||||
|
function asyncJob(item, cb)
|
||||||
|
{
|
||||||
|
// different delays (in ms) per item
|
||||||
|
var delay = item * 25;
|
||||||
|
|
||||||
|
// pretend different jobs take different time to finish
|
||||||
|
// and not in consequential order
|
||||||
|
var timeoutId = setTimeout(function() {
|
||||||
|
target.push(item);
|
||||||
|
cb(null, item * 2);
|
||||||
|
}, delay);
|
||||||
|
|
||||||
|
// allow to cancel "leftover" jobs upon error
|
||||||
|
// return function, invoking of which will abort this job
|
||||||
|
return clearTimeout.bind(null, timeoutId);
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
More examples could be found in [test/test-parallel-array.js](test/test-parallel-array.js).
|
||||||
|
|
||||||
|
#### Input Object
|
||||||
|
|
||||||
|
Also it supports named jobs, listed via object.
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
var parallel = require('asynckit/parallel')
|
||||||
|
, assert = require('assert')
|
||||||
|
;
|
||||||
|
|
||||||
|
var source = { first: 1, one: 1, four: 4, sixteen: 16, sixtyFour: 64, thirtyTwo: 32, eight: 8, two: 2 }
|
||||||
|
, expectedResult = { first: 2, one: 2, four: 8, sixteen: 32, sixtyFour: 128, thirtyTwo: 64, eight: 16, two: 4 }
|
||||||
|
, expectedTarget = [ 1, 1, 2, 4, 8, 16, 32, 64 ]
|
||||||
|
, expectedKeys = [ 'first', 'one', 'two', 'four', 'eight', 'sixteen', 'thirtyTwo', 'sixtyFour' ]
|
||||||
|
, target = []
|
||||||
|
, keys = []
|
||||||
|
;
|
||||||
|
|
||||||
|
parallel(source, asyncJob, function(err, result)
|
||||||
|
{
|
||||||
|
assert.deepEqual(result, expectedResult);
|
||||||
|
assert.deepEqual(target, expectedTarget);
|
||||||
|
assert.deepEqual(keys, expectedKeys);
|
||||||
|
});
|
||||||
|
|
||||||
|
// supports full value, key, callback (shortcut) interface
|
||||||
|
function asyncJob(item, key, cb)
|
||||||
|
{
|
||||||
|
// different delays (in ms) per item
|
||||||
|
var delay = item * 25;
|
||||||
|
|
||||||
|
// pretend different jobs take different time to finish
|
||||||
|
// and not in consequential order
|
||||||
|
var timeoutId = setTimeout(function() {
|
||||||
|
keys.push(key);
|
||||||
|
target.push(item);
|
||||||
|
cb(null, item * 2);
|
||||||
|
}, delay);
|
||||||
|
|
||||||
|
// allow to cancel "leftover" jobs upon error
|
||||||
|
// return function, invoking of which will abort this job
|
||||||
|
return clearTimeout.bind(null, timeoutId);
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
More examples could be found in [test/test-parallel-object.js](test/test-parallel-object.js).
|
||||||
|
|
||||||
|
### Serial Jobs
|
||||||
|
|
||||||
|
Runs iterator over provided array sequentially. Stores output in the `result` array,
|
||||||
|
on the matching positions. In unlikely event of an error from one of the jobs,
|
||||||
|
will not proceed to the rest of the items in the list
|
||||||
|
and return error along with salvaged data to the main callback function.
|
||||||
|
|
||||||
|
#### Input Array
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
var serial = require('asynckit/serial')
|
||||||
|
, assert = require('assert')
|
||||||
|
;
|
||||||
|
|
||||||
|
var source = [ 1, 1, 4, 16, 64, 32, 8, 2 ]
|
||||||
|
, expectedResult = [ 2, 2, 8, 32, 128, 64, 16, 4 ]
|
||||||
|
, expectedTarget = [ 0, 1, 2, 3, 4, 5, 6, 7 ]
|
||||||
|
, target = []
|
||||||
|
;
|
||||||
|
|
||||||
|
serial(source, asyncJob, function(err, result)
|
||||||
|
{
|
||||||
|
assert.deepEqual(result, expectedResult);
|
||||||
|
assert.deepEqual(target, expectedTarget);
|
||||||
|
});
|
||||||
|
|
||||||
|
// extended interface (item, key, callback)
|
||||||
|
// also supported for arrays
|
||||||
|
function asyncJob(item, key, cb)
|
||||||
|
{
|
||||||
|
target.push(key);
|
||||||
|
|
||||||
|
// it will be automatically made async
|
||||||
|
// even it iterator "returns" in the same event loop
|
||||||
|
cb(null, item * 2);
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
More examples could be found in [test/test-serial-array.js](test/test-serial-array.js).
|
||||||
|
|
||||||
|
#### Input Object
|
||||||
|
|
||||||
|
Also it supports named jobs, listed via object.
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
var serial = require('asynckit').serial
|
||||||
|
, assert = require('assert')
|
||||||
|
;
|
||||||
|
|
||||||
|
var source = [ 1, 1, 4, 16, 64, 32, 8, 2 ]
|
||||||
|
, expectedResult = [ 2, 2, 8, 32, 128, 64, 16, 4 ]
|
||||||
|
, expectedTarget = [ 0, 1, 2, 3, 4, 5, 6, 7 ]
|
||||||
|
, target = []
|
||||||
|
;
|
||||||
|
|
||||||
|
var source = { first: 1, one: 1, four: 4, sixteen: 16, sixtyFour: 64, thirtyTwo: 32, eight: 8, two: 2 }
|
||||||
|
, expectedResult = { first: 2, one: 2, four: 8, sixteen: 32, sixtyFour: 128, thirtyTwo: 64, eight: 16, two: 4 }
|
||||||
|
, expectedTarget = [ 1, 1, 4, 16, 64, 32, 8, 2 ]
|
||||||
|
, target = []
|
||||||
|
;
|
||||||
|
|
||||||
|
|
||||||
|
serial(source, asyncJob, function(err, result)
|
||||||
|
{
|
||||||
|
assert.deepEqual(result, expectedResult);
|
||||||
|
assert.deepEqual(target, expectedTarget);
|
||||||
|
});
|
||||||
|
|
||||||
|
// shortcut interface (item, callback)
|
||||||
|
// works for object as well as for the arrays
|
||||||
|
function asyncJob(item, cb)
|
||||||
|
{
|
||||||
|
target.push(item);
|
||||||
|
|
||||||
|
// it will be automatically made async
|
||||||
|
// even it iterator "returns" in the same event loop
|
||||||
|
cb(null, item * 2);
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
More examples could be found in [test/test-serial-object.js](test/test-serial-object.js).
|
||||||
|
|
||||||
|
_Note: Since _object_ is an _unordered_ collection of properties,
|
||||||
|
it may produce unexpected results with sequential iterations.
|
||||||
|
Whenever order of the jobs' execution is important please use `serialOrdered` method._
|
||||||
|
|
||||||
|
### Ordered Serial Iterations
|
||||||
|
|
||||||
|
TBD
|
||||||
|
|
||||||
|
For example [compare-property](compare-property) package.
|
||||||
|
|
||||||
|
### Streaming interface
|
||||||
|
|
||||||
|
TBD
|
||||||
|
|
||||||
|
## Want to Know More?
|
||||||
|
|
||||||
|
More examples can be found in [test folder](test/).
|
||||||
|
|
||||||
|
Or open an [issue](https://github.com/alexindigo/asynckit/issues) with questions and/or suggestions.
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
AsyncKit is licensed under the MIT license.
|
||||||
+76
@@ -0,0 +1,76 @@
|
|||||||
|
/* eslint no-console: "off" */
|
||||||
|
|
||||||
|
var asynckit = require('./')
|
||||||
|
, async = require('async')
|
||||||
|
, assert = require('assert')
|
||||||
|
, expected = 0
|
||||||
|
;
|
||||||
|
|
||||||
|
var Benchmark = require('benchmark');
|
||||||
|
var suite = new Benchmark.Suite;
|
||||||
|
|
||||||
|
var source = [];
|
||||||
|
for (var z = 1; z < 100; z++)
|
||||||
|
{
|
||||||
|
source.push(z);
|
||||||
|
expected += z;
|
||||||
|
}
|
||||||
|
|
||||||
|
suite
|
||||||
|
// add tests
|
||||||
|
|
||||||
|
.add('async.map', function(deferred)
|
||||||
|
{
|
||||||
|
var total = 0;
|
||||||
|
|
||||||
|
async.map(source,
|
||||||
|
function(i, cb)
|
||||||
|
{
|
||||||
|
setImmediate(function()
|
||||||
|
{
|
||||||
|
total += i;
|
||||||
|
cb(null, total);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
function(err, result)
|
||||||
|
{
|
||||||
|
assert.ifError(err);
|
||||||
|
assert.equal(result[result.length - 1], expected);
|
||||||
|
deferred.resolve();
|
||||||
|
});
|
||||||
|
}, {'defer': true})
|
||||||
|
|
||||||
|
|
||||||
|
.add('asynckit.parallel', function(deferred)
|
||||||
|
{
|
||||||
|
var total = 0;
|
||||||
|
|
||||||
|
asynckit.parallel(source,
|
||||||
|
function(i, cb)
|
||||||
|
{
|
||||||
|
setImmediate(function()
|
||||||
|
{
|
||||||
|
total += i;
|
||||||
|
cb(null, total);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
function(err, result)
|
||||||
|
{
|
||||||
|
assert.ifError(err);
|
||||||
|
assert.equal(result[result.length - 1], expected);
|
||||||
|
deferred.resolve();
|
||||||
|
});
|
||||||
|
}, {'defer': true})
|
||||||
|
|
||||||
|
|
||||||
|
// add listeners
|
||||||
|
.on('cycle', function(ev)
|
||||||
|
{
|
||||||
|
console.log(String(ev.target));
|
||||||
|
})
|
||||||
|
.on('complete', function()
|
||||||
|
{
|
||||||
|
console.log('Fastest is ' + this.filter('fastest').map('name'));
|
||||||
|
})
|
||||||
|
// run async
|
||||||
|
.run({ 'async': true });
|
||||||
+6
@@ -0,0 +1,6 @@
|
|||||||
|
module.exports =
|
||||||
|
{
|
||||||
|
parallel : require('./parallel.js'),
|
||||||
|
serial : require('./serial.js'),
|
||||||
|
serialOrdered : require('./serialOrdered.js')
|
||||||
|
};
|
||||||
+29
@@ -0,0 +1,29 @@
|
|||||||
|
// API
|
||||||
|
module.exports = abort;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Aborts leftover active jobs
|
||||||
|
*
|
||||||
|
* @param {object} state - current state object
|
||||||
|
*/
|
||||||
|
function abort(state)
|
||||||
|
{
|
||||||
|
Object.keys(state.jobs).forEach(clean.bind(state));
|
||||||
|
|
||||||
|
// reset leftover jobs
|
||||||
|
state.jobs = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cleans up leftover job by invoking abort function for the provided job id
|
||||||
|
*
|
||||||
|
* @this state
|
||||||
|
* @param {string|number} key - job id to abort
|
||||||
|
*/
|
||||||
|
function clean(key)
|
||||||
|
{
|
||||||
|
if (typeof this.jobs[key] == 'function')
|
||||||
|
{
|
||||||
|
this.jobs[key]();
|
||||||
|
}
|
||||||
|
}
|
||||||
+34
@@ -0,0 +1,34 @@
|
|||||||
|
var defer = require('./defer.js');
|
||||||
|
|
||||||
|
// API
|
||||||
|
module.exports = async;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Runs provided callback asynchronously
|
||||||
|
* even if callback itself is not
|
||||||
|
*
|
||||||
|
* @param {function} callback - callback to invoke
|
||||||
|
* @returns {function} - augmented callback
|
||||||
|
*/
|
||||||
|
function async(callback)
|
||||||
|
{
|
||||||
|
var isAsync = false;
|
||||||
|
|
||||||
|
// check if async happened
|
||||||
|
defer(function() { isAsync = true; });
|
||||||
|
|
||||||
|
return function async_callback(err, result)
|
||||||
|
{
|
||||||
|
if (isAsync)
|
||||||
|
{
|
||||||
|
callback(err, result);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
defer(function nextTick_callback()
|
||||||
|
{
|
||||||
|
callback(err, result);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
+26
@@ -0,0 +1,26 @@
|
|||||||
|
module.exports = defer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Runs provided function on next iteration of the event loop
|
||||||
|
*
|
||||||
|
* @param {function} fn - function to run
|
||||||
|
*/
|
||||||
|
function defer(fn)
|
||||||
|
{
|
||||||
|
var nextTick = typeof setImmediate == 'function'
|
||||||
|
? setImmediate
|
||||||
|
: (
|
||||||
|
typeof process == 'object' && typeof process.nextTick == 'function'
|
||||||
|
? process.nextTick
|
||||||
|
: null
|
||||||
|
);
|
||||||
|
|
||||||
|
if (nextTick)
|
||||||
|
{
|
||||||
|
nextTick(fn);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setTimeout(fn, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
+75
@@ -0,0 +1,75 @@
|
|||||||
|
var async = require('./async.js')
|
||||||
|
, abort = require('./abort.js')
|
||||||
|
;
|
||||||
|
|
||||||
|
// API
|
||||||
|
module.exports = iterate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Iterates over each job object
|
||||||
|
*
|
||||||
|
* @param {array|object} list - array or object (named list) to iterate over
|
||||||
|
* @param {function} iterator - iterator to run
|
||||||
|
* @param {object} state - current job status
|
||||||
|
* @param {function} callback - invoked when all elements processed
|
||||||
|
*/
|
||||||
|
function iterate(list, iterator, state, callback)
|
||||||
|
{
|
||||||
|
// store current index
|
||||||
|
var key = state['keyedList'] ? state['keyedList'][state.index] : state.index;
|
||||||
|
|
||||||
|
state.jobs[key] = runJob(iterator, key, list[key], function(error, output)
|
||||||
|
{
|
||||||
|
// don't repeat yourself
|
||||||
|
// skip secondary callbacks
|
||||||
|
if (!(key in state.jobs))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// clean up jobs
|
||||||
|
delete state.jobs[key];
|
||||||
|
|
||||||
|
if (error)
|
||||||
|
{
|
||||||
|
// don't process rest of the results
|
||||||
|
// stop still active jobs
|
||||||
|
// and reset the list
|
||||||
|
abort(state);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
state.results[key] = output;
|
||||||
|
}
|
||||||
|
|
||||||
|
// return salvaged results
|
||||||
|
callback(error, state.results);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Runs iterator over provided job element
|
||||||
|
*
|
||||||
|
* @param {function} iterator - iterator to invoke
|
||||||
|
* @param {string|number} key - key/index of the element in the list of jobs
|
||||||
|
* @param {mixed} item - job description
|
||||||
|
* @param {function} callback - invoked after iterator is done with the job
|
||||||
|
* @returns {function|mixed} - job abort function or something else
|
||||||
|
*/
|
||||||
|
function runJob(iterator, key, item, callback)
|
||||||
|
{
|
||||||
|
var aborter;
|
||||||
|
|
||||||
|
// allow shortcut if iterator expects only two arguments
|
||||||
|
if (iterator.length == 2)
|
||||||
|
{
|
||||||
|
aborter = iterator(item, async(callback));
|
||||||
|
}
|
||||||
|
// otherwise go with full three arguments
|
||||||
|
else
|
||||||
|
{
|
||||||
|
aborter = iterator(item, key, async(callback));
|
||||||
|
}
|
||||||
|
|
||||||
|
return aborter;
|
||||||
|
}
|
||||||
+91
@@ -0,0 +1,91 @@
|
|||||||
|
var streamify = require('./streamify.js')
|
||||||
|
, defer = require('./defer.js')
|
||||||
|
;
|
||||||
|
|
||||||
|
// API
|
||||||
|
module.exports = ReadableAsyncKit;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Base constructor for all streams
|
||||||
|
* used to hold properties/methods
|
||||||
|
*/
|
||||||
|
function ReadableAsyncKit()
|
||||||
|
{
|
||||||
|
ReadableAsyncKit.super_.apply(this, arguments);
|
||||||
|
|
||||||
|
// list of active jobs
|
||||||
|
this.jobs = {};
|
||||||
|
|
||||||
|
// add stream methods
|
||||||
|
this.destroy = destroy;
|
||||||
|
this._start = _start;
|
||||||
|
this._read = _read;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Destroys readable stream,
|
||||||
|
* by aborting outstanding jobs
|
||||||
|
*
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
|
function destroy()
|
||||||
|
{
|
||||||
|
if (this.destroyed)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.destroyed = true;
|
||||||
|
|
||||||
|
if (typeof this.terminator == 'function')
|
||||||
|
{
|
||||||
|
this.terminator();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Starts provided jobs in async manner
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
function _start()
|
||||||
|
{
|
||||||
|
// first argument – runner function
|
||||||
|
var runner = arguments[0]
|
||||||
|
// take away first argument
|
||||||
|
, args = Array.prototype.slice.call(arguments, 1)
|
||||||
|
// second argument - input data
|
||||||
|
, input = args[0]
|
||||||
|
// last argument - result callback
|
||||||
|
, endCb = streamify.callback.call(this, args[args.length - 1])
|
||||||
|
;
|
||||||
|
|
||||||
|
args[args.length - 1] = endCb;
|
||||||
|
// third argument - iterator
|
||||||
|
args[1] = streamify.iterator.call(this, args[1]);
|
||||||
|
|
||||||
|
// allow time for proper setup
|
||||||
|
defer(function()
|
||||||
|
{
|
||||||
|
if (!this.destroyed)
|
||||||
|
{
|
||||||
|
this.terminator = runner.apply(null, args);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
endCb(null, Array.isArray(input) ? [] : {});
|
||||||
|
}
|
||||||
|
}.bind(this));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implement _read to comply with Readable streams
|
||||||
|
* Doesn't really make sense for flowing object mode
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
function _read()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
+25
@@ -0,0 +1,25 @@
|
|||||||
|
var parallel = require('../parallel.js');
|
||||||
|
|
||||||
|
// API
|
||||||
|
module.exports = ReadableParallel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Streaming wrapper to `asynckit.parallel`
|
||||||
|
*
|
||||||
|
* @param {array|object} list - array or object (named list) to iterate over
|
||||||
|
* @param {function} iterator - iterator to run
|
||||||
|
* @param {function} callback - invoked when all elements processed
|
||||||
|
* @returns {stream.Readable#}
|
||||||
|
*/
|
||||||
|
function ReadableParallel(list, iterator, callback)
|
||||||
|
{
|
||||||
|
if (!(this instanceof ReadableParallel))
|
||||||
|
{
|
||||||
|
return new ReadableParallel(list, iterator, callback);
|
||||||
|
}
|
||||||
|
|
||||||
|
// turn on object mode
|
||||||
|
ReadableParallel.super_.call(this, {objectMode: true});
|
||||||
|
|
||||||
|
this._start(parallel, list, iterator, callback);
|
||||||
|
}
|
||||||
+25
@@ -0,0 +1,25 @@
|
|||||||
|
var serial = require('../serial.js');
|
||||||
|
|
||||||
|
// API
|
||||||
|
module.exports = ReadableSerial;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Streaming wrapper to `asynckit.serial`
|
||||||
|
*
|
||||||
|
* @param {array|object} list - array or object (named list) to iterate over
|
||||||
|
* @param {function} iterator - iterator to run
|
||||||
|
* @param {function} callback - invoked when all elements processed
|
||||||
|
* @returns {stream.Readable#}
|
||||||
|
*/
|
||||||
|
function ReadableSerial(list, iterator, callback)
|
||||||
|
{
|
||||||
|
if (!(this instanceof ReadableSerial))
|
||||||
|
{
|
||||||
|
return new ReadableSerial(list, iterator, callback);
|
||||||
|
}
|
||||||
|
|
||||||
|
// turn on object mode
|
||||||
|
ReadableSerial.super_.call(this, {objectMode: true});
|
||||||
|
|
||||||
|
this._start(serial, list, iterator, callback);
|
||||||
|
}
|
||||||
+29
@@ -0,0 +1,29 @@
|
|||||||
|
var serialOrdered = require('../serialOrdered.js');
|
||||||
|
|
||||||
|
// API
|
||||||
|
module.exports = ReadableSerialOrdered;
|
||||||
|
// expose sort helpers
|
||||||
|
module.exports.ascending = serialOrdered.ascending;
|
||||||
|
module.exports.descending = serialOrdered.descending;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Streaming wrapper to `asynckit.serialOrdered`
|
||||||
|
*
|
||||||
|
* @param {array|object} list - array or object (named list) to iterate over
|
||||||
|
* @param {function} iterator - iterator to run
|
||||||
|
* @param {function} sortMethod - custom sort function
|
||||||
|
* @param {function} callback - invoked when all elements processed
|
||||||
|
* @returns {stream.Readable#}
|
||||||
|
*/
|
||||||
|
function ReadableSerialOrdered(list, iterator, sortMethod, callback)
|
||||||
|
{
|
||||||
|
if (!(this instanceof ReadableSerialOrdered))
|
||||||
|
{
|
||||||
|
return new ReadableSerialOrdered(list, iterator, sortMethod, callback);
|
||||||
|
}
|
||||||
|
|
||||||
|
// turn on object mode
|
||||||
|
ReadableSerialOrdered.super_.call(this, {objectMode: true});
|
||||||
|
|
||||||
|
this._start(serialOrdered, list, iterator, sortMethod, callback);
|
||||||
|
}
|
||||||
+37
@@ -0,0 +1,37 @@
|
|||||||
|
// API
|
||||||
|
module.exports = state;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates initial state object
|
||||||
|
* for iteration over list
|
||||||
|
*
|
||||||
|
* @param {array|object} list - list to iterate over
|
||||||
|
* @param {function|null} sortMethod - function to use for keys sort,
|
||||||
|
* or `null` to keep them as is
|
||||||
|
* @returns {object} - initial state object
|
||||||
|
*/
|
||||||
|
function state(list, sortMethod)
|
||||||
|
{
|
||||||
|
var isNamedList = !Array.isArray(list)
|
||||||
|
, initState =
|
||||||
|
{
|
||||||
|
index : 0,
|
||||||
|
keyedList: isNamedList || sortMethod ? Object.keys(list) : null,
|
||||||
|
jobs : {},
|
||||||
|
results : isNamedList ? {} : [],
|
||||||
|
size : isNamedList ? Object.keys(list).length : list.length
|
||||||
|
}
|
||||||
|
;
|
||||||
|
|
||||||
|
if (sortMethod)
|
||||||
|
{
|
||||||
|
// sort array keys based on it's values
|
||||||
|
// sort object's keys just on own merit
|
||||||
|
initState.keyedList.sort(isNamedList ? sortMethod : function(a, b)
|
||||||
|
{
|
||||||
|
return sortMethod(list[a], list[b]);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return initState;
|
||||||
|
}
|
||||||
+141
@@ -0,0 +1,141 @@
|
|||||||
|
var async = require('./async.js');
|
||||||
|
|
||||||
|
// API
|
||||||
|
module.exports = {
|
||||||
|
iterator: wrapIterator,
|
||||||
|
callback: wrapCallback
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wraps iterators with long signature
|
||||||
|
*
|
||||||
|
* @this ReadableAsyncKit#
|
||||||
|
* @param {function} iterator - function to wrap
|
||||||
|
* @returns {function} - wrapped function
|
||||||
|
*/
|
||||||
|
function wrapIterator(iterator)
|
||||||
|
{
|
||||||
|
var stream = this;
|
||||||
|
|
||||||
|
return function(item, key, cb)
|
||||||
|
{
|
||||||
|
var aborter
|
||||||
|
, wrappedCb = async(wrapIteratorCallback.call(stream, cb, key))
|
||||||
|
;
|
||||||
|
|
||||||
|
stream.jobs[key] = wrappedCb;
|
||||||
|
|
||||||
|
// it's either shortcut (item, cb)
|
||||||
|
if (iterator.length == 2)
|
||||||
|
{
|
||||||
|
aborter = iterator(item, wrappedCb);
|
||||||
|
}
|
||||||
|
// or long format (item, key, cb)
|
||||||
|
else
|
||||||
|
{
|
||||||
|
aborter = iterator(item, key, wrappedCb);
|
||||||
|
}
|
||||||
|
|
||||||
|
return aborter;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wraps provided callback function
|
||||||
|
* allowing to execute snitch function before
|
||||||
|
* real callback
|
||||||
|
*
|
||||||
|
* @this ReadableAsyncKit#
|
||||||
|
* @param {function} callback - function to wrap
|
||||||
|
* @returns {function} - wrapped function
|
||||||
|
*/
|
||||||
|
function wrapCallback(callback)
|
||||||
|
{
|
||||||
|
var stream = this;
|
||||||
|
|
||||||
|
var wrapped = function(error, result)
|
||||||
|
{
|
||||||
|
return finisher.call(stream, error, result, callback);
|
||||||
|
};
|
||||||
|
|
||||||
|
return wrapped;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wraps provided iterator callback function
|
||||||
|
* makes sure snitch only called once,
|
||||||
|
* but passes secondary calls to the original callback
|
||||||
|
*
|
||||||
|
* @this ReadableAsyncKit#
|
||||||
|
* @param {function} callback - callback to wrap
|
||||||
|
* @param {number|string} key - iteration key
|
||||||
|
* @returns {function} wrapped callback
|
||||||
|
*/
|
||||||
|
function wrapIteratorCallback(callback, key)
|
||||||
|
{
|
||||||
|
var stream = this;
|
||||||
|
|
||||||
|
return function(error, output)
|
||||||
|
{
|
||||||
|
// don't repeat yourself
|
||||||
|
if (!(key in stream.jobs))
|
||||||
|
{
|
||||||
|
callback(error, output);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// clean up jobs
|
||||||
|
delete stream.jobs[key];
|
||||||
|
|
||||||
|
return streamer.call(stream, error, {key: key, value: output}, callback);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stream wrapper for iterator callback
|
||||||
|
*
|
||||||
|
* @this ReadableAsyncKit#
|
||||||
|
* @param {mixed} error - error response
|
||||||
|
* @param {mixed} output - iterator output
|
||||||
|
* @param {function} callback - callback that expects iterator results
|
||||||
|
*/
|
||||||
|
function streamer(error, output, callback)
|
||||||
|
{
|
||||||
|
if (error && !this.error)
|
||||||
|
{
|
||||||
|
this.error = error;
|
||||||
|
this.pause();
|
||||||
|
this.emit('error', error);
|
||||||
|
// send back value only, as expected
|
||||||
|
callback(error, output && output.value);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// stream stuff
|
||||||
|
this.push(output);
|
||||||
|
|
||||||
|
// back to original track
|
||||||
|
// send back value only, as expected
|
||||||
|
callback(error, output && output.value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stream wrapper for finishing callback
|
||||||
|
*
|
||||||
|
* @this ReadableAsyncKit#
|
||||||
|
* @param {mixed} error - error response
|
||||||
|
* @param {mixed} output - iterator output
|
||||||
|
* @param {function} callback - callback that expects final results
|
||||||
|
*/
|
||||||
|
function finisher(error, output, callback)
|
||||||
|
{
|
||||||
|
// signal end of the stream
|
||||||
|
// only for successfully finished streams
|
||||||
|
if (!error)
|
||||||
|
{
|
||||||
|
this.push(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
// back to original track
|
||||||
|
callback(error, output);
|
||||||
|
}
|
||||||
+29
@@ -0,0 +1,29 @@
|
|||||||
|
var abort = require('./abort.js')
|
||||||
|
, async = require('./async.js')
|
||||||
|
;
|
||||||
|
|
||||||
|
// API
|
||||||
|
module.exports = terminator;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Terminates jobs in the attached state context
|
||||||
|
*
|
||||||
|
* @this AsyncKitState#
|
||||||
|
* @param {function} callback - final callback to invoke after termination
|
||||||
|
*/
|
||||||
|
function terminator(callback)
|
||||||
|
{
|
||||||
|
if (!Object.keys(this.jobs).length)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// fast forward iteration index
|
||||||
|
this.index = this.size;
|
||||||
|
|
||||||
|
// abort jobs
|
||||||
|
abort(this);
|
||||||
|
|
||||||
|
// send back results we have so far
|
||||||
|
async(callback)(null, this.results);
|
||||||
|
}
|
||||||
+63
@@ -0,0 +1,63 @@
|
|||||||
|
{
|
||||||
|
"name": "asynckit",
|
||||||
|
"version": "0.4.0",
|
||||||
|
"description": "Minimal async jobs utility library, with streams support",
|
||||||
|
"main": "index.js",
|
||||||
|
"scripts": {
|
||||||
|
"clean": "rimraf coverage",
|
||||||
|
"lint": "eslint *.js lib/*.js test/*.js",
|
||||||
|
"test": "istanbul cover --reporter=json tape -- 'test/test-*.js' | tap-spec",
|
||||||
|
"win-test": "tape test/test-*.js",
|
||||||
|
"browser": "browserify -t browserify-istanbul test/lib/browserify_adjustment.js test/test-*.js | obake --coverage | tap-spec",
|
||||||
|
"report": "istanbul report",
|
||||||
|
"size": "browserify index.js | size-table asynckit",
|
||||||
|
"debug": "tape test/test-*.js"
|
||||||
|
},
|
||||||
|
"pre-commit": [
|
||||||
|
"clean",
|
||||||
|
"lint",
|
||||||
|
"test",
|
||||||
|
"browser",
|
||||||
|
"report",
|
||||||
|
"size"
|
||||||
|
],
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git+https://github.com/alexindigo/asynckit.git"
|
||||||
|
},
|
||||||
|
"keywords": [
|
||||||
|
"async",
|
||||||
|
"jobs",
|
||||||
|
"parallel",
|
||||||
|
"serial",
|
||||||
|
"iterator",
|
||||||
|
"array",
|
||||||
|
"object",
|
||||||
|
"stream",
|
||||||
|
"destroy",
|
||||||
|
"terminate",
|
||||||
|
"abort"
|
||||||
|
],
|
||||||
|
"author": "Alex Indigo <iam@alexindigo.com>",
|
||||||
|
"license": "MIT",
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/alexindigo/asynckit/issues"
|
||||||
|
},
|
||||||
|
"homepage": "https://github.com/alexindigo/asynckit#readme",
|
||||||
|
"devDependencies": {
|
||||||
|
"browserify": "^13.0.0",
|
||||||
|
"browserify-istanbul": "^2.0.0",
|
||||||
|
"coveralls": "^2.11.9",
|
||||||
|
"eslint": "^2.9.0",
|
||||||
|
"istanbul": "^0.4.3",
|
||||||
|
"obake": "^0.1.2",
|
||||||
|
"phantomjs-prebuilt": "^2.1.7",
|
||||||
|
"pre-commit": "^1.1.3",
|
||||||
|
"reamde": "^1.1.0",
|
||||||
|
"rimraf": "^2.5.2",
|
||||||
|
"size-table": "^0.2.0",
|
||||||
|
"tap-spec": "^4.1.1",
|
||||||
|
"tape": "^4.5.1"
|
||||||
|
},
|
||||||
|
"dependencies": {}
|
||||||
|
}
|
||||||
+43
@@ -0,0 +1,43 @@
|
|||||||
|
var iterate = require('./lib/iterate.js')
|
||||||
|
, initState = require('./lib/state.js')
|
||||||
|
, terminator = require('./lib/terminator.js')
|
||||||
|
;
|
||||||
|
|
||||||
|
// Public API
|
||||||
|
module.exports = parallel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Runs iterator over provided array elements in parallel
|
||||||
|
*
|
||||||
|
* @param {array|object} list - array or object (named list) to iterate over
|
||||||
|
* @param {function} iterator - iterator to run
|
||||||
|
* @param {function} callback - invoked when all elements processed
|
||||||
|
* @returns {function} - jobs terminator
|
||||||
|
*/
|
||||||
|
function parallel(list, iterator, callback)
|
||||||
|
{
|
||||||
|
var state = initState(list);
|
||||||
|
|
||||||
|
while (state.index < (state['keyedList'] || list).length)
|
||||||
|
{
|
||||||
|
iterate(list, iterator, state, function(error, result)
|
||||||
|
{
|
||||||
|
if (error)
|
||||||
|
{
|
||||||
|
callback(error, result);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// looks like it's the last one
|
||||||
|
if (Object.keys(state.jobs).length === 0)
|
||||||
|
{
|
||||||
|
callback(null, state.results);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
state.index++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return terminator.bind(state, callback);
|
||||||
|
}
|
||||||
+17
@@ -0,0 +1,17 @@
|
|||||||
|
var serialOrdered = require('./serialOrdered.js');
|
||||||
|
|
||||||
|
// Public API
|
||||||
|
module.exports = serial;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Runs iterator over provided array elements in series
|
||||||
|
*
|
||||||
|
* @param {array|object} list - array or object (named list) to iterate over
|
||||||
|
* @param {function} iterator - iterator to run
|
||||||
|
* @param {function} callback - invoked when all elements processed
|
||||||
|
* @returns {function} - jobs terminator
|
||||||
|
*/
|
||||||
|
function serial(list, iterator, callback)
|
||||||
|
{
|
||||||
|
return serialOrdered(list, iterator, null, callback);
|
||||||
|
}
|
||||||
+75
@@ -0,0 +1,75 @@
|
|||||||
|
var iterate = require('./lib/iterate.js')
|
||||||
|
, initState = require('./lib/state.js')
|
||||||
|
, terminator = require('./lib/terminator.js')
|
||||||
|
;
|
||||||
|
|
||||||
|
// Public API
|
||||||
|
module.exports = serialOrdered;
|
||||||
|
// sorting helpers
|
||||||
|
module.exports.ascending = ascending;
|
||||||
|
module.exports.descending = descending;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Runs iterator over provided sorted array elements in series
|
||||||
|
*
|
||||||
|
* @param {array|object} list - array or object (named list) to iterate over
|
||||||
|
* @param {function} iterator - iterator to run
|
||||||
|
* @param {function} sortMethod - custom sort function
|
||||||
|
* @param {function} callback - invoked when all elements processed
|
||||||
|
* @returns {function} - jobs terminator
|
||||||
|
*/
|
||||||
|
function serialOrdered(list, iterator, sortMethod, callback)
|
||||||
|
{
|
||||||
|
var state = initState(list, sortMethod);
|
||||||
|
|
||||||
|
iterate(list, iterator, state, function iteratorHandler(error, result)
|
||||||
|
{
|
||||||
|
if (error)
|
||||||
|
{
|
||||||
|
callback(error, result);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
state.index++;
|
||||||
|
|
||||||
|
// are we there yet?
|
||||||
|
if (state.index < (state['keyedList'] || list).length)
|
||||||
|
{
|
||||||
|
iterate(list, iterator, state, iteratorHandler);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// done here
|
||||||
|
callback(null, state.results);
|
||||||
|
});
|
||||||
|
|
||||||
|
return terminator.bind(state, callback);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* -- Sort methods
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sort helper to sort array elements in ascending order
|
||||||
|
*
|
||||||
|
* @param {mixed} a - an item to compare
|
||||||
|
* @param {mixed} b - an item to compare
|
||||||
|
* @returns {number} - comparison result
|
||||||
|
*/
|
||||||
|
function ascending(a, b)
|
||||||
|
{
|
||||||
|
return a < b ? -1 : a > b ? 1 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sort helper to sort array elements in descending order
|
||||||
|
*
|
||||||
|
* @param {mixed} a - an item to compare
|
||||||
|
* @param {mixed} b - an item to compare
|
||||||
|
* @returns {number} - comparison result
|
||||||
|
*/
|
||||||
|
function descending(a, b)
|
||||||
|
{
|
||||||
|
return -1 * ascending(a, b);
|
||||||
|
}
|
||||||
+21
@@ -0,0 +1,21 @@
|
|||||||
|
var inherits = require('util').inherits
|
||||||
|
, Readable = require('stream').Readable
|
||||||
|
, ReadableAsyncKit = require('./lib/readable_asynckit.js')
|
||||||
|
, ReadableParallel = require('./lib/readable_parallel.js')
|
||||||
|
, ReadableSerial = require('./lib/readable_serial.js')
|
||||||
|
, ReadableSerialOrdered = require('./lib/readable_serial_ordered.js')
|
||||||
|
;
|
||||||
|
|
||||||
|
// API
|
||||||
|
module.exports =
|
||||||
|
{
|
||||||
|
parallel : ReadableParallel,
|
||||||
|
serial : ReadableSerial,
|
||||||
|
serialOrdered : ReadableSerialOrdered,
|
||||||
|
};
|
||||||
|
|
||||||
|
inherits(ReadableAsyncKit, Readable);
|
||||||
|
|
||||||
|
inherits(ReadableParallel, ReadableAsyncKit);
|
||||||
|
inherits(ReadableSerial, ReadableAsyncKit);
|
||||||
|
inherits(ReadableSerialOrdered, ReadableAsyncKit);
|
||||||
+23
@@ -0,0 +1,23 @@
|
|||||||
|
(The MIT License)
|
||||||
|
|
||||||
|
Copyright (c) 2014 Jonathan Ong <me@jongleberry.com>
|
||||||
|
Copyright (c) 2014-2015 Douglas Christopher Wilson <doug@somethingdoug.com>
|
||||||
|
|
||||||
|
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.
|
||||||
+509
@@ -0,0 +1,509 @@
|
|||||||
|
# body-parser
|
||||||
|
|
||||||
|
[![NPM Version][npm-version-image]][npm-url]
|
||||||
|
[![NPM Downloads][npm-downloads-image]][npm-url]
|
||||||
|
[![Build Status][ci-image]][ci-url]
|
||||||
|
[![Test Coverage][coveralls-image]][coveralls-url]
|
||||||
|
[![OpenSSF Scorecard Badge][ossf-scorecard-badge]][ossf-scorecard-visualizer]
|
||||||
|
|
||||||
|
Node.js body parsing middleware.
|
||||||
|
|
||||||
|
Parse incoming request bodies in a middleware before your handlers, available
|
||||||
|
under the `req.body` property.
|
||||||
|
|
||||||
|
**Note** As `req.body`'s shape is based on user-controlled input, all
|
||||||
|
properties and values in this object are untrusted and should be validated
|
||||||
|
before trusting. For example, `req.body.foo.toString()` may fail in multiple
|
||||||
|
ways, for example the `foo` property may not be there or may not be a string,
|
||||||
|
and `toString` may not be a function and instead a string or other user input.
|
||||||
|
|
||||||
|
[Learn about the anatomy of an HTTP transaction in Node.js](https://nodejs.org/en/learn/http/anatomy-of-an-http-transaction).
|
||||||
|
|
||||||
|
_This does not handle multipart bodies_, due to their complex and typically
|
||||||
|
large nature. For multipart bodies, you may be interested in the following
|
||||||
|
modules:
|
||||||
|
|
||||||
|
* [busboy](https://www.npmjs.com/package/busboy#readme) and
|
||||||
|
[connect-busboy](https://www.npmjs.com/package/connect-busboy#readme)
|
||||||
|
* [multiparty](https://www.npmjs.com/package/multiparty#readme) and
|
||||||
|
[connect-multiparty](https://www.npmjs.com/package/connect-multiparty#readme)
|
||||||
|
* [formidable](https://www.npmjs.com/package/formidable#readme)
|
||||||
|
* [multer](https://www.npmjs.com/package/multer#readme)
|
||||||
|
|
||||||
|
This module provides the following parsers:
|
||||||
|
|
||||||
|
* [JSON body parser](#bodyparserjsonoptions)
|
||||||
|
* [Raw body parser](#bodyparserrawoptions)
|
||||||
|
* [Text body parser](#bodyparsertextoptions)
|
||||||
|
* [URL-encoded form body parser](#bodyparserurlencodedoptions)
|
||||||
|
|
||||||
|
Other body parsers you might be interested in:
|
||||||
|
|
||||||
|
- [body](https://www.npmjs.com/package/body#readme)
|
||||||
|
- [co-body](https://www.npmjs.com/package/co-body#readme)
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ npm install body-parser
|
||||||
|
```
|
||||||
|
|
||||||
|
## API
|
||||||
|
|
||||||
|
```js
|
||||||
|
// Import all parsers
|
||||||
|
const bodyParser = require('body-parser')
|
||||||
|
|
||||||
|
// Or import individual parsers directly
|
||||||
|
const json = require('body-parser/json')
|
||||||
|
const urlencoded = require('body-parser/urlencoded')
|
||||||
|
const raw = require('body-parser/raw')
|
||||||
|
const text = require('body-parser/text')
|
||||||
|
```
|
||||||
|
|
||||||
|
The `bodyParser` object exposes various factories to create middlewares. All
|
||||||
|
middlewares will populate the `req.body` property with the parsed body when
|
||||||
|
the `Content-Type` request header matches the `type` option.
|
||||||
|
|
||||||
|
The various errors returned by this module are described in the
|
||||||
|
[errors section](#errors).
|
||||||
|
|
||||||
|
### bodyParser.json([options])
|
||||||
|
|
||||||
|
Returns middleware that only parses `json` and only looks at requests where
|
||||||
|
the `Content-Type` header matches the `type` option. This parser accepts any
|
||||||
|
Unicode encoding of the body and supports automatic inflation of `gzip`,
|
||||||
|
`br` (brotli) and `deflate` encodings.
|
||||||
|
|
||||||
|
A new `body` object containing the parsed data is populated on the `request`
|
||||||
|
object after the middleware (i.e. `req.body`).
|
||||||
|
|
||||||
|
#### Options
|
||||||
|
|
||||||
|
The `json` function takes an optional `options` object that may contain any of
|
||||||
|
the following keys:
|
||||||
|
|
||||||
|
##### defaultCharset
|
||||||
|
|
||||||
|
Specify the default character set for the json content if the charset is not
|
||||||
|
specified in the `Content-Type` header of the request. Defaults to `utf-8`.
|
||||||
|
|
||||||
|
##### inflate
|
||||||
|
|
||||||
|
When set to `true`, then deflated (compressed) bodies will be inflated; when
|
||||||
|
`false`, deflated bodies are rejected. Defaults to `true`.
|
||||||
|
|
||||||
|
##### limit
|
||||||
|
|
||||||
|
Controls the maximum request body size. If this is a number, then the value
|
||||||
|
specifies the number of bytes; if it is a string, the value is passed to the
|
||||||
|
[bytes](https://www.npmjs.com/package/bytes) library for parsing. Defaults
|
||||||
|
to `'100kb'`.
|
||||||
|
|
||||||
|
> It’s recommended not to configure a very high limit and to use the default value whenever possible. Allowing larger payloads increases memory usage because of the resources required for decoding and transformations, and it can also lead to longer response times as more data is processed. By ‘very high’, we mean values above the default, for example payloads of 5 MB or more can already start to introduce these risks. With the default limits, these issues do not occur.
|
||||||
|
|
||||||
|
##### reviver
|
||||||
|
|
||||||
|
The `reviver` option is passed directly to `JSON.parse` as the second
|
||||||
|
argument. You can find more information on this argument
|
||||||
|
[in the MDN documentation about JSON.parse](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse#the_reviver_parameter).
|
||||||
|
|
||||||
|
##### strict
|
||||||
|
|
||||||
|
When set to `true`, will only accept arrays and objects; when `false` will
|
||||||
|
accept anything `JSON.parse` accepts. Defaults to `true`.
|
||||||
|
|
||||||
|
##### type
|
||||||
|
|
||||||
|
The `type` option is used to determine what media type the middleware will
|
||||||
|
parse. This option can be a string, array of strings, or a function. If not a
|
||||||
|
function, `type` option is passed directly to the
|
||||||
|
[type-is](https://www.npmjs.com/package/type-is#readme) library and this can
|
||||||
|
be an extension name (like `json`), a mime type (like `application/json`), or
|
||||||
|
a mime type with a wildcard (like `*/*` or `*/json`). If a function, the `type`
|
||||||
|
option is called as `fn(req)` and the request is parsed if it returns a truthy
|
||||||
|
value. Defaults to `application/json`.
|
||||||
|
|
||||||
|
##### verify
|
||||||
|
|
||||||
|
The `verify` option, if supplied, is called as `verify(req, res, buf, encoding)`,
|
||||||
|
where `buf` is a `Buffer` of the raw request body and `encoding` is the
|
||||||
|
encoding of the request. The parsing can be aborted by throwing an error.
|
||||||
|
|
||||||
|
### bodyParser.raw([options])
|
||||||
|
|
||||||
|
Returns middleware that parses all bodies as a `Buffer` and only looks at
|
||||||
|
requests where the `Content-Type` header matches the `type` option. This
|
||||||
|
parser supports automatic inflation of `gzip`, `br` (brotli) and `deflate`
|
||||||
|
encodings.
|
||||||
|
|
||||||
|
A new `body` object containing the parsed data is populated on the `request`
|
||||||
|
object after the middleware (i.e. `req.body`). This will be a `Buffer` object
|
||||||
|
of the body.
|
||||||
|
|
||||||
|
#### Options
|
||||||
|
|
||||||
|
The `raw` function takes an optional `options` object that may contain any of
|
||||||
|
the following keys:
|
||||||
|
|
||||||
|
##### inflate
|
||||||
|
|
||||||
|
When set to `true`, then deflated (compressed) bodies will be inflated; when
|
||||||
|
`false`, deflated bodies are rejected. Defaults to `true`.
|
||||||
|
|
||||||
|
##### limit
|
||||||
|
|
||||||
|
Controls the maximum request body size. If this is a number, then the value
|
||||||
|
specifies the number of bytes; if it is a string, the value is passed to the
|
||||||
|
[bytes](https://www.npmjs.com/package/bytes) library for parsing. Defaults
|
||||||
|
to `'100kb'`.
|
||||||
|
|
||||||
|
> It’s recommended not to configure a very high limit and to use the default value whenever possible. Allowing larger payloads increases memory usage because of the resources required for decoding and transformations, and it can also lead to longer response times as more data is processed. By ‘very high’, we mean values above the default, for example payloads of 5 MB or more can already start to introduce these risks. With the default limits, these issues do not occur.
|
||||||
|
|
||||||
|
##### type
|
||||||
|
|
||||||
|
The `type` option is used to determine what media type the middleware will
|
||||||
|
parse. This option can be a string, array of strings, or a function.
|
||||||
|
If not a function, `type` option is passed directly to the
|
||||||
|
[type-is](https://www.npmjs.com/package/type-is#readme) library and this
|
||||||
|
can be an extension name (like `bin`), a mime type (like
|
||||||
|
`application/octet-stream`), or a mime type with a wildcard (like `*/*` or
|
||||||
|
`application/*`). If a function, the `type` option is called as `fn(req)`
|
||||||
|
and the request is parsed if it returns a truthy value. Defaults to
|
||||||
|
`application/octet-stream`.
|
||||||
|
|
||||||
|
##### verify
|
||||||
|
|
||||||
|
The `verify` option, if supplied, is called as `verify(req, res, buf, encoding)`,
|
||||||
|
where `buf` is a `Buffer` of the raw request body and `encoding` is the
|
||||||
|
encoding of the request. The parsing can be aborted by throwing an error.
|
||||||
|
|
||||||
|
### bodyParser.text([options])
|
||||||
|
|
||||||
|
Returns middleware that parses all bodies as a string and only looks at
|
||||||
|
requests where the `Content-Type` header matches the `type` option. This
|
||||||
|
parser supports automatic inflation of `gzip`, `br` (brotli) and `deflate`
|
||||||
|
encodings.
|
||||||
|
|
||||||
|
A new `body` string containing the parsed data is populated on the `request`
|
||||||
|
object after the middleware (i.e. `req.body`). This will be a string of the
|
||||||
|
body.
|
||||||
|
|
||||||
|
#### Options
|
||||||
|
|
||||||
|
The `text` function takes an optional `options` object that may contain any of
|
||||||
|
the following keys:
|
||||||
|
|
||||||
|
##### defaultCharset
|
||||||
|
|
||||||
|
Specify the default character set for the text content if the charset is not
|
||||||
|
specified in the `Content-Type` header of the request. Defaults to `utf-8`.
|
||||||
|
|
||||||
|
##### inflate
|
||||||
|
|
||||||
|
When set to `true`, then deflated (compressed) bodies will be inflated; when
|
||||||
|
`false`, deflated bodies are rejected. Defaults to `true`.
|
||||||
|
|
||||||
|
##### limit
|
||||||
|
|
||||||
|
Controls the maximum request body size. If this is a number, then the value
|
||||||
|
specifies the number of bytes; if it is a string, the value is passed to the
|
||||||
|
[bytes](https://www.npmjs.com/package/bytes) library for parsing. Defaults
|
||||||
|
to `'100kb'`.
|
||||||
|
|
||||||
|
> It’s recommended not to configure a very high limit and to use the default value whenever possible. Allowing larger payloads increases memory usage because of the resources required for decoding and transformations, and it can also lead to longer response times as more data is processed. By ‘very high’, we mean values above the default, for example payloads of 5 MB or more can already start to introduce these risks. With the default limits, these issues do not occur.
|
||||||
|
|
||||||
|
##### type
|
||||||
|
|
||||||
|
The `type` option is used to determine what media type the middleware will
|
||||||
|
parse. This option can be a string, array of strings, or a function. If not
|
||||||
|
a function, `type` option is passed directly to the
|
||||||
|
[type-is](https://www.npmjs.com/package/type-is#readme) library and this can
|
||||||
|
be an extension name (like `txt`), a mime type (like `text/plain`), or a mime
|
||||||
|
type with a wildcard (like `*/*` or `text/*`). If a function, the `type`
|
||||||
|
option is called as `fn(req)` and the request is parsed if it returns a
|
||||||
|
truthy value. Defaults to `text/plain`.
|
||||||
|
|
||||||
|
##### verify
|
||||||
|
|
||||||
|
The `verify` option, if supplied, is called as `verify(req, res, buf, encoding)`,
|
||||||
|
where `buf` is a `Buffer` of the raw request body and `encoding` is the
|
||||||
|
encoding of the request. The parsing can be aborted by throwing an error.
|
||||||
|
|
||||||
|
### bodyParser.urlencoded([options])
|
||||||
|
|
||||||
|
Returns middleware that only parses `urlencoded` bodies and only looks at
|
||||||
|
requests where the `Content-Type` header matches the `type` option. This
|
||||||
|
parser accepts only UTF-8 and ISO-8859-1 encodings of the body and supports
|
||||||
|
automatic inflation of `gzip`, `br` (brotli) and `deflate` encodings.
|
||||||
|
|
||||||
|
A new `body` object containing the parsed data is populated on the `request`
|
||||||
|
object after the middleware (i.e. `req.body`). This object will contain
|
||||||
|
key-value pairs, where the value can be a string or array (when `extended` is
|
||||||
|
`false`), or any type (when `extended` is `true`).
|
||||||
|
|
||||||
|
#### Options
|
||||||
|
|
||||||
|
The `urlencoded` function takes an optional `options` object that may contain
|
||||||
|
any of the following keys:
|
||||||
|
|
||||||
|
##### extended
|
||||||
|
|
||||||
|
The "extended" syntax allows for rich objects and arrays to be encoded into the
|
||||||
|
URL-encoded format, allowing for a JSON-like experience with URL-encoded. For
|
||||||
|
more information, please [see the qs
|
||||||
|
library](https://www.npmjs.com/package/qs#readme).
|
||||||
|
|
||||||
|
Defaults to `false`.
|
||||||
|
|
||||||
|
##### inflate
|
||||||
|
|
||||||
|
When set to `true`, then deflated (compressed) bodies will be inflated; when
|
||||||
|
`false`, deflated bodies are rejected. Defaults to `true`.
|
||||||
|
|
||||||
|
##### limit
|
||||||
|
|
||||||
|
Controls the maximum request body size. If this is a number, then the value
|
||||||
|
specifies the number of bytes; if it is a string, the value is passed to the
|
||||||
|
[bytes](https://www.npmjs.com/package/bytes) library for parsing. Defaults
|
||||||
|
to `'100kb'`.
|
||||||
|
|
||||||
|
> It’s recommended not to configure a very high limit and to use the default value whenever possible. Allowing larger payloads increases memory usage because of the resources required for decoding and transformations, and it can also lead to longer response times as more data is processed. By ‘very high’, we mean values above the default, for example payloads of 5 MB or more can already start to introduce these risks. With the default limits, these issues do not occur.
|
||||||
|
|
||||||
|
##### parameterLimit
|
||||||
|
|
||||||
|
The `parameterLimit` option controls the maximum number of parameters that
|
||||||
|
are allowed in the URL-encoded data. If a request contains more parameters
|
||||||
|
than this value, a 413 will be returned to the client. Defaults to `1000`.
|
||||||
|
|
||||||
|
##### type
|
||||||
|
|
||||||
|
The `type` option is used to determine what media type the middleware will
|
||||||
|
parse. This option can be a string, array of strings, or a function. If not
|
||||||
|
a function, `type` option is passed directly to the
|
||||||
|
[type-is](https://www.npmjs.com/package/type-is#readme) library and this can
|
||||||
|
be an extension name (like `urlencoded`), a mime type (like
|
||||||
|
`application/x-www-form-urlencoded`), or a mime type with a wildcard (like
|
||||||
|
`*/x-www-form-urlencoded`). If a function, the `type` option is called as
|
||||||
|
`fn(req)` and the request is parsed if it returns a truthy value. Defaults
|
||||||
|
to `application/x-www-form-urlencoded`.
|
||||||
|
|
||||||
|
##### verify
|
||||||
|
|
||||||
|
The `verify` option, if supplied, is called as `verify(req, res, buf, encoding)`,
|
||||||
|
where `buf` is a `Buffer` of the raw request body and `encoding` is the
|
||||||
|
encoding of the request. The parsing can be aborted by throwing an error.
|
||||||
|
|
||||||
|
##### defaultCharset
|
||||||
|
|
||||||
|
The default charset to parse as, if not specified in content-type. Must be
|
||||||
|
either `utf-8` or `iso-8859-1`. Defaults to `utf-8`.
|
||||||
|
|
||||||
|
##### charsetSentinel
|
||||||
|
|
||||||
|
Whether to let the value of the `utf8` parameter take precedence as the charset
|
||||||
|
selector. It requires the form to contain a parameter named `utf8` with a value
|
||||||
|
of `✓`. Defaults to `false`.
|
||||||
|
|
||||||
|
##### interpretNumericEntities
|
||||||
|
|
||||||
|
Whether to decode numeric entities such as `☺` when parsing an iso-8859-1
|
||||||
|
form. Defaults to `false`.
|
||||||
|
|
||||||
|
|
||||||
|
##### depth
|
||||||
|
|
||||||
|
The `depth` option is used to configure the maximum depth of the `qs` library when `extended` is `true`. This allows you to limit the amount of keys that are parsed and can be useful to prevent certain types of abuse. Defaults to `32`. It is recommended to keep this value as low as possible.
|
||||||
|
|
||||||
|
## Errors
|
||||||
|
|
||||||
|
The middlewares provided by this module create errors using the
|
||||||
|
[`http-errors` module](https://www.npmjs.com/package/http-errors). The errors
|
||||||
|
will typically have a `status`/`statusCode` property that contains the suggested
|
||||||
|
HTTP response code, an `expose` property to determine if the `message` property
|
||||||
|
should be displayed to the client, a `type` property to determine the type of
|
||||||
|
error without matching against the `message`, and a `body` property containing
|
||||||
|
the read body, if available.
|
||||||
|
|
||||||
|
The following are the common errors created, though any error can come through
|
||||||
|
for various reasons.
|
||||||
|
|
||||||
|
### content encoding unsupported
|
||||||
|
|
||||||
|
This error will occur when the request had a `Content-Encoding` header that
|
||||||
|
contained an encoding but the "inflation" option was set to `false`. The
|
||||||
|
`status` property is set to `415`, the `type` property is set to
|
||||||
|
`'encoding.unsupported'`, and the `charset` property will be set to the
|
||||||
|
encoding that is unsupported.
|
||||||
|
|
||||||
|
### entity parse failed
|
||||||
|
|
||||||
|
This error will occur when the request contained an entity that could not be
|
||||||
|
parsed by the middleware. The `status` property is set to `400`, the `type`
|
||||||
|
property is set to `'entity.parse.failed'`, and the `body` property is set to
|
||||||
|
the entity value that failed parsing.
|
||||||
|
|
||||||
|
### entity verify failed
|
||||||
|
|
||||||
|
This error will occur when the request contained an entity that could not be
|
||||||
|
failed verification by the defined `verify` option. The `status` property is
|
||||||
|
set to `403`, the `type` property is set to `'entity.verify.failed'`, and the
|
||||||
|
`body` property is set to the entity value that failed verification.
|
||||||
|
|
||||||
|
### request aborted
|
||||||
|
|
||||||
|
This error will occur when the request is aborted by the client before reading
|
||||||
|
the body has finished. The `received` property will be set to the number of
|
||||||
|
bytes received before the request was aborted and the `expected` property is
|
||||||
|
set to the number of expected bytes. The `status` property is set to `400`
|
||||||
|
and `type` property is set to `'request.aborted'`.
|
||||||
|
|
||||||
|
### request entity too large
|
||||||
|
|
||||||
|
This error will occur when the request body's size is larger than the "limit"
|
||||||
|
option. The `limit` property will be set to the byte limit and the `length`
|
||||||
|
property will be set to the request body's length. The `status` property is
|
||||||
|
set to `413` and the `type` property is set to `'entity.too.large'`.
|
||||||
|
|
||||||
|
### request size did not match content length
|
||||||
|
|
||||||
|
This error will occur when the request's length did not match the length from
|
||||||
|
the `Content-Length` header. This typically occurs when the request is malformed,
|
||||||
|
typically when the `Content-Length` header was calculated based on characters
|
||||||
|
instead of bytes. The `status` property is set to `400` and the `type` property
|
||||||
|
is set to `'request.size.invalid'`.
|
||||||
|
|
||||||
|
### stream encoding should not be set
|
||||||
|
|
||||||
|
This error will occur when something called the `req.setEncoding` method prior
|
||||||
|
to this middleware. This module operates directly on bytes only and you cannot
|
||||||
|
call `req.setEncoding` when using this module. The `status` property is set to
|
||||||
|
`500` and the `type` property is set to `'stream.encoding.set'`.
|
||||||
|
|
||||||
|
### stream is not readable
|
||||||
|
|
||||||
|
This error will occur when the request is no longer readable when this middleware
|
||||||
|
attempts to read it. This typically means something other than a middleware from
|
||||||
|
this module read the request body already and the middleware was also configured to
|
||||||
|
read the same request. The `status` property is set to `500` and the `type`
|
||||||
|
property is set to `'stream.not.readable'`.
|
||||||
|
|
||||||
|
### too many parameters
|
||||||
|
|
||||||
|
This error will occur when the content of the request exceeds the configured
|
||||||
|
`parameterLimit` for the `urlencoded` parser. The `status` property is set to
|
||||||
|
`413` and the `type` property is set to `'parameters.too.many'`.
|
||||||
|
|
||||||
|
### unsupported charset "BOGUS"
|
||||||
|
|
||||||
|
This error will occur when the request had a charset parameter in the
|
||||||
|
`Content-Type` header, but the `iconv-lite` module does not support it OR the
|
||||||
|
parser does not support it. The charset is contained in the message as well
|
||||||
|
as in the `charset` property. The `status` property is set to `415`, the
|
||||||
|
`type` property is set to `'charset.unsupported'`, and the `charset` property
|
||||||
|
is set to the charset that is unsupported.
|
||||||
|
|
||||||
|
### unsupported content encoding "bogus"
|
||||||
|
|
||||||
|
This error will occur when the request had a `Content-Encoding` header that
|
||||||
|
contained an unsupported encoding. The encoding is contained in the message
|
||||||
|
as well as in the `encoding` property. The `status` property is set to `415`,
|
||||||
|
the `type` property is set to `'encoding.unsupported'`, and the `encoding`
|
||||||
|
property is set to the encoding that is unsupported.
|
||||||
|
|
||||||
|
### The input exceeded the depth
|
||||||
|
|
||||||
|
This error occurs when using `bodyParser.urlencoded` with the `extended` property set to `true` and the input exceeds the configured `depth` option. The `status` property is set to `400`. It is recommended to review the `depth` option and evaluate if it requires a higher value. When the `depth` option is set to `32` (default value), the error will not be thrown.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
### Express/Connect top-level generic
|
||||||
|
|
||||||
|
This example demonstrates adding a generic JSON and URL-encoded parser as a
|
||||||
|
top-level middleware, which will parse the bodies of all incoming requests.
|
||||||
|
This is the simplest setup.
|
||||||
|
|
||||||
|
```js
|
||||||
|
const express = require('express')
|
||||||
|
const bodyParser = require('body-parser')
|
||||||
|
|
||||||
|
const app = express()
|
||||||
|
|
||||||
|
// parse application/x-www-form-urlencoded
|
||||||
|
app.use(bodyParser.urlencoded())
|
||||||
|
|
||||||
|
// parse application/json
|
||||||
|
app.use(bodyParser.json())
|
||||||
|
|
||||||
|
app.use(function (req, res) {
|
||||||
|
res.setHeader('Content-Type', 'text/plain')
|
||||||
|
res.write('you posted:\n')
|
||||||
|
res.end(String(JSON.stringify(req.body, null, 2)))
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
|
### Express route-specific
|
||||||
|
|
||||||
|
This example demonstrates adding body parsers specifically to the routes that
|
||||||
|
need them. In general, this is the most recommended way to use body-parser with
|
||||||
|
Express.
|
||||||
|
|
||||||
|
```js
|
||||||
|
const express = require('express')
|
||||||
|
const bodyParser = require('body-parser')
|
||||||
|
|
||||||
|
const app = express()
|
||||||
|
|
||||||
|
// create application/json parser
|
||||||
|
const jsonParser = bodyParser.json()
|
||||||
|
|
||||||
|
// create application/x-www-form-urlencoded parser
|
||||||
|
const urlencodedParser = bodyParser.urlencoded()
|
||||||
|
|
||||||
|
// POST /login gets urlencoded bodies
|
||||||
|
app.post('/login', urlencodedParser, function (req, res) {
|
||||||
|
if (!req.body || !req.body.username) res.sendStatus(400)
|
||||||
|
res.send('welcome, ' + req.body.username)
|
||||||
|
})
|
||||||
|
|
||||||
|
// POST /api/users gets JSON bodies
|
||||||
|
app.post('/api/users', jsonParser, function (req, res) {
|
||||||
|
if (!req.body) res.sendStatus(400)
|
||||||
|
// create user in req.body
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
|
### Change accepted type for parsers
|
||||||
|
|
||||||
|
All the parsers accept a `type` option which allows you to change the
|
||||||
|
`Content-Type` that the middleware will parse.
|
||||||
|
|
||||||
|
```js
|
||||||
|
const express = require('express')
|
||||||
|
const bodyParser = require('body-parser')
|
||||||
|
|
||||||
|
const app = express()
|
||||||
|
|
||||||
|
// parse various different custom JSON types as JSON
|
||||||
|
app.use(bodyParser.json({ type: 'application/*+json' }))
|
||||||
|
|
||||||
|
// parse some custom thing into a Buffer
|
||||||
|
app.use(bodyParser.raw({ type: 'application/vnd.custom-type' }))
|
||||||
|
|
||||||
|
// parse an HTML body into a string
|
||||||
|
app.use(bodyParser.text({ type: 'text/html' }))
|
||||||
|
```
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
[MIT](LICENSE)
|
||||||
|
|
||||||
|
[ci-image]: https://img.shields.io/github/actions/workflow/status/expressjs/body-parser/ci.yml?branch=master&label=ci
|
||||||
|
[ci-url]: https://github.com/expressjs/body-parser/actions/workflows/ci.yml
|
||||||
|
[coveralls-image]: https://img.shields.io/coverallsCoverage/github/expressjs/body-parser?branch=master
|
||||||
|
[coveralls-url]: https://coveralls.io/r/expressjs/body-parser?branch=master
|
||||||
|
[npm-downloads-image]: https://img.shields.io/npm/dm/body-parser
|
||||||
|
[npm-url]: https://npmjs.com/package/body-parser
|
||||||
|
[npm-version-image]: https://img.shields.io/npm/v/body-parser
|
||||||
|
[ossf-scorecard-badge]: https://api.scorecard.dev/projects/github.com/expressjs/body-parser/badge
|
||||||
|
[ossf-scorecard-visualizer]: https://ossf.github.io/scorecard-visualizer/#/projects/github.com/expressjs/body-parser
|
||||||
+55
@@ -0,0 +1,55 @@
|
|||||||
|
/*!
|
||||||
|
* body-parser
|
||||||
|
* Copyright(c) 2014-2015 Douglas Christopher Wilson
|
||||||
|
* MIT Licensed
|
||||||
|
*/
|
||||||
|
|
||||||
|
'use strict'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {Object} Parsers
|
||||||
|
* @property {Function} json JSON parser
|
||||||
|
* @property {Function} raw Raw parser
|
||||||
|
* @property {Function} text Text parser
|
||||||
|
* @property {Function} urlencoded URL-encoded parser
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Module exports.
|
||||||
|
* @type {Function & Parsers}
|
||||||
|
*/
|
||||||
|
exports = module.exports = bodyParser
|
||||||
|
|
||||||
|
/**
|
||||||
|
* JSON parser.
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
|
exports.json = require('./lib/types/json')
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Raw parser.
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
|
exports.raw = require('./lib/types/raw')
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Text parser.
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
|
exports.text = require('./lib/types/text')
|
||||||
|
|
||||||
|
/**
|
||||||
|
* URL-encoded parser.
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
|
exports.urlencoded = require('./lib/types/urlencoded')
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a middleware to parse json and urlencoded bodies.
|
||||||
|
*
|
||||||
|
* @deprecated
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
|
function bodyParser () {
|
||||||
|
throw new Error('The bodyParser() generic has been split into individual middleware to use instead.')
|
||||||
|
}
|
||||||
+247
@@ -0,0 +1,247 @@
|
|||||||
|
/*!
|
||||||
|
* body-parser
|
||||||
|
* Copyright(c) 2014-2015 Douglas Christopher Wilson
|
||||||
|
* MIT Licensed
|
||||||
|
*/
|
||||||
|
|
||||||
|
'use strict'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Module dependencies.
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
|
||||||
|
const createError = require('http-errors')
|
||||||
|
const getBody = require('raw-body')
|
||||||
|
const iconv = require('iconv-lite')
|
||||||
|
const onFinished = require('on-finished')
|
||||||
|
const zlib = require('node:zlib')
|
||||||
|
const hasBody = require('type-is').hasBody
|
||||||
|
const { getCharset } = require('./utils')
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Module exports.
|
||||||
|
*/
|
||||||
|
|
||||||
|
module.exports = read
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Read a request into a buffer and parse.
|
||||||
|
*
|
||||||
|
* @param {Object} req
|
||||||
|
* @param {Object} res
|
||||||
|
* @param {Function} next
|
||||||
|
* @param {Function} parse
|
||||||
|
* @param {Function} debug
|
||||||
|
* @param {Object} options
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
function read (req, res, next, parse, debug, options) {
|
||||||
|
if (onFinished.isFinished(req)) {
|
||||||
|
debug('body already parsed')
|
||||||
|
next()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!('body' in req)) {
|
||||||
|
req.body = undefined
|
||||||
|
}
|
||||||
|
|
||||||
|
// skip requests without bodies
|
||||||
|
if (!hasBody(req)) {
|
||||||
|
debug('skip empty body')
|
||||||
|
next()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
debug('content-type %j', req.headers['content-type'])
|
||||||
|
|
||||||
|
// determine if request should be parsed
|
||||||
|
if (!options.shouldParse(req)) {
|
||||||
|
debug('skip parsing')
|
||||||
|
next()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
let encoding = null
|
||||||
|
if (options?.skipCharset !== true) {
|
||||||
|
encoding = getCharset(req) || options.defaultCharset
|
||||||
|
|
||||||
|
// validate charset
|
||||||
|
if (!!options?.isValidCharset && !options.isValidCharset(encoding)) {
|
||||||
|
debug('invalid charset')
|
||||||
|
next(createError(415, 'unsupported charset "' + encoding.toUpperCase() + '"', {
|
||||||
|
charset: encoding,
|
||||||
|
type: 'charset.unsupported'
|
||||||
|
}))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let length
|
||||||
|
const opts = options
|
||||||
|
let stream
|
||||||
|
|
||||||
|
// read options
|
||||||
|
const verify = opts.verify
|
||||||
|
|
||||||
|
try {
|
||||||
|
// get the content stream
|
||||||
|
stream = contentstream(req, debug, opts.inflate)
|
||||||
|
length = stream.length
|
||||||
|
stream.length = undefined
|
||||||
|
} catch (err) {
|
||||||
|
return next(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// set raw-body options
|
||||||
|
opts.length = length
|
||||||
|
opts.encoding = verify
|
||||||
|
? null
|
||||||
|
: encoding
|
||||||
|
|
||||||
|
// assert charset is supported
|
||||||
|
if (opts.encoding === null && encoding !== null && !iconv.encodingExists(encoding)) {
|
||||||
|
return next(createError(415, 'unsupported charset "' + encoding.toUpperCase() + '"', {
|
||||||
|
charset: encoding.toLowerCase(),
|
||||||
|
type: 'charset.unsupported'
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
|
||||||
|
// read body
|
||||||
|
debug('read body')
|
||||||
|
getBody(stream, opts, function (error, body) {
|
||||||
|
if (error) {
|
||||||
|
let _error
|
||||||
|
|
||||||
|
if (error.type === 'encoding.unsupported') {
|
||||||
|
// echo back charset
|
||||||
|
_error = createError(415, 'unsupported charset "' + encoding.toUpperCase() + '"', {
|
||||||
|
charset: encoding.toLowerCase(),
|
||||||
|
type: 'charset.unsupported'
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
// set status code on error
|
||||||
|
_error = createError(400, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
// unpipe from stream and destroy
|
||||||
|
if (stream !== req) {
|
||||||
|
req.unpipe()
|
||||||
|
stream.destroy()
|
||||||
|
}
|
||||||
|
|
||||||
|
// read off entire request
|
||||||
|
dump(req, function onfinished () {
|
||||||
|
next(createError(400, _error))
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// verify
|
||||||
|
if (verify) {
|
||||||
|
try {
|
||||||
|
debug('verify body')
|
||||||
|
verify(req, res, body, encoding)
|
||||||
|
} catch (err) {
|
||||||
|
next(createError(403, err, {
|
||||||
|
body: body,
|
||||||
|
type: err.type || 'entity.verify.failed'
|
||||||
|
}))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// parse
|
||||||
|
let str = body
|
||||||
|
try {
|
||||||
|
debug('parse body')
|
||||||
|
str = typeof body !== 'string' && encoding !== null
|
||||||
|
? iconv.decode(body, encoding)
|
||||||
|
: body
|
||||||
|
req.body = parse(str, encoding)
|
||||||
|
} catch (err) {
|
||||||
|
next(createError(400, err, {
|
||||||
|
body: str,
|
||||||
|
type: err.type || 'entity.parse.failed'
|
||||||
|
}))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
next()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the content stream of the request.
|
||||||
|
*
|
||||||
|
* @param {Object} req
|
||||||
|
* @param {Function} debug
|
||||||
|
* @param {boolean} inflate
|
||||||
|
* @returns {Object}
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
function contentstream (req, debug, inflate) {
|
||||||
|
const encoding = (req.headers['content-encoding'] || 'identity').toLowerCase()
|
||||||
|
const length = req.headers['content-length']
|
||||||
|
|
||||||
|
debug('content-encoding "%s"', encoding)
|
||||||
|
|
||||||
|
if (inflate === false && encoding !== 'identity') {
|
||||||
|
throw createError(415, 'content encoding unsupported', {
|
||||||
|
encoding: encoding,
|
||||||
|
type: 'encoding.unsupported'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
if (encoding === 'identity') {
|
||||||
|
req.length = length
|
||||||
|
return req
|
||||||
|
}
|
||||||
|
|
||||||
|
const stream = createDecompressionStream(encoding, debug)
|
||||||
|
req.pipe(stream)
|
||||||
|
return stream
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a decompression stream for the given encoding.
|
||||||
|
* @param {string} encoding
|
||||||
|
* @param {Function} debug
|
||||||
|
* @returns {Object}
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
function createDecompressionStream (encoding, debug) {
|
||||||
|
switch (encoding) {
|
||||||
|
case 'deflate':
|
||||||
|
debug('inflate body')
|
||||||
|
return zlib.createInflate()
|
||||||
|
case 'gzip':
|
||||||
|
debug('gunzip body')
|
||||||
|
return zlib.createGunzip()
|
||||||
|
case 'br':
|
||||||
|
debug('brotli decompress body')
|
||||||
|
return zlib.createBrotliDecompress()
|
||||||
|
default:
|
||||||
|
throw createError(415, 'unsupported content encoding "' + encoding + '"', {
|
||||||
|
encoding: encoding,
|
||||||
|
type: 'encoding.unsupported'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dump the contents of a request.
|
||||||
|
*
|
||||||
|
* @param {Object} req
|
||||||
|
* @param {Function} callback
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
function dump (req, callback) {
|
||||||
|
if (onFinished.isFinished(req)) {
|
||||||
|
callback(null)
|
||||||
|
} else {
|
||||||
|
onFinished(req, callback)
|
||||||
|
req.resume()
|
||||||
|
}
|
||||||
|
}
|
||||||
+186
@@ -0,0 +1,186 @@
|
|||||||
|
/*!
|
||||||
|
* body-parser
|
||||||
|
* Copyright(c) 2014 Jonathan Ong
|
||||||
|
* Copyright(c) 2014-2015 Douglas Christopher Wilson
|
||||||
|
* MIT Licensed
|
||||||
|
*/
|
||||||
|
|
||||||
|
'use strict'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Module dependencies.
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
|
||||||
|
const debug = require('debug')('body-parser:json')
|
||||||
|
const read = require('../read')
|
||||||
|
const { normalizeOptions } = require('../utils')
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Module exports.
|
||||||
|
*/
|
||||||
|
|
||||||
|
module.exports = json
|
||||||
|
|
||||||
|
/**
|
||||||
|
* RegExp to match the first non-space in a string.
|
||||||
|
*
|
||||||
|
* Allowed whitespace is defined in RFC 7159:
|
||||||
|
*
|
||||||
|
* ws = *(
|
||||||
|
* %x20 / ; Space
|
||||||
|
* %x09 / ; Horizontal tab
|
||||||
|
* %x0A / ; Line feed or New line
|
||||||
|
* %x0D ) ; Carriage return
|
||||||
|
*/
|
||||||
|
const FIRST_CHAR_REGEXP = /^[\x20\x09\x0a\x0d]*([^\x20\x09\x0a\x0d])/ // eslint-disable-line no-control-regex
|
||||||
|
|
||||||
|
const JSON_SYNTAX_CHAR = '#'
|
||||||
|
const JSON_SYNTAX_REGEXP = /#+/g
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a middleware to parse JSON bodies.
|
||||||
|
*
|
||||||
|
* @param {Object} [options]
|
||||||
|
* @returns {Function}
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
|
function json (options) {
|
||||||
|
const normalizedOptions = normalizeOptions(options, 'application/json')
|
||||||
|
|
||||||
|
const parse = createJsonParser(options)
|
||||||
|
|
||||||
|
const readOptions = {
|
||||||
|
...normalizedOptions,
|
||||||
|
// assert charset per RFC 7159 sec 8.1
|
||||||
|
isValidCharset: (charset) => charset.slice(0, 4) === 'utf-'
|
||||||
|
}
|
||||||
|
|
||||||
|
return function jsonParser (req, res, next) {
|
||||||
|
read(req, res, next, parse, debug, readOptions)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a JSON parse function
|
||||||
|
*
|
||||||
|
* @param {object} [options]
|
||||||
|
* @return {function}
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
function createJsonParser (options) {
|
||||||
|
const reviver = options?.reviver
|
||||||
|
const strict = options?.strict !== false
|
||||||
|
|
||||||
|
if (strict) {
|
||||||
|
return function parse (body) {
|
||||||
|
if (body.length === 0) {
|
||||||
|
// special-case empty json body, as it's a common client-side mistake
|
||||||
|
// TODO: maybe make this configurable or part of "strict" option
|
||||||
|
return {}
|
||||||
|
}
|
||||||
|
|
||||||
|
const first = firstchar(body)
|
||||||
|
if (first !== '{' && first !== '[') {
|
||||||
|
debug('strict violation')
|
||||||
|
throw createStrictSyntaxError(body, first)
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
debug('parse json')
|
||||||
|
return JSON.parse(body, reviver)
|
||||||
|
} catch (e) {
|
||||||
|
throw normalizeJsonSyntaxError(e, {
|
||||||
|
message: e.message,
|
||||||
|
stack: e.stack
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return function parse (body) {
|
||||||
|
if (body.length === 0) {
|
||||||
|
// special-case empty json body, as it's a common client-side mistake
|
||||||
|
// TODO: maybe make this configurable or part of "strict" option
|
||||||
|
return {}
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
debug('parse json')
|
||||||
|
return JSON.parse(body, reviver)
|
||||||
|
} catch (e) {
|
||||||
|
throw normalizeJsonSyntaxError(e, {
|
||||||
|
message: e.message,
|
||||||
|
stack: e.stack
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create strict violation syntax error matching native error.
|
||||||
|
*
|
||||||
|
* @param {string} str
|
||||||
|
* @param {string} char
|
||||||
|
* @returns {Error}
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
function createStrictSyntaxError (str, char) {
|
||||||
|
const index = str.indexOf(char)
|
||||||
|
let partial = ''
|
||||||
|
|
||||||
|
if (index !== -1) {
|
||||||
|
partial = str.substring(0, index) + JSON_SYNTAX_CHAR.repeat(str.length - index)
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
JSON.parse(partial); /* istanbul ignore next */ throw new SyntaxError('strict violation')
|
||||||
|
} catch (e) {
|
||||||
|
return normalizeJsonSyntaxError(e, {
|
||||||
|
message: e.message.replace(JSON_SYNTAX_REGEXP, function (placeholder) {
|
||||||
|
return str.substring(index, index + placeholder.length)
|
||||||
|
}),
|
||||||
|
stack: e.stack
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the first non-whitespace character in a string.
|
||||||
|
*
|
||||||
|
* @param {string} str
|
||||||
|
* @returns {string|undefined}
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
function firstchar (str) {
|
||||||
|
const match = FIRST_CHAR_REGEXP.exec(str)
|
||||||
|
|
||||||
|
return match
|
||||||
|
? match[1]
|
||||||
|
: undefined
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Normalize a SyntaxError for JSON.parse.
|
||||||
|
*
|
||||||
|
* @param {SyntaxError} error
|
||||||
|
* @param {Object} obj
|
||||||
|
* @returns {SyntaxError}
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
function normalizeJsonSyntaxError (error, obj) {
|
||||||
|
const keys = Object.getOwnPropertyNames(error)
|
||||||
|
|
||||||
|
for (let i = 0; i < keys.length; i++) {
|
||||||
|
const key = keys[i]
|
||||||
|
if (key !== 'stack' && key !== 'message') {
|
||||||
|
delete error[key]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// replace stack before message for Node.js 0.10 and below
|
||||||
|
error.stack = obj.stack.replace(error.message, obj.message)
|
||||||
|
error.message = obj.message
|
||||||
|
|
||||||
|
return error
|
||||||
|
}
|
||||||
+42
@@ -0,0 +1,42 @@
|
|||||||
|
/*!
|
||||||
|
* body-parser
|
||||||
|
* Copyright(c) 2014-2015 Douglas Christopher Wilson
|
||||||
|
* MIT Licensed
|
||||||
|
*/
|
||||||
|
|
||||||
|
'use strict'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Module dependencies.
|
||||||
|
*/
|
||||||
|
|
||||||
|
const debug = require('debug')('body-parser:raw')
|
||||||
|
const read = require('../read')
|
||||||
|
const { normalizeOptions, passthrough } = require('../utils')
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Module exports.
|
||||||
|
*/
|
||||||
|
|
||||||
|
module.exports = raw
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a middleware to parse raw bodies.
|
||||||
|
*
|
||||||
|
* @param {Object} [options]
|
||||||
|
* @returns {Function}
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
|
function raw (options) {
|
||||||
|
const normalizedOptions = normalizeOptions(options, 'application/octet-stream')
|
||||||
|
|
||||||
|
const readOptions = {
|
||||||
|
...normalizedOptions,
|
||||||
|
// Skip charset validation and parse the body as is
|
||||||
|
skipCharset: true
|
||||||
|
}
|
||||||
|
|
||||||
|
return function rawParser (req, res, next) {
|
||||||
|
read(req, res, next, passthrough, debug, readOptions)
|
||||||
|
}
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user