@teambit/preview 1.0.114 → 1.0.116
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/artifacts/__bit_junit.xml +2 -2
- package/artifacts/preview/teambit_preview_preview-preview.js +1 -1
- package/dist/{preview-1703992959524.js → preview-1704113440840.js} +2 -2
- package/dist/preview-modules.d.ts +1 -10
- package/dist/preview-modules.js +21 -25
- package/dist/preview-modules.js.map +1 -1
- package/dist/preview.composition.d.ts +1 -0
- package/dist/preview.graphql.d.ts +6 -0
- package/dist/preview.graphql.js +15 -1
- package/dist/preview.graphql.js.map +1 -1
- package/dist/preview.main.runtime.d.ts +35 -1
- package/dist/preview.main.runtime.js +63 -5
- package/dist/preview.main.runtime.js.map +1 -1
- package/dist/preview.preview.runtime.js +2 -4
- package/dist/preview.preview.runtime.js.map +1 -1
- package/dist/preview.start-plugin.d.ts +1 -0
- package/dist/types/preview-module.d.ts +1 -28
- package/dist/types/preview-module.js.map +1 -1
- package/package.json +18 -17
- package/preview-modules.tsx +1 -28
- package/preview.main.runtime.tsx +79 -3
- package/preview.preview.runtime.tsx +2 -3
- package/types/preview-module.ts +1 -32
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
2
|
<testsuites>
|
|
3
|
-
<testsuite name="teambit.preview/preview@1.0.
|
|
4
|
-
<testcase classname="create-peer-link.spec.js" name="should output snapshot" time="0.
|
|
3
|
+
<testsuite name="teambit.preview/preview@1.0.116" timestamp="2024-01-01T13:22:10.923Z" tests="1" failures="0" errors="0" skipped="0">
|
|
4
|
+
<testcase classname="create-peer-link.spec.js" name="should output snapshot" time="0.204"/>
|
|
5
5
|
</testsuite>
|
|
6
6
|
</testsuites>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["teambit.preview/preview-preview"]=t():e["teambit.preview/preview-preview"]=t()}(self,(()=>(()=>{"use strict";var e={
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["teambit.preview/preview-preview"]=t():e["teambit.preview/preview-preview"]=t()}(self,(()=>(()=>{"use strict";var e={99967:(e,t,n)=>{var o={id:"teambit.preview/preview@1.0.116",homepage:"https://bit.cloud/teambit/preview/preview",exported:!0};function r(){const e=i(n(87363));return r=function(){return e},e}function i(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0}),t.Logo=void 0,r.__bit_component=o,i.__bit_component=o;const a=()=>r().default.createElement("div",{style:{height:"100%",display:"flex",justifyContent:"center"}},r().default.createElement("img",{style:{width:70},src:"https://static.bit.dev/extensions-icons/preview.svg"}));a.__bit_component=o,t.Logo=a},68637:(e,t,n)=>{Object.defineProperty(t,"M",{enumerable:!0,get:function(){return o.default}});var o=r(n(43990));function r(e){return e&&e.__esModule?e:{default:e}}r.__bit_component={id:"teambit.preview/aspect-docs/preview@0.0.165",homepage:"https://bit.cloud/teambit/preview/aspect-docs/preview",exported:!0}},43990:(e,t,n)=>{var o={id:"teambit.preview/aspect-docs/preview@0.0.165",homepage:"https://bit.cloud/teambit/preview/aspect-docs/preview",exported:!0};Object.defineProperty(t,"__esModule",{value:!0}),t.default=m,a(n(87363));var r=n(40040),i=["components"];function a(e){return e&&e.__esModule?e:{default:e}}function s(){return s=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},s.apply(this,arguments)}function p(e,t){if(null==e)return{};var n,o,r=d(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(o=0;o<i.length;o++)n=i[o],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function d(e,t){if(null==e)return{};var n,o,r={},i=Object.keys(e);for(o=0;o<i.length;o++)n=i[o],t.indexOf(n)>=0||(r[n]=e[n]);return r}a.__bit_component=o,s.__bit_component=o,p.__bit_component=o,d.__bit_component=o;var l={},c="wrapper";function m(e){var t=e.components,n=p(e,i);return(0,r.mdx)(c,s({},l,n,{components:t,mdxType:"MDXLayout"}),(0,r.mdx)("p",null,"The Preview aspect handles the bundling and rendering of component compositions and documentation, for the Workspace UI and Scope UI."),(0,r.mdx)("p",null,"Preview is used to display components in development (on ",(0,r.mdx)("inlineCode",{parentName:"p"},"bit start"),") as well as in their released versions (assets for the release version are generated as part of the build process)."),(0,r.mdx)("p",null,"The Preview aspect handles each component according to the configurations set by the environment that is used by that component. That means both the documentation and the component compositions will be bundled and displayed differently for different environments."),(0,r.mdx)("h2",null,"Rational"),(0,r.mdx)("p",null,"In a standard web application, UI components ",(0,r.mdx)("em",{parentName:"p"},"serving the same application")," are bundled together to produce the necessary assets to make them renderable by the browser."),(0,r.mdx)("p",null,"Components in a Bit workspace are not all in the service of the same application. Each component is authored, tagged and exported as an independent component.\nThat means a few things:"),(0,r.mdx)("ol",null,(0,r.mdx)("li",{parentName:"ol"},(0,r.mdx)("p",{parentName:"li"},"Components in a Bit workspace are not consumed ,directly or indirectly, by a single entry file (e.g, the app's ",(0,r.mdx)("inlineCode",{parentName:"p"},"index.js"),"). That makes it impossible for the bundler to follow the files needed to be bundled.")),(0,r.mdx)("li",{parentName:"ol"},(0,r.mdx)("p",{parentName:"li"},"Different components in a single workspace may be implemented using different technologies and bundled using different configurations or even different bundlers."))),(0,r.mdx)("p",null,"Preview solves the above challenges by creating a temporary entry file for each group of components using the same environment.\nIt then serves this file to the Bundler, to be bundled according to the environment and the purpose of bundling. That is, to display components in development or to display the components' release versions (for a \"production-level\" exhibition of the component's documentation and compositions)."),(0,r.mdx)("h2",null,"Usage"),(0,r.mdx)("h3",null,"Extending the Preview aspect"),(0,r.mdx)("p",null,"The preview aspect can be extended to generate other renderable artifacts , either when running Bit's development server or as part of the build pipeline (for a component's tagged version).\nThese artifacts can present additional information that assists in inspecting a component (for example, showing the results of accessibility tests)."))}m.__bit_component=o,m.isMDXComponent=!0},40040:e=>{e.exports=MdxJsReact},87363:e=>{e.exports=React}},t={};function n(o){var r=t[o];if(void 0!==r)return r.exports;var i=t[o]={exports:{}};return e[o](i,i.exports,n),i.exports}n.d=(e,t)=>{for(var o in t)n.o(t,o)&&!n.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};return(()=>{n.r(o),n.d(o,{compositions:()=>m,compositions_metadata:()=>f,overview:()=>u});var e={};n.r(e),n.d(e,{default:()=>c});var t=n(99967),r=(n(87363),n(40040));const i=TeambitMdxUiMdxScopeContext;var a=n(68637),s=["components"];function p(){return p=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},p.apply(this,arguments)}var d={},l="wrapper";function c(e){var t=e.components,n=function(e,t){if(null==e)return{};var n,o,r=function(e,t){if(null==e)return{};var n,o,r={},i=Object.keys(e);for(o=0;o<i.length;o++)n=i[o],t.indexOf(n)>=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(o=0;o<i.length;o++)n=i[o],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}(e,s);return(0,r.mdx)(l,p({},d,n,{components:t,mdxType:"MDXLayout"}),(0,r.mdx)(i.MDXScopeProvider,{components:{Preview:a.M},mdxType:"MDXScopeProvider"},(0,r.mdx)(a.M,{mdxType:"Preview"})))}c.isMDXComponent=!0;const m=[t],u=[e],f={compositions:[{displayName:"Logo",identifier:"Logo"}]}})(),o})()));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.preview_preview@1.0.
|
|
2
|
-
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.preview_preview@1.0.
|
|
1
|
+
import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.preview_preview@1.0.116/dist/preview.composition.js';
|
|
2
|
+
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.preview_preview@1.0.116/dist/preview.docs.mdx';
|
|
3
3
|
|
|
4
4
|
export const compositions = [compositions_0];
|
|
5
5
|
export const overview = [overview_0];
|
|
@@ -1,10 +1 @@
|
|
|
1
|
-
|
|
2
|
-
type ModuleId = string;
|
|
3
|
-
export declare class PreviewModules extends Map<ModuleId, PreviewModule> {
|
|
4
|
-
onSet: Set<() => void>;
|
|
5
|
-
set(id: ModuleId, preview: PreviewModule): this;
|
|
6
|
-
loadComponentPreviews(compId: string, previews: Record<string, ModuleFile[]>): void;
|
|
7
|
-
}
|
|
8
|
-
export declare const PREVIEW_MODULES: PreviewModules;
|
|
9
|
-
export declare function linkModules(previewName: string, previewModule: PreviewModule): void;
|
|
10
|
-
export {};
|
|
1
|
+
export { PreviewModules, linkModules, PREVIEW_MODULES } from '@teambit/preview.modules.preview-modules';
|
package/dist/preview-modules.js
CHANGED
|
@@ -3,34 +3,30 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports
|
|
7
|
-
|
|
8
|
-
function
|
|
9
|
-
|
|
10
|
-
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); }
|
|
11
|
-
class PreviewModules extends Map {
|
|
12
|
-
constructor(...args) {
|
|
13
|
-
super(...args);
|
|
14
|
-
_defineProperty(this, "onSet", new Set());
|
|
6
|
+
Object.defineProperty(exports, "PREVIEW_MODULES", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _previewModules().PREVIEW_MODULES;
|
|
15
10
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "PreviewModules", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _previewModules().PreviewModules;
|
|
20
16
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
preview.componentMap[compId] = moduleFile;
|
|
27
|
-
});
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "linkModules", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () {
|
|
21
|
+
return _previewModules().linkModules;
|
|
28
22
|
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const
|
|
32
|
-
function
|
|
33
|
-
|
|
23
|
+
});
|
|
24
|
+
function _previewModules() {
|
|
25
|
+
const data = require("@teambit/preview.modules.preview-modules");
|
|
26
|
+
_previewModules = function () {
|
|
27
|
+
return data;
|
|
28
|
+
};
|
|
29
|
+
return data;
|
|
34
30
|
}
|
|
35
31
|
|
|
36
32
|
//# sourceMappingURL=preview-modules.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["_previewModules","data","require"],"sources":["preview-modules.tsx"],"sourcesContent":["export { PreviewModules, linkModules, PREVIEW_MODULES } from '@teambit/preview.modules.preview-modules';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAAA,gBAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,eAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA"}
|
|
@@ -18,6 +18,12 @@ export declare function previewSchema(previewExtension: PreviewMain): {
|
|
|
18
18
|
legacyHeader: ({ component }: {
|
|
19
19
|
component: any;
|
|
20
20
|
}) => Promise<boolean>;
|
|
21
|
+
onlyOverview: ({ component }: {
|
|
22
|
+
component: any;
|
|
23
|
+
}) => Promise<boolean>;
|
|
24
|
+
useNameParam: ({ component }: {
|
|
25
|
+
component: any;
|
|
26
|
+
}) => Promise<boolean>;
|
|
21
27
|
skipIncludes: ({ component }: {
|
|
22
28
|
component: any;
|
|
23
29
|
}) => Promise<boolean>;
|
package/dist/preview.graphql.js
CHANGED
|
@@ -23,7 +23,12 @@ function previewSchema(previewExtension) {
|
|
|
23
23
|
isScaling: Boolean
|
|
24
24
|
includesEnvTemplate: Boolean
|
|
25
25
|
legacyHeader: Boolean
|
|
26
|
+
"""
|
|
27
|
+
@deprecated use onlyOverview
|
|
28
|
+
"""
|
|
26
29
|
skipIncludes: Boolean
|
|
30
|
+
onlyOverview: Boolean
|
|
31
|
+
useNameParam: Boolean
|
|
27
32
|
}
|
|
28
33
|
|
|
29
34
|
extend type Component {
|
|
@@ -55,10 +60,19 @@ function previewSchema(previewExtension) {
|
|
|
55
60
|
}) => {
|
|
56
61
|
return previewExtension.isLegacyHeader(component);
|
|
57
62
|
},
|
|
63
|
+
onlyOverview: ({
|
|
64
|
+
component
|
|
65
|
+
}) => {
|
|
66
|
+
return previewExtension.getOnlyOverview(component);
|
|
67
|
+
},
|
|
68
|
+
useNameParam: ({
|
|
69
|
+
component
|
|
70
|
+
}) => {
|
|
71
|
+
return previewExtension.getUseNameParam(component);
|
|
72
|
+
},
|
|
58
73
|
skipIncludes: ({
|
|
59
74
|
component
|
|
60
75
|
}) => {
|
|
61
|
-
// return true;
|
|
62
76
|
return previewExtension.isSupportSkipIncludes(component);
|
|
63
77
|
}
|
|
64
78
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_graphqlTag","data","_interopRequireDefault","require","obj","__esModule","default","previewSchema","previewExtension","typeDefs","gql","resolvers","Component","preview","component","Preview","includesEnvTemplate","isBundledWithEnv","isScaling","doesScaling","legacyHeader","isLegacyHeader","skipIncludes","isSupportSkipIncludes"],"sources":["preview.graphql.ts"],"sourcesContent":["import { Component } from '@teambit/component';\nimport gql from 'graphql-tag';\n\nimport { PreviewMain } from './preview.main.runtime';\n\nexport function previewSchema(previewExtension: PreviewMain) {\n return {\n typeDefs: gql`\n type Preview {\n # url: String!\n \"\"\"\n Check if the component supports scaling\n \"\"\"\n isScaling: Boolean\n includesEnvTemplate: Boolean\n legacyHeader: Boolean\n skipIncludes: Boolean\n }\n\n extend type Component {\n preview: Preview\n }\n `,\n resolvers: {\n Component: {\n preview: (component: Component) => {\n // return previewExtension.getPreview(component);\n return { component };\n },\n },\n Preview: {\n includesEnvTemplate: ({ component }) => {\n return previewExtension.isBundledWithEnv(component);\n },\n isScaling: ({ component }) => {\n return previewExtension.doesScaling(component);\n },\n legacyHeader: ({ component }) => {\n return previewExtension.isLegacyHeader(component);\n },\n
|
|
1
|
+
{"version":3,"names":["_graphqlTag","data","_interopRequireDefault","require","obj","__esModule","default","previewSchema","previewExtension","typeDefs","gql","resolvers","Component","preview","component","Preview","includesEnvTemplate","isBundledWithEnv","isScaling","doesScaling","legacyHeader","isLegacyHeader","onlyOverview","getOnlyOverview","useNameParam","getUseNameParam","skipIncludes","isSupportSkipIncludes"],"sources":["preview.graphql.ts"],"sourcesContent":["import { Component } from '@teambit/component';\nimport gql from 'graphql-tag';\n\nimport { PreviewMain } from './preview.main.runtime';\n\nexport function previewSchema(previewExtension: PreviewMain) {\n return {\n typeDefs: gql`\n type Preview {\n # url: String!\n \"\"\"\n Check if the component supports scaling\n \"\"\"\n isScaling: Boolean\n includesEnvTemplate: Boolean\n legacyHeader: Boolean\n \"\"\"\n @deprecated use onlyOverview\n \"\"\"\n skipIncludes: Boolean\n onlyOverview: Boolean\n useNameParam: Boolean\n }\n\n extend type Component {\n preview: Preview\n }\n `,\n resolvers: {\n Component: {\n preview: (component: Component) => {\n // return previewExtension.getPreview(component);\n return { component };\n },\n },\n Preview: {\n includesEnvTemplate: ({ component }) => {\n return previewExtension.isBundledWithEnv(component);\n },\n isScaling: ({ component }) => {\n return previewExtension.doesScaling(component);\n },\n legacyHeader: ({ component }) => {\n return previewExtension.isLegacyHeader(component);\n },\n onlyOverview: ({ component }) => {\n return previewExtension.getOnlyOverview(component);\n },\n useNameParam: ({ component }) => {\n return previewExtension.getUseNameParam(component);\n },\n skipIncludes: ({ component }) => {\n return previewExtension.isSupportSkipIncludes(component);\n },\n },\n },\n };\n}\n"],"mappings":";;;;;;AACA,SAAAA,YAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,WAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAA8B,SAAAC,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAIvB,SAASG,aAAaA,CAACC,gBAA6B,EAAE;EAC3D,OAAO;IACLC,QAAQ,EAAE,IAAAC,qBAAG,CAAC;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;IACDC,SAAS,EAAE;MACTC,SAAS,EAAE;QACTC,OAAO,EAAGC,SAAoB,IAAK;UACjC;UACA,OAAO;YAAEA;UAAU,CAAC;QACtB;MACF,CAAC;MACDC,OAAO,EAAE;QACPC,mBAAmB,EAAEA,CAAC;UAAEF;QAAU,CAAC,KAAK;UACtC,OAAON,gBAAgB,CAACS,gBAAgB,CAACH,SAAS,CAAC;QACrD,CAAC;QACDI,SAAS,EAAEA,CAAC;UAAEJ;QAAU,CAAC,KAAK;UAC5B,OAAON,gBAAgB,CAACW,WAAW,CAACL,SAAS,CAAC;QAChD,CAAC;QACDM,YAAY,EAAEA,CAAC;UAAEN;QAAU,CAAC,KAAK;UAC/B,OAAON,gBAAgB,CAACa,cAAc,CAACP,SAAS,CAAC;QACnD,CAAC;QACDQ,YAAY,EAAEA,CAAC;UAAER;QAAU,CAAC,KAAK;UAC/B,OAAON,gBAAgB,CAACe,eAAe,CAACT,SAAS,CAAC;QACpD,CAAC;QACDU,YAAY,EAAEA,CAAC;UAAEV;QAAU,CAAC,KAAK;UAC/B,OAAON,gBAAgB,CAACiB,eAAe,CAACX,SAAS,CAAC;QACpD,CAAC;QACDY,YAAY,EAAEA,CAAC;UAAEZ;QAAU,CAAC,KAAK;UAC/B,OAAON,gBAAgB,CAACmB,qBAAqB,CAACb,SAAS,CAAC;QAC1D;MACF;IACF;EACF,CAAC;AACH"}
|
|
@@ -58,6 +58,14 @@ export type PreviewAnyComponentData = {
|
|
|
58
58
|
* Calculated by the component's env
|
|
59
59
|
*/
|
|
60
60
|
splitComponentBundle?: boolean;
|
|
61
|
+
/**
|
|
62
|
+
* don't allow other aspects implementing a preview definition to be included in your preview.
|
|
63
|
+
*/
|
|
64
|
+
onlyOverview?: boolean;
|
|
65
|
+
/**
|
|
66
|
+
* use name query params to select a specific composition to render.
|
|
67
|
+
*/
|
|
68
|
+
useNameParam?: boolean;
|
|
61
69
|
/**
|
|
62
70
|
* don't allow other aspects implementing a preview definition to be included in your preview.
|
|
63
71
|
*/
|
|
@@ -68,6 +76,8 @@ export type PreviewAnyComponentData = {
|
|
|
68
76
|
*/
|
|
69
77
|
export type PreviewEnvComponentData = {
|
|
70
78
|
isScaling?: boolean;
|
|
79
|
+
supportsOnlyOverview?: boolean;
|
|
80
|
+
supportsUseNameParam?: boolean;
|
|
71
81
|
};
|
|
72
82
|
export type PreviewConfig = {
|
|
73
83
|
bundlingStrategy?: string;
|
|
@@ -78,6 +88,7 @@ export type PreviewConfig = {
|
|
|
78
88
|
* default - no limit.
|
|
79
89
|
*/
|
|
80
90
|
maxChunkSize?: number;
|
|
91
|
+
onlyOverview?: boolean;
|
|
81
92
|
};
|
|
82
93
|
export type EnvPreviewConfig = {
|
|
83
94
|
strategyName?: PreviewStrategyName;
|
|
@@ -137,6 +148,20 @@ export declare class PreviewMain {
|
|
|
137
148
|
* @returns
|
|
138
149
|
*/
|
|
139
150
|
getPreviewData(component: Component): PreviewComponentData | undefined;
|
|
151
|
+
/**
|
|
152
|
+
* check if the current version of env component supports skipping other included previews
|
|
153
|
+
* @param envComponent
|
|
154
|
+
* @returns
|
|
155
|
+
*/
|
|
156
|
+
doesEnvIncludesOnlyOverview(envComponent: Component): boolean;
|
|
157
|
+
/**
|
|
158
|
+
* check if the current version of env component supports name query param
|
|
159
|
+
* @param envComponent
|
|
160
|
+
* @returns
|
|
161
|
+
*/
|
|
162
|
+
doesEnvUseNameParam(envComponent: Component): boolean;
|
|
163
|
+
private calculateIncludeOnlyOverview;
|
|
164
|
+
private calculateUseNameParam;
|
|
140
165
|
/**
|
|
141
166
|
* Calculate preview data on component load
|
|
142
167
|
* @param component
|
|
@@ -148,7 +173,7 @@ export declare class PreviewMain {
|
|
|
148
173
|
* @param component
|
|
149
174
|
* @returns
|
|
150
175
|
*/
|
|
151
|
-
calcPreviewDataFromEnv(component: Component): Promise<Omit<PreviewAnyComponentData, 'doesScaling'> | undefined>;
|
|
176
|
+
calcPreviewDataFromEnv(component: Component): Promise<Omit<PreviewAnyComponentData, 'doesScaling' | 'onlyOverview' | 'useNameParam'> | undefined>;
|
|
152
177
|
/**
|
|
153
178
|
* calculate extra preview data for env components (on load)
|
|
154
179
|
* @param envComponent
|
|
@@ -192,6 +217,14 @@ export declare class PreviewMain {
|
|
|
192
217
|
*/
|
|
193
218
|
isEnvSupportScaling(envComponent: Component): boolean;
|
|
194
219
|
isSupportSkipIncludes(component: Component): Promise<boolean>;
|
|
220
|
+
/**
|
|
221
|
+
* check if the component preview should only include the overview (skipping rendering of the compostions and properties table)
|
|
222
|
+
*/
|
|
223
|
+
getOnlyOverview(component: Component): Promise<boolean>;
|
|
224
|
+
/**
|
|
225
|
+
* check if the component preview should include the name query param
|
|
226
|
+
*/
|
|
227
|
+
getUseNameParam(component: Component): Promise<boolean>;
|
|
195
228
|
/**
|
|
196
229
|
* This function is calculate the isScaling support flag for the component preview.
|
|
197
230
|
* This is calculated only for the env component and not for the component itself.
|
|
@@ -285,6 +318,7 @@ export declare class PreviewMain {
|
|
|
285
318
|
static dependencies: import("@teambit/harmony").Aspect[];
|
|
286
319
|
static defaultConfig: {
|
|
287
320
|
disabled: boolean;
|
|
321
|
+
onlyOverview: boolean;
|
|
288
322
|
};
|
|
289
323
|
static provider([bundler, builder, componentExtension, uiMain, envs, workspace, pkg, pubsub, aspectLoader, loggerMain, dependencyResolver, graphql, watcher, scope,]: [
|
|
290
324
|
BundlerMain,
|
|
@@ -396,6 +396,40 @@ class PreviewMain {
|
|
|
396
396
|
return previewData;
|
|
397
397
|
}
|
|
398
398
|
|
|
399
|
+
/**
|
|
400
|
+
* check if the current version of env component supports skipping other included previews
|
|
401
|
+
* @param envComponent
|
|
402
|
+
* @returns
|
|
403
|
+
*/
|
|
404
|
+
doesEnvIncludesOnlyOverview(envComponent) {
|
|
405
|
+
const previewData = this.getPreviewData(envComponent);
|
|
406
|
+
return !!previewData?.supportsOnlyOverview;
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
/**
|
|
410
|
+
* check if the current version of env component supports name query param
|
|
411
|
+
* @param envComponent
|
|
412
|
+
* @returns
|
|
413
|
+
*/
|
|
414
|
+
doesEnvUseNameParam(envComponent) {
|
|
415
|
+
const previewData = this.getPreviewData(envComponent);
|
|
416
|
+
return !!previewData?.supportsUseNameParam;
|
|
417
|
+
}
|
|
418
|
+
async calculateIncludeOnlyOverview(component) {
|
|
419
|
+
if (this.envs.isUsingCoreEnv(component)) {
|
|
420
|
+
return true;
|
|
421
|
+
}
|
|
422
|
+
const envComponent = await this.envs.getEnvComponent(component);
|
|
423
|
+
return this.doesEnvIncludesOnlyOverview(envComponent);
|
|
424
|
+
}
|
|
425
|
+
async calculateUseNameParam(component) {
|
|
426
|
+
if (this.envs.isUsingCoreEnv(component)) {
|
|
427
|
+
return true;
|
|
428
|
+
}
|
|
429
|
+
const envComponent = await this.envs.getEnvComponent(component);
|
|
430
|
+
return this.doesEnvUseNameParam(envComponent);
|
|
431
|
+
}
|
|
432
|
+
|
|
399
433
|
/**
|
|
400
434
|
* Calculate preview data on component load
|
|
401
435
|
* @param component
|
|
@@ -405,8 +439,12 @@ class PreviewMain {
|
|
|
405
439
|
const doesScaling = await this.calcDoesScalingForComponent(component);
|
|
406
440
|
const dataFromEnv = await this.calcPreviewDataFromEnv(component);
|
|
407
441
|
const envData = (await this.calculateDataForEnvComponent(component)) || {};
|
|
442
|
+
const onlyOverview = await this.calculateIncludeOnlyOverview(component);
|
|
443
|
+
const useNameParam = await this.calculateUseNameParam(component);
|
|
408
444
|
const data = _objectSpread(_objectSpread({
|
|
409
|
-
doesScaling
|
|
445
|
+
doesScaling,
|
|
446
|
+
onlyOverview,
|
|
447
|
+
useNameParam
|
|
410
448
|
}, dataFromEnv), envData);
|
|
411
449
|
return data;
|
|
412
450
|
}
|
|
@@ -441,14 +479,15 @@ class PreviewMain {
|
|
|
441
479
|
*/
|
|
442
480
|
async calculateDataForEnvComponent(envComponent) {
|
|
443
481
|
const isEnv = this.envs.isEnv(envComponent);
|
|
482
|
+
|
|
444
483
|
// If the component is not an env, we don't want to store anything in the data
|
|
445
484
|
if (!isEnv) return undefined;
|
|
446
485
|
const previewAspectConfig = this.getPreviewAspectConfig(envComponent);
|
|
447
486
|
const data = {
|
|
448
487
|
// default to true if the env doesn't have a preview config
|
|
449
|
-
isScaling: previewAspectConfig?.isScaling ?? true
|
|
450
|
-
|
|
451
|
-
|
|
488
|
+
isScaling: previewAspectConfig?.isScaling ?? true,
|
|
489
|
+
supportsOnlyOverview: true,
|
|
490
|
+
supportsUseNameParam: true
|
|
452
491
|
};
|
|
453
492
|
return data;
|
|
454
493
|
}
|
|
@@ -566,6 +605,7 @@ class PreviewMain {
|
|
|
566
605
|
return !!previewData?.isScaling;
|
|
567
606
|
}
|
|
568
607
|
async isSupportSkipIncludes(component) {
|
|
608
|
+
if (!this.config.onlyOverview) return false;
|
|
569
609
|
const isCore = this.envs.isUsingCoreEnv(component);
|
|
570
610
|
if (isCore) return false;
|
|
571
611
|
const envComponent = await this.envs.getEnvComponent(component);
|
|
@@ -573,6 +613,23 @@ class PreviewMain {
|
|
|
573
613
|
return !!previewData?.skipIncludes;
|
|
574
614
|
}
|
|
575
615
|
|
|
616
|
+
/**
|
|
617
|
+
* check if the component preview should only include the overview (skipping rendering of the compostions and properties table)
|
|
618
|
+
*/
|
|
619
|
+
async getOnlyOverview(component) {
|
|
620
|
+
if (!this.config.onlyOverview) return false;
|
|
621
|
+
const previewData = this.getPreviewData(component);
|
|
622
|
+
return previewData?.onlyOverview ?? false;
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
/**
|
|
626
|
+
* check if the component preview should include the name query param
|
|
627
|
+
*/
|
|
628
|
+
async getUseNameParam(component) {
|
|
629
|
+
const previewData = this.getPreviewData(component);
|
|
630
|
+
return previewData?.useNameParam ?? false;
|
|
631
|
+
}
|
|
632
|
+
|
|
576
633
|
/**
|
|
577
634
|
* This function is calculate the isScaling support flag for the component preview.
|
|
578
635
|
* This is calculated only for the env component and not for the component itself.
|
|
@@ -869,7 +926,8 @@ _defineProperty(PreviewMain, "slots", [_harmony().Slot.withType(), _harmony().Sl
|
|
|
869
926
|
_defineProperty(PreviewMain, "runtime", _cli().MainRuntime);
|
|
870
927
|
_defineProperty(PreviewMain, "dependencies", [_bundler().BundlerAspect, _builder().BuilderAspect, _component().ComponentAspect, _ui().UIAspect, _envs().EnvsAspect, _workspace().default, _pkg().PkgAspect, _pubsub().PubsubAspect, _aspectLoader().AspectLoaderAspect, _logger().LoggerAspect, _dependencyResolver().DependencyResolverAspect, _graphql().default, _watcher().default, _scope().default]);
|
|
871
928
|
_defineProperty(PreviewMain, "defaultConfig", {
|
|
872
|
-
disabled: false
|
|
929
|
+
disabled: false,
|
|
930
|
+
onlyOverview: false
|
|
873
931
|
});
|
|
874
932
|
_preview().PreviewAspect.addRuntime(PreviewMain);
|
|
875
933
|
|