@shopify/ui-extensions-server-kit 5.4.0 → 5.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/README.md +1 -1
- package/dist/ExtensionServerClient/ExtensionServerClient.d.ts +3 -5
- package/dist/ExtensionServerClient/server-types.d.ts +31 -7
- package/dist/_virtual/jsx-runtime.cjs.js +1 -0
- package/dist/_virtual/jsx-runtime.cjs2.js +1 -0
- package/dist/_virtual/jsx-runtime.es.js +5 -0
- package/dist/_virtual/jsx-runtime.es2.js +4 -0
- package/dist/_virtual/react-jsx-runtime.development.cjs.js +1 -0
- package/dist/_virtual/react-jsx-runtime.development.es.js +4 -0
- package/dist/_virtual/react-jsx-runtime.production.min.cjs.js +1 -0
- package/dist/_virtual/react-jsx-runtime.production.min.es.js +4 -0
- package/dist/i18n.d.ts +2 -8
- package/dist/index.cjs.js +1 -1
- package/dist/index.cjs2.js +1 -1
- package/dist/index.es.js +18 -18
- package/dist/index.es2.js +3 -3
- package/dist/node_modules/.pnpm/react@18.3.1/node_modules/react/cjs/react-jsx-runtime.development.cjs.js +22 -0
- package/dist/node_modules/.pnpm/react@18.3.1/node_modules/react/cjs/react-jsx-runtime.development.es.js +604 -0
- package/dist/node_modules/.pnpm/react@18.3.1/node_modules/react/cjs/react-jsx-runtime.production.min.cjs.js +9 -0
- package/dist/node_modules/.pnpm/react@18.3.1/node_modules/react/cjs/react-jsx-runtime.production.min.es.js +28 -0
- package/dist/node_modules/.pnpm/react@18.3.1/node_modules/react/jsx-runtime.cjs.js +1 -0
- package/dist/node_modules/.pnpm/react@18.3.1/node_modules/react/jsx-runtime.es.js +10 -0
- package/dist/packages/ui-extensions-server-kit/src/ExtensionServerClient/ExtensionServerClient.cjs.js +1 -0
- package/dist/{ExtensionServerClient → packages/ui-extensions-server-kit/src/ExtensionServerClient}/ExtensionServerClient.es.js +21 -18
- package/dist/packages/ui-extensions-server-kit/src/context/ExtensionServerProvider.cjs.js +1 -0
- package/dist/packages/ui-extensions-server-kit/src/context/ExtensionServerProvider.es.js +30 -0
- package/dist/{context → packages/ui-extensions-server-kit/src/context}/constants.cjs.js +1 -1
- package/dist/packages/ui-extensions-server-kit/src/hooks/useExtensionServerContext.cjs.js +1 -0
- package/dist/{hooks → packages/ui-extensions-server-kit/src/hooks}/useExtensionServerContext.es.js +3 -2
- package/dist/packages/ui-extensions-server-kit/src/testing/MockExtensionServerProvider.cjs.js +1 -0
- package/dist/packages/ui-extensions-server-kit/src/testing/MockExtensionServerProvider.es.js +25 -0
- package/dist/packages/ui-extensions-server-kit/src/utilities/isUIExtension.cjs.js +1 -0
- package/dist/{utilities → packages/ui-extensions-server-kit/src/utilities}/isUIExtension.es.js +3 -2
- package/dist/{utilities → packages/ui-extensions-server-kit/src/utilities}/isValidSurface.cjs.js +1 -1
- package/dist/packages/ui-extensions-server-kit/src/utilities/isValidSurface.es.js +7 -0
- package/dist/types.d.ts +11 -8
- package/dist/utilities/isUIExtension.d.ts +1 -1
- package/dist/utilities/isValidSurface.d.ts +1 -1
- package/dist/utilities/set.d.ts +1 -1
- package/node_modules/{@shopify/react-testing/LICENSE.md → @testing-library/react/LICENSE} +2 -3
- package/node_modules/@testing-library/react/README.md +692 -0
- package/node_modules/@testing-library/react/dist/@testing-library/react.cjs.js +537 -0
- package/node_modules/@testing-library/react/dist/@testing-library/react.esm.js +497 -0
- package/node_modules/@testing-library/react/dist/@testing-library/react.pure.cjs.js +501 -0
- package/node_modules/@testing-library/react/dist/@testing-library/react.pure.esm.js +461 -0
- package/node_modules/@testing-library/react/dist/@testing-library/react.pure.umd.js +502 -0
- package/node_modules/@testing-library/react/dist/@testing-library/react.pure.umd.js.map +1 -0
- package/node_modules/@testing-library/react/dist/@testing-library/react.pure.umd.min.js +2 -0
- package/node_modules/@testing-library/react/dist/@testing-library/react.pure.umd.min.js.map +1 -0
- package/node_modules/@testing-library/react/dist/@testing-library/react.umd.js +538 -0
- package/node_modules/@testing-library/react/dist/@testing-library/react.umd.js.map +1 -0
- package/node_modules/@testing-library/react/dist/@testing-library/react.umd.min.js +2 -0
- package/node_modules/@testing-library/react/dist/@testing-library/react.umd.min.js.map +1 -0
- package/node_modules/@testing-library/react/dist/act-compat.js +80 -0
- package/node_modules/@testing-library/react/dist/config.js +33 -0
- package/node_modules/@testing-library/react/dist/fire-event.js +70 -0
- package/node_modules/@testing-library/react/dist/index.js +52 -0
- package/node_modules/@testing-library/react/dist/pure.js +356 -0
- package/node_modules/@testing-library/react/dont-cleanup-after-each.js +1 -0
- package/node_modules/@testing-library/react/package.json +116 -0
- package/node_modules/@testing-library/react/pure.d.ts +1 -0
- package/node_modules/@testing-library/react/pure.js +2 -0
- package/node_modules/@testing-library/react/types/index.d.ts +287 -0
- package/node_modules/@testing-library/react/types/pure.d.ts +1 -0
- package/node_modules/@vitejs/plugin-react/README.md +159 -0
- package/node_modules/@vitejs/plugin-react/dist/index.d.ts +75 -0
- package/node_modules/@vitejs/plugin-react/dist/index.js +401 -0
- package/node_modules/@vitejs/plugin-react/dist/refresh-runtime.js +663 -0
- package/node_modules/@vitejs/plugin-react/package.json +77 -0
- package/node_modules/@vitejs/plugin-react/types/preamble.d.ts +1 -0
- package/package.json +8 -9
- package/project.json +1 -1
- package/src/ExtensionServerClient/ExtensionServerClient.test.ts +6 -5
- package/src/ExtensionServerClient/ExtensionServerClient.ts +27 -19
- package/src/ExtensionServerClient/server-types.ts +17 -7
- package/src/ExtensionServerClient/types.ts +0 -2
- package/src/context/ExtensionServerProvider.test.tsx +55 -73
- package/src/context/ExtensionServerProvider.tsx +1 -0
- package/src/i18n.ts +2 -5
- package/src/state/reducers/extensionServerReducer.test.ts +2 -2
- package/src/types.ts +11 -6
- package/src/utilities/assetToString.ts +0 -1
- package/src/utilities/isUIExtension.ts +5 -4
- package/src/utilities/isValidSurface.ts +2 -3
- package/src/utilities/replaceUpdated.ts +0 -2
- package/src/utilities/set.ts +10 -5
- package/tests/setup.ts +1 -4
- package/vite.config.mts +57 -0
- package/dist/ExtensionServerClient/ExtensionServerClient.cjs.js +0 -1
- package/dist/context/ExtensionServerProvider.cjs.js +0 -1
- package/dist/context/ExtensionServerProvider.es.js +0 -29
- package/dist/hooks/useExtensionServerContext.cjs.js +0 -1
- package/dist/testing/MockExtensionServerProvider.cjs.js +0 -1
- package/dist/testing/MockExtensionServerProvider.es.js +0 -24
- package/dist/utilities/isUIExtension.cjs.js +0 -1
- package/dist/utilities/isValidSurface.es.js +0 -7
- package/node_modules/@shopify/react-testing/README.md +0 -711
- package/node_modules/@shopify/react-testing/build/cjs/TestWrapper.js +0 -52
- package/node_modules/@shopify/react-testing/build/cjs/_virtual/_rollupPluginBabelHelpers.js +0 -47
- package/node_modules/@shopify/react-testing/build/cjs/compat.js +0 -14
- package/node_modules/@shopify/react-testing/build/cjs/destroy.js +0 -13
- package/node_modules/@shopify/react-testing/build/cjs/element.js +0 -225
- package/node_modules/@shopify/react-testing/build/cjs/index.js +0 -21
- package/node_modules/@shopify/react-testing/build/cjs/matchers/components.js +0 -46
- package/node_modules/@shopify/react-testing/build/cjs/matchers/context.js +0 -25
- package/node_modules/@shopify/react-testing/build/cjs/matchers/index.js +0 -16
- package/node_modules/@shopify/react-testing/build/cjs/matchers/props.js +0 -38
- package/node_modules/@shopify/react-testing/build/cjs/matchers/strings.js +0 -42
- package/node_modules/@shopify/react-testing/build/cjs/matchers/utilities.js +0 -110
- package/node_modules/@shopify/react-testing/build/cjs/mount.js +0 -76
- package/node_modules/@shopify/react-testing/build/cjs/root.js +0 -284
- package/node_modules/@shopify/react-testing/build/cjs/toReactString.js +0 -86
- package/node_modules/@shopify/react-testing/build/cjs/types.js +0 -28
- package/node_modules/@shopify/react-testing/build/esm/TestWrapper.mjs +0 -44
- package/node_modules/@shopify/react-testing/build/esm/_virtual/_rollupPluginBabelHelpers.mjs +0 -42
- package/node_modules/@shopify/react-testing/build/esm/compat.mjs +0 -10
- package/node_modules/@shopify/react-testing/build/esm/destroy.mjs +0 -9
- package/node_modules/@shopify/react-testing/build/esm/element.mjs +0 -221
- package/node_modules/@shopify/react-testing/build/esm/index.mjs +0 -5
- package/node_modules/@shopify/react-testing/build/esm/matchers/components.mjs +0 -41
- package/node_modules/@shopify/react-testing/build/esm/matchers/context.mjs +0 -21
- package/node_modules/@shopify/react-testing/build/esm/matchers/index.mjs +0 -14
- package/node_modules/@shopify/react-testing/build/esm/matchers/props.mjs +0 -33
- package/node_modules/@shopify/react-testing/build/esm/matchers/strings.mjs +0 -37
- package/node_modules/@shopify/react-testing/build/esm/matchers/utilities.mjs +0 -101
- package/node_modules/@shopify/react-testing/build/esm/mount.mjs +0 -70
- package/node_modules/@shopify/react-testing/build/esm/root.mjs +0 -275
- package/node_modules/@shopify/react-testing/build/esm/toReactString.mjs +0 -80
- package/node_modules/@shopify/react-testing/build/esm/types.mjs +0 -26
- package/node_modules/@shopify/react-testing/build/esnext/TestWrapper.esnext +0 -44
- package/node_modules/@shopify/react-testing/build/esnext/compat.esnext +0 -10
- package/node_modules/@shopify/react-testing/build/esnext/destroy.esnext +0 -9
- package/node_modules/@shopify/react-testing/build/esnext/element.esnext +0 -221
- package/node_modules/@shopify/react-testing/build/esnext/index.esnext +0 -5
- package/node_modules/@shopify/react-testing/build/esnext/matchers/components.esnext +0 -41
- package/node_modules/@shopify/react-testing/build/esnext/matchers/context.esnext +0 -21
- package/node_modules/@shopify/react-testing/build/esnext/matchers/index.esnext +0 -14
- package/node_modules/@shopify/react-testing/build/esnext/matchers/props.esnext +0 -33
- package/node_modules/@shopify/react-testing/build/esnext/matchers/strings.esnext +0 -37
- package/node_modules/@shopify/react-testing/build/esnext/matchers/utilities.esnext +0 -99
- package/node_modules/@shopify/react-testing/build/esnext/mount.esnext +0 -71
- package/node_modules/@shopify/react-testing/build/esnext/root.esnext +0 -275
- package/node_modules/@shopify/react-testing/build/esnext/toReactString.esnext +0 -80
- package/node_modules/@shopify/react-testing/build/esnext/types.esnext +0 -26
- package/node_modules/@shopify/react-testing/build/ts/TestWrapper.d.ts +0 -17
- package/node_modules/@shopify/react-testing/build/ts/TestWrapper.d.ts.map +0 -1
- package/node_modules/@shopify/react-testing/build/ts/compat.d.ts +0 -3
- package/node_modules/@shopify/react-testing/build/ts/compat.d.ts.map +0 -1
- package/node_modules/@shopify/react-testing/build/ts/destroy.d.ts +0 -2
- package/node_modules/@shopify/react-testing/build/ts/destroy.d.ts.map +0 -1
- package/node_modules/@shopify/react-testing/build/ts/element.d.ts +0 -42
- package/node_modules/@shopify/react-testing/build/ts/element.d.ts.map +0 -1
- package/node_modules/@shopify/react-testing/build/ts/index.d.ts +0 -7
- package/node_modules/@shopify/react-testing/build/ts/index.d.ts.map +0 -1
- package/node_modules/@shopify/react-testing/build/ts/matchers/components.d.ts +0 -12
- package/node_modules/@shopify/react-testing/build/ts/matchers/components.d.ts.map +0 -1
- package/node_modules/@shopify/react-testing/build/ts/matchers/context.d.ts +0 -8
- package/node_modules/@shopify/react-testing/build/ts/matchers/context.d.ts.map +0 -1
- package/node_modules/@shopify/react-testing/build/ts/matchers/index.d.ts +0 -20
- package/node_modules/@shopify/react-testing/build/ts/matchers/index.d.ts.map +0 -1
- package/node_modules/@shopify/react-testing/build/ts/matchers/props.d.ts +0 -10
- package/node_modules/@shopify/react-testing/build/ts/matchers/props.d.ts.map +0 -1
- package/node_modules/@shopify/react-testing/build/ts/matchers/strings.d.ts +0 -11
- package/node_modules/@shopify/react-testing/build/ts/matchers/strings.d.ts.map +0 -1
- package/node_modules/@shopify/react-testing/build/ts/matchers/utilities.d.ts +0 -17
- package/node_modules/@shopify/react-testing/build/ts/matchers/utilities.d.ts.map +0 -1
- package/node_modules/@shopify/react-testing/build/ts/mount.d.ts +0 -39
- package/node_modules/@shopify/react-testing/build/ts/mount.d.ts.map +0 -1
- package/node_modules/@shopify/react-testing/build/ts/root.d.ts +0 -55
- package/node_modules/@shopify/react-testing/build/ts/root.d.ts.map +0 -1
- package/node_modules/@shopify/react-testing/build/ts/toReactString.d.ts +0 -5
- package/node_modules/@shopify/react-testing/build/ts/toReactString.d.ts.map +0 -1
- package/node_modules/@shopify/react-testing/build/ts/types.d.ts +0 -89
- package/node_modules/@shopify/react-testing/build/ts/types.d.ts.map +0 -1
- package/node_modules/@shopify/react-testing/index.esnext +0 -1
- package/node_modules/@shopify/react-testing/index.js +0 -1
- package/node_modules/@shopify/react-testing/index.mjs +0 -1
- package/node_modules/@shopify/react-testing/matchers.esnext +0 -1
- package/node_modules/@shopify/react-testing/matchers.js +0 -1
- package/node_modules/@shopify/react-testing/matchers.mjs +0 -1
- package/node_modules/@shopify/react-testing/package.json +0 -69
- package/node_modules/@shopify/ui-extensions-test-utils/CHANGELOG.md +0 -66
- package/node_modules/@shopify/ui-extensions-test-utils/dist/index.d.ts +0 -3
- package/node_modules/@shopify/ui-extensions-test-utils/dist/index.js +0 -3
- package/node_modules/@shopify/ui-extensions-test-utils/dist/render.d.ts +0 -2
- package/node_modules/@shopify/ui-extensions-test-utils/dist/render.js +0 -5
- package/node_modules/@shopify/ui-extensions-test-utils/dist/renderHook.d.ts +0 -17
- package/node_modules/@shopify/ui-extensions-test-utils/dist/renderHook.js +0 -20
- package/node_modules/@shopify/ui-extensions-test-utils/dist/withProviders.d.ts +0 -9
- package/node_modules/@shopify/ui-extensions-test-utils/dist/withProviders.js +0 -7
- package/node_modules/@shopify/ui-extensions-test-utils/package.json +0 -40
- package/node_modules/@shopify/ui-extensions-test-utils/project.json +0 -39
- package/node_modules/@vitejs/plugin-react-refresh/README.md +0 -73
- package/node_modules/@vitejs/plugin-react-refresh/index.d.ts +0 -14
- package/node_modules/@vitejs/plugin-react-refresh/index.js +0 -239
- package/node_modules/@vitejs/plugin-react-refresh/package.json +0 -35
- /package/dist/{ExtensionServerClient → packages/ui-extensions-server-kit/src/ExtensionServerClient}/types.cjs.js +0 -0
- /package/dist/{ExtensionServerClient → packages/ui-extensions-server-kit/src/ExtensionServerClient}/types.es.js +0 -0
- /package/dist/{context → packages/ui-extensions-server-kit/src/context}/constants.es.js +0 -0
- /package/dist/{hooks → packages/ui-extensions-server-kit/src/hooks}/useExtensionServerState.cjs.js +0 -0
- /package/dist/{hooks → packages/ui-extensions-server-kit/src/hooks}/useExtensionServerState.es.js +0 -0
- /package/dist/{hooks → packages/ui-extensions-server-kit/src/hooks}/useIsomorphicLayoutEffect.cjs.js +0 -0
- /package/dist/{hooks → packages/ui-extensions-server-kit/src/hooks}/useIsomorphicLayoutEffect.es.js +0 -0
- /package/dist/{i18n.cjs.js → packages/ui-extensions-server-kit/src/i18n.cjs.js} +0 -0
- /package/dist/{i18n.es.js → packages/ui-extensions-server-kit/src/i18n.es.js} +0 -0
- /package/dist/{state → packages/ui-extensions-server-kit/src/state}/actions/actions.cjs.js +0 -0
- /package/dist/{state → packages/ui-extensions-server-kit/src/state}/actions/actions.es.js +0 -0
- /package/dist/{state → packages/ui-extensions-server-kit/src/state}/reducers/constants.cjs.js +0 -0
- /package/dist/{state → packages/ui-extensions-server-kit/src/state}/reducers/constants.es.js +0 -0
- /package/dist/{state → packages/ui-extensions-server-kit/src/state}/reducers/extensionServerReducer.cjs.js +0 -0
- /package/dist/{state → packages/ui-extensions-server-kit/src/state}/reducers/extensionServerReducer.es.js +0 -0
- /package/dist/{testing → packages/ui-extensions-server-kit/src/testing}/app.cjs.js +0 -0
- /package/dist/{testing → packages/ui-extensions-server-kit/src/testing}/app.es.js +0 -0
- /package/dist/{testing → packages/ui-extensions-server-kit/src/testing}/extensions.cjs.js +0 -0
- /package/dist/{testing → packages/ui-extensions-server-kit/src/testing}/extensions.es.js +0 -0
- /package/dist/{types.cjs.js → packages/ui-extensions-server-kit/src/types.cjs.js} +0 -0
- /package/dist/{types.es.js → packages/ui-extensions-server-kit/src/types.es.js} +0 -0
- /package/dist/{utilities → packages/ui-extensions-server-kit/src/utilities}/assetToString.cjs.js +0 -0
- /package/dist/{utilities → packages/ui-extensions-server-kit/src/utilities}/assetToString.es.js +0 -0
- /package/dist/{utilities → packages/ui-extensions-server-kit/src/utilities}/noop.cjs.js +0 -0
- /package/dist/{utilities → packages/ui-extensions-server-kit/src/utilities}/noop.es.js +0 -0
- /package/dist/{utilities → packages/ui-extensions-server-kit/src/utilities}/replaceUpdated.cjs.js +0 -0
- /package/dist/{utilities → packages/ui-extensions-server-kit/src/utilities}/replaceUpdated.es.js +0 -0
- /package/dist/{utilities → packages/ui-extensions-server-kit/src/utilities}/set.cjs.js +0 -0
- /package/dist/{utilities → packages/ui-extensions-server-kit/src/utilities}/set.es.js +0 -0
- /package/node_modules/@vitejs/{plugin-react-refresh → plugin-react}/LICENSE +0 -0
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@vitejs/plugin-react",
|
|
3
|
+
"version": "5.1.4",
|
|
4
|
+
"description": "The default Vite plugin for React projects",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"babel",
|
|
7
|
+
"fast refresh",
|
|
8
|
+
"react",
|
|
9
|
+
"react-refresh",
|
|
10
|
+
"vite",
|
|
11
|
+
"vite-plugin"
|
|
12
|
+
],
|
|
13
|
+
"homepage": "https://github.com/vitejs/vite-plugin-react/tree/main/packages/plugin-react#readme",
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/vitejs/vite-plugin-react/issues"
|
|
16
|
+
},
|
|
17
|
+
"license": "MIT",
|
|
18
|
+
"author": "Evan You",
|
|
19
|
+
"contributors": [
|
|
20
|
+
"Alec Larson",
|
|
21
|
+
"Arnaud Barré"
|
|
22
|
+
],
|
|
23
|
+
"repository": {
|
|
24
|
+
"type": "git",
|
|
25
|
+
"url": "git+https://github.com/vitejs/vite-plugin-react.git",
|
|
26
|
+
"directory": "packages/plugin-react"
|
|
27
|
+
},
|
|
28
|
+
"files": [
|
|
29
|
+
"dist",
|
|
30
|
+
"types"
|
|
31
|
+
],
|
|
32
|
+
"type": "module",
|
|
33
|
+
"exports": {
|
|
34
|
+
".": "./dist/index.js",
|
|
35
|
+
"./preamble": "./types/preamble.d.ts"
|
|
36
|
+
},
|
|
37
|
+
"scripts": {
|
|
38
|
+
"dev": "tsdown --watch ./src --watch ../common",
|
|
39
|
+
"build": "tsdown",
|
|
40
|
+
"prepublishOnly": "npm run build",
|
|
41
|
+
"test-unit": "vitest run"
|
|
42
|
+
},
|
|
43
|
+
"dependencies": {
|
|
44
|
+
"@babel/core": "^7.29.0",
|
|
45
|
+
"@babel/plugin-transform-react-jsx-self": "^7.27.1",
|
|
46
|
+
"@babel/plugin-transform-react-jsx-source": "^7.27.1",
|
|
47
|
+
"@rolldown/pluginutils": "1.0.0-rc.3",
|
|
48
|
+
"@types/babel__core": "^7.20.5",
|
|
49
|
+
"react-refresh": "^0.18.0"
|
|
50
|
+
},
|
|
51
|
+
"devDependencies": {
|
|
52
|
+
"@vitejs/react-common": "workspace:*",
|
|
53
|
+
"babel-plugin-react-compiler": "19.1.0-rc.3",
|
|
54
|
+
"react": "^19.2.4",
|
|
55
|
+
"react-dom": "^19.2.4",
|
|
56
|
+
"rolldown": "1.0.0-rc.3",
|
|
57
|
+
"tsdown": "^0.20.3"
|
|
58
|
+
},
|
|
59
|
+
"peerDependencies": {
|
|
60
|
+
"vite": "^4.2.0 || ^5.0.0 || ^6.0.0 || ^7.0.0"
|
|
61
|
+
},
|
|
62
|
+
"engines": {
|
|
63
|
+
"node": "^20.19.0 || >=22.12.0"
|
|
64
|
+
},
|
|
65
|
+
"compatiblePackages": {
|
|
66
|
+
"schemaVersion": 1,
|
|
67
|
+
"rolldown": {
|
|
68
|
+
"type": "compatible",
|
|
69
|
+
"versions": "^1.0.0-beta.44",
|
|
70
|
+
"note": "You can use Rolldown's built-in feature directly."
|
|
71
|
+
},
|
|
72
|
+
"rollup": {
|
|
73
|
+
"type": "incompatible",
|
|
74
|
+
"reason": "Uses Rolldown-specific APIs or Vite-specific APIs"
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shopify/ui-extensions-server-kit",
|
|
3
|
-
"version": "5.4.
|
|
3
|
+
"version": "5.4.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -43,17 +43,16 @@
|
|
|
43
43
|
}
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@
|
|
47
|
-
"@
|
|
48
|
-
"@
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"react": "^
|
|
52
|
-
"vi-fetch": "^0.8.0",
|
|
46
|
+
"@testing-library/react": "^16.3.2",
|
|
47
|
+
"@types/react": "^18.2.0",
|
|
48
|
+
"@vitejs/plugin-react": "^5.1.4",
|
|
49
|
+
"jsdom": "^25.0.0",
|
|
50
|
+
"react": "^18.2.0",
|
|
51
|
+
"react-dom": "^18.2.0",
|
|
53
52
|
"vite": "6.4.1"
|
|
54
53
|
},
|
|
55
54
|
"peerDependencies": {
|
|
56
|
-
"react": "
|
|
55
|
+
"react": ">=17.0.2"
|
|
57
56
|
},
|
|
58
57
|
"scripts": {
|
|
59
58
|
"build": "nx build",
|
package/project.json
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"executor": "nx:run-commands",
|
|
18
18
|
"outputs": ["{workspaceRoot}/dist"],
|
|
19
19
|
"options": {
|
|
20
|
-
"command": "pnpm vite build --config vite.config.
|
|
20
|
+
"command": "pnpm vite build --config vite.config.mts",
|
|
21
21
|
"cwd": "packages/ui-extensions-server-kit"
|
|
22
22
|
}
|
|
23
23
|
},
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import {ExtensionServerClient} from './ExtensionServerClient'
|
|
2
2
|
import {DeepPartial} from '../types'
|
|
3
3
|
import {mockApp} from '../testing'
|
|
4
|
-
|
|
4
|
+
|
|
5
5
|
import {Localization} from 'i18n.js'
|
|
6
|
+
import {beforeEach, expect, test, vi, describe} from 'vitest'
|
|
6
7
|
|
|
7
8
|
// Mock React's act function because jest-websocket-mock tries to use it
|
|
8
9
|
vi.mock('react-dom/test-utils', () => ({
|
|
@@ -51,7 +52,7 @@ class MockWebSocket implements Partial<WebSocket> {
|
|
|
51
52
|
onmessage: ((ev: MessageEvent) => any) | null = null
|
|
52
53
|
onclose: ((ev: CloseEvent) => any) | null = null
|
|
53
54
|
server: MockWebSocketServer
|
|
54
|
-
private eventListeners:
|
|
55
|
+
private eventListeners: Record<string, Set<EventListener>> = {
|
|
55
56
|
open: new Set(),
|
|
56
57
|
message: new Set(),
|
|
57
58
|
close: new Set(),
|
|
@@ -1032,7 +1033,7 @@ describe('ExtensionServerClient', () => {
|
|
|
1032
1033
|
mockSocketServer.connect(mockSocket)
|
|
1033
1034
|
|
|
1034
1035
|
// Persist data
|
|
1035
|
-
const extensionData = {extensions: [{uuid: '123'}]}
|
|
1036
|
+
const extensionData = {extensions: [{uuid: '123'}]} as any
|
|
1036
1037
|
client.persist('update', extensionData)
|
|
1037
1038
|
|
|
1038
1039
|
// Verify the correct message was sent
|
|
@@ -1092,7 +1093,7 @@ describe('ExtensionServerClient', () => {
|
|
|
1092
1093
|
extensionPoints: [{localization: {}, name: 'いらっしゃいませ!', description: '拡張子の説明'}],
|
|
1093
1094
|
},
|
|
1094
1095
|
],
|
|
1095
|
-
}
|
|
1096
|
+
} as any
|
|
1096
1097
|
|
|
1097
1098
|
// Persist the data
|
|
1098
1099
|
client.persist('update', extensionData)
|
|
@@ -1125,7 +1126,7 @@ describe('ExtensionServerClient', () => {
|
|
|
1125
1126
|
// Create data with localization fields
|
|
1126
1127
|
const extensionData = {
|
|
1127
1128
|
extensions: [{uuid: '123', type: 'ui_extension', localization: {}, extensionPoints: [{localization: {}}]}],
|
|
1128
|
-
}
|
|
1129
|
+
} as any
|
|
1129
1130
|
|
|
1130
1131
|
// Persist the data
|
|
1131
1132
|
client.persist('update', extensionData)
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-dynamic-delete */
|
|
2
1
|
/* eslint-disable no-console */
|
|
3
|
-
import {Surface} from './types.js'
|
|
4
2
|
import {ExtensionServer} from './server-types.js'
|
|
3
|
+
import {Surface} from './types.js'
|
|
5
4
|
import {
|
|
6
5
|
FlattenedLocalization,
|
|
7
6
|
Localization,
|
|
@@ -21,12 +20,16 @@ export class ExtensionServerClient implements ExtensionServer.Client {
|
|
|
21
20
|
|
|
22
21
|
protected EVENT_THAT_WILL_MUTATE_THE_SERVER = ['update']
|
|
23
22
|
|
|
24
|
-
|
|
25
|
-
protected
|
|
23
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
24
|
+
protected listeners: Record<string, Set<(payload: any) => void>> = {}
|
|
25
|
+
protected connectionListeners: {close: Set<(event: Event) => void>; open: Set<(event: Event) => void>} = {
|
|
26
|
+
close: new Set(),
|
|
27
|
+
open: new Set(),
|
|
28
|
+
}
|
|
26
29
|
|
|
27
30
|
protected connected = false
|
|
28
31
|
|
|
29
|
-
private uiExtensionsByUuid:
|
|
32
|
+
private uiExtensionsByUuid: Record<string, ExtensionServer.UIExtension> = {}
|
|
30
33
|
|
|
31
34
|
constructor(options: DeepPartial<ExtensionServer.Options> = {}) {
|
|
32
35
|
this.id = (Math.random() + 1).toString(36).substring(7)
|
|
@@ -47,7 +50,7 @@ export class ExtensionServerClient implements ExtensionServer.Client {
|
|
|
47
50
|
const optionsChanged = JSON.stringify(newOptions) !== JSON.stringify(this.options)
|
|
48
51
|
|
|
49
52
|
if (optionsChanged) {
|
|
50
|
-
this.options = newOptions
|
|
53
|
+
this.options = newOptions as ExtensionServer.Options
|
|
51
54
|
this.setupConnection(true)
|
|
52
55
|
}
|
|
53
56
|
|
|
@@ -102,14 +105,17 @@ export class ExtensionServerClient implements ExtensionServer.Client {
|
|
|
102
105
|
* }
|
|
103
106
|
* ```
|
|
104
107
|
*/
|
|
105
|
-
|
|
108
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
109
|
+
;(data as any).extensions?.forEach((extension: ExtensionPayload) => {
|
|
106
110
|
TRANSLATED_KEYS.forEach((key) => {
|
|
107
111
|
if (isUIExtension(extension)) {
|
|
108
112
|
extension.extensionPoints?.forEach((extensionPoint) => {
|
|
109
|
-
|
|
113
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
114
|
+
delete (extensionPoint as any)[key]
|
|
110
115
|
})
|
|
111
116
|
}
|
|
112
|
-
|
|
117
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
118
|
+
delete (extension as any)[key]
|
|
113
119
|
})
|
|
114
120
|
})
|
|
115
121
|
return this.connection?.send(JSON.stringify({event, data}))
|
|
@@ -119,7 +125,8 @@ export class ExtensionServerClient implements ExtensionServer.Client {
|
|
|
119
125
|
}
|
|
120
126
|
|
|
121
127
|
public emit<TEvent extends keyof ExtensionServer.DispatchEvents>(...args: ExtensionServer.EmitArgs<TEvent>): void {
|
|
122
|
-
const
|
|
128
|
+
const event = args[0]
|
|
129
|
+
const data = args.length > 1 ? args[1] : undefined
|
|
123
130
|
|
|
124
131
|
if (this.EVENT_THAT_WILL_MUTATE_THE_SERVER.includes(event as string)) {
|
|
125
132
|
return console.warn(
|
|
@@ -156,19 +163,20 @@ export class ExtensionServerClient implements ExtensionServer.Client {
|
|
|
156
163
|
this.connection?.addEventListener('message', (message) => {
|
|
157
164
|
try {
|
|
158
165
|
const {event, data} = JSON.parse(message.data) as ExtensionServer.ServerEvents
|
|
166
|
+
const typedData = data
|
|
159
167
|
|
|
160
168
|
if (event === 'dispatch') {
|
|
161
|
-
const {type, payload} =
|
|
169
|
+
const {type, payload} = typedData as {type: string; payload: unknown}
|
|
162
170
|
this.listeners[type]?.forEach((listener) => listener(payload))
|
|
163
171
|
return
|
|
164
172
|
}
|
|
165
173
|
|
|
166
|
-
const filteredExtensions =
|
|
167
|
-
? filterExtensionsBySurface(
|
|
168
|
-
:
|
|
174
|
+
const filteredExtensions = typedData.extensions
|
|
175
|
+
? filterExtensionsBySurface(typedData.extensions, this.options.surface)
|
|
176
|
+
: typedData.extensions
|
|
169
177
|
|
|
170
178
|
this.listeners[event]?.forEach((listener) => {
|
|
171
|
-
listener({...
|
|
179
|
+
listener({...typedData, extensions: this._getLocalizedExtensions(filteredExtensions)})
|
|
172
180
|
})
|
|
173
181
|
// eslint-disable-next-line no-catch-all/no-catch-all
|
|
174
182
|
} catch (err) {
|
|
@@ -213,9 +221,9 @@ export class ExtensionServerClient implements ExtensionServer.Client {
|
|
|
213
221
|
|
|
214
222
|
const localization = shouldUpdateTranslations
|
|
215
223
|
? getFlattenedLocalization(extension.localization, this.options.locales)
|
|
216
|
-
: this.uiExtensionsByUuid[extension.uuid]?.localization ?? extension.localization
|
|
224
|
+
: (this.uiExtensionsByUuid[extension.uuid]?.localization ?? extension.localization)
|
|
217
225
|
|
|
218
|
-
const parsedTranslation:
|
|
226
|
+
const parsedTranslation: Record<string, string> =
|
|
219
227
|
localization && isFlattenedTranslations(localization) ? JSON.parse(localization.translations) : localization
|
|
220
228
|
|
|
221
229
|
const localizedExtension = {
|
|
@@ -260,7 +268,7 @@ export class ExtensionServerClient implements ExtensionServer.Client {
|
|
|
260
268
|
})
|
|
261
269
|
}
|
|
262
270
|
|
|
263
|
-
private _getLocalizedValue(translations:
|
|
271
|
+
private _getLocalizedValue(translations: Record<string, string>, value: string): string {
|
|
264
272
|
const translationKey = value.replace('t:', '')
|
|
265
273
|
return translations[translationKey] || value
|
|
266
274
|
}
|
|
@@ -295,7 +303,7 @@ function filterExtensionsBySurface(extensions: ExtensionPayload[], surface: Surf
|
|
|
295
303
|
}
|
|
296
304
|
|
|
297
305
|
if (Array.isArray(extension.extensionPoints)) {
|
|
298
|
-
const extensionPoints
|
|
306
|
+
const extensionPoints = extension.extensionPoints as (string | {surface: Surface; [key: string]: unknown})[]
|
|
299
307
|
const extensionPointMatchingSurface = extensionPoints.filter((extensionPoint) => {
|
|
300
308
|
if (typeof extensionPoint === 'string') {
|
|
301
309
|
return false
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import {Surface} from './types.js'
|
|
2
|
-
import {ExtensionPayload, ExtensionPoint} from '../types'
|
|
3
|
-
import {FlattenedLocalization, Localization} from '../i18n'
|
|
2
|
+
import {ExtensionPayload, ExtensionPoint, App} from '../types'
|
|
3
|
+
import {FlattenedLocalization, LocalesOptions, Localization} from '../i18n'
|
|
4
4
|
|
|
5
|
+
// Re-export and augment the global ExtensionServer namespace
|
|
5
6
|
export namespace ExtensionServer {
|
|
6
7
|
export interface UIExtension extends ExtensionPayload {
|
|
7
8
|
extensionPoints: ExtensionPoint[]
|
|
@@ -29,24 +30,33 @@ export namespace ExtensionServer {
|
|
|
29
30
|
protocols?: string | string[]
|
|
30
31
|
}
|
|
31
32
|
surface?: Surface
|
|
32
|
-
locales?:
|
|
33
|
+
locales?: LocalesOptions
|
|
33
34
|
}
|
|
34
35
|
|
|
35
36
|
export interface ServerEvents {
|
|
36
37
|
event: string
|
|
38
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
37
39
|
data: any
|
|
38
40
|
}
|
|
39
41
|
|
|
40
|
-
export interface InboundEvents {
|
|
41
|
-
|
|
42
|
+
export interface InboundEvents extends DispatchEvents {
|
|
43
|
+
dispatch: {type: keyof DispatchEvents; payload: DispatchEvents[keyof DispatchEvents]}
|
|
44
|
+
connected: {extensions: ExtensionPayload[]; app?: App; store: string}
|
|
45
|
+
update: {extensions?: ExtensionPayload[]; app?: App}
|
|
42
46
|
}
|
|
43
47
|
|
|
44
48
|
export interface OutboundPersistEvents {
|
|
45
|
-
|
|
49
|
+
update: {
|
|
50
|
+
extensions?: ExtensionPayload[]
|
|
51
|
+
app?: App
|
|
52
|
+
}
|
|
46
53
|
}
|
|
47
54
|
|
|
48
55
|
export interface DispatchEvents {
|
|
49
|
-
|
|
56
|
+
refresh: {uuid: string}[]
|
|
57
|
+
focus: {uuid: string}[]
|
|
58
|
+
unfocus: void
|
|
59
|
+
navigate: {url: string}
|
|
50
60
|
}
|
|
51
61
|
|
|
52
62
|
export type EmitArgs<TEvent extends keyof DispatchEvents> = undefined extends DispatchEvents[TEvent]
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import {ExtensionServerProvider} from './ExtensionServerProvider'
|
|
2
|
-
import {mockApp, mockExtension} from '../testing'
|
|
3
2
|
import {useExtensionServerContext} from '../hooks'
|
|
4
3
|
import {createConnectedAction} from '../state'
|
|
5
|
-
import {
|
|
4
|
+
import {mockApp, mockExtension} from '../testing'
|
|
5
|
+
import React from 'react'
|
|
6
6
|
import {beforeEach, afterEach, expect} from 'vitest'
|
|
7
|
+
import {renderHook, act} from '@testing-library/react'
|
|
7
8
|
|
|
8
|
-
// Create a custom mock WebSocket implementation to avoid using jest-websocket-mock
|
|
9
9
|
class MockWebSocketServer {
|
|
10
10
|
clients: MockWebSocket[] = []
|
|
11
11
|
messages: any[] = []
|
|
12
12
|
|
|
13
13
|
connect(socket: MockWebSocket) {
|
|
14
|
-
// Make socket connection active
|
|
15
14
|
this.clients.push(socket)
|
|
16
15
|
socket.readyState = 1
|
|
17
16
|
socket.onopen?.({} as Event)
|
|
@@ -28,7 +27,6 @@ class MockWebSocketServer {
|
|
|
28
27
|
}
|
|
29
28
|
|
|
30
29
|
close() {
|
|
31
|
-
// Close all socket connections
|
|
32
30
|
this.clients.forEach((client) => {
|
|
33
31
|
client.readyState = 3
|
|
34
32
|
client.onclose?.({} as CloseEvent)
|
|
@@ -45,7 +43,7 @@ class MockWebSocket implements Partial<WebSocket> {
|
|
|
45
43
|
onmessage: ((ev: MessageEvent) => any) | null = null
|
|
46
44
|
onclose: ((ev: CloseEvent) => any) | null = null
|
|
47
45
|
server: MockWebSocketServer
|
|
48
|
-
private eventListeners:
|
|
46
|
+
private eventListeners: Record<string, Set<EventListener>> = {
|
|
49
47
|
open: new Set(),
|
|
50
48
|
message: new Set(),
|
|
51
49
|
close: new Set(),
|
|
@@ -63,7 +61,6 @@ class MockWebSocket implements Partial<WebSocket> {
|
|
|
63
61
|
}
|
|
64
62
|
this.eventListeners[type].add(listener)
|
|
65
63
|
|
|
66
|
-
// Map standard event handlers to addEventListener
|
|
67
64
|
if (type === 'open' && this.onopen === null) {
|
|
68
65
|
this.onopen = (event) => {
|
|
69
66
|
this.eventListeners.open.forEach((listener) => listener(event))
|
|
@@ -113,27 +110,27 @@ class MockWebSocket implements Partial<WebSocket> {
|
|
|
113
110
|
}
|
|
114
111
|
}
|
|
115
112
|
|
|
116
|
-
// Set up mock socket server and prepare for test environment
|
|
117
113
|
let mockSocketServer: MockWebSocketServer
|
|
118
114
|
let originalWebSocket: typeof WebSocket
|
|
119
115
|
|
|
120
|
-
|
|
116
|
+
function createWrapper(options: {connection: {url?: string}}) {
|
|
117
|
+
return function Wrapper({children}: {children: React.ReactNode}) {
|
|
118
|
+
return <ExtensionServerProvider options={options}>{children}</ExtensionServerProvider>
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
121
122
|
beforeEach(() => {
|
|
122
123
|
mockSocketServer = new MockWebSocketServer()
|
|
123
124
|
|
|
124
|
-
// Store original WebSocket and replace with our mock
|
|
125
125
|
originalWebSocket = globalThis.WebSocket
|
|
126
126
|
|
|
127
|
-
// Mock WebSocket global
|
|
128
127
|
globalThis.WebSocket = function (url: string) {
|
|
129
128
|
const socket = new MockWebSocket(url, mockSocketServer)
|
|
130
129
|
return socket as unknown as WebSocket
|
|
131
130
|
} as unknown as typeof WebSocket
|
|
132
131
|
})
|
|
133
132
|
|
|
134
|
-
// Restore original WebSocket after each test
|
|
135
133
|
afterEach(() => {
|
|
136
|
-
// Restore the original WebSocket
|
|
137
134
|
globalThis.WebSocket = originalWebSocket
|
|
138
135
|
})
|
|
139
136
|
|
|
@@ -142,17 +139,17 @@ describe('ExtensionServerProvider tests', () => {
|
|
|
142
139
|
test('creates a new ExtensionServerClient instance', async () => {
|
|
143
140
|
const options = {connection: {url: 'ws://example-host.com:8000/extensions/'}}
|
|
144
141
|
|
|
145
|
-
const
|
|
142
|
+
const {result} = renderHook(useExtensionServerContext, {wrapper: createWrapper(options)})
|
|
146
143
|
|
|
147
|
-
expect(
|
|
144
|
+
expect(result.current.client).toBeDefined()
|
|
148
145
|
})
|
|
149
146
|
|
|
150
147
|
test('does not start a new connection if an empty url is passed', async () => {
|
|
151
148
|
const options = {connection: {}}
|
|
152
149
|
|
|
153
|
-
const
|
|
150
|
+
const {result} = renderHook(useExtensionServerContext, {wrapper: createWrapper(options)})
|
|
154
151
|
|
|
155
|
-
expect(
|
|
152
|
+
expect(result.current.client.connection).toBeUndefined()
|
|
156
153
|
})
|
|
157
154
|
})
|
|
158
155
|
|
|
@@ -160,18 +157,13 @@ describe('ExtensionServerProvider tests', () => {
|
|
|
160
157
|
test('starts a new connection by calling connect', async () => {
|
|
161
158
|
const options = {connection: {url: 'ws://example-host.com:8000/extensions/'}}
|
|
162
159
|
|
|
163
|
-
const
|
|
164
|
-
|
|
165
|
-
connection: {url: ''},
|
|
166
|
-
},
|
|
160
|
+
const {result} = renderHook(useExtensionServerContext, {
|
|
161
|
+
wrapper: createWrapper({connection: {url: ''}}),
|
|
167
162
|
})
|
|
168
163
|
|
|
169
|
-
|
|
170
|
-
wrapper.act(({connect}) => connect(options))
|
|
164
|
+
act(() => result.current.connect(options))
|
|
171
165
|
|
|
172
|
-
|
|
173
|
-
// Just check that the connection object exists
|
|
174
|
-
expect(wrapper.result.client.connection).toBeDefined()
|
|
166
|
+
expect(result.current.client.connection).toBeDefined()
|
|
175
167
|
})
|
|
176
168
|
})
|
|
177
169
|
|
|
@@ -181,13 +173,14 @@ describe('ExtensionServerProvider tests', () => {
|
|
|
181
173
|
const app = mockApp()
|
|
182
174
|
const extension = mockExtension()
|
|
183
175
|
const payload = {app, extensions: [extension], store: 'test-store.com'}
|
|
184
|
-
const wrapper = renderHook(useExtensionServerContext, withProviders(ExtensionServerProvider), {options})
|
|
185
176
|
|
|
186
|
-
|
|
187
|
-
|
|
177
|
+
const {result} = renderHook(useExtensionServerContext, {wrapper: createWrapper(options)})
|
|
178
|
+
|
|
179
|
+
act(() => {
|
|
180
|
+
result.current.dispatch({type: 'connected', payload})
|
|
188
181
|
})
|
|
189
182
|
|
|
190
|
-
expect(
|
|
183
|
+
expect(result.current.state).toStrictEqual({
|
|
191
184
|
app,
|
|
192
185
|
extensions: [extension],
|
|
193
186
|
store: 'test-store.com',
|
|
@@ -201,16 +194,14 @@ describe('ExtensionServerProvider tests', () => {
|
|
|
201
194
|
const extension = mockExtension()
|
|
202
195
|
const data = {app, store: 'test-store.com', extensions: [extension]}
|
|
203
196
|
const options = {connection: {url: 'ws://example-host.com:8000/extensions/'}}
|
|
204
|
-
const wrapper = renderHook(useExtensionServerContext, withProviders(ExtensionServerProvider), {options})
|
|
205
197
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
dispatch(createConnectedAction(data))
|
|
198
|
+
const {result} = renderHook(useExtensionServerContext, {wrapper: createWrapper(options)})
|
|
199
|
+
|
|
200
|
+
act(() => {
|
|
201
|
+
result.current.dispatch(createConnectedAction(data))
|
|
210
202
|
})
|
|
211
203
|
|
|
212
|
-
|
|
213
|
-
expect(wrapper.result.state).toEqual({
|
|
204
|
+
expect(result.current.state).toEqual({
|
|
214
205
|
app,
|
|
215
206
|
extensions: [extension],
|
|
216
207
|
store: 'test-store.com',
|
|
@@ -223,20 +214,18 @@ describe('ExtensionServerProvider tests', () => {
|
|
|
223
214
|
const update = {...extension, version: 'v2'}
|
|
224
215
|
const data = {app, store: 'test-store.com', extensions: [extension]}
|
|
225
216
|
const options = {connection: {url: 'ws://example-host.com:8000/extensions/'}}
|
|
226
|
-
const wrapper = renderHook(useExtensionServerContext, withProviders(ExtensionServerProvider), {options})
|
|
227
217
|
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
218
|
+
const {result} = renderHook(useExtensionServerContext, {wrapper: createWrapper(options)})
|
|
219
|
+
|
|
220
|
+
act(() => {
|
|
221
|
+
result.current.dispatch(createConnectedAction(data))
|
|
231
222
|
})
|
|
232
223
|
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
dispatch(createConnectedAction({...data, extensions: [update]}))
|
|
224
|
+
act(() => {
|
|
225
|
+
result.current.dispatch(createConnectedAction({...data, extensions: [update]}))
|
|
236
226
|
})
|
|
237
227
|
|
|
238
|
-
|
|
239
|
-
expect(wrapper.result.state).toEqual({
|
|
228
|
+
expect(result.current.state).toEqual({
|
|
240
229
|
app,
|
|
241
230
|
extensions: [update],
|
|
242
231
|
store: 'test-store.com',
|
|
@@ -248,21 +237,19 @@ describe('ExtensionServerProvider tests', () => {
|
|
|
248
237
|
const extension = mockExtension()
|
|
249
238
|
const data = {app, store: 'test-store.com', extensions: [extension]}
|
|
250
239
|
const options = {connection: {url: 'ws://example-host.com:8000/extensions/'}}
|
|
251
|
-
const wrapper = renderHook(useExtensionServerContext, withProviders(ExtensionServerProvider), {options})
|
|
252
240
|
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
241
|
+
const {result} = renderHook(useExtensionServerContext, {wrapper: createWrapper(options)})
|
|
242
|
+
|
|
243
|
+
act(() => {
|
|
244
|
+
result.current.dispatch(createConnectedAction(data))
|
|
256
245
|
})
|
|
257
246
|
|
|
258
|
-
|
|
259
|
-
expect(
|
|
260
|
-
expect(wrapper.result.state.extensions[0].uuid).toBe(extension.uuid)
|
|
247
|
+
expect(result.current.state.extensions.length).toBe(1)
|
|
248
|
+
expect(result.current.state.extensions[0].uuid).toBe(extension.uuid)
|
|
261
249
|
})
|
|
262
250
|
|
|
263
251
|
test('persists focus data to the state', async () => {
|
|
264
252
|
const app = mockApp()
|
|
265
|
-
// Create extension with development object that includes focused property
|
|
266
253
|
const extension = {
|
|
267
254
|
...mockExtension(),
|
|
268
255
|
development: {
|
|
@@ -272,15 +259,14 @@ describe('ExtensionServerProvider tests', () => {
|
|
|
272
259
|
}
|
|
273
260
|
const data = {app, store: 'test-store.com', extensions: [extension]}
|
|
274
261
|
const options = {connection: {url: 'ws://example-host.com:8000/extensions/'}}
|
|
275
|
-
const wrapper = renderHook(useExtensionServerContext, withProviders(ExtensionServerProvider), {options})
|
|
276
262
|
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
263
|
+
const {result} = renderHook(useExtensionServerContext, {wrapper: createWrapper(options)})
|
|
264
|
+
|
|
265
|
+
act(() => {
|
|
266
|
+
result.current.dispatch(createConnectedAction(data))
|
|
280
267
|
})
|
|
281
268
|
|
|
282
|
-
|
|
283
|
-
wrapper.act(({dispatch}) => {
|
|
269
|
+
act(() => {
|
|
284
270
|
const focusedExtension = {
|
|
285
271
|
...extension,
|
|
286
272
|
development: {
|
|
@@ -288,17 +274,15 @@ describe('ExtensionServerProvider tests', () => {
|
|
|
288
274
|
focused: true,
|
|
289
275
|
},
|
|
290
276
|
}
|
|
291
|
-
dispatch(createConnectedAction({...data, extensions: [focusedExtension]}))
|
|
277
|
+
result.current.dispatch(createConnectedAction({...data, extensions: [focusedExtension]}))
|
|
292
278
|
})
|
|
293
279
|
|
|
294
|
-
|
|
295
|
-
const [updatedExtension] = wrapper.result.state.extensions
|
|
280
|
+
const [updatedExtension] = result.current.state.extensions
|
|
296
281
|
expect(updatedExtension.development.focused).toBe(true)
|
|
297
282
|
})
|
|
298
283
|
|
|
299
284
|
test('persists unfocus data to the state', async () => {
|
|
300
285
|
const app = mockApp()
|
|
301
|
-
// Set extension as initially focused
|
|
302
286
|
const extension = {
|
|
303
287
|
...mockExtension(),
|
|
304
288
|
development: {
|
|
@@ -309,15 +293,14 @@ describe('ExtensionServerProvider tests', () => {
|
|
|
309
293
|
|
|
310
294
|
const data = {app, store: 'test-store.com', extensions: [extension]}
|
|
311
295
|
const options = {connection: {url: 'ws://example-host.com:8000/extensions/'}}
|
|
312
|
-
const wrapper = renderHook(useExtensionServerContext, withProviders(ExtensionServerProvider), {options})
|
|
313
296
|
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
297
|
+
const {result} = renderHook(useExtensionServerContext, {wrapper: createWrapper(options)})
|
|
298
|
+
|
|
299
|
+
act(() => {
|
|
300
|
+
result.current.dispatch(createConnectedAction(data))
|
|
317
301
|
})
|
|
318
302
|
|
|
319
|
-
|
|
320
|
-
wrapper.act(({dispatch}) => {
|
|
303
|
+
act(() => {
|
|
321
304
|
const unfocusedExtension = {
|
|
322
305
|
...extension,
|
|
323
306
|
development: {
|
|
@@ -325,11 +308,10 @@ describe('ExtensionServerProvider tests', () => {
|
|
|
325
308
|
focused: false,
|
|
326
309
|
},
|
|
327
310
|
}
|
|
328
|
-
dispatch(createConnectedAction({...data, extensions: [unfocusedExtension]}))
|
|
311
|
+
result.current.dispatch(createConnectedAction({...data, extensions: [unfocusedExtension]}))
|
|
329
312
|
})
|
|
330
313
|
|
|
331
|
-
|
|
332
|
-
const [updatedExtension] = wrapper.result.state.extensions
|
|
314
|
+
const [updatedExtension] = result.current.state.extensions
|
|
333
315
|
expect(updatedExtension.development.focused).toBe(false)
|
|
334
316
|
})
|
|
335
317
|
})
|
|
@@ -11,6 +11,7 @@ import {ExtensionServerClient} from '../ExtensionServerClient'
|
|
|
11
11
|
import {ExtensionServer} from '../ExtensionServerClient/server-types.js'
|
|
12
12
|
import {useIsomorphicLayoutEffect} from '../hooks/useIsomorphicLayoutEffect'
|
|
13
13
|
import {useExtensionServerState} from '../hooks/useExtensionServerState'
|
|
14
|
+
|
|
14
15
|
import React, {useCallback, useMemo, useState} from 'react'
|
|
15
16
|
|
|
16
17
|
import type {ExtensionServerProviderProps} from './types'
|