@teambit/component 1.0.1079 → 1.0.1081

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.
@@ -38,6 +38,19 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
38
38
  function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
39
39
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
40
40
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
41
+ /**
42
+ * Per-Component-instance caches for resolver field outputs. Each batched lane-compare request fans
43
+ * out to ~10–20 `Component` ops that all eventually call `host.get()` for the same versioned id —
44
+ * which returns the same `Component` instance (via `ScopeComponentLoader.componentsCache`). Without
45
+ * these WeakMaps, every op re-runs the same `aspects.filter(include).serialize()`,
46
+ * `tags.toArray().map(toObject)`, `headTag.toObject()` etc.
47
+ *
48
+ * WeakMaps so entries disappear when the underlying `Component` is evicted from scope cache.
49
+ */
50
+ const aspectsResolverCache = new WeakMap();
51
+ const tagsResolverCache = new WeakMap();
52
+ const headTagResolverCache = new WeakMap();
53
+ const fsResolverCache = new WeakMap();
41
54
  function componentSchema(componentExtension) {
42
55
  return {
43
56
  typeDefs: (0, _graphqlTag().gql)`
@@ -183,6 +196,10 @@ function componentSchema(componentExtension) {
183
196
  # load a component.
184
197
  get(id: String!, withState: Boolean): Component
185
198
 
199
+ # load multiple components in a single op. items are aligned to the input order;
200
+ # an id that fails to resolve becomes null in its slot rather than failing the call.
201
+ getMany(ids: [String!]!, withState: Boolean): [Component]!
202
+
186
203
  # list components
187
204
  list(offset: Int, limit: Int): [Component]!
188
205
 
@@ -203,7 +220,11 @@ function componentSchema(componentExtension) {
203
220
  id: component => component.id.toObject(),
204
221
  displayName: component => component.displayName,
205
222
  fs: component => {
206
- return component.state.filesystem.files.map(file => file.relative);
223
+ const cached = fsResolverCache.get(component);
224
+ if (cached) return cached;
225
+ const result = component.state.filesystem.files.map(file => file.relative);
226
+ fsResolverCache.set(component, result);
227
+ return result;
207
228
  },
208
229
  log: async component => {
209
230
  const snap = await component.loadSnap(component.id.version);
@@ -225,16 +246,36 @@ function componentSchema(componentExtension) {
225
246
  mainFile: component => {
226
247
  return component.state._consumer.mainFile;
227
248
  },
228
- headTag: component => component.headTag?.toObject(),
249
+ headTag: component => {
250
+ if (headTagResolverCache.has(component)) return headTagResolverCache.get(component);
251
+ const result = component.headTag?.toObject();
252
+ headTagResolverCache.set(component, result);
253
+ return result;
254
+ },
229
255
  latest: component => component.latest,
230
256
  tags: component => {
257
+ const cached = tagsResolverCache.get(component);
258
+ if (cached) return cached;
231
259
  // graphql doesn't support map types
232
- return component.tags.toArray().map(tag => tag.toObject());
260
+ const result = component.tags.toArray().map(tag => tag.toObject());
261
+ tagsResolverCache.set(component, result);
262
+ return result;
233
263
  },
234
264
  aspects: (component, {
235
265
  include
236
266
  }) => {
237
- return component.state.aspects.filter(include).serialize();
267
+ let perComponent = aspectsResolverCache.get(component);
268
+ if (!perComponent) {
269
+ perComponent = new Map();
270
+ aspectsResolverCache.set(component, perComponent);
271
+ }
272
+ // sort the include list so callers that pass the same set in different order still hit cache.
273
+ const cacheKey = include ? [...include].sort().join('|') : '__all__';
274
+ const cached = perComponent.get(cacheKey);
275
+ if (cached) return cached;
276
+ const result = component.state.aspects.filter(include).serialize();
277
+ perComponent.set(cacheKey, result);
278
+ return result;
238
279
  },
239
280
  // Here only to not break old queries
240
281
  elementsUrl: () => undefined,
@@ -263,6 +304,21 @@ function componentSchema(componentExtension) {
263
304
  return null;
264
305
  }
265
306
  },
307
+ getMany: async (host, {
308
+ ids
309
+ }) => {
310
+ // run resolves+loads in parallel — `host.getMany` uses `mapSeries` under the hood, which
311
+ // serializes the work and defeats the whole point of bulk. each entry is independent and
312
+ // the underlying ScopeComponentLoader has its own per-id cache, so concurrency is safe.
313
+ return Promise.all(ids.map(async id => {
314
+ try {
315
+ const componentId = await host.resolveComponentId(id);
316
+ return await host.get(componentId);
317
+ } catch {
318
+ return null;
319
+ }
320
+ }));
321
+ },
266
322
  snaps: async (host, {
267
323
  id
268
324
  }) => {
@@ -285,8 +341,18 @@ function componentSchema(componentExtension) {
285
341
  }));
286
342
  },
287
343
  id: async (host, _args, _context, info) => {
288
- const extensionId = info.variableValues.extensionId;
289
- return extensionId ? `${host.name}/${extensionId}` : host.name;
344
+ // suffix the id with the requested host id so data fetched from different hosts (e.g. the
345
+ // workspace vs the scope during local-vs-scope compare, #9549) normalizes into distinct
346
+ // Apollo cache entities. A child field resolver can't see its parent's args, so the
347
+ // requested host is read from the operation's variables — and queries pass it under TWO
348
+ // names: `$extensionId` (file/artifact/lane-component queries) and `$host` (bulk
349
+ // compare/api-diff queries). Honoring both keeps the entity id consistent across the
350
+ // conventions. When this depended on `$extensionId` alone, the same host normalized into
351
+ // two different entities depending on which query fetched it; every response re-pointed
352
+ // the `getHost` root ref at its own flavor, orphaning the other's cached fields — which
353
+ // forced cache-first consumers (the bulk compare pager) into endless refetch loops.
354
+ const hostId = info.variableValues.extensionId ?? info.variableValues.host;
355
+ return hostId ? `${host.name}/${hostId}` : host.name;
290
356
  },
291
357
  name: async host => {
292
358
  return host.name;
@@ -1 +1 @@
1
- {"version":3,"names":["_stripAnsi","data","_interopRequireDefault","require","_graphqlTag","_graphqlTypeJson","_toolboxPath","e","__esModule","default","ownKeys","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","_toPropertyKey","value","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","componentSchema","componentExtension","typeDefs","gql","resolvers","JSONObject","GraphQLJSONObject","Component","id","component","toObject","displayName","fs","state","filesystem","files","map","file","relative","log","snap","loadSnap","version","date","timestamp","getTime","email","author","username","name","hash","getFile","path","maybeFile","find","pathNormalizeToLinux","undefined","contents","toString","mainFile","_consumer","headTag","latest","tags","toArray","tag","aspects","include","serialize","elementsUrl","logs","head","takeHeadFromComponent","finalFilter","getLogs","ComponentHost","get","host","componentId","resolveComponentId","snaps","list","listInvalid","invalidComps","err","errorName","errorMessage","message","stripAnsi","_args","_context","info","extensionId","variableValues","Query","getHost","componentExt"],"sources":["component.graphql.ts"],"sourcesContent":["import stripAnsi from 'strip-ansi';\nimport { gql } from 'graphql-tag';\nimport { GraphQLJSONObject } from 'graphql-type-json';\nimport type { ComponentID, ComponentIdObj } from '@teambit/component-id';\nimport { pathNormalizeToLinux } from '@teambit/toolbox.path.path';\nimport type { ComponentLog } from '@teambit/objects';\nimport type { Schema } from '@teambit/graphql';\nimport type { Component } from './component';\nimport type { ComponentFactory } from './component-factory';\nimport type { ComponentMain } from './component.main.runtime';\n\nexport function componentSchema(componentExtension: ComponentMain): Schema {\n return {\n typeDefs: gql`\n scalar JSON\n scalar JSONObject\n\n type ComponentID {\n name: String!\n version: String\n scope: String\n }\n\n type Tag {\n # semver assigned to the tag.\n version: String!\n\n # tag hash.\n hash: String!\n }\n\n type Snap {\n # hash of the snapshot.\n hash: String!\n\n # time of the snapshot.\n timestamp: String!\n\n # parents of the snap\n parents: [String]!\n\n # snapper\n author: Author!\n\n # snapshot message\n message: String\n }\n\n type LogEntry {\n message: String!\n displayName: String\n username: String\n parents: [String]!\n email: String\n date: String\n hash: String!\n tag: String\n id: String!\n profileImage: String\n\n # whether this specific version is deprecated (full component deprecation or matched by a deprecation range)\n deprecated: Boolean\n }\n\n type Author {\n # display name of the snapper.\n displayName: String!\n\n # author of the snapper.\n email: String!\n }\n\n type Component {\n # id of the component.\n id: ComponentID!\n\n # head snap of the component.\n head: Snap\n\n # head tag of the component.\n headTag: Tag\n\n # list of all relative component paths.\n fs: [String]\n\n # relative path to the main file of the component\n mainFile: String\n\n # return specific file contents by relative file path.\n getFile(path: String): String\n\n # latest version of the component.\n latest: String\n\n # display name of the component\n displayName: String!\n\n # component buildStatus\n buildStatus: String\n\n # list of component releases.\n tags: [Tag]!\n\n # Log entry of the component.\n log: LogEntry!\n\n \"\"\"\n component logs\n \"\"\"\n logs(\n \"\"\"\n type of logs to show (tag or snap)\n \"\"\"\n type: String\n offset: Int\n limit: Int\n \"\"\"\n head to start traversing logs from\n \"\"\"\n head: String\n sort: String\n \"\"\"\n start traversing logs from the fetched component's head\n \"\"\"\n takeHeadFromComponent: Boolean\n ): [LogEntry]!\n\n aspects(include: [String]): [Aspect]\n\n \"\"\"\n element url of the component - this is deprecated, and will return empty string now.\n it's here to not break old queries\n \"\"\"\n elementsUrl: String @deprecated(reason: \"Not in use anymore\")\n }\n\n type Aspect {\n id: String!\n icon: String\n config: JSONObject\n data: JSONObject\n }\n\n type InvalidComponent {\n id: ComponentID!\n errorName: String!\n errorMessage: String!\n }\n\n type ComponentHost {\n id: ID!\n name: String!\n\n # load a component.\n get(id: String!, withState: Boolean): Component\n\n # list components\n list(offset: Int, limit: Int): [Component]!\n\n # list invalid components and their errors\n listInvalid: [InvalidComponent]!\n\n # get component logs(snaps) by component id\n snaps(id: String!): [LogEntry]! @deprecated(reason: \"Use the logs field on Component\")\n }\n\n type Query {\n getHost(id: String): ComponentHost\n }\n `,\n resolvers: {\n JSONObject: GraphQLJSONObject,\n Component: {\n id: (component: Component): ComponentIdObj => component.id.toObject(),\n displayName: (component: Component) => component.displayName,\n fs: (component: Component) => {\n return component.state.filesystem.files.map((file) => file.relative);\n },\n log: async (component: Component) => {\n const snap = await component.loadSnap(component.id.version);\n return {\n ...snap,\n date: snap.timestamp.getTime(),\n email: snap.author.email,\n username: snap.author.name,\n displayName: snap.author.displayName,\n id: snap.hash,\n };\n },\n getFile: (component: Component, { path }: { path: string }) => {\n const maybeFile = component.state.filesystem.files.find(\n (file) => pathNormalizeToLinux(file.relative) === path\n );\n if (!maybeFile) return undefined;\n return maybeFile.contents.toString('utf-8');\n },\n mainFile: (component: Component) => {\n return component.state._consumer.mainFile;\n },\n headTag: (component: Component) => component.headTag?.toObject(),\n latest: (component: Component) => component.latest,\n tags: (component) => {\n // graphql doesn't support map types\n return component.tags.toArray().map((tag) => tag.toObject());\n },\n aspects: (component: Component, { include }: { include?: string[] }) => {\n return component.state.aspects.filter(include).serialize();\n },\n // Here only to not break old queries\n elementsUrl: () => undefined,\n logs: async (\n component: Component,\n filter?: {\n type?: string;\n offset?: number;\n limit?: number;\n head?: string;\n sort?: string;\n takeHeadFromComponent: boolean;\n }\n ) => {\n let head = filter?.head;\n if (!head && filter?.takeHeadFromComponent) {\n head = component.id.version;\n }\n const finalFilter = { ...filter, head };\n return (await component.getLogs(finalFilter)).map((log) => ({ ...log, id: log.hash }));\n },\n },\n ComponentHost: {\n get: async (host: ComponentFactory, { id }: { id: string }) => {\n try {\n const componentId = await host.resolveComponentId(id);\n const component = await host.get(componentId);\n return component;\n } catch {\n return null;\n }\n },\n snaps: async (host: ComponentFactory, { id }: { id: string }): Promise<ComponentLog[]> => {\n const componentId = await host.resolveComponentId(id);\n // return (await host.getLogs(componentId)).map(log => ({...log, id: log.hash}))\n return host.getLogs(componentId);\n },\n list: async (host: ComponentFactory, filter?: { offset: number; limit: number }) => {\n return host.list(filter);\n },\n listInvalid: async (host: ComponentFactory) => {\n const invalidComps = await host.listInvalid();\n return invalidComps.map(({ id, err }) => ({\n id: id as ComponentID,\n errorName: err.name,\n errorMessage: err.message ? stripAnsi(err.message) : err.name,\n }));\n },\n id: async (host: ComponentFactory, _args, _context, info) => {\n const extensionId = info.variableValues.extensionId;\n return extensionId ? `${host.name}/${extensionId}` : host.name;\n },\n name: async (host: ComponentFactory) => {\n return host.name;\n },\n },\n Query: {\n getHost: (componentExt: ComponentMain, { id }: { id: string }) => {\n return componentExtension.getHost(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C,QAAQ,EAAE,IAAAC,iBAAG;AACjB;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;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;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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;IACDC,SAAS,EAAE;MACTC,UAAU,EAAEC,oCAAiB;MAC7BC,SAAS,EAAE;QACTC,EAAE,EAAGC,SAAoB,IAAqBA,SAAS,CAACD,EAAE,CAACE,QAAQ,CAAC,CAAC;QACrEC,WAAW,EAAGF,SAAoB,IAAKA,SAAS,CAACE,WAAW;QAC5DC,EAAE,EAAGH,SAAoB,IAAK;UAC5B,OAAOA,SAAS,CAACI,KAAK,CAACC,UAAU,CAACC,KAAK,CAACC,GAAG,CAAEC,IAAI,IAAKA,IAAI,CAACC,QAAQ,CAAC;QACtE,CAAC;QACDC,GAAG,EAAE,MAAOV,SAAoB,IAAK;UACnC,MAAMW,IAAI,GAAG,MAAMX,SAAS,CAACY,QA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AOJ,IAAsB,EAAElF,MAA0C,KAAK;UAClF,OAAOkF,IAAI,CAACI,IAAI,CAACtF,MAAM,CAAC;QAC1B,CAAC;QACDuF,WAAW,EAAE,MAAOL,IAAsB,IAAK;UAC7C,MAAMM,YAAY,GAAG,MAAMN,IAAI,CAACK,WAAW,CAAC,CAAC;UAC7C,OAAOC,YAAY,CAAC/C,GAAG,CAAC,CAAC;YAAER,EAAE;YAAEwD;UAAI,CAAC,MAAM;YACxCxD,EAAE,EAAEA,EAAiB;YACrByD,SAAS,EAAED,GAAG,CAACnC,IAAI;YACnBqC,YAAY,EAAEF,GAAG,CAACG,OAAO,GAAG,IAAAC,oBAAS,EAACJ,GAAG,CAACG,OAAO,CAAC,GAAGH,GAAG,CAACnC;UAC3D,CAAC,CAAC,CAAC;QACL,CAAC;QACDrB,EAAE,EAAE,MAAAA,CAAOiD,IAAsB,EAAEY,KAAK,EAAEC,QAAQ,EAAEC,IAAI,KAAK;UAC3D,MAAMC,WAAW,GAAGD,IAAI,CAACE,cAAc,CAACD,WAAW;UACnD,OAAOA,WAAW,GAAG,GAAGf,IAAI,CAAC5B,IAAI,IAAI2C,WAAW,EAAE,GAAGf,IAAI,CAAC5B,IAAI;QAChE,CAAC;QACDA,IAAI,EAAE,MAAO4B,IAAsB,IAAK;UACtC,OAAOA,IAAI,CAAC5B,IAAI;QAClB;MACF,CAAC;MACD6C,KAAK,EAAE;QACLC,OAAO,EAAEA,CAACC,YAA2B,EAAE;UAAEpE;QAAmB,CAAC,KAAK;UAChE,OAAOP,kBAAkB,CAAC0E,OAAO,CAACnE,EAAE,CAAC;QACvC;MACF;IACF;EACF,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"names":["_stripAnsi","data","_interopRequireDefault","require","_graphqlTag","_graphqlTypeJson","_toolboxPath","e","__esModule","default","ownKeys","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","_toPropertyKey","value","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","aspectsResolverCache","WeakMap","tagsResolverCache","headTagResolverCache","fsResolverCache","componentSchema","componentExtension","typeDefs","gql","resolvers","JSONObject","GraphQLJSONObject","Component","id","component","toObject","displayName","fs","cached","get","result","state","filesystem","files","map","file","relative","set","log","snap","loadSnap","version","date","timestamp","getTime","email","author","username","name","hash","getFile","path","maybeFile","find","pathNormalizeToLinux","undefined","contents","toString","mainFile","_consumer","headTag","has","latest","tags","toArray","tag","aspects","include","perComponent","Map","cacheKey","sort","join","serialize","elementsUrl","logs","head","takeHeadFromComponent","finalFilter","getLogs","ComponentHost","host","componentId","resolveComponentId","getMany","ids","Promise","all","snaps","list","listInvalid","invalidComps","err","errorName","errorMessage","message","stripAnsi","_args","_context","info","hostId","variableValues","extensionId","Query","getHost","componentExt"],"sources":["component.graphql.ts"],"sourcesContent":["import stripAnsi from 'strip-ansi';\nimport { gql } from 'graphql-tag';\nimport { GraphQLJSONObject } from 'graphql-type-json';\nimport type { ComponentID, ComponentIdObj } from '@teambit/component-id';\nimport { pathNormalizeToLinux } from '@teambit/toolbox.path.path';\nimport type { ComponentLog } from '@teambit/objects';\nimport type { Schema } from '@teambit/graphql';\nimport type { Component } from './component';\nimport type { ComponentFactory } from './component-factory';\nimport type { ComponentMain } from './component.main.runtime';\n\n/**\n * Per-Component-instance caches for resolver field outputs. Each batched lane-compare request fans\n * out to ~10–20 `Component` ops that all eventually call `host.get()` for the same versioned id —\n * which returns the same `Component` instance (via `ScopeComponentLoader.componentsCache`). Without\n * these WeakMaps, every op re-runs the same `aspects.filter(include).serialize()`,\n * `tags.toArray().map(toObject)`, `headTag.toObject()` etc.\n *\n * WeakMaps so entries disappear when the underlying `Component` is evicted from scope cache.\n */\nconst aspectsResolverCache = new WeakMap<Component, Map<string, any>>();\nconst tagsResolverCache = new WeakMap<Component, any>();\nconst headTagResolverCache = new WeakMap<Component, any>();\nconst fsResolverCache = new WeakMap<Component, string[]>();\n\nexport function componentSchema(componentExtension: ComponentMain): Schema {\n return {\n typeDefs: gql`\n scalar JSON\n scalar JSONObject\n\n type ComponentID {\n name: String!\n version: String\n scope: String\n }\n\n type Tag {\n # semver assigned to the tag.\n version: String!\n\n # tag hash.\n hash: String!\n }\n\n type Snap {\n # hash of the snapshot.\n hash: String!\n\n # time of the snapshot.\n timestamp: String!\n\n # parents of the snap\n parents: [String]!\n\n # snapper\n author: Author!\n\n # snapshot message\n message: String\n }\n\n type LogEntry {\n message: String!\n displayName: String\n username: String\n parents: [String]!\n email: String\n date: String\n hash: String!\n tag: String\n id: String!\n profileImage: String\n\n # whether this specific version is deprecated (full component deprecation or matched by a deprecation range)\n deprecated: Boolean\n }\n\n type Author {\n # display name of the snapper.\n displayName: String!\n\n # author of the snapper.\n email: String!\n }\n\n type Component {\n # id of the component.\n id: ComponentID!\n\n # head snap of the component.\n head: Snap\n\n # head tag of the component.\n headTag: Tag\n\n # list of all relative component paths.\n fs: [String]\n\n # relative path to the main file of the component\n mainFile: String\n\n # return specific file contents by relative file path.\n getFile(path: String): String\n\n # latest version of the component.\n latest: String\n\n # display name of the component\n displayName: String!\n\n # component buildStatus\n buildStatus: String\n\n # list of component releases.\n tags: [Tag]!\n\n # Log entry of the component.\n log: LogEntry!\n\n \"\"\"\n component logs\n \"\"\"\n logs(\n \"\"\"\n type of logs to show (tag or snap)\n \"\"\"\n type: String\n offset: Int\n limit: Int\n \"\"\"\n head to start traversing logs from\n \"\"\"\n head: String\n sort: String\n \"\"\"\n start traversing logs from the fetched component's head\n \"\"\"\n takeHeadFromComponent: Boolean\n ): [LogEntry]!\n\n aspects(include: [String]): [Aspect]\n\n \"\"\"\n element url of the component - this is deprecated, and will return empty string now.\n it's here to not break old queries\n \"\"\"\n elementsUrl: String @deprecated(reason: \"Not in use anymore\")\n }\n\n type Aspect {\n id: String!\n icon: String\n config: JSONObject\n data: JSONObject\n }\n\n type InvalidComponent {\n id: ComponentID!\n errorName: String!\n errorMessage: String!\n }\n\n type ComponentHost {\n id: ID!\n name: String!\n\n # load a component.\n get(id: String!, withState: Boolean): Component\n\n # load multiple components in a single op. items are aligned to the input order;\n # an id that fails to resolve becomes null in its slot rather than failing the call.\n getMany(ids: [String!]!, withState: Boolean): [Component]!\n\n # list components\n list(offset: Int, limit: Int): [Component]!\n\n # list invalid components and their errors\n listInvalid: [InvalidComponent]!\n\n # get component logs(snaps) by component id\n snaps(id: String!): [LogEntry]! @deprecated(reason: \"Use the logs field on Component\")\n }\n\n type Query {\n getHost(id: String): ComponentHost\n }\n `,\n resolvers: {\n JSONObject: GraphQLJSONObject,\n Component: {\n id: (component: Component): ComponentIdObj => component.id.toObject(),\n displayName: (component: Component) => component.displayName,\n fs: (component: Component) => {\n const cached = fsResolverCache.get(component);\n if (cached) return cached;\n const result = component.state.filesystem.files.map((file) => file.relative);\n fsResolverCache.set(component, result);\n return result;\n },\n log: async (component: Component) => {\n const snap = await component.loadSnap(component.id.version);\n return {\n ...snap,\n date: snap.timestamp.getTime(),\n email: snap.author.email,\n username: snap.author.name,\n displayName: snap.author.displayName,\n id: snap.hash,\n };\n },\n getFile: (component: Component, { path }: { path: string }) => {\n const maybeFile = component.state.filesystem.files.find(\n (file) => pathNormalizeToLinux(file.relative) === path\n );\n if (!maybeFile) return undefined;\n return maybeFile.contents.toString('utf-8');\n },\n mainFile: (component: Component) => {\n return component.state._consumer.mainFile;\n },\n headTag: (component: Component) => {\n if (headTagResolverCache.has(component)) return headTagResolverCache.get(component);\n const result = component.headTag?.toObject();\n headTagResolverCache.set(component, result);\n return result;\n },\n latest: (component: Component) => component.latest,\n tags: (component) => {\n const cached = tagsResolverCache.get(component);\n if (cached) return cached;\n // graphql doesn't support map types\n const result = component.tags.toArray().map((tag) => tag.toObject());\n tagsResolverCache.set(component, result);\n return result;\n },\n aspects: (component: Component, { include }: { include?: string[] }) => {\n let perComponent = aspectsResolverCache.get(component);\n if (!perComponent) {\n perComponent = new Map();\n aspectsResolverCache.set(component, perComponent);\n }\n // sort the include list so callers that pass the same set in different order still hit cache.\n const cacheKey = include ? [...include].sort().join('|') : '__all__';\n const cached = perComponent.get(cacheKey);\n if (cached) return cached;\n const result = component.state.aspects.filter(include).serialize();\n perComponent.set(cacheKey, result);\n return result;\n },\n // Here only to not break old queries\n elementsUrl: () => undefined,\n logs: async (\n component: Component,\n filter?: {\n type?: string;\n offset?: number;\n limit?: number;\n head?: string;\n sort?: string;\n takeHeadFromComponent: boolean;\n }\n ) => {\n let head = filter?.head;\n if (!head && filter?.takeHeadFromComponent) {\n head = component.id.version;\n }\n const finalFilter = { ...filter, head };\n return (await component.getLogs(finalFilter)).map((log) => ({ ...log, id: log.hash }));\n },\n },\n ComponentHost: {\n get: async (host: ComponentFactory, { id }: { id: string }) => {\n try {\n const componentId = await host.resolveComponentId(id);\n const component = await host.get(componentId);\n return component;\n } catch {\n return null;\n }\n },\n getMany: async (host: ComponentFactory, { ids }: { ids: string[] }) => {\n // run resolves+loads in parallel — `host.getMany` uses `mapSeries` under the hood, which\n // serializes the work and defeats the whole point of bulk. each entry is independent and\n // the underlying ScopeComponentLoader has its own per-id cache, so concurrency is safe.\n return Promise.all(\n ids.map(async (id) => {\n try {\n const componentId = await host.resolveComponentId(id);\n return await host.get(componentId);\n } catch {\n return null;\n }\n })\n );\n },\n snaps: async (host: ComponentFactory, { id }: { id: string }): Promise<ComponentLog[]> => {\n const componentId = await host.resolveComponentId(id);\n // return (await host.getLogs(componentId)).map(log => ({...log, id: log.hash}))\n return host.getLogs(componentId);\n },\n list: async (host: ComponentFactory, filter?: { offset: number; limit: number }) => {\n return host.list(filter);\n },\n listInvalid: async (host: ComponentFactory) => {\n const invalidComps = await host.listInvalid();\n return invalidComps.map(({ id, err }) => ({\n id: id as ComponentID,\n errorName: err.name,\n errorMessage: err.message ? stripAnsi(err.message) : err.name,\n }));\n },\n id: async (host: ComponentFactory, _args, _context, info) => {\n // suffix the id with the requested host id so data fetched from different hosts (e.g. the\n // workspace vs the scope during local-vs-scope compare, #9549) normalizes into distinct\n // Apollo cache entities. A child field resolver can't see its parent's args, so the\n // requested host is read from the operation's variables — and queries pass it under TWO\n // names: `$extensionId` (file/artifact/lane-component queries) and `$host` (bulk\n // compare/api-diff queries). Honoring both keeps the entity id consistent across the\n // conventions. When this depended on `$extensionId` alone, the same host normalized into\n // two different entities depending on which query fetched it; every response re-pointed\n // the `getHost` root ref at its own flavor, orphaning the other's cached fields — which\n // forced cache-first consumers (the bulk compare pager) into endless refetch loops.\n const hostId = info.variableValues.extensionId ?? info.variableValues.host;\n return hostId ? `${host.name}/${hostId}` : host.name;\n },\n name: async (host: ComponentFactory) => {\n return host.name;\n },\n },\n Query: {\n getHost: (componentExt: ComponentMain, { id }: { id: string }) => {\n return componentExtension.getHost(id);\n },\n },\n },\n };\n}\n"],"mappings":";;;;;;AAAA,SAAAA,WAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,UAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,YAAA;EAAA,MAAAH,IAAA,GAAAE,OAAA;EAAAC,WAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,iBAAA;EAAA,MAAAJ,IAAA,GAAAE,OAAA;EAAAE,gBAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAK,aAAA;EAAA,MAAAL,IAAA,GAAAE,OAAA;EAAAG,YAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAAkE,SAAAC,uBAAAK,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAG,QAAAH,CAAA,EAAAI,CAAA,QAAAC,CA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AL,CAAA;AAAA,SAAAuB,eAAAlB,CAAA,QAAAsB,CAAA,GAAAC,YAAA,CAAAvB,CAAA,uCAAAsB,CAAA,GAAAA,CAAA,GAAAA,CAAA;AAAA,SAAAC,aAAAvB,CAAA,EAAAD,CAAA,2BAAAC,CAAA,KAAAA,CAAA,SAAAA,CAAA,MAAAL,CAAA,GAAAK,CAAA,CAAAwB,MAAA,CAAAC,WAAA,kBAAA9B,CAAA,QAAA2B,CAAA,GAAA3B,CAAA,CAAA+B,IAAA,CAAA1B,CAAA,EAAAD,CAAA,uCAAAuB,CAAA,SAAAA,CAAA,YAAAK,SAAA,yEAAA5B,CAAA,GAAA6B,MAAA,GAAAC,MAAA,EAAA7B,CAAA;AAOlE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM8B,oBAAoB,GAAG,IAAIC,OAAO,CAA8B,CAAC;AACvE,MAAMC,iBAAiB,GAAG,IAAID,OAAO,CAAiB,CAAC;AACvD,MAAME,oBAAoB,GAAG,IAAIF,OAAO,CAAiB,CAAC;AAC1D,MAAMG,eAAe,GAAG,IAAIH,OAAO,CAAsB,CAAC;AAEnD,SAASI,eAAeA,CAACC,kBAAiC,EAAU;EACzE,OAAO;IACLC,QAAQ,EAAE,IAAAC,iBAAG;AACjB;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;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;AAC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E,MAAOT,IAAsB,IAAK;UAC7C,MAAMU,YAAY,GAAG,MAAMV,IAAI,CAACS,WAAW,CAAC,CAAC;UAC7C,OAAOC,YAAY,CAACzD,GAAG,CAAC,CAAC;YAAEX,EAAE;YAAEqE;UAAI,CAAC,MAAM;YACxCrE,EAAE,EAAEA,EAAiB;YACrBsE,SAAS,EAAED,GAAG,CAAC5C,IAAI;YACnB8C,YAAY,EAAEF,GAAG,CAACG,OAAO,GAAG,IAAAC,oBAAS,EAACJ,GAAG,CAACG,OAAO,CAAC,GAAGH,GAAG,CAAC5C;UAC3D,CAAC,CAAC,CAAC;QACL,CAAC;QACDzB,EAAE,EAAE,MAAAA,CAAO0D,IAAsB,EAAEgB,KAAK,EAAEC,QAAQ,EAAEC,IAAI,KAAK;UAC3D;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA,MAAMC,MAAM,GAAGD,IAAI,CAACE,cAAc,CAACC,WAAW,IAAIH,IAAI,CAACE,cAAc,CAACpB,IAAI;UAC1E,OAAOmB,MAAM,GAAG,GAAGnB,IAAI,CAACjC,IAAI,IAAIoD,MAAM,EAAE,GAAGnB,IAAI,CAACjC,IAAI;QACtD,CAAC;QACDA,IAAI,EAAE,MAAOiC,IAAsB,IAAK;UACtC,OAAOA,IAAI,CAACjC,IAAI;QAClB;MACF,CAAC;MACDuD,KAAK,EAAE;QACLC,OAAO,EAAEA,CAACC,YAA2B,EAAE;UAAElF;QAAmB,CAAC,KAAK;UAChE,OAAOP,kBAAkB,CAACwF,OAAO,CAACjF,EAAE,CAAC;QACvC;MACF;IACF;EACF,CAAC;AACH","ignoreList":[]}
@@ -1,5 +1,5 @@
1
- import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.component_component@1.0.1079/dist/component.composition.js';
2
- import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.component_component@1.0.1079/dist/component.docs.mdx';
1
+ import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.component_component@1.0.1081/dist/component.composition.js';
2
+ import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.component_component@1.0.1081/dist/component.docs.mdx';
3
3
 
4
4
  export const compositions = [compositions_0];
5
5
  export const overview = [overview_0];
@@ -96,8 +96,15 @@
96
96
  }
97
97
  }
98
98
 
99
+ // The component top bar packs left-side nav (Overview, Code, Tests, Preview …) and right-side
100
+ // dropdowns (Use package, Versions, Workspace) on the same row. Below `$br-lg` the right side
101
+ // takes so much horizontal space that the ResponsiveNavbar collapses every nav tab into the
102
+ // overflow "more" dropdown — which is what produces the "…" the user sees instead of tabs.
103
+ // Hiding the Use-package dropdown earlier (at < lg, not < md) reclaims the room so the nav
104
+ // stays visible on tablet viewports too. Users on mobile can still copy the install command
105
+ // from the dedicated "Use package" panel that the docs overview renders inline.
99
106
  .hideOnMobile {
100
- @media screen and (max-width: $br-md) {
107
+ @media screen and (max-width: $br-lg) {
101
108
  display: none;
102
109
  }
103
110
  }
@@ -105,4 +112,13 @@
105
112
  .useBoxContainer {
106
113
  width: 500px !important;
107
114
  border: 1px solid var(--border-medium-color, #ededed);
115
+
116
+ // Mobile: cap to viewport width, drop fixed pixel width, scroll horizontally if a tab title
117
+ // (or the install snippet) is wider. Without this the 500px container overflows past the
118
+ // viewport edge, which is why the second consume-method tab and the package-name snippet were
119
+ // both truncating to "…".
120
+ @media screen and (max-width: $br-md) {
121
+ width: calc(100vw - 24px) !important;
122
+ max-width: 500px;
123
+ }
108
124
  }
@@ -1,5 +1,5 @@
1
1
  import type { ComponentLogsResult, Filters } from './use-component.model';
2
- export declare function useComponentLogs(componentId: string, host: string, filters?: Filters, skipFromProps?: boolean): ComponentLogsResult;
2
+ export declare function useComponentLogs(componentId: string, host: string, filters?: Filters, skipFromProps?: boolean, context?: Record<string, any>): ComponentLogsResult;
3
3
  export declare function useComponentLogsInit(componentId: string, host: string, filters?: Filters, skip?: boolean): {
4
4
  logOffset: number | undefined;
5
5
  variables: {
@@ -47,7 +47,7 @@ function _() {
47
47
  };
48
48
  return data;
49
49
  }
50
- function useComponentLogs(componentId, host, filters, skipFromProps) {
50
+ function useComponentLogs(componentId, host, filters, skipFromProps, context) {
51
51
  const {
52
52
  variables,
53
53
  skip
@@ -59,7 +59,8 @@ function useComponentLogs(componentId, host, filters, skipFromProps) {
59
59
  } = (0, _uiFoundationUiHooks().useDataQuery)(_useComponent().GET_COMPONENT_WITH_LOGS, {
60
60
  variables,
61
61
  skip,
62
- errorPolicy: 'all'
62
+ errorPolicy: 'all',
63
+ context
63
64
  });
64
65
  const rawComponent = data?.getHost?.get;
65
66
  const rawCompLogs = rawComponent?.logs;
@@ -1 +1 @@
1
- {"version":3,"names":["_react","data","require","_uiFoundationUiHooks","_useComponent","_componentError","_useComponent2","_","useComponentLogs","componentId","host","filters","skipFromProps","variables","skip","useComponentLogsInit","error","loading","useDataQuery","GET_COMPONENT_WITH_LOGS","errorPolicy","rawComponent","getHost","get","rawCompLogs","logs","componentError","ComponentError","message","undefined","idDepKey","id","scope","name","version","useMemo","ComponentID","fromObject","packageName","latest","componentLogs","log","head","logHead","offset","logOffset","sort","logSort","limit","logLimit","type","logType","takeHeadFromComponent","logTakeHeadFromComponent","extensionId","getOffsetValue"],"sources":["use-component-logs.ts"],"sourcesContent":["import { useMemo } from 'react';\nimport type { LegacyComponentLog } from '@teambit/legacy-component-log';\nimport { useDataQuery } from '@teambit/ui-foundation.ui.hooks.use-data-query';\nimport type { ComponentLogsResult, Filters } from './use-component.model';\nimport { GET_COMPONENT_WITH_LOGS } from './use-component.fragments';\nimport { ComponentError } from './component-error';\nimport { getOffsetValue } from './use-component.utils';\nimport { ComponentID } from '..';\n\nexport function useComponentLogs(\n componentId: string,\n host: string,\n filters?: Filters,\n skipFromProps?: boolean\n): ComponentLogsResult {\n const { variables, skip } = useComponentLogsInit(componentId, host, filters, skipFromProps);\n\n const { data, error, loading } = useDataQuery(GET_COMPONENT_WITH_LOGS, {\n variables,\n skip,\n errorPolicy: 'all',\n });\n\n const rawComponent = data?.getHost?.get;\n const rawCompLogs: Array<LegacyComponentLog> = rawComponent?.logs;\n\n const componentError =\n error && !data\n ? new ComponentError(500, error.message)\n : (!rawComponent && !loading && new ComponentError(404)) || undefined;\n\n const idDepKey = rawComponent?.id\n ? `${rawComponent?.id?.scope}/${rawComponent?.id?.name}@${rawComponent?.id?.version}}`\n : undefined;\n\n const id: ComponentID | undefined = useMemo(\n () => (rawComponent ? ComponentID.fromObject(rawComponent.id) : undefined),\n [idDepKey]\n );\n\n return {\n loading,\n id,\n packageName: rawComponent?.packageName,\n latest: rawComponent?.latest,\n error: componentError,\n componentLogs: {\n logs: rawCompLogs,\n loading,\n },\n };\n}\n\nexport function useComponentLogsInit(componentId: string, host: string, filters?: Filters, skip?: boolean) {\n const { log } = filters || {};\n const {\n head: logHead,\n offset: logOffset,\n sort: logSort,\n limit: logLimit,\n type: logType,\n takeHeadFromComponent: logTakeHeadFromComponent,\n } = log || {};\n const variables = {\n id: componentId,\n extensionId: host,\n logOffset: getOffsetValue(logOffset, logLimit),\n logLimit,\n logType,\n logHead,\n logSort,\n logTakeHeadFromComponent,\n };\n return {\n logOffset,\n variables,\n skip,\n };\n}\n"],"mappings":";;;;;;;AAAA,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,MAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAE,qBAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,oBAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAG,cAAA;EAAA,MAAAH,IAAA,GAAAC,OAAA;EAAAE,aAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,gBAAA;EAAA,MAAAJ,IAAA,GAAAC,OAAA;EAAAG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AAO,EACzC,MAAOd,YAAY,GAAGe,eAAW,CAACC,UAAU,CAAChB,YAAY,CAACU,EAAE,CAAC,GAAGF,SAAU,EAC1E,CAACC,QAAQ,CACX,CAAC;EAED,OAAO;IACLb,OAAO;IACPc,EAAE;IACFO,WAAW,EAAEjB,YAAY,EAAEiB,WAAW;IACtCC,MAAM,EAAElB,YAAY,EAAEkB,MAAM;IAC5BvB,KAAK,EAAEU,cAAc;IACrBc,aAAa,EAAE;MACbf,IAAI,EAAED,WAAW;MACjBP;IACF;EACF,CAAC;AACH;AAEO,SAASF,oBAAoBA,CAACN,WAAmB,EAAEC,IAAY,EAAEC,OAAiB,EAAEG,IAAc,EAAE;EACzG,MAAM;IAAE2B;EAAI,CAAC,GAAG9B,OAAO,IAAI,CAAC,CAAC;EAC7B,MAAM;IACJ+B,IAAI,EAAEC,OAAO;IACbC,MAAM,EAAEC,SAAS;IACjBC,IAAI,EAAEC,OAAO;IACbC,KAAK,EAAEC,QAAQ;IACfC,IAAI,EAAEC,OAAO;IACbC,qBAAqB,EAAEC;EACzB,CAAC,GAAGZ,GAAG,IAAI,CAAC,CAAC;EACb,MAAM5B,SAAS,GAAG;IAChBkB,EAAE,EAAEtB,WAAW;IACf6C,WAAW,EAAE5C,IAAI;IACjBmC,SAAS,EAAE,IAAAU,+BAAc,EAACV,SAAS,EAAEI,QAAQ,CAAC;IAC9CA,QAAQ;IACRE,OAAO;IACPR,OAAO;IACPI,OAAO;IACPM;EACF,CAAC;EACD,OAAO;IACLR,SAAS;IACThC,SAAS;IACTC;EACF,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"names":["_react","data","require","_uiFoundationUiHooks","_useComponent","_componentError","_useComponent2","_","useComponentLogs","componentId","host","filters","skipFromProps","context","variables","skip","useComponentLogsInit","error","loading","useDataQuery","GET_COMPONENT_WITH_LOGS","errorPolicy","rawComponent","getHost","get","rawCompLogs","logs","componentError","ComponentError","message","undefined","idDepKey","id","scope","name","version","useMemo","ComponentID","fromObject","packageName","latest","componentLogs","log","head","logHead","offset","logOffset","sort","logSort","limit","logLimit","type","logType","takeHeadFromComponent","logTakeHeadFromComponent","extensionId","getOffsetValue"],"sources":["use-component-logs.ts"],"sourcesContent":["import { useMemo } from 'react';\nimport type { LegacyComponentLog } from '@teambit/legacy-component-log';\nimport { useDataQuery } from '@teambit/ui-foundation.ui.hooks.use-data-query';\nimport type { ComponentLogsResult, Filters } from './use-component.model';\nimport { GET_COMPONENT_WITH_LOGS } from './use-component.fragments';\nimport { ComponentError } from './component-error';\nimport { getOffsetValue } from './use-component.utils';\nimport { ComponentID } from '..';\n\nexport function useComponentLogs(\n componentId: string,\n host: string,\n filters?: Filters,\n skipFromProps?: boolean,\n context?: Record<string, any>\n): ComponentLogsResult {\n const { variables, skip } = useComponentLogsInit(componentId, host, filters, skipFromProps);\n\n const { data, error, loading } = useDataQuery(GET_COMPONENT_WITH_LOGS, {\n variables,\n skip,\n errorPolicy: 'all',\n context,\n });\n\n const rawComponent = data?.getHost?.get;\n const rawCompLogs: Array<LegacyComponentLog> = rawComponent?.logs;\n\n const componentError =\n error && !data\n ? new ComponentError(500, error.message)\n : (!rawComponent && !loading && new ComponentError(404)) || undefined;\n\n const idDepKey = rawComponent?.id\n ? `${rawComponent?.id?.scope}/${rawComponent?.id?.name}@${rawComponent?.id?.version}}`\n : undefined;\n\n const id: ComponentID | undefined = useMemo(\n () => (rawComponent ? ComponentID.fromObject(rawComponent.id) : undefined),\n [idDepKey]\n );\n\n return {\n loading,\n id,\n packageName: rawComponent?.packageName,\n latest: rawComponent?.latest,\n error: componentError,\n componentLogs: {\n logs: rawCompLogs,\n loading,\n },\n };\n}\n\nexport function useComponentLogsInit(componentId: string, host: string, filters?: Filters, skip?: boolean) {\n const { log } = filters || {};\n const {\n head: logHead,\n offset: logOffset,\n sort: logSort,\n limit: logLimit,\n type: logType,\n takeHeadFromComponent: logTakeHeadFromComponent,\n } = log || {};\n const variables = {\n id: componentId,\n extensionId: host,\n logOffset: getOffsetVal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qBAAqB,EAAEC;EACzB,CAAC,GAAGZ,GAAG,IAAI,CAAC,CAAC;EACb,MAAM5B,SAAS,GAAG;IAChBkB,EAAE,EAAEvB,WAAW;IACf8C,WAAW,EAAE7C,IAAI;IACjBoC,SAAS,EAAE,IAAAU,+BAAc,EAACV,SAAS,EAAEI,QAAQ,CAAC;IAC9CA,QAAQ;IACRE,OAAO;IACPR,OAAO;IACPI,OAAO;IACPM;EACF,CAAC;EACD,OAAO;IACLR,SAAS;IACThC,SAAS;IACTC;EACF,CAAC;AACH","ignoreList":[]}
@@ -1,3 +1,8 @@
1
1
  import type { ComponentQueryResult, Filters } from './use-component.model';
2
- /** provides data to component ui page, making sure both variables and return value are safely typed and memoized */
3
- export declare function useComponentQuery(componentId: string, host: string, filters?: Filters, skip?: boolean): ComponentQueryResult;
2
+ /**
3
+ * provides data to component ui page, making sure both variables and return value are safely typed and memoized.
4
+ *
5
+ * Logs are fetched separately and opt-in via `useComponentLogs` (gated by `filters.log`), so views
6
+ * that don't render snap history (lane-compare, bulk panels) don't pay for the expensive logs query.
7
+ */
8
+ export declare function useComponentQuery(componentId: string, host: string, filters?: Filters, skip?: boolean, context?: Record<string, any>): ComponentQueryResult;
@@ -65,8 +65,13 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
65
65
  function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
66
66
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
67
67
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
68
- /** provides data to component ui page, making sure both variables and return value are safely typed and memoized */
69
- function useComponentQuery(componentId, host, filters, skip) {
68
+ /**
69
+ * provides data to component ui page, making sure both variables and return value are safely typed and memoized.
70
+ *
71
+ * Logs are fetched separately and opt-in via `useComponentLogs` (gated by `filters.log`), so views
72
+ * that don't render snap history (lane-compare, bulk panels) don't pay for the expensive logs query.
73
+ */
74
+ function useComponentQuery(componentId, host, filters, skip, context) {
70
75
  const idRef = (0, _react().useRef)(componentId);
71
76
  idRef.current = componentId;
72
77
  const variables = {
@@ -80,14 +85,21 @@ function useComponentQuery(componentId, host, filters, skip) {
80
85
  } = (0, _uiFoundationUiHooks().useDataQuery)(_useComponent().GET_COMPONENT, {
81
86
  variables,
82
87
  skip,
83
- errorPolicy: 'all'
88
+ errorPolicy: 'all',
89
+ context
84
90
  });
91
+
92
+ // Only fetch logs when a log filter is explicitly provided — most callers (lane-compare,
93
+ // bulk component panels) never look at history, so the per-component logs query was firing
94
+ // for nothing. Pages that need the history panel pass `filters: { log: {...} }` and
95
+ // `useComponentLogs` runs as before.
96
+ const wantsLogs = !!filters?.log;
85
97
  const {
86
98
  loading: loadingLogs,
87
99
  componentLogs: {
88
100
  logs
89
101
  } = {}
90
- } = (0, _useComponentLogs().useComponentLogs)(componentId, host, filters, skip);
102
+ } = (0, _useComponentLogs().useComponentLogs)(componentId, host, filters, skip || !wantsLogs, context);
91
103
  const rawComponent = data?.getHost?.get;
92
104
  const idDepKey = rawComponent?.id ? `${rawComponent?.id?.scope}/${rawComponent?.id?.name}@${rawComponent?.id?.version}}` : undefined;
93
105
  const id = (0, _react().useMemo)(() => rawComponent ? _componentId().ComponentID.fromObject(rawComponent.id) : undefined, [idDepKey]);
@@ -1 +1 @@
1
- {"version":3,"names":["_react","data","require","_uiFoundationUiHooks","_componentId","_componentDescriptor","_componentModel","_useComponent","_useComponentLogs","_componentError","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","_toPropertyKey","value","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","useComponentQuery","componentId","host","filters","skip","idRef","useRef","current","variables","id","extensionId","error","loading","useDataQuery","GET_COMPONENT","errorPolicy","loadingLogs","componentLogs","logs","useComponentLogs","rawComponent","getHost","get","idDepKey","scope","name","version","undefined","useMemo","ComponentID","fromObject","componentError","ComponentError","message","component","ComponentModel","from","toString","componentDescriptor","aspectList","entries","aspects","map","aspectObject","aspectId","aspectData","ComponentDescriptor"],"sources":["use-component-query.ts"],"sourcesContent":["import { useMemo, useRef } from 'react';\nimport { useDataQuery } from '@teambit/ui-foundation.ui.hooks.use-data-query';\nimport { ComponentID } from '@teambit/component-id';\nimport { ComponentDescriptor } from '@teambit/component-descriptor';\nimport { ComponentModel } from './component-model';\nimport type { ComponentQueryResult, Filters } from './use-component.model';\nimport { GET_COMPONENT } from './use-component.fragments';\nimport { useComponentLogs } from './use-component-logs';\nimport { ComponentError } from './component-error';\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?: Filters,\n skip?: boolean\n): ComponentQueryResult {\n const idRef = useRef(componentId);\n idRef.current = componentId;\n const variables = {\n id: componentId,\n extensionId: host,\n };\n\n const { data, error, loading } = useDataQuery(GET_COMPONENT, {\n variables,\n skip,\n errorPolicy: 'all',\n });\n\n const { loading: loadingLogs, componentLogs: { logs } = {} } = useComponentLogs(componentId, host, filters, skip);\n\n const rawComponent = data?.getHost?.get;\n\n const idDepKey = rawComponent?.id\n ? `${rawComponent?.id?.scope}/${rawComponent?.id?.name}@${rawComponent?.id?.version}}`\n : undefined;\n\n const id: ComponentID | undefined = useMemo(\n () => (rawComponent ? ComponentID.fromObject(rawComponent.id) : undefined),\n [idDepKey]\n );\n\n const componentError =\n error && !data\n ? new ComponentError(500, error.message)\n : (!rawComponent && !loading && new ComponentError(404)) || undefined;\n\n const component = useMemo(\n () => (rawComponent ? ComponentModel.from({ ...rawComponent, host, logs }) : undefined),\n [id?.toString(), logs]\n );\n\n const componentDescriptor = useMemo(() => {\n const aspectList = {\n entries: rawComponent?.aspects.map((aspectObject) => {\n return {\n ...aspectObject,\n aspectId: aspectObject.id,\n aspectData: aspectObject.data,\n };\n }),\n };\n\n return id ? ComponentDescriptor.fromObject({ id: id.toString(), aspectList }) : undefined;\n }, [id?.toString()]);\n\n return useMemo(() => {\n return {\n componentDescriptor,\n component,\n componentLogs: {\n loading: loadingLogs,\n logs,\n },\n error: componentError || undefined,\n loading,\n };\n }, [host, component, componentDescriptor, componentError]);\n}\n"],"mappings":";;;;;;AAAA,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,MAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,qBAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,oBAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,aAAA;EAAA,MAAAH,IAAA,GAAAC,OAAA;EAAAE,YAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,qBAAA;EAAA,MAAAJ,IAAA,GAAAC,OAAA;EAAAG,oBAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAK,gBAAA;EAAA,MAAAL,IAAA,GAAAC,OAAA;EAAAI,eAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAM,cAAA;EAAA,MAAAN,IAAA,GAAAC,OAAA;EAAAK,aAAA,YAAAA,CAAA;IAAA,OAAAN,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAO,kBAAA;EAAA,MAAAP,IAAA,GAAAC,OAAA;EAAAM,iBAAA,YAAAA,CAAA;IAAA,OAA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,CAAC;IAED,OAAOmD,EAAE,GAAGqC,0CAAmB,CAAChB,UAAU,CAAC;MAAErB,EAAE,EAAEA,EAAE,CAAC4B,QAAQ,CAAC,CAAC;MAAEE;IAAW,CAAC,CAAC,GAAGZ,SAAS;EAC3F,CAAC,EAAE,CAAClB,EAAE,EAAE4B,QAAQ,CAAC,CAAC,CAAC,CAAC;EAEpB,OAAO,IAAAT,gBAAO,EAAC,MAAM;IACnB,OAAO;MACLU,mBAAmB;MACnBJ,SAAS;MACTjB,aAAa,EAAE;QACbL,OAAO,EAAEI,WAAW;QACpBE;MACF,CAAC;MACDP,KAAK,EAAEoB,cAAc,IAAIJ,SAAS;MAClCf;IACF,CAAC;EACH,CAAC,EAAE,CAACV,IAAI,EAAEgC,SAAS,EAAEI,mBAAmB,EAAEP,cAAc,CAAC,CAAC;AAC5D","ignoreList":[]}
1
+ {"version":3,"names":["_react","data","require","_uiFoundationUiHooks","_componentId","_componentDescriptor","_componentModel","_useComponent","_useComponentLogs","_componentError","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","_toPropertyKey","value","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","useComponentQuery","componentId","host","filters","skip","context","idRef","useRef","current","variables","id","extensionId","error","loading","useDataQuery","GET_COMPONENT","errorPolicy","wantsLogs","log","loadingLogs","componentLogs","logs","useComponentLogs","rawComponent","getHost","get","idDepKey","scope","name","version","undefined","useMemo","ComponentID","fromObject","componentError","ComponentError","message","component","ComponentModel","from","toString","componentDescriptor","aspectList","entries","aspects","map","aspectObject","aspectId","aspectData","ComponentDescriptor"],"sources":["use-component-query.ts"],"sourcesContent":["import { useMemo, useRef } from 'react';\nimport { useDataQuery } from '@teambit/ui-foundation.ui.hooks.use-data-query';\nimport { ComponentID } from '@teambit/component-id';\nimport { ComponentDescriptor } from '@teambit/component-descriptor';\nimport { ComponentModel } from './component-model';\nimport type { ComponentQueryResult, Filters } from './use-component.model';\nimport { GET_COMPONENT } from './use-component.fragments';\nimport { useComponentLogs } from './use-component-logs';\nimport { ComponentError } from './component-error';\n\n/**\n * provides data to component ui page, making sure both variables and return value are safely typed and memoized.\n *\n * Logs are fetched separately and opt-in via `useComponentLogs` (gated by `filters.log`), so views\n * that don't render snap history (lane-compare, bulk panels) don't pay for the expensive logs query.\n */\nexport function useComponentQuery(\n componentId: string,\n host: string,\n filters?: Filters,\n skip?: boolean,\n context?: Record<string, any>\n): ComponentQueryResult {\n const idRef = useRef(componentId);\n idRef.current = componentId;\n const variables = {\n id: componentId,\n extensionId: host,\n };\n\n const { data, error, loading } = useDataQuery(GET_COMPONENT, {\n variables,\n skip,\n errorPolicy: 'all',\n context,\n });\n\n // Only fetch logs when a log filter is explicitly provided — most callers (lane-compare,\n // bulk component panels) never look at history, so the per-component logs query was firing\n // for nothing. Pages that need the history panel pass `filters: { log: {...} }` and\n // `useComponentLogs` runs as before.\n const wantsLogs = !!filters?.log;\n const { loading: loadingLogs, componentLogs: { logs } = {} } = useComponentLogs(\n componentId,\n host,\n filters,\n skip || !wantsLogs,\n context\n );\n\n const rawComponent = data?.getHost?.get;\n\n const idDepKey = rawComponent?.id\n ? `${rawComponent?.id?.scope}/${rawComponent?.id?.name}@${rawComponent?.id?.version}}`\n : undefined;\n\n const id: ComponentID | undefined = useMemo(\n () => (rawComponent ? ComponentID.fromObject(rawComponent.id) : undefined),\n [idDepKey]\n );\n\n const componentError =\n error && !data\n ? new ComponentError(500, error.message)\n : (!rawComponent && !loading && new ComponentError(404)) || undefined;\n\n const component = useMemo(\n () => (rawComponent ? ComponentModel.from({ ...rawComponent, host, logs }) : undefined),\n [id?.toString(), logs]\n );\n\n const componentDescriptor = useMemo(() => {\n const aspectList = {\n entries: rawComponent?.aspects.map((aspectObject) => {\n return {\n ...aspectObject,\n aspectId: aspectObject.id,\n aspectData: aspectObject.data,\n };\n }),\n };\n\n return id ? ComponentDescriptor.fromObject({ id: id.toString(), aspectList }) : undefined;\n }, [id?.toString()]);\n\n return useMemo(() => {\n return {\n componentDescriptor,\n component,\n componentLogs: {\n loading: loadingLogs,\n logs,\n },\n error: componentError || undefined,\n loading,\n };\n }, [host, component, componentDescriptor, componentError]);\n}\n"],"mappings":";;;;;;AAAA,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,MAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,qBAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,oBAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,aAAA;EAAA,MAAAH,IAAA,GAAAC,OAAA;EAAAE,YAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,qBAAA;EAAA,MAAAJ,IAAA,GAAAC,OAAA;EAAAG,oBAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAK,gBAAA;EAAA,MAAAL,IAAA,GAAAC,OAAA;EAAAI,eAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAM,cAAA;EAAA,MAAAN,IAAA,GAAAC,OAAA;EAAAK,aAAA,YAAAA,CAAA;IAAA,OAAAN,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAO,kBAAA;EAAA,MAAAP,IAAA,GAAAC,OAAA;EAAAM,iBAAA,YAAAA,CAAA;IAAA,OAAAP,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAQ,gBAAA;EAAA,MAAAR,IAAA,GAAAC,OAAA;EAAAO,eAAA,YAAAA,CAAA;IAAA,OAAAR,IAAA;EAAA;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,CAAC;IACH,CAAC;IAED,OAAOoD,EAAE,GAAGuC,0CAAmB,CAAChB,UAAU,CAAC;MAAEvB,EAAE,EAAEA,EAAE,CAAC8B,QAAQ,CAAC,CAAC;MAAEE;IAAW,CAAC,CAAC,GAAGZ,SAAS;EAC3F,CAAC,EAAE,CAACpB,EAAE,EAAE8B,QAAQ,CAAC,CAAC,CAAC,CAAC;EAEpB,OAAO,IAAAT,gBAAO,EAAC,MAAM;IACnB,OAAO;MACLU,mBAAmB;MACnBJ,SAAS;MACTjB,aAAa,EAAE;QACbP,OAAO,EAAEM,WAAW;QACpBE;MACF,CAAC;MACDT,KAAK,EAAEsB,cAAc,IAAIJ,SAAS;MAClCjB;IACF,CAAC;EACH,CAAC,EAAE,CAACX,IAAI,EAAEmC,SAAS,EAAEI,mBAAmB,EAAEP,cAAc,CAAC,CAAC;AAC5D","ignoreList":[]}
@@ -23,7 +23,9 @@ const componentOverviewFields = exports.componentOverviewFields = (0, _client().
23
23
  id {
24
24
  ...componentIdFields
25
25
  }
26
- aspects(include: ["teambit.preview/preview", "teambit.envs/envs"]) {
26
+ # dependency-resolver is required by InlineDepsCompare — reads
27
+ # descriptor.get('teambit.dependencies/dependency-resolver').dependencies to compute the diff.
28
+ aspects(include: ["teambit.preview/preview", "teambit.envs/envs", "teambit.dependencies/dependency-resolver"]) {
27
29
  # 'id' property in gql refers to a *global* identifier and used for caching.
28
30
  # this makes aspect data cache under the same key, even when they are under different components.
29
31
  # renaming the property fixes that.
@@ -1 +1 @@
1
- {"version":3,"names":["_client","data","require","componentIdFields","exports","gql","componentOverviewFields","componentFields","componentFieldsWithLogs","COMPONENT_QUERY_LOG_FIELDS","GET_COMPONENT","GET_COMPONENT_WITH_LOGS","SUB_SUBSCRIPTION_ADDED","SUB_COMPONENT_CHANGED","SUB_COMPONENT_REMOVED"],"sources":["use-component.fragments.ts"],"sourcesContent":["import { gql } from '@apollo/client';\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.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 id\n data\n }\n description\n deprecation {\n isDeprecate\n newId\n range\n }\n labels\n displayName\n server {\n id\n env\n url\n host\n basePath\n }\n buildStatus\n env {\n id\n icon\n }\n size {\n compressedTotal\n }\n preview {\n includesEnvTemplate\n legacyHeader\n isScaling\n skipIncludes\n onlyOverview\n useNameParam\n }\n compositions {\n identifier\n displayName\n filepath\n }\n }\n ${componentIdFields}\n`;\n\nexport const componentFields = gql`\n fragment componentFields on Component {\n ...componentOverviewFields\n packageName\n latest\n compositions {\n identifier\n displayName\n }\n tags {\n version\n }\n }\n ${componentOverviewFields}\n`;\n\nexport const componentFieldsWithLogs = gql`\n fragment componentFieldWithLogs on Component {\n id {\n ...componentIdFields\n }\n packageName\n latest\n logs(\n type: $logType\n offset: $logOffset\n limit: $logLimit\n sort: $logSort\n head: $logHead\n takeHeadFromComponent: $logTakeHeadFromComponent\n ) {\n id\n message\n username\n email\n date\n hash\n tag\n displayName\n deprecated\n }\n }\n ${componentIdFields}\n`;\n\nexport const COMPONENT_QUERY_LOG_FIELDS = `\n $logOffset: Int\n $logLimit: Int\n $logType: String\n $logHead: String\n $logSort: String\n $logTakeHeadFromComponent: Boolean\n`;\n\nexport const GET_COMPONENT = gql`\n query Component($extensionId: String!, $id: String!) {\n getHost(id: $extensionId) {\n id # used for GQL caching\n get(id: $id) {\n ...componentFields\n }\n }\n }\n ${componentFields}\n`;\n\nexport const GET_COMPONENT_WITH_LOGS = gql`\n query Component(\n $extensionId: String!\n $id: String!\n ${COMPONENT_QUERY_LOG_FIELDS}\n ) {\n getHost(id: $extensionId) {\n id # used for GQL caching\n get(id: $id) {\n ...componentFieldWithLogs\n }\n }\n }\n ${componentFieldsWithLogs}\n`;\n\nexport const SUB_SUBSCRIPTION_ADDED = gql`\n subscription OnComponentAdded {\n componentAdded {\n component {\n ...componentFields\n }\n }\n }\n ${componentFields}\n`;\n\nexport const SUB_COMPONENT_CHANGED = gql`\n subscription OnComponentChanged {\n componentChanged {\n component {\n ...componentFields\n }\n }\n }\n ${componentFields}\n`;\n\nexport const SUB_COMPONENT_REMOVED = gql`\n subscription OnComponentRemoved {\n componentRemoved {\n componentIds {\n ...componentIdFields\n }\n }\n }\n ${componentIdFields}\n`;\n"],"mappings":";;;;;;AAAA,SAAAA,QAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,OAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEO,MAAME,iBAAiB,GAAAC,OAAA,CAAAD,iBAAA,GAAG,IAAAE,aAAG;AACpC;AACA;AACA;AACA;AACA;AACA,CAAC;AAEM,MAAMC,uBAAuB,GAAAF,OAAA,CAAAE,uBAAA,GAAG,IAAAD,aAAG;AAC1C;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;AACA;AACA,IAAIF,iBAAiB;AACrB,CAAC;AAEM,MAAMI,eAAe,GAAAH,OAAA,CAAAG,eAAA,GAAG,IAAAF,aAAG;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAIC,uBAAuB;AAC3B,CAAC;AAEM,MAAME,uBAAuB,GAAAJ,OAAA,CAAAI,uBAAA,GAAG,IAAAH,aAAG;AAC1C;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,IAAIF,iBAAiB;AACrB,CAAC;AAEM,MAAMM,0BAA0B,GAAAL,OAAA,CAAAK,0BAAA,GAAG;AAC1C;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAEM,MAAMC,aAAa,GAAAN,OAAA,CAAAM,aAAA,GAAG,IAAAL,aAAG;AAChC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAIE,eAAe;AACnB,CAAC;AAEM,MAAMI,uBAAuB,GAAAP,OAAA,CAAAO,uBAAA,GAAG,IAAAN,aAAG;AAC1C;AACA;AACA;AACA,MAAMI,0BAA0B;AAChC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAID,uBAAuB;AAC3B,CAAC;AAEM,MAAMI,sBAAsB,GAAAR,OAAA,CAAAQ,sBAAA,GAAG,IAAAP,aAAG;AACzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAIE,eAAe;AACnB,CAAC;AAEM,MAAMM,qBAAqB,GAAAT,OAAA,CAAAS,qBAAA,GAAG,IAAAR,aAAG;AACxC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAIE,eAAe;AACnB,CAAC;AAEM,MAAMO,qBAAqB,GAAAV,OAAA,CAAAU,qBAAA,GAAG,IAAAT,aAAG;AACxC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAIF,iBAAiB;AACrB,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["_client","data","require","componentIdFields","exports","gql","componentOverviewFields","componentFields","componentFieldsWithLogs","COMPONENT_QUERY_LOG_FIELDS","GET_COMPONENT","GET_COMPONENT_WITH_LOGS","SUB_SUBSCRIPTION_ADDED","SUB_COMPONENT_CHANGED","SUB_COMPONENT_REMOVED"],"sources":["use-component.fragments.ts"],"sourcesContent":["import { gql } from '@apollo/client';\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 # dependency-resolver is required by InlineDepsCompare — reads\n # descriptor.get('teambit.dependencies/dependency-resolver').dependencies to compute the diff.\n aspects(include: [\"teambit.preview/preview\", \"teambit.envs/envs\", \"teambit.dependencies/dependency-resolver\"]) {\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 id\n data\n }\n description\n deprecation {\n isDeprecate\n newId\n range\n }\n labels\n displayName\n server {\n id\n env\n url\n host\n basePath\n }\n buildStatus\n env {\n id\n icon\n }\n size {\n compressedTotal\n }\n preview {\n includesEnvTemplate\n legacyHeader\n isScaling\n skipIncludes\n onlyOverview\n useNameParam\n }\n compositions {\n identifier\n displayName\n filepath\n }\n }\n ${componentIdFields}\n`;\n\nexport const componentFields = gql`\n fragment componentFields on Component {\n ...componentOverviewFields\n packageName\n latest\n compositions {\n identifier\n displayName\n }\n tags {\n version\n }\n }\n ${componentOverviewFields}\n`;\n\nexport const componentFieldsWithLogs = gql`\n fragment componentFieldWithLogs on Component {\n id {\n ...componentIdFields\n }\n packageName\n latest\n logs(\n type: $logType\n offset: $logOffset\n limit: $logLimit\n sort: $logSort\n head: $logHead\n takeHeadFromComponent: $logTakeHeadFromComponent\n ) {\n id\n message\n username\n email\n date\n hash\n tag\n displayName\n deprecated\n }\n }\n ${componentIdFields}\n`;\n\nexport const COMPONENT_QUERY_LOG_FIELDS = `\n $logOffset: Int\n $logLimit: Int\n $logType: String\n $logHead: String\n $logSort: String\n $logTakeHeadFromComponent: Boolean\n`;\n\nexport const GET_COMPONENT = gql`\n query Component($extensionId: String!, $id: String!) {\n getHost(id: $extensionId) {\n id # used for GQL caching\n get(id: $id) {\n ...componentFields\n }\n }\n }\n ${componentFields}\n`;\n\nexport const GET_COMPONENT_WITH_LOGS = gql`\n query Component(\n $extensionId: String!\n $id: String!\n ${COMPONENT_QUERY_LOG_FIELDS}\n ) {\n getHost(id: $extensionId) {\n id # used for GQL caching\n get(id: $id) {\n ...componentFieldWithLogs\n }\n }\n }\n ${componentFieldsWithLogs}\n`;\n\nexport const SUB_SUBSCRIPTION_ADDED = gql`\n subscription OnComponentAdded {\n componentAdded {\n component {\n ...componentFields\n }\n }\n }\n ${componentFields}\n`;\n\nexport const SUB_COMPONENT_CHANGED = gql`\n subscription OnComponentChanged {\n componentChanged {\n component {\n ...componentFields\n }\n }\n }\n ${componentFields}\n`;\n\nexport const SUB_COMPONENT_REMOVED = gql`\n subscription OnComponentRemoved {\n componentRemoved {\n componentIds {\n ...componentIdFields\n }\n }\n }\n ${componentIdFields}\n`;\n"],"mappings":";;;;;;AAAA,SAAAA,QAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,OAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEO,MAAME,iBAAiB,GAAAC,OAAA,CAAAD,iBAAA,GAAG,IAAAE,aAAG;AACpC;AACA;AACA;AACA;AACA;AACA,CAAC;AAEM,MAAMC,uBAAuB,GAAAF,OAAA,CAAAE,uBAAA,GAAG,IAAAD,aAAG;AAC1C;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;AACA;AACA;AACA;AACA,IAAIF,iBAAiB;AACrB,CAAC;AAEM,MAAMI,eAAe,GAAAH,OAAA,CAAAG,eAAA,GAAG,IAAAF,aAAG;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAIC,uBAAuB;AAC3B,CAAC;AAEM,MAAME,uBAAuB,GAAAJ,OAAA,CAAAI,uBAAA,GAAG,IAAAH,aAAG;AAC1C;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,IAAIF,iBAAiB;AACrB,CAAC;AAEM,MAAMM,0BAA0B,GAAAL,OAAA,CAAAK,0BAAA,GAAG;AAC1C;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAEM,MAAMC,aAAa,GAAAN,OAAA,CAAAM,aAAA,GAAG,IAAAL,aAAG;AAChC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAIE,eAAe;AACnB,CAAC;AAEM,MAAMI,uBAAuB,GAAAP,OAAA,CAAAO,uBAAA,GAAG,IAAAN,aAAG;AAC1C;AACA;AACA;AACA,MAAMI,0BAA0B;AAChC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAID,uBAAuB;AAC3B,CAAC;AAEM,MAAMI,sBAAsB,GAAAR,OAAA,CAAAQ,sBAAA,GAAG,IAAAP,aAAG;AACzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAIE,eAAe;AACnB,CAAC;AAEM,MAAMM,qBAAqB,GAAAT,OAAA,CAAAS,qBAAA,GAAG,IAAAR,aAAG;AACxC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAIE,eAAe;AACnB,CAAC;AAEM,MAAMO,qBAAqB,GAAAV,OAAA,CAAAU,qBAAA,GAAG,IAAAT,aAAG;AACxC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAIF,iBAAiB;AACrB,CAAC","ignoreList":[]}
@@ -43,12 +43,13 @@ function useComponent(host, id, options) {
43
43
  version,
44
44
  logFilters,
45
45
  customUseComponent,
46
- skip
46
+ skip,
47
+ context
47
48
  } = options || {};
48
49
  const componentVersion = (version || query.get('version')) ?? undefined;
49
50
  const componentIdStr = id && withVersion(id, componentVersion);
50
51
  const targetUseComponent = customUseComponent || _useComponentQuery().useComponentQuery;
51
- return targetUseComponent(componentIdStr || '', host, logFilters, skip || !id);
52
+ return targetUseComponent(componentIdStr || '', host, logFilters, skip || !id, context);
52
53
  }
53
54
  function withVersion(id, version) {
54
55
  if (!version) return id;
@@ -1 +1 @@
1
- {"version":3,"names":["_uiFoundationUiReactRouter","data","require","_useComponentQuery","_useComponent","useComponent","host","id","options","query","useQuery","version","logFilters","customUseComponent","skip","componentVersion","get","undefined","componentIdStr","withVersion","targetUseComponent","useComponentQuery","includes"],"sources":["use-component.tsx"],"sourcesContent":["import { useQuery } from '@teambit/ui-foundation.ui.react-router.use-query';\nimport { useComponentQuery } from './use-component-query';\nimport type { ComponentQueryResult, UseComponentOptions } from './use-component.model';\nimport { UseComponentType, Filters } from './use-component.model';\n\nexport { UseComponentType, Filters };\n\nexport function useComponent(host: string, id?: string, options?: UseComponentOptions): ComponentQueryResult {\n const query = useQuery();\n const { version, logFilters, customUseComponent, skip } = options || {};\n const componentVersion = (version || query.get('version')) ?? undefined;\n\n const componentIdStr = id && withVersion(id, componentVersion);\n const targetUseComponent = customUseComponent || useComponentQuery;\n\n return targetUseComponent(componentIdStr || '', host, logFilters, skip || !id);\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"],"mappings":";;;;;;;;;;;;;;;;;;AAAA,SAAAA,2BAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,0BAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,mBAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,kBAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAG,cAAA;EAAA,MAAAH,IAAA,GAAAC,OAAA;EAAAE,aAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAIO,SAASI,YAAYA,CAACC,IAAY,EAAEC,EAAW,EAAEC,OAA6B,EAAwB;EAC3G,MAAMC,KAAK,GAAG,IAAAC,qCAAQ,EAAC,CAAC;EACxB,MAAM;IAAEC,OAAO;IAAEC,UAAU;IAAEC,kBAAkB;IAAEC;EAAK,CAAC,GAAGN,OAAO,IAAI,CAAC,CAAC;EACvE,MAAMO,gBAAgB,GAAG,CAACJ,OAAO,IAAIF,KAAK,CAACO,GAAG,CAAC,SAAS,CAAC,KAAKC,SAAS;EAEvE,MAAMC,cAAc,GAAGX,EAAE,IAAIY,WAAW,CAACZ,EAAE,EAAEQ,gBAAgB,CAAC;EAC9D,MAAMK,kBAAkB,GAAGP,kBAAkB,IAAIQ,sCAAiB;EAElE,OAAOD,kBAAkB,CAACF,cAAc,IAAI,EAAE,EAAEZ,IAAI,EAAEM,UAAU,EAAEE,IAAI,IAAI,CAACP,EAAE,CAAC;AAChF;AAEA,SAASY,WAAWA,CAACZ,EAAU,EAAEI,OAAgB,EAAE;EACjD,IAAI,CAACA,OAAO,EAAE,OAAOJ,EAAE;EACvB,IAAIA,EAAE,CAACe,QAAQ,CAAC,GAAG,CAAC,EAAE,OAAOf,EAAE;EAC/B,OAAO,GAAGA,EAAE,IAAII,OAAO,EAAE;AAC3B","ignoreList":[]}
1
+ {"version":3,"names":["_uiFoundationUiReactRouter","data","require","_useComponentQuery","_useComponent","useComponent","host","id","options","query","useQuery","version","logFilters","customUseComponent","skip","context","componentVersion","get","undefined","componentIdStr","withVersion","targetUseComponent","useComponentQuery","includes"],"sources":["use-component.tsx"],"sourcesContent":["import { useQuery } from '@teambit/ui-foundation.ui.react-router.use-query';\nimport { useComponentQuery } from './use-component-query';\nimport type { ComponentQueryResult, UseComponentOptions } from './use-component.model';\nimport { UseComponentType, Filters } from './use-component.model';\n\nexport { UseComponentType, Filters };\n\nexport function useComponent(host: string, id?: string, options?: UseComponentOptions): ComponentQueryResult {\n const query = useQuery();\n const { version, logFilters, customUseComponent, skip, context } = options || {};\n const componentVersion = (version || query.get('version')) ?? undefined;\n\n const componentIdStr = id && withVersion(id, componentVersion);\n const targetUseComponent = customUseComponent || useComponentQuery;\n\n return targetUseComponent(componentIdStr || '', host, logFilters, skip || !id, context);\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"],"mappings":";;;;;;;;;;;;;;;;;;AAAA,SAAAA,2BAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,0BAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,mBAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,kBAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAG,cAAA;EAAA,MAAAH,IAAA,GAAAC,OAAA;EAAAE,aAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAIO,SAASI,YAAYA,CAACC,IAAY,EAAEC,EAAW,EAAEC,OAA6B,EAAwB;EAC3G,MAAMC,KAAK,GAAG,IAAAC,qCAAQ,EAAC,CAAC;EACxB,MAAM;IAAEC,OAAO;IAAEC,UAAU;IAAEC,kBAAkB;IAAEC,IAAI;IAAEC;EAAQ,CAAC,GAAGP,OAAO,IAAI,CAAC,CAAC;EAChF,MAAMQ,gBAAgB,GAAG,CAACL,OAAO,IAAIF,KAAK,CAACQ,GAAG,CAAC,SAAS,CAAC,KAAKC,SAAS;EAEvE,MAAMC,cAAc,GAAGZ,EAAE,IAAIa,WAAW,CAACb,EAAE,EAAES,gBAAgB,CAAC;EAC9D,MAAMK,kBAAkB,GAAGR,kBAAkB,IAAIS,sCAAiB;EAElE,OAAOD,kBAAkB,CAACF,cAAc,IAAI,EAAE,EAAEb,IAAI,EAAEM,UAAU,EAAEE,IAAI,IAAI,CAACP,EAAE,EAAEQ,OAAO,CAAC;AACzF;AAEA,SAASK,WAAWA,CAACb,EAAU,EAAEI,OAAgB,EAAE;EACjD,IAAI,CAACA,OAAO,EAAE,OAAOJ,EAAE;EACvB,IAAIA,EAAE,CAACgB,QAAQ,CAAC,GAAG,CAAC,EAAE,OAAOhB,EAAE;EAC/B,OAAO,GAAGA,EAAE,IAAII,OAAO,EAAE;AAC3B","ignoreList":[]}
@@ -21,6 +21,8 @@ export type UseComponentOptions = {
21
21
  logFilters?: Filters;
22
22
  customUseComponent?: UseComponentType;
23
23
  skip?: boolean;
24
+ /** apollo operation context forwarded to the underlying queries (e.g. `{ batch: true }`) */
25
+ context?: Record<string, any>;
24
26
  };
25
27
  export type ComponentQueryResult = {
26
28
  component?: ComponentModel;
@@ -41,4 +43,4 @@ export type ComponentLogs = {
41
43
  logs?: LegacyComponentLog[];
42
44
  loading?: boolean;
43
45
  };
44
- export type UseComponentType = (id: string, host: string, filters?: Filters, skip?: boolean) => ComponentQueryResult;
46
+ export type UseComponentType = (id: string, host: string, filters?: Filters, skip?: boolean, context?: Record<string, any>) => ComponentQueryResult;
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["use-component.model.ts"],"sourcesContent":["import type { ComponentDescriptor } from '@teambit/component-descriptor';\nimport type { LegacyComponentLog } from '@teambit/legacy-component-log';\nimport type { ComponentID } from '../';\nimport type { ComponentError } from './component-error';\nimport type { ComponentModel } from './component-model';\n\nexport type LogFilter = {\n offset?: number;\n limit?: number;\n head?: string;\n sort?: string;\n takeHeadFromComponent?: boolean;\n};\n\nexport type Filters = {\n log?: LogFilter & { type?: string };\n loading?: boolean;\n};\n\nexport type UseComponentOptions = {\n version?: string;\n logFilters?: Filters;\n customUseComponent?: UseComponentType;\n skip?: boolean;\n};\n\nexport type ComponentQueryResult = {\n component?: ComponentModel;\n componentDescriptor?: ComponentDescriptor;\n componentLogs?: ComponentLogs;\n loading?: boolean;\n error?: ComponentError;\n};\n\nexport type ComponentLogsResult = {\n id?: ComponentID;\n componentLogs?: ComponentLogs;\n latest?: string;\n packageName?: string;\n error?: ComponentError;\n loading?: boolean;\n};\n\nexport type ComponentLogs = {\n logs?: LegacyComponentLog[];\n loading?: boolean;\n};\n\nexport type UseComponentType = (id: string, host: string, filters?: Filters, skip?: boolean) => ComponentQueryResult;\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"names":[],"sources":["use-component.model.ts"],"sourcesContent":["import type { ComponentDescriptor } from '@teambit/component-descriptor';\nimport type { LegacyComponentLog } from '@teambit/legacy-component-log';\nimport type { ComponentID } from '../';\nimport type { ComponentError } from './component-error';\nimport type { ComponentModel } from './component-model';\n\nexport type LogFilter = {\n offset?: number;\n limit?: number;\n head?: string;\n sort?: string;\n takeHeadFromComponent?: boolean;\n};\n\nexport type Filters = {\n log?: LogFilter & { type?: string };\n loading?: boolean;\n};\n\nexport type UseComponentOptions = {\n version?: string;\n logFilters?: Filters;\n customUseComponent?: UseComponentType;\n skip?: boolean;\n /** apollo operation context forwarded to the underlying queries (e.g. `{ batch: true }`) */\n context?: Record<string, any>;\n};\n\nexport type ComponentQueryResult = {\n component?: ComponentModel;\n componentDescriptor?: ComponentDescriptor;\n componentLogs?: ComponentLogs;\n loading?: boolean;\n error?: ComponentError;\n};\n\nexport type ComponentLogsResult = {\n id?: ComponentID;\n componentLogs?: ComponentLogs;\n latest?: string;\n packageName?: string;\n error?: ComponentError;\n loading?: boolean;\n};\n\nexport type ComponentLogs = {\n logs?: LegacyComponentLog[];\n loading?: boolean;\n};\n\nexport type UseComponentType = (\n id: string,\n host: string,\n filters?: Filters,\n skip?: boolean,\n context?: Record<string, any>\n) => ComponentQueryResult;\n"],"mappings":"","ignoreList":[]}
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@teambit/component",
3
- "version": "1.0.1079",
3
+ "version": "1.0.1081",
4
4
  "homepage": "https://bit.cloud/teambit/component/component",
5
5
  "main": "dist/index.js",
6
6
  "componentId": {
7
7
  "scope": "teambit.component",
8
8
  "name": "component",
9
- "version": "1.0.1079"
9
+ "version": "1.0.1081"
10
10
  },
11
11
  "dependencies": {
12
12
  "@teambit/any-fs": "0.0.5",
@@ -28,70 +28,70 @@
28
28
  "@teambit/ui-foundation.ui.menu-widget-icon": "0.0.502",
29
29
  "@teambit/graph.cleargraph": "0.0.11",
30
30
  "@teambit/legacy-bit-id": "1.1.3",
31
+ "@teambit/toolbox.path.match-patterns": "0.0.32",
32
+ "@teambit/toolbox.string.eol": "0.0.18",
33
+ "@teambit/toolbox.string.capitalize": "0.0.513",
31
34
  "@teambit/harmony": "0.4.12",
35
+ "@teambit/toolbox.path.path": "0.0.21",
32
36
  "@teambit/bit-error": "0.0.404",
37
+ "@teambit/component.ui.deprecation-icon": "0.0.509",
33
38
  "@teambit/ui-foundation.ui.is-browser": "0.0.500",
34
39
  "@teambit/ui-foundation.ui.main-dropdown": "0.0.505",
35
40
  "@teambit/ui-foundation.ui.react-router.slot-router": "0.0.527",
36
- "@teambit/component.ui.deprecation-icon": "0.0.509",
37
41
  "@teambit/ui-foundation.ui.use-box.menu": "1.0.16",
38
- "@teambit/ui-foundation.ui.hooks.use-data-query": "0.0.506",
39
42
  "@teambit/ui-foundation.ui.react-router.use-query": "0.0.505",
43
+ "@teambit/design.ui.empty-box": "0.0.364",
40
44
  "@teambit/documenter.ui.heading": "4.1.8",
41
45
  "@teambit/documenter.ui.separator": "4.1.7",
42
46
  "@teambit/harmony.ui.aspect-box": "0.0.511",
43
- "@teambit/design.ui.empty-box": "0.0.364",
44
47
  "@teambit/design.ui.pages.not-found": "0.0.371",
45
48
  "@teambit/design.ui.pages.server-error": "0.0.368",
46
49
  "@teambit/design.ui.styles.ellipsis": "0.0.357",
47
50
  "@teambit/envs.ui.env-icon": "0.0.508",
48
51
  "@teambit/explorer.ui.command-bar": "2.0.19",
49
- "@teambit/workspace.ui.use-workspace-mode": "0.0.3",
50
52
  "@teambit/design.navigation.responsive-navbar": "0.0.8",
53
+ "@teambit/workspace.ui.use-workspace-mode": "0.0.3",
51
54
  "@teambit/base-ui.layout.breakpoints": "1.0.0",
52
- "@teambit/lanes.hooks.use-lanes": "0.0.293",
53
55
  "@teambit/lanes.ui.models.lanes-model": "0.0.233",
54
56
  "@teambit/ui-foundation.ui.use-box.dropdown": "0.0.151",
55
- "@teambit/legacy.extension-data": "0.0.142",
56
- "@teambit/aspect-loader": "1.0.1079",
57
- "@teambit/dependency-resolver": "1.0.1079",
58
- "@teambit/legacy.consumer-component": "0.0.141",
59
- "@teambit/objects": "0.0.586",
60
- "@teambit/component.sources": "0.0.192",
61
- "@teambit/toolbox.path.match-patterns": "0.0.32",
62
- "@teambit/toolbox.string.eol": "0.0.18",
63
- "@teambit/toolbox.string.capitalize": "0.0.513",
64
- "@teambit/graphql": "1.0.1079",
65
- "@teambit/toolbox.path.path": "0.0.21",
66
- "@teambit/cli": "0.0.1357",
67
- "@teambit/express": "0.0.1456",
68
- "@teambit/logger": "0.0.1450",
69
- "@teambit/legacy.constants": "0.0.37",
70
- "@teambit/command-bar": "1.0.1079",
71
- "@teambit/component-package-version": "0.0.457",
72
- "@teambit/preview": "1.0.1079",
73
- "@teambit/pubsub": "1.0.1079",
74
- "@teambit/react-router": "1.0.1079",
75
- "@teambit/ui": "1.0.1079",
76
- "@teambit/legacy.utils": "0.0.45",
77
- "@teambit/component-issues": "0.0.180",
78
- "@teambit/pkg.modules.semver-helper": "0.0.30",
79
- "@teambit/cli-table": "0.0.57",
80
- "@teambit/legacy.bit-map": "0.0.197",
81
- "@teambit/pkg.modules.component-package-name": "0.0.147",
82
- "@teambit/legacy-component-log": "0.0.425",
83
- "@teambit/component-descriptor": "0.0.458",
84
- "@teambit/semantics.doc-parser": "0.0.148",
85
- "@teambit/legacy.consumer": "0.0.140",
86
- "@teambit/legacy.dependency-graph": "0.0.143",
87
- "@teambit/legacy.loader": "0.0.26",
88
- "@teambit/legacy.scope": "0.0.140",
89
- "@teambit/scope.remotes": "0.0.140",
90
- "@teambit/legacy.component-diff": "0.0.196",
91
- "@teambit/compositions": "1.0.1079",
92
- "@teambit/deprecation": "1.0.1079",
93
- "@teambit/envs": "1.0.1079",
94
- "@teambit/component.ui.version-dropdown": "0.0.933"
57
+ "@teambit/legacy.extension-data": "0.0.143",
58
+ "@teambit/aspect-loader": "1.0.1081",
59
+ "@teambit/dependency-resolver": "1.0.1081",
60
+ "@teambit/legacy.consumer-component": "0.0.142",
61
+ "@teambit/objects": "0.0.588",
62
+ "@teambit/component.sources": "0.0.193",
63
+ "@teambit/graphql": "1.0.1081",
64
+ "@teambit/cli": "0.0.1358",
65
+ "@teambit/express": "0.0.1457",
66
+ "@teambit/logger": "0.0.1451",
67
+ "@teambit/legacy.constants": "0.0.38",
68
+ "@teambit/command-bar": "1.0.1081",
69
+ "@teambit/component-package-version": "0.0.458",
70
+ "@teambit/preview": "1.0.1081",
71
+ "@teambit/pubsub": "1.0.1081",
72
+ "@teambit/react-router": "1.0.1081",
73
+ "@teambit/ui": "1.0.1081",
74
+ "@teambit/legacy.utils": "0.0.46",
75
+ "@teambit/component-issues": "0.0.181",
76
+ "@teambit/pkg.modules.semver-helper": "0.0.31",
77
+ "@teambit/ui-foundation.ui.hooks.use-data-query": "0.0.507",
78
+ "@teambit/cli-table": "0.0.58",
79
+ "@teambit/legacy.bit-map": "0.0.198",
80
+ "@teambit/pkg.modules.component-package-name": "0.0.148",
81
+ "@teambit/legacy-component-log": "0.0.426",
82
+ "@teambit/component-descriptor": "0.0.459",
83
+ "@teambit/semantics.doc-parser": "0.0.149",
84
+ "@teambit/legacy.consumer": "0.0.141",
85
+ "@teambit/legacy.dependency-graph": "0.0.144",
86
+ "@teambit/legacy.loader": "0.0.27",
87
+ "@teambit/legacy.scope": "0.0.141",
88
+ "@teambit/scope.remotes": "0.0.141",
89
+ "@teambit/legacy.component-diff": "0.0.197",
90
+ "@teambit/compositions": "1.0.1081",
91
+ "@teambit/deprecation": "1.0.1081",
92
+ "@teambit/envs": "1.0.1081",
93
+ "@teambit/component.ui.version-dropdown": "0.0.934",
94
+ "@teambit/lanes.hooks.use-lanes": "0.0.294"
95
95
  },
96
96
  "devDependencies": {
97
97
  "@types/lodash": "4.14.165",
@@ -102,7 +102,7 @@
102
102
  "@types/lodash.compact": "3.0.6",
103
103
  "@types/mocha": "9.1.0",
104
104
  "@teambit/component.content.component-overview": "1.96.10",
105
- "@teambit/harmony.envs.core-aspect-env": "2.0.4"
105
+ "@teambit/harmony.envs.core-aspect-env": "2.0.3"
106
106
  },
107
107
  "peerDependencies": {
108
108
  "@apollo/client": "^3.12.0",
@@ -96,8 +96,15 @@
96
96
  }
97
97
  }
98
98
 
99
+ // The component top bar packs left-side nav (Overview, Code, Tests, Preview …) and right-side
100
+ // dropdowns (Use package, Versions, Workspace) on the same row. Below `$br-lg` the right side
101
+ // takes so much horizontal space that the ResponsiveNavbar collapses every nav tab into the
102
+ // overflow "more" dropdown — which is what produces the "…" the user sees instead of tabs.
103
+ // Hiding the Use-package dropdown earlier (at < lg, not < md) reclaims the room so the nav
104
+ // stays visible on tablet viewports too. Users on mobile can still copy the install command
105
+ // from the dedicated "Use package" panel that the docs overview renders inline.
99
106
  .hideOnMobile {
100
- @media screen and (max-width: $br-md) {
107
+ @media screen and (max-width: $br-lg) {
101
108
  display: none;
102
109
  }
103
110
  }
@@ -105,4 +112,13 @@
105
112
  .useBoxContainer {
106
113
  width: 500px !important;
107
114
  border: 1px solid var(--border-medium-color, #ededed);
115
+
116
+ // Mobile: cap to viewport width, drop fixed pixel width, scroll horizontally if a tab title
117
+ // (or the install snippet) is wider. Without this the 500px container overflows past the
118
+ // viewport edge, which is why the second consume-method tab and the package-name snippet were
119
+ // both truncating to "…".
120
+ @media screen and (max-width: $br-md) {
121
+ width: calc(100vw - 24px) !important;
122
+ max-width: 500px;
123
+ }
108
124
  }
@@ -11,7 +11,8 @@ export function useComponentLogs(
11
11
  componentId: string,
12
12
  host: string,
13
13
  filters?: Filters,
14
- skipFromProps?: boolean
14
+ skipFromProps?: boolean,
15
+ context?: Record<string, any>
15
16
  ): ComponentLogsResult {
16
17
  const { variables, skip } = useComponentLogsInit(componentId, host, filters, skipFromProps);
17
18
 
@@ -19,6 +20,7 @@ export function useComponentLogs(
19
20
  variables,
20
21
  skip,
21
22
  errorPolicy: 'all',
23
+ context,
22
24
  });
23
25
 
24
26
  const rawComponent = data?.getHost?.get;
@@ -8,12 +8,18 @@ import { GET_COMPONENT } from './use-component.fragments';
8
8
  import { useComponentLogs } from './use-component-logs';
9
9
  import { ComponentError } from './component-error';
10
10
 
11
- /** provides data to component ui page, making sure both variables and return value are safely typed and memoized */
11
+ /**
12
+ * provides data to component ui page, making sure both variables and return value are safely typed and memoized.
13
+ *
14
+ * Logs are fetched separately and opt-in via `useComponentLogs` (gated by `filters.log`), so views
15
+ * that don't render snap history (lane-compare, bulk panels) don't pay for the expensive logs query.
16
+ */
12
17
  export function useComponentQuery(
13
18
  componentId: string,
14
19
  host: string,
15
20
  filters?: Filters,
16
- skip?: boolean
21
+ skip?: boolean,
22
+ context?: Record<string, any>
17
23
  ): ComponentQueryResult {
18
24
  const idRef = useRef(componentId);
19
25
  idRef.current = componentId;
@@ -26,9 +32,21 @@ export function useComponentQuery(
26
32
  variables,
27
33
  skip,
28
34
  errorPolicy: 'all',
35
+ context,
29
36
  });
30
37
 
31
- const { loading: loadingLogs, componentLogs: { logs } = {} } = useComponentLogs(componentId, host, filters, skip);
38
+ // Only fetch logs when a log filter is explicitly provided most callers (lane-compare,
39
+ // bulk component panels) never look at history, so the per-component logs query was firing
40
+ // for nothing. Pages that need the history panel pass `filters: { log: {...} }` and
41
+ // `useComponentLogs` runs as before.
42
+ const wantsLogs = !!filters?.log;
43
+ const { loading: loadingLogs, componentLogs: { logs } = {} } = useComponentLogs(
44
+ componentId,
45
+ host,
46
+ filters,
47
+ skip || !wantsLogs,
48
+ context
49
+ );
32
50
 
33
51
  const rawComponent = data?.getHost?.get;
34
52
 
@@ -13,7 +13,9 @@ export const componentOverviewFields = gql`
13
13
  id {
14
14
  ...componentIdFields
15
15
  }
16
- aspects(include: ["teambit.preview/preview", "teambit.envs/envs"]) {
16
+ # dependency-resolver is required by InlineDepsCompare — reads
17
+ # descriptor.get('teambit.dependencies/dependency-resolver').dependencies to compute the diff.
18
+ aspects(include: ["teambit.preview/preview", "teambit.envs/envs", "teambit.dependencies/dependency-resolver"]) {
17
19
  # 'id' property in gql refers to a *global* identifier and used for caching.
18
20
  # this makes aspect data cache under the same key, even when they are under different components.
19
21
  # renaming the property fixes that.
@@ -22,6 +22,8 @@ export type UseComponentOptions = {
22
22
  logFilters?: Filters;
23
23
  customUseComponent?: UseComponentType;
24
24
  skip?: boolean;
25
+ /** apollo operation context forwarded to the underlying queries (e.g. `{ batch: true }`) */
26
+ context?: Record<string, any>;
25
27
  };
26
28
 
27
29
  export type ComponentQueryResult = {
@@ -46,4 +48,10 @@ export type ComponentLogs = {
46
48
  loading?: boolean;
47
49
  };
48
50
 
49
- export type UseComponentType = (id: string, host: string, filters?: Filters, skip?: boolean) => ComponentQueryResult;
51
+ export type UseComponentType = (
52
+ id: string,
53
+ host: string,
54
+ filters?: Filters,
55
+ skip?: boolean,
56
+ context?: Record<string, any>
57
+ ) => ComponentQueryResult;
@@ -7,13 +7,13 @@ export { UseComponentType, Filters };
7
7
 
8
8
  export function useComponent(host: string, id?: string, options?: UseComponentOptions): ComponentQueryResult {
9
9
  const query = useQuery();
10
- const { version, logFilters, customUseComponent, skip } = options || {};
10
+ const { version, logFilters, customUseComponent, skip, context } = options || {};
11
11
  const componentVersion = (version || query.get('version')) ?? undefined;
12
12
 
13
13
  const componentIdStr = id && withVersion(id, componentVersion);
14
14
  const targetUseComponent = customUseComponent || useComponentQuery;
15
15
 
16
- return targetUseComponent(componentIdStr || '', host, logFilters, skip || !id);
16
+ return targetUseComponent(componentIdStr || '', host, logFilters, skip || !id, context);
17
17
  }
18
18
 
19
19
  function withVersion(id: string, version?: string) {