@shopify/ui-extensions-server-kit 5.4.0 → 5.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/README.md +3 -3
- 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 +21 -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 +9 -10
- package/project.json +3 -21
- 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 +16 -11
- package/src/types.ts +23 -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.2.0",
|
|
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 || ^8.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.
|
|
3
|
+
"version": "5.5.0",
|
|
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
|
-
"
|
|
53
|
-
"vite": "6.4.1"
|
|
46
|
+
"@testing-library/react": "^16.3.2",
|
|
47
|
+
"@types/react": "^18.2.0",
|
|
48
|
+
"@vitejs/plugin-react": "^5.2.0",
|
|
49
|
+
"jsdom": "^25.0.0",
|
|
50
|
+
"react": "^18.2.0",
|
|
51
|
+
"react-dom": "^18.2.0",
|
|
52
|
+
"vite": "6.4.3"
|
|
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
|
@@ -13,30 +13,12 @@
|
|
|
13
13
|
"cwd": "packages/ui-extensions-server-kit"
|
|
14
14
|
}
|
|
15
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
16
|
"build": {
|
|
34
17
|
"executor": "nx:run-commands",
|
|
35
|
-
"dependsOn": ["build
|
|
36
|
-
"outputs": ["{workspaceRoot}/dist"],
|
|
37
|
-
"inputs": ["{projectRoot}/src/**/*", "{projectRoot}/testing.*", "{projectRoot}/index.*"],
|
|
18
|
+
"dependsOn": ["^build"],
|
|
38
19
|
"options": {
|
|
39
|
-
"
|
|
20
|
+
"commands": ["pnpm vite build --config vite.config.mts", "pnpm tsc --emitDeclarationOnly"],
|
|
21
|
+
"parallel": true,
|
|
40
22
|
"cwd": "packages/ui-extensions-server-kit"
|
|
41
23
|
}
|
|
42
24
|
},
|
|
@@ -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]
|