@moonbase.sh/vue 0.1.33 → 0.1.34
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 +41 -1
- package/dist/index.d.cts +6 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +41 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -65,6 +65,7 @@ var StorefrontContextImpl = class {
|
|
|
65
65
|
const cachedOrderJson = localStorage.getItem("moonbase_session");
|
|
66
66
|
if (cachedOrderJson) {
|
|
67
67
|
this.currentOrder = (0, import_vue.ref)(JSON.parse(cachedOrderJson));
|
|
68
|
+
const _1 = this.refreshOrder();
|
|
68
69
|
} else {
|
|
69
70
|
this.currentOrder = (0, import_vue.ref)({
|
|
70
71
|
id: (0, import_uuid.v4)(),
|
|
@@ -92,7 +93,7 @@ var StorefrontContextImpl = class {
|
|
|
92
93
|
}
|
|
93
94
|
install(app) {
|
|
94
95
|
app.provide(storefrontKey, this);
|
|
95
|
-
console.log("
|
|
96
|
+
console.log("Moonbase.sh storefront installed");
|
|
96
97
|
}
|
|
97
98
|
async updateUser() {
|
|
98
99
|
try {
|
|
@@ -130,6 +131,33 @@ var StorefrontContextImpl = class {
|
|
|
130
131
|
break;
|
|
131
132
|
}
|
|
132
133
|
}
|
|
134
|
+
async refreshOrder() {
|
|
135
|
+
try {
|
|
136
|
+
const latestOrder = await this.client.orders.get(this.currentOrder.value.id);
|
|
137
|
+
if (latestOrder) {
|
|
138
|
+
if (latestOrder.status !== import_api_client.OrderStatus.Open) {
|
|
139
|
+
this.resetOrder();
|
|
140
|
+
} else {
|
|
141
|
+
localStorage.setItem("moonbase_session", JSON.stringify(latestOrder));
|
|
142
|
+
this.currentOrder.value = latestOrder;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
} catch (err) {
|
|
146
|
+
if (err != null)
|
|
147
|
+
this.resetOrder();
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
resetOrder() {
|
|
151
|
+
var _a;
|
|
152
|
+
this.currentOrder.value = {
|
|
153
|
+
id: (0, import_uuid.v4)(),
|
|
154
|
+
currency: ((_a = this.storefront.value) == null ? void 0 : _a.suggestedCurrency) || "",
|
|
155
|
+
status: import_api_client.OrderStatus.Open,
|
|
156
|
+
items: [],
|
|
157
|
+
couponsApplied: []
|
|
158
|
+
};
|
|
159
|
+
localStorage.setItem("moonbase_session", JSON.stringify(this.currentOrder.value));
|
|
160
|
+
}
|
|
133
161
|
};
|
|
134
162
|
|
|
135
163
|
// src/index.ts
|
|
@@ -264,6 +292,18 @@ function useAuth() {
|
|
|
264
292
|
const _ = storefront.updateStorefront();
|
|
265
293
|
return user;
|
|
266
294
|
},
|
|
295
|
+
signUp: async (name, email, password, acceptedPrivacyPolicy, acceptedTermsAndConditions) => {
|
|
296
|
+
const user = await storefront.client.identity.signUp(
|
|
297
|
+
name,
|
|
298
|
+
email,
|
|
299
|
+
password,
|
|
300
|
+
acceptedPrivacyPolicy,
|
|
301
|
+
acceptedTermsAndConditions
|
|
302
|
+
);
|
|
303
|
+
storefront.currentUser.value = user;
|
|
304
|
+
const _ = storefront.updateStorefront();
|
|
305
|
+
return user;
|
|
306
|
+
},
|
|
267
307
|
signOut: () => {
|
|
268
308
|
storefront.client.tokenStore.setUser(null);
|
|
269
309
|
storefront.currentUser.value = null;
|
package/dist/index.d.cts
CHANGED
|
@@ -56,6 +56,12 @@ declare function useAuth(): {
|
|
|
56
56
|
name: string;
|
|
57
57
|
tenantId: string;
|
|
58
58
|
}>;
|
|
59
|
+
signUp: (name: string, email: string, password: string, acceptedPrivacyPolicy: boolean, acceptedTermsAndConditions: boolean) => Promise<{
|
|
60
|
+
id: string;
|
|
61
|
+
email: string;
|
|
62
|
+
name: string;
|
|
63
|
+
tenantId: string;
|
|
64
|
+
}>;
|
|
59
65
|
signOut: () => void;
|
|
60
66
|
update: (name: string, email: string, emailConfirmationToken?: string) => Promise<{
|
|
61
67
|
needsEmailConfirmationToken: boolean;
|
package/dist/index.d.ts
CHANGED
|
@@ -56,6 +56,12 @@ declare function useAuth(): {
|
|
|
56
56
|
name: string;
|
|
57
57
|
tenantId: string;
|
|
58
58
|
}>;
|
|
59
|
+
signUp: (name: string, email: string, password: string, acceptedPrivacyPolicy: boolean, acceptedTermsAndConditions: boolean) => Promise<{
|
|
60
|
+
id: string;
|
|
61
|
+
email: string;
|
|
62
|
+
name: string;
|
|
63
|
+
tenantId: string;
|
|
64
|
+
}>;
|
|
59
65
|
signOut: () => void;
|
|
60
66
|
update: (name: string, email: string, emailConfirmationToken?: string) => Promise<{
|
|
61
67
|
needsEmailConfirmationToken: boolean;
|
package/dist/index.js
CHANGED
|
@@ -33,6 +33,7 @@ var StorefrontContextImpl = class {
|
|
|
33
33
|
const cachedOrderJson = localStorage.getItem("moonbase_session");
|
|
34
34
|
if (cachedOrderJson) {
|
|
35
35
|
this.currentOrder = ref(JSON.parse(cachedOrderJson));
|
|
36
|
+
const _1 = this.refreshOrder();
|
|
36
37
|
} else {
|
|
37
38
|
this.currentOrder = ref({
|
|
38
39
|
id: uuidv4(),
|
|
@@ -60,7 +61,7 @@ var StorefrontContextImpl = class {
|
|
|
60
61
|
}
|
|
61
62
|
install(app) {
|
|
62
63
|
app.provide(storefrontKey, this);
|
|
63
|
-
console.log("
|
|
64
|
+
console.log("Moonbase.sh storefront installed");
|
|
64
65
|
}
|
|
65
66
|
async updateUser() {
|
|
66
67
|
try {
|
|
@@ -98,6 +99,33 @@ var StorefrontContextImpl = class {
|
|
|
98
99
|
break;
|
|
99
100
|
}
|
|
100
101
|
}
|
|
102
|
+
async refreshOrder() {
|
|
103
|
+
try {
|
|
104
|
+
const latestOrder = await this.client.orders.get(this.currentOrder.value.id);
|
|
105
|
+
if (latestOrder) {
|
|
106
|
+
if (latestOrder.status !== OrderStatus.Open) {
|
|
107
|
+
this.resetOrder();
|
|
108
|
+
} else {
|
|
109
|
+
localStorage.setItem("moonbase_session", JSON.stringify(latestOrder));
|
|
110
|
+
this.currentOrder.value = latestOrder;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
} catch (err) {
|
|
114
|
+
if (err != null)
|
|
115
|
+
this.resetOrder();
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
resetOrder() {
|
|
119
|
+
var _a;
|
|
120
|
+
this.currentOrder.value = {
|
|
121
|
+
id: uuidv4(),
|
|
122
|
+
currency: ((_a = this.storefront.value) == null ? void 0 : _a.suggestedCurrency) || "",
|
|
123
|
+
status: OrderStatus.Open,
|
|
124
|
+
items: [],
|
|
125
|
+
couponsApplied: []
|
|
126
|
+
};
|
|
127
|
+
localStorage.setItem("moonbase_session", JSON.stringify(this.currentOrder.value));
|
|
128
|
+
}
|
|
101
129
|
};
|
|
102
130
|
|
|
103
131
|
// src/index.ts
|
|
@@ -232,6 +260,18 @@ function useAuth() {
|
|
|
232
260
|
const _ = storefront.updateStorefront();
|
|
233
261
|
return user;
|
|
234
262
|
},
|
|
263
|
+
signUp: async (name, email, password, acceptedPrivacyPolicy, acceptedTermsAndConditions) => {
|
|
264
|
+
const user = await storefront.client.identity.signUp(
|
|
265
|
+
name,
|
|
266
|
+
email,
|
|
267
|
+
password,
|
|
268
|
+
acceptedPrivacyPolicy,
|
|
269
|
+
acceptedTermsAndConditions
|
|
270
|
+
);
|
|
271
|
+
storefront.currentUser.value = user;
|
|
272
|
+
const _ = storefront.updateStorefront();
|
|
273
|
+
return user;
|
|
274
|
+
},
|
|
235
275
|
signOut: () => {
|
|
236
276
|
storefront.client.tokenStore.setUser(null);
|
|
237
277
|
storefront.currentUser.value = null;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moonbase.sh/vue",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.34",
|
|
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",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"@vue/devtools-api": "^6.5.0",
|
|
17
17
|
"uuid": "^9.0.0",
|
|
18
|
-
"@moonbase.sh/api-client": "0.1.
|
|
18
|
+
"@moonbase.sh/api-client": "0.1.34"
|
|
19
19
|
},
|
|
20
20
|
"peerDependencies": {
|
|
21
21
|
"vue": "^3.2.0"
|