@salla.sa/twilight 2.0.292 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salla.sa/twilight",
3
- "version": "2.0.292",
3
+ "version": "2.0.293",
4
4
  "description": "Salla Theme Toolkit, Webcomponents, Events, Requests, Utils",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -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
  }
@@ -105,7 +105,7 @@ export type EventName = string
105
105
  | 'wishlist::added'
106
106
  | 'wishlist::removed'
107
107
  | 'wishlist::addition.failed'
108
- | 'wishlist::removing.failed';
108
+ | 'wishlist::removing.failed'
109
109
  export {
110
110
  AuthEvent,
111
111
  CartEvent,
@@ -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
@@ -113,7 +113,7 @@ class WatcherPlugin {
113
113
 
114
114
  files.map((file)=>{
115
115
  if(file.toLowerCase().endsWith('.twig'))
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'});
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'});
117
117
 
118
118
  if(this.connection) this.connection.sendUTF(JSON.stringify({msg:"reload"}));
119
119
  });
@@ -132,7 +132,7 @@ class WatcherPlugin {
132
132
  }
133
133
 
134
134
  getEntry() {
135
- let viewsPath = path.join(process.cwd(), "views");
135
+ let viewsPath = path.join(process.cwd(), "src/views");
136
136
  return this.isWin && this.isWebpack5
137
137
  ? viewsPath
138
138
  : glob.sync(path.join(viewsPath, "**/*.twig"), {absolute: true});
@@ -142,28 +142,34 @@ class WatcherPlugin {
142
142
  * @param {{mode:'development'|'none'|'production', watch:boolean, ...}} options - @see https://webpack.js.org/configuration
143
143
  * @return {boolean}
144
144
  */
145
- canWatch(options) {
145
+ canWatch(options) {
146
146
  if (options.mode !== 'development' || !options.watch) {
147
147
  console.log(color.green, `✓ Skipping Watching Theme files in production.`, color.normal);
148
148
  return false;
149
149
  }
150
- return true;
150
+
151
+ return !!this.theme_id;
151
152
  }
152
153
  }
153
154
  function parseNpmScriptsPassedArgs(str){
154
155
  // get all strings between equal sign
155
156
  let strs = str.match(/"([^"]*)"/g);
157
+
158
+ if(strs===null) return {};
156
159
  // remove quotes
157
160
  strs = strs.map(str => str.replace(/"/g, ''));
161
+
158
162
  // split by =
159
163
  strs = strs.map(str => str.split('='));
160
164
  // to be object
161
165
  strs = strs.map(str => {
162
166
  let obj = {};
163
- obj[str[0]] = str[1];
167
+ let key = str[0];
168
+ // remove index 0
169
+ str.shift();
170
+ obj[key] = str.join('=');
164
171
  return obj;
165
- }
166
- );
172
+ });
167
173
  // reduce to one object
168
174
  return strs.reduce((acc, curr) => {
169
175
  return {...acc, ...curr};
package/types/.DS_Store DELETED
Binary file
Binary file