@teambit/workspace 0.0.844 → 0.0.845
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/dist/ui/workspace/use-workspace.js +3 -0
- package/dist/ui/workspace/use-workspace.js.map +1 -1
- package/dist/workspace.js +6 -2
- package/dist/workspace.js.map +1 -1
- package/dist/workspace.ui.runtime.d.ts +2 -1
- package/dist/workspace.ui.runtime.js +27 -6
- package/dist/workspace.ui.runtime.js.map +1 -1
- package/package-tar/teambit-workspace-0.0.845.tgz +0 -0
- package/package.json +35 -35
- package/{preview-1662281577904.js → preview-1662521943539.js} +2 -2
- package/ui/workspace/use-workspace.ts +3 -0
- package/workspace.ui.runtime.tsx +16 -6
- package/package-tar/teambit-workspace-0.0.844.tgz +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["wcComponentFields","gql","WORKSPACE","COMPONENT_SUBSCRIPTION_ADDED","COMPONENT_SUBSCRIPTION_CHANGED","COMPONENT_SUBSCRIPTION_REMOVED","useWorkspace","options","useDataQuery","data","subscribeToMore","rest","optionsRef","useLatest","useEffect","unSubCompAddition","document","updateQuery","prev","subscriptionData","update","addedComponent","componentAdded","component","componentExists","workspace","components","find","ComponentID","isEqualObj","id","ignoreVersion","setTimeout","current","onComponentAdded","ComponentModel","from","unSubCompChange","updatedComponent","componentChanged","onComponentUpdated","map","name","unSubCompRemoved","idsToRemove","componentRemoved","componentIds","length","onComponentRemoved","fromObject","filter","every","useMemo","Workspace","undefined"],"sources":["use-workspace.ts"],"sourcesContent":["import { useEffect, useMemo } from 'react';\nimport { ComponentModel } from '@teambit/component';\nimport useLatest from '@react-hook/latest';\nimport { useDataQuery } from '@teambit/ui-foundation.ui.hooks.use-data-query';\nimport { gql } from '@apollo/client';\nimport { ComponentID, ComponentIdObj } from '@teambit/component-id';\n\nimport { Workspace } from './workspace-model';\n\ntype UseWorkspaceOptions = {\n onComponentAdded?: (component: ComponentModel[]) => void;\n onComponentUpdated?: (component: ComponentModel[]) => void;\n onComponentRemoved?: (compId: ComponentID[]) => void;\n};\ntype RawComponent = { id: ComponentIdObj };\n\nconst wcComponentFields = gql`\n fragment wcComponentFields on Component {\n id {\n name\n version\n scope\n }\n compositions {\n identifier\n }\n description\n issuesCount\n status {\n isOutdated\n isNew\n isInScope\n isStaged\n modifyInfo {\n hasModifiedFiles\n hasModifiedDependencies\n }\n isDeleted\n }\n deprecation {\n isDeprecate\n newId\n }\n server {\n env\n url\n }\n env {\n id\n icon\n }\n }\n`;\n\nconst WORKSPACE = gql`\n query workspace {\n workspace {\n name\n path\n icon\n components {\n ...wcComponentFields\n }\n }\n }\n ${wcComponentFields}\n`;\n\nconst COMPONENT_SUBSCRIPTION_ADDED = gql`\n subscription OnComponentAdded {\n componentAdded {\n component {\n ...wcComponentFields\n }\n }\n }\n ${wcComponentFields}\n`;\n\nconst COMPONENT_SUBSCRIPTION_CHANGED = gql`\n subscription OnComponentChanged {\n componentChanged {\n component {\n ...wcComponentFields\n }\n }\n }\n ${wcComponentFields}\n`;\n\nconst COMPONENT_SUBSCRIPTION_REMOVED = gql`\n subscription OnComponentRemoved {\n componentRemoved {\n componentIds {\n name\n version\n scope\n }\n }\n }\n`;\n\nexport function useWorkspace(options: UseWorkspaceOptions = {}) {\n const { data, subscribeToMore, ...rest } = useDataQuery(WORKSPACE);\n const optionsRef = useLatest(options);\n\n useEffect(() => {\n const unSubCompAddition = subscribeToMore({\n document: COMPONENT_SUBSCRIPTION_ADDED,\n updateQuery: (prev, { subscriptionData }) => {\n const update = subscriptionData.data;\n const addedComponent = update?.componentAdded?.component;\n if (!addedComponent) return prev;\n\n const componentExists = prev.workspace.components.find((component: any) =>\n ComponentID.isEqualObj(component.id, addedComponent.id, { ignoreVersion: true })\n );\n if (componentExists) return prev;\n\n // side effect - trigger observers\n setTimeout(() => optionsRef.current.onComponentAdded?.([ComponentModel.from(addedComponent)]));\n\n return {\n ...prev,\n workspace: {\n ...prev.workspace,\n components: [...prev.workspace.components, addedComponent],\n },\n };\n },\n });\n\n const unSubCompChange = subscribeToMore({\n document: COMPONENT_SUBSCRIPTION_CHANGED,\n updateQuery: (prev, { subscriptionData }) => {\n const update = subscriptionData.data;\n if (!update) return prev;\n\n const updatedComponent = update.componentChanged.component;\n // side effect - trigger observers\n setTimeout(() => optionsRef.current.onComponentUpdated?.([ComponentModel.from(updatedComponent)]));\n\n return {\n ...prev,\n workspace: {\n ...prev.workspace,\n components: prev.workspace.components.map((component) =>\n component.id.name === updatedComponent.id.name ? updatedComponent : component\n ),\n },\n };\n },\n });\n\n const unSubCompRemoved = subscribeToMore({\n document: COMPONENT_SUBSCRIPTION_REMOVED,\n updateQuery: (prev, { subscriptionData }) => {\n const idsToRemove: ComponentIdObj[] | undefined = subscriptionData.data?.componentRemoved?.componentIds;\n if (!idsToRemove || idsToRemove.length === 0) return prev;\n\n // side effect - trigger observers\n setTimeout(() => optionsRef.current.onComponentRemoved?.(idsToRemove.map((id) => ComponentID.fromObject(id))));\n\n return {\n ...prev,\n workspace: {\n ...prev.workspace,\n components: prev.workspace.components.filter((component: RawComponent) =>\n idsToRemove.every((id) => !ComponentID.isEqualObj(id, component.id))\n ),\n },\n };\n },\n });\n\n // TODO - sub to component removal\n\n return () => {\n unSubCompAddition();\n unSubCompChange();\n unSubCompRemoved();\n };\n }, [optionsRef]);\n\n const workspace = useMemo(() => {\n return data?.workspace ? Workspace.from(data?.workspace) : undefined;\n }, [data?.workspace]);\n\n return {\n workspace,\n subscribeToMore,\n ...rest,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;;;;;AASA,MAAMA,iBAAiB,GAAG,IAAAC,aAAA,CAAI;AAC9B;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;AACA;AACA;AACA;AACA;AACA,
|
|
1
|
+
{"version":3,"names":["wcComponentFields","gql","WORKSPACE","COMPONENT_SUBSCRIPTION_ADDED","COMPONENT_SUBSCRIPTION_CHANGED","COMPONENT_SUBSCRIPTION_REMOVED","useWorkspace","options","useDataQuery","data","subscribeToMore","rest","optionsRef","useLatest","useEffect","unSubCompAddition","document","updateQuery","prev","subscriptionData","update","addedComponent","componentAdded","component","componentExists","workspace","components","find","ComponentID","isEqualObj","id","ignoreVersion","setTimeout","current","onComponentAdded","ComponentModel","from","unSubCompChange","updatedComponent","componentChanged","onComponentUpdated","map","name","unSubCompRemoved","idsToRemove","componentRemoved","componentIds","length","onComponentRemoved","fromObject","filter","every","useMemo","Workspace","undefined"],"sources":["use-workspace.ts"],"sourcesContent":["import { useEffect, useMemo } from 'react';\nimport { ComponentModel } from '@teambit/component';\nimport useLatest from '@react-hook/latest';\nimport { useDataQuery } from '@teambit/ui-foundation.ui.hooks.use-data-query';\nimport { gql } from '@apollo/client';\nimport { ComponentID, ComponentIdObj } from '@teambit/component-id';\n\nimport { Workspace } from './workspace-model';\n\ntype UseWorkspaceOptions = {\n onComponentAdded?: (component: ComponentModel[]) => void;\n onComponentUpdated?: (component: ComponentModel[]) => void;\n onComponentRemoved?: (compId: ComponentID[]) => void;\n};\ntype RawComponent = { id: ComponentIdObj };\n\nconst wcComponentFields = gql`\n fragment wcComponentFields on Component {\n id {\n name\n version\n scope\n }\n compositions {\n identifier\n }\n description\n issuesCount\n status {\n isOutdated\n isNew\n isInScope\n isStaged\n modifyInfo {\n hasModifiedFiles\n hasModifiedDependencies\n }\n isDeleted\n }\n preview {\n isScaling\n }\n deprecation {\n isDeprecate\n newId\n }\n server {\n env\n url\n }\n env {\n id\n icon\n }\n }\n`;\n\nconst WORKSPACE = gql`\n query workspace {\n workspace {\n name\n path\n icon\n components {\n ...wcComponentFields\n }\n }\n }\n ${wcComponentFields}\n`;\n\nconst COMPONENT_SUBSCRIPTION_ADDED = gql`\n subscription OnComponentAdded {\n componentAdded {\n component {\n ...wcComponentFields\n }\n }\n }\n ${wcComponentFields}\n`;\n\nconst COMPONENT_SUBSCRIPTION_CHANGED = gql`\n subscription OnComponentChanged {\n componentChanged {\n component {\n ...wcComponentFields\n }\n }\n }\n ${wcComponentFields}\n`;\n\nconst COMPONENT_SUBSCRIPTION_REMOVED = gql`\n subscription OnComponentRemoved {\n componentRemoved {\n componentIds {\n name\n version\n scope\n }\n }\n }\n`;\n\nexport function useWorkspace(options: UseWorkspaceOptions = {}) {\n const { data, subscribeToMore, ...rest } = useDataQuery(WORKSPACE);\n const optionsRef = useLatest(options);\n\n useEffect(() => {\n const unSubCompAddition = subscribeToMore({\n document: COMPONENT_SUBSCRIPTION_ADDED,\n updateQuery: (prev, { subscriptionData }) => {\n const update = subscriptionData.data;\n const addedComponent = update?.componentAdded?.component;\n if (!addedComponent) return prev;\n\n const componentExists = prev.workspace.components.find((component: any) =>\n ComponentID.isEqualObj(component.id, addedComponent.id, { ignoreVersion: true })\n );\n if (componentExists) return prev;\n\n // side effect - trigger observers\n setTimeout(() => optionsRef.current.onComponentAdded?.([ComponentModel.from(addedComponent)]));\n\n return {\n ...prev,\n workspace: {\n ...prev.workspace,\n components: [...prev.workspace.components, addedComponent],\n },\n };\n },\n });\n\n const unSubCompChange = subscribeToMore({\n document: COMPONENT_SUBSCRIPTION_CHANGED,\n updateQuery: (prev, { subscriptionData }) => {\n const update = subscriptionData.data;\n if (!update) return prev;\n\n const updatedComponent = update.componentChanged.component;\n // side effect - trigger observers\n setTimeout(() => optionsRef.current.onComponentUpdated?.([ComponentModel.from(updatedComponent)]));\n\n return {\n ...prev,\n workspace: {\n ...prev.workspace,\n components: prev.workspace.components.map((component) =>\n component.id.name === updatedComponent.id.name ? updatedComponent : component\n ),\n },\n };\n },\n });\n\n const unSubCompRemoved = subscribeToMore({\n document: COMPONENT_SUBSCRIPTION_REMOVED,\n updateQuery: (prev, { subscriptionData }) => {\n const idsToRemove: ComponentIdObj[] | undefined = subscriptionData.data?.componentRemoved?.componentIds;\n if (!idsToRemove || idsToRemove.length === 0) return prev;\n\n // side effect - trigger observers\n setTimeout(() => optionsRef.current.onComponentRemoved?.(idsToRemove.map((id) => ComponentID.fromObject(id))));\n\n return {\n ...prev,\n workspace: {\n ...prev.workspace,\n components: prev.workspace.components.filter((component: RawComponent) =>\n idsToRemove.every((id) => !ComponentID.isEqualObj(id, component.id))\n ),\n },\n };\n },\n });\n\n // TODO - sub to component removal\n\n return () => {\n unSubCompAddition();\n unSubCompChange();\n unSubCompRemoved();\n };\n }, [optionsRef]);\n\n const workspace = useMemo(() => {\n return data?.workspace ? Workspace.from(data?.workspace) : undefined;\n }, [data?.workspace]);\n\n return {\n workspace,\n subscribeToMore,\n ...rest,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;;;;;AASA,MAAMA,iBAAiB,GAAG,IAAAC,aAAA,CAAI;AAC9B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA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3C,IAAI,SAAJ,IAAAA,IAAI,WAAJ,IAAAA,IAAI,CAAEgB,SAAN,GAAkB4B,2BAAA,CAAUjB,IAAV,CAAe3B,IAAf,aAAeA,IAAf,uBAAeA,IAAI,CAAEgB,SAArB,CAAlB,GAAoD6B,SAA3D;EACD,CAFiB,EAEf,CAAC7C,IAAD,aAACA,IAAD,uBAACA,IAAI,CAAEgB,SAAP,CAFe,CAAlB;EAIA;IACEA,SADF;IAEEf;EAFF,GAGKC,IAHL;AAKD"}
|
package/dist/workspace.js
CHANGED
|
@@ -1949,9 +1949,13 @@ needed-for: ${neededFor || '<unknown>'}`);
|
|
|
1949
1949
|
|
|
1950
1950
|
const scopeIdsGrouped = await this.scope.groupAspectIdsByEnvOfTheList(scopeIds);
|
|
1951
1951
|
const scopeEnvsManifestsIds = scopeIdsGrouped.envs && scopeIdsGrouped.envs.length ? await this.scope.loadAspects(scopeIdsGrouped.envs, throwOnError, 'workspace.loadAspects loading scope aspects') : [];
|
|
1952
|
-
const
|
|
1952
|
+
const {
|
|
1953
|
+
manifests: scopeOtherManifests
|
|
1954
|
+
} = scopeIdsGrouped.other && scopeIdsGrouped.other.length ? await this.scope.getManifestsGraphRecursively(scopeIdsGrouped.other, (0, _lodash().compact)(workspaceManifestsIds), throwOnError, {
|
|
1953
1955
|
packageManagerConfigRootDir: this.path
|
|
1954
|
-
}) :
|
|
1956
|
+
}) : {
|
|
1957
|
+
manifests: []
|
|
1958
|
+
};
|
|
1955
1959
|
const scopeOtherManifestsIds = (0, _lodash().compact)(scopeOtherManifests.map(m => m.id));
|
|
1956
1960
|
await this.aspectLoader.loadExtensionsByManifests([...scopeOtherManifests, ...workspaceManifests], throwOnError); // Try require components for potential plugins
|
|
1957
1961
|
|