@moonbase.sh/vue 0.2.115 → 0.2.117
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 +177 -176
- package/dist/index.d.cts +251 -251
- package/dist/index.d.ts +251 -251
- package/dist/index.js +168 -162
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -139,6 +139,7 @@ var _StorefrontContextImpl = class _StorefrontContextImpl {
|
|
|
139
139
|
this.stateFactory = stateFactory;
|
|
140
140
|
this.currentUser = (0, import_vue.ref)(null);
|
|
141
141
|
this.loadedUser = (0, import_vue.ref)(false);
|
|
142
|
+
this.refreshOrderAbortController = new AbortController();
|
|
142
143
|
this.debouncedPushOrderContent = debounce((order) => this.client.orders.pushContent(order, void 0, this.hasUtm ? this.utm.value : void 0), 500);
|
|
143
144
|
var _a;
|
|
144
145
|
if (typeof window === "undefined") {
|
|
@@ -287,6 +288,8 @@ var _StorefrontContextImpl = class _StorefrontContextImpl {
|
|
|
287
288
|
async pushOrderContent() {
|
|
288
289
|
if (typeof window !== "undefined")
|
|
289
290
|
localStorage.setItem(_StorefrontContextImpl.sessionKey, JSON.stringify(this.currentOrder.value));
|
|
291
|
+
this.refreshOrderAbortController.abort();
|
|
292
|
+
this.refreshOrderAbortController = new AbortController();
|
|
290
293
|
this.debouncedPushOrderContent(this.currentOrder.value);
|
|
291
294
|
}
|
|
292
295
|
handleStorageUpdate(event) {
|
|
@@ -315,7 +318,7 @@ var _StorefrontContextImpl = class _StorefrontContextImpl {
|
|
|
315
318
|
}
|
|
316
319
|
async refreshOrder() {
|
|
317
320
|
try {
|
|
318
|
-
const latestOrder = await this.client.orders.get(this.currentOrder.value.id);
|
|
321
|
+
const latestOrder = await this.client.orders.get(this.currentOrder.value.id, this.refreshOrderAbortController.signal);
|
|
319
322
|
if (latestOrder) {
|
|
320
323
|
if (latestOrder.status !== import_storefront_api2.OrderStatus.Open) {
|
|
321
324
|
this.resetOrder();
|
|
@@ -326,7 +329,7 @@ var _StorefrontContextImpl = class _StorefrontContextImpl {
|
|
|
326
329
|
}
|
|
327
330
|
}
|
|
328
331
|
} catch (err) {
|
|
329
|
-
if (err
|
|
332
|
+
if (err instanceof import_storefront_api2.NotAuthorizedError)
|
|
330
333
|
this.resetOrder();
|
|
331
334
|
}
|
|
332
335
|
}
|
|
@@ -359,97 +362,19 @@ _StorefrontContextImpl.storefrontKey = "moonbase_storefront";
|
|
|
359
362
|
_StorefrontContextImpl.utmKey = "moonbase_utm";
|
|
360
363
|
var StorefrontContextImpl = _StorefrontContextImpl;
|
|
361
364
|
|
|
362
|
-
// src/index.ts
|
|
363
|
-
__reExport(src_exports, require("@moonbase.sh/storefront-api"), module.exports);
|
|
364
|
-
|
|
365
|
-
// src/composables/useBundle.ts
|
|
366
|
-
var import_vue2 = require("vue");
|
|
367
|
-
function useBundle(bundleId, context) {
|
|
368
|
-
const storefront = context != null ? context : (0, import_vue2.inject)(storefrontKey);
|
|
369
|
-
if (!storefront)
|
|
370
|
-
throw new Error("No storefront configured");
|
|
371
|
-
return (0, import_vue2.computed)(() => storefront.storefront.value.bundles.find((b) => b.id === bundleId) || null);
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
// src/composables/useBundles.ts
|
|
375
|
-
var import_vue3 = require("vue");
|
|
376
|
-
function useBundles(context) {
|
|
377
|
-
const storefront = context != null ? context : (0, import_vue3.inject)(storefrontKey);
|
|
378
|
-
if (!storefront)
|
|
379
|
-
throw new Error("No storefront configured");
|
|
380
|
-
return (0, import_vue3.computed)(() => storefront.storefront.value.bundles);
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
// src/composables/useProduct.ts
|
|
384
|
-
var import_vue4 = require("vue");
|
|
385
|
-
function useProduct(productId, context) {
|
|
386
|
-
const storefront = context != null ? context : (0, import_vue4.inject)(storefrontKey);
|
|
387
|
-
if (!storefront)
|
|
388
|
-
throw new Error("No storefront configured");
|
|
389
|
-
return (0, import_vue4.computed)(() => storefront.storefront.value.products.find((p) => p.id === productId) || null);
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
// src/composables/useProducts.ts
|
|
393
|
-
var import_vue5 = require("vue");
|
|
394
|
-
function useProducts(context) {
|
|
395
|
-
const storefront = context != null ? context : (0, import_vue5.inject)(storefrontKey);
|
|
396
|
-
if (!storefront)
|
|
397
|
-
throw new Error("No storefront configured");
|
|
398
|
-
return (0, import_vue5.computed)(() => storefront.storefront.value.products);
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
// src/composables/useInventory.ts
|
|
402
|
-
var import_vue6 = require("vue");
|
|
403
|
-
function useInventory(context) {
|
|
404
|
-
const storefront = context != null ? context : (0, import_vue6.inject)(storefrontKey);
|
|
405
|
-
if (!storefront)
|
|
406
|
-
throw new Error("No storefront configured");
|
|
407
|
-
return {
|
|
408
|
-
getLicenses: async (nextUrl) => {
|
|
409
|
-
return storefront.client.inventory.licenses.get(nextUrl);
|
|
410
|
-
},
|
|
411
|
-
getLicenseActivations: async (licenseId, nextUrl) => {
|
|
412
|
-
return storefront.client.inventory.licenses.getActivations(licenseId, nextUrl);
|
|
413
|
-
},
|
|
414
|
-
getProduct: async (productId, version) => {
|
|
415
|
-
return storefront.client.inventory.products.get(productId, version);
|
|
416
|
-
},
|
|
417
|
-
getProducts: async (nextUrl) => {
|
|
418
|
-
return storefront.client.inventory.products.getOwned(nextUrl);
|
|
419
|
-
},
|
|
420
|
-
getProductLicenses: async (productId, nextUrl) => {
|
|
421
|
-
return storefront.client.inventory.products.getLicenses(productId, nextUrl);
|
|
422
|
-
},
|
|
423
|
-
getProductActivations: async (productId, nextUrl) => {
|
|
424
|
-
return storefront.client.inventory.products.getActivations(productId, nextUrl);
|
|
425
|
-
},
|
|
426
|
-
revokeActivation: async (activation) => {
|
|
427
|
-
return storefront.client.inventory.licenses.revokeActivation(activation.licenseId, activation.id);
|
|
428
|
-
},
|
|
429
|
-
activateProduct: async (deviceToken, activationMethod) => {
|
|
430
|
-
return storefront.client.inventory.activation.activate(deviceToken, activationMethod);
|
|
431
|
-
},
|
|
432
|
-
downloadProduct: async (download) => {
|
|
433
|
-
if (!download.path)
|
|
434
|
-
throw new Error("Product is not downloadable");
|
|
435
|
-
window.location.href = await storefront.client.inventory.products.getDownloadUrl(download.path);
|
|
436
|
-
}
|
|
437
|
-
};
|
|
438
|
-
}
|
|
439
|
-
|
|
440
365
|
// src/composables/useActivationRequest.ts
|
|
441
366
|
var import_storefront_api3 = require("@moonbase.sh/storefront-api");
|
|
442
|
-
var
|
|
367
|
+
var import_vue2 = require("vue");
|
|
443
368
|
function useActivationRequest(token, context) {
|
|
444
|
-
const storefront = context != null ? context : (0,
|
|
369
|
+
const storefront = context != null ? context : (0, import_vue2.inject)(storefrontKey);
|
|
445
370
|
if (!storefront)
|
|
446
371
|
throw new Error("No storefront configured");
|
|
447
|
-
const activationRequest = storefront.stateFactory(`activation-request-${(0,
|
|
448
|
-
const error = storefront.stateFactory(`activation-request-${(0,
|
|
449
|
-
const loading = storefront.stateFactory(`activation-request-${(0,
|
|
450
|
-
const fulfilling = storefront.stateFactory(`activation-request-${(0,
|
|
451
|
-
const completing = storefront.stateFactory(`activation-request-${(0,
|
|
452
|
-
const completionTimeout = storefront.stateFactory(`activation-request-${(0,
|
|
372
|
+
const activationRequest = storefront.stateFactory(`activation-request-${(0, import_vue2.toValue)(token)}`, null);
|
|
373
|
+
const error = storefront.stateFactory(`activation-request-${(0, import_vue2.toValue)(token)}-error`, null);
|
|
374
|
+
const loading = storefront.stateFactory(`activation-request-${(0, import_vue2.toValue)(token)}-loading`, true);
|
|
375
|
+
const fulfilling = storefront.stateFactory(`activation-request-${(0, import_vue2.toValue)(token)}-fulfilling`, false);
|
|
376
|
+
const completing = storefront.stateFactory(`activation-request-${(0, import_vue2.toValue)(token)}-completing`, false);
|
|
377
|
+
const completionTimeout = storefront.stateFactory(`activation-request-${(0, import_vue2.toValue)(token)}-completion-timeout`, null);
|
|
453
378
|
const checkCompletion = async () => {
|
|
454
379
|
if (!activationRequest.value)
|
|
455
380
|
return;
|
|
@@ -461,7 +386,7 @@ function useActivationRequest(token, context) {
|
|
|
461
386
|
completionTimeout.value = setTimeout(checkCompletion, 1500);
|
|
462
387
|
}
|
|
463
388
|
};
|
|
464
|
-
(0,
|
|
389
|
+
(0, import_vue2.watch)(() => (0, import_vue2.toValue)(token), async (newRequestId) => {
|
|
465
390
|
try {
|
|
466
391
|
if (newRequestId && newRequestId.length > 0) {
|
|
467
392
|
activationRequest.value = await storefront.client.activationRequests.get(newRequestId);
|
|
@@ -478,13 +403,13 @@ function useActivationRequest(token, context) {
|
|
|
478
403
|
loading.value = false;
|
|
479
404
|
}
|
|
480
405
|
}, { immediate: true });
|
|
481
|
-
(0,
|
|
406
|
+
(0, import_vue2.onBeforeUnmount)(() => {
|
|
482
407
|
if (completionTimeout.value)
|
|
483
408
|
clearTimeout(completionTimeout.value);
|
|
484
409
|
});
|
|
485
|
-
(0,
|
|
410
|
+
(0, import_vue2.watch)(storefront.currentUser, async () => {
|
|
486
411
|
var _a, _b;
|
|
487
|
-
const requestId = (0,
|
|
412
|
+
const requestId = (0, import_vue2.toValue)(token);
|
|
488
413
|
if (!requestId || ((_b = (_a = activationRequest.value) == null ? void 0 : _a.licenseEligibility) == null ? void 0 : _b.eligible))
|
|
489
414
|
return;
|
|
490
415
|
loading.value = true;
|
|
@@ -505,7 +430,7 @@ function useActivationRequest(token, context) {
|
|
|
505
430
|
fulfilling,
|
|
506
431
|
completing,
|
|
507
432
|
error,
|
|
508
|
-
isInstalled: (0,
|
|
433
|
+
isInstalled: (0, import_vue2.computed)(() => {
|
|
509
434
|
var _a;
|
|
510
435
|
return activationRequest && ((_a = activationRequest.value) == null ? void 0 : _a.status) === import_storefront_api3.ActivationRequestStatus.Completed;
|
|
511
436
|
}),
|
|
@@ -531,44 +456,99 @@ function useActivationRequest(token, context) {
|
|
|
531
456
|
};
|
|
532
457
|
}
|
|
533
458
|
|
|
534
|
-
// src/composables/
|
|
535
|
-
var
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
const storefront = context != null ? context : (0, import_vue8.inject)(storefrontKey);
|
|
459
|
+
// src/composables/useAuth.ts
|
|
460
|
+
var import_vue3 = require("vue");
|
|
461
|
+
function useAuth(context) {
|
|
462
|
+
const storefront = context != null ? context : (0, import_vue3.inject)(storefrontKey);
|
|
539
463
|
if (!storefront)
|
|
540
464
|
throw new Error("No storefront configured");
|
|
541
465
|
return {
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
466
|
+
user: storefront.currentUser,
|
|
467
|
+
loaded: storefront.loadedUser,
|
|
468
|
+
loadedPromise: storefront.loadedUserPromise,
|
|
469
|
+
signIn: async (email, password) => {
|
|
470
|
+
const user = await storefront.client.identity.signIn(email, password);
|
|
471
|
+
storefront.currentUser.value = user;
|
|
472
|
+
const _ = storefront.updateStorefront();
|
|
473
|
+
return user;
|
|
550
474
|
},
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
475
|
+
signUp: async (name, email, password, address, acceptedPrivacyPolicy, acceptedTermsAndConditions, communicationOptIn) => {
|
|
476
|
+
const user = await storefront.client.identity.signUp(
|
|
477
|
+
name,
|
|
478
|
+
email,
|
|
479
|
+
password,
|
|
480
|
+
address,
|
|
481
|
+
acceptedPrivacyPolicy,
|
|
482
|
+
acceptedTermsAndConditions,
|
|
483
|
+
communicationOptIn
|
|
484
|
+
);
|
|
485
|
+
storefront.currentUser.value = user;
|
|
486
|
+
const _ = storefront.updateStorefront();
|
|
487
|
+
return user;
|
|
488
|
+
},
|
|
489
|
+
signOut: async () => {
|
|
490
|
+
storefront.client.tokenStore.setUser(null);
|
|
491
|
+
await Promise.all([storefront.updateStorefront(), storefront.surrenderOrder()]);
|
|
492
|
+
storefront.currentUser.value = null;
|
|
493
|
+
},
|
|
494
|
+
update: async (name, email, emailConfirmationToken, communicationPreferences) => {
|
|
495
|
+
const result = await storefront.client.identity.update(name, email, emailConfirmationToken, communicationPreferences);
|
|
496
|
+
if (storefront.currentUser.value) {
|
|
497
|
+
storefront.currentUser.value.name = name;
|
|
498
|
+
if (communicationPreferences)
|
|
499
|
+
storefront.currentUser.value.communicationPreferences = communicationPreferences;
|
|
558
500
|
}
|
|
501
|
+
return result;
|
|
502
|
+
},
|
|
503
|
+
setPassword: async (currentPassword, newPassword) => {
|
|
504
|
+
await storefront.client.identity.setPassword(currentPassword, newPassword);
|
|
505
|
+
},
|
|
506
|
+
forgotPassword: async (email) => {
|
|
507
|
+
await storefront.client.identity.forgotPassword(email);
|
|
508
|
+
},
|
|
509
|
+
resetPassword: async (email, newPassword, code) => {
|
|
510
|
+
await storefront.client.identity.resetPassword(email, newPassword, code);
|
|
511
|
+
},
|
|
512
|
+
confirmAccount: async (email, code) => {
|
|
513
|
+
return await storefront.client.identity.confirmAccount(email, code);
|
|
514
|
+
},
|
|
515
|
+
confirmEmail: async (email, code) => {
|
|
516
|
+
return await storefront.client.identity.confirmEmail(email, code);
|
|
517
|
+
},
|
|
518
|
+
confirmEmailChange: async (email, code) => {
|
|
519
|
+
await storefront.client.identity.confirmEmailChange(email, code);
|
|
520
|
+
return await storefront.updateUser();
|
|
559
521
|
}
|
|
560
522
|
};
|
|
561
523
|
}
|
|
562
524
|
|
|
525
|
+
// src/composables/useBundle.ts
|
|
526
|
+
var import_vue4 = require("vue");
|
|
527
|
+
function useBundle(bundleId, context) {
|
|
528
|
+
const storefront = context != null ? context : (0, import_vue4.inject)(storefrontKey);
|
|
529
|
+
if (!storefront)
|
|
530
|
+
throw new Error("No storefront configured");
|
|
531
|
+
return (0, import_vue4.computed)(() => storefront.storefront.value.bundles.find((b) => b.id === bundleId) || null);
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
// src/composables/useBundles.ts
|
|
535
|
+
var import_vue5 = require("vue");
|
|
536
|
+
function useBundles(context) {
|
|
537
|
+
const storefront = context != null ? context : (0, import_vue5.inject)(storefrontKey);
|
|
538
|
+
if (!storefront)
|
|
539
|
+
throw new Error("No storefront configured");
|
|
540
|
+
return (0, import_vue5.computed)(() => storefront.storefront.value.bundles);
|
|
541
|
+
}
|
|
542
|
+
|
|
563
543
|
// src/composables/useCart.ts
|
|
564
|
-
var
|
|
565
|
-
var
|
|
544
|
+
var import_storefront_api4 = require("@moonbase.sh/storefront-api");
|
|
545
|
+
var import_vue6 = require("vue");
|
|
566
546
|
function useCart(context) {
|
|
567
|
-
const storefront = context != null ? context : (0,
|
|
547
|
+
const storefront = context != null ? context : (0, import_vue6.inject)(storefrontKey);
|
|
568
548
|
if (!storefront)
|
|
569
549
|
throw new Error("No storefront configured");
|
|
570
550
|
return {
|
|
571
|
-
items: (0,
|
|
551
|
+
items: (0, import_vue6.computed)(() => storefront.currentOrder.value.items.map((item) => {
|
|
572
552
|
var _a, _b;
|
|
573
553
|
if (item.type === "Product") {
|
|
574
554
|
const product = storefront.storefront.value.products.find((p) => p.id === item.productId);
|
|
@@ -594,8 +574,8 @@ function useCart(context) {
|
|
|
594
574
|
};
|
|
595
575
|
}
|
|
596
576
|
})),
|
|
597
|
-
currency: (0,
|
|
598
|
-
total: (0,
|
|
577
|
+
currency: (0, import_vue6.computed)(() => storefront.currentOrder.value.currency || storefront.storefront.value.suggestedCurrency),
|
|
578
|
+
total: (0, import_vue6.computed)(() => {
|
|
599
579
|
const currency = storefront.currentOrder.value.currency || storefront.storefront.value.suggestedCurrency;
|
|
600
580
|
const total = storefront.currentOrder.value.items.reduce((agg, item) => {
|
|
601
581
|
var _a, _b, _c, _d, _e, _f;
|
|
@@ -616,7 +596,7 @@ function useCart(context) {
|
|
|
616
596
|
return { amount: total, currency };
|
|
617
597
|
}),
|
|
618
598
|
addToCart: (item, variation) => {
|
|
619
|
-
item = (0,
|
|
599
|
+
item = (0, import_vue6.unref)(item);
|
|
620
600
|
variation != null ? variation : variation = item.defaultVariation;
|
|
621
601
|
if (!variation)
|
|
622
602
|
throw new Error("Added item does not have a default variation, and none have been specified");
|
|
@@ -650,7 +630,7 @@ function useCart(context) {
|
|
|
650
630
|
};
|
|
651
631
|
storefront.currentOrder.value.items.push(lineItem);
|
|
652
632
|
} else {
|
|
653
|
-
throw new
|
|
633
|
+
throw new import_storefront_api4.MoonbaseError("Invalid input", `Could not handle item of type '${item.type}'`);
|
|
654
634
|
}
|
|
655
635
|
} else {
|
|
656
636
|
lineItem.quantity += 1;
|
|
@@ -700,80 +680,71 @@ function useCart(context) {
|
|
|
700
680
|
};
|
|
701
681
|
}
|
|
702
682
|
|
|
703
|
-
// src/composables/
|
|
704
|
-
var
|
|
705
|
-
function
|
|
706
|
-
const storefront = context != null ? context : (0,
|
|
683
|
+
// src/composables/useInventory.ts
|
|
684
|
+
var import_vue7 = require("vue");
|
|
685
|
+
function useInventory(context) {
|
|
686
|
+
const storefront = context != null ? context : (0, import_vue7.inject)(storefrontKey);
|
|
707
687
|
if (!storefront)
|
|
708
688
|
throw new Error("No storefront configured");
|
|
709
689
|
return {
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
loadedPromise: storefront.loadedUserPromise,
|
|
713
|
-
signIn: async (email, password) => {
|
|
714
|
-
const user = await storefront.client.identity.signIn(email, password);
|
|
715
|
-
storefront.currentUser.value = user;
|
|
716
|
-
const _ = storefront.updateStorefront();
|
|
717
|
-
return user;
|
|
718
|
-
},
|
|
719
|
-
signUp: async (name, email, password, address, acceptedPrivacyPolicy, acceptedTermsAndConditions, communicationOptIn) => {
|
|
720
|
-
const user = await storefront.client.identity.signUp(
|
|
721
|
-
name,
|
|
722
|
-
email,
|
|
723
|
-
password,
|
|
724
|
-
address,
|
|
725
|
-
acceptedPrivacyPolicy,
|
|
726
|
-
acceptedTermsAndConditions,
|
|
727
|
-
communicationOptIn
|
|
728
|
-
);
|
|
729
|
-
storefront.currentUser.value = user;
|
|
730
|
-
const _ = storefront.updateStorefront();
|
|
731
|
-
return user;
|
|
690
|
+
getLicenses: async (nextUrl) => {
|
|
691
|
+
return storefront.client.inventory.licenses.get(nextUrl);
|
|
732
692
|
},
|
|
733
|
-
|
|
734
|
-
storefront.client.
|
|
735
|
-
await Promise.all([storefront.updateStorefront(), storefront.surrenderOrder()]);
|
|
736
|
-
storefront.currentUser.value = null;
|
|
693
|
+
getLicenseActivations: async (licenseId, nextUrl) => {
|
|
694
|
+
return storefront.client.inventory.licenses.getActivations(licenseId, nextUrl);
|
|
737
695
|
},
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
if (storefront.currentUser.value) {
|
|
741
|
-
storefront.currentUser.value.name = name;
|
|
742
|
-
if (communicationPreferences)
|
|
743
|
-
storefront.currentUser.value.communicationPreferences = communicationPreferences;
|
|
744
|
-
}
|
|
745
|
-
return result;
|
|
696
|
+
getProduct: async (productId, version) => {
|
|
697
|
+
return storefront.client.inventory.products.get(productId, version);
|
|
746
698
|
},
|
|
747
|
-
|
|
748
|
-
|
|
699
|
+
getProducts: async (nextUrl) => {
|
|
700
|
+
return storefront.client.inventory.products.getOwned(nextUrl);
|
|
749
701
|
},
|
|
750
|
-
|
|
751
|
-
|
|
702
|
+
getProductLicenses: async (productId, nextUrl) => {
|
|
703
|
+
return storefront.client.inventory.products.getLicenses(productId, nextUrl);
|
|
752
704
|
},
|
|
753
|
-
|
|
754
|
-
|
|
705
|
+
getProductActivations: async (productId, nextUrl) => {
|
|
706
|
+
return storefront.client.inventory.products.getActivations(productId, nextUrl);
|
|
755
707
|
},
|
|
756
|
-
|
|
757
|
-
return
|
|
708
|
+
revokeActivation: async (activation) => {
|
|
709
|
+
return storefront.client.inventory.licenses.revokeActivation(activation.licenseId, activation.id);
|
|
758
710
|
},
|
|
759
|
-
|
|
760
|
-
return
|
|
711
|
+
activateProduct: async (deviceToken, activationMethod) => {
|
|
712
|
+
return storefront.client.inventory.activation.activate(deviceToken, activationMethod);
|
|
761
713
|
},
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
714
|
+
downloadProduct: async (download) => {
|
|
715
|
+
if (!download.path)
|
|
716
|
+
throw new Error("Product is not downloadable");
|
|
717
|
+
window.location.href = await storefront.client.inventory.products.getDownloadUrl(download.path);
|
|
765
718
|
}
|
|
766
719
|
};
|
|
767
720
|
}
|
|
768
721
|
|
|
722
|
+
// src/composables/useProduct.ts
|
|
723
|
+
var import_vue8 = require("vue");
|
|
724
|
+
function useProduct(productId, context) {
|
|
725
|
+
const storefront = context != null ? context : (0, import_vue8.inject)(storefrontKey);
|
|
726
|
+
if (!storefront)
|
|
727
|
+
throw new Error("No storefront configured");
|
|
728
|
+
return (0, import_vue8.computed)(() => storefront.storefront.value.products.find((p) => p.id === productId) || null);
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
// src/composables/useProducts.ts
|
|
732
|
+
var import_vue9 = require("vue");
|
|
733
|
+
function useProducts(context) {
|
|
734
|
+
const storefront = context != null ? context : (0, import_vue9.inject)(storefrontKey);
|
|
735
|
+
if (!storefront)
|
|
736
|
+
throw new Error("No storefront configured");
|
|
737
|
+
return (0, import_vue9.computed)(() => storefront.storefront.value.products);
|
|
738
|
+
}
|
|
739
|
+
|
|
769
740
|
// src/composables/useVendor.ts
|
|
770
|
-
var
|
|
741
|
+
var import_vue10 = require("vue");
|
|
771
742
|
function useVendor(context) {
|
|
772
|
-
const storefront = context != null ? context : (0,
|
|
743
|
+
const storefront = context != null ? context : (0, import_vue10.inject)(storefrontKey);
|
|
773
744
|
if (!storefront)
|
|
774
745
|
throw new Error("No storefront configured");
|
|
775
|
-
const vendor = (0,
|
|
776
|
-
const loading = (0,
|
|
746
|
+
const vendor = (0, import_vue10.ref)(null);
|
|
747
|
+
const loading = (0, import_vue10.ref)(true);
|
|
777
748
|
storefront.client.vendor.get().then((v) => {
|
|
778
749
|
vendor.value = v;
|
|
779
750
|
loading.value = false;
|
|
@@ -784,7 +755,37 @@ function useVendor(context) {
|
|
|
784
755
|
};
|
|
785
756
|
}
|
|
786
757
|
|
|
758
|
+
// src/composables/useVoucher.ts
|
|
759
|
+
var import_storefront_api5 = require("@moonbase.sh/storefront-api");
|
|
760
|
+
var import_vue11 = require("vue");
|
|
761
|
+
function useVoucher(context) {
|
|
762
|
+
const storefront = context != null ? context : (0, import_vue11.inject)(storefrontKey);
|
|
763
|
+
if (!storefront)
|
|
764
|
+
throw new Error("No storefront configured");
|
|
765
|
+
return {
|
|
766
|
+
peek: async (code) => {
|
|
767
|
+
try {
|
|
768
|
+
return await storefront.client.vouchers.peek(code);
|
|
769
|
+
} catch (e) {
|
|
770
|
+
if (e instanceof import_storefront_api5.NotFoundError)
|
|
771
|
+
throw new Error("Voucher code invalid");
|
|
772
|
+
throw e;
|
|
773
|
+
}
|
|
774
|
+
},
|
|
775
|
+
redeem: async (code) => {
|
|
776
|
+
try {
|
|
777
|
+
return await storefront.client.vouchers.redeem(code);
|
|
778
|
+
} catch (e) {
|
|
779
|
+
if (e instanceof import_storefront_api5.NotFoundError)
|
|
780
|
+
throw new Error("Voucher code invalid");
|
|
781
|
+
throw e;
|
|
782
|
+
}
|
|
783
|
+
}
|
|
784
|
+
};
|
|
785
|
+
}
|
|
786
|
+
|
|
787
787
|
// src/index.ts
|
|
788
|
+
__reExport(src_exports, require("@moonbase.sh/storefront-api"), module.exports);
|
|
788
789
|
function createStorefront(endpoint, stateFactory, config) {
|
|
789
790
|
const configuration = {
|
|
790
791
|
...config != null ? config : {},
|