@salla.sa/twilight 2.0.291 → 2.0.293
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/@salla.sa/twilight.min.js +2 -2
- package/dist/@salla.sa/twilight.min.js.map +1 -1
- package/dist/cjs/index.js +2 -2
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +2 -2
- package/dist/esm/index.js.map +1 -1
- package/package.json +1 -1
- package/types/actions.d.ts +2 -2
- package/types/api/product/response.d.ts +11 -0
- package/types/event/index.d.ts +1 -1
- package/types/event/product.d.ts +4 -1
- package/watcher.js +39 -5
- package/types/.DS_Store +0 -0
- package/types/api/.DS_Store +0 -0
package/package.json
CHANGED
package/types/actions.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AuthApi, CartApi, CommentApi, CurrencyApi, DocumentApi, RatingApi, GiftApi, OrderApi,
|
|
3
|
-
ProductApi, ProfileApi, TwilightApi, WishlistApi, LoyaltyApi
|
|
3
|
+
ProductApi, ProfileApi, TwilightApi, WishlistApi, LoyaltyApi,
|
|
4
4
|
} from "./api";
|
|
5
5
|
import {
|
|
6
6
|
AuthEvent, CartEvent, CommentEvent, CurrencyEvent, DocumentEvent, RatingEvent, GiftEvent,
|
|
7
|
-
InfiniteScrollEvent, OrderEvent, ProductEvent, ProfileEvent, TwilightEvent, WishlistEvent, LoyaltyEvent
|
|
7
|
+
InfiniteScrollEvent, OrderEvent, ProductEvent, ProfileEvent, TwilightEvent, WishlistEvent, LoyaltyEvent,
|
|
8
8
|
} from "./event";
|
|
9
9
|
|
|
10
10
|
export default interface SallaActions {
|
|
@@ -6,6 +6,10 @@ type paymentMethod = {
|
|
|
6
6
|
slug: 'bank';
|
|
7
7
|
name: 'BankTransfer';
|
|
8
8
|
};
|
|
9
|
+
export interface SizeGuide {
|
|
10
|
+
name: string;
|
|
11
|
+
description: string;
|
|
12
|
+
}
|
|
9
13
|
export interface Offer {
|
|
10
14
|
id: number;
|
|
11
15
|
name: string;
|
|
@@ -59,4 +63,11 @@ export namespace ProductResponse {
|
|
|
59
63
|
export interface offers extends SuccessResponse {
|
|
60
64
|
data: Offer[] | [];
|
|
61
65
|
}
|
|
66
|
+
|
|
67
|
+
export interface sizeGuides extends SuccessResponse {
|
|
68
|
+
data: Array<SizeGuide>;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
|
|
62
73
|
}
|
package/types/event/index.d.ts
CHANGED
package/types/event/product.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import {OfferSummary} from "../api/cart";
|
|
1
2
|
import {ProductResponse} from "../api/product";
|
|
2
3
|
import {RequestError, RequestErrorEvent, RequestErrorEventWithData, SuccessResponse} from "../common";
|
|
3
|
-
import {OfferSummary} from "../api/cart";
|
|
4
4
|
|
|
5
5
|
export default interface ProductEvent {
|
|
6
6
|
onPriceUpdated: (callback: (response: ProductResponse.getPrice, product_id: number) => void) => void;
|
|
@@ -15,4 +15,7 @@ export default interface ProductEvent {
|
|
|
15
15
|
onOfferExisted: (callback: (offer: OfferSummary) => void) => void;
|
|
16
16
|
onOffersFetched: (callback: (response: ProductResponse.offers) => void) => void;
|
|
17
17
|
onFetchOffersFailed: RequestErrorEvent;
|
|
18
|
+
|
|
19
|
+
onsizeGuideFetched: (callback: (response: ProductResponse.sizeGuides, prod_id: number) => void) => void;
|
|
20
|
+
onSizeGuideFetchFailed: RequestErrorEvent;
|
|
18
21
|
}
|
package/watcher.js
CHANGED
|
@@ -60,6 +60,16 @@ class WatcherPlugin {
|
|
|
60
60
|
this.upload_url = upload_url;
|
|
61
61
|
this.store_id = store_id;
|
|
62
62
|
this.draft_id = draft_id;
|
|
63
|
+
|
|
64
|
+
if(typeof theme_id === "undefined"){
|
|
65
|
+
// a hacky way to get args from process.env.npm_lifecycle_script
|
|
66
|
+
let args = parseNpmScriptsPassedArgs(process.env.npm_lifecycle_script);
|
|
67
|
+
this.theme_id = args.theme_id;
|
|
68
|
+
this.upload_url = args.upload_url;
|
|
69
|
+
this.store_id = args.store_id;
|
|
70
|
+
this.draft_id = args.draft_id;
|
|
71
|
+
port = args.port || 8000;
|
|
72
|
+
}
|
|
63
73
|
|
|
64
74
|
let client = new WebSocketClient();
|
|
65
75
|
|
|
@@ -103,7 +113,7 @@ class WatcherPlugin {
|
|
|
103
113
|
|
|
104
114
|
files.map((file)=>{
|
|
105
115
|
if(file.toLowerCase().endsWith('.twig'))
|
|
106
|
-
execSync(`${this.sallaCli} theme sync -f "${file}" -id ${this.theme_id} -store_id
|
|
116
|
+
execSync(`${this.sallaCli} theme sync -f "${file}" -id ${this.theme_id} -store_id ${this.store_id} -draft_id ${this.draft_id} -upload_url ${this.upload_url}`, {stdio: 'inherit'});
|
|
107
117
|
|
|
108
118
|
if(this.connection) this.connection.sendUTF(JSON.stringify({msg:"reload"}));
|
|
109
119
|
});
|
|
@@ -122,7 +132,7 @@ class WatcherPlugin {
|
|
|
122
132
|
}
|
|
123
133
|
|
|
124
134
|
getEntry() {
|
|
125
|
-
let viewsPath = path.join(process.cwd(), "views");
|
|
135
|
+
let viewsPath = path.join(process.cwd(), "src/views");
|
|
126
136
|
return this.isWin && this.isWebpack5
|
|
127
137
|
? viewsPath
|
|
128
138
|
: glob.sync(path.join(viewsPath, "**/*.twig"), {absolute: true});
|
|
@@ -132,13 +142,37 @@ class WatcherPlugin {
|
|
|
132
142
|
* @param {{mode:'development'|'none'|'production', watch:boolean, ...}} options - @see https://webpack.js.org/configuration
|
|
133
143
|
* @return {boolean}
|
|
134
144
|
*/
|
|
135
|
-
|
|
145
|
+
canWatch(options) {
|
|
136
146
|
if (options.mode !== 'development' || !options.watch) {
|
|
137
147
|
console.log(color.green, `✓ Skipping Watching Theme files in production.`, color.normal);
|
|
138
148
|
return false;
|
|
139
149
|
}
|
|
140
|
-
|
|
150
|
+
|
|
151
|
+
return !!this.theme_id;
|
|
141
152
|
}
|
|
142
153
|
}
|
|
143
|
-
|
|
154
|
+
function parseNpmScriptsPassedArgs(str){
|
|
155
|
+
// get all strings between equal sign
|
|
156
|
+
let strs = str.match(/"([^"]*)"/g);
|
|
157
|
+
|
|
158
|
+
if(strs===null) return {};
|
|
159
|
+
// remove quotes
|
|
160
|
+
strs = strs.map(str => str.replace(/"/g, ''));
|
|
161
|
+
|
|
162
|
+
// split by =
|
|
163
|
+
strs = strs.map(str => str.split('='));
|
|
164
|
+
// to be object
|
|
165
|
+
strs = strs.map(str => {
|
|
166
|
+
let obj = {};
|
|
167
|
+
let key = str[0];
|
|
168
|
+
// remove index 0
|
|
169
|
+
str.shift();
|
|
170
|
+
obj[key] = str.join('=');
|
|
171
|
+
return obj;
|
|
172
|
+
});
|
|
173
|
+
// reduce to one object
|
|
174
|
+
return strs.reduce((acc, curr) => {
|
|
175
|
+
return {...acc, ...curr};
|
|
176
|
+
})
|
|
177
|
+
}
|
|
144
178
|
module.exports = WatcherPlugin;
|
package/types/.DS_Store
DELETED
|
Binary file
|
package/types/api/.DS_Store
DELETED
|
Binary file
|