@shopfront/bridge 1.9.0 → 1.10.0

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.
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="TypeScriptCompiler">
4
+ <option name="nodeInterpreterTextField" value="$USER_HOME$/.nvm/versions/node/v14.15.0/bin/node" />
5
+ </component>
6
+ </project>
@@ -0,0 +1,7 @@
1
+ <component name="InspectionProjectProfileManager">
2
+ <profile version="1.0">
3
+ <option name="myName" value="Project Default" />
4
+ <inspection_tool class="JSIgnoredPromiseFromCall" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
5
+ <inspection_tool class="JSMethodCanBeStatic" enabled="false" level="WARNING" enabled_by_default="false" />
6
+ </profile>
7
+ </component>
package/.idea/misc.xml ADDED
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="JavaScriptSettings">
4
+ <option name="languageLevel" value="ES6" />
5
+ </component>
6
+ </project>
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectModuleManager">
4
+ <modules>
5
+ <module fileurl="file://$PROJECT_DIR$/.idea/shopfront-embedded-bridge.iml" filepath="$PROJECT_DIR$/.idea/shopfront-embedded-bridge.iml" />
6
+ </modules>
7
+ </component>
8
+ </project>
@@ -0,0 +1,10 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <module type="WEB_MODULE" version="4">
3
+ <component name="NewModuleRootManager">
4
+ <content url="file://$MODULE_DIR$">
5
+ <excludeFolder url="file://$MODULE_DIR$/lib" />
6
+ </content>
7
+ <orderEntry type="inheritedJdk" />
8
+ <orderEntry type="sourceFolder" forTests="false" />
9
+ </component>
10
+ </module>
package/.idea/vcs.xml ADDED
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="VcsDirectoryMappings">
4
+ <mapping directory="$PROJECT_DIR$" vcs="Git" />
5
+ </component>
6
+ </project>
@@ -53,4 +53,5 @@ export declare class Application {
53
53
  user: string | null;
54
54
  }>;
55
55
  printReceipt(content: string): void;
56
+ getOption<TValueType>(option: string, defaultValue: TValueType): Promise<TValueType>;
56
57
  }
@@ -65,7 +65,8 @@ class Application {
65
65
  }
66
66
  else if (event === "RESPONSE_CURRENT_SALE" ||
67
67
  event === "RESPONSE_DATABASE_REQUEST" ||
68
- event === "RESPONSE_LOCATION") {
68
+ event === "RESPONSE_LOCATION" ||
69
+ event === "RESPONSE_OPTION") {
69
70
  // Handled elsewhere
70
71
  return;
71
72
  }
@@ -335,5 +336,31 @@ class Application {
335
336
  type: "text",
336
337
  });
337
338
  }
339
+ async getOption(option, defaultValue) {
340
+ const request = `OptionRequest-${Date.now().toString()}`;
341
+ const promise = new Promise(res => {
342
+ const listener = (event, data) => {
343
+ if (event !== "RESPONSE_OPTION") {
344
+ return;
345
+ }
346
+ data = data;
347
+ if (data.requestId !== request) {
348
+ return;
349
+ }
350
+ this.bridge.removeEventListener(listener);
351
+ res(data.value);
352
+ };
353
+ this.bridge.addEventListener(listener);
354
+ });
355
+ this.bridge.sendMessage(ApplicationEvents_1.ToShopfront.GET_OPTION, {
356
+ requestId: request,
357
+ option,
358
+ });
359
+ const optionValue = await promise;
360
+ if (typeof optionValue === "undefined") {
361
+ return defaultValue;
362
+ }
363
+ return optionValue;
364
+ }
338
365
  }
339
366
  exports.Application = Application;
@@ -34,6 +34,7 @@ export declare enum ToShopfront {
34
34
  RESPONSE_SALE_KEYS = "RESPONSE_SALE_KEYS",
35
35
  PRINT_RECEIPT = "PRINT_RECEIPT",
36
36
  REDIRECT = "REDIRECT",
37
+ GET_OPTION = "GET_OPTION",
37
38
  SELL_SCREEN_OPTION_CHANGE = "SELL_SCREEN_OPTION_CHANGE",
38
39
  INTERNAL_PAGE_MESSAGE = "INTERNAL_PAGE_MESSAGE",
39
40
  TABLE_UPDATE = "TABLE_UPDATE"
@@ -117,13 +118,13 @@ export interface FromShopfront {
117
118
  REQUEST_BUTTONS: RequestButtons;
118
119
  REQUEST_TABLE_COLUMNS: RequestTableColumns;
119
120
  REQUEST_SELL_SCREEN_OPTIONS: RequestSellScreenOptions;
121
+ CALLBACK: Callback;
120
122
  INTERNAL_PAGE_MESSAGE: InternalPageMessage;
121
123
  REGISTER_CHANGED: RegisterChanged;
122
- CALLBACK: Callback;
123
124
  FORMAT_INTEGRATED_PRODUCT: FormatIntegratedProduct;
124
125
  REQUEST_CUSTOMER_LIST_OPTIONS: RequestCustomerListOptions;
125
- REQUEST_SALE_KEYS: RequestSaleKeys;
126
126
  SALE_COMPLETE: SaleComplete;
127
+ REQUEST_SALE_KEYS: RequestSaleKeys;
127
128
  }
128
129
  export declare const directShopfrontEvents: readonly ["SALE_ADD_PRODUCT", "SALE_REMOVE_PRODUCT", "SALE_UPDATE_PRODUCTS", "SALE_CHANGE_QUANTITY", "SALE_ADD_CUSTOMER", "SALE_REMOVE_CUSTOMER", "SALE_CLEAR"];
129
130
  export declare type DirectShopfrontEvent = typeof directShopfrontEvents[number];
@@ -133,4 +134,5 @@ export interface FromShopfrontInternal {
133
134
  RESPONSE_CURRENT_SALE: "RESPONSE_CURRENT_SALE";
134
135
  RESPONSE_DATABASE_REQUEST: "RESPONSE_DATABASE_REQUEST";
135
136
  RESPONSE_LOCATION: "RESPONSE_LOCATION";
137
+ RESPONSE_OPTION: "RESPONSE_OPTION";
136
138
  }
@@ -21,6 +21,7 @@ var ToShopfront;
21
21
  ToShopfront["RESPONSE_SALE_KEYS"] = "RESPONSE_SALE_KEYS";
22
22
  ToShopfront["PRINT_RECEIPT"] = "PRINT_RECEIPT";
23
23
  ToShopfront["REDIRECT"] = "REDIRECT";
24
+ ToShopfront["GET_OPTION"] = "GET_OPTION";
24
25
  // Emitable Events
25
26
  ToShopfront["SELL_SCREEN_OPTION_CHANGE"] = "SELL_SCREEN_OPTION_CHANGE";
26
27
  ToShopfront["INTERNAL_PAGE_MESSAGE"] = "INTERNAL_PAGE_MESSAGE";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shopfront/bridge",
3
- "version": "1.9.0",
3
+ "version": "1.10.0",
4
4
  "main": "./lib/index.js",
5
5
  "license": "ISC",
6
6
  "description": "The bridge used to embed your application within Shopfront",
package/yarn.lock DELETED
@@ -1,8 +0,0 @@
1
- # THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
2
- # yarn lockfile v1
3
-
4
-
5
- typescript@^4.1.2:
6
- version "4.1.2"
7
- resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.1.2.tgz#6369ef22516fe5e10304aae5a5c4862db55380e9"
8
- integrity sha512-thGloWsGH3SOxv1SoY7QojKi0tc+8FnOmiarEGMbd/lar7QOEd3hvlx3Fp5y6FlDUGl9L+pd4n2e+oToGMmhRQ==