@teambit/component 0.0.700 → 0.0.703

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/index.d.ts CHANGED
@@ -19,6 +19,7 @@ export type { ComponentUI } from './component.ui.runtime';
19
19
  export { Section } from './section';
20
20
  export { ComponentContext, ComponentDescriptorContext, useComponentDescriptor } from './ui/context/component-context';
21
21
  export type { ComponentProviderProps, ComponentDescriptorProviderProps } from './ui/context';
22
+ export { componentFields, componentIdFields, componentOverviewFields } from './ui';
22
23
  export { ConsumePlugin } from './ui/menu';
23
24
  export { RegisteredComponentRoute, ComponentUrlParams } from './component.route';
24
25
  export { ComponentModel, ComponentModelProps } from './ui/component-model';
package/dist/index.js CHANGED
@@ -149,6 +149,24 @@ Object.defineProperty(exports, "TagProps", {
149
149
  return _tag().TagProps;
150
150
  }
151
151
  });
152
+ Object.defineProperty(exports, "componentFields", {
153
+ enumerable: true,
154
+ get: function () {
155
+ return _ui().componentFields;
156
+ }
157
+ });
158
+ Object.defineProperty(exports, "componentIdFields", {
159
+ enumerable: true,
160
+ get: function () {
161
+ return _ui().componentIdFields;
162
+ }
163
+ });
164
+ Object.defineProperty(exports, "componentOverviewFields", {
165
+ enumerable: true,
166
+ get: function () {
167
+ return _ui().componentOverviewFields;
168
+ }
169
+ });
152
170
  exports.default = void 0;
153
171
  Object.defineProperty(exports, "useComponentDescriptor", {
154
172
  enumerable: true,
@@ -293,6 +311,16 @@ function _componentContext() {
293
311
  return data;
294
312
  }
295
313
 
314
+ function _ui() {
315
+ const data = require("./ui");
316
+
317
+ _ui = function () {
318
+ return data;
319
+ };
320
+
321
+ return data;
322
+ }
323
+
296
324
  function _menu() {
297
325
  const data = require("./ui/menu");
298
326
 
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["index.ts"],"names":["ComponentAspect"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;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;;AAIA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAIA;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;;AAGA;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;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AApBA;AACA;AAGA;AACA;AAgBA;AACA;eAEeA,4B","sourcesContent":["import { ComponentAspect } from './component.aspect';\n\nexport { useComponentHost } from './host';\nexport { Component, InvalidComponent } from './component';\nexport { ComponentID } from '@teambit/component-id';\nexport { default as ComponentFS } from './component-fs';\nexport type { default as ComponentConfig } from './config';\nexport type { ComponentFactory } from './component-factory';\nexport type { AspectList } from './aspect-list';\nexport { AspectEntry, AspectData, ResolveComponentIdFunc } from './aspect-entry';\n// TODO: check why it's not working when using the index in snap dir like this:\n// export { Snap, Author } from './snap';\nexport { Snap, SnapProps } from './snap/snap';\nexport type { Author } from './snap/author';\n// TODO: check why it's not working when using the index in tag dir like this:\n// export { Tag } from './tag';\nexport { Tag, TagProps } from './tag/tag';\nexport { State } from './state';\nexport type { Hash } from './hash';\nexport { TagMap } from './tag-map';\nexport { ComponentMap } from './component-map';\nexport type { ComponentMain } from './component.main.runtime';\nexport type { ComponentUI } from './component.ui.runtime';\nexport { Section } from './section';\nexport { ComponentContext, ComponentDescriptorContext, useComponentDescriptor } from './ui/context/component-context';\nexport type { ComponentProviderProps, ComponentDescriptorProviderProps } from './ui/context';\nexport { ConsumePlugin } from './ui/menu';\nexport { RegisteredComponentRoute, ComponentUrlParams } from './component.route';\nexport { ComponentModel, ComponentModelProps } from './ui/component-model';\nexport type { ShowFragment, ShowRow } from './show';\nexport { default as Config } from './config';\n// export { AspectList } from './aspect-list';\n// export { AspectEntry } from './aspect-entry';\nexport { ComponentAspect };\nexport default ComponentAspect;\n"]}
1
+ {"version":3,"sources":["index.ts"],"names":["ComponentAspect"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;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;;AAIA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAIA;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;;AAGA;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;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AArBA;AACA;AAGA;AACA;AAiBA;AACA;eAEeA,4B","sourcesContent":["import { ComponentAspect } from './component.aspect';\n\nexport { useComponentHost } from './host';\nexport { Component, InvalidComponent } from './component';\nexport { ComponentID } from '@teambit/component-id';\nexport { default as ComponentFS } from './component-fs';\nexport type { default as ComponentConfig } from './config';\nexport type { ComponentFactory } from './component-factory';\nexport type { AspectList } from './aspect-list';\nexport { AspectEntry, AspectData, ResolveComponentIdFunc } from './aspect-entry';\n// TODO: check why it's not working when using the index in snap dir like this:\n// export { Snap, Author } from './snap';\nexport { Snap, SnapProps } from './snap/snap';\nexport type { Author } from './snap/author';\n// TODO: check why it's not working when using the index in tag dir like this:\n// export { Tag } from './tag';\nexport { Tag, TagProps } from './tag/tag';\nexport { State } from './state';\nexport type { Hash } from './hash';\nexport { TagMap } from './tag-map';\nexport { ComponentMap } from './component-map';\nexport type { ComponentMain } from './component.main.runtime';\nexport type { ComponentUI } from './component.ui.runtime';\nexport { Section } from './section';\nexport { ComponentContext, ComponentDescriptorContext, useComponentDescriptor } from './ui/context/component-context';\nexport type { ComponentProviderProps, ComponentDescriptorProviderProps } from './ui/context';\nexport { componentFields, componentIdFields, componentOverviewFields } from './ui';\nexport { ConsumePlugin } from './ui/menu';\nexport { RegisteredComponentRoute, ComponentUrlParams } from './component.route';\nexport { ComponentModel, ComponentModelProps } from './ui/component-model';\nexport type { ShowFragment, ShowRow } from './show';\nexport { default as Config } from './config';\n// export { AspectList } from './aspect-list';\n// export { AspectEntry } from './aspect-entry';\nexport { ComponentAspect };\nexport default ComponentAspect;\n"]}
@@ -2,3 +2,4 @@ export { Component } from './component';
2
2
  export { ComponentModel, ComponentModelProps } from './component-model';
3
3
  export { ComponentContext, ComponentProvider } from './context';
4
4
  export { useComponent } from './use-component';
5
+ export { componentIdFields, componentOverviewFields, componentFields } from './use-component-query';
package/dist/ui/index.js CHANGED
@@ -33,6 +33,24 @@ Object.defineProperty(exports, "ComponentProvider", {
33
33
  return _context().ComponentProvider;
34
34
  }
35
35
  });
36
+ Object.defineProperty(exports, "componentFields", {
37
+ enumerable: true,
38
+ get: function () {
39
+ return _useComponentQuery().componentFields;
40
+ }
41
+ });
42
+ Object.defineProperty(exports, "componentIdFields", {
43
+ enumerable: true,
44
+ get: function () {
45
+ return _useComponentQuery().componentIdFields;
46
+ }
47
+ });
48
+ Object.defineProperty(exports, "componentOverviewFields", {
49
+ enumerable: true,
50
+ get: function () {
51
+ return _useComponentQuery().componentOverviewFields;
52
+ }
53
+ });
36
54
  Object.defineProperty(exports, "useComponent", {
37
55
  enumerable: true,
38
56
  get: function () {
@@ -80,4 +98,14 @@ function _useComponent() {
80
98
  return data;
81
99
  }
82
100
 
101
+ function _useComponentQuery() {
102
+ const data = require("./use-component-query");
103
+
104
+ _useComponentQuery = function () {
105
+ return data;
106
+ };
107
+
108
+ return data;
109
+ }
110
+
83
111
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["index.ts"],"names":[],"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","sourcesContent":["export { Component } from './component';\nexport { ComponentModel, ComponentModelProps } from './component-model';\nexport { ComponentContext, ComponentProvider } from './context';\nexport { useComponent } from './use-component';\n"]}
1
+ {"version":3,"sources":["index.ts"],"names":[],"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;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA","sourcesContent":["export { Component } from './component';\nexport { ComponentModel, ComponentModelProps } from './component-model';\nexport { ComponentContext, ComponentProvider } from './context';\nexport { useComponent } from './use-component';\nexport { componentIdFields, componentOverviewFields, componentFields } from './use-component-query';\n"]}
@@ -76,7 +76,7 @@
76
76
  }
77
77
  }
78
78
  @media screen and (max-width: $br-lg) {
79
- display: none;
79
+ display: none;
80
80
  }
81
81
  }
82
82
  .widget {
@@ -1,6 +1,9 @@
1
1
  import { ComponentDescriptor } from '@teambit/component-descriptor';
2
2
  import { ComponentModel } from './component-model';
3
3
  import { ComponentError } from './component-error';
4
+ export declare const componentIdFields: import("@apollo/client").DocumentNode;
5
+ export declare const componentOverviewFields: import("@apollo/client").DocumentNode;
6
+ export declare const componentFields: import("@apollo/client").DocumentNode;
4
7
  /** provides data to component ui page, making sure both variables and return value are safely typed and memoized */
5
8
  export declare function useComponentQuery(componentId: string, host: string, filters?: {
6
9
  log?: {
@@ -5,6 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
+ exports.componentOverviewFields = exports.componentIdFields = exports.componentFields = void 0;
8
9
  exports.useComponentQuery = useComponentQuery;
9
10
 
10
11
  function _defineProperty2() {
@@ -98,8 +99,9 @@ const componentIdFields = (0, _client().gql)`
98
99
  scope
99
100
  }
100
101
  `;
101
- const componentFields = (0, _client().gql)`
102
- fragment componentFields on Component {
102
+ exports.componentIdFields = componentIdFields;
103
+ const componentOverviewFields = (0, _client().gql)`
104
+ fragment componentOverviewFields on Component {
103
105
  id {
104
106
  ...componentIdFields
105
107
  }
@@ -110,17 +112,34 @@ const componentFields = (0, _client().gql)`
110
112
  aspectId: id
111
113
  aspectData: data
112
114
  }
113
- packageName
114
115
  elementsUrl
115
116
  description
116
117
  labels
117
118
  displayName
118
- latest
119
119
  server {
120
120
  env
121
121
  url
122
122
  }
123
123
  buildStatus
124
+ env {
125
+ id
126
+ icon
127
+ }
128
+ preview {
129
+ includesEnvTemplate
130
+ }
131
+ }
132
+ ${componentIdFields}
133
+ `;
134
+ exports.componentOverviewFields = componentOverviewFields;
135
+ const componentFields = (0, _client().gql)`
136
+ fragment componentFields on Component {
137
+ id {
138
+ ...componentIdFields
139
+ }
140
+ ...componentOverviewFields
141
+ packageName
142
+ latest
124
143
  compositions {
125
144
  identifier
126
145
  displayName
@@ -128,10 +147,6 @@ const componentFields = (0, _client().gql)`
128
147
  tags {
129
148
  version
130
149
  }
131
- env {
132
- id
133
- icon
134
- }
135
150
  logs(type: $logType, offset: $logOffset, limit: $logLimit, head: $logHead, sort: $logSort) {
136
151
  id
137
152
  message
@@ -141,12 +156,11 @@ const componentFields = (0, _client().gql)`
141
156
  hash
142
157
  tag
143
158
  }
144
- preview {
145
- includesEnvTemplate
146
- }
147
159
  }
148
160
  ${componentIdFields}
161
+ ${componentOverviewFields}
149
162
  `;
163
+ exports.componentFields = componentFields;
150
164
  const GET_COMPONENT = (0, _client().gql)`
151
165
  query Component(
152
166
  $id: String!
@@ -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","filters","idRef","current","data","error","loading","subscribeToMore","variables","id","extensionId","log","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","aspectList","entries","aspects","fromObject","componentDescriptor","ComponentDescriptor","toString","undefined","ComponentModel","from","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;;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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAID,iBAAkB;AACtB,CAhDA;AAkDA,MAAME,aAAa,GAAG,kBAAI;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAID,eAAgB;AACpB,CAlBA;AAoBA,MAAME,sBAAsB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AAYc,UAAZ,CAAuBJ,YAAY,CAAC7B,EAApC,CAA3B;;AACA,WAAO;AACLkC,MAAAA,mBAAmB,EAAElC,EAAE,GAAGmC,2CAAoBF,UAApB,CAA+B;AAAEjC,QAAAA,EAAE,EAAEA,EAAE,CAACoC,QAAH,EAAN;AAAqBN,QAAAA;AAArB,OAA/B,CAAH,GAAuEO,SADzF;AAELxB,MAAAA,SAAS,EAAEgB,YAAY,GAAGS,iCAAeC,IAAf,iCAAyBV,YAAzB;AAAuCtC,QAAAA;AAAvC,SAAH,GAAoD8C,SAFtE;AAGL;AACAzC,MAAAA,KAAK,EAAEA,KAAK,GACR,KAAI4C,gCAAJ,EAAmB,GAAnB,EAAwB5C,KAAK,CAAC6C,OAA9B,CADQ,GAER,CAACZ,YAAD,IAAiB,CAAChC,OAAlB,GACA,KAAI2C,gCAAJ,EAAmB,GAAnB,CADA,GAEAH;AARC,KAAP;AAUD,GAfM,EAeJ,CAACR,YAAD,EAAetC,IAAf,EAAqBK,KAArB,CAfI,CAAP;AAgBD","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';\nimport { ComponentDescriptor } from '@teambit/component-descriptor';\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 aspects(include: [\"teambit.preview/preview\", \"teambit.pipelines/builder\", \"teambit.envs/envs\"]) {\n # 'id' property in gql refers to a *global* identifier and used for caching.\n # this makes aspect data cache under the same key, even when they are under different components.\n # renaming the property fixes that.\n aspectId: id\n aspectData: data\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 logs(type: $logType, offset: $logOffset, limit: $logLimit, head: $logHead, sort: $logSort) {\n id\n message\n username\n email\n date\n hash\n tag\n }\n preview {\n includesEnvTemplate\n }\n }\n ${componentIdFields}\n`;\n\nconst GET_COMPONENT = gql`\n query Component(\n $id: String!\n $extensionId: String!\n $logType: String\n $logOffset: Int\n $logLimit: Int\n $logHead: String\n $logSort: String\n ) {\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($logType: String, $logOffset: Int, $logLimit: Int, $logHead: String, $logSort: String) {\n componentAdded {\n component {\n ...componentFields\n }\n }\n }\n ${componentFields}\n`;\n\nconst SUB_COMPONENT_CHANGED = gql`\n subscription OnComponentChanged(\n $logType: String\n $logOffset: Int\n $logLimit: Int\n $logHead: String\n $logSort: String\n ) {\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(\n componentId: string,\n host: string,\n filters?: { log?: { logType?: string; logOffset?: number; logLimit?: number; logHead?: string; logSort?: string } }\n) {\n const idRef = useRef(componentId);\n idRef.current = componentId;\n const { data, error, loading, subscribeToMore } = useDataQuery(GET_COMPONENT, {\n variables: { id: componentId, extensionId: host, ...(filters?.log || {}) },\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 return useMemo(() => {\n const aspectList = {\n entries: rawComponent?.aspects,\n };\n const id = rawComponent && ComponentID.fromObject(rawComponent.id);\n return {\n componentDescriptor: id ? ComponentDescriptor.fromObject({ id: id.toString(), aspectList }) : undefined,\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"]}
1
+ {"version":3,"sources":["use-component-query.ts"],"names":["componentIdFields","componentOverviewFields","componentFields","GET_COMPONENT","SUB_SUBSCRIPTION_ADDED","SUB_COMPONENT_CHANGED","SUB_COMPONENT_REMOVED","useComponentQuery","componentId","host","filters","idRef","current","data","error","loading","subscribeToMore","variables","id","extensionId","log","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","aspectList","entries","aspects","fromObject","componentDescriptor","ComponentDescriptor","toString","undefined","ComponentModel","from","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;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;;;;;AAEO,MAAMA,iBAAiB,GAAG,kBAAI;AACrC;AACA;AACA;AACA;AACA;AACA,CANO;;AAQA,MAAMC,uBAAuB,GAAG,kBAAI;AAC3C;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,CA9BO;;AAgCA,MAAME,eAAe,GAAG,kBAAI;AACnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAIF,iBAAkB;AACtB,IAAIC,uBAAwB;AAC5B,CA3BO;;AA6BP,MAAME,aAAa,G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MoB,UAAU,GAAG;AACjBC,MAAAA,OAAO,EAAEF,YAAF,aAAEA,YAAF,uBAAEA,YAAY,CAAEG;AADN,KAAnB;;AAGA,UAAMhC,EAAE,GAAG6B,YAAY,IAAIV,2BAAYc,UAAZ,CAAuBJ,YAAY,CAAC7B,EAApC,CAA3B;;AACA,WAAO;AACLkC,MAAAA,mBAAmB,EAAElC,EAAE,GAAGmC,2CAAoBF,UAApB,CAA+B;AAAEjC,QAAAA,EAAE,EAAEA,EAAE,CAACoC,QAAH,EAAN;AAAqBN,QAAAA;AAArB,OAA/B,CAAH,GAAuEO,SADzF;AAELxB,MAAAA,SAAS,EAAEgB,YAAY,GAAGS,iCAAeC,IAAf,iCAAyBV,YAAzB;AAAuCtC,QAAAA;AAAvC,SAAH,GAAoD8C,SAFtE;AAGL;AACAzC,MAAAA,KAAK,EAAEA,KAAK,GACR,KAAI4C,gCAAJ,EAAmB,GAAnB,EAAwB5C,KAAK,CAAC6C,OAA9B,CADQ,GAER,CAACZ,YAAD,IAAiB,CAAChC,OAAlB,GACA,KAAI2C,gCAAJ,EAAmB,GAAnB,CADA,GAEAH;AARC,KAAP;AAUD,GAfM,EAeJ,CAACR,YAAD,EAAetC,IAAf,EAAqBK,KAArB,CAfI,CAAP;AAgBD","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';\nimport { ComponentDescriptor } from '@teambit/component-descriptor';\n\nimport { ComponentModel } from './component-model';\nimport { ComponentError } from './component-error';\n\nexport const componentIdFields = gql`\n fragment componentIdFields on ComponentID {\n name\n version\n scope\n }\n`;\n\nexport const componentOverviewFields = gql`\n fragment componentOverviewFields on Component {\n id {\n ...componentIdFields\n }\n aspects(include: [\"teambit.preview/preview\", \"teambit.pipelines/builder\", \"teambit.envs/envs\"]) {\n # 'id' property in gql refers to a *global* identifier and used for caching.\n # this makes aspect data cache under the same key, even when they are under different components.\n # renaming the property fixes that.\n aspectId: id\n aspectData: data\n }\n elementsUrl\n description\n labels\n displayName\n server {\n env\n url\n }\n buildStatus\n env {\n id\n icon\n }\n preview {\n includesEnvTemplate\n }\n }\n ${componentIdFields}\n`;\n\nexport const componentFields = gql`\n fragment componentFields on Component {\n id {\n ...componentIdFields\n }\n ...componentOverviewFields\n packageName\n latest\n compositions {\n identifier\n displayName\n }\n tags {\n version\n }\n logs(type: $logType, offset: $logOffset, limit: $logLimit, head: $logHead, sort: $logSort) {\n id\n message\n username\n email\n date\n hash\n tag\n }\n }\n ${componentIdFields}\n ${componentOverviewFields}\n`;\n\nconst GET_COMPONENT = gql`\n query Component(\n $id: String!\n $extensionId: String!\n $logType: String\n $logOffset: Int\n $logLimit: Int\n $logHead: String\n $logSort: String\n ) {\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($logType: String, $logOffset: Int, $logLimit: Int, $logHead: String, $logSort: String) {\n componentAdded {\n component {\n ...componentFields\n }\n }\n }\n ${componentFields}\n`;\n\nconst SUB_COMPONENT_CHANGED = gql`\n subscription OnComponentChanged(\n $logType: String\n $logOffset: Int\n $logLimit: Int\n $logHead: String\n $logSort: String\n ) {\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(\n componentId: string,\n host: string,\n filters?: { log?: { logType?: string; logOffset?: number; logLimit?: number; logHead?: string; logSort?: string } }\n) {\n const idRef = useRef(componentId);\n idRef.current = componentId;\n const { data, error, loading, subscribeToMore } = useDataQuery(GET_COMPONENT, {\n variables: { id: componentId, extensionId: host, ...(filters?.log || {}) },\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 return useMemo(() => {\n const aspectList = {\n entries: rawComponent?.aspects,\n };\n const id = rawComponent && ComponentID.fromObject(rawComponent.id);\n return {\n componentDescriptor: id ? ComponentDescriptor.fromObject({ id: id.toString(), aspectList }) : undefined,\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"]}
@@ -62,7 +62,7 @@ function useComponent(host, id) {
62
62
  if (!targetId) throw new TypeError('useComponent received no component id');
63
63
  const currentLane = lanesContext === null || lanesContext === void 0 ? void 0 : lanesContext.viewedLane; // when on a lane, always fetch all the logs starting from the 'head' version
64
64
 
65
- const logHead = lanesContext === null || lanesContext === void 0 ? void 0 : (_lanesContext$viewedL = lanesContext.viewedLane) === null || _lanesContext$viewedL === void 0 ? void 0 : (_lanesContext$viewedL2 = _lanesContext$viewedL.components.find(component => component.model.id.fullName === targetId)) === null || _lanesContext$viewedL2 === void 0 ? void 0 : _lanesContext$viewedL2.model.id.version;
65
+ const logHead = lanesContext === null || lanesContext === void 0 ? void 0 : (_lanesContext$viewedL = lanesContext.viewedLane) === null || _lanesContext$viewedL === void 0 ? void 0 : (_lanesContext$viewedL2 = _lanesContext$viewedL.components.find(component => component.id.fullName === targetId)) === null || _lanesContext$viewedL2 === void 0 ? void 0 : _lanesContext$viewedL2.id.version;
66
66
  const logFilters = currentLane ? {
67
67
  log: {
68
68
  logHead
@@ -1 +1 @@
1
- {"version":3,"sources":["use-component.tsx"],"names":["useComponent","host","id","params","componentId","query","version","get","undefined","lanesContext","targetId","toString","ignoreVersion","TypeError","currentLane","viewedLane","logHead","components","find","component","model","fullName","logFilters","log","withVersion","includes"],"mappings":";;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAYO,SAASA,YAAT,CAAsBC,IAA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,EAAxB;AACD","sourcesContent":["import { useRouteMatch } from 'react-router-dom';\nimport { ComponentID } from '@teambit/component-id';\nimport { useQuery } from '@teambit/ui-foundation.ui.react-router.use-query';\nimport { ComponentDescriptor } from '@teambit/component-descriptor';\nimport { useLanesContext } from '@teambit/lanes.ui.lanes';\nimport { ComponentModel } from './component-model';\nimport { ComponentError } from './component-error';\nimport { useComponentQuery } from './use-component-query';\n\nexport type Component = {\n component?: ComponentModel;\n error?: ComponentError;\n componentDescriptor?: ComponentDescriptor;\n};\n\ntype ComponentRoute = {\n componentId?: string;\n};\n\nexport function useComponent(host: string, id?: ComponentID): Component {\n const {\n params: { componentId },\n } = useRouteMatch<ComponentRoute>();\n const query = useQuery();\n const version = query.get('version') || undefined;\n const lanesContext = useLanesContext();\n const targetId = id?.toString({ ignoreVersion: true }) || componentId;\n if (!targetId) throw new TypeError('useComponent received no component id');\n const currentLane = lanesContext?.viewedLane;\n // when on a lane, always fetch all the logs starting from the 'head' version\n const logHead = lanesContext?.viewedLane?.components.find((component) => component.model.id.fullName === targetId)\n ?.model.id.version;\n const logFilters = currentLane\n ? {\n log: {\n logHead,\n },\n }\n : undefined;\n\n return useComponentQuery(withVersion(targetId, version), host, logFilters);\n}\n\nfunction withVersion(id: string, version?: string) {\n if (!version) return id;\n if (id.includes('@')) return id;\n return `${id}@${version}`;\n}\n"]}
1
+ {"version":3,"sources":["use-component.tsx"],"names":["useComponent","host","id","params","componentId","query","version","get","undefined","lanesContext","targetId","toString","ignoreVersion","TypeError","currentLane","viewedLane","logHead","components","find","component","fullName","logFilters","log","withVersion","includes"],"mappings":";;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAYO,SAASA,YAAT,CAAsBC,IAAtB,EAAoCC,EAApC,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om';\nimport { ComponentID } from '@teambit/component-id';\nimport { useQuery } from '@teambit/ui-foundation.ui.react-router.use-query';\nimport { ComponentDescriptor } from '@teambit/component-descriptor';\nimport { useLanesContext } from '@teambit/lanes.ui.lanes';\nimport { ComponentModel } from './component-model';\nimport { ComponentError } from './component-error';\nimport { useComponentQuery } from './use-component-query';\n\nexport type Component = {\n component?: ComponentModel;\n error?: ComponentError;\n componentDescriptor?: ComponentDescriptor;\n};\n\ntype ComponentRoute = {\n componentId?: string;\n};\n\nexport function useComponent(host: string, id?: ComponentID): Component {\n const {\n params: { componentId },\n } = useRouteMatch<ComponentRoute>();\n const query = useQuery();\n const version = query.get('version') || undefined;\n const lanesContext = useLanesContext();\n const targetId = id?.toString({ ignoreVersion: true }) || componentId;\n if (!targetId) throw new TypeError('useComponent received no component id');\n const currentLane = lanesContext?.viewedLane;\n // when on a lane, always fetch all the logs starting from the 'head' version\n const logHead = lanesContext?.viewedLane?.components.find((component) => component.id.fullName === targetId)?.id\n .version;\n const logFilters = currentLane\n ? {\n log: {\n logHead,\n },\n }\n : undefined;\n\n return useComponentQuery(withVersion(targetId, version), host, logFilters);\n}\n\nfunction withVersion(id: string, version?: string) {\n if (!version) return id;\n if (id.includes('@')) return id;\n return `${id}@${version}`;\n}\n"]}
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@teambit/component",
3
- "version": "0.0.700",
3
+ "version": "0.0.703",
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.700"
9
+ "version": "0.0.703"
10
10
  },
11
11
  "dependencies": {
12
12
  "@teambit/any-fs": "0.0.5",
@@ -32,37 +32,37 @@
32
32
  "@teambit/design.inputs.dropdown": "0.0.7",
33
33
  "@teambit/component-id": "0.0.402",
34
34
  "@teambit/ui-foundation.ui.menu-widget-icon": "0.0.488",
35
- "@teambit/aspect-loader": "0.0.700",
35
+ "@teambit/aspect-loader": "0.0.703",
36
36
  "@teambit/legacy-bit-id": "0.0.399",
37
37
  "@teambit/toolbox.string.capitalize": "0.0.483",
38
- "@teambit/cli": "0.0.465",
39
- "@teambit/config": "0.0.478",
40
- "@teambit/express": "0.0.561",
41
- "@teambit/graphql": "0.0.700",
38
+ "@teambit/cli": "0.0.467",
39
+ "@teambit/config": "0.0.480",
40
+ "@teambit/express": "0.0.563",
41
+ "@teambit/graphql": "0.0.703",
42
42
  "@teambit/bit-error": "0.0.394",
43
- "@teambit/command-bar": "0.0.700",
44
- "@teambit/preview": "0.0.700",
45
- "@teambit/pubsub": "0.0.700",
43
+ "@teambit/command-bar": "0.0.703",
44
+ "@teambit/preview": "0.0.703",
45
+ "@teambit/pubsub": "0.0.703",
46
46
  "@teambit/ui-foundation.ui.is-browser": "0.0.486",
47
47
  "@teambit/ui-foundation.ui.main-dropdown": "0.0.486",
48
48
  "@teambit/ui-foundation.ui.react-router.slot-router": "0.0.488",
49
49
  "@teambit/ui-foundation.ui.use-box.menu": "0.0.114",
50
- "@teambit/ui": "0.0.700",
51
- "@teambit/component-issues": "0.0.49",
50
+ "@teambit/ui": "0.0.703",
51
+ "@teambit/component-issues": "0.0.50",
52
52
  "@teambit/ui-foundation.ui.hooks.use-data-query": "0.0.487",
53
53
  "@teambit/cli-table": "0.0.33",
54
- "@teambit/component-descriptor": "0.0.29",
55
- "@teambit/lanes.ui.lanes": "0.0.31",
54
+ "@teambit/component-descriptor": "0.0.31",
55
+ "@teambit/lanes.ui.lanes": "0.0.33",
56
56
  "@teambit/ui-foundation.ui.react-router.use-query": "0.0.486",
57
57
  "@teambit/design.ui.empty-box": "0.0.353",
58
58
  "@teambit/harmony.ui.aspect-box": "0.0.486",
59
59
  "@teambit/design.ui.pages.not-found": "0.0.354",
60
60
  "@teambit/design.ui.pages.server-error": "0.0.354",
61
- "@teambit/compositions": "0.0.700",
62
- "@teambit/deprecation": "0.0.700",
63
- "@teambit/envs": "0.0.700",
61
+ "@teambit/compositions": "0.0.703",
62
+ "@teambit/deprecation": "0.0.703",
63
+ "@teambit/envs": "0.0.703",
64
64
  "@teambit/legacy-component-log": "0.0.392",
65
- "@teambit/component.ui.version-dropdown": "0.0.516",
65
+ "@teambit/component.ui.version-dropdown": "0.0.518",
66
66
  "@teambit/ui-foundation.ui.full-loader": "0.0.486",
67
67
  "@teambit/ui-foundation.ui.use-box.dropdown": "0.0.114",
68
68
  "@teambit/ui-foundation.ui.constants.z-indexes": "0.0.487",
@@ -85,7 +85,7 @@
85
85
  },
86
86
  "peerDependencies": {
87
87
  "@apollo/client": "^3.0.0",
88
- "@teambit/legacy": "1.0.243",
88
+ "@teambit/legacy": "1.0.245",
89
89
  "react-dom": "^16.8.0 || ^17.0.0",
90
90
  "react": "^16.8.0 || ^17.0.0"
91
91
  },
@@ -113,7 +113,7 @@
113
113
  "react": "-"
114
114
  },
115
115
  "peerDependencies": {
116
- "@teambit/legacy": "1.0.243",
116
+ "@teambit/legacy": "1.0.245",
117
117
  "react-dom": "^16.8.0 || ^17.0.0",
118
118
  "react": "^16.8.0 || ^17.0.0"
119
119
  }
@@ -1,2 +1,2 @@
1
- export const compositions = [require('/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.component_component@0.0.700/dist/component.composition.js')]
2
- export const overview = [require('/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.component_component@0.0.700/dist/component.docs.mdx')]
1
+ export const compositions = [require('/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.component_component@0.0.703/dist/component.composition.js')]
2
+ export const overview = [require('/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.component_component@0.0.703/dist/component.docs.mdx')]
package/tsconfig.json CHANGED
@@ -10,22 +10,23 @@
10
10
  "target": "es2015",
11
11
  "module": "commonjs",
12
12
  "jsx": "react",
13
+ "allowJs": true,
14
+ "composite": true,
13
15
  "declaration": true,
14
16
  "sourceMap": true,
15
17
  "skipLibCheck": true,
18
+ "outDir": "dist",
16
19
  "moduleResolution": "node",
17
20
  "esModuleInterop": true,
21
+ "rootDir": ".",
18
22
  "resolveJsonModule": true,
19
- "composite": true,
20
23
  "emitDeclarationOnly": true,
21
- "outDir": "dist",
22
24
  "experimentalDecorators": true,
23
25
  "emitDecoratorMetadata": true,
24
26
  "allowSyntheticDefaultImports": true,
25
27
  "strictPropertyInitialization": false,
26
28
  "strict": true,
27
29
  "noImplicitAny": false,
28
- "rootDir": ".",
29
30
  "preserveConstEnums": true
30
31
  },
31
32
  "exclude": [
package/ui/index.ts CHANGED
@@ -2,3 +2,4 @@ export { Component } from './component';
2
2
  export { ComponentModel, ComponentModelProps } from './component-model';
3
3
  export { ComponentContext, ComponentProvider } from './context';
4
4
  export { useComponent } from './use-component';
5
+ export { componentIdFields, componentOverviewFields, componentFields } from './use-component-query';
@@ -76,7 +76,7 @@
76
76
  }
77
77
  }
78
78
  @media screen and (max-width: $br-lg) {
79
- display: none;
79
+ display: none;
80
80
  }
81
81
  }
82
82
  .widget {
@@ -7,7 +7,7 @@ import { ComponentDescriptor } from '@teambit/component-descriptor';
7
7
  import { ComponentModel } from './component-model';
8
8
  import { ComponentError } from './component-error';
9
9
 
10
- const componentIdFields = gql`
10
+ export const componentIdFields = gql`
11
11
  fragment componentIdFields on ComponentID {
12
12
  name
13
13
  version
@@ -15,8 +15,8 @@ const componentIdFields = gql`
15
15
  }
16
16
  `;
17
17
 
18
- const componentFields = gql`
19
- fragment componentFields on Component {
18
+ export const componentOverviewFields = gql`
19
+ fragment componentOverviewFields on Component {
20
20
  id {
21
21
  ...componentIdFields
22
22
  }
@@ -27,17 +27,34 @@ const componentFields = gql`
27
27
  aspectId: id
28
28
  aspectData: data
29
29
  }
30
- packageName
31
30
  elementsUrl
32
31
  description
33
32
  labels
34
33
  displayName
35
- latest
36
34
  server {
37
35
  env
38
36
  url
39
37
  }
40
38
  buildStatus
39
+ env {
40
+ id
41
+ icon
42
+ }
43
+ preview {
44
+ includesEnvTemplate
45
+ }
46
+ }
47
+ ${componentIdFields}
48
+ `;
49
+
50
+ export const componentFields = gql`
51
+ fragment componentFields on Component {
52
+ id {
53
+ ...componentIdFields
54
+ }
55
+ ...componentOverviewFields
56
+ packageName
57
+ latest
41
58
  compositions {
42
59
  identifier
43
60
  displayName
@@ -45,10 +62,6 @@ const componentFields = gql`
45
62
  tags {
46
63
  version
47
64
  }
48
- env {
49
- id
50
- icon
51
- }
52
65
  logs(type: $logType, offset: $logOffset, limit: $logLimit, head: $logHead, sort: $logSort) {
53
66
  id
54
67
  message
@@ -58,11 +71,9 @@ const componentFields = gql`
58
71
  hash
59
72
  tag
60
73
  }
61
- preview {
62
- includesEnvTemplate
63
- }
64
74
  }
65
75
  ${componentIdFields}
76
+ ${componentOverviewFields}
66
77
  `;
67
78
 
68
79
  const GET_COMPONENT = gql`
@@ -28,8 +28,8 @@ export function useComponent(host: string, id?: ComponentID): Component {
28
28
  if (!targetId) throw new TypeError('useComponent received no component id');
29
29
  const currentLane = lanesContext?.viewedLane;
30
30
  // when on a lane, always fetch all the logs starting from the 'head' version
31
- const logHead = lanesContext?.viewedLane?.components.find((component) => component.model.id.fullName === targetId)
32
- ?.model.id.version;
31
+ const logHead = lanesContext?.viewedLane?.components.find((component) => component.id.fullName === targetId)?.id
32
+ .version;
33
33
  const logFilters = currentLane
34
34
  ? {
35
35
  log: {