@teambit/preview 1.0.209 → 1.0.211

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.
Files changed (41) hide show
  1. package/artifacts/__bit_junit.xml +2 -2
  2. package/artifacts/preview/teambit_preview_preview-preview.js +1 -1
  3. package/artifacts/schema.json +3 -3
  4. package/artifacts/ui-bundle/asset-manifest.json +2 -2
  5. package/artifacts/ui-bundle/static/js/{main.0cd580c1.cjs → main.72e9feac.cjs} +3 -3
  6. package/dist/bundler/chunks.js +1 -1
  7. package/dist/component-preview.route.js +1 -1
  8. package/dist/component-preview.route.js.map +1 -1
  9. package/dist/env-preview-template.task.js +1 -1
  10. package/dist/env-preview-template.task.js.map +1 -1
  11. package/dist/env-template.route.js +1 -1
  12. package/dist/env-template.route.js.map +1 -1
  13. package/dist/events/click-inside-an-iframe.js +1 -1
  14. package/dist/events/click-inside-an-iframe.js.map +1 -1
  15. package/dist/execution-ref.js +1 -1
  16. package/dist/pre-bundle.js +1 -1
  17. package/dist/pre-bundle.js.map +1 -1
  18. package/dist/pre-bundle.task.js +1 -1
  19. package/dist/pre-bundle.task.js.map +1 -1
  20. package/dist/{preview-1711509617758.js → preview-1711682321261.js} +2 -2
  21. package/dist/preview-assets.route.js +1 -1
  22. package/dist/preview-assets.route.js.map +1 -1
  23. package/dist/preview.main.runtime.js +1 -1
  24. package/dist/preview.main.runtime.js.map +1 -1
  25. package/dist/preview.preview.runtime.js +1 -1
  26. package/dist/preview.preview.runtime.js.map +1 -1
  27. package/dist/preview.route.js +1 -1
  28. package/dist/preview.route.js.map +1 -1
  29. package/dist/preview.service.js +1 -1
  30. package/dist/preview.start-plugin.js +1 -1
  31. package/dist/preview.start-plugin.js.map +1 -1
  32. package/dist/preview.task.js +1 -1
  33. package/dist/preview.task.js.map +1 -1
  34. package/dist/size-event.js +1 -1
  35. package/dist/size-event.js.map +1 -1
  36. package/dist/strategies/component-strategy.js +1 -1
  37. package/dist/strategies/component-strategy.js.map +1 -1
  38. package/dist/strategies/env-strategy.js +1 -1
  39. package/dist/strategies/env-strategy.js.map +1 -1
  40. package/package.json +18 -18
  41. /package/artifacts/ui-bundle/static/js/{main.0cd580c1.cjs.LICENSE.txt → main.72e9feac.cjs.LICENSE.txt} +0 -0
@@ -8,7 +8,7 @@ exports.generateTemplateEntries = generateTemplateEntries;
8
8
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
9
9
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
10
10
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
11
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
11
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
12
12
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
13
13
  // TODO - we can remove the need to depenedOn preview-root, if we output chunks as "jsonp".
14
14
  //
@@ -19,7 +19,7 @@ function _artifactFileMiddleware() {
19
19
  return data;
20
20
  }
21
21
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
22
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
22
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
23
23
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
24
24
  class ComponentPreviewRoute {
25
25
  constructor(
@@ -1 +1 @@
1
- {"version":3,"names":["_uiFoundationUiPages","data","require","_artifactFileMiddleware","_defineProperty","obj","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","t","i","_toPrimitive","String","r","e","Symbol","toPrimitive","call","TypeError","Number","ComponentPreviewRoute","constructor","preview","logger","req","res","next","isLegacyPath","component","status","send","noPreview","artifact","getPreview","error","serverError","getArtifactFileMiddleware","exports"],"sources":["component-preview.route.ts"],"sourcesContent":["import type { NextFunction, Request, Response, Route } from '@teambit/express';\nimport type { Component } from '@teambit/component';\nimport { noPreview, serverError } from '@teambit/ui-foundation.ui.pages.static-error';\nimport type { Logger } from '@teambit/logger';\n\nimport { PreviewMain } from './preview.main.runtime';\nimport type { PreviewArtifact } from './preview-artifact';\nimport type { PreviewUrlParams } from './artifact-file-middleware';\nimport { getArtifactFileMiddleware } from './artifact-file-middleware';\n\nexport class ComponentPreviewRoute implements Route {\n constructor(\n /**\n * preview extension.\n */\n private preview: PreviewMain,\n private logger: Logger\n ) {}\n\n route = `/component-preview/:filePath(*)`;\n method = 'get';\n\n middlewares = [\n async (req: Request<PreviewUrlParams>, res: Response, next: NextFunction) => {\n try {\n let isLegacyPath = false;\n // @ts-ignore TODO: @guy please fix.\n const component = req.component as Component | undefined;\n if (!component) return res.status(404).send(noPreview());\n\n let artifact: PreviewArtifact | undefined;\n // TODO - prevent error `getVinylsAndImportIfMissing is not a function` #4680\n try {\n isLegacyPath = true;\n artifact = await this.preview.getPreview(component);\n } catch (e: any) {\n this.logger.error(`preview.getPreview has failed`, e);\n return res.status(404).send(noPreview());\n }\n // @ts-ignore\n req.artifact = artifact;\n // @ts-ignore\n req.isLegacyPath = isLegacyPath;\n return next();\n } catch (e: any) {\n this.logger.error('failed getting preview', e);\n return res.status(500).send(serverError());\n }\n },\n getArtifactFileMiddleware(this.logger),\n ];\n}\n"],"mappings":";;;;;;AAEA,SAAAA,qBAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,oBAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAMA,SAAAE,wBAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,uBAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAAuE,SAAAG,gBAAAC,GAAA,EAAAC,GAAA,EAAAC,KAAA,IAAAD,GAAA,GAAAE,cAAA,CAAAF,GAAA,OAAAA,GAAA,IAAAD,GAAA,IAAAI,MAAA,CAAAC,cAAA,CAAAL,GAAA,EAAAC,GAAA,IAAAC,KAAA,EAAAA,KAAA,EAAAI,UAAA,QAAAC,YAAA,QAAAC,QAAA,oBAAAR,GAAA,CAAAC,GAAA,IAAAC,KAAA,WAAAF,GAAA;AAAA,SAAAG,eAAAM,CAAA,QAAAC,CAAA,GAAAC,YAAA,CAAAF,CAAA,uCAAAC,CAAA,GAAAA,CAAA,GAAAE,MAAA,CAAAF,CAAA;AAAA,SAAAC,aAAAF,CAAA,EAAAI,CAAA,2BAAAJ,CAAA,KAAAA,CAAA,SAAAA,CAAA,MAAAK,CAAA,GAAAL,CAAA,CAAAM,MAAA,CAAAC,WAAA,kBAAAF,CAAA,QAAAJ,CAAA,GAAAI,CAAA,CAAAG,IAAA,CAAAR,CAAA,EAAAI,CAAA,uCAAAH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ACC,IAAI,CAAC,IAAAK,kCAAW,EAAC,CAAC,CAAC;MAC5C;IACF,CAAC,EACD,IAAAC,mDAAyB,EAAC,IAAI,CAACb,MAAM,CAAC,CACvC;EAjCE;AAkCL;AAACc,OAAA,CAAAjB,qBAAA,GAAAA,qBAAA","ignoreList":[]}
1
+ {"version":3,"names":["_uiFoundationUiPages","data","require","_artifactFileMiddleware","_defineProperty","obj","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","t","i","_toPrimitive","r","e","Symbol","toPrimitive","call","TypeError","String","Number","ComponentPreviewRoute","constructor","preview","logger","req","res","next","isLegacyPath","component","status","send","noPreview","artifact","getPreview","error","serverError","getArtifactFileMiddleware","exports"],"sources":["component-preview.route.ts"],"sourcesContent":["import type { NextFunction, Request, Response, Route } from '@teambit/express';\nimport type { Component } from '@teambit/component';\nimport { noPreview, serverError } from '@teambit/ui-foundation.ui.pages.static-error';\nimport type { Logger } from '@teambit/logger';\n\nimport { PreviewMain } from './preview.main.runtime';\nimport type { PreviewArtifact } from './preview-artifact';\nimport type { PreviewUrlParams } from './artifact-file-middleware';\nimport { getArtifactFileMiddleware } from './artifact-file-middleware';\n\nexport class ComponentPreviewRoute implements Route {\n constructor(\n /**\n * preview extension.\n */\n private preview: PreviewMain,\n private logger: Logger\n ) {}\n\n route = `/component-preview/:filePath(*)`;\n method = 'get';\n\n middlewares = [\n async (req: Request<PreviewUrlParams>, res: Response, next: NextFunction) => {\n try {\n let isLegacyPath = false;\n // @ts-ignore TODO: @guy please fix.\n const component = req.component as Component | undefined;\n if (!component) return res.status(404).send(noPreview());\n\n let artifact: PreviewArtifact | undefined;\n // TODO - prevent error `getVinylsAndImportIfMissing is not a function` #4680\n try {\n isLegacyPath = true;\n artifact = await this.preview.getPreview(component);\n } catch (e: any) {\n this.logger.error(`preview.getPreview has failed`, e);\n return res.status(404).send(noPreview());\n }\n // @ts-ignore\n req.artifact = artifact;\n // @ts-ignore\n req.isLegacyPath = isLegacyPath;\n return next();\n } catch (e: any) {\n this.logger.error('failed getting preview', e);\n return res.status(500).send(serverError());\n }\n },\n getArtifactFileMiddleware(this.logger),\n ];\n}\n"],"mappings":";;;;;;AAEA,SAAAA,qBAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,oBAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAMA,SAAAE,wBAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,uBAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAAuE,SAAAG,gBAAAC,GAAA,EAAAC,GAAA,EAAAC,KAAA,IAAAD,GAAA,GAAAE,cAAA,CAAAF,GAAA,OAAAA,GAAA,IAAAD,GAAA,IAAAI,MAAA,CAAAC,cAAA,CAAAL,GAAA,EAAAC,GAAA,IAAAC,KAAA,EAAAA,KAAA,EAAAI,UAAA,QAAAC,YAAA,QAAAC,QAAA,oBAAAR,GAAA,CAAAC,GAAA,IAAAC,KAAA,WAAAF,GAAA;AAAA,SAAAG,eAAAM,CAAA,QAAAC,CAAA,GAAAC,YAAA,CAAAF,CAAA,uCAAAC,CAAA,GAAAA,CAAA,GAAAA,CAAA;AAAA,SAAAC,aAAAF,CAAA,EAAAG,CAAA,2BAAAH,CAAA,KAAAA,CAAA,SAAAA,CAAA,MAAAI,CAAA,GAAAJ,CAAA,CAAAK,MAAA,CAAAC,WAAA,kBAAAF,CAAA,QAAAH,CAAA,GAAAG,CAAA,CAAAG,IAAA,CAAAP,CAAA,EAAAG,CAAA,uCAAAF,CAAA,SAAAA,CAAA,YAAAO,SAAA,yEAAAL,CAAA,GAAAM,MAAA,GAAAC,MAAA,EAAAV,CAAA;AAEhE,MAAMW,qBAAqB,CAAkB;EAClDC,WAAWA;EACT;AACJ;AACA;EACYC,OAAoB,EACpBC,MAAc,EACtB;IAAA,KAFQD,OAAoB,GAApBA,OAAoB;IAAA,KACpBC,MAAc,G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length; r++) { var t =
83
83
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
84
84
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
85
85
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
86
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
86
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
87
87
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
88
88
  const GENERATE_ENV_TEMPLATE_TASK_NAME = exports.GENERATE_ENV_TEMPLATE_TASK_NAME = 'GenerateEnvTemplate';
89
89
  class EnvPreviewTemplateTask {
@@ -1 +1 @@
1
- {"version":3,"names":["_builder","data","require","_cli","_pMapSeries","_interopRequireDefault","_component","_path","_lodash","_fsExtra","_chunks","_htmlPlugin","_createPeersLink","_excluded","obj","__esModule","default","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","_objectWithoutProperties","source","excluded","target","_objectWithoutPropertiesLoose","key","i","sourceSymbolKeys","indexOf","prototype","propertyIsEnumerable","call","sourceKeys","value","_toPropertyKey","configurable","writable","_toPrimitive","String","Symbol","toPrimitive","TypeError","Number","GENERATE_ENV_TEMPLATE_TASK_NAME","exports","EnvPreviewTemplateTask","constructor","preview","envs","aspectLoader","dependencyResolver","logger","execute","context","previewDefs","getDefs","htmlConfig","map","previewModule","generateHtmlConfig","dev","originalSeedersIds","capsuleNetwork","originalSeedersCapsules","c","component","id","toString","grouped","mapSeries","components","includes","undefined","envDef","getEnvFromComponent","env","bundlingStrategy","getBundlingStrategy","name","getEnvTargetFromComponent","shouldUseDefaultBundler","envToGetBundler","getEnvsEnvDefinition","groupEnvId","targets","isEmpty","componentsResults","runBundlerForGroups","groups","bundlerContext","assign","entry","development","metaData","initiator","envId","isEnvTemplate","bundlerResults","entries","targetsGroup","bundler","getTemplateBundler","bundlerResult","run","results","computeResults","flatten","isCoreEnv","envComponent","envPreviewConfig","getEnvPreviewConfig","peers","getPreviewHostDependenciesFromEnv","capsule","graphCapsules","getCapsule","Error","previewRoot","writePreviewRuntime","generateEntries","splitComponentBundle","workDir","path","outputPath","computeOutputPath","existsSync","mkdirpSync","resolvedEnvAspects","resolveAspects","MainRuntime","requestedOnly","filterByRuntime","resolvedEnv","hostRootDir","aspectPath","warn","html","chunking","splitChunks","hostDependencies","aliasHostDependencies","previewModules","getPreviewModules","previewEntries","_ref","rest","linkFile","writeLink","ComponentMap","create","peerLink","writePeerLink","generateTemplateEntries","previewRootPath","allResults","result","errors","err","message","warning","warnings","startTime","endTime","artifacts","getArtifactDef","modules","compact","Promise","all","def","renderTemplatePathByEnv","prefix","include","join","getArtifactDirectory","CAPSULE_ARTIFACTS_DIR","globPatterns","rootDir"],"sources":["env-preview-template.task.ts"],"sourcesContent":["import {\n BuildContext,\n BuiltTaskResult,\n BuildTask,\n TaskLocation,\n ComponentResult,\n CAPSULE_ARTIFACTS_DIR,\n} from '@teambit/builder';\nimport { MainRuntime } from '@teambit/cli';\nimport mapSeries from 'p-map-series';\nimport { Component, ComponentMap } from '@teambit/component';\nimport { AspectLoaderMain } from '@teambit/aspect-loader';\nimport { Bundler, BundlerContext, BundlerHtmlConfig, BundlerResult, Target } from '@teambit/bundler';\nimport type { EnvDefinition, Environment, EnvsMain } from '@teambit/envs';\nimport { join } from 'path';\nimport { compact, flatten, isEmpty } from 'lodash';\nimport { Logger } from '@teambit/logger';\nimport { DependencyResolverMain } from '@teambit/dependency-resolver';\nimport { existsSync, mkdirpSync } from 'fs-extra';\nimport type { PreviewMain } from './preview.main.runtime';\nimport { generateTemplateEntries } from './bundler/chunks';\nimport { generateHtmlConfig } from './bundler/html-plugin';\nimport { writePeerLink } from './bundler/create-peers-link';\n\nexport type ModuleExpose = {\n name: string;\n path: string;\n include?: string[];\n};\n\ntype TargetsGroup = {\n env: Environment;\n envToGetBundler: Environment;\n targets: Target[];\n};\ntype TargetsGroupMap = {\n [envId: string]: TargetsGroup;\n};\n\nexport const GENERATE_ENV_TEMPLATE_TASK_NAME = 'GenerateEnvTemplate';\n\nexport class EnvPreviewTemplateTask implements BuildTask {\n aspectId = 'teambit.preview/preview';\n name = GENERATE_ENV_TEMPLATE_TASK_NAME;\n location: TaskLocation = 'end';\n // readonly dependencies = [CompilerAspect.id];\n\n constructor(\n private preview: PreviewMain,\n private envs: EnvsMain,\n private aspectLoader: AspectLoaderMain,\n private dependencyResolver: DependencyResolverMain,\n private logger: Logger\n ) {}\n\n async execute(context: BuildContext): Promise<BuiltTaskResult> {\n const previewDefs = this.preview.getDefs();\n const htmlConfig = previewDefs.map((previewModule) => generateHtmlConfig(previewModule, { dev: context.dev }));\n const originalSeedersIds = context.capsuleNetwork.originalSeedersCapsules.map((c) => c.component.id.toString());\n const grouped: TargetsGroupMap = {};\n // avoid running them with `Promise.all` because getEnv methods do import/isolate which can't be in parallel.\n await mapSeries(context.components, async (component) => {\n // Do not run over other components in the graph. it make the process much longer with no need\n if (originalSeedersIds && originalSeedersIds.length && !originalSeedersIds.includes(component.id.toString())) {\n return undefined;\n }\n const envDef = this.envs.getEnvFromComponent(component);\n if (!envDef) return undefined;\n const env = envDef.env;\n const bundlingStrategy = this.preview.getBundlingStrategy(envDef.env);\n if (bundlingStrategy.name === 'env') {\n return undefined;\n }\n const target = await this.getEnvTargetFromComponent(context, component, envDef, htmlConfig);\n if (!target) return undefined;\n const shouldUseDefaultBundler = this.shouldUseDefaultBundler(envDef);\n let envToGetBundler = this.envs.getEnvsEnvDefinition().env;\n let groupEnvId = 'default';\n if (!shouldUseDefaultBundler) {\n envToGetBundler = env;\n groupEnvId = envDef.id;\n }\n if (!grouped[groupEnvId]) {\n grouped[groupEnvId] = {\n env,\n envToGetBundler,\n targets: [target],\n };\n } else {\n grouped[groupEnvId].targets.push(target);\n }\n return undefined;\n });\n if (isEmpty(grouped)) {\n return { componentsResults: [] };\n }\n\n return this.runBundlerForGroups(context, grouped);\n }\n\n private async runBundlerForGroups(context: BuildContext, groups: TargetsGroupMap): Promise<BuiltTaskResult> {\n const bundlerContext: BundlerContext = Object.assign(context, {\n targets: [],\n entry: [],\n development: context.dev,\n metaData: {\n initiator: `${GENERATE_ENV_TEMPLATE_TASK_NAME} task`,\n envId: context.id,\n isEnvTemplate: true,\n },\n });\n\n const bundlerResults = await mapSeries(Object.entries(groups), async ([, targetsGroup]) => {\n bundlerContext.targets = targetsGroup.targets;\n const bundler: Bundler = await targetsGroup.envToGetBundler.getTemplateBundler(bundlerContext);\n const bundlerResult = await bundler.run();\n return bundlerResult;\n });\n\n const results = await this.computeResults(bundlerContext, flatten(bundlerResults));\n return results;\n }\n\n private shouldUseDefaultBundler(envDef: EnvDefinition): boolean {\n if (this.aspectLoader.isCoreEnv(envDef.id) && envDef.id !== 'teambit.react/react-native') return true;\n const env = envDef.env;\n if (env.getTemplateBundler && typeof env.getTemplateBundler === 'function') return false;\n return true;\n }\n\n private async getEnvTargetFromComponent(\n context: BuildContext,\n envComponent: Component,\n envDef: EnvDefinition,\n htmlConfig: BundlerHtmlConfig[]\n ): Promise<Target | undefined> {\n const envPreviewConfig = this.preview.getEnvPreviewConfig(envDef.env);\n\n const peers = await this.dependencyResolver.getPreviewHostDependenciesFromEnv(envDef.env);\n // const module = await this.getPreviewModule(envComponent);\n // const entries = Object.keys(module).map((key) => module.exposes[key]);\n const capsule = context.capsuleNetwork.graphCapsules.getCapsule(envComponent.id);\n if (!capsule) throw new Error('no capsule found');\n // Passing here the env itself to make sure it's preview runtime will be part of the preview root file\n // that's needed to make sure the providers register there are running correctly\n const previewRoot = await this.preview.writePreviewRuntime(context, [envComponent.id.toString()]);\n const entries = await this.generateEntries({\n envDef,\n splitComponentBundle: envPreviewConfig.splitComponentBundle ?? false,\n workDir: capsule.path,\n peers,\n previewRoot,\n });\n const outputPath = this.computeOutputPath(context, envComponent);\n if (!existsSync(outputPath)) mkdirpSync(outputPath);\n const resolvedEnvAspects = await this.preview.resolveAspects(MainRuntime.name, [envComponent.id], undefined, {\n requestedOnly: true,\n // required to support envs that are plguins (.bit-env files)\n filterByRuntime: false,\n });\n const resolvedEnv = resolvedEnvAspects[0];\n const hostRootDir = resolvedEnv?.aspectPath;\n\n if (!hostRootDir) {\n this.logger.warn(`env preview template task, hostRootDir is not defined, for env ${envComponent.id.toString()}`);\n }\n\n return {\n peers,\n html: htmlConfig,\n entries,\n chunking: { splitChunks: true },\n components: [envComponent],\n outputPath,\n /* It's a path to the root of the host component. */\n hostRootDir,\n hostDependencies: peers,\n aliasHostDependencies: true,\n };\n }\n\n private async generateEntries({\n previewRoot,\n workDir,\n peers,\n envDef,\n splitComponentBundle,\n }: {\n previewRoot: string;\n workDir: string;\n peers: string[];\n envDef: EnvDefinition;\n splitComponentBundle: boolean;\n }) {\n const previewModules = await this.getPreviewModules(envDef);\n const previewEntries = previewModules.map(({ name, path, ...rest }) => {\n const linkFile = this.preview.writeLink(\n name,\n ComponentMap.create([]),\n { default: path },\n workDir,\n splitComponentBundle\n );\n\n return { name, path, ...rest, entry: linkFile };\n });\n const peerLink = await writePeerLink(peers, workDir);\n\n const entries = generateTemplateEntries({\n peers: peerLink,\n previewRootPath: previewRoot,\n previewModules: previewEntries,\n });\n return entries;\n }\n\n async computeResults(context: BundlerContext, results: BundlerResult[]) {\n const allResults = results.map((result) => {\n const componentsResults: ComponentResult[] = result.components.map((component) => {\n return {\n component,\n errors: result.errors.map((err) => (typeof err === 'string' ? err : err.message)),\n warning: result.warnings,\n startTime: result.startTime,\n endTime: result.endTime,\n };\n });\n return componentsResults;\n });\n\n const componentsResults = flatten(allResults);\n\n const artifacts = getArtifactDef();\n\n return {\n componentsResults,\n artifacts,\n };\n }\n\n private async getPreviewModules(envDef: EnvDefinition): Promise<ModuleExpose[]> {\n const previewDefs = this.preview.getDefs();\n\n const modules = compact(\n await Promise.all(\n previewDefs.map(async (def) => {\n if (!def.renderTemplatePathByEnv) return undefined;\n return {\n name: def.prefix,\n path: (await def.renderTemplatePathByEnv(envDef.env)) || '',\n include: def.include,\n };\n })\n )\n );\n\n return modules;\n }\n\n private computeOutputPath(context: BuildContext, component: Component) {\n const capsule = context.capsuleNetwork.graphCapsules.getCapsule(component.id);\n if (!capsule) throw new Error('no capsule found');\n return join(capsule.path, getArtifactDirectory());\n }\n}\n\nexport function getArtifactDirectory() {\n return join(CAPSULE_ARTIFACTS_DIR, 'env-template');\n}\n\nexport function getArtifactDef() {\n return [\n {\n name: 'env-template',\n globPatterns: ['**'],\n rootDir: getArtifactDirectory(),\n },\n ];\n}\n"],"mappings":";;;;;;;;AAAA,SAAAA,SAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,QAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAQA,SAAAE,KAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,IAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;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W,CAACG,GAAG,CAAC,MAAOgH,GAAG,IAAK;MAC7B,IAAI,CAACA,GAAG,CAACC,uBAAuB,EAAE,OAAOlG,SAAS;MAClD,OAAO;QACLM,IAAI,EAAE2F,GAAG,CAACE,MAAM;QAChBjD,IAAI,EAAE,CAAC,MAAM+C,GAAG,CAACC,uBAAuB,CAACjG,MAAM,CAACE,GAAG,CAAC,KAAK,EAAE;QAC3DiG,OAAO,EAAEH,GAAG,CAACG;MACf,CAAC;IACH,CAAC,CACH,CACF,CAAC;IAED,OAAOP,OAAO;EAChB;EAEQzC,iBAAiBA,CAACvE,OAAqB,EAAEY,SAAoB,EAAE;IACrE,MAAMgD,OAAO,GAAG5D,OAAO,CAACS,cAAc,CAACoD,aAAa,CAACC,UAAU,CAAClD,SAAS,CAACC,EAAE,CAAC;IAC7E,IAAI,CAAC+C,OAAO,EAAE,MAAM,IAAIG,KAAK,CAAC,kBAAkB,CAAC;IACjD,OAAO,IAAAyD,YAAI,EAAC5D,OAAO,CAACS,IAAI,EAAEoD,oBAAoB,CAAC,CAAC,CAAC;EACnD;AACF;AAAClI,OAAA,CAAAC,sBAAA,GAAAA,sBAAA;AAEM,SAASiI,oBAAoBA,CAAA,EAAG;EACrC,OAAO,IAAAD,YAAI,EAACE,gCAAqB,EAAE,cAAc,CAAC;AACpD;AAEO,SAASX,cAAcA,CAAA,EAAG;EAC/B,OAAO,CACL;IACEtF,IAAI,EAAE,cAAc;IACpBkG,YAAY,EAAE,CAAC,IAAI,CAAC;IACpBC,OAAO,EAAEH,oBAAoB,CAAC;EAChC,CAAC,CACF;AACH","ignoreList":[]}
1
+ {"version":3,"names":["_builder","data","require","_cli","_pMapSeries","_interopRequireDefault","_component","_path","_lodash","_fsExtra","_chunks","_htmlPlugin","_createPeersLink","_excluded","obj","__esModule","default","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","_objectWithoutProperties","source","excluded","target","_objectWithoutPropertiesLoose","key","i","sourceSymbolKeys","indexOf","prototype","propertyIsEnumerable","call","sourceKeys","value","_toPropertyKey","configurable","writable","_toPrimitive","Symbol","toPrimitive","TypeError","String","Number","GENERATE_ENV_TEMPLATE_TASK_NAME","exports","EnvPreviewTemplateTask","constructor","preview","envs","aspectLoader","dependencyResolver","logger","execute","context","previewDefs","getDefs","htmlConfig","map","previewModule","generateHtmlConfig","dev","originalSeedersIds","capsuleNetwork","originalSeedersCapsules","c","component","id","toString","grouped","mapSeries","components","includes","undefined","envDef","getEnvFromComponent","env","bundlingStrategy","getBundlingStrategy","name","getEnvTargetFromComponent","shouldUseDefaultBundler","envToGetBundler","getEnvsEnvDefinition","groupEnvId","targets","isEmpty","componentsResults","runBundlerForGroups","groups","bundlerContext","assign","entry","development","metaData","initiator","envId","isEnvTemplate","bundlerResults","entries","targetsGroup","bundler","getTemplateBundler","bundlerResult","run","results","computeResults","flatten","isCoreEnv","envComponent","envPreviewConfig","getEnvPreviewConfig","peers","getPreviewHostDependenciesFromEnv","capsule","graphCapsules","getCapsule","Error","previewRoot","writePreviewRuntime","generateEntries","splitComponentBundle","workDir","path","outputPath","computeOutputPath","existsSync","mkdirpSync","resolvedEnvAspects","resolveAspects","MainRuntime","requestedOnly","filterByRuntime","resolvedEnv","hostRootDir","aspectPath","warn","html","chunking","splitChunks","hostDependencies","aliasHostDependencies","previewModules","getPreviewModules","previewEntries","_ref","rest","linkFile","writeLink","ComponentMap","create","peerLink","writePeerLink","generateTemplateEntries","previewRootPath","allResults","result","errors","err","message","warning","warnings","startTime","endTime","artifacts","getArtifactDef","modules","compact","Promise","all","def","renderTemplatePathByEnv","prefix","include","join","getArtifactDirectory","CAPSULE_ARTIFACTS_DIR","globPatterns","rootDir"],"sources":["env-preview-template.task.ts"],"sourcesContent":["import {\n BuildContext,\n BuiltTaskResult,\n BuildTask,\n TaskLocation,\n ComponentResult,\n CAPSULE_ARTIFACTS_DIR,\n} from '@teambit/builder';\nimport { MainRuntime } from '@teambit/cli';\nimport mapSeries from 'p-map-series';\nimport { Component, ComponentMap } from '@teambit/component';\nimport { AspectLoaderMain } from '@teambit/aspect-loader';\nimport { Bundler, BundlerContext, BundlerHtmlConfig, BundlerResult, Target } from '@teambit/bundler';\nimport type { EnvDefinition, Environment, EnvsMain } from '@teambit/envs';\nimport { join } from 'path';\nimport { compact, flatten, isEmpty } from 'lodash';\nimport { Logger } from '@teambit/logger';\nimport { DependencyResolverMain } from '@teambit/dependency-resolver';\nimport { existsSync, mkdirpSync } from 'fs-extra';\nimport type { PreviewMain } from './preview.main.runtime';\nimport { generateTemplateEntries } from './bundler/chunks';\nimport { generateHtmlConfig } from './bundler/html-plugin';\nimport { writePeerLink } from './bundler/create-peers-link';\n\nexport type ModuleExpose = {\n name: string;\n path: string;\n include?: string[];\n};\n\ntype TargetsGroup = {\n env: Environment;\n envToGetBundler: Environment;\n targets: Target[];\n};\ntype TargetsGroupMap = {\n [envId: string]: TargetsGroup;\n};\n\nexport const GENERATE_ENV_TEMPLATE_TASK_NAME = 'GenerateEnvTemplate';\n\nexport class EnvPreviewTemplateTask implements BuildTask {\n aspectId = 'teambit.preview/preview';\n name = GENERATE_ENV_TEMPLATE_TASK_NAME;\n location: TaskLocation = 'end';\n // readonly dependencies = [CompilerAspect.id];\n\n constructor(\n private preview: PreviewMain,\n private envs: EnvsMain,\n private aspectLoader: AspectLoaderMain,\n private dependencyResolver: DependencyResolverMain,\n private logger: Logger\n ) {}\n\n async execute(context: BuildContext): Promise<BuiltTaskResult> {\n const previewDefs = this.preview.getDefs();\n const htmlConfig = previewDefs.map((previewModule) => generateHtmlConfig(previewModule, { dev: context.dev }));\n const originalSeedersIds = context.capsuleNetwork.originalSeedersCapsules.map((c) => c.component.id.toString());\n const grouped: TargetsGroupMap = {};\n // avoid running them with `Promise.all` because getEnv methods do import/isolate which can't be in parallel.\n await mapSeries(context.components, async (component) => {\n // Do not run over other components in the graph. it make the process much longer with no need\n if (originalSeedersIds && originalSeedersIds.length && !originalSeedersIds.includes(component.id.toString())) {\n return undefined;\n }\n const envDef = this.envs.getEnvFromComponent(component);\n if (!envDef) return undefined;\n const env = envDef.env;\n const bundlingStrategy = this.preview.getBundlingStrategy(envDef.env);\n if (bundlingStrategy.name === 'env') {\n return undefined;\n }\n const target = await this.getEnvTargetFromComponent(context, component, envDef, htmlConfig);\n if (!target) return undefined;\n const shouldUseDefaultBundler = this.shouldUseDefaultBundler(envDef);\n let envToGetBundler = this.envs.getEnvsEnvDefinition().env;\n let groupEnvId = 'default';\n if (!shouldUseDefaultBundler) {\n envToGetBundler = env;\n groupEnvId = envDef.id;\n }\n if (!grouped[groupEnvId]) {\n grouped[groupEnvId] = {\n env,\n envToGetBundler,\n targets: [target],\n };\n } else {\n grouped[groupEnvId].targets.push(target);\n }\n return undefined;\n });\n if (isEmpty(grouped)) {\n return { componentsResults: [] };\n }\n\n return this.runBundlerForGroups(context, grouped);\n }\n\n private async runBundlerForGroups(context: BuildContext, groups: TargetsGroupMap): Promise<BuiltTaskResult> {\n const bundlerContext: BundlerContext = Object.assign(context, {\n targets: [],\n entry: [],\n development: context.dev,\n metaData: {\n initiator: `${GENERATE_ENV_TEMPLATE_TASK_NAME} task`,\n envId: context.id,\n isEnvTemplate: true,\n },\n });\n\n const bundlerResults = await mapSeries(Object.entries(groups), async ([, targetsGroup]) => {\n bundlerContext.targets = targetsGroup.targets;\n const bundler: Bundler = await targetsGroup.envToGetBundler.getTemplateBundler(bundlerContext);\n const bundlerResult = await bundler.run();\n return bundlerResult;\n });\n\n const results = await this.computeResults(bundlerContext, flatten(bundlerResults));\n return results;\n }\n\n private shouldUseDefaultBundler(envDef: EnvDefinition): boolean {\n if (this.aspectLoader.isCoreEnv(envDef.id) && envDef.id !== 'teambit.react/react-native') return true;\n const env = envDef.env;\n if (env.getTemplateBundler && typeof env.getTemplateBundler === 'function') return false;\n return true;\n }\n\n private async getEnvTargetFromComponent(\n context: BuildContext,\n envComponent: Component,\n envDef: EnvDefinition,\n htmlConfig: BundlerHtmlConfig[]\n ): Promise<Target | undefined> {\n const envPreviewConfig = this.preview.getEnvPreviewConfig(envDef.env);\n\n const peers = await this.dependencyResolver.getPreviewHostDependenciesFromEnv(envDef.env);\n // const module = await this.getPreviewModule(envComponent);\n // const entries = Object.keys(module).map((key) => module.exposes[key]);\n const capsule = context.capsuleNetwork.graphCapsules.getCapsule(envComponent.id);\n if (!capsule) throw new Error('no capsule found');\n // Passing here the env itself to make sure it's preview runtime will be part of the preview root file\n // that's needed to make sure the providers register there are running correctly\n const previewRoot = await this.preview.writePreviewRuntime(context, [envComponent.id.toString()]);\n const entries = await this.generateEntries({\n envDef,\n splitComponentBundle: envPreviewConfig.splitComponentBundle ?? false,\n workDir: capsule.path,\n peers,\n previewRoot,\n });\n const outputPath = this.computeOutputPath(context, envComponent);\n if (!existsSync(outputPath)) mkdirpSync(outputPath);\n const resolvedEnvAspects = await this.preview.resolveAspects(MainRuntime.name, [envComponent.id], undefined, {\n requestedOnly: true,\n // required to support envs that are plguins (.bit-env files)\n filterByRuntime: false,\n });\n const resolvedEnv = resolvedEnvAspects[0];\n const hostRootDir = resolvedEnv?.aspectPath;\n\n if (!hostRootDir) {\n this.logger.warn(`env preview template task, hostRootDir is not defined, for env ${envComponent.id.toString()}`);\n }\n\n return {\n peers,\n html: htmlConfig,\n entries,\n chunking: { splitChunks: true },\n components: [envComponent],\n outputPath,\n /* It's a path to the root of the host component. */\n hostRootDir,\n hostDependencies: peers,\n aliasHostDependencies: true,\n };\n }\n\n private async generateEntries({\n previewRoot,\n workDir,\n peers,\n envDef,\n splitComponentBundle,\n }: {\n previewRoot: string;\n workDir: string;\n peers: string[];\n envDef: EnvDefinition;\n splitComponentBundle: boolean;\n }) {\n const previewModules = await this.getPreviewModules(envDef);\n const previewEntries = previewModules.map(({ name, path, ...rest }) => {\n const linkFile = this.preview.writeLink(\n name,\n ComponentMap.create([]),\n { default: path },\n workDir,\n splitComponentBundle\n );\n\n return { name, path, ...rest, entry: linkFile };\n });\n const peerLink = await writePeerLink(peers, workDir);\n\n const entries = generateTemplateEntries({\n peers: peerLink,\n previewRootPath: previewRoot,\n previewModules: previewEntries,\n });\n return entries;\n }\n\n async computeResults(context: BundlerContext, results: BundlerResult[]) {\n const allResults = results.map((result) => {\n const componentsResults: ComponentResult[] = result.components.map((component) => {\n return {\n component,\n errors: result.errors.map((err) => (typeof err === 'string' ? err : err.message)),\n warning: result.warnings,\n startTime: result.startTime,\n endTime: result.endTime,\n };\n });\n return componentsResults;\n });\n\n const componentsResults = flatten(allResults);\n\n const artifacts = getArtifactDef();\n\n return {\n componentsResults,\n artifacts,\n };\n }\n\n private async getPreviewModules(envDef: EnvDefinition): Promise<ModuleExpose[]> {\n const previewDefs = this.preview.getDefs();\n\n const modules = compact(\n await Promise.all(\n previewDefs.map(async (def) => {\n if (!def.renderTemplatePathByEnv) return undefined;\n return {\n name: def.prefix,\n path: (await def.renderTemplatePathByEnv(envDef.env)) || '',\n include: def.include,\n };\n })\n )\n );\n\n return modules;\n }\n\n private computeOutputPath(context: BuildContext, component: Component) {\n const capsule = context.capsuleNetwork.graphCapsules.getCapsule(component.id);\n if (!capsule) throw new Error('no capsule found');\n return join(capsule.path, getArtifactDirectory());\n }\n}\n\nexport function getArtifactDirectory() {\n return join(CAPSULE_ARTIFACTS_DIR, 'env-template');\n}\n\nexport function getArtifactDef() {\n return [\n {\n name: 'env-template',\n globPatterns: ['**'],\n rootDir: getArtifactDirectory(),\n },\n ];\n}\n"],"mappings":";;;;;;;;AAAA,SAAAA,SAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,QAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAQA,SAAAE,KAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,IAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;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GAAG,CAAC,MAAOgH,GAAG,IAAK;MAC7B,IAAI,CAACA,GAAG,CAACC,uBAAuB,EAAE,OAAOlG,SAAS;MAClD,OAAO;QACLM,IAAI,EAAE2F,GAAG,CAACE,MAAM;QAChBjD,IAAI,EAAE,CAAC,MAAM+C,GAAG,CAACC,uBAAuB,CAACjG,MAAM,CAACE,GAAG,CAAC,KAAK,EAAE;QAC3DiG,OAAO,EAAEH,GAAG,CAACG;MACf,CAAC;IACH,CAAC,CACH,CACF,CAAC;IAED,OAAOP,OAAO;EAChB;EAEQzC,iBAAiBA,CAACvE,OAAqB,EAAEY,SAAoB,EAAE;IACrE,MAAMgD,OAAO,GAAG5D,OAAO,CAACS,cAAc,CAACoD,aAAa,CAACC,UAAU,CAAClD,SAAS,CAACC,EAAE,CAAC;IAC7E,IAAI,CAAC+C,OAAO,EAAE,MAAM,IAAIG,KAAK,CAAC,kBAAkB,CAAC;IACjD,OAAO,IAAAyD,YAAI,EAAC5D,OAAO,CAACS,IAAI,EAAEoD,oBAAoB,CAAC,CAAC,CAAC;EACnD;AACF;AAAClI,OAAA,CAAAC,sBAAA,GAAAA,sBAAA;AAEM,SAASiI,oBAAoBA,CAAA,EAAG;EACrC,OAAO,IAAAD,YAAI,EAACE,gCAAqB,EAAE,cAAc,CAAC;AACpD;AAEO,SAASX,cAAcA,CAAA,EAAG;EAC/B,OAAO,CACL;IACEtF,IAAI,EAAE,cAAc;IACpBkG,YAAY,EAAE,CAAC,IAAI,CAAC;IACpBC,OAAO,EAAEH,oBAAoB,CAAC;EAChC,CAAC,CACF;AACH","ignoreList":[]}
@@ -19,7 +19,7 @@ function _artifactFileMiddleware() {
19
19
  return data;
20
20
  }
21
21
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
22
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
22
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
23
23
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
24
24
  // Week for now
25
25
  const CACHE_MAX_AGE = 60 * 60 * 24 * 7;
@@ -1 +1 @@
1
- {"version":3,"names":["_uiFoundationUiPages","data","require","_artifactFileMiddleware","_defineProperty","obj","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","t","i","_toPrimitive","String","r","e","Symbol","toPrimitive","call","TypeError","Number","CACHE_MAX_AGE","getCacheControl","_filePath","_contents","mimeType","undefined","EnvTemplateRoute","constructor","preview","logger","req","res","next","artifact","componentId","envId","params","getEnvTemplateByEnvId","error","status","send","noPreview","isLegacyPath","serverError","getArtifactFileMiddleware","exports"],"sources":["env-template.route.ts"],"sourcesContent":["import type { NextFunction, Request, Response } from '@teambit/express';\nimport type { ComponentUrlParams, RegisteredComponentRoute } from '@teambit/component';\nimport { noPreview, serverError } from '@teambit/ui-foundation.ui.pages.static-error';\nimport type { Logger } from '@teambit/logger';\n\nimport type { PreviewMain } from './preview.main.runtime';\nimport type { PreviewArtifact } from './preview-artifact';\nimport { getArtifactFileMiddleware, GetCacheControlFunc } from './artifact-file-middleware';\n\ntype UrlParams = ComponentUrlParams & {\n filePath?: string;\n};\n\n// Week for now\nconst CACHE_MAX_AGE = 60 * 60 * 24 * 7;\n\nconst getCacheControl: GetCacheControlFunc = (_filePath: string, _contents: string, mimeType?: string | null) => {\n // Do not cache the html files\n if (mimeType && mimeType === 'text/html') {\n return undefined;\n }\n return `private, max-age=${CACHE_MAX_AGE}`;\n};\n\nexport class EnvTemplateRoute implements RegisteredComponentRoute {\n constructor(\n /**\n * preview extension.\n */\n private preview: PreviewMain,\n private logger: Logger\n ) {}\n\n route = `/env-template/:previewName/:filePath(*)`;\n method = 'get';\n\n // Since we might give it a core env id\n // Then in the component route when we do host.get(id) it will fail, as we don't have the core envs in the scope/workspace\n resolveComponent = false;\n\n // @ts-ignore\n middlewares = [\n async (req: Request<UrlParams>, res: Response, next: NextFunction) => {\n try {\n // @ts-ignore TODO: @guy please fix.\n // const component = req.component as Component | undefined;\n // if (!component) return res.status(404).send(noPreview());\n\n let artifact: PreviewArtifact | undefined;\n // TODO - prevent error `getVinylsAndImportIfMissing is not a function` #4680\n try {\n const { componentId: envId } = req.params;\n artifact = await this.preview.getEnvTemplateByEnvId(envId);\n } catch (e: any) {\n this.logger.error(`getEnvTemplateByEnvId has failed`, e);\n return res.status(404).send(noPreview());\n }\n\n // @ts-ignore\n req.artifact = artifact;\n // @ts-ignore\n req.isLegacyPath = false;\n\n return next();\n } catch (e: any) {\n this.logger.error('failed getting preview', e);\n return res.status(500).send(serverError());\n }\n },\n getArtifactFileMiddleware(this.logger, getCacheControl),\n ];\n}\n"],"mappings":";;;;;;AAEA,SAAAA,qBAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,oBAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAKA,SAAAE,wBAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,uBAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAA4F,SAAAG,gBAAAC,GAAA,EAAAC,GAAA,EAAAC,KAAA,IAAAD,GAAA,GAAAE,cAAA,CAAAF,GAAA,OAAAA,GAAA,IAAAD,GAAA,IAAAI,MAAA,CAAAC,cAAA,CAAAL,GAAA,EAAAC,GAAA,IAAAC,KAAA,EAAAA,KAAA,EAAAI,UAAA,QAAAC,YAAA,QAAAC,QAAA,oBAAAR,GAAA,CAAAC,GAAA,IAAAC,KAAA,WAAAF,GAAA;AAAA,SAAAG,eAAAM,CAAA,QAAAC,CAAA,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CAAC,OAAOrB,CAAM,EAAE;UACf,IAAI,CAACe,MAAM,CAACS,KAAK,CAAE,kCAAiC,EAAExB,CAAC,CAAC;UACxD,OAAOiB,GAAG,CAACQ,MAAM,CAAC,GAAG,CAAC,CAACC,IAAI,CAAC,IAAAC,gCAAS,EAAC,CAAC,CAAC;QAC1C;;QAEA;QACAX,GAAG,CAACG,QAAQ,GAAGA,QAAQ;QACvB;QACAH,GAAG,CAACY,YAAY,GAAG,KAAK;QAExB,OAAOV,IAAI,CAAC,CAAC;MACf,CAAC,CAAC,OAAOlB,CAAM,EAAE;QACf,IAAI,CAACe,MAAM,CAACS,KAAK,CAAC,wBAAwB,EAAExB,CAAC,CAAC;QAC9C,OAAOiB,GAAG,CAACQ,MAAM,CAAC,GAAG,CAAC,CAACC,IAAI,CAAC,IAAAG,kCAAW,EAAC,CAAC,CAAC;MAC5C;IACF,CAAC,EACD,IAAAC,mDAAyB,EAAC,IAAI,CAACf,MAAM,EAAER,eAAe,CAAC,CACxD;EAvCE;AAwCL;AAACwB,OAAA,CAAAnB,gBAAA,GAAAA,gBAAA","ignoreList":[]}
1
+ {"version":3,"names":["_uiFoundationUiPages","data","require","_artifactFileMiddleware","_defineProperty","obj","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","t","i","_toPrimitive","r","e","Symbol","toPrimitive","call","TypeError","String","Number","CACHE_MAX_AGE","getCacheControl","_filePath","_contents","mimeType","undefined","EnvTemplateRoute","constructor","preview","logger","req","res","next","artifact","componentId","envId","params","getEnvTemplateByEnvId","error","status","send","noPreview","isLegacyPath","serverError","getArtifactFileMiddleware","exports"],"sources":["env-template.route.ts"],"sourcesContent":["import type { NextFunction, Request, Response } from '@teambit/express';\nimport type { ComponentUrlParams, RegisteredComponentRoute } from '@teambit/component';\nimport { noPreview, serverError } from '@teambit/ui-foundation.ui.pages.static-error';\nimport type { Logger } from '@teambit/logger';\n\nimport type { PreviewMain } from './preview.main.runtime';\nimport type { PreviewArtifact } from './preview-artifact';\nimport { getArtifactFileMiddleware, GetCacheControlFunc } from './artifact-file-middleware';\n\ntype UrlParams = ComponentUrlParams & {\n filePath?: string;\n};\n\n// Week for now\nconst CACHE_MAX_AGE = 60 * 60 * 24 * 7;\n\nconst getCacheControl: GetCacheControlFunc = (_filePath: string, _contents: string, mimeType?: string | null) => {\n // Do not cache the html files\n if (mimeType && mimeType === 'text/html') {\n return undefined;\n }\n return `private, max-age=${CACHE_MAX_AGE}`;\n};\n\nexport class EnvTemplateRoute implements RegisteredComponentRoute {\n constructor(\n /**\n * preview extension.\n */\n private preview: PreviewMain,\n private logger: Logger\n ) {}\n\n route = `/env-template/:previewName/:filePath(*)`;\n method = 'get';\n\n // Since we might give it a core env id\n // Then in the component route when we do host.get(id) it will fail, as we don't have the core envs in the scope/workspace\n resolveComponent = false;\n\n // @ts-ignore\n middlewares = [\n async (req: Request<UrlParams>, res: Response, next: NextFunction) => {\n try {\n // @ts-ignore TODO: @guy please fix.\n // const component = req.component as Component | undefined;\n // if (!component) return res.status(404).send(noPreview());\n\n let artifact: PreviewArtifact | undefined;\n // TODO - prevent error `getVinylsAndImportIfMissing is not a function` #4680\n try {\n const { componentId: envId } = req.params;\n artifact = await this.preview.getEnvTemplateByEnvId(envId);\n } catch (e: any) {\n this.logger.error(`getEnvTemplateByEnvId has failed`, e);\n return res.status(404).send(noPreview());\n }\n\n // @ts-ignore\n req.artifact = artifact;\n // @ts-ignore\n req.isLegacyPath = false;\n\n return next();\n } catch (e: any) {\n this.logger.error('failed getting preview', e);\n return res.status(500).send(serverError());\n }\n },\n getArtifactFileMiddleware(this.logger, getCacheControl),\n ];\n}\n"],"mappings":";;;;;;AAEA,SAAAA,qBAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,oBAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAKA,SAAAE,wBAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,uBAAA,YAAAA,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CAAwC;IAAAA,eAAA,iBACxC,KAAK;IAEd;IACA;IAAAA,eAAA,2BACmB,KAAK;IAExB;IAAAA,eAAA,sBACc,CACZ,OAAO+B,GAAuB,EAAEC,GAAa,EAAEC,IAAkB,KAAK;MACpE,IAAI;QACF;QACA;QACA;;QAEA,IAAIC,QAAqC;QACzC;QACA,IAAI;UACF,MAAM;YAAEC,WAAW,EAAEC;UAAM,CAAC,GAAGL,GAAG,CAACM,MAAM;UACzCH,QAAQ,GAAG,MAAM,IAAI,CAACL,OAAO,CAACS,qBAAqB,CAACF,KAAK,CAAC;QAC5D,CAAC,CAAC,OAAOtB,CAAM,EAAE;UACf,IAAI,CAACgB,MAAM,CAACS,KAAK,CAAE,kCAAiC,EAAEzB,CAAC,CAAC;UACxD,OAAOkB,GAAG,CAACQ,MAAM,CAAC,GAAG,CAAC,CAACC,IAAI,CAAC,IAAAC,gCAAS,EAAC,CAAC,CAAC;QAC1C;;QAEA;QACAX,GAAG,CAACG,QAAQ,GAAGA,QAAQ;QACvB;QACAH,GAAG,CAACY,YAAY,GAAG,KAAK;QAExB,OAAOV,IAAI,CAAC,CAAC;MACf,CAAC,CAAC,OAAOnB,CAAM,EAAE;QACf,IAAI,CAACgB,MAAM,CAACS,KAAK,CAAC,wBAAwB,EAAEzB,CAAC,CAAC;QAC9C,OAAOkB,GAAG,CAACQ,MAAM,CAAC,GAAG,CAAC,CAACC,IAAI,CAAC,IAAAG,kCAAW,EAAC,CAAC,CAAC;MAC5C;IACF,CAAC,EACD,IAAAC,mDAAyB,EAAC,IAAI,CAACf,MAAM,EAAER,eAAe,CAAC,CACxD;EAvCE;AAwCL;AAACwB,OAAA,CAAAnB,gBAAA,GAAAA,gBAAA","ignoreList":[]}
@@ -12,7 +12,7 @@ function _pubsub() {
12
12
  return data;
13
13
  }
14
14
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
15
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
15
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
16
16
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /* eslint-disable max-classes-per-file */
17
17
  class ClickInsideAnIframeEventData {
18
18
  constructor(clickEvent) {
@@ -1 +1 @@
1
- {"version":3,"names":["_pubsub","data","require","_defineProperty","obj","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","t","i","_toPrimitive","String","r","e","Symbol","toPrimitive","call","TypeError","Number","ClickInsideAnIframeEventData","constructor","clickEvent","ClickInsideAnIframeEvent","BitBaseEvent","timestamp","Date","now","TYPE","exports"],"sources":["click-inside-an-iframe.ts"],"sourcesContent":["/* eslint-disable max-classes-per-file */\nimport { BitBaseEvent } from '@teambit/pubsub';\n\nclass ClickInsideAnIframeEventData {\n constructor(private clickEvent: any) {}\n}\n\nexport class ClickInsideAnIframeEvent extends BitBaseEvent<ClickInsideAnIframeEventData> {\n static readonly TYPE = 'click-inside-an-iframe';\n\n constructor(readonly timestamp = Date.now(), readonly clickEvent) {\n super(ClickInsideAnIframeEvent.TYPE, '0.0.1', timestamp, new ClickInsideAnIframeEventData(clickEvent));\n }\n}\n"],"mappings":";;;;;;AACA,SAAAA,QAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,OAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAA+C,SAAAE,gBAAAC,GAAA,EAAAC,GAAA,EAAAC,KAAA,IAAAD,GAAA,GAAAE,cAAA,CAAAF,GAAA,OAAAA,GAAA,IAAAD,GAAA,IAAAI,MAAA,CAAAC,cAAA,CAAAL,GAAA,EAAAC,GAAA,IAAAC,KAAA,EAAAA,KAAA,EAAAI,UAAA,QAAAC,YAAA,QAAAC,QAAA,oBAAAR,GAAA,CAAAC,GAAA,IAAAC,KAAA,WAAAF,GAAA;AAAA,SAAAG,eAAAM,CAAA,QAAAC,CAAA,GAAAC,YAAA,CAAAF,CAAA,uCAAAC,CAAA,GAAAA,CAAA,GAAAE,MAAA,CAAAF,CAAA;AAAA,SAAAC,aAAAF,CAAA,EAAAI,CAAA,2BAAAJ,CAAA,KAAAA,CAAA,SAAAA,CAAA,MAAAK,CAAA,GAAAL,CAAA,CAAAM,MAAA,CAAAC,WAAA,kBAAAF,CAAA,QAAAJ,CAAA,GAAAI,CAAA,CAAAG,IAAA,CAAAR,CAAA,EAAAI,CAAA,uCAAAH,CAAA,SAAAA,CAAA,YAAAQ,SAAA,yEAAAL,CAAA,GAAAD,MAAA,GAAAO,MAAA,EAAAV,CAAA,KAD/C;AAGA,MAAMW,4BAA4B,CAAC;EACjCC,WAAWA,CAASC,UAAe,EAAE;IAAA,KAAjBA,UAAe,GAAfA,UAAe;EAAG;AACxC;AAEO,MAAMC,wBAAwB,SAASC,sBAAY,CAA+B;EAGvFH,WAAWA,CAAUI,SAAS,GAAGC,IAAI,CAACC,GAAG,CAAC,CAAC,EAAWL,UAAU,EAAE;IAChE,KAAK,CAACC,wBAAwB,CAACK,IAAI,EAAE,OAAO,EAAEH,SAAS,EAAE,IAAIL,4BAA4B,CAACE,UAAU,CAAC,CAAC;IAAC,KADpFG,SAAS,GAATA,SAAS;IAAA,KAAwBH,UAAU,GAAVA,UAAU;EAEhE;AACF;AAACO,OAAA,CAAAN,wBAAA,GAAAA,wBAAA;AAAAxB,eAAA,CANYwB,wBAAwB,UACZ,wBAAwB","ignoreList":[]}
1
+ {"version":3,"names":["_pubsub","data","require","_defineProperty","obj","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","t","i","_toPrimitive","r","e","Symbol","toPrimitive","call","TypeError","String","Number","ClickInsideAnIframeEventData","constructor","clickEvent","ClickInsideAnIframeEvent","BitBaseEvent","timestamp","Date","now","TYPE","exports"],"sources":["click-inside-an-iframe.ts"],"sourcesContent":["/* eslint-disable max-classes-per-file */\nimport { BitBaseEvent } from '@teambit/pubsub';\n\nclass ClickInsideAnIframeEventData {\n constructor(private clickEvent: any) {}\n}\n\nexport class ClickInsideAnIframeEvent extends BitBaseEvent<ClickInsideAnIframeEventData> {\n static readonly TYPE = 'click-inside-an-iframe';\n\n constructor(readonly timestamp = Date.now(), readonly clickEvent) {\n super(ClickInsideAnIframeEvent.TYPE, '0.0.1', timestamp, new ClickInsideAnIframeEventData(clickEvent));\n }\n}\n"],"mappings":";;;;;;AACA,SAAAA,QAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,OAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAA+C,SAAAE,gBAAAC,GAAA,EAAAC,GAAA,EAAAC,KAAA,IAAAD,GAAA,GAAAE,cAAA,CAAAF,GAAA,OAAAA,GAAA,IAAAD,GAAA,IAAAI,MAAA,CAAAC,cAAA,CAAAL,GAAA,EAAAC,GAAA,IAAAC,KAAA,EAAAA,KAAA,EAAAI,UAAA,QAAAC,YAAA,QAAAC,QAAA,oBAAAR,GAAA,CAAAC,GAAA,IAAAC,KAAA,WAAAF,GAAA;AAAA,SAAAG,eAAAM,CAAA,QAAAC,CAAA,GAAAC,YAAA,CAAAF,CAAA,uCAAAC,CAAA,GAAAA,CAAA,GAAAA,CAAA;AAAA,SAAAC,aAAAF,CAAA,EAAAG,CAAA,2BAAAH,CAAA,KAAAA,CAAA,SAAAA,CAAA,MAAAI,CAAA,GAAAJ,CAAA,CAAAK,MAAA,CAAAC,WAAA,kBAAAF,CAAA,QAAAH,CAAA,GAAAG,CAAA,CAAAG,IAAA,CAAAP,CAAA,EAAAG,CAAA,uCAAAF,CAAA,SAAAA,CAAA,YAAAO,SAAA,yEAAAL,CAAA,GAAAM,MAAA,GAAAC,MAAA,EAAAV,CAAA,KAD/C;AAGA,MAAMW,4BAA4B,CAAC;EACjCC,WAAWA,CAASC,UAAe,EAAE;IAAA,KAAjBA,UAAe,GAAfA,UAAe;EAAG;AACxC;AAEO,MAAMC,wBAAwB,SAASC,sBAAY,CAA+B;EAGvFH,WAAWA,CAAUI,SAAS,GAAGC,IAAI,CAACC,GAAG,CAAC,CAAC,EAAWL,UAAU,EAAE;IAChE,KAAK,CAACC,wBAAwB,CAACK,IAAI,EAAE,OAAO,EAAEH,SAAS,EAAE,IAAIL,4BAA4B,CAACE,UAAU,CAAC,CAAC;IAAC,KADpFG,SAAS,GAATA,SAAS;IAAA,KAAwBH,UAAU,GAAVA,UAAU;EAEhE;AACF;AAACO,OAAA,CAAAN,wBAAA,GAAAA,wBAAA;AAAAxB,eAAA,CANYwB,wBAAwB,UACZ,wBAAwB","ignoreList":[]}
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.ExecutionRef = void 0;
7
7
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
8
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
8
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
9
9
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
10
10
  // TODO - use workspace.list() instead of this
11
11
  class ExecutionRef {
@@ -79,7 +79,7 @@ function _preBundleUtils() {
79
79
  }
80
80
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
81
81
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
82
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
82
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
83
83
  const RUNTIME_NAME = exports.RUNTIME_NAME = 'preview';
84
84
  const PUBLIC_DIR = exports.PUBLIC_DIR = (0, _path().join)('public', 'bit-preview');
85
85
  const UIROOT_ASPECT_ID = exports.UIROOT_ASPECT_ID = 'teambit.workspace/workspace';
@@ -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') || 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,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,O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IF,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","ignoreList":[]}
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","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,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,IA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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","ignoreList":[]}
@@ -40,7 +40,7 @@ function _preview() {
40
40
  return data;
41
41
  }
42
42
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
43
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
43
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
44
44
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
45
45
  const BUNDLE_TASK_NAME = exports.BUNDLE_TASK_NAME = 'PreBundlePreview';
46
46
  const BUNDLE_DIR = exports.BUNDLE_DIR = 'ui-bundle';
@@ -1 +1 @@
1
- {"version":3,"names":["_path","data","require","_builder","_preBundleUtils","_preBundle","_preview","_defineProperty","obj","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","t","i","_toPrimitive","String","r","e","Symbol","toPrimitive","call","TypeError","Number","BUNDLE_TASK_NAME","exports","BUNDLE_DIR","PreBundlePreviewTask","constructor","ui","logger","PreviewAspect","id","execute","context","capsule","capsuleNetwork","seedersCapsules","find","c","component","toStringWithoutVersion","componentsResults","outputPath","join","path","CAPSULE_ARTIFACTS_DIR","info","uiRoot","getUi","resolvedAspects","resolveAspects","RUNTIME_NAME","buildPreBundlePreview","generateHash","error","Error","artifacts","getBundleArtifactDef","maybeUiRoot","generateBundleHash"],"sources":["pre-bundle.task.ts"],"sourcesContent":["import { join } from 'path';\nimport { BuildContext, BuildTask, BuiltTaskResult, CAPSULE_ARTIFACTS_DIR, TaskLocation } from '@teambit/builder';\nimport { Capsule } from '@teambit/isolator';\nimport { Logger } from '@teambit/logger';\nimport { UIRoot, UiMain } from '@teambit/ui';\nimport { generateBundleHash, getBundleArtifactDef } from './pre-bundle-utils';\nimport { RUNTIME_NAME, buildPreBundlePreview } from './pre-bundle';\nimport { PreviewAspect } from './preview.aspect';\n\nexport const BUNDLE_TASK_NAME = 'PreBundlePreview';\nexport const BUNDLE_DIR = 'ui-bundle';\n\nexport class PreBundlePreviewTask implements BuildTask {\n aspectId = PreviewAspect.id;\n name = BUNDLE_TASK_NAME;\n location: TaskLocation = 'end';\n\n constructor(private ui: UiMain, private logger: Logger) {}\n\n async execute(context: BuildContext): Promise<BuiltTaskResult> {\n const capsule: Capsule | undefined = context.capsuleNetwork.seedersCapsules.find(\n (c) => c.component.id.toStringWithoutVersion() === PreviewAspect.id\n );\n if (!capsule) {\n return { componentsResults: [] };\n }\n\n try {\n const outputPath = join(capsule.path, CAPSULE_ARTIFACTS_DIR, BUNDLE_DIR);\n this.logger.info(`Generating UI bundle at ${outputPath}...`);\n const [, uiRoot] = this.ui.getUi() as [string, UIRoot];\n const resolvedAspects = await uiRoot.resolveAspects(RUNTIME_NAME);\n await buildPreBundlePreview(resolvedAspects, outputPath);\n await this.generateHash(outputPath);\n } catch (error) {\n this.logger.error('Generating UI bundle failed', error);\n throw new Error('Generating UI bundle failed');\n }\n\n return {\n componentsResults: [],\n artifacts: [getBundleArtifactDef(BUNDLE_DIR, '')],\n };\n }\n\n private async generateHash(outputPath: string): Promise<void> {\n const maybeUiRoot = this.ui.getUi();\n if (!maybeUiRoot) throw new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ACG,cAAc,CAACC,yBAAY,CAAC;MACjE,MAAM,IAAAC,kCAAqB,EAACH,eAAe,EAAEP,UAAU,CAAC;MACxD,MAAM,IAAI,CAACW,YAAY,CAACX,UAAU,CAAC;IACrC,CAAC,CAAC,OAAOY,KAAK,EAAE;MACd,IAAI,CAACzB,MAAM,CAACyB,KAAK,CAAC,6BAA6B,EAAEA,KAAK,CAAC;MACvD,MAAM,IAAIC,KAAK,CAAC,6BAA6B,CAAC;IAChD;IAEA,OAAO;MACLd,iBAAiB,EAAE,EAAE;MACrBe,SAAS,EAAE,CAAC,IAAAC,sCAAoB,EAAChC,UAAU,EAAE,EAAE,CAAC;IAClD,CAAC;EACH;EAEA,MAAc4B,YAAYA,CAACX,UAAkB,EAAiB;IAC5D,MAAMgB,WAAW,GAAG,IAAI,CAAC9B,EAAE,CAACoB,KAAK,CAAC,CAAC;IACnC,IAAI,CAACU,WAAW,EAAE,MAAM,IAAIH,KAAK,CAAC,iBAAiB,CAAC;IAEpD,MAAM,GAAGR,MAAM,CAAC,GAAGW,WAAW;IAC9B,MAAM,IAAAC,oCAAkB,EAACZ,MAAM,EAAEI,yBAAY,EAAET,UAAU,CAAC;EAC5D;AACF;AAAClB,OAAA,CAAAE,oBAAA,GAAAA,oBAAA","ignoreList":[]}
1
+ {"version":3,"names":["_path","data","require","_builder","_preBundleUtils","_preBundle","_preview","_defineProperty","obj","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","t","i","_toPrimitive","r","e","Symbol","toPrimitive","call","TypeError","String","Number","BUNDLE_TASK_NAME","exports","BUNDLE_DIR","PreBundlePreviewTask","constructor","ui","logger","PreviewAspect","id","execute","context","capsule","capsuleNetwork","seedersCapsules","find","c","component","toStringWithoutVersion","componentsResults","outputPath","join","path","CAPSULE_ARTIFACTS_DIR","info","uiRoot","getUi","resolvedAspects","resolveAspects","RUNTIME_NAME","buildPreBundlePreview","generateHash","error","Error","artifacts","getBundleArtifactDef","maybeUiRoot","generateBundleHash"],"sources":["pre-bundle.task.ts"],"sourcesContent":["import { join } from 'path';\nimport { BuildContext, BuildTask, BuiltTaskResult, CAPSULE_ARTIFACTS_DIR, TaskLocation } from '@teambit/builder';\nimport { Capsule } from '@teambit/isolator';\nimport { Logger } from '@teambit/logger';\nimport { UIRoot, UiMain } from '@teambit/ui';\nimport { generateBundleHash, getBundleArtifactDef } from './pre-bundle-utils';\nimport { RUNTIME_NAME, buildPreBundlePreview } from './pre-bundle';\nimport { PreviewAspect } from './preview.aspect';\n\nexport const BUNDLE_TASK_NAME = 'PreBundlePreview';\nexport const BUNDLE_DIR = 'ui-bundle';\n\nexport class PreBundlePreviewTask implements BuildTask {\n aspectId = PreviewAspect.id;\n name = BUNDLE_TASK_NAME;\n location: TaskLocation = 'end';\n\n constructor(private ui: UiMain, private logger: Logger) {}\n\n async execute(context: BuildContext): Promise<BuiltTaskResult> {\n const capsule: Capsule | undefined = context.capsuleNetwork.seedersCapsules.find(\n (c) => c.component.id.toStringWithoutVersion() === PreviewAspect.id\n );\n if (!capsule) {\n return { componentsResults: [] };\n }\n\n try {\n const outputPath = join(capsule.path, CAPSULE_ARTIFACTS_DIR, BUNDLE_DIR);\n this.logger.info(`Generating UI bundle at ${outputPath}...`);\n const [, uiRoot] = this.ui.getUi() as [string, UIRoot];\n const resolvedAspects = await uiRoot.resolveAspects(RUNTIME_NAME);\n await buildPreBundlePreview(resolvedAspects, outputPath);\n await this.generateHash(outputPath);\n } catch (error) {\n this.logger.error('Generating UI bundle failed', error);\n throw new Error('Generating UI bundle failed');\n }\n\n return {\n componentsResults: [],\n artifacts: [getBundleArtifactDef(BUNDLE_DIR, '')],\n };\n }\n\n private async generateHash(outputPath: string): Promise<void> {\n const maybeUiRoot = this.ui.getUi();\n if (!maybeUiRoot) throw new Error('no uiRoot found');\n\n const [, uiRoot] = maybeUiRoot;\n await generateBundleHash(uiRoot, RUNTIME_NAME, outputPath);\n }\n}\n"],"mappings":";;;;;;AAAA,SAAAA,MAAA;EAAA,MAAA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C,OAAOY,KAAK,EAAE;MACd,IAAI,CAACzB,MAAM,CAACyB,KAAK,CAAC,6BAA6B,EAAEA,KAAK,CAAC;MACvD,MAAM,IAAIC,KAAK,CAAC,6BAA6B,CAAC;IAChD;IAEA,OAAO;MACLd,iBAAiB,EAAE,EAAE;MACrBe,SAAS,EAAE,CAAC,IAAAC,sCAAoB,EAAChC,UAAU,EAAE,EAAE,CAAC;IAClD,CAAC;EACH;EAEA,MAAc4B,YAAYA,CAACX,UAAkB,EAAiB;IAC5D,MAAMgB,WAAW,GAAG,IAAI,CAAC9B,EAAE,CAACoB,KAAK,CAAC,CAAC;IACnC,IAAI,CAACU,WAAW,EAAE,MAAM,IAAIH,KAAK,CAAC,iBAAiB,CAAC;IAEpD,MAAM,GAAGR,MAAM,CAAC,GAAGW,WAAW;IAC9B,MAAM,IAAAC,oCAAkB,EAACZ,MAAM,EAAEI,yBAAY,EAAET,UAAU,CAAC;EAC5D;AACF;AAAClB,OAAA,CAAAE,oBAAA,GAAAA,oBAAA","ignoreList":[]}
@@ -1,5 +1,5 @@
1
- import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.preview_preview@1.0.209/dist/preview.composition.js';
2
- import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.preview_preview@1.0.209/dist/preview.docs.mdx';
1
+ import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.preview_preview@1.0.211/dist/preview.composition.js';
2
+ import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.preview_preview@1.0.211/dist/preview.docs.mdx';
3
3
 
4
4
  export const compositions = [compositions_0];
5
5
  export const overview = [overview_0];
@@ -12,7 +12,7 @@ function _uiFoundationUiPages() {
12
12
  return data;
13
13
  }
14
14
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
15
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
15
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
16
16
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
17
17
  class PreviewAssetsRoute {
18
18
  constructor(
@@ -1 +1 @@
1
- {"version":3,"names":["_uiFoundationUiPages","data","require","_defineProperty","obj","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","t","i","_toPrimitive","String","r","e","Symbol","toPrimitive","call","TypeError","Number","PreviewAssetsRoute","constructor","preview","logger","req","res","component","status","jsonp","error","result","getPreviewFiles","json","send","serverError","exports"],"sources":["preview-assets.route.ts"],"sourcesContent":["import type { Request, Response, Route } from '@teambit/express';\nimport type { Component } from '@teambit/component';\nimport { serverError } from '@teambit/ui-foundation.ui.pages.static-error';\nimport type { Logger } from '@teambit/logger';\n\nimport { PreviewMain } from './preview.main.runtime';\n\nexport class PreviewAssetsRoute implements Route {\n constructor(\n /**\n * preview extension.\n */\n private preview: PreviewMain,\n private logger: Logger\n ) {}\n\n route = '/preview-assets';\n method = 'get';\n\n middlewares = [\n async (req: Request, res: Response) => {\n try {\n // @ts-ignore TODO: @guy please fix.\n const component = req.component as Component | undefined;\n // if (!component) return res.status(404).send(noPreview());\n if (!component) return res.status(404).jsonp({ error: 'not found' });\n const result = await this.preview.getPreviewFiles(component);\n if (!result) return res.status(404).jsonp({ error: 'not found' });\n return res.json(result);\n } catch (e: any) {\n this.logger.error('failed getting preview assets', e);\n return res.status(500).send(serverError());\n }\n },\n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A,IAAI,CAACA,SAAS,EAAE,OAAOD,GAAG,CAACE,MAAM,CAAC,GAAG,CAAC,CAACC,KAAK,CAAC;UAAEC,KAAK,EAAE;QAAY,CAAC,CAAC;QACpE,MAAMC,MAAM,GAAG,MAAM,IAAI,CAACR,OAAO,CAACS,eAAe,CAACL,SAAS,CAAC;QAC5D,IAAI,CAACI,MAAM,EAAE,OAAOL,GAAG,CAACE,MAAM,CAAC,GAAG,CAAC,CAACC,KAAK,CAAC;UAAEC,KAAK,EAAE;QAAY,CAAC,CAAC;QACjE,OAAOJ,GAAG,CAACO,IAAI,CAACF,MAAM,CAAC;MACzB,CAAC,CAAC,OAAOhB,CAAM,EAAE;QACf,IAAI,CAACS,MAAM,CAACM,KAAK,CAAC,+BAA+B,EAAEf,CAAC,CAAC;QACrD,OAAOW,GAAG,CAACE,MAAM,CAAC,GAAG,CAAC,CAACM,IAAI,CAAC,IAAAC,kCAAW,EAAC,CAAC,CAAC;MAC5C;IACF,CAAC,CACF;EApBE;AAqBL;AAACC,OAAA,CAAAf,kBAAA,GAAAA,kBAAA","ignoreList":[]}
1
+ {"version":3,"names":["_uiFoundationUiPages","data","require","_defineProperty","obj","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","t","i","_toPrimitive","r","e","Symbol","toPrimitive","call","TypeError","String","Number","PreviewAssetsRoute","constructor","preview","logger","req","res","component","status","jsonp","error","result","getPreviewFiles","json","send","serverError","exports"],"sources":["preview-assets.route.ts"],"sourcesContent":["import type { Request, Response, Route } from '@teambit/express';\nimport type { Component } from '@teambit/component';\nimport { serverError } from '@teambit/ui-foundation.ui.pages.static-error';\nimport type { Logger } from '@teambit/logger';\n\nimport { PreviewMain } from './preview.main.runtime';\n\nexport class PreviewAssetsRoute implements Route {\n constructor(\n /**\n * preview extension.\n */\n private preview: PreviewMain,\n private logger: Logger\n ) {}\n\n route = '/preview-assets';\n method = 'get';\n\n middlewares = [\n async (req: Request, res: Response) => {\n try {\n // @ts-ignore TODO: @guy please fix.\n const component = req.component as Component | undefined;\n // if (!component) return res.status(404).send(noPreview());\n if (!component) return res.status(404).jsonp({ error: 'not found' });\n const result = await this.preview.getPreviewFiles(component);\n if (!result) return res.status(404).jsonp({ error: 'not found' });\n return res.json(result);\n } catch (e: any) {\n this.logger.error('failed getting preview assets', e);\n return res.status(500).send(serverError());\n }\n },\n ];\n}\n"],"mappings":";;;;;;AAEA,SAAAA,qBAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,oBAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAA2E,SAAAE,gBAAAC,GAAA,EAAAC,GAAA,EAAAC,KAAA,IAAAD,GAAA,GAAAE,cAAA,CAAAF,GAAA,OAAAA,GAAA,IAAAD,GAAA,IAAAI,MAAA,CAAAC,cAAA,CAAAL,GAAA,EAAAC,GAAA,IAAAC,KAAA,EAAAA,KAAA,EAAAI,UAAA,QAAAC,YAAA,QAAAC,QAAA,oBAAAR,GAAA,CAAAC,GAAA,IAAAC,KAAA,WAAAF,GAAA;AAAA,SAAAG,eAAAM,CAAA,QAAAC,CAAA,GAAAC,YAAA,CAAAF,CAAA,uCAAAC,CAAA,GAAAA,CAAA,GAAAA,CAAA;AAAA,SAAAC,aAAAF,CAAA,EAAAG,CAAA,2BAAAH,CAAA,KAAAA,CAAA,SAAAA,CAAA,MAAAI,CAAA,GAAAJ,CAAA,CAAAK,MAAA,CAAAC,WAAA,kBAAAF,CAAA,QAAAH,CAAA,GAAAG,CAAA,CAAAG,IAAA,CAAAP,CAAA,EAAAG,CAAA,uCAAAF,CAAA,SAAAA,CAAA,YAAAO,SAAA,yEAAAL,CAAA,GAAAM,MAAA,GAAAC,MAAA,EAAAV,CAAA;AAKpE,MAAMW,kBAAkB,CAAkB;EAC/CC,WAAWA;EACT;AACJ;AACA;EACYC,OAAoB,EACpBC,MAAc,EACtB;IAAA,KAFQD,OAAoB,GAApBA,OAAoB;IAAA,KACpBC,MAAc,GAAdA,MAAc;IAAAxB,eAAA,gBAGhB,iBAAiB;IAAAA,eAAA,iBAChB,KAAK;IAAAA,eAAA,sBAEA,CACZ,OAAOyB,GAAY,EAAEC,GAAa,KAAK;MACrC,IAAI;QACF;QACA,MAAMC,SAAS,GAAGF,GAAG,CAACE,SAAkC;QACxD;QACA,IAAI,CAACA,SAAS,EAAE,OAAOD,GAAG,CAACE,MAAM,CAAC,GAAG,CAAC,CAACC,KAAK,CAAC;UAAEC,KAAK,EAAE;QAAY,CAAC,CAAC;QACpE,MAAMC,MAAM,GAAG,MAAM,IAAI,CAACR,OAAO,CAACS,eAAe,CAACL,SAAS,CAAC;QAC5D,IAAI,CAACI,MAAM,EAAE,OAAOL,GAAG,CAACE,MAAM,CAAC,GAAG,CAAC,CAACC,KAAK,CAAC;UAAEC,KAAK,EAAE;QAAY,CAAC,CAAC;QACjE,OAAOJ,GAAG,CAACO,IAAI,CAACF,MAAM,CAAC;MACzB,CAAC,CAAC,OAAOjB,CAAM,EAAE;QACf,IAAI,CAACU,MAAM,CAACM,KAAK,CAAC,+BAA+B,EAAEhB,CAAC,CAAC;QACrD,OAAOY,GAAG,CAACE,MAAM,CAAC,GAAG,CAAC,CAACM,IAAI,CAAC,IAAAC,kCAAW,EAAC,CAAC,CAAC;MAC5C;IACF,CAAC,CACF;EApBE;AAqBL;AAACC,OAAA,CAAAf,kBAAA,GAAAA,kBAAA","ignoreList":[]}
@@ -309,7 +309,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
309
309
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
310
310
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
311
311
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
312
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
312
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
313
313
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
314
314
  const noopResult = {
315
315
  results: [],