@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.
Files changed (60) hide show
  1. package/artifacts/__bit_junit.xml +2 -2
  2. package/artifacts/preview/teambit_preview_preview-preview.js +1 -1
  3. package/artifacts/schema.json +13401 -0
  4. package/dist/artifact-file-middleware.js.map +1 -1
  5. package/dist/bundler/chunks.js.map +1 -1
  6. package/dist/bundler/create-peer-link.spec.js.map +1 -1
  7. package/dist/bundler/create-peers-link.js.map +1 -1
  8. package/dist/bundler/html-plugin.js.map +1 -1
  9. package/dist/bundler/html-template.js.map +1 -1
  10. package/dist/bundling-strategy.js.map +1 -1
  11. package/dist/component-preview.js.map +1 -1
  12. package/dist/component-preview.route.js.map +1 -1
  13. package/dist/env-preview-template.task.js.map +1 -1
  14. package/dist/env-template.route.js.map +1 -1
  15. package/dist/events/click-inside-an-iframe.js.map +1 -1
  16. package/dist/events/index.js.map +1 -1
  17. package/dist/exceptions/bundling-strategy-not-found.js.map +1 -1
  18. package/dist/exceptions/index.js.map +1 -1
  19. package/dist/exceptions/preview-artifact-not-found.js.map +1 -1
  20. package/dist/exceptions/preview-not-found.js.map +1 -1
  21. package/dist/exceptions/preview-output-file-not-found.js.map +1 -1
  22. package/dist/execution-ref.js.map +1 -1
  23. package/dist/generate-link.js.map +1 -1
  24. package/dist/gql/fetch-component-aspects.js.map +1 -1
  25. package/dist/html-utils.js.map +1 -1
  26. package/dist/index.js.map +1 -1
  27. package/dist/mk-temp-dir.js.map +1 -1
  28. package/dist/pre-bundle-utils.js.map +1 -1
  29. package/dist/pre-bundle.js.map +1 -1
  30. package/dist/pre-bundle.task.js.map +1 -1
  31. package/dist/preview-1710224484125.js +7 -0
  32. package/dist/preview-artifact.js.map +1 -1
  33. package/dist/preview-assets.route.js.map +1 -1
  34. package/dist/preview-context.js.map +1 -1
  35. package/dist/preview-definition.js.map +1 -1
  36. package/dist/preview-env.js.map +1 -1
  37. package/dist/preview-modules.js.map +1 -1
  38. package/dist/preview-type.js.map +1 -1
  39. package/dist/preview.aspect.js.map +1 -1
  40. package/dist/preview.composition.js.map +1 -1
  41. package/dist/preview.graphql.js.map +1 -1
  42. package/dist/preview.js.map +1 -1
  43. package/dist/preview.main.runtime.js.map +1 -1
  44. package/dist/preview.preview.runtime.js.map +1 -1
  45. package/dist/preview.route.js.map +1 -1
  46. package/dist/preview.service.js.map +1 -1
  47. package/dist/preview.start-plugin.js.map +1 -1
  48. package/dist/preview.task.js.map +1 -1
  49. package/dist/rendering-context.js.map +1 -1
  50. package/dist/size-event.js.map +1 -1
  51. package/dist/strategies/component-strategy.d.ts +2 -2
  52. package/dist/strategies/component-strategy.js.map +1 -1
  53. package/dist/strategies/env-strategy.js.map +1 -1
  54. package/dist/strategies/generate-component-link.js.map +1 -1
  55. package/dist/strategies/index.js.map +1 -1
  56. package/dist/strategies/strategies-names.js.map +1 -1
  57. package/dist/types/preview-module.js.map +1 -1
  58. package/dist/webpack/webpack.config.js.map +1 -1
  59. package/package.json +23 -23
  60. package/dist/preview-1710040632859.js +0 -7
@@ -1 +1 @@
1
- {"version":3,"names":["_mime","data","_interopRequireDefault","require","_uiFoundationUiPages","obj","__esModule","default","getArtifactFileMiddleware","logger","getCacheControlFunc","req","res","artifact","isLegacyPath","file","getEnvTemplateFile","params","previewName","filePath","getPreviewFile","status","send","noPreview","contents","str","cwd","path","contentType","mime","getType","set","cacheControl","e","error","serverError","prevName","finalFilePath","matchedFile","getFileEndsWith","parts","filter","x","join"],"sources":["artifact-file-middleware.ts"],"sourcesContent":["import mime from 'mime';\nimport type { Request, Response, Middleware } from '@teambit/express';\nimport { noPreview, serverError } from '@teambit/ui-foundation.ui.pages.static-error';\nimport type { Logger } from '@teambit/logger';\nimport type { PreviewArtifact } from './preview-artifact';\n\nexport type PreviewUrlParams = {\n /**\n * preview name like overview or composition\n */\n previewName?: string;\n /** `/preview/:filePath(*)` */\n filePath?: string;\n};\n\nexport type GetCacheControlFunc = (filePath: string, contents: string, mimeType?: string | null) => string | undefined;\n\nexport function getArtifactFileMiddleware(logger: Logger, getCacheControlFunc?: GetCacheControlFunc): Middleware {\n return async (req: Request<PreviewUrlParams>, res: Response) => {\n try {\n // @ts-ignore\n const artifact: PreviewArtifact = req.artifact;\n // @ts-ignore\n const isLegacyPath = req.isLegacyPath;\n let file;\n if (!isLegacyPath) {\n file = getEnvTemplateFile(artifact, req.params.previewName, req.params.filePath);\n } else {\n file = getPreviewFile(artifact, req.params.previewName, req.params.filePath);\n }\n if (!file) return res.status(404).send(noPreview());\n\n const contents = file.contents;\n const str = `${file.cwd}/${file.path}`;\n const contentType = mime.getType(str);\n if (contentType) res.set('Content-Type', contentType);\n if (getCacheControlFunc) {\n const cacheControl = getCacheControlFunc(str, contents, contentType);\n if (cacheControl) {\n res.set('Cache-control', cacheControl);\n }\n }\n return res.send(contents);\n } catch (e: any) {\n logger.error('failed getting preview', e);\n return res.status(500).send(serverError());\n }\n };\n}\n\nfunction getEnvTemplateFile(artifact: PreviewArtifact, previewName?: string, filePath?: string) {\n const prevName = previewName || 'overview';\n const finalFilePath = filePath || `${prevName}.html`;\n const matchedFile = artifact?.getFileEndsWith(finalFilePath);\n return matchedFile;\n}\n\nfunction getPreviewFile(artifact: PreviewArtifact, previewName?: string, filePath?: string) {\n let finalFilePath = 'index.html';\n if (previewName || filePath) {\n const parts = [previewName, filePath].filter((x) => x);\n finalFilePath = parts.join('/');\n }\n const matchedFile = artifact?.getFileEndsWith(finalFilePath);\n return matchedFile;\n}\n"],"mappings":";;;;;;AAAA,SAAAA,MAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,KAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAG,qBAAA;EAAA,MAAAH,IAAA,GAAAE,OAAA;EAAAC,oBAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EA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eAAe,EAAEC,YAAY,CAAC;QACxC;MACF;MACA,OAAOpB,GAAG,CAACU,IAAI,CAACE,QAAQ,CAAC;IAC3B,CAAC,CAAC,OAAOS,CAAM,EAAE;MACfxB,MAAM,CAACyB,KAAK,CAAC,wBAAwB,EAAED,CAAC,CAAC;MACzC,OAAOrB,GAAG,CAACS,MAAM,CAAC,GAAG,CAAC,CAACC,IAAI,CAAC,IAAAa,kCAAW,EAAC,CAAC,CAAC;IAC5C;EACF,CAAC;AACH;AAEA,SAASnB,kBAAkBA,CAACH,QAAyB,EAAEK,WAAoB,EAAEC,QAAiB,EAAE;EAC9F,MAAMiB,QAAQ,GAAGlB,WAAW,IAAI,UAAU;EAC1C,MAAMmB,aAAa,GAAGlB,QAAQ,IAAK,GAAEiB,QAAS,OAAM;EACpD,MAAME,WAAW,GAAGzB,QAAQ,EAAE0B,eAAe,CAACF,aAAa,CAAC;EAC5D,OAAOC,WAAW;AACpB;AAEA,SAASlB,cAAcA,CAACP,QAAyB,EAAEK,WAAoB,EAAEC,QAAiB,EAAE;EAC1F,IAAIkB,aAAa,GAAG,YAAY;EAChC,IAAInB,WAAW,IAAIC,QAAQ,EAAE;IAC3B,MAAMqB,KAAK,GAAG,CAACtB,WAAW,EAAEC,QAAQ,CAAC,CAACsB,MAAM,CAAEC,CAAC,IAAKA,CAAC,CAAC;IACtDL,aAAa,GAAGG,KAAK,CAACG,IAAI,CAAC,GAAG,CAAC;EACjC;EACA,MAAML,WAAW,GAAGzB,QAAQ,EAAE0B,eAAe,CAACF,aAAa,CAAC;EAC5D,OAAOC,WAAW;AACpB"}
1
+ {"version":3,"names":["_mime","data","_interopRequireDefault","require","_uiFoundationUiPages","obj","__esModule","default","getArtifactFileMiddleware","logger","getCacheControlFunc","req","res","artifact","isLegacyPath","file","getEnvTemplateFile","params","previewName","filePath","getPreviewFile","status","send","noPreview","contents","str","cwd","path","contentType","mime","getType","set","cacheControl","e","error","serverError","prevName","finalFilePath","matchedFile","getFileEndsWith","parts","filter","x","join"],"sources":["artifact-file-middleware.ts"],"sourcesContent":["import mime from 'mime';\nimport type { Request, Response, Middleware } from '@teambit/express';\nimport { noPreview, serverError } from '@teambit/ui-foundation.ui.pages.static-error';\nimport type { Logger } from '@teambit/logger';\nimport type { PreviewArtifact } from './preview-artifact';\n\nexport type PreviewUrlParams = {\n /**\n * preview name like overview or composition\n */\n previewName?: string;\n /** `/preview/:filePath(*)` */\n filePath?: string;\n};\n\nexport type GetCacheControlFunc = (filePath: string, contents: string, mimeType?: string | null) => string | undefined;\n\nexport function getArtifactFileMiddleware(logger: Logger, getCacheControlFunc?: GetCacheControlFunc): Middleware {\n return async (req: Request<PreviewUrlParams>, res: Response) => {\n try {\n // @ts-ignore\n const artifact: PreviewArtifact = req.artifact;\n // @ts-ignore\n const isLegacyPath = req.isLegacyPath;\n let file;\n if (!isLegacyPath) {\n file = getEnvTemplateFile(artifact, req.params.previewName, req.params.filePath);\n } else {\n file = getPreviewFile(artifact, req.params.previewName, req.params.filePath);\n }\n if (!file) return res.status(404).send(noPreview());\n\n const contents = file.contents;\n const str = `${file.cwd}/${file.path}`;\n const contentType = mime.getType(str);\n if (contentType) res.set('Content-Type', contentType);\n if (getCacheControlFunc) {\n const cacheControl = getCacheControlFunc(str, contents, contentType);\n if (cacheControl) {\n res.set('Cache-control', cacheControl);\n }\n }\n return res.send(contents);\n } catch (e: any) {\n logger.error('failed getting preview', e);\n return res.status(500).send(serverError());\n }\n };\n}\n\nfunction getEnvTemplateFile(artifact: PreviewArtifact, previewName?: string, filePath?: string) {\n const prevName = previewName || 'overview';\n const finalFilePath = filePath || `${prevName}.html`;\n const matchedFile = artifact?.getFileEndsWith(finalFilePath);\n return matchedFile;\n}\n\nfunction getPreviewFile(artifact: PreviewArtifact, previewName?: string, filePath?: string) {\n let finalFilePath = 'index.html';\n if (previewName || filePath) {\n const parts = [previewName, filePath].filter((x) => x);\n finalFilePath = parts.join('/');\n }\n const matchedFile = artifact?.getFileEndsWith(finalFilePath);\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aAAa,CAAC;EAC5D,OAAOC,WAAW;AACpB","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["CHUNK_NAMES","exports","previewRoot","peers","generateTemplateEntries","options","previewChunks","previewModules","forEach","name","entry","include","dependOn","import","_objectSpread","previewRootPath"],"sources":["chunks.ts"],"sourcesContent":["import type { BundlerEntryMap } from '@teambit/bundler';\n\n// TODO - we can remove the need to depenedOn preview-root, if we output chunks as \"jsonp\".\n//\n// for example:\n// config.entry.someJsonpChunk = {\n// import: \"./xxx\",\n// library: { type: \"jsonp\", name: \"foobar\" }\n// }\n// will result in this output:\n// foobar(() => { ...; return MODULE })\n\nexport const CHUNK_NAMES = {\n previewRoot: 'preview-root',\n peers: 'peers',\n};\n\ntype TemplateEntryOptions = {\n previewRootPath: string;\n peers: string | string[];\n previewModules: {\n name: string;\n entry: string;\n /** other preview modules to includes */\n include?: string[];\n }[];\n};\n\nexport function generateTemplateEntries(options: TemplateEntryOptions): BundlerEntryMap {\n const previewChunks = {};\n options.previewModules.forEach(({ name, entry, include = [] }) => {\n previewChunks[name] = {\n dependOn: [CHUNK_NAMES.peers, CHUNK_NAMES.previewRoot, ...include],\n import: entry,\n };\n });\n\n return {\n [CHUNK_NAMES.peers]: options.peers,\n [CHUNK_NAMES.previewRoot]: {\n dependOn: [CHUNK_NAMES.peers],\n import: options.previewRootPath,\n },\n ...previewChunks,\n };\n}\n"],"mappings":";;;;;;;;;;;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEO,MAAMA,WAAW,GAAAC,OAAA,CAAAD,WAAA,GAAG;EACzBE,WAAW,EAAE,cAAc;EAC3BC,KAAK,EAAE;AACT,CAAC;AAaM,SAASC,uBAAuBA,CAACC,OAA6B,EAAmB;EACtF,MAAMC,aAAa,GAAG,CAAC,CAAC;EACxBD,OAAO,CAACE,cAAc,CAACC,OAAO,CAAC,CAAC;IAAEC,IAAI;IAAEC,KAAK;IAAEC,OAAO,GAAG;EAAG,CAAC,KAAK;IAChEL,aAAa,CAACG,IAAI,CAAC,GAAG;MACpBG,QAAQ,EAAE,CAACZ,WAAW,CAACG,KAAK,EAAEH,WAAW,CAACE,WAAW,EAAE,GAAGS,OAAO,CAAC;MAClEE,MAAM,EAAEH;IACV,CAAC;EACH,CAAC,CAAC;EAEF,OAAAI,aAAA;IACE,CAACd,WAAW,CAACG,KAAK,GAAGE,OAAO,CAACF,KAAK;IAClC,CAACH,WAAW,CAACE,WAAW,GAAG;MACzBU,QAAQ,EAAE,CAACZ,WAAW,CAACG,KAAK,CAAC;MAC7BU,MAAM,EAAER,OAAO,CAACU;IAClB;EAAC,GACET,aAAa;AAEpB"}
1
+ {"version":3,"names":["CHUNK_NAMES","exports","previewRoot","peers","generateTemplateEntries","options","previewChunks","previewModules","forEach","name","entry","include","dependOn","import","_objectSpread","previewRootPath"],"sources":["chunks.ts"],"sourcesContent":["import type { BundlerEntryMap } from '@teambit/bundler';\n\n// TODO - we can remove the need to depenedOn preview-root, if we output chunks as \"jsonp\".\n//\n// for example:\n// config.entry.someJsonpChunk = {\n// import: \"./xxx\",\n// library: { type: \"jsonp\", name: \"foobar\" }\n// }\n// will result in this output:\n// foobar(() => { ...; return MODULE })\n\nexport const CHUNK_NAMES = {\n previewRoot: 'preview-root',\n peers: 'peers',\n};\n\ntype TemplateEntryOptions = {\n previewRootPath: string;\n peers: string | string[];\n previewModules: {\n name: string;\n entry: string;\n /** other preview modules to includes */\n include?: string[];\n }[];\n};\n\nexport function generateTemplateEntries(options: TemplateEntryOptions): BundlerEntryMap {\n const previewChunks = {};\n options.previewModules.forEach(({ name, entry, include = [] }) => {\n previewChunks[name] = {\n dependOn: [CHUNK_NAMES.peers, CHUNK_NAMES.previewRoot, ...include],\n import: entry,\n };\n });\n\n return {\n [CHUNK_NAMES.peers]: options.peers,\n [CHUNK_NAMES.previewRoot]: {\n dependOn: [CHUNK_NAMES.peers],\n import: options.previewRootPath,\n },\n ...previewChunks,\n };\n}\n"],"mappings":";;;;;;;;;;;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEO,MAAMA,WAAW,GAAAC,OAAA,CAAAD,WAAA,GAAG;EACzBE,WAAW,EAAE,cAAc;EAC3BC,KAAK,EAAE;AACT,CAAC;AAaM,SAASC,uBAAuBA,CAACC,OAA6B,EAAmB;EACtF,MAAMC,aAAa,GAAG,CAAC,CAAC;EACxBD,OAAO,CAACE,cAAc,CAACC,OAAO,CAAC,CAAC;IAAEC,IAAI;IAAEC,KAAK;IAAEC,OAAO,GAAG;EAAG,CAAC,KAAK;IAChEL,aAAa,CAACG,IAAI,CAAC,GAAG;MACpBG,QAAQ,EAAE,CAACZ,WAAW,CAACG,KAAK,EAAEH,WAAW,CAACE,WAAW,EAAE,GAAGS,OAAO,CAAC;MAClEE,MAAM,EAAEH;IACV,CAAC;EACH,CAAC,CAAC;EAEF,OAAAI,aAAA;IACE,CAACd,WAAW,CAACG,KAAK,GAAGE,OAAO,CAACF,KAAK;IAClC,CAACH,WAAW,CAACE,WAAW,GAAG;MACzBU,QAAQ,EAAE,CAACZ,WAAW,CAACG,KAAK,CAAC;MAC7BU,MAAM,EAAER,OAAO,CAACU;IAClB;EAAC,GACET,aAAa;AAEpB","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["_chai","data","require","_createPeersLink","guardSnapshot","snapshot","describe","it","result","generatePeerLink","expect","to","equal"],"sources":["create-peer-link.spec.ts"],"sourcesContent":["import { expect } from 'chai';\nimport { generatePeerLink } from './create-peers-link';\n\nconst guardSnapshot = `function guard(property, expected) {\n var existing = globalObj[property];\n\n if (existing === expected && expected !== undefined)\n console.warn('[expose-peers] \"' + property + '\" already exists in global scope, but with correct value');\n else if (existing !== undefined)\n throw new Error('[expose-peers] \"' + property + '\" already exists in the global scope, cannot overwrite');\n}`;\n\nconst snapshot = `// @ts-nocheck\nimport * as FooBar from \"foo-bar\";\nimport * as BuzQux from \"@buz/qux\";\n\nconst globalObj = window;\n\nguard(\"FooBar\", FooBar);\nguard(\"BuzQux\", BuzQux);\n\nglobalObj[\"FooBar\"] = FooBar;\nglobalObj[\"BuzQux\"] = BuzQux;\n\n${guardSnapshot}\n`;\n\ndescribe('peers link', () => {\n it('should output snapshot', () => {\n const result = generatePeerLink(['foo-bar', '@buz/qux']);\n\n expect(result).to.equal(snapshot);\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,iBAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,gBAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,MAAMG,aAAa,GAAI;AACvB;AACA;AACA;AACA;AACA;AACA;AACA,EAAE;AAEF,MAAMC,QAAQ,GAAI;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAED,aAAc;AAChB,CAAC;AAEDE,QAAQ,CAAC,YAAY,EAAE,MAAM;EAC3BC,EAAE,CAAC,wBAAwB,EAAE,MAAM;IACjC,MAAMC,MAAM,GAAG,IAAAC,mCAAgB,EAAC,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;IAExD,IAAAC,cAAM,EAACF,MAAM,CAAC,CAACG,EAAE,CAACC,KAAK,CAACP,QAAQ,CAAC;EACnC,CAAC,CAAC;AACJ,CAAC,CAAC"}
1
+ {"version":3,"names":["_chai","data","require","_createPeersLink","guardSnapshot","snapshot","describe","it","result","generatePeerLink","expect","to","equal"],"sources":["create-peer-link.spec.ts"],"sourcesContent":["import { expect } from 'chai';\nimport { generatePeerLink } from './create-peers-link';\n\nconst guardSnapshot = `function guard(property, expected) {\n var existing = globalObj[property];\n\n if (existing === expected && expected !== undefined)\n console.warn('[expose-peers] \"' + property + '\" already exists in global scope, but with correct value');\n else if (existing !== undefined)\n throw new Error('[expose-peers] \"' + property + '\" already exists in the global scope, cannot overwrite');\n}`;\n\nconst snapshot = `// @ts-nocheck\nimport * as FooBar from \"foo-bar\";\nimport * as BuzQux from \"@buz/qux\";\n\nconst globalObj = window;\n\nguard(\"FooBar\", FooBar);\nguard(\"BuzQux\", BuzQux);\n\nglobalObj[\"FooBar\"] = FooBar;\nglobalObj[\"BuzQux\"] = BuzQux;\n\n${guardSnapshot}\n`;\n\ndescribe('peers link', () => {\n it('should output snapshot', () => {\n const result = generatePeerLink(['foo-bar', '@buz/qux']);\n\n expect(result).to.equal(snapshot);\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,iBAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,gBAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,MAAMG,aAAa,GAAI;AACvB;AACA;AACA;AACA;AACA;AACA;AACA,EAAE;AAEF,MAAMC,QAAQ,GAAI;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAED,aAAc;AAChB,CAAC;AAEDE,QAAQ,CAAC,YAAY,EAAE,MAAM;EAC3BC,EAAE,CAAC,wBAAwB,EAAE,MAAM;IACjC,MAAMC,MAAM,GAAG,IAAAC,mCAAgB,EAAC,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;IAExD,IAAAC,cAAM,EAACF,MAAM,CAAC,CAACG,EAAE,CAACC,KAAK,CAACP,QAAQ,CAAC;EACnC,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["_path","data","require","_fsExtra","_camelcase","_interopRequireDefault","_objectHash","obj","__esModule","default","writePeerLink","peers","workdir","content","generatePeerLink","fullpath","join","hash","writeFile","links","map","p","packageName","varName","toVarName","x","localName","camelcase","replace","pascalCase"],"sources":["create-peers-link.ts"],"sourcesContent":["import { join } from 'path';\nimport { writeFile } from 'fs-extra';\nimport camelcase from 'camelcase';\nimport hash from 'object-hash';\n\nexport async function writePeerLink(peers: string[], workdir: string) {\n const content = generatePeerLink(peers);\n const fullpath = join(workdir, `peers-link.${hash(content)}.js`);\n\n await writeFile(fullpath, content);\n\n return fullpath;\n}\n\n// TODO - this exposes the packages in the \"window\" strategy,\n// should use a better strategy like umd, systemjs, or jsonp\n\nexport function generatePeerLink(peers: string[]) {\n if (!peers) return '';\n\n const links = peers.map((p) => ({\n packageName: p,\n varName: toVarName(p),\n }));\n\n return `// @ts-nocheck\n${links.map((x) => `import * as ${x.varName} from \"${x.packageName}\"`).join(';\\n')};\n\nconst globalObj = window;\n\n${links.map(({ varName: localName }) => `guard(\"${localName}\", ${localName})`).join(';\\n')};\n\n${links.map((x) => `globalObj[\"${x.varName}\"] = ${x.varName}`).join(';\\n')};\n\nfunction guard(property, expected) {\n var existing = globalObj[property];\n\n if (existing === expected && expected !== undefined)\n console.warn('[expose-peers] \"' + property + '\" already exists in global scope, but with correct value');\n else if (existing !== undefined)\n throw new Error('[expose-peers] \"' + property + '\" already exists in the global scope, cannot overwrite');\n}\n`;\n}\n\nfunction toVarName(packageName: string) {\n return camelcase(packageName.replace('@', '__').replace('/', '_'), { pascalCase: true });\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,WAAA;EAAA,MAAAH,IAAA,GAAAI,sBAAA,CAAAH,OAAA;EAAAE,U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CAAC,IAAM,cAAaA,CAAC,CAACF,OAAQ,QAAOE,CAAC,CAACF,OAAQ,EAAC,CAAC,CAACP,IAAI,CAAC,KAAK,CAAE;AAC3E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD;AAEA,SAASQ,SAASA,CAACF,WAAmB,EAAE;EACtC,OAAO,IAAAK,oBAAS,EAACL,WAAW,CAACM,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC,CAACA,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE;IAAEC,UAAU,EAAE;EAAK,CAAC,CAAC;AAC1F"}
1
+ {"version":3,"names":["_path","data","require","_fsExtra","_camelcase","_interopRequireDefault","_objectHash","obj","__esModule","default","writePeerLink","peers","workdir","content","generatePeerLink","fullpath","join","hash","writeFile","links","map","p","packageName","varName","toVarName","x","localName","camelcase","replace","pascalCase"],"sources":["create-peers-link.ts"],"sourcesContent":["import { join } from 'path';\nimport { writeFile } from 'fs-extra';\nimport camelcase from 'camelcase';\nimport hash from 'object-hash';\n\nexport async function writePeerLink(peers: string[], workdir: string) {\n const content = generatePeerLink(peers);\n const fullpath = join(workdir, `peers-link.${hash(content)}.js`);\n\n await writeFile(fullpath, content);\n\n return fullpath;\n}\n\n// TODO - this exposes the packages in the \"window\" strategy,\n// should use a better strategy like umd, systemjs, or jsonp\n\nexport function generatePeerLink(peers: string[]) {\n if (!peers) return '';\n\n const links = peers.map((p) => ({\n packageName: p,\n varName: toVarName(p),\n }));\n\n return `// @ts-nocheck\n${links.map((x) => `import * as ${x.varName} from \"${x.packageName}\"`).join(';\\n')};\n\nconst globalObj = window;\n\n${links.map(({ varName: localName }) => `guard(\"${localName}\", ${localName})`).join(';\\n')};\n\n${links.map((x) => `globalObj[\"${x.varName}\"] = ${x.varName}`).join(';\\n')};\n\nfunction guard(property, expected) {\n var existing = globalObj[property];\n\n if (existing === expected && expected !== undefined)\n console.warn('[expose-peers] \"' + property + '\" already exists in global scope, but with correct value');\n else if (existing !== undefined)\n throw new Error('[expose-peers] \"' + property + '\" already exists in the global scope, cannot overwrite');\n}\n`;\n}\n\nfunction toVarName(packageName: string) {\n return camelcase(packageName.replace('@', '__').replace('/', '_'), { pascalCase: true });\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,WAAA;EAAA,MAAAH,IAAA,GAAAI,sBAAA,CAAAH,OAAA;EAAAE,UAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAK,YAAA;EAAA,MAAAL,IAAA,GAAAI,sBAAA,CAAAH,OAAA;EAAAI,WAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAA+B,SAAAI,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAExB,eAAeG,aAAaA,CAACC,KAAe,EAAEC,OAAe,EAAE;EACpE,MAAMC,OAAO,GAAGC,gBAAgB,CAACH,KAAK,CAAC;EACvC,MAAMI,QAAQ,GAAG,IAAAC,YAAI,EAACJ,OAAO,EAAG,cAAa,IAAAK,qBAAI,EAACJ,OAAO,CAAE,KAAI,CAAC;EAEhE,MAAM,IAAAK,oBAAS,EAACH,QAAQ,EAAEF,OAAO,CAAC;EAElC,OAAOE,QAAQ;AACjB;;AAEA;AACA;;AAEO,SAASD,gBAAgBA,CAACH,KAAe,EAAE;EAChD,IAAI,CAACA,KAAK,EAAE,OAAO,EAAE;EAErB,MAAMQ,KAAK,GAAGR,KAAK,CAACS,GAAG,CAAEC,CAAC,KAAM;IAC9BC,WAAW,EAAED,CAAC;IACdE,OAAO,EAAEC,SAAS,CAACH,CAAC;EACtB,CAAC,CAAC,CAAC;EAEH,OAAQ;AACV,EAAEF,KAAK,CAACC,GAAG,CAAEK,CAAC,IAAM,eAAcA,CAAC,CAACF,OAAQ,UAASE,CAAC,CAACH,WAAY,GAAE,CAAC,CAACN,IAAI,CAAC,KAAK,CAAE;AACnF;AACA;AACA;AACA,EAAEG,KAAK,CAACC,GAAG,CAAC,CAAC;IAAEG,OAAO,EAAEG;EAAU,CAAC,KAAM,UAASA,SAAU,MAAKA,SAAU,GAAE,CAAC,CAACV,IAAI,CAAC,KAAK,CAAE;AAC3F;AACA,EAAEG,KAAK,CAACC,GAAG,CAAEK,CAAC,IAAM,cAAaA,CAAC,CAACF,OAAQ,QAAOE,CAAC,CAACF,OAAQ,EAAC,CAAC,CAACP,IAAI,CAAC,KAAK,CAAE;AAC3E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD;AAEA,SAASQ,SAASA,CAACF,WAAmB,EAAE;EACtC,OAAO,IAAAK,oBAAS,EAACL,WAAW,CAACM,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC,CAACA,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE;IAAEC,UAAU,EAAE;EAAK,CAAC,CAAC;AAC1F","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["_lodash","data","_interopRequireDefault","require","_htmlTemplate","_chunks","obj","__esModule","default","generateHtmlConfig","previewDef","options","chunks","compact","includePeers","CHUNK_NAMES","peers","previewRoot","include","prefix","config","title","templateContent","html","minify","dev","filename"],"sources":["html-plugin.ts"],"sourcesContent":["import compact from 'lodash.compact';\nimport type { BundlerHtmlConfig } from '@teambit/bundler';\nimport { PreviewDefinition } from '../preview-definition';\nimport { html } from './html-template';\n\nimport { CHUNK_NAMES } from './chunks';\n\nexport function generateHtmlConfig(previewDef: PreviewDefinition, options: { dev?: boolean }) {\n const chunks = compact([\n previewDef.includePeers && CHUNK_NAMES.peers,\n CHUNK_NAMES.previewRoot,\n ...(previewDef.include || []),\n previewDef.prefix,\n ]);\n\n const config: BundlerHtmlConfig = {\n title: 'Preview',\n templateContent: html('Preview'),\n minify: options?.dev ?? true,\n chunks,\n filename: `${previewDef.prefix}.html`,\n };\n return config;\n}\n"],"mappings":";;;;;;AAAA,SAAAA,QAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,OAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAGA,SAAAG,cAAA;EAAA,MAAAH,IAAA,GAAAE,OAAA;EAAAC,aAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAI,QAAA;EAAA,MAAAJ,IAAA,GAAAE,OAAA;EAAAE,OAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAAuC,SAAAC,uBAAAI,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAEhC,SAASG,kBAAkBA,CAACC,UAA6B,EAAEC,OAA0B,EAAE;EAC5F,MAAMC,MAAM,GAAG,IAAAC,iBAAO,EAAC,CACrBH,UAAU,CAACI,YAAY,IAAIC,qBAAW,CAACC,KAAK,EAC5CD,qBAAW,CAACE,WAAW,EACvB,IAAIP,UAAU,CAACQ,OAAO,IAAI,EAAE,CAAC,EAC7BR,UAAU,CAACS,MAAM,CAClB,CAAC;EAEF,MAAMC,MAAyB,GAAG;IAChCC,KAAK,EAAE,SAAS;IAChBC,eAAe,EAAE,IAAAC,oBAAI,EAAC,SAAS,CAAC;IAChCC,MAAM,EAAEb,OAAO,EAAEc,GAAG,IAAI,IAAI;IAC5Bb,MAAM;IACNc,QAAQ,EAAG,GAAEhB,UAAU,CAACS,MAAO;EACjC,CAAC;EACD,OAAOC,MAAM;AACf"}
1
+ {"version":3,"names":["_lodash","data","_interopRequireDefault","require","_htmlTemplate","_chunks","obj","__esModule","default","generateHtmlConfig","previewDef","options","chunks","compact","includePeers","CHUNK_NAMES","peers","previewRoot","include","prefix","config","title","templateContent","html","minify","dev","filename"],"sources":["html-plugin.ts"],"sourcesContent":["import compact from 'lodash.compact';\nimport type { BundlerHtmlConfig } from '@teambit/bundler';\nimport { PreviewDefinition } from '../preview-definition';\nimport { html } from './html-template';\n\nimport { CHUNK_NAMES } from './chunks';\n\nexport function generateHtmlConfig(previewDef: PreviewDefinition, options: { dev?: boolean }) {\n const chunks = compact([\n previewDef.includePeers && CHUNK_NAMES.peers,\n CHUNK_NAMES.previewRoot,\n ...(previewDef.include || []),\n previewDef.prefix,\n ]);\n\n const config: BundlerHtmlConfig = {\n title: 'Preview',\n templateContent: html('Preview'),\n minify: options?.dev ?? true,\n chunks,\n filename: `${previewDef.prefix}.html`,\n };\n return config;\n}\n"],"mappings":";;;;;;AAAA,SAAAA,QAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,OAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAGA,SAAAG,cAAA;EAAA,MAAAH,IAAA,GAAAE,OAAA;EAAAC,aAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAI,QAAA;EAAA,MAAAJ,IAAA,GAAAE,OAAA;EAAAE,OAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAAuC,SAAAC,uBAAAI,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAEhC,SAASG,kBAAkBA,CAACC,UAA6B,EAAEC,OAA0B,EAAE;EAC5F,MAAMC,MAAM,GAAG,IAAAC,iBAAO,EAAC,CACrBH,UAAU,CAACI,YAAY,IAAIC,qBAAW,CAACC,KAAK,EAC5CD,qBAAW,CAACE,WAAW,EACvB,IAAIP,UAAU,CAACQ,OAAO,IAAI,EAAE,CAAC,EAC7BR,UAAU,CAACS,MAAM,CAClB,CAAC;EAEF,MAAMC,MAAyB,GAAG;IAChCC,KAAK,EAAE,SAAS;IAChBC,eAAe,EAAE,IAAAC,oBAAI,EAAC,SAAS,CAAC;IAChCC,MAAM,EAAEb,OAAO,EAAEc,GAAG,IAAI,IAAI;IAC5Bb,MAAM;IACNc,QAAQ,EAAG,GAAEhB,UAAU,CAACS,MAAO;EACjC,CAAC;EACD,OAAOC,MAAM;AACf","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["html","title"],"sources":["html-template.ts"],"sourcesContent":["/** html template for Previews (docs, compositions, etc) */\nexport function html(title: string) {\n return `\n <!DOCTYPE html>\n <html lang=\"en\">\n <head>\n <meta charset=\"utf-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n <title>${title}</title>\n <script>\n // Allow to use react dev-tools inside the examples\n try { window.__REACT_DEVTOOLS_GLOBAL_HOOK__ = window.parent.__REACT_DEVTOOLS_GLOBAL_HOOK__; } catch {}\n </script>\n <style> body { margin: 0; } </style>\n </head>\n <body>\n <div id=\"root\"></div>\n </body>\n </html>\n `;\n}\n"],"mappings":";;;;;;AAAA;AACO,SAASA,IAAIA,CAACC,KAAa,EAAE;EAClC,OAAQ;AACV;AACA;AACA;AACA;AACA;AACA,eAAeA,KAAM;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH"}
1
+ {"version":3,"names":["html","title"],"sources":["html-template.ts"],"sourcesContent":["/** html template for Previews (docs, compositions, etc) */\nexport function html(title: string) {\n return `\n <!DOCTYPE html>\n <html lang=\"en\">\n <head>\n <meta charset=\"utf-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n <title>${title}</title>\n <script>\n // Allow to use react dev-tools inside the examples\n try { window.__REACT_DEVTOOLS_GLOBAL_HOOK__ = window.parent.__REACT_DEVTOOLS_GLOBAL_HOOK__; } catch {}\n </script>\n <style> body { margin: 0; } </style>\n </head>\n <body>\n <div id=\"root\"></div>\n </body>\n </html>\n `;\n}\n"],"mappings":";;;;;;AAAA;AACO,SAASA,IAAIA,CAACC,KAAa,EAAE;EAClC,OAAQ;AACV;AACA;AACA;AACA;AACA;AACA,eAAeA,KAAM;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["bundling-strategy.ts"],"sourcesContent":["import { BuildContext, BuiltTaskResult } from '@teambit/builder';\nimport { Target, BundlerResult, BundlerContext } from '@teambit/bundler';\nimport { PreviewDefinition } from './preview-definition';\nimport { PreviewTask } from './preview.task';\n\ntype ComputeTargetsExtraContextKeys = {\n splitComponentBundle?: boolean;\n};\n\nexport type ComputeTargetsContext = BuildContext & ComputeTargetsExtraContextKeys;\nexport interface BundlingStrategy {\n /**\n * name of the bundling strategy.\n */\n name: string;\n\n /**\n * compute bundling targets for the build context.\n */\n computeTargets(\n context: ComputeTargetsContext,\n previewDefs: PreviewDefinition[],\n previewTask: PreviewTask\n ): Promise<Target[]>;\n\n /**\n * compute the results of the bundler.\n */\n computeResults(context: BundlerContext, results: BundlerResult[], previewTask: PreviewTask): Promise<BuiltTaskResult>;\n}\n"],"mappings":""}
1
+ {"version":3,"names":[],"sources":["bundling-strategy.ts"],"sourcesContent":["import { BuildContext, BuiltTaskResult } from '@teambit/builder';\nimport { Target, BundlerResult, BundlerContext } from '@teambit/bundler';\nimport { PreviewDefinition } from './preview-definition';\nimport { PreviewTask } from './preview.task';\n\ntype ComputeTargetsExtraContextKeys = {\n splitComponentBundle?: boolean;\n};\n\nexport type ComputeTargetsContext = BuildContext & ComputeTargetsExtraContextKeys;\nexport interface BundlingStrategy {\n /**\n * name of the bundling strategy.\n */\n name: string;\n\n /**\n * compute bundling targets for the build context.\n */\n computeTargets(\n context: ComputeTargetsContext,\n previewDefs: PreviewDefinition[],\n previewTask: PreviewTask\n ): Promise<Target[]>;\n\n /**\n * compute the results of the bundler.\n */\n computeResults(context: BundlerContext, results: BundlerResult[], previewTask: PreviewTask): Promise<BuiltTaskResult>;\n}\n"],"mappings":"","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["_previewUi","data","require"],"sources":["component-preview.ts"],"sourcesContent":["import { ComponentPreview } from '@teambit/preview.ui.component-preview';\n\nexport { ComponentPreview };\n"],"mappings":";;;;;;;;;;;AAAA,SAAAA,WAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,UAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA"}
1
+ {"version":3,"names":["_previewUi","data","require"],"sources":["component-preview.ts"],"sourcesContent":["import { ComponentPreview } from '@teambit/preview.ui.component-preview';\n\nexport { ComponentPreview };\n"],"mappings":";;;;;;;;;;;AAAA,SAAAA,WAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,UAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA","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","ComponentPreviewRoute","constructor","preview","logger","req","res","next","isLegacyPath","component","status","send","noPreview","artifact","getPreview","error","serverError","getArtifactFileMiddleware","exports"],"sources":["component-preview.route.ts"],"sourcesContent":["import type { NextFunction, Request, Response, Route } from '@teambit/express';\nimport type { Component } from '@teambit/component';\nimport { noPreview, serverError } from '@teambit/ui-foundation.ui.pages.static-error';\nimport type { Logger } from '@teambit/logger';\n\nimport { PreviewMain } from './preview.main.runtime';\nimport type { PreviewArtifact } from './preview-artifact';\nimport type { PreviewUrlParams } from './artifact-file-middleware';\nimport { getArtifactFileMiddleware } from './artifact-file-middleware';\n\nexport class ComponentPreviewRoute implements Route {\n constructor(\n /**\n * preview extension.\n */\n private preview: PreviewMain,\n private logger: Logger\n ) {}\n\n route = `/component-preview/:filePath(*)`;\n method = 'get';\n\n middlewares = [\n async (req: Request<PreviewUrlParams>, res: Response, next: NextFunction) => {\n try {\n let isLegacyPath = false;\n // @ts-ignore TODO: @guy please fix.\n const component = req.component as Component | undefined;\n if (!component) return res.status(404).send(noPreview());\n\n let artifact: PreviewArtifact | undefined;\n // TODO - prevent error `getVinylsAndImportIfMissing is not a function` #4680\n try {\n isLegacyPath = true;\n artifact = await this.preview.getPreview(component);\n } catch (e: any) {\n this.logger.error(`preview.getPreview has failed`, e);\n return res.status(404).send(noPreview());\n }\n // @ts-ignore\n req.artifact = artifact;\n // @ts-ignore\n req.isLegacyPath = isLegacyPath;\n return next();\n } catch (e: any) {\n this.logger.error('failed getting preview', e);\n return res.status(500).send(serverError());\n }\n },\n getArtifactFileMiddleware(this.logger),\n ];\n}\n"],"mappings":";;;;;;AAEA,SAAAA,qBAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,oBAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAMA,SAAAE,wBAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,uBAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAAuE,SAAAG,gBAAAC,GAAA,EAAAC,GAAA,EAAAC,KAAA,IAAAD,GAAA,GAAAE,cAAA,CAAAF,GAAA,OAAAA,GAAA,IAAAD,GAAA,IAAAI,MAAA,CAAAC,cAAA,CAAAL,GAAA,EAAAC,GAAA,IAAAC,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ACf,IAAI,CAACS,MAAM,CAACW,KAAK,CAAE,+BAA8B,EAAEpB,CAAC,CAAC;UACrD,OAAOW,GAAG,CAACI,MAAM,CAAC,GAAG,CAAC,CAACC,IAAI,CAAC,IAAAC,gCAAS,EAAC,CAAC,CAAC;QAC1C;QACA;QACAP,GAAG,CAACQ,QAAQ,GAAGA,QAAQ;QACvB;QACAR,GAAG,CAACG,YAAY,GAAGA,YAAY;QAC/B,OAAOD,IAAI,CAAC,CAAC;MACf,CAAC,CAAC,OAAOZ,CAAM,EAAE;QACf,IAAI,CAACS,MAAM,CAACW,KAAK,CAAC,wBAAwB,EAAEpB,CAAC,CAAC;QAC9C,OAAOW,GAAG,CAACI,MAAM,CAAC,GAAG,CAAC,CAACC,IAAI,CAAC,IAAAK,kCAAW,EAAC,CAAC,CAAC;MAC5C;IACF,CAAC,EACD,IAAAC,mDAAyB,EAAC,IAAI,CAACb,MAAM,CAAC,CACvC;EAjCE;AAkCL;AAACc,OAAA,CAAAjB,qBAAA,GAAAA,qBAAA"}
1
+ {"version":3,"names":["_uiFoundationUiPages","data","require","_artifactFileMiddleware","_defineProperty","obj","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","t","i","_toPrimitive","String","r","e","Symbol","toPrimitive","call","TypeError","Number","ComponentPreviewRoute","constructor","preview","logger","req","res","next","isLegacyPath","component","status","send","noPreview","artifact","getPreview","error","serverError","getArtifactFileMiddleware","exports"],"sources":["component-preview.route.ts"],"sourcesContent":["import type { NextFunction, Request, Response, Route } from '@teambit/express';\nimport type { Component } from '@teambit/component';\nimport { noPreview, serverError } from '@teambit/ui-foundation.ui.pages.static-error';\nimport type { Logger } from '@teambit/logger';\n\nimport { PreviewMain } from './preview.main.runtime';\nimport type { PreviewArtifact } from './preview-artifact';\nimport type { PreviewUrlParams } from './artifact-file-middleware';\nimport { getArtifactFileMiddleware } from './artifact-file-middleware';\n\nexport class ComponentPreviewRoute implements Route {\n constructor(\n /**\n * preview extension.\n */\n private preview: PreviewMain,\n private logger: Logger\n ) {}\n\n route = `/component-preview/:filePath(*)`;\n method = 'get';\n\n middlewares = [\n async (req: Request<PreviewUrlParams>, res: Response, next: NextFunction) => {\n try {\n let isLegacyPath = false;\n // @ts-ignore TODO: @guy please fix.\n const component = req.component as Component | undefined;\n if (!component) return res.status(404).send(noPreview());\n\n let artifact: PreviewArtifact | undefined;\n // TODO - prevent error `getVinylsAndImportIfMissing is not a function` #4680\n try {\n isLegacyPath = true;\n artifact = await this.preview.getPreview(component);\n } catch (e: any) {\n this.logger.error(`preview.getPreview has failed`, e);\n return res.status(404).send(noPreview());\n }\n // @ts-ignore\n req.artifact = artifact;\n // @ts-ignore\n req.isLegacyPath = isLegacyPath;\n return next();\n } catch (e: any) {\n this.logger.error('failed getting preview', e);\n return res.status(500).send(serverError());\n }\n },\n getArtifactFileMiddleware(this.logger),\n ];\n}\n"],"mappings":";;;;;;AAEA,SAAAA,qBAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,oBAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAMA,SAAAE,wBAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,uBAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAAuE,SAAAG,gBAAAC,GAAA,EAAAC,GAAA,EAAAC,KAAA,IAAAD,GAAA,GAAAE,cAAA,CAAAF,GAAA,OAAAA,GAAA,IAAAD,GAAA,IAAAI,MAAA,CAAAC,cAAA,CAAAL,GAAA,EAAAC,GAAA,IAAAC,KAAA,EAAAA,KAAA,EAAAI,UAAA,QAAAC,YAAA,QAAAC,QAAA,oBAAAR,GAAA,CAAAC,GAAA,IAAAC,KAAA,WAAAF,GAAA;AAAA,SAAAG,eAAAM,CAAA,QAAAC,CAAA,GAAAC,YAAA,CAAAF,CAAA,uCAAAC,CAAA,GAAAA,CAAA,GAAAE,MAAA,CAAAF,CAA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R,GAAG,CAACG,YAAY,GAAGA,YAAY;QAC/B,OAAOD,IAAI,CAAC,CAAC;MACf,CAAC,CAAC,OAAOZ,CAAM,EAAE;QACf,IAAI,CAACS,MAAM,CAACW,KAAK,CAAC,wBAAwB,EAAEpB,CAAC,CAAC;QAC9C,OAAOW,GAAG,CAACI,MAAM,CAAC,GAAG,CAAC,CAACC,IAAI,CAAC,IAAAK,kCAAW,EAAC,CAAC,CAAC;MAC5C;IACF,CAAC,EACD,IAAAC,mDAAyB,EAAC,IAAI,CAACb,MAAM,CAAC,CACvC;EAjCE;AAkCL;AAACc,OAAA,CAAAjB,qBAAA,GAAAA,qBAAA","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["_builder","data","require","_cli","_pMapSeries","_interopRequireDefault","_component","_path","_lodash","_fsExtra","_chunks","_htmlPlugin","_createPeersLink","_excluded","obj","__esModule","default","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","_objectWithoutProperties","source","excluded","target","_objectWithoutPropertiesLoose","key","i","sourceSymbolKeys","indexOf","prototype","propertyIsEnumerable","call","sourceKeys","value","_toPropertyKey","configurable","writable","_toPrimitive","String","Symbol","toPrimitive","TypeError","Number","GENERATE_ENV_TEMPLATE_TASK_NAME","exports","EnvPreviewTemplateTask","constructor","preview","envs","aspectLoader","dependencyResolver","logger","execute","context","previewDefs","getDefs","htmlConfig","map","previewModule","generateHtmlConfig","dev","originalSeedersIds","capsuleNetwork","originalSeedersCapsules","c","component","id","toString","grouped","mapSeries","components","includes","undefined","envDef","getEnvFromComponent","env","bundlingStrategy","getBundlingStrategy","name","getEnvTargetFromComponent","shouldUseDefaultBundler","envToGetBundler","getEnvsEnvDefinition","groupEnvId","targets","isEmpty","componentsResults","runBundlerForGroups","groups","bundlerContext","assign","entry","development","metaData","initiator","envId","isEnvTemplate","bundlerResults","entries","targetsGroup","bundler","getTemplateBundler","bundlerResult","run","results","computeResults","flatten","isCoreEnv","envComponent","envPreviewConfig","getEnvPreviewConfig","peers","getPreviewHostDependenciesFromEnv","capsule","graphCapsules","getCapsule","Error","previewRoot","writePreviewRuntime","generateEntries","splitComponentBundle","workDir","path","outputPath","computeOutputPath","existsSync","mkdirpSync","resolvedEnvAspects","resolveAspects","MainRuntime","requestedOnly","filterByRuntime","resolvedEnv","hostRootDir","aspectPath","warn","html","chunking","splitChunks","hostDependencies","aliasHostDependencies","previewModules","getPreviewModules","previewEntries","_ref","rest","linkFile","writeLink","ComponentMap","create","peerLink","writePeerLink","generateTemplateEntries","previewRootPath","allResults","result","errors","err","message","warning","warnings","startTime","endTime","artifacts","getArtifactDef","modules","compact","Promise","all","def","renderTemplatePathByEnv","prefix","include","join","getArtifactDirectory","CAPSULE_ARTIFACTS_DIR","globPatterns","rootDir"],"sources":["env-preview-template.task.ts"],"sourcesContent":["import {\n BuildContext,\n BuiltTaskResult,\n BuildTask,\n TaskLocation,\n ComponentResult,\n CAPSULE_ARTIFACTS_DIR,\n} from '@teambit/builder';\nimport { MainRuntime } from '@teambit/cli';\nimport mapSeries from 'p-map-series';\nimport { Component, ComponentMap } from '@teambit/component';\nimport { AspectLoaderMain } from '@teambit/aspect-loader';\nimport { Bundler, BundlerContext, BundlerHtmlConfig, BundlerResult, Target } from '@teambit/bundler';\nimport type { EnvDefinition, Environment, EnvsMain } from '@teambit/envs';\nimport { join } from 'path';\nimport { compact, flatten, isEmpty } from 'lodash';\nimport { Logger } from '@teambit/logger';\nimport { DependencyResolverMain } from '@teambit/dependency-resolver';\nimport { existsSync, mkdirpSync } from 'fs-extra';\nimport type { PreviewMain } from './preview.main.runtime';\nimport { generateTemplateEntries } from './bundler/chunks';\nimport { generateHtmlConfig } from './bundler/html-plugin';\nimport { writePeerLink } from './bundler/create-peers-link';\n\nexport type ModuleExpose = {\n name: string;\n path: string;\n include?: string[];\n};\n\ntype TargetsGroup = {\n env: Environment;\n envToGetBundler: Environment;\n targets: Target[];\n};\ntype TargetsGroupMap = {\n [envId: string]: TargetsGroup;\n};\n\nexport const GENERATE_ENV_TEMPLATE_TASK_NAME = 'GenerateEnvTemplate';\n\nexport class EnvPreviewTemplateTask implements BuildTask {\n aspectId = 'teambit.preview/preview';\n name = GENERATE_ENV_TEMPLATE_TASK_NAME;\n location: TaskLocation = 'end';\n // readonly dependencies = [CompilerAspect.id];\n\n constructor(\n private preview: PreviewMain,\n private envs: EnvsMain,\n private aspectLoader: AspectLoaderMain,\n private dependencyResolver: DependencyResolverMain,\n private logger: Logger\n ) {}\n\n async execute(context: BuildContext): Promise<BuiltTaskResult> {\n const previewDefs = this.preview.getDefs();\n const htmlConfig = previewDefs.map((previewModule) => generateHtmlConfig(previewModule, { dev: context.dev }));\n const originalSeedersIds = context.capsuleNetwork.originalSeedersCapsules.map((c) => c.component.id.toString());\n const grouped: TargetsGroupMap = {};\n // avoid running them with `Promise.all` because getEnv methods do import/isolate which can't be in parallel.\n await mapSeries(context.components, async (component) => {\n // Do not run over other components in the graph. it make the process much longer with no need\n if (originalSeedersIds && originalSeedersIds.length && !originalSeedersIds.includes(component.id.toString())) {\n return undefined;\n }\n const envDef = this.envs.getEnvFromComponent(component);\n if (!envDef) return undefined;\n const env = envDef.env;\n const bundlingStrategy = this.preview.getBundlingStrategy(envDef.env);\n if (bundlingStrategy.name === 'env') {\n return undefined;\n }\n const target = await this.getEnvTargetFromComponent(context, component, envDef, htmlConfig);\n if (!target) return undefined;\n const shouldUseDefaultBundler = this.shouldUseDefaultBundler(envDef);\n let envToGetBundler = this.envs.getEnvsEnvDefinition().env;\n let groupEnvId = 'default';\n if (!shouldUseDefaultBundler) {\n envToGetBundler = env;\n groupEnvId = envDef.id;\n }\n if (!grouped[groupEnvId]) {\n grouped[groupEnvId] = {\n env,\n envToGetBundler,\n targets: [target],\n };\n } else {\n grouped[groupEnvId].targets.push(target);\n }\n return undefined;\n });\n if (isEmpty(grouped)) {\n return { componentsResults: [] };\n }\n\n return this.runBundlerForGroups(context, grouped);\n }\n\n private async runBundlerForGroups(context: BuildContext, groups: TargetsGroupMap): Promise<BuiltTaskResult> {\n const bundlerContext: BundlerContext = Object.assign(context, {\n targets: [],\n entry: [],\n development: context.dev,\n metaData: {\n initiator: `${GENERATE_ENV_TEMPLATE_TASK_NAME} task`,\n envId: context.id,\n isEnvTemplate: true,\n },\n });\n\n const bundlerResults = await mapSeries(Object.entries(groups), async ([, targetsGroup]) => {\n bundlerContext.targets = targetsGroup.targets;\n const bundler: Bundler = await targetsGroup.envToGetBundler.getTemplateBundler(bundlerContext);\n const bundlerResult = await bundler.run();\n return bundlerResult;\n });\n\n const results = await this.computeResults(bundlerContext, flatten(bundlerResults));\n return results;\n }\n\n private shouldUseDefaultBundler(envDef: EnvDefinition): boolean {\n if (this.aspectLoader.isCoreEnv(envDef.id) && envDef.id !== 'teambit.react/react-native') return true;\n const env = envDef.env;\n if (env.getTemplateBundler && typeof env.getTemplateBundler === 'function') return false;\n return true;\n }\n\n private async getEnvTargetFromComponent(\n context: BuildContext,\n envComponent: Component,\n envDef: EnvDefinition,\n htmlConfig: BundlerHtmlConfig[]\n ): Promise<Target | undefined> {\n const envPreviewConfig = this.preview.getEnvPreviewConfig(envDef.env);\n\n const peers = await this.dependencyResolver.getPreviewHostDependenciesFromEnv(envDef.env);\n // const module = await this.getPreviewModule(envComponent);\n // const entries = Object.keys(module).map((key) => module.exposes[key]);\n const capsule = context.capsuleNetwork.graphCapsules.getCapsule(envComponent.id);\n if (!capsule) throw new Error('no capsule found');\n // Passing here the env itself to make sure it's preview runtime will be part of the preview root file\n // that's needed to make sure the providers register there are running correctly\n const previewRoot = await this.preview.writePreviewRuntime(context, [envComponent.id.toString()]);\n const entries = await this.generateEntries({\n envDef,\n splitComponentBundle: envPreviewConfig.splitComponentBundle ?? false,\n workDir: capsule.path,\n peers,\n previewRoot,\n });\n const outputPath = this.computeOutputPath(context, envComponent);\n if (!existsSync(outputPath)) mkdirpSync(outputPath);\n const resolvedEnvAspects = await this.preview.resolveAspects(MainRuntime.name, [envComponent.id], undefined, {\n requestedOnly: true,\n // required to support envs that are plguins (.bit-env files)\n filterByRuntime: false,\n });\n const resolvedEnv = resolvedEnvAspects[0];\n const hostRootDir = resolvedEnv?.aspectPath;\n\n if (!hostRootDir) {\n this.logger.warn(`env preview template task, hostRootDir is not defined, for env ${envComponent.id.toString()}`);\n }\n\n return {\n peers,\n html: htmlConfig,\n entries,\n chunking: { splitChunks: true },\n components: [envComponent],\n outputPath,\n /* It's a path to the root of the host component. */\n hostRootDir,\n hostDependencies: peers,\n aliasHostDependencies: true,\n };\n }\n\n private async generateEntries({\n previewRoot,\n workDir,\n peers,\n envDef,\n splitComponentBundle,\n }: {\n previewRoot: string;\n workDir: string;\n peers: string[];\n envDef: EnvDefinition;\n splitComponentBundle: boolean;\n }) {\n const previewModules = await this.getPreviewModules(envDef);\n const previewEntries = previewModules.map(({ name, path, ...rest }) => {\n const linkFile = this.preview.writeLink(\n name,\n ComponentMap.create([]),\n { default: path },\n workDir,\n splitComponentBundle\n );\n\n return { name, path, ...rest, entry: linkFile };\n });\n const peerLink = await writePeerLink(peers, workDir);\n\n const entries = generateTemplateEntries({\n peers: peerLink,\n previewRootPath: previewRoot,\n previewModules: previewEntries,\n });\n return entries;\n }\n\n async computeResults(context: BundlerContext, results: BundlerResult[]) {\n const allResults = results.map((result) => {\n const componentsResults: ComponentResult[] = result.components.map((component) => {\n return {\n component,\n errors: result.errors.map((err) => (typeof err === 'string' ? err : err.message)),\n warning: result.warnings,\n startTime: result.startTime,\n endTime: result.endTime,\n };\n });\n return componentsResults;\n });\n\n const componentsResults = flatten(allResults);\n\n const artifacts = getArtifactDef();\n\n return {\n componentsResults,\n artifacts,\n };\n }\n\n private async getPreviewModules(envDef: EnvDefinition): Promise<ModuleExpose[]> {\n const previewDefs = this.preview.getDefs();\n\n const modules = compact(\n await Promise.all(\n previewDefs.map(async (def) => {\n if (!def.renderTemplatePathByEnv) return undefined;\n return {\n name: def.prefix,\n path: (await def.renderTemplatePathByEnv(envDef.env)) || '',\n include: def.include,\n };\n })\n )\n );\n\n return modules;\n }\n\n private computeOutputPath(context: BuildContext, component: Component) {\n const capsule = context.capsuleNetwork.graphCapsules.getCapsule(component.id);\n if (!capsule) throw new Error('no capsule found');\n return join(capsule.path, getArtifactDirectory());\n }\n}\n\nexport function getArtifactDirectory() {\n return join(CAPSULE_ARTIFACTS_DIR, 'env-template');\n}\n\nexport function getArtifactDef() {\n return [\n {\n name: 'env-template',\n globPatterns: ['**'],\n rootDir: getArtifactDirectory(),\n },\n ];\n}\n"],"mappings":";;;;;;;;AAAA,SAAAA,SAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,QAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAQA,SAAAE,KAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,IAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,YAAA;EAAA,MAAAH,IAAA,GAAAI,sBAAA,CAAAH,OAAA;EAAAE,WAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAK,WAAA;EAAA,MAAAL,IAAA,GAAAC,OAAA;EAAAI,UAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAIA,SAAAM,MAAA;EAAA,MAAAN,IAAA,GAAAC,OAAA;EAAAK,KAAA,YAAAA,CAAA;IAAA,OAAAN,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAO,QAAA;EAAA,MAAAP,IAAA,GAAAC,OAAA;EAAAM,OAAA,YAAAA,CAAA;IAAA,OAAAP,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAGA,SAAAQ,SAAA;EAAA,MAAAR,I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,kBAAkB,CAAC;IACjD,OAAO,IAAAyD,YAAI,EAAC5D,OAAO,CAACS,IAAI,EAAEoD,oBAAoB,CAAC,CAAC,CAAC;EACnD;AACF;AAAClI,OAAA,CAAAC,sBAAA,GAAAA,sBAAA;AAEM,SAASiI,oBAAoBA,CAAA,EAAG;EACrC,OAAO,IAAAD,YAAI,EAACE,gCAAqB,EAAE,cAAc,CAAC;AACpD;AAEO,SAASX,cAAcA,CAAA,EAAG;EAC/B,OAAO,CACL;IACEtF,IAAI,EAAE,cAAc;IACpBkG,YAAY,EAAE,CAAC,IAAI,CAAC;IACpBC,OAAO,EAAEH,oBAAoB,CAAC;EAChC,CAAC,CACF;AACH"}
1
+ {"version":3,"names":["_builder","data","require","_cli","_pMapSeries","_interopRequireDefault","_component","_path","_lodash","_fsExtra","_chunks","_htmlPlugin","_createPeersLink","_excluded","obj","__esModule","default","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","_objectWithoutProperties","source","excluded","target","_objectWithoutPropertiesLoose","key","i","sourceSymbolKeys","indexOf","prototype","propertyIsEnumerable","call","sourceKeys","value","_toPropertyKey","configurable","writable","_toPrimitive","String","Symbol","toPrimitive","TypeError","Number","GENERATE_ENV_TEMPLATE_TASK_NAME","exports","EnvPreviewTemplateTask","constructor","preview","envs","aspectLoader","dependencyResolver","logger","execute","context","previewDefs","getDefs","htmlConfig","map","previewModule","generateHtmlConfig","dev","originalSeedersIds","capsuleNetwork","originalSeedersCapsules","c","component","id","toString","grouped","mapSeries","components","includes","undefined","envDef","getEnvFromComponent","env","bundlingStrategy","getBundlingStrategy","name","getEnvTargetFromComponent","shouldUseDefaultBundler","envToGetBundler","getEnvsEnvDefinition","groupEnvId","targets","isEmpty","componentsResults","runBundlerForGroups","groups","bundlerContext","assign","entry","development","metaData","initiator","envId","isEnvTemplate","bundlerResults","entries","targetsGroup","bundler","getTemplateBundler","bundlerResult","run","results","computeResults","flatten","isCoreEnv","envComponent","envPreviewConfig","getEnvPreviewConfig","peers","getPreviewHostDependenciesFromEnv","capsule","graphCapsules","getCapsule","Error","previewRoot","writePreviewRuntime","generateEntries","splitComponentBundle","workDir","path","outputPath","computeOutputPath","existsSync","mkdirpSync","resolvedEnvAspects","resolveAspects","MainRuntime","requestedOnly","filterByRuntime","resolvedEnv","hostRootDir","aspectPath","warn","html","chunking","splitChunks","hostDependencies","aliasHostDependencies","previewModules","getPreviewModules","previewEntries","_ref","rest","linkFile","writeLink","ComponentMap","create","peerLink","writePeerLink","generateTemplateEntries","previewRootPath","allResults","result","errors","err","message","warning","warnings","startTime","endTime","artifacts","getArtifactDef","modules","compact","Promise","all","def","renderTemplatePathByEnv","prefix","include","join","getArtifactDirectory","CAPSULE_ARTIFACTS_DIR","globPatterns","rootDir"],"sources":["env-preview-template.task.ts"],"sourcesContent":["import {\n BuildContext,\n BuiltTaskResult,\n BuildTask,\n TaskLocation,\n ComponentResult,\n CAPSULE_ARTIFACTS_DIR,\n} from '@teambit/builder';\nimport { MainRuntime } from '@teambit/cli';\nimport mapSeries from 'p-map-series';\nimport { Component, ComponentMap } from '@teambit/component';\nimport { AspectLoaderMain } from '@teambit/aspect-loader';\nimport { Bundler, BundlerContext, BundlerHtmlConfig, BundlerResult, Target } from '@teambit/bundler';\nimport type { EnvDefinition, Environment, EnvsMain } from '@teambit/envs';\nimport { join } from 'path';\nimport { compact, flatten, isEmpty } from 'lodash';\nimport { Logger } from '@teambit/logger';\nimport { DependencyResolverMain } from '@teambit/dependency-resolver';\nimport { existsSync, mkdirpSync } from 'fs-extra';\nimport type { PreviewMain } from './preview.main.runtime';\nimport { generateTemplateEntries } from './bundler/chunks';\nimport { generateHtmlConfig } from './bundler/html-plugin';\nimport { writePeerLink } from './bundler/create-peers-link';\n\nexport type ModuleExpose = {\n name: string;\n path: string;\n include?: string[];\n};\n\ntype TargetsGroup = {\n env: Environment;\n envToGetBundler: Environment;\n targets: Target[];\n};\ntype TargetsGroupMap = {\n [envId: string]: TargetsGroup;\n};\n\nexport const GENERATE_ENV_TEMPLATE_TASK_NAME = 'GenerateEnvTemplate';\n\nexport class EnvPreviewTemplateTask implements BuildTask {\n aspectId = 'teambit.preview/preview';\n name = GENERATE_ENV_TEMPLATE_TASK_NAME;\n location: TaskLocation = 'end';\n // readonly dependencies = [CompilerAspect.id];\n\n constructor(\n private preview: PreviewMain,\n private envs: EnvsMain,\n private aspectLoader: AspectLoaderMain,\n private dependencyResolver: DependencyResolverMain,\n private logger: Logger\n ) {}\n\n async execute(context: BuildContext): Promise<BuiltTaskResult> {\n const previewDefs = this.preview.getDefs();\n const htmlConfig = previewDefs.map((previewModule) => generateHtmlConfig(previewModule, { dev: context.dev }));\n const originalSeedersIds = context.capsuleNetwork.originalSeedersCapsules.map((c) => c.component.id.toString());\n const grouped: TargetsGroupMap = {};\n // avoid running them with `Promise.all` because getEnv methods do import/isolate which can't be in parallel.\n await mapSeries(context.components, async (component) => {\n // Do not run over other components in the graph. it make the process much longer with no need\n if (originalSeedersIds && originalSeedersIds.length && !originalSeedersIds.includes(component.id.toString())) {\n return undefined;\n }\n const envDef = this.envs.getEnvFromComponent(component);\n if (!envDef) return undefined;\n const env = envDef.env;\n const bundlingStrategy = this.preview.getBundlingStrategy(envDef.env);\n if (bundlingStrategy.name === 'env') {\n return undefined;\n }\n const target = await this.getEnvTargetFromComponent(context, component, envDef, htmlConfig);\n if (!target) return undefined;\n const shouldUseDefaultBundler = this.shouldUseDefaultBundler(envDef);\n let envToGetBundler = this.envs.getEnvsEnvDefinition().env;\n let groupEnvId = 'default';\n if (!shouldUseDefaultBundler) {\n envToGetBundler = env;\n groupEnvId = envDef.id;\n }\n if (!grouped[groupEnvId]) {\n grouped[groupEnvId] = {\n env,\n envToGetBundler,\n targets: [target],\n };\n } else {\n grouped[groupEnvId].targets.push(target);\n }\n return undefined;\n });\n if (isEmpty(grouped)) {\n return { componentsResults: [] };\n }\n\n return this.runBundlerForGroups(context, grouped);\n }\n\n private async runBundlerForGroups(context: BuildContext, groups: TargetsGroupMap): Promise<BuiltTaskResult> {\n const bundlerContext: BundlerContext = Object.assign(context, {\n targets: [],\n entry: [],\n development: context.dev,\n metaData: {\n initiator: `${GENERATE_ENV_TEMPLATE_TASK_NAME} task`,\n envId: context.id,\n isEnvTemplate: true,\n },\n });\n\n const bundlerResults = await mapSeries(Object.entries(groups), async ([, targetsGroup]) => {\n bundlerContext.targets = targetsGroup.targets;\n const bundler: Bundler = await targetsGroup.envToGetBundler.getTemplateBundler(bundlerContext);\n const bundlerResult = await bundler.run();\n return bundlerResult;\n });\n\n const results = await this.computeResults(bundlerContext, flatten(bundlerResults));\n return results;\n }\n\n private shouldUseDefaultBundler(envDef: EnvDefinition): boolean {\n if (this.aspectLoader.isCoreEnv(envDef.id) && envDef.id !== 'teambit.react/react-native') return true;\n const env = envDef.env;\n if (env.getTemplateBundler && typeof env.getTemplateBundler === 'function') return false;\n return true;\n }\n\n private async getEnvTargetFromComponent(\n context: BuildContext,\n envComponent: Component,\n envDef: EnvDefinition,\n htmlConfig: BundlerHtmlConfig[]\n ): Promise<Target | undefined> {\n const envPreviewConfig = this.preview.getEnvPreviewConfig(envDef.env);\n\n const peers = await this.dependencyResolver.getPreviewHostDependenciesFromEnv(envDef.env);\n // const module = await this.getPreviewModule(envComponent);\n // const entries = Object.keys(module).map((key) => module.exposes[key]);\n const capsule = context.capsuleNetwork.graphCapsules.getCapsule(envComponent.id);\n if (!capsule) throw new Error('no capsule found');\n // Passing here the env itself to make sure it's preview runtime will be part of the preview root file\n // that's needed to make sure the providers register there are running correctly\n const previewRoot = await this.preview.writePreviewRuntime(context, [envComponent.id.toString()]);\n const entries = await this.generateEntries({\n envDef,\n splitComponentBundle: envPreviewConfig.splitComponentBundle ?? false,\n workDir: capsule.path,\n peers,\n previewRoot,\n });\n const outputPath = this.computeOutputPath(context, envComponent);\n if (!existsSync(outputPath)) mkdirpSync(outputPath);\n const resolvedEnvAspects = await this.preview.resolveAspects(MainRuntime.name, [envComponent.id], undefined, {\n requestedOnly: true,\n // required to support envs that are plguins (.bit-env files)\n filterByRuntime: false,\n });\n const resolvedEnv = resolvedEnvAspects[0];\n const hostRootDir = resolvedEnv?.aspectPath;\n\n if (!hostRootDir) {\n this.logger.warn(`env preview template task, hostRootDir is not defined, for env ${envComponent.id.toString()}`);\n }\n\n return {\n peers,\n html: htmlConfig,\n entries,\n chunking: { splitChunks: true },\n components: [envComponent],\n outputPath,\n /* It's a path to the root of the host component. */\n hostRootDir,\n hostDependencies: peers,\n aliasHostDependencies: true,\n };\n }\n\n private async generateEntries({\n previewRoot,\n workDir,\n peers,\n envDef,\n splitComponentBundle,\n }: {\n previewRoot: string;\n workDir: string;\n peers: string[];\n envDef: EnvDefinition;\n splitComponentBundle: boolean;\n }) {\n const previewModules = await this.getPreviewModules(envDef);\n const previewEntries = previewModules.map(({ name, path, ...rest }) => {\n const linkFile = this.preview.writeLink(\n name,\n ComponentMap.create([]),\n { default: path },\n workDir,\n splitComponentBundle\n );\n\n return { name, path, ...rest, entry: linkFile };\n });\n const peerLink = await writePeerLink(peers, workDir);\n\n const entries = generateTemplateEntries({\n peers: peerLink,\n previewRootPath: previewRoot,\n previewModules: previewEntries,\n });\n return entries;\n }\n\n async computeResults(context: BundlerContext, results: BundlerResult[]) {\n const allResults = results.map((result) => {\n const componentsResults: ComponentResult[] = result.components.map((component) => {\n return {\n component,\n errors: result.errors.map((err) => (typeof err === 'string' ? err : err.message)),\n warning: result.warnings,\n startTime: result.startTime,\n endTime: result.endTime,\n };\n });\n return componentsResults;\n });\n\n const componentsResults = flatten(allResults);\n\n const artifacts = getArtifactDef();\n\n return {\n componentsResults,\n artifacts,\n };\n }\n\n private async getPreviewModules(envDef: EnvDefinition): Promise<ModuleExpose[]> {\n const previewDefs = this.preview.getDefs();\n\n const modules = compact(\n await Promise.all(\n previewDefs.map(async (def) => {\n if (!def.renderTemplatePathByEnv) return undefined;\n return {\n name: def.prefix,\n path: (await def.renderTemplatePathByEnv(envDef.env)) || '',\n include: def.include,\n };\n })\n )\n );\n\n return modules;\n }\n\n private computeOutputPath(context: BuildContext, component: Component) {\n const capsule = context.capsuleNetwork.graphCapsules.getCapsule(component.id);\n if (!capsule) throw new Error('no capsule found');\n return join(capsule.path, getArtifactDirectory());\n }\n}\n\nexport function getArtifactDirectory() {\n return join(CAPSULE_ARTIFACTS_DIR, 'env-template');\n}\n\nexport function getArtifactDef() {\n return [\n {\n name: 'env-template',\n globPatterns: ['**'],\n rootDir: getArtifactDirectory(),\n },\n ];\n}\n"],"mappings":";;;;;;;;AAAA,SAAAA,SAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,QAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAQA,SAAAE,KAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,IAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,YAAA;EAAA,MAAAH,IAAA,GAAAI,sBAAA,CAAAH,OAAA;EAAAE,WAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAK,WAAA;EAAA,MAAAL,IAAA,GAAAC,OAAA;EAAAI,UAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAIA,SAAAM,MAAA;EAAA,MAAAN,IAAA,GAAAC,OAAA;EAAAK,KAAA,YAAAA,CAAA;IAAA,OAAAN,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAO,QAAA;EAAA,MAAAP,IAAA,GAAAC,OAAA;EAAAM,OAAA,YAAAA,CAAA;IAAA,OAAAP,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAGA,SAAAQ,SAAA;EAAA,MAAAR,IAAA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AAkB,CAAC;IACjD,OAAO,IAAAyD,YAAI,EAAC5D,OAAO,CAACS,IAAI,EAAEoD,oBAAoB,CAAC,CAAC,CAAC;EACnD;AACF;AAAClI,OAAA,CAAAC,sBAAA,GAAAA,sBAAA;AAEM,SAASiI,oBAAoBA,CAAA,EAAG;EACrC,OAAO,IAAAD,YAAI,EAACE,gCAAqB,EAAE,cAAc,CAAC;AACpD;AAEO,SAASX,cAAcA,CAAA,EAAG;EAC/B,OAAO,CACL;IACEtF,IAAI,EAAE,cAAc;IACpBkG,YAAY,EAAE,CAAC,IAAI,CAAC;IACpBC,OAAO,EAAEH,oBAAoB,CAAC;EAChC,CAAC,CACF;AACH","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["_uiFoundationUiPages","data","require","_artifactFileMiddleware","_defineProperty","obj","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","t","i","_toPrimitive","String","r","e","Symbol","toPrimitive","call","TypeError","Number","CACHE_MAX_AGE","getCacheControl","_filePath","_contents","mimeType","undefined","EnvTemplateRoute","constructor","preview","logger","req","res","next","artifact","componentId","envId","params","getEnvTemplateByEnvId","error","status","send","noPreview","isLegacyPath","serverError","getArtifactFileMiddleware","exports"],"sources":["env-template.route.ts"],"sourcesContent":["import type { NextFunction, Request, Response } from '@teambit/express';\nimport type { ComponentUrlParams, RegisteredComponentRoute } from '@teambit/component';\nimport { noPreview, serverError } from '@teambit/ui-foundation.ui.pages.static-error';\nimport type { Logger } from '@teambit/logger';\n\nimport type { PreviewMain } from './preview.main.runtime';\nimport type { PreviewArtifact } from './preview-artifact';\nimport { getArtifactFileMiddleware, GetCacheControlFunc } from './artifact-file-middleware';\n\ntype UrlParams = ComponentUrlParams & {\n filePath?: string;\n};\n\n// Week for now\nconst CACHE_MAX_AGE = 60 * 60 * 24 * 7;\n\nconst getCacheControl: GetCacheControlFunc = (_filePath: string, _contents: string, mimeType?: string | null) => {\n // Do not cache the html files\n if (mimeType && mimeType === 'text/html') {\n return undefined;\n }\n return `private, max-age=${CACHE_MAX_AGE}`;\n};\n\nexport class EnvTemplateRoute implements RegisteredComponentRoute {\n constructor(\n /**\n * preview extension.\n */\n private preview: PreviewMain,\n private logger: Logger\n ) {}\n\n route = `/env-template/:previewName/:filePath(*)`;\n method = 'get';\n\n // Since we might give it a core env id\n // Then in the component route when we do host.get(id) it will fail, as we don't have the core envs in the scope/workspace\n resolveComponent = false;\n\n // @ts-ignore\n middlewares = [\n async (req: Request<UrlParams>, res: Response, next: NextFunction) => {\n try {\n // @ts-ignore TODO: @guy please fix.\n // const component = req.component as Component | undefined;\n // if (!component) return res.status(404).send(noPreview());\n\n let artifact: PreviewArtifact | undefined;\n // TODO - prevent error `getVinylsAndImportIfMissing is not a function` #4680\n try {\n const { componentId: envId } = req.params;\n artifact = await this.preview.getEnvTemplateByEnvId(envId);\n } catch (e: any) {\n this.logger.error(`getEnvTemplateByEnvId has failed`, e);\n return res.status(404).send(noPreview());\n }\n\n // @ts-ignore\n req.artifact = artifact;\n // @ts-ignore\n req.isLegacyPath = false;\n\n return next();\n } catch (e: any) {\n this.logger.error('failed getting preview', e);\n return res.status(500).send(serverError());\n }\n },\n getArtifactFileMiddleware(this.logger, getCacheControl),\n ];\n}\n"],"mappings":";;;;;;AAEA,SAAAA,qBAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,oBAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAKA,SAAAE,wBAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,uBAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAA4F,SAAAG,gBAAAC,GAAA,EAAAC,GAAA,EAAAC,KAAA,IAAAD,GAAA,GAAAE,cAAA,CAAAF,GAAA,OAAAA,GAAA,IAAAD,GAAA,IAAAI,MAAA,CAAAC,cAAA,CAAAL,GAAA,EAAAC,GAAA,IAAAC,KAAA,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AAEC,WAAW,EAAEC;UAAM,CAAC,GAAGL,GAAG,CAACM,MAAM;UACzCH,QAAQ,GAAG,MAAM,IAAI,CAACL,OAAO,CAACS,qBAAqB,CAACF,KAAK,CAAC;QAC5D,CAAC,CAAC,OAAOrB,CAAM,EAAE;UACf,IAAI,CAACe,MAAM,CAACS,KAAK,CAAE,kCAAiC,EAAExB,CAAC,CAAC;UACxD,OAAOiB,GAAG,CAACQ,MAAM,CAAC,GAAG,CAAC,CAACC,IAAI,CAAC,IAAAC,gCAAS,EAAC,CAAC,CAAC;QAC1C;;QAEA;QACAX,GAAG,CAACG,QAAQ,GAAGA,QAAQ;QACvB;QACAH,GAAG,CAACY,YAAY,GAAG,KAAK;QAExB,OAAOV,IAAI,CAAC,CAAC;MACf,CAAC,CAAC,OAAOlB,CAAM,EAAE;QACf,IAAI,CAACe,MAAM,CAACS,KAAK,CAAC,wBAAwB,EAAExB,CAAC,CAAC;QAC9C,OAAOiB,GAAG,CAACQ,MAAM,CAAC,GAAG,CAAC,CAACC,IAAI,CAAC,IAAAG,kCAAW,EAAC,CAAC,CAAC;MAC5C;IACF,CAAC,EACD,IAAAC,mDAAyB,EAAC,IAAI,CAACf,MAAM,EAAER,eAAe,CAAC,CACxD;EAvCE;AAwCL;AAACwB,OAAA,CAAAnB,gBAAA,GAAAA,gBAAA"}
1
+ {"version":3,"names":["_uiFoundationUiPages","data","require","_artifactFileMiddleware","_defineProperty","obj","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","t","i","_toPrimitive","String","r","e","Symbol","toPrimitive","call","TypeError","Number","CACHE_MAX_AGE","getCacheControl","_filePath","_contents","mimeType","undefined","EnvTemplateRoute","constructor","preview","logger","req","res","next","artifact","componentId","envId","params","getEnvTemplateByEnvId","error","status","send","noPreview","isLegacyPath","serverError","getArtifactFileMiddleware","exports"],"sources":["env-template.route.ts"],"sourcesContent":["import type { NextFunction, Request, Response } from '@teambit/express';\nimport type { ComponentUrlParams, RegisteredComponentRoute } from '@teambit/component';\nimport { noPreview, serverError } from '@teambit/ui-foundation.ui.pages.static-error';\nimport type { Logger } from '@teambit/logger';\n\nimport type { PreviewMain } from './preview.main.runtime';\nimport type { PreviewArtifact } from './preview-artifact';\nimport { getArtifactFileMiddleware, GetCacheControlFunc } from './artifact-file-middleware';\n\ntype UrlParams = ComponentUrlParams & {\n filePath?: string;\n};\n\n// Week for now\nconst CACHE_MAX_AGE = 60 * 60 * 24 * 7;\n\nconst getCacheControl: GetCacheControlFunc = (_filePath: string, _contents: string, mimeType?: string | null) => {\n // Do not cache the html files\n if (mimeType && mimeType === 'text/html') {\n return undefined;\n }\n return `private, max-age=${CACHE_MAX_AGE}`;\n};\n\nexport class EnvTemplateRoute implements RegisteredComponentRoute {\n constructor(\n /**\n * preview extension.\n */\n private preview: PreviewMain,\n private logger: Logger\n ) {}\n\n route = `/env-template/:previewName/:filePath(*)`;\n method = 'get';\n\n // Since we might give it a core env id\n // Then in the component route when we do host.get(id) it will fail, as we don't have the core envs in the scope/workspace\n resolveComponent = false;\n\n // @ts-ignore\n middlewares = [\n async (req: Request<UrlParams>, res: Response, next: NextFunction) => {\n try {\n // @ts-ignore TODO: @guy please fix.\n // const component = req.component as Component | undefined;\n // if (!component) return res.status(404).send(noPreview());\n\n let artifact: PreviewArtifact | undefined;\n // TODO - prevent error `getVinylsAndImportIfMissing is not a function` #4680\n try {\n const { componentId: envId } = req.params;\n artifact = await this.preview.getEnvTemplateByEnvId(envId);\n } catch (e: any) {\n this.logger.error(`getEnvTemplateByEnvId has failed`, e);\n return res.status(404).send(noPreview());\n }\n\n // @ts-ignore\n req.artifact = artifact;\n // @ts-ignore\n req.isLegacyPath = false;\n\n return next();\n } catch (e: any) {\n this.logger.error('failed getting preview', e);\n return res.status(500).send(serverError());\n }\n },\n getArtifactFileMiddleware(this.logger, getCacheControl),\n ];\n}\n"],"mappings":";;;;;;AAEA,SAAAA,qBAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,oBAAA,Y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
1
- {"version":3,"names":["_pubsub","data","require","_defineProperty","obj","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","t","i","_toPrimitive","String","r","e","Symbol","toPrimitive","call","TypeError","Number","ClickInsideAnIframeEventData","constructor","clickEvent","ClickInsideAnIframeEvent","BitBaseEvent","timestamp","Date","now","TYPE","exports"],"sources":["click-inside-an-iframe.ts"],"sourcesContent":["/* eslint-disable max-classes-per-file */\nimport { BitBaseEvent } from '@teambit/pubsub';\n\nclass ClickInsideAnIframeEventData {\n constructor(private clickEvent: any) {}\n}\n\nexport class ClickInsideAnIframeEvent extends BitBaseEvent<ClickInsideAnIframeEventData> {\n static readonly TYPE = 'click-inside-an-iframe';\n\n constructor(readonly timestamp = Date.now(), readonly clickEvent) {\n super(ClickInsideAnIframeEvent.TYPE, '0.0.1', timestamp, new ClickInsideAnIframeEventData(clickEvent));\n }\n}\n"],"mappings":";;;;;;AACA,SAAAA,QAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,OAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAA+C,SAAAE,gBAAAC,GAAA,EAAAC,GAAA,EAAAC,KAAA,IAAAD,GAAA,GAAAE,cAAA,CAAAF,GAAA,OAAAA,GAAA,IAAAD,GAAA,IAAAI,MAAA,CAAAC,cAAA,CAAAL,GAAA,EAAAC,GAAA,IAAAC,KAAA,EAAAA,KAAA,EAAAI,UAAA,QAAAC,YAAA,QAAAC,QAAA,oBAAAR,GAAA,CAAAC,GAAA,IAAAC,KAAA,WAAAF,GAAA;AAAA,SAAAG,eAAAM,CAAA,QAAAC,CAAA,GAAAC,YAAA,CAAAF,CAAA,uCAAAC,CAAA,GAAAA,CAAA,GAAAE,MAAA,CAAAF,CAAA;AAAA,SAAAC,aAAAF,CAAA,EAAAI,CAAA,2BAAAJ,CAAA,KAAAA,CAAA,SAAAA,CAAA,MAAAK,CAAA,GAAAL,CAAA,CAAAM,MAAA,CAAAC,WAAA,kBAAAF,CAAA,QAAAJ,CAAA,GAAAI,CAAA,CAAAG,IAAA,CAAAR,CAAA,EAAAI,CAAA,uCAAAH,CAAA,SAAAA,CAAA,YAAAQ,SAAA,yEAAAL,CAAA,GAAAD,MAAA,GAAAO,MAAA,EAAAV,CAAA,KAD/C;AAGA,MAAMW,4BAA4B,CAAC;EACjCC,WAAWA,CAASC,UAAe,EAAE;IAAA,KAAjBA,UAAe,GAAfA,UAAe;EAAG;AACxC;AAEO,MAAMC,wBAAwB,SAASC,sBAAY,CAA+B;EAGvFH,WAAWA,CAAUI,SAAS,GAAGC,IAAI,CAACC,GAAG,CAAC,CAAC,EAAWL,UAAU,EAAE;IAChE,KAAK,CAACC,wBAAwB,CAACK,IAAI,EAAE,OAAO,EAAEH,SAAS,EAAE,IAAIL,4BAA4B,CAACE,UAAU,CAAC,CAAC;IAAC,KADpFG,SAAS,GAATA,SAAS;IAAA,KAAwBH,UAAU,GAAVA,UAAU;EAEhE;AACF;AAACO,OAAA,CAAAN,wBAAA,GAAAA,wBAAA;AAAAxB,eAAA,CANYwB,wBAAwB,UACZ,wBAAwB"}
1
+ {"version":3,"names":["_pubsub","data","require","_defineProperty","obj","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","t","i","_toPrimitive","String","r","e","Symbol","toPrimitive","call","TypeError","Number","ClickInsideAnIframeEventData","constructor","clickEvent","ClickInsideAnIframeEvent","BitBaseEvent","timestamp","Date","now","TYPE","exports"],"sources":["click-inside-an-iframe.ts"],"sourcesContent":["/* eslint-disable max-classes-per-file */\nimport { BitBaseEvent } from '@teambit/pubsub';\n\nclass ClickInsideAnIframeEventData {\n constructor(private clickEvent: any) {}\n}\n\nexport class ClickInsideAnIframeEvent extends BitBaseEvent<ClickInsideAnIframeEventData> {\n static readonly TYPE = 'click-inside-an-iframe';\n\n constructor(readonly timestamp = Date.now(), readonly clickEvent) {\n super(ClickInsideAnIframeEvent.TYPE, '0.0.1', timestamp, new ClickInsideA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AU,CAAC,CAAC;IAAC,KADpFG,SAAS,GAATA,SAAS;IAAA,KAAwBH,UAAU,GAAVA,UAAU;EAEhE;AACF;AAACO,OAAA,CAAAN,wBAAA,GAAAA,wBAAA;AAAAxB,eAAA,CANYwB,wBAAwB,UACZ,wBAAwB","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["_clickInsideAnIframe","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get"],"sources":["index.ts"],"sourcesContent":["export * from './click-inside-an-iframe';\n"],"mappings":";;;;;AAAA,IAAAA,oBAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,oBAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,oBAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,oBAAA,CAAAK,GAAA;IAAA;EAAA;AAAA"}
1
+ {"version":3,"names":["_clickInsideAnIframe","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get"],"sources":["index.ts"],"sourcesContent":["export * from './click-inside-an-iframe';\n"],"mappings":";;;;;AAAA,IAAAA,oBAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,oBAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,oBAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,oBAAA,CAAAK,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["BundlingStrategyNotFound","Error","constructor","strategyName","exports"],"sources":["bundling-strategy-not-found.ts"],"sourcesContent":["export class BundlingStrategyNotFound extends Error {\n constructor(private strategyName: string) {\n super(`bundling strategy with name ${strategyName} was not found`);\n }\n}\n"],"mappings":";;;;;;AAAO,MAAMA,wBAAwB,SAASC,KAAK,CAAC;EAClDC,WAAWA,CAASC,YAAoB,EAAE;IACxC,KAAK,CAAE,+BAA8BA,YAAa,gBAAe,CAAC;IAAC,KADjDA,YAAoB,GAApBA,YAAoB;EAExC;AACF;AAACC,OAAA,CAAAJ,wBAAA,GAAAA,wBAAA"}
1
+ {"version":3,"names":["BundlingStrategyNotFound","Error","constructor","strategyName","exports"],"sources":["bundling-strategy-not-found.ts"],"sourcesContent":["export class BundlingStrategyNotFound extends Error {\n constructor(private strategyName: string) {\n super(`bundling strategy with name ${strategyName} was not found`);\n }\n}\n"],"mappings":";;;;;;AAAO,MAAMA,wBAAwB,SAASC,KAAK,CAAC;EAClDC,WAAWA,CAASC,YAAoB,EAAE;IACxC,KAAK,CAAE,+BAA8BA,YAAa,gBAAe,CAAC;IAAC,KADjDA,YAAoB,GAApBA,YAAoB;EAExC;AACF;AAACC,OAAA,CAAAJ,wBAAA,GAAAA,wBAAA","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["_previewNotFound","data","require","_previewArtifactNotFound","_bundlingStrategyNotFound","_previewOutputFileNotFound"],"sources":["index.ts"],"sourcesContent":["export { PreviewNotFound } from './preview-not-found';\nexport { PreviewArtifactNotFound } from './preview-artifact-not-found';\nexport { BundlingStrategyNotFound } from './bundling-strategy-not-found';\nexport { PreviewOutputFileNotFound } from './preview-output-file-not-found';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAAA,iBAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,gBAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,yBAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,wBAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,0BAAA;EAAA,MAAAH,IAAA,GAAAC,OAAA;EAAAE,yBAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,2BAAA;EAAA,MAAAJ,IAAA,GAAAC,OAAA;EAAAG,0BAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA"}
1
+ {"version":3,"names":["_previewNotFound","data","require","_previewArtifactNotFound","_bundlingStrategyNotFound","_previewOutputFileNotFound"],"sources":["index.ts"],"sourcesContent":["export { PreviewNotFound } from './preview-not-found';\nexport { PreviewArtifactNotFound } from './preview-artifact-not-found';\nexport { BundlingStrategyNotFound } from './bundling-strategy-not-found';\nexport { PreviewOutputFileNotFound } from './preview-output-file-not-found';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAAA,iBAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,gBAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,yBAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,wBAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,0BAAA;EAAA,MAAAH,IAAA,GAAAC,OAAA;EAAAE,yBAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,2BAAA;EAAA,MAAAJ,IAAA,GAAAC,OAAA;EAAAG,0BAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["_bitError","data","require","PreviewArtifactNotFound","BitError","constructor","componentId","toString","exports"],"sources":["preview-artifact-not-found.ts"],"sourcesContent":["import { BitError } from '@teambit/bit-error';\nimport { ComponentID } from '@teambit/component';\n\nexport class PreviewArtifactNotFound extends BitError {\n constructor(componentId: ComponentID) {\n super(`preview for component ${componentId.toString()} was not found`);\n }\n}\n"],"mappings":";;;;;;AAAA,SAAAA,UAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,SAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAGO,MAAME,uBAAuB,SAASC,oBAAQ,CAAC;EACpDC,WAAWA,CAACC,WAAwB,EAAE;IACpC,KAAK,CAAE,yBAAwBA,WAAW,CAACC,QAAQ,CAAC,CAAE,gBAAe,CAAC;EACxE;AACF;AAACC,OAAA,CAAAL,uBAAA,GAAAA,uBAAA"}
1
+ {"version":3,"names":["_bitError","data","require","PreviewArtifactNotFound","BitError","constructor","componentId","toString","exports"],"sources":["preview-artifact-not-found.ts"],"sourcesContent":["import { BitError } from '@teambit/bit-error';\nimport { ComponentID } from '@teambit/component';\n\nexport class PreviewArtifactNotFound extends BitError {\n constructor(componentId: ComponentID) {\n super(`preview for component ${componentId.toString()} was not found`);\n }\n}\n"],"mappings":";;;;;;AAAA,SAAAA,UAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,SAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAGO,MAAME,uBAAuB,SAASC,oBAAQ,CAAC;EACpDC,WAAWA,CAACC,WAAwB,EAAE;IACpC,KAAK,CAAE,yBAAwBA,WAAW,CAACC,QAAQ,CAAC,CAAE,gBAAe,CAAC;EACxE;AACF;AAACC,OAAA,CAAAL,uBAAA,GAAAA,uBAAA","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["PreviewNotFound","Error","constructor","name","exports"],"sources":["preview-not-found.ts"],"sourcesContent":["export class PreviewNotFound extends Error {\n constructor(name: string | null) {\n super(`Preview for name: ${name} was not found`);\n }\n}\n"],"mappings":";;;;;;AAAO,MAAMA,eAAe,SAASC,KAAK,CAAC;EACzCC,WAAWA,CAACC,IAAmB,EAAE;IAC/B,KAAK,CAAE,qBAAoBA,IAAK,gBAAe,CAAC;EAClD;AACF;AAACC,OAAA,CAAAJ,eAAA,GAAAA,eAAA"}
1
+ {"version":3,"names":["PreviewNotFound","Error","constructor","name","exports"],"sources":["preview-not-found.ts"],"sourcesContent":["export class PreviewNotFound extends Error {\n constructor(name: string | null) {\n super(`Preview for name: ${name} was not found`);\n }\n}\n"],"mappings":";;;;;;AAAO,MAAMA,eAAe,SAASC,KAAK,CAAC;EACzCC,WAAWA,CAACC,IAAmB,EAAE;IAC/B,KAAK,CAAE,qBAAoBA,IAAK,gBAAe,CAAC;EAClD;AACF;AAACC,OAAA,CAAAJ,eAAA,GAAAA,eAAA","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["_bitError","data","require","PreviewOutputFileNotFound","BitError","constructor","componentId","filePath","toString","exports"],"sources":["preview-output-file-not-found.ts"],"sourcesContent":["import { BitError } from '@teambit/bit-error';\nimport { ComponentID } from '@teambit/component';\n\nexport class PreviewOutputFileNotFound extends BitError {\n constructor(componentId: ComponentID, filePath: string) {\n super(`preview output file for component: \"${componentId.toString()}\" was not found in the path: \"${filePath}\".\n\nThis is usually a result of an error during the bundling process.\nThe error might be an error of another component that uses the same env.\nRun \"bit build\" with \"--dev\" to see more info.\nRun \"bit envs\" to see other components that uses the same env`);\n }\n}\n"],"mappings":";;;;;;AAAA,SAAAA,UAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,SAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAGO,MAAME,yBAAyB,SAASC,oBAAQ,CAAC;EACtDC,WAAWA,CAACC,WAAwB,EAAEC,QAAgB,EAAE;IACtD,KAAK,CAAE,uCAAsCD,WAAW,CAACE,QAAQ,CAAC,CAAE,iCAAgCD,QAAS;AACjH;AACA;AACA;AACA;AACA,8DAA8D,CAAC;EAC7D;AACF;AAACE,OAAA,CAAAN,yBAAA,GAAAA,yBAAA"}
1
+ {"version":3,"names":["_bitError","data","require","PreviewOutputFileNotFound","BitError","constructor","componentId","filePath","toString","exports"],"sources":["preview-output-file-not-found.ts"],"sourcesContent":["import { BitError } from '@teambit/bit-error';\nimport { ComponentID } from '@teambit/component';\n\nexport class PreviewOutputFileNotFound extends BitError {\n constructor(componentId: ComponentID, filePath: string) {\n super(`preview output file for component: \"${componentId.toString()}\" was not found in the path: \"${filePath}\".\n\nThis is usually a result of an error during the bundling process.\nThe error might be an error of another component that uses the same env.\nRun \"bit build\" with \"--dev\" to see more info.\nRun \"bit envs\" to see other components that uses the same env`);\n }\n}\n"],"mappings":";;;;;;AAAA,SAAAA,UAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,SAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAGO,MAAME,yBAAyB,SAASC,oBAAQ,CAAC;EACtDC,WAAWA,CAACC,WAAwB,EAAEC,QAAgB,EAAE;IACtD,KAAK,CAAE,uCAAsCD,WAAW,CAACE,QAAQ,CAAC,CAAE,iCAAgCD,QAAS;AACjH;AACA;AACA;AACA;AACA,8DAA8D,CAAC;EAC7D;AACF;AAACE,OAAA,CAAAN,yBAAA,GAAAA,yBAAA","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["ExecutionRef","constructor","executionCtx","_defineProperty","currentComponents","components","add","added","concat","remove","removed","filter","c","id","toString","update","next","map","equals","get","find","x","isEqual","exports"],"sources":["execution-ref.ts"],"sourcesContent":["import { Component, ComponentID } from '@teambit/component';\nimport type { ExecutionContext } from '@teambit/envs';\n\n// TODO - use workspace.list() instead of this\nexport class ExecutionRef {\n constructor(public executionCtx: ExecutionContext) {\n this.currentComponents = executionCtx.components;\n }\n\n currentComponents: Component[];\n\n add(added: Component) {\n this.currentComponents = this.currentComponents.concat(added);\n }\n remove(removed: ComponentID) {\n this.currentComponents = this.currentComponents.filter((c) => c.id.toString() !== removed.toString());\n }\n update(next: Component) {\n this.currentComponents = this.currentComponents.map((c) => (c.equals(next) ? next : c));\n }\n\n get(id: ComponentID) {\n return this.currentComponents.find((x) => x.id.isEqual(id));\n }\n}\n"],"mappings":";;;;;;;;;AAGA;AACO,MAAMA,YAAY,CAAC;EACxBC,WAAWA,CAAQC,YAA8B,EAAE;IAAA,KAAhCA,YAA8B,GAA9BA,YAA8B;IAAAC,eAAA;IAC/C,IAAI,CAACC,iBAAiB,GAAGF,YAAY,CAACG,UAAU;EAClD;EAIAC,GAAGA,CAACC,KAAgB,EAAE;IACpB,IAAI,CAACH,iBAAiB,GAAG,IAAI,CAACA,iBAAiB,CAACI,MAAM,CAACD,KAAK,CAAC;EAC/D;EACAE,MAAMA,CAACC,OAAoB,EAAE;IAC3B,IAAI,CAACN,iBAAiB,GAAG,IAAI,CAACA,iBAAiB,CAACO,MAAM,CAAEC,CAAC,IAAKA,CAAC,CAACC,EAAE,CAACC,QAAQ,CAAC,CAAC,KAAKJ,OAAO,CAACI,QAAQ,CAAC,CAAC,CAAC;EACvG;EACAC,MAAMA,CAACC,IAAe,EAAE;IACtB,IAAI,CAACZ,iBAAiB,GAAG,IAAI,CAACA,iBAAiB,CAACa,GAAG,CAAEL,CAAC,IAAMA,CAAC,CAACM,MAAM,CAACF,IAAI,CAAC,GAAGA,IAAI,GAAGJ,CAAE,CAAC;EACzF;EAEAO,GAAGA,CAACN,EAAe,EAAE;IACnB,OAAO,IAAI,CAACT,iBAAiB,CAACgB,IAAI,CAAEC,CAAC,IAAKA,CAAC,CAACR,EAAE,CAACS,OAAO,CAACT,EAAE,CAAC,CAAC;EAC7D;AACF;AAACU,OAAA,CAAAvB,YAAA,GAAAA,YAAA"}
1
+ {"version":3,"names":["ExecutionRef","constructor","executionCtx","_defineProperty","currentComponents","components","add","added","concat","remove","removed","filter","c","id","toString","update","next","map","equals","get","find","x","isEqual","exports"],"sources":["execution-ref.ts"],"sourcesContent":["import { Component, ComponentID } from '@teambit/component';\nimport type { ExecutionContext } from '@teambit/envs';\n\n// TODO - use workspace.list() instead of this\nexport class ExecutionRef {\n constructor(public executionCtx: ExecutionContext) {\n this.currentComponents = executionCtx.components;\n }\n\n currentComponents: Component[];\n\n add(added: Component) {\n this.currentComponents = this.currentComponents.concat(added);\n }\n remove(removed: ComponentID) {\n this.currentComponents = this.currentComponents.filter((c) => c.id.toString() !== removed.toString());\n }\n update(next: Component) {\n this.currentComponents = this.currentComponents.map((c) => (c.equals(next) ? next : c));\n }\n\n get(id: ComponentID) {\n return this.currentComponents.find((x) => x.id.isEqual(id));\n }\n}\n"],"mappings":";;;;;;;;;AAGA;AACO,MAAMA,YAAY,CAAC;EACxBC,WAAWA,CAAQC,YAA8B,EAAE;IAAA,KAAhCA,YAA8B,GAA9BA,YAA8B;IAAAC,eAAA;IAC/C,IAAI,CAACC,iBAAiB,GAAGF,YAAY,CAACG,UAAU;EAClD;EAIAC,GAAGA,CAACC,KAAgB,EAAE;IACpB,IAAI,CAACH,iBAAiB,GAAG,IAAI,CAACA,iBAAiB,CAACI,MAAM,CAACD,KAAK,CAAC;EAC/D;EACAE,MAAMA,CAACC,OAAoB,EAAE;IAC3B,IAAI,CAACN,iBAAiB,GAAG,IAAI,CAACA,iBAAiB,CAACO,MAAM,CAAEC,CAAC,IAAKA,CAAC,CAACC,EAAE,CAACC,QAAQ,CAAC,CAAC,KAAKJ,OAAO,CAACI,QAAQ,CAAC,CAAC,CAAC;EACvG;EACAC,MAAMA,CAACC,IAAe,EAAE;IACtB,IAAI,CAACZ,iBAAiB,GAAG,IAAI,CAACA,iBAAiB,CAACa,GAAG,CAAEL,CAAC,IAAMA,CAAC,CAACM,MAAM,CAACF,IAAI,CAAC,GAAGA,IAAI,GAAGJ,CAAE,CAAC;EACzF;EAEAO,GAAGA,CAACN,EAAe,EAAE;IACnB,OAAO,IAAI,CAACT,iBAAiB,CAACgB,IAAI,CAAEC,CAAC,IAAKA,CAAC,CAACR,EAAE,CAACS,OAAO,CAACT,EAAE,CAAC,CAAC;EAC7D;AACF;AAACU,OAAA,CAAAvB,YAAA,GAAAA,YAAA","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["_toolboxPath","data","require","_camelcase","_interopRequireDefault","obj","__esModule","default","generateLink","prefix","componentMap","mainModulesMap","isSplitComponentBundle","links","toArray","map","component","modulePath","compIdx","componentIdentifier","id","fullName","modules","path","pathIdx","varName","moduleVarName","resolveFrom","toWindowsCompatiblePath","modulesLinks","Object","entries","envId","getEnvVarName","link","module","join","filter","line","componentIdx","fileIdx","envNameFormatted","camelcase","replace"],"sources":["generate-link.ts"],"sourcesContent":["import { toWindowsCompatiblePath } from '@teambit/toolbox.path.to-windows-compatible-path';\nimport camelcase from 'camelcase';\nimport type { ComponentMap } from '@teambit/component';\n\nexport type MainModulesMap = {\n /**\n * Path to default module in case there is no specific module for the current environment.\n */\n default: string;\n [envId: string]: string;\n};\n\n// :TODO refactor to building an AST and generate source code based on it.\nexport function generateLink(\n prefix: string,\n componentMap: ComponentMap<string[]>,\n mainModulesMap?: MainModulesMap,\n isSplitComponentBundle = false\n): string {\n const links = componentMap.toArray().map(([component, modulePath], compIdx) => ({\n componentIdentifier: component.id.fullName,\n modules: modulePath.map((path, pathIdx) => ({\n varName: moduleVarName(compIdx, pathIdx),\n resolveFrom: toWindowsCompatiblePath(path),\n })),\n }));\n\n let modulesLinks;\n if (mainModulesMap) {\n modulesLinks = Object.entries(mainModulesMap).map(([envId, path]) => {\n const resolveFrom = toWindowsCompatiblePath(path);\n const varName = getEnvVarName(envId);\n return { envId, varName, resolveFrom };\n });\n }\n\n return `\nimport { linkModules } from '@teambit/preview/dist/preview.preview.runtime.js';\n\n${links\n .map((link) => link.modules.map((module) => `import * as ${module.varName} from \"${module.resolveFrom}\";`).join('\\n'))\n .filter((line) => line !== '') // prevent empty lines\n .join('\\n')}\n\n${modulesLinks.map((module) => `import * as ${module.varName} from \"${module.resolveFrom}\";`).join('\\n')}\n\nlinkModules('${prefix}', {\n modulesMap: {\n ${modulesLinks\n // must include all components, including empty\n .map((module) => `\"${module.envId}\": ${module.varName}`)\n .join(',\\n ')}\n },\n isSplitComponentBundle: ${isSplitComponentBundle},\n componentMap: {\n${links\n // must include all components, including empty\n .map((link) => ` \"${link.componentIdentifier}\": [${link.modules.map((module) => module.varName).join(', ')}]`)\n .join(',\\n')}\n }\n});\n`;\n}\n\nfunction moduleVarName(componentIdx: number, fileIdx: number) {\n return `file_${componentIdx}_${fileIdx}`;\n}\n\nfunction getEnvVarName(envId: string) {\n const envNameFormatted = camelcase(envId.replace('@', '').replace('.', '-').replace(/\\//g, '-'));\n const varName = `${envNameFormatted}MainModule`;\n return varName;\n}\n"],"mappings":";;;;;;AAAA,SAAAA,aAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,YAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,WAAA;EAAA,MAAAF,IAAA,GAAAG,sBAAA,CAAAF,OAAA;EAAAC,UAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAAkC,SAAAG,uBAAAC,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAWlC;AACO,SAASG,YAAYA,CAC1BC,MAAc,EACdC,YAAoC,EACpCC,cAA+B,EAC/BC,sBAAsB,GAAG,KAAK,EACtB;EACR,MAAMC,KAAK,GAAGH,YAAY,CAACI,OAAO,CAAC,CAAC,CAACC,GAAG,CAAC,CAAC,CAACC,SAAS,EAAEC,UAAU,CAAC,EAAEC,OAAO,MAAM;IAC9EC,mBAAmB,EAAEH,SAAS,CAACI,EAAE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,IAAI,CAAC,SAAS,CAAE;AACvB;AACA,4BAA4BxB,sBAAuB;AACnD;AACA,EAAEC;EACA;EAAA,CACCE,GAAG,CAAEmB,IAAI,IAAM,QAAOA,IAAI,CAACf,mBAAoB,OAAMe,IAAI,CAACZ,OAAO,CAACP,GAAG,CAAEoB,MAAM,IAAKA,MAAM,CAACV,OAAO,CAAC,CAACW,IAAI,CAAC,IAAI,CAAE,GAAE,CAAC,CAChHA,IAAI,CAAC,KAAK,CAAE;AACf;AACA;AACA,CAAC;AACD;AAEA,SAASV,aAAaA,CAACa,YAAoB,EAAEC,OAAe,EAAE;EAC5D,OAAQ,QAAOD,YAAa,IAAGC,OAAQ,EAAC;AAC1C;AAEA,SAASP,aAAaA,CAACD,KAAa,EAAE;EACpC,MAAMS,gBAAgB,GAAG,IAAAC,oBAAS,EAACV,KAAK,CAACW,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAACA,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAACA,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;EAChG,MAAMlB,OAAO,GAAI,GAAEgB,gBAAiB,YAAW;EAC/C,OAAOhB,OAAO;AAChB"}
1
+ {"version":3,"names":["_toolboxPath","data","require","_camelcase","_interopRequireDefault","obj","__esModule","default","generateLink","prefix","componentMap","mainModulesMap","isSplitComponentBundle","links","toArray","map","component","modulePath","compIdx","componentIdentifier","id","fullName","modules","path","pathIdx","varName","moduleVarName","resolveFrom","toWindowsCompatiblePath","modulesLinks","Object","entries","envId","getEnvVarName","link","module","join","filter","line","componentIdx","fileIdx","envNameFormatted","camelcase","replace"],"sources":["generate-link.ts"],"sourcesContent":["import { toWindowsCompatiblePath } from '@teambit/toolbox.path.to-windows-compatible-path';\nimport camelcase from 'camelcase';\nimport type { ComponentMap } from '@teambit/component';\n\nexport type MainModulesMap = {\n /**\n * Path to default module in case there is no specific module for the current environment.\n */\n default: string;\n [envId: string]: string;\n};\n\n// :TODO refactor to building an AST and generate source code based on it.\nexport function generateLink(\n prefix: string,\n componentMap: ComponentMap<string[]>,\n mainModulesMap?: MainModulesMap,\n isSplitComponentBundle = false\n): string {\n const links = componentMap.toArray().map(([component, modulePath], compIdx) => ({\n componentIdentifier: component.id.fullName,\n modules: modulePath.map((path, pathIdx) => ({\n varName: moduleVarName(compIdx, pathIdx),\n resolveFrom: toWindowsCompatiblePath(path),\n })),\n }));\n\n let modulesLinks;\n if (mainModulesMap) {\n modulesLinks = Object.entries(mainModulesMap).map(([envId, path]) => {\n const resolveFrom = toWindowsCompatiblePath(path);\n const varName = getEnvVarName(envId);\n return { envId, varName, resolveFrom };\n });\n }\n\n return `\nimport { linkModules } from '@teambit/preview/dist/preview.preview.runtime.js';\n\n${links\n .map((link) => link.modules.map((module) => `import * as ${module.varName} from \"${module.resolveFrom}\";`).join('\\n'))\n .filter((line) => line !== '') // prevent empty lines\n .join('\\n')}\n\n${modulesLinks.map((module) => `import * as ${module.varName} from \"${module.resolveFrom}\";`).join('\\n')}\n\nlinkModules('${prefix}', {\n modulesMap: {\n ${modulesLinks\n // must include all components, including empty\n .map((module) => `\"${module.envId}\": ${module.varName}`)\n .join(',\\n ')}\n },\n isSplitComponentBundle: ${isSplitComponentBundle},\n componentMap: {\n${links\n // must include all components, including empty\n .map((link) => ` \"${link.componentIdentifier}\": [${link.modules.map((module) => module.varName).join(', ')}]`)\n .join(',\\n')}\n }\n});\n`;\n}\n\nfunction moduleVarName(componentIdx: number, fileIdx: number) {\n return `file_${componentIdx}_${fileIdx}`;\n}\n\nfunction getEnvVarName(envId: string) {\n const envNameFormatted = camelcase(envId.replace('@', '').replace('.', '-').replace(/\\//g, '-'));\n const varName = `${envNameFormatted}MainModule`;\n return varName;\n}\n"],"mappings":";;;;;;AAAA,SAAAA,aAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,YAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,WAAA;E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;AAChB","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["_graphqlRequest","data","require","GQL_SERVER","GET_COMPONENT_ASPECTS","gql","fetchComponentAspects","componentId","response","request","id","toString","getHost","get","aspects","map","x","err","console","error","undefined"],"sources":["fetch-component-aspects.tsx"],"sourcesContent":["import { request, gql } from 'graphql-request';\n\nconst GQL_SERVER = '/graphql';\nconst GET_COMPONENT_ASPECTS = gql`\n query getComponentAspects($id: String!) {\n getHost {\n id\n get(id: $id) {\n aspects {\n id\n }\n }\n }\n }\n`;\ntype QueryResult = {\n getHost: {\n id: string;\n get: {\n aspects: { id: string }[];\n };\n };\n};\n\nexport async function fetchComponentAspects(componentId: string) {\n try {\n const response = await request<QueryResult>(GQL_SERVER, GET_COMPONENT_ASPECTS, { id: componentId.toString() });\n return response.getHost.get.aspects.map((x) => x.id);\n } catch (err: any) {\n // eslint-disable-next-line no-console\n console.error(`[gql] error on \"getComponentAspects\" - \"${err.toString()}\"`);\n return undefined;\n }\n}\n"],"mappings":";;;;;;AAAA,SAAAA,gBAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,eAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,MAAME,UAAU,GAAG,UAAU;AAC7B,MAAMC,qBAAqB,GAAG,IAAAC,qBAAG,CAAC;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAUM,eAAeC,qBAAqBA,CAACC,WAAmB,EAAE;EAC/D,IAAI;IACF,MAAMC,QAAQ,GAAG,MAAM,IAAAC,yBAAO,EAAcN,UAAU,EAAEC,qBAAqB,EAAE;MAAEM,EAAE,EAAEH,WAAW,CAACI,QAAQ,CAAC;IAAE,CAAC,CAAC;IAC9G,OAAOH,QAAQ,CAACI,OAAO,CAACC,GAAG,CAACC,OAAO,CAACC,GAAG,CAAEC,CAAC,IAAKA,CAAC,CAACN,EAAE,CAAC;EACtD,CAAC,CAAC,OAAOO,GAAQ,EAAE;IACjB;IACAC,OAAO,CAACC,KAAK,CAAE,2CAA0CF,GAAG,CAACN,QAAQ,CAAC,CAAE,GAAE,CAAC;IAC3E,OAAOS,SAAS;EAClB;AACF"}
1
+ {"version":3,"names":["_graphqlRequest","data","require","GQL_SERVER","GET_COMPONENT_ASPECTS","gql","fetchComponentAspects","componentId","response","request","id","toString","getHost","get","aspects","map","x","err","console","error","undefined"],"sources":["fetch-component-aspects.tsx"],"sourcesContent":["import { request, gql } from 'graphql-request';\n\nconst GQL_SERVER = '/graphql';\nconst GET_COMPONENT_ASPECTS = gql`\n query getComponentAspects($id: String!) {\n getHost {\n id\n get(id: $id) {\n aspects {\n id\n }\n }\n }\n }\n`;\ntype QueryResult = {\n getHost: {\n id: string;\n get: {\n aspects: { id: string }[];\n };\n };\n};\n\nexport async function fetchComponentAspects(componentId: string) {\n try {\n const response = await request<QueryResult>(GQL_SERVER, GET_COMPONENT_ASPECTS, { id: componentId.toString() });\n return response.getHost.get.aspects.map((x) => x.id);\n } catch (err: any) {\n // eslint-disable-next-line no-console\n console.error(`[gql] error on \"getComponentAspects\" - \"${err.toString()}\"`);\n return undefined;\n }\n}\n"],"mappings":";;;;;;AAAA,SAAAA,gBAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,eAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,MAAME,UAAU,GAAG,UAAU;AAC7B,MAAMC,qBAAqB,GAAG,IAAAC,qBAAG,CAAC;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAUM,eAAeC,qBAAqBA,CAACC,WAAmB,EAAE;EAC/D,IAAI;IACF,MAAMC,QAAQ,GAAG,MAAM,IAAAC,yBAAO,EAAcN,UAAU,EAAEC,qBAAqB,EAAE;MAAEM,EAAE,EAAEH,WAAW,CAACI,QAAQ,CAAC;IAAE,CAAC,CAAC;IAC9G,OAAOH,QAAQ,CAACI,OAAO,CAACC,GAAG,CAACC,OAAO,CAACC,GAAG,CAAEC,CAAC,IAAKA,CAAC,CAACN,EAAE,CAAC;EACtD,CAAC,CAAC,OAAOO,GAAQ,EAAE;IACjB;IACAC,OAAO,CAACC,KAAK,CAAE,2CAA0CF,GAAG,CAACN,QAAQ,CAAC,CAAE,GAAE,CAAC;IAC3E,OAAOS,SAAS;EAClB;AACF","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["loadScript","src","Promise","resolve","reject","script","document","createElement","setAttribute","onload","onerror","message","_","_1","_2","error","Error","head","appendChild","loadLink","href","link","endsWith"],"sources":["html-utils.tsx"],"sourcesContent":["export function loadScript({ src }: { src: string }) {\n return new Promise<void>((resolve, reject) => {\n const script = document.createElement('script');\n\n script.setAttribute('defer', 'defer');\n script.src = src;\n\n script.onload = () => resolve();\n script.onerror = (message, _, _1, _2, error) =>\n reject(error || new Error(`[preview.preview] failed to load script: ${message}`));\n\n document.head.appendChild(script);\n });\n}\n\nexport function loadLink({ href }: { href: string }) {\n return new Promise<void>((resolve, reject) => {\n const link = document.createElement('link');\n\n if (href.endsWith('.css')) link.setAttribute('rel', 'stylesheet');\n link.setAttribute('href', href);\n\n link.onload = () => resolve();\n link.onerror = (message, _, _1, _2, error) =>\n reject(error || new Error(`[preview.preview] failed to load link: ${message}`));\n\n document.head.appendChild(link);\n });\n}\n"],"mappings":";;;;;;;AAAO,SAASA,UAAUA,CAAC;EAAEC;AAAqB,CAAC,EAAE;EACnD,OAAO,IAAIC,OAAO,CAAO,CAACC,OAAO,EAAEC,MAAM,KAAK;IAC5C,MAAMC,MAAM,GAAGC,QAAQ,CAACC,aAAa,CAAC,QAAQ,CAAC;IAE/CF,MAAM,CAACG,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC;IACrCH,MAAM,CAACJ,GAAG,GAAGA,GAAG;IAEhBI,MAAM,CAACI,MAAM,GAAG,MAAMN,OAAO,CAAC,CAAC;IAC/BE,MAAM,CAACK,OAAO,GAAG,CAACC,OAAO,EAAEC,CAAC,EAAEC,EAAE,EAAEC,EAAE,EAAEC,KAAK,KACzCX,MAAM,CAACW,KAAK,IAAI,IAAIC,KAAK,CAAE,4CAA2CL,OAAQ,EAAC,CAAC,CAAC;IAEnFL,QAAQ,CAACW,IAAI,CAACC,WAAW,CAACb,MAAM,CAAC;EACnC,CAAC,CAAC;AACJ;AAEO,SAASc,QAAQA,CAAC;EAAEC;AAAuB,CAAC,EAAE;EACnD,OAAO,IAAIlB,OAAO,CAAO,CAACC,OAAO,EAAEC,MAAM,KAAK;IAC5C,MAAMiB,IAAI,GAAGf,QAAQ,CAACC,aAAa,CAAC,MAAM,CAAC;IAE3C,IAAIa,IAAI,CAACE,QAAQ,CAAC,MAAM,CAAC,EAAED,IAAI,CAACb,YAAY,CAAC,KAAK,EAAE,YAAY,CAAC;IACjEa,IAAI,CAACb,YAAY,CAAC,MAAM,EAAEY,IAAI,CAAC;IAE/BC,IAAI,CAACZ,MAAM,GAAG,MAAMN,OAAO,CAAC,CAAC;IAC7BkB,IAAI,CAACX,OAAO,GAAG,CAACC,OAAO,EAAEC,CAAC,EAAEC,EAAE,EAAEC,EAAE,EAAEC,KAAK,KACvCX,MAAM,CAACW,KAAK,IAAI,IAAIC,KAAK,CAAE,0CAAyCL,OAAQ,EAAC,CAAC,CAAC;IAEjFL,QAAQ,CAACW,IAAI,CAACC,WAAW,CAACG,IAAI,CAAC;EACjC,CAAC,CAAC;AACJ"}
1
+ {"version":3,"names":["loadScript","src","Promise","resolve","reject","script","document","createElement","setAttribute","onload","onerror","message","_","_1","_2","error","Error","head","appendChild","loadLink","href","link","endsWith"],"sources":["html-utils.tsx"],"sourcesContent":["export function loadScript({ src }: { src: string }) {\n return new Promise<void>((resolve, reject) => {\n const script = document.createElement('script');\n\n script.setAttribute('defer', 'defer');\n script.src = src;\n\n script.onload = () => resolve();\n script.onerror = (message, _, _1, _2, error) =>\n reject(error || new Error(`[preview.preview] failed to load script: ${message}`));\n\n document.head.appendChild(script);\n });\n}\n\nexport function loadLink({ href }: { href: string }) {\n return new Promise<void>((resolve, reject) => {\n const link = document.createElement('link');\n\n if (href.endsWith('.css')) link.setAttribute('rel', 'stylesheet');\n link.setAttribute('href', href);\n\n link.onload = () => resolve();\n link.onerror = (message, _, _1, _2, error) =>\n reject(error || new Error(`[preview.preview] failed to load link: ${message}`));\n\n document.head.appendChild(link);\n });\n}\n"],"mappings":";;;;;;;AAAO,SAASA,UAAUA,CAAC;EAAEC;AAAqB,CAAC,EAAE;EACnD,OAAO,IAAIC,OAAO,CAAO,CAACC,OAAO,EAAEC,MAAM,KAAK;IAC5C,MAAMC,MAAM,GAAGC,QAAQ,CAACC,aAAa,CAAC,QAAQ,CAAC;IAE/CF,MAAM,CAACG,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC;IACrCH,MAAM,CAACJ,GAAG,GAAGA,GAAG;IAEhBI,MAAM,CAACI,MAAM,GAAG,MAAMN,OAAO,CAAC,CAAC;IAC/BE,MAAM,CAACK,OAAO,GAAG,CAACC,OAAO,EAAEC,CAAC,EAAEC,EAAE,EAAEC,EAAE,EAAEC,KAAK,KACzCX,MAAM,CAACW,KAAK,IAAI,IAAIC,KAAK,CAAE,4CAA2CL,OAAQ,EAAC,CAAC,CAAC;IAEnFL,QAAQ,CAACW,IAAI,CAACC,WAAW,CAACb,MAAM,CAAC;EACnC,CAAC,CAAC;AACJ;AAEO,SAASc,QAAQA,CAAC;EAAEC;AAAuB,CAAC,EAAE;EACnD,OAAO,IAAIlB,OAAO,CAAO,CAACC,OAAO,EAAEC,MAAM,KAAK;IAC5C,MAAMiB,IAAI,GAAGf,QAAQ,CAACC,aAAa,CAAC,MAAM,CAAC;IAE3C,IAAIa,IAAI,CAACE,QAAQ,CAAC,MAAM,CAAC,EAAED,IAAI,CAACb,YAAY,CAAC,KAAK,EAAE,YAAY,CAAC;IACjEa,IAAI,CAACb,YAAY,CAAC,MAAM,EAAEY,IAAI,CAAC;IAE/BC,IAAI,CAACZ,MAAM,GAAG,MAAMN,OAAO,CAAC,CAAC;IAC7BkB,IAAI,CAACX,OAAO,GAAG,CAACC,OAAO,EAAEC,CAAC,EAAEC,EAAE,EAAEC,EAAE,EAAEC,KAAK,KACvCX,MAAM,CAACW,KAAK,IAAI,IAAIC,KAAK,CAAE,0CAAyCL,OAAQ,EAAC,CAAC,CAAC;IAEjFL,QAAQ,CAACW,IAAI,CAACC,WAAW,CAACG,IAAI,CAAC;EACjC,CAAC,CAAC;AACJ","ignoreList":[]}
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["_preview","data","require","_events","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_strategiesNames"],"sources":["index.ts"],"sourcesContent":["export { PreviewAspect as default, PreviewAspect, PreviewRuntime } from './preview.aspect';\n\nexport * from './events';\nexport type { PreviewEnv, Preview } from './preview-env';\nexport type {\n PreviewMain,\n EnvPreviewConfig,\n ComponentPreviewSize,\n PreviewStrategyName,\n PreviewFiles,\n ComponentPreviewMetaData,\n} from './preview.main.runtime';\nexport type { PreviewPreview, RenderingContextOptions, RenderingContextProvider } from './preview.preview.runtime';\nexport type { PreviewDefinition } from './preview-definition';\nexport type { PreviewModule, ModuleFile } from './types/preview-module';\nexport type { RenderingContext } from './rendering-context';\n// Exporting directly from the inner file to prevent breaking the bundling process\nexport { ENV_PREVIEW_STRATEGY_NAME, COMPONENT_PREVIEW_STRATEGY_NAME } from './strategies/strategies-names';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAAA,SAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,QAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,IAAAE,OAAA,GAAAD,OAAA;AAAAE,MAAA,CAAAC,IAAA,CAAAF,OAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAJ,OAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAZ,OAAA,CAAAI,GAAA;IAAA;EAAA;AAAA;AAeA,SAAAS,iBAAA;EAAA,MAAAf,IAAA,GAAAC,OAAA;EAAAc,gBAAA,YAAAA,CAAA;IAAA,OAAAf,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA"}
1
+ {"version":3,"names":["_preview","data","require","_events","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_strategiesNames"],"sources":["index.ts"],"sourcesContent":["export { PreviewAspect as default, PreviewAspect, PreviewRuntime } from './preview.aspect';\n\nexport * from './events';\nexport type { PreviewEnv, Preview } from './preview-env';\nexport type {\n PreviewMain,\n EnvPreviewConfig,\n ComponentPreviewSize,\n PreviewStrategyName,\n PreviewFiles,\n ComponentPreviewMetaData,\n} from './preview.main.runtime';\nexport type { PreviewPreview, RenderingContextOptions, RenderingContextProvider } from './preview.preview.runtime';\nexport type { PreviewDefinition } from './preview-definition';\nexport type { PreviewModule, ModuleFile } from './types/preview-module';\nexport type { RenderingContext } from './rendering-context';\n// Exporting directly from the inner file to prevent breaking the bundling process\nexport { ENV_PREVIEW_STRATEGY_NAME, COMPONENT_PREVIEW_STRATEGY_NAME } from './strategies/strategies-names';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAAA,SAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,QAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,IAAAE,OAAA,GAAAD,OAAA;AAAAE,MAAA,CAAAC,IAAA,CAAAF,OAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAJ,OAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAZ,OAAA,CAAAI,GAAA;IAAA;EAAA;AAAA;AAeA,SAAAS,iBAAA;EAAA,MAAAf,IAAA,GAAAC,OAAA;EAAAc,gBAAA,YAAAA,CAAA;IAAA,OAAAf,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["_fsExtra","data","require","_os","_path","makeTempDir","prefix","mkdtempSync","tmpdir","sep"],"sources":["mk-temp-dir.ts"],"sourcesContent":["import { mkdtempSync } from 'fs-extra';\nimport { tmpdir } from 'os';\nimport { sep } from 'path';\n\nexport function makeTempDir(prefix = '') {\n return mkdtempSync(`${tmpdir()}${sep}${prefix}`);\n}\n"],"mappings":";;;;;;AAAA,SAAAA,SAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,QAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,IAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,GAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,MAAA;EAAA,MAAAH,IAAA,GAAAC,OAAA;EAAAE,KAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEO,SAASI,WAAWA,CAACC,MAAM,GAAG,EAAE,EAAE;EACvC,OAAO,IAAAC,sBAAW,EAAE,GAAE,IAAAC,YAAM,EAAC,CAAE,GAAEC,WAAI,GAAEH,MAAO,EAAC,CAAC;AAClD"}
1
+ {"version":3,"names":["_fsExtra","data","require","_os","_path","makeTempDir","prefix","mkdtempSync","tmpdir","sep"],"sources":["mk-temp-dir.ts"],"sourcesContent":["import { mkdtempSync } from 'fs-extra';\nimport { tmpdir } from 'os';\nimport { sep } from 'path';\n\nexport function makeTempDir(prefix = '') {\n return mkdtempSync(`${tmpdir()}${sep}${prefix}`);\n}\n"],"mappings":";;;;;;AAAA,SAAAA,SAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,QAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,IAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,GAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,MAAA;EAAA,MAAAH,IAAA,GAAAC,OAAA;EAAAE,KAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEO,SAASI,WAAWA,CAACC,MAAM,GAAG,EAAE,EAAE;EACvC,OAAO,IAAAC,sBAAW,EAAE,GAAE,IAAAC,YAAM,EAAC,CAAE,GAAEC,WAAI,GAAEH,MAAO,EAAC,CAAC;AAClD","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["_path","data","require","_fsExtra","_aspectLoader","_utils","BUNDLE_HASH_FILENAME","exports","readBundleHash","bundleId","bundleDir","aspectDir","bundleUiPathFromBvm","getBundlePath","hashFilePath","join","existsSync","readFileSync","toString","createBundleHash","uiRoot","runtime","aspects","resolveAspects","sort","a","b","getId","aspectPath","aspectIds","map","aspect","sha1","generateBundleHash","outputPath","hash","mkdirSync","writeFileSync","getBundleArtifactDirectory","getBundleArtifactDef","rootDir","name","globPatterns","dirFromBvms","getAspectDirFromBvm","bundlePath","undefined","err","clearConsole","process","stdout","write","platform"],"sources":["pre-bundle-utils.ts"],"sourcesContent":["import { join } from 'path';\nimport { existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs-extra';\nimport { UIRoot } from '@teambit/ui';\nimport { getAspectDirFromBvm } from '@teambit/aspect-loader';\nimport { SlotRegistry } from '@teambit/harmony';\nimport { ArtifactDefinition } from '@teambit/builder';\nimport { sha1 } from '@teambit/legacy/dist/utils';\n\n/// utils\n\nexport type UIRootRegistry = SlotRegistry<UIRoot>;\n\n// bundle hash\n\nexport const BUNDLE_HASH_FILENAME = '.hash';\n\nexport function readBundleHash(bundleId: string, bundleDir: string, aspectDir: string): string {\n const bundleUiPathFromBvm = getBundlePath(bundleId, bundleDir, aspectDir);\n if (!bundleUiPathFromBvm) {\n return '';\n }\n const hashFilePath = join(bundleUiPathFromBvm, BUNDLE_HASH_FILENAME);\n if (existsSync(hashFilePath)) {\n return readFileSync(hashFilePath).toString();\n }\n return '';\n}\n\nexport async function createBundleHash(uiRoot: UIRoot, runtime: string): Promise<string> {\n const aspects = await uiRoot.resolveAspects(runtime);\n aspects.sort((a, b) => ((a.getId || a.aspectPath) > (b.getId || b.aspectPath) ? 1 : -1));\n const aspectIds = aspects.map((aspect) => aspect.getId || aspect.aspectPath);\n return sha1(aspectIds.join(''));\n}\n\nexport async function generateBundleHash(uiRoot: UIRoot, runtime: string, outputPath: string): Promise<void> {\n const hash = await createBundleHash(uiRoot, runtime);\n if (!existsSync(outputPath)) mkdirSync(outputPath);\n writeFileSync(join(outputPath, BUNDLE_HASH_FILENAME), hash);\n}\n\n// bundle artifact\n\nexport function getBundleArtifactDirectory(bundleDir: string, aspectDir: string) {\n return join('artifacts', bundleDir, aspectDir);\n}\n\nexport function getBundleArtifactDef(bundleDir: string, aspectDir: string): ArtifactDefinition {\n const rootDir = getBundleArtifactDirectory(bundleDir, aspectDir);\n return {\n name: `${bundleDir}${aspectDir ? '-' : ''}${aspectDir}`,\n globPatterns: [`${rootDir}/**`],\n };\n}\n\nexport function getBundlePath(bundleId: string, bundleDir: string, aspectDir: string): string | undefined {\n try {\n const dirFromBvms = getAspectDirFromBvm(bundleId);\n const bundlePath = join(dirFromBvms, getBundleArtifactDirectory(bundleDir, aspectDir));\n if (!existsSync(bundlePath)) {\n return undefined;\n }\n return bundlePath;\n } catch (err) {\n return undefined;\n }\n}\n\n// others\n\nexport function clearConsole() {\n process.stdout.write(process.platform === 'win32' ? '\\x1B[2J\\x1B[0f' : '\\x1B[2J\\x1B[3J\\x1B[H');\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;AAEA,SAAAG,cAAA;EAAA,MAAAH,IAAA,GAAAC,OAAA;EAAAE,aAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAGA,SAAAI,OAAA;EAAA,MAAAJ,IAAA,GAAAC,OAAA;EAAAG,MAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA;;AAIA;;AAEO,MAAMK,oBAAoB,GAAAC,OAAA,CAAAD,oBAAA,GAAG,OAAO;AAEpC,SAASE,cAAcA,CAACC,QAAgB,EAAEC,SAAiB,EAAEC,SAAiB,EAAU;EAC7F,MAAMC,mBAAmB,GAAGC,aAAa,CAACJ,QAAQ,EAAEC,SAAS,EAAEC,SAAS,CAAC;EACzE,IAAI,CAACC,mBAAmB,EA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AEC,SAAS,CAAC;AAChD;AAEO,SAAS4B,oBAAoBA,CAAC7B,SAAiB,EAAEC,SAAiB,EAAsB;EAC7F,MAAM6B,OAAO,GAAGF,0BAA0B,CAAC5B,SAAS,EAAEC,SAAS,CAAC;EAChE,OAAO;IACL8B,IAAI,EAAG,GAAE/B,SAAU,GAAEC,SAAS,GAAG,GAAG,GAAG,EAAG,GAAEA,SAAU,EAAC;IACvD+B,YAAY,EAAE,CAAE,GAAEF,OAAQ,KAAI;EAChC,CAAC;AACH;AAEO,SAAS3B,aAAaA,CAACJ,QAAgB,EAAEC,SAAiB,EAAEC,SAAiB,EAAsB;EACxG,IAAI;IACF,MAAMgC,WAAW,GAAG,IAAAC,mCAAmB,EAACnC,QAAQ,CAAC;IACjD,MAAMoC,UAAU,GAAG,IAAA9B,YAAI,EAAC4B,WAAW,EAAEL,0BAA0B,CAAC5B,SAAS,EAAEC,SAAS,CAAC,CAAC;IACtF,IAAI,CAAC,IAAAK,qBAAU,EAAC6B,UAAU,CAAC,EAAE;MAC3B,OAAOC,SAAS;IAClB;IACA,OAAOD,UAAU;EACnB,CAAC,CAAC,OAAOE,GAAG,EAAE;IACZ,OAAOD,SAAS;EAClB;AACF;;AAEA;;AAEO,SAASE,YAAYA,CAAA,EAAG;EAC7BC,OAAO,CAACC,MAAM,CAACC,KAAK,CAACF,OAAO,CAACG,QAAQ,KAAK,OAAO,GAAG,gBAAgB,GAAG,sBAAsB,CAAC;AAChG"}
1
+ {"version":3,"names":["_path","data","require","_fsExtra","_aspectLoader","_utils","BUNDLE_HASH_FILENAME","exports","readBundleHash","bundleId","bundleDir","aspectDir","bundleUiPathFromBvm","getBundlePath","hashFilePath","join","existsSync","readFileSync","toString","createBundleHash","uiRoot","runtime","aspects","resolveAspects","sort","a","b","getId","aspectPath","aspectIds","map","aspect","sha1","generateBundleHash","outputPath","hash","mkdirSync","writeFileSync","getBundleArtifactDirectory","getBundleArtifactDef","rootDir","name","globPatterns","dirFromBvms","getAspectDirFromBvm","bundlePath","undefined","err","clearConsole","process","stdout","write","platform"],"sources":["pre-bundle-utils.ts"],"sourcesContent":["import { join } from 'path';\nimport { existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs-extra';\nimport { UIRoot } from '@teambit/ui';\nimport { getAspectDirFromBvm } from '@teambit/aspect-loader';\nimport { SlotRegistry } from '@teambit/harmony';\nimport { ArtifactDefinition } from '@teambit/builder';\nimport { sha1 } from '@teambit/legacy/dist/utils';\n\n/// utils\n\nexport type UIRootRegistry = SlotRegistry<UIRoot>;\n\n// bundle hash\n\nexport const BUNDLE_HASH_FILENAME = '.hash';\n\nexport function readBundleHash(bundleId: string, bundleDir: string, aspectDir: string): string {\n const bundleUiPathFromBvm = getBundlePath(bundleId, bundleDir, aspectDir);\n if (!bundleUiPathFromBvm) {\n return '';\n }\n const hashFilePath = join(bundleUiPathFromBvm, BUNDLE_HASH_FILENAME);\n if (existsSync(hashFilePath)) {\n return readFileSync(hashFilePath).toString();\n }\n return '';\n}\n\nexport async function createBundleHash(uiRoot: UIRoot, runtime: string): Promise<string> {\n const aspects = await uiRoot.resolveAspects(runtime);\n aspects.sort((a, b) => ((a.getId || a.aspectPath) > (b.getId || b.aspectPath) ? 1 : -1));\n const aspectIds = aspects.map((aspect) => aspect.getId || aspect.aspectPath);\n return sha1(aspectIds.join(''));\n}\n\nexport async function generateBundleHash(uiRoot: UIRoot, runtime: string, outputPath: string): Promise<void> {\n const hash = await createBundleHash(uiRoot, runtime);\n if (!existsSync(outputPath)) mkdirSync(outputPath);\n writeFileSync(join(outputPath, BUNDLE_HASH_FILENAME), hash);\n}\n\n// bundle artifact\n\nexport function getBundleArtifactDirectory(bundleDir: string, aspectDir: string) {\n return join('artifacts', bundleDir, aspectDir);\n}\n\nexport function getBundleArtifactDef(bundleDir: string, aspectDir: string): ArtifactDefinition {\n const rootDir = getBundleArtifactDirectory(bundleDir, aspectDir);\n return {\n name: `${bundleDir}${aspectDir ? '-' : ''}${aspectDir}`,\n globPatterns: [`${rootDir}/**`],\n };\n}\n\nexport function getBundlePath(bundleId: string, bundleDir: string, aspectDir: string): string | undefined {\n try {\n const dirFromBvms = getAspectDirFromBvm(bundleId);\n const bundlePath = join(dirFromBvms, getBundleArtifactDirectory(bundleDir, aspectDir));\n if (!existsSync(bundlePath)) {\n return undefined;\n }\n return bundlePath;\n } catch (err) {\n return undefined;\n }\n}\n\n// others\n\nexport function clearConsole() {\n process.stdout.write(process.platform === 'win32' ? '\\x1B[2J\\x1B[0f' : '\\x1B[2J\\x1B[3J\\x1B[H');\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;AAEA,SAAAG,cAAA;EAAA,MAAAH,IAAA,GAAAC,OAAA;EAAAE,aAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAGA,SAAAI,OAAA;EAAA,MAAAJ,IAAA,GAAAC,OAAA;EAAAG,MAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA;;AAIA;;AAEO,MAAMK,oBAAoB,GAAAC,OAAA,CAAAD,oBAAA,GAAG,OAAO;AAEpC,SAASE,cAAcA,CAACC,QAAgB,EAAEC,SAAiB,EAAEC,SAAiB,EAAU;EAC7F,MAAMC,mBAAmB,GAAGC,aAAa,CAACJ,QAAQ,EAAEC,SAAS,EAAEC,SAAS,CAAC;EACzE,IAAI,CAACC,mBAAmB,EAAE;IACxB,OAAO,EAAE;EACX;EACA,MAAME,YAAY,GAAG,IAAAC,YAAI,EAACH,mBAAmB,EAAEN,oBAAo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,MAAM6B,OAAO,GAAGF,0BAA0B,CAAC5B,SAAS,EAAEC,SAAS,CAAC;EAChE,OAAO;IACL8B,IAAI,EAAG,GAAE/B,SAAU,GAAEC,SAAS,GAAG,GAAG,GAAG,EAAG,GAAEA,SAAU,EAAC;IACvD+B,YAAY,EAAE,CAAE,GAAEF,OAAQ,KAAI;EAChC,CAAC;AACH;AAEO,SAAS3B,aAAaA,CAACJ,QAAgB,EAAEC,SAAiB,EAAEC,SAAiB,EAAsB;EACxG,IAAI;IACF,MAAMgC,WAAW,GAAG,IAAAC,mCAAmB,EAACnC,QAAQ,CAAC;IACjD,MAAMoC,UAAU,GAAG,IAAA9B,YAAI,EAAC4B,WAAW,EAAEL,0BAA0B,CAAC5B,SAAS,EAAEC,SAAS,CAAC,CAAC;IACtF,IAAI,CAAC,IAAAK,qBAAU,EAAC6B,UAAU,CAAC,EAAE;MAC3B,OAAOC,SAAS;IAClB;IACA,OAAOD,UAAU;EACnB,CAAC,CAAC,OAAOE,GAAG,EAAE;IACZ,OAAOD,SAAS;EAClB;AACF;;AAEA;;AAEO,SAASE,YAAYA,CAAA,EAAG;EAC7BC,OAAO,CAACC,MAAM,CAACC,KAAK,CAACF,OAAO,CAACG,QAAQ,KAAK,OAAO,GAAG,gBAAgB,GAAG,sBAAsB,CAAC;AAChG","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["_path","data","require","_fsExtra","_interopRequireWildcard","_harmonyModules","_utils","_toolboxPath","_webpack","_interopRequireDefault","_util","_preview","_webpack2","_preBundleUtils","obj","__esModule","default","_getRequireWildcardCache","e","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","RUNTIME_NAME","exports","PUBLIC_DIR","join","UIROOT_ASPECT_ID","ENTRY_CONTENT_TEMPLATE","generatePreBundlePreviewEntry","aspectDefs","rootExtensionName","runtimeName","rootAspectId","dir","harmonyImport","createHarmonyImports","imports","createImports","identifiers","getIdentifiers","idSetters","getIdSetters","contents","replace","replaceAll","JSON","stringify","entryPath","resolve","sha1","fs","existsSync","outputFileSync","buildPreBundlePreview","resolvedAspects","customOutputDir","outputDir","mainEntry","PreviewAspect","id","__dirname","config","createWebpackConfig","compiler","webpack","compilerRun","promisify","run","bind","results","Error","hasErrors","clearConsole","toString","generateBundlePreviewEntry","previewPreBundlePath","manifestPath","manifest","readJsonSync","entrypoints","map","entry","toWindowsCompatiblePath","endsWith","previewRuntime"],"sources":["pre-bundle.ts"],"sourcesContent":["import { join, resolve } from 'path';\nimport fs, { existsSync, outputFileSync, readJsonSync } from 'fs-extra';\nimport { AspectDefinition } from '@teambit/aspect-loader';\nimport {\n createHarmonyImports,\n createImports,\n getIdSetters,\n getIdentifiers,\n} from '@teambit/harmony.modules.harmony-root-generator';\nimport { sha1 } from '@teambit/legacy/dist/utils';\nimport { toWindowsCompatiblePath } from '@teambit/toolbox.path.to-windows-compatible-path';\nimport webpack from 'webpack';\nimport { promisify } from 'util';\nimport { PreviewAspect } from './preview.aspect';\nimport { createWebpackConfig } from './webpack/webpack.config';\nimport { clearConsole } from './pre-bundle-utils';\n\nexport const RUNTIME_NAME = 'preview';\nexport const PUBLIC_DIR = join('public', 'bit-preview');\nexport const UIROOT_ASPECT_ID = 'teambit.workspace/workspace';\n\nconst ENTRY_CONTENT_TEMPLATE = `__IMPORTS__\n\nexport const run = (config, customAspects = []) => {\n const isBrowser = typeof window !== \"undefined\";\n const windowConfig = isBrowser ? window.harmonyAppConfig : undefined;\n const mergedConfig = { ...config, ...windowConfig };\n __ID_SETTERS__\n function render(...props) {\n return Harmony.load(\n [\n ...customAspects,\n __IDENTIFIERS__,\n ],\n __RUNTIME_NAME__,\n mergedConfig\n ).then((harmony) => {\n return harmony\n .run()\n .then(() => harmony.get(__ROOT_ASPECT__))\n .then((rootExtension) => {\n const ssrSetup = !isBrowser && rootExtension.setupSsr;\n const setup = rootExtension.setup;\n const setupFunc = (ssrSetup || setup || function noop() {}).bind(\n rootExtension\n );\n return Promise.resolve(setupFunc()).then(\n () => {\n return rootExtension\n }\n );\n })\n .then((rootExtension) => {\n if (isBrowser) {\n return rootExtension.render(\n __ROOT_EXTENSION_NAME__,\n ...props\n );\n } else {\n return rootExtension.renderSsr(\n __ROOT_EXTENSION_NAME__,\n ...props\n );\n }\n })\n .catch((err) => {\n throw err;\n });\n });\n }\n if (isBrowser || __RUNTIME_NAME__ === \"main\") render();\n};\n`;\n\nexport const generatePreBundlePreviewEntry = (\n aspectDefs: AspectDefinition[],\n rootExtensionName: string,\n runtimeName: string,\n rootAspectId: string,\n dir: string\n) => {\n const harmonyImport = createHarmonyImports();\n const imports = createImports(aspectDefs);\n const identifiers = getIdentifiers(aspectDefs, 'Aspect');\n const idSetters = getIdSetters(aspectDefs, 'Aspect');\n const contents = ENTRY_CONTENT_TEMPLATE.replace('__IMPORTS__', [harmonyImport, imports].join('\\n'))\n .replace('__IDENTIFIERS__', identifiers.join(', '))\n .replace('__ID_SETTERS__', idSetters.join('\\n'))\n .replaceAll('__RUNTIME_NAME__', JSON.stringify(runtimeName))\n .replaceAll('__ROOT_ASPECT__', JSON.stringify(rootAspectId))\n .replaceAll('__ROOT_EXTENSION_NAME__', JSON.stringify(rootExtensionName));\n const entryPath = resolve(join(dir, `ui-bundle-entry.${sha1(contents)}.js`));\n if (!fs.existsSync(entryPath)) {\n fs.outputFileSync(entryPath, contents);\n }\n return entryPath;\n};\n\nexport async function buildPreBundlePreview(resolvedAspects: AspectDefinition[], customOutputDir?: string) {\n const outputDir = customOutputDir || resolve(PUBLIC_DIR);\n const mainEntry = generatePreBundlePreviewEntry(\n resolvedAspects,\n UIROOT_ASPECT_ID,\n RUNTIME_NAME,\n PreviewAspect.id,\n __dirname\n );\n const config = createWebpackConfig(outputDir, mainEntry);\n const compiler = webpack(config);\n const compilerRun = promisify(compiler.run.bind(compiler));\n const results = await compilerRun();\n if (!results) throw new Error();\n if (results?.hasErrors()) {\n clearConsole();\n throw new Error(results?.toString());\n }\n return results;\n}\n\nexport async function generateBundlePreviewEntry(rootAspectId: string, previewPreBundlePath: string, config: object) {\n const manifestPath = join(previewPreBundlePath, 'asset-manifest.json');\n const manifest = readJsonSync(manifestPath);\n const imports = manifest.entrypoints\n .map((entry: string) => {\n const entryPath = toWindowsCompatiblePath(join(previewPreBundlePath, entry));\n return entry.endsWith('.js') || entry.endsWith('.cjs') || entry.endsWith('.mjs')\n ? `import { run } from '${entryPath}';`\n : `import '${entryPath}';`;\n })\n .join('\\n');\n config['teambit.harmony/bit'] = rootAspectId;\n\n const contents = [imports, `run(${JSON.stringify(config, null, 2)});`].join('\\n');\n const previewRuntime = resolve(join(__dirname, `preview.entry.${sha1(contents)}.js`));\n\n if (!existsSync(previewRuntime)) {\n outputFileSync(previewRuntime, contents);\n }\n\n return previewRuntime;\n}\n"],"mappings":";;;;;;;;;AAAA,SAAAA,MAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,KAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,SAAA;EAAA,MAAAF,IAAA,GAAAG,uBAAA,CAAAF,OAAA;EAAAC,QAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAI,gBAAA;EAAA,MAAAJ,IAAA,GAAAC,OAAA;EAAAG,eAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAMA,SAAAK,OAAA;EAAA,MAAAL,IAAA,GAAAC,OAAA;EAAAI,MAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAM,aAAA;EAAA,MAAAN,IAAA,GAAAC,OAAA;EAAAK,YAAA,YAAAA,CAAA;IAAA,OAAAN,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAO,SAAA;EAAA,MAAAP,IAAA,GAAA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AAU,IAAG;EAC9B,CAAC,CAAC,CACDtB,IAAI,CAAC,IAAI,CAAC;EACboC,MAAM,CAAC,qBAAqB,CAAC,GAAG7B,YAAY;EAE5C,MAAMU,QAAQ,GAAG,CAACN,OAAO,EAAG,OAAMS,IAAI,CAACC,SAAS,CAACe,MAAM,EAAE,IAAI,EAAE,CAAC,CAAE,IAAG,CAAC,CAACpC,IAAI,CAAC,IAAI,CAAC;EACjF,MAAM2D,cAAc,GAAG,IAAApC,eAAO,EAAC,IAAAvB,YAAI,EAACmC,SAAS,EAAG,iBAAgB,IAAAX,aAAI,EAACP,QAAQ,CAAE,KAAI,CAAC,CAAC;EAErF,IAAI,CAAC,IAAAS,qBAAU,EAACiC,cAAc,CAAC,EAAE;IAC/B,IAAAhC,yBAAc,EAACgC,cAAc,EAAE1C,QAAQ,CAAC;EAC1C;EAEA,OAAO0C,cAAc;AACvB"}
1
+ {"version":3,"names":["_path","data","require","_fsExtra","_interopRequireWildcard","_harmonyModules","_utils","_toolboxPath","_webpack","_interopRequireDefault","_util","_preview","_webpack2","_preBundleUtils","obj","__esModule","default","_getRequireWildcardCache","e","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","RUNTIME_NAME","exports","PUBLIC_DIR","join","UIROOT_ASPECT_ID","ENTRY_CONTENT_TEMPLATE","generatePreBundlePreviewEntry","aspectDefs","rootExtensionName","runtimeName","rootAspectId","dir","harmonyImport","createHarmonyImports","imports","createImports","identifiers","getIdentifiers","idSetters","getIdSetters","contents","replace","replaceAll","JSON","stringify","entryPath","resolve","sha1","fs","existsSync","outputFileSync","buildPreBundlePreview","resolvedAspects","customOutputDir","outputDir","mainEntry","PreviewAspect","id","__dirname","config","createWebpackConfig","compiler","webpack","compilerRun","promisify","run","bind","results","Error","hasErrors","clearConsole","toString","generateBundlePreviewEntry","previewPreBundlePath","manifestPath","manifest","readJsonSync","entrypoints","map","entry","toWindowsCompatiblePath","endsWith","previewRuntime"],"sources":["pre-bundle.ts"],"sourcesContent":["import { join, resolve } from 'path';\nimport fs, { existsSync, outputFileSync, readJsonSync } from 'fs-extra';\nimport { AspectDefinition } from '@teambit/aspect-loader';\nimport {\n createHarmonyImports,\n createImports,\n getIdSetters,\n getIdentifiers,\n} from '@teambit/harmony.modules.harmony-root-generator';\nimport { sha1 } from '@teambit/legacy/dist/utils';\nimport { toWindowsCompatiblePath } from '@teambit/toolbox.path.to-windows-compatible-path';\nimport webpack from 'webpack';\nimport { promisify } from 'util';\nimport { PreviewAspect } from './preview.aspect';\nimport { createWebpackConfig } from './webpack/webpack.config';\nimport { clearConsole } from './pre-bundle-utils';\n\nexport const RUNTIME_NAME = 'preview';\nexport const PUBLIC_DIR = join('public', 'bit-preview');\nexport const UIROOT_ASPECT_ID = 'teambit.workspace/workspace';\n\nconst ENTRY_CONTENT_TEMPLATE = `__IMPORTS__\n\nexport const run = (config, customAspects = []) => {\n const isBrowser = typeof window !== \"undefined\";\n const windowConfig = isBrowser ? window.harmonyAppConfig : undefined;\n const mergedConfig = { ...config, ...windowConfig };\n __ID_SETTERS__\n function render(...props) {\n return Harmony.load(\n [\n ...customAspects,\n __IDENTIFIERS__,\n ],\n __RUNTIME_NAME__,\n mergedConfig\n ).then((harmony) => {\n return harmony\n .run()\n .then(() => harmony.get(__ROOT_ASPECT__))\n .then((rootExtension) => {\n const ssrSetup = !isBrowser && rootExtension.setupSsr;\n const setup = rootExtension.setup;\n const setupFunc = (ssrSetup || setup || function noop() {}).bind(\n rootExtension\n );\n return Promise.resolve(setupFunc()).then(\n () => {\n return rootExtension\n }\n );\n })\n .then((rootExtension) => {\n if (isBrowser) {\n return rootExtension.render(\n __ROOT_EXTENSION_NAME__,\n ...props\n );\n } else {\n return rootExtension.renderSsr(\n __ROOT_EXTENSION_NAME__,\n ...props\n );\n }\n })\n .catch((err) => {\n throw err;\n });\n });\n }\n if (isBrowser || __RUNTIME_NAME__ === \"main\") render();\n};\n`;\n\nexport const generatePreBundlePreviewEntry = (\n aspectDefs: AspectDefinition[],\n rootExtensionName: string,\n runtimeName: string,\n rootAspectId: string,\n dir: string\n) => {\n const harmonyImport = createHarmonyImports();\n const imports = createImports(aspectDefs);\n const identifiers = getIdentifiers(aspectDefs, 'Aspect');\n const idSetters = getIdSetters(aspectDefs, 'Aspect');\n const contents = ENTRY_CONTENT_TEMPLATE.replace('__IMPORTS__', [harmonyImport, imports].join('\\n'))\n .replace('__IDENTIFIERS__', identifiers.join(', '))\n .replace('__ID_SETTERS__', idSetters.join('\\n'))\n .replaceAll('__RUNTIME_NAME__', JSON.stringify(runtimeName))\n .replaceAll('__ROOT_ASPECT__', JSON.stringify(rootAspectId))\n .replaceAll('__ROOT_EXTENSION_NAME__', JSON.stringify(rootExtensionName));\n const entryPath = resolve(join(dir, `ui-bundle-entry.${sha1(contents)}.js`));\n if (!fs.existsSync(entryPath)) {\n fs.outputFileSync(entryPath, contents);\n }\n return entryPath;\n};\n\nexport async function buildPreBundlePreview(resolvedAspects: AspectDefinition[], customOutputDir?: string) {\n const outputDir = customOutputDir || resolve(PUBLIC_DIR);\n const mainEntry = generatePreBundlePreviewEntry(\n resolvedAspects,\n UIROOT_ASPECT_ID,\n RUNTIME_NAME,\n PreviewAspect.id,\n __dirname\n );\n const config = createWebpackConfig(outputDir, mainEntry);\n const compiler = webpack(config);\n const compilerRun = promisify(compiler.run.bind(compiler));\n const results = await compilerRun();\n if (!results) throw new Error();\n if (results?.hasErrors()) {\n clearConsole();\n throw new Error(results?.toString());\n }\n return results;\n}\n\nexport async function generateBundlePreviewEntry(rootAspectId: string, previewPreBundlePath: string, config: object) {\n const manifestPath = join(previewPreBundlePath, 'asset-manifest.json');\n const manifest = readJsonSync(manifestPath);\n const imports = manifest.entrypoints\n .map((entry: string) => {\n const entryPath = toWindowsCompatiblePath(join(previewPreBundlePath, entry));\n return entry.endsWith('.js') || entry.endsWith('.cjs') || entry.endsWith('.mjs')\n ? `import { run } from '${entryPath}';`\n : `import '${entryPath}';`;\n })\n .join('\\n');\n config['teambit.harmony/bit'] = rootAspectId;\n\n const contents = [imports, `run(${JSON.stringify(config, null, 2)});`].join('\\n');\n const previewRuntime = resolve(join(__dirname, `preview.entry.${sha1(contents)}.js`));\n\n if (!existsSync(previewRuntime)) {\n outputFileSync(previewRuntime, contents);\n }\n\n return previewRuntime;\n}\n"],"mappings":";;;;;;;;;AAAA,SAAAA,MAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,KAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,SAAA;EAAA,MAAAF,IAAA,GAAAG,uBAAA,CAAAF,OAAA;EAAAC,QAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAI,gBAAA;EAAA,MAAAJ,IAAA,GAAAC,OAAA;EAAAG,eAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAMA,SAAAK,OAAA;EAAA,MAAAL,IAAA,GAAAC,OAAA;EAAAI,MAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAM,aAAA;EAAA,MAAAN,IAAA,GAAAC,OAAA;EAAAK,YAAA,YAAAA,CAAA;IAAA,OAAAN,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAO,SAAA;EAAA,MAAAP,IAAA,GAAAQ,sBAAA,CAAAP,OAAA;EAAAM,QAAA,YAAAA,CAAA;IAAA,OAAAP,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAS,MAAA;EAAA,MAAAT,IAAA,GAAAC,OAAA;EAAAQ,KAAA,YAAAA,CAAA;IAAA,OAAAT,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAU,SAAA;EAAA,MAAAV,IAAA,GAAAC,OAAA;EAAA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