@teambit/code 0.0.878 → 0.0.880

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.
@@ -1,7 +1,7 @@
1
1
  import { ComponentAspect, ComponentUI } from '@teambit/component';
2
2
  import { UIRuntime } from '@teambit/ui';
3
3
  import React from 'react';
4
- import { SlotRegistry, Slot } from '@teambit/harmony';
4
+ import { Harmony, SlotRegistry, Slot } from '@teambit/harmony';
5
5
  import type { FileIconMatch } from '@teambit/code.ui.utils.get-file-icon';
6
6
  import { staticStorageUrl } from '@teambit/base-ui.constants.storage';
7
7
  import { CodePage } from '@teambit/code.ui.code-tab-page';
@@ -23,11 +23,12 @@ export class CodeUI {
23
23
  /**
24
24
  * register an icon for a specific file type. pass icon and a match method/regexp
25
25
  */
26
+ private host: string,
26
27
  private fileIconSlot?: FileIconSlot
27
28
  ) {}
28
29
 
29
30
  getCodePage = () => {
30
- return <CodePage fileIconSlot={this.fileIconSlot} />;
31
+ return <CodePage fileIconSlot={this.fileIconSlot} host={this.host} />;
31
32
  };
32
33
 
33
34
  registerEnvFileIcon(icons: FileIconMatch[]) {
@@ -42,10 +43,13 @@ export class CodeUI {
42
43
 
43
44
  static async provider(
44
45
  [component, componentCompare]: [ComponentUI, ComponentCompareUI],
45
- config,
46
- [fileIconSlot]: [FileIconSlot]
46
+ _,
47
+ [fileIconSlot]: [FileIconSlot],
48
+ harmony: Harmony
47
49
  ) {
48
- const ui = new CodeUI(fileIconSlot);
50
+ const { config } = harmony;
51
+ const host = String(config.get('teambit.harmony/bit'));
52
+ const ui = new CodeUI(host, fileIconSlot);
49
53
  const section = new CodeSection(ui);
50
54
  // overrides the default tsx react icon with the typescript icon
51
55
  ui.registerEnvFileIcon([
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import { ComponentUI } from '@teambit/component';
3
- import { SlotRegistry } from '@teambit/harmony';
3
+ import { Harmony, SlotRegistry } from '@teambit/harmony';
4
4
  import type { FileIconMatch } from '@teambit/code.ui.utils.get-file-icon';
5
5
  import { ComponentCompareUI } from '@teambit/component-compare';
6
6
  export declare type FileIconSlot = SlotRegistry<FileIconMatch[]>;
@@ -12,16 +12,17 @@ export declare class CodeUI {
12
12
  /**
13
13
  * register an icon for a specific file type. pass icon and a match method/regexp
14
14
  */
15
+ private host;
15
16
  private fileIconSlot?;
16
17
  constructor(
17
18
  /**
18
19
  * register an icon for a specific file type. pass icon and a match method/regexp
19
20
  */
20
- fileIconSlot?: FileIconSlot | undefined);
21
+ host: string, fileIconSlot?: FileIconSlot | undefined);
21
22
  getCodePage: () => JSX.Element;
22
23
  registerEnvFileIcon(icons: FileIconMatch[]): this;
23
24
  static dependencies: import("@teambit/harmony").Aspect[];
24
25
  static runtime: import("@teambit/harmony").RuntimeDefinition;
25
26
  static slots: ((registerFn: () => string) => SlotRegistry<string>)[];
26
- static provider([component, componentCompare]: [ComponentUI, ComponentCompareUI], config: any, [fileIconSlot]: [FileIconSlot]): Promise<CodeUI>;
27
+ static provider([component, componentCompare]: [ComponentUI, ComponentCompareUI], _: any, [fileIconSlot]: [FileIconSlot], harmony: Harmony): Promise<CodeUI>;
27
28
  }
@@ -132,11 +132,13 @@ class CodeUI {
132
132
  /**
133
133
  * register an icon for a specific file type. pass icon and a match method/regexp
134
134
  */
135
- fileIconSlot) {
135
+ host, fileIconSlot) {
136
+ this.host = host;
136
137
  this.fileIconSlot = fileIconSlot;
137
138
  (0, _defineProperty2().default)(this, "getCodePage", () => {
138
139
  return /*#__PURE__*/_react().default.createElement(_codeUi().CodePage, {
139
- fileIconSlot: this.fileIconSlot
140
+ fileIconSlot: this.fileIconSlot,
141
+ host: this.host
140
142
  });
141
143
  });
142
144
  }
@@ -148,8 +150,12 @@ class CodeUI {
148
150
  return this;
149
151
  }
150
152
 
151
- static async provider([component, componentCompare], config, [fileIconSlot]) {
152
- const ui = new CodeUI(fileIconSlot);
153
+ static async provider([component, componentCompare], _, [fileIconSlot], harmony) {
154
+ const {
155
+ config
156
+ } = harmony;
157
+ const host = String(config.get('teambit.harmony/bit'));
158
+ const ui = new CodeUI(host, fileIconSlot);
153
159
  const section = new (_code2().CodeSection)(ui); // overrides the default tsx react icon with the typescript icon
154
160
 
155
161
  ui.registerEnvFileIcon([fileName => isTsx.test(fileName) ? `${_baseUiConstants().staticStorageUrl}/file-icons/file_type_typescript.svg` : undefined]);
@@ -1 +1 @@
1
- {"version":3,"names":["isTsx","CodeUI","constructor","fileIconSlot","registerEnvFileIcon","icons","register","provider","component","componentCompare","config","ui","section","CodeSection","fileName","test","staticStorageUrl","undefined","registerRoute","route","registerWidget","navigationLink","order","codeCompare","CodeCompareSection","registerNavigation","props","registerRoutes","ComponentAspect","ComponentCompareAspect","UIRuntime","Slot","withType","CodeAspect","addRuntime"],"sources":["code.ui.runtime.tsx"],"sourcesContent":["import { ComponentAspect, ComponentUI } from '@teambit/component';\nimport { UIRuntime } from '@teambit/ui';\nimport React from 'react';\nimport { SlotRegistry, Slot } from '@teambit/harmony';\nimport type { FileIconMatch } from '@teambit/code.ui.utils.get-file-icon';\nimport { staticStorageUrl } from '@teambit/base-ui.constants.storage';\nimport { CodePage } from '@teambit/code.ui.code-tab-page';\nimport { ComponentCompareUI, ComponentCompareAspect } from '@teambit/component-compare';\nimport { CodeAspect } from './code.aspect';\nimport { CodeSection } from './code.section';\nimport { CodeCompareSection } from './code.compare.section';\n\nconst isTsx = /\\.tsx$/;\n\nexport type FileIconSlot = SlotRegistry<FileIconMatch[]>;\n\n/**\n * Component code tab aspect. Presents the code tab page and allows to control the code tab and register specific icons for each file type.\n * @example CodeUI.registerEnvFileIcon([(fileName) => (/your-regexp/.test(fileName) ? 'your.icon.url' : undefined)])\n */\nexport class CodeUI {\n constructor(\n /**\n * register an icon for a specific file type. pass icon and a match method/regexp\n */\n private fileIconSlot?: FileIconSlot\n ) {}\n\n getCodePage = () => {\n return <CodePage fileIconSlot={this.fileIconSlot} />;\n };\n\n registerEnvFileIcon(icons: FileIconMatch[]) {\n this.fileIconSlot?.register(icons);\n return this;\n }\n static dependencies = [ComponentAspect, ComponentCompareAspect];\n\n static runtime = UIRuntime;\n\n static slots = [Slot.withType<string>()];\n\n static async provider(\n [component, componentCompare]: [ComponentUI, ComponentCompareUI],\n config,\n [fileIconSlot]: [FileIconSlot]\n ) {\n const ui = new CodeUI(fileIconSlot);\n const section = new CodeSection(ui);\n // overrides the default tsx react icon with the typescript icon\n ui.registerEnvFileIcon([\n (fileName) => (isTsx.test(fileName) ? `${staticStorageUrl}/file-icons/file_type_typescript.svg` : undefined),\n ]);\n component.registerRoute([section.route]);\n component.registerWidget(section.navigationLink, section.order);\n const codeCompare = new CodeCompareSection(fileIconSlot);\n componentCompare.registerNavigation({\n props: codeCompare.navigationLink,\n order: codeCompare.navigationLink.order,\n });\n componentCompare.registerRoutes([codeCompare.route]);\n return ui;\n }\n}\n\nCodeAspect.addRuntime(CodeUI);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA,MAAMA,KAAK,GAAG,QAAd;;AAIA;AACA;AACA;AACA;AACO,MAAMC,MAAN,CAAa;EAClBC,WAAW;EACT;AACJ;AACA;EACYC,YAJC,EAKT;IAAA,KADQA,YACR,GADQA,YACR;IAAA,qDAEY,MAAM;MAClB,oB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odeUI","constructor","host","fileIconSlot","registerEnvFileIcon","icons","register","provider","component","componentCompare","_","harmony","config","String","get","ui","section","CodeSection","fileName","test","staticStorageUrl","undefined","registerRoute","route","registerWidget","navigationLink","order","codeCompare","CodeCompareSection","registerNavigation","props","registerRoutes","ComponentAspect","ComponentCompareAspect","UIRuntime","Slot","withType","CodeAspect","addRuntime"],"sources":["code.ui.runtime.tsx"],"sourcesContent":["import { ComponentAspect, ComponentUI } from '@teambit/component';\nimport { UIRuntime } from '@teambit/ui';\nimport React from 'react';\nimport { Harmony, SlotRegistry, Slot } from '@teambit/harmony';\nimport type { FileIconMatch } from '@teambit/code.ui.utils.get-file-icon';\nimport { staticStorageUrl } from '@teambit/base-ui.constants.storage';\nimport { CodePage } from '@teambit/code.ui.code-tab-page';\nimport { ComponentCompareUI, ComponentCompareAspect } from '@teambit/component-compare';\nimport { CodeAspect } from './code.aspect';\nimport { CodeSection } from './code.section';\nimport { CodeCompareSection } from './code.compare.section';\n\nconst isTsx = /\\.tsx$/;\n\nexport type FileIconSlot = SlotRegistry<FileIconMatch[]>;\n\n/**\n * Component code tab aspect. Presents the code tab page and allows to control the code tab and register specific icons for each file type.\n * @example CodeUI.registerEnvFileIcon([(fileName) => (/your-regexp/.test(fileName) ? 'your.icon.url' : undefined)])\n */\nexport class CodeUI {\n constructor(\n /**\n * register an icon for a specific file type. pass icon and a match method/regexp\n */\n private host: string,\n private fileIconSlot?: FileIconSlot\n ) {}\n\n getCodePage = () => {\n return <CodePage fileIconSlot={this.fileIconSlot} host={this.host} />;\n };\n\n registerEnvFileIcon(icons: FileIconMatch[]) {\n this.fileIconSlot?.register(icons);\n return this;\n }\n static dependencies = [ComponentAspect, ComponentCompareAspect];\n\n static runtime = UIRuntime;\n\n static slots = [Slot.withType<string>()];\n\n static async provider(\n [component, componentCompare]: [ComponentUI, ComponentCompareUI],\n _,\n [fileIconSlot]: [FileIconSlot],\n harmony: Harmony\n ) {\n const { config } = harmony;\n const host = String(config.get('teambit.harmony/bit'));\n const ui = new CodeUI(host, fileIconSlot);\n const section = new CodeSection(ui);\n // overrides the default tsx react icon with the typescript icon\n ui.registerEnvFileIcon([\n (fileName) => (isTsx.test(fileName) ? `${staticStorageUrl}/file-icons/file_type_typescript.svg` : undefined),\n ]);\n component.registerRoute([section.route]);\n component.registerWidget(section.navigationLink, section.order);\n const codeCompare = new CodeCompareSection(fileIconSlot);\n componentCompare.registerNavigation({\n props: codeCompare.navigationLink,\n order: codeCompare.navigationLink.order,\n });\n componentCompare.registerRoutes([codeCompare.route]);\n return ui;\n }\n}\n\nCodeAspect.addRuntime(CodeUI);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA,MAAMA,KAAK,GAAG,QAAd;;AAIA;AACA;AACA;AACA;AACO,MAAMC,MAAN,CAAa;EAClBC,WAAW;EACT;AACJ;AACA;EACYC,IAJC,EAKDC,YALC,EAMT;IAAA,KAFQD,IAER,GAFQA,IAER;IAAA,KADQC,YACR,GADQA,YACR;IAAA,qDAEY,MAAM;MAClB,oBAAO,+BAAC,kBAAD;QAAU,YAAY,EAAE,KAAKA,YAA7B;QAA2C,IAAI,EAAE,KAAKD;MAAtD,EAAP;IACD,CAJC;EAAE;;EAMJE,mBAAmB,CAACC,KAAD,EAAyB;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CAAsBtC,MAAtB"}
package/package.json CHANGED
@@ -1,25 +1,25 @@
1
1
  {
2
2
  "name": "@teambit/code",
3
- "version": "0.0.878",
3
+ "version": "0.0.880",
4
4
  "homepage": "https://bit.dev/teambit/component/code",
5
5
  "main": "dist/index.js",
6
6
  "componentId": {
7
7
  "scope": "teambit.component",
8
8
  "name": "code",
9
- "version": "0.0.878"
9
+ "version": "0.0.880"
10
10
  },
11
11
  "dependencies": {
12
12
  "@babel/runtime": "7.12.18",
13
13
  "core-js": "^3.0.0",
14
14
  "@teambit/harmony": "0.3.3",
15
15
  "@teambit/base-ui.constants.storage": "1.0.0",
16
- "@teambit/code.ui.code-compare": "0.0.102",
17
- "@teambit/component": "0.0.878",
16
+ "@teambit/code.ui.code-compare": "0.0.104",
17
+ "@teambit/component": "0.0.880",
18
18
  "@teambit/ui-foundation.ui.menu-widget-icon": "0.0.494",
19
- "@teambit/code.ui.code-tab-page": "0.0.592",
19
+ "@teambit/code.ui.code-tab-page": "0.0.593",
20
20
  "@teambit/code.ui.utils.get-file-icon": "0.0.492",
21
- "@teambit/component-compare": "0.0.126",
22
- "@teambit/ui": "0.0.878"
21
+ "@teambit/component-compare": "0.0.128",
22
+ "@teambit/ui": "0.0.880"
23
23
  },
24
24
  "devDependencies": {
25
25
  "@types/react": "^17.0.8",
@@ -30,7 +30,7 @@
30
30
  "@types/node": "12.20.4"
31
31
  },
32
32
  "peerDependencies": {
33
- "@teambit/legacy": "1.0.369",
33
+ "@teambit/legacy": "1.0.373",
34
34
  "react-dom": "^16.8.0 || ^17.0.0",
35
35
  "react": "^16.8.0 || ^17.0.0"
36
36
  },
@@ -1,5 +1,5 @@
1
- import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.component_code@0.0.878/dist/code.composition.js';
2
- import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.component_code@0.0.878/dist/code.docs.mdx';
1
+ import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.component_code@0.0.880/dist/code.composition.js';
2
+ import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.component_code@0.0.880/dist/code.docs.mdx';
3
3
 
4
4
  export const compositions = [compositions_0];
5
5
  export const overview = [overview_0];