@shopify/ui-extensions-server-kit 5.2.1 → 5.3.1

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.
Files changed (170) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +2 -2
  3. package/dist/ExtensionServerClient/ExtensionServerClient.cjs.js +1 -1
  4. package/dist/ExtensionServerClient/ExtensionServerClient.d.ts +1 -0
  5. package/dist/ExtensionServerClient/ExtensionServerClient.es.js +1 -1
  6. package/dist/ExtensionServerClient/ExtensionServerClient.test.d.ts +8 -0
  7. package/dist/ExtensionServerClient/server-types.d.ts +42 -0
  8. package/dist/context/constants.cjs.js +1 -1
  9. package/dist/context/constants.d.ts +0 -1
  10. package/dist/context/constants.es.js +0 -1
  11. package/dist/context/types.d.ts +1 -0
  12. package/dist/hooks/index.d.ts +0 -2
  13. package/dist/i18n.cjs.js +1 -1
  14. package/dist/i18n.d.ts +1 -20
  15. package/dist/i18n.es.js +0 -1
  16. package/dist/index.cjs.js +1 -1
  17. package/dist/index.es.js +40 -48
  18. package/dist/testing/extensions.cjs.js +1 -1
  19. package/dist/testing/extensions.es.js +2 -2
  20. package/dist/types.cjs.js +1 -1
  21. package/dist/types.d.ts +10 -4
  22. package/dist/types.es.js +2 -2
  23. package/dist/utilities/index.d.ts +0 -1
  24. package/node_modules/@shopify/ui-extensions-test-utils/dist/index.d.ts +3 -0
  25. package/node_modules/@shopify/ui-extensions-test-utils/dist/render.d.ts +2 -0
  26. package/node_modules/@shopify/ui-extensions-test-utils/dist/renderHook.d.ts +17 -0
  27. package/node_modules/@shopify/ui-extensions-test-utils/dist/withProviders.d.ts +9 -0
  28. package/node_modules/@shopify/ui-extensions-test-utils/dist/withProviders.js +1 -0
  29. package/node_modules/@shopify/ui-extensions-test-utils/package.json +2 -3
  30. package/package.json +8 -7
  31. package/project.json +0 -16
  32. package/src/ExtensionServerClient/ExtensionServerClient.test.ts +837 -330
  33. package/src/ExtensionServerClient/ExtensionServerClient.ts +10 -8
  34. package/src/ExtensionServerClient/server-types.ts +55 -0
  35. package/src/ExtensionServerClient/types.ts +2 -0
  36. package/src/context/ExtensionServerProvider.test.tsx +202 -39
  37. package/src/context/ExtensionServerProvider.tsx +1 -0
  38. package/src/context/constants.ts +3 -2
  39. package/src/context/types.ts +1 -0
  40. package/src/hooks/index.ts +0 -2
  41. package/src/i18n.ts +3 -3
  42. package/src/state/reducers/extensionServerReducer.test.ts +2 -2
  43. package/src/testing/extensions.ts +2 -2
  44. package/src/types.ts +9 -4
  45. package/src/utilities/index.ts +0 -1
  46. package/src/utilities/replaceUpdated.ts +1 -0
  47. package/src/utilities/set.ts +1 -0
  48. package/dist/hooks/useExtensionClient.cjs.js +0 -1
  49. package/dist/hooks/useExtensionClient.d.ts +0 -1
  50. package/dist/hooks/useExtensionClient.es.js +0 -8
  51. package/dist/hooks/useExtensionServerEvent.cjs.js +0 -1
  52. package/dist/hooks/useExtensionServerEvent.d.ts +0 -1
  53. package/dist/hooks/useExtensionServerEvent.es.js +0 -9
  54. package/dist/utilities/groupByKey.cjs.js +0 -1
  55. package/dist/utilities/groupByKey.d.ts +0 -3
  56. package/dist/utilities/groupByKey.es.js +0 -6
  57. package/node_modules/@types/node/LICENSE +0 -21
  58. package/node_modules/@types/node/README.md +0 -15
  59. package/node_modules/@types/node/assert/strict.d.ts +0 -8
  60. package/node_modules/@types/node/assert.d.ts +0 -985
  61. package/node_modules/@types/node/async_hooks.d.ts +0 -522
  62. package/node_modules/@types/node/buffer.d.ts +0 -2321
  63. package/node_modules/@types/node/child_process.d.ts +0 -1544
  64. package/node_modules/@types/node/cluster.d.ts +0 -432
  65. package/node_modules/@types/node/console.d.ts +0 -412
  66. package/node_modules/@types/node/constants.d.ts +0 -19
  67. package/node_modules/@types/node/crypto.d.ts +0 -4451
  68. package/node_modules/@types/node/dgram.d.ts +0 -586
  69. package/node_modules/@types/node/diagnostics_channel.d.ts +0 -192
  70. package/node_modules/@types/node/dns/promises.d.ts +0 -381
  71. package/node_modules/@types/node/dns.d.ts +0 -809
  72. package/node_modules/@types/node/dom-events.d.ts +0 -122
  73. package/node_modules/@types/node/domain.d.ts +0 -170
  74. package/node_modules/@types/node/events.d.ts +0 -803
  75. package/node_modules/@types/node/fs/promises.d.ts +0 -1205
  76. package/node_modules/@types/node/fs.d.ts +0 -4211
  77. package/node_modules/@types/node/globals.d.ts +0 -377
  78. package/node_modules/@types/node/globals.global.d.ts +0 -1
  79. package/node_modules/@types/node/http.d.ts +0 -1801
  80. package/node_modules/@types/node/http2.d.ts +0 -2386
  81. package/node_modules/@types/node/https.d.ts +0 -544
  82. package/node_modules/@types/node/index.d.ts +0 -88
  83. package/node_modules/@types/node/inspector.d.ts +0 -2739
  84. package/node_modules/@types/node/module.d.ts +0 -298
  85. package/node_modules/@types/node/net.d.ts +0 -913
  86. package/node_modules/@types/node/os.d.ts +0 -473
  87. package/node_modules/@types/node/package.json +0 -235
  88. package/node_modules/@types/node/path.d.ts +0 -191
  89. package/node_modules/@types/node/perf_hooks.d.ts +0 -626
  90. package/node_modules/@types/node/process.d.ts +0 -1531
  91. package/node_modules/@types/node/punycode.d.ts +0 -117
  92. package/node_modules/@types/node/querystring.d.ts +0 -141
  93. package/node_modules/@types/node/readline/promises.d.ts +0 -143
  94. package/node_modules/@types/node/readline.d.ts +0 -666
  95. package/node_modules/@types/node/repl.d.ts +0 -430
  96. package/node_modules/@types/node/stream/consumers.d.ts +0 -12
  97. package/node_modules/@types/node/stream/promises.d.ts +0 -83
  98. package/node_modules/@types/node/stream/web.d.ts +0 -336
  99. package/node_modules/@types/node/stream.d.ts +0 -1731
  100. package/node_modules/@types/node/string_decoder.d.ts +0 -67
  101. package/node_modules/@types/node/test.d.ts +0 -1113
  102. package/node_modules/@types/node/timers/promises.d.ts +0 -93
  103. package/node_modules/@types/node/timers.d.ts +0 -126
  104. package/node_modules/@types/node/tls.d.ts +0 -1203
  105. package/node_modules/@types/node/trace_events.d.ts +0 -171
  106. package/node_modules/@types/node/ts4.8/assert/strict.d.ts +0 -8
  107. package/node_modules/@types/node/ts4.8/assert.d.ts +0 -985
  108. package/node_modules/@types/node/ts4.8/async_hooks.d.ts +0 -522
  109. package/node_modules/@types/node/ts4.8/buffer.d.ts +0 -2321
  110. package/node_modules/@types/node/ts4.8/child_process.d.ts +0 -1544
  111. package/node_modules/@types/node/ts4.8/cluster.d.ts +0 -432
  112. package/node_modules/@types/node/ts4.8/console.d.ts +0 -412
  113. package/node_modules/@types/node/ts4.8/constants.d.ts +0 -19
  114. package/node_modules/@types/node/ts4.8/crypto.d.ts +0 -4450
  115. package/node_modules/@types/node/ts4.8/dgram.d.ts +0 -586
  116. package/node_modules/@types/node/ts4.8/diagnostics_channel.d.ts +0 -192
  117. package/node_modules/@types/node/ts4.8/dns/promises.d.ts +0 -381
  118. package/node_modules/@types/node/ts4.8/dns.d.ts +0 -809
  119. package/node_modules/@types/node/ts4.8/dom-events.d.ts +0 -122
  120. package/node_modules/@types/node/ts4.8/domain.d.ts +0 -170
  121. package/node_modules/@types/node/ts4.8/events.d.ts +0 -754
  122. package/node_modules/@types/node/ts4.8/fs/promises.d.ts +0 -1205
  123. package/node_modules/@types/node/ts4.8/fs.d.ts +0 -4211
  124. package/node_modules/@types/node/ts4.8/globals.d.ts +0 -377
  125. package/node_modules/@types/node/ts4.8/globals.global.d.ts +0 -1
  126. package/node_modules/@types/node/ts4.8/http.d.ts +0 -1801
  127. package/node_modules/@types/node/ts4.8/http2.d.ts +0 -2386
  128. package/node_modules/@types/node/ts4.8/https.d.ts +0 -544
  129. package/node_modules/@types/node/ts4.8/index.d.ts +0 -88
  130. package/node_modules/@types/node/ts4.8/inspector.d.ts +0 -2739
  131. package/node_modules/@types/node/ts4.8/module.d.ts +0 -298
  132. package/node_modules/@types/node/ts4.8/net.d.ts +0 -913
  133. package/node_modules/@types/node/ts4.8/os.d.ts +0 -473
  134. package/node_modules/@types/node/ts4.8/path.d.ts +0 -191
  135. package/node_modules/@types/node/ts4.8/perf_hooks.d.ts +0 -626
  136. package/node_modules/@types/node/ts4.8/process.d.ts +0 -1531
  137. package/node_modules/@types/node/ts4.8/punycode.d.ts +0 -117
  138. package/node_modules/@types/node/ts4.8/querystring.d.ts +0 -141
  139. package/node_modules/@types/node/ts4.8/readline/promises.d.ts +0 -143
  140. package/node_modules/@types/node/ts4.8/readline.d.ts +0 -666
  141. package/node_modules/@types/node/ts4.8/repl.d.ts +0 -430
  142. package/node_modules/@types/node/ts4.8/stream/consumers.d.ts +0 -12
  143. package/node_modules/@types/node/ts4.8/stream/promises.d.ts +0 -83
  144. package/node_modules/@types/node/ts4.8/stream/web.d.ts +0 -336
  145. package/node_modules/@types/node/ts4.8/stream.d.ts +0 -1731
  146. package/node_modules/@types/node/ts4.8/string_decoder.d.ts +0 -67
  147. package/node_modules/@types/node/ts4.8/test.d.ts +0 -1113
  148. package/node_modules/@types/node/ts4.8/timers/promises.d.ts +0 -93
  149. package/node_modules/@types/node/ts4.8/timers.d.ts +0 -126
  150. package/node_modules/@types/node/ts4.8/tls.d.ts +0 -1203
  151. package/node_modules/@types/node/ts4.8/trace_events.d.ts +0 -171
  152. package/node_modules/@types/node/ts4.8/tty.d.ts +0 -206
  153. package/node_modules/@types/node/ts4.8/url.d.ts +0 -937
  154. package/node_modules/@types/node/ts4.8/util.d.ts +0 -2075
  155. package/node_modules/@types/node/ts4.8/v8.d.ts +0 -541
  156. package/node_modules/@types/node/ts4.8/vm.d.ts +0 -667
  157. package/node_modules/@types/node/ts4.8/wasi.d.ts +0 -158
  158. package/node_modules/@types/node/ts4.8/worker_threads.d.ts +0 -692
  159. package/node_modules/@types/node/ts4.8/zlib.d.ts +0 -517
  160. package/node_modules/@types/node/tty.d.ts +0 -206
  161. package/node_modules/@types/node/url.d.ts +0 -937
  162. package/node_modules/@types/node/util.d.ts +0 -2075
  163. package/node_modules/@types/node/v8.d.ts +0 -541
  164. package/node_modules/@types/node/vm.d.ts +0 -667
  165. package/node_modules/@types/node/wasi.d.ts +0 -158
  166. package/node_modules/@types/node/worker_threads.d.ts +0 -692
  167. package/node_modules/@types/node/zlib.d.ts +0 -517
  168. package/src/hooks/useExtensionClient.ts +0 -6
  169. package/src/hooks/useExtensionServerEvent.ts +0 -11
  170. package/src/utilities/groupByKey.ts +0 -3
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @shopify/ui-extensions-server-kit
2
2
 
3
+ ## 5.3.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 7f2f69a: Added optional `error` property to ExtensionPayload which include the `message` and `file`
8
+
9
+ ## 5.3.0
10
+
11
+ ### Minor Changes
12
+
13
+ - 386bf0e: Add support for displaying UI Extension dev logs
14
+
3
15
  ## 5.2.1
4
16
 
5
17
  ### Patch Changes
package/README.md CHANGED
@@ -13,7 +13,7 @@ Learn more in the [commands docs](./packages/cli/README.md#commands).
13
13
 
14
14
  <p>&nbsp;</p>
15
15
 
16
- ### Before you begin ###
16
+ ## Before you begin
17
17
 
18
18
  Install the latest version of [Node.js](https://nodejs.org/en/download/) and [npm](https://docs.npmjs.com/getting-started) (or another package manager of your choice).
19
19
 
@@ -41,7 +41,7 @@ To work with themes, the CLI needs to be installed globally with:
41
41
 
42
42
  You can also use do it through Homebrew on macOS: `brew tap shopify/shopify && brew install shopify-cli`
43
43
 
44
- Learn more in the docs: [Shopify CLI for themes](https://shopify.dev/docs/themes/tools/cli)
44
+ Learn more in the docs: [Shopify CLI for themes](https://shopify.dev/docs/storefronts/themes/tools/cli)
45
45
 
46
46
  <p>&nbsp;</p>
47
47
 
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("../i18n.cjs.js"),E=require("../utilities/isValidSurface.cjs.js"),f=require("../utilities/isUIExtension.cjs.js");class g{constructor(n={}){this.EVENT_THAT_WILL_MUTATE_THE_SERVER=["update"],this.listeners={},this.connectionListeners={close:new Set,open:new Set},this.connected=!1,this.uiExtensionsByUuid={},this.id=(Math.random()+1).toString(36).substring(7),this.options=p({...n,connection:{automaticConnect:!0,protocols:[],...n.connection??{}}}),this.setupConnection(this.options.connection.automaticConnect)}connect(n={connection:{}}){const t=S(this.options,n);return JSON.stringify(t)!==JSON.stringify(this.options)&&(this.options=t,this.setupConnection(!0)),()=>{this.closeConnection()}}on(n,t){return this.listeners[n]||(this.listeners[n]=new Set),this.listeners[n].add(t),()=>this.listeners[n].delete(t)}persist(n,t){var s,e,i;if(this.EVENT_THAT_WILL_MUTATE_THE_SERVER.includes(n))return this.options.locales?((e=t.extensions)==null||e.forEach(o=>{h.TRANSLATED_KEYS.forEach(a=>{var c;f.isUIExtension(o)&&((c=o.extensionPoints)==null||c.forEach(l=>{delete l[a]})),delete o[a]})}),(i=this.connection)==null?void 0:i.send(JSON.stringify({event:n,data:t}))):(s=this.connection)==null?void 0:s.send(JSON.stringify({event:n,data:t}));console.warn('You tried to use "persist" with a dispatch event. Please use the "emit" method instead.')}emit(...n){var e;const[t,s]=n;if(this.EVENT_THAT_WILL_MUTATE_THE_SERVER.includes(t))return console.warn(`You tried to use "emit" with a the "${t}" event. Please use the "persist" method instead to persist changes to the server.`);(e=this.connection)==null||e.send(JSON.stringify({event:"dispatch",data:{type:t,payload:s}}))}onConnection(n,t){return this.connectionListeners[n].add(t),()=>this.connectionListeners[n].delete(t)}initializeConnection(){var n;this.connection&&(this.connection.addEventListener("open",t=>{this.connected=!0,this.connectionListeners.open.forEach(s=>s(t))}),this.connection.addEventListener("close",t=>{this.connected=!1,this.connectionListeners.close.forEach(s=>s(t))}),(n=this.connection)==null||n.addEventListener("message",t=>{var s,e;try{const{event:i,data:o}=JSON.parse(t.data);if(i==="dispatch"){const{type:c,payload:l}=o;(s=this.listeners[c])==null||s.forEach(u=>u(l));return}const a=o.extensions?T(o.extensions,this.options.surface):o.extensions;(e=this.listeners[i])==null||e.forEach(c=>{c({...o,extensions:this._getLocalizedExtensions(a)})})}catch(i){console.error("[ExtensionServer] Something went wrong while parsing a server message:",i instanceof Error?i.message:i)}}))}setupConnection(n=!0){this.options.connection.url&&n&&(this.closeConnection(),this.connection=new WebSocket(this.options.connection.url,this.options.connection.protocols),this.initializeConnection())}closeConnection(){var n;this.connected&&((n=this.connection)==null||n.close())}_getLocalizedExtensions(n){return n==null?void 0:n.map(t=>{var a,c,l,u,d;if(!this.options.locales||!f.isUIExtension(t))return t;const e=((c=(a=this.uiExtensionsByUuid[t.uuid])==null?void 0:a.localization)==null?void 0:c.lastUpdated)!==((l=t.localization)==null?void 0:l.lastUpdated)?h.getFlattenedLocalization(t.localization,this.options.locales):((u=this.uiExtensionsByUuid[t.uuid])==null?void 0:u.localization)||t.localization,i=e&&h.isFlattenedTranslations(e)?JSON.parse(e.translations):e,o={...t,localization:e,name:i&&t.name.startsWith("t:")?this._getLocalizedValue(i,t.name):t.name,...t.description&&{description:i&&((d=t.description)!=null&&d.startsWith("t:"))?this._getLocalizedValue(i,t.description):t.description}};return this.uiExtensionsByUuid[t.uuid]={...o,extensionPoints:this._getLocalizedExtensionPoints(e,o)},this.uiExtensionsByUuid[t.uuid]})}_getLocalizedExtensionPoints(n,{extensionPoints:t,name:s,description:e}){return!n||!h.isFlattenedTranslations(n)?t:t==null?void 0:t.map(i=>({...i,localization:n,name:s,...e&&{description:e}}))}_getLocalizedValue(n,t){const s=t.replace("t:","");return n[s]||t}}function S(r,n){return p({...r,...n,connection:{...r.connection,...n.connection}})}function p(r){return E.isValidSurface(r.surface)||delete r.surface,r}function T(r,n){return n?r.filter(t=>t.surface===n?!0:Array.isArray(t.extensionPoints)?t.extensionPoints.filter(i=>typeof i=="string"?!1:i.surface===n).length>0:!1):r}exports.ExtensionServerClient=g;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("../i18n.cjs.js"),E=require("../utilities/isValidSurface.cjs.js"),f=require("../utilities/isUIExtension.cjs.js");class g{constructor(n={}){this.EVENT_THAT_WILL_MUTATE_THE_SERVER=["update"],this.listeners={},this.connectionListeners={close:new Set,open:new Set},this.connected=!1,this.uiExtensionsByUuid={},this.id=(Math.random()+1).toString(36).substring(7),this.options=p({...n,connection:{automaticConnect:!0,protocols:[],...n.connection??{}}}),this.setupConnection(this.options.connection.automaticConnect)}connect(n={connection:{}}){const t=S(this.options,n);return JSON.stringify(t)!==JSON.stringify(this.options)&&(this.options=t,this.setupConnection(!0)),()=>{this.closeConnection()}}on(n,t){return this.listeners[n]||(this.listeners[n]=new Set),this.listeners[n].add(t),()=>this.listeners[n].delete(t)}persist(n,t){var s,e,i;if(this.EVENT_THAT_WILL_MUTATE_THE_SERVER.includes(n))return this.options.locales?((e=t.extensions)==null||e.forEach(o=>{h.TRANSLATED_KEYS.forEach(a=>{var c;f.isUIExtension(o)&&((c=o.extensionPoints)==null||c.forEach(l=>{delete l[a]})),delete o[a]})}),(i=this.connection)==null?void 0:i.send(JSON.stringify({event:n,data:t}))):(s=this.connection)==null?void 0:s.send(JSON.stringify({event:n,data:t}));console.warn('You tried to use "persist" with a dispatch event. Please use the "emit" method instead.')}emit(...n){var e;const[t,s]=n;if(this.EVENT_THAT_WILL_MUTATE_THE_SERVER.includes(t))return console.warn(`You tried to use "emit" with a the "${t}" event. Please use the "persist" method instead to persist changes to the server.`);(e=this.connection)==null||e.send(JSON.stringify({event:"dispatch",data:{type:t,payload:s}}))}onConnection(n,t){return this.connectionListeners[n].add(t),()=>this.connectionListeners[n].delete(t)}initializeConnection(){var n;this.connection&&(this.connection.addEventListener("open",t=>{this.connected=!0,this.connectionListeners.open.forEach(s=>s(t))}),this.connection.addEventListener("close",t=>{this.connected=!1,this.connectionListeners.close.forEach(s=>s(t))}),(n=this.connection)==null||n.addEventListener("message",t=>{var s,e;try{const{event:i,data:o}=JSON.parse(t.data);if(i==="dispatch"){const{type:c,payload:l}=o;(s=this.listeners[c])==null||s.forEach(u=>u(l));return}const a=o.extensions?T(o.extensions,this.options.surface):o.extensions;(e=this.listeners[i])==null||e.forEach(c=>{c({...o,extensions:this._getLocalizedExtensions(a)})})}catch(i){console.error("[ExtensionServer] Something went wrong while parsing a server message:",i instanceof Error?i.message:i)}}))}setupConnection(n=!0){this.options.connection.url&&n&&(this.closeConnection(),this.connection=new WebSocket(this.options.connection.url,this.options.connection.protocols),this.initializeConnection())}closeConnection(){var n;this.connected&&((n=this.connection)==null||n.close())}_getLocalizedExtensions(n){return n==null?void 0:n.map(t=>{var a,c,l,u,d;if(!this.options.locales||!f.isUIExtension(t))return t;const e=((c=(a=this.uiExtensionsByUuid[t.uuid])==null?void 0:a.localization)==null?void 0:c.lastUpdated)!==((l=t.localization)==null?void 0:l.lastUpdated)?h.getFlattenedLocalization(t.localization,this.options.locales):((u=this.uiExtensionsByUuid[t.uuid])==null?void 0:u.localization)??t.localization,i=e&&h.isFlattenedTranslations(e)?JSON.parse(e.translations):e,o={...t,localization:e,name:i&&t.name.startsWith("t:")?this._getLocalizedValue(i,t.name):t.name,...t.description&&{description:i&&((d=t.description)!=null&&d.startsWith("t:"))?this._getLocalizedValue(i,t.description):t.description}};return this.uiExtensionsByUuid[t.uuid]={...o,extensionPoints:this._getLocalizedExtensionPoints(e,o)},this.uiExtensionsByUuid[t.uuid]})}_getLocalizedExtensionPoints(n,{extensionPoints:t,name:s,description:e}){return!n||!h.isFlattenedTranslations(n)?t:t==null?void 0:t.map(i=>({...i,localization:n,name:s,...e&&{description:e}}))}_getLocalizedValue(n,t){const s=t.replace("t:","");return n[s]||t}}function S(r,n){return p({...r,...n,connection:{...r.connection,...n.connection}})}function p(r){return E.isValidSurface(r.surface)||delete r.surface,r}function T(r,n){return n?r.filter(t=>t.surface===n?!0:Array.isArray(t.extensionPoints)?t.extensionPoints.filter(i=>typeof i=="string"?!1:i.surface===n).length>0:!1):r}exports.ExtensionServerClient=g;
@@ -1,3 +1,4 @@
1
+ import { ExtensionServer } from './server-types.js';
1
2
  import { DeepPartial } from '../types';
2
3
  export declare class ExtensionServerClient implements ExtensionServer.Client {
3
4
  id: string;
@@ -85,7 +85,7 @@ class z {
85
85
  var a, c, h, l, u;
86
86
  if (!this.options.locales || !f(t))
87
87
  return t;
88
- const e = ((c = (a = this.uiExtensionsByUuid[t.uuid]) == null ? void 0 : a.localization) == null ? void 0 : c.lastUpdated) !== ((h = t.localization) == null ? void 0 : h.lastUpdated) ? g(t.localization, this.options.locales) : ((l = this.uiExtensionsByUuid[t.uuid]) == null ? void 0 : l.localization) || t.localization, i = e && d(e) ? JSON.parse(e.translations) : e, o = {
88
+ const e = ((c = (a = this.uiExtensionsByUuid[t.uuid]) == null ? void 0 : a.localization) == null ? void 0 : c.lastUpdated) !== ((h = t.localization) == null ? void 0 : h.lastUpdated) ? g(t.localization, this.options.locales) : ((l = this.uiExtensionsByUuid[t.uuid]) == null ? void 0 : l.localization) ?? t.localization, i = e && d(e) ? JSON.parse(e.translations) : e, o = {
89
89
  ...t,
90
90
  localization: e,
91
91
  name: i && t.name.startsWith("t:") ? this._getLocalizedValue(i, t.name) : t.name,
@@ -1 +1,9 @@
1
+ declare module './ExtensionServerClient' {
2
+ namespace ExtensionServer {
3
+ interface ConnectionOptions {
4
+ url?: string;
5
+ automaticConnect?: boolean;
6
+ }
7
+ }
8
+ }
1
9
  export {};
@@ -0,0 +1,42 @@
1
+ import { Surface } from './types.js';
2
+ import { ExtensionPayload, ExtensionPoint } from '../types';
3
+ import { FlattenedLocalization, Localization } from '../i18n';
4
+ export declare namespace ExtensionServer {
5
+ interface UIExtension extends ExtensionPayload {
6
+ extensionPoints: ExtensionPoint[];
7
+ localization?: FlattenedLocalization | Localization | null;
8
+ }
9
+ interface Client {
10
+ id: string;
11
+ connection: WebSocket;
12
+ options: Options;
13
+ connect(options?: Options): () => void;
14
+ on<TEvent extends keyof InboundEvents>(event: TEvent, listener: (payload: InboundEvents[TEvent]) => void): () => void;
15
+ persist<TEvent extends keyof OutboundPersistEvents>(event: TEvent, data: OutboundPersistEvents[TEvent]): void;
16
+ emit<TEvent extends keyof DispatchEvents>(...args: EmitArgs<TEvent>): void;
17
+ onConnection<TEvent extends 'close' | 'open'>(event: TEvent, listener: (event: Event) => void): () => void;
18
+ }
19
+ interface Options {
20
+ connection: {
21
+ url?: string;
22
+ automaticConnect?: boolean;
23
+ protocols?: string | string[];
24
+ };
25
+ surface?: Surface;
26
+ locales?: any;
27
+ }
28
+ interface ServerEvents {
29
+ event: string;
30
+ data: any;
31
+ }
32
+ interface InboundEvents {
33
+ [key: string]: any;
34
+ }
35
+ interface OutboundPersistEvents {
36
+ [key: string]: any;
37
+ }
38
+ interface DispatchEvents {
39
+ [key: string]: any;
40
+ }
41
+ type EmitArgs<TEvent extends keyof DispatchEvents> = undefined extends DispatchEvents[TEvent] ? [event: TEvent] : [event: TEvent, payload: DispatchEvents[TEvent]];
42
+ }
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("../ExtensionServerClient/ExtensionServerClient.cjs.js"),o=require("../state/reducers/constants.cjs.js"),e=require("../utilities/noop.cjs.js"),r=require("react"),t={connect:e.noop,dispatch:e.noop,state:o.INITIAL_STATE,client:new n.ExtensionServerClient},s=r.createContext(t);exports.DEFAULT_VALUE=t;exports.extensionServerContext=s;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("../ExtensionServerClient/ExtensionServerClient.cjs.js"),n=require("../state/reducers/constants.cjs.js"),e=require("../utilities/noop.cjs.js"),o=require("react"),r={connect:e.noop,dispatch:e.noop,state:n.INITIAL_STATE,client:new t.ExtensionServerClient},s=o.createContext(r);exports.extensionServerContext=s;
@@ -1,3 +1,2 @@
1
1
  import type { ExtensionServerContext } from './types';
2
- export declare const DEFAULT_VALUE: ExtensionServerContext;
3
2
  export declare const extensionServerContext: import("react").Context<ExtensionServerContext>;
@@ -9,6 +9,5 @@ const r = {
9
9
  client: new o()
10
10
  }, s = n(r);
11
11
  export {
12
- r as DEFAULT_VALUE,
13
12
  s as extensionServerContext
14
13
  };
@@ -1,3 +1,4 @@
1
+ import { ExtensionServer } from '../ExtensionServerClient/server-types.js';
1
2
  import type { ExtensionServerState, ExtensionServerActions } from '../state';
2
3
  export interface ExtensionServerContext {
3
4
  client: ExtensionServer.Client;
@@ -1,5 +1,3 @@
1
- export * from './useExtensionClient';
2
1
  export * from './useExtensionServerContext';
3
- export * from './useExtensionServerEvent';
4
2
  export * from './useExtensionServerState';
5
3
  export * from './useIsomorphicLayoutEffect';
package/dist/i18n.cjs.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const L=["localization","name","description"];function u(n){const t=new Map;return f(n,(e,s)=>t.set(e,s)),t}function f(n,t,e){Object.keys(n).forEach(s=>{const o=n[s],r=e?`${e}.${s}`:s;o!=null&&(typeof o=="string"?t(r,o):f(o,t,r))})}function c(n,t){const e=a(n.translations[n.defaultLocale]),s=i(t),o=a(n.translations[s]),r=a(n.translations[t]);return d(new Map([...e,...o,...r]))}function a(n){return n?u(n):new Map}function p(n,t){const e=new Set(Object.keys(n.translations));if(e.size===0||e.has(t.user))return t.user;const s=i(t.user);if(e.has(s))return s;if(t.shop&&e.has(t.shop))return t.shop;const o=t.shop&&i(t.shop);return o&&e.has(o)?o:n.defaultLocale}function d(n){const t={};for(const[e,s]of n)t[e]=s;return t}function i(n){return n.split("-")[0]}function T(n,t){if(!n||!t)return;if(l(n))return n;const e=p(n,t),s=JSON.stringify(c(n,e));return{extensionLocale:e,translations:s,lastUpdated:n.lastUpdated}}function l(n){return typeof n.translations=="string"&&Object.prototype.hasOwnProperty.call(n,"extensionLocale")}exports.TRANSLATED_KEYS=L;exports.dictionaryToFlatMap=u;exports.flattenDevExtensionTranslations=c;exports.getFlattenedLocalization=T;exports.isFlattenedTranslations=l;exports.resolveDevExtensionLocale=p;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=["localization","name","description"];function L(n){const t=new Map;return u(n,(e,s)=>t.set(e,s)),t}function u(n,t,e){Object.keys(n).forEach(s=>{const o=n[s],r=e?`${e}.${s}`:s;o!=null&&(typeof o=="string"?t(r,o):u(o,t,r))})}function f(n,t){const e=a(n.translations[n.defaultLocale]),s=i(t),o=a(n.translations[s]),r=a(n.translations[t]);return d(new Map([...e,...o,...r]))}function a(n){return n?L(n):new Map}function c(n,t){const e=new Set(Object.keys(n.translations));if(e.size===0||e.has(t.user))return t.user;const s=i(t.user);if(e.has(s))return s;if(t.shop&&e.has(t.shop))return t.shop;const o=t.shop&&i(t.shop);return o&&e.has(o)?o:n.defaultLocale}function d(n){const t={};for(const[e,s]of n)t[e]=s;return t}function i(n){return n.split("-")[0]}function T(n,t){if(!n||!t)return;if(p(n))return n;const e=c(n,t),s=JSON.stringify(f(n,e));return{extensionLocale:e,translations:s,lastUpdated:n.lastUpdated}}function p(n){return typeof n.translations=="string"&&Object.prototype.hasOwnProperty.call(n,"extensionLocale")}exports.TRANSLATED_KEYS=l;exports.flattenDevExtensionTranslations=f;exports.getFlattenedLocalization=T;exports.isFlattenedTranslations=p;exports.resolveDevExtensionLocale=c;
package/dist/i18n.d.ts CHANGED
@@ -22,9 +22,6 @@ export interface LocalesOptions {
22
22
  user: string;
23
23
  shop?: string;
24
24
  }
25
- export interface TranslationDictionary {
26
- [key: string]: string | TranslationDictionary;
27
- }
28
25
  /**
29
26
  * This is a flattened dictionary of extension translations for the active locale.
30
27
  *
@@ -63,26 +60,10 @@ export interface TranslationDictionary {
63
60
  * }
64
61
  * ```
65
62
  */
66
- export interface ExtensionTranslationMap {
63
+ interface ExtensionTranslationMap {
67
64
  [key: string]: string;
68
65
  }
69
66
  export declare const TRANSLATED_KEYS: string[];
70
- /**
71
- * From a nested dictionary like the following :
72
- *
73
- * ```typescript
74
- * const dictionary = {
75
- * Foo: {
76
- * Bar: {
77
- * fooBar: 'something'
78
- * }
79
- * }
80
- * }
81
- *
82
- * Returns a map containing this pair : {'Foo.Bar.fooBar': 'something'}
83
- * ```
84
- */
85
- export declare function dictionaryToFlatMap(dictionary: TranslationDictionary): Map<string, string>;
86
67
  export declare function flattenDevExtensionTranslations(localization: Localization, locale: string): ExtensionTranslationMap;
87
68
  export declare function resolveDevExtensionLocale(localization: Localization, locales: {
88
69
  user: string;
package/dist/i18n.es.js CHANGED
@@ -53,7 +53,6 @@ function d(n) {
53
53
  }
54
54
  export {
55
55
  h as TRANSLATED_KEYS,
56
- f as dictionaryToFlatMap,
57
56
  c as flattenDevExtensionTranslations,
58
57
  l as getFlattenedLocalization,
59
58
  d as isFlattenedTranslations,
package/dist/index.cjs.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./context/ExtensionServerProvider.cjs.js"),n=require("./context/constants.cjs.js"),o=require("./ExtensionServerClient/ExtensionServerClient.cjs.js"),s=require("./ExtensionServerClient/types.cjs.js"),i=require("./hooks/useExtensionClient.cjs.js"),c=require("./hooks/useExtensionServerContext.cjs.js"),a=require("./hooks/useExtensionServerEvent.cjs.js"),u=require("./hooks/useExtensionServerState.cjs.js"),E=require("./hooks/useIsomorphicLayoutEffect.cjs.js"),t=require("./state/actions/actions.cjs.js"),S=require("./state/reducers/constants.cjs.js"),x=require("./state/reducers/extensionServerReducer.cjs.js"),l=require("./types.cjs.js"),v=require("./utilities/groupByKey.cjs.js"),A=require("./utilities/noop.cjs.js"),d=require("./utilities/replaceUpdated.cjs.js"),p=require("./utilities/set.cjs.js"),T=require("./utilities/assetToString.cjs.js"),q=require("./utilities/isValidSurface.cjs.js"),L=require("./utilities/isUIExtension.cjs.js"),e=require("./i18n.cjs.js");exports.ExtensionServerProvider=r.ExtensionServerProvider;exports.DEFAULT_VALUE=n.DEFAULT_VALUE;exports.extensionServerContext=n.extensionServerContext;exports.ExtensionServerClient=o.ExtensionServerClient;exports.AVAILABLE_SURFACES=s.AVAILABLE_SURFACES;exports.useExtensionClient=i.useExtensionClient;exports.useExtensionServerContext=c.useExtensionServerContext;exports.useExtensionServerEvent=a.useExtensionServerEvent;exports.useExtensionServerState=u.useExtensionServerState;exports.useIsomorphicLayoutEffect=E.useIsomorphicLayoutEffect;exports.createConnectedAction=t.createConnectedAction;exports.createFocusAction=t.createFocusAction;exports.createRefreshAction=t.createRefreshAction;exports.createUnfocusAction=t.createUnfocusAction;exports.createUpdateAction=t.createUpdateAction;exports.INITIAL_STATE=S.INITIAL_STATE;exports.extensionServerReducer=x.extensionServerReducer;exports.Status=l.Status;exports.groupByKey=v.groupByKey;exports.noop=A.noop;exports.replaceUpdated=d.replaceUpdated;exports.set=p.set;exports.assetToString=T.assetToString;exports.isValidSurface=q.isValidSurface;exports.isUIExtension=L.isUIExtension;exports.TRANSLATED_KEYS=e.TRANSLATED_KEYS;exports.dictionaryToFlatMap=e.dictionaryToFlatMap;exports.flattenDevExtensionTranslations=e.flattenDevExtensionTranslations;exports.getFlattenedLocalization=e.getFlattenedLocalization;exports.isFlattenedTranslations=e.isFlattenedTranslations;exports.resolveDevExtensionLocale=e.resolveDevExtensionLocale;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./context/ExtensionServerProvider.cjs.js"),r=require("./context/constants.cjs.js"),o=require("./ExtensionServerClient/ExtensionServerClient.cjs.js"),s=require("./ExtensionServerClient/types.cjs.js"),i=require("./hooks/useExtensionServerContext.cjs.js"),c=require("./hooks/useExtensionServerState.cjs.js"),a=require("./hooks/useIsomorphicLayoutEffect.cjs.js"),e=require("./state/actions/actions.cjs.js"),u=require("./state/reducers/constants.cjs.js"),S=require("./state/reducers/extensionServerReducer.cjs.js"),E=require("./types.cjs.js"),x=require("./utilities/noop.cjs.js"),l=require("./utilities/replaceUpdated.cjs.js"),v=require("./utilities/set.cjs.js"),A=require("./utilities/assetToString.cjs.js"),d=require("./utilities/isValidSurface.cjs.js"),q=require("./utilities/isUIExtension.cjs.js"),t=require("./i18n.cjs.js");exports.ExtensionServerProvider=n.ExtensionServerProvider;exports.extensionServerContext=r.extensionServerContext;exports.ExtensionServerClient=o.ExtensionServerClient;exports.AVAILABLE_SURFACES=s.AVAILABLE_SURFACES;exports.useExtensionServerContext=i.useExtensionServerContext;exports.useExtensionServerState=c.useExtensionServerState;exports.useIsomorphicLayoutEffect=a.useIsomorphicLayoutEffect;exports.createConnectedAction=e.createConnectedAction;exports.createFocusAction=e.createFocusAction;exports.createRefreshAction=e.createRefreshAction;exports.createUnfocusAction=e.createUnfocusAction;exports.createUpdateAction=e.createUpdateAction;exports.INITIAL_STATE=u.INITIAL_STATE;exports.extensionServerReducer=S.extensionServerReducer;exports.Status=E.Status;exports.noop=x.noop;exports.replaceUpdated=l.replaceUpdated;exports.set=v.set;exports.assetToString=A.assetToString;exports.isValidSurface=d.isValidSurface;exports.isUIExtension=q.isUIExtension;exports.TRANSLATED_KEYS=t.TRANSLATED_KEYS;exports.flattenDevExtensionTranslations=t.flattenDevExtensionTranslations;exports.getFlattenedLocalization=t.getFlattenedLocalization;exports.isFlattenedTranslations=t.isFlattenedTranslations;exports.resolveDevExtensionLocale=t.resolveDevExtensionLocale;
package/dist/index.es.js CHANGED
@@ -1,54 +1,46 @@
1
1
  import { ExtensionServerProvider as r } from "./context/ExtensionServerProvider.es.js";
2
- import { DEFAULT_VALUE as n, extensionServerContext as x } from "./context/constants.es.js";
3
- import { ExtensionServerClient as i } from "./ExtensionServerClient/ExtensionServerClient.es.js";
2
+ import { extensionServerContext as n } from "./context/constants.es.js";
3
+ import { ExtensionServerClient as s } from "./ExtensionServerClient/ExtensionServerClient.es.js";
4
4
  import { AVAILABLE_SURFACES as a } from "./ExtensionServerClient/types.es.js";
5
- import { useExtensionClient as m } from "./hooks/useExtensionClient.es.js";
6
- import { useExtensionServerContext as E } from "./hooks/useExtensionServerContext.es.js";
7
- import { useExtensionServerEvent as A } from "./hooks/useExtensionServerEvent.es.js";
8
- import { useExtensionServerState as u } from "./hooks/useExtensionServerState.es.js";
9
- import { useIsomorphicLayoutEffect as d } from "./hooks/useIsomorphicLayoutEffect.es.js";
10
- import { createConnectedAction as L, createFocusAction as U, createRefreshAction as C, createUnfocusAction as F, createUpdateAction as I } from "./state/actions/actions.es.js";
11
- import { INITIAL_STATE as D } from "./state/reducers/constants.es.js";
12
- import { extensionServerReducer as _ } from "./state/reducers/extensionServerReducer.es.js";
13
- import { Status as V } from "./types.es.js";
14
- import { groupByKey as B } from "./utilities/groupByKey.es.js";
15
- import { noop as N } from "./utilities/noop.es.js";
16
- import { replaceUpdated as M } from "./utilities/replaceUpdated.es.js";
17
- import { set as Y } from "./utilities/set.es.js";
18
- import { assetToString as j } from "./utilities/assetToString.es.js";
19
- import { isValidSurface as q } from "./utilities/isValidSurface.es.js";
20
- import { isUIExtension as G } from "./utilities/isUIExtension.es.js";
21
- import { TRANSLATED_KEYS as J, dictionaryToFlatMap as O, flattenDevExtensionTranslations as Q, getFlattenedLocalization as W, isFlattenedTranslations as X, resolveDevExtensionLocale as Z } from "./i18n.es.js";
5
+ import { useExtensionServerContext as p } from "./hooks/useExtensionServerContext.es.js";
6
+ import { useExtensionServerState as m } from "./hooks/useExtensionServerState.es.js";
7
+ import { useIsomorphicLayoutEffect as A } from "./hooks/useIsomorphicLayoutEffect.es.js";
8
+ import { createConnectedAction as l, createFocusAction as v, createRefreshAction as d, createUnfocusAction as u, createUpdateAction as T } from "./state/actions/actions.es.js";
9
+ import { INITIAL_STATE as I } from "./state/reducers/constants.es.js";
10
+ import { extensionServerReducer as U } from "./state/reducers/extensionServerReducer.es.js";
11
+ import { Status as R } from "./types.es.js";
12
+ import { noop as _ } from "./utilities/noop.es.js";
13
+ import { replaceUpdated as h } from "./utilities/replaceUpdated.es.js";
14
+ import { set as V } from "./utilities/set.es.js";
15
+ import { assetToString as z } from "./utilities/assetToString.es.js";
16
+ import { isValidSurface as K } from "./utilities/isValidSurface.es.js";
17
+ import { isUIExtension as Y } from "./utilities/isUIExtension.es.js";
18
+ import { TRANSLATED_KEYS as j, flattenDevExtensionTranslations as k, getFlattenedLocalization as q, isFlattenedTranslations as w, resolveDevExtensionLocale as G } from "./i18n.es.js";
22
19
  export {
23
20
  a as AVAILABLE_SURFACES,
24
- n as DEFAULT_VALUE,
25
- i as ExtensionServerClient,
21
+ s as ExtensionServerClient,
26
22
  r as ExtensionServerProvider,
27
- D as INITIAL_STATE,
28
- V as Status,
29
- J as TRANSLATED_KEYS,
30
- j as assetToString,
31
- L as createConnectedAction,
32
- U as createFocusAction,
33
- C as createRefreshAction,
34
- F as createUnfocusAction,
35
- I as createUpdateAction,
36
- O as dictionaryToFlatMap,
37
- x as extensionServerContext,
38
- _ as extensionServerReducer,
39
- Q as flattenDevExtensionTranslations,
40
- W as getFlattenedLocalization,
41
- B as groupByKey,
42
- X as isFlattenedTranslations,
43
- G as isUIExtension,
44
- q as isValidSurface,
45
- N as noop,
46
- M as replaceUpdated,
47
- Z as resolveDevExtensionLocale,
48
- Y as set,
49
- m as useExtensionClient,
50
- E as useExtensionServerContext,
51
- A as useExtensionServerEvent,
52
- u as useExtensionServerState,
53
- d as useIsomorphicLayoutEffect
23
+ I as INITIAL_STATE,
24
+ R as Status,
25
+ j as TRANSLATED_KEYS,
26
+ z as assetToString,
27
+ l as createConnectedAction,
28
+ v as createFocusAction,
29
+ d as createRefreshAction,
30
+ u as createUnfocusAction,
31
+ T as createUpdateAction,
32
+ n as extensionServerContext,
33
+ U as extensionServerReducer,
34
+ k as flattenDevExtensionTranslations,
35
+ q as getFlattenedLocalization,
36
+ w as isFlattenedTranslations,
37
+ Y as isUIExtension,
38
+ K as isValidSurface,
39
+ _ as noop,
40
+ h as replaceUpdated,
41
+ G as resolveDevExtensionLocale,
42
+ V as set,
43
+ p as useExtensionServerContext,
44
+ m as useExtensionServerState,
45
+ A as useIsomorphicLayoutEffect
54
46
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("../types.cjs.js");let i=0;function a(e){return`00000000000${e}`.slice(-12)}function r(e={}){const t=`00000000-0000-0000-0000-${a(i++)}`,n=Date.now();return{handle:"my-extension",name:"My extension",description:"My extension description",surface:"admin",type:"purchase_option",externalType:"external_type",uuid:t,version:"extension version",...e,assets:{main:{name:"main",url:`https://secure-link.com/extensions/${t}/assets/handle.js?lastUpdated=${n}`,lastUpdated:n},...e.assets||{}},development:{hidden:!1,status:s.Status.Success,resource:{url:"resourceUrl"},root:{url:`https://secure-link.com/extensions/${t}`},renderer:{name:"render name",version:"1.0.0"},...e.development||{}},extensionPoints:e.extensionPoints,capabilities:e.capabilities,localization:e.localization,authenticatedRedirectStartUrl:e.authenticatedRedirectStartUrl,authenticatedRedirectRedirectUrls:e.authenticatedRedirectRedirectUrls,settings:{fields:[{key:"sample-key",name:"sample_name",type:"sample_type"}]}}}exports.mockExtension=r;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("../types.cjs.js");let i=0;function a(e){return`00000000000${e}`.slice(-12)}function r(e={}){const t=`00000000-0000-0000-0000-${a(i++)}`,n=Date.now();return{handle:"my-extension",name:"My extension",description:"My extension description",surface:"admin",type:"purchase_option",externalType:"external_type",uuid:t,version:"extension version",...e,assets:{main:{name:"main",url:`https://secure-link.com/extensions/${t}/assets/handle.js?lastUpdated=${n}`,lastUpdated:n},...e.assets??{}},development:{hidden:!1,status:s.Status.Success,resource:{url:"resourceUrl"},root:{url:`https://secure-link.com/extensions/${t}`},renderer:{name:"render name",version:"1.0.0"},...e.development??{}},extensionPoints:e.extensionPoints,capabilities:e.capabilities,localization:e.localization,authenticatedRedirectStartUrl:e.authenticatedRedirectStartUrl,authenticatedRedirectRedirectUrls:e.authenticatedRedirectRedirectUrls,settings:{fields:[{key:"sample-key",name:"sample_name",type:"sample_type"}]}}}exports.mockExtension=r;
@@ -21,7 +21,7 @@ function c(e = {}) {
21
21
  url: `https://secure-link.com/extensions/${t}/assets/handle.js?lastUpdated=${n}`,
22
22
  lastUpdated: n
23
23
  },
24
- ...e.assets || {}
24
+ ...e.assets ?? {}
25
25
  },
26
26
  development: {
27
27
  hidden: !1,
@@ -36,7 +36,7 @@ function c(e = {}) {
36
36
  name: "render name",
37
37
  version: "1.0.0"
38
38
  },
39
- ...e.development || {}
39
+ ...e.development ?? {}
40
40
  },
41
41
  // this is due to the naive DeepPartial but also more complex ones
42
42
  // [see stackoverflow](https://stackoverflow.com/a/68699273) assume that
package/dist/types.cjs.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var e=(r=>(r.Error="error",r.Success="success",r))(e||{});exports.Status=e;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var t=(e=>(e.Success="success",e))(t||{});exports.Status=t;
package/dist/types.d.ts CHANGED
@@ -73,14 +73,14 @@ declare global {
73
73
  export type DeepPartial<T> = {
74
74
  [P in keyof T]?: DeepPartial<T[P]>;
75
75
  };
76
- export interface ResourceURL {
76
+ interface ResourceURL {
77
77
  url: string;
78
78
  }
79
79
  export interface Asset extends ResourceURL {
80
80
  name: string;
81
81
  lastUpdated: number;
82
82
  }
83
- export interface Metafield {
83
+ interface Metafield {
84
84
  namespace: string;
85
85
  key: string;
86
86
  }
@@ -93,8 +93,11 @@ export interface ExtensionPoint {
93
93
  localization?: FlattenedLocalization | Localization | null;
94
94
  name: string;
95
95
  description?: string;
96
+ assets?: {
97
+ [name: string]: Asset;
98
+ };
96
99
  }
97
- export type ExtensionPoints = string[] | ExtensionPoint[] | null;
100
+ type ExtensionPoints = string[] | ExtensionPoint[] | null;
98
101
  interface CollectBuyerConsentCapabilities {
99
102
  smsMarketing: boolean;
100
103
  customerPrivacy: boolean;
@@ -125,6 +128,10 @@ export interface ExtensionPayload {
125
128
  name: string;
126
129
  version: string;
127
130
  };
131
+ error?: {
132
+ message: string;
133
+ file?: string;
134
+ };
128
135
  };
129
136
  uuid: string;
130
137
  version: string;
@@ -149,7 +156,6 @@ export interface ExtensionPayload {
149
156
  };
150
157
  }
151
158
  export declare enum Status {
152
- Error = "error",
153
159
  Success = "success"
154
160
  }
155
161
  export interface App {
package/dist/types.es.js CHANGED
@@ -1,4 +1,4 @@
1
- var e = /* @__PURE__ */ ((r) => (r.Error = "error", r.Success = "success", r))(e || {});
1
+ var c = /* @__PURE__ */ ((s) => (s.Success = "success", s))(c || {});
2
2
  export {
3
- e as Status
3
+ c as Status
4
4
  };
@@ -1,4 +1,3 @@
1
- export * from './groupByKey';
2
1
  export * from './noop';
3
2
  export * from './replaceUpdated';
4
3
  export * from './set';
@@ -0,0 +1,3 @@
1
+ export * from './render';
2
+ export * from './renderHook';
3
+ export * from './withProviders';
@@ -0,0 +1,2 @@
1
+ import React from 'react';
2
+ export declare function render<TProps, TProviderProps>(element: React.ReactElement<TProps>, Providers?: React.ComponentType<TProviderProps>, options?: Omit<TProviderProps, 'children'>): import("@shopify/react-testing").Root<any>;
@@ -0,0 +1,17 @@
1
+ import React from 'react';
2
+ export interface HookWrapper<T> {
3
+ result: T;
4
+ /**
5
+ * Use to wrap calls to stateful hook methods:
6
+ *
7
+ * ```ts
8
+ * const hook = testHook(() => useToggle(false))
9
+ * expect(hook.result.value).toBe(false)
10
+ * hook.act(() => hook.result.toggle())
11
+ * expect(hook.result.value).toBe(true)
12
+ * ```
13
+ **/
14
+ act<TR>(callback: (currentResult: T) => TR): TR;
15
+ forceUpdate(): void;
16
+ }
17
+ export declare function renderHook<T, TP>(hook: () => T, Providers?: React.ComponentType<TP>, options?: Omit<TP, 'children'>): HookWrapper<T>;
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ export type ProviderComponent<TProps = any> = React.ComponentType<React.PropsWithChildren<TProps>>;
3
+ export type Tail<T extends any[]> = T extends [head: any, ...tail: infer TRest] ? TRest : never;
4
+ export type PropUnion<TProviders extends any[], TProps extends {
5
+ [k: string]: any;
6
+ } = Empty> = TProviders[0] extends React.ComponentType<any> ? React.ComponentPropsWithoutRef<TProviders[0]> & PropUnion<Tail<TProviders>> : TProps;
7
+ export interface Empty {
8
+ }
9
+ export declare function withProviders<T extends ProviderComponent[]>(...providers: T): ProviderComponent<PropUnion<T>>;
@@ -1,3 +1,4 @@
1
+ /* eslint-disable @typescript-eslint/no-empty-interface */
1
2
  import React from 'react';
2
3
  export function withProviders(...providers) {
3
4
  return function Providers({ children, ...props }) {
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@shopify/ui-extensions-test-utils",
3
3
  "version": "3.26.0",
4
+ "packageManager": "pnpm@10.11.1",
4
5
  "private": true,
5
6
  "license": "MIT",
6
7
  "main": "dist/index",
@@ -28,12 +29,10 @@
28
29
  },
29
30
  "devDependencies": {
30
31
  "@shopify/react-testing": "^3.0.0",
31
- "@types/node": "18.19.3",
32
32
  "@types/react": "16.14.0",
33
33
  "@types/react-dom": "^16.9.11",
34
34
  "react": "^17.0.2",
35
- "react-dom": "^17.0.2",
36
- "typescript": "5.2.2"
35
+ "react-dom": "^17.0.2"
37
36
  },
38
37
  "peerDependencies": {
39
38
  "react": "^17.0.2"
package/package.json CHANGED
@@ -1,8 +1,13 @@
1
1
  {
2
2
  "name": "@shopify/ui-extensions-server-kit",
3
- "version": "5.2.1",
3
+ "version": "5.3.1",
4
4
  "private": false,
5
5
  "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/Shopify/cli.git",
9
+ "directory": "packages/ui-extensions-server-kit"
10
+ },
6
11
  "exports": {
7
12
  "./package.json": "./package.json",
8
13
  ".": {
@@ -40,15 +45,12 @@
40
45
  "devDependencies": {
41
46
  "@shopify/react-testing": "^3.0.0",
42
47
  "@shopify/ui-extensions-test-utils": "3.26.0",
43
- "@types/node": "18.19.3",
44
48
  "@types/react": "17.0.2",
45
49
  "@vitejs/plugin-react-refresh": "^1.3.6",
46
- "jest-websocket-mock": "^2.4.0",
47
50
  "jsdom": "^20.0.3",
48
51
  "react": "^17.0.2",
49
- "typescript": "5.2.2",
50
52
  "vi-fetch": "^0.8.0",
51
- "vite": "^5.3.1"
53
+ "vite": "6.3.6"
52
54
  },
53
55
  "peerDependencies": {
54
56
  "react": "^17.0.2"
@@ -58,7 +60,6 @@
58
60
  "clean": "nx clean",
59
61
  "lint": "nx lint",
60
62
  "lint:fix": "nx lint:fix",
61
- "test": "nx run ui-extensions-server-kit:test",
62
- "test:watch": "nx test:watch"
63
+ "vitest": "vitest"
63
64
  }
64
65
  }
package/project.json CHANGED
@@ -53,22 +53,6 @@
53
53
  "command": "pnpm eslint src --fix",
54
54
  "cwd": "packages/ui-extensions-server-kit"
55
55
  }
56
- },
57
- "test": {
58
- "executor": "nx:run-commands",
59
- "dependsOn": ["^build"],
60
- "options": {
61
- "command": "pnpm vitest run",
62
- "cwd": "packages/ui-extensions-server-kit"
63
- }
64
- },
65
- "test:watch": {
66
- "executor": "nx:run-commands",
67
- "dependsOn": ["^build"],
68
- "options": {
69
- "command": "pnpm vitest watch",
70
- "cwd": "packages/ui-extensions-server-kit"
71
- }
72
56
  }
73
57
  }
74
58
  }