@lifi/perps-sdk-provider-lighter 22.1.0 → 22.1.1

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/README.md CHANGED
@@ -53,7 +53,11 @@ Each provider instance shares one request hold across its Lighter API clients, p
53
53
 
54
54
  ## WASM signer loading
55
55
 
56
- The Go signer binary ships as a separate asset and the package resolves it itself. The ESM build points a static `new URL('../../wasm/lighter-signer.wasm', import.meta.url)` at it, which webpack, Turbopack and Vite production builds rewrite into an emitted asset URL, while Node reads the installed binary from disk. The loader checks the WASM preamble of whatever the URL serves; if a bundler relocated the module — Vite's dependency optimizer rewrites the package into `.vite/deps`, leaving the static URL pointing at the cache directory — it re-resolves through that bundler's own asset pipeline. Go's `wasm_exec.js` is packaged as generated text and evaluated as-is.
56
+ The Go signer binary ships as a separate asset that the package resolves itself. The ESM build uses `new URL('../../wasm/lighter-signer.wasm', import.meta.url)`. Webpack, Turbopack, and Vite production builds rewrite this expression into an emitted asset URL. Node reads the installed binary from disk. The loader checks the WASM preamble of the response. Vite's dependency optimizer can relocate the package into `.vite/deps`, which invalidates the static URL. The loader then resolves the asset through the bundler's own asset pipeline.
57
+
58
+ Go's `wasm_exec.js` ships inside a generated initializer that compiles into both CommonJS and ESM. Package imports do not initialize Go or install its globals. `loadLighterWasm()` initializes the runtime after reading the binary, so callers can install required polyfills after import. The package evaluates no script text.
59
+
60
+ Under a Content Security Policy, `script-src` must include `'wasm-unsafe-eval'` so the browser can run `WebAssembly.instantiate`. `'unsafe-eval'` is not required.
57
61
 
58
62
  Applications need no `optimizeDeps.exclude`, no `?url`/`?raw` imports, no `public/` copy step, no caller-supplied URL and no bundler configuration. `loadLighterWasm()` is exported for hosts that want to warm the signer up (and its 12.9 MB download) before the user's first trade:
59
63
 
@@ -63,6 +67,21 @@ import { loadLighterWasm } from '@lifi/perps-sdk-provider-lighter'
63
67
  await loadLighterWasm()
64
68
  ```
65
69
 
70
+ ## Consumer verification
71
+
72
+ Run these commands from the repository root:
73
+
74
+ ```sh
75
+ pnpm --filter @lifi/perps-sdk-provider-lighter exec playwright install chromium
76
+ pnpm --filter @lifi/perps-sdk-provider-lighter test:consumers
77
+ ```
78
+
79
+ On Linux systems without browser libraries, use `playwright install --with-deps chromium` for the installation step.
80
+
81
+ The four Next targets execute the client probe in headless Chromium. They cover development and production with webpack and Turbopack. Browser exceptions, failed probes, missing results, and invalid WASM responses fail the checks. The checks also verify the emitted asset and its chunk reference.
82
+
83
+ Playwright is a development dependency. SDK consumers do not need it.
84
+
66
85
  ## Documentation
67
86
 
68
87
  - [`@lifi/perps-sdk` README](https://www.npmjs.com/package/@lifi/perps-sdk) — client setup, options, and the WebSocket API
@@ -1,2 +1,5 @@
1
- export declare const WASM_EXEC_JS: string;
1
+ export declare function createGoRuntime(): {
2
+ importObject: WebAssembly.Imports;
3
+ run(instance: WebAssembly.Instance): Promise<void>;
4
+ };
2
5
  //# sourceMappingURL=wasmExecRuntime.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"wasmExecRuntime.d.ts","sourceRoot":"","sources":["../../../../src/signers/generated/wasmExecRuntime.ts"],"names":[],"mappings":"AA8jBA,eAAO,MAAM,YAAY,EAAE,MAAmC,CAAA"}
1
+ {"version":3,"file":"wasmExecRuntime.d.ts","sourceRoot":"","sources":["../../../../src/signers/generated/wasmExecRuntime.ts"],"names":[],"mappings":"AAKA,wBAAgB,eAAe,IAAI;IACjC,YAAY,EAAE,WAAW,CAAC,OAAO,CAAA;IACjC,GAAG,CAAC,QAAQ,EAAE,WAAW,CAAC,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CACnD,CAojBA"}