@teambit/preview 1.0.188 → 1.0.189
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/artifacts/__bit_junit.xml +2 -2
- package/artifacts/preview/teambit_preview_preview-preview.js +1 -1
- package/artifacts/schema.json +13401 -0
- package/dist/artifact-file-middleware.js.map +1 -1
- package/dist/bundler/chunks.js.map +1 -1
- package/dist/bundler/create-peer-link.spec.js.map +1 -1
- package/dist/bundler/create-peers-link.js.map +1 -1
- package/dist/bundler/html-plugin.js.map +1 -1
- package/dist/bundler/html-template.js.map +1 -1
- package/dist/bundling-strategy.js.map +1 -1
- package/dist/component-preview.js.map +1 -1
- package/dist/component-preview.route.js.map +1 -1
- package/dist/env-preview-template.task.js.map +1 -1
- package/dist/env-template.route.js.map +1 -1
- package/dist/events/click-inside-an-iframe.js.map +1 -1
- package/dist/events/index.js.map +1 -1
- package/dist/exceptions/bundling-strategy-not-found.js.map +1 -1
- package/dist/exceptions/index.js.map +1 -1
- package/dist/exceptions/preview-artifact-not-found.js.map +1 -1
- package/dist/exceptions/preview-not-found.js.map +1 -1
- package/dist/exceptions/preview-output-file-not-found.js.map +1 -1
- package/dist/execution-ref.js.map +1 -1
- package/dist/generate-link.js.map +1 -1
- package/dist/gql/fetch-component-aspects.js.map +1 -1
- package/dist/html-utils.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/mk-temp-dir.js.map +1 -1
- package/dist/pre-bundle-utils.js.map +1 -1
- package/dist/pre-bundle.js.map +1 -1
- package/dist/pre-bundle.task.js.map +1 -1
- package/dist/preview-1710224484125.js +7 -0
- package/dist/preview-artifact.js.map +1 -1
- package/dist/preview-assets.route.js.map +1 -1
- package/dist/preview-context.js.map +1 -1
- package/dist/preview-definition.js.map +1 -1
- package/dist/preview-env.js.map +1 -1
- package/dist/preview-modules.js.map +1 -1
- package/dist/preview-type.js.map +1 -1
- package/dist/preview.aspect.js.map +1 -1
- package/dist/preview.composition.js.map +1 -1
- package/dist/preview.graphql.js.map +1 -1
- package/dist/preview.js.map +1 -1
- package/dist/preview.main.runtime.js.map +1 -1
- package/dist/preview.preview.runtime.js.map +1 -1
- package/dist/preview.route.js.map +1 -1
- package/dist/preview.service.js.map +1 -1
- package/dist/preview.start-plugin.js.map +1 -1
- package/dist/preview.task.js.map +1 -1
- package/dist/rendering-context.js.map +1 -1
- package/dist/size-event.js.map +1 -1
- package/dist/strategies/component-strategy.d.ts +2 -2
- package/dist/strategies/component-strategy.js.map +1 -1
- package/dist/strategies/env-strategy.js.map +1 -1
- package/dist/strategies/generate-component-link.js.map +1 -1
- package/dist/strategies/index.js.map +1 -1
- package/dist/strategies/strategies-names.js.map +1 -1
- package/dist/types/preview-module.js.map +1 -1
- package/dist/webpack/webpack.config.js.map +1 -1
- package/package.json +23 -23
- package/dist/preview-1710040632859.js +0 -7
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_pubsub","data","require","_harmony","_componentId","_crossFetch","_interopRequireDefault","_memoizee","_lodash","_exceptions","_preview","_events","_renderingContext","_fetchComponentAspects","_previewModules","_htmlUtils","_sizeEvent","obj","__esModule","default","_defineProperty","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","t","i","_toPrimitive","String","r","e","Symbol","toPrimitive","call","TypeError","Number","PreviewPreview","constructor","pubsub","previewSlot","renderingContextSlot","isReady","Promise","resolve","_setupPromise","PREVIEW_MODULES","onSet","add","rootExt","window","document","body","style","width","previewName","componentId","envId","getLocation","name","getDefault","isDev","preview","getPreview","PreviewNotFound","includesAll","all","include","map","inclPreviewName","includedPreview","undefined","inclPreviewModule","getPreviewModule","selectPreviewModel","fullName","query","getQuery","onlyOverview","getParam","includes","filter","module","isObject","keysWithoutDefault","keys","defaultKeys","intersection","length","componentAspects","getComponentAspects","toString","previewModule","render","getRenderingContext","reportSize","setViewport","setFullScreen","memoize","fetchComponentAspects","max","maxAge","registerClickPubSub","addEventListener","timestamp","Date","now","clickEvent","assign","pub","PreviewAspect","id","ClickInsideAnIframeEvent","has","includedReady","every","included","fullScreen","root","getElementById","height","viewPort","maxWidth","parent","sendPubsubEvent","SizeEvent","offsetWidth","offsetHeight","debounce","counter","interval","setInterval","clearInterval","compShortId","relevantModel","get","Error","componentMap","componentPreviews","fetchComponentPreview","loadComponentPreviews","component","metadata","modulesMap","componentMapMetadata","previewFile","allFiles","fetchComponentPreviewFiles","file","endsWith","addComponentFileElement","loadPreviewScript","previewBundleFileName","addComponentFileScriptElement","addComponentFileLinkElement","catch","err","previewAssetsRoute","stringId","url","res","crossFetch","status","parsed","json","isBundledWithEnv","files","previewRoute","src","loadScript","href","loadLink","globalId","toStringWithoutVersion","componentPreview","registerPreview","register","aspectsFilter","RenderingContext","registerRenderContext","renderContext","previews","values","defaultOne","find","previewCandidate","param","params","URLSearchParams","withoutHash","location","hash","substring","after","split","before","ComponentID","tryFromString","provider","config","exports","PreviewRuntime","PubsubAspect","Slot","withType","addRuntime"],"sources":["preview.preview.runtime.tsx"],"sourcesContent":["import { PubsubAspect, PubsubPreview } from '@teambit/pubsub';\nimport { Slot, SlotRegistry } from '@teambit/harmony';\nimport { ComponentID } from '@teambit/component-id';\nimport crossFetch from 'cross-fetch';\nimport memoize from 'memoizee';\nimport { debounce, intersection, isObject } from 'lodash';\n\nimport { PreviewNotFound } from './exceptions';\nimport { PreviewType } from './preview-type';\nimport { PreviewAspect, PreviewRuntime } from './preview.aspect';\nimport { ClickInsideAnIframeEvent } from './events';\nimport { ModuleFile, PreviewModule } from './types/preview-module';\nimport { RenderingContext } from './rendering-context';\nimport { fetchComponentAspects } from './gql/fetch-component-aspects';\nimport { PREVIEW_MODULES } from './preview-modules';\nimport { loadScript, loadLink } from './html-utils';\nimport { SizeEvent } from './size-event';\n\n// forward linkModules() for generate-link.ts\nexport { linkModules } from './preview-modules';\n\nexport type PreviewSlot = SlotRegistry<PreviewType>;\n\nexport type RenderingContextOptions = { aspectsFilter?: string[] };\nexport type RenderingContextProvider = (options: RenderingContextOptions) => { [key: string]: any };\nexport type RenderingContextSlot = SlotRegistry<RenderingContextProvider>;\n\nexport class PreviewPreview {\n constructor(\n /**\n * register to pubsub\n */\n private pubsub: PubsubPreview,\n\n /**\n * preview slot.\n */\n private previewSlot: PreviewSlot,\n\n private renderingContextSlot: RenderingContextSlot\n ) {\n this.registerClickPubSub();\n }\n\n private registerClickPubSub() {\n window.addEventListener('click', (e) => {\n const timestamp = Date.now();\n const clickEvent = Object.assign({}, e);\n this.pubsub.pub(PreviewAspect.id, new ClickInsideAnIframeEvent(timestamp, clickEvent));\n });\n }\n\n private isDev = false;\n\n private isReady() {\n const { previewName } = this.getLocation();\n const name = previewName || this.getDefault();\n\n if (!PREVIEW_MODULES.has(name)) return false;\n const preview = this.getPreview(name);\n if (!preview) return false;\n const includedReady = preview.include?.every((included) => PREVIEW_MODULES.has(included)) ?? true;\n if (!includedReady) return false;\n\n return true;\n }\n\n private _setupPromise?: Promise<void>;\n setup = () => {\n if (this.isReady()) return Promise.resolve();\n\n this._setupPromise ??= new Promise((resolve) => {\n PREVIEW_MODULES.onSet.add(() => {\n if (this.isReady()) resolve();\n });\n });\n\n return this._setupPromise;\n };\n\n /**\n * render the preview.\n */\n render = async (rootExt?: string) => {\n // fit content always.\n window.document.body.style.width = 'fit-content';\n\n const { previewName, componentId, envId } = this.getLocation();\n const name = previewName || this.getDefault();\n if (rootExt) this.isDev = rootExt === 'teambit.workspace/workspace';\n\n const preview = this.getPreview(name);\n if (!preview || !componentId) {\n throw new PreviewNotFound(previewName);\n }\n\n const includesAll = await Promise.all(\n (preview.include || []).map(async (inclPreviewName) => {\n const includedPreview = this.getPreview(inclPreviewName);\n if (!includedPreview) return undefined;\n\n const inclPreviewModule = await this.getPreviewModule(inclPreviewName, componentId);\n return includedPreview.selectPreviewModel?.(componentId.fullName, inclPreviewModule);\n })\n );\n\n const query = this.getQuery();\n const onlyOverview = this.getParam(query, 'onlyOverview');\n\n const includes =\n onlyOverview === 'true'\n ? []\n : includesAll\n .filter((module) => !!module)\n .map((module) => {\n if (!module.default || !isObject(module.default)) return module;\n // This aims to handle use cases where we have package.json with type:\"module\" in the root\n // in that case sometime we might get the props both under default and in the object root\n const keysWithoutDefault = Object.keys(module).filter((key) => key !== 'default');\n const defaultKeys = Object.keys(module.default);\n if (intersection(keysWithoutDefault, defaultKeys).length === defaultKeys.length) return module.default;\n return module;\n });\n\n // during build / tag, the component is isolated, so all aspects are relevant, and do not require filtering\n const componentAspects = this.isDev ? await this.getComponentAspects(componentId.toString()) : undefined;\n const previewModule = await this.getPreviewModule(name, componentId);\n const render = preview.render(\n componentId,\n envId || '',\n previewModule,\n includes,\n this.getRenderingContext(componentAspects)\n );\n\n this.reportSize();\n this.setViewport();\n this.setFullScreen();\n return render;\n };\n\n setFullScreen() {\n const query = this.getQuery();\n const fullScreen = this.getParam(query, 'fullscreen');\n\n if (!fullScreen) return;\n\n const root = window.document.getElementById('root');\n\n if (root) {\n root.style.height = '100vh';\n }\n }\n\n setViewport() {\n const query = this.getQuery();\n const viewPort = this.getParam(query, 'viewport');\n if (!viewPort) {\n window.document.body.style.width = '100%';\n return;\n }\n\n window.document.body.style.maxWidth = `${viewPort}px`;\n }\n\n reportSize() {\n if (!window?.parent || !window?.document) return;\n // TODO: discuss with gilad for a better way to resolve page loaded here.\n\n const sendPubsubEvent = () => {\n this.pubsub.pub(\n PreviewAspect.id,\n new SizeEvent({\n width: window.document.body.offsetWidth,\n height: window.document.body.offsetHeight,\n })\n );\n };\n\n window.document.body.addEventListener('resize', debounce(sendPubsubEvent, 300));\n\n let counter = 0;\n const interval = setInterval(() => {\n // TODO: think\n counter += 1;\n if (counter > 10) {\n clearInterval(interval);\n return;\n }\n this.pubsub.pub(\n PreviewAspect.id,\n new SizeEvent({\n width: window.document.body.offsetWidth,\n height: window.document.body.offsetHeight,\n })\n );\n }, 200);\n }\n\n async getPreviewModule(previewName: string, id: ComponentID): Promise<PreviewModule> {\n const compShortId = id.fullName;\n\n const relevantModel = PREVIEW_MODULES.get(previewName);\n if (!relevantModel) throw new Error(`[preview.preview] missing preview \"${previewName}\"`);\n if (relevantModel.componentMap[compShortId]) return relevantModel;\n\n const componentPreviews = await this.fetchComponentPreview(id, previewName);\n PREVIEW_MODULES.loadComponentPreviews(compShortId, componentPreviews);\n\n const component = componentPreviews[previewName];\n const metadata = componentPreviews[`${previewName}_metadata`];\n\n return {\n modulesMap: relevantModel.modulesMap,\n componentMap: {\n [id.fullName]: component,\n },\n componentMapMetadata: {\n [id.fullName]: metadata,\n },\n };\n }\n\n async fetchComponentPreview(id: ComponentID, name: string): Promise<Record<string, ModuleFile[]>> {\n let previewFile: string | undefined;\n const allFiles = await this.fetchComponentPreviewFiles(id, name);\n // It's a component bundled with the env\n if (allFiles === null) return {};\n\n await Promise.all(\n allFiles.map((file) => {\n // We want to run the preview file always last\n if (file.endsWith('-preview.js')) {\n previewFile = file;\n return undefined;\n }\n\n return this.addComponentFileElement(id, file);\n })\n );\n\n if (!previewFile) return {};\n return this.loadPreviewScript(id, name, previewFile);\n }\n\n private addComponentFileElement(id: ComponentID, previewBundleFileName: string) {\n if (previewBundleFileName.endsWith('.js')) {\n return this.addComponentFileScriptElement(id, previewBundleFileName);\n }\n\n // TODO - should we load assets other than .css / .js?\n // if (previewBundleFileName.endsWith('.css')) {\n this.addComponentFileLinkElement(id, previewBundleFileName).catch((err) => {\n throw new Error(\n `[preview.preview] failed loading asset \"${previewBundleFileName}\". Error - \"${err?.toString()}\"`\n );\n });\n\n // do NOT await non js assets, as they might never load (like images), and not critical for rendering.\n return undefined;\n }\n\n private async fetchComponentPreviewFiles(id: ComponentID, previewName: string): Promise<string[] | null> {\n const previewAssetsRoute = `~aspect/preview-assets`;\n const stringId = id.toString();\n const url = `/api/${stringId}/${previewAssetsRoute}`;\n\n const res = await crossFetch(url);\n if (res.status >= 400) {\n throw new PreviewNotFound(previewName);\n }\n const parsed = await res.json();\n // This is component bundled with the env, no reason to bring the files, as they will be the files of the env\n if (parsed.isBundledWithEnv) {\n return null;\n }\n if (!parsed.files || !parsed.files.length) {\n throw new PreviewNotFound(previewName);\n }\n return parsed.files;\n }\n\n private addComponentFileScriptElement(id: ComponentID, previewBundleFileName: string) {\n const previewRoute = `~aspect/component-preview`;\n const stringId = id.toString();\n const src = `/api/${stringId}/${previewRoute}/${previewBundleFileName}`;\n return loadScript({ src });\n }\n\n private addComponentFileLinkElement(id: ComponentID, previewBundleFileName: string) {\n const stringId = id.toString();\n const previewRoute = `~aspect/component-preview`;\n const href = `/api/${stringId}/${previewRoute}/${previewBundleFileName}`;\n return loadLink({ href });\n }\n\n private async loadPreviewScript(id: ComponentID, previewName: string, previewBundleFileName: string) {\n const previewRoute = `~aspect/component-preview`;\n const src = `/api/${id.toString()}/${previewRoute}/${previewBundleFileName}`;\n await loadScript({ src });\n\n // TODO - replace with jsonp\n const globalId = `${id.toStringWithoutVersion()}-preview`;\n const componentPreview = window[globalId];\n if (!componentPreview) throw new PreviewNotFound(previewName);\n\n return componentPreview as Record<string, ModuleFile[]>;\n }\n\n private getComponentAspects = memoize(fetchComponentAspects, {\n max: 100,\n maxAge: 12 * 60 * 60 * 1000,\n });\n\n /**\n * register a new preview.\n */\n registerPreview(preview: PreviewType) {\n this.previewSlot.register(preview);\n return this;\n }\n\n /**\n * get the preview rendering context.\n */\n getRenderingContext(aspectsFilter?: string[]) {\n return new RenderingContext(this.renderingContextSlot, { aspectsFilter });\n }\n\n /**\n * allows aspects to add rendering contexts.\n * render context is available through all preview definitions.\n */\n registerRenderContext(renderContext: RenderingContextProvider) {\n this.renderingContextSlot.register(renderContext);\n return this;\n }\n\n getDefault() {\n const previews = this.previewSlot.values();\n const defaultOne = previews.find((previewCandidate) => previewCandidate.default);\n\n return defaultOne?.name || previews[0].name;\n }\n\n private getPreview(previewName: string): undefined | PreviewType {\n const previews = this.previewSlot.values();\n const preview = previews.find((previewCandidate) => previewCandidate.name === previewName);\n\n return preview;\n }\n\n getParam(query: string, param: string) {\n const params = new URLSearchParams(query);\n return params.get(param);\n }\n\n getQuery() {\n const withoutHash = window.location.hash.substring(1);\n const [, after] = withoutHash.split('?');\n return after;\n }\n\n private getLocation() {\n const withoutHash = window.location.hash.substring(1);\n const [before, after] = withoutHash.split('?');\n\n return {\n previewName: this.getParam(after, 'preview'),\n envId: this.getParam(after, 'env'),\n componentId: ComponentID.tryFromString(before),\n };\n }\n\n static runtime = PreviewRuntime;\n\n static dependencies = [PubsubAspect];\n\n static slots = [Slot.withType<PreviewType>(), Slot.withType<RenderingContextProvider>()];\n\n static async provider(\n [pubsub]: [PubsubPreview],\n config,\n [previewSlot, renderingContextSlot]: [PreviewSlot, RenderingContextSlot]\n ) {\n const preview = new PreviewPreview(pubsub, previewSlot, renderingContextSlot);\n\n window.addEventListener('hashchange', () => {\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n preview.render();\n });\n\n return preview;\n }\n}\n\nPreviewAspect.addRuntime(PreviewPreview);\n"],"mappings":";;;;;;;;;;;;AAAA,SAAAA,QAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,OAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,SAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,QAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,aAAA;EAAA,MAAAH,IAAA,GAAAC,OAAA;EAAAE,YAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,YAAA;EAAA,MAAAJ,IAAA,GAAAK,sBAAA,CAAAJ,OAAA;EAAAG,WAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAM,UAAA;EAAA,MAAAN,IAAA,GAAAK,sBAAA,CAAAJ,OAAA;EAAAK,SAAA,YAAAA,CAAA;IAAA,OAAAN,IA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,CAACE,MAAM,EAAEC,WAAW,EAAEC,oBAAoB,CAAC;IAE7ES,MAAM,CAACqD,gBAAgB,CAAC,YAAY,EAAE,MAAM;MAC1C;MACAzC,OAAO,CAAC+B,MAAM,CAAC,CAAC;IAClB,CAAC,CAAC;IAEF,OAAO/B,OAAO;EAChB;AACF;AAAC0I,OAAA,CAAAnK,cAAA,GAAAA,cAAA;AAAApB,eAAA,CA/WYoB,cAAc,aA2VRoK,yBAAc;AAAAxL,eAAA,CA3VpBoB,cAAc,kBA6VH,CAACqK,sBAAY,CAAC;AAAAzL,eAAA,CA7VzBoB,cAAc,WA+VV,CAACsK,eAAI,CAACC,QAAQ,CAAc,CAAC,EAAED,eAAI,CAACC,QAAQ,CAA2B,CAAC,CAAC;AAkB1F9F,wBAAa,CAAC+F,UAAU,CAACxK,cAAc,CAAC"}
|
1
|
+
{"version":3,"names":["_pubsub","data","require","_harmony","_componentId","_crossFetch","_interopRequireDefault","_memoizee","_lodash","_exceptions","_preview","_events","_renderingContext","_fetchComponentAspects","_previewModules","_htmlUtils","_sizeEvent","obj","__esModule","default","_defineProperty","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","t","i","_toPrimitive","String","r","e","Symbol","toPrimitive","call","TypeError","Number","PreviewPreview","constructor","pubsub","previewSlot","renderingContextSlot","isReady","Promise","resolve","_setupPromise","PREVIEW_MODULES","onSet","add","rootExt","window","document","body","style","width","previewName","componentId","envId","getLocation","name","getDefault","isDev","preview","getPreview","PreviewNotFound","includesAll","all","include","map","inclPreviewName","includedPreview","undefined","inclPreviewModule","getPreviewModule","selectPreviewModel","fullName","query","getQuery","onlyOverview","getParam","includes","filter","module","isObject","keysWithoutDefault","keys","defaultKeys","intersection","length","componentAspects","getComponentAspects","toString","previewModule","render","getRenderingContext","reportSize","setViewport","setFullScreen","memoize","fetchComponentAspects","max","maxAge","registerClickPubSub","addEventListener","timestamp","Date","now","clickEvent","assign","pub","PreviewAspect","id","ClickInsideAnIframeEvent","has","includedReady","every","included","fullScreen","root","getElementById","height","viewPort","maxWidth","parent","sendPubsubEvent","SizeEvent","offsetWidth","offsetHeight","debounce","counter","interval","setInterval","clearInterval","compShortId","relevantModel","get","Error","componentMap","componentPreviews","fetchComponentPreview","loadComponentPreviews","component","metadata","modulesMap","componentMapMetadata","previewFile","allFiles","fetchComponentPreviewFiles","file","endsWith","addComponentFileElement","loadPreviewScript","previewBundleFileName","addComponentFileScriptElement","addComponentFileLinkElement","catch","err","previewAssetsRoute","stringId","url","res","crossFetch","status","parsed","json","isBundledWithEnv","files","previewRoute","src","loadScript","href","loadLink","globalId","toStringWithoutVersion","componentPreview","registerPreview","register","aspectsFilter","RenderingContext","registerRenderContext","renderContext","previews","values","defaultOne","find","previewCandidate","param","params","URLSearchParams","withoutHash","location","hash","substring","after","split","before","ComponentID","tryFromString","provider","config","exports","PreviewRuntime","PubsubAspect","Slot","withType","addRuntime"],"sources":["preview.preview.runtime.tsx"],"sourcesContent":["import { PubsubAspect, PubsubPreview } from '@teambit/pubsub';\nimport { Slot, SlotRegistry } from '@teambit/harmony';\nimport { ComponentID } from '@teambit/component-id';\nimport crossFetch from 'cross-fetch';\nimport memoize from 'memoizee';\nimport { debounce, intersection, isObject } from 'lodash';\n\nimport { PreviewNotFound } from './exceptions';\nimport { PreviewType } from './preview-type';\nimport { PreviewAspect, PreviewRuntime } from './preview.aspect';\nimport { ClickInsideAnIframeEvent } from './events';\nimport { ModuleFile, PreviewModule } from './types/preview-module';\nimport { RenderingContext } from './rendering-context';\nimport { fetchComponentAspects } from './gql/fetch-component-aspects';\nimport { PREVIEW_MODULES } from './preview-modules';\nimport { loadScript, loadLink } from './html-utils';\nimport { SizeEvent } from './size-event';\n\n// forward linkModules() for generate-link.ts\nexport { linkModules } from './preview-modules';\n\nexport type PreviewSlot = SlotRegistry<PreviewType>;\n\nexport type RenderingContextOptions = { aspectsFilter?: string[] };\nexport type RenderingContextProvider = (options: RenderingContextOptions) => { [key: string]: any };\nexport type RenderingContextSlot = SlotRegistry<RenderingContextProvider>;\n\nexport class PreviewPreview {\n constructor(\n /**\n * register to pubsub\n */\n private pubsub: PubsubPreview,\n\n /**\n * preview slot.\n */\n private previewSlot: PreviewSlot,\n\n private renderingContextSlot: RenderingContextSlot\n ) {\n this.registerClickPubSub();\n }\n\n private registerClickPubSub() {\n window.addEventListener('click', (e) => {\n const timestamp = Date.now();\n const clickEvent = Object.assign({}, e);\n this.pubsub.pub(PreviewAspect.id, new ClickInsideAnIframeEvent(timestamp, clickEvent));\n });\n }\n\n private isDev = false;\n\n private isReady() {\n const { previewName } = this.getLocation();\n const name = previewName || this.getDefault();\n\n if (!PREVIEW_MODULES.has(name)) return false;\n const preview = this.getPreview(name);\n if (!preview) return false;\n const includedReady = preview.include?.every((included) => PREVIEW_MODULES.has(included)) ?? true;\n if (!includedReady) return false;\n\n return true;\n }\n\n private _setupPromise?: Promise<void>;\n setup = () => {\n if (this.isReady()) return Promise.resolve();\n\n this._setupPromise ??= new Promise((resolve) => {\n PREVIEW_MODULES.onSet.add(() => {\n if (this.isReady()) resolve();\n });\n });\n\n return this._setupPromise;\n };\n\n /**\n * render the preview.\n */\n render = async (rootExt?: string) => {\n // fit content always.\n window.document.body.style.width = 'fit-content';\n\n const { previewName, componentId, envId } = this.getLocation();\n const name = previewName || this.getDefault();\n if (rootExt) this.isDev = rootExt === 'teambit.workspace/workspace';\n\n const preview = this.getPreview(name);\n if (!preview || !componentId) {\n throw new PreviewNotFound(previewName);\n }\n\n const includesAll = await Promise.all(\n (preview.include || []).map(async (inclPreviewName) => {\n const includedPreview = this.getPreview(inclPreviewName);\n if (!includedPreview) return undefined;\n\n const inclPreviewModule = await this.getPreviewModule(inclPreviewName, componentId);\n return includedPreview.selectPreviewModel?.(componentId.fullName, inclPreviewModule);\n })\n );\n\n const query = this.getQuery();\n const onlyOverview = this.getParam(query, 'onlyOverview');\n\n const includes =\n onlyOverview === 'true'\n ? []\n : includesAll\n .filter((module) => !!module)\n .map((module) => {\n if (!module.default || !isObject(module.default)) return module;\n // This aims to handle use cases where we have package.json with type:\"module\" in the root\n // in that case sometime we might get the props both under default and in the object root\n const keysWithoutDefault = Object.keys(module).filter((key) => key !== 'default');\n const defaultKeys = Object.keys(module.default);\n if (intersection(keysWithoutDefault, defaultKeys).length === defaultKeys.length) return module.default;\n return module;\n });\n\n // during build / tag, the component is isolated, so all aspects are relevant, and do not require filtering\n const componentAspects = this.isDev ? await this.getComponentAspects(componentId.toString()) : undefined;\n const previewModule = await this.getPreviewModule(name, componentId);\n const render = preview.render(\n componentId,\n envId || '',\n previewModule,\n includes,\n this.getRenderingContext(componentAspects)\n );\n\n this.reportSize();\n this.setViewport();\n this.setFullScreen();\n return render;\n };\n\n setFullScreen() {\n const query = this.getQuery();\n const fullScreen = this.getParam(query, 'fullscreen');\n\n if (!fullScreen) return;\n\n const root = window.document.getElementById('root');\n\n if (root) {\n root.style.height = '100vh';\n }\n }\n\n setViewport() {\n const query = this.getQuery();\n const viewPort = this.getParam(query, 'viewport');\n if (!viewPort) {\n window.document.body.style.width = '100%';\n return;\n }\n\n window.document.body.style.maxWidth = `${viewPort}px`;\n }\n\n reportSize() {\n if (!window?.parent || !window?.document) return;\n // TODO: discuss with gilad for a better way to resolve page loaded here.\n\n const sendPubsubEvent = () => {\n this.pubsub.pub(\n PreviewAspect.id,\n new SizeEvent({\n width: window.document.body.offsetWidth,\n height: window.document.body.offsetHeight,\n })\n );\n };\n\n window.document.body.addEventListener('resize', debounce(sendPubsubEvent, 300));\n\n let counter = 0;\n const interval = setInterval(() => {\n // TODO: think\n counter += 1;\n if (counter > 10) {\n clearInterval(interval);\n return;\n }\n this.pubsub.pub(\n PreviewAspect.id,\n new SizeEvent({\n width: window.document.body.offsetWidth,\n height: window.document.body.offsetHeight,\n })\n );\n }, 200);\n }\n\n async getPreviewModule(previewName: string, id: ComponentID): Promise<PreviewModule> {\n const compShortId = id.fullName;\n\n const relevantModel = PREVIEW_MODULES.get(previewName);\n if (!relevantModel) throw new Error(`[preview.preview] missing preview \"${previewName}\"`);\n if (relevantModel.componentMap[compShortId]) return relevantModel;\n\n const componentPreviews = await this.fetchComponentPreview(id, previewName);\n PREVIEW_MODULES.loadComponentPreviews(compShortId, componentPreviews);\n\n const component = componentPreviews[previewName];\n const metadata = componentPreviews[`${previewName}_metadata`];\n\n return {\n modulesMap: relevantModel.modulesMap,\n componentMap: {\n [id.fullName]: component,\n },\n componentMapMetadata: {\n [id.fullName]: metadata,\n },\n };\n }\n\n async fetchComponentPreview(id: ComponentID, name: string): Promise<Record<string, ModuleFile[]>> {\n let previewFile: string | undefined;\n const allFiles = await this.fetchComponentPreviewFiles(id, name);\n // It's a component bundled with the env\n if (allFiles === null) return {};\n\n await Promise.all(\n allFiles.map((file) => {\n // We want to run the preview file always last\n if (file.endsWith('-preview.js')) {\n previewFile = file;\n return undefined;\n }\n\n return this.addComponentFileElement(id, file);\n })\n );\n\n if (!previewFile) return {};\n return this.loadPreviewScript(id, name, previewFile);\n }\n\n private addComponentFileElement(id: ComponentID, previewBundleFileName: string) {\n if (previewBundleFileName.endsWith('.js')) {\n return this.addComponentFileScriptElement(id, previewBundleFileName);\n }\n\n // TODO - should we load assets other than .css / .js?\n // if (previewBundleFileName.endsWith('.css')) {\n this.addComponentFileLinkElement(id, previewBundleFileName).catch((err) => {\n throw new Error(\n `[preview.preview] failed loading asset \"${previewBundleFileName}\". Error - \"${err?.toString()}\"`\n );\n });\n\n // do NOT await non js assets, as they might never load (like images), and not critical for rendering.\n return undefined;\n }\n\n private async fetchComponentPreviewFiles(id: ComponentID, previewName: string): Promise<string[] | null> {\n const previewAssetsRoute = `~aspect/preview-assets`;\n const stringId = id.toString();\n const url = `/api/${stringId}/${previewAssetsRoute}`;\n\n const res = await crossFetch(url);\n if (res.status >= 400) {\n throw new PreviewNotFound(previewName);\n }\n const parsed = await res.json();\n // This is component bundled with the env, no reason to bring the files, as they will be the files of the env\n if (parsed.isBundledWithEnv) {\n return null;\n }\n if (!parsed.files || !parsed.files.length) {\n throw new PreviewNotFound(previewName);\n }\n return parsed.files;\n }\n\n private addComponentFileScriptElement(id: ComponentID, previewBundleFileName: string) {\n const previewRoute = `~aspect/component-preview`;\n const stringId = id.toString();\n const src = `/api/${stringId}/${previewRoute}/${previewBundleFileName}`;\n return loadScript({ src });\n }\n\n private addComponentFileLinkElement(id: ComponentID, previewBundleFileName: string) {\n const stringId = id.toString();\n const previewRoute = `~aspect/component-preview`;\n const href = `/api/${stringId}/${previewRoute}/${previewBundleFileName}`;\n return loadLink({ href });\n }\n\n private async loadPreviewScript(id: ComponentID, previewName: string, previewBundleFileName: string) {\n const previewRoute = `~aspect/component-preview`;\n const src = `/api/${id.toString()}/${previewRoute}/${previewBundleFileName}`;\n await loadScript({ src });\n\n // TODO - replace with jsonp\n const globalId = `${id.toStringWithoutVersion()}-preview`;\n const componentPreview = window[globalId];\n if (!componentPreview) throw new PreviewNotFound(previewName);\n\n return componentPreview as Record<string, ModuleFile[]>;\n }\n\n private getComponentAspects = memoize(fetchComponentAspects, {\n max: 100,\n maxAge: 12 * 60 * 60 * 1000,\n });\n\n /**\n * register a new preview.\n */\n registerPreview(preview: PreviewType) {\n this.previewSlot.register(preview);\n return this;\n }\n\n /**\n * get the preview rendering context.\n */\n getRenderingContext(aspectsFilter?: string[]) {\n return new RenderingContext(this.renderingContextSlot, { aspectsFilter });\n }\n\n /**\n * allows aspects to add rendering contexts.\n * render context is available through all preview definitions.\n */\n registerRenderContext(renderContext: RenderingContextProvider) {\n this.renderingContextSlot.register(renderContext);\n return this;\n }\n\n getDefault() {\n const previews = this.previewSlot.values();\n const defaultOne = previews.find((previewCandidate) => previewCandidate.default);\n\n return defaultOne?.name || previews[0].name;\n }\n\n private getPreview(previewName: string): undefined | PreviewType {\n const previews = this.previewSlot.values();\n const preview = previews.find((previewCandidate) => previewCandidate.name === previewName);\n\n return preview;\n }\n\n getParam(query: string, param: string) {\n const params = new URLSearchParams(query);\n return params.get(param);\n }\n\n getQuery() {\n const withoutHash = window.location.hash.substring(1);\n const [, after] = withoutHash.split('?');\n return after;\n }\n\n private getLocation() {\n const withoutHash = window.location.hash.substring(1);\n const [before, after] = withoutHash.split('?');\n\n return {\n previewName: this.getParam(after, 'preview'),\n envId: this.getParam(after, 'env'),\n componentId: ComponentID.tryFromString(before),\n };\n }\n\n static runtime = PreviewRuntime;\n\n static dependencies = [PubsubAspect];\n\n static slots = [Slot.withType<PreviewType>(), Slot.withType<RenderingContextProvider>()];\n\n static async provider(\n [pubsub]: [PubsubPreview],\n config,\n [previewSlot, renderingContextSlot]: [PreviewSlot, RenderingContextSlot]\n ) {\n const preview = new PreviewPreview(pubsub, previewSlot, renderingContextSlot);\n\n window.addEventListener('hashchange', () => {\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n preview.render();\n });\n\n return preview;\n }\n}\n\nPreviewAspect.addRuntime(PreviewPreview);\n"],"mappings":";;;;;;;;;;;;AAAA,SAAAA,QAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,OAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,SAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,QAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,aAAA;EAAA,MAAAH,IAAA,GAAAC,OAAA;EAAAE,YAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,YAAA;EAAA,MAAAJ,IAAA,GAAAK,sBAAA,CAAAJ,OAAA;EAAAG,WAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAM,UAAA;EAAA,MAAAN,IAAA,GAAAK,sBAAA,CAAAJ,OAAA;EAAAK,SAAA,YAAAA,CAAA;IAAA,OAAAN,IAAA;EAAA;EAAA,OAAAA,IAAA;AA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C,oBAAoB,CAAC;IAE7ES,MAAM,CAACqD,gBAAgB,CAAC,YAAY,EAAE,MAAM;MAC1C;MACAzC,OAAO,CAAC+B,MAAM,CAAC,CAAC;IAClB,CAAC,CAAC;IAEF,OAAO/B,OAAO;EAChB;AACF;AAAC0I,OAAA,CAAAnK,cAAA,GAAAA,cAAA;AAAApB,eAAA,CA/WYoB,cAAc,aA2VRoK,yBAAc;AAAAxL,eAAA,CA3VpBoB,cAAc,kBA6VH,CAACqK,sBAAY,CAAC;AAAAzL,eAAA,CA7VzBoB,cAAc,WA+VV,CAACsK,eAAI,CAACC,QAAQ,CAAc,CAAC,EAAED,eAAI,CAACC,QAAQ,CAA2B,CAAC,CAAC;AAkB1F9F,wBAAa,CAAC+F,UAAU,CAACxK,cAAc,CAAC","ignoreList":[]}
|
@@ -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","PreviewRoute","constructor","preview","logger","req","res","next","component","status","send","noPreview","isLegacyPath","isBundledWithEnv","artifact","getEnvTemplateFromComponentEnv","getPreview","error","serverError","getArtifactFileMiddleware","exports"],"sources":["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 { PreviewArtifact } from './preview-artifact';\nimport { getArtifactFileMiddleware } from './artifact-file-middleware';\nimport type { PreviewUrlParams } from './artifact-file-middleware';\n\nexport class PreviewRoute implements Route {\n constructor(\n /**\n * preview extension.\n */\n private preview: PreviewMain,\n private logger: Logger\n ) {}\n\n route = `/preview/:previewName?/:filePath(*)`;\n method = 'get';\n\n middlewares = [\n async (req: Request<PreviewUrlParams>, 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 const isLegacyPath = await this.preview.isBundledWithEnv(component);\n\n let artifact: PreviewArtifact | undefined;\n // TODO - prevent error `getVinylsAndImportIfMissing is not a function` #4680\n try {\n // Taking the env template (in this case we will take the component only bundle throw component-preview route)\n // We use this route for the env template for backward compatibility - new scopes which contain components tagged with old versions of bit\n if (!isLegacyPath) {\n artifact = await this.preview.getEnvTemplateFromComponentEnv(component);\n } else {\n // If it's legacy (bundled together with the env template) take the preview bundle from the component directly\n artifact = await this.preview.getPreview(component);\n }\n } catch (e: any) {\n this.logger.error(`getEnvTemplateFromComponentEnv or 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;AAKA,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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AAC;UACrD;QACF,CAAC,CAAC,OAAOb,CAAM,EAAE;UACf,IAAI,CAACS,MAAM,CAACa,KAAK,CAAE,yDAAwD,EAAEtB,CAAC,CAAC;UAC/E,OAAOW,GAAG,CAACG,MAAM,CAAC,GAAG,CAAC,CAACC,IAAI,CAAC,IAAAC,gCAAS,EAAC,CAAC,CAAC;QAC1C;QACA;QACAN,GAAG,CAACS,QAAQ,GAAGA,QAAQ;QACvB;QACAT,GAAG,CAACO,YAAY,GAAGA,YAAY;QAC/B,OAAOL,IAAI,CAAC,CAAC;MACf,CAAC,CAAC,OAAOZ,CAAM,EAAE;QACf,IAAI,CAACS,MAAM,CAACa,KAAK,CAAC,wBAAwB,EAAEtB,CAAC,CAAC;QAC9C,OAAOW,GAAG,CAACG,MAAM,CAAC,GAAG,CAAC,CAACC,IAAI,CAAC,IAAAQ,kCAAW,EAAC,CAAC,CAAC;MAC5C;IACF,CAAC,EACD,IAAAC,mDAAyB,EAAC,IAAI,CAACf,MAAM,CAAC,CACvC;EAvCE;AAwCL;AAACgB,OAAA,CAAAnB,YAAA,GAAAA,YAAA"}
|
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","PreviewRoute","constructor","preview","logger","req","res","next","component","status","send","noPreview","isLegacyPath","isBundledWithEnv","artifact","getEnvTemplateFromComponentEnv","getPreview","error","serverError","getArtifactFileMiddleware","exports"],"sources":["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 { PreviewArtifact } from './preview-artifact';\nimport { getArtifactFileMiddleware } from './artifact-file-middleware';\nimport type { PreviewUrlParams } from './artifact-file-middleware';\n\nexport class PreviewRoute implements Route {\n constructor(\n /**\n * preview extension.\n */\n private preview: PreviewMain,\n private logger: Logger\n ) {}\n\n route = `/preview/:previewName?/:filePath(*)`;\n method = 'get';\n\n middlewares = [\n async (req: Request<PreviewUrlParams>, 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 const isLegacyPath = await this.preview.isBundledWithEnv(component);\n\n let artifact: PreviewArtifact | undefined;\n // TODO - prevent error `getVinylsAndImportIfMissing is not a function` #4680\n try {\n // Taking the env template (in this case we will take the component only bundle throw component-preview route)\n // We use this route for the env template for backward compatibility - new scopes which contain components tagged with old versions of bit\n if (!isLegacyPath) {\n artifact = await this.preview.getEnvTemplateFromComponentEnv(component);\n } else {\n // If it's legacy (bundled together with the env template) take the preview bundle from the component directly\n artifact = await this.preview.getPreview(component);\n }\n } catch (e: any) {\n this.logger.error(`getEnvTemplateFromComponentEnv or 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;AAKA,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,MAA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ACjBE,QAAQ,GAAG,MAAM,IAAI,CAACX,OAAO,CAACY,8BAA8B,CAACP,SAAS,CAAC;UACzE,CAAC,MAAM;YACL;YACAM,QAAQ,GAAG,MAAM,IAAI,CAACX,OAAO,CAACa,UAAU,CAACR,SAAS,CAAC;UACrD;QACF,CAAC,CAAC,OAAOb,CAAM,EAAE;UACf,IAAI,CAACS,MAAM,CAACa,KAAK,CAAE,yDAAwD,EAAEtB,CAAC,CAAC;UAC/E,OAAOW,GAAG,CAACG,MAAM,CAAC,GAAG,CAAC,CAACC,IAAI,CAAC,IAAAC,gCAAS,EAAC,CAAC,CAAC;QAC1C;QACA;QACAN,GAAG,CAACS,QAAQ,GAAGA,QAAQ;QACvB;QACAT,GAAG,CAACO,YAAY,GAAGA,YAAY;QAC/B,OAAOL,IAAI,CAAC,CAAC;MACf,CAAC,CAAC,OAAOZ,CAAM,EAAE;QACf,IAAI,CAACS,MAAM,CAACa,KAAK,CAAC,wBAAwB,EAAEtB,CAAC,CAAC;QAC9C,OAAOW,GAAG,CAACG,MAAM,CAAC,GAAG,CAAC,CAACC,IAAI,CAAC,IAAAQ,kCAAW,EAAC,CAAC,CAAC;MAC5C;IACF,CAAC,EACD,IAAAC,mDAAyB,EAAC,IAAI,CAACf,MAAM,CAAC,CACvC;EAvCE;AAwCL;AAACgB,OAAA,CAAAnB,YAAA,GAAAA,YAAA","ignoreList":[]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["PreviewService","constructor","_defineProperty","transform","env","envContext","preview","undefined","transformMap","getAdditionalHostDependencies","getHostDependencies","bind","getMounter","getDocsTemplate","getPreviewConfig","getTemplateBundler","context","exports"],"sources":["preview.service.tsx"],"sourcesContent":["import { EnvService, Env, EnvContext, ServiceTransformationMap } from '@teambit/envs';\nimport { EnvPreviewConfig } from './preview.main.runtime';\n\ntype PreviewTransformationMap = ServiceTransformationMap & {\n /**\n * Returns a paths to a function which mounts a given component to DOM\n * Required for `bit start` & `bit build`\n */\n getMounter?: () => string;\n\n /**\n * Returns a path to a docs template.\n * Required for `bit start` & `bit build`\n */\n getDocsTemplate?: () => string;\n\n /**\n * Returns a list of additional host dependencies\n * this list will be provided as globals on the window after bit preview bundle\n * by default bit will merge this list with the peers from the getDependencies function\n */\n getAdditionalHostDependencies?: () => string[] | Promise<string[]>;\n\n /**\n * Returns preview config like the strategy name to use when bundling the components for the preview\n */\n getPreviewConfig?: () => EnvPreviewConfig;\n};\n\nexport class PreviewService implements EnvService<any> {\n name = 'preview';\n\n transform(env: Env, envContext: EnvContext): PreviewTransformationMap | undefined {\n // Old env\n if (!env?.preview) return undefined;\n const preview = env.preview()(envContext);\n\n const transformMap: PreviewTransformationMap = {\n getAdditionalHostDependencies: preview.getHostDependencies.bind(preview),\n getMounter: preview.getMounter.bind(preview),\n getDocsTemplate: preview.getDocsTemplate.bind(preview),\n getPreviewConfig: preview.getPreviewConfig.bind(preview),\n };\n\n if (preview.getTemplateBundler) {\n transformMap.getTemplateBundler = (context) => preview.getTemplateBundler(context)(envContext);\n }\n\n return transformMap;\n }\n}\n"],"mappings":";;;;;;;;;AA6BO,MAAMA,cAAc,CAA4B;EAAAC,YAAA;IAAAC,eAAA,eAC9C,SAAS;EAAA;EAEhBC,SAASA,CAACC,GAAQ,EAAEC,UAAsB,EAAwC;IAChF;IACA,IAAI,CAACD,GAAG,EAAEE,OAAO,EAAE,OAAOC,SAAS;IACnC,MAAMD,OAAO,GAAGF,GAAG,CAACE,OAAO,CAAC,CAAC,CAACD,UAAU,CAAC;IAEzC,MAAMG,YAAsC,GAAG;MAC7CC,6BAA6B,EAAEH,OAAO,CAACI,mBAAmB,CAACC,IAAI,CAACL,OAAO,CAAC;MACxEM,UAAU,EAAEN,OAAO,CAACM,UAAU,CAACD,IAAI,CAACL,OAAO,CAAC;MAC5CO,eAAe,EAAEP,OAAO,CAACO,eAAe,CAACF,IAAI,CAACL,OAAO,CAAC;MACtDQ,gBAAgB,EAAER,OAAO,CAACQ,gBAAgB,CAACH,IAAI,CAACL,OAAO;IACzD,CAAC;IAED,IAAIA,OAAO,CAACS,kBAAkB,EAAE;MAC9BP,YAAY,CAACO,kBAAkB,GAAIC,OAAO,IAAKV,OAAO,CAACS,kBAAkB,CAACC,OAAO,CAAC,CAACX,UAAU,CAAC;IAChG;IAEA,OAAOG,YAAY;EACrB;AACF;AAACS,OAAA,CAAAjB,cAAA,GAAAA,cAAA"}
|
1
|
+
{"version":3,"names":["PreviewService","constructor","_defineProperty","transform","env","envContext","preview","undefined","transformMap","getAdditionalHostDependencies","getHostDependencies","bind","getMounter","getDocsTemplate","getPreviewConfig","getTemplateBundler","context","exports"],"sources":["preview.service.tsx"],"sourcesContent":["import { EnvService, Env, EnvContext, ServiceTransformationMap } from '@teambit/envs';\nimport { EnvPreviewConfig } from './preview.main.runtime';\n\ntype PreviewTransformationMap = ServiceTransformationMap & {\n /**\n * Returns a paths to a function which mounts a given component to DOM\n * Required for `bit start` & `bit build`\n */\n getMounter?: () => string;\n\n /**\n * Returns a path to a docs template.\n * Required for `bit start` & `bit build`\n */\n getDocsTemplate?: () => string;\n\n /**\n * Returns a list of additional host dependencies\n * this list will be provided as globals on the window after bit preview bundle\n * by default bit will merge this list with the peers from the getDependencies function\n */\n getAdditionalHostDependencies?: () => string[] | Promise<string[]>;\n\n /**\n * Returns preview config like the strategy name to use when bundling the components for the preview\n */\n getPreviewConfig?: () => EnvPreviewConfig;\n};\n\nexport class PreviewService implements EnvService<any> {\n name = 'preview';\n\n transform(env: Env, envContext: EnvContext): PreviewTransformationMap | undefined {\n // Old env\n if (!env?.preview) return undefined;\n const preview = env.preview()(envContext);\n\n const transformMap: PreviewTransformationMap = {\n getAdditionalHostDependencies: preview.getHostDependencies.bind(preview),\n getMounter: preview.getMounter.bind(preview),\n getDocsTemplate: preview.getDocsTemplate.bind(preview),\n getPreviewConfig: preview.getPreviewConfig.bind(preview),\n };\n\n if (preview.getTemplateBundler) {\n transformMap.getTemplateBundler = (context) => preview.getTemplateBundler(context)(envContext);\n }\n\n return transformMap;\n }\n}\n"],"mappings":";;;;;;;;;AA6BO,MAAMA,cAAc,CAA4B;EAAAC,YAAA;IAAAC,eAAA,eAC9C,SAAS;EAAA;EAEhBC,SAASA,CAACC,GAAQ,EAAEC,UAAsB,EAAwC;IAChF;IACA,IAAI,CAACD,GAAG,EAAEE,OAAO,EAAE,OAAOC,SAAS;IACnC,MAAMD,OAAO,GAAGF,GAAG,CAACE,OAAO,CAAC,CAAC,CAACD,UAAU,CAAC;IAEzC,MAAMG,YAAsC,GAAG;MAC7CC,6BAA6B,EAAEH,OAAO,CAACI,mBAAmB,CAACC,IAAI,CAACL,OAAO,CAAC;MACxEM,UAAU,EAAEN,OAAO,CAACM,UAAU,CAACD,IAAI,CAACL,OAAO,CAAC;MAC5CO,eAAe,EAAEP,OAAO,CAACO,eAAe,CAACF,IAAI,CAACL,OAAO,CAAC;MACtDQ,gBAAgB,EAAER,OAAO,CAACQ,gBAAgB,CAACH,IAAI,CAACL,OAAO;IACzD,CAAC;IAED,IAAIA,OAAO,CAACS,kBAAkB,EAAE;MAC9BP,YAAY,CAACO,kBAAkB,GAAIC,OAAO,IAAKV,OAAO,CAACS,kBAAkB,CAACC,OAAO,CAAC,CAACX,UAAU,CAAC;IAChG;IAEA,OAAOG,YAAY;EACrB;AACF;AAACS,OAAA,CAAAjB,cAAA,GAAAA,cAAA","ignoreList":[]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_lodash","data","require","_previewCli","_compiler","_watcher","_chalk","_interopRequireDefault","obj","__esModule","default","_defineProperty","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","t","i","_toPrimitive","String","r","e","Symbol","toPrimitive","call","TypeError","Number","PreviewStartPlugin","constructor","workspace","bundler","ui","pubsub","logger","watcher","Promise","resolve","setReady","initiate","options","listenToDevServers","components","getComponentsByUserInput","pattern","previewServers","devServer","forEach","server","serversMap","context","envRuntime","id","listen","watch","spawnTSServer","checkTypes","CheckTypes","None","preCompile","compile","initiator","CompilationInitiator","Start","catch","err","msg","error","console","message","concat","getProxy","proxyConfigs","map","target","port","ws","flatten","SubscribeToWebpackEvents","onStart","handleOnStartCompiling","onDone","results","handleOnDoneCompiling","serversState","isCompiling","spinnerId","getSpinnerId","text","getSpinnerCompilingMessage","multiSpinner","add","isReady","errors","warnings","previewServer","hasErrors","length","getWarningsWithoutIgnored","hasWarnings","url","getSpinnerDoneMessage","fail","warn","succeed","noneAreCompiling","values","every","x","whenReady","readyPromise","exports","IGNORE_WARNINGS","filter","warning","find","reg","match","envId","verbose","prefix","chalk","cyan","includedEnvs","relatedContexts","stringifyIncludedEnvs","errorsTxt","join","errorsTxtWithTitle","red","warningsTxt","warningsTxtWithTitle","yellow","urlMessage"],"sources":["preview.start-plugin.tsx"],"sourcesContent":["import { flatten } from 'lodash';\nimport { BundlerMain, ComponentServer } from '@teambit/bundler';\nimport { PubsubMain } from '@teambit/pubsub';\nimport { ProxyEntry, StartPlugin, StartPluginOptions, UiMain } from '@teambit/ui';\nimport { Workspace } from '@teambit/workspace';\nimport { SubscribeToWebpackEvents, CompilationResult } from '@teambit/preview.cli.webpack-events-listener';\nimport { CompilationInitiator } from '@teambit/compiler';\nimport { Logger } from '@teambit/logger';\nimport { CheckTypes, WatcherMain } from '@teambit/watcher';\nimport chalk from 'chalk';\n\ntype ServerState = {\n isCompiling?: boolean;\n isReady?: boolean;\n errors?: Error[];\n warnings?: Error[];\n results?: any[];\n};\n\ntype ServerStateMap = Record<string, ServerState>;\n\nexport class PreviewStartPlugin implements StartPlugin {\n constructor(\n private workspace: Workspace,\n private bundler: BundlerMain,\n private ui: UiMain,\n private pubsub: PubsubMain,\n private logger: Logger,\n private watcher: WatcherMain\n ) {}\n\n previewServers: ComponentServer[] = [];\n serversState: ServerStateMap = {};\n serversMap: Record<string, ComponentServer> = {};\n\n async initiate(options: StartPluginOptions) {\n this.listenToDevServers();\n\n const components = await this.workspace.getComponentsByUserInput(!options.pattern, options.pattern);\n // TODO: logic for creating preview servers must be refactored to this aspect from the DevServer aspect.\n const previewServers = await this.bundler.devServer(components);\n previewServers.forEach((server) => {\n this.serversMap[server.context.envRuntime.id] = server;\n // DON'T add wait! this promise never resolves, so it would stop the start process!\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n server.listen();\n });\n this.watcher\n .watch({\n spawnTSServer: true,\n checkTypes: CheckTypes.None,\n preCompile: false,\n compile: true,\n initiator: CompilationInitiator.Start,\n })\n .catch((err) => {\n const msg = `watcher found an error`;\n this.logger.error(msg, err);\n this.logger.console(`${msg}, ${err.message}`);\n });\n this.previewServers = this.previewServers.concat(previewServers);\n }\n\n getProxy(): ProxyEntry[] {\n const proxyConfigs = this.previewServers.map<ProxyEntry[]>((server) => {\n return [\n {\n context: [`/preview/${server.context.envRuntime.id}`],\n target: `http://localhost:${server.port}`,\n },\n {\n context: [`/_hmr/${server.context.envRuntime.id}`],\n target: `http://localhost:${server.port}`,\n ws: true,\n },\n ];\n });\n\n return flatten(proxyConfigs);\n }\n\n // TODO: this should be a part of the devServer\n private listenToDevServers() {\n // keep state changes immutable!\n SubscribeToWebpackEvents(this.pubsub, {\n onStart: (id) => {\n this.handleOnStartCompiling(id);\n },\n onDone: (id, results) => {\n this.handleOnDoneCompiling(id, results);\n },\n });\n }\n\n private handleOnStartCompiling(id: string) {\n this.serversState[id] = { isCompiling: true };\n const spinnerId = getSpinnerId(id);\n const text = getSpinnerCompilingMessage(this.serversMap[id]);\n this.logger.multiSpinner.add(spinnerId, { text });\n }\n\n private handleOnDoneCompiling(id: string, results: CompilationResult) {\n this.serversState[id] = {\n isCompiling: false,\n isReady: true,\n errors: results.errors,\n warnings: results.warnings,\n };\n const previewServer = this.serversMap[id];\n const spinnerId = getSpinnerId(id);\n const errors = results.errors || [];\n const hasErrors = !!errors.length;\n const warnings = getWarningsWithoutIgnored(results.warnings);\n const hasWarnings = !!warnings.length;\n const url = `http://localhost:${previewServer.port}`;\n const text = getSpinnerDoneMessage(this.serversMap[id], errors, warnings, url);\n if (hasErrors) {\n this.logger.multiSpinner.fail(spinnerId, { text });\n } else if (hasWarnings) {\n this.logger.multiSpinner.warn(spinnerId, { text });\n } else {\n this.logger.multiSpinner.succeed(spinnerId, { text });\n }\n\n const noneAreCompiling = Object.values(this.serversState).every((x) => !x.isCompiling);\n if (noneAreCompiling) this.setReady();\n }\n\n private setReady: () => void;\n private readyPromise = new Promise<void>((resolve) => (this.setReady = resolve));\n get whenReady(): Promise<void> {\n return this.readyPromise;\n }\n}\n\nfunction getWarningsWithoutIgnored(warnings?: Error[]): Error[] {\n if (!warnings || !warnings.length) return [];\n const IGNORE_WARNINGS = [\n // Webpack 5+ has no facility to disable this warning.\n // System.import is used in @angular/core for deprecated string-form lazy routes\n /System.import\\(\\) is deprecated and will be removed soon/i,\n // We need to include all the files in the compilation because we don't know what people will use in their compositions\n /is part of the TypeScript compilation but it's unused/i,\n // https://github.com/webpack-contrib/source-map-loader/blob/b2de4249c7431dd8432da607e08f0f65e9d64219/src/index.js#L83\n /Failed to parse source map from/,\n ];\n warnings.filter((warning) => !IGNORE_WARNINGS.find((reg) => warning?.message?.match(reg)));\n return warnings;\n}\n\nfunction getSpinnerId(envId: string) {\n return `preview-${envId}`;\n}\n\nfunction getSpinnerCompilingMessage(server: ComponentServer, verbose = false) {\n const prefix = 'COMPILING';\n const envId = chalk.cyan(server.context.envRuntime.id);\n let includedEnvs = '';\n if (server.context.relatedContexts && server.context.relatedContexts.length > 1) {\n includedEnvs = `on behalf of ${chalk.cyan(stringifyIncludedEnvs(server.context.relatedContexts, verbose))}`;\n }\n return `${prefix} ${envId} ${includedEnvs}`;\n}\n\nfunction getSpinnerDoneMessage(\n server: ComponentServer,\n errors: Error[],\n warnings: Error[],\n url: string,\n verbose = false\n) {\n const hasErrors = !!errors.length;\n const hasWarnings = !!warnings.length;\n const prefix = hasErrors ? 'FAILED' : 'RUNNING';\n const envId = chalk.cyan(server.context.envRuntime.id);\n let includedEnvs = '';\n if (server.context.relatedContexts && server.context.relatedContexts.length > 1) {\n includedEnvs = ` on behalf of ${chalk.cyan(stringifyIncludedEnvs(server.context.relatedContexts, verbose))}`;\n }\n const errorsTxt = hasErrors ? errors.map((err) => err.message).join('\\n') : '';\n const errorsTxtWithTitle = hasErrors ? chalk.red(`\\nErrors:\\n${errorsTxt}`) : '';\n const warningsTxt = hasWarnings ? warnings.map((warning) => warning.message).join('\\n') : '';\n const warningsTxtWithTitle = hasWarnings ? chalk.yellow(`\\nWarnings:\\n${warningsTxt}`) : '';\n\n const urlMessage = hasErrors ? '' : `at ${chalk.cyan(url)}`;\n return `${prefix} ${envId}${includedEnvs} ${urlMessage} ${errorsTxtWithTitle} ${warningsTxtWithTitle}`;\n}\n\nfunction stringifyIncludedEnvs(includedEnvs: string[] = [], verbose = false) {\n if (includedEnvs.length < 2) return '';\n if (includedEnvs.length > 2 && !verbose) return ` ${includedEnvs.length} other envs`;\n return includedEnvs.join(', ');\n}\n"],"mappings":";;;;;;AAAA,SAAAA,QAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,OAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAKA,SAAAE,YAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,WAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,UAAA;EAAA,MAAAH,IAAA,GAAAC,OAAA;EAAAE,SAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAI,SAAA;EAAA,MAAAJ,IAAA,GAAAC,OAAA;EAAAG,QAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAK,OAAA;EAAA,MAAAL,IAAA,GAAAM,sBAAA,CAAAL,OAAA;EAAAI,MAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,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,GAAG,EAAE;EAE3F,MAAMG,UAAU,GAAGrC,SAAS,GAAG,EAAE,GAAI,MAAKyB,gBAAK,CAACC,IAAI,CAACtB,GAAG,CAAE,EAAC;EAC3D,OAAQ,GAAEoB,MAAO,IAAGF,KAAM,GAAEK,YAAa,IAAGU,UAAW,IAAGL,kBAAmB,IAAGG,oBAAqB,EAAC;AACxG;AAEA,SAASN,qBAAqBA,CAACF,YAAsB,GAAG,EAAE,EAAEJ,OAAO,GAAG,KAAK,EAAE;EAC3E,IAAII,YAAY,CAAC1B,MAAM,GAAG,CAAC,EAAE,OAAO,EAAE;EACtC,IAAI0B,YAAY,CAAC1B,MAAM,GAAG,CAAC,IAAI,CAACsB,OAAO,EAAE,OAAQ,IAAGI,YAAY,CAAC1B,MAAO,aAAY;EACpF,OAAO0B,YAAY,CAACI,IAAI,CAAC,IAAI,CAAC;AAChC"}
|
1
|
+
{"version":3,"names":["_lodash","data","require","_previewCli","_compiler","_watcher","_chalk","_interopRequireDefault","obj","__esModule","default","_defineProperty","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","t","i","_toPrimitive","String","r","e","Symbol","toPrimitive","call","TypeError","Number","PreviewStartPlugin","constructor","workspace","bundler","ui","pubsub","logger","watcher","Promise","resolve","setReady","initiate","options","listenToDevServers","components","getComponentsByUserInput","pattern","previewServers","devServer","forEach","server","serversMap","context","envRuntime","id","listen","watch","spawnTSServer","checkTypes","CheckTypes","None","preCompile","compile","initiator","CompilationInitiator","Start","catch","err","msg","error","console","message","concat","getProxy","proxyConfigs","map","target","port","ws","flatten","SubscribeToWebpackEvents","onStart","handleOnStartCompiling","onDone","results","handleOnDoneCompiling","serversState","isCompiling","spinnerId","getSpinnerId","text","getSpinnerCompilingMessage","multiSpinner","add","isReady","errors","warnings","previewServer","hasErrors","length","getWarningsWithoutIgnored","hasWarnings","url","getSpinnerDoneMessage","fail","warn","succeed","noneAreCompiling","values","every","x","whenReady","readyPromise","exports","IGNORE_WARNINGS","filter","warning","find","reg","match","envId","verbose","prefix","chalk","cyan","includedEnvs","relatedContexts","stringifyIncludedEnvs","errorsTxt","join","errorsTxtWithTitle","red","warningsTxt","warningsTxtWithTitle","yellow","urlMessage"],"sources":["preview.start-plugin.tsx"],"sourcesContent":["import { flatten } from 'lodash';\nimport { BundlerMain, ComponentServer } from '@teambit/bundler';\nimport { PubsubMain } from '@teambit/pubsub';\nimport { ProxyEntry, StartPlugin, StartPluginOptions, UiMain } from '@teambit/ui';\nimport { Workspace } from '@teambit/workspace';\nimport { SubscribeToWebpackEvents, CompilationResult } from '@teambit/preview.cli.webpack-events-listener';\nimport { CompilationInitiator } from '@teambit/compiler';\nimport { Logger } from '@teambit/logger';\nimport { CheckTypes, WatcherMain } from '@teambit/watcher';\nimport chalk from 'chalk';\n\ntype ServerState = {\n isCompiling?: boolean;\n isReady?: boolean;\n errors?: Error[];\n warnings?: Error[];\n results?: any[];\n};\n\ntype ServerStateMap = Record<string, ServerState>;\n\nexport class PreviewStartPlugin implements StartPlugin {\n constructor(\n private workspace: Workspace,\n private bundler: BundlerMain,\n private ui: UiMain,\n private pubsub: PubsubMain,\n private logger: Logger,\n private watcher: WatcherMain\n ) {}\n\n previewServers: ComponentServer[] = [];\n serversState: ServerStateMap = {};\n serversMap: Record<string, ComponentServer> = {};\n\n async initiate(options: StartPluginOptions) {\n this.listenToDevServers();\n\n const components = await this.workspace.getComponentsByUserInput(!options.pattern, options.pattern);\n // TODO: logic for creating preview servers must be refactored to this aspect from the DevServer aspect.\n const previewServers = await this.bundler.devServer(components);\n previewServers.forEach((server) => {\n this.serversMap[server.context.envRuntime.id] = server;\n // DON'T add wait! this promise never resolves, so it would stop the start process!\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n server.listen();\n });\n this.watcher\n .watch({\n spawnTSServer: true,\n checkTypes: CheckTypes.None,\n preCompile: false,\n compile: true,\n initiator: CompilationInitiator.Start,\n })\n .catch((err) => {\n const msg = `watcher found an error`;\n this.logger.error(msg, err);\n this.logger.console(`${msg}, ${err.message}`);\n });\n this.previewServers = this.previewServers.concat(previewServers);\n }\n\n getProxy(): ProxyEntry[] {\n const proxyConfigs = this.previewServers.map<ProxyEntry[]>((server) => {\n return [\n {\n context: [`/preview/${server.context.envRuntime.id}`],\n target: `http://localhost:${server.port}`,\n },\n {\n context: [`/_hmr/${server.context.envRuntime.id}`],\n target: `http://localhost:${server.port}`,\n ws: true,\n },\n ];\n });\n\n return flatten(proxyConfigs);\n }\n\n // TODO: this should be a part of the devServer\n private listenToDevServers() {\n // keep state changes immutable!\n SubscribeToWebpackEvents(this.pubsub, {\n onStart: (id) => {\n this.handleOnStartCompiling(id);\n },\n onDone: (id, results) => {\n this.handleOnDoneCompiling(id, results);\n },\n });\n }\n\n private handleOnStartCompiling(id: string) {\n this.serversState[id] = { isCompiling: true };\n const spinnerId = getSpinnerId(id);\n const text = getSpinnerCompilingMessage(this.serversMap[id]);\n this.logger.multiSpinner.add(spinnerId, { text });\n }\n\n private handleOnDoneCompiling(id: string, results: CompilationResult) {\n this.serversState[id] = {\n isCompiling: false,\n isReady: true,\n errors: results.errors,\n warnings: results.warnings,\n };\n const previewServer = this.serversMap[id];\n const spinnerId = getSpinnerId(id);\n const errors = results.errors || [];\n const hasErrors = !!errors.length;\n const warnings = getWarningsWithoutIgnored(results.warnings);\n const hasWarnings = !!warnings.length;\n const url = `http://localhost:${previewServer.port}`;\n const text = getSpinnerDoneMessage(this.serversMap[id], errors, warnings, url);\n if (hasErrors) {\n this.logger.multiSpinner.fail(spinnerId, { text });\n } else if (hasWarnings) {\n this.logger.multiSpinner.warn(spinnerId, { text });\n } else {\n this.logger.multiSpinner.succeed(spinnerId, { text });\n }\n\n const noneAreCompiling = Object.values(this.serversState).every((x) => !x.isCompiling);\n if (noneAreCompiling) this.setReady();\n }\n\n private setReady: () => void;\n private readyPromise = new Promise<void>((resolve) => (this.setReady = resolve));\n get whenReady(): Promise<void> {\n return this.readyPromise;\n }\n}\n\nfunction getWarningsWithoutIgnored(warnings?: Error[]): Error[] {\n if (!warnings || !warnings.length) return [];\n const IGNORE_WARNINGS = [\n // Webpack 5+ has no facility to disable this warning.\n // System.import is used in @angular/core for deprecated string-form lazy routes\n /System.import\\(\\) is deprecated and will be removed soon/i,\n // We need to include all the files in the compilation because we don't know what people will use in their compositions\n /is part of the TypeScript compilation but it's unused/i,\n // https://github.com/webpack-contrib/source-map-loader/blob/b2de4249c7431dd8432da607e08f0f65e9d64219/src/index.js#L83\n /Failed to parse source map from/,\n ];\n warnings.filter((warning) => !IGNORE_WARNINGS.find((reg) => warning?.message?.match(reg)));\n return warnings;\n}\n\nfunction getSpinnerId(envId: string) {\n return `preview-${envId}`;\n}\n\nfunction getSpinnerCompilingMessage(server: ComponentServer, verbose = false) {\n const prefix = 'COMPILING';\n const envId = chalk.cyan(server.context.envRuntime.id);\n let includedEnvs = '';\n if (server.context.relatedContexts && server.context.relatedContexts.length > 1) {\n includedEnvs = `on behalf of ${chalk.cyan(stringifyIncludedEnvs(server.context.relatedContexts, verbose))}`;\n }\n return `${prefix} ${envId} ${includedEnvs}`;\n}\n\nfunction getSpinnerDoneMessage(\n server: ComponentServer,\n errors: Error[],\n warnings: Error[],\n url: string,\n verbose = false\n) {\n const hasErrors = !!errors.length;\n const hasWarnings = !!warnings.length;\n const prefix = hasErrors ? 'FAILED' : 'RUNNING';\n const envId = chalk.cyan(server.context.envRuntime.id);\n let includedEnvs = '';\n if (server.context.relatedContexts && server.context.relatedContexts.length > 1) {\n includedEnvs = ` on behalf of ${chalk.cyan(stringifyIncludedEnvs(server.context.relatedContexts, verbose))}`;\n }\n const errorsTxt = hasErrors ? errors.map((err) => err.message).join('\\n') : '';\n const errorsTxtWithTitle = hasErrors ? chalk.red(`\\nErrors:\\n${errorsTxt}`) : '';\n const warningsTxt = hasWarnings ? warnings.map((warning) => warning.message).join('\\n') : '';\n const warningsTxtWithTitle = hasWarnings ? chalk.yellow(`\\nWarnings:\\n${warningsTxt}`) : '';\n\n const urlMessage = hasErrors ? '' : `at ${chalk.cyan(url)}`;\n return `${prefix} ${envId}${includedEnvs} ${urlMessage} ${errorsTxtWithTitle} ${warningsTxtWithTitle}`;\n}\n\nfunction stringifyIncludedEnvs(includedEnvs: string[] = [], verbose = false) {\n if (includedEnvs.length < 2) return '';\n if (includedEnvs.length > 2 && !verbose) return ` ${includedEnvs.length} other envs`;\n return includedEnvs.join(', ');\n}\n"],"mappings":";;;;;;AAAA,SAAAA,QAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,OAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAKA,SAAAE,YAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,WAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,UAAA;EAAA,MAAAH,IAAA,GAAAC,OAAA;EAAAE,SAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAI,SAAA;EAAA,MAAAJ,IAAA,GAAAC,OAAA;EAAAG,QAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAK,OAAA;EAAA,MAAAL,IAAA,GAAAM,sBAAA,CAAAL,OAAA;EAAAI,MAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAA0B,SAAAM,uBAAAC,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAAA,SAAAG,gBAAAH,GAAA,EAAAI,GAAA,EAAAC,KAAA,IAAAD,GAAA,GAAAE,cAAA,CAAAF,GAAA,OAAAA,GAAA,IAAAJ,GAAA,IAAAO,MAAA,CAAAC,cAAA,CAAAR,GAAA,EAAAI,GAAA,IAAAC,KAAA,EAAAA,KAAA,E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CAAC1B,MAAM,GAAG,CAAC,EAAE,OAAO,EAAE;EACtC,IAAI0B,YAAY,CAAC1B,MAAM,GAAG,CAAC,IAAI,CAACsB,OAAO,EAAE,OAAQ,IAAGI,YAAY,CAAC1B,MAAO,aAAY;EACpF,OAAO0B,YAAY,CAACI,IAAI,CAAC,IAAI,CAAC;AAChC","ignoreList":[]}
|
package/dist/preview.task.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_path","data","require","_builder","_defineProperty","obj","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","t","i","_toPrimitive","String","r","e","Symbol","toPrimitive","call","TypeError","Number","PREVIEW_TASK_NAME","exports","PreviewTask","constructor","bundler","preview","dependencyResolver","logger","execute","context","defs","getDefs","url","envRuntime","id","bundlingStrategy","getBundlingStrategy","env","envPreviewConfig","getEnvPreviewConfig","splitComponentBundle","computeTargetsContext","assign","targets","computeTargets","bundlerContext","compress","name","entry","publicPath","getPreviewDirectory","rootPath","development","dev","metaData","initiator","envId","getBundler","bundlerResults","run","results","computeResults","getLinkFileDirectory","join","CAPSULE_ARTIFACTS_DIR","outputPath","resolve","getPathsFromMap","capsule","moduleMap","compiler","getCompiler","map","files","file","path","getDistPathBySrcPath","relative"],"sources":["preview.task.ts"],"sourcesContent":["import { resolve, join } from 'path';\nimport { ExecutionContext } from '@teambit/envs';\nimport { BuildContext, BuiltTaskResult, BuildTask, TaskLocation, CAPSULE_ARTIFACTS_DIR } from '@teambit/builder';\nimport { Bundler, BundlerContext, BundlerMain, Target } from '@teambit/bundler';\nimport { Compiler } from '@teambit/compiler';\nimport { ComponentMap } from '@teambit/component';\nimport { Capsule } from '@teambit/isolator';\nimport { AbstractVinyl } from '@teambit/legacy/dist/consumer/component/sources';\nimport { DependencyResolverMain } from '@teambit/dependency-resolver';\nimport { Logger } from '@teambit/logger';\nimport { PreviewMain } from './preview.main.runtime';\n\nexport const PREVIEW_TASK_NAME = 'GeneratePreview';\nexport class PreviewTask implements BuildTask {\n constructor(\n /**\n * bundler extension.\n */\n private bundler: BundlerMain,\n\n /**\n * preview extension.\n */\n private preview: PreviewMain,\n\n private dependencyResolver: DependencyResolverMain,\n private logger: Logger\n ) {}\n\n aspectId = 'teambit.preview/preview';\n name = PREVIEW_TASK_NAME;\n description = 'Bundling components for preview';\n location: TaskLocation = 'end';\n // readonly dependencies = [CompilerAspect.id];\n\n async execute(context: BuildContext): Promise<BuiltTaskResult> {\n const defs = this.preview.getDefs();\n const url = `/preview/${context.envRuntime.id}`;\n const bundlingStrategy = this.preview.getBundlingStrategy(context.env);\n const envPreviewConfig = this.preview.getEnvPreviewConfig(context.env);\n const splitComponentBundle = envPreviewConfig.splitComponentBundle ?? false;\n const computeTargetsContext = Object.assign(context, { splitComponentBundle });\n\n const targets: Target[] = await bundlingStrategy.computeTargets(computeTargetsContext, defs, this);\n\n const bundlerContext: BundlerContext = Object.assign(context, {\n targets,\n compress: bundlingStrategy.name !== 'env' && splitComponentBundle,\n entry: [],\n publicPath: this.getPreviewDirectory(context),\n rootPath: url,\n development: context.dev,\n metaData: {\n initiator: `${PREVIEW_TASK_NAME} task`,\n envId: context.id,\n },\n });\n\n const bundler: Bundler = await context.env.getBundler(bundlerContext);\n const bundlerResults = await bundler.run();\n\n const results = bundlingStrategy.computeResults(bundlerContext, bundlerResults, this);\n return results;\n }\n\n getLinkFileDirectory() {\n return join(CAPSULE_ARTIFACTS_DIR, 'preview-links');\n }\n\n getPreviewDirectory(context: ExecutionContext) {\n const outputPath = resolve(`${context.id}/public`);\n return outputPath;\n }\n\n getPathsFromMap(\n capsule: Capsule,\n moduleMap: ComponentMap<AbstractVinyl[]>,\n context: BuildContext\n ): ComponentMap<string[]> {\n const compiler: Compiler = context.env.getCompiler(context);\n return moduleMap.map((files) => {\n return files.map((file) => join(capsule.path, compiler.getDistPathBySrcPath(file.relative)));\n });\n }\n}\n"],"mappings":";;;;;;AAAA,SAAAA,MAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA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F,MAAMV,OAAgB,GAAG,MAAMK,OAAO,CAACQ,GAAG,CAACoB,UAAU,CAACZ,cAAc,CAAC;IACrE,MAAMa,cAAc,GAAG,MAAMlC,OAAO,CAACmC,GAAG,CAAC,CAAC;IAE1C,MAAMC,OAAO,GAAGzB,gBAAgB,CAAC0B,cAAc,CAAChB,cAAc,EAAEa,cAAc,EAAE,IAAI,CAAC;IACrF,OAAOE,OAAO;EAChB;EAEAE,oBAAoBA,CAAA,EAAG;IACrB,OAAO,IAAAC,YAAI,EAACC,gCAAqB,EAAE,eAAe,CAAC;EACrD;EAEAd,mBAAmBA,CAACrB,OAAyB,EAAE;IAC7C,MAAMoC,UAAU,GAAG,IAAAC,eAAO,EAAE,GAAErC,OAAO,CAACK,EAAG,SAAQ,CAAC;IAClD,OAAO+B,UAAU;EACnB;EAEAE,eAAeA,CACbC,OAAgB,EAChBC,SAAwC,EACxCxC,OAAqB,EACG;IACxB,MAAMyC,QAAkB,GAAGzC,OAAO,CAACQ,GAAG,CAACkC,WAAW,CAAC1C,OAAO,CAAC;IAC3D,OAAOwC,SAAS,CAACG,GAAG,CAAEC,KAAK,IAAK;MAC9B,OAAOA,KAAK,CAACD,GAAG,CAAEE,IAAI,IAAK,IAAAX,YAAI,EAACK,OAAO,CAACO,IAAI,EAAEL,QAAQ,CAACM,oBAAoB,CAACF,IAAI,CAACG,QAAQ,CAAC,CAAC,CAAC;IAC9F,CAAC,CAAC;EACJ;AACF;AAACxD,OAAA,CAAAC,WAAA,GAAAA,WAAA"}
|
1
|
+
{"version":3,"names":["_path","data","require","_builder","_defineProperty","obj","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","t","i","_toPrimitive","String","r","e","Symbol","toPrimitive","call","TypeError","Number","PREVIEW_TASK_NAME","exports","PreviewTask","constructor","bundler","preview","dependencyResolver","logger","execute","context","defs","getDefs","url","envRuntime","id","bundlingStrategy","getBundlingStrategy","env","envPreviewConfig","getEnvPreviewConfig","splitComponentBundle","computeTargetsContext","assign","targets","computeTargets","bundlerContext","compress","name","entry","publicPath","getPreviewDirectory","rootPath","development","dev","metaData","initiator","envId","getBundler","bundlerResults","run","results","computeResults","getLinkFileDirectory","join","CAPSULE_ARTIFACTS_DIR","outputPath","resolve","getPathsFromMap","capsule","moduleMap","compiler","getCompiler","map","files","file","path","getDistPathBySrcPath","relative"],"sources":["preview.task.ts"],"sourcesContent":["import { resolve, join } from 'path';\nimport { ExecutionContext } from '@teambit/envs';\nimport { BuildContext, BuiltTaskResult, BuildTask, TaskLocation, CAPSULE_ARTIFACTS_DIR } from '@teambit/builder';\nimport { Bundler, BundlerContext, BundlerMain, Target } from '@teambit/bundler';\nimport { Compiler } from '@teambit/compiler';\nimport { ComponentMap } from '@teambit/component';\nimport { Capsule } from '@teambit/isolator';\nimport { AbstractVinyl } from '@teambit/legacy/dist/consumer/component/sources';\nimport { DependencyResolverMain } from '@teambit/dependency-resolver';\nimport { Logger } from '@teambit/logger';\nimport { PreviewMain } from './preview.main.runtime';\n\nexport const PREVIEW_TASK_NAME = 'GeneratePreview';\nexport class PreviewTask implements BuildTask {\n constructor(\n /**\n * bundler extension.\n */\n private bundler: BundlerMain,\n\n /**\n * preview extension.\n */\n private preview: PreviewMain,\n\n private dependencyResolver: DependencyResolverMain,\n private logger: Logger\n ) {}\n\n aspectId = 'teambit.preview/preview';\n name = PREVIEW_TASK_NAME;\n description = 'Bundling components for preview';\n location: TaskLocation = 'end';\n // readonly dependencies = [CompilerAspect.id];\n\n async execute(context: BuildContext): Promise<BuiltTaskResult> {\n const defs = this.preview.getDefs();\n const url = `/preview/${context.envRuntime.id}`;\n const bundlingStrategy = this.preview.getBundlingStrategy(context.env);\n const envPreviewConfig = this.preview.getEnvPreviewConfig(context.env);\n const splitComponentBundle = envPreviewConfig.splitComponentBundle ?? false;\n const computeTargetsContext = Object.assign(context, { splitComponentBundle });\n\n const targets: Target[] = await bundlingStrategy.computeTargets(computeTargetsContext, defs, this);\n\n const bundlerContext: BundlerContext = Object.assign(context, {\n targets,\n compress: bundlingStrategy.name !== 'env' && splitComponentBundle,\n entry: [],\n publicPath: this.getPreviewDirectory(context),\n rootPath: url,\n development: context.dev,\n metaData: {\n initiator: `${PREVIEW_TASK_NAME} task`,\n envId: context.id,\n },\n });\n\n const bundler: Bundler = await context.env.getBundler(bundlerContext);\n const bundlerResults = await bundler.run();\n\n const results = bundlingStrategy.computeResults(bundlerContext, bundlerResults, this);\n return results;\n }\n\n getLinkFileDirectory() {\n return join(CAPSULE_ARTIFACTS_DIR, 'preview-links');\n }\n\n getPreviewDirectory(context: ExecutionContext) {\n const outputPath = resolve(`${context.id}/public`);\n return outputPath;\n }\n\n getPathsFromMap(\n capsule: Capsule,\n moduleMap: ComponentMap<AbstractVinyl[]>,\n context: BuildContext\n ): ComponentMap<string[]> {\n const compiler: Compiler = context.env.getCompiler(context);\n return moduleMap.map((files) => {\n return files.map((file) => join(capsule.path, compiler.getDistPathBySrcPath(file.relative)));\n });\n }\n}\n"],"mappings":";;;;;;AAAA,SAAAA,MAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,KAAA,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;AAAiH,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,CAAA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,OAAqB,EACG;IACxB,MAAMyC,QAAkB,GAAGzC,OAAO,CAACQ,GAAG,CAACkC,WAAW,CAAC1C,OAAO,CAAC;IAC3D,OAAOwC,SAAS,CAACG,GAAG,CAAEC,KAAK,IAAK;MAC9B,OAAOA,KAAK,CAACD,GAAG,CAAEE,IAAI,IAAK,IAAAX,YAAI,EAACK,OAAO,CAACO,IAAI,EAAEL,QAAQ,CAACM,oBAAoB,CAACF,IAAI,CAACG,QAAQ,CAAC,CAAC,CAAC;IAC9F,CAAC,CAAC;EACJ;AACF;AAACxD,OAAA,CAAAC,WAAA,GAAAA,WAAA","ignoreList":[]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["RenderingContext","constructor","contexts","options","get","aspectId","contextFactory","exports"],"sources":["rendering-context.ts"],"sourcesContent":["import { RenderingContextSlot } from './preview.preview.runtime';\n\nexport type RenderingContextOptions = { aspectsFilter?: string[] };\nexport type RenderingContextProvider = (options: RenderingContextOptions) => { [key: string]: any };\n\nexport class RenderingContext {\n constructor(private contexts: RenderingContextSlot, private options: RenderingContextOptions = {}) {}\n\n /**\n * obtain rendering context of a specific aspect.\n */\n get(aspectId: string) {\n const contextFactory = this.contexts.get(aspectId);\n return contextFactory?.(this.options);\n }\n}\n"],"mappings":";;;;;;AAKO,MAAMA,gBAAgB,CAAC;EAC5BC,WAAWA,CAASC,QAA8B,EAAUC,OAAgC,GAAG,CAAC,CAAC,EAAE;IAAA,KAA/ED,QAA8B,GAA9BA,QAA8B;IAAA,KAAUC,OAAgC,GAAhCA,OAAgC;EAAQ;;EAEpG;AACF;AACA;EACEC,GAAGA,CAACC,QAAgB,EAAE;IACpB,MAAMC,cAAc,GAAG,IAAI,CAACJ,QAAQ,CAACE,GAAG,CAACC,QAAQ,CAAC;IAClD,OAAOC,cAAc,GAAG,IAAI,CAACH,OAAO,CAAC;EACvC;AACF;AAACI,OAAA,CAAAP,gBAAA,GAAAA,gBAAA"}
|
1
|
+
{"version":3,"names":["RenderingContext","constructor","contexts","options","get","aspectId","contextFactory","exports"],"sources":["rendering-context.ts"],"sourcesContent":["import { RenderingContextSlot } from './preview.preview.runtime';\n\nexport type RenderingContextOptions = { aspectsFilter?: string[] };\nexport type RenderingContextProvider = (options: RenderingContextOptions) => { [key: string]: any };\n\nexport class RenderingContext {\n constructor(private contexts: RenderingContextSlot, private options: RenderingContextOptions = {}) {}\n\n /**\n * obtain rendering context of a specific aspect.\n */\n get(aspectId: string) {\n const contextFactory = this.contexts.get(aspectId);\n return contextFactory?.(this.options);\n }\n}\n"],"mappings":";;;;;;AAKO,MAAMA,gBAAgB,CAAC;EAC5BC,WAAWA,CAASC,QAA8B,EAAUC,OAAgC,GAAG,CAAC,CAAC,EAAE;IAAA,KAA/ED,QAA8B,GAA9BA,QAA8B;IAAA,KAAUC,OAAgC,GAAhCA,OAAgC;EAAQ;;EAEpG;AACF;AACA;EACEC,GAAGA,CAACC,QAAgB,EAAE;IACpB,MAAMC,cAAc,GAAG,IAAI,CAACJ,QAAQ,CAACE,GAAG,CAACC,QAAQ,CAAC;IAClD,OAAOC,cAAc,GAAG,IAAI,CAACH,OAAO,CAAC;EACvC;AACF;AAACI,OAAA,CAAAP,gBAAA,GAAAA,gBAAA","ignoreList":[]}
|
package/dist/size-event.js.map
CHANGED
@@ -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","SizeEvent","BitBaseEvent","constructor","sizeEvent","TYPE","Date","getTime","exports"],"sources":["size-event.ts"],"sourcesContent":["import { BitBaseEvent } from '@teambit/pubsub';\n\nexport type SizeEventType = {\n height: number;\n width: number;\n};\n\nexport class SizeEvent extends BitBaseEvent<SizeEventType> {\n static readonly TYPE = 'preview-size';\n\n constructor(sizeEvent: SizeEventType) {\n super(SizeEvent.TYPE, '0.0.1', new Date().getTime(), sizeEvent);\n }\n}\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","enumerable","configurable","writable","t","i","_toPrimitive","String","r","e","Symbol","toPrimitive","call","TypeError","Number","SizeEvent","BitBaseEvent","constructor","sizeEvent","TYPE","Date","getTime","exports"],"sources":["size-event.ts"],"sourcesContent":["import { BitBaseEvent } from '@teambit/pubsub';\n\nexport type SizeEventType = {\n height: number;\n width: number;\n};\n\nexport class SizeEvent extends BitBaseEvent<SizeEventType> {\n static readonly TYPE = 'preview-size';\n\n constructor(sizeEvent: SizeEventType) {\n super(SizeEvent.TYPE, '0.0.1', new Date().getTime(), sizeEvent);\n }\n}\n"],"mappings":";;;;;;AAAA,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;AAOxC,MAAMW,SAAS,SAASC,sBAAY,CAAgB;EAGzDC,WAAWA,CAACC,SAAwB,EAAE;IACpC,KAAK,CAACH,SAAS,CAACI,IAAI,EAAE,OAAO,EAAE,IAAIC,IAAI,CAAC,CAAC,CAACC,OAAO,CAAC,CAAC,EAAEH,SAAS,CAAC;EACjE;AACF;AAACI,OAAA,CAAAP,SAAA,GAAAA,SAAA;AAAArB,eAAA,CANYqB,SAAS,UACG,cAAc","ignoreList":[]}
|
@@ -8,8 +8,8 @@ import type { PreviewDefinition } from '../preview-definition';
|
|
8
8
|
import type { PreviewMain } from '../preview.main.runtime';
|
9
9
|
export declare const PREVIEW_CHUNK_SUFFIX = "preview";
|
10
10
|
export declare const COMPONENT_CHUNK_SUFFIX = "component";
|
11
|
-
export declare const PREVIEW_CHUNK_FILENAME_SUFFIX
|
12
|
-
export declare const COMPONENT_CHUNK_FILENAME_SUFFIX
|
11
|
+
export declare const PREVIEW_CHUNK_FILENAME_SUFFIX = "preview.js";
|
12
|
+
export declare const COMPONENT_CHUNK_FILENAME_SUFFIX = "component.js";
|
13
13
|
export declare const COMPONENT_STRATEGY_SIZE_KEY_NAME = "size";
|
14
14
|
export declare const COMPONENT_STRATEGY_ARTIFACT_NAME = "preview-component";
|
15
15
|
type ComponentEntry = {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_path","data","require","_fsExtra","_lodash","_builder","_bitError","_generateComponentLink","_exceptions","_defineProperty","obj","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","t","i","_toPrimitive","String","r","e","Symbol","toPrimitive","call","TypeError","Number","PREVIEW_CHUNK_SUFFIX","exports","COMPONENT_CHUNK_SUFFIX","PREVIEW_CHUNK_FILENAME_SUFFIX","COMPONENT_CHUNK_FILENAME_SUFFIX","COMPONENT_STRATEGY_SIZE_KEY_NAME","COMPONENT_STRATEGY_ARTIFACT_NAME","ComponentBundlingStrategy","constructor","preview","pkg","dependencyResolver","computeTargets","context","previewDefs","outputPath","getOutputPath","existsSync","mkdirpSync","origComponents","capsuleNetwork","originalSeedersCapsules","map","capsule","component","entriesArr","Promise","all","computeComponentEntry","chunkSize","config","maxChunkSize","chunks","chunk","peers","getPreviewHostDependenciesFromEnv","envDefinition","env","targets","currentChunk","entries","components","forEach","entry","assign","push","hostRootDir","envRuntime","envAspectDefinition","aspectPath","hostDependencies","aliasHostDependencies","externalizeHostDependencies","componentPreviewPath","computePaths","componentPath","getPaths","mainFile","componentPreview","getComponentChunkId","id","splitComponentBundle","toStringWithoutVersion","undefined","filename","getComponentChunkFileName","toString","fsCompatible","ignoreVersion","import","dependOn","library","name","type","componentId","idstr","suffix","getAssetAbsolutePath","asset","path","join","getAssetFilename","split","copyAssetsToCapsules","result","graphCapsules","getCapsule","files","findAssetsForComponent","assets","entriesAssetsMap","artifactDirFullPath","getArtifactDirectory","filePath","PreviewOutputFileNotFound","destFilePath","dirname","fs","copyFileSync","componentEntryId","componentPreviewEntryId","componentFiles","componentAuxiliaryFiles","auxiliaryAssets","componentPreviewFiles","componentPreviewAuxiliaryFiles","concat","CAPSULE_ARTIFACTS_DIR","computeComponentMetadata","file","basename","size","compressedSize","filesTotalSize","assetsSize","compressedTotalFiles","compressedAssetsSize","assetsTotalSize","auxiliaryAssetsSize","compressedTotalAssets","compressedAuxiliaryAssetsSize","totalSize","compressedTotal","metadata","totalFiles","totalAssets","total","computeResults","results","componentsResults","flatten","computeTargetResult","artifacts","getArtifactDef","isEmpty","errors","err","message","warning","warnings","startTime","endTime","globPatterns","rootDir","getDirName","envName","replace","resolve","capsulesRootDir","compiler","getCompiler","getDistPathBySrcPath","relative","getComponentOutputPath","capsulePath","distDir","getDistDir","defs","BitError","moduleMapsPromise","previewDef","moduleMap","getModuleMap","getMetadata","maybeFiles","get","prefix","paths","compiledPaths","moduleMaps","contents","generateComponentLink","targetDir","writeLinkContents"],"sources":["component-strategy.ts"],"sourcesContent":["import { join, resolve, basename, dirname } from 'path';\nimport { existsSync, mkdirpSync } from 'fs-extra';\nimport { Component } from '@teambit/component';\nimport { ComponentID } from '@teambit/component-id';\nimport { flatten, isEmpty, chunk } from 'lodash';\nimport { Compiler } from '@teambit/compiler';\nimport type { AbstractVinyl } from '@teambit/legacy/dist/consumer/component/sources';\nimport type { Capsule } from '@teambit/isolator';\nimport { CAPSULE_ARTIFACTS_DIR, ComponentResult } from '@teambit/builder';\nimport type { PkgMain } from '@teambit/pkg';\nimport { BitError } from '@teambit/bit-error';\nimport type { DependencyResolverMain } from '@teambit/dependency-resolver';\nimport type { BundlerResult, BundlerContext, Asset, BundlerEntryMap, EntriesAssetsMap, Target } from '@teambit/bundler';\nimport { BundlingStrategy, ComputeTargetsContext } from '../bundling-strategy';\nimport type { PreviewDefinition } from '../preview-definition';\nimport type { ComponentPreviewMetaData, PreviewMain } from '../preview.main.runtime';\nimport { generateComponentLink } from './generate-component-link';\nimport { PreviewOutputFileNotFound } from '../exceptions';\n\nexport const PREVIEW_CHUNK_SUFFIX = 'preview';\nexport const COMPONENT_CHUNK_SUFFIX = 'component';\nexport const PREVIEW_CHUNK_FILENAME_SUFFIX = `${PREVIEW_CHUNK_SUFFIX}.js`;\nexport const COMPONENT_CHUNK_FILENAME_SUFFIX = `${COMPONENT_CHUNK_SUFFIX}.js`;\n\nexport const COMPONENT_STRATEGY_SIZE_KEY_NAME = 'size';\nexport const COMPONENT_STRATEGY_ARTIFACT_NAME = 'preview-component';\n\ntype ComponentEntry = {\n component: Component;\n entries: Object;\n};\n/**\n * bundles all components in a given env into the same bundle.\n */\nexport class ComponentBundlingStrategy implements BundlingStrategy {\n name = 'component';\n\n constructor(private preview: PreviewMain, private pkg: PkgMain, private dependencyResolver: DependencyResolverMain) {}\n\n async computeTargets(context: ComputeTargetsContext, previewDefs: PreviewDefinition[]): Promise<Target[]> {\n const outputPath = this.getOutputPath(context);\n if (!existsSync(outputPath)) mkdirpSync(outputPath);\n\n // const entriesArr = flatten(\n // await Promise.all(\n // context.capsuleNetwork.seedersCapsules.map((capsule) => {\n // return this.computeComponentEntry(previewDefs, capsule.component, context);\n // }, {})\n // )\n // );\n\n const origComponents = context.capsuleNetwork.originalSeedersCapsules.map((capsule) => capsule.component);\n\n const entriesArr = await Promise.all(\n origComponents.map((component) => {\n return this.computeComponentEntry(previewDefs, component, context);\n }, {})\n );\n\n const chunkSize = this.preview.config.maxChunkSize;\n\n const chunks = chunkSize ? chunk(entriesArr, chunkSize) : [entriesArr];\n\n const peers = await this.dependencyResolver.getPreviewHostDependenciesFromEnv(context.envDefinition.env);\n\n const targets = chunks.map((currentChunk) => {\n const entries: BundlerEntryMap = {};\n const components: Component[] = [];\n currentChunk.forEach((entry) => {\n Object.assign(entries, entry.entries);\n components.push(entry.component);\n });\n\n return {\n entries,\n components,\n outputPath,\n hostRootDir: context.envRuntime.envAspectDefinition.aspectPath,\n hostDependencies: peers,\n aliasHostDependencies: true,\n externalizeHostDependencies: true,\n };\n });\n\n return targets;\n // const entries = entriesArr.reduce((entriesMap, entry) => {\n // entriesMap[entry.library.name] = entry;\n // return entriesMap;\n // }, {});\n\n // const modules = await Promise.all(entriesArr.map(async (entry) => {\n // const dependencies = this.dependencyResolver.getDependencies(entry.component);\n // const manifest = dependencies.toDependenciesManifest();\n // const peer = Object.entries(manifest.peerDependencies || {}).reduce((acc, [packageName, version]) => {\n // acc[packageName] = {\n // singleton: true,\n // requiredVersion: version\n // };\n\n // return acc;\n // }, {});\n // // console.log(entry);\n // return {\n // name: entry.library.name,\n // exposes: {\n // '.': entry.import || ''\n // },\n // shared: {\n // ...manifest.dependencies,\n // ...peer\n // },\n // };\n // }));\n }\n\n async computeComponentEntry(\n previewDefs: PreviewDefinition[],\n component: Component,\n context: ComputeTargetsContext\n ): Promise<ComponentEntry> {\n const componentPreviewPath = await this.computePaths(previewDefs, context, component);\n const [componentPath] = this.getPaths(context, component, [component.mainFile]);\n\n const chunks = {\n componentPreview: this.getComponentChunkId(component.id, 'preview'),\n component: context.splitComponentBundle ? component.id.toStringWithoutVersion() : undefined,\n };\n\n const entries = {\n [chunks.componentPreview]: {\n filename: this.getComponentChunkFileName(\n component.id.toString({\n fsCompatible: true,\n ignoreVersion: true,\n }),\n 'preview'\n ),\n import: componentPreviewPath,\n dependOn: chunks.component,\n library: { name: chunks.componentPreview, type: 'umd' },\n },\n };\n\n if (chunks.component) {\n entries[chunks.component] = {\n filename: this.getComponentChunkFileName(\n component.id.toString({\n fsCompatible: true,\n ignoreVersion: true,\n }),\n 'component'\n ),\n dependOn: undefined,\n import: componentPath,\n library: { name: chunks.component, type: 'umd' },\n };\n }\n\n return { component, entries };\n }\n\n private getComponentChunkId(componentId: ComponentID, type: 'component' | 'preview') {\n const id =\n type === 'component'\n ? componentId.toStringWithoutVersion()\n : `${componentId.toStringWithoutVersion()}-${PREVIEW_CHUNK_SUFFIX}`;\n return id;\n }\n\n private getComponentChunkFileName(idstr: string, type: 'component' | 'preview') {\n const suffix = type === 'component' ? COMPONENT_CHUNK_FILENAME_SUFFIX : PREVIEW_CHUNK_FILENAME_SUFFIX;\n return `${idstr}-${suffix}`;\n }\n\n private getAssetAbsolutePath(context: BundlerContext, asset: Asset): string {\n const path = this.getOutputPath(context);\n return join(path, 'public', this.getAssetFilename(asset));\n }\n\n private getAssetFilename(asset: Asset): string {\n // handle cases where the asset name is something like my-image.svg?hash (while the filename in the fs is just my-image.svg)\n const [name] = asset.name.split('?');\n return name;\n }\n\n copyAssetsToCapsules(context: BundlerContext, result: BundlerResult) {\n context.components.forEach((component) => {\n const capsule = context.capsuleNetwork.graphCapsules.getCapsule(component.id);\n if (!capsule) return;\n const files = this.findAssetsForComponent(component, result.assets, result.entriesAssetsMap || {});\n if (!files) return;\n const artifactDirFullPath = join(capsule.path, this.getArtifactDirectory());\n // We don't use the mkdirSync as it uses the capsule fs which uses memfs, which doesn't know to handle nested none existing folders\n mkdirpSync(artifactDirFullPath);\n\n files.forEach((asset) => {\n const filePath = this.getAssetAbsolutePath(context, asset);\n if (!existsSync(filePath)) {\n throw new PreviewOutputFileNotFound(component.id, filePath);\n }\n const destFilePath = join(artifactDirFullPath, this.getAssetFilename(asset));\n mkdirpSync(dirname(destFilePath));\n capsule.fs.copyFileSync(filePath, destFilePath);\n });\n });\n }\n\n // private getCssFileName(componentId: ComponentID): string {\n // return `${componentId.toString({ ignoreVersion: true, fsCompatible: true })}.css`;\n // }\n\n private findAssetsForComponent(\n component: Component,\n assets: Asset[],\n entriesAssetsMap: EntriesAssetsMap\n ): Asset[] | undefined {\n if (!assets) return undefined;\n\n const componentEntryId = component.id.toStringWithoutVersion();\n const componentPreviewEntryId = this.getComponentChunkId(component.id, 'preview');\n const componentFiles = entriesAssetsMap[componentEntryId]?.assets || [];\n const componentAuxiliaryFiles = entriesAssetsMap[componentEntryId]?.auxiliaryAssets || [];\n const componentPreviewFiles = entriesAssetsMap[componentPreviewEntryId]?.assets || [];\n const componentPreviewAuxiliaryFiles = entriesAssetsMap[componentPreviewEntryId]?.auxiliaryAssets || [];\n\n const files = componentFiles\n .concat(componentAuxiliaryFiles)\n .concat(componentPreviewFiles)\n .concat(componentPreviewAuxiliaryFiles);\n return files;\n }\n\n private getArtifactDirectory() {\n return join(CAPSULE_ARTIFACTS_DIR, 'preview');\n }\n\n private computeComponentMetadata(\n context: BundlerContext,\n result: BundlerResult,\n component: Component\n ): ComponentPreviewMetaData {\n const componentEntryId = component.id.toStringWithoutVersion();\n if (!result?.entriesAssetsMap || !result?.entriesAssetsMap[componentEntryId]) {\n return {};\n }\n const files = (result.entriesAssetsMap[componentEntryId]?.assets || []).map((file) => {\n return {\n name: basename(file.name),\n size: file.size,\n compressedSize: file.compressedSize,\n };\n });\n const filesTotalSize = result.entriesAssetsMap[componentEntryId]?.assetsSize || 0;\n const compressedTotalFiles = result.entriesAssetsMap[componentEntryId]?.compressedAssetsSize || 0;\n const assets = (result.entriesAssetsMap[componentEntryId]?.auxiliaryAssets || []).map((file) => {\n return {\n name: basename(file.name),\n size: file.size,\n compressedSize: file.compressedSize,\n };\n });\n const assetsTotalSize = result.entriesAssetsMap[componentEntryId]?.auxiliaryAssetsSize || 0;\n const compressedTotalAssets = result.entriesAssetsMap[componentEntryId]?.compressedAuxiliaryAssetsSize || 0;\n const totalSize = filesTotalSize + assetsTotalSize;\n const compressedTotal = compressedTotalFiles + compressedTotalAssets;\n\n const metadata = {\n [COMPONENT_STRATEGY_SIZE_KEY_NAME]: {\n files,\n assets,\n totalFiles: filesTotalSize,\n totalAssets: assetsTotalSize,\n total: totalSize,\n compressedTotalFiles,\n compressedTotalAssets,\n compressedTotal,\n },\n };\n\n return metadata;\n }\n\n async computeResults(context: BundlerContext, results: BundlerResult[]) {\n const componentsResults = flatten(\n await Promise.all(results.map((result) => this.computeTargetResult(context, result)))\n );\n\n const artifacts = this.getArtifactDef();\n\n return {\n componentsResults,\n artifacts,\n };\n }\n\n async computeTargetResult(context: BundlerContext, result: BundlerResult) {\n if (isEmpty(result.errors)) {\n // In case there are errors files will not be emitted so trying to copy them will fail anyway\n this.copyAssetsToCapsules(context, result);\n }\n\n const componentsResults: ComponentResult[] = result.components.map((component) => {\n const metadata = this.computeComponentMetadata(context, result, component);\n return {\n component,\n metadata,\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\n return componentsResults;\n }\n\n private getArtifactDef() {\n // eslint-disable-next-line @typescript-eslint/prefer-as-const\n // const env: 'env' = 'env';\n // const rootDir = this.getDirName(context);\n\n return [\n {\n name: COMPONENT_STRATEGY_ARTIFACT_NAME,\n globPatterns: ['**'],\n rootDir: this.getArtifactDirectory(),\n // context: env,\n },\n ];\n }\n\n getDirName(context: ComputeTargetsContext) {\n const envName = context.id.replace('/', '__');\n return `${envName}-preview`;\n }\n\n private getOutputPath(context: ComputeTargetsContext) {\n return resolve(`${context.capsuleNetwork.capsulesRootDir}/${this.getDirName(context)}`);\n }\n\n private getPaths(context: ComputeTargetsContext, component: Component, files: AbstractVinyl[]) {\n const capsule = context.capsuleNetwork.graphCapsules.getCapsule(component.id);\n if (!capsule) return [];\n const compiler: Compiler = context.env.getCompiler();\n return files.map((file) => join(capsule.path, compiler.getDistPathBySrcPath(file.relative)));\n }\n\n private getComponentOutputPath(capsule: Capsule, context: ComputeTargetsContext) {\n const capsulePath = resolve(`${capsule.path}`);\n const compiler: Compiler = context.env.getCompiler();\n const distDir = compiler.getDistDir?.() || 'dist';\n return join(capsulePath, distDir);\n }\n\n private async computePaths(\n defs: PreviewDefinition[],\n context: ComputeTargetsContext,\n component: Component\n ): Promise<string> {\n // const previewMain = await this.preview.writePreviewRuntime(context);\n const capsule = context.capsuleNetwork.graphCapsules.getCapsule(component.id);\n // if (!capsule) return undefined;\n if (!capsule)\n throw new BitError(\n `could not find capsule for component ${component.id.toString()} during compute paths to bundle`\n );\n const moduleMapsPromise = defs.map(async (previewDef) => {\n const moduleMap = await previewDef.getModuleMap([component]);\n const metadata = previewDef.getMetadata ? await previewDef.getMetadata(component) : undefined;\n const maybeFiles = moduleMap.get(component);\n if (!maybeFiles || !capsule) return { prefix: previewDef.prefix, paths: [] };\n\n const [, files] = maybeFiles;\n const compiledPaths = this.getPaths(context, component, files);\n\n return {\n prefix: previewDef.prefix,\n paths: compiledPaths,\n metadata,\n };\n });\n\n const moduleMaps = await Promise.all(moduleMapsPromise);\n\n const contents = generateComponentLink(moduleMaps);\n const targetDir = this.getComponentOutputPath(capsule, context);\n\n return this.preview.writeLinkContents(contents, targetDir, 'preview');\n }\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,GAAAC,OAAA;EAAAC,QAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAGA,SAAAG,QAAA;EAAA,MAAAH,IAAA,GAAAC,OAAA;EAA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AMD,UAAU,CAACE,YAAY,CAAC,CAAC1I,SAAS,CAAC,CAAC;MAC5D,MAAMmG,QAAQ,GAAGqC,UAAU,CAACG,WAAW,GAAG,MAAMH,UAAU,CAACG,WAAW,CAAC3I,SAAS,CAAC,GAAGuC,SAAS;MAC7F,MAAMqG,UAAU,GAAGH,SAAS,CAACI,GAAG,CAAC7I,SAAS,CAAC;MAC3C,IAAI,CAAC4I,UAAU,IAAI,CAAC7I,OAAO,EAAE,OAAO;QAAE+I,MAAM,EAAEN,UAAU,CAACM,MAAM;QAAEC,KAAK,EAAE;MAAG,CAAC;MAE5E,MAAM,GAAGhF,KAAK,CAAC,GAAG6E,UAAU;MAC5B,MAAMI,aAAa,GAAG,IAAI,CAAChH,QAAQ,CAAC3C,OAAO,EAAEW,SAAS,EAAE+D,KAAK,CAAC;MAE9D,OAAO;QACL+E,MAAM,EAAEN,UAAU,CAACM,MAAM;QACzBC,KAAK,EAAEC,aAAa;QACpB7C;MACF,CAAC;IACH,CAAC,CAAC;IAEF,MAAM8C,UAAU,GAAG,MAAM/I,OAAO,CAACC,GAAG,CAACoI,iBAAiB,CAAC;IAEvD,MAAMW,QAAQ,GAAG,IAAAC,8CAAqB,EAACF,UAAU,CAAC;IAClD,MAAMG,SAAS,GAAG,IAAI,CAACnB,sBAAsB,CAAClI,OAAO,EAAEV,OAAO,CAAC;IAE/D,OAAO,IAAI,CAACJ,OAAO,CAACoK,iBAAiB,CAACH,QAAQ,EAAEE,SAAS,EAAE,SAAS,CAAC;EACvE;AACF;AAAC3K,OAAA,CAAAM,yBAAA,GAAAA,yBAAA"}
|
1
|
+
{"version":3,"names":["_path","data","require","_fsExtra","_lodash","_builder","_bitError","_generateComponentLink","_exceptions","_defineProperty","obj","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","t","i","_toPrimitive","String","r","e","Symbol","toPrimitive","call","TypeError","Number","PREVIEW_CHUNK_SUFFIX","exports","COMPONENT_CHUNK_SUFFIX","PREVIEW_CHUNK_FILENAME_SUFFIX","COMPONENT_CHUNK_FILENAME_SUFFIX","COMPONENT_STRATEGY_SIZE_KEY_NAME","COMPONENT_STRATEGY_ARTIFACT_NAME","ComponentBundlingStrategy","constructor","preview","pkg","dependencyResolver","computeTargets","context","previewDefs","outputPath","getOutputPath","existsSync","mkdirpSync","origComponents","capsuleNetwork","originalSeedersCapsules","map","capsule","component","entriesArr","Promise","all","computeComponentEntry","chunkSize","config","maxChunkSize","chunks","chunk","peers","getPreviewHostDependenciesFromEnv","envDefinition","env","targets","currentChunk","entries","components","forEach","entry","assign","push","hostRootDir","envRuntime","envAspectDefinition","aspectPath","hostDependencies","aliasHostDependencies","externalizeHostDependencies","componentPreviewPath","computePaths","componentPath","getPaths","mainFile","componentPreview","getComponentChunkId","id","splitComponentBundle","toStringWithoutVersion","undefined","filename","getComponentChunkFileName","toString","fsCompatible","ignoreVersion","import","dependOn","library","name","type","componentId","idstr","suffix","getAssetAbsolutePath","asset","path","join","getAssetFilename","split","copyAssetsToCapsules","result","graphCapsules","getCapsule","files","findAssetsForComponent","assets","entriesAssetsMap","artifactDirFullPath","getArtifactDirectory","filePath","PreviewOutputFileNotFound","destFilePath","dirname","fs","copyFileSync","componentEntryId","componentPreviewEntryId","componentFiles","componentAuxiliaryFiles","auxiliaryAssets","componentPreviewFiles","componentPreviewAuxiliaryFiles","concat","CAPSULE_ARTIFACTS_DIR","computeComponentMetadata","file","basename","size","compressedSize","filesTotalSize","assetsSize","compressedTotalFiles","compressedAssetsSize","assetsTotalSize","auxiliaryAssetsSize","compressedTotalAssets","compressedAuxiliaryAssetsSize","totalSize","compressedTotal","metadata","totalFiles","totalAssets","total","computeResults","results","componentsResults","flatten","computeTargetResult","artifacts","getArtifactDef","isEmpty","errors","err","message","warning","warnings","startTime","endTime","globPatterns","rootDir","getDirName","envName","replace","resolve","capsulesRootDir","compiler","getCompiler","getDistPathBySrcPath","relative","getComponentOutputPath","capsulePath","distDir","getDistDir","defs","BitError","moduleMapsPromise","previewDef","moduleMap","getModuleMap","getMetadata","maybeFiles","get","prefix","paths","compiledPaths","moduleMaps","contents","generateComponentLink","targetDir","writeLinkContents"],"sources":["component-strategy.ts"],"sourcesContent":["import { join, resolve, basename, dirname } from 'path';\nimport { existsSync, mkdirpSync } from 'fs-extra';\nimport { Component } from '@teambit/component';\nimport { ComponentID } from '@teambit/component-id';\nimport { flatten, isEmpty, chunk } from 'lodash';\nimport { Compiler } from '@teambit/compiler';\nimport type { AbstractVinyl } from '@teambit/legacy/dist/consumer/component/sources';\nimport type { Capsule } from '@teambit/isolator';\nimport { CAPSULE_ARTIFACTS_DIR, ComponentResult } from '@teambit/builder';\nimport type { PkgMain } from '@teambit/pkg';\nimport { BitError } from '@teambit/bit-error';\nimport type { DependencyResolverMain } from '@teambit/dependency-resolver';\nimport type { BundlerResult, BundlerContext, Asset, BundlerEntryMap, EntriesAssetsMap, Target } from '@teambit/bundler';\nimport { BundlingStrategy, ComputeTargetsContext } from '../bundling-strategy';\nimport type { PreviewDefinition } from '../preview-definition';\nimport type { ComponentPreviewMetaData, PreviewMain } from '../preview.main.runtime';\nimport { generateComponentLink } from './generate-component-link';\nimport { PreviewOutputFileNotFound } from '../exceptions';\n\nexport const PREVIEW_CHUNK_SUFFIX = 'preview';\nexport const COMPONENT_CHUNK_SUFFIX = 'component';\nexport const PREVIEW_CHUNK_FILENAME_SUFFIX = `${PREVIEW_CHUNK_SUFFIX}.js`;\nexport const COMPONENT_CHUNK_FILENAME_SUFFIX = `${COMPONENT_CHUNK_SUFFIX}.js`;\n\nexport const COMPONENT_STRATEGY_SIZE_KEY_NAME = 'size';\nexport const COMPONENT_STRATEGY_ARTIFACT_NAME = 'preview-component';\n\ntype ComponentEntry = {\n component: Component;\n entries: Object;\n};\n/**\n * bundles all components in a given env into the same bundle.\n */\nexport class ComponentBundlingStrategy implements BundlingStrategy {\n name = 'component';\n\n constructor(private preview: PreviewMain, private pkg: PkgMain, private dependencyResolver: DependencyResolverMain) {}\n\n async computeTargets(context: ComputeTargetsContext, previewDefs: PreviewDefinition[]): Promise<Target[]> {\n const outputPath = this.getOutputPath(context);\n if (!existsSync(outputPath)) mkdirpSync(outputPath);\n\n // const entriesArr = flatten(\n // await Promise.all(\n // context.capsuleNetwork.seedersCapsules.map((capsule) => {\n // return this.computeComponentEntry(previewDefs, capsule.component, context);\n // }, {})\n // )\n // );\n\n const origComponents = context.capsuleNetwork.originalSeedersCapsules.map((capsule) => capsule.component);\n\n const entriesArr = await Promise.all(\n origComponents.map((component) => {\n return this.computeComponentEntry(previewDefs, component, context);\n }, {})\n );\n\n const chunkSize = this.preview.config.maxChunkSize;\n\n const chunks = chunkSize ? chunk(entriesArr, chunkSize) : [entriesArr];\n\n const peers = await this.dependencyResolver.getPreviewHostDependenciesFromEnv(context.envDefinition.env);\n\n const targets = chunks.map((currentChunk) => {\n const entries: BundlerEntryMap = {};\n const components: Component[] = [];\n currentChunk.forEach((entry) => {\n Object.assign(entries, entry.entries);\n components.push(entry.component);\n });\n\n return {\n entries,\n components,\n outputPath,\n hostRootDir: context.envRuntime.envAspectDefinition.aspectPath,\n hostDependencies: peers,\n aliasHostDependencies: true,\n externalizeHostDependencies: true,\n };\n });\n\n return targets;\n // const entries = entriesArr.reduce((entriesMap, entry) => {\n // entriesMap[entry.library.name] = entry;\n // return entriesMap;\n // }, {});\n\n // const modules = await Promise.all(entriesArr.map(async (entry) => {\n // const dependencies = this.dependencyResolver.getDependencies(entry.component);\n // const manifest = dependencies.toDependenciesManifest();\n // const peer = Object.entries(manifest.peerDependencies || {}).reduce((acc, [packageName, version]) => {\n // acc[packageName] = {\n // singleton: true,\n // requiredVersion: version\n // };\n\n // return acc;\n // }, {});\n // // console.log(entry);\n // return {\n // name: entry.library.name,\n // exposes: {\n // '.': entry.import || ''\n // },\n // shared: {\n // ...manifest.dependencies,\n // ...peer\n // },\n // };\n // }));\n }\n\n async computeComponentEntry(\n previewDefs: PreviewDefinition[],\n component: Component,\n context: ComputeTargetsContext\n ): Promise<ComponentEntry> {\n const componentPreviewPath = await this.computePaths(previewDefs, context, component);\n const [componentPath] = this.getPaths(context, component, [component.mainFile]);\n\n const chunks = {\n componentPreview: this.getComponentChunkId(component.id, 'preview'),\n component: context.splitComponentBundle ? component.id.toStringWithoutVersion() : undefined,\n };\n\n const entries = {\n [chunks.componentPreview]: {\n filename: this.getComponentChunkFileName(\n component.id.toString({\n fsCompatible: true,\n ignoreVersion: true,\n }),\n 'preview'\n ),\n import: componentPreviewPath,\n dependOn: chunks.component,\n library: { name: chunks.componentPreview, type: 'umd' },\n },\n };\n\n if (chunks.component) {\n entries[chunks.component] = {\n filename: this.getComponentChunkFileName(\n component.id.toString({\n fsCompatible: true,\n ignoreVersion: true,\n }),\n 'component'\n ),\n dependOn: undefined,\n import: componentPath,\n library: { name: chunks.component, type: 'umd' },\n };\n }\n\n return { component, entries };\n }\n\n private getComponentChunkId(componentId: ComponentID, type: 'component' | 'preview') {\n const id =\n type === 'component'\n ? componentId.toStringWithoutVersion()\n : `${componentId.toStringWithoutVersion()}-${PREVIEW_CHUNK_SUFFIX}`;\n return id;\n }\n\n private getComponentChunkFileName(idstr: string, type: 'component' | 'preview') {\n const suffix = type === 'component' ? COMPONENT_CHUNK_FILENAME_SUFFIX : PREVIEW_CHUNK_FILENAME_SUFFIX;\n return `${idstr}-${suffix}`;\n }\n\n private getAssetAbsolutePath(context: BundlerContext, asset: Asset): string {\n const path = this.getOutputPath(context);\n return join(path, 'public', this.getAssetFilename(asset));\n }\n\n private getAssetFilename(asset: Asset): string {\n // handle cases where the asset name is something like my-image.svg?hash (while the filename in the fs is just my-image.svg)\n const [name] = asset.name.split('?');\n return name;\n }\n\n copyAssetsToCapsules(context: BundlerContext, result: BundlerResult) {\n context.components.forEach((component) => {\n const capsule = context.capsuleNetwork.graphCapsules.getCapsule(component.id);\n if (!capsule) return;\n const files = this.findAssetsForComponent(component, result.assets, result.entriesAssetsMap || {});\n if (!files) return;\n const artifactDirFullPath = join(capsule.path, this.getArtifactDirectory());\n // We don't use the mkdirSync as it uses the capsule fs which uses memfs, which doesn't know to handle nested none existing folders\n mkdirpSync(artifactDirFullPath);\n\n files.forEach((asset) => {\n const filePath = this.getAssetAbsolutePath(context, asset);\n if (!existsSync(filePath)) {\n throw new PreviewOutputFileNotFound(component.id, filePath);\n }\n const destFilePath = join(artifactDirFullPath, this.getAssetFilename(asset));\n mkdirpSync(dirname(destFilePath));\n capsule.fs.copyFileSync(filePath, destFilePath);\n });\n });\n }\n\n // private getCssFileName(componentId: ComponentID): string {\n // return `${componentId.toString({ ignoreVersion: true, fsCompatible: true })}.css`;\n // }\n\n private findAssetsForComponent(\n component: Component,\n assets: Asset[],\n entriesAssetsMap: EntriesAssetsMap\n ): Asset[] | undefined {\n if (!assets) return undefined;\n\n const componentEntryId = component.id.toStringWithoutVersion();\n const componentPreviewEntryId = this.getComponentChunkId(component.id, 'preview');\n const componentFiles = entriesAssetsMap[componentEntryId]?.assets || [];\n const componentAuxiliaryFiles = entriesAssetsMap[componentEntryId]?.auxiliaryAssets || [];\n const componentPreviewFiles = entriesAssetsMap[componentPreviewEntryId]?.assets || [];\n const componentPreviewAuxiliaryFiles = entriesAssetsMap[componentPreviewEntryId]?.auxiliaryAssets || [];\n\n const files = componentFiles\n .concat(componentAuxiliaryFiles)\n .concat(componentPreviewFiles)\n .concat(componentPreviewAuxiliaryFiles);\n return files;\n }\n\n private getArtifactDirectory() {\n return join(CAPSULE_ARTIFACTS_DIR, 'preview');\n }\n\n private computeComponentMetadata(\n context: BundlerContext,\n result: BundlerResult,\n component: Component\n ): ComponentPreviewMetaData {\n const componentEntryId = component.id.toStringWithoutVersion();\n if (!result?.entriesAssetsMap || !result?.entriesAssetsMap[componentEntryId]) {\n return {};\n }\n const files = (result.entriesAssetsMap[componentEntryId]?.assets || []).map((file) => {\n return {\n name: basename(file.name),\n size: file.size,\n compressedSize: file.compressedSize,\n };\n });\n const filesTotalSize = result.entriesAssetsMap[componentEntryId]?.assetsSize || 0;\n const compressedTotalFiles = result.entriesAssetsMap[componentEntryId]?.compressedAssetsSize || 0;\n const assets = (result.entriesAssetsMap[componentEntryId]?.auxiliaryAssets || []).map((file) => {\n return {\n name: basename(file.name),\n size: file.size,\n compressedSize: file.compressedSize,\n };\n });\n const assetsTotalSize = result.entriesAssetsMap[componentEntryId]?.auxiliaryAssetsSize || 0;\n const compressedTotalAssets = result.entriesAssetsMap[componentEntryId]?.compressedAuxiliaryAssetsSize || 0;\n const totalSize = filesTotalSize + assetsTotalSize;\n const compressedTotal = compressedTotalFiles + compressedTotalAssets;\n\n const metadata = {\n [COMPONENT_STRATEGY_SIZE_KEY_NAME]: {\n files,\n assets,\n totalFiles: filesTotalSize,\n totalAssets: assetsTotalSize,\n total: totalSize,\n compressedTotalFiles,\n compressedTotalAssets,\n compressedTotal,\n },\n };\n\n return metadata;\n }\n\n async computeResults(context: BundlerContext, results: BundlerResult[]) {\n const componentsResults = flatten(\n await Promise.all(results.map((result) => this.computeTargetResult(context, result)))\n );\n\n const artifacts = this.getArtifactDef();\n\n return {\n componentsResults,\n artifacts,\n };\n }\n\n async computeTargetResult(context: BundlerContext, result: BundlerResult) {\n if (isEmpty(result.errors)) {\n // In case there are errors files will not be emitted so trying to copy them will fail anyway\n this.copyAssetsToCapsules(context, result);\n }\n\n const componentsResults: ComponentResult[] = result.components.map((component) => {\n const metadata = this.computeComponentMetadata(context, result, component);\n return {\n component,\n metadata,\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\n return componentsResults;\n }\n\n private getArtifactDef() {\n // eslint-disable-next-line @typescript-eslint/prefer-as-const\n // const env: 'env' = 'env';\n // const rootDir = this.getDirName(context);\n\n return [\n {\n name: COMPONENT_STRATEGY_ARTIFACT_NAME,\n globPatterns: ['**'],\n rootDir: this.getArtifactDirectory(),\n // context: env,\n },\n ];\n }\n\n getDirName(context: ComputeTargetsContext) {\n const envName = context.id.replace('/', '__');\n return `${envName}-preview`;\n }\n\n private getOutputPath(context: ComputeTargetsContext) {\n return resolve(`${context.capsuleNetwork.capsulesRootDir}/${this.getDirName(context)}`);\n }\n\n private getPaths(context: ComputeTargetsContext, component: Component, files: AbstractVinyl[]) {\n const capsule = context.capsuleNetwork.graphCapsules.getCapsule(component.id);\n if (!capsule) return [];\n const compiler: Compiler = context.env.getCompiler();\n return files.map((file) => join(capsule.path, compiler.getDistPathBySrcPath(file.relative)));\n }\n\n private getComponentOutputPath(capsule: Capsule, context: ComputeTargetsContext) {\n const capsulePath = resolve(`${capsule.path}`);\n const compiler: Compiler = context.env.getCompiler();\n const distDir = compiler.getDistDir?.() || 'dist';\n return join(capsulePath, distDir);\n }\n\n private async computePaths(\n defs: PreviewDefinition[],\n context: ComputeTargetsContext,\n component: Component\n ): Promise<string> {\n // const previewMain = await this.preview.writePreviewRuntime(context);\n const capsule = context.capsuleNetwork.graphCapsules.getCapsule(component.id);\n // if (!capsule) return undefined;\n if (!capsule)\n throw new BitError(\n `could not find capsule for component ${component.id.toString()} during compute paths to bundle`\n );\n const moduleMapsPromise = defs.map(async (previewDef) => {\n const moduleMap = await previewDef.getModuleMap([component]);\n const metadata = previewDef.getMetadata ? await previewDef.getMetadata(component) : undefined;\n const maybeFiles = moduleMap.get(component);\n if (!maybeFiles || !capsule) return { prefix: previewDef.prefix, paths: [] };\n\n const [, files] = maybeFiles;\n const compiledPaths = this.getPaths(context, component, files);\n\n return {\n prefix: previewDef.prefix,\n paths: compiledPaths,\n metadata,\n };\n });\n\n const moduleMaps = await Promise.all(moduleMapsPromise);\n\n const contents = generateComponentLink(moduleMaps);\n const targetDir = this.getComponentOutputPath(capsule, context);\n\n return this.preview.writeLinkContents(contents, targetDir, 'preview');\n }\n}\n"],"mappings":";;;;;;AAAA,SAAAA,MAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,KAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;A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_fsExtra","_lodash","_component","_htmlTemplate","_defineProperty","obj","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","t","i","_toPrimitive","String","r","e","Symbol","toPrimitive","call","TypeError","Number","ENV_STRATEGY_ARTIFACT_NAME","exports","EnvBundlingStrategy","constructor","preview","pkg","dependencyResolver","computeTargets","context","previewDefs","outputPath","getOutputPath","existsSync","mkdirpSync","htmlConfig","generateHtmlConfig","dev","peers","getPreviewHostDependenciesFromEnv","envDefinition","env","entries","computePaths","html","components","hostDependencies","aliasHostDependencies","options","config","title","templateContent","cache","minify","computeResults","results","result","componentsResults","map","component","errors","err","message","warning","warnings","startTime","endTime","artifacts","getArtifactDef","rootDir","getDirName","name","globPatterns","envName","id","replace","resolve","capsuleNetwork","capsulesRootDir","getPaths","files","capsule","compiler","getCompiler","file","join","path","getDistPathBySrcPath","relative","defs","previewMain","writePreviewRuntime","moduleMapsPromise","previewDef","moduleMap","getModuleMap","paths","ComponentMap","as","graphCapsules","getCapsule","maybeFiles","get","compiledPaths","template","renderTemplatePath","link","writeLink","prefix","default","flatten","toArray","concat","moduleMaps","Promise","all"],"sources":["env-strategy.ts"],"sourcesContent":["import { join, resolve } from 'path';\nimport { existsSync, mkdirpSync } from 'fs-extra';\nimport { flatten } from 'lodash';\nimport { ComponentMap } from '@teambit/component';\nimport { Compiler } from '@teambit/compiler';\nimport { AbstractVinyl } from '@teambit/legacy/dist/consumer/component/sources';\nimport { Capsule } from '@teambit/isolator';\nimport { ComponentResult } from '@teambit/builder';\nimport { BundlerContext, BundlerHtmlConfig, BundlerResult } from '@teambit/bundler';\nimport { DependencyResolverMain } from '@teambit/dependency-resolver';\nimport { PkgMain } from '@teambit/pkg';\nimport type { BundlingStrategy, ComputeTargetsContext } from '../bundling-strategy';\nimport { PreviewDefinition } from '../preview-definition';\nimport { PreviewMain } from '../preview.main.runtime';\nimport { html } from '../bundler/html-template';\n\nexport const ENV_STRATEGY_ARTIFACT_NAME = 'preview';\n\n/**\n * bundles all components in a given env into the same bundle.\n */\nexport class EnvBundlingStrategy implements BundlingStrategy {\n name = 'env';\n\n constructor(private preview: PreviewMain, private pkg: PkgMain, private dependencyResolver: DependencyResolverMain) {}\n\n async computeTargets(context: ComputeTargetsContext, previewDefs: PreviewDefinition[]) {\n const outputPath = this.getOutputPath(context);\n if (!existsSync(outputPath)) mkdirpSync(outputPath);\n const htmlConfig = this.generateHtmlConfig({ dev: context.dev });\n const peers = await this.dependencyResolver.getPreviewHostDependenciesFromEnv(context.envDefinition.env);\n\n return [\n {\n entries: await this.computePaths(outputPath, previewDefs, context),\n html: [htmlConfig],\n components: context.components,\n outputPath,\n /* It's a path to the root of the host component. */\n // hostRootDir, handle this\n hostDependencies: peers,\n aliasHostDependencies: true,\n },\n ];\n }\n\n private generateHtmlConfig(options: { dev?: boolean }): BundlerHtmlConfig {\n const config = {\n title: 'Preview',\n templateContent: html('Preview'),\n cache: false,\n minify: options?.dev ?? true,\n };\n return config;\n }\n\n async computeResults(context: BundlerContext, results: BundlerResult[]) {\n const result = results[0];\n\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\n const artifacts = this.getArtifactDef(context);\n\n return {\n componentsResults,\n artifacts,\n };\n }\n\n private getArtifactDef(context: ComputeTargetsContext) {\n // eslint-disable-next-line @typescript-eslint/prefer-as-const\n const env: 'env' = 'env';\n const rootDir = this.getDirName(context);\n\n return [\n {\n name: ENV_STRATEGY_ARTIFACT_NAME,\n globPatterns: ['public/**'],\n rootDir,\n context: env,\n },\n ];\n }\n\n getDirName(context: ComputeTargetsContext) {\n const envName = context.id.replace('/', '__');\n return `${envName}-preview`;\n }\n\n private getOutputPath(context: ComputeTargetsContext) {\n return resolve(`${context.capsuleNetwork.capsulesRootDir}/${this.getDirName(context)}`);\n }\n\n private getPaths(context: ComputeTargetsContext, files: AbstractVinyl[], capsule: Capsule) {\n const compiler: Compiler = context.env.getCompiler();\n return files.map((file) => join(capsule.path, compiler.getDistPathBySrcPath(file.relative)));\n }\n\n private async computePaths(\n outputPath: string,\n defs: PreviewDefinition[],\n context: ComputeTargetsContext\n ): Promise<string[]> {\n const previewMain = await this.preview.writePreviewRuntime(context);\n const moduleMapsPromise = defs.map(async (previewDef) => {\n const moduleMap = await previewDef.getModuleMap(context.components);\n\n const paths = ComponentMap.as(context.components, (component) => {\n const capsule = context.capsuleNetwork.graphCapsules.getCapsule(component.id);\n const maybeFiles = moduleMap.get(component);\n if (!maybeFiles || !capsule) return [];\n const [, files] = maybeFiles;\n const compiledPaths = this.getPaths(context, files, capsule);\n return compiledPaths;\n });\n\n const template = previewDef.renderTemplatePath ? await previewDef.renderTemplatePath(context) : 'undefined';\n\n const link = this.preview.writeLink(\n previewDef.prefix,\n paths,\n { default: template || 'undefined' },\n outputPath,\n false\n );\n\n const files = flatten(paths.toArray().map(([, file]) => file)).concat([link]);\n\n if (template) return files.concat([template]);\n return files;\n });\n\n const moduleMaps = await Promise.all(moduleMapsPromise);\n\n return flatten(moduleMaps.concat([previewMain]));\n }\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,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,WAAA;EAAA,MAAAJ,IAAA,GAAAC,OAAA;EAAAG,UAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,O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CAAC,CAAC4B,MAAM,CAAC,CAACN,IAAI,CAAC,CAAC;MAE7E,IAAIF,QAAQ,EAAE,OAAOxB,KAAK,CAACgC,MAAM,CAAC,CAACR,QAAQ,CAAC,CAAC;MAC7C,OAAOxB,KAAK;IACd,CAAC,CAAC;IAEF,MAAMiC,UAAU,GAAG,MAAMC,OAAO,CAACC,GAAG,CAACvB,iBAAiB,CAAC;IAEvD,OAAO,IAAAkB,iBAAO,EAACG,UAAU,CAACD,MAAM,CAAC,CAACtB,WAAW,CAAC,CAAC,CAAC;EAClD;AACF;AAACpE,OAAA,CAAAC,mBAAA,GAAAA,mBAAA"}
|
1
|
+
{"version":3,"names":["_path","data","require","_fsExtra","_lodash","_component","_htmlTemplate","_defineProperty","obj","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","t","i","_toPrimitive","String","r","e","Symbol","toPrimitive","call","TypeError","Number","ENV_STRATEGY_ARTIFACT_NAME","exports","EnvBundlingStrategy","constructor","preview","pkg","dependencyResolver","computeTargets","context","previewDefs","outputPath","getOutputPath","existsSync","mkdirpSync","htmlConfig","generateHtmlConfig","dev","peers","getPreviewHostDependenciesFromEnv","envDefinition","env","entries","computePaths","html","components","hostDependencies","aliasHostDependencies","options","config","title","templateContent","cache","minify","computeResults","results","result","componentsResults","map","component","errors","err","message","warning","warnings","startTime","endTime","artifacts","getArtifactDef","rootDir","getDirName","name","globPatterns","envName","id","replace","resolve","capsuleNetwork","capsulesRootDir","getPaths","files","capsule","compiler","getCompiler","file","join","path","getDistPathBySrcPath","relative","defs","previewMain","writePreviewRuntime","moduleMapsPromise","previewDef","moduleMap","getModuleMap","paths","ComponentMap","as","graphCapsules","getCapsule","maybeFiles","get","compiledPaths","template","renderTemplatePath","link","writeLink","prefix","default","flatten","toArray","concat","moduleMaps","Promise","all"],"sources":["env-strategy.ts"],"sourcesContent":["import { join, resolve } from 'path';\nimport { existsSync, mkdirpSync } from 'fs-extra';\nimport { flatten } from 'lodash';\nimport { ComponentMap } from '@teambit/component';\nimport { Compiler } from '@teambit/compiler';\nimport { AbstractVinyl } from '@teambit/legacy/dist/consumer/component/sources';\nimport { Capsule } from '@teambit/isolator';\nimport { ComponentResult } from '@teambit/builder';\nimport { BundlerContext, BundlerHtmlConfig, BundlerResult } from '@teambit/bundler';\nimport { DependencyResolverMain } from '@teambit/dependency-resolver';\nimport { PkgMain } from '@teambit/pkg';\nimport type { BundlingStrategy, ComputeTargetsContext } from '../bundling-strategy';\nimport { PreviewDefinition } from '../preview-definition';\nimport { PreviewMain } from '../preview.main.runtime';\nimport { html } from '../bundler/html-template';\n\nexport const ENV_STRATEGY_ARTIFACT_NAME = 'preview';\n\n/**\n * bundles all components in a given env into the same bundle.\n */\nexport class EnvBundlingStrategy implements BundlingStrategy {\n name = 'env';\n\n constructor(private preview: PreviewMain, private pkg: PkgMain, private dependencyResolver: DependencyResolverMain) {}\n\n async computeTargets(context: ComputeTargetsContext, previewDefs: PreviewDefinition[]) {\n const outputPath = this.getOutputPath(context);\n if (!existsSync(outputPath)) mkdirpSync(outputPath);\n const htmlConfig = this.generateHtmlConfig({ dev: context.dev });\n const peers = await this.dependencyResolver.getPreviewHostDependenciesFromEnv(context.envDefinition.env);\n\n return [\n {\n entries: await this.computePaths(outputPath, previewDefs, context),\n html: [htmlConfig],\n components: context.components,\n outputPath,\n /* It's a path to the root of the host component. */\n // hostRootDir, handle this\n hostDependencies: peers,\n aliasHostDependencies: true,\n },\n ];\n }\n\n private generateHtmlConfig(options: { dev?: boolean }): BundlerHtmlConfig {\n const config = {\n title: 'Preview',\n templateContent: html('Preview'),\n cache: false,\n minify: options?.dev ?? true,\n };\n return config;\n }\n\n async computeResults(context: BundlerContext, results: BundlerResult[]) {\n const result = results[0];\n\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\n const artifacts = this.getArtifactDef(context);\n\n return {\n componentsResults,\n artifacts,\n };\n }\n\n private getArtifactDef(context: ComputeTargetsContext) {\n // eslint-disable-next-line @typescript-eslint/prefer-as-const\n const env: 'env' = 'env';\n const rootDir = this.getDirName(context);\n\n return [\n {\n name: ENV_STRATEGY_ARTIFACT_NAME,\n globPatterns: ['public/**'],\n rootDir,\n context: env,\n },\n ];\n }\n\n getDirName(context: ComputeTargetsContext) {\n const envName = context.id.replace('/', '__');\n return `${envName}-preview`;\n }\n\n private getOutputPath(context: ComputeTargetsContext) {\n return resolve(`${context.capsuleNetwork.capsulesRootDir}/${this.getDirName(context)}`);\n }\n\n private getPaths(context: ComputeTargetsContext, files: AbstractVinyl[], capsule: Capsule) {\n const compiler: Compiler = context.env.getCompiler();\n return files.map((file) => join(capsule.path, compiler.getDistPathBySrcPath(file.relative)));\n }\n\n private async computePaths(\n outputPath: string,\n defs: PreviewDefinition[],\n context: ComputeTargetsContext\n ): Promise<string[]> {\n const previewMain = await this.preview.writePreviewRuntime(context);\n const moduleMapsPromise = defs.map(async (previewDef) => {\n const moduleMap = await previewDef.getModuleMap(context.components);\n\n const paths = ComponentMap.as(context.components, (component) => {\n const capsule = context.capsuleNetwork.graphCapsules.getCapsule(component.id);\n const maybeFiles = moduleMap.get(component);\n if (!maybeFiles || !capsule) return [];\n const [, files] = maybeFiles;\n const compiledPaths = this.getPaths(context, files, capsule);\n return compiledPaths;\n });\n\n const template = previewDef.renderTemplatePath ? await previewDef.renderTemplatePath(context) : 'undefined';\n\n const link = this.preview.writeLink(\n previewDef.prefix,\n paths,\n { default: template || 'undefined' },\n outputPath,\n false\n );\n\n const files = flatten(paths.toArray().map(([, file]) => file)).concat([link]);\n\n if (template) return files.concat([template]);\n return files;\n });\n\n const moduleMaps = await Promise.all(moduleMapsPromise);\n\n return flatten(moduleMaps.concat([previewMain]));\n }\n}\n"],"mappings":";;;;;;AAAA,SAAAA,MAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,KAAA,YAAAA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