@arcjet/analyze 1.0.0-alpha.2 → 1.0.0-alpha.4

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.js CHANGED
@@ -15,20 +15,20 @@ async function init() {
15
15
  return;
16
16
  }
17
17
  if (state === "uninitialized") {
18
- let wasmModule;
19
- // We use `NEXT_RUNTIME` env var to DCE the Node/Browser code in the `else` block
20
- // possible values: "edge" | "nodejs" | undefined
21
- if (process.env["NEXT_RUNTIME"] === "edge") {
22
- const mod = await import(
23
- // @ts-expect-error
24
- './wasm/arcjet_analyze_js_req_bg.wasm?module');
25
- wasmModule = mod.default;
26
- }
27
- else {
28
- const { wasm } = await import('./wasm/arcjet.wasm.js');
29
- wasmModule = await WebAssembly.compile(wasm);
30
- }
31
18
  try {
19
+ let wasmModule;
20
+ // We use `NEXT_RUNTIME` env var to DCE the Node/Browser code in the `else` block
21
+ // possible values: "edge" | "nodejs" | undefined
22
+ if (process.env["NEXT_RUNTIME"] === "edge") {
23
+ const mod = await import(
24
+ // @ts-expect-error
25
+ './wasm/arcjet_analyze_js_req_bg.wasm?module');
26
+ wasmModule = mod.default;
27
+ }
28
+ else {
29
+ const { wasm } = await import('./wasm/arcjet.wasm.js');
30
+ wasmModule = await WebAssembly.compile(await wasm());
31
+ }
32
32
  await initWasm(wasmModule);
33
33
  state = "initialized";
34
34
  }
package/index.ts CHANGED
@@ -44,21 +44,21 @@ async function init(): Promise<WasmAPI | undefined> {
44
44
  }
45
45
 
46
46
  if (state === "uninitialized") {
47
- let wasmModule: WebAssembly.Module;
48
- // We use `NEXT_RUNTIME` env var to DCE the Node/Browser code in the `else` block
49
- // possible values: "edge" | "nodejs" | undefined
50
- if (process.env["NEXT_RUNTIME"] === "edge") {
51
- const mod = await import(
52
- // @ts-expect-error
53
- "./wasm/arcjet_analyze_js_req_bg.wasm?module"
54
- );
55
- wasmModule = mod.default;
56
- } else {
57
- const { wasm } = await import("./wasm/arcjet.wasm.js");
58
- wasmModule = await WebAssembly.compile(wasm);
59
- }
60
-
61
47
  try {
48
+ let wasmModule: WebAssembly.Module;
49
+ // We use `NEXT_RUNTIME` env var to DCE the Node/Browser code in the `else` block
50
+ // possible values: "edge" | "nodejs" | undefined
51
+ if (process.env["NEXT_RUNTIME"] === "edge") {
52
+ const mod = await import(
53
+ // @ts-expect-error
54
+ "./wasm/arcjet_analyze_js_req_bg.wasm?module"
55
+ );
56
+ wasmModule = mod.default;
57
+ } else {
58
+ const { wasm } = await import("./wasm/arcjet.wasm.js");
59
+ wasmModule = await WebAssembly.compile(await wasm());
60
+ }
61
+
62
62
  await initWasm(wasmModule);
63
63
  state = "initialized";
64
64
  } catch (err) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcjet/analyze",
3
- "version": "1.0.0-alpha.2",
3
+ "version": "1.0.0-alpha.4",
4
4
  "description": "Arcjet local analysis engine",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://arcjet.com",
@@ -10,7 +10,8 @@
10
10
  "directory": "analyze"
11
11
  },
12
12
  "engines": {
13
- "node": ">=18"
13
+ "node": ">=18",
14
+ "npm": ">=10"
14
15
  },
15
16
  "type": "module",
16
17
  "main": "./index.js",
@@ -28,23 +29,24 @@
28
29
  "prepublishOnly": "npm run build",
29
30
  "build": "rollup --config rollup.config.js",
30
31
  "lint": "eslint .",
32
+ "pretest": "npm run build",
31
33
  "test": "NODE_OPTIONS=--experimental-vm-modules jest --passWithNoTests"
32
34
  },
33
35
  "sideEffects": [
34
36
  "./wasm/arcjet_analyze_js_req_bg.js"
35
37
  ],
36
38
  "dependencies": {
37
- "@arcjet/logger": "1.0.0-alpha.2"
39
+ "@arcjet/logger": "1.0.0-alpha.4"
38
40
  },
39
41
  "devDependencies": {
40
- "@arcjet/eslint-config": "1.0.0-alpha.2",
41
- "@arcjet/rollup-config": "1.0.0-alpha.2",
42
- "@arcjet/tsconfig": "1.0.0-alpha.2",
42
+ "@arcjet/eslint-config": "1.0.0-alpha.4",
43
+ "@arcjet/rollup-config": "1.0.0-alpha.4",
44
+ "@arcjet/tsconfig": "1.0.0-alpha.4",
43
45
  "@jest/globals": "29.7.0",
46
+ "@rollup/wasm-node": "4.8.0",
44
47
  "@types/node": "18.18.0",
45
48
  "jest": "29.7.0",
46
- "rollup": "4.6.1",
47
- "typescript": "5.3.2"
49
+ "typescript": "5.3.3"
48
50
  },
49
51
  "publishConfig": {
50
52
  "access": "public",
@@ -24,4 +24,8 @@
24
24
  * properly support consistent asset bundling techniques.
25
25
  */
26
26
 
27
- export const wasm: ArrayBuffer;
27
+ /**
28
+ * Returns an ArrayBuffer for the Arcjet Wasm binary, decoded from a base64 Data
29
+ * URL.
30
+ */
31
+ export function wasm(): Promise<ArrayBuffer>;