@teambit/preview 0.0.881 → 0.0.883

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 (84) hide show
  1. package/dist/artifact-file-middleware.js +2 -22
  2. package/dist/artifact-file-middleware.js.map +1 -1
  3. package/dist/bundler/chunks.js +1 -9
  4. package/dist/bundler/chunks.js.map +1 -1
  5. package/dist/bundler/create-peer-link.spec.js +0 -3
  6. package/dist/bundler/create-peer-link.spec.js.map +1 -1
  7. package/dist/bundler/create-peers-link.js +3 -20
  8. package/dist/bundler/create-peers-link.js.map +1 -1
  9. package/dist/bundler/html-plugin.js +0 -13
  10. package/dist/bundler/html-plugin.js.map +1 -1
  11. package/dist/bundler/html-template.js +0 -1
  12. package/dist/bundler/html-template.js.map +1 -1
  13. package/dist/component-preview.js +0 -3
  14. package/dist/component-preview.js.map +1 -1
  15. package/dist/component-preview.route.js +8 -23
  16. package/dist/component-preview.route.js.map +1 -1
  17. package/dist/env-preview-template.task.js +9 -75
  18. package/dist/env-preview-template.task.js.map +1 -1
  19. package/dist/env-template.route.js +6 -22
  20. package/dist/env-template.route.js.map +1 -1
  21. package/dist/events/click-inside-an-iframe.js +1 -12
  22. package/dist/events/click-inside-an-iframe.js.map +1 -1
  23. package/dist/events/index.js +0 -2
  24. package/dist/events/index.js.map +1 -1
  25. package/dist/exceptions/bundling-strategy-not-found.js +0 -3
  26. package/dist/exceptions/bundling-strategy-not-found.js.map +1 -1
  27. package/dist/exceptions/index.js +0 -12
  28. package/dist/exceptions/index.js.map +1 -1
  29. package/dist/exceptions/preview-artifact-not-found.js +0 -6
  30. package/dist/exceptions/preview-artifact-not-found.js.map +1 -1
  31. package/dist/exceptions/preview-not-found.js +0 -3
  32. package/dist/exceptions/preview-not-found.js.map +1 -1
  33. package/dist/exceptions/preview-output-file-not-found.js +0 -6
  34. package/dist/exceptions/preview-output-file-not-found.js.map +1 -1
  35. package/dist/execution-ref.js +0 -11
  36. package/dist/execution-ref.js.map +1 -1
  37. package/dist/generate-link.js +2 -7
  38. package/dist/generate-link.js.map +1 -1
  39. package/dist/gql/fetch-component-aspects.js +0 -6
  40. package/dist/gql/fetch-component-aspects.js.map +1 -1
  41. package/dist/html-utils.js +0 -9
  42. package/dist/html-utils.js.map +1 -1
  43. package/dist/index.js +0 -8
  44. package/dist/index.js.map +1 -1
  45. package/dist/mk-temp-dir.js +0 -10
  46. package/dist/mk-temp-dir.js.map +1 -1
  47. package/dist/preview-artifact.js +0 -12
  48. package/dist/preview-artifact.js.map +1 -1
  49. package/dist/preview-assets.route.js +2 -13
  50. package/dist/preview-assets.route.js.map +1 -1
  51. package/dist/preview-modules.js +0 -11
  52. package/dist/preview-modules.js.map +1 -1
  53. package/dist/preview.aspect.js +0 -6
  54. package/dist/preview.aspect.js.map +1 -1
  55. package/dist/preview.composition.js +0 -6
  56. package/dist/preview.composition.js.map +1 -1
  57. package/dist/preview.graphql.js +0 -5
  58. package/dist/preview.graphql.js.map +1 -1
  59. package/dist/preview.main.runtime.js +53 -226
  60. package/dist/preview.main.runtime.js.map +1 -1
  61. package/dist/preview.preview.runtime.js +18 -108
  62. package/dist/preview.preview.runtime.js.map +1 -1
  63. package/dist/preview.route.js +6 -21
  64. package/dist/preview.route.js.map +1 -1
  65. package/dist/preview.start-plugin.js +8 -42
  66. package/dist/preview.start-plugin.js.map +1 -1
  67. package/dist/preview.task.js +1 -20
  68. package/dist/preview.task.js.map +1 -1
  69. package/dist/rendering-context.js +1 -5
  70. package/dist/rendering-context.js.map +1 -1
  71. package/dist/size-event.js +0 -10
  72. package/dist/size-event.js.map +1 -1
  73. package/dist/strategies/component-strategy.js +19 -69
  74. package/dist/strategies/component-strategy.js.map +1 -1
  75. package/dist/strategies/env-strategy.js +1 -40
  76. package/dist/strategies/env-strategy.js.map +1 -1
  77. package/dist/strategies/generate-component-link.js +4 -7
  78. package/dist/strategies/generate-component-link.js.map +1 -1
  79. package/dist/strategies/index.js +0 -6
  80. package/dist/strategies/index.js.map +1 -1
  81. package/package-tar/teambit-preview-0.0.883.tgz +0 -0
  82. package/package.json +15 -15
  83. package/{preview-1666409808293.js → preview-1666582798766.js} +2 -2
  84. package/package-tar/teambit-preview-0.0.881.tgz +0 -0
@@ -27,44 +27,32 @@ Object.defineProperty(exports, "PreviewOutputFileNotFound", {
27
27
  return _previewOutputFileNotFound().PreviewOutputFileNotFound;
28
28
  }
29
29
  });
30
-
31
30
  function _previewNotFound() {
32
31
  const data = require("./preview-not-found");
33
-
34
32
  _previewNotFound = function () {
35
33
  return data;
36
34
  };
37
-
38
35
  return data;
39
36
  }
40
-
41
37
  function _previewArtifactNotFound() {
42
38
  const data = require("./preview-artifact-not-found");
43
-
44
39
  _previewArtifactNotFound = function () {
45
40
  return data;
46
41
  };
47
-
48
42
  return data;
49
43
  }
50
-
51
44
  function _bundlingStrategyNotFound() {
52
45
  const data = require("./bundling-strategy-not-found");
53
-
54
46
  _bundlingStrategyNotFound = function () {
55
47
  return data;
56
48
  };
57
-
58
49
  return data;
59
50
  }
60
-
61
51
  function _previewOutputFileNotFound() {
62
52
  const data = require("./preview-output-file-not-found");
63
-
64
53
  _previewOutputFileNotFound = function () {
65
54
  return data;
66
55
  };
67
-
68
56
  return data;
69
57
  }
70
58
 
@@ -1 +1 @@
1
- {"version":3,"names":[],"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;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA"}
1
+ {"version":3,"names":[],"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;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA"}
@@ -4,24 +4,18 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.PreviewArtifactNotFound = void 0;
7
-
8
7
  function _bitError() {
9
8
  const data = require("@teambit/bit-error");
10
-
11
9
  _bitError = function () {
12
10
  return data;
13
11
  };
14
-
15
12
  return data;
16
13
  }
17
-
18
14
  class PreviewArtifactNotFound extends _bitError().BitError {
19
15
  constructor(componentId) {
20
16
  super(`preview for component ${componentId.toString()} was not found`);
21
17
  }
22
-
23
18
  }
24
-
25
19
  exports.PreviewArtifactNotFound = PreviewArtifactNotFound;
26
20
 
27
21
  //# sourceMappingURL=preview-artifact-not-found.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["PreviewArtifactNotFound","BitError","constructor","componentId","toString"],"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;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAGO,MAAMA,uBAAN,SAAsCC,oBAAtC,CAA+C;EACpDC,WAAW,CAACC,WAAD,EAA2B;IACpC,MAAO,yBAAwBA,WAAW,CAACC,QAAZ,EAAuB,gBAAtD;EACD;;AAHmD"}
1
+ {"version":3,"names":["PreviewArtifactNotFound","BitError","constructor","componentId","toString"],"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;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAGO,MAAMA,uBAAuB,SAASC,oBAAQ,CAAC;EACpDC,WAAW,CAACC,WAAwB,EAAE;IACpC,KAAK,CAAE,yBAAwBA,WAAW,CAACC,QAAQ,EAAG,gBAAe,CAAC;EACxE;AACF;AAAC"}
@@ -4,14 +4,11 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.PreviewNotFound = void 0;
7
-
8
7
  class PreviewNotFound extends Error {
9
8
  constructor(name) {
10
9
  super(`Preview for name: ${name} was not found`);
11
10
  }
12
-
13
11
  }
14
-
15
12
  exports.PreviewNotFound = PreviewNotFound;
16
13
 
17
14
  //# sourceMappingURL=preview-not-found.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["PreviewNotFound","Error","constructor","name"],"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,eAAN,SAA8BC,KAA9B,CAAoC;EACzCC,WAAW,CAACC,IAAD,EAAsB;IAC/B,MAAO,qBAAoBA,IAAK,gBAAhC;EACD;;AAHwC"}
1
+ {"version":3,"names":["PreviewNotFound","Error","constructor","name"],"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,WAAW,CAACC,IAAmB,EAAE;IAC/B,KAAK,CAAE,qBAAoBA,IAAK,gBAAe,CAAC;EAClD;AACF;AAAC"}
@@ -4,17 +4,13 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.PreviewOutputFileNotFound = void 0;
7
-
8
7
  function _bitError() {
9
8
  const data = require("@teambit/bit-error");
10
-
11
9
  _bitError = function () {
12
10
  return data;
13
11
  };
14
-
15
12
  return data;
16
13
  }
17
-
18
14
  class PreviewOutputFileNotFound extends _bitError().BitError {
19
15
  constructor(componentId, filePath) {
20
16
  super(`preview output file for component: "${componentId.toString()}" was not found in the path: "${filePath}".
@@ -24,9 +20,7 @@ The error might be an error of another component that uses the same env.
24
20
  Run "bit build" with "--dev" to see more info.
25
21
  Run "bit envs" to see other components that uses the same env`);
26
22
  }
27
-
28
23
  }
29
-
30
24
  exports.PreviewOutputFileNotFound = PreviewOutputFileNotFound;
31
25
 
32
26
  //# sourceMappingURL=preview-output-file-not-found.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["PreviewOutputFileNotFound","BitError","constructor","componentId","filePath","toString"],"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;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAGO,MAAMA,yBAAN,SAAwCC,oBAAxC,CAAiD;EACtDC,WAAW,CAACC,WAAD,EAA2BC,QAA3B,EAA6C;IACtD,MAAO,uCAAsCD,WAAW,CAACE,QAAZ,EAAuB,iCAAgCD,QAAS;AACjH;AACA;AACA;AACA;AACA,8DALI;EAMD;;AARqD"}
1
+ {"version":3,"names":["PreviewOutputFileNotFound","BitError","constructor","componentId","filePath","toString"],"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;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAGO,MAAMA,yBAAyB,SAASC,oBAAQ,CAAC;EACtDC,WAAW,CAACC,WAAwB,EAAEC,QAAgB,EAAE;IACtD,KAAK,CAAE,uCAAsCD,WAAW,CAACE,QAAQ,EAAG,iCAAgCD,QAAS;AACjH;AACA;AACA;AACA;AACA,8DAA8D,CAAC;EAC7D;AACF;AAAC"}
@@ -1,22 +1,17 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.ExecutionRef = void 0;
9
-
10
8
  function _defineProperty2() {
11
9
  const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
12
-
13
10
  _defineProperty2 = function () {
14
11
  return data;
15
12
  };
16
-
17
13
  return data;
18
14
  }
19
-
20
15
  // TODO - use workspace.list() instead of this
21
16
  class ExecutionRef {
22
17
  constructor(executionCtx) {
@@ -24,25 +19,19 @@ class ExecutionRef {
24
19
  (0, _defineProperty2().default)(this, "currentComponents", void 0);
25
20
  this.currentComponents = executionCtx.components;
26
21
  }
27
-
28
22
  add(added) {
29
23
  this.currentComponents = this.currentComponents.concat(added);
30
24
  }
31
-
32
25
  remove(removed) {
33
26
  this.currentComponents = this.currentComponents.filter(c => c.id.toString() !== removed.toString());
34
27
  }
35
-
36
28
  update(next) {
37
29
  this.currentComponents = this.currentComponents.map(c => c.equals(next) ? next : c);
38
30
  }
39
-
40
31
  get(id) {
41
32
  return this.currentComponents.find(x => x.id.isEqual(id));
42
33
  }
43
-
44
34
  }
45
-
46
35
  exports.ExecutionRef = ExecutionRef;
47
36
 
48
37
  //# sourceMappingURL=execution-ref.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["ExecutionRef","constructor","executionCtx","currentComponents","components","add","added","concat","remove","removed","filter","c","id","toString","update","next","map","equals","get","find","x","isEqual"],"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,YAAN,CAAmB;EACxBC,WAAW,CAAQC,YAAR,EAAwC;IAAA,KAAhCA,YAAgC,GAAhCA,YAAgC;IAAA;IACjD,KAAKC,iBAAL,GAAyBD,YAAY,CAACE,UAAtC;EACD;;EAIDC,GAAG,CAACC,KAAD,EAAmB;IACpB,KAAKH,iBAAL,GAAyB,KAAKA,iBAAL,CAAuBI,MAAvB,CAA8BD,KAA9B,CAAzB;EACD;;EACDE,MAAM,CAACC,OAAD,EAAuB;IAC3B,KAAKN,iBAAL,GAAyB,KAAKA,iBAAL,CAAuBO,MAAvB,CAA+BC,CAAD,IAAOA,CAAC,CAACC,EAAF,CAAKC,QAAL,OAAoBJ,OAAO,CAACI,QAAR,EAAzD,CAAzB;EACD;;EACDC,MAAM,CAACC,IAAD,EAAkB;IACtB,KAAKZ,iBAAL,GAAyB,KAAKA,iBAAL,CAAuBa,GAAvB,CAA4BL,CAAD,IAAQA,CAAC,CAACM,MAAF,CAASF,IAAT,IAAiBA,IAAjB,GAAwBJ,CAA3D,CAAzB;EACD;;EAEDO,GAAG,CAACN,EAAD,EAAkB;IACnB,OAAO,KAAKT,iBAAL,CAAuBgB,IAAvB,CAA6BC,CAAD,IAAOA,CAAC,CAACR,EAAF,CAAKS,OAAL,CAAaT,EAAb,CAAnC,CAAP;EACD;;AAnBuB"}
1
+ {"version":3,"names":["ExecutionRef","constructor","executionCtx","currentComponents","components","add","added","concat","remove","removed","filter","c","id","toString","update","next","map","equals","get","find","x","isEqual"],"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,WAAW,CAAQC,YAA8B,EAAE;IAAA,KAAhCA,YAA8B,GAA9BA,YAA8B;IAAA;IAC/C,IAAI,CAACC,iBAAiB,GAAGD,YAAY,CAACE,UAAU;EAClD;EAIAC,GAAG,CAACC,KAAgB,EAAE;IACpB,IAAI,CAACH,iBAAiB,GAAG,IAAI,CAACA,iBAAiB,CAACI,MAAM,CAACD,KAAK,CAAC;EAC/D;EACAE,MAAM,CAACC,OAAoB,EAAE;IAC3B,IAAI,CAACN,iBAAiB,GAAG,IAAI,CAACA,iBAAiB,CAACO,MAAM,CAAEC,CAAC,IAAKA,CAAC,CAACC,EAAE,CAACC,QAAQ,EAAE,KAAKJ,OAAO,CAACI,QAAQ,EAAE,CAAC;EACvG;EACAC,MAAM,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,GAAG,CAACN,EAAe,EAAE;IACnB,OAAO,IAAI,CAACT,iBAAiB,CAACgB,IAAI,CAAEC,CAAC,IAAKA,CAAC,CAACR,EAAE,CAACS,OAAO,CAACT,EAAE,CAAC,CAAC;EAC7D;AACF;AAAC"}
@@ -1,22 +1,17 @@
1
1
  "use strict";
2
2
 
3
3
  require("core-js/modules/es.array.iterator.js");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.generateLink = generateLink;
9
-
10
8
  function _toolboxPath() {
11
9
  const data = require("@teambit/toolbox.path.to-windows-compatible-path");
12
-
13
10
  _toolboxPath = function () {
14
11
  return data;
15
12
  };
16
-
17
13
  return data;
18
14
  }
19
-
20
15
  // :TODO refactor to building an AST and generate source code based on it.
21
16
  function generateLink(prefix, componentMap, mainModule, isSplitComponentBundle = false) {
22
17
  const links = componentMap.toArray().map(([component, modulePath], compIdx) => ({
@@ -37,13 +32,13 @@ linkModules('${prefix}', {
37
32
  mainModule,
38
33
  isSplitComponentBundle: ${isSplitComponentBundle},
39
34
  componentMap: {
40
- ${links // must include all components, including empty
35
+ ${links
36
+ // must include all components, including empty
41
37
  .map(link => ` "${link.componentIdentifier}": [${link.modules.map(module => module.varName).join(', ')}]`).join(',\n')}
42
38
  }
43
39
  });
44
40
  `;
45
41
  }
46
-
47
42
  function moduleVarName(componentIdx, fileIdx) {
48
43
  return `file_${componentIdx}_${fileIdx}`;
49
44
  }
@@ -1 +1 @@
1
- {"version":3,"names":["generateLink","prefix","componentMap","mainModule","isSplitComponentBundle","links","toArray","map","component","modulePath","compIdx","componentIdentifier","id","fullName","modules","path","pathIdx","varName","moduleVarName","resolveFrom","toWindowsCompatiblePath","require","resolve","link","module","join","filter","line","componentIdx","fileIdx"],"sources":["generate-link.ts"],"sourcesContent":["import { toWindowsCompatiblePath } from '@teambit/toolbox.path.to-windows-compatible-path';\nimport type { ComponentMap } from '@teambit/component';\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 mainModule?: string,\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 return `\nimport { linkModules } from '${toWindowsCompatiblePath(require.resolve('./preview.preview.runtime'))}';\n${mainModule ? `import * as mainModule from '${toWindowsCompatiblePath(mainModule)}';` : 'const mainModule = {};'}\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\nlinkModules('${prefix}', {\n mainModule,\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"],"mappings":";;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAGA;AACO,SAASA,YAAT,CACLC,MADK,EAELC,YAFK,EAGLC,UAHK,EAILC,sBAAsB,GAAG,KAJpB,EAKG;EACR,MAAMC,KAAK,GAAGH,YAAY,CAACI,OAAb,GAAuBC,GAAvB,CAA2B,CAAC,CAACC,SAAD,EAAYC,UAAZ,CAAD,EAA0BC,OAA1B,MAAuC;IAC9EC,mBAAmB,EAAEH,SAAS,CAACI,EAAV,CAAaC,QAD4C;IAE9EC,OAAO,EAAEL,UAAU,CAACF,GAAX,CAAe,CAACQ,IAAD,EAAOC,OAAP,MAAoB;MAC1CC,OAAO,EAAEC,aAAa,CAACR,OAAD,EAAUM,OAAV,CADoB;MAE1CG,WAAW,EAAE,IAAAC,sCAAA,EAAwBL,IAAxB;IAF6B,CAApB,CAAf;EAFqE,CAAvC,CAA3B,CAAd;EAQA,OAAQ;AACV,+BAA+B,IAAAK,sCAAA,EAAwBC,OAAO,CAACC,OAAR,CAAgB,2BAAhB,CAAxB,CAAsE;AACrG,EAAEnB,UAAU,GAAI,gCAA+B,IAAAiB,sCAAA,EAAwBjB,UAAxB,CAAoC,IAAvE,GAA6E,wBAAyB;AAClH;AACA,EAAEE,KAAK,CACJE,GADD,CACMgB,IAAD,IAAUA,IAAI,CAACT,OAAL,CAAaP,GAAb,CAAkBiB,MAAD,IAAa,eAAcA,MAAM,CAACP,OAAQ,UAASO,MAAM,CAACL,WAAY,IAAvF,EAA4FM,IAA5F,CAAiG,IAAjG,CADf,EAECC,MAFD,CAESC,IAAD,IAAUA,IAAI,KAAK,EAF3B,EAE+B;EAF/B,CAGCF,IAHD,CAGM,IAHN,CAGY;AACd;AACA,eAAexB,MAAO;AACtB;AACA,4BAA4BG,sBAAuB;AACnD;AACA,EAAEC,KAAK,CACL;EADK,CAEJE,GAFD,CAEMgB,IAAD,IAAW,QAAOA,IAAI,CAACZ,mBAAoB,OAAMY,IAAI,CAACT,OAAL,CAAaP,GAAb,CAAkBiB,MAAD,IAAYA,MAAM,CAACP,OAApC,EAA6CQ,IAA7C,CAAkD,IAAlD,CAAwD,GAF9G,EAGCA,IAHD,CAGM,KAHN,CAGa;AACf;AACA;AACA,CAnBE;AAoBD;;AAED,SAASP,aAAT,CAAuBU,YAAvB,EAA6CC,OAA7C,EAA8D;EAC5D,OAAQ,QAAOD,YAAa,IAAGC,OAAQ,EAAvC;AACD"}
1
+ {"version":3,"names":["generateLink","prefix","componentMap","mainModule","isSplitComponentBundle","links","toArray","map","component","modulePath","compIdx","componentIdentifier","id","fullName","modules","path","pathIdx","varName","moduleVarName","resolveFrom","toWindowsCompatiblePath","require","resolve","link","module","join","filter","line","componentIdx","fileIdx"],"sources":["generate-link.ts"],"sourcesContent":["import { toWindowsCompatiblePath } from '@teambit/toolbox.path.to-windows-compatible-path';\nimport type { ComponentMap } from '@teambit/component';\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 mainModule?: string,\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 return `\nimport { linkModules } from '${toWindowsCompatiblePath(require.resolve('./preview.preview.runtime'))}';\n${mainModule ? `import * as mainModule from '${toWindowsCompatiblePath(mainModule)}';` : 'const mainModule = {};'}\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\nlinkModules('${prefix}', {\n mainModule,\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"],"mappings":";;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAGA;AACO,SAASA,YAAY,CAC1BC,MAAc,EACdC,YAAoC,EACpCC,UAAmB,EACnBC,sBAAsB,GAAG,KAAK,EACtB;EACR,MAAMC,KAAK,GAAGH,YAAY,CAACI,OAAO,EAAE,CAACC,GAAG,CAAC,CAAC,CAACC,SAAS,EAAEC,UAAU,CAAC,EAAEC,OAAO,MAAM;IAC9EC,mBAAmB,EAAEH,SAAS,CAACI,EAAE,CAACC,QAAQ;IAC1CC,OAAO,EAAEL,UAAU,CAACF,GAAG,CAAC,CAACQ,IAAI,EAAEC,OAAO,MAAM;MAC1CC,OAAO,EAAEC,aAAa,CAACR,OAAO,EAAEM,OAAO,CAAC;MACxCG,WAAW,EAAE,IAAAC,sCAAuB,EAACL,IAAI;IAC3C,CAAC,CAAC;EACJ,CAAC,CAAC,CAAC;EAEH,OAAQ;AACV,+BAA+B,IAAAK,sCAAuB,EAACC,OAAO,CAACC,OAAO,CAAC,2BAA2B,CAAC,CAAE;AACrG,EAAEnB,UAAU,GAAI,gCAA+B,IAAAiB,sCAAuB,EAACjB,UAAU,CAAE,IAAG,GAAG,wBAAyB;AAClH;AACA,EAAEE,KAAK,CACJE,GAAG,CAAEgB,IAAI,IAAKA,IAAI,CAACT,OAAO,CAACP,GAAG,CAAEiB,MAAM,IAAM,eAAcA,MAAM,CAACP,OAAQ,UAASO,MAAM,CAACL,WAAY,IAAG,CAAC,CAACM,IAAI,CAAC,IAAI,CAAC,CAAC,CACrHC,MAAM,CAAEC,IAAI,IAAKA,IAAI,KAAK,EAAE,CAAC,CAAC;EAAA,CAC9BF,IAAI,CAAC,IAAI,CAAE;AACd;AACA,eAAexB,MAAO;AACtB;AACA,4BAA4BG,sBAAuB;AACnD;AACA,EAAEC;EACA;EAAA,CACCE,GAAG,CAAEgB,IAAI,IAAM,QAAOA,IAAI,CAACZ,mBAAoB,OAAMY,IAAI,CAACT,OAAO,CAACP,GAAG,CAAEiB,MAAM,IAAKA,MAAM,CAACP,OAAO,CAAC,CAACQ,IAAI,CAAC,IAAI,CAAE,GAAE,CAAC,CAChHA,IAAI,CAAC,KAAK,CAAE;AACf;AACA;AACA,CAAC;AACD;AAEA,SAASP,aAAa,CAACU,YAAoB,EAAEC,OAAe,EAAE;EAC5D,OAAQ,QAAOD,YAAa,IAAGC,OAAQ,EAAC;AAC1C"}
@@ -1,22 +1,17 @@
1
1
  "use strict";
2
2
 
3
3
  require("core-js/modules/es.promise.js");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.fetchComponentAspects = fetchComponentAspects;
9
-
10
8
  function _graphqlRequest() {
11
9
  const data = require("graphql-request");
12
-
13
10
  _graphqlRequest = function () {
14
11
  return data;
15
12
  };
16
-
17
13
  return data;
18
14
  }
19
-
20
15
  const GQL_SERVER = '/graphql';
21
16
  const GET_COMPONENT_ASPECTS = (0, _graphqlRequest().gql)`
22
17
  query getComponentAspects($id: String!) {
@@ -30,7 +25,6 @@ const GET_COMPONENT_ASPECTS = (0, _graphqlRequest().gql)`
30
25
  }
31
26
  }
32
27
  `;
33
-
34
28
  async function fetchComponentAspects(componentId) {
35
29
  try {
36
30
  const response = await (0, _graphqlRequest().request)(GQL_SERVER, GET_COMPONENT_ASPECTS, {
@@ -1 +1 @@
1
- {"version":3,"names":["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;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA,MAAMA,UAAU,GAAG,UAAnB;AACA,MAAMC,qBAAqB,GAAG,IAAAC,qBAAA,CAAI;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAXA;;AAqBO,eAAeC,qBAAf,CAAqCC,WAArC,EAA0D;EAC/D,IAAI;IACF,MAAMC,QAAQ,GAAG,MAAM,IAAAC,yBAAA,EAAqBN,UAArB,EAAiCC,qBAAjC,EAAwD;MAAEM,EAAE,EAAEH,WAAW,CAACI,QAAZ;IAAN,CAAxD,CAAvB;IACA,OAAOH,QAAQ,CAACI,OAAT,CAAiBC,GAAjB,CAAqBC,OAArB,CAA6BC,GAA7B,CAAkCC,CAAD,IAAOA,CAAC,CAACN,EAA1C,CAAP;EACD,CAHD,CAGE,OAAOO,GAAP,EAAiB;IACjB;IACAC,OAAO,CAACC,KAAR,CAAe,2CAA0CF,GAAG,CAACN,QAAJ,EAAe,GAAxE;IACA,OAAOS,SAAP;EACD;AACF"}
1
+ {"version":3,"names":["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;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA,MAAMA,UAAU,GAAG,UAAU;AAC7B,MAAMC,qBAAqB,GAAG,IAAAC,qBAAG,CAAC;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAUM,eAAeC,qBAAqB,CAACC,WAAmB,EAAE;EAC/D,IAAI;IACF,MAAMC,QAAQ,GAAG,MAAM,IAAAC,yBAAO,EAAcN,UAAU,EAAEC,qBAAqB,EAAE;MAAEM,EAAE,EAAEH,WAAW,CAACI,QAAQ;IAAG,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,EAAG,GAAE,CAAC;IAC3E,OAAOS,SAAS;EAClB;AACF"}
@@ -1,13 +1,11 @@
1
1
  "use strict";
2
2
 
3
3
  require("core-js/modules/es.promise.js");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.loadLink = loadLink;
9
8
  exports.loadScript = loadScript;
10
-
11
9
  function loadScript({
12
10
  src
13
11
  }) {
@@ -15,15 +13,11 @@ function loadScript({
15
13
  const script = document.createElement('script');
16
14
  script.setAttribute('defer', 'defer');
17
15
  script.src = src;
18
-
19
16
  script.onload = () => resolve();
20
-
21
17
  script.onerror = (message, _, _1, _2, error) => reject(error || new Error(`[preview.preview] failed to load script: ${message}`));
22
-
23
18
  document.head.appendChild(script);
24
19
  });
25
20
  }
26
-
27
21
  function loadLink({
28
22
  href
29
23
  }) {
@@ -31,11 +25,8 @@ function loadLink({
31
25
  const link = document.createElement('link');
32
26
  if (href.endsWith('.css')) link.setAttribute('rel', 'stylesheet');
33
27
  link.setAttribute('href', href);
34
-
35
28
  link.onload = () => resolve();
36
-
37
29
  link.onerror = (message, _, _1, _2, error) => reject(error || new Error(`[preview.preview] failed to load link: ${message}`));
38
-
39
30
  document.head.appendChild(link);
40
31
  });
41
32
  }
@@ -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,UAAT,CAAoB;EAAEC;AAAF,CAApB,EAA8C;EACnD,OAAO,IAAIC,OAAJ,CAAkB,CAACC,OAAD,EAAUC,MAAV,KAAqB;IAC5C,MAAMC,MAAM,GAAGC,QAAQ,CAACC,aAAT,CAAuB,QAAvB,CAAf;IAEAF,MAAM,CAACG,YAAP,CAAoB,OAApB,EAA6B,OAA7B;IACAH,MAAM,CAACJ,GAAP,GAAaA,GAAb;;IAEAI,MAAM,CAACI,MAAP,GAAgB,MAAMN,OAAO,EAA7B;;IACAE,MAAM,CAACK,OAAP,GAAiB,CAACC,OAAD,EAAUC,CAAV,EAAaC,EAAb,EAAiBC,EAAjB,EAAqBC,KAArB,KACfX,MAAM,CAACW,KAAK,IAAI,IAAIC,KAAJ,CAAW,4CAA2CL,OAAQ,EAA9D,CAAV,CADR;;IAGAL,QAAQ,CAACW,IAAT,CAAcC,WAAd,CAA0Bb,MAA1B;EACD,CAXM,CAAP;AAYD;;AAEM,SAASc,QAAT,CAAkB;EAAEC;AAAF,CAAlB,EAA8C;EACnD,OAAO,IAAIlB,OAAJ,CAAkB,CAACC,OAAD,EAAUC,MAAV,KAAqB;IAC5C,MAAMiB,IAAI,GAAGf,QAAQ,CAACC,aAAT,CAAuB,MAAvB,CAAb;IAEA,IAAIa,IAAI,CAACE,QAAL,CAAc,MAAd,CAAJ,EAA2BD,IAAI,CAACb,YAAL,CAAkB,KAAlB,EAAyB,YAAzB;IAC3Ba,IAAI,CAACb,YAAL,CAAkB,MAAlB,EAA0BY,IAA1B;;IAEAC,IAAI,CAACZ,MAAL,GAAc,MAAMN,OAAO,EAA3B;;IACAkB,IAAI,CAACX,OAAL,GAAe,CAACC,OAAD,EAAUC,CAAV,EAAaC,EAAb,EAAiBC,EAAjB,EAAqBC,KAArB,KACbX,MAAM,CAACW,KAAK,IAAI,IAAIC,KAAJ,CAAW,0CAAyCL,OAAQ,EAA5D,CAAV,CADR;;IAGAL,QAAQ,CAACW,IAAT,CAAcC,WAAd,CAA0BG,IAA1B;EACD,CAXM,CAAP;AAYD"}
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,UAAU,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,EAAE;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,QAAQ,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,EAAE;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"}
package/dist/index.js CHANGED
@@ -32,19 +32,14 @@ Object.defineProperty(exports, "default", {
32
32
  return _preview().PreviewAspect;
33
33
  }
34
34
  });
35
-
36
35
  function _preview() {
37
36
  const data = require("./preview.aspect");
38
-
39
37
  _preview = function () {
40
38
  return data;
41
39
  };
42
-
43
40
  return data;
44
41
  }
45
-
46
42
  var _events = require("./events");
47
-
48
43
  Object.keys(_events).forEach(function (key) {
49
44
  if (key === "default" || key === "__esModule") return;
50
45
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
@@ -56,14 +51,11 @@ Object.keys(_events).forEach(function (key) {
56
51
  }
57
52
  });
58
53
  });
59
-
60
54
  function _previewDefinition() {
61
55
  const data = require("./preview-definition");
62
-
63
56
  _previewDefinition = function () {
64
57
  return data;
65
58
  };
66
-
67
59
  return data;
68
60
  }
69
61
 
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export { PreviewAspect as default, PreviewAspect, PreviewRuntime } from './preview.aspect';\n\nexport * from './events';\nexport type { PreviewMain, EnvPreviewConfig, ComponentPreviewSize } from './preview.main.runtime';\nexport type { PreviewPreview, RenderingContextOptions, RenderingContextProvider } from './preview.preview.runtime';\nexport { PreviewDefinition } from './preview-definition';\nexport type { PreviewModule, ModuleFile } from './types/preview-module';\nexport type { RenderingContext } from './rendering-context';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AAGA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA"}
1
+ {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export { PreviewAspect as default, PreviewAspect, PreviewRuntime } from './preview.aspect';\n\nexport * from './events';\nexport type { PreviewMain, EnvPreviewConfig, ComponentPreviewSize } from './preview.main.runtime';\nexport type { PreviewPreview, RenderingContextOptions, RenderingContextProvider } from './preview.preview.runtime';\nexport { PreviewDefinition } from './preview-definition';\nexport type { PreviewModule, ModuleFile } from './types/preview-module';\nexport type { RenderingContext } from './rendering-context';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AAGA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA"}
@@ -4,37 +4,27 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.makeTempDir = makeTempDir;
7
-
8
7
  function _fsExtra() {
9
8
  const data = require("fs-extra");
10
-
11
9
  _fsExtra = function () {
12
10
  return data;
13
11
  };
14
-
15
12
  return data;
16
13
  }
17
-
18
14
  function _os() {
19
15
  const data = require("os");
20
-
21
16
  _os = function () {
22
17
  return data;
23
18
  };
24
-
25
19
  return data;
26
20
  }
27
-
28
21
  function _path() {
29
22
  const data = require("path");
30
-
31
23
  _path = function () {
32
24
  return data;
33
25
  };
34
-
35
26
  return data;
36
27
  }
37
-
38
28
  function makeTempDir(prefix = '') {
39
29
  return (0, _fsExtra().mkdtempSync)(`${(0, _os().tmpdir)()}${_path().sep}${prefix}`);
40
30
  }
@@ -1 +1 @@
1
- {"version":3,"names":["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;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEO,SAASA,WAAT,CAAqBC,MAAM,GAAG,EAA9B,EAAkC;EACvC,OAAO,IAAAC,sBAAA,EAAa,GAAE,IAAAC,YAAA,GAAS,GAAEC,WAAI,GAAEH,MAAO,EAAvC,CAAP;AACD"}
1
+ {"version":3,"names":["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;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEO,SAASA,WAAW,CAACC,MAAM,GAAG,EAAE,EAAE;EACvC,OAAO,IAAAC,sBAAW,EAAE,GAAE,IAAAC,YAAM,GAAG,GAAEC,WAAI,GAAEH,MAAO,EAAC,CAAC;AAClD"}
@@ -4,51 +4,39 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.PreviewArtifact = void 0;
7
-
8
7
  function _utils() {
9
8
  const data = require("@teambit/legacy/dist/utils");
10
-
11
9
  _utils = function () {
12
10
  return data;
13
11
  };
14
-
15
12
  return data;
16
13
  }
17
-
18
14
  function _lodash() {
19
15
  const data = require("lodash");
20
-
21
16
  _lodash = function () {
22
17
  return data;
23
18
  };
24
-
25
19
  return data;
26
20
  }
27
-
28
21
  class PreviewArtifact {
29
22
  constructor(artifacts) {
30
23
  this.artifacts = artifacts;
31
24
  }
32
-
33
25
  getPaths() {
34
26
  // TODO: check why the artifacts stored twice, then remove this uniq here
35
27
  return (0, _lodash().uniq)(this.artifacts.map(artifact => artifact.relative));
36
28
  }
37
-
38
29
  getFile(path) {
39
30
  return this.artifacts.find(file => {
40
31
  return (0, _utils().pathNormalizeToLinux)(file.relative) === path;
41
32
  });
42
33
  }
43
-
44
34
  getFileEndsWith(path) {
45
35
  return this.artifacts.find(file => {
46
36
  return (0, _utils().pathNormalizeToLinux)(file.relative).endsWith(path);
47
37
  });
48
38
  }
49
-
50
39
  }
51
-
52
40
  exports.PreviewArtifact = PreviewArtifact;
53
41
 
54
42
  //# sourceMappingURL=preview-artifact.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["PreviewArtifact","constructor","artifacts","getPaths","uniq","map","artifact","relative","getFile","path","find","file","pathNormalizeToLinux","getFileEndsWith","endsWith"],"sources":["preview-artifact.ts"],"sourcesContent":["import { AbstractVinyl } from '@teambit/legacy/dist/consumer/component/sources';\nimport { pathNormalizeToLinux } from '@teambit/legacy/dist/utils';\nimport { uniq } from 'lodash';\n\nexport class PreviewArtifact {\n constructor(private artifacts: AbstractVinyl[]) {}\n\n getPaths() {\n // TODO: check why the artifacts stored twice, then remove this uniq here\n return uniq(this.artifacts.map((artifact) => artifact.relative));\n }\n\n getFile(path: string) {\n return this.artifacts.find((file) => {\n return pathNormalizeToLinux(file.relative) === path;\n });\n }\n\n getFileEndsWith(path: string) {\n return this.artifacts.find((file) => {\n return pathNormalizeToLinux(file.relative).endsWith(path);\n });\n }\n}\n"],"mappings":";;;;;;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEO,MAAMA,eAAN,CAAsB;EAC3BC,WAAW,CAASC,SAAT,EAAqC;IAAA,KAA5BA,SAA4B,GAA5BA,SAA4B;EAAE;;EAElDC,QAAQ,GAAG;IACT;IACA,OAAO,IAAAC,cAAA,EAAK,KAAKF,SAAL,CAAeG,GAAf,CAAoBC,QAAD,IAAcA,QAAQ,CAACC,QAA1C,CAAL,CAAP;EACD;;EAEDC,OAAO,CAACC,IAAD,EAAe;IACpB,OAAO,KAAKP,SAAL,CAAeQ,IAAf,CAAqBC,IAAD,IAAU;MACnC,OAAO,IAAAC,6BAAA,EAAqBD,IAAI,CAACJ,QAA1B,MAAwCE,IAA/C;IACD,CAFM,CAAP;EAGD;;EAEDI,eAAe,CAACJ,IAAD,EAAe;IAC5B,OAAO,KAAKP,SAAL,CAAeQ,IAAf,CAAqBC,IAAD,IAAU;MACnC,OAAO,IAAAC,6BAAA,EAAqBD,IAAI,CAACJ,QAA1B,EAAoCO,QAApC,CAA6CL,IAA7C,CAAP;IACD,CAFM,CAAP;EAGD;;AAlB0B"}
1
+ {"version":3,"names":["PreviewArtifact","constructor","artifacts","getPaths","uniq","map","artifact","relative","getFile","path","find","file","pathNormalizeToLinux","getFileEndsWith","endsWith"],"sources":["preview-artifact.ts"],"sourcesContent":["import { AbstractVinyl } from '@teambit/legacy/dist/consumer/component/sources';\nimport { pathNormalizeToLinux } from '@teambit/legacy/dist/utils';\nimport { uniq } from 'lodash';\n\nexport class PreviewArtifact {\n constructor(private artifacts: AbstractVinyl[]) {}\n\n getPaths() {\n // TODO: check why the artifacts stored twice, then remove this uniq here\n return uniq(this.artifacts.map((artifact) => artifact.relative));\n }\n\n getFile(path: string) {\n return this.artifacts.find((file) => {\n return pathNormalizeToLinux(file.relative) === path;\n });\n }\n\n getFileEndsWith(path: string) {\n return this.artifacts.find((file) => {\n return pathNormalizeToLinux(file.relative).endsWith(path);\n });\n }\n}\n"],"mappings":";;;;;;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEO,MAAMA,eAAe,CAAC;EAC3BC,WAAW,CAASC,SAA0B,EAAE;IAAA,KAA5BA,SAA0B,GAA1BA,SAA0B;EAAG;EAEjDC,QAAQ,GAAG;IACT;IACA,OAAO,IAAAC,cAAI,EAAC,IAAI,CAACF,SAAS,CAACG,GAAG,CAAEC,QAAQ,IAAKA,QAAQ,CAACC,QAAQ,CAAC,CAAC;EAClE;EAEAC,OAAO,CAACC,IAAY,EAAE;IACpB,OAAO,IAAI,CAACP,SAAS,CAACQ,IAAI,CAAEC,IAAI,IAAK;MACnC,OAAO,IAAAC,6BAAoB,EAACD,IAAI,CAACJ,QAAQ,CAAC,KAAKE,IAAI;IACrD,CAAC,CAAC;EACJ;EAEAI,eAAe,CAACJ,IAAY,EAAE;IAC5B,OAAO,IAAI,CAACP,SAAS,CAACQ,IAAI,CAAEC,IAAI,IAAK;MACnC,OAAO,IAAAC,6BAAoB,EAACD,IAAI,CAACJ,QAAQ,CAAC,CAACO,QAAQ,CAACL,IAAI,CAAC;IAC3D,CAAC,CAAC;EACJ;AACF;AAAC"}
@@ -1,34 +1,25 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  require("core-js/modules/es.promise.js");
6
-
7
5
  Object.defineProperty(exports, "__esModule", {
8
6
  value: true
9
7
  });
10
8
  exports.PreviewAssetsRoute = void 0;
11
-
12
9
  function _defineProperty2() {
13
10
  const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
14
-
15
11
  _defineProperty2 = function () {
16
12
  return data;
17
13
  };
18
-
19
14
  return data;
20
15
  }
21
-
22
16
  function _uiFoundationUiPages() {
23
17
  const data = require("@teambit/ui-foundation.ui.pages.static-error");
24
-
25
18
  _uiFoundationUiPages = function () {
26
19
  return data;
27
20
  };
28
-
29
21
  return data;
30
22
  }
31
-
32
23
  class PreviewAssetsRoute {
33
24
  constructor(
34
25
  /**
@@ -42,8 +33,8 @@ class PreviewAssetsRoute {
42
33
  (0, _defineProperty2().default)(this, "middlewares", [async (req, res) => {
43
34
  try {
44
35
  // @ts-ignore TODO: @guy please fix.
45
- const component = req.component; // if (!component) return res.status(404).send(noPreview());
46
-
36
+ const component = req.component;
37
+ // if (!component) return res.status(404).send(noPreview());
47
38
  if (!component) return res.status(404).jsonp({
48
39
  error: 'not found'
49
40
  });
@@ -58,9 +49,7 @@ class PreviewAssetsRoute {
58
49
  }
59
50
  }]);
60
51
  }
61
-
62
52
  }
63
-
64
53
  exports.PreviewAssetsRoute = PreviewAssetsRoute;
65
54
 
66
55
  //# sourceMappingURL=preview-assets.route.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["PreviewAssetsRoute","constructor","preview","logger","req","res","component","status","jsonp","error","result","getPreviewFiles","json","e","send","serverError"],"sources":["preview-assets.route.ts"],"sourcesContent":["import type { Request, Response, Route } from '@teambit/express';\nimport type { Component } from '@teambit/component';\nimport { serverError } from '@teambit/ui-foundation.ui.pages.static-error';\nimport type { Logger } from '@teambit/logger';\n\nimport { PreviewMain } from './preview.main.runtime';\n\nexport class PreviewAssetsRoute implements Route {\n constructor(\n /**\n * preview extension.\n */\n private preview: PreviewMain,\n private logger: Logger\n ) {}\n\n route = '/preview-assets';\n method = 'get';\n\n middlewares = [\n async (req: Request, res: Response) => {\n try {\n // @ts-ignore TODO: @guy please fix.\n const component = req.component as Component | undefined;\n // if (!component) return res.status(404).send(noPreview());\n if (!component) return res.status(404).jsonp({ error: 'not found' });\n const result = await this.preview.getPreviewFiles(component);\n if (!result) return res.status(404).jsonp({ error: 'not found' });\n return res.json(result);\n } catch (e: any) {\n this.logger.error('failed getting preview assets', e);\n return res.status(500).send(serverError());\n }\n },\n ];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAKO,MAAMA,kBAAN,CAA0C;EAC/CC,WAAW;EACT;AACJ;AACA;EACYC,OAJC,EAKDC,MALC,EAMT;IAAA,KAFQD,OAER,GAFQA,OAER;IAAA,KADQC,MACR,GADQA,MACR;IAAA,+CAEM,iBAFN;IAAA,gDAGO,KAHP;IAAA,qDAKY,CACZ,OAAOC,GAAP,EAAqBC,GAArB,KAAuC;MACrC,IAAI;QACF;QACA,MAAMC,SAAS,GAAGF,GAAG,CAACE,SAAtB,CAFE,CAGF;;QACA,IAAI,CAACA,SAAL,EAAgB,OAAOD,GAAG,CAACE,MAAJ,CAAW,GAAX,EAAgBC,KAAhB,CAAsB;UAAEC,KAAK,EAAE;QAAT,CAAtB,CAAP;QAChB,MAAMC,MAAM,GAAG,MAAM,KAAKR,OAAL,CAAaS,eAAb,CAA6BL,SAA7B,CAArB;QACA,IAAI,CAACI,MAAL,EAAa,OAAOL,GAAG,CAACE,MAAJ,CAAW,GAAX,EAAgBC,KAAhB,CAAsB;UAAEC,KAAK,EAAE;QAAT,CAAtB,CAAP;QACb,OAAOJ,GAAG,CAACO,IAAJ,CAASF,MAAT,CAAP;MACD,CARD,CAQE,OAAOG,CAAP,EAAe;QACf,KAAKV,MAAL,CAAYM,KAAZ,CAAkB,+BAAlB,EAAmDI,CAAnD;QACA,OAAOR,GAAG,CAACE,MAAJ,CAAW,GAAX,EAAgBO,IAAhB,CAAqB,IAAAC,kCAAA,GAArB,CAAP;MACD;IACF,CAdW,CALZ;EAAE;;AAP2C"}
1
+ {"version":3,"names":["PreviewAssetsRoute","constructor","preview","logger","req","res","component","status","jsonp","error","result","getPreviewFiles","json","e","send","serverError"],"sources":["preview-assets.route.ts"],"sourcesContent":["import type { Request, Response, Route } from '@teambit/express';\nimport type { Component } from '@teambit/component';\nimport { serverError } from '@teambit/ui-foundation.ui.pages.static-error';\nimport type { Logger } from '@teambit/logger';\n\nimport { PreviewMain } from './preview.main.runtime';\n\nexport class PreviewAssetsRoute implements Route {\n constructor(\n /**\n * preview extension.\n */\n private preview: PreviewMain,\n private logger: Logger\n ) {}\n\n route = '/preview-assets';\n method = 'get';\n\n middlewares = [\n async (req: Request, res: Response) => {\n try {\n // @ts-ignore TODO: @guy please fix.\n const component = req.component as Component | undefined;\n // if (!component) return res.status(404).send(noPreview());\n if (!component) return res.status(404).jsonp({ error: 'not found' });\n const result = await this.preview.getPreviewFiles(component);\n if (!result) return res.status(404).jsonp({ error: 'not found' });\n return res.json(result);\n } catch (e: any) {\n this.logger.error('failed getting preview assets', e);\n return res.status(500).send(serverError());\n }\n },\n ];\n}\n"],"mappings":";;;;;;;;;;;;;;;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAKO,MAAMA,kBAAkB,CAAkB;EAC/CC,WAAW;EACT;AACJ;AACA;EACYC,OAAoB,EACpBC,MAAc,EACtB;IAAA,KAFQD,OAAoB,GAApBA,OAAoB;IAAA,KACpBC,MAAc,GAAdA,MAAc;IAAA,+CAGhB,iBAAiB;IAAA,gDAChB,KAAK;IAAA,qDAEA,CACZ,OAAOC,GAAY,EAAEC,GAAa,KAAK;MACrC,IAAI;QACF;QACA,MAAMC,SAAS,GAAGF,GAAG,CAACE,SAAkC;QACxD;QACA,IAAI,CAACA,SAAS,EAAE,OAAOD,GAAG,CAACE,MAAM,CAAC,GAAG,CAAC,CAACC,KAAK,CAAC;UAAEC,KAAK,EAAE;QAAY,CAAC,CAAC;QACpE,MAAMC,MAAM,GAAG,MAAM,IAAI,CAACR,OAAO,CAACS,eAAe,CAACL,SAAS,CAAC;QAC5D,IAAI,CAACI,MAAM,EAAE,OAAOL,GAAG,CAACE,MAAM,CAAC,GAAG,CAAC,CAACC,KAAK,CAAC;UAAEC,KAAK,EAAE;QAAY,CAAC,CAAC;QACjE,OAAOJ,GAAG,CAACO,IAAI,CAACF,MAAM,CAAC;MACzB,CAAC,CAAC,OAAOG,CAAM,EAAE;QACf,IAAI,CAACV,MAAM,CAACM,KAAK,CAAC,+BAA+B,EAAEI,CAAC,CAAC;QACrD,OAAOR,GAAG,CAACE,MAAM,CAAC,GAAG,CAAC,CAACO,IAAI,CAAC,IAAAC,kCAAW,GAAE,CAAC;MAC5C;IACF,CAAC,CACF;EApBE;AAqBL;AAAC"}