@schmock/vue 2.3.0 → 2.3.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Khalic Lab
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,33 @@
1
+ # @schmock/vue
2
+
3
+ Vue 3 adapter for Schmock — a plugin and a composable that intercept `fetch`.
4
+
5
+ Part of [Schmock](https://github.com/khalic-lab/schmock) — mock APIs from OpenAPI specs or hand-crafted routes.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ bun add -d @schmock/vue
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ ```typescript
16
+ import { createApp } from "vue";
17
+ import { schmock } from "@schmock/core";
18
+ import { schmockPlugin } from "@schmock/vue";
19
+
20
+ const mock = schmock();
21
+ mock("GET /users", [{ id: 1, name: "Alice" }]);
22
+
23
+ createApp(App).use(schmockPlugin, { mock });
24
+ ```
25
+
26
+ ## Documentation
27
+
28
+ - [Vue adapter](https://github.com/khalic-lab/schmock/blob/main/docs/vue.md)
29
+ - [Testing patterns](https://github.com/khalic-lab/schmock/blob/main/docs/testing.md)
30
+
31
+ ## License
32
+
33
+ MIT © Khalic Lab
package/dist/index.d.ts CHANGED
@@ -1,8 +1,15 @@
1
- import { type Plugin } from "vue";
1
+ import type * as Schmock from "@schmock/core";
2
+ import { type App, type Plugin } from "vue";
2
3
  export interface SchmockPluginOptions {
3
4
  mock: Schmock.CallableMockInstance;
4
5
  interceptOptions?: Schmock.InterceptOptions;
5
6
  }
7
+ /**
8
+ * Release the interception lease an app acquired when `schmockPlugin` was
9
+ * installed. Idempotent, and safe to call for an app that never intercepted
10
+ * (a never-mounted app, a failed mount, or a server-rendered app).
11
+ */
12
+ export declare function restoreSchmockInterception(app: App): void;
6
13
  export declare const schmockPlugin: Plugin<SchmockPluginOptions>;
7
14
  export declare function useSchmock(): Schmock.CallableMockInstance;
8
15
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAuC,KAAK,MAAM,EAAE,MAAM,KAAK,CAAC;AASvE,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,OAAO,CAAC,oBAAoB,CAAC;IACnC,gBAAgB,CAAC,EAAE,OAAO,CAAC,gBAAgB,CAAC;CAC7C;AAED,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,oBAAoB,CAYtD,CAAC;AAIF,wBAAgB,UAAU,IAAI,OAAO,CAAC,oBAAoB,CAQzD"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,OAAO,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,KAAK,GAAG,EAA6B,KAAK,MAAM,EAAE,MAAM,KAAK,CAAC;AASvE,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,OAAO,CAAC,oBAAoB,CAAC;IACnC,gBAAgB,CAAC,EAAE,OAAO,CAAC,gBAAgB,CAAC;CAC7C;AAOD;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,GAAG,EAAE,GAAG,GAAG,IAAI,CAMzD;AAED,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,oBAAoB,CA6BtD,CAAC;AAIF,wBAAgB,UAAU,IAAI,OAAO,CAAC,oBAAoB,CAQzD"}
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{inject as s}from"vue";var o=Symbol("schmock"),m={install(c,t){let{mock:n,interceptOptions:e}=t,i=n.intercept(e);c.provide(o,n),c.onUnmount(()=>{i.restore()})}};function p(){let c=s(o);if(!c)throw Error("useSchmock must be used in a component with schmockPlugin installed");return c}export{p as useSchmock,m as schmockPlugin};
1
+ import{inject as Q}from"vue";var D=Symbol("schmock"),y=new WeakMap;function B(q){let x=y.get(q);if(!x)return;y.delete(q),x.restore()}var T={install(q,x){let{mock:z,interceptOptions:F}=x;if(q.provide(D,z),typeof document>"u")return;let G=z.intercept(F);y.set(q,G);let J=q.mount.bind(q);q.mount=(...N)=>{try{return J(...N)}catch(P){throw B(q),P}},q.onUnmount(()=>{B(q)})}};function V(){let q=Q(D);if(!q)throw Error("useSchmock must be used in a component with schmockPlugin installed");return q}export{V as useSchmock,T as schmockPlugin,B as restoreSchmockInterception};
package/package.json CHANGED
@@ -1,8 +1,17 @@
1
1
  {
2
2
  "name": "@schmock/vue",
3
- "version": "2.3.0",
3
+ "version": "2.3.1",
4
4
  "description": "Vue adapter for Schmock — Plugin and composables",
5
5
  "type": "module",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/khalic-lab/schmock.git",
9
+ "directory": "packages/vue"
10
+ },
11
+ "homepage": "https://github.com/khalic-lab/schmock/tree/main/packages/vue#readme",
12
+ "bugs": {
13
+ "url": "https://github.com/khalic-lab/schmock/issues"
14
+ },
6
15
  "main": "./dist/index.js",
7
16
  "types": "./dist/index.d.ts",
8
17
  "exports": {
@@ -16,7 +25,8 @@
16
25
  "dist"
17
26
  ],
18
27
  "scripts": {
19
- "build": "bun build:lib && bun build:types",
28
+ "clean": "rm -rf dist && rm -f tsconfig.tsbuildinfo",
29
+ "build": "bun run clean && bun run build:lib && bun run build:types",
20
30
  "build:lib": "bun build --minify --target browser --outdir=dist src/index.ts --external @schmock/core --external vue",
21
31
  "build:types": "tsc -p tsconfig.json",
22
32
  "test": "vitest run",
@@ -29,7 +39,7 @@
29
39
  "license": "MIT",
30
40
  "dependencies": {},
31
41
  "peerDependencies": {
32
- "@schmock/core": "^2.3.0",
42
+ "@schmock/core": "^2.3.1",
33
43
  "vue": "^3.5.0"
34
44
  },
35
45
  "devDependencies": {