@teambit/docs 1.0.992 → 1.0.994

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.
@@ -11,19 +11,30 @@ function _react() {
11
11
  };
12
12
  return data;
13
13
  }
14
- function _reactDom() {
15
- const data = _interopRequireDefault(require("react-dom"));
16
- _reactDom = function () {
17
- return data;
18
- };
19
- return data;
20
- }
21
14
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
22
- // let docs = [];
23
-
15
+ let root;
16
+ function createCompatRoot(container) {
17
+ try {
18
+ // React 18+: react-dom/client exists and exports createRoot
19
+ // eslint-disable-next-line import/no-extraneous-dependencies
20
+ return require('react-dom/client').createRoot(container);
21
+ } catch {
22
+ // React 17 fallback: react-dom/client does not exist
23
+ // eslint-disable-next-line import/no-extraneous-dependencies
24
+ const ReactDOM = require('react-dom');
25
+ return {
26
+ render: element => {
27
+ ReactDOM.render(element, container);
28
+ }
29
+ };
30
+ }
31
+ }
24
32
  function addDocs(docs) {
25
33
  const Doc = docs[0];
26
- _reactDom().default.render(/*#__PURE__*/_react().default.createElement(Doc, null), document.getElementById('root'));
34
+ if (!root) {
35
+ root = createCompatRoot(document.getElementById('root'));
36
+ }
37
+ root.render(/*#__PURE__*/_react().default.createElement(Doc, null));
27
38
  }
28
39
 
29
40
  //# sourceMappingURL=docs-store.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_react","data","_interopRequireDefault","require","_reactDom","e","__esModule","default","addDocs","docs","Doc","ReactDOM","render","createElement","document","getElementById"],"sources":["docs-store.tsx"],"sourcesContent":["import React from 'react';\nimport ReactDOM from 'react-dom';\n\n// let docs = [];\n\nexport function addDocs(docs: any[]) {\n const Doc = docs[0];\n ReactDOM.render(<Doc />, document.getElementById('root'));\n}\n"],"mappings":";;;;;;AAAA,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,MAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,UAAA;EAAA,MAAAH,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAC,SAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAAiC,SAAAC,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAEjC;;AAEO,SAASG,OAAOA,CAACC,IAAW,EAAE;EACnC,MAAMC,GAAG,GAAGD,IAAI,CAAC,CAAC,CAAC;EACnBE,mBAAQ,CAACC,MAAM,cAACZ,MAAA,GAAAO,OAAA,CAAAM,aAAA,CAACH,GAAG,MAAE,CAAC,EAAEI,QAAQ,CAACC,cAAc,CAAC,MAAM,CAAC,CAAC;AAC3D","ignoreList":[]}
1
+ {"version":3,"names":["_react","data","_interopRequireDefault","require","e","__esModule","default","root","createCompatRoot","container","createRoot","ReactDOM","render","element","addDocs","docs","Doc","document","getElementById","createElement"],"sources":["docs-store.tsx"],"sourcesContent":["import React from 'react';\n\ntype Root = { render: (element: React.ReactElement) => void };\nlet root: Root | undefined;\n\nfunction createCompatRoot(container: HTMLElement): Root {\n try {\n // React 18+: react-dom/client exists and exports createRoot\n // eslint-disable-next-line import/no-extraneous-dependencies\n return require('react-dom/client').createRoot(container);\n } catch {\n // React 17 fallback: react-dom/client does not exist\n // eslint-disable-next-line import/no-extraneous-dependencies\n const ReactDOM = require('react-dom');\n return {\n render: (element) => {\n ReactDOM.render(element, container);\n },\n };\n }\n}\n\nexport function addDocs(docs: any[]) {\n const Doc = docs[0];\n if (!root) {\n root = createCompatRoot(document.getElementById('root')!);\n }\n root.render(<Doc />);\n}\n"],"mappings":";;;;;;AAAA,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,MAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAA0B,SAAAC,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAG1B,IAAIG,IAAsB;AAE1B,SAASC,gBAAgBA,CAACC,SAAsB,EAAQ;EACtD,IAAI;IACF;IACA;IACA,OAAON,OAAO,CAAC,kBAAkB,CAAC,CAACO,UAAU,CAACD,SAAS,CAAC;EAC1D,CAAC,CAAC,MAAM;IACN;IACA;IACA,MAAME,QAAQ,GAAGR,OAAO,CAAC,WAAW,CAAC;IACrC,OAAO;MACLS,MAAM,EAAGC,OAAO,IAAK;QACnBF,QAAQ,CAACC,MAAM,CAACC,OAAO,EAAEJ,SAAS,CAAC;MACrC;IACF,CAAC;EACH;AACF;AAEO,SAASK,OAAOA,CAACC,IAAW,EAAE;EACnC,MAAMC,GAAG,GAAGD,IAAI,CAAC,CAAC,CAAC;EACnB,IAAI,CAACR,IAAI,EAAE;IACTA,IAAI,GAAGC,gBAAgB,CAACS,QAAQ,CAACC,cAAc,CAAC,MAAM,CAAE,CAAC;EAC3D;EACAX,IAAI,CAACK,MAAM,cAACZ,MAAA,GAAAM,OAAA,CAAAa,aAAA,CAACH,GAAG,MAAE,CAAC,CAAC;AACtB","ignoreList":[]}
package/dist/docs.d.ts CHANGED
@@ -6,7 +6,7 @@ export type Example = {
6
6
  scope?: {
7
7
  [key: string]: any;
8
8
  };
9
- jsx?: JSX.Element;
9
+ jsx?: React.JSX.Element;
10
10
  code: string;
11
11
  };
12
12
  export type Docs = {
package/dist/docs.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["defaultDocs","exports","default","labels","abstract","examples"],"sources":["docs.ts"],"sourcesContent":["import type { ReactElement } from 'react';\nimport type React from 'react';\n\nexport type Example = {\n title?: string;\n description?: ReactElement;\n scope?: { [key: string]: any };\n jsx?: JSX.Element;\n code: string;\n};\n\nexport type Docs = {\n /**\n * default is the docs content.\n */\n default: React.ComponentType;\n\n /**\n * component abstract.\n */\n abstract: string;\n\n /**\n * array of labels.\n */\n labels: string[];\n\n /**\n * @deprecated\n */\n examples: Example[];\n};\n\nexport const defaultDocs: Docs = {\n default: () => null,\n labels: [],\n abstract: '',\n examples: [],\n};\n"],"mappings":";;;;;;AAiCO,MAAMA,WAAiB,GAAAC,OAAA,CAAAD,WAAA,GAAG;EAC/BE,OAAO,EAAEA,CAAA,KAAM,IAAI;EACnBC,MAAM,EAAE,EAAE;EACVC,QAAQ,EAAE,EAAE;EACZC,QAAQ,EAAE;AACZ,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["defaultDocs","exports","default","labels","abstract","examples"],"sources":["docs.ts"],"sourcesContent":["import type { ReactElement } from 'react';\nimport type React from 'react';\n\nexport type Example = {\n title?: string;\n description?: ReactElement;\n scope?: { [key: string]: any };\n jsx?: React.JSX.Element;\n code: string;\n};\n\nexport type Docs = {\n /**\n * default is the docs content.\n */\n default: React.ComponentType;\n\n /**\n * component abstract.\n */\n abstract: string;\n\n /**\n * array of labels.\n */\n labels: string[];\n\n /**\n * @deprecated\n */\n examples: Example[];\n};\n\nexport const defaultDocs: Docs = {\n default: () => null,\n labels: [],\n abstract: '',\n examples: [],\n};\n"],"mappings":";;;;;;AAiCO,MAAMA,WAAiB,GAAAC,OAAA,CAAAD,WAAA,GAAG;EAC/BE,OAAO,EAAEA,CAAA,KAAM,IAAI;EACnBC,MAAM,EAAE,EAAE;EACVC,QAAQ,EAAE,EAAE;EACZC,QAAQ,EAAE;AACZ,CAAC","ignoreList":[]}
@@ -1,5 +1,5 @@
1
- import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.docs_docs@1.0.992/dist/docs.composition.js';
2
- import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.docs_docs@1.0.992/dist/docs.docs.mdx';
1
+ import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.docs_docs@1.0.994/dist/docs.composition.js';
2
+ import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.docs_docs@1.0.994/dist/docs.docs.mdx';
3
3
 
4
4
  export const compositions = [compositions_0];
5
5
  export const overview = [overview_0];
package/docs-store.tsx CHANGED
@@ -1,9 +1,29 @@
1
1
  import React from 'react';
2
- import ReactDOM from 'react-dom';
3
2
 
4
- // let docs = [];
3
+ type Root = { render: (element: React.ReactElement) => void };
4
+ let root: Root | undefined;
5
+
6
+ function createCompatRoot(container: HTMLElement): Root {
7
+ try {
8
+ // React 18+: react-dom/client exists and exports createRoot
9
+ // eslint-disable-next-line import/no-extraneous-dependencies
10
+ return require('react-dom/client').createRoot(container);
11
+ } catch {
12
+ // React 17 fallback: react-dom/client does not exist
13
+ // eslint-disable-next-line import/no-extraneous-dependencies
14
+ const ReactDOM = require('react-dom');
15
+ return {
16
+ render: (element) => {
17
+ ReactDOM.render(element, container);
18
+ },
19
+ };
20
+ }
21
+ }
5
22
 
6
23
  export function addDocs(docs: any[]) {
7
24
  const Doc = docs[0];
8
- ReactDOM.render(<Doc />, document.getElementById('root'));
25
+ if (!root) {
26
+ root = createCompatRoot(document.getElementById('root')!);
27
+ }
28
+ root.render(<Doc />);
9
29
  }
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@teambit/docs",
3
- "version": "1.0.992",
3
+ "version": "1.0.994",
4
4
  "homepage": "https://bit.cloud/teambit/docs/docs",
5
5
  "main": "dist/index.js",
6
6
  "componentId": {
7
7
  "scope": "teambit.docs",
8
8
  "name": "docs",
9
- "version": "1.0.992"
9
+ "version": "1.0.994"
10
10
  },
11
11
  "dependencies": {
12
12
  "graphql-tag": "2.12.1",
@@ -14,31 +14,31 @@
14
14
  "classnames": "^2.5.1",
15
15
  "@teambit/docs.entities.doc": "0.0.12",
16
16
  "@teambit/harmony": "0.4.7",
17
- "@teambit/cli": "0.0.1325",
18
- "@teambit/component.sources": "0.0.168",
19
- "@teambit/legacy.consumer-component": "0.0.117",
20
- "@teambit/logger": "0.0.1418",
21
- "@teambit/preview.ui.component-preview": "1.0.33",
22
17
  "@teambit/docs.ui.overview-compare-section": "0.0.102",
23
18
  "@teambit/docs.ui.overview-compare": "1.0.12",
24
- "@teambit/compositions.panels.composition-gallery": "0.0.225",
25
- "@teambit/workspace.ui.use-workspace-mode": "0.0.2",
19
+ "@teambit/preview.ui.component-preview": "1.0.34",
26
20
  "@teambit/component.ui.component-meta": "0.0.368",
21
+ "@teambit/compositions.panels.composition-gallery": "0.0.226",
22
+ "@teambit/workspace.ui.use-workspace-mode": "0.0.3",
27
23
  "@teambit/base-ui.loaders.skeleton": "1.0.2",
28
- "@teambit/compiler": "1.0.992",
29
- "@teambit/component": "1.0.992",
30
- "@teambit/pkg": "1.0.992",
31
- "@teambit/workspace": "1.0.992",
32
- "@teambit/dev-files": "1.0.992",
33
- "@teambit/envs": "1.0.992",
34
- "@teambit/graphql": "1.0.992",
35
- "@teambit/preview": "1.0.992",
36
- "@teambit/scope": "1.0.992",
37
- "@teambit/api-reference": "1.0.992",
38
- "@teambit/component-compare": "1.0.992",
39
- "@teambit/ui": "1.0.992",
40
- "@teambit/pubsub": "1.0.992",
41
- "@teambit/compositions": "1.0.992"
24
+ "@teambit/compiler": "1.0.994",
25
+ "@teambit/component": "1.0.994",
26
+ "@teambit/pkg": "1.0.994",
27
+ "@teambit/workspace": "1.0.994",
28
+ "@teambit/cli": "0.0.1327",
29
+ "@teambit/component.sources": "0.0.169",
30
+ "@teambit/dev-files": "1.0.994",
31
+ "@teambit/envs": "1.0.994",
32
+ "@teambit/graphql": "1.0.994",
33
+ "@teambit/legacy.consumer-component": "0.0.118",
34
+ "@teambit/logger": "0.0.1420",
35
+ "@teambit/preview": "1.0.994",
36
+ "@teambit/scope": "1.0.994",
37
+ "@teambit/api-reference": "1.0.994",
38
+ "@teambit/component-compare": "1.0.994",
39
+ "@teambit/ui": "1.0.994",
40
+ "@teambit/pubsub": "1.0.994",
41
+ "@teambit/compositions": "1.0.994"
42
42
  },
43
43
  "devDependencies": {
44
44
  "@types/lodash": "4.14.165",
@@ -46,13 +46,13 @@
46
46
  "@types/mocha": "9.1.0",
47
47
  "@teambit/docs.content.docs-overview": "1.96.8",
48
48
  "@teambit/component-id": "1.2.4",
49
- "@teambit/harmony.envs.core-aspect-env": "0.1.4"
49
+ "@teambit/harmony.envs.core-aspect-env": "0.1.5"
50
50
  },
51
51
  "peerDependencies": {
52
- "react": "^17.0.0 || ^18.0.0",
53
- "react-dom": "^17.0.0 || ^18.0.0",
54
- "@types/react": "^17.0.73",
55
- "@types/react-dom": "^17.0.5"
52
+ "react": "^17.0.0 || ^18.0.0 || ^19.0.0",
53
+ "react-dom": "^17.0.0 || ^18.0.0 || ^19.0.0",
54
+ "@types/react": "^19.0.0",
55
+ "@types/react-dom": "^19.0.0"
56
56
  },
57
57
  "license": "Apache-2.0",
58
58
  "optionalDependencies": {},