@teambit/component 0.0.640 → 0.0.641
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/{__preview-1643858579620.js → __preview-1644176887286.js} +1 -1
- package/dist/ui/use-component-query.js +2 -0
- package/dist/ui/use-component-query.js.map +1 -1
- package/package-tar/teambit-component-0.0.641.tgz +0 -0
- package/package.json +16 -16
- package/ui/use-component-query.ts +2 -0
- package/package-tar/teambit-component-0.0.640.tgz +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
export const overview = [require('/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.component_component@0.0.
|
|
1
|
+
export const overview = [require('/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.component_component@0.0.641/dist/component.docs.mdx')]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["use-component-query.ts"],"names":["componentIdFields","componentFields","GET_COMPONENT","SUB_SUBSCRIPTION_ADDED","SUB_COMPONENT_CHANGED","SUB_COMPONENT_REMOVED","useComponentQuery","componentId","host","idRef","current","data","error","loading","subscribeToMore","variables","id","extensionId","unsubAddition","document","updateQuery","prev","subscriptionData","prevComponent","getHost","get","addedComponent","componentAdded","component","name","unsubChanges","updatedComponent","componentChanged","isUpdated","ComponentID","isEqualObj","unsubRemoval","removedIds","componentRemoved","componentIds","length","isRemoved","some","removedId","rawComponent","ComponentModel","from","undefined","ComponentError","message"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;;;;;AAEA,MAAMA,iBAAiB,GAAG,kBAAI;AAC9B;AACA;AACA;AACA;AACA;AACA,CANA;AAQA,MAAMC,eAAe,GAAG,kBAAI;AAC5B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAID,iBAAkB;AACtB,
|
|
1
|
+
{"version":3,"sources":["use-component-query.ts"],"names":["componentIdFields","componentFields","GET_COMPONENT","SUB_SUBSCRIPTION_ADDED","SUB_COMPONENT_CHANGED","SUB_COMPONENT_REMOVED","useComponentQuery","componentId","host","idRef","current","data","error","loading","subscribeToMore","variables","id","extensionId","unsubAddition","document","updateQuery","prev","subscriptionData","prevComponent","getHost","get","addedComponent","componentAdded","component","name","unsubChanges","updatedComponent","componentChanged","isUpdated","ComponentID","isEqualObj","unsubRemoval","removedIds","componentRemoved","componentIds","length","isRemoved","some","removedId","rawComponent","ComponentModel","from","undefined","ComponentError","message"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;;;;;AAEA,MAAMA,iBAAiB,GAAG,kBAAI;AAC9B;AACA;AACA;AACA;AACA;AACA,CANA;AAQA,MAAMC,eAAe,GAAG,kBAAI;AAC5B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAID,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;AAEL;AACAnC,MAAAA,KAAK,EAAEA,KAAK,GACR,KAAIoC,gCAAJ,EAAmB,GAAnB,EAAwBpC,KAAK,CAACqC,OAA9B,CADQ,GAER,CAACL,YAAD,IAAiB,CAAC/B,OAAlB,GACA,KAAImC,gCAAJ,EAAmB,GAAnB,CADA,GAEAD;AAPC,KAAP;AASD,GAVM,EAUJ,CAACH,YAAD,EAAepC,IAAf,EAAqBI,KAArB,CAVI,CAAP;AAWD","sourcesContent":["import { useMemo, useEffect, useRef } from 'react';\nimport { gql } from '@apollo/client';\nimport { useDataQuery } from '@teambit/ui-foundation.ui.hooks.use-data-query';\nimport { ComponentID, ComponentIdObj } from '@teambit/component-id';\n\nimport { ComponentModel } from './component-model';\nimport { ComponentError } from './component-error';\n\nconst componentIdFields = gql`\n fragment componentIdFields on ComponentID {\n name\n version\n scope\n }\n`;\n\nconst componentFields = gql`\n fragment componentFields on Component {\n id {\n ...componentIdFields\n }\n packageName\n elementsUrl\n description\n labels\n displayName\n latest\n server {\n env\n url\n }\n buildStatus\n compositions {\n identifier\n displayName\n }\n tags {\n version\n }\n env {\n id\n icon\n }\n preview {\n includesEnvTemplate\n }\n }\n ${componentIdFields}\n`;\n\nconst GET_COMPONENT = gql`\n query Component($id: String!, $extensionId: String!) {\n getHost(id: $extensionId) {\n id # used for GQL caching\n get(id: $id) {\n ...componentFields\n }\n }\n }\n ${componentFields}\n`;\n\nconst SUB_SUBSCRIPTION_ADDED = gql`\n subscription OnComponentAdded {\n componentAdded {\n component {\n ...componentFields\n }\n }\n }\n ${componentFields}\n`;\n\nconst SUB_COMPONENT_CHANGED = gql`\n subscription OnComponentChanged {\n componentChanged {\n component {\n ...componentFields\n }\n }\n }\n ${componentFields}\n`;\n\nconst SUB_COMPONENT_REMOVED = gql`\n subscription OnComponentRemoved {\n componentRemoved {\n componentIds {\n ...componentIdFields\n }\n }\n }\n ${componentIdFields}\n`;\n\n/** provides data to component ui page, making sure both variables and return value are safely typed and memoized */\nexport function useComponentQuery(componentId: string, host: string) {\n const idRef = useRef(componentId);\n idRef.current = componentId;\n const { data, error, loading, subscribeToMore } = useDataQuery(GET_COMPONENT, {\n variables: { id: componentId, extensionId: host },\n });\n\n useEffect(() => {\n // @TODO @Kutner fix subscription for scope\n if (host !== 'teambit.workspace/workspace') {\n return () => {};\n }\n\n const unsubAddition = subscribeToMore({\n document: SUB_SUBSCRIPTION_ADDED,\n updateQuery: (prev, { subscriptionData }) => {\n const prevComponent = prev?.getHost?.get;\n const addedComponent = subscriptionData?.data?.componentAdded?.component;\n\n if (!addedComponent || prevComponent) return prev;\n\n if (idRef.current === addedComponent.id.name) {\n return {\n ...prev,\n getHost: {\n ...prev.getHost,\n get: addedComponent,\n },\n };\n }\n\n return prev;\n },\n });\n\n const unsubChanges = subscribeToMore({\n document: SUB_COMPONENT_CHANGED,\n updateQuery: (prev, { subscriptionData }) => {\n if (!subscriptionData.data) return prev;\n\n const prevComponent = prev?.getHost?.get;\n const updatedComponent = subscriptionData?.data?.componentChanged?.component;\n\n const isUpdated = updatedComponent && ComponentID.isEqualObj(prevComponent?.id, updatedComponent?.id);\n\n if (isUpdated) {\n return {\n ...prev,\n getHost: {\n ...prev.getHost,\n get: updatedComponent,\n },\n };\n }\n\n return prev;\n },\n });\n\n const unsubRemoval = subscribeToMore({\n document: SUB_COMPONENT_REMOVED,\n updateQuery: (prev, { subscriptionData }) => {\n if (!subscriptionData.data) return prev;\n\n const prevComponent = prev?.getHost?.get;\n const removedIds: ComponentIdObj[] | undefined = subscriptionData?.data?.componentRemoved?.componentIds;\n if (!prevComponent || !removedIds?.length) return prev;\n\n const isRemoved = removedIds.some((removedId) => ComponentID.isEqualObj(removedId, prevComponent.id));\n\n if (isRemoved) {\n return {\n ...prev,\n getHost: {\n ...prev.getHost,\n get: null,\n },\n };\n }\n\n return prev;\n },\n });\n\n return () => {\n unsubChanges();\n unsubAddition();\n unsubRemoval();\n };\n }, []);\n\n const rawComponent = data?.getHost?.get;\n\n return useMemo(() => {\n return {\n component: rawComponent ? ComponentModel.from({ ...rawComponent, host }) : undefined,\n // eslint-disable-next-line\n error: error\n ? new ComponentError(500, error.message)\n : !rawComponent && !loading\n ? new ComponentError(404)\n : undefined,\n };\n }, [rawComponent, host, error]);\n}\n"]}
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teambit/component",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.641",
|
|
4
4
|
"homepage": "https://bit.dev/teambit/component/component",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"componentId": {
|
|
7
7
|
"scope": "teambit.component",
|
|
8
8
|
"name": "component",
|
|
9
|
-
"version": "0.0.
|
|
9
|
+
"version": "0.0.641"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"lodash": "4.17.21",
|
|
@@ -29,22 +29,22 @@
|
|
|
29
29
|
"@teambit/base-ui.routing.routing-provider": "1.0.0",
|
|
30
30
|
"@teambit/component-id": "0.0.400",
|
|
31
31
|
"@teambit/ui-foundation.ui.menu-widget-icon": "0.0.487",
|
|
32
|
-
"@teambit/aspect-loader": "0.0.
|
|
32
|
+
"@teambit/aspect-loader": "0.0.641",
|
|
33
33
|
"@teambit/legacy-bit-id": "0.0.397",
|
|
34
34
|
"@teambit/toolbox.string.capitalize": "0.0.482",
|
|
35
|
-
"@teambit/cli": "0.0.
|
|
36
|
-
"@teambit/config": "0.0.
|
|
37
|
-
"@teambit/express": "0.0.
|
|
38
|
-
"@teambit/graphql": "0.0.
|
|
35
|
+
"@teambit/cli": "0.0.438",
|
|
36
|
+
"@teambit/config": "0.0.451",
|
|
37
|
+
"@teambit/express": "0.0.532",
|
|
38
|
+
"@teambit/graphql": "0.0.641",
|
|
39
39
|
"@teambit/bit-error": "0.0.394",
|
|
40
|
-
"@teambit/command-bar": "0.0.
|
|
41
|
-
"@teambit/preview": "0.0.
|
|
42
|
-
"@teambit/pubsub": "0.0.
|
|
40
|
+
"@teambit/command-bar": "0.0.641",
|
|
41
|
+
"@teambit/preview": "0.0.641",
|
|
42
|
+
"@teambit/pubsub": "0.0.641",
|
|
43
43
|
"@teambit/ui-foundation.ui.is-browser": "0.0.485",
|
|
44
44
|
"@teambit/ui-foundation.ui.main-dropdown": "0.0.485",
|
|
45
45
|
"@teambit/ui-foundation.ui.react-router.slot-router": "0.0.487",
|
|
46
46
|
"@teambit/ui-foundation.ui.use-box.menu": "0.0.108",
|
|
47
|
-
"@teambit/ui": "0.0.
|
|
47
|
+
"@teambit/ui": "0.0.641",
|
|
48
48
|
"@teambit/component-issues": "0.0.45",
|
|
49
49
|
"@teambit/ui-foundation.ui.hooks.use-data-query": "0.0.486",
|
|
50
50
|
"@teambit/cli-table": "0.0.33",
|
|
@@ -53,9 +53,9 @@
|
|
|
53
53
|
"@teambit/harmony.ui.aspect-box": "0.0.485",
|
|
54
54
|
"@teambit/design.ui.pages.not-found": "0.0.353",
|
|
55
55
|
"@teambit/design.ui.pages.server-error": "0.0.353",
|
|
56
|
-
"@teambit/compositions": "0.0.
|
|
57
|
-
"@teambit/deprecation": "0.0.
|
|
58
|
-
"@teambit/envs": "0.0.
|
|
56
|
+
"@teambit/compositions": "0.0.641",
|
|
57
|
+
"@teambit/deprecation": "0.0.641",
|
|
58
|
+
"@teambit/envs": "0.0.641",
|
|
59
59
|
"@teambit/component.ui.version-dropdown": "0.0.491",
|
|
60
60
|
"@teambit/ui-foundation.ui.use-box.dropdown": "0.0.108",
|
|
61
61
|
"@teambit/ui-foundation.ui.react-router.extend-path": "0.0.485"
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
},
|
|
78
78
|
"peerDependencies": {
|
|
79
79
|
"@apollo/client": "^3.0.0",
|
|
80
|
-
"@teambit/legacy": "1.0.
|
|
80
|
+
"@teambit/legacy": "1.0.216",
|
|
81
81
|
"react-dom": "^16.8.0 || ^17.0.0",
|
|
82
82
|
"react": "^16.8.0 || ^17.0.0"
|
|
83
83
|
},
|
|
@@ -105,7 +105,7 @@
|
|
|
105
105
|
"react": "-"
|
|
106
106
|
},
|
|
107
107
|
"peerDependencies": {
|
|
108
|
-
"@teambit/legacy": "1.0.
|
|
108
|
+
"@teambit/legacy": "1.0.216",
|
|
109
109
|
"react-dom": "^16.8.0 || ^17.0.0",
|
|
110
110
|
"react": "^16.8.0 || ^17.0.0"
|
|
111
111
|
}
|
|
Binary file
|