orderopia-ordering-api-client-vue 0.0.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/dist/index.cjs +68 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +48 -0
- package/dist/index.d.ts +48 -0
- package/dist/index.js +42 -0
- package/dist/index.js.map +1 -0
- package/package.json +38 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
OrderopiaVuePlugin: () => OrderopiaVuePlugin,
|
|
24
|
+
useBasket: () => useBasket
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(index_exports);
|
|
27
|
+
|
|
28
|
+
// src/composables/useBasket.ts
|
|
29
|
+
var import_vue = require("vue");
|
|
30
|
+
var import_orderopia_ordering_api_client = require("orderopia-ordering-api-client");
|
|
31
|
+
function useBasket() {
|
|
32
|
+
const basket = (0, import_vue.ref)(import_orderopia_ordering_api_client.basketManager.getBasket());
|
|
33
|
+
let unsubscribe = null;
|
|
34
|
+
(0, import_vue.onMounted)(() => {
|
|
35
|
+
unsubscribe = import_orderopia_ordering_api_client.basketManager.subscribe((state) => {
|
|
36
|
+
basket.value = state;
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
(0, import_vue.onUnmounted)(() => {
|
|
40
|
+
unsubscribe?.();
|
|
41
|
+
unsubscribe = null;
|
|
42
|
+
});
|
|
43
|
+
const totalQuantity = (0, import_vue.computed)(
|
|
44
|
+
() => basket.value.items.reduce((sum, i) => sum + i.quantity, 0)
|
|
45
|
+
);
|
|
46
|
+
return {
|
|
47
|
+
basket,
|
|
48
|
+
totalQuantity,
|
|
49
|
+
// pass-through convenience (optional but nice)
|
|
50
|
+
addToBasket: import_orderopia_ordering_api_client.basketManager.addToBasket.bind(import_orderopia_ordering_api_client.basketManager),
|
|
51
|
+
removeFromBasket: import_orderopia_ordering_api_client.basketManager.removeFromBasket.bind(import_orderopia_ordering_api_client.basketManager),
|
|
52
|
+
clearBasket: import_orderopia_ordering_api_client.basketManager.clearBasket.bind(import_orderopia_ordering_api_client.basketManager)
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// src/install.ts
|
|
57
|
+
function OrderopiaVuePlugin() {
|
|
58
|
+
return {
|
|
59
|
+
install(app) {
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
64
|
+
0 && (module.exports = {
|
|
65
|
+
OrderopiaVuePlugin,
|
|
66
|
+
useBasket
|
|
67
|
+
});
|
|
68
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/composables/useBasket.ts","../src/install.ts"],"sourcesContent":["// src/index.ts\r\nexport { useBasket } from './composables/useBasket'\r\nexport { OrderopiaVuePlugin } from './install'\r\n","// src/composables/useBasket.ts\r\nimport { ref, computed, onMounted, onUnmounted } from 'vue'\r\nimport {\r\n basketManager,\r\n type BasketState\r\n} from 'orderopia-ordering-api-client'\r\nexport function useBasket() {\r\n const basket = ref<BasketState>(basketManager.getBasket())\r\n\r\n let unsubscribe: (() => void) | null = null\r\n\r\n onMounted(() => {\r\n unsubscribe = basketManager.subscribe(state => {\r\n basket.value = state\r\n })\r\n })\r\n\r\n onUnmounted(() => {\r\n unsubscribe?.()\r\n unsubscribe = null\r\n })\r\n\r\n const totalQuantity = computed(() =>\r\n basket.value.items.reduce((sum, i) => sum + i.quantity, 0)\r\n )\r\n\r\n return {\r\n basket,\r\n totalQuantity,\r\n\r\n // pass-through convenience (optional but nice)\r\n addToBasket: basketManager.addToBasket.bind(basketManager),\r\n removeFromBasket: basketManager.removeFromBasket.bind(basketManager),\r\n clearBasket: basketManager.clearBasket.bind(basketManager)\r\n }\r\n}\r\n","// src/install.ts\r\nimport type { App } from 'vue'\r\n\r\nexport function OrderopiaVuePlugin() {\r\n return {\r\n install(app: App) {\r\n // nothing yet, but future-proof\r\n }\r\n }\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCA,iBAAsD;AACtD,2CAGO;AACA,SAAS,YAAY;AAC1B,QAAM,aAAS,gBAAiB,mDAAc,UAAU,CAAC;AAEzD,MAAI,cAAmC;AAEvC,4BAAU,MAAM;AACd,kBAAc,mDAAc,UAAU,WAAS;AAC7C,aAAO,QAAQ;AAAA,IACjB,CAAC;AAAA,EACH,CAAC;AAED,8BAAY,MAAM;AAChB,kBAAc;AACd,kBAAc;AAAA,EAChB,CAAC;AAED,QAAM,oBAAgB;AAAA,IAAS,MAC7B,OAAO,MAAM,MAAM,OAAO,CAAC,KAAK,MAAM,MAAM,EAAE,UAAU,CAAC;AAAA,EAC3D;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA;AAAA,IAGA,aAAa,mDAAc,YAAY,KAAK,kDAAa;AAAA,IACzD,kBAAkB,mDAAc,iBAAiB,KAAK,kDAAa;AAAA,IACnE,aAAa,mDAAc,YAAY,KAAK,kDAAa;AAAA,EAC3D;AACF;;;AChCO,SAAS,qBAAqB;AACnC,SAAO;AAAA,IACL,QAAQ,KAAU;AAAA,IAElB;AAAA,EACF;AACF;","names":[]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import * as orderopia_ordering_api_client from 'orderopia-ordering-api-client';
|
|
2
|
+
import { BasketState } from 'orderopia-ordering-api-client';
|
|
3
|
+
import * as vue from 'vue';
|
|
4
|
+
import { App } from 'vue';
|
|
5
|
+
|
|
6
|
+
declare function useBasket(): {
|
|
7
|
+
basket: vue.Ref<{
|
|
8
|
+
merchantId?: number | null | undefined;
|
|
9
|
+
menuId?: number | null | undefined;
|
|
10
|
+
sessionId?: string | null | undefined;
|
|
11
|
+
pendingIdempotencyKey?: string | null | undefined;
|
|
12
|
+
items: {
|
|
13
|
+
basketItemId: number;
|
|
14
|
+
quantity: number;
|
|
15
|
+
note?: string | null | undefined;
|
|
16
|
+
options?: {
|
|
17
|
+
optionId: number;
|
|
18
|
+
quantity: number;
|
|
19
|
+
}[] | null | undefined;
|
|
20
|
+
}[];
|
|
21
|
+
updatedAtUtc: string;
|
|
22
|
+
}, BasketState | {
|
|
23
|
+
merchantId?: number | null | undefined;
|
|
24
|
+
menuId?: number | null | undefined;
|
|
25
|
+
sessionId?: string | null | undefined;
|
|
26
|
+
pendingIdempotencyKey?: string | null | undefined;
|
|
27
|
+
items: {
|
|
28
|
+
basketItemId: number;
|
|
29
|
+
quantity: number;
|
|
30
|
+
note?: string | null | undefined;
|
|
31
|
+
options?: {
|
|
32
|
+
optionId: number;
|
|
33
|
+
quantity: number;
|
|
34
|
+
}[] | null | undefined;
|
|
35
|
+
}[];
|
|
36
|
+
updatedAtUtc: string;
|
|
37
|
+
}>;
|
|
38
|
+
totalQuantity: vue.ComputedRef<number>;
|
|
39
|
+
addToBasket: (item: orderopia_ordering_api_client.BasketItem) => BasketState;
|
|
40
|
+
removeFromBasket: (item: orderopia_ordering_api_client.BasketItem) => BasketState;
|
|
41
|
+
clearBasket: () => BasketState;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
declare function OrderopiaVuePlugin(): {
|
|
45
|
+
install(app: App): void;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export { OrderopiaVuePlugin, useBasket };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import * as orderopia_ordering_api_client from 'orderopia-ordering-api-client';
|
|
2
|
+
import { BasketState } from 'orderopia-ordering-api-client';
|
|
3
|
+
import * as vue from 'vue';
|
|
4
|
+
import { App } from 'vue';
|
|
5
|
+
|
|
6
|
+
declare function useBasket(): {
|
|
7
|
+
basket: vue.Ref<{
|
|
8
|
+
merchantId?: number | null | undefined;
|
|
9
|
+
menuId?: number | null | undefined;
|
|
10
|
+
sessionId?: string | null | undefined;
|
|
11
|
+
pendingIdempotencyKey?: string | null | undefined;
|
|
12
|
+
items: {
|
|
13
|
+
basketItemId: number;
|
|
14
|
+
quantity: number;
|
|
15
|
+
note?: string | null | undefined;
|
|
16
|
+
options?: {
|
|
17
|
+
optionId: number;
|
|
18
|
+
quantity: number;
|
|
19
|
+
}[] | null | undefined;
|
|
20
|
+
}[];
|
|
21
|
+
updatedAtUtc: string;
|
|
22
|
+
}, BasketState | {
|
|
23
|
+
merchantId?: number | null | undefined;
|
|
24
|
+
menuId?: number | null | undefined;
|
|
25
|
+
sessionId?: string | null | undefined;
|
|
26
|
+
pendingIdempotencyKey?: string | null | undefined;
|
|
27
|
+
items: {
|
|
28
|
+
basketItemId: number;
|
|
29
|
+
quantity: number;
|
|
30
|
+
note?: string | null | undefined;
|
|
31
|
+
options?: {
|
|
32
|
+
optionId: number;
|
|
33
|
+
quantity: number;
|
|
34
|
+
}[] | null | undefined;
|
|
35
|
+
}[];
|
|
36
|
+
updatedAtUtc: string;
|
|
37
|
+
}>;
|
|
38
|
+
totalQuantity: vue.ComputedRef<number>;
|
|
39
|
+
addToBasket: (item: orderopia_ordering_api_client.BasketItem) => BasketState;
|
|
40
|
+
removeFromBasket: (item: orderopia_ordering_api_client.BasketItem) => BasketState;
|
|
41
|
+
clearBasket: () => BasketState;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
declare function OrderopiaVuePlugin(): {
|
|
45
|
+
install(app: App): void;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export { OrderopiaVuePlugin, useBasket };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// src/composables/useBasket.ts
|
|
2
|
+
import { ref, computed, onMounted, onUnmounted } from "vue";
|
|
3
|
+
import {
|
|
4
|
+
basketManager
|
|
5
|
+
} from "orderopia-ordering-api-client";
|
|
6
|
+
function useBasket() {
|
|
7
|
+
const basket = ref(basketManager.getBasket());
|
|
8
|
+
let unsubscribe = null;
|
|
9
|
+
onMounted(() => {
|
|
10
|
+
unsubscribe = basketManager.subscribe((state) => {
|
|
11
|
+
basket.value = state;
|
|
12
|
+
});
|
|
13
|
+
});
|
|
14
|
+
onUnmounted(() => {
|
|
15
|
+
unsubscribe?.();
|
|
16
|
+
unsubscribe = null;
|
|
17
|
+
});
|
|
18
|
+
const totalQuantity = computed(
|
|
19
|
+
() => basket.value.items.reduce((sum, i) => sum + i.quantity, 0)
|
|
20
|
+
);
|
|
21
|
+
return {
|
|
22
|
+
basket,
|
|
23
|
+
totalQuantity,
|
|
24
|
+
// pass-through convenience (optional but nice)
|
|
25
|
+
addToBasket: basketManager.addToBasket.bind(basketManager),
|
|
26
|
+
removeFromBasket: basketManager.removeFromBasket.bind(basketManager),
|
|
27
|
+
clearBasket: basketManager.clearBasket.bind(basketManager)
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// src/install.ts
|
|
32
|
+
function OrderopiaVuePlugin() {
|
|
33
|
+
return {
|
|
34
|
+
install(app) {
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
export {
|
|
39
|
+
OrderopiaVuePlugin,
|
|
40
|
+
useBasket
|
|
41
|
+
};
|
|
42
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/composables/useBasket.ts","../src/install.ts"],"sourcesContent":["// src/composables/useBasket.ts\r\nimport { ref, computed, onMounted, onUnmounted } from 'vue'\r\nimport {\r\n basketManager,\r\n type BasketState\r\n} from 'orderopia-ordering-api-client'\r\nexport function useBasket() {\r\n const basket = ref<BasketState>(basketManager.getBasket())\r\n\r\n let unsubscribe: (() => void) | null = null\r\n\r\n onMounted(() => {\r\n unsubscribe = basketManager.subscribe(state => {\r\n basket.value = state\r\n })\r\n })\r\n\r\n onUnmounted(() => {\r\n unsubscribe?.()\r\n unsubscribe = null\r\n })\r\n\r\n const totalQuantity = computed(() =>\r\n basket.value.items.reduce((sum, i) => sum + i.quantity, 0)\r\n )\r\n\r\n return {\r\n basket,\r\n totalQuantity,\r\n\r\n // pass-through convenience (optional but nice)\r\n addToBasket: basketManager.addToBasket.bind(basketManager),\r\n removeFromBasket: basketManager.removeFromBasket.bind(basketManager),\r\n clearBasket: basketManager.clearBasket.bind(basketManager)\r\n }\r\n}\r\n","// src/install.ts\r\nimport type { App } from 'vue'\r\n\r\nexport function OrderopiaVuePlugin() {\r\n return {\r\n install(app: App) {\r\n // nothing yet, but future-proof\r\n }\r\n }\r\n}\r\n"],"mappings":";AACA,SAAS,KAAK,UAAU,WAAW,mBAAmB;AACtD;AAAA,EACE;AAAA,OAEK;AACA,SAAS,YAAY;AAC1B,QAAM,SAAS,IAAiB,cAAc,UAAU,CAAC;AAEzD,MAAI,cAAmC;AAEvC,YAAU,MAAM;AACd,kBAAc,cAAc,UAAU,WAAS;AAC7C,aAAO,QAAQ;AAAA,IACjB,CAAC;AAAA,EACH,CAAC;AAED,cAAY,MAAM;AAChB,kBAAc;AACd,kBAAc;AAAA,EAChB,CAAC;AAED,QAAM,gBAAgB;AAAA,IAAS,MAC7B,OAAO,MAAM,MAAM,OAAO,CAAC,KAAK,MAAM,MAAM,EAAE,UAAU,CAAC;AAAA,EAC3D;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA;AAAA,IAGA,aAAa,cAAc,YAAY,KAAK,aAAa;AAAA,IACzD,kBAAkB,cAAc,iBAAiB,KAAK,aAAa;AAAA,IACnE,aAAa,cAAc,YAAY,KAAK,aAAa;AAAA,EAC3D;AACF;;;AChCO,SAAS,qBAAqB;AACnC,SAAO;AAAA,IACL,QAAQ,KAAU;AAAA,IAElB;AAAA,EACF;AACF;","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "orderopia-ordering-api-client-vue",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Vue bindings for Orderopia Ordering API Client",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "./dist/index.cjs",
|
|
8
|
+
"module": "./dist/index.js",
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"import": "./dist/index.js",
|
|
14
|
+
"require": "./dist/index.cjs"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"dist"
|
|
19
|
+
],
|
|
20
|
+
"scripts": {
|
|
21
|
+
"build": "tsup src/index.ts --format esm,cjs --dts --sourcemap --clean",
|
|
22
|
+
"dev": "tsup src/index.ts --format esm,cjs --dts --sourcemap --watch",
|
|
23
|
+
"prepublishOnly": "npm run build",
|
|
24
|
+
"test": "vitest"
|
|
25
|
+
},
|
|
26
|
+
"peerDependencies": {
|
|
27
|
+
"vue": "^3.3.0"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"tsup": "^8.0.0",
|
|
31
|
+
"typescript": "^5.0.0",
|
|
32
|
+
"vitest": "^4.0.17",
|
|
33
|
+
"vue": "^3.3.0"
|
|
34
|
+
},
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"orderopia-ordering-api-client": "^0.0.6"
|
|
37
|
+
}
|
|
38
|
+
}
|