@moonbase.sh/vue 0.2.64 → 0.2.66
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 +5 -5
- package/dist/index.js +19 -19
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -179,7 +179,7 @@ var _StorefrontContextImpl = class _StorefrontContextImpl {
|
|
|
179
179
|
const cachedOrderJson = localStorage.getItem(_StorefrontContextImpl.sessionKey);
|
|
180
180
|
if (cachedOrderJson) {
|
|
181
181
|
this.currentOrder = (0, import_vue.ref)(JSON.parse(cachedOrderJson));
|
|
182
|
-
|
|
182
|
+
this.refreshOrder();
|
|
183
183
|
} else {
|
|
184
184
|
this.currentOrder = (0, import_vue.ref)({
|
|
185
185
|
id: (0, import_uuid.v4)(),
|
|
@@ -189,7 +189,7 @@ var _StorefrontContextImpl = class _StorefrontContextImpl {
|
|
|
189
189
|
couponsApplied: []
|
|
190
190
|
});
|
|
191
191
|
if (this.hasUtm) {
|
|
192
|
-
|
|
192
|
+
this.pushOrderContent();
|
|
193
193
|
}
|
|
194
194
|
}
|
|
195
195
|
const cachedStorefrontJson = localStorage.getItem(_StorefrontContextImpl.storefrontKey);
|
|
@@ -207,8 +207,8 @@ var _StorefrontContextImpl = class _StorefrontContextImpl {
|
|
|
207
207
|
if (this.client.tokenStore.hasAccessToken) {
|
|
208
208
|
this.currentUser.value = this.client.tokenStore.user;
|
|
209
209
|
}
|
|
210
|
-
|
|
211
|
-
|
|
210
|
+
this.updateStorefront();
|
|
211
|
+
this.updateUser();
|
|
212
212
|
if (window.location) {
|
|
213
213
|
const urlParams2 = new URLSearchParams(window.location.search);
|
|
214
214
|
const intent = urlParams2.get("mb_intent");
|
|
@@ -284,7 +284,7 @@ var _StorefrontContextImpl = class _StorefrontContextImpl {
|
|
|
284
284
|
async pushOrderContent() {
|
|
285
285
|
if (typeof window !== "undefined")
|
|
286
286
|
localStorage.setItem(_StorefrontContextImpl.sessionKey, JSON.stringify(this.currentOrder.value));
|
|
287
|
-
|
|
287
|
+
this.debouncedPushOrderContent(this.currentOrder.value);
|
|
288
288
|
}
|
|
289
289
|
handleStorageUpdate(event) {
|
|
290
290
|
var _a;
|
package/dist/index.js
CHANGED
|
@@ -144,7 +144,7 @@ var _StorefrontContextImpl = class _StorefrontContextImpl {
|
|
|
144
144
|
const cachedOrderJson = localStorage.getItem(_StorefrontContextImpl.sessionKey);
|
|
145
145
|
if (cachedOrderJson) {
|
|
146
146
|
this.currentOrder = ref(JSON.parse(cachedOrderJson));
|
|
147
|
-
|
|
147
|
+
this.refreshOrder();
|
|
148
148
|
} else {
|
|
149
149
|
this.currentOrder = ref({
|
|
150
150
|
id: uuidv4(),
|
|
@@ -154,7 +154,7 @@ var _StorefrontContextImpl = class _StorefrontContextImpl {
|
|
|
154
154
|
couponsApplied: []
|
|
155
155
|
});
|
|
156
156
|
if (this.hasUtm) {
|
|
157
|
-
|
|
157
|
+
this.pushOrderContent();
|
|
158
158
|
}
|
|
159
159
|
}
|
|
160
160
|
const cachedStorefrontJson = localStorage.getItem(_StorefrontContextImpl.storefrontKey);
|
|
@@ -172,8 +172,8 @@ var _StorefrontContextImpl = class _StorefrontContextImpl {
|
|
|
172
172
|
if (this.client.tokenStore.hasAccessToken) {
|
|
173
173
|
this.currentUser.value = this.client.tokenStore.user;
|
|
174
174
|
}
|
|
175
|
-
|
|
176
|
-
|
|
175
|
+
this.updateStorefront();
|
|
176
|
+
this.updateUser();
|
|
177
177
|
if (window.location) {
|
|
178
178
|
const urlParams2 = new URLSearchParams(window.location.search);
|
|
179
179
|
const intent = urlParams2.get("mb_intent");
|
|
@@ -249,7 +249,7 @@ var _StorefrontContextImpl = class _StorefrontContextImpl {
|
|
|
249
249
|
async pushOrderContent() {
|
|
250
250
|
if (typeof window !== "undefined")
|
|
251
251
|
localStorage.setItem(_StorefrontContextImpl.sessionKey, JSON.stringify(this.currentOrder.value));
|
|
252
|
-
|
|
252
|
+
this.debouncedPushOrderContent(this.currentOrder.value);
|
|
253
253
|
}
|
|
254
254
|
handleStorageUpdate(event) {
|
|
255
255
|
var _a;
|
|
@@ -321,39 +321,39 @@ var StorefrontContextImpl = _StorefrontContextImpl;
|
|
|
321
321
|
export * from "@moonbase.sh/storefront-api";
|
|
322
322
|
|
|
323
323
|
// src/composables/useBundle.ts
|
|
324
|
-
import { computed
|
|
324
|
+
import { computed, inject } from "vue";
|
|
325
325
|
function useBundle(bundleId, context) {
|
|
326
326
|
const storefront = context != null ? context : inject(storefrontKey);
|
|
327
327
|
if (!storefront)
|
|
328
328
|
throw new Error("No storefront configured");
|
|
329
|
-
return
|
|
329
|
+
return computed(() => storefront.storefront.value.bundles.find((b) => b.id === bundleId) || null);
|
|
330
330
|
}
|
|
331
331
|
|
|
332
332
|
// src/composables/useBundles.ts
|
|
333
|
-
import { computed as
|
|
333
|
+
import { computed as computed2, inject as inject2 } from "vue";
|
|
334
334
|
function useBundles(context) {
|
|
335
335
|
const storefront = context != null ? context : inject2(storefrontKey);
|
|
336
336
|
if (!storefront)
|
|
337
337
|
throw new Error("No storefront configured");
|
|
338
|
-
return
|
|
338
|
+
return computed2(() => storefront.storefront.value.bundles);
|
|
339
339
|
}
|
|
340
340
|
|
|
341
341
|
// src/composables/useProduct.ts
|
|
342
|
-
import { computed as
|
|
342
|
+
import { computed as computed3, inject as inject3 } from "vue";
|
|
343
343
|
function useProduct(productId, context) {
|
|
344
344
|
const storefront = context != null ? context : inject3(storefrontKey);
|
|
345
345
|
if (!storefront)
|
|
346
346
|
throw new Error("No storefront configured");
|
|
347
|
-
return
|
|
347
|
+
return computed3(() => storefront.storefront.value.products.find((p) => p.id === productId) || null);
|
|
348
348
|
}
|
|
349
349
|
|
|
350
350
|
// src/composables/useProducts.ts
|
|
351
|
-
import { computed as
|
|
351
|
+
import { computed as computed4, inject as inject4 } from "vue";
|
|
352
352
|
function useProducts(context) {
|
|
353
353
|
const storefront = context != null ? context : inject4(storefrontKey);
|
|
354
354
|
if (!storefront)
|
|
355
355
|
throw new Error("No storefront configured");
|
|
356
|
-
return
|
|
356
|
+
return computed4(() => storefront.storefront.value.products);
|
|
357
357
|
}
|
|
358
358
|
|
|
359
359
|
// src/composables/useInventory.ts
|
|
@@ -397,7 +397,7 @@ function useInventory(context) {
|
|
|
397
397
|
|
|
398
398
|
// src/composables/useActivationRequest.ts
|
|
399
399
|
import { ActivationRequestStatus } from "@moonbase.sh/storefront-api";
|
|
400
|
-
import { computed as
|
|
400
|
+
import { computed as computed5, inject as inject6, onBeforeUnmount, toValue, watch as watch2 } from "vue";
|
|
401
401
|
function useActivationRequest(token, context) {
|
|
402
402
|
const storefront = context != null ? context : inject6(storefrontKey);
|
|
403
403
|
if (!storefront)
|
|
@@ -463,7 +463,7 @@ function useActivationRequest(token, context) {
|
|
|
463
463
|
fulfilling,
|
|
464
464
|
completing,
|
|
465
465
|
error,
|
|
466
|
-
isInstalled:
|
|
466
|
+
isInstalled: computed5(() => {
|
|
467
467
|
var _a;
|
|
468
468
|
return activationRequest && ((_a = activationRequest.value) == null ? void 0 : _a.status) === ActivationRequestStatus.Completed;
|
|
469
469
|
}),
|
|
@@ -519,14 +519,14 @@ function useVoucher(context) {
|
|
|
519
519
|
}
|
|
520
520
|
|
|
521
521
|
// src/composables/useCart.ts
|
|
522
|
-
import { computed as
|
|
522
|
+
import { computed as computed6, inject as inject8, unref } from "vue";
|
|
523
523
|
import { MoonbaseError as MoonbaseError2 } from "@moonbase.sh/storefront-api";
|
|
524
524
|
function useCart(context) {
|
|
525
525
|
const storefront = context != null ? context : inject8(storefrontKey);
|
|
526
526
|
if (!storefront)
|
|
527
527
|
throw new Error("No storefront configured");
|
|
528
528
|
return {
|
|
529
|
-
items:
|
|
529
|
+
items: computed6(() => storefront.currentOrder.value.items.map((item) => {
|
|
530
530
|
var _a, _b;
|
|
531
531
|
if (item.type === "Product") {
|
|
532
532
|
const product = storefront.storefront.value.products.find((p) => p.id === item.productId);
|
|
@@ -552,8 +552,8 @@ function useCart(context) {
|
|
|
552
552
|
};
|
|
553
553
|
}
|
|
554
554
|
})),
|
|
555
|
-
currency:
|
|
556
|
-
total:
|
|
555
|
+
currency: computed6(() => storefront.currentOrder.value.currency || storefront.storefront.value.suggestedCurrency),
|
|
556
|
+
total: computed6(() => {
|
|
557
557
|
const currency = storefront.currentOrder.value.currency || storefront.storefront.value.suggestedCurrency;
|
|
558
558
|
const total = storefront.currentOrder.value.items.reduce((agg, item) => {
|
|
559
559
|
var _a, _b, _c, _d, _e, _f;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moonbase.sh/vue",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.66",
|
|
5
5
|
"description": "Package to let you build vue.js storefronts with Moonbase.sh as payment and delivery provider",
|
|
6
6
|
"author": "Tobias Lønnerød Madsen <m@dsen.tv>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"@vue/devtools-api": "^6.6.3",
|
|
20
20
|
"uuid": "^9.0.1",
|
|
21
21
|
"zod": "^3.23.8",
|
|
22
|
-
"@moonbase.sh/storefront-api": "0.2.
|
|
22
|
+
"@moonbase.sh/storefront-api": "0.2.66"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"@types/uuid": "^9.0.8",
|