@shopify/ui-extensions-server-kit 5.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +121 -0
- package/README.md +74 -0
- package/dist/ExtensionServerClient/ExtensionServerClient.cjs.js +1 -0
- package/dist/ExtensionServerClient/ExtensionServerClient.d.ts +28 -0
- package/dist/ExtensionServerClient/ExtensionServerClient.es.js +133 -0
- package/dist/ExtensionServerClient/ExtensionServerClient.test.d.ts +1 -0
- package/dist/ExtensionServerClient/index.d.ts +2 -0
- package/dist/ExtensionServerClient/types.cjs.js +1 -0
- package/dist/ExtensionServerClient/types.d.ts +124 -0
- package/dist/ExtensionServerClient/types.es.js +4 -0
- package/dist/context/ExtensionServerProvider.cjs.js +1 -0
- package/dist/context/ExtensionServerProvider.d.ts +2 -0
- package/dist/context/ExtensionServerProvider.es.js +29 -0
- package/dist/context/ExtensionServerProvider.test.d.ts +1 -0
- package/dist/context/constants.cjs.js +1 -0
- package/dist/context/constants.d.ts +3 -0
- package/dist/context/constants.es.js +14 -0
- package/dist/context/index.d.ts +3 -0
- package/dist/context/types.d.ts +11 -0
- package/dist/hooks/index.d.ts +5 -0
- package/dist/hooks/useExtensionClient.cjs.js +1 -0
- package/dist/hooks/useExtensionClient.d.ts +1 -0
- package/dist/hooks/useExtensionClient.es.js +8 -0
- package/dist/hooks/useExtensionServerContext.cjs.js +1 -0
- package/dist/hooks/useExtensionServerContext.d.ts +1 -0
- package/dist/hooks/useExtensionServerContext.es.js +6 -0
- package/dist/hooks/useExtensionServerEvent.cjs.js +1 -0
- package/dist/hooks/useExtensionServerEvent.d.ts +1 -0
- package/dist/hooks/useExtensionServerEvent.es.js +9 -0
- package/dist/hooks/useExtensionServerState.cjs.js +1 -0
- package/dist/hooks/useExtensionServerState.d.ts +1 -0
- package/dist/hooks/useExtensionServerState.es.js +9 -0
- package/dist/hooks/useIsomorphicLayoutEffect.cjs.js +1 -0
- package/dist/hooks/useIsomorphicLayoutEffect.d.ts +2 -0
- package/dist/hooks/useIsomorphicLayoutEffect.es.js +5 -0
- package/dist/i18n.cjs.js +1 -0
- package/dist/i18n.d.ts +93 -0
- package/dist/i18n.es.js +61 -0
- package/dist/i18n.test.d.ts +1 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.cjs2.js +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.es.js +54 -0
- package/dist/index.es2.js +8 -0
- package/dist/state/actions/actions.cjs.js +1 -0
- package/dist/state/actions/actions.d.ts +6 -0
- package/dist/state/actions/actions.es.js +37 -0
- package/dist/state/actions/index.d.ts +2 -0
- package/dist/state/actions/types.d.ts +21 -0
- package/dist/state/index.d.ts +2 -0
- package/dist/state/reducers/constants.cjs.js +1 -0
- package/dist/state/reducers/constants.d.ts +2 -0
- package/dist/state/reducers/constants.es.js +7 -0
- package/dist/state/reducers/extensionServerReducer.cjs.js +1 -0
- package/dist/state/reducers/extensionServerReducer.d.ts +3 -0
- package/dist/state/reducers/extensionServerReducer.es.js +57 -0
- package/dist/state/reducers/extensionServerReducer.test.d.ts +1 -0
- package/dist/state/reducers/index.d.ts +3 -0
- package/dist/state/reducers/types.d.ts +6 -0
- package/dist/testing/MockExtensionServerProvider.cjs.js +1 -0
- package/dist/testing/MockExtensionServerProvider.d.ts +7 -0
- package/dist/testing/MockExtensionServerProvider.es.js +24 -0
- package/dist/testing/app.cjs.js +1 -0
- package/dist/testing/app.d.ts +2 -0
- package/dist/testing/app.es.js +16 -0
- package/dist/testing/extensions.cjs.js +1 -0
- package/dist/testing/extensions.d.ts +6 -0
- package/dist/testing/extensions.es.js +65 -0
- package/dist/testing/index.d.ts +3 -0
- package/dist/types.cjs.js +1 -0
- package/dist/types.d.ts +169 -0
- package/dist/types.es.js +4 -0
- package/dist/utilities/assetToString.cjs.js +1 -0
- package/dist/utilities/assetToString.d.ts +2 -0
- package/dist/utilities/assetToString.es.js +7 -0
- package/dist/utilities/assetToString.test.d.ts +1 -0
- package/dist/utilities/groupByKey.cjs.js +1 -0
- package/dist/utilities/groupByKey.d.ts +3 -0
- package/dist/utilities/groupByKey.es.js +6 -0
- package/dist/utilities/index.d.ts +7 -0
- package/dist/utilities/isUIExtension.cjs.js +1 -0
- package/dist/utilities/isUIExtension.d.ts +1 -0
- package/dist/utilities/isUIExtension.es.js +6 -0
- package/dist/utilities/isValidSurface.cjs.js +1 -0
- package/dist/utilities/isValidSurface.d.ts +2 -0
- package/dist/utilities/isValidSurface.es.js +7 -0
- package/dist/utilities/noop.cjs.js +1 -0
- package/dist/utilities/noop.d.ts +1 -0
- package/dist/utilities/noop.es.js +5 -0
- package/dist/utilities/replaceUpdated.cjs.js +1 -0
- package/dist/utilities/replaceUpdated.d.ts +1 -0
- package/dist/utilities/replaceUpdated.es.js +14 -0
- package/dist/utilities/replaceUpdated.test.d.ts +1 -0
- package/dist/utilities/set.cjs.js +1 -0
- package/dist/utilities/set.d.ts +4 -0
- package/dist/utilities/set.es.js +18 -0
- package/dist/utilities/set.test.d.ts +1 -0
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/index.mjs +1 -0
- package/node_modules/@shopify/react-testing/LICENSE.md +21 -0
- package/node_modules/@shopify/react-testing/README.md +711 -0
- package/node_modules/@shopify/react-testing/build/cjs/TestWrapper.js +52 -0
- package/node_modules/@shopify/react-testing/build/cjs/_virtual/_rollupPluginBabelHelpers.js +47 -0
- package/node_modules/@shopify/react-testing/build/cjs/compat.js +14 -0
- package/node_modules/@shopify/react-testing/build/cjs/destroy.js +13 -0
- package/node_modules/@shopify/react-testing/build/cjs/element.js +225 -0
- package/node_modules/@shopify/react-testing/build/cjs/index.js +21 -0
- package/node_modules/@shopify/react-testing/build/cjs/matchers/components.js +46 -0
- package/node_modules/@shopify/react-testing/build/cjs/matchers/context.js +25 -0
- package/node_modules/@shopify/react-testing/build/cjs/matchers/index.js +16 -0
- package/node_modules/@shopify/react-testing/build/cjs/matchers/props.js +38 -0
- package/node_modules/@shopify/react-testing/build/cjs/matchers/strings.js +42 -0
- package/node_modules/@shopify/react-testing/build/cjs/matchers/utilities.js +110 -0
- package/node_modules/@shopify/react-testing/build/cjs/mount.js +76 -0
- package/node_modules/@shopify/react-testing/build/cjs/root.js +284 -0
- package/node_modules/@shopify/react-testing/build/cjs/toReactString.js +86 -0
- package/node_modules/@shopify/react-testing/build/cjs/types.js +28 -0
- package/node_modules/@shopify/react-testing/build/esm/TestWrapper.mjs +44 -0
- package/node_modules/@shopify/react-testing/build/esm/_virtual/_rollupPluginBabelHelpers.mjs +42 -0
- package/node_modules/@shopify/react-testing/build/esm/compat.mjs +10 -0
- package/node_modules/@shopify/react-testing/build/esm/destroy.mjs +9 -0
- package/node_modules/@shopify/react-testing/build/esm/element.mjs +221 -0
- package/node_modules/@shopify/react-testing/build/esm/index.mjs +5 -0
- package/node_modules/@shopify/react-testing/build/esm/matchers/components.mjs +41 -0
- package/node_modules/@shopify/react-testing/build/esm/matchers/context.mjs +21 -0
- package/node_modules/@shopify/react-testing/build/esm/matchers/index.mjs +14 -0
- package/node_modules/@shopify/react-testing/build/esm/matchers/props.mjs +33 -0
- package/node_modules/@shopify/react-testing/build/esm/matchers/strings.mjs +37 -0
- package/node_modules/@shopify/react-testing/build/esm/matchers/utilities.mjs +101 -0
- package/node_modules/@shopify/react-testing/build/esm/mount.mjs +70 -0
- package/node_modules/@shopify/react-testing/build/esm/root.mjs +275 -0
- package/node_modules/@shopify/react-testing/build/esm/toReactString.mjs +80 -0
- package/node_modules/@shopify/react-testing/build/esm/types.mjs +26 -0
- package/node_modules/@shopify/react-testing/build/esnext/TestWrapper.esnext +44 -0
- package/node_modules/@shopify/react-testing/build/esnext/compat.esnext +10 -0
- package/node_modules/@shopify/react-testing/build/esnext/destroy.esnext +9 -0
- package/node_modules/@shopify/react-testing/build/esnext/element.esnext +221 -0
- package/node_modules/@shopify/react-testing/build/esnext/index.esnext +5 -0
- package/node_modules/@shopify/react-testing/build/esnext/matchers/components.esnext +41 -0
- package/node_modules/@shopify/react-testing/build/esnext/matchers/context.esnext +21 -0
- package/node_modules/@shopify/react-testing/build/esnext/matchers/index.esnext +14 -0
- package/node_modules/@shopify/react-testing/build/esnext/matchers/props.esnext +33 -0
- package/node_modules/@shopify/react-testing/build/esnext/matchers/strings.esnext +37 -0
- package/node_modules/@shopify/react-testing/build/esnext/matchers/utilities.esnext +99 -0
- package/node_modules/@shopify/react-testing/build/esnext/mount.esnext +71 -0
- package/node_modules/@shopify/react-testing/build/esnext/root.esnext +275 -0
- package/node_modules/@shopify/react-testing/build/esnext/toReactString.esnext +80 -0
- package/node_modules/@shopify/react-testing/build/esnext/types.esnext +26 -0
- package/node_modules/@shopify/react-testing/build/ts/TestWrapper.d.ts +17 -0
- package/node_modules/@shopify/react-testing/build/ts/TestWrapper.d.ts.map +1 -0
- package/node_modules/@shopify/react-testing/build/ts/compat.d.ts +3 -0
- package/node_modules/@shopify/react-testing/build/ts/compat.d.ts.map +1 -0
- package/node_modules/@shopify/react-testing/build/ts/destroy.d.ts +2 -0
- package/node_modules/@shopify/react-testing/build/ts/destroy.d.ts.map +1 -0
- package/node_modules/@shopify/react-testing/build/ts/element.d.ts +42 -0
- package/node_modules/@shopify/react-testing/build/ts/element.d.ts.map +1 -0
- package/node_modules/@shopify/react-testing/build/ts/index.d.ts +7 -0
- package/node_modules/@shopify/react-testing/build/ts/index.d.ts.map +1 -0
- package/node_modules/@shopify/react-testing/build/ts/matchers/components.d.ts +12 -0
- package/node_modules/@shopify/react-testing/build/ts/matchers/components.d.ts.map +1 -0
- package/node_modules/@shopify/react-testing/build/ts/matchers/context.d.ts +8 -0
- package/node_modules/@shopify/react-testing/build/ts/matchers/context.d.ts.map +1 -0
- package/node_modules/@shopify/react-testing/build/ts/matchers/index.d.ts +20 -0
- package/node_modules/@shopify/react-testing/build/ts/matchers/index.d.ts.map +1 -0
- package/node_modules/@shopify/react-testing/build/ts/matchers/props.d.ts +10 -0
- package/node_modules/@shopify/react-testing/build/ts/matchers/props.d.ts.map +1 -0
- package/node_modules/@shopify/react-testing/build/ts/matchers/strings.d.ts +11 -0
- package/node_modules/@shopify/react-testing/build/ts/matchers/strings.d.ts.map +1 -0
- package/node_modules/@shopify/react-testing/build/ts/matchers/utilities.d.ts +17 -0
- package/node_modules/@shopify/react-testing/build/ts/matchers/utilities.d.ts.map +1 -0
- package/node_modules/@shopify/react-testing/build/ts/mount.d.ts +39 -0
- package/node_modules/@shopify/react-testing/build/ts/mount.d.ts.map +1 -0
- package/node_modules/@shopify/react-testing/build/ts/root.d.ts +55 -0
- package/node_modules/@shopify/react-testing/build/ts/root.d.ts.map +1 -0
- package/node_modules/@shopify/react-testing/build/ts/toReactString.d.ts +5 -0
- package/node_modules/@shopify/react-testing/build/ts/toReactString.d.ts.map +1 -0
- package/node_modules/@shopify/react-testing/build/ts/types.d.ts +89 -0
- package/node_modules/@shopify/react-testing/build/ts/types.d.ts.map +1 -0
- package/node_modules/@shopify/react-testing/index.esnext +1 -0
- package/node_modules/@shopify/react-testing/index.js +1 -0
- package/node_modules/@shopify/react-testing/index.mjs +1 -0
- package/node_modules/@shopify/react-testing/matchers.esnext +1 -0
- package/node_modules/@shopify/react-testing/matchers.js +1 -0
- package/node_modules/@shopify/react-testing/matchers.mjs +1 -0
- package/node_modules/@shopify/react-testing/package.json +69 -0
- package/node_modules/@shopify/ui-extensions-test-utils/CHANGELOG.md +66 -0
- package/node_modules/@shopify/ui-extensions-test-utils/dist/index.js +3 -0
- package/node_modules/@shopify/ui-extensions-test-utils/dist/render.js +5 -0
- package/node_modules/@shopify/ui-extensions-test-utils/dist/renderHook.js +20 -0
- package/node_modules/@shopify/ui-extensions-test-utils/dist/withProviders.js +6 -0
- package/node_modules/@shopify/ui-extensions-test-utils/package.json +41 -0
- package/node_modules/@shopify/ui-extensions-test-utils/project.json +39 -0
- package/node_modules/@types/node/LICENSE +21 -0
- package/node_modules/@types/node/README.md +15 -0
- package/node_modules/@types/node/assert/strict.d.ts +8 -0
- package/node_modules/@types/node/assert.d.ts +985 -0
- package/node_modules/@types/node/async_hooks.d.ts +522 -0
- package/node_modules/@types/node/buffer.d.ts +2321 -0
- package/node_modules/@types/node/child_process.d.ts +1544 -0
- package/node_modules/@types/node/cluster.d.ts +432 -0
- package/node_modules/@types/node/console.d.ts +412 -0
- package/node_modules/@types/node/constants.d.ts +19 -0
- package/node_modules/@types/node/crypto.d.ts +4451 -0
- package/node_modules/@types/node/dgram.d.ts +586 -0
- package/node_modules/@types/node/diagnostics_channel.d.ts +192 -0
- package/node_modules/@types/node/dns/promises.d.ts +381 -0
- package/node_modules/@types/node/dns.d.ts +809 -0
- package/node_modules/@types/node/dom-events.d.ts +122 -0
- package/node_modules/@types/node/domain.d.ts +170 -0
- package/node_modules/@types/node/events.d.ts +803 -0
- package/node_modules/@types/node/fs/promises.d.ts +1205 -0
- package/node_modules/@types/node/fs.d.ts +4211 -0
- package/node_modules/@types/node/globals.d.ts +377 -0
- package/node_modules/@types/node/globals.global.d.ts +1 -0
- package/node_modules/@types/node/http.d.ts +1801 -0
- package/node_modules/@types/node/http2.d.ts +2386 -0
- package/node_modules/@types/node/https.d.ts +544 -0
- package/node_modules/@types/node/index.d.ts +88 -0
- package/node_modules/@types/node/inspector.d.ts +2739 -0
- package/node_modules/@types/node/module.d.ts +298 -0
- package/node_modules/@types/node/net.d.ts +913 -0
- package/node_modules/@types/node/os.d.ts +473 -0
- package/node_modules/@types/node/package.json +235 -0
- package/node_modules/@types/node/path.d.ts +191 -0
- package/node_modules/@types/node/perf_hooks.d.ts +626 -0
- package/node_modules/@types/node/process.d.ts +1531 -0
- package/node_modules/@types/node/punycode.d.ts +117 -0
- package/node_modules/@types/node/querystring.d.ts +141 -0
- package/node_modules/@types/node/readline/promises.d.ts +143 -0
- package/node_modules/@types/node/readline.d.ts +666 -0
- package/node_modules/@types/node/repl.d.ts +430 -0
- package/node_modules/@types/node/stream/consumers.d.ts +12 -0
- package/node_modules/@types/node/stream/promises.d.ts +83 -0
- package/node_modules/@types/node/stream/web.d.ts +336 -0
- package/node_modules/@types/node/stream.d.ts +1731 -0
- package/node_modules/@types/node/string_decoder.d.ts +67 -0
- package/node_modules/@types/node/test.d.ts +1113 -0
- package/node_modules/@types/node/timers/promises.d.ts +93 -0
- package/node_modules/@types/node/timers.d.ts +126 -0
- package/node_modules/@types/node/tls.d.ts +1203 -0
- package/node_modules/@types/node/trace_events.d.ts +171 -0
- package/node_modules/@types/node/ts4.8/assert/strict.d.ts +8 -0
- package/node_modules/@types/node/ts4.8/assert.d.ts +985 -0
- package/node_modules/@types/node/ts4.8/async_hooks.d.ts +522 -0
- package/node_modules/@types/node/ts4.8/buffer.d.ts +2321 -0
- package/node_modules/@types/node/ts4.8/child_process.d.ts +1544 -0
- package/node_modules/@types/node/ts4.8/cluster.d.ts +432 -0
- package/node_modules/@types/node/ts4.8/console.d.ts +412 -0
- package/node_modules/@types/node/ts4.8/constants.d.ts +19 -0
- package/node_modules/@types/node/ts4.8/crypto.d.ts +4450 -0
- package/node_modules/@types/node/ts4.8/dgram.d.ts +586 -0
- package/node_modules/@types/node/ts4.8/diagnostics_channel.d.ts +192 -0
- package/node_modules/@types/node/ts4.8/dns/promises.d.ts +381 -0
- package/node_modules/@types/node/ts4.8/dns.d.ts +809 -0
- package/node_modules/@types/node/ts4.8/dom-events.d.ts +122 -0
- package/node_modules/@types/node/ts4.8/domain.d.ts +170 -0
- package/node_modules/@types/node/ts4.8/events.d.ts +754 -0
- package/node_modules/@types/node/ts4.8/fs/promises.d.ts +1205 -0
- package/node_modules/@types/node/ts4.8/fs.d.ts +4211 -0
- package/node_modules/@types/node/ts4.8/globals.d.ts +377 -0
- package/node_modules/@types/node/ts4.8/globals.global.d.ts +1 -0
- package/node_modules/@types/node/ts4.8/http.d.ts +1801 -0
- package/node_modules/@types/node/ts4.8/http2.d.ts +2386 -0
- package/node_modules/@types/node/ts4.8/https.d.ts +544 -0
- package/node_modules/@types/node/ts4.8/index.d.ts +88 -0
- package/node_modules/@types/node/ts4.8/inspector.d.ts +2739 -0
- package/node_modules/@types/node/ts4.8/module.d.ts +298 -0
- package/node_modules/@types/node/ts4.8/net.d.ts +913 -0
- package/node_modules/@types/node/ts4.8/os.d.ts +473 -0
- package/node_modules/@types/node/ts4.8/path.d.ts +191 -0
- package/node_modules/@types/node/ts4.8/perf_hooks.d.ts +626 -0
- package/node_modules/@types/node/ts4.8/process.d.ts +1531 -0
- package/node_modules/@types/node/ts4.8/punycode.d.ts +117 -0
- package/node_modules/@types/node/ts4.8/querystring.d.ts +141 -0
- package/node_modules/@types/node/ts4.8/readline/promises.d.ts +143 -0
- package/node_modules/@types/node/ts4.8/readline.d.ts +666 -0
- package/node_modules/@types/node/ts4.8/repl.d.ts +430 -0
- package/node_modules/@types/node/ts4.8/stream/consumers.d.ts +12 -0
- package/node_modules/@types/node/ts4.8/stream/promises.d.ts +83 -0
- package/node_modules/@types/node/ts4.8/stream/web.d.ts +336 -0
- package/node_modules/@types/node/ts4.8/stream.d.ts +1731 -0
- package/node_modules/@types/node/ts4.8/string_decoder.d.ts +67 -0
- package/node_modules/@types/node/ts4.8/test.d.ts +1113 -0
- package/node_modules/@types/node/ts4.8/timers/promises.d.ts +93 -0
- package/node_modules/@types/node/ts4.8/timers.d.ts +126 -0
- package/node_modules/@types/node/ts4.8/tls.d.ts +1203 -0
- package/node_modules/@types/node/ts4.8/trace_events.d.ts +171 -0
- package/node_modules/@types/node/ts4.8/tty.d.ts +206 -0
- package/node_modules/@types/node/ts4.8/url.d.ts +937 -0
- package/node_modules/@types/node/ts4.8/util.d.ts +2075 -0
- package/node_modules/@types/node/ts4.8/v8.d.ts +541 -0
- package/node_modules/@types/node/ts4.8/vm.d.ts +667 -0
- package/node_modules/@types/node/ts4.8/wasi.d.ts +158 -0
- package/node_modules/@types/node/ts4.8/worker_threads.d.ts +692 -0
- package/node_modules/@types/node/ts4.8/zlib.d.ts +517 -0
- package/node_modules/@types/node/tty.d.ts +206 -0
- package/node_modules/@types/node/url.d.ts +937 -0
- package/node_modules/@types/node/util.d.ts +2075 -0
- package/node_modules/@types/node/v8.d.ts +541 -0
- package/node_modules/@types/node/vm.d.ts +667 -0
- package/node_modules/@types/node/wasi.d.ts +158 -0
- package/node_modules/@types/node/worker_threads.d.ts +692 -0
- package/node_modules/@types/node/zlib.d.ts +517 -0
- package/node_modules/@types/react/LICENSE +21 -0
- package/node_modules/@types/react/README.md +16 -0
- package/node_modules/@types/react/experimental.d.ts +192 -0
- package/node_modules/@types/react/global.d.ts +151 -0
- package/node_modules/@types/react/index.d.ts +3175 -0
- package/node_modules/@types/react/jsx-dev-runtime.d.ts +2 -0
- package/node_modules/@types/react/jsx-runtime.d.ts +2 -0
- package/node_modules/@types/react/package.json +149 -0
- package/node_modules/@vitejs/plugin-react-refresh/LICENSE +21 -0
- package/node_modules/@vitejs/plugin-react-refresh/README.md +73 -0
- package/node_modules/@vitejs/plugin-react-refresh/index.d.ts +14 -0
- package/node_modules/@vitejs/plugin-react-refresh/index.js +239 -0
- package/node_modules/@vitejs/plugin-react-refresh/package.json +35 -0
- package/package.json +65 -0
- package/project.json +74 -0
- package/scripts/create-entry-files.ts +44 -0
- package/src/ExtensionServerClient/ExtensionServerClient.test.ts +730 -0
- package/src/ExtensionServerClient/ExtensionServerClient.ts +310 -0
- package/src/ExtensionServerClient/index.ts +2 -0
- package/src/ExtensionServerClient/types.ts +159 -0
- package/src/context/ExtensionServerProvider.test.tsx +173 -0
- package/src/context/ExtensionServerProvider.tsx +46 -0
- package/src/context/constants.ts +15 -0
- package/src/context/index.ts +3 -0
- package/src/context/types.ts +13 -0
- package/src/hooks/index.ts +5 -0
- package/src/hooks/useExtensionClient.ts +6 -0
- package/src/hooks/useExtensionServerContext.ts +4 -0
- package/src/hooks/useExtensionServerEvent.ts +11 -0
- package/src/hooks/useExtensionServerState.ts +6 -0
- package/src/hooks/useIsomorphicLayoutEffect.ts +6 -0
- package/src/i18n.test.ts +417 -0
- package/src/i18n.ts +208 -0
- package/src/index.ts +7 -0
- package/src/state/actions/actions.ts +36 -0
- package/src/state/actions/index.ts +2 -0
- package/src/state/actions/types.ts +26 -0
- package/src/state/index.ts +2 -0
- package/src/state/reducers/constants.ts +6 -0
- package/src/state/reducers/extensionServerReducer.test.ts +160 -0
- package/src/state/reducers/extensionServerReducer.ts +87 -0
- package/src/state/reducers/index.ts +3 -0
- package/src/state/reducers/types.ts +7 -0
- package/src/testing/MockExtensionServerProvider.tsx +36 -0
- package/src/testing/app.ts +15 -0
- package/src/testing/extensions.ts +70 -0
- package/src/testing/index.ts +3 -0
- package/src/types.ts +172 -0
- package/src/utilities/assetToString.test.ts +16 -0
- package/src/utilities/assetToString.ts +8 -0
- package/src/utilities/groupByKey.ts +3 -0
- package/src/utilities/index.ts +7 -0
- package/src/utilities/isUIExtension.ts +7 -0
- package/src/utilities/isValidSurface.ts +7 -0
- package/src/utilities/noop.ts +1 -0
- package/src/utilities/replaceUpdated.test.ts +26 -0
- package/src/utilities/replaceUpdated.ts +16 -0
- package/src/utilities/set.test.ts +19 -0
- package/src/utilities/set.ts +29 -0
- package/testing.d.ts +1 -0
- package/testing.js +1 -0
- package/testing.mjs +1 -0
- package/tests/setup.ts +6 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
# @shopify/ui-extensions-server-kit
|
|
2
|
+
|
|
3
|
+
## 5.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 1d6fe3475: Increase minimum Node version to 18
|
|
8
|
+
- 0896e62b1: Versioned app config support
|
|
9
|
+
|
|
10
|
+
## 5.1.0
|
|
11
|
+
|
|
12
|
+
### Minor Changes
|
|
13
|
+
|
|
14
|
+
- 84fddcf69: Added support for optional localizable description to UI extensions dev and deploy
|
|
15
|
+
|
|
16
|
+
## 5.0.0
|
|
17
|
+
|
|
18
|
+
### Major Changes
|
|
19
|
+
|
|
20
|
+
- ec90885f4: Drop support for setting a translatable label at the extension point level.
|
|
21
|
+
The translatable merchant-facing string should be set at using the extension's name instead.
|
|
22
|
+
|
|
23
|
+
### Minor Changes
|
|
24
|
+
|
|
25
|
+
- b8e11a77d: @shopify/ui-extensions-server-kit enable subscribing to connection open/close events
|
|
26
|
+
|
|
27
|
+
### Patch Changes
|
|
28
|
+
|
|
29
|
+
- 8519a9701: Update helper for return the surface for each extension target to account for new target names
|
|
30
|
+
|
|
31
|
+
## 4.2.1
|
|
32
|
+
|
|
33
|
+
### Patch Changes
|
|
34
|
+
|
|
35
|
+
- ae1e35d42: Add missing apiVersion prop to the UIExtension interface
|
|
36
|
+
|
|
37
|
+
## 4.2.0
|
|
38
|
+
|
|
39
|
+
### Minor Changes
|
|
40
|
+
|
|
41
|
+
- 2c6e98652: Enable ui-extensions-server-kit to send translated strings for the requested locales
|
|
42
|
+
|
|
43
|
+
## 4.1.0
|
|
44
|
+
|
|
45
|
+
### Minor Changes
|
|
46
|
+
|
|
47
|
+
- 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
|
|
48
|
+
|
|
49
|
+
## 4.0.1
|
|
50
|
+
|
|
51
|
+
### Patch Changes
|
|
52
|
+
|
|
53
|
+
- 10b86c459: Expose missing API types
|
|
54
|
+
|
|
55
|
+
## 4.0.0
|
|
56
|
+
|
|
57
|
+
### Major Changes
|
|
58
|
+
|
|
59
|
+
- 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
|
|
60
|
+
|
|
61
|
+
## 3.25.0
|
|
62
|
+
|
|
63
|
+
## 3.24.1
|
|
64
|
+
|
|
65
|
+
## 3.24.0
|
|
66
|
+
|
|
67
|
+
## 3.23.0
|
|
68
|
+
|
|
69
|
+
## 3.22.1
|
|
70
|
+
|
|
71
|
+
## 3.22.0
|
|
72
|
+
|
|
73
|
+
## 3.21.0
|
|
74
|
+
|
|
75
|
+
## 3.20.1
|
|
76
|
+
|
|
77
|
+
## 3.20.0
|
|
78
|
+
|
|
79
|
+
## 3.19.0
|
|
80
|
+
|
|
81
|
+
## 3.18.0
|
|
82
|
+
|
|
83
|
+
## 3.17.0
|
|
84
|
+
|
|
85
|
+
## 3.16.3
|
|
86
|
+
|
|
87
|
+
## 3.16.2
|
|
88
|
+
|
|
89
|
+
## 3.16.1
|
|
90
|
+
|
|
91
|
+
## 3.16.0
|
|
92
|
+
|
|
93
|
+
## 3.15.0
|
|
94
|
+
|
|
95
|
+
## 3.14.0
|
|
96
|
+
|
|
97
|
+
## 3.13.1
|
|
98
|
+
|
|
99
|
+
## 3.13.0
|
|
100
|
+
|
|
101
|
+
## 3.12.0
|
|
102
|
+
|
|
103
|
+
## 3.11.0
|
|
104
|
+
|
|
105
|
+
### Patch Changes
|
|
106
|
+
|
|
107
|
+
- 4fca2930: Fix prepack and private configurations
|
|
108
|
+
|
|
109
|
+
## 3.10.1
|
|
110
|
+
|
|
111
|
+
## 3.10.0
|
|
112
|
+
|
|
113
|
+
## 3.9.2
|
|
114
|
+
|
|
115
|
+
## 3.9.1
|
|
116
|
+
|
|
117
|
+
## 3.9.0
|
|
118
|
+
|
|
119
|
+
## 3.8.0
|
|
120
|
+
|
|
121
|
+
## 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"></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> </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> </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> </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> </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> </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> </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 @@
|
|
|
1
|
+
export {};
|
|
@@ -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 @@
|
|
|
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,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,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,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 @@
|
|
|
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 @@
|
|
|
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 @@
|
|
|
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;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useExtensionServerState(): [import("../state").ExtensionServerState, import("react").Dispatch<import("../state").ExtensionServerActions>];
|