@arcjet/analyze-wasm 1.0.0-beta.1 → 1.0.0-beta.11

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.
package/index.ts DELETED
@@ -1,60 +0,0 @@
1
- import { instantiate } from "./wasm/arcjet_analyze_js_req.component.js";
2
- import type {
3
- ImportObject,
4
- BotConfig,
5
- DetectedSensitiveInfoEntity,
6
- SensitiveInfoEntity,
7
- EmailValidationResult,
8
- BotResult,
9
- SensitiveInfoResult,
10
- EmailValidationConfig,
11
- SensitiveInfoEntities,
12
- } from "./wasm/arcjet_analyze_js_req.component.js";
13
- import type { ArcjetJsReqSensitiveInformationIdentifier } from "./wasm/interfaces/arcjet-js-req-sensitive-information-identifier.js";
14
-
15
- import { wasm as componentCoreWasm } from "./wasm/arcjet_analyze_js_req.component.core.wasm?js";
16
- import { wasm as componentCore2Wasm } from "./wasm/arcjet_analyze_js_req.component.core2.wasm?js";
17
- import { wasm as componentCore3Wasm } from "./wasm/arcjet_analyze_js_req.component.core3.wasm?js";
18
-
19
- type DetectSensitiveInfoFunction =
20
- typeof ArcjetJsReqSensitiveInformationIdentifier.detect;
21
-
22
- const componentCoreWasmPromise = componentCoreWasm();
23
- const componentCore2WasmPromise = componentCore2Wasm();
24
- const componentCore3WasmPromise = componentCore3Wasm();
25
-
26
- async function moduleFromPath(path: string): Promise<WebAssembly.Module> {
27
- if (path === "arcjet_analyze_js_req.component.core.wasm") {
28
- return componentCoreWasmPromise;
29
- }
30
- if (path === "arcjet_analyze_js_req.component.core2.wasm") {
31
- return componentCore2WasmPromise;
32
- }
33
- if (path === "arcjet_analyze_js_req.component.core3.wasm") {
34
- return componentCore3WasmPromise;
35
- }
36
-
37
- throw new Error(`Unknown path: ${path}`);
38
- }
39
-
40
- export async function initializeWasm(coreImports: ImportObject) {
41
- try {
42
- // Await the instantiation to catch the failure
43
- return instantiate(moduleFromPath, coreImports);
44
- } catch {
45
- return undefined;
46
- }
47
- }
48
-
49
- export {
50
- type BotConfig,
51
- type DetectedSensitiveInfoEntity,
52
- type SensitiveInfoEntity,
53
- type EmailValidationConfig,
54
- type EmailValidationResult,
55
- type BotResult,
56
- type SensitiveInfoResult,
57
- type SensitiveInfoEntities,
58
- type DetectSensitiveInfoFunction,
59
- type ImportObject,
60
- };
package/wasm.d.ts DELETED
@@ -1,28 +0,0 @@
1
- /**
2
- * Vercel uses the `.wasm?module` suffix to make WebAssembly available in their
3
- * Vercel Functions product.
4
- *
5
- * https://vercel.com/docs/functions/wasm#using-a-webassembly-file
6
- */
7
- declare module "*.wasm?module" {
8
- export default WebAssembly.Module;
9
- }
10
-
11
- /**
12
- * The Cloudflare docs say they support the `.wasm?module` suffix, but that
13
- * seems to no longer be the case with Wrangler 2 so we need to have separate
14
- * imports for just the `.wasm` files.
15
- *
16
- * https://developers.cloudflare.com/workers/runtime-apis/webassembly/javascript/#bundling
17
- */
18
- declare module "*.wasm" {
19
- export default WebAssembly.Module;
20
- }
21
-
22
- /**
23
- * Our Rollup build turns `.wasm?js` imports into JS imports that provide the
24
- * `wasm()` function which decodes a base64 Data URL into a WebAssembly Module
25
- */
26
- declare module "*.wasm?js" {
27
- export function wasm(): Promise<WebAssembly.Module>;
28
- }
package/workerd.ts DELETED
@@ -1,56 +0,0 @@
1
- import { instantiate } from "./wasm/arcjet_analyze_js_req.component.js";
2
- import type {
3
- ImportObject,
4
- BotConfig,
5
- DetectedSensitiveInfoEntity,
6
- SensitiveInfoEntity,
7
- EmailValidationResult,
8
- BotResult,
9
- SensitiveInfoResult,
10
- EmailValidationConfig,
11
- SensitiveInfoEntities,
12
- } from "./wasm/arcjet_analyze_js_req.component.js";
13
- import type { ArcjetJsReqSensitiveInformationIdentifier } from "./wasm/interfaces/arcjet-js-req-sensitive-information-identifier.js";
14
-
15
- import componentCoreWasm from "./wasm/arcjet_analyze_js_req.component.core.wasm";
16
- import componentCore2Wasm from "./wasm/arcjet_analyze_js_req.component.core2.wasm";
17
- import componentCore3Wasm from "./wasm/arcjet_analyze_js_req.component.core3.wasm";
18
-
19
- type DetectSensitiveInfoFunction =
20
- typeof ArcjetJsReqSensitiveInformationIdentifier.detect;
21
-
22
- async function moduleFromPath(path: string): Promise<WebAssembly.Module> {
23
- if (path === "arcjet_analyze_js_req.component.core.wasm") {
24
- return componentCoreWasm;
25
- }
26
- if (path === "arcjet_analyze_js_req.component.core2.wasm") {
27
- return componentCore2Wasm;
28
- }
29
- if (path === "arcjet_analyze_js_req.component.core3.wasm") {
30
- return componentCore3Wasm;
31
- }
32
-
33
- throw new Error(`Unknown path: ${path}`);
34
- }
35
-
36
- export async function initializeWasm(coreImports: ImportObject) {
37
- try {
38
- // Await the instantiation to catch the failure
39
- return instantiate(moduleFromPath, coreImports);
40
- } catch {
41
- return undefined;
42
- }
43
- }
44
-
45
- export {
46
- type BotConfig,
47
- type DetectedSensitiveInfoEntity,
48
- type SensitiveInfoEntity,
49
- type EmailValidationConfig,
50
- type EmailValidationResult,
51
- type BotResult,
52
- type SensitiveInfoResult,
53
- type SensitiveInfoEntities,
54
- type DetectSensitiveInfoFunction,
55
- type ImportObject,
56
- };