-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
96f8279
commit 352e7ad
Showing
33 changed files
with
1,697 additions
and
585 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,3 +23,4 @@ output-exif.* | |
nasa-small.* | ||
output-overlay-png.png | ||
output-debian.jpeg | ||
*.wasm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ resolver = "2" | |
[profile.release] | ||
lto = 'fat' | ||
codegen-units = 1 | ||
strip = 'symbols' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from '@napi-rs/image-wasm32-wasi' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
import { | ||
instantiateNapiModuleSync as __emnapiInstantiateNapiModuleSync, | ||
getDefaultContext as __emnapiGetDefaultContext, | ||
WASI as __WASI, | ||
} from '@napi-rs/wasm-runtime' | ||
import { Volume as __Volume, createFsFromVolume as __createFsFromVolume } from '@napi-rs/wasm-runtime/fs' | ||
|
||
import __wasmUrl from './image.wasm32-wasi.wasm?url' | ||
|
||
const __fs = __createFsFromVolume( | ||
__Volume.fromJSON({ | ||
'/': null, | ||
}), | ||
) | ||
|
||
const __wasi = new __WASI({ | ||
version: 'preview1', | ||
fs: __fs, | ||
}) | ||
|
||
const __emnapiContext = __emnapiGetDefaultContext() | ||
|
||
const __sharedMemory = new WebAssembly.Memory({ | ||
initial: 1024, | ||
maximum: 10240, | ||
shared: true, | ||
}) | ||
|
||
const __wasmFile = await fetch(__wasmUrl).then((res) => res.arrayBuffer()) | ||
|
||
const { | ||
instance: __napiInstance, | ||
module: __wasiModule, | ||
napiModule: __napiModule, | ||
} = __emnapiInstantiateNapiModuleSync(__wasmFile, { | ||
context: __emnapiContext, | ||
asyncWorkPoolSize: 4, | ||
wasi: __wasi, | ||
onCreateWorker() { | ||
return new Worker(new URL('./wasi-worker-browser.mjs', import.meta.url), { | ||
type: 'module', | ||
}) | ||
}, | ||
overwriteImports(importObject) { | ||
importObject.env = { | ||
...importObject.env, | ||
...importObject.napi, | ||
...importObject.emnapi, | ||
memory: __sharedMemory, | ||
} | ||
return importObject | ||
}, | ||
beforeInit({ instance }) { | ||
__napi_rs_initialize_modules(instance) | ||
}, | ||
}) | ||
|
||
function __napi_rs_initialize_modules(__napiInstance) { | ||
__napiInstance.exports['__napi_register__AvifConfig_struct_0']?.() | ||
__napiInstance.exports['__napi_register__ChromaSubsampling_1']?.() | ||
__napiInstance.exports['__napi_register__FastResizeFilter_2']?.() | ||
__napiInstance.exports['__napi_register__ResizeFit_3']?.() | ||
__napiInstance.exports['__napi_register__FastResizeOptions_struct_4']?.() | ||
__napiInstance.exports['__napi_register__JpegCompressOptions_struct_5']?.() | ||
__napiInstance.exports['__napi_register__compress_jpeg_sync_6']?.() | ||
__napiInstance.exports['__napi_register__CompressJpegTask_impl_7']?.() | ||
__napiInstance.exports['__napi_register__compress_jpeg_8']?.() | ||
__napiInstance.exports['__napi_register__CompressionType_9']?.() | ||
__napiInstance.exports['__napi_register__FilterType_10']?.() | ||
__napiInstance.exports['__napi_register__PngEncodeOptions_struct_11']?.() | ||
__napiInstance.exports['__napi_register__PngRowFilter_12']?.() | ||
__napiInstance.exports['__napi_register__PNGLosslessOptions_struct_13']?.() | ||
__napiInstance.exports['__napi_register__lossless_compress_png_sync_14']?.() | ||
__napiInstance.exports['__napi_register__LosslessPngTask_impl_15']?.() | ||
__napiInstance.exports['__napi_register__lossless_compress_png_16']?.() | ||
__napiInstance.exports['__napi_register__PngQuantOptions_struct_17']?.() | ||
__napiInstance.exports['__napi_register__png_quantize_sync_18']?.() | ||
__napiInstance.exports['__napi_register__PngQuantTask_impl_19']?.() | ||
__napiInstance.exports['__napi_register__png_quantize_20']?.() | ||
__napiInstance.exports['__napi_register__Orientation_21']?.() | ||
__napiInstance.exports['__napi_register__ResizeFilterType_22']?.() | ||
__napiInstance.exports['__napi_register__JsColorType_23']?.() | ||
__napiInstance.exports['__napi_register__Metadata_struct_24']?.() | ||
__napiInstance.exports['__napi_register__MetadataTask_impl_25']?.() | ||
__napiInstance.exports['__napi_register__ResizeOptions_struct_26']?.() | ||
__napiInstance.exports['__napi_register__EncodeTask_impl_27']?.() | ||
__napiInstance.exports['__napi_register__Transformer_struct_28']?.() | ||
__napiInstance.exports['__napi_register__Transformer_impl_70']?.() | ||
} | ||
export const Transformer = __napiModule.exports.Transformer | ||
export const ChromaSubsampling = __napiModule.exports.ChromaSubsampling | ||
export const CompressionType = __napiModule.exports.CompressionType | ||
export const compressJpeg = __napiModule.exports.compressJpeg | ||
export const compressJpegSync = __napiModule.exports.compressJpegSync | ||
export const FastResizeFilter = __napiModule.exports.FastResizeFilter | ||
export const FilterType = __napiModule.exports.FilterType | ||
export const JsColorType = __napiModule.exports.JsColorType | ||
export const losslessCompressPng = __napiModule.exports.losslessCompressPng | ||
export const losslessCompressPngSync = __napiModule.exports.losslessCompressPngSync | ||
export const Orientation = __napiModule.exports.Orientation | ||
export const pngQuantize = __napiModule.exports.pngQuantize | ||
export const pngQuantizeSync = __napiModule.exports.pngQuantizeSync | ||
export const PngRowFilter = __napiModule.exports.PngRowFilter | ||
export const ResizeFilterType = __napiModule.exports.ResizeFilterType | ||
export const ResizeFit = __napiModule.exports.ResizeFit |
Oops, something went wrong.