@stll/anonymize-wasm 2.4.2 → 2.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,132 +0,0 @@
1
- /* eslint-disable */
2
- /* prettier-ignore */
3
-
4
- /* auto-generated by NAPI-RS */
5
-
6
- const __nodeFs = require('node:fs')
7
- const __nodePath = require('node:path')
8
- const { WASI: __nodeWASI } = require('@napi-rs/wasm-runtime')
9
- const { Worker } = require('node:worker_threads')
10
-
11
- const {
12
- createOnMessage: __wasmCreateOnMessageForFsProxy,
13
- getDefaultContext: __emnapiGetDefaultContext,
14
- instantiateNapiModuleSync: __emnapiInstantiateNapiModuleSync,
15
- } = require('@napi-rs/wasm-runtime')
16
-
17
- const __rootDir = __nodePath.parse(process.cwd()).root
18
-
19
- const __wasi = new __nodeWASI({
20
- version: 'preview1',
21
- fs: __nodeFs,
22
- env: process.env,
23
- preopens: {
24
- [__rootDir]: __rootDir,
25
- }
26
- })
27
-
28
- const __emnapiContext = __emnapiGetDefaultContext()
29
-
30
- const __sharedMemory = new WebAssembly.Memory({
31
- initial: 4000,
32
- maximum: 65536,
33
- shared: true,
34
- })
35
-
36
- let __wasmFilePath = __nodePath.join(__dirname, 'index.wasm32-wasi.wasm')
37
- const __wasmDebugFilePath = __nodePath.join(__dirname, 'index.wasm32-wasi.debug.wasm')
38
-
39
- if (__nodeFs.existsSync(__wasmDebugFilePath)) {
40
- __wasmFilePath = __wasmDebugFilePath
41
- } else if (!__nodeFs.existsSync(__wasmFilePath)) {
42
- try {
43
- __wasmFilePath = require.resolve('@stll/anonymize-wasm-wasm32-wasi/index.wasm32-wasi.wasm')
44
- } catch {
45
- throw new Error('Cannot find index.wasm32-wasi.wasm file, and @stll/anonymize-wasm-wasm32-wasi package is not installed.')
46
- }
47
- }
48
-
49
- const { instance: __napiInstance, module: __wasiModule, napiModule: __napiModule } = __emnapiInstantiateNapiModuleSync(__nodeFs.readFileSync(__wasmFilePath), {
50
- context: __emnapiContext,
51
- asyncWorkPoolSize: (function() {
52
- const threadsSizeFromEnv = Number(process.env.NAPI_RS_ASYNC_WORK_POOL_SIZE ?? process.env.UV_THREADPOOL_SIZE)
53
- // NaN > 0 is false
54
- if (threadsSizeFromEnv > 0) {
55
- return threadsSizeFromEnv
56
- } else {
57
- return 4
58
- }
59
- })(),
60
- reuseWorker: true,
61
- wasi: __wasi,
62
- onCreateWorker() {
63
- const worker = new Worker(__nodePath.join(__dirname, 'wasi-worker.mjs'), {
64
- env: process.env,
65
- })
66
- worker.onmessage = ({ data }) => {
67
- __wasmCreateOnMessageForFsProxy(__nodeFs)(data)
68
- }
69
-
70
- // The main thread of Node.js waits for all the active handles before exiting.
71
- // But Rust threads are never waited without `thread::join`.
72
- // So here we hack the code of Node.js to prevent the workers from being referenced (active).
73
- // According to https://github.com/nodejs/node/blob/19e0d472728c79d418b74bddff588bea70a403d0/lib/internal/worker.js#L415,
74
- // a worker is consist of two handles: kPublicPort and kHandle.
75
- {
76
- const kPublicPort = Object.getOwnPropertySymbols(worker).find(s =>
77
- s.toString().includes("kPublicPort")
78
- );
79
- if (kPublicPort) {
80
- worker[kPublicPort].ref = () => {};
81
- }
82
-
83
- const kHandle = Object.getOwnPropertySymbols(worker).find(s =>
84
- s.toString().includes("kHandle")
85
- );
86
- if (kHandle) {
87
- worker[kHandle].ref = () => {};
88
- }
89
-
90
- worker.unref();
91
- }
92
- return worker
93
- },
94
- overwriteImports(importObject) {
95
- importObject.env = {
96
- ...importObject.env,
97
- ...importObject.napi,
98
- ...importObject.emnapi,
99
- memory: __sharedMemory,
100
- }
101
- return importObject
102
- },
103
- beforeInit({ instance }) {
104
- for (const name of Object.keys(instance.exports)) {
105
- if (name.startsWith('__napi_register__')) {
106
- instance.exports[name]()
107
- }
108
- }
109
- },
110
- })
111
- module.exports = __napiModule.exports
112
- module.exports.NativePreparedRedactionSession = __napiModule.exports.NativePreparedRedactionSession
113
- module.exports.NativePreparedSearch = __napiModule.exports.NativePreparedSearch
114
- module.exports.NativePreparedSessionRedactionPlan = __napiModule.exports.NativePreparedSessionRedactionPlan
115
- module.exports.assembleStaticSearchCompressedPackageBytes = __napiModule.exports.assembleStaticSearchCompressedPackageBytes
116
- module.exports.assembleStaticSearchConfigJson = __napiModule.exports.assembleStaticSearchConfigJson
117
- module.exports.assembleStaticSearchPackageBytes = __napiModule.exports.assembleStaticSearchPackageBytes
118
- module.exports.convertExternalDetectionBatch = __napiModule.exports.convertExternalDetectionBatch
119
- module.exports.externalDetectionLimitsJson = __napiModule.exports.externalDetectionLimitsJson
120
- module.exports.extractDocxTextJson = __napiModule.exports.extractDocxTextJson
121
- module.exports.inspectPdfJson = __napiModule.exports.inspectPdfJson
122
- module.exports.nativePackageVersion = __napiModule.exports.nativePackageVersion
123
- module.exports.normalizeForSearch = __napiModule.exports.normalizeForSearch
124
- module.exports.planDocxRestorationJson = __napiModule.exports.planDocxRestorationJson
125
- module.exports.prepareStaticSearchArtifactsBytes = __napiModule.exports.prepareStaticSearchArtifactsBytes
126
- module.exports.prepareStaticSearchCompressedPackageBytes = __napiModule.exports.prepareStaticSearchCompressedPackageBytes
127
- module.exports.prepareStaticSearchPackageBytes = __napiModule.exports.prepareStaticSearchPackageBytes
128
- module.exports.redactStaticEntitiesDiagnosticsJson = __napiModule.exports.redactStaticEntitiesDiagnosticsJson
129
- module.exports.redactStaticEntitiesJson = __napiModule.exports.redactStaticEntitiesJson
130
- module.exports.redactStaticEntitiesSummaryDiagnosticsJson = __napiModule.exports.redactStaticEntitiesSummaryDiagnosticsJson
131
- module.exports.rewriteDocxTextNative = __napiModule.exports.rewriteDocxTextNative
132
- module.exports.rewritePdfRasterFromDetectionsJson = __napiModule.exports.rewritePdfRasterFromDetectionsJson