@teambit/preview 0.0.1158 → 0.0.1159
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/artifact-file-middleware.js +1 -2
- package/dist/artifact-file-middleware.js.map +1 -1
- package/dist/bundler/chunks.js +4 -10
- package/dist/bundler/chunks.js.map +1 -1
- package/dist/bundler/create-peers-link.js +1 -4
- package/dist/bundler/create-peers-link.js.map +1 -1
- package/dist/bundler/html-plugin.js +2 -4
- package/dist/bundler/html-plugin.js.map +1 -1
- package/dist/component-preview.route.js +6 -12
- package/dist/component-preview.route.js.map +1 -1
- package/dist/env-preview-template.task.js +13 -24
- package/dist/env-preview-template.task.js.map +1 -1
- package/dist/env-template.route.js +7 -13
- package/dist/env-template.route.js.map +1 -1
- package/dist/events/click-inside-an-iframe.js +4 -11
- package/dist/events/click-inside-an-iframe.js.map +1 -1
- package/dist/execution-ref.js +4 -9
- package/dist/execution-ref.js.map +1 -1
- package/dist/generate-link.js +1 -4
- package/dist/generate-link.js.map +1 -1
- package/dist/gql/fetch-component-aspects.js +0 -1
- package/dist/gql/fetch-component-aspects.js.map +1 -1
- package/dist/html-utils.js +0 -1
- package/dist/html-utils.js.map +1 -1
- package/dist/{preview-1694575035715.js → preview-1694624356552.js} +2 -2
- package/dist/preview-assets.route.js +6 -12
- package/dist/preview-assets.route.js.map +1 -1
- package/dist/preview-modules.js +4 -10
- package/dist/preview-modules.js.map +1 -1
- package/dist/preview.composition.js +1 -1
- package/dist/preview.composition.js.map +1 -1
- package/dist/preview.graphql.js +1 -1
- package/dist/preview.graphql.js.map +1 -1
- package/dist/preview.main.runtime.js +20 -29
- package/dist/preview.main.runtime.js.map +1 -1
- package/dist/preview.preview.runtime.js +15 -26
- package/dist/preview.preview.runtime.js.map +1 -1
- package/dist/preview.route.js +6 -12
- package/dist/preview.route.js.map +1 -1
- package/dist/preview.service.js +4 -9
- package/dist/preview.service.js.map +1 -1
- package/dist/preview.start-plugin.js +10 -17
- package/dist/preview.start-plugin.js.map +1 -1
- package/dist/preview.task.js +8 -15
- package/dist/preview.task.js.map +1 -1
- package/dist/size-event.js +4 -9
- package/dist/size-event.js.map +1 -1
- package/dist/strategies/component-strategy.js +4 -13
- package/dist/strategies/component-strategy.js.map +1 -1
- package/dist/strategies/env-strategy.js +5 -15
- package/dist/strategies/env-strategy.js.map +1 -1
- package/dist/strategies/generate-component-link.js +0 -1
- package/dist/strategies/generate-component-link.js.map +1 -1
- package/package.json +23 -25
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ExecutionRef","constructor","executionCtx","
|
|
1
|
+
{"version":3,"names":["ExecutionRef","constructor","executionCtx","_defineProperty","currentComponents","components","add","added","concat","remove","removed","filter","c","id","toString","update","next","map","equals","get","find","x","isEqual","exports"],"sources":["execution-ref.ts"],"sourcesContent":["import { Component, ComponentID } from '@teambit/component';\nimport type { ExecutionContext } from '@teambit/envs';\n\n// TODO - use workspace.list() instead of this\nexport class ExecutionRef {\n constructor(public executionCtx: ExecutionContext) {\n this.currentComponents = executionCtx.components;\n }\n\n currentComponents: Component[];\n\n add(added: Component) {\n this.currentComponents = this.currentComponents.concat(added);\n }\n remove(removed: ComponentID) {\n this.currentComponents = this.currentComponents.filter((c) => c.id.toString() !== removed.toString());\n }\n update(next: Component) {\n this.currentComponents = this.currentComponents.map((c) => (c.equals(next) ? next : c));\n }\n\n get(id: ComponentID) {\n return this.currentComponents.find((x) => x.id.isEqual(id));\n }\n}\n"],"mappings":";;;;;;;;;AAGA;AACO,MAAMA,YAAY,CAAC;EACxBC,WAAWA,CAAQC,YAA8B,EAAE;IAAA,KAAhCA,YAA8B,GAA9BA,YAA8B;IAAAC,eAAA;IAC/C,IAAI,CAACC,iBAAiB,GAAGF,YAAY,CAACG,UAAU;EAClD;EAIAC,GAAGA,CAACC,KAAgB,EAAE;IACpB,IAAI,CAACH,iBAAiB,GAAG,IAAI,CAACA,iBAAiB,CAACI,MAAM,CAACD,KAAK,CAAC;EAC/D;EACAE,MAAMA,CAACC,OAAoB,EAAE;IAC3B,IAAI,CAACN,iBAAiB,GAAG,IAAI,CAACA,iBAAiB,CAACO,MAAM,CAAEC,CAAC,IAAKA,CAAC,CAACC,EAAE,CAACC,QAAQ,CAAC,CAAC,KAAKJ,OAAO,CAACI,QAAQ,CAAC,CAAC,CAAC;EACvG;EACAC,MAAMA,CAACC,IAAe,EAAE;IACtB,IAAI,CAACZ,iBAAiB,GAAG,IAAI,CAACA,iBAAiB,CAACa,GAAG,CAAEL,CAAC,IAAMA,CAAC,CAACM,MAAM,CAACF,IAAI,CAAC,GAAGA,IAAI,GAAGJ,CAAE,CAAC;EACzF;EAEAO,GAAGA,CAACN,EAAe,EAAE;IACnB,OAAO,IAAI,CAACT,iBAAiB,CAACgB,IAAI,CAAEC,CAAC,IAAKA,CAAC,CAACR,EAAE,CAACS,OAAO,CAACT,EAAE,CAAC,CAAC;EAC7D;AACF;AAACU,OAAA,CAAAvB,YAAA,GAAAA,YAAA"}
|
package/dist/generate-link.js
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
require("core-js/modules/es.array.iterator.js");
|
|
5
|
-
require("core-js/modules/es.regexp.exec.js");
|
|
6
|
-
require("core-js/modules/es.string.replace.js");
|
|
7
3
|
Object.defineProperty(exports, "__esModule", {
|
|
8
4
|
value: true
|
|
9
5
|
});
|
|
@@ -22,6 +18,7 @@ function _camelcase() {
|
|
|
22
18
|
};
|
|
23
19
|
return data;
|
|
24
20
|
}
|
|
21
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
25
22
|
// :TODO refactor to building an AST and generate source code based on it.
|
|
26
23
|
function generateLink(prefix, componentMap, mainModulesMap, isSplitComponentBundle = false) {
|
|
27
24
|
const links = componentMap.toArray().map(([component, modulePath], compIdx) => ({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_toolboxPath","data","require","_camelcase","_interopRequireDefault","generateLink","prefix","componentMap","mainModulesMap","isSplitComponentBundle","links","toArray","map","component","modulePath","compIdx","componentIdentifier","id","fullName","modules","path","pathIdx","varName","moduleVarName","resolveFrom","toWindowsCompatiblePath","modulesLinks","Object","entries","envId","getEnvVarName","resolve","link","module","join","filter","line","componentIdx","fileIdx","envNameFormatted","camelcase","replace"],"sources":["generate-link.ts"],"sourcesContent":["import { toWindowsCompatiblePath } from '@teambit/toolbox.path.to-windows-compatible-path';\nimport camelcase from 'camelcase';\nimport type { ComponentMap } from '@teambit/component';\n\nexport type MainModulesMap = {\n /**\n * Path to default module in case there is no specific module for the current environment.\n */\n default: string;\n [envId: string]: string;\n};\n\n// :TODO refactor to building an AST and generate source code based on it.\nexport function generateLink(\n prefix: string,\n componentMap: ComponentMap<string[]>,\n mainModulesMap?: MainModulesMap,\n isSplitComponentBundle = false\n): string {\n const links = componentMap.toArray().map(([component, modulePath], compIdx) => ({\n componentIdentifier: component.id.fullName,\n modules: modulePath.map((path, pathIdx) => ({\n varName: moduleVarName(compIdx, pathIdx),\n resolveFrom: toWindowsCompatiblePath(path),\n })),\n }));\n\n let modulesLinks;\n if (mainModulesMap) {\n modulesLinks = Object.entries(mainModulesMap).map(([envId, path]) => {\n const resolveFrom = toWindowsCompatiblePath(path);\n const varName = getEnvVarName(envId);\n return { envId, varName, resolveFrom };\n });\n }\n\n return `\nimport { linkModules } from '${toWindowsCompatiblePath(require.resolve('./preview.preview.runtime'))}';\n\n${links\n .map((link) => link.modules.map((module) => `import * as ${module.varName} from \"${module.resolveFrom}\";`).join('\\n'))\n .filter((line) => line !== '') // prevent empty lines\n .join('\\n')}\n\n${modulesLinks.map((module) => `import * as ${module.varName} from \"${module.resolveFrom}\";`).join('\\n')}\n\nlinkModules('${prefix}', {\n modulesMap: {\n ${modulesLinks\n // must include all components, including empty\n .map((module) => `\"${module.envId}\": ${module.varName}`)\n .join(',\\n ')}\n },\n isSplitComponentBundle: ${isSplitComponentBundle},\n componentMap: {\n${links\n // must include all components, including empty\n .map((link) => ` \"${link.componentIdentifier}\": [${link.modules.map((module) => module.varName).join(', ')}]`)\n .join(',\\n')}\n }\n});\n`;\n}\n\nfunction moduleVarName(componentIdx: number, fileIdx: number) {\n return `file_${componentIdx}_${fileIdx}`;\n}\n\nfunction getEnvVarName(envId: string) {\n const envNameFormatted = camelcase(envId.replace('@', '').replace('.', '-').replace(/\\//g, '-'));\n const varName = `${envNameFormatted}MainModule`;\n return varName;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["_toolboxPath","data","require","_camelcase","_interopRequireDefault","obj","__esModule","default","generateLink","prefix","componentMap","mainModulesMap","isSplitComponentBundle","links","toArray","map","component","modulePath","compIdx","componentIdentifier","id","fullName","modules","path","pathIdx","varName","moduleVarName","resolveFrom","toWindowsCompatiblePath","modulesLinks","Object","entries","envId","getEnvVarName","resolve","link","module","join","filter","line","componentIdx","fileIdx","envNameFormatted","camelcase","replace"],"sources":["generate-link.ts"],"sourcesContent":["import { toWindowsCompatiblePath } from '@teambit/toolbox.path.to-windows-compatible-path';\nimport camelcase from 'camelcase';\nimport type { ComponentMap } from '@teambit/component';\n\nexport type MainModulesMap = {\n /**\n * Path to default module in case there is no specific module for the current environment.\n */\n default: string;\n [envId: string]: string;\n};\n\n// :TODO refactor to building an AST and generate source code based on it.\nexport function generateLink(\n prefix: string,\n componentMap: ComponentMap<string[]>,\n mainModulesMap?: MainModulesMap,\n isSplitComponentBundle = false\n): string {\n const links = componentMap.toArray().map(([component, modulePath], compIdx) => ({\n componentIdentifier: component.id.fullName,\n modules: modulePath.map((path, pathIdx) => ({\n varName: moduleVarName(compIdx, pathIdx),\n resolveFrom: toWindowsCompatiblePath(path),\n })),\n }));\n\n let modulesLinks;\n if (mainModulesMap) {\n modulesLinks = Object.entries(mainModulesMap).map(([envId, path]) => {\n const resolveFrom = toWindowsCompatiblePath(path);\n const varName = getEnvVarName(envId);\n return { envId, varName, resolveFrom };\n });\n }\n\n return `\nimport { linkModules } from '${toWindowsCompatiblePath(require.resolve('./preview.preview.runtime'))}';\n\n${links\n .map((link) => link.modules.map((module) => `import * as ${module.varName} from \"${module.resolveFrom}\";`).join('\\n'))\n .filter((line) => line !== '') // prevent empty lines\n .join('\\n')}\n\n${modulesLinks.map((module) => `import * as ${module.varName} from \"${module.resolveFrom}\";`).join('\\n')}\n\nlinkModules('${prefix}', {\n modulesMap: {\n ${modulesLinks\n // must include all components, including empty\n .map((module) => `\"${module.envId}\": ${module.varName}`)\n .join(',\\n ')}\n },\n isSplitComponentBundle: ${isSplitComponentBundle},\n componentMap: {\n${links\n // must include all components, including empty\n .map((link) => ` \"${link.componentIdentifier}\": [${link.modules.map((module) => module.varName).join(', ')}]`)\n .join(',\\n')}\n }\n});\n`;\n}\n\nfunction moduleVarName(componentIdx: number, fileIdx: number) {\n return `file_${componentIdx}_${fileIdx}`;\n}\n\nfunction getEnvVarName(envId: string) {\n const envNameFormatted = camelcase(envId.replace('@', '').replace('.', '-').replace(/\\//g, '-'));\n const varName = `${envNameFormatted}MainModule`;\n return varName;\n}\n"],"mappings":"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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_graphqlRequest","data","require","GQL_SERVER","GET_COMPONENT_ASPECTS","gql","fetchComponentAspects","componentId","response","request","id","toString","getHost","get","aspects","map","x","err","console","error","undefined"],"sources":["fetch-component-aspects.tsx"],"sourcesContent":["import { request, gql } from 'graphql-request';\n\nconst GQL_SERVER = '/graphql';\nconst GET_COMPONENT_ASPECTS = gql`\n query getComponentAspects($id: String!) {\n getHost {\n id\n get(id: $id) {\n aspects {\n id\n }\n }\n }\n }\n`;\ntype QueryResult = {\n getHost: {\n id: string;\n get: {\n aspects: { id: string }[];\n };\n };\n};\n\nexport async function fetchComponentAspects(componentId: string) {\n try {\n const response = await request<QueryResult>(GQL_SERVER, GET_COMPONENT_ASPECTS, { id: componentId.toString() });\n return response.getHost.get.aspects.map((x) => x.id);\n } catch (err: any) {\n // eslint-disable-next-line no-console\n console.error(`[gql] error on \"getComponentAspects\" - \"${err.toString()}\"`);\n return undefined;\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["_graphqlRequest","data","require","GQL_SERVER","GET_COMPONENT_ASPECTS","gql","fetchComponentAspects","componentId","response","request","id","toString","getHost","get","aspects","map","x","err","console","error","undefined"],"sources":["fetch-component-aspects.tsx"],"sourcesContent":["import { request, gql } from 'graphql-request';\n\nconst GQL_SERVER = '/graphql';\nconst GET_COMPONENT_ASPECTS = gql`\n query getComponentAspects($id: String!) {\n getHost {\n id\n get(id: $id) {\n aspects {\n id\n }\n }\n }\n }\n`;\ntype QueryResult = {\n getHost: {\n id: string;\n get: {\n aspects: { id: string }[];\n };\n };\n};\n\nexport async function fetchComponentAspects(componentId: string) {\n try {\n const response = await request<QueryResult>(GQL_SERVER, GET_COMPONENT_ASPECTS, { id: componentId.toString() });\n return response.getHost.get.aspects.map((x) => x.id);\n } catch (err: any) {\n // eslint-disable-next-line no-console\n console.error(`[gql] error on \"getComponentAspects\" - \"${err.toString()}\"`);\n return undefined;\n }\n}\n"],"mappings":";;;;;;AAAA,SAAAA,gBAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,eAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,MAAME,UAAU,GAAG,UAAU;AAC7B,MAAMC,qBAAqB,GAAG,IAAAC,qBAAG,CAAC;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAUM,eAAeC,qBAAqBA,CAACC,WAAmB,EAAE;EAC/D,IAAI;IACF,MAAMC,QAAQ,GAAG,MAAM,IAAAC,yBAAO,EAAcN,UAAU,EAAEC,qBAAqB,EAAE;MAAEM,EAAE,EAAEH,WAAW,CAACI,QAAQ,CAAC;IAAE,CAAC,CAAC;IAC9G,OAAOH,QAAQ,CAACI,OAAO,CAACC,GAAG,CAACC,OAAO,CAACC,GAAG,CAAEC,CAAC,IAAKA,CAAC,CAACN,EAAE,CAAC;EACtD,CAAC,CAAC,OAAOO,GAAQ,EAAE;IACjB;IACAC,OAAO,CAACC,KAAK,CAAE,2CAA0CF,GAAG,CAACN,QAAQ,CAAC,CAAE,GAAE,CAAC;IAC3E,OAAOS,SAAS;EAClB;AACF"}
|
package/dist/html-utils.js
CHANGED
package/dist/html-utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["loadScript","src","Promise","resolve","reject","script","document","createElement","setAttribute","onload","onerror","message","_","_1","_2","error","Error","head","appendChild","loadLink","href","link","endsWith"],"sources":["html-utils.tsx"],"sourcesContent":["export function loadScript({ src }: { src: string }) {\n return new Promise<void>((resolve, reject) => {\n const script = document.createElement('script');\n\n script.setAttribute('defer', 'defer');\n script.src = src;\n\n script.onload = () => resolve();\n script.onerror = (message, _, _1, _2, error) =>\n reject(error || new Error(`[preview.preview] failed to load script: ${message}`));\n\n document.head.appendChild(script);\n });\n}\n\nexport function loadLink({ href }: { href: string }) {\n return new Promise<void>((resolve, reject) => {\n const link = document.createElement('link');\n\n if (href.endsWith('.css')) link.setAttribute('rel', 'stylesheet');\n link.setAttribute('href', href);\n\n link.onload = () => resolve();\n link.onerror = (message, _, _1, _2, error) =>\n reject(error || new Error(`[preview.preview] failed to load link: ${message}`));\n\n document.head.appendChild(link);\n });\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["loadScript","src","Promise","resolve","reject","script","document","createElement","setAttribute","onload","onerror","message","_","_1","_2","error","Error","head","appendChild","loadLink","href","link","endsWith"],"sources":["html-utils.tsx"],"sourcesContent":["export function loadScript({ src }: { src: string }) {\n return new Promise<void>((resolve, reject) => {\n const script = document.createElement('script');\n\n script.setAttribute('defer', 'defer');\n script.src = src;\n\n script.onload = () => resolve();\n script.onerror = (message, _, _1, _2, error) =>\n reject(error || new Error(`[preview.preview] failed to load script: ${message}`));\n\n document.head.appendChild(script);\n });\n}\n\nexport function loadLink({ href }: { href: string }) {\n return new Promise<void>((resolve, reject) => {\n const link = document.createElement('link');\n\n if (href.endsWith('.css')) link.setAttribute('rel', 'stylesheet');\n link.setAttribute('href', href);\n\n link.onload = () => resolve();\n link.onerror = (message, _, _1, _2, error) =>\n reject(error || new Error(`[preview.preview] failed to load link: ${message}`));\n\n document.head.appendChild(link);\n });\n}\n"],"mappings":";;;;;;;AAAO,SAASA,UAAUA,CAAC;EAAEC;AAAqB,CAAC,EAAE;EACnD,OAAO,IAAIC,OAAO,CAAO,CAACC,OAAO,EAAEC,MAAM,KAAK;IAC5C,MAAMC,MAAM,GAAGC,QAAQ,CAACC,aAAa,CAAC,QAAQ,CAAC;IAE/CF,MAAM,CAACG,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC;IACrCH,MAAM,CAACJ,GAAG,GAAGA,GAAG;IAEhBI,MAAM,CAACI,MAAM,GAAG,MAAMN,OAAO,CAAC,CAAC;IAC/BE,MAAM,CAACK,OAAO,GAAG,CAACC,OAAO,EAAEC,CAAC,EAAEC,EAAE,EAAEC,EAAE,EAAEC,KAAK,KACzCX,MAAM,CAACW,KAAK,IAAI,IAAIC,KAAK,CAAE,4CAA2CL,OAAQ,EAAC,CAAC,CAAC;IAEnFL,QAAQ,CAACW,IAAI,CAACC,WAAW,CAACb,MAAM,CAAC;EACnC,CAAC,CAAC;AACJ;AAEO,SAASc,QAAQA,CAAC;EAAEC;AAAuB,CAAC,EAAE;EACnD,OAAO,IAAIlB,OAAO,CAAO,CAACC,OAAO,EAAEC,MAAM,KAAK;IAC5C,MAAMiB,IAAI,GAAGf,QAAQ,CAACC,aAAa,CAAC,MAAM,CAAC;IAE3C,IAAIa,IAAI,CAACE,QAAQ,CAAC,MAAM,CAAC,EAAED,IAAI,CAACb,YAAY,CAAC,KAAK,EAAE,YAAY,CAAC;IACjEa,IAAI,CAACb,YAAY,CAAC,MAAM,EAAEY,IAAI,CAAC;IAE/BC,IAAI,CAACZ,MAAM,GAAG,MAAMN,OAAO,CAAC,CAAC;IAC7BkB,IAAI,CAACX,OAAO,GAAG,CAACC,OAAO,EAAEC,CAAC,EAAEC,EAAE,EAAEC,EAAE,EAAEC,KAAK,KACvCX,MAAM,CAACW,KAAK,IAAI,IAAIC,KAAK,CAAE,0CAAyCL,OAAQ,EAAC,CAAC,CAAC;IAEjFL,QAAQ,CAACW,IAAI,CAACC,WAAW,CAACG,IAAI,CAAC;EACjC,CAAC,CAAC;AACJ"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.preview_preview@0.0.
|
|
2
|
-
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.preview_preview@0.0.
|
|
1
|
+
import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.preview_preview@0.0.1159/dist/preview.composition.js';
|
|
2
|
+
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.preview_preview@0.0.1159/dist/preview.docs.mdx';
|
|
3
3
|
|
|
4
4
|
export const compositions = [compositions_0];
|
|
5
5
|
export const overview = [overview_0];
|
|
@@ -1,18 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
require("core-js/modules/es.promise.js");
|
|
5
3
|
Object.defineProperty(exports, "__esModule", {
|
|
6
4
|
value: true
|
|
7
5
|
});
|
|
8
6
|
exports.PreviewAssetsRoute = void 0;
|
|
9
|
-
function _defineProperty2() {
|
|
10
|
-
const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
_defineProperty2 = function () {
|
|
12
|
-
return data;
|
|
13
|
-
};
|
|
14
|
-
return data;
|
|
15
|
-
}
|
|
16
7
|
function _uiFoundationUiPages() {
|
|
17
8
|
const data = require("@teambit/ui-foundation.ui.pages.static-error");
|
|
18
9
|
_uiFoundationUiPages = function () {
|
|
@@ -20,6 +11,9 @@ function _uiFoundationUiPages() {
|
|
|
20
11
|
};
|
|
21
12
|
return data;
|
|
22
13
|
}
|
|
14
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
15
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
16
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
23
17
|
class PreviewAssetsRoute {
|
|
24
18
|
constructor(
|
|
25
19
|
/**
|
|
@@ -28,9 +22,9 @@ class PreviewAssetsRoute {
|
|
|
28
22
|
preview, logger) {
|
|
29
23
|
this.preview = preview;
|
|
30
24
|
this.logger = logger;
|
|
31
|
-
(
|
|
32
|
-
(
|
|
33
|
-
(
|
|
25
|
+
_defineProperty(this, "route", '/preview-assets');
|
|
26
|
+
_defineProperty(this, "method", 'get');
|
|
27
|
+
_defineProperty(this, "middlewares", [async (req, res) => {
|
|
34
28
|
try {
|
|
35
29
|
// @ts-ignore TODO: @guy please fix.
|
|
36
30
|
const component = req.component;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_uiFoundationUiPages","data","require","
|
|
1
|
+
{"version":3,"names":["_uiFoundationUiPages","data","require","_defineProperty","obj","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","arg","_toPrimitive","String","input","hint","prim","Symbol","toPrimitive","undefined","res","call","TypeError","Number","PreviewAssetsRoute","constructor","preview","logger","req","component","status","jsonp","error","result","getPreviewFiles","json","e","send","serverError","exports"],"sources":["preview-assets.route.ts"],"sourcesContent":["import type { Request, Response, Route } from '@teambit/express';\nimport type { Component } from '@teambit/component';\nimport { serverError } from '@teambit/ui-foundation.ui.pages.static-error';\nimport type { Logger } from '@teambit/logger';\n\nimport { PreviewMain } from './preview.main.runtime';\n\nexport class PreviewAssetsRoute implements Route {\n constructor(\n /**\n * preview extension.\n */\n private preview: PreviewMain,\n private logger: Logger\n ) {}\n\n route = '/preview-assets';\n method = 'get';\n\n middlewares = [\n async (req: Request, res: Response) => {\n try {\n // @ts-ignore TODO: @guy please fix.\n const component = req.component as Component | undefined;\n // if (!component) return res.status(404).send(noPreview());\n if (!component) return res.status(404).jsonp({ error: 'not found' });\n const result = await this.preview.getPreviewFiles(component);\n if (!result) return res.status(404).jsonp({ error: 'not found' });\n return res.json(result);\n } catch (e: any) {\n this.logger.error('failed getting preview assets', e);\n return res.status(500).send(serverError());\n }\n },\n ];\n}\n"],"mappings":";;;;;;AAEA,SAAAA,qBAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,oBAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAA2E,SAAAE,gBAAAC,GAAA,EAAAC,GAAA,EAAAC,KAAA,IAAAD,GAAA,GAAAE,cAAA,CAAAF,GAAA,OAAAA,GAAA,IAAAD,GAAA,IAAAI,MAAA,CAAAC,cAAA,CAAAL,GAAA,EAAAC,GAAA,IAAAC,KAAA,EAAAA,KAAA,EAAAI,UAAA,QAAAC,YAAA,QAAAC,QAAA,oBAAAR,GAAA,CAAAC,GAAA,IAAAC,KAAA,WAAAF,GAAA;AAAA,SAAAG,eAAAM,GAAA,QAAAR,GAAA,GAAAS,YAAA,CAAAD,GAAA,2BAAAR,GAAA,gBAAAA,GAAA,GAAAU,MAAA,CAAAV,GAAA;AAAA,SAAAS,aAAAE,KAAA,EAAAC,IAAA,eAAAD,KAAA,iBAAAA,KAAA,kBAAAA,KAAA,MAAAE,IAAA,GAAAF,KAAA,CAAAG,MAAA,CAAAC,WAAA,OAAAF,IAAA,KAAAG,SAAA,QAAAC,GAAA,GAAAJ,IAAA,CAAAK,IAAA,CAAAP,KAAA,EAAAC,IAAA,2BAAAK,GAAA,sBAAAA,GAAA,YAAAE,SAAA,4DAAAP,IAAA,gBAAAF,MAAA,GAAAU,MAAA,EAAAT,KAAA;AAKpE,MAAMU,kBAAkB,CAAkB;EAC/CC,WAAWA;EACT;AACJ;AACA;EACYC,OAAoB,EACpBC,MAAc,EACtB;IAAA,KAFQD,OAAoB,GAApBA,OAAoB;IAAA,KACpBC,MAAc,GAAdA,MAAc;IAAA1B,eAAA,gBAGhB,iBAAiB;IAAAA,eAAA,iBAChB,KAAK;IAAAA,eAAA,sBAEA,CACZ,OAAO2B,GAAY,EAAER,GAAa,KAAK;MACrC,IAAI;QACF;QACA,MAAMS,SAAS,GAAGD,GAAG,CAACC,SAAkC;QACxD;QACA,IAAI,CAACA,SAAS,EAAE,OAAOT,GAAG,CAACU,MAAM,CAAC,GAAG,CAAC,CAACC,KAAK,CAAC;UAAEC,KAAK,EAAE;QAAY,CAAC,CAAC;QACpE,MAAMC,MAAM,GAAG,MAAM,IAAI,CAACP,OAAO,CAACQ,eAAe,CAACL,SAAS,CAAC;QAC5D,IAAI,CAACI,MAAM,EAAE,OAAOb,GAAG,CAACU,MAAM,CAAC,GAAG,CAAC,CAACC,KAAK,CAAC;UAAEC,KAAK,EAAE;QAAY,CAAC,CAAC;QACjE,OAAOZ,GAAG,CAACe,IAAI,CAACF,MAAM,CAAC;MACzB,CAAC,CAAC,OAAOG,CAAM,EAAE;QACf,IAAI,CAACT,MAAM,CAACK,KAAK,CAAC,+BAA+B,EAAEI,CAAC,CAAC;QACrD,OAAOhB,GAAG,CAACU,MAAM,CAAC,GAAG,CAAC,CAACO,IAAI,CAAC,IAAAC,kCAAW,EAAC,CAAC,CAAC;MAC5C;IACF,CAAC,CACF;EApBE;AAqBL;AAACC,OAAA,CAAAf,kBAAA,GAAAA,kBAAA"}
|
package/dist/preview-modules.js
CHANGED
|
@@ -1,23 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
require("core-js/modules/es.array.iterator.js");
|
|
5
3
|
Object.defineProperty(exports, "__esModule", {
|
|
6
4
|
value: true
|
|
7
5
|
});
|
|
8
6
|
exports.PreviewModules = exports.PREVIEW_MODULES = void 0;
|
|
9
7
|
exports.linkModules = linkModules;
|
|
10
|
-
function
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
return data;
|
|
14
|
-
};
|
|
15
|
-
return data;
|
|
16
|
-
}
|
|
8
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
9
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
10
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
17
11
|
class PreviewModules extends Map {
|
|
18
12
|
constructor(...args) {
|
|
19
13
|
super(...args);
|
|
20
|
-
(
|
|
14
|
+
_defineProperty(this, "onSet", new Set());
|
|
21
15
|
}
|
|
22
16
|
set(id, preview) {
|
|
23
17
|
super.set(id, preview);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["PreviewModules","Map","constructor","args","
|
|
1
|
+
{"version":3,"names":["PreviewModules","Map","constructor","args","_defineProperty","Set","set","id","preview","onSet","forEach","callback","loadComponentPreviews","compId","previews","Object","entries","previewName","moduleFile","get","componentMap","exports","PREVIEW_MODULES","linkModules","previewModule"],"sources":["preview-modules.tsx"],"sourcesContent":["import type { PreviewModule, ModuleFile } from './types/preview-module';\n\ntype ModuleId = string;\n\nexport class PreviewModules extends Map<ModuleId, PreviewModule> {\n onSet = new Set<() => void>();\n\n override set(id: ModuleId, preview: PreviewModule) {\n super.set(id, preview);\n this.onSet.forEach((callback) => callback());\n return this;\n }\n\n loadComponentPreviews(compId: string, previews: Record<string, ModuleFile[]>) {\n Object.entries(previews).forEach(([previewName, moduleFile]) => {\n const preview = this.get(previewName);\n if (!preview) return; // TODO - ok for now\n\n preview.componentMap[compId] = moduleFile;\n });\n }\n}\n\nexport const PREVIEW_MODULES = new PreviewModules();\n\nexport function linkModules(previewName: string, previewModule: PreviewModule) {\n PREVIEW_MODULES.set(previewName, previewModule);\n}\n"],"mappings":";;;;;;;;;;AAIO,MAAMA,cAAc,SAASC,GAAG,CAA0B;EAAAC,YAAA,GAAAC,IAAA;IAAA,SAAAA,IAAA;IAAAC,eAAA,gBACvD,IAAIC,GAAG,CAAa,CAAC;EAAA;EAEpBC,GAAGA,CAACC,EAAY,EAAEC,OAAsB,EAAE;IACjD,KAAK,CAACF,GAAG,CAACC,EAAE,EAAEC,OAAO,CAAC;IACtB,IAAI,CAACC,KAAK,CAACC,OAAO,CAAEC,QAAQ,IAAKA,QAAQ,CAAC,CAAC,CAAC;IAC5C,OAAO,IAAI;EACb;EAEAC,qBAAqBA,CAACC,MAAc,EAAEC,QAAsC,EAAE;IAC5EC,MAAM,CAACC,OAAO,CAACF,QAAQ,CAAC,CAACJ,OAAO,CAAC,CAAC,CAACO,WAAW,EAAEC,UAAU,CAAC,KAAK;MAC9D,MAAMV,OAAO,GAAG,IAAI,CAACW,GAAG,CAACF,WAAW,CAAC;MACrC,IAAI,CAACT,OAAO,EAAE,OAAO,CAAC;;MAEtBA,OAAO,CAACY,YAAY,CAACP,MAAM,CAAC,GAAGK,UAAU;IAC3C,CAAC,CAAC;EACJ;AACF;AAACG,OAAA,CAAArB,cAAA,GAAAA,cAAA;AAEM,MAAMsB,eAAe,GAAG,IAAItB,cAAc,CAAC,CAAC;AAACqB,OAAA,CAAAC,eAAA,GAAAA,eAAA;AAE7C,SAASC,WAAWA,CAACN,WAAmB,EAAEO,aAA4B,EAAE;EAC7EF,eAAe,CAAChB,GAAG,CAACW,WAAW,EAAEO,aAAa,CAAC;AACjD"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
@@ -12,6 +11,7 @@ function _react() {
|
|
|
12
11
|
};
|
|
13
12
|
return data;
|
|
14
13
|
}
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
15
|
const Logo = () => /*#__PURE__*/_react().default.createElement("div", {
|
|
16
16
|
style: {
|
|
17
17
|
height: '100%',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","data","_interopRequireDefault","require","
|
|
1
|
+
{"version":3,"names":["_react","data","_interopRequireDefault","require","obj","__esModule","default","Logo","createElement","style","height","display","justifyContent","width","src","exports"],"sources":["preview.composition.tsx"],"sourcesContent":["import React from 'react';\n\nexport const Logo = () => (\n <div style={{ height: '100%', display: 'flex', justifyContent: 'center' }}>\n <img style={{ width: 70 }} src=\"https://static.bit.dev/extensions-icons/preview.svg\" />\n </div>\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,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAEnB,MAAMG,IAAI,GAAGA,CAAA,kBAClBP,MAAA,GAAAM,OAAA,CAAAE,aAAA;EAAKC,KAAK,EAAE;IAAEC,MAAM,EAAE,MAAM;IAAEC,OAAO,EAAE,MAAM;IAAEC,cAAc,EAAE;EAAS;AAAE,gBACxEZ,MAAA,GAAAM,OAAA,CAAAE,aAAA;EAAKC,KAAK,EAAE;IAAEI,KAAK,EAAE;EAAG,CAAE;EAACC,GAAG,EAAC;AAAqD,CAAE,CACnF,CACN;AAACC,OAAA,CAAAR,IAAA,GAAAA,IAAA"}
|
package/dist/preview.graphql.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
@@ -12,6 +11,7 @@ function _graphqlTag() {
|
|
|
12
11
|
};
|
|
13
12
|
return data;
|
|
14
13
|
}
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
15
|
function previewSchema(previewExtension) {
|
|
16
16
|
return {
|
|
17
17
|
typeDefs: (0, _graphqlTag().default)`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_graphqlTag","data","_interopRequireDefault","require","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 skipIncludes: ({ component }) => {\n // return true;\n return previewExtension.isSupportSkipIncludes(component);\n },\n },\n },\n };\n}\n"],"mappings":"
|
|
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 skipIncludes: ({ component }) => {\n // return true;\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,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;UACA,OAAON,gBAAgB,CAACe,qBAAqB,CAACT,SAAS,CAAC;QAC1D;MACF;IACF;EACF,CAAC;AACH"}
|
|
@@ -1,19 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
require("core-js/modules/es.array.iterator.js");
|
|
5
|
-
require("core-js/modules/es.promise.js");
|
|
6
3
|
Object.defineProperty(exports, "__esModule", {
|
|
7
4
|
value: true
|
|
8
5
|
});
|
|
9
6
|
exports.PreviewMain = void 0;
|
|
10
|
-
function _defineProperty2() {
|
|
11
|
-
const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
12
|
-
_defineProperty2 = function () {
|
|
13
|
-
return data;
|
|
14
|
-
};
|
|
15
|
-
return data;
|
|
16
|
-
}
|
|
17
7
|
function _builder() {
|
|
18
8
|
const data = require("@teambit/builder");
|
|
19
9
|
_builder = function () {
|
|
@@ -273,8 +263,12 @@ function _preview6() {
|
|
|
273
263
|
};
|
|
274
264
|
return data;
|
|
275
265
|
}
|
|
266
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
276
267
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
277
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (
|
|
268
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
269
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
270
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
271
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
278
272
|
const noopResult = {
|
|
279
273
|
results: [],
|
|
280
274
|
toString: () => `updating link file`
|
|
@@ -316,12 +310,12 @@ class PreviewMain {
|
|
|
316
310
|
this.workspace = workspace;
|
|
317
311
|
this.logger = logger;
|
|
318
312
|
this.dependencyResolver = dependencyResolver;
|
|
319
|
-
(
|
|
320
|
-
(
|
|
321
|
-
(
|
|
313
|
+
_defineProperty(this, "writeHash", new Map());
|
|
314
|
+
_defineProperty(this, "timestamp", Date.now());
|
|
315
|
+
_defineProperty(this, "executionRefs", new Map());
|
|
322
316
|
// TODO - executionContext should be responsible for updating components list, and emit 'update' events
|
|
323
317
|
// instead we keep track of changes
|
|
324
|
-
(
|
|
318
|
+
_defineProperty(this, "handleComponentChange", async (c, updater) => {
|
|
325
319
|
const env = this.envs.getEnv(c);
|
|
326
320
|
const envId = env.id.toString();
|
|
327
321
|
const executionRef = this.executionRefs.get(envId);
|
|
@@ -335,7 +329,7 @@ class PreviewMain {
|
|
|
335
329
|
await this.updateLinkFiles(executionRef.currentComponents, executionRef.executionCtx);
|
|
336
330
|
return noopResult;
|
|
337
331
|
});
|
|
338
|
-
(
|
|
332
|
+
_defineProperty(this, "handleComponentRemoval", cId => {
|
|
339
333
|
let component;
|
|
340
334
|
this.executionRefs.forEach(components => {
|
|
341
335
|
const found = components.get(cId);
|
|
@@ -419,7 +413,6 @@ class PreviewMain {
|
|
|
419
413
|
* @returns
|
|
420
414
|
*/
|
|
421
415
|
async calcPreviewDataFromEnv(component) {
|
|
422
|
-
var _envPreviewConfig$spl;
|
|
423
416
|
// Prevent infinite loop that caused by the fact that the env of the aspect env or the env env is the same as the component
|
|
424
417
|
// so we can't load it since during load we are trying to get env component and load it again
|
|
425
418
|
if (component.id.toStringWithoutVersion() === 'teambit.harmony/aspect' || component.id.toStringWithoutVersion() === 'teambit.envs/env') {
|
|
@@ -432,7 +425,7 @@ class PreviewMain {
|
|
|
432
425
|
const envPreviewConfig = this.getEnvPreviewConfig(env);
|
|
433
426
|
const data = {
|
|
434
427
|
strategyName: envPreviewConfig === null || envPreviewConfig === void 0 ? void 0 : envPreviewConfig.strategyName,
|
|
435
|
-
splitComponentBundle: (
|
|
428
|
+
splitComponentBundle: (envPreviewConfig === null || envPreviewConfig === void 0 ? void 0 : envPreviewConfig.splitComponentBundle) ?? false
|
|
436
429
|
};
|
|
437
430
|
return data;
|
|
438
431
|
}
|
|
@@ -443,14 +436,13 @@ class PreviewMain {
|
|
|
443
436
|
* @returns
|
|
444
437
|
*/
|
|
445
438
|
async calculateDataForEnvComponent(envComponent) {
|
|
446
|
-
var _previewAspectConfig$;
|
|
447
439
|
const isEnv = this.envs.isEnv(envComponent);
|
|
448
440
|
// If the component is not an env, we don't want to store anything in the data
|
|
449
441
|
if (!isEnv) return undefined;
|
|
450
442
|
const previewAspectConfig = this.getPreviewAspectConfig(envComponent);
|
|
451
443
|
const data = {
|
|
452
444
|
// default to true if the env doesn't have a preview config
|
|
453
|
-
isScaling: (
|
|
445
|
+
isScaling: (previewAspectConfig === null || previewAspectConfig === void 0 ? void 0 : previewAspectConfig.isScaling) ?? true
|
|
454
446
|
// disalbe it for now, we will re-enable it later
|
|
455
447
|
// skipIncludes: true,
|
|
456
448
|
};
|
|
@@ -545,7 +537,7 @@ class PreviewMain {
|
|
|
545
537
|
}
|
|
546
538
|
const envComponent = await this.envs.getEnvComponent(component);
|
|
547
539
|
const envSupportScaling = await this.calculateIsEnvSupportScaling(envComponent);
|
|
548
|
-
return envSupportScaling
|
|
540
|
+
return envSupportScaling ?? true;
|
|
549
541
|
}
|
|
550
542
|
const previewData = this.getPreviewData(component);
|
|
551
543
|
if (!previewData) return false;
|
|
@@ -589,13 +581,12 @@ class PreviewMain {
|
|
|
589
581
|
* @returns
|
|
590
582
|
*/
|
|
591
583
|
async calculateIsEnvSupportScaling(envComponent) {
|
|
592
|
-
var _previewAspectConfig$2;
|
|
593
584
|
const isEnv = this.envs.isEnv(envComponent);
|
|
594
585
|
// If the component is not an env, we don't want to store anything in the data
|
|
595
586
|
if (!isEnv) return undefined;
|
|
596
587
|
const previewAspectConfig = this.getPreviewAspectConfig(envComponent);
|
|
597
588
|
// default to true if the env doesn't have a preview config
|
|
598
|
-
return (
|
|
589
|
+
return (previewAspectConfig === null || previewAspectConfig === void 0 ? void 0 : previewAspectConfig.isScaling) ?? true;
|
|
599
590
|
}
|
|
600
591
|
|
|
601
592
|
/**
|
|
@@ -720,7 +711,7 @@ class PreviewMain {
|
|
|
720
711
|
updateLinkFiles(components = [], context) {
|
|
721
712
|
const previews = this.previewSlot.values();
|
|
722
713
|
const paths = previews.map(async previewDef => {
|
|
723
|
-
var _previewDef$renderTem
|
|
714
|
+
var _previewDef$renderTem;
|
|
724
715
|
const defaultTemplatePath = await ((_previewDef$renderTem = previewDef.renderTemplatePathByEnv) === null || _previewDef$renderTem === void 0 ? void 0 : _previewDef$renderTem.call(previewDef, context.env));
|
|
725
716
|
const visitedEnvs = new Set();
|
|
726
717
|
const mainModulesMap = {
|
|
@@ -729,7 +720,7 @@ class PreviewMain {
|
|
|
729
720
|
[context.envDefinition.id]: defaultTemplatePath
|
|
730
721
|
};
|
|
731
722
|
const map = await previewDef.getModuleMap(components);
|
|
732
|
-
const isSplitComponentBundle =
|
|
723
|
+
const isSplitComponentBundle = this.getEnvPreviewConfig().splitComponentBundle ?? false;
|
|
733
724
|
const withPathsP = map.asyncMap(async (files, component) => {
|
|
734
725
|
var _environment$getCompi, _compilerInstance$get;
|
|
735
726
|
const envDef = this.envs.getEnv(component);
|
|
@@ -873,10 +864,10 @@ class PreviewMain {
|
|
|
873
864
|
}
|
|
874
865
|
}
|
|
875
866
|
exports.PreviewMain = PreviewMain;
|
|
876
|
-
(
|
|
877
|
-
(
|
|
878
|
-
(
|
|
879
|
-
(
|
|
867
|
+
_defineProperty(PreviewMain, "slots", [_harmony().Slot.withType(), _harmony().Slot.withType()]);
|
|
868
|
+
_defineProperty(PreviewMain, "runtime", _cli().MainRuntime);
|
|
869
|
+
_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]);
|
|
870
|
+
_defineProperty(PreviewMain, "defaultConfig", {
|
|
880
871
|
disabled: false
|
|
881
872
|
});
|
|
882
873
|
_preview().PreviewAspect.addRuntime(PreviewMain);
|