@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,149 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@types/react",
|
|
3
|
+
"version": "17.0.2",
|
|
4
|
+
"description": "TypeScript definitions for React",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"contributors": [
|
|
7
|
+
{
|
|
8
|
+
"name": "Asana",
|
|
9
|
+
"url": "https://asana.com"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"name": "AssureSign",
|
|
13
|
+
"url": "http://www.assuresign.com"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"name": "Microsoft",
|
|
17
|
+
"url": "https://microsoft.com"
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"name": "John Reilly",
|
|
21
|
+
"url": "https://github.com/johnnyreilly",
|
|
22
|
+
"githubUsername": "johnnyreilly"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"name": "Benoit Benezech",
|
|
26
|
+
"url": "https://github.com/bbenezech",
|
|
27
|
+
"githubUsername": "bbenezech"
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"name": "Patricio Zavolinsky",
|
|
31
|
+
"url": "https://github.com/pzavolinsky",
|
|
32
|
+
"githubUsername": "pzavolinsky"
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"name": "Digiguru",
|
|
36
|
+
"url": "https://github.com/digiguru",
|
|
37
|
+
"githubUsername": "digiguru"
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"name": "Eric Anderson",
|
|
41
|
+
"url": "https://github.com/ericanderson",
|
|
42
|
+
"githubUsername": "ericanderson"
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"name": "Dovydas Navickas",
|
|
46
|
+
"url": "https://github.com/DovydasNavickas",
|
|
47
|
+
"githubUsername": "DovydasNavickas"
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"name": "Josh Rutherford",
|
|
51
|
+
"url": "https://github.com/theruther4d",
|
|
52
|
+
"githubUsername": "theruther4d"
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
"name": "Guilherme Hübner",
|
|
56
|
+
"url": "https://github.com/guilhermehubner",
|
|
57
|
+
"githubUsername": "guilhermehubner"
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"name": "Ferdy Budhidharma",
|
|
61
|
+
"url": "https://github.com/ferdaber",
|
|
62
|
+
"githubUsername": "ferdaber"
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"name": "Johann Rakotoharisoa",
|
|
66
|
+
"url": "https://github.com/jrakotoharisoa",
|
|
67
|
+
"githubUsername": "jrakotoharisoa"
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
"name": "Olivier Pascal",
|
|
71
|
+
"url": "https://github.com/pascaloliv",
|
|
72
|
+
"githubUsername": "pascaloliv"
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
"name": "Martin Hochel",
|
|
76
|
+
"url": "https://github.com/hotell",
|
|
77
|
+
"githubUsername": "hotell"
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"name": "Frank Li",
|
|
81
|
+
"url": "https://github.com/franklixuefei",
|
|
82
|
+
"githubUsername": "franklixuefei"
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
"name": "Jessica Franco",
|
|
86
|
+
"url": "https://github.com/Jessidhia",
|
|
87
|
+
"githubUsername": "Jessidhia"
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
"name": "Saransh Kataria",
|
|
91
|
+
"url": "https://github.com/saranshkataria",
|
|
92
|
+
"githubUsername": "saranshkataria"
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
"name": "Kanitkorn Sujautra",
|
|
96
|
+
"url": "https://github.com/lukyth",
|
|
97
|
+
"githubUsername": "lukyth"
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
"name": "Sebastian Silbermann",
|
|
101
|
+
"url": "https://github.com/eps1lon",
|
|
102
|
+
"githubUsername": "eps1lon"
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
"name": "Kyle Scully",
|
|
106
|
+
"url": "https://github.com/zieka",
|
|
107
|
+
"githubUsername": "zieka"
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
"name": "Cong Zhang",
|
|
111
|
+
"url": "https://github.com/dancerphil",
|
|
112
|
+
"githubUsername": "dancerphil"
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
"name": "Dimitri Mitropoulos",
|
|
116
|
+
"url": "https://github.com/dimitropoulos",
|
|
117
|
+
"githubUsername": "dimitropoulos"
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
"name": "JongChan Choi",
|
|
121
|
+
"url": "https://github.com/disjukr",
|
|
122
|
+
"githubUsername": "disjukr"
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
"name": "Victor Magalhães",
|
|
126
|
+
"url": "https://github.com/vhfmag",
|
|
127
|
+
"githubUsername": "vhfmag"
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
"name": "Dale Tan",
|
|
131
|
+
"url": "https://github.com/hellatan",
|
|
132
|
+
"githubUsername": "hellatan"
|
|
133
|
+
}
|
|
134
|
+
],
|
|
135
|
+
"main": "",
|
|
136
|
+
"types": "index.d.ts",
|
|
137
|
+
"repository": {
|
|
138
|
+
"type": "git",
|
|
139
|
+
"url": "https://github.com/DefinitelyTyped/DefinitelyTyped.git",
|
|
140
|
+
"directory": "types/react"
|
|
141
|
+
},
|
|
142
|
+
"scripts": {},
|
|
143
|
+
"dependencies": {
|
|
144
|
+
"@types/prop-types": "*",
|
|
145
|
+
"csstype": "^3.0.2"
|
|
146
|
+
},
|
|
147
|
+
"typesPublisherContentHash": "b4bc71e5ae8e6467bc315f57f8e7b98e248d5994ecaaf51bd4e674de77bfb6fc",
|
|
148
|
+
"typeScriptVersion": "3.4"
|
|
149
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2019-present, Yuxi (Evan) You and Vite contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# @vitejs/plugin-react-refresh [](https://npmjs.com/package/@vitejs/plugin-react-refresh)
|
|
2
|
+
|
|
3
|
+
Provides [React Refresh](https://www.npmjs.com/package/react-refresh) support for Vite.
|
|
4
|
+
|
|
5
|
+
```js
|
|
6
|
+
// vite.config.js
|
|
7
|
+
import reactRefresh from '@vitejs/plugin-react-refresh'
|
|
8
|
+
|
|
9
|
+
export default {
|
|
10
|
+
plugins: [reactRefresh()]
|
|
11
|
+
}
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Specifying Additional Parser Plugins
|
|
15
|
+
|
|
16
|
+
If you are using ES syntax that are still in proposal status (e.g. class properties), you can selectively enable them via the `parserPlugins` option:
|
|
17
|
+
|
|
18
|
+
```js
|
|
19
|
+
export default {
|
|
20
|
+
plugins: [
|
|
21
|
+
reactRefresh({
|
|
22
|
+
parserPlugins: ['classProperties', 'classPrivateProperties']
|
|
23
|
+
})
|
|
24
|
+
]
|
|
25
|
+
}
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
[Full list of Babel parser plugins](https://babeljs.io/docs/en/babel-parser#ecmascript-proposalshttpsgithubcombabelproposals).
|
|
29
|
+
|
|
30
|
+
## Specifying files to include or exclude from refreshing
|
|
31
|
+
|
|
32
|
+
By default, @vite/plugin-react-refresh will process files ending with `.js`, `.jsx`, `.ts`, and `.tsx`, and excludes all files in `node_modules`.
|
|
33
|
+
|
|
34
|
+
In some situations you may not want a file to act as an HMR boundary, instead preferring that the changes propagate higher in the stack before being handled. In these cases, you can provide an `include` and/or `exclude` option, which can be regex or a [picomatch](https://github.com/micromatch/picomatch#globbing-features) pattern, or array of either. Files must match include and not exclude to be processed. Note, when using either `include`, or `exclude`, the defaults will not be merged in, so re-apply them if necessary.
|
|
35
|
+
|
|
36
|
+
```js
|
|
37
|
+
export default {
|
|
38
|
+
plugins: [
|
|
39
|
+
reactRefresh({
|
|
40
|
+
// Exclude storybook stories and node_modules
|
|
41
|
+
exclude: [/\.stories\.(t|j)sx?$/, /node_modules/],
|
|
42
|
+
// Only .tsx files
|
|
43
|
+
include: '**/*.tsx'
|
|
44
|
+
})
|
|
45
|
+
]
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Notes
|
|
50
|
+
|
|
51
|
+
- If using TSX, any TS-supported syntax will already be transpiled away so you won't need to specify them here.
|
|
52
|
+
|
|
53
|
+
- This option only enables the plugin to parse these syntax - it does not perform any transpilation since this plugin is dev-only.
|
|
54
|
+
|
|
55
|
+
- If you wish to transpile the syntax for production, you will need to configure the transform separately using [@rollup/plugin-babel](https://github.com/rollup/plugins/tree/master/packages/babel) as a build-only plugin.
|
|
56
|
+
|
|
57
|
+
## Middleware Mode Notes
|
|
58
|
+
|
|
59
|
+
When Vite is launched in **Middleware Mode**, you need to make sure your entry `index.html` file is transformed with `ViteDevServer.transformIndexHtml`. Otherwise, you may get an error prompting `Uncaught Error: @vitejs/plugin-react-refresh can't detect preamble. Something is wrong.`
|
|
60
|
+
|
|
61
|
+
To mitigate this issue, you can explicitly transform your `index.html` like this when configuring your express server:
|
|
62
|
+
|
|
63
|
+
```js
|
|
64
|
+
app.get('/', async (req, res, next) => {
|
|
65
|
+
try {
|
|
66
|
+
let html = fs.readFileSync(path.resolve(root, 'index.html'), 'utf-8')
|
|
67
|
+
html = await viteServer.transformIndexHtml(req.url, html)
|
|
68
|
+
res.send(html)
|
|
69
|
+
} catch (e) {
|
|
70
|
+
return next(e)
|
|
71
|
+
}
|
|
72
|
+
})
|
|
73
|
+
```
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Plugin } from 'vite'
|
|
2
|
+
import { ParserOptions } from '@babel/core'
|
|
3
|
+
|
|
4
|
+
type PluginFactory = (options?: Options) => Plugin
|
|
5
|
+
|
|
6
|
+
declare const createPlugin: PluginFactory & { preambleCode: string }
|
|
7
|
+
|
|
8
|
+
export interface Options {
|
|
9
|
+
parserPlugins?: ParserOptions['plugins']
|
|
10
|
+
include?: string | RegExp | Array<string | RegExp>
|
|
11
|
+
exclude?: string | RegExp | Array<string | RegExp>
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export default createPlugin
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
const fs = require('fs')
|
|
3
|
+
const { transformSync, ParserOptions } = require('@babel/core')
|
|
4
|
+
const { createFilter } = require('@rollup/pluginutils')
|
|
5
|
+
const runtimePublicPath = '/@react-refresh'
|
|
6
|
+
const runtimeFilePath = require.resolve(
|
|
7
|
+
'react-refresh/cjs/react-refresh-runtime.development.js'
|
|
8
|
+
)
|
|
9
|
+
|
|
10
|
+
const runtimeCode = `
|
|
11
|
+
const exports = {}
|
|
12
|
+
${fs.readFileSync(runtimeFilePath, 'utf-8')}
|
|
13
|
+
function debounce(fn, delay) {
|
|
14
|
+
let handle
|
|
15
|
+
return () => {
|
|
16
|
+
clearTimeout(handle)
|
|
17
|
+
handle = setTimeout(fn, delay)
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.performReactRefresh = debounce(exports.performReactRefresh, 16)
|
|
21
|
+
export default exports
|
|
22
|
+
`
|
|
23
|
+
|
|
24
|
+
const preambleCode = `
|
|
25
|
+
import RefreshRuntime from "__BASE__${runtimePublicPath.slice(1)}"
|
|
26
|
+
RefreshRuntime.injectIntoGlobalHook(window)
|
|
27
|
+
window.$RefreshReg$ = () => {}
|
|
28
|
+
window.$RefreshSig$ = () => (type) => type
|
|
29
|
+
window.__vite_plugin_react_preamble_installed__ = true
|
|
30
|
+
`
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Transform plugin for transforming and injecting per-file refresh code.
|
|
34
|
+
*
|
|
35
|
+
* @type {import('.').default}
|
|
36
|
+
*/
|
|
37
|
+
function reactRefreshPlugin(opts) {
|
|
38
|
+
let shouldSkip = false
|
|
39
|
+
let base = '/'
|
|
40
|
+
const filter = createFilter(
|
|
41
|
+
(opts && opts.include) || /\.(t|j)sx?$/,
|
|
42
|
+
(opts && opts.exclude) || /node_modules/
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
return {
|
|
46
|
+
name: 'react-refresh',
|
|
47
|
+
|
|
48
|
+
enforce: 'pre',
|
|
49
|
+
|
|
50
|
+
configResolved(config) {
|
|
51
|
+
shouldSkip = config.command === 'build' || config.isProduction
|
|
52
|
+
base = config.base
|
|
53
|
+
},
|
|
54
|
+
|
|
55
|
+
resolveId(id) {
|
|
56
|
+
if (id === runtimePublicPath) {
|
|
57
|
+
return id
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
|
|
61
|
+
load(id) {
|
|
62
|
+
if (id === runtimePublicPath) {
|
|
63
|
+
return runtimeCode
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
|
|
67
|
+
transform(code, id, ssr) {
|
|
68
|
+
if (shouldSkip || ssr) {
|
|
69
|
+
return
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (!filter(id)) {
|
|
73
|
+
return
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// plain js/ts files can't use React without importing it, so skip
|
|
77
|
+
// them whenever possible
|
|
78
|
+
if (!id.endsWith('x') && !code.includes('react')) {
|
|
79
|
+
return
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* @type ParserOptions["plugins"]
|
|
84
|
+
*/
|
|
85
|
+
const parserPlugins = [
|
|
86
|
+
'jsx',
|
|
87
|
+
'importMeta',
|
|
88
|
+
// since the plugin now applies before esbuild transforms the code,
|
|
89
|
+
// we need to enable some stage 3 syntax since they are supported in
|
|
90
|
+
// TS and some environments already.
|
|
91
|
+
'topLevelAwait',
|
|
92
|
+
'classProperties',
|
|
93
|
+
'classPrivateProperties',
|
|
94
|
+
'classPrivateMethods'
|
|
95
|
+
]
|
|
96
|
+
if (/\.tsx?$/.test(id)) {
|
|
97
|
+
// it's a typescript file
|
|
98
|
+
// TODO: maybe we need to read tsconfig to determine parser plugins to
|
|
99
|
+
// enable here, but allowing decorators by default since it's very
|
|
100
|
+
// commonly used with TS.
|
|
101
|
+
parserPlugins.push('typescript', 'decorators-legacy')
|
|
102
|
+
}
|
|
103
|
+
if (opts && opts.parserPlugins) {
|
|
104
|
+
parserPlugins.push(...opts.parserPlugins)
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const isReasonReact = id.endsWith('.bs.js')
|
|
108
|
+
const result = transformSync(code, {
|
|
109
|
+
babelrc: false,
|
|
110
|
+
configFile: false,
|
|
111
|
+
filename: id,
|
|
112
|
+
parserOpts: {
|
|
113
|
+
sourceType: 'module',
|
|
114
|
+
allowAwaitOutsideFunction: true,
|
|
115
|
+
plugins: parserPlugins
|
|
116
|
+
},
|
|
117
|
+
generatorOpts: {
|
|
118
|
+
decoratorsBeforeExport: true
|
|
119
|
+
},
|
|
120
|
+
plugins: [
|
|
121
|
+
require('@babel/plugin-transform-react-jsx-self'),
|
|
122
|
+
require('@babel/plugin-transform-react-jsx-source'),
|
|
123
|
+
[require('react-refresh/babel'), { skipEnvCheck: true }]
|
|
124
|
+
],
|
|
125
|
+
ast: !isReasonReact,
|
|
126
|
+
sourceMaps: true,
|
|
127
|
+
sourceFileName: id
|
|
128
|
+
})
|
|
129
|
+
|
|
130
|
+
if (!/\$RefreshReg\$\(/.test(result.code)) {
|
|
131
|
+
// no component detected in the file
|
|
132
|
+
return code
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
const header = `
|
|
136
|
+
import RefreshRuntime from "${runtimePublicPath}";
|
|
137
|
+
|
|
138
|
+
let prevRefreshReg;
|
|
139
|
+
let prevRefreshSig;
|
|
140
|
+
|
|
141
|
+
if (!window.__vite_plugin_react_preamble_installed__) {
|
|
142
|
+
throw new Error(
|
|
143
|
+
"@vitejs/plugin-react-refresh can't detect preamble. Something is wrong. " +
|
|
144
|
+
"See https://github.com/vitejs/vite-plugin-react/pull/11#discussion_r430879201"
|
|
145
|
+
);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
if (import.meta.hot) {
|
|
149
|
+
prevRefreshReg = window.$RefreshReg$;
|
|
150
|
+
prevRefreshSig = window.$RefreshSig$;
|
|
151
|
+
window.$RefreshReg$ = (type, id) => {
|
|
152
|
+
RefreshRuntime.register(type, ${JSON.stringify(id)} + " " + id)
|
|
153
|
+
};
|
|
154
|
+
window.$RefreshSig$ = RefreshRuntime.createSignatureFunctionForTransform;
|
|
155
|
+
}`.replace(/[\n]+/gm, '')
|
|
156
|
+
|
|
157
|
+
const footer = `
|
|
158
|
+
if (import.meta.hot) {
|
|
159
|
+
window.$RefreshReg$ = prevRefreshReg;
|
|
160
|
+
window.$RefreshSig$ = prevRefreshSig;
|
|
161
|
+
|
|
162
|
+
${
|
|
163
|
+
isReasonReact || isRefreshBoundary(result.ast)
|
|
164
|
+
? `import.meta.hot.accept();`
|
|
165
|
+
: ``
|
|
166
|
+
}
|
|
167
|
+
if (!window.__vite_plugin_react_timeout) {
|
|
168
|
+
window.__vite_plugin_react_timeout = setTimeout(() => {
|
|
169
|
+
window.__vite_plugin_react_timeout = 0;
|
|
170
|
+
RefreshRuntime.performReactRefresh();
|
|
171
|
+
}, 30);
|
|
172
|
+
}
|
|
173
|
+
}`
|
|
174
|
+
|
|
175
|
+
return {
|
|
176
|
+
code: `${header}${result.code}${footer}`,
|
|
177
|
+
map: result.map
|
|
178
|
+
}
|
|
179
|
+
},
|
|
180
|
+
|
|
181
|
+
transformIndexHtml() {
|
|
182
|
+
if (shouldSkip) {
|
|
183
|
+
return
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
return [
|
|
187
|
+
{
|
|
188
|
+
tag: 'script',
|
|
189
|
+
attrs: { type: 'module' },
|
|
190
|
+
children: preambleCode.replace(`__BASE__`, base)
|
|
191
|
+
}
|
|
192
|
+
]
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* @param {import('@babel/core').BabelFileResult['ast']} ast
|
|
199
|
+
*/
|
|
200
|
+
function isRefreshBoundary(ast) {
|
|
201
|
+
// Every export must be a React component.
|
|
202
|
+
return ast.program.body.every((node) => {
|
|
203
|
+
if (node.type !== 'ExportNamedDeclaration') {
|
|
204
|
+
return true
|
|
205
|
+
}
|
|
206
|
+
const { declaration, specifiers } = node
|
|
207
|
+
if (declaration) {
|
|
208
|
+
if (declaration.type === 'VariableDeclaration') {
|
|
209
|
+
return declaration.declarations.every((variable) =>
|
|
210
|
+
isComponentLikeIdentifier(variable.id)
|
|
211
|
+
)
|
|
212
|
+
}
|
|
213
|
+
if (declaration.type === 'FunctionDeclaration') {
|
|
214
|
+
return isComponentLikeIdentifier(declaration.id)
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
return specifiers.every((spec) => {
|
|
218
|
+
return isComponentLikeIdentifier(spec.exported)
|
|
219
|
+
})
|
|
220
|
+
})
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* @param {import('@babel/types').Node} node
|
|
225
|
+
*/
|
|
226
|
+
function isComponentLikeIdentifier(node) {
|
|
227
|
+
return node.type === 'Identifier' && isComponentLikeName(node.name)
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* @param {string} name
|
|
232
|
+
*/
|
|
233
|
+
function isComponentLikeName(name) {
|
|
234
|
+
return typeof name === 'string' && name[0] >= 'A' && name[0] <= 'Z'
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
module.exports = reactRefreshPlugin
|
|
238
|
+
reactRefreshPlugin['default'] = reactRefreshPlugin
|
|
239
|
+
reactRefreshPlugin.preambleCode = preambleCode
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@vitejs/plugin-react-refresh",
|
|
3
|
+
"version": "1.3.6",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"author": "Evan You",
|
|
6
|
+
"files": [
|
|
7
|
+
"index.js",
|
|
8
|
+
"index.d.ts"
|
|
9
|
+
],
|
|
10
|
+
"main": "index.js",
|
|
11
|
+
"types": "index.d.ts",
|
|
12
|
+
"scripts": {
|
|
13
|
+
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s --commit-path . --lerna-package plugin-react-refresh",
|
|
14
|
+
"release": "node ../../scripts/release.js --skipBuild"
|
|
15
|
+
},
|
|
16
|
+
"engines": {
|
|
17
|
+
"node": ">=12.0.0"
|
|
18
|
+
},
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "git+https://github.com/vitejs/vite.git",
|
|
22
|
+
"directory": "packages/plugin-react-refresh"
|
|
23
|
+
},
|
|
24
|
+
"bugs": {
|
|
25
|
+
"url": "https://github.com/vitejs/vite/issues"
|
|
26
|
+
},
|
|
27
|
+
"homepage": "https://github.com/vitejs/vite/tree/main/packages/plugin-react-refresh#readme",
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"@babel/core": "^7.14.8",
|
|
30
|
+
"@babel/plugin-transform-react-jsx-self": "^7.14.5",
|
|
31
|
+
"@babel/plugin-transform-react-jsx-source": "^7.14.5",
|
|
32
|
+
"@rollup/pluginutils": "^4.1.1",
|
|
33
|
+
"react-refresh": "^0.10.0"
|
|
34
|
+
}
|
|
35
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@shopify/ui-extensions-server-kit",
|
|
3
|
+
"version": "0.0.0-snapshot-20240814205424",
|
|
4
|
+
"private": false,
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"exports": {
|
|
7
|
+
"./package.json": "./package.json",
|
|
8
|
+
".": {
|
|
9
|
+
"require": "./index.js",
|
|
10
|
+
"import": "./index.mjs",
|
|
11
|
+
"types": "./index.d.ts"
|
|
12
|
+
},
|
|
13
|
+
"./testing": {
|
|
14
|
+
"require": "./testing.js",
|
|
15
|
+
"import": "./testing.mjs",
|
|
16
|
+
"types": "./testing.d.ts"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"main": "index.js",
|
|
20
|
+
"module": "index.mjs",
|
|
21
|
+
"types": "index.d.ts",
|
|
22
|
+
"files": [
|
|
23
|
+
"**"
|
|
24
|
+
],
|
|
25
|
+
"eslintConfig": {
|
|
26
|
+
"extends": [
|
|
27
|
+
"../../.eslintrc.cjs"
|
|
28
|
+
],
|
|
29
|
+
"rules": {
|
|
30
|
+
"@typescript-eslint/no-explicit-any": "off",
|
|
31
|
+
"import/extensions": [
|
|
32
|
+
"error",
|
|
33
|
+
"never",
|
|
34
|
+
{
|
|
35
|
+
"ignorePackages": true
|
|
36
|
+
}
|
|
37
|
+
]
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@shopify/react-testing": "^3.0.0",
|
|
42
|
+
"@shopify/ui-extensions-test-utils": "3.26.0",
|
|
43
|
+
"@types/node": "18.19.3",
|
|
44
|
+
"@types/react": "17.0.2",
|
|
45
|
+
"@vitejs/plugin-react-refresh": "^1.3.6",
|
|
46
|
+
"jest-websocket-mock": "^2.4.0",
|
|
47
|
+
"jsdom": "^20.0.3",
|
|
48
|
+
"react": "^17.0.2",
|
|
49
|
+
"typescript": "5.2.2",
|
|
50
|
+
"vi-fetch": "^0.8.0",
|
|
51
|
+
"vite": "^5.3.1"
|
|
52
|
+
},
|
|
53
|
+
"peerDependencies": {
|
|
54
|
+
"react": "^17.0.2"
|
|
55
|
+
},
|
|
56
|
+
"scripts": {
|
|
57
|
+
"build": "nx build",
|
|
58
|
+
"clean": "nx clean",
|
|
59
|
+
"lint": "nx lint",
|
|
60
|
+
"lint:fix": "nx lint:fix",
|
|
61
|
+
"test": "nx run ui-extensions-server-kit:test",
|
|
62
|
+
"test:watch": "nx test:watch"
|
|
63
|
+
}
|
|
64
|
+
}
|
package/project.json
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "ui-extensions-server-kit",
|
|
3
|
+
"$schema": "../../node_modules/nx/schemas/project-schema.json",
|
|
4
|
+
"sourceRoot": "packages/ui-extensions-server-kit/src",
|
|
5
|
+
"projectType": "library",
|
|
6
|
+
"implicitDependencies": ["ui-extensions-test-utils"],
|
|
7
|
+
"tags": ["scope:feature", "scope:ui-extensions"],
|
|
8
|
+
"targets": {
|
|
9
|
+
"clean": {
|
|
10
|
+
"executor": "nx:run-commands",
|
|
11
|
+
"options": {
|
|
12
|
+
"command": "pnpm rimraf dist/",
|
|
13
|
+
"cwd": "packages/ui-extensions-server-kit"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"build:code": {
|
|
17
|
+
"executor": "nx:run-commands",
|
|
18
|
+
"outputs": ["{workspaceRoot}/dist"],
|
|
19
|
+
"options": {
|
|
20
|
+
"command": "pnpm vite build --config vite.config.ts",
|
|
21
|
+
"cwd": "packages/ui-extensions-server-kit"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"build:types": {
|
|
25
|
+
"executor": "nx:run-commands",
|
|
26
|
+
"dependsOn": ["^build"],
|
|
27
|
+
"outputs": ["{workspaceRoot}/dist"],
|
|
28
|
+
"options": {
|
|
29
|
+
"command": "pnpm tsc --emitDeclarationOnly",
|
|
30
|
+
"cwd": "packages/ui-extensions-server-kit"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"build": {
|
|
34
|
+
"executor": "nx:run-commands",
|
|
35
|
+
"dependsOn": ["build:code", "build:types"],
|
|
36
|
+
"outputs": ["{workspaceRoot}/dist"],
|
|
37
|
+
"inputs": ["{projectRoot}/src/**/*", "{projectRoot}/testing.*", "{projectRoot}/index.*"],
|
|
38
|
+
"options": {
|
|
39
|
+
"command": "cd .",
|
|
40
|
+
"cwd": "packages/ui-extensions-server-kit"
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
"lint": {
|
|
44
|
+
"executor": "nx:run-commands",
|
|
45
|
+
"options": {
|
|
46
|
+
"command": "pnpm eslint src",
|
|
47
|
+
"cwd": "packages/ui-extensions-server-kit"
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
"lint:fix": {
|
|
51
|
+
"executor": "nx:run-commands",
|
|
52
|
+
"options": {
|
|
53
|
+
"command": "pnpm eslint src --fix",
|
|
54
|
+
"cwd": "packages/ui-extensions-server-kit"
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
"test": {
|
|
58
|
+
"executor": "nx:run-commands",
|
|
59
|
+
"dependsOn": ["^build"],
|
|
60
|
+
"options": {
|
|
61
|
+
"command": "pnpm vitest run",
|
|
62
|
+
"cwd": "packages/ui-extensions-server-kit"
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
"test:watch": {
|
|
66
|
+
"executor": "nx:run-commands",
|
|
67
|
+
"dependsOn": ["^build"],
|
|
68
|
+
"options": {
|
|
69
|
+
"command": "pnpm vitest watch",
|
|
70
|
+
"cwd": "packages/ui-extensions-server-kit"
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|