@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.
- package/CHANGELOG.md +127 -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 +173 -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 +64 -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 +177 -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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useExtensionServerState(): [import("../state").ExtensionServerState, import("react").Dispatch<import("../state").ExtensionServerActions>];
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { INITIAL_STATE as e } from "../state/reducers/constants.es.js";
|
|
2
|
+
import { extensionServerReducer as r } from "../state/reducers/extensionServerReducer.es.js";
|
|
3
|
+
import { useReducer as o } from "react";
|
|
4
|
+
function m() {
|
|
5
|
+
return o(r, e);
|
|
6
|
+
}
|
|
7
|
+
export {
|
|
8
|
+
m as useExtensionServerState
|
|
9
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),t=typeof window>"u"||!window.navigator||/ServerSideRendering|^Deno\//.test(window.navigator.userAgent),o=t?e.useEffect:e.useLayoutEffect;exports.useIsomorphicLayoutEffect=o;
|
package/dist/i18n.cjs.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const L=["localization","name","description"];function u(n){const t=new Map;return f(n,(e,s)=>t.set(e,s)),t}function f(n,t,e){Object.keys(n).forEach(s=>{const o=n[s],r=e?`${e}.${s}`:s;o!=null&&(typeof o=="string"?t(r,o):f(o,t,r))})}function c(n,t){const e=a(n.translations[n.defaultLocale]),s=i(t),o=a(n.translations[s]),r=a(n.translations[t]);return d(new Map([...e,...o,...r]))}function a(n){return n?u(n):new Map}function p(n,t){const e=new Set(Object.keys(n.translations));if(e.size===0||e.has(t.user))return t.user;const s=i(t.user);if(e.has(s))return s;if(t.shop&&e.has(t.shop))return t.shop;const o=t.shop&&i(t.shop);return o&&e.has(o)?o:n.defaultLocale}function d(n){const t={};for(const[e,s]of n)t[e]=s;return t}function i(n){return n.split("-")[0]}function T(n,t){if(!n||!t)return;if(l(n))return n;const e=p(n,t),s=JSON.stringify(c(n,e));return{extensionLocale:e,translations:s,lastUpdated:n.lastUpdated}}function l(n){return typeof n.translations=="string"&&Object.prototype.hasOwnProperty.call(n,"extensionLocale")}exports.TRANSLATED_KEYS=L;exports.dictionaryToFlatMap=u;exports.flattenDevExtensionTranslations=c;exports.getFlattenedLocalization=T;exports.isFlattenedTranslations=l;exports.resolveDevExtensionLocale=p;
|
package/dist/i18n.d.ts
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* These translation utilities were adapted from https://github.com/Shopify/checkout-web/blob/master/app/utilities/development-mode/i18n-utilities.tsx
|
|
3
|
+
* */
|
|
4
|
+
type Translation = string | {
|
|
5
|
+
[key: string]: Translation;
|
|
6
|
+
};
|
|
7
|
+
export interface Localization {
|
|
8
|
+
defaultLocale: string;
|
|
9
|
+
translations: {
|
|
10
|
+
[key: string]: {
|
|
11
|
+
[key: string]: Translation;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
lastUpdated: number;
|
|
15
|
+
}
|
|
16
|
+
export interface FlattenedLocalization {
|
|
17
|
+
extensionLocale: string;
|
|
18
|
+
translations: string;
|
|
19
|
+
lastUpdated: number;
|
|
20
|
+
}
|
|
21
|
+
export interface LocalesOptions {
|
|
22
|
+
user: string;
|
|
23
|
+
shop?: string;
|
|
24
|
+
}
|
|
25
|
+
export interface TranslationDictionary {
|
|
26
|
+
[key: string]: string | TranslationDictionary;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* This is a flattened dictionary of extension translations for the active locale.
|
|
30
|
+
*
|
|
31
|
+
* Here are some examples for the 'en' locale.
|
|
32
|
+
*
|
|
33
|
+
* Nested keys are dot separated. Consider this translation definition:
|
|
34
|
+
*
|
|
35
|
+
* ```
|
|
36
|
+
* {
|
|
37
|
+
* "greetings": {
|
|
38
|
+
* "hello": "Hello {{user}}"
|
|
39
|
+
* }
|
|
40
|
+
* }
|
|
41
|
+
* ```
|
|
42
|
+
*
|
|
43
|
+
* It would be represented in this flattened dictionary as:
|
|
44
|
+
* ```
|
|
45
|
+
* {
|
|
46
|
+
* "greetings.hello": "Hello {{user}}"
|
|
47
|
+
* }
|
|
48
|
+
* ```
|
|
49
|
+
* Pluralized translations will also be flattened. Consider this definition:
|
|
50
|
+
* ```
|
|
51
|
+
* {
|
|
52
|
+
* "loyaltyPointsRemaining": {
|
|
53
|
+
* "one": "You have {{count}} loyalty point",
|
|
54
|
+
* "other": "You have {{count}} loyalty points",
|
|
55
|
+
* }
|
|
56
|
+
* }
|
|
57
|
+
* ```
|
|
58
|
+
* It would be represented in this flattened dictionary as:
|
|
59
|
+
* ```
|
|
60
|
+
* {
|
|
61
|
+
* "loyaltyPointsRemaining.one": "You have {{count}} loyalty point",
|
|
62
|
+
* "loyaltyPointsRemaining.other": "You have {{count}} loyalty points",
|
|
63
|
+
* }
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
export interface ExtensionTranslationMap {
|
|
67
|
+
[key: string]: string;
|
|
68
|
+
}
|
|
69
|
+
export declare const TRANSLATED_KEYS: string[];
|
|
70
|
+
/**
|
|
71
|
+
* From a nested dictionary like the following :
|
|
72
|
+
*
|
|
73
|
+
* ```typescript
|
|
74
|
+
* const dictionary = {
|
|
75
|
+
* Foo: {
|
|
76
|
+
* Bar: {
|
|
77
|
+
* fooBar: 'something'
|
|
78
|
+
* }
|
|
79
|
+
* }
|
|
80
|
+
* }
|
|
81
|
+
*
|
|
82
|
+
* Returns a map containing this pair : {'Foo.Bar.fooBar': 'something'}
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
85
|
+
export declare function dictionaryToFlatMap(dictionary: TranslationDictionary): Map<string, string>;
|
|
86
|
+
export declare function flattenDevExtensionTranslations(localization: Localization, locale: string): ExtensionTranslationMap;
|
|
87
|
+
export declare function resolveDevExtensionLocale(localization: Localization, locales: {
|
|
88
|
+
user: string;
|
|
89
|
+
shop?: string;
|
|
90
|
+
}): string;
|
|
91
|
+
export declare function getFlattenedLocalization(localization?: FlattenedLocalization | Localization | null, locales?: LocalesOptions): FlattenedLocalization | undefined;
|
|
92
|
+
export declare function isFlattenedTranslations(localization: Localization | FlattenedLocalization): localization is FlattenedLocalization;
|
|
93
|
+
export {};
|
package/dist/i18n.es.js
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
const h = ["localization", "name", "description"];
|
|
2
|
+
function f(n) {
|
|
3
|
+
const t = /* @__PURE__ */ new Map();
|
|
4
|
+
return u(n, (e, s) => t.set(e, s)), t;
|
|
5
|
+
}
|
|
6
|
+
function u(n, t, e) {
|
|
7
|
+
Object.keys(n).forEach((s) => {
|
|
8
|
+
const r = n[s], o = e ? `${e}.${s}` : s;
|
|
9
|
+
r != null && (typeof r == "string" ? t(o, r) : u(r, t, o));
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
function c(n, t) {
|
|
13
|
+
const e = a(n.translations[n.defaultLocale]), s = i(t), r = a(n.translations[s]), o = a(n.translations[t]);
|
|
14
|
+
return L(
|
|
15
|
+
new Map([...e, ...r, ...o])
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
function a(n) {
|
|
19
|
+
return n ? f(n) : /* @__PURE__ */ new Map();
|
|
20
|
+
}
|
|
21
|
+
function p(n, t) {
|
|
22
|
+
const e = new Set(Object.keys(n.translations));
|
|
23
|
+
if (e.size === 0 || e.has(t.user)) return t.user;
|
|
24
|
+
const s = i(t.user);
|
|
25
|
+
if (e.has(s)) return s;
|
|
26
|
+
if (t.shop && e.has(t.shop)) return t.shop;
|
|
27
|
+
const r = t.shop && i(t.shop);
|
|
28
|
+
return r && e.has(r) ? r : n.defaultLocale;
|
|
29
|
+
}
|
|
30
|
+
function L(n) {
|
|
31
|
+
const t = {};
|
|
32
|
+
for (const [e, s] of n)
|
|
33
|
+
t[e] = s;
|
|
34
|
+
return t;
|
|
35
|
+
}
|
|
36
|
+
function i(n) {
|
|
37
|
+
return n.split("-")[0];
|
|
38
|
+
}
|
|
39
|
+
function l(n, t) {
|
|
40
|
+
if (!n || !t)
|
|
41
|
+
return;
|
|
42
|
+
if (d(n))
|
|
43
|
+
return n;
|
|
44
|
+
const e = p(n, t), s = JSON.stringify(c(n, e));
|
|
45
|
+
return {
|
|
46
|
+
extensionLocale: e,
|
|
47
|
+
translations: s,
|
|
48
|
+
lastUpdated: n.lastUpdated
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
function d(n) {
|
|
52
|
+
return typeof n.translations == "string" && Object.prototype.hasOwnProperty.call(n, "extensionLocale");
|
|
53
|
+
}
|
|
54
|
+
export {
|
|
55
|
+
h as TRANSLATED_KEYS,
|
|
56
|
+
f as dictionaryToFlatMap,
|
|
57
|
+
c as flattenDevExtensionTranslations,
|
|
58
|
+
l as getFlattenedLocalization,
|
|
59
|
+
d as isFlattenedTranslations,
|
|
60
|
+
p as resolveDevExtensionLocale
|
|
61
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./context/ExtensionServerProvider.cjs.js"),n=require("./context/constants.cjs.js"),o=require("./ExtensionServerClient/ExtensionServerClient.cjs.js"),s=require("./ExtensionServerClient/types.cjs.js"),i=require("./hooks/useExtensionClient.cjs.js"),c=require("./hooks/useExtensionServerContext.cjs.js"),a=require("./hooks/useExtensionServerEvent.cjs.js"),u=require("./hooks/useExtensionServerState.cjs.js"),E=require("./hooks/useIsomorphicLayoutEffect.cjs.js"),t=require("./state/actions/actions.cjs.js"),S=require("./state/reducers/constants.cjs.js"),x=require("./state/reducers/extensionServerReducer.cjs.js"),l=require("./types.cjs.js"),v=require("./utilities/groupByKey.cjs.js"),A=require("./utilities/noop.cjs.js"),d=require("./utilities/replaceUpdated.cjs.js"),p=require("./utilities/set.cjs.js"),T=require("./utilities/assetToString.cjs.js"),q=require("./utilities/isValidSurface.cjs.js"),L=require("./utilities/isUIExtension.cjs.js"),e=require("./i18n.cjs.js");exports.ExtensionServerProvider=r.ExtensionServerProvider;exports.DEFAULT_VALUE=n.DEFAULT_VALUE;exports.extensionServerContext=n.extensionServerContext;exports.ExtensionServerClient=o.ExtensionServerClient;exports.AVAILABLE_SURFACES=s.AVAILABLE_SURFACES;exports.useExtensionClient=i.useExtensionClient;exports.useExtensionServerContext=c.useExtensionServerContext;exports.useExtensionServerEvent=a.useExtensionServerEvent;exports.useExtensionServerState=u.useExtensionServerState;exports.useIsomorphicLayoutEffect=E.useIsomorphicLayoutEffect;exports.createConnectedAction=t.createConnectedAction;exports.createFocusAction=t.createFocusAction;exports.createRefreshAction=t.createRefreshAction;exports.createUnfocusAction=t.createUnfocusAction;exports.createUpdateAction=t.createUpdateAction;exports.INITIAL_STATE=S.INITIAL_STATE;exports.extensionServerReducer=x.extensionServerReducer;exports.Status=l.Status;exports.groupByKey=v.groupByKey;exports.noop=A.noop;exports.replaceUpdated=d.replaceUpdated;exports.set=p.set;exports.assetToString=T.assetToString;exports.isValidSurface=q.isValidSurface;exports.isUIExtension=L.isUIExtension;exports.TRANSLATED_KEYS=e.TRANSLATED_KEYS;exports.dictionaryToFlatMap=e.dictionaryToFlatMap;exports.flattenDevExtensionTranslations=e.flattenDevExtensionTranslations;exports.getFlattenedLocalization=e.getFlattenedLocalization;exports.isFlattenedTranslations=e.isFlattenedTranslations;exports.resolveDevExtensionLocale=e.resolveDevExtensionLocale;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./testing/MockExtensionServerProvider.cjs.js"),o=require("./testing/app.cjs.js"),r=require("./testing/extensions.cjs.js");exports.MockExtensionServerProvider=e.MockExtensionServerProvider;exports.mockApp=o.mockApp;exports.mockExtension=r.mockExtension;
|
package/dist/index.d.ts
ADDED
package/dist/index.es.js
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { ExtensionServerProvider as r } from "./context/ExtensionServerProvider.es.js";
|
|
2
|
+
import { DEFAULT_VALUE as n, extensionServerContext as x } from "./context/constants.es.js";
|
|
3
|
+
import { ExtensionServerClient as i } from "./ExtensionServerClient/ExtensionServerClient.es.js";
|
|
4
|
+
import { AVAILABLE_SURFACES as a } from "./ExtensionServerClient/types.es.js";
|
|
5
|
+
import { useExtensionClient as m } from "./hooks/useExtensionClient.es.js";
|
|
6
|
+
import { useExtensionServerContext as E } from "./hooks/useExtensionServerContext.es.js";
|
|
7
|
+
import { useExtensionServerEvent as A } from "./hooks/useExtensionServerEvent.es.js";
|
|
8
|
+
import { useExtensionServerState as u } from "./hooks/useExtensionServerState.es.js";
|
|
9
|
+
import { useIsomorphicLayoutEffect as d } from "./hooks/useIsomorphicLayoutEffect.es.js";
|
|
10
|
+
import { createConnectedAction as L, createFocusAction as U, createRefreshAction as C, createUnfocusAction as F, createUpdateAction as I } from "./state/actions/actions.es.js";
|
|
11
|
+
import { INITIAL_STATE as D } from "./state/reducers/constants.es.js";
|
|
12
|
+
import { extensionServerReducer as _ } from "./state/reducers/extensionServerReducer.es.js";
|
|
13
|
+
import { Status as V } from "./types.es.js";
|
|
14
|
+
import { groupByKey as B } from "./utilities/groupByKey.es.js";
|
|
15
|
+
import { noop as N } from "./utilities/noop.es.js";
|
|
16
|
+
import { replaceUpdated as M } from "./utilities/replaceUpdated.es.js";
|
|
17
|
+
import { set as Y } from "./utilities/set.es.js";
|
|
18
|
+
import { assetToString as j } from "./utilities/assetToString.es.js";
|
|
19
|
+
import { isValidSurface as q } from "./utilities/isValidSurface.es.js";
|
|
20
|
+
import { isUIExtension as G } from "./utilities/isUIExtension.es.js";
|
|
21
|
+
import { TRANSLATED_KEYS as J, dictionaryToFlatMap as O, flattenDevExtensionTranslations as Q, getFlattenedLocalization as W, isFlattenedTranslations as X, resolveDevExtensionLocale as Z } from "./i18n.es.js";
|
|
22
|
+
export {
|
|
23
|
+
a as AVAILABLE_SURFACES,
|
|
24
|
+
n as DEFAULT_VALUE,
|
|
25
|
+
i as ExtensionServerClient,
|
|
26
|
+
r as ExtensionServerProvider,
|
|
27
|
+
D as INITIAL_STATE,
|
|
28
|
+
V as Status,
|
|
29
|
+
J as TRANSLATED_KEYS,
|
|
30
|
+
j as assetToString,
|
|
31
|
+
L as createConnectedAction,
|
|
32
|
+
U as createFocusAction,
|
|
33
|
+
C as createRefreshAction,
|
|
34
|
+
F as createUnfocusAction,
|
|
35
|
+
I as createUpdateAction,
|
|
36
|
+
O as dictionaryToFlatMap,
|
|
37
|
+
x as extensionServerContext,
|
|
38
|
+
_ as extensionServerReducer,
|
|
39
|
+
Q as flattenDevExtensionTranslations,
|
|
40
|
+
W as getFlattenedLocalization,
|
|
41
|
+
B as groupByKey,
|
|
42
|
+
X as isFlattenedTranslations,
|
|
43
|
+
G as isUIExtension,
|
|
44
|
+
q as isValidSurface,
|
|
45
|
+
N as noop,
|
|
46
|
+
M as replaceUpdated,
|
|
47
|
+
Z as resolveDevExtensionLocale,
|
|
48
|
+
Y as set,
|
|
49
|
+
m as useExtensionClient,
|
|
50
|
+
E as useExtensionServerContext,
|
|
51
|
+
A as useExtensionServerEvent,
|
|
52
|
+
u as useExtensionServerState,
|
|
53
|
+
d as useIsomorphicLayoutEffect
|
|
54
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { MockExtensionServerProvider as e } from "./testing/MockExtensionServerProvider.es.js";
|
|
2
|
+
import { mockApp as p } from "./testing/app.es.js";
|
|
3
|
+
import { mockExtension as x } from "./testing/extensions.es.js";
|
|
4
|
+
export {
|
|
5
|
+
e as MockExtensionServerProvider,
|
|
6
|
+
p as mockApp,
|
|
7
|
+
x as mockExtension
|
|
8
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function t(e){return{type:"connected",payload:e}}function c(e){return{type:"update",payload:e}}function n(e){return{type:"refresh",payload:e}}function o(e){return{type:"focus",payload:e}}function r(e){return{type:"unfocus",payload:e}}exports.createConnectedAction=t;exports.createFocusAction=o;exports.createRefreshAction=n;exports.createUnfocusAction=r;exports.createUpdateAction=c;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ConnectedAction, UpdateAction, RefreshAction, FocusAction, UnfocusAction } from './types';
|
|
2
|
+
export declare function createConnectedAction(payload: ConnectedAction['payload']): ConnectedAction;
|
|
3
|
+
export declare function createUpdateAction(payload: UpdateAction['payload']): UpdateAction;
|
|
4
|
+
export declare function createRefreshAction(payload: RefreshAction['payload']): RefreshAction;
|
|
5
|
+
export declare function createFocusAction(payload: FocusAction['payload']): FocusAction;
|
|
6
|
+
export declare function createUnfocusAction(payload: UnfocusAction['payload']): UnfocusAction;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
function t(e) {
|
|
2
|
+
return {
|
|
3
|
+
type: "connected",
|
|
4
|
+
payload: e
|
|
5
|
+
};
|
|
6
|
+
}
|
|
7
|
+
function n(e) {
|
|
8
|
+
return {
|
|
9
|
+
type: "update",
|
|
10
|
+
payload: e
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
function c(e) {
|
|
14
|
+
return {
|
|
15
|
+
type: "refresh",
|
|
16
|
+
payload: e
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
function r(e) {
|
|
20
|
+
return {
|
|
21
|
+
type: "focus",
|
|
22
|
+
payload: e
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
function o(e) {
|
|
26
|
+
return {
|
|
27
|
+
type: "unfocus",
|
|
28
|
+
payload: e
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
export {
|
|
32
|
+
t as createConnectedAction,
|
|
33
|
+
r as createFocusAction,
|
|
34
|
+
c as createRefreshAction,
|
|
35
|
+
o as createUnfocusAction,
|
|
36
|
+
n as createUpdateAction
|
|
37
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export interface ConnectedAction {
|
|
2
|
+
type: 'connected';
|
|
3
|
+
payload: ExtensionServer.InboundEvents['connected'];
|
|
4
|
+
}
|
|
5
|
+
export interface UpdateAction {
|
|
6
|
+
type: 'update';
|
|
7
|
+
payload: ExtensionServer.InboundEvents['update'];
|
|
8
|
+
}
|
|
9
|
+
export interface RefreshAction {
|
|
10
|
+
type: 'refresh';
|
|
11
|
+
payload: ExtensionServer.InboundEvents['refresh'];
|
|
12
|
+
}
|
|
13
|
+
export interface FocusAction {
|
|
14
|
+
type: 'focus';
|
|
15
|
+
payload: ExtensionServer.InboundEvents['focus'];
|
|
16
|
+
}
|
|
17
|
+
export interface UnfocusAction {
|
|
18
|
+
type: 'unfocus';
|
|
19
|
+
payload: ExtensionServer.InboundEvents['unfocus'];
|
|
20
|
+
}
|
|
21
|
+
export type ExtensionServerActions = ConnectedAction | UpdateAction | RefreshAction | FocusAction | UnfocusAction;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e={extensions:[],store:""};exports.INITIAL_STATE=e;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("../../utilities/replaceUpdated.cjs.js"),o=require("../../utilities/set.cjs.js"),p=require("../../utilities/assetToString.cjs.js");function c(r,t){switch(t.type){case"connected":{const s=(t.payload.extensions??[]).map(e=>(Object.keys(e.assets).forEach(u=>e.assets[u].url=p.assetToString(e.assets[u])),e));return{...r,store:t.payload.store,app:t.payload.app,extensions:s}}case"update":{const s=(t.payload.extensions??[]).map(e=>(Object.keys(e.assets).forEach(u=>e.assets[u].url=p.assetToString(e.assets[u])),e));return{...r,app:{...r.app??{},...t.payload.app??{}},extensions:d.replaceUpdated(r.extensions,s,({uuid:e})=>e)}}case"refresh":return{...r,extensions:r.extensions.map(s=>{if(t.payload.some(({uuid:e})=>s.uuid===e)){const e={};return Object.keys(s.assets).forEach(u=>{const a={...s.assets[u]};a.lastUpdated=Date.now(),a.url=p.assetToString(a),e[u]=a}),o.set(s,u=>u.assets,e)}return s})};case"focus":return{...r,extensions:r.extensions.map(s=>t.payload.some(({uuid:e})=>s.uuid===e)?o.set(s,e=>e.development.focused,!0):s.development.focused?o.set(s,e=>e.development.focused,!1):s)};case"unfocus":return{...r,extensions:r.extensions.map(s=>s.development.focused?o.set(s,e=>e.development.focused,!1):s)};default:return r}}exports.extensionServerReducer=c;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { replaceUpdated as t } from "../../utilities/replaceUpdated.es.js";
|
|
2
|
+
import { set as o } from "../../utilities/set.es.js";
|
|
3
|
+
import { assetToString as d } from "../../utilities/assetToString.es.js";
|
|
4
|
+
function m(r, u) {
|
|
5
|
+
switch (u.type) {
|
|
6
|
+
case "connected": {
|
|
7
|
+
const s = (u.payload.extensions ?? []).map((e) => (Object.keys(e.assets).forEach(
|
|
8
|
+
(p) => e.assets[p].url = d(e.assets[p])
|
|
9
|
+
), e));
|
|
10
|
+
return {
|
|
11
|
+
...r,
|
|
12
|
+
store: u.payload.store,
|
|
13
|
+
app: u.payload.app,
|
|
14
|
+
extensions: s
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
case "update": {
|
|
18
|
+
const s = (u.payload.extensions ?? []).map((e) => (Object.keys(e.assets).forEach(
|
|
19
|
+
(p) => e.assets[p].url = d(e.assets[p])
|
|
20
|
+
), e));
|
|
21
|
+
return {
|
|
22
|
+
...r,
|
|
23
|
+
app: { ...r.app ?? {}, ...u.payload.app ?? {} },
|
|
24
|
+
extensions: t(r.extensions, s, ({ uuid: e }) => e)
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
case "refresh":
|
|
28
|
+
return {
|
|
29
|
+
...r,
|
|
30
|
+
extensions: r.extensions.map((s) => {
|
|
31
|
+
if (u.payload.some(({ uuid: e }) => s.uuid === e)) {
|
|
32
|
+
const e = {};
|
|
33
|
+
return Object.keys(s.assets).forEach((p) => {
|
|
34
|
+
const a = { ...s.assets[p] };
|
|
35
|
+
a.lastUpdated = Date.now(), a.url = d(a), e[p] = a;
|
|
36
|
+
}), o(s, (p) => p.assets, e);
|
|
37
|
+
}
|
|
38
|
+
return s;
|
|
39
|
+
})
|
|
40
|
+
};
|
|
41
|
+
case "focus":
|
|
42
|
+
return {
|
|
43
|
+
...r,
|
|
44
|
+
extensions: r.extensions.map((s) => u.payload.some(({ uuid: e }) => s.uuid === e) ? o(s, (e) => e.development.focused, !0) : s.development.focused ? o(s, (e) => e.development.focused, !1) : s)
|
|
45
|
+
};
|
|
46
|
+
case "unfocus":
|
|
47
|
+
return {
|
|
48
|
+
...r,
|
|
49
|
+
extensions: r.extensions.map((s) => s.development.focused ? o(s, (e) => e.development.focused, !1) : s)
|
|
50
|
+
};
|
|
51
|
+
default:
|
|
52
|
+
return r;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
export {
|
|
56
|
+
m as extensionServerReducer
|
|
57
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("../context/ExtensionServerProvider.cjs.js"),c=require("../context/constants.cjs.js"),s=require("../hooks/useExtensionServerContext.cjs.js"),t=require("react");function u({children:n,...e}){const r=s.useExtensionServerContext(),o=t.useMemo(()=>({...r,...e}),[r,e]);return t.createElement(c.extensionServerContext.Provider,{value:o},n)}function v({children:n,options:e={connection:{}},...r}){return t.createElement(i.ExtensionServerProvider,{options:e},t.createElement(u,{...r},n))}exports.MockExtensionServerProvider=v;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ExtensionServerProviderProps, ExtensionServerContext } from '../context';
|
|
2
|
+
interface InternalProviderProps extends Partial<ExtensionServerContext> {
|
|
3
|
+
children?: ExtensionServerProviderProps['children'];
|
|
4
|
+
}
|
|
5
|
+
type MockExtensionServerProviderProps = Partial<ExtensionServerProviderProps> & InternalProviderProps;
|
|
6
|
+
export declare function MockExtensionServerProvider({ children, options, ...props }: MockExtensionServerProviderProps): JSX.Element;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ExtensionServerProvider as i } from "../context/ExtensionServerProvider.es.js";
|
|
2
|
+
import { extensionServerContext as c } from "../context/constants.es.js";
|
|
3
|
+
import { useExtensionServerContext as m } from "../hooks/useExtensionServerContext.es.js";
|
|
4
|
+
import n, { useMemo as v } from "react";
|
|
5
|
+
function a({ children: t, ...e }) {
|
|
6
|
+
const r = m(), o = v(
|
|
7
|
+
() => ({
|
|
8
|
+
...r,
|
|
9
|
+
...e
|
|
10
|
+
}),
|
|
11
|
+
[r, e]
|
|
12
|
+
);
|
|
13
|
+
return /* @__PURE__ */ n.createElement(c.Provider, { value: o }, t);
|
|
14
|
+
}
|
|
15
|
+
function l({
|
|
16
|
+
children: t,
|
|
17
|
+
options: e = { connection: {} },
|
|
18
|
+
...r
|
|
19
|
+
}) {
|
|
20
|
+
return /* @__PURE__ */ n.createElement(i, { options: e }, /* @__PURE__ */ n.createElement(a, { ...r }, t));
|
|
21
|
+
}
|
|
22
|
+
export {
|
|
23
|
+
l as MockExtensionServerProvider
|
|
24
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function o(){return{id:"id-1",apiKey:"12345",applicationUrl:"www.applicationUrl.com",title:"App title",url:"mock url",mobileUrl:"mock mobile url",icon:{transformedSrc:"www.transformed-src.com"}}}exports.mockApp=o;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
function r() {
|
|
2
|
+
return {
|
|
3
|
+
id: "id-1",
|
|
4
|
+
apiKey: "12345",
|
|
5
|
+
applicationUrl: "www.applicationUrl.com",
|
|
6
|
+
title: "App title",
|
|
7
|
+
url: "mock url",
|
|
8
|
+
mobileUrl: "mock mobile url",
|
|
9
|
+
icon: {
|
|
10
|
+
transformedSrc: "www.transformed-src.com"
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export {
|
|
15
|
+
r as mockApp
|
|
16
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("../types.cjs.js");let i=0;function a(e){return`00000000000${e}`.slice(-12)}function r(e={}){const t=`00000000-0000-0000-0000-${a(i++)}`,n=Date.now();return{handle:"my-extension",name:"My extension",description:"My extension description",surface:"admin",type:"purchase_option",externalType:"external_type",uuid:t,version:"extension version",...e,assets:{main:{name:"main",url:`https://secure-link.com/extensions/${t}/assets/handle.js?lastUpdated=${n}`,lastUpdated:n},...e.assets||{}},development:{hidden:!1,status:s.Status.Success,resource:{url:"resourceUrl"},root:{url:`https://secure-link.com/extensions/${t}`},renderer:{name:"render name",version:"1.0.0"},...e.development||{}},extensionPoints:e.extensionPoints,capabilities:e.capabilities,localization:e.localization,authenticatedRedirectStartUrl:e.authenticatedRedirectStartUrl,authenticatedRedirectRedirectUrls:e.authenticatedRedirectRedirectUrls,settings:{fields:[{key:"sample-key",name:"sample_name",type:"sample_type"}]}}}exports.mockExtension=r;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { Status as s } from "../types.es.js";
|
|
2
|
+
let i = 0;
|
|
3
|
+
function a(e) {
|
|
4
|
+
return `00000000000${e}`.slice(-12);
|
|
5
|
+
}
|
|
6
|
+
function c(e = {}) {
|
|
7
|
+
const t = `00000000-0000-0000-0000-${a(i++)}`, n = Date.now();
|
|
8
|
+
return {
|
|
9
|
+
handle: "my-extension",
|
|
10
|
+
name: "My extension",
|
|
11
|
+
description: "My extension description",
|
|
12
|
+
surface: "admin",
|
|
13
|
+
type: "purchase_option",
|
|
14
|
+
externalType: "external_type",
|
|
15
|
+
uuid: t,
|
|
16
|
+
version: "extension version",
|
|
17
|
+
...e,
|
|
18
|
+
assets: {
|
|
19
|
+
main: {
|
|
20
|
+
name: "main",
|
|
21
|
+
url: `https://secure-link.com/extensions/${t}/assets/handle.js?lastUpdated=${n}`,
|
|
22
|
+
lastUpdated: n
|
|
23
|
+
},
|
|
24
|
+
...e.assets || {}
|
|
25
|
+
},
|
|
26
|
+
development: {
|
|
27
|
+
hidden: !1,
|
|
28
|
+
status: s.Success,
|
|
29
|
+
resource: {
|
|
30
|
+
url: "resourceUrl"
|
|
31
|
+
},
|
|
32
|
+
root: {
|
|
33
|
+
url: `https://secure-link.com/extensions/${t}`
|
|
34
|
+
},
|
|
35
|
+
renderer: {
|
|
36
|
+
name: "render name",
|
|
37
|
+
version: "1.0.0"
|
|
38
|
+
},
|
|
39
|
+
...e.development || {}
|
|
40
|
+
},
|
|
41
|
+
// this is due to the naive DeepPartial but also more complex ones
|
|
42
|
+
// [see stackoverflow](https://stackoverflow.com/a/68699273) assume that
|
|
43
|
+
// `DeepPartial<Array<T>> === Array<T | undefined>` while we are looking for
|
|
44
|
+
// `DeepPartial<Array<T>> === Array<T> | undefined`.
|
|
45
|
+
// This is the case for extension points and seems hard to fix
|
|
46
|
+
// in a generalized, non-surprising way
|
|
47
|
+
extensionPoints: e.extensionPoints,
|
|
48
|
+
capabilities: e.capabilities,
|
|
49
|
+
localization: e.localization,
|
|
50
|
+
authenticatedRedirectStartUrl: e.authenticatedRedirectStartUrl,
|
|
51
|
+
authenticatedRedirectRedirectUrls: e.authenticatedRedirectRedirectUrls,
|
|
52
|
+
settings: {
|
|
53
|
+
fields: [
|
|
54
|
+
{
|
|
55
|
+
key: "sample-key",
|
|
56
|
+
name: "sample_name",
|
|
57
|
+
type: "sample_type"
|
|
58
|
+
}
|
|
59
|
+
]
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
export {
|
|
64
|
+
c as mockExtension
|
|
65
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var e=(r=>(r.Error="error",r.Success="success",r))(e||{});exports.Status=e;
|