@getaster/mock 0.3.5 → 0.4.5

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.
Files changed (2) hide show
  1. package/README.md +35 -0
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -20,6 +20,41 @@ or install script is required. It provides ES modules and TypeScript declaration
20
20
  Node.js use requires Node 22 or later. Browser builds must serve the WASM asset
21
21
  over HTTP or pass its bytes explicitly.
22
22
 
23
+ ### The WASM location and browser route
24
+
25
+ The engine is `wasm/odata_mock.wasm` inside the installed package. The package
26
+ exports the file, so `import.meta.resolve('@getaster/mock/wasm/odata_mock.wasm')`
27
+ returns its location in Node.js and Bun.
28
+
29
+ A browser page typically passes a URL and lets the development server serve it.
30
+ The documented convention is the root-relative route:
31
+
32
+ ```js
33
+ const mock = await createMockService({
34
+ metadata, data,
35
+ wasm: new URL('odata_mock.wasm', document.baseURI),
36
+ });
37
+ ```
38
+
39
+ The server must serve the installed file at `/odata_mock.wasm`:
40
+
41
+ ```js
42
+ import { fileURLToPath } from 'node:url';
43
+ const wasm = Bun.file(fileURLToPath(import.meta.resolve('@getaster/mock/wasm/odata_mock.wasm')));
44
+
45
+ Bun.serve({
46
+ port: 4200,
47
+ routes: {
48
+ '/odata_mock.wasm': () => new Response(wasm, { headers: { 'content-type': 'application/wasm' } }),
49
+ },
50
+ });
51
+ ```
52
+
53
+ `apps/showcase/serve.ts` implements this route for the repository's demo, and
54
+ `scripts/verify-wasm.ts` checks the binary's checksum, module and attribution
55
+ files before distribution. Pass `wasm` bytes, a `URL` or a URL string instead
56
+ when the file lives elsewhere; its default is the package-relative file.
57
+
23
58
  ## Run a local service in Node.js
24
59
 
25
60
  TypeScript projects using this Node.js example also need `@types/node` as a
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getaster/mock",
3
- "version": "0.3.5",
3
+ "version": "0.4.5",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -11,7 +11,7 @@
11
11
  "./wasm/odata_mock.wasm": "./wasm/odata_mock.wasm"
12
12
  },
13
13
  "dependencies": {
14
- "@getaster/data": "0.3.5"
14
+ "@getaster/data": "0.4.5"
15
15
  },
16
16
  "license": "Apache-2.0",
17
17
  "repository": {