@moonbase.sh/vue 0.1.106 → 0.1.107

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 CHANGED
@@ -124,6 +124,14 @@ var _StorefrontContextImpl = class _StorefrontContextImpl {
124
124
  const _2 = this.updateStorefront();
125
125
  const _3 = this.updateUser();
126
126
  }
127
+ get loadedUserPromise() {
128
+ return new Promise((resolve) => {
129
+ (0, import_vue.watch)(this.loadedUser, (isLoaded) => {
130
+ if (isLoaded)
131
+ resolve();
132
+ });
133
+ });
134
+ }
127
135
  install(app) {
128
136
  app.provide(storefrontKey, this);
129
137
  console.log("Moonbase.sh storefront installed, learn more at https://moonbase.sh/docs");
@@ -490,6 +498,7 @@ function useAuth() {
490
498
  return {
491
499
  user: storefront.currentUser,
492
500
  loaded: storefront.loadedUser,
501
+ loadedPromise: storefront.loadedUserPromise,
493
502
  signIn: async (email, password) => {
494
503
  const user = await storefront.client.identity.signIn(email, password);
495
504
  storefront.currentUser.value = user;
package/dist/index.d.cts CHANGED
@@ -14,6 +14,7 @@ interface StorefrontContext extends Pick<Plugin, keyof Plugin> {
14
14
  currentOrder: Ref<Order>;
15
15
  currentUser: Ref<User | null>;
16
16
  loadedUser: Ref<boolean>;
17
+ loadedUserPromise: Promise<void>;
17
18
  client: MoonbaseClient;
18
19
  updateStorefront(): Promise<void>;
19
20
  pushOrderContent(): Promise<void>;
@@ -925,6 +926,7 @@ declare function useAuth(): {
925
926
  } | undefined;
926
927
  } | null>;
927
928
  loaded: vue.Ref<boolean>;
929
+ loadedPromise: Promise<void>;
928
930
  signIn: (email: string, password: string) => Promise<{
929
931
  id: string;
930
932
  email: string;
package/dist/index.d.ts CHANGED
@@ -14,6 +14,7 @@ interface StorefrontContext extends Pick<Plugin, keyof Plugin> {
14
14
  currentOrder: Ref<Order>;
15
15
  currentUser: Ref<User | null>;
16
16
  loadedUser: Ref<boolean>;
17
+ loadedUserPromise: Promise<void>;
17
18
  client: MoonbaseClient;
18
19
  updateStorefront(): Promise<void>;
19
20
  pushOrderContent(): Promise<void>;
@@ -925,6 +926,7 @@ declare function useAuth(): {
925
926
  } | undefined;
926
927
  } | null>;
927
928
  loaded: vue.Ref<boolean>;
929
+ loadedPromise: Promise<void>;
928
930
  signIn: (email: string, password: string) => Promise<{
929
931
  id: string;
930
932
  email: string;
package/dist/index.js CHANGED
@@ -4,7 +4,7 @@ import { ref as ref2 } from "vue";
4
4
 
5
5
  // src/context.ts
6
6
  import { v4 as uuidv4 } from "uuid";
7
- import { computed, ref } from "vue";
7
+ import { computed, ref, watch } from "vue";
8
8
  import { NotAuthenticatedError, OrderStatus } from "@moonbase.sh/storefront-api";
9
9
 
10
10
  // src/symbols.ts
@@ -89,6 +89,14 @@ var _StorefrontContextImpl = class _StorefrontContextImpl {
89
89
  const _2 = this.updateStorefront();
90
90
  const _3 = this.updateUser();
91
91
  }
92
+ get loadedUserPromise() {
93
+ return new Promise((resolve) => {
94
+ watch(this.loadedUser, (isLoaded) => {
95
+ if (isLoaded)
96
+ resolve();
97
+ });
98
+ });
99
+ }
92
100
  install(app) {
93
101
  app.provide(storefrontKey, this);
94
102
  console.log("Moonbase.sh storefront installed, learn more at https://moonbase.sh/docs");
@@ -243,7 +251,7 @@ function useInventory() {
243
251
 
244
252
  // src/composables/useActivationRequest.ts
245
253
  import { ActivationRequestStatus } from "@moonbase.sh/storefront-api";
246
- import { computed as computed6, inject as inject6, onBeforeUnmount, watch } from "vue";
254
+ import { computed as computed6, inject as inject6, onBeforeUnmount, watch as watch2 } from "vue";
247
255
  function useActivationRequest(requestId) {
248
256
  const storefront = inject6(storefrontKey);
249
257
  if (!storefront)
@@ -263,7 +271,7 @@ function useActivationRequest(requestId) {
263
271
  if (completionTimeout.value)
264
272
  clearTimeout(completionTimeout.value);
265
273
  });
266
- watch(storefront.currentUser, async () => {
274
+ watch2(storefront.currentUser, async () => {
267
275
  loading.value = true;
268
276
  try {
269
277
  activationRequest.value = await storefront.client.activationRequests.get(requestId);
@@ -455,6 +463,7 @@ function useAuth() {
455
463
  return {
456
464
  user: storefront.currentUser,
457
465
  loaded: storefront.loadedUser,
466
+ loadedPromise: storefront.loadedUserPromise,
458
467
  signIn: async (email, password) => {
459
468
  const user = await storefront.client.identity.signIn(email, password);
460
469
  storefront.currentUser.value = user;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@moonbase.sh/vue",
3
3
  "type": "module",
4
- "version": "0.1.106",
4
+ "version": "0.1.107",
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",
@@ -18,7 +18,7 @@
18
18
  "dependencies": {
19
19
  "@vue/devtools-api": "^6.5.1",
20
20
  "uuid": "^9.0.1",
21
- "@moonbase.sh/storefront-api": "0.1.106"
21
+ "@moonbase.sh/storefront-api": "0.1.107"
22
22
  },
23
23
  "devDependencies": {
24
24
  "@types/uuid": "^9.0.7",