@teambit/preview 1.0.149 → 1.0.151

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.
@@ -167,7 +167,7 @@ async function generateBundlePreviewEntry(rootAspectId, previewPreBundlePath, co
167
167
  const manifest = (0, _fsExtra().readJsonSync)(manifestPath);
168
168
  const imports = manifest.entrypoints.map(entry => {
169
169
  const entryPath = (0, _toolboxPath().toWindowsCompatiblePath)((0, _path().join)(previewPreBundlePath, entry));
170
- return entry.endsWith('.js') ? `import { run } from '${entryPath}';` : `import '${entryPath}';`;
170
+ return entry.endsWith('.js') || entry.endsWith('.cjs') || entry.endsWith('.mjs') ? `import { run } from '${entryPath}';` : `import '${entryPath}';`;
171
171
  }).join('\n');
172
172
  config['teambit.harmony/bit'] = rootAspectId;
173
173
  const contents = [imports, `run(${JSON.stringify(config, null, 2)});`].join('\n');
@@ -1 +1 @@
1
- {"version":3,"names":["_path","data","require","_fsExtra","_interopRequireWildcard","_harmonyModules","_utils","_toolboxPath","_webpack","_interopRequireDefault","_util","_preview","_webpack2","_preBundleUtils","obj","__esModule","default","_getRequireWildcardCache","e","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","RUNTIME_NAME","exports","PUBLIC_DIR","join","UIROOT_ASPECT_ID","ENTRY_CONTENT_TEMPLATE","generatePreBundlePreviewEntry","aspectDefs","rootExtensionName","runtimeName","rootAspectId","dir","harmonyImport","createHarmonyImports","imports","createImports","identifiers","getIdentifiers","idSetters","getIdSetters","contents","replace","replaceAll","JSON","stringify","entryPath","resolve","sha1","fs","existsSync","outputFileSync","buildPreBundlePreview","resolvedAspects","customOutputDir","outputDir","mainEntry","PreviewAspect","id","__dirname","config","createWebpackConfig","compiler","webpack","compilerRun","promisify","run","bind","results","Error","hasErrors","clearConsole","toString","generateBundlePreviewEntry","previewPreBundlePath","manifestPath","manifest","readJsonSync","entrypoints","map","entry","toWindowsCompatiblePath","endsWith","previewRuntime"],"sources":["pre-bundle.ts"],"sourcesContent":["import { join, resolve } from 'path';\nimport fs, { existsSync, outputFileSync, readJsonSync } from 'fs-extra';\nimport { AspectDefinition } from '@teambit/aspect-loader';\nimport {\n createHarmonyImports,\n createImports,\n getIdSetters,\n getIdentifiers,\n} from '@teambit/harmony.modules.harmony-root-generator';\nimport { sha1 } from '@teambit/legacy/dist/utils';\nimport { toWindowsCompatiblePath } from '@teambit/toolbox.path.to-windows-compatible-path';\nimport webpack from 'webpack';\nimport { promisify } from 'util';\nimport { PreviewAspect } from './preview.aspect';\nimport { createWebpackConfig } from './webpack/webpack.config';\nimport { clearConsole } from './pre-bundle-utils';\n\nexport const RUNTIME_NAME = 'preview';\nexport const PUBLIC_DIR = join('public', 'bit-preview');\nexport const UIROOT_ASPECT_ID = 'teambit.workspace/workspace';\n\nconst ENTRY_CONTENT_TEMPLATE = `__IMPORTS__\n\nexport const run = (config, customAspects = []) => {\n const isBrowser = typeof window !== \"undefined\";\n const windowConfig = isBrowser ? window.harmonyAppConfig : undefined;\n const mergedConfig = { ...config, ...windowConfig };\n __ID_SETTERS__\n function render(...props) {\n return Harmony.load(\n [\n ...customAspects,\n __IDENTIFIERS__,\n ],\n __RUNTIME_NAME__,\n mergedConfig\n ).then((harmony) => {\n return harmony\n .run()\n .then(() => harmony.get(__ROOT_ASPECT__))\n .then((rootExtension) => {\n const ssrSetup = !isBrowser && rootExtension.setupSsr;\n const setup = rootExtension.setup;\n const setupFunc = (ssrSetup || setup || function noop() {}).bind(\n rootExtension\n );\n return Promise.resolve(setupFunc()).then(\n () => {\n return rootExtension\n }\n );\n })\n .then((rootExtension) => {\n if (isBrowser) {\n return rootExtension.render(\n __ROOT_EXTENSION_NAME__,\n ...props\n );\n } else {\n return rootExtension.renderSsr(\n __ROOT_EXTENSION_NAME__,\n ...props\n );\n }\n })\n .catch((err) => {\n throw err;\n });\n });\n }\n if (isBrowser || __RUNTIME_NAME__ === \"main\") render();\n};\n`;\n\nexport const generatePreBundlePreviewEntry = (\n aspectDefs: AspectDefinition[],\n rootExtensionName: string,\n runtimeName: string,\n rootAspectId: string,\n dir: string\n) => {\n const harmonyImport = createHarmonyImports();\n const imports = createImports(aspectDefs);\n const identifiers = getIdentifiers(aspectDefs, 'Aspect');\n const idSetters = getIdSetters(aspectDefs, 'Aspect');\n const contents = ENTRY_CONTENT_TEMPLATE.replace('__IMPORTS__', [harmonyImport, imports].join('\\n'))\n .replace('__IDENTIFIERS__', identifiers.join(', '))\n .replace('__ID_SETTERS__', idSetters.join('\\n'))\n .replaceAll('__RUNTIME_NAME__', JSON.stringify(runtimeName))\n .replaceAll('__ROOT_ASPECT__', JSON.stringify(rootAspectId))\n .replaceAll('__ROOT_EXTENSION_NAME__', JSON.stringify(rootExtensionName));\n const entryPath = resolve(join(dir, `ui-bundle-entry.${sha1(contents)}.js`));\n if (!fs.existsSync(entryPath)) {\n fs.outputFileSync(entryPath, contents);\n }\n return entryPath;\n};\n\nexport async function buildPreBundlePreview(resolvedAspects: AspectDefinition[], customOutputDir?: string) {\n const outputDir = customOutputDir || resolve(PUBLIC_DIR);\n const mainEntry = generatePreBundlePreviewEntry(\n resolvedAspects,\n UIROOT_ASPECT_ID,\n RUNTIME_NAME,\n PreviewAspect.id,\n __dirname\n );\n const config = createWebpackConfig(outputDir, mainEntry);\n const compiler = webpack(config);\n const compilerRun = promisify(compiler.run.bind(compiler));\n const results = await compilerRun();\n if (!results) throw new Error();\n if (results?.hasErrors()) {\n clearConsole();\n throw new Error(results?.toString());\n }\n return results;\n}\n\nexport async function generateBundlePreviewEntry(rootAspectId: string, previewPreBundlePath: string, config: object) {\n const manifestPath = join(previewPreBundlePath, 'asset-manifest.json');\n const manifest = readJsonSync(manifestPath);\n const imports = manifest.entrypoints\n .map((entry: string) => {\n const entryPath = toWindowsCompatiblePath(join(previewPreBundlePath, entry));\n return entry.endsWith('.js') ? `import { run } from '${entryPath}';` : `import '${entryPath}';`;\n })\n .join('\\n');\n config['teambit.harmony/bit'] = rootAspectId;\n\n const contents = [imports, `run(${JSON.stringify(config, null, 2)});`].join('\\n');\n const previewRuntime = resolve(join(__dirname, `preview.entry.${sha1(contents)}.js`));\n\n if (!existsSync(previewRuntime)) {\n outputFileSync(previewRuntime, contents);\n }\n\n return previewRuntime;\n}\n"],"mappings":";;;;;;;;;AAAA,SAAAA,MAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,KAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,SAAA;EAAA,MAAAF,IAAA,GAAAG,uBAAA,CAAAF,OAAA;EAAAC,QAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAI,gBAAA;EAAA,MAAAJ,IAAA,GAAAC,OAAA;EAAAG,eAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAMA,SAAAK,OAAA;EAAA,MAAAL,IAAA,GAAAC,OAAA;EAAAI,MAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAM,aAAA;EAAA,MAAAN,IAAA,GAAAC,OAAA;EAAAK,YAAA,YAAAA,CAAA;IAAA,OAAAN,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAO,SAAA;EAAA,MAAAP,IAAA,GAAAQ,sBAAA,CAAAP,OAAA;EAAAM,QAAA,YAAAA,CAAA;IAAA,OAAAP,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAS,MAAA;EAAA,MAAAT,IAAA,GAAAC,OAAA;EAAAQ,KAAA,YAAAA,CAAA;IAAA,OAAAT,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAU,SAAA;EAAA,MAAAV,IAAA,GAAAC,OAAA;EAAAS,QAAA,YAAAA,CAAA;I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AC;EAErF,IAAI,CAAC,IAAAS,qBAAU,EAACiC,cAAc,CAAC,EAAE;IAC/B,IAAAhC,yBAAc,EAACgC,cAAc,EAAE1C,QAAQ,CAAC;EAC1C;EAEA,OAAO0C,cAAc;AACvB"}
1
+ {"version":3,"names":["_path","data","require","_fsExtra","_interopRequireWildcard","_harmonyModules","_utils","_toolboxPath","_webpack","_interopRequireDefault","_util","_preview","_webpack2","_preBundleUtils","obj","__esModule","default","_getRequireWildcardCache","e","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","RUNTIME_NAME","exports","PUBLIC_DIR","join","UIROOT_ASPECT_ID","ENTRY_CONTENT_TEMPLATE","generatePreBundlePreviewEntry","aspectDefs","rootExtensionName","runtimeName","rootAspectId","dir","harmonyImport","createHarmonyImports","imports","createImports","identifiers","getIdentifiers","idSetters","getIdSetters","contents","replace","replaceAll","JSON","stringify","entryPath","resolve","sha1","fs","existsSync","outputFileSync","buildPreBundlePreview","resolvedAspects","customOutputDir","outputDir","mainEntry","PreviewAspect","id","__dirname","config","createWebpackConfig","compiler","webpack","compilerRun","promisify","run","bind","results","Error","hasErrors","clearConsole","toString","generateBundlePreviewEntry","previewPreBundlePath","manifestPath","manifest","readJsonSync","entrypoints","map","entry","toWindowsCompatiblePath","endsWith","previewRuntime"],"sources":["pre-bundle.ts"],"sourcesContent":["import { join, resolve } from 'path';\nimport fs, { existsSync, outputFileSync, readJsonSync } from 'fs-extra';\nimport { AspectDefinition } from '@teambit/aspect-loader';\nimport {\n createHarmonyImports,\n createImports,\n getIdSetters,\n getIdentifiers,\n} from '@teambit/harmony.modules.harmony-root-generator';\nimport { sha1 } from '@teambit/legacy/dist/utils';\nimport { toWindowsCompatiblePath } from '@teambit/toolbox.path.to-windows-compatible-path';\nimport webpack from 'webpack';\nimport { promisify } from 'util';\nimport { PreviewAspect } from './preview.aspect';\nimport { createWebpackConfig } from './webpack/webpack.config';\nimport { clearConsole } from './pre-bundle-utils';\n\nexport const RUNTIME_NAME = 'preview';\nexport const PUBLIC_DIR = join('public', 'bit-preview');\nexport const UIROOT_ASPECT_ID = 'teambit.workspace/workspace';\n\nconst ENTRY_CONTENT_TEMPLATE = `__IMPORTS__\n\nexport const run = (config, customAspects = []) => {\n const isBrowser = typeof window !== \"undefined\";\n const windowConfig = isBrowser ? window.harmonyAppConfig : undefined;\n const mergedConfig = { ...config, ...windowConfig };\n __ID_SETTERS__\n function render(...props) {\n return Harmony.load(\n [\n ...customAspects,\n __IDENTIFIERS__,\n ],\n __RUNTIME_NAME__,\n mergedConfig\n ).then((harmony) => {\n return harmony\n .run()\n .then(() => harmony.get(__ROOT_ASPECT__))\n .then((rootExtension) => {\n const ssrSetup = !isBrowser && rootExtension.setupSsr;\n const setup = rootExtension.setup;\n const setupFunc = (ssrSetup || setup || function noop() {}).bind(\n rootExtension\n );\n return Promise.resolve(setupFunc()).then(\n () => {\n return rootExtension\n }\n );\n })\n .then((rootExtension) => {\n if (isBrowser) {\n return rootExtension.render(\n __ROOT_EXTENSION_NAME__,\n ...props\n );\n } else {\n return rootExtension.renderSsr(\n __ROOT_EXTENSION_NAME__,\n ...props\n );\n }\n })\n .catch((err) => {\n throw err;\n });\n });\n }\n if (isBrowser || __RUNTIME_NAME__ === \"main\") render();\n};\n`;\n\nexport const generatePreBundlePreviewEntry = (\n aspectDefs: AspectDefinition[],\n rootExtensionName: string,\n runtimeName: string,\n rootAspectId: string,\n dir: string\n) => {\n const harmonyImport = createHarmonyImports();\n const imports = createImports(aspectDefs);\n const identifiers = getIdentifiers(aspectDefs, 'Aspect');\n const idSetters = getIdSetters(aspectDefs, 'Aspect');\n const contents = ENTRY_CONTENT_TEMPLATE.replace('__IMPORTS__', [harmonyImport, imports].join('\\n'))\n .replace('__IDENTIFIERS__', identifiers.join(', '))\n .replace('__ID_SETTERS__', idSetters.join('\\n'))\n .replaceAll('__RUNTIME_NAME__', JSON.stringify(runtimeName))\n .replaceAll('__ROOT_ASPECT__', JSON.stringify(rootAspectId))\n .replaceAll('__ROOT_EXTENSION_NAME__', JSON.stringify(rootExtensionName));\n const entryPath = resolve(join(dir, `ui-bundle-entry.${sha1(contents)}.js`));\n if (!fs.existsSync(entryPath)) {\n fs.outputFileSync(entryPath, contents);\n }\n return entryPath;\n};\n\nexport async function buildPreBundlePreview(resolvedAspects: AspectDefinition[], customOutputDir?: string) {\n const outputDir = customOutputDir || resolve(PUBLIC_DIR);\n const mainEntry = generatePreBundlePreviewEntry(\n resolvedAspects,\n UIROOT_ASPECT_ID,\n RUNTIME_NAME,\n PreviewAspect.id,\n __dirname\n );\n const config = createWebpackConfig(outputDir, mainEntry);\n const compiler = webpack(config);\n const compilerRun = promisify(compiler.run.bind(compiler));\n const results = await compilerRun();\n if (!results) throw new Error();\n if (results?.hasErrors()) {\n clearConsole();\n throw new Error(results?.toString());\n }\n return results;\n}\n\nexport async function generateBundlePreviewEntry(rootAspectId: string, previewPreBundlePath: string, config: object) {\n const manifestPath = join(previewPreBundlePath, 'asset-manifest.json');\n const manifest = readJsonSync(manifestPath);\n const imports = manifest.entrypoints\n .map((entry: string) => {\n const entryPath = toWindowsCompatiblePath(join(previewPreBundlePath, entry));\n return entry.endsWith('.js') || entry.endsWith('.cjs') || entry.endsWith('.mjs')\n ? `import { run } from '${entryPath}';`\n : `import '${entryPath}';`;\n })\n .join('\\n');\n config['teambit.harmony/bit'] = rootAspectId;\n\n const contents = [imports, `run(${JSON.stringify(config, null, 2)});`].join('\\n');\n const previewRuntime = resolve(join(__dirname, `preview.entry.${sha1(contents)}.js`));\n\n if (!existsSync(previewRuntime)) {\n outputFileSync(previewRuntime, contents);\n }\n\n return previewRuntime;\n}\n"],"mappings":";;;;;;;;;AAAA,SAAAA,MAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,KAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,SAAA;EAAA,M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AAoB,EAAE2C,oBAA4B,EAAEd,MAAc,EAAE;EACnH,MAAMe,YAAY,GAAG,IAAAnD,YAAI,EAACkD,oBAAoB,EAAE,qBAAqB,CAAC;EACtE,MAAME,QAAQ,GAAG,IAAAC,uBAAY,EAACF,YAAY,CAAC;EAC3C,MAAMxC,OAAO,GAAGyC,QAAQ,CAACE,WAAW,CACjCC,GAAG,CAAEC,KAAa,IAAK;IACtB,MAAMlC,SAAS,GAAG,IAAAmC,sCAAuB,EAAC,IAAAzD,YAAI,EAACkD,oBAAoB,EAAEM,KAAK,CAAC,CAAC;IAC5E,OAAOA,KAAK,CAACE,QAAQ,CAAC,KAAK,CAAC,IAAIF,KAAK,CAACE,QAAQ,CAAC,MAAM,CAAC,IAAIF,KAAK,CAACE,QAAQ,CAAC,MAAM,CAAC,GAC3E,wBAAuBpC,SAAU,IAAG,GACpC,WAAUA,SAAU,IAAG;EAC9B,CAAC,CAAC,CACDtB,IAAI,CAAC,IAAI,CAAC;EACboC,MAAM,CAAC,qBAAqB,CAAC,GAAG7B,YAAY;EAE5C,MAAMU,QAAQ,GAAG,CAACN,OAAO,EAAG,OAAMS,IAAI,CAACC,SAAS,CAACe,MAAM,EAAE,IAAI,EAAE,CAAC,CAAE,IAAG,CAAC,CAACpC,IAAI,CAAC,IAAI,CAAC;EACjF,MAAM2D,cAAc,GAAG,IAAApC,eAAO,EAAC,IAAAvB,YAAI,EAACmC,SAAS,EAAG,iBAAgB,IAAAX,aAAI,EAACP,QAAQ,CAAE,KAAI,CAAC,CAAC;EAErF,IAAI,CAAC,IAAAS,qBAAU,EAACiC,cAAc,CAAC,EAAE;IAC/B,IAAAhC,yBAAc,EAACgC,cAAc,EAAE1C,QAAQ,CAAC;EAC1C;EAEA,OAAO0C,cAAc;AACvB"}
@@ -1,5 +1,5 @@
1
- import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.preview_preview@1.0.149/dist/preview.composition.js';
2
- import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.preview_preview@1.0.149/dist/preview.docs.mdx';
1
+ import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.preview_preview@1.0.151/dist/preview.composition.js';
2
+ import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.preview_preview@1.0.151/dist/preview.docs.mdx';
3
3
 
4
4
  export const compositions = [compositions_0];
5
5
  export const overview = [overview_0];
@@ -172,6 +172,13 @@ function _scope() {
172
172
  };
173
173
  return data;
174
174
  }
175
+ function _featureToggle() {
176
+ const data = require("@teambit/legacy/dist/api/consumer/lib/feature-toggle");
177
+ _featureToggle = function () {
178
+ return data;
179
+ };
180
+ return data;
181
+ }
175
182
  function _exceptions() {
176
183
  const data = require("./exceptions");
177
184
  _exceptions = function () {
@@ -634,7 +641,7 @@ class PreviewMain {
634
641
  return !!previewData?.isScaling;
635
642
  }
636
643
  async isSupportSkipIncludes(component) {
637
- if (!this.config.onlyOverview) return false;
644
+ if (!this.config.onlyOverview && !(0, _featureToggle().isFeatureEnabled)(_featureToggle().ONLY_OVERVIEW)) return false;
638
645
  const isCore = this.envs.isUsingCoreEnv(component);
639
646
  if (isCore) return false;
640
647
  const envComponent = await this.envs.getEnvComponent(component);
@@ -646,7 +653,7 @@ class PreviewMain {
646
653
  * check if the component preview should only include the overview (skipping rendering of the compostions and properties table)
647
654
  */
648
655
  async getOnlyOverview(component) {
649
- if (!this.config.onlyOverview) return false;
656
+ if (!this.config.onlyOverview && !(0, _featureToggle().isFeatureEnabled)(_featureToggle().ONLY_OVERVIEW)) return false;
650
657
  const previewData = this.getPreviewData(component);
651
658
  return previewData?.onlyOverview ?? false;
652
659
  }
@@ -1 +1 @@
1
- {"version":3,"names":["_builder","data","require","_bundler","_pubsub","_cli","_component","_envs","_harmony","_ui","_cache","_constants","_bitError","_objectHash","_interopRequireDefault","_lodash","_fsExtra","_path","_pkg","_aspectLoader","_workspace","_logger","_dependencyResolver","_artifactFiles","_watcher","_graphql","_scope","_exceptions","_generateLink","_previewArtifact","_preview","_preview2","_preview3","_strategies","_executionRef","_preview4","_envPreviewTemplate","_envTemplate","_componentPreview","_preview5","_previewAssets","_preview6","_preBundle","_preBundle2","_preBundleUtils","obj","__esModule","default","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","key","value","_toPropertyKey","configurable","writable","i","_toPrimitive","String","Symbol","toPrimitive","call","TypeError","Number","noopResult","results","toString","DEFAULT_TEMP_DIR","join","CACHE_ROOT","PreviewAspect","id","PreviewMain","constructor","harmony","previewSlot","ui","cache","envs","componentAspect","pkg","aspectLoader","config","bundlingStrategySlot","builder","workspace","logger","dependencyResolver","Map","Date","now","c","updater","env","getEnv","envId","executionRef","executionRefs","get","warn","updateLinkFiles","currentComponents","executionCtx","cId","component","components","found","Promise","resolve","handleComponentChange","remove","tempFolder","getTempDir","getComponentBundleSize","getDataByAspect","undefined","COMPONENT_STRATEGY_SIZE_KEY_NAME","getPreview","artifacts","getArtifactsVinylByAspectAndTaskName","PREVIEW_TASK_NAME","PreviewArtifact","getPreviewFiles","isBundledWithEnv","files","getPaths","getPreviewAspectConfig","state","aspects","getPreviewData","previewData","doesEnvIncludesOnlyOverview","envComponent","supportsOnlyOverview","doesEnvUseNameParam","supportsUseNameParam","calculateIncludeOnlyOverview","isUsingCoreEnv","getEnvComponent","calculateUseNameParam","calcPreviewData","doesScaling","calcDoesScalingForComponent","dataFromEnv","calcPreviewDataFromEnv","envData","calculateDataForEnvComponent","onlyOverview","useNameParam","toStringWithoutVersion","strategyName","COMPONENT_PREVIEW_STRATEGY_NAME","splitComponentBundle","envPreviewConfig","getEnvPreviewConfig","isEnv","previewAspectConfig","isScaling","calcIsBundledWithEnv","envPreviewData","isBundledWithEnvBackward","ENV_PREVIEW_STRATEGY_NAME","getArtifactsVinylByAspectAndName","COMPONENT_STRATEGY_ARTIFACT_NAME","isNew","isEnvSupportScaling","inWorkspace","hasId","envSupportScaling","calculateIsEnvSupportScaling","isSupportSkipIncludes","isCore","skipIncludes","getOnlyOverview","getUseNameParam","isLegacyHeader","ENV_WITH_LEGACY_DOCS","ENV_STRATEGY_ARTIFACT_NAME","envType","getEnvData","type","includes","getEnvTemplate","GENERATE_ENV_TEMPLATE_TASK_NAME","getCoreEnvTemplate","coreEnvDir","getAspectDir","artifactDef","getEnvTemplateArtifactDef","artifactFactory","ArtifactFactory","rootDir","getRootDir","existsSync","coreEnvDirFromBvm","getAspectDirFromBvm","paths","resolvePaths","artifactFiles","ArtifactFiles","populateVinylsFromPaths","vinyls","getEnvTemplateFromComponentEnv","getEnvId","getEnvTemplateByEnvId","isCoreEnv","host","getHost","resolvedEnvId","resolveComponentId","BitError","getDefs","values","writeLink","prefix","moduleMap","mainModulesMap","dirName","isSplitComponentBundle","contents","generateLink","writeLinkContents","targetDir","hash","objectHash","targetPath","timestamp","writeHash","writeFileSync","set","getPreviewTarget","context","relatedContexts","ctxId","ExecutionRef","previewRuntime","writePreviewEntry","linkFiles","aspectsIdsToNotFilterOut","rebuild","skipUiBuild","runtimeOptions","name","uiRoot","getUi","cacheKey","path","RUNTIME_NAME","currentBundleHash","createBundleHash","preBundleHash","readBundleHash","BUNDLE_DIR","workspaceBundleDir","PUBLIC_DIR","lastBundleHash","bundlePath","getBundlePath","resolvedAspects","resolveAspects","PreviewRuntime","filteredAspects","filterAspectsByExecutionContext","buildPreBundlePreview","generateBundlePreviewEntry","toObject","previews","map","previewDef","defaultTemplatePath","renderTemplatePathByEnv","visitedEnvs","Set","envDefinition","getModuleMap","withPathsP","asyncMap","envDef","environment","has","modulePath","add","compilerInstance","getCompiler","getPreviewComponentRootPath","getRuntimeModulePath","file","distRelativePath","getDistPathBySrcPath","relative","withPaths","dirPath","mkdirSync","recursive","link","all","writePreviewRuntime","filePath","generateRoot","runtimeName","componentIds","opts","root","MainRuntime","Error","allComponentContextAspects","reduce","acc","curr","concat","ids","hostAspects","allAspectsToInclude","uniq","filtered","aspect","getId","isCoreAspect","getDefaultStrategies","EnvBundlingStrategy","ComponentBundlingStrategy","getPreviewConfig","getBundlingStrategy","defaultStrategies","strategyFromEnv","bundlingStrategy","strategies","selected","find","strategy","BundlingStrategyNotFound","registerBundlingStrategy","register","registerDefinition","provider","bundler","componentExtension","uiMain","pubsub","loggerMain","graphql","watcher","scope","createLogger","preview","registerStartPlugin","PreviewStartPlugin","registerRoute","PreviewRoute","ComponentPreviewRoute","EnvTemplateRoute","PreviewAssetsRoute","registerTarget","entry","bind","disabled","registerBuildTasks","EnvPreviewTemplateTask","PreviewTask","PreBundlePreviewTask","registerOnComponentAdd","registerOnComponentLoad","registerOnComponentChange","update","registerOnComponentRemove","handleComponentRemoval","registerOnCompAspectReCalc","registerService","PreviewService","previewSchema","exports","Slot","withType","BundlerAspect","BuilderAspect","ComponentAspect","UIAspect","CacheAspect","EnvsAspect","WorkspaceAspect","PkgAspect","PubsubAspect","AspectLoaderAspect","LoggerAspect","DependencyResolverAspect","GraphqlAspect","WatcherAspect","ScopeAspect","addRuntime"],"sources":["preview.main.runtime.ts"],"sourcesContent":["import { ArtifactFactory, BuilderAspect } from '@teambit/builder';\nimport type { BuilderMain } from '@teambit/builder';\nimport { Asset, BundlerAspect, BundlerMain } from '@teambit/bundler';\nimport { PubsubAspect, PubsubMain } from '@teambit/pubsub';\nimport { MainRuntime } from '@teambit/cli';\nimport {\n Component,\n ComponentAspect,\n ComponentMain,\n ComponentMap,\n ComponentID,\n ResolveAspectsOptions,\n} from '@teambit/component';\nimport { EnvsAspect } from '@teambit/envs';\nimport type { EnvsMain, ExecutionContext, PreviewEnv } from '@teambit/envs';\nimport { Slot, SlotRegistry, Harmony } from '@teambit/harmony';\nimport { UIAspect, UiMain, UIRoot } from '@teambit/ui';\nimport { CacheAspect, CacheMain } from '@teambit/cache';\nimport { CACHE_ROOT } from '@teambit/legacy/dist/constants';\nimport { BitError } from '@teambit/bit-error';\nimport objectHash from 'object-hash';\nimport { uniq } from 'lodash';\nimport { writeFileSync, existsSync, mkdirSync } from 'fs-extra';\nimport { join } from 'path';\nimport { PkgAspect, PkgMain } from '@teambit/pkg';\nimport { AspectLoaderAspect, getAspectDir, getAspectDirFromBvm } from '@teambit/aspect-loader';\nimport type { AspectDefinition, AspectLoaderMain } from '@teambit/aspect-loader';\nimport WorkspaceAspect, { Workspace } from '@teambit/workspace';\nimport { LoggerAspect, LoggerMain, Logger } from '@teambit/logger';\nimport { DependencyResolverAspect } from '@teambit/dependency-resolver';\nimport type { DependencyResolverMain } from '@teambit/dependency-resolver';\nimport { ArtifactFiles } from '@teambit/legacy/dist/consumer/component/sources/artifact-files';\nimport WatcherAspect, { WatcherMain } from '@teambit/watcher';\nimport GraphqlAspect, { GraphqlMain } from '@teambit/graphql';\nimport ScopeAspect, { ScopeMain } from '@teambit/scope';\nimport { BundlingStrategyNotFound } from './exceptions';\nimport { generateLink, MainModulesMap } from './generate-link';\nimport { PreviewArtifact } from './preview-artifact';\nimport { PreviewDefinition } from './preview-definition';\nimport { PreviewAspect, PreviewRuntime } from './preview.aspect';\nimport { PreviewRoute } from './preview.route';\nimport { PreviewTask, PREVIEW_TASK_NAME } from './preview.task';\nimport { BundlingStrategy } from './bundling-strategy';\nimport {\n EnvBundlingStrategy,\n ComponentBundlingStrategy,\n COMPONENT_STRATEGY_ARTIFACT_NAME,\n COMPONENT_STRATEGY_SIZE_KEY_NAME,\n ENV_PREVIEW_STRATEGY_NAME,\n ENV_STRATEGY_ARTIFACT_NAME,\n COMPONENT_PREVIEW_STRATEGY_NAME,\n} from './strategies';\nimport { ExecutionRef } from './execution-ref';\nimport { PreviewStartPlugin } from './preview.start-plugin';\nimport {\n EnvPreviewTemplateTask,\n GENERATE_ENV_TEMPLATE_TASK_NAME,\n getArtifactDef as getEnvTemplateArtifactDef,\n} from './env-preview-template.task';\nimport { EnvTemplateRoute } from './env-template.route';\nimport { ComponentPreviewRoute } from './component-preview.route';\nimport { previewSchema } from './preview.graphql';\nimport { PreviewAssetsRoute } from './preview-assets.route';\nimport { PreviewService } from './preview.service';\nimport { PUBLIC_DIR, RUNTIME_NAME, buildPreBundlePreview, generateBundlePreviewEntry } from './pre-bundle';\nimport { BUNDLE_DIR, PreBundlePreviewTask } from './pre-bundle.task';\nimport { createBundleHash, getBundlePath, readBundleHash } from './pre-bundle-utils';\n\nconst noopResult = {\n results: [],\n toString: () => `updating link file`,\n};\n\nconst DEFAULT_TEMP_DIR = join(CACHE_ROOT, PreviewAspect.id);\n\nexport type PreviewDefinitionRegistry = SlotRegistry<PreviewDefinition>;\n\nexport type PreviewStrategyName = 'env' | 'component';\n\nexport type PreviewFiles = {\n files: string[];\n isBundledWithEnv: boolean;\n};\n\nexport type ComponentPreviewSizedFile = Asset;\n\nexport type ComponentPreviewSize = {\n files: ComponentPreviewSizedFile[];\n assets: ComponentPreviewSizedFile[];\n totalFiles: number;\n compressedTotalFiles?: number;\n totalAssets: number;\n compressedTotalAssets?: number;\n total: number;\n compressedTotal?: number;\n};\n\nexport type ComponentPreviewMetaData = {\n size?: ComponentPreviewSize;\n};\n\nexport type PreviewVariantConfig = {\n isScaling?: boolean;\n};\n\n/**\n * Preview data that stored on the component on load\n */\nexport type PreviewComponentData = PreviewAnyComponentData & PreviewEnvComponentData;\n\n/**\n * Preview data that stored on the component on load for any component\n */\nexport type PreviewAnyComponentData = {\n doesScaling?: boolean;\n /**\n * The strategy configured by the component's env\n */\n strategyName?: PreviewStrategyName;\n /**\n * Does the component has a bundle for the component itself (separated from the compositions/docs)\n * Calculated by the component's env\n */\n splitComponentBundle?: boolean;\n\n /**\n * don't allow other aspects implementing a preview definition to be included in your preview.\n */\n onlyOverview?: boolean;\n\n /**\n * use name query params to select a specific composition to render.\n */\n useNameParam?: boolean;\n\n /**\n * don't allow other aspects implementing a preview definition to be included in your preview.\n */\n skipIncludes?: boolean;\n};\n\n/**\n * Preview data that stored on the component on load if the component is an env\n */\nexport type PreviewEnvComponentData = {\n isScaling?: boolean;\n supportsOnlyOverview?: boolean;\n supportsUseNameParam?: boolean;\n};\n\nexport type PreviewConfig = {\n bundlingStrategy?: string;\n disabled: boolean;\n /**\n * limit concurrent components when running the bundling step for your bundler during generate components preview task.\n * this helps mitigate large memory consumption for the build pipeline. This may increase the overall time for the generate-preview task, but reduce memory footprint.\n * default - no limit.\n */\n maxChunkSize?: number;\n onlyOverview?: boolean;\n};\n\nexport type EnvPreviewConfig = {\n strategyName?: PreviewStrategyName;\n splitComponentBundle?: boolean;\n};\n\nexport type BundlingStrategySlot = SlotRegistry<BundlingStrategy>;\n\nexport type GenerateLinkFn = (prefix: string, componentMap: ComponentMap<string[]>, defaultModule?: string) => string;\n\nexport class PreviewMain {\n constructor(\n /**\n * harmony context.\n */\n private harmony: Harmony,\n\n /**\n * slot for preview definitions.\n */\n private previewSlot: PreviewDefinitionRegistry,\n\n private ui: UiMain,\n\n private cache: CacheMain,\n\n private envs: EnvsMain,\n\n private componentAspect: ComponentMain,\n\n private pkg: PkgMain,\n\n private aspectLoader: AspectLoaderMain,\n\n readonly config: PreviewConfig,\n\n private bundlingStrategySlot: BundlingStrategySlot,\n\n private builder: BuilderMain,\n\n private workspace: Workspace | undefined,\n\n private logger: Logger,\n\n private dependencyResolver: DependencyResolverMain\n ) {}\n\n get tempFolder(): string {\n return this.workspace?.getTempDir(PreviewAspect.id) || DEFAULT_TEMP_DIR;\n }\n\n getComponentBundleSize(component: Component): ComponentPreviewSize | undefined {\n const data = this.builder.getDataByAspect(component, PreviewAspect.id);\n\n if (!data) return undefined;\n return data[COMPONENT_STRATEGY_SIZE_KEY_NAME];\n }\n\n async getPreview(component: Component): Promise<PreviewArtifact | undefined> {\n const artifacts = await this.builder.getArtifactsVinylByAspectAndTaskName(\n component,\n PreviewAspect.id,\n PREVIEW_TASK_NAME\n );\n if (!artifacts) return undefined;\n return new PreviewArtifact(artifacts);\n }\n\n /**\n * Get a list of all the artifact files generated during the GeneratePreview task\n * @param component\n * @returns\n */\n async getPreviewFiles(component: Component): Promise<PreviewFiles | undefined> {\n const artifacts = await this.getPreview(component);\n const isBundledWithEnv = await this.isBundledWithEnv(component);\n if (!artifacts) return undefined;\n return {\n files: artifacts.getPaths(),\n isBundledWithEnv,\n };\n }\n\n /**\n * Get the preview config of the component.\n * (config that was set by variants or on bitmap)\n * @param component\n * @returns\n */\n getPreviewAspectConfig(component: Component): PreviewVariantConfig | undefined {\n return component.state.aspects.get(PreviewAspect.id)?.config;\n }\n\n /**\n * Get the preview data of the component.\n * (data that was calculated during the on load process)\n * @param component\n * @returns\n */\n getPreviewData(component: Component): PreviewComponentData | undefined {\n const previewData = component.state.aspects.get(PreviewAspect.id)?.data;\n return previewData;\n }\n\n /**\n * check if the current version of env component supports skipping other included previews\n * @param envComponent\n * @returns\n */\n doesEnvIncludesOnlyOverview(envComponent: Component): boolean {\n const previewData = this.getPreviewData(envComponent);\n return !!previewData?.supportsOnlyOverview;\n }\n\n /**\n * check if the current version of env component supports name query param\n * @param envComponent\n * @returns\n */\n doesEnvUseNameParam(envComponent: Component): boolean {\n const previewData = this.getPreviewData(envComponent);\n return !!previewData?.supportsUseNameParam;\n }\n\n private async calculateIncludeOnlyOverview(component: Component): Promise<boolean> {\n if (this.envs.isUsingCoreEnv(component)) {\n return true;\n }\n const envComponent = await this.envs.getEnvComponent(component);\n return this.doesEnvIncludesOnlyOverview(envComponent);\n }\n\n private async calculateUseNameParam(component: Component): Promise<boolean> {\n if (this.envs.isUsingCoreEnv(component)) {\n return true;\n }\n const envComponent = await this.envs.getEnvComponent(component);\n return this.doesEnvUseNameParam(envComponent);\n }\n\n /**\n * Calculate preview data on component load\n * @param component\n * @returns\n */\n async calcPreviewData(component: Component): Promise<PreviewComponentData> {\n const doesScaling = await this.calcDoesScalingForComponent(component);\n const dataFromEnv = await this.calcPreviewDataFromEnv(component);\n const envData = (await this.calculateDataForEnvComponent(component)) || {};\n const onlyOverview = await this.calculateIncludeOnlyOverview(component);\n const useNameParam = await this.calculateUseNameParam(component);\n\n const data: PreviewComponentData = {\n doesScaling,\n onlyOverview,\n useNameParam,\n ...dataFromEnv,\n ...envData,\n };\n return data;\n }\n\n /**\n * Calculate preview data on component that configured by its env\n * @param component\n * @returns\n */\n async calcPreviewDataFromEnv(\n component: Component\n ): Promise<Omit<PreviewAnyComponentData, 'doesScaling' | 'onlyOverview' | 'useNameParam'> | undefined> {\n // 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\n // so we can't load it since during load we are trying to get env component and load it again\n if (\n component.id.toStringWithoutVersion() === 'teambit.harmony/aspect' ||\n component.id.toStringWithoutVersion() === 'teambit.envs/env'\n ) {\n return {\n strategyName: COMPONENT_PREVIEW_STRATEGY_NAME,\n splitComponentBundle: false,\n };\n }\n\n const env = this.envs.getEnv(component).env;\n const envPreviewConfig = this.getEnvPreviewConfig(env);\n const data = {\n strategyName: envPreviewConfig?.strategyName,\n splitComponentBundle: envPreviewConfig?.splitComponentBundle ?? false,\n };\n return data;\n }\n\n /**\n * calculate extra preview data for env components (on load)\n * @param envComponent\n * @returns\n */\n private async calculateDataForEnvComponent(envComponent: Component): Promise<PreviewEnvComponentData | undefined> {\n const isEnv = this.envs.isEnv(envComponent);\n\n // If the component is not an env, we don't want to store anything in the data\n if (!isEnv) return undefined;\n\n const previewAspectConfig = this.getPreviewAspectConfig(envComponent);\n\n const data = {\n // default to true if the env doesn't have a preview config\n isScaling: previewAspectConfig?.isScaling ?? true,\n supportsOnlyOverview: true,\n supportsUseNameParam: true,\n };\n return data;\n }\n\n /**\n * Check if the component preview bundle contain the env as part of the bundle or only the component code\n * (we used in the past to bundle them together, there might also be specific envs which still uses the env strategy)\n * This should be used only for calculating the value on load.\n * otherwise, use the isBundledWithEnv function\n * @param component\n * @returns\n */\n async calcIsBundledWithEnv(component: Component): Promise<boolean> {\n const envPreviewData = await this.calcPreviewDataFromEnv(component);\n return envPreviewData?.strategyName !== 'component';\n }\n\n /**\n * Check if the component preview bundle contain the env as part of the bundle or only the component code\n * (we used in the past to bundle them together, there might also be specific envs which still uses the env strategy)\n * @param component\n * @returns\n */\n async isBundledWithEnv(component: Component): Promise<boolean> {\n const data = await this.getPreviewData(component);\n // For components that tagged in the past we didn't store the data, so we calculate it the old way\n // We comparing the strategyName to undefined to cover a specific case when it doesn't exist at all.\n if (!data || data.strategyName === undefined) return this.isBundledWithEnvBackward(component);\n return data.strategyName === ENV_PREVIEW_STRATEGY_NAME;\n }\n\n /**\n * This is a legacy calculation for the isBundledWithEnv\n * This calc is based on the component artifacts which is very expensive operation as it requires to fetch and load the artifacts\n * See the new implementation in the isBundledWithEnv method\n * @param component\n * @returns\n */\n private async isBundledWithEnvBackward(component: Component): Promise<boolean> {\n const artifacts = await this.builder.getArtifactsVinylByAspectAndName(\n component,\n PreviewAspect.id,\n COMPONENT_STRATEGY_ARTIFACT_NAME\n );\n if (!artifacts || !artifacts.length) return true;\n\n return false;\n }\n\n // This used on component load to calc the final result of support is scaling for a given component\n // This calc based on the env, env data, env preview config and more\n // if you want to get the final result use the `doesScaling` method below\n // This should be used only for component load\n private async calcDoesScalingForComponent(component: Component): Promise<boolean> {\n const isBundledWithEnv = await this.calcIsBundledWithEnv(component);\n // if it's a core env and the env template is apart from the component it means the template bundle already contain the scaling functionality\n if (this.envs.isUsingCoreEnv(component)) {\n // If the component is new, no point to check the is bundle with env (there is no artifacts so it will for sure return false)\n // If it's new, and we are here, it means that we already use a version of the env that support scaling\n const isNew = await component.isNew();\n if (isNew) {\n return true;\n }\n return isBundledWithEnv === false;\n }\n // For envs that bundled with the env return true always\n if (isBundledWithEnv) {\n return true;\n }\n const envComponent = await this.envs.getEnvComponent(component);\n return this.isEnvSupportScaling(envComponent);\n }\n\n /**\n * can the current component preview scale in size for different preview sizes.\n * this calculation is based on the env of the component and if the env of the component support it.\n */\n async doesScaling(component: Component): Promise<boolean> {\n const inWorkspace = await this.workspace?.hasId(component.id);\n // Support case when we have the dev server for the env, in that case we calc the data of the env as we can't rely on the env data from the scope\n // since we bundle it for the dev server again\n if (inWorkspace) {\n // if it's a core env and the env template is apart from the component it means the template bundle already contain the scaling functionality\n if (this.envs.isUsingCoreEnv(component)) {\n const isBundledWithEnv = await this.isBundledWithEnv(component);\n // If the component is new, no point to check the is bundle with env (there is no artifacts so it will for sure return false)\n // If it's new, and we are here, it means that we already use a version of the env that support scaling\n const isNew = await component.isNew();\n if (isNew) {\n return true;\n }\n return isBundledWithEnv === false;\n }\n const envComponent = await this.envs.getEnvComponent(component);\n const envSupportScaling = await this.calculateIsEnvSupportScaling(envComponent);\n return envSupportScaling ?? true;\n }\n const previewData = this.getPreviewData(component);\n if (!previewData) return false;\n // Get the does scaling (the new calculation) or the old calc used in isScaling (between versions (about) 848 and 860)\n if (previewData.doesScaling !== undefined) return previewData.doesScaling;\n // in case this component were tagged with versions between 848 and 860 we need to use the old calculation\n // together with the env calculation\n // In that case it means the component already tagged, so we take the env calc from the env data and not re-calc it\n if (previewData.isScaling) {\n const envComponent = await this.envs.getEnvComponent(component);\n const envSupportScaling = this.isEnvSupportScaling(envComponent);\n return !!envSupportScaling;\n }\n return false;\n }\n\n /**\n * Check if the current version of the env support scaling\n * @param envComponent\n * @returns\n */\n isEnvSupportScaling(envComponent: Component): boolean {\n const previewData = this.getPreviewData(envComponent);\n return !!previewData?.isScaling;\n }\n\n async isSupportSkipIncludes(component: Component) {\n if (!this.config.onlyOverview) return false;\n\n const isCore = this.envs.isUsingCoreEnv(component);\n if (isCore) return false;\n\n const envComponent = await this.envs.getEnvComponent(component);\n const previewData = this.getPreviewData(envComponent);\n return !!previewData?.skipIncludes;\n }\n\n /**\n * check if the component preview should only include the overview (skipping rendering of the compostions and properties table)\n */\n async getOnlyOverview(component: Component): Promise<boolean> {\n if (!this.config.onlyOverview) return false;\n const previewData = this.getPreviewData(component);\n return previewData?.onlyOverview ?? false;\n }\n\n /**\n * check if the component preview should include the name query param\n */\n async getUseNameParam(component: Component): Promise<boolean> {\n const previewData = this.getPreviewData(component);\n return previewData?.useNameParam ?? false;\n }\n\n /**\n * This function is calculate the isScaling support flag for the component preview.\n * This is calculated only for the env component and not for the component itself.\n * It should be only used during the (env) component on load.\n * Once the component load, you should only use the `isEnvSupportScaling` to fetch it from the calculated data.\n * If you want to check if an env for a given component support scaling, use the `isScaling` function.\n * @param component\n * @returns\n */\n private async calculateIsEnvSupportScaling(envComponent: Component): Promise<boolean | undefined> {\n const isEnv = this.envs.isEnv(envComponent);\n // If the component is not an env, we don't want to store anything in the data\n if (!isEnv) return undefined;\n const previewAspectConfig = this.getPreviewAspectConfig(envComponent);\n // default to true if the env doesn't have a preview config\n return previewAspectConfig?.isScaling ?? true;\n }\n\n /**\n * Check if the component preview bundle contain the header inside of it (legacy)\n * today we are not including the header inside anymore\n * @param component\n * @returns\n */\n async isLegacyHeader(component: Component): Promise<boolean> {\n // these envs had header in their docs\n const ENV_WITH_LEGACY_DOCS = ['react', 'env', 'aspect', 'lit', 'html', 'node', 'mdx', 'react-native', 'readme'];\n\n const artifacts = await this.builder.getArtifactsVinylByAspectAndName(\n component,\n PreviewAspect.id,\n ENV_STRATEGY_ARTIFACT_NAME\n );\n const envType = this.envs.getEnvData(component).type;\n return !!artifacts && !!artifacts.length && ENV_WITH_LEGACY_DOCS.includes(envType || '');\n }\n\n /**\n * Getting the env template artifact\n * This should be called with the env itself or it will return undefined\n * If you want to get the env template from the env of the component,\n * use: getEnvTemplateFromComponentEnv below\n *\n * @param component\n * @returns\n */\n async getEnvTemplate(component: Component): Promise<PreviewArtifact | undefined> {\n const artifacts = await this.builder.getArtifactsVinylByAspectAndTaskName(\n component,\n PreviewAspect.id,\n GENERATE_ENV_TEMPLATE_TASK_NAME\n );\n if (!artifacts || !artifacts.length) return undefined;\n\n return new PreviewArtifact(artifacts);\n }\n\n /**\n * This is a special method to get a core env template\n * As the core envs doesn't exist in the scope we need to bring it from other place\n * We will bring it from the core env package files\n */\n private async getCoreEnvTemplate(envId: string): Promise<PreviewArtifact | undefined> {\n const coreEnvDir = getAspectDir(envId);\n // const finalDir = join(coreEnvDir, getEnvTemplateArtifactDirectory());\n const artifactDef = getEnvTemplateArtifactDef()[0];\n const artifactFactory = new ArtifactFactory();\n\n let rootDir = artifactFactory.getRootDir(coreEnvDir, artifactDef);\n if (!existsSync(rootDir)) {\n // fallback to the bvm folder\n const coreEnvDirFromBvm = getAspectDirFromBvm(envId);\n rootDir = artifactFactory.getRootDir(coreEnvDirFromBvm, artifactDef);\n }\n if (!existsSync(rootDir)) {\n return undefined;\n }\n const paths = artifactFactory.resolvePaths(rootDir, artifactDef);\n if (!paths || !paths.length) {\n return undefined;\n }\n const artifactFiles = new ArtifactFiles(paths);\n\n artifactFiles.populateVinylsFromPaths(rootDir);\n return new PreviewArtifact(artifactFiles.vinyls);\n }\n\n /**\n * This will fetch the component env, then will take the env template from the component env\n * @param component\n */\n async getEnvTemplateFromComponentEnv(component: Component): Promise<PreviewArtifact | undefined> {\n const envId = this.envs.getEnvId(component);\n return this.getEnvTemplateByEnvId(envId);\n }\n\n /**\n * This will fetch the component env, then will take the env template from the component env\n * @param component\n */\n async getEnvTemplateByEnvId(envId: string): Promise<PreviewArtifact | undefined> {\n // Special treatment for core envs\n if (this.aspectLoader.isCoreEnv(envId)) {\n return this.getCoreEnvTemplate(envId);\n }\n const host = this.componentAspect.getHost();\n const resolvedEnvId = await host.resolveComponentId(envId);\n const envComponent = await host.get(resolvedEnvId);\n if (!envComponent) {\n throw new BitError(`can't load env. env id is ${envId}`);\n }\n return this.getEnvTemplate(envComponent);\n }\n\n getDefs(): PreviewDefinition[] {\n return this.previewSlot.values();\n }\n\n private writeHash = new Map<string, string>();\n private timestamp = Date.now();\n\n /**\n * write a link to load custom modules dynamically.\n * @param prefix write\n * @param moduleMap map of components to module paths to require.\n * @param defaultModule\n * @param dirName\n */\n writeLink(\n prefix: string,\n moduleMap: ComponentMap<string[]>,\n mainModulesMap: MainModulesMap,\n dirName: string,\n isSplitComponentBundle: boolean\n ) {\n const contents = generateLink(prefix, moduleMap, mainModulesMap, isSplitComponentBundle);\n return this.writeLinkContents(contents, dirName, prefix);\n }\n\n writeLinkContents(contents: string, targetDir: string, prefix: string) {\n const hash = objectHash(contents);\n const targetPath = join(targetDir, `${prefix}-${this.timestamp}.js`);\n\n // write only if link has changed (prevents triggering fs watches)\n if (this.writeHash.get(targetPath) !== hash) {\n writeFileSync(targetPath, contents);\n this.writeHash.set(targetPath, hash);\n }\n\n return targetPath;\n }\n\n private executionRefs = new Map<string, ExecutionRef>();\n\n private async getPreviewTarget(\n /** execution context (of the specific env) */\n context: ExecutionContext\n ): Promise<string[]> {\n // store context for later link-file updates\n // also register related envs that this context is acting on their behalf\n [context.id, ...context.relatedContexts].forEach((ctxId) => {\n this.executionRefs.set(ctxId, new ExecutionRef(context));\n });\n\n const previewRuntime = await this.writePreviewEntry(context);\n const linkFiles = await this.updateLinkFiles(context.components, context);\n\n return [...linkFiles, previewRuntime];\n }\n\n private async writePreviewEntry(context: { components: Component[] }, aspectsIdsToNotFilterOut: string[] = []) {\n const { rebuild, skipUiBuild } = this.ui.runtimeOptions;\n\n const [name, uiRoot] = this.getUi();\n const cacheKey = `${uiRoot.path}|${RUNTIME_NAME}`;\n const currentBundleHash = await createBundleHash(uiRoot, RUNTIME_NAME);\n const preBundleHash = readBundleHash(PreviewAspect.id, BUNDLE_DIR, '');\n const workspaceBundleDir = join(uiRoot.path, PUBLIC_DIR);\n const lastBundleHash = await this.cache.get(cacheKey);\n\n let bundlePath = '';\n\n // ensure the pre-bundle is ready\n if (!rebuild && !existsSync(workspaceBundleDir) && (currentBundleHash === preBundleHash || skipUiBuild)) {\n // use pre-bundle\n bundlePath = getBundlePath(PreviewAspect.id, BUNDLE_DIR, '') as string;\n } else if (!rebuild && existsSync(workspaceBundleDir) && (currentBundleHash === lastBundleHash || skipUiBuild)) {\n // use workspace bundle\n bundlePath = workspaceBundleDir;\n } else {\n // do build\n const resolvedAspects = await this.resolveAspects(PreviewRuntime.name, undefined, uiRoot);\n const filteredAspects = this.filterAspectsByExecutionContext(resolvedAspects, context, aspectsIdsToNotFilterOut);\n\n await buildPreBundlePreview(filteredAspects);\n bundlePath = workspaceBundleDir;\n await this.cache.set(cacheKey, currentBundleHash);\n }\n\n // prepare the runtime entry\n const previewRuntime = await generateBundlePreviewEntry(name, bundlePath, this.harmony.config.toObject());\n\n return previewRuntime;\n }\n\n private updateLinkFiles(components: Component[] = [], context: ExecutionContext) {\n const previews = this.previewSlot.values();\n const paths = previews.map(async (previewDef) => {\n const defaultTemplatePath = await previewDef.renderTemplatePathByEnv?.(context.env);\n const visitedEnvs = new Set();\n const mainModulesMap: MainModulesMap = {\n // @ts-ignore\n default: defaultTemplatePath,\n [context.envDefinition.id]: defaultTemplatePath,\n };\n\n const map = await previewDef.getModuleMap(components);\n const isSplitComponentBundle = this.getEnvPreviewConfig().splitComponentBundle ?? false;\n const withPathsP = map.asyncMap(async (files, component) => {\n const envDef = this.envs.getEnv(component);\n const environment = envDef.env;\n const envId = envDef.id;\n\n if (!mainModulesMap[envId] && !visitedEnvs.has(envId)) {\n const modulePath = await previewDef.renderTemplatePathByEnv?.(envDef.env);\n if (modulePath) {\n mainModulesMap[envId] = modulePath;\n }\n visitedEnvs.add(envId);\n }\n const compilerInstance = environment.getCompiler?.();\n const modulePath =\n compilerInstance?.getPreviewComponentRootPath?.(component) || this.pkg.getRuntimeModulePath(component);\n return files.map((file) => {\n if (!this.workspace || !compilerInstance) {\n return file.path;\n }\n const distRelativePath = compilerInstance.getDistPathBySrcPath(file.relative);\n return join(this.workspace.path, modulePath, distRelativePath);\n });\n // return files.map((file) => file.path);\n });\n const withPaths = await withPathsP;\n\n const dirPath = join(this.tempFolder, context.id);\n if (!existsSync(dirPath)) mkdirSync(dirPath, { recursive: true });\n\n const link = this.writeLink(previewDef.prefix, withPaths, mainModulesMap, dirPath, isSplitComponentBundle);\n return link;\n });\n\n return Promise.all(paths);\n }\n\n async writePreviewRuntime(context: { components: Component[] }, aspectsIdsToNotFilterOut: string[] = []) {\n const [name, uiRoot] = this.getUi();\n const resolvedAspects = await this.resolveAspects(PreviewRuntime.name, undefined, uiRoot);\n const filteredAspects = this.filterAspectsByExecutionContext(resolvedAspects, context, aspectsIdsToNotFilterOut);\n const filePath = await this.ui.generateRoot(filteredAspects, name, 'preview', PreviewAspect.id);\n return filePath;\n }\n\n async resolveAspects(\n runtimeName?: string,\n componentIds?: ComponentID[],\n uiRoot?: UIRoot,\n opts?: ResolveAspectsOptions\n ): Promise<AspectDefinition[]> {\n const root = uiRoot || this.getUi()[1];\n runtimeName = runtimeName || MainRuntime.name;\n const resolvedAspects = await root.resolveAspects(runtimeName, componentIds, opts);\n return resolvedAspects;\n }\n\n private getUi() {\n const ui = this.ui.getUi();\n if (!ui) throw new Error('ui not found');\n return ui;\n }\n\n /**\n * Filter the aspects to have only aspects that are:\n * 1. core aspects\n * 2. configured on the host (workspace/scope)\n * 3. used by at least one component from the context\n * @param aspects\n * @param context\n */\n private filterAspectsByExecutionContext(\n aspects: AspectDefinition[],\n context: { components: Component[] },\n aspectsIdsToNotFilterOut: string[] = []\n ) {\n let allComponentContextAspects: string[] = [];\n allComponentContextAspects = context.components.reduce((acc, curr) => {\n return acc.concat(curr.state.aspects.ids);\n }, allComponentContextAspects);\n const hostAspects = Object.keys(this.harmony.config.toObject());\n const allAspectsToInclude = uniq(hostAspects.concat(allComponentContextAspects));\n const filtered = aspects.filter((aspect) => {\n if (!aspect.getId) {\n return false;\n }\n return (\n this.aspectLoader.isCoreAspect(aspect.getId) ||\n allAspectsToInclude.includes(aspect.getId) ||\n aspectsIdsToNotFilterOut.includes(aspect.getId)\n );\n });\n\n return filtered;\n }\n\n private getDefaultStrategies() {\n return [\n new EnvBundlingStrategy(this, this.pkg, this.dependencyResolver),\n new ComponentBundlingStrategy(this, this.pkg, this.dependencyResolver),\n ];\n }\n\n // TODO - executionContext should be responsible for updating components list, and emit 'update' events\n // instead we keep track of changes\n private handleComponentChange = async (c: Component, updater: (currentComponents: ExecutionRef) => void) => {\n const env = this.envs.getEnv(c);\n const envId = env.id.toString();\n\n const executionRef = this.executionRefs.get(envId);\n if (!executionRef) {\n this.logger.warn(\n `failed to update link file for component \"${c.id.toString()}\" - could not find execution context for ${envId}`\n );\n return noopResult;\n }\n\n // add / remove / etc\n updater(executionRef);\n\n await this.updateLinkFiles(executionRef.currentComponents, executionRef.executionCtx);\n return noopResult;\n };\n\n private handleComponentRemoval = (cId: ComponentID) => {\n let component: Component | undefined;\n this.executionRefs.forEach((components) => {\n const found = components.get(cId);\n if (found) component = found;\n });\n if (!component) return Promise.resolve(noopResult);\n\n return this.handleComponentChange(component, (currentComponents) => currentComponents.remove(cId));\n };\n\n getEnvPreviewConfig(env?: PreviewEnv): EnvPreviewConfig {\n const config = env?.getPreviewConfig && typeof env?.getPreviewConfig === 'function' ? env?.getPreviewConfig() : {};\n\n return config;\n }\n\n /**\n * return the configured bundling strategy.\n */\n getBundlingStrategy(env?: PreviewEnv): BundlingStrategy {\n const defaultStrategies = this.getDefaultStrategies();\n const envPreviewConfig = this.getEnvPreviewConfig(env);\n const strategyFromEnv = envPreviewConfig?.strategyName;\n const strategyName = strategyFromEnv || this.config.bundlingStrategy || 'env';\n const strategies = this.bundlingStrategySlot.values().concat(defaultStrategies);\n const selected = strategies.find((strategy) => {\n return strategy.name === strategyName;\n });\n\n if (!selected) throw new BundlingStrategyNotFound(strategyName);\n\n return selected;\n }\n\n /**\n * register a new bundling strategy. default available strategies are `env` and ``\n */\n registerBundlingStrategy(bundlingStrategy: BundlingStrategy) {\n this.bundlingStrategySlot.register(bundlingStrategy);\n return this;\n }\n\n /**\n * register a new preview definition.\n */\n registerDefinition(previewDef: PreviewDefinition) {\n this.previewSlot.register(previewDef);\n }\n\n static slots = [Slot.withType<PreviewDefinition>(), Slot.withType<BundlingStrategy>()];\n\n static runtime = MainRuntime;\n static dependencies = [\n BundlerAspect,\n BuilderAspect,\n ComponentAspect,\n UIAspect,\n CacheAspect,\n EnvsAspect,\n WorkspaceAspect,\n PkgAspect,\n PubsubAspect,\n AspectLoaderAspect,\n LoggerAspect,\n DependencyResolverAspect,\n GraphqlAspect,\n WatcherAspect,\n ScopeAspect,\n ];\n\n static defaultConfig = {\n disabled: false,\n onlyOverview: false,\n };\n\n static async provider(\n // eslint-disable-next-line max-len\n [\n bundler,\n builder,\n componentExtension,\n uiMain,\n cache,\n envs,\n workspace,\n pkg,\n pubsub,\n aspectLoader,\n loggerMain,\n dependencyResolver,\n graphql,\n watcher,\n scope,\n ]: [\n BundlerMain,\n BuilderMain,\n ComponentMain,\n UiMain,\n CacheMain,\n EnvsMain,\n Workspace | undefined,\n PkgMain,\n PubsubMain,\n AspectLoaderMain,\n LoggerMain,\n DependencyResolverMain,\n GraphqlMain,\n WatcherMain,\n ScopeMain\n ],\n config: PreviewConfig,\n [previewSlot, bundlingStrategySlot]: [PreviewDefinitionRegistry, BundlingStrategySlot],\n harmony: Harmony\n ) {\n const logger = loggerMain.createLogger(PreviewAspect.id);\n // app.registerApp(new PreviewApp());\n const preview = new PreviewMain(\n harmony,\n previewSlot,\n uiMain,\n cache,\n envs,\n componentExtension,\n pkg,\n aspectLoader,\n config,\n bundlingStrategySlot,\n builder,\n workspace,\n logger,\n dependencyResolver\n );\n\n if (workspace)\n uiMain.registerStartPlugin(new PreviewStartPlugin(workspace, bundler, uiMain, pubsub, logger, watcher));\n\n componentExtension.registerRoute([\n new PreviewRoute(preview, logger),\n new ComponentPreviewRoute(preview, logger),\n // @ts-ignore\n new EnvTemplateRoute(preview, logger),\n new PreviewAssetsRoute(preview, logger),\n ]);\n\n bundler.registerTarget([\n {\n entry: preview.getPreviewTarget.bind(preview),\n },\n ]);\n\n if (!config.disabled)\n builder.registerBuildTasks([\n new EnvPreviewTemplateTask(preview, envs, aspectLoader, dependencyResolver, logger),\n new PreviewTask(bundler, preview, dependencyResolver, logger),\n new PreBundlePreviewTask(uiMain, logger),\n ]);\n\n if (workspace) {\n workspace.registerOnComponentAdd((c) =>\n preview.handleComponentChange(c, (currentComponents) => currentComponents.add(c))\n );\n workspace.registerOnComponentLoad(async (component) => {\n return preview.calcPreviewData(component);\n });\n workspace.registerOnComponentChange((c) =>\n preview.handleComponentChange(c, (currentComponents) => currentComponents.update(c))\n );\n workspace.registerOnComponentRemove((cId) => preview.handleComponentRemoval(cId));\n }\n if (scope) {\n scope.registerOnCompAspectReCalc((c) => preview.calcPreviewData(c));\n }\n\n envs.registerService(new PreviewService());\n\n graphql.register(previewSchema(preview));\n\n return preview;\n }\n}\n\nPreviewAspect.addRuntime(PreviewMain);\n"],"mappings":";;;;;;AAAA,SAAAA,SAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,QAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAE,SAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,QAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,QAAA;EAAA,MAAAH,IAAA,GAAAC,OAAA;EAAAE,OAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,KAAA;EAAA,MAAAJ,IAAA,GAAAC,OAAA;EAAAG,IAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAK,WAAA;EAAA,MAAAL,IAAA,GAAAC,OAAA;EAAAI,UAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAQA,SAAAM,MAAA;EAAA,MAAAN,IAAA,GAAAC,OAAA;EAAAK,KAAA,YAAAA,CAAA;IAAA,OAAAN,IAAA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,QAAQ,CAAC,IAAAqC,yBAAa,EAACzB,OAAO,CAAC,CAAC;IAExC,OAAOA,OAAO;EAChB;AACF;AAAC0B,OAAA,CAAA1S,WAAA,GAAAA,WAAA;AAAAzB,eAAA,CAt2BYyB,WAAW,WAouBP,CAAC2S,eAAI,CAACC,QAAQ,CAAoB,CAAC,EAAED,eAAI,CAACC,QAAQ,CAAmB,CAAC,CAAC;AAAArU,eAAA,CApuB3EyB,WAAW,aAsuBLuO,kBAAW;AAAAhQ,eAAA,CAtuBjByB,WAAW,kBAuuBA,CACpB6S,wBAAa,EACbC,wBAAa,EACbC,4BAAe,EACfC,cAAQ,EACRC,oBAAW,EACXC,kBAAU,EACVC,oBAAe,EACfC,gBAAS,EACTC,sBAAY,EACZC,kCAAkB,EAClBC,sBAAY,EACZC,8CAAwB,EACxBC,kBAAa,EACbC,kBAAa,EACbC,gBAAW,CACZ;AAAApV,eAAA,CAvvBUyB,WAAW,mBAyvBC;EACrB2R,QAAQ,EAAE,KAAK;EACfhN,YAAY,EAAE;AAChB,CAAC;AA4GH7E,wBAAa,CAAC8T,UAAU,CAAC5T,WAAW,CAAC"}
1
+ {"version":3,"names":["_builder","data","require","_bundler","_pubsub","_cli","_component","_envs","_harmony","_ui","_cache","_constants","_bitError","_objectHash","_interopRequireDefault","_lodash","_fsExtra","_path","_pkg","_aspectLoader","_workspace","_logger","_dependencyResolver","_artifactFiles","_watcher","_graphql","_scope","_featureToggle","_exceptions","_generateLink","_previewArtifact","_preview","_preview2","_preview3","_strategies","_executionRef","_preview4","_envPreviewTemplate","_envTemplate","_componentPreview","_preview5","_previewAssets","_preview6","_preBundle","_preBundle2","_preBundleUtils","obj","__esModule","default","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","key","value","_toPropertyKey","configurable","writable","i","_toPrimitive","String","Symbol","toPrimitive","call","TypeError","Number","noopResult","results","toString","DEFAULT_TEMP_DIR","join","CACHE_ROOT","PreviewAspect","id","PreviewMain","constructor","harmony","previewSlot","ui","cache","envs","componentAspect","pkg","aspectLoader","config","bundlingStrategySlot","builder","workspace","logger","dependencyResolver","Map","Date","now","c","updater","env","getEnv","envId","executionRef","executionRefs","get","warn","updateLinkFiles","currentComponents","executionCtx","cId","component","components","found","Promise","resolve","handleComponentChange","remove","tempFolder","getTempDir","getComponentBundleSize","getDataByAspect","undefined","COMPONENT_STRATEGY_SIZE_KEY_NAME","getPreview","artifacts","getArtifactsVinylByAspectAndTaskName","PREVIEW_TASK_NAME","PreviewArtifact","getPreviewFiles","isBundledWithEnv","files","getPaths","getPreviewAspectConfig","state","aspects","getPreviewData","previewData","doesEnvIncludesOnlyOverview","envComponent","supportsOnlyOverview","doesEnvUseNameParam","supportsUseNameParam","calculateIncludeOnlyOverview","isUsingCoreEnv","getEnvComponent","calculateUseNameParam","calcPreviewData","doesScaling","calcDoesScalingForComponent","dataFromEnv","calcPreviewDataFromEnv","envData","calculateDataForEnvComponent","onlyOverview","useNameParam","toStringWithoutVersion","strategyName","COMPONENT_PREVIEW_STRATEGY_NAME","splitComponentBundle","envPreviewConfig","getEnvPreviewConfig","isEnv","previewAspectConfig","isScaling","calcIsBundledWithEnv","envPreviewData","isBundledWithEnvBackward","ENV_PREVIEW_STRATEGY_NAME","getArtifactsVinylByAspectAndName","COMPONENT_STRATEGY_ARTIFACT_NAME","isNew","isEnvSupportScaling","inWorkspace","hasId","envSupportScaling","calculateIsEnvSupportScaling","isSupportSkipIncludes","isFeatureEnabled","ONLY_OVERVIEW","isCore","skipIncludes","getOnlyOverview","getUseNameParam","isLegacyHeader","ENV_WITH_LEGACY_DOCS","ENV_STRATEGY_ARTIFACT_NAME","envType","getEnvData","type","includes","getEnvTemplate","GENERATE_ENV_TEMPLATE_TASK_NAME","getCoreEnvTemplate","coreEnvDir","getAspectDir","artifactDef","getEnvTemplateArtifactDef","artifactFactory","ArtifactFactory","rootDir","getRootDir","existsSync","coreEnvDirFromBvm","getAspectDirFromBvm","paths","resolvePaths","artifactFiles","ArtifactFiles","populateVinylsFromPaths","vinyls","getEnvTemplateFromComponentEnv","getEnvId","getEnvTemplateByEnvId","isCoreEnv","host","getHost","resolvedEnvId","resolveComponentId","BitError","getDefs","values","writeLink","prefix","moduleMap","mainModulesMap","dirName","isSplitComponentBundle","contents","generateLink","writeLinkContents","targetDir","hash","objectHash","targetPath","timestamp","writeHash","writeFileSync","set","getPreviewTarget","context","relatedContexts","ctxId","ExecutionRef","previewRuntime","writePreviewEntry","linkFiles","aspectsIdsToNotFilterOut","rebuild","skipUiBuild","runtimeOptions","name","uiRoot","getUi","cacheKey","path","RUNTIME_NAME","currentBundleHash","createBundleHash","preBundleHash","readBundleHash","BUNDLE_DIR","workspaceBundleDir","PUBLIC_DIR","lastBundleHash","bundlePath","getBundlePath","resolvedAspects","resolveAspects","PreviewRuntime","filteredAspects","filterAspectsByExecutionContext","buildPreBundlePreview","generateBundlePreviewEntry","toObject","previews","map","previewDef","defaultTemplatePath","renderTemplatePathByEnv","visitedEnvs","Set","envDefinition","getModuleMap","withPathsP","asyncMap","envDef","environment","has","modulePath","add","compilerInstance","getCompiler","getPreviewComponentRootPath","getRuntimeModulePath","file","distRelativePath","getDistPathBySrcPath","relative","withPaths","dirPath","mkdirSync","recursive","link","all","writePreviewRuntime","filePath","generateRoot","runtimeName","componentIds","opts","root","MainRuntime","Error","allComponentContextAspects","reduce","acc","curr","concat","ids","hostAspects","allAspectsToInclude","uniq","filtered","aspect","getId","isCoreAspect","getDefaultStrategies","EnvBundlingStrategy","ComponentBundlingStrategy","getPreviewConfig","getBundlingStrategy","defaultStrategies","strategyFromEnv","bundlingStrategy","strategies","selected","find","strategy","BundlingStrategyNotFound","registerBundlingStrategy","register","registerDefinition","provider","bundler","componentExtension","uiMain","pubsub","loggerMain","graphql","watcher","scope","createLogger","preview","registerStartPlugin","PreviewStartPlugin","registerRoute","PreviewRoute","ComponentPreviewRoute","EnvTemplateRoute","PreviewAssetsRoute","registerTarget","entry","bind","disabled","registerBuildTasks","EnvPreviewTemplateTask","PreviewTask","PreBundlePreviewTask","registerOnComponentAdd","registerOnComponentLoad","registerOnComponentChange","update","registerOnComponentRemove","handleComponentRemoval","registerOnCompAspectReCalc","registerService","PreviewService","previewSchema","exports","Slot","withType","BundlerAspect","BuilderAspect","ComponentAspect","UIAspect","CacheAspect","EnvsAspect","WorkspaceAspect","PkgAspect","PubsubAspect","AspectLoaderAspect","LoggerAspect","DependencyResolverAspect","GraphqlAspect","WatcherAspect","ScopeAspect","addRuntime"],"sources":["preview.main.runtime.ts"],"sourcesContent":["import { ArtifactFactory, BuilderAspect } from '@teambit/builder';\nimport type { BuilderMain } from '@teambit/builder';\nimport { Asset, BundlerAspect, BundlerMain } from '@teambit/bundler';\nimport { PubsubAspect, PubsubMain } from '@teambit/pubsub';\nimport { MainRuntime } from '@teambit/cli';\nimport {\n Component,\n ComponentAspect,\n ComponentMain,\n ComponentMap,\n ComponentID,\n ResolveAspectsOptions,\n} from '@teambit/component';\nimport { EnvsAspect } from '@teambit/envs';\nimport type { EnvsMain, ExecutionContext, PreviewEnv } from '@teambit/envs';\nimport { Slot, SlotRegistry, Harmony } from '@teambit/harmony';\nimport { UIAspect, UiMain, UIRoot } from '@teambit/ui';\nimport { CacheAspect, CacheMain } from '@teambit/cache';\nimport { CACHE_ROOT } from '@teambit/legacy/dist/constants';\nimport { BitError } from '@teambit/bit-error';\nimport objectHash from 'object-hash';\nimport { uniq } from 'lodash';\nimport { writeFileSync, existsSync, mkdirSync } from 'fs-extra';\nimport { join } from 'path';\nimport { PkgAspect, PkgMain } from '@teambit/pkg';\nimport { AspectLoaderAspect, getAspectDir, getAspectDirFromBvm } from '@teambit/aspect-loader';\nimport type { AspectDefinition, AspectLoaderMain } from '@teambit/aspect-loader';\nimport WorkspaceAspect, { Workspace } from '@teambit/workspace';\nimport { LoggerAspect, LoggerMain, Logger } from '@teambit/logger';\nimport { DependencyResolverAspect } from '@teambit/dependency-resolver';\nimport type { DependencyResolverMain } from '@teambit/dependency-resolver';\nimport { ArtifactFiles } from '@teambit/legacy/dist/consumer/component/sources/artifact-files';\nimport WatcherAspect, { WatcherMain } from '@teambit/watcher';\nimport GraphqlAspect, { GraphqlMain } from '@teambit/graphql';\nimport ScopeAspect, { ScopeMain } from '@teambit/scope';\nimport { ONLY_OVERVIEW, isFeatureEnabled } from '@teambit/legacy/dist/api/consumer/lib/feature-toggle';\nimport { BundlingStrategyNotFound } from './exceptions';\nimport { generateLink, MainModulesMap } from './generate-link';\nimport { PreviewArtifact } from './preview-artifact';\nimport { PreviewDefinition } from './preview-definition';\nimport { PreviewAspect, PreviewRuntime } from './preview.aspect';\nimport { PreviewRoute } from './preview.route';\nimport { PreviewTask, PREVIEW_TASK_NAME } from './preview.task';\nimport { BundlingStrategy } from './bundling-strategy';\nimport {\n EnvBundlingStrategy,\n ComponentBundlingStrategy,\n COMPONENT_STRATEGY_ARTIFACT_NAME,\n COMPONENT_STRATEGY_SIZE_KEY_NAME,\n ENV_PREVIEW_STRATEGY_NAME,\n ENV_STRATEGY_ARTIFACT_NAME,\n COMPONENT_PREVIEW_STRATEGY_NAME,\n} from './strategies';\nimport { ExecutionRef } from './execution-ref';\nimport { PreviewStartPlugin } from './preview.start-plugin';\nimport {\n EnvPreviewTemplateTask,\n GENERATE_ENV_TEMPLATE_TASK_NAME,\n getArtifactDef as getEnvTemplateArtifactDef,\n} from './env-preview-template.task';\nimport { EnvTemplateRoute } from './env-template.route';\nimport { ComponentPreviewRoute } from './component-preview.route';\nimport { previewSchema } from './preview.graphql';\nimport { PreviewAssetsRoute } from './preview-assets.route';\nimport { PreviewService } from './preview.service';\nimport { PUBLIC_DIR, RUNTIME_NAME, buildPreBundlePreview, generateBundlePreviewEntry } from './pre-bundle';\nimport { BUNDLE_DIR, PreBundlePreviewTask } from './pre-bundle.task';\nimport { createBundleHash, getBundlePath, readBundleHash } from './pre-bundle-utils';\n\nconst noopResult = {\n results: [],\n toString: () => `updating link file`,\n};\n\nconst DEFAULT_TEMP_DIR = join(CACHE_ROOT, PreviewAspect.id);\n\nexport type PreviewDefinitionRegistry = SlotRegistry<PreviewDefinition>;\n\nexport type PreviewStrategyName = 'env' | 'component';\n\nexport type PreviewFiles = {\n files: string[];\n isBundledWithEnv: boolean;\n};\n\nexport type ComponentPreviewSizedFile = Asset;\n\nexport type ComponentPreviewSize = {\n files: ComponentPreviewSizedFile[];\n assets: ComponentPreviewSizedFile[];\n totalFiles: number;\n compressedTotalFiles?: number;\n totalAssets: number;\n compressedTotalAssets?: number;\n total: number;\n compressedTotal?: number;\n};\n\nexport type ComponentPreviewMetaData = {\n size?: ComponentPreviewSize;\n};\n\nexport type PreviewVariantConfig = {\n isScaling?: boolean;\n};\n\n/**\n * Preview data that stored on the component on load\n */\nexport type PreviewComponentData = PreviewAnyComponentData & PreviewEnvComponentData;\n\n/**\n * Preview data that stored on the component on load for any component\n */\nexport type PreviewAnyComponentData = {\n doesScaling?: boolean;\n /**\n * The strategy configured by the component's env\n */\n strategyName?: PreviewStrategyName;\n /**\n * Does the component has a bundle for the component itself (separated from the compositions/docs)\n * Calculated by the component's env\n */\n splitComponentBundle?: boolean;\n\n /**\n * don't allow other aspects implementing a preview definition to be included in your preview.\n */\n onlyOverview?: boolean;\n\n /**\n * use name query params to select a specific composition to render.\n */\n useNameParam?: boolean;\n\n /**\n * don't allow other aspects implementing a preview definition to be included in your preview.\n */\n skipIncludes?: boolean;\n};\n\n/**\n * Preview data that stored on the component on load if the component is an env\n */\nexport type PreviewEnvComponentData = {\n isScaling?: boolean;\n supportsOnlyOverview?: boolean;\n supportsUseNameParam?: boolean;\n};\n\nexport type PreviewConfig = {\n bundlingStrategy?: string;\n disabled: boolean;\n /**\n * limit concurrent components when running the bundling step for your bundler during generate components preview task.\n * this helps mitigate large memory consumption for the build pipeline. This may increase the overall time for the generate-preview task, but reduce memory footprint.\n * default - no limit.\n */\n maxChunkSize?: number;\n onlyOverview?: boolean;\n};\n\nexport type EnvPreviewConfig = {\n strategyName?: PreviewStrategyName;\n splitComponentBundle?: boolean;\n};\n\nexport type BundlingStrategySlot = SlotRegistry<BundlingStrategy>;\n\nexport type GenerateLinkFn = (prefix: string, componentMap: ComponentMap<string[]>, defaultModule?: string) => string;\n\nexport class PreviewMain {\n constructor(\n /**\n * harmony context.\n */\n private harmony: Harmony,\n\n /**\n * slot for preview definitions.\n */\n private previewSlot: PreviewDefinitionRegistry,\n\n private ui: UiMain,\n\n private cache: CacheMain,\n\n private envs: EnvsMain,\n\n private componentAspect: ComponentMain,\n\n private pkg: PkgMain,\n\n private aspectLoader: AspectLoaderMain,\n\n readonly config: PreviewConfig,\n\n private bundlingStrategySlot: BundlingStrategySlot,\n\n private builder: BuilderMain,\n\n private workspace: Workspace | undefined,\n\n private logger: Logger,\n\n private dependencyResolver: DependencyResolverMain\n ) {}\n\n get tempFolder(): string {\n return this.workspace?.getTempDir(PreviewAspect.id) || DEFAULT_TEMP_DIR;\n }\n\n getComponentBundleSize(component: Component): ComponentPreviewSize | undefined {\n const data = this.builder.getDataByAspect(component, PreviewAspect.id);\n\n if (!data) return undefined;\n return data[COMPONENT_STRATEGY_SIZE_KEY_NAME];\n }\n\n async getPreview(component: Component): Promise<PreviewArtifact | undefined> {\n const artifacts = await this.builder.getArtifactsVinylByAspectAndTaskName(\n component,\n PreviewAspect.id,\n PREVIEW_TASK_NAME\n );\n if (!artifacts) return undefined;\n return new PreviewArtifact(artifacts);\n }\n\n /**\n * Get a list of all the artifact files generated during the GeneratePreview task\n * @param component\n * @returns\n */\n async getPreviewFiles(component: Component): Promise<PreviewFiles | undefined> {\n const artifacts = await this.getPreview(component);\n const isBundledWithEnv = await this.isBundledWithEnv(component);\n if (!artifacts) return undefined;\n return {\n files: artifacts.getPaths(),\n isBundledWithEnv,\n };\n }\n\n /**\n * Get the preview config of the component.\n * (config that was set by variants or on bitmap)\n * @param component\n * @returns\n */\n getPreviewAspectConfig(component: Component): PreviewVariantConfig | undefined {\n return component.state.aspects.get(PreviewAspect.id)?.config;\n }\n\n /**\n * Get the preview data of the component.\n * (data that was calculated during the on load process)\n * @param component\n * @returns\n */\n getPreviewData(component: Component): PreviewComponentData | undefined {\n const previewData = component.state.aspects.get(PreviewAspect.id)?.data;\n return previewData;\n }\n\n /**\n * check if the current version of env component supports skipping other included previews\n * @param envComponent\n * @returns\n */\n doesEnvIncludesOnlyOverview(envComponent: Component): boolean {\n const previewData = this.getPreviewData(envComponent);\n return !!previewData?.supportsOnlyOverview;\n }\n\n /**\n * check if the current version of env component supports name query param\n * @param envComponent\n * @returns\n */\n doesEnvUseNameParam(envComponent: Component): boolean {\n const previewData = this.getPreviewData(envComponent);\n return !!previewData?.supportsUseNameParam;\n }\n\n private async calculateIncludeOnlyOverview(component: Component): Promise<boolean> {\n if (this.envs.isUsingCoreEnv(component)) {\n return true;\n }\n const envComponent = await this.envs.getEnvComponent(component);\n return this.doesEnvIncludesOnlyOverview(envComponent);\n }\n\n private async calculateUseNameParam(component: Component): Promise<boolean> {\n if (this.envs.isUsingCoreEnv(component)) {\n return true;\n }\n const envComponent = await this.envs.getEnvComponent(component);\n return this.doesEnvUseNameParam(envComponent);\n }\n\n /**\n * Calculate preview data on component load\n * @param component\n * @returns\n */\n async calcPreviewData(component: Component): Promise<PreviewComponentData> {\n const doesScaling = await this.calcDoesScalingForComponent(component);\n const dataFromEnv = await this.calcPreviewDataFromEnv(component);\n const envData = (await this.calculateDataForEnvComponent(component)) || {};\n const onlyOverview = await this.calculateIncludeOnlyOverview(component);\n const useNameParam = await this.calculateUseNameParam(component);\n\n const data: PreviewComponentData = {\n doesScaling,\n onlyOverview,\n useNameParam,\n ...dataFromEnv,\n ...envData,\n };\n return data;\n }\n\n /**\n * Calculate preview data on component that configured by its env\n * @param component\n * @returns\n */\n async calcPreviewDataFromEnv(\n component: Component\n ): Promise<Omit<PreviewAnyComponentData, 'doesScaling' | 'onlyOverview' | 'useNameParam'> | undefined> {\n // 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\n // so we can't load it since during load we are trying to get env component and load it again\n if (\n component.id.toStringWithoutVersion() === 'teambit.harmony/aspect' ||\n component.id.toStringWithoutVersion() === 'teambit.envs/env'\n ) {\n return {\n strategyName: COMPONENT_PREVIEW_STRATEGY_NAME,\n splitComponentBundle: false,\n };\n }\n\n const env = this.envs.getEnv(component).env;\n const envPreviewConfig = this.getEnvPreviewConfig(env);\n const data = {\n strategyName: envPreviewConfig?.strategyName,\n splitComponentBundle: envPreviewConfig?.splitComponentBundle ?? false,\n };\n return data;\n }\n\n /**\n * calculate extra preview data for env components (on load)\n * @param envComponent\n * @returns\n */\n private async calculateDataForEnvComponent(envComponent: Component): Promise<PreviewEnvComponentData | undefined> {\n const isEnv = this.envs.isEnv(envComponent);\n\n // If the component is not an env, we don't want to store anything in the data\n if (!isEnv) return undefined;\n\n const previewAspectConfig = this.getPreviewAspectConfig(envComponent);\n\n const data = {\n // default to true if the env doesn't have a preview config\n isScaling: previewAspectConfig?.isScaling ?? true,\n supportsOnlyOverview: true,\n supportsUseNameParam: true,\n };\n return data;\n }\n\n /**\n * Check if the component preview bundle contain the env as part of the bundle or only the component code\n * (we used in the past to bundle them together, there might also be specific envs which still uses the env strategy)\n * This should be used only for calculating the value on load.\n * otherwise, use the isBundledWithEnv function\n * @param component\n * @returns\n */\n async calcIsBundledWithEnv(component: Component): Promise<boolean> {\n const envPreviewData = await this.calcPreviewDataFromEnv(component);\n return envPreviewData?.strategyName !== 'component';\n }\n\n /**\n * Check if the component preview bundle contain the env as part of the bundle or only the component code\n * (we used in the past to bundle them together, there might also be specific envs which still uses the env strategy)\n * @param component\n * @returns\n */\n async isBundledWithEnv(component: Component): Promise<boolean> {\n const data = await this.getPreviewData(component);\n // For components that tagged in the past we didn't store the data, so we calculate it the old way\n // We comparing the strategyName to undefined to cover a specific case when it doesn't exist at all.\n if (!data || data.strategyName === undefined) return this.isBundledWithEnvBackward(component);\n return data.strategyName === ENV_PREVIEW_STRATEGY_NAME;\n }\n\n /**\n * This is a legacy calculation for the isBundledWithEnv\n * This calc is based on the component artifacts which is very expensive operation as it requires to fetch and load the artifacts\n * See the new implementation in the isBundledWithEnv method\n * @param component\n * @returns\n */\n private async isBundledWithEnvBackward(component: Component): Promise<boolean> {\n const artifacts = await this.builder.getArtifactsVinylByAspectAndName(\n component,\n PreviewAspect.id,\n COMPONENT_STRATEGY_ARTIFACT_NAME\n );\n if (!artifacts || !artifacts.length) return true;\n\n return false;\n }\n\n // This used on component load to calc the final result of support is scaling for a given component\n // This calc based on the env, env data, env preview config and more\n // if you want to get the final result use the `doesScaling` method below\n // This should be used only for component load\n private async calcDoesScalingForComponent(component: Component): Promise<boolean> {\n const isBundledWithEnv = await this.calcIsBundledWithEnv(component);\n // if it's a core env and the env template is apart from the component it means the template bundle already contain the scaling functionality\n if (this.envs.isUsingCoreEnv(component)) {\n // If the component is new, no point to check the is bundle with env (there is no artifacts so it will for sure return false)\n // If it's new, and we are here, it means that we already use a version of the env that support scaling\n const isNew = await component.isNew();\n if (isNew) {\n return true;\n }\n return isBundledWithEnv === false;\n }\n // For envs that bundled with the env return true always\n if (isBundledWithEnv) {\n return true;\n }\n const envComponent = await this.envs.getEnvComponent(component);\n return this.isEnvSupportScaling(envComponent);\n }\n\n /**\n * can the current component preview scale in size for different preview sizes.\n * this calculation is based on the env of the component and if the env of the component support it.\n */\n async doesScaling(component: Component): Promise<boolean> {\n const inWorkspace = await this.workspace?.hasId(component.id);\n // Support case when we have the dev server for the env, in that case we calc the data of the env as we can't rely on the env data from the scope\n // since we bundle it for the dev server again\n if (inWorkspace) {\n // if it's a core env and the env template is apart from the component it means the template bundle already contain the scaling functionality\n if (this.envs.isUsingCoreEnv(component)) {\n const isBundledWithEnv = await this.isBundledWithEnv(component);\n // If the component is new, no point to check the is bundle with env (there is no artifacts so it will for sure return false)\n // If it's new, and we are here, it means that we already use a version of the env that support scaling\n const isNew = await component.isNew();\n if (isNew) {\n return true;\n }\n return isBundledWithEnv === false;\n }\n const envComponent = await this.envs.getEnvComponent(component);\n const envSupportScaling = await this.calculateIsEnvSupportScaling(envComponent);\n return envSupportScaling ?? true;\n }\n const previewData = this.getPreviewData(component);\n if (!previewData) return false;\n // Get the does scaling (the new calculation) or the old calc used in isScaling (between versions (about) 848 and 860)\n if (previewData.doesScaling !== undefined) return previewData.doesScaling;\n // in case this component were tagged with versions between 848 and 860 we need to use the old calculation\n // together with the env calculation\n // In that case it means the component already tagged, so we take the env calc from the env data and not re-calc it\n if (previewData.isScaling) {\n const envComponent = await this.envs.getEnvComponent(component);\n const envSupportScaling = this.isEnvSupportScaling(envComponent);\n return !!envSupportScaling;\n }\n return false;\n }\n\n /**\n * Check if the current version of the env support scaling\n * @param envComponent\n * @returns\n */\n isEnvSupportScaling(envComponent: Component): boolean {\n const previewData = this.getPreviewData(envComponent);\n return !!previewData?.isScaling;\n }\n\n async isSupportSkipIncludes(component: Component) {\n if (!this.config.onlyOverview && !isFeatureEnabled(ONLY_OVERVIEW)) return false;\n const isCore = this.envs.isUsingCoreEnv(component);\n if (isCore) return false;\n\n const envComponent = await this.envs.getEnvComponent(component);\n const previewData = this.getPreviewData(envComponent);\n return !!previewData?.skipIncludes;\n }\n\n /**\n * check if the component preview should only include the overview (skipping rendering of the compostions and properties table)\n */\n async getOnlyOverview(component: Component): Promise<boolean> {\n if (!this.config.onlyOverview && !isFeatureEnabled(ONLY_OVERVIEW)) return false;\n const previewData = this.getPreviewData(component);\n return previewData?.onlyOverview ?? false;\n }\n\n /**\n * check if the component preview should include the name query param\n */\n async getUseNameParam(component: Component): Promise<boolean> {\n const previewData = this.getPreviewData(component);\n return previewData?.useNameParam ?? false;\n }\n\n /**\n * This function is calculate the isScaling support flag for the component preview.\n * This is calculated only for the env component and not for the component itself.\n * It should be only used during the (env) component on load.\n * Once the component load, you should only use the `isEnvSupportScaling` to fetch it from the calculated data.\n * If you want to check if an env for a given component support scaling, use the `isScaling` function.\n * @param component\n * @returns\n */\n private async calculateIsEnvSupportScaling(envComponent: Component): Promise<boolean | undefined> {\n const isEnv = this.envs.isEnv(envComponent);\n // If the component is not an env, we don't want to store anything in the data\n if (!isEnv) return undefined;\n const previewAspectConfig = this.getPreviewAspectConfig(envComponent);\n // default to true if the env doesn't have a preview config\n return previewAspectConfig?.isScaling ?? true;\n }\n\n /**\n * Check if the component preview bundle contain the header inside of it (legacy)\n * today we are not including the header inside anymore\n * @param component\n * @returns\n */\n async isLegacyHeader(component: Component): Promise<boolean> {\n // these envs had header in their docs\n const ENV_WITH_LEGACY_DOCS = ['react', 'env', 'aspect', 'lit', 'html', 'node', 'mdx', 'react-native', 'readme'];\n\n const artifacts = await this.builder.getArtifactsVinylByAspectAndName(\n component,\n PreviewAspect.id,\n ENV_STRATEGY_ARTIFACT_NAME\n );\n const envType = this.envs.getEnvData(component).type;\n return !!artifacts && !!artifacts.length && ENV_WITH_LEGACY_DOCS.includes(envType || '');\n }\n\n /**\n * Getting the env template artifact\n * This should be called with the env itself or it will return undefined\n * If you want to get the env template from the env of the component,\n * use: getEnvTemplateFromComponentEnv below\n *\n * @param component\n * @returns\n */\n async getEnvTemplate(component: Component): Promise<PreviewArtifact | undefined> {\n const artifacts = await this.builder.getArtifactsVinylByAspectAndTaskName(\n component,\n PreviewAspect.id,\n GENERATE_ENV_TEMPLATE_TASK_NAME\n );\n if (!artifacts || !artifacts.length) return undefined;\n\n return new PreviewArtifact(artifacts);\n }\n\n /**\n * This is a special method to get a core env template\n * As the core envs doesn't exist in the scope we need to bring it from other place\n * We will bring it from the core env package files\n */\n private async getCoreEnvTemplate(envId: string): Promise<PreviewArtifact | undefined> {\n const coreEnvDir = getAspectDir(envId);\n // const finalDir = join(coreEnvDir, getEnvTemplateArtifactDirectory());\n const artifactDef = getEnvTemplateArtifactDef()[0];\n const artifactFactory = new ArtifactFactory();\n\n let rootDir = artifactFactory.getRootDir(coreEnvDir, artifactDef);\n if (!existsSync(rootDir)) {\n // fallback to the bvm folder\n const coreEnvDirFromBvm = getAspectDirFromBvm(envId);\n rootDir = artifactFactory.getRootDir(coreEnvDirFromBvm, artifactDef);\n }\n if (!existsSync(rootDir)) {\n return undefined;\n }\n const paths = artifactFactory.resolvePaths(rootDir, artifactDef);\n if (!paths || !paths.length) {\n return undefined;\n }\n const artifactFiles = new ArtifactFiles(paths);\n\n artifactFiles.populateVinylsFromPaths(rootDir);\n return new PreviewArtifact(artifactFiles.vinyls);\n }\n\n /**\n * This will fetch the component env, then will take the env template from the component env\n * @param component\n */\n async getEnvTemplateFromComponentEnv(component: Component): Promise<PreviewArtifact | undefined> {\n const envId = this.envs.getEnvId(component);\n return this.getEnvTemplateByEnvId(envId);\n }\n\n /**\n * This will fetch the component env, then will take the env template from the component env\n * @param component\n */\n async getEnvTemplateByEnvId(envId: string): Promise<PreviewArtifact | undefined> {\n // Special treatment for core envs\n if (this.aspectLoader.isCoreEnv(envId)) {\n return this.getCoreEnvTemplate(envId);\n }\n const host = this.componentAspect.getHost();\n const resolvedEnvId = await host.resolveComponentId(envId);\n const envComponent = await host.get(resolvedEnvId);\n if (!envComponent) {\n throw new BitError(`can't load env. env id is ${envId}`);\n }\n return this.getEnvTemplate(envComponent);\n }\n\n getDefs(): PreviewDefinition[] {\n return this.previewSlot.values();\n }\n\n private writeHash = new Map<string, string>();\n private timestamp = Date.now();\n\n /**\n * write a link to load custom modules dynamically.\n * @param prefix write\n * @param moduleMap map of components to module paths to require.\n * @param defaultModule\n * @param dirName\n */\n writeLink(\n prefix: string,\n moduleMap: ComponentMap<string[]>,\n mainModulesMap: MainModulesMap,\n dirName: string,\n isSplitComponentBundle: boolean\n ) {\n const contents = generateLink(prefix, moduleMap, mainModulesMap, isSplitComponentBundle);\n return this.writeLinkContents(contents, dirName, prefix);\n }\n\n writeLinkContents(contents: string, targetDir: string, prefix: string) {\n const hash = objectHash(contents);\n const targetPath = join(targetDir, `${prefix}-${this.timestamp}.js`);\n\n // write only if link has changed (prevents triggering fs watches)\n if (this.writeHash.get(targetPath) !== hash) {\n writeFileSync(targetPath, contents);\n this.writeHash.set(targetPath, hash);\n }\n\n return targetPath;\n }\n\n private executionRefs = new Map<string, ExecutionRef>();\n\n private async getPreviewTarget(\n /** execution context (of the specific env) */\n context: ExecutionContext\n ): Promise<string[]> {\n // store context for later link-file updates\n // also register related envs that this context is acting on their behalf\n [context.id, ...context.relatedContexts].forEach((ctxId) => {\n this.executionRefs.set(ctxId, new ExecutionRef(context));\n });\n\n const previewRuntime = await this.writePreviewEntry(context);\n const linkFiles = await this.updateLinkFiles(context.components, context);\n\n return [...linkFiles, previewRuntime];\n }\n\n private async writePreviewEntry(context: { components: Component[] }, aspectsIdsToNotFilterOut: string[] = []) {\n const { rebuild, skipUiBuild } = this.ui.runtimeOptions;\n\n const [name, uiRoot] = this.getUi();\n const cacheKey = `${uiRoot.path}|${RUNTIME_NAME}`;\n const currentBundleHash = await createBundleHash(uiRoot, RUNTIME_NAME);\n const preBundleHash = readBundleHash(PreviewAspect.id, BUNDLE_DIR, '');\n const workspaceBundleDir = join(uiRoot.path, PUBLIC_DIR);\n const lastBundleHash = await this.cache.get(cacheKey);\n\n let bundlePath = '';\n\n // ensure the pre-bundle is ready\n if (!rebuild && !existsSync(workspaceBundleDir) && (currentBundleHash === preBundleHash || skipUiBuild)) {\n // use pre-bundle\n bundlePath = getBundlePath(PreviewAspect.id, BUNDLE_DIR, '') as string;\n } else if (!rebuild && existsSync(workspaceBundleDir) && (currentBundleHash === lastBundleHash || skipUiBuild)) {\n // use workspace bundle\n bundlePath = workspaceBundleDir;\n } else {\n // do build\n const resolvedAspects = await this.resolveAspects(PreviewRuntime.name, undefined, uiRoot);\n const filteredAspects = this.filterAspectsByExecutionContext(resolvedAspects, context, aspectsIdsToNotFilterOut);\n\n await buildPreBundlePreview(filteredAspects);\n bundlePath = workspaceBundleDir;\n await this.cache.set(cacheKey, currentBundleHash);\n }\n\n // prepare the runtime entry\n const previewRuntime = await generateBundlePreviewEntry(name, bundlePath, this.harmony.config.toObject());\n\n return previewRuntime;\n }\n\n private updateLinkFiles(components: Component[] = [], context: ExecutionContext) {\n const previews = this.previewSlot.values();\n const paths = previews.map(async (previewDef) => {\n const defaultTemplatePath = await previewDef.renderTemplatePathByEnv?.(context.env);\n const visitedEnvs = new Set();\n const mainModulesMap: MainModulesMap = {\n // @ts-ignore\n default: defaultTemplatePath,\n [context.envDefinition.id]: defaultTemplatePath,\n };\n\n const map = await previewDef.getModuleMap(components);\n const isSplitComponentBundle = this.getEnvPreviewConfig().splitComponentBundle ?? false;\n const withPathsP = map.asyncMap(async (files, component) => {\n const envDef = this.envs.getEnv(component);\n const environment = envDef.env;\n const envId = envDef.id;\n\n if (!mainModulesMap[envId] && !visitedEnvs.has(envId)) {\n const modulePath = await previewDef.renderTemplatePathByEnv?.(envDef.env);\n if (modulePath) {\n mainModulesMap[envId] = modulePath;\n }\n visitedEnvs.add(envId);\n }\n const compilerInstance = environment.getCompiler?.();\n const modulePath =\n compilerInstance?.getPreviewComponentRootPath?.(component) || this.pkg.getRuntimeModulePath(component);\n return files.map((file) => {\n if (!this.workspace || !compilerInstance) {\n return file.path;\n }\n const distRelativePath = compilerInstance.getDistPathBySrcPath(file.relative);\n return join(this.workspace.path, modulePath, distRelativePath);\n });\n // return files.map((file) => file.path);\n });\n const withPaths = await withPathsP;\n\n const dirPath = join(this.tempFolder, context.id);\n if (!existsSync(dirPath)) mkdirSync(dirPath, { recursive: true });\n\n const link = this.writeLink(previewDef.prefix, withPaths, mainModulesMap, dirPath, isSplitComponentBundle);\n return link;\n });\n\n return Promise.all(paths);\n }\n\n async writePreviewRuntime(context: { components: Component[] }, aspectsIdsToNotFilterOut: string[] = []) {\n const [name, uiRoot] = this.getUi();\n const resolvedAspects = await this.resolveAspects(PreviewRuntime.name, undefined, uiRoot);\n const filteredAspects = this.filterAspectsByExecutionContext(resolvedAspects, context, aspectsIdsToNotFilterOut);\n const filePath = await this.ui.generateRoot(filteredAspects, name, 'preview', PreviewAspect.id);\n return filePath;\n }\n\n async resolveAspects(\n runtimeName?: string,\n componentIds?: ComponentID[],\n uiRoot?: UIRoot,\n opts?: ResolveAspectsOptions\n ): Promise<AspectDefinition[]> {\n const root = uiRoot || this.getUi()[1];\n runtimeName = runtimeName || MainRuntime.name;\n const resolvedAspects = await root.resolveAspects(runtimeName, componentIds, opts);\n return resolvedAspects;\n }\n\n private getUi() {\n const ui = this.ui.getUi();\n if (!ui) throw new Error('ui not found');\n return ui;\n }\n\n /**\n * Filter the aspects to have only aspects that are:\n * 1. core aspects\n * 2. configured on the host (workspace/scope)\n * 3. used by at least one component from the context\n * @param aspects\n * @param context\n */\n private filterAspectsByExecutionContext(\n aspects: AspectDefinition[],\n context: { components: Component[] },\n aspectsIdsToNotFilterOut: string[] = []\n ) {\n let allComponentContextAspects: string[] = [];\n allComponentContextAspects = context.components.reduce((acc, curr) => {\n return acc.concat(curr.state.aspects.ids);\n }, allComponentContextAspects);\n const hostAspects = Object.keys(this.harmony.config.toObject());\n const allAspectsToInclude = uniq(hostAspects.concat(allComponentContextAspects));\n const filtered = aspects.filter((aspect) => {\n if (!aspect.getId) {\n return false;\n }\n return (\n this.aspectLoader.isCoreAspect(aspect.getId) ||\n allAspectsToInclude.includes(aspect.getId) ||\n aspectsIdsToNotFilterOut.includes(aspect.getId)\n );\n });\n\n return filtered;\n }\n\n private getDefaultStrategies() {\n return [\n new EnvBundlingStrategy(this, this.pkg, this.dependencyResolver),\n new ComponentBundlingStrategy(this, this.pkg, this.dependencyResolver),\n ];\n }\n\n // TODO - executionContext should be responsible for updating components list, and emit 'update' events\n // instead we keep track of changes\n private handleComponentChange = async (c: Component, updater: (currentComponents: ExecutionRef) => void) => {\n const env = this.envs.getEnv(c);\n const envId = env.id.toString();\n\n const executionRef = this.executionRefs.get(envId);\n if (!executionRef) {\n this.logger.warn(\n `failed to update link file for component \"${c.id.toString()}\" - could not find execution context for ${envId}`\n );\n return noopResult;\n }\n\n // add / remove / etc\n updater(executionRef);\n\n await this.updateLinkFiles(executionRef.currentComponents, executionRef.executionCtx);\n return noopResult;\n };\n\n private handleComponentRemoval = (cId: ComponentID) => {\n let component: Component | undefined;\n this.executionRefs.forEach((components) => {\n const found = components.get(cId);\n if (found) component = found;\n });\n if (!component) return Promise.resolve(noopResult);\n\n return this.handleComponentChange(component, (currentComponents) => currentComponents.remove(cId));\n };\n\n getEnvPreviewConfig(env?: PreviewEnv): EnvPreviewConfig {\n const config = env?.getPreviewConfig && typeof env?.getPreviewConfig === 'function' ? env?.getPreviewConfig() : {};\n\n return config;\n }\n\n /**\n * return the configured bundling strategy.\n */\n getBundlingStrategy(env?: PreviewEnv): BundlingStrategy {\n const defaultStrategies = this.getDefaultStrategies();\n const envPreviewConfig = this.getEnvPreviewConfig(env);\n const strategyFromEnv = envPreviewConfig?.strategyName;\n const strategyName = strategyFromEnv || this.config.bundlingStrategy || 'env';\n const strategies = this.bundlingStrategySlot.values().concat(defaultStrategies);\n const selected = strategies.find((strategy) => {\n return strategy.name === strategyName;\n });\n\n if (!selected) throw new BundlingStrategyNotFound(strategyName);\n\n return selected;\n }\n\n /**\n * register a new bundling strategy. default available strategies are `env` and ``\n */\n registerBundlingStrategy(bundlingStrategy: BundlingStrategy) {\n this.bundlingStrategySlot.register(bundlingStrategy);\n return this;\n }\n\n /**\n * register a new preview definition.\n */\n registerDefinition(previewDef: PreviewDefinition) {\n this.previewSlot.register(previewDef);\n }\n\n static slots = [Slot.withType<PreviewDefinition>(), Slot.withType<BundlingStrategy>()];\n\n static runtime = MainRuntime;\n static dependencies = [\n BundlerAspect,\n BuilderAspect,\n ComponentAspect,\n UIAspect,\n CacheAspect,\n EnvsAspect,\n WorkspaceAspect,\n PkgAspect,\n PubsubAspect,\n AspectLoaderAspect,\n LoggerAspect,\n DependencyResolverAspect,\n GraphqlAspect,\n WatcherAspect,\n ScopeAspect,\n ];\n\n static defaultConfig = {\n disabled: false,\n onlyOverview: false,\n };\n\n static async provider(\n // eslint-disable-next-line max-len\n [\n bundler,\n builder,\n componentExtension,\n uiMain,\n cache,\n envs,\n workspace,\n pkg,\n pubsub,\n aspectLoader,\n loggerMain,\n dependencyResolver,\n graphql,\n watcher,\n scope,\n ]: [\n BundlerMain,\n BuilderMain,\n ComponentMain,\n UiMain,\n CacheMain,\n EnvsMain,\n Workspace | undefined,\n PkgMain,\n PubsubMain,\n AspectLoaderMain,\n LoggerMain,\n DependencyResolverMain,\n GraphqlMain,\n WatcherMain,\n ScopeMain\n ],\n config: PreviewConfig,\n [previewSlot, bundlingStrategySlot]: [PreviewDefinitionRegistry, BundlingStrategySlot],\n harmony: Harmony\n ) {\n const logger = loggerMain.createLogger(PreviewAspect.id);\n // app.registerApp(new PreviewApp());\n const preview = new PreviewMain(\n harmony,\n previewSlot,\n uiMain,\n cache,\n envs,\n componentExtension,\n pkg,\n aspectLoader,\n config,\n bundlingStrategySlot,\n builder,\n workspace,\n logger,\n dependencyResolver\n );\n\n if (workspace)\n uiMain.registerStartPlugin(new PreviewStartPlugin(workspace, bundler, uiMain, pubsub, logger, watcher));\n\n componentExtension.registerRoute([\n new PreviewRoute(preview, logger),\n new ComponentPreviewRoute(preview, logger),\n // @ts-ignore\n new EnvTemplateRoute(preview, logger),\n new PreviewAssetsRoute(preview, logger),\n ]);\n\n bundler.registerTarget([\n {\n entry: preview.getPreviewTarget.bind(preview),\n },\n ]);\n\n if (!config.disabled)\n builder.registerBuildTasks([\n new EnvPreviewTemplateTask(preview, envs, aspectLoader, dependencyResolver, logger),\n new PreviewTask(bundler, preview, dependencyResolver, logger),\n new PreBundlePreviewTask(uiMain, logger),\n ]);\n\n if (workspace) {\n workspace.registerOnComponentAdd((c) =>\n preview.handleComponentChange(c, (currentComponents) => currentComponents.add(c))\n );\n workspace.registerOnComponentLoad(async (component) => {\n return preview.calcPreviewData(component);\n });\n workspace.registerOnComponentChange((c) =>\n preview.handleComponentChange(c, (currentComponents) => currentComponents.update(c))\n );\n workspace.registerOnComponentRemove((cId) => preview.handleComponentRemoval(cId));\n }\n if (scope) {\n scope.registerOnCompAspectReCalc((c) => preview.calcPreviewData(c));\n }\n\n envs.registerService(new PreviewService());\n\n graphql.register(previewSchema(preview));\n\n return preview;\n }\n}\n\nPreviewAspect.addRuntime(PreviewMain);\n"],"mappings":";;;;;;AAAA,SAAAA,SAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,QAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAE,SAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,QAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,QAAA;EAAA,MAAAH,IAAA,GAAAC,OAAA;EAAAE,OAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,KAAA;EAAA,MAAAJ,IAAA,GAAAC,OAAA;EAAAG,IAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAK,WAAA;EAAA,MAAAL,IAAA,GAAAC,OAAA;EAAAI,UAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAQA,SAAAM,MAAA;EAAA,MAAAN,IAAA,GAAAC,OAAA;EAAAK,KAAA,YAAAA,CAAA;IAAA,OAAAN,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAO,SAAA;EAAA,MAAAP,IAAA,GAAAC,OAAA;EAAAM,QAAA,YAAAA,CAAA;IAAA,OAAAP,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAQ,IAAA;EAAA,MAAAR,IAAA,GAAAC,OAAA;EAAAO,GAAA,YAAAA,CAAA;IAAA,OAAAR,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAS,OAAA;EAAA,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AO;EAChB;AACF;AAAC0B,OAAA,CAAA5S,WAAA,GAAAA,WAAA;AAAAzB,eAAA,CAr2BYyB,WAAW,WAmuBP,CAAC6S,eAAI,CAACC,QAAQ,CAAoB,CAAC,EAAED,eAAI,CAACC,QAAQ,CAAmB,CAAC,CAAC;AAAAvU,eAAA,CAnuB3EyB,WAAW,aAquBLyO,kBAAW;AAAAlQ,eAAA,CAruBjByB,WAAW,kBAsuBA,CACpB+S,wBAAa,EACbC,wBAAa,EACbC,4BAAe,EACfC,cAAQ,EACRC,oBAAW,EACXC,kBAAU,EACVC,oBAAe,EACfC,gBAAS,EACTC,sBAAY,EACZC,kCAAkB,EAClBC,sBAAY,EACZC,8CAAwB,EACxBC,kBAAa,EACbC,kBAAa,EACbC,gBAAW,CACZ;AAAAtV,eAAA,CAtvBUyB,WAAW,mBAwvBC;EACrB6R,QAAQ,EAAE,KAAK;EACflN,YAAY,EAAE;AAChB,CAAC;AA4GH7E,wBAAa,CAACgU,UAAU,CAAC9T,WAAW,CAAC"}
@@ -161,7 +161,16 @@ class PreviewPreview {
161
161
  }));
162
162
  const query = this.getQuery();
163
163
  const onlyOverview = this.getParam(query, 'onlyOverview');
164
- const includes = onlyOverview === 'true' ? [] : includesAll.filter(module => !!module);
164
+ const includes = onlyOverview === 'true' ? [] : includesAll.filter(module => !!module).map(module => {
165
+ if (!module.default || !(0, _lodash().isObject)(module.default)) return module;
166
+ // This aims to handle use cases where we have package.json with type:"module" in the root
167
+ // in that case sometime we might get the props both under default and in the object root
168
+ const keysWithoutDefault = Object.keys(module).filter(key => key !== 'default');
169
+ const defaultKeys = Object.keys(module.default);
170
+ if ((0, _lodash().intersection)(keysWithoutDefault, defaultKeys).length === defaultKeys.length) return module.default;
171
+ return module;
172
+ });
173
+
165
174
  // during build / tag, the component is isolated, so all aspects are relevant, and do not require filtering
166
175
  const componentAspects = this.isDev ? await this.getComponentAspects(componentId.toString()) : undefined;
167
176
  const previewModule = await this.getPreviewModule(name, componentId);