@shopify/ui-extensions-server-kit 0.0.0-snapshot-20240814205424

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 (367) hide show
  1. package/CHANGELOG.md +127 -0
  2. package/README.md +74 -0
  3. package/dist/ExtensionServerClient/ExtensionServerClient.cjs.js +1 -0
  4. package/dist/ExtensionServerClient/ExtensionServerClient.d.ts +28 -0
  5. package/dist/ExtensionServerClient/ExtensionServerClient.es.js +133 -0
  6. package/dist/ExtensionServerClient/ExtensionServerClient.test.d.ts +1 -0
  7. package/dist/ExtensionServerClient/index.d.ts +2 -0
  8. package/dist/ExtensionServerClient/types.cjs.js +1 -0
  9. package/dist/ExtensionServerClient/types.d.ts +124 -0
  10. package/dist/ExtensionServerClient/types.es.js +4 -0
  11. package/dist/context/ExtensionServerProvider.cjs.js +1 -0
  12. package/dist/context/ExtensionServerProvider.d.ts +2 -0
  13. package/dist/context/ExtensionServerProvider.es.js +29 -0
  14. package/dist/context/ExtensionServerProvider.test.d.ts +1 -0
  15. package/dist/context/constants.cjs.js +1 -0
  16. package/dist/context/constants.d.ts +3 -0
  17. package/dist/context/constants.es.js +14 -0
  18. package/dist/context/index.d.ts +3 -0
  19. package/dist/context/types.d.ts +11 -0
  20. package/dist/hooks/index.d.ts +5 -0
  21. package/dist/hooks/useExtensionClient.cjs.js +1 -0
  22. package/dist/hooks/useExtensionClient.d.ts +1 -0
  23. package/dist/hooks/useExtensionClient.es.js +8 -0
  24. package/dist/hooks/useExtensionServerContext.cjs.js +1 -0
  25. package/dist/hooks/useExtensionServerContext.d.ts +1 -0
  26. package/dist/hooks/useExtensionServerContext.es.js +6 -0
  27. package/dist/hooks/useExtensionServerEvent.cjs.js +1 -0
  28. package/dist/hooks/useExtensionServerEvent.d.ts +1 -0
  29. package/dist/hooks/useExtensionServerEvent.es.js +9 -0
  30. package/dist/hooks/useExtensionServerState.cjs.js +1 -0
  31. package/dist/hooks/useExtensionServerState.d.ts +1 -0
  32. package/dist/hooks/useExtensionServerState.es.js +9 -0
  33. package/dist/hooks/useIsomorphicLayoutEffect.cjs.js +1 -0
  34. package/dist/hooks/useIsomorphicLayoutEffect.d.ts +2 -0
  35. package/dist/hooks/useIsomorphicLayoutEffect.es.js +5 -0
  36. package/dist/i18n.cjs.js +1 -0
  37. package/dist/i18n.d.ts +93 -0
  38. package/dist/i18n.es.js +61 -0
  39. package/dist/i18n.test.d.ts +1 -0
  40. package/dist/index.cjs.js +1 -0
  41. package/dist/index.cjs2.js +1 -0
  42. package/dist/index.d.ts +7 -0
  43. package/dist/index.es.js +54 -0
  44. package/dist/index.es2.js +8 -0
  45. package/dist/state/actions/actions.cjs.js +1 -0
  46. package/dist/state/actions/actions.d.ts +6 -0
  47. package/dist/state/actions/actions.es.js +37 -0
  48. package/dist/state/actions/index.d.ts +2 -0
  49. package/dist/state/actions/types.d.ts +21 -0
  50. package/dist/state/index.d.ts +2 -0
  51. package/dist/state/reducers/constants.cjs.js +1 -0
  52. package/dist/state/reducers/constants.d.ts +2 -0
  53. package/dist/state/reducers/constants.es.js +7 -0
  54. package/dist/state/reducers/extensionServerReducer.cjs.js +1 -0
  55. package/dist/state/reducers/extensionServerReducer.d.ts +3 -0
  56. package/dist/state/reducers/extensionServerReducer.es.js +57 -0
  57. package/dist/state/reducers/extensionServerReducer.test.d.ts +1 -0
  58. package/dist/state/reducers/index.d.ts +3 -0
  59. package/dist/state/reducers/types.d.ts +6 -0
  60. package/dist/testing/MockExtensionServerProvider.cjs.js +1 -0
  61. package/dist/testing/MockExtensionServerProvider.d.ts +7 -0
  62. package/dist/testing/MockExtensionServerProvider.es.js +24 -0
  63. package/dist/testing/app.cjs.js +1 -0
  64. package/dist/testing/app.d.ts +2 -0
  65. package/dist/testing/app.es.js +16 -0
  66. package/dist/testing/extensions.cjs.js +1 -0
  67. package/dist/testing/extensions.d.ts +6 -0
  68. package/dist/testing/extensions.es.js +65 -0
  69. package/dist/testing/index.d.ts +3 -0
  70. package/dist/types.cjs.js +1 -0
  71. package/dist/types.d.ts +173 -0
  72. package/dist/types.es.js +4 -0
  73. package/dist/utilities/assetToString.cjs.js +1 -0
  74. package/dist/utilities/assetToString.d.ts +2 -0
  75. package/dist/utilities/assetToString.es.js +7 -0
  76. package/dist/utilities/assetToString.test.d.ts +1 -0
  77. package/dist/utilities/groupByKey.cjs.js +1 -0
  78. package/dist/utilities/groupByKey.d.ts +3 -0
  79. package/dist/utilities/groupByKey.es.js +6 -0
  80. package/dist/utilities/index.d.ts +7 -0
  81. package/dist/utilities/isUIExtension.cjs.js +1 -0
  82. package/dist/utilities/isUIExtension.d.ts +1 -0
  83. package/dist/utilities/isUIExtension.es.js +6 -0
  84. package/dist/utilities/isValidSurface.cjs.js +1 -0
  85. package/dist/utilities/isValidSurface.d.ts +2 -0
  86. package/dist/utilities/isValidSurface.es.js +7 -0
  87. package/dist/utilities/noop.cjs.js +1 -0
  88. package/dist/utilities/noop.d.ts +1 -0
  89. package/dist/utilities/noop.es.js +5 -0
  90. package/dist/utilities/replaceUpdated.cjs.js +1 -0
  91. package/dist/utilities/replaceUpdated.d.ts +1 -0
  92. package/dist/utilities/replaceUpdated.es.js +14 -0
  93. package/dist/utilities/replaceUpdated.test.d.ts +1 -0
  94. package/dist/utilities/set.cjs.js +1 -0
  95. package/dist/utilities/set.d.ts +4 -0
  96. package/dist/utilities/set.es.js +18 -0
  97. package/dist/utilities/set.test.d.ts +1 -0
  98. package/index.d.ts +1 -0
  99. package/index.js +1 -0
  100. package/index.mjs +1 -0
  101. package/node_modules/@shopify/react-testing/LICENSE.md +21 -0
  102. package/node_modules/@shopify/react-testing/README.md +711 -0
  103. package/node_modules/@shopify/react-testing/build/cjs/TestWrapper.js +52 -0
  104. package/node_modules/@shopify/react-testing/build/cjs/_virtual/_rollupPluginBabelHelpers.js +47 -0
  105. package/node_modules/@shopify/react-testing/build/cjs/compat.js +14 -0
  106. package/node_modules/@shopify/react-testing/build/cjs/destroy.js +13 -0
  107. package/node_modules/@shopify/react-testing/build/cjs/element.js +225 -0
  108. package/node_modules/@shopify/react-testing/build/cjs/index.js +21 -0
  109. package/node_modules/@shopify/react-testing/build/cjs/matchers/components.js +46 -0
  110. package/node_modules/@shopify/react-testing/build/cjs/matchers/context.js +25 -0
  111. package/node_modules/@shopify/react-testing/build/cjs/matchers/index.js +16 -0
  112. package/node_modules/@shopify/react-testing/build/cjs/matchers/props.js +38 -0
  113. package/node_modules/@shopify/react-testing/build/cjs/matchers/strings.js +42 -0
  114. package/node_modules/@shopify/react-testing/build/cjs/matchers/utilities.js +110 -0
  115. package/node_modules/@shopify/react-testing/build/cjs/mount.js +76 -0
  116. package/node_modules/@shopify/react-testing/build/cjs/root.js +284 -0
  117. package/node_modules/@shopify/react-testing/build/cjs/toReactString.js +86 -0
  118. package/node_modules/@shopify/react-testing/build/cjs/types.js +28 -0
  119. package/node_modules/@shopify/react-testing/build/esm/TestWrapper.mjs +44 -0
  120. package/node_modules/@shopify/react-testing/build/esm/_virtual/_rollupPluginBabelHelpers.mjs +42 -0
  121. package/node_modules/@shopify/react-testing/build/esm/compat.mjs +10 -0
  122. package/node_modules/@shopify/react-testing/build/esm/destroy.mjs +9 -0
  123. package/node_modules/@shopify/react-testing/build/esm/element.mjs +221 -0
  124. package/node_modules/@shopify/react-testing/build/esm/index.mjs +5 -0
  125. package/node_modules/@shopify/react-testing/build/esm/matchers/components.mjs +41 -0
  126. package/node_modules/@shopify/react-testing/build/esm/matchers/context.mjs +21 -0
  127. package/node_modules/@shopify/react-testing/build/esm/matchers/index.mjs +14 -0
  128. package/node_modules/@shopify/react-testing/build/esm/matchers/props.mjs +33 -0
  129. package/node_modules/@shopify/react-testing/build/esm/matchers/strings.mjs +37 -0
  130. package/node_modules/@shopify/react-testing/build/esm/matchers/utilities.mjs +101 -0
  131. package/node_modules/@shopify/react-testing/build/esm/mount.mjs +70 -0
  132. package/node_modules/@shopify/react-testing/build/esm/root.mjs +275 -0
  133. package/node_modules/@shopify/react-testing/build/esm/toReactString.mjs +80 -0
  134. package/node_modules/@shopify/react-testing/build/esm/types.mjs +26 -0
  135. package/node_modules/@shopify/react-testing/build/esnext/TestWrapper.esnext +44 -0
  136. package/node_modules/@shopify/react-testing/build/esnext/compat.esnext +10 -0
  137. package/node_modules/@shopify/react-testing/build/esnext/destroy.esnext +9 -0
  138. package/node_modules/@shopify/react-testing/build/esnext/element.esnext +221 -0
  139. package/node_modules/@shopify/react-testing/build/esnext/index.esnext +5 -0
  140. package/node_modules/@shopify/react-testing/build/esnext/matchers/components.esnext +41 -0
  141. package/node_modules/@shopify/react-testing/build/esnext/matchers/context.esnext +21 -0
  142. package/node_modules/@shopify/react-testing/build/esnext/matchers/index.esnext +14 -0
  143. package/node_modules/@shopify/react-testing/build/esnext/matchers/props.esnext +33 -0
  144. package/node_modules/@shopify/react-testing/build/esnext/matchers/strings.esnext +37 -0
  145. package/node_modules/@shopify/react-testing/build/esnext/matchers/utilities.esnext +99 -0
  146. package/node_modules/@shopify/react-testing/build/esnext/mount.esnext +71 -0
  147. package/node_modules/@shopify/react-testing/build/esnext/root.esnext +275 -0
  148. package/node_modules/@shopify/react-testing/build/esnext/toReactString.esnext +80 -0
  149. package/node_modules/@shopify/react-testing/build/esnext/types.esnext +26 -0
  150. package/node_modules/@shopify/react-testing/build/ts/TestWrapper.d.ts +17 -0
  151. package/node_modules/@shopify/react-testing/build/ts/TestWrapper.d.ts.map +1 -0
  152. package/node_modules/@shopify/react-testing/build/ts/compat.d.ts +3 -0
  153. package/node_modules/@shopify/react-testing/build/ts/compat.d.ts.map +1 -0
  154. package/node_modules/@shopify/react-testing/build/ts/destroy.d.ts +2 -0
  155. package/node_modules/@shopify/react-testing/build/ts/destroy.d.ts.map +1 -0
  156. package/node_modules/@shopify/react-testing/build/ts/element.d.ts +42 -0
  157. package/node_modules/@shopify/react-testing/build/ts/element.d.ts.map +1 -0
  158. package/node_modules/@shopify/react-testing/build/ts/index.d.ts +7 -0
  159. package/node_modules/@shopify/react-testing/build/ts/index.d.ts.map +1 -0
  160. package/node_modules/@shopify/react-testing/build/ts/matchers/components.d.ts +12 -0
  161. package/node_modules/@shopify/react-testing/build/ts/matchers/components.d.ts.map +1 -0
  162. package/node_modules/@shopify/react-testing/build/ts/matchers/context.d.ts +8 -0
  163. package/node_modules/@shopify/react-testing/build/ts/matchers/context.d.ts.map +1 -0
  164. package/node_modules/@shopify/react-testing/build/ts/matchers/index.d.ts +20 -0
  165. package/node_modules/@shopify/react-testing/build/ts/matchers/index.d.ts.map +1 -0
  166. package/node_modules/@shopify/react-testing/build/ts/matchers/props.d.ts +10 -0
  167. package/node_modules/@shopify/react-testing/build/ts/matchers/props.d.ts.map +1 -0
  168. package/node_modules/@shopify/react-testing/build/ts/matchers/strings.d.ts +11 -0
  169. package/node_modules/@shopify/react-testing/build/ts/matchers/strings.d.ts.map +1 -0
  170. package/node_modules/@shopify/react-testing/build/ts/matchers/utilities.d.ts +17 -0
  171. package/node_modules/@shopify/react-testing/build/ts/matchers/utilities.d.ts.map +1 -0
  172. package/node_modules/@shopify/react-testing/build/ts/mount.d.ts +39 -0
  173. package/node_modules/@shopify/react-testing/build/ts/mount.d.ts.map +1 -0
  174. package/node_modules/@shopify/react-testing/build/ts/root.d.ts +55 -0
  175. package/node_modules/@shopify/react-testing/build/ts/root.d.ts.map +1 -0
  176. package/node_modules/@shopify/react-testing/build/ts/toReactString.d.ts +5 -0
  177. package/node_modules/@shopify/react-testing/build/ts/toReactString.d.ts.map +1 -0
  178. package/node_modules/@shopify/react-testing/build/ts/types.d.ts +89 -0
  179. package/node_modules/@shopify/react-testing/build/ts/types.d.ts.map +1 -0
  180. package/node_modules/@shopify/react-testing/index.esnext +1 -0
  181. package/node_modules/@shopify/react-testing/index.js +1 -0
  182. package/node_modules/@shopify/react-testing/index.mjs +1 -0
  183. package/node_modules/@shopify/react-testing/matchers.esnext +1 -0
  184. package/node_modules/@shopify/react-testing/matchers.js +1 -0
  185. package/node_modules/@shopify/react-testing/matchers.mjs +1 -0
  186. package/node_modules/@shopify/react-testing/package.json +69 -0
  187. package/node_modules/@shopify/ui-extensions-test-utils/CHANGELOG.md +66 -0
  188. package/node_modules/@shopify/ui-extensions-test-utils/dist/index.js +3 -0
  189. package/node_modules/@shopify/ui-extensions-test-utils/dist/render.js +5 -0
  190. package/node_modules/@shopify/ui-extensions-test-utils/dist/renderHook.js +20 -0
  191. package/node_modules/@shopify/ui-extensions-test-utils/dist/withProviders.js +6 -0
  192. package/node_modules/@shopify/ui-extensions-test-utils/package.json +41 -0
  193. package/node_modules/@shopify/ui-extensions-test-utils/project.json +39 -0
  194. package/node_modules/@types/node/LICENSE +21 -0
  195. package/node_modules/@types/node/README.md +15 -0
  196. package/node_modules/@types/node/assert/strict.d.ts +8 -0
  197. package/node_modules/@types/node/assert.d.ts +985 -0
  198. package/node_modules/@types/node/async_hooks.d.ts +522 -0
  199. package/node_modules/@types/node/buffer.d.ts +2321 -0
  200. package/node_modules/@types/node/child_process.d.ts +1544 -0
  201. package/node_modules/@types/node/cluster.d.ts +432 -0
  202. package/node_modules/@types/node/console.d.ts +412 -0
  203. package/node_modules/@types/node/constants.d.ts +19 -0
  204. package/node_modules/@types/node/crypto.d.ts +4451 -0
  205. package/node_modules/@types/node/dgram.d.ts +586 -0
  206. package/node_modules/@types/node/diagnostics_channel.d.ts +192 -0
  207. package/node_modules/@types/node/dns/promises.d.ts +381 -0
  208. package/node_modules/@types/node/dns.d.ts +809 -0
  209. package/node_modules/@types/node/dom-events.d.ts +122 -0
  210. package/node_modules/@types/node/domain.d.ts +170 -0
  211. package/node_modules/@types/node/events.d.ts +803 -0
  212. package/node_modules/@types/node/fs/promises.d.ts +1205 -0
  213. package/node_modules/@types/node/fs.d.ts +4211 -0
  214. package/node_modules/@types/node/globals.d.ts +377 -0
  215. package/node_modules/@types/node/globals.global.d.ts +1 -0
  216. package/node_modules/@types/node/http.d.ts +1801 -0
  217. package/node_modules/@types/node/http2.d.ts +2386 -0
  218. package/node_modules/@types/node/https.d.ts +544 -0
  219. package/node_modules/@types/node/index.d.ts +88 -0
  220. package/node_modules/@types/node/inspector.d.ts +2739 -0
  221. package/node_modules/@types/node/module.d.ts +298 -0
  222. package/node_modules/@types/node/net.d.ts +913 -0
  223. package/node_modules/@types/node/os.d.ts +473 -0
  224. package/node_modules/@types/node/package.json +235 -0
  225. package/node_modules/@types/node/path.d.ts +191 -0
  226. package/node_modules/@types/node/perf_hooks.d.ts +626 -0
  227. package/node_modules/@types/node/process.d.ts +1531 -0
  228. package/node_modules/@types/node/punycode.d.ts +117 -0
  229. package/node_modules/@types/node/querystring.d.ts +141 -0
  230. package/node_modules/@types/node/readline/promises.d.ts +143 -0
  231. package/node_modules/@types/node/readline.d.ts +666 -0
  232. package/node_modules/@types/node/repl.d.ts +430 -0
  233. package/node_modules/@types/node/stream/consumers.d.ts +12 -0
  234. package/node_modules/@types/node/stream/promises.d.ts +83 -0
  235. package/node_modules/@types/node/stream/web.d.ts +336 -0
  236. package/node_modules/@types/node/stream.d.ts +1731 -0
  237. package/node_modules/@types/node/string_decoder.d.ts +67 -0
  238. package/node_modules/@types/node/test.d.ts +1113 -0
  239. package/node_modules/@types/node/timers/promises.d.ts +93 -0
  240. package/node_modules/@types/node/timers.d.ts +126 -0
  241. package/node_modules/@types/node/tls.d.ts +1203 -0
  242. package/node_modules/@types/node/trace_events.d.ts +171 -0
  243. package/node_modules/@types/node/ts4.8/assert/strict.d.ts +8 -0
  244. package/node_modules/@types/node/ts4.8/assert.d.ts +985 -0
  245. package/node_modules/@types/node/ts4.8/async_hooks.d.ts +522 -0
  246. package/node_modules/@types/node/ts4.8/buffer.d.ts +2321 -0
  247. package/node_modules/@types/node/ts4.8/child_process.d.ts +1544 -0
  248. package/node_modules/@types/node/ts4.8/cluster.d.ts +432 -0
  249. package/node_modules/@types/node/ts4.8/console.d.ts +412 -0
  250. package/node_modules/@types/node/ts4.8/constants.d.ts +19 -0
  251. package/node_modules/@types/node/ts4.8/crypto.d.ts +4450 -0
  252. package/node_modules/@types/node/ts4.8/dgram.d.ts +586 -0
  253. package/node_modules/@types/node/ts4.8/diagnostics_channel.d.ts +192 -0
  254. package/node_modules/@types/node/ts4.8/dns/promises.d.ts +381 -0
  255. package/node_modules/@types/node/ts4.8/dns.d.ts +809 -0
  256. package/node_modules/@types/node/ts4.8/dom-events.d.ts +122 -0
  257. package/node_modules/@types/node/ts4.8/domain.d.ts +170 -0
  258. package/node_modules/@types/node/ts4.8/events.d.ts +754 -0
  259. package/node_modules/@types/node/ts4.8/fs/promises.d.ts +1205 -0
  260. package/node_modules/@types/node/ts4.8/fs.d.ts +4211 -0
  261. package/node_modules/@types/node/ts4.8/globals.d.ts +377 -0
  262. package/node_modules/@types/node/ts4.8/globals.global.d.ts +1 -0
  263. package/node_modules/@types/node/ts4.8/http.d.ts +1801 -0
  264. package/node_modules/@types/node/ts4.8/http2.d.ts +2386 -0
  265. package/node_modules/@types/node/ts4.8/https.d.ts +544 -0
  266. package/node_modules/@types/node/ts4.8/index.d.ts +88 -0
  267. package/node_modules/@types/node/ts4.8/inspector.d.ts +2739 -0
  268. package/node_modules/@types/node/ts4.8/module.d.ts +298 -0
  269. package/node_modules/@types/node/ts4.8/net.d.ts +913 -0
  270. package/node_modules/@types/node/ts4.8/os.d.ts +473 -0
  271. package/node_modules/@types/node/ts4.8/path.d.ts +191 -0
  272. package/node_modules/@types/node/ts4.8/perf_hooks.d.ts +626 -0
  273. package/node_modules/@types/node/ts4.8/process.d.ts +1531 -0
  274. package/node_modules/@types/node/ts4.8/punycode.d.ts +117 -0
  275. package/node_modules/@types/node/ts4.8/querystring.d.ts +141 -0
  276. package/node_modules/@types/node/ts4.8/readline/promises.d.ts +143 -0
  277. package/node_modules/@types/node/ts4.8/readline.d.ts +666 -0
  278. package/node_modules/@types/node/ts4.8/repl.d.ts +430 -0
  279. package/node_modules/@types/node/ts4.8/stream/consumers.d.ts +12 -0
  280. package/node_modules/@types/node/ts4.8/stream/promises.d.ts +83 -0
  281. package/node_modules/@types/node/ts4.8/stream/web.d.ts +336 -0
  282. package/node_modules/@types/node/ts4.8/stream.d.ts +1731 -0
  283. package/node_modules/@types/node/ts4.8/string_decoder.d.ts +67 -0
  284. package/node_modules/@types/node/ts4.8/test.d.ts +1113 -0
  285. package/node_modules/@types/node/ts4.8/timers/promises.d.ts +93 -0
  286. package/node_modules/@types/node/ts4.8/timers.d.ts +126 -0
  287. package/node_modules/@types/node/ts4.8/tls.d.ts +1203 -0
  288. package/node_modules/@types/node/ts4.8/trace_events.d.ts +171 -0
  289. package/node_modules/@types/node/ts4.8/tty.d.ts +206 -0
  290. package/node_modules/@types/node/ts4.8/url.d.ts +937 -0
  291. package/node_modules/@types/node/ts4.8/util.d.ts +2075 -0
  292. package/node_modules/@types/node/ts4.8/v8.d.ts +541 -0
  293. package/node_modules/@types/node/ts4.8/vm.d.ts +667 -0
  294. package/node_modules/@types/node/ts4.8/wasi.d.ts +158 -0
  295. package/node_modules/@types/node/ts4.8/worker_threads.d.ts +692 -0
  296. package/node_modules/@types/node/ts4.8/zlib.d.ts +517 -0
  297. package/node_modules/@types/node/tty.d.ts +206 -0
  298. package/node_modules/@types/node/url.d.ts +937 -0
  299. package/node_modules/@types/node/util.d.ts +2075 -0
  300. package/node_modules/@types/node/v8.d.ts +541 -0
  301. package/node_modules/@types/node/vm.d.ts +667 -0
  302. package/node_modules/@types/node/wasi.d.ts +158 -0
  303. package/node_modules/@types/node/worker_threads.d.ts +692 -0
  304. package/node_modules/@types/node/zlib.d.ts +517 -0
  305. package/node_modules/@types/react/LICENSE +21 -0
  306. package/node_modules/@types/react/README.md +16 -0
  307. package/node_modules/@types/react/experimental.d.ts +192 -0
  308. package/node_modules/@types/react/global.d.ts +151 -0
  309. package/node_modules/@types/react/index.d.ts +3175 -0
  310. package/node_modules/@types/react/jsx-dev-runtime.d.ts +2 -0
  311. package/node_modules/@types/react/jsx-runtime.d.ts +2 -0
  312. package/node_modules/@types/react/package.json +149 -0
  313. package/node_modules/@vitejs/plugin-react-refresh/LICENSE +21 -0
  314. package/node_modules/@vitejs/plugin-react-refresh/README.md +73 -0
  315. package/node_modules/@vitejs/plugin-react-refresh/index.d.ts +14 -0
  316. package/node_modules/@vitejs/plugin-react-refresh/index.js +239 -0
  317. package/node_modules/@vitejs/plugin-react-refresh/package.json +35 -0
  318. package/package.json +64 -0
  319. package/project.json +74 -0
  320. package/scripts/create-entry-files.ts +44 -0
  321. package/src/ExtensionServerClient/ExtensionServerClient.test.ts +730 -0
  322. package/src/ExtensionServerClient/ExtensionServerClient.ts +310 -0
  323. package/src/ExtensionServerClient/index.ts +2 -0
  324. package/src/ExtensionServerClient/types.ts +159 -0
  325. package/src/context/ExtensionServerProvider.test.tsx +173 -0
  326. package/src/context/ExtensionServerProvider.tsx +46 -0
  327. package/src/context/constants.ts +15 -0
  328. package/src/context/index.ts +3 -0
  329. package/src/context/types.ts +13 -0
  330. package/src/hooks/index.ts +5 -0
  331. package/src/hooks/useExtensionClient.ts +6 -0
  332. package/src/hooks/useExtensionServerContext.ts +4 -0
  333. package/src/hooks/useExtensionServerEvent.ts +11 -0
  334. package/src/hooks/useExtensionServerState.ts +6 -0
  335. package/src/hooks/useIsomorphicLayoutEffect.ts +6 -0
  336. package/src/i18n.test.ts +417 -0
  337. package/src/i18n.ts +208 -0
  338. package/src/index.ts +7 -0
  339. package/src/state/actions/actions.ts +36 -0
  340. package/src/state/actions/index.ts +2 -0
  341. package/src/state/actions/types.ts +26 -0
  342. package/src/state/index.ts +2 -0
  343. package/src/state/reducers/constants.ts +6 -0
  344. package/src/state/reducers/extensionServerReducer.test.ts +160 -0
  345. package/src/state/reducers/extensionServerReducer.ts +87 -0
  346. package/src/state/reducers/index.ts +3 -0
  347. package/src/state/reducers/types.ts +7 -0
  348. package/src/testing/MockExtensionServerProvider.tsx +36 -0
  349. package/src/testing/app.ts +15 -0
  350. package/src/testing/extensions.ts +70 -0
  351. package/src/testing/index.ts +3 -0
  352. package/src/types.ts +177 -0
  353. package/src/utilities/assetToString.test.ts +16 -0
  354. package/src/utilities/assetToString.ts +8 -0
  355. package/src/utilities/groupByKey.ts +3 -0
  356. package/src/utilities/index.ts +7 -0
  357. package/src/utilities/isUIExtension.ts +7 -0
  358. package/src/utilities/isValidSurface.ts +7 -0
  359. package/src/utilities/noop.ts +1 -0
  360. package/src/utilities/replaceUpdated.test.ts +26 -0
  361. package/src/utilities/replaceUpdated.ts +16 -0
  362. package/src/utilities/set.test.ts +19 -0
  363. package/src/utilities/set.ts +29 -0
  364. package/testing.d.ts +1 -0
  365. package/testing.js +1 -0
  366. package/testing.mjs +1 -0
  367. package/tests/setup.ts +6 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,127 @@
1
+ # @shopify/ui-extensions-server-kit
2
+
3
+ ## 0.0.0-snapshot-20240814205424
4
+
5
+ ### Patch Changes
6
+
7
+ - 40a7b1229: CLI now better handles 429 rate limiting for large projects
8
+
9
+ ## 5.2.0
10
+
11
+ ### Minor Changes
12
+
13
+ - 1d6fe3475: Increase minimum Node version to 18
14
+ - 0896e62b1: Versioned app config support
15
+
16
+ ## 5.1.0
17
+
18
+ ### Minor Changes
19
+
20
+ - 84fddcf69: Added support for optional localizable description to UI extensions dev and deploy
21
+
22
+ ## 5.0.0
23
+
24
+ ### Major Changes
25
+
26
+ - ec90885f4: Drop support for setting a translatable label at the extension point level.
27
+ The translatable merchant-facing string should be set at using the extension's name instead.
28
+
29
+ ### Minor Changes
30
+
31
+ - b8e11a77d: @shopify/ui-extensions-server-kit enable subscribing to connection open/close events
32
+
33
+ ### Patch Changes
34
+
35
+ - 8519a9701: Update helper for return the surface for each extension target to account for new target names
36
+
37
+ ## 4.2.1
38
+
39
+ ### Patch Changes
40
+
41
+ - ae1e35d42: Add missing apiVersion prop to the UIExtension interface
42
+
43
+ ## 4.2.0
44
+
45
+ ### Minor Changes
46
+
47
+ - 2c6e98652: Enable ui-extensions-server-kit to send translated strings for the requested locales
48
+
49
+ ## 4.1.0
50
+
51
+ ### Minor Changes
52
+
53
+ - 335a96a24: Improved dev console with new UX & functionality. New functionality: Preview app link and QRCode, better post purchase extension instructions, copy button for all preview links, support for upcoming UI extension changes
54
+
55
+ ## 4.0.1
56
+
57
+ ### Patch Changes
58
+
59
+ - 10b86c459: Expose missing API types
60
+
61
+ ## 4.0.0
62
+
63
+ ### Major Changes
64
+
65
+ - feee9215: Remove APIClient from ui-extensions-server-kit. APIClient is not used by the package and although it's exposed externally, all its functionality is also handled by ExtensionServerClient
66
+
67
+ ## 3.25.0
68
+
69
+ ## 3.24.1
70
+
71
+ ## 3.24.0
72
+
73
+ ## 3.23.0
74
+
75
+ ## 3.22.1
76
+
77
+ ## 3.22.0
78
+
79
+ ## 3.21.0
80
+
81
+ ## 3.20.1
82
+
83
+ ## 3.20.0
84
+
85
+ ## 3.19.0
86
+
87
+ ## 3.18.0
88
+
89
+ ## 3.17.0
90
+
91
+ ## 3.16.3
92
+
93
+ ## 3.16.2
94
+
95
+ ## 3.16.1
96
+
97
+ ## 3.16.0
98
+
99
+ ## 3.15.0
100
+
101
+ ## 3.14.0
102
+
103
+ ## 3.13.1
104
+
105
+ ## 3.13.0
106
+
107
+ ## 3.12.0
108
+
109
+ ## 3.11.0
110
+
111
+ ### Patch Changes
112
+
113
+ - 4fca2930: Fix prepack and private configurations
114
+
115
+ ## 3.10.1
116
+
117
+ ## 3.10.0
118
+
119
+ ## 3.9.2
120
+
121
+ ## 3.9.1
122
+
123
+ ## 3.9.0
124
+
125
+ ## 3.8.0
126
+
127
+ ## 3.7.1
package/README.md ADDED
@@ -0,0 +1,74 @@
1
+ <img src="https://github.com/Shopify/cli/blob/main/assets/logo.png?raw=true" width="150"/>
2
+
3
+ # Shopify CLI
4
+ <a href="http://twitter.com/ShopifyDevs"><img src="https://img.shields.io/twitter/follow/ShopifyDevs?style=flat-square" alt="Twitter Followers"></a>
5
+ <img src="https://img.shields.io/badge/License-MIT-green.svg" alt="License">
6
+ <a href="https://github.com/Shopify/cli/actions/workflows/shopify-cli.yml">![badge](https://github.com/Shopify/cli/actions/workflows/shopify-cli.yml/badge.svg)</a>
7
+
8
+ With the Shopify command line interface (Shopify CLI 3.0), you can:
9
+ - initialize, build, dev, and deploy Shopify apps, extensions, functions and themes
10
+ - build custom storefronts and manage their hosting
11
+
12
+ Learn more in the [commands docs](./packages/cli/README.md#commands).
13
+
14
+ <p>&nbsp;</p>
15
+
16
+ ### Before you begin ###
17
+
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
+
20
+ <p>&nbsp;</p>
21
+
22
+ ## Developing apps with Shopify CLI
23
+
24
+ When you’re building a Shopify app, you can initialize your project using your preferred package manager. A single command will install all the dependencies you need — including Shopify CLI itself.
25
+
26
+ Initialize your project using one of the following commands:
27
+ - `npm init @shopify/app@latest` (installed by default with Node)
28
+ - `pnpm create @shopify/create-app@latest`
29
+ - `yarn create @shopify/app`
30
+ - `bun create @shopify/app@latest` (experimental)
31
+
32
+ Learn more in the docs: [Create an app](https://shopify.dev/apps/getting-started/create)
33
+
34
+ <p>&nbsp;</p>
35
+
36
+ ## Developing themes with Shopify CLI
37
+
38
+ To work with themes, the CLI needs to be installed globally with:
39
+
40
+ - `npm install -g @shopify/cli @shopify/theme`
41
+
42
+ You can also use do it through Homebrew on macOS: `brew tap shopify/shopify && brew install shopify-cli`
43
+
44
+ Learn more in the docs: [Shopify CLI for themes](https://shopify.dev/docs/themes/tools/cli)
45
+
46
+ <p>&nbsp;</p>
47
+
48
+ ## Developing Hydrogen custom storefronts with Shopify CLI ##
49
+
50
+ The Hydrogen code lives here: https://github.com/Shopify/hydrogen/tree/main/packages/cli
51
+
52
+ Learn more in the docs: [Shopify CLI for Hydrogen storefronts](https://shopify.dev/docs/custom-storefronts/hydrogen/cli)
53
+
54
+ <p>&nbsp;</p>
55
+
56
+ ## Help 🖐
57
+
58
+ If you encounter issues using the CLI or have feedback you'd like to share with us, below are some options:
59
+
60
+ - [Open a GitHub issue](https://github.com/Shopify/cli/issues) - To report bugs or request new features, open an issue in the Shopify CLI repository
61
+ - [Shopify Community Forums](https://community.shopify.com/) - Visit our forums to connect with the community and learn more about Shopify CLI development
62
+ - [CLI Documentation - Apps](https://shopify.dev/apps/tools/cli) - To view CLI documentation for app development
63
+ - [CLI Documentation - Themes](https://shopify.dev/themes/tools/cli) - To view CLI documentation for theme development
64
+ - [CLI Documentation - Hydrogen](https://shopify.dev/custom-storefronts/tools/cli) - To view CLI documentation for Hydrogen (custom storefront) development
65
+
66
+ ## Contribute 👩🏽‍💻
67
+
68
+ If you'd like to contribute to the project, check out the [contributors docs](/docs) and the [steps to get started](/docs/cli/get-started.md).
69
+
70
+ <p>&nbsp;</p>
71
+
72
+ ## References
73
+
74
+ - [oclif](https://oclif.io/)
@@ -0,0 +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;
@@ -0,0 +1,28 @@
1
+ import { DeepPartial } from '../types';
2
+ export declare class ExtensionServerClient implements ExtensionServer.Client {
3
+ id: string;
4
+ connection: WebSocket;
5
+ options: ExtensionServer.Options;
6
+ protected EVENT_THAT_WILL_MUTATE_THE_SERVER: string[];
7
+ protected listeners: {
8
+ [key: string]: Set<any>;
9
+ };
10
+ protected connectionListeners: {
11
+ close: Set<any>;
12
+ open: Set<any>;
13
+ };
14
+ protected connected: boolean;
15
+ private uiExtensionsByUuid;
16
+ constructor(options?: DeepPartial<ExtensionServer.Options>);
17
+ connect(options?: ExtensionServer.Options): () => void;
18
+ on<TEvent extends keyof ExtensionServer.InboundEvents>(event: TEvent, listener: (payload: ExtensionServer.InboundEvents[TEvent]) => void): () => void;
19
+ persist<TEvent extends keyof ExtensionServer.OutboundPersistEvents>(event: TEvent, data: ExtensionServer.OutboundPersistEvents[TEvent]): void;
20
+ emit<TEvent extends keyof ExtensionServer.DispatchEvents>(...args: ExtensionServer.EmitArgs<TEvent>): void;
21
+ onConnection<TEvent extends keyof typeof this.connectionListeners>(event: TEvent, listener: (event: Event) => void): () => void;
22
+ protected initializeConnection(): void;
23
+ protected setupConnection(connectWebsocket?: boolean): void;
24
+ protected closeConnection(): void;
25
+ private _getLocalizedExtensions;
26
+ private _getLocalizedExtensionPoints;
27
+ private _getLocalizedValue;
28
+ }
@@ -0,0 +1,133 @@
1
+ import { TRANSLATED_KEYS as E, getFlattenedLocalization as g, isFlattenedTranslations as d } from "../i18n.es.js";
2
+ import { isValidSurface as m } from "../utilities/isValidSurface.es.js";
3
+ import { isUIExtension as f } from "../utilities/isUIExtension.es.js";
4
+ class z {
5
+ constructor(n = {}) {
6
+ this.EVENT_THAT_WILL_MUTATE_THE_SERVER = ["update"], this.listeners = {}, this.connectionListeners = { close: /* @__PURE__ */ new Set(), open: /* @__PURE__ */ new Set() }, this.connected = !1, this.uiExtensionsByUuid = {}, this.id = (Math.random() + 1).toString(36).substring(7), this.options = p({
7
+ ...n,
8
+ connection: {
9
+ automaticConnect: !0,
10
+ protocols: [],
11
+ ...n.connection ?? {}
12
+ }
13
+ }), this.setupConnection(this.options.connection.automaticConnect);
14
+ }
15
+ connect(n = { connection: {} }) {
16
+ const t = S(this.options, n);
17
+ return JSON.stringify(t) !== JSON.stringify(this.options) && (this.options = t, this.setupConnection(!0)), () => {
18
+ this.closeConnection();
19
+ };
20
+ }
21
+ on(n, t) {
22
+ return this.listeners[n] || (this.listeners[n] = /* @__PURE__ */ new Set()), this.listeners[n].add(t), () => this.listeners[n].delete(t);
23
+ }
24
+ persist(n, t) {
25
+ var s, e, i;
26
+ if (this.EVENT_THAT_WILL_MUTATE_THE_SERVER.includes(n))
27
+ return this.options.locales ? ((e = t.extensions) == null || e.forEach((o) => {
28
+ E.forEach((a) => {
29
+ var c;
30
+ f(o) && ((c = o.extensionPoints) == null || c.forEach((h) => {
31
+ delete h[a];
32
+ })), delete o[a];
33
+ });
34
+ }), (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 }));
35
+ console.warn('You tried to use "persist" with a dispatch event. Please use the "emit" method instead.');
36
+ }
37
+ emit(...n) {
38
+ var e;
39
+ const [t, s] = n;
40
+ if (this.EVENT_THAT_WILL_MUTATE_THE_SERVER.includes(t))
41
+ return console.warn(
42
+ `You tried to use "emit" with a the "${t}" event. Please use the "persist" method instead to persist changes to the server.`
43
+ );
44
+ (e = this.connection) == null || e.send(JSON.stringify({ event: "dispatch", data: { type: t, payload: s } }));
45
+ }
46
+ onConnection(n, t) {
47
+ return this.connectionListeners[n].add(t), () => this.connectionListeners[n].delete(t);
48
+ }
49
+ initializeConnection() {
50
+ var n;
51
+ this.connection && (this.connection.addEventListener("open", (t) => {
52
+ this.connected = !0, this.connectionListeners.open.forEach((s) => s(t));
53
+ }), this.connection.addEventListener("close", (t) => {
54
+ this.connected = !1, this.connectionListeners.close.forEach((s) => s(t));
55
+ }), (n = this.connection) == null || n.addEventListener("message", (t) => {
56
+ var s, e;
57
+ try {
58
+ const { event: i, data: o } = JSON.parse(t.data);
59
+ if (i === "dispatch") {
60
+ const { type: c, payload: h } = o;
61
+ (s = this.listeners[c]) == null || s.forEach((l) => l(h));
62
+ return;
63
+ }
64
+ const a = o.extensions ? T(o.extensions, this.options.surface) : o.extensions;
65
+ (e = this.listeners[i]) == null || e.forEach((c) => {
66
+ c({ ...o, extensions: this._getLocalizedExtensions(a) });
67
+ });
68
+ } catch (i) {
69
+ console.error(
70
+ "[ExtensionServer] Something went wrong while parsing a server message:",
71
+ i instanceof Error ? i.message : i
72
+ );
73
+ }
74
+ }));
75
+ }
76
+ setupConnection(n = !0) {
77
+ this.options.connection.url && n && (this.closeConnection(), this.connection = new WebSocket(this.options.connection.url, this.options.connection.protocols), this.initializeConnection());
78
+ }
79
+ closeConnection() {
80
+ var n;
81
+ this.connected && ((n = this.connection) == null || n.close());
82
+ }
83
+ _getLocalizedExtensions(n) {
84
+ return n == null ? void 0 : n.map((t) => {
85
+ var a, c, h, l, u;
86
+ if (!this.options.locales || !f(t))
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 = {
89
+ ...t,
90
+ localization: e,
91
+ name: i && t.name.startsWith("t:") ? this._getLocalizedValue(i, t.name) : t.name,
92
+ ...t.description && {
93
+ description: i && ((u = t.description) != null && u.startsWith("t:")) ? this._getLocalizedValue(i, t.description) : t.description
94
+ }
95
+ };
96
+ return this.uiExtensionsByUuid[t.uuid] = {
97
+ ...o,
98
+ extensionPoints: this._getLocalizedExtensionPoints(e, o)
99
+ }, this.uiExtensionsByUuid[t.uuid];
100
+ });
101
+ }
102
+ _getLocalizedExtensionPoints(n, { extensionPoints: t, name: s, description: e }) {
103
+ return !n || !d(n) ? t : t == null ? void 0 : t.map((i) => ({
104
+ ...i,
105
+ localization: n,
106
+ name: s,
107
+ ...e && { description: e }
108
+ }));
109
+ }
110
+ _getLocalizedValue(n, t) {
111
+ const s = t.replace("t:", "");
112
+ return n[s] || t;
113
+ }
114
+ }
115
+ function S(r, n) {
116
+ return p({
117
+ ...r,
118
+ ...n,
119
+ connection: {
120
+ ...r.connection,
121
+ ...n.connection
122
+ }
123
+ });
124
+ }
125
+ function p(r) {
126
+ return m(r.surface) || delete r.surface, r;
127
+ }
128
+ function T(r, n) {
129
+ 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;
130
+ }
131
+ export {
132
+ z as ExtensionServerClient
133
+ };
@@ -0,0 +1,2 @@
1
+ export * from './ExtensionServerClient';
2
+ export * from './types';
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=["admin","checkout","post_purchase","point_of_sale","customer-accounts"];exports.AVAILABLE_SURFACES=t;
@@ -0,0 +1,124 @@
1
+ import type { LocalesOptions } from '../i18n';
2
+ declare global {
3
+ namespace ExtensionServer {
4
+ /**
5
+ * Events being received by the extension server where the keys are the event names
6
+ * and the values are the payload of the given action. In case no payload is
7
+ * required, a value of void should be used.
8
+ */
9
+ interface InboundEvents {
10
+ }
11
+ /**
12
+ * Events being sent to the extension server where the keys are the event names
13
+ * and the values are the payload of the given action. In case no payload is
14
+ * required, a value of void should be used.
15
+ *
16
+ * Persist events are those that will generate changes on the server, like
17
+ * update and connected events. Dispatch events are those that will
18
+ * simply be proxied to the clients connected to the server.
19
+ */
20
+ interface OutboundPersistEvents {
21
+ }
22
+ interface DispatchEvents {
23
+ }
24
+ /**
25
+ * Extension server client class options. These are used to configure
26
+ * the client class.
27
+ */
28
+ interface Options {
29
+ connection: {
30
+ /**
31
+ * The absolute URL of the WebSocket.
32
+ */
33
+ url?: string;
34
+ /**
35
+ * This defines if we should automatically attempt to connect when the
36
+ * class is instantiated.
37
+ *
38
+ * @defaultValue true
39
+ */
40
+ automaticConnect?: boolean;
41
+ /**
42
+ * The sub-protocol selected by the server.
43
+ *
44
+ * @defaultValue []
45
+ */
46
+ protocols?: string | string[];
47
+ };
48
+ /**
49
+ * If provided the extension server will only return extensions that matches the specified surface
50
+ */
51
+ surface?: Surface;
52
+ /**
53
+ * If provided the extension server will return a requested translations object with flattened
54
+ * translations for each extension matching the requested locales
55
+ */
56
+ locales?: LocalesOptions;
57
+ }
58
+ /**
59
+ * Extension server client class. This class will be used to connect and
60
+ * communicate with the extension server.
61
+ */
62
+ interface Client {
63
+ /**
64
+ * Connection options
65
+ */
66
+ options: Options;
67
+ /**
68
+ * Reconnecting WebSocket Client
69
+ */
70
+ connection: WebSocket;
71
+ /**
72
+ * Function to add an event listener to messages coming from
73
+ * the extension server connection.
74
+ */
75
+ on<TEvent extends keyof ExtensionServer.InboundEvents>(event: TEvent, cb: EventListener<TEvent>): EventUnsubscriber;
76
+ /**
77
+ * Function to emit an event that will persist changes to the extension server.
78
+ */
79
+ persist<TEvent extends keyof OutboundPersistEvents>(event: TEvent, payload: OutboundPersistEvents[TEvent]): void;
80
+ /**
81
+ * Function to emit an event to the extension server.
82
+ */
83
+ emit<TEvent extends keyof DispatchEvents>(...args: EmitArgs<TEvent>): void;
84
+ /**
85
+ * Function that opens a connection with the extensions server.
86
+ */
87
+ connect(options?: Options): () => void;
88
+ }
89
+ /**
90
+ * This defines how the ExtensionServer client's static class is defined and the constructor
91
+ * arguments it requires.
92
+ *
93
+ * @example
94
+ * ```
95
+ * const client = new ExtensionServer({ url: 'wss://localhost:1234' });
96
+ * ```
97
+ */
98
+ type StaticClient = Static<ExtensionServer.Client, [option?: ExtensionServer.Options]>;
99
+ /**
100
+ * This helper type allows us to account for nullish payloads on the emit function.
101
+ * In practice, this will allow TypeScript to type-check the event being emitted
102
+ * and, if the payload isn't required, the second argument won't be necessary.
103
+ */
104
+ type EmitArgs<TEvent extends keyof ExtensionServer.DispatchEvents> = ExtensionServer.DispatchEvents[TEvent] extends void ? [event: TEvent] : [event: TEvent, payload: ExtensionServer.DispatchEvents[TEvent]];
105
+ /**
106
+ * This is a helper interface that allows us to define the static methods of a given
107
+ * class. This is useful to define static methods, static properties
108
+ * and constructor variables.
109
+ */
110
+ interface Static<T = unknown, TArgs extends unknown[] = unknown[]> {
111
+ prototype: T;
112
+ new (...args: TArgs): T;
113
+ }
114
+ /**
115
+ * This helper creates a partial interface with exception to the defined key values.
116
+ */
117
+ type PartialExcept<TOject, TKey extends keyof TOject> = Partial<Omit<TOject, TKey>> & Pick<TOject, TKey>;
118
+ type EventListener<TEvent extends keyof ExtensionServer.InboundEvents> = (payload: ExtensionServer.InboundEvents[TEvent]) => void;
119
+ type EventUnsubscriber = () => void;
120
+ }
121
+ }
122
+ export declare const AVAILABLE_SURFACES: readonly ["admin", "checkout", "post_purchase", "point_of_sale", "customer-accounts"];
123
+ export type Surface = (typeof AVAILABLE_SURFACES)[number];
124
+ export {};
@@ -0,0 +1,4 @@
1
+ const o = ["admin", "checkout", "post_purchase", "point_of_sale", "customer-accounts"];
2
+ export {
3
+ o as AVAILABLE_SURFACES
4
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const E=require("./constants.cjs.js"),o=require("../state/actions/actions.cjs.js"),d=require("../ExtensionServerClient/ExtensionServerClient.cjs.js"),a=require("../hooks/useIsomorphicLayoutEffect.cjs.js"),p=require("../hooks/useExtensionServerState.cjs.js"),r=require("react");function x({children:f,options:S}){const[i,n]=p.useExtensionServerState(),[c,v]=r.useState(S),[t]=r.useState(()=>new d.ExtensionServerClient),u=r.useCallback((s=c)=>{v(s)},[c]);a.useIsomorphicLayoutEffect(()=>t.connect(c),[t,c]),a.useIsomorphicLayoutEffect(()=>{const s=[t.on("update",e=>n(o.createUpdateAction(e))),t.on("connected",e=>n(o.createConnectedAction(e))),t.on("refresh",e=>n(o.createRefreshAction(e))),t.on("focus",e=>n(o.createFocusAction(e))),t.on("unfocus",e=>n(o.createUnfocusAction(e)))];return()=>s.forEach(e=>e())},[n]);const l=r.useMemo(()=>({dispatch:n,state:i,connect:u,client:t}),[n,u,i,t]);return r.createElement(E.extensionServerContext.Provider,{value:l},f)}exports.ExtensionServerProvider=x;
@@ -0,0 +1,2 @@
1
+ import type { ExtensionServerProviderProps } from './types';
2
+ export declare function ExtensionServerProvider({ children, options: defaultOptions }: ExtensionServerProviderProps): JSX.Element;
@@ -0,0 +1,29 @@
1
+ import { extensionServerContext as d } from "./constants.es.js";
2
+ import { createUpdateAction as l, createConnectedAction as v, createRefreshAction as x, createFocusAction as E, createUnfocusAction as S } from "../state/actions/actions.es.js";
3
+ import { ExtensionServerClient as h } from "../ExtensionServerClient/ExtensionServerClient.es.js";
4
+ import { useIsomorphicLayoutEffect as i } from "../hooks/useIsomorphicLayoutEffect.es.js";
5
+ import { useExtensionServerState as A } from "../hooks/useExtensionServerState.es.js";
6
+ import C, { useState as a, useCallback as P, useMemo as R } from "react";
7
+ function I({ children: u, options: f }) {
8
+ const [c, o] = A(), [n, m] = a(f), [t] = a(() => new h()), s = P(
9
+ (r = n) => {
10
+ m(r);
11
+ },
12
+ [n]
13
+ );
14
+ i(() => t.connect(n), [t, n]), i(() => {
15
+ const r = [
16
+ t.on("update", (e) => o(l(e))),
17
+ t.on("connected", (e) => o(v(e))),
18
+ t.on("refresh", (e) => o(x(e))),
19
+ t.on("focus", (e) => o(E(e))),
20
+ t.on("unfocus", (e) => o(S(e)))
21
+ ];
22
+ return () => r.forEach((e) => e());
23
+ }, [o]);
24
+ const p = R(() => ({ dispatch: o, state: c, connect: s, client: t }), [o, s, c, t]);
25
+ return /* @__PURE__ */ C.createElement(d.Provider, { value: p }, u);
26
+ }
27
+ export {
28
+ I as ExtensionServerProvider
29
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +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;
@@ -0,0 +1,3 @@
1
+ import type { ExtensionServerContext } from './types';
2
+ export declare const DEFAULT_VALUE: ExtensionServerContext;
3
+ export declare const extensionServerContext: import("react").Context<ExtensionServerContext>;
@@ -0,0 +1,14 @@
1
+ import { ExtensionServerClient as o } from "../ExtensionServerClient/ExtensionServerClient.es.js";
2
+ import { INITIAL_STATE as e } from "../state/reducers/constants.es.js";
3
+ import { noop as t } from "../utilities/noop.es.js";
4
+ import { createContext as n } from "react";
5
+ const r = {
6
+ connect: t,
7
+ dispatch: t,
8
+ state: e,
9
+ client: new o()
10
+ }, s = n(r);
11
+ export {
12
+ r as DEFAULT_VALUE,
13
+ s as extensionServerContext
14
+ };
@@ -0,0 +1,3 @@
1
+ export * from './ExtensionServerProvider';
2
+ export * from './constants';
3
+ export * from './types';
@@ -0,0 +1,11 @@
1
+ import type { ExtensionServerState, ExtensionServerActions } from '../state';
2
+ export interface ExtensionServerContext {
3
+ client: ExtensionServer.Client;
4
+ state: ExtensionServerState;
5
+ connect(options?: ExtensionServer.Options): void;
6
+ dispatch(action: ExtensionServerActions): void;
7
+ }
8
+ export interface ExtensionServerProviderProps {
9
+ children?: React.ReactNode;
10
+ options: ExtensionServer.Options;
11
+ }
@@ -0,0 +1,5 @@
1
+ export * from './useExtensionClient';
2
+ export * from './useExtensionServerContext';
3
+ export * from './useExtensionServerEvent';
4
+ export * from './useExtensionServerState';
5
+ export * from './useIsomorphicLayoutEffect';
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./useExtensionServerContext.cjs.js");function n(){const{client:e}=t.useExtensionServerContext();return e}exports.useExtensionClient=n;
@@ -0,0 +1 @@
1
+ export declare function useExtensionClient(): ExtensionServer.Client;
@@ -0,0 +1,8 @@
1
+ import { useExtensionServerContext as n } from "./useExtensionServerContext.es.js";
2
+ function o() {
3
+ const { client: e } = n();
4
+ return e;
5
+ }
6
+ export {
7
+ o as useExtensionClient
8
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../context/constants.cjs.js"),t=require("react"),n=()=>t.useContext(e.extensionServerContext);exports.useExtensionServerContext=n;
@@ -0,0 +1 @@
1
+ export declare const useExtensionServerContext: () => import("../context").ExtensionServerContext;
@@ -0,0 +1,6 @@
1
+ import { extensionServerContext as e } from "../context/constants.es.js";
2
+ import { useContext as t } from "react";
3
+ const n = () => t(e);
4
+ export {
5
+ n as useExtensionServerContext
6
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./useExtensionServerContext.cjs.js"),r=require("./useIsomorphicLayoutEffect.cjs.js");function s(e,t){const{client:o}=n.useExtensionServerContext();r.useIsomorphicLayoutEffect(()=>o.on(e,t),[o,e,t])}exports.useExtensionServerEvent=s;
@@ -0,0 +1 @@
1
+ export declare function useExtensionServerEvent<TEvent extends keyof ExtensionServer.InboundEvents>(event: TEvent, listener: ExtensionServer.EventListener<TEvent>): void;
@@ -0,0 +1,9 @@
1
+ import { useExtensionServerContext as n } from "./useExtensionServerContext.es.js";
2
+ import { useIsomorphicLayoutEffect as r } from "./useIsomorphicLayoutEffect.es.js";
3
+ function c(o, t) {
4
+ const { client: e } = n();
5
+ r(() => e.on(o, t), [e, o, t]);
6
+ }
7
+ export {
8
+ c as useExtensionServerEvent
9
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../state/reducers/constants.cjs.js"),r=require("../state/reducers/extensionServerReducer.cjs.js"),t=require("react");function n(){return t.useReducer(r.extensionServerReducer,e.INITIAL_STATE)}exports.useExtensionServerState=n;