@komaci/esm-generator 240.1.5 → 242.1.1

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 (50) hide show
  1. package/build/__tests__/adgAstGeneration.spec.d.ts +2 -0
  2. package/build/__tests__/adgAstGeneration.spec.js +31 -0
  3. package/build/__tests__/compositionAstGeneration.spec.d.ts +2 -0
  4. package/build/__tests__/compositionAstGeneration.spec.js +396 -0
  5. package/build/__tests__/fixtures-combined-files/exclude-partial-classProps-indirect-importRef-getter/actual.js +5 -1
  6. package/build/__tests__/fixtures-combined-files/include-all-indirect-importRef-getter-complex/actual.js +5 -1
  7. package/build/__tests__/fixtures-combined-files/include-class-prop-indirect-importRef-getter/actual.js +5 -1
  8. package/build/__tests__/fixtures-combined-files/only-named-export-with-template/actual.d.ts +1 -0
  9. package/build/__tests__/fixtures-combined-files/only-named-export-with-template/actual.js +2 -0
  10. package/build/__tests__/fixtures-script-files/imports/actual.js +5 -1
  11. package/build/__tests__/fixtures-script-files/imports-namespaced/actual.js +5 -1
  12. package/build/__tests__/fixtures-script-files/wire-imports/actual.js +5 -1
  13. package/build/__tests__/functionAstGeneration.spec.d.ts +2 -0
  14. package/build/__tests__/functionAstGeneration.spec.js +416 -0
  15. package/build/__tests__/general-komaci-docs/import-types/source.js +5 -1
  16. package/build/__tests__/general-komaci-docs/template-component/source.js +3 -3
  17. package/build/__tests__/genericAstGeneration.spec.d.ts +2 -0
  18. package/build/__tests__/genericAstGeneration.spec.js +877 -0
  19. package/build/__tests__/index.spec.js +34 -18
  20. package/build/__tests__/komaci-ast-unit.spec.js +240 -448
  21. package/build/__tests__/komaci-bundle-module.fixtures.spec.js +1 -0
  22. package/build/__tests__/komaci-script-module.fixtures.spec.js +5 -1
  23. package/build/__tests__/komaci-template-module.fixtures.spec.js +2 -1
  24. package/build/componentAstProcessing.d.ts +34 -0
  25. package/build/componentAstProcessing.js +105 -0
  26. package/build/compositionAstGeneration.d.ts +76 -0
  27. package/build/compositionAstGeneration.js +299 -0
  28. package/build/functionAstGeneration.d.ts +81 -0
  29. package/build/functionAstGeneration.js +345 -0
  30. package/build/genericAstGeneration.d.ts +115 -0
  31. package/build/genericAstGeneration.js +644 -0
  32. package/build/index.d.ts +6 -0
  33. package/build/index.js +77 -89
  34. package/build/types.d.ts +13 -2
  35. package/build/types.js +69 -1
  36. package/package.json +4 -4
  37. package/build/__tests__/modGenScript.spec.d.ts +0 -2
  38. package/build/__tests__/modGenScript.spec.js +0 -110
  39. package/build/__tests__/modGenTemplate.spec.d.ts +0 -2
  40. package/build/__tests__/modGenTemplate.spec.js +0 -196
  41. package/build/__tests__/shared.spec.d.ts +0 -2
  42. package/build/__tests__/shared.spec.js +0 -62
  43. package/build/__tests__/templateStrings.spec.d.ts +0 -2
  44. package/build/__tests__/templateStrings.spec.js +0 -130
  45. package/build/modGenScript.d.ts +0 -38
  46. package/build/modGenScript.js +0 -1027
  47. package/build/modGenTemplate.d.ts +0 -37
  48. package/build/modGenTemplate.js +0 -402
  49. package/build/shared.d.ts +0 -170
  50. package/build/shared.js +0 -588
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -20,7 +24,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
20
24
  };
21
25
  Object.defineProperty(exports, "__esModule", { value: true });
22
26
  const __1 = require("..");
23
- const modgen = __importStar(require("../modGenScript"));
27
+ const modgen = __importStar(require("../genericAstGeneration"));
24
28
  describe('Handling errors that throw inside a call to generateKomaciModule', () => {
25
29
  it('should return error adg when an error is produced', () => {
26
30
  const input = {
@@ -37,7 +41,8 @@ describe('Handling errors that throw inside a call to generateKomaciModule', ()
37
41
  },
38
42
  };
39
43
  const res = (0, __1.generateKomaciModule)(input);
40
- const expectedModuleFirstHalf = 'export default function (fct, ctx) {\n' +
44
+ const expectedModuleFirstHalf = 'import registerAdgFunction from "komaci/registerAdgFunction";\n\n' +
45
+ 'function adg0(fct, ctx) {\n' +
41
46
  ' const {\n' +
42
47
  ' adg\n' +
43
48
  ' } = fct;\n' +
@@ -45,10 +50,13 @@ describe('Handling errors that throw inside a call to generateKomaciModule', ()
45
50
  ' t: "ErrorFunction",\n' +
46
51
  ' c: {\n' +
47
52
  ' "error": "[komaci esm-generator] unrecognized input type",\n';
48
- const expectedModuleSecondHalf = ' }\n' + ' }], []);\n' + '}';
53
+ const expectedModuleSecondHalf = ' return [];\n' +
54
+ ' }, []);\n' +
55
+ '}\n' +
56
+ '\nexport default registerAdgFunction(adg0);';
49
57
  const lines = res.split('\n');
50
- const skipStack = lines.slice(0, 8).join('\n') + '\n';
51
- const skipStackEnd = lines.slice(lines.length - 3).join('\n');
58
+ const skipStack = lines.slice(0, 10).join('\n') + '\n';
59
+ const skipStackEnd = lines.slice(lines.length - 5).join('\n');
52
60
  expect(skipStack).toBe(expectedModuleFirstHalf);
53
61
  expect(skipStackEnd).toBe(expectedModuleSecondHalf);
54
62
  });
@@ -66,23 +74,27 @@ describe('Handling errors that throw inside a call to generateKomaciModule', ()
66
74
  'test.html': '<html><body><h1>Hey</h1></body></html>',
67
75
  },
68
76
  };
69
- const mock = jest.spyOn(modgen, 'generateCombinedModule');
77
+ const mock = jest.spyOn(modgen, 'generateResolvableModule');
70
78
  mock.mockImplementationOnce(() => {
71
79
  throw 'not an error';
72
80
  });
73
81
  const res = (0, __1.generateKomaciModule)(input);
74
- const expectedModuleFirstHalf = 'export default function (fct, ctx) {\n' +
82
+ const expectedModuleFirstHalf = 'import registerAdgFunction from "komaci/registerAdgFunction";\n\n' +
83
+ 'function adg0(fct, ctx) {\n' +
75
84
  ' const {\n' +
76
85
  ' adg\n' +
77
86
  ' } = fct;\n' +
78
87
  ' return adg(undefined, {}, [{\n' +
79
88
  ' t: "ErrorFunction",\n' +
80
89
  ' c: {\n' +
81
- ' "error": "[komaci esm-generator] Something that is not an error was thrown"\n';
82
- const expectedModuleSecondHalf = ' }\n' + ' }], []);\n' + '}';
90
+ ' "error": "[komaci] Something that is not an error was thrown"\n';
91
+ const expectedModuleSecondHalf = ' return [];\n' +
92
+ ' }, []);\n' +
93
+ '}\n' +
94
+ '\nexport default registerAdgFunction(adg0);';
83
95
  const lines = res.split('\n');
84
- const skipStack = lines.slice(0, 8).join('\n') + '\n';
85
- const skipStackEnd = lines.slice(lines.length - 3).join('\n');
96
+ const skipStack = lines.slice(0, 10).join('\n') + '\n';
97
+ const skipStackEnd = lines.slice(lines.length - 5).join('\n');
86
98
  expect(skipStack).toBe(expectedModuleFirstHalf);
87
99
  expect(skipStackEnd).toBe(expectedModuleSecondHalf);
88
100
  });
@@ -100,23 +112,27 @@ describe('Handling errors that throw inside a call to generateKomaciModule', ()
100
112
  'test.html': '<html><body><h1>Hey</h1></body></html>',
101
113
  },
102
114
  };
103
- const mock = jest.spyOn(modgen, 'generateCombinedModule');
115
+ const mock = jest.spyOn(modgen, 'generateResolvableModule');
104
116
  mock.mockImplementationOnce(() => {
105
117
  throw undefined;
106
118
  });
107
119
  const res = (0, __1.generateKomaciModule)(input);
108
- const expectedModuleFirstHalf = 'export default function (fct, ctx) {\n' +
120
+ const expectedModuleFirstHalf = 'import registerAdgFunction from "komaci/registerAdgFunction";\n\n' +
121
+ 'function adg0(fct, ctx) {\n' +
109
122
  ' const {\n' +
110
123
  ' adg\n' +
111
124
  ' } = fct;\n' +
112
125
  ' return adg(undefined, {}, [{\n' +
113
126
  ' t: "ErrorFunction",\n' +
114
127
  ' c: {\n' +
115
- ' "error": "[komaci esm-generator] Something that is not an error was thrown"\n';
116
- const expectedModuleSecondHalf = ' }\n' + ' }], []);\n' + '}';
128
+ ' "error": "[komaci] Something that is not an error was thrown"\n';
129
+ const expectedModuleSecondHalf = ' return [];\n' +
130
+ ' }, []);\n' +
131
+ '}\n' +
132
+ '\nexport default registerAdgFunction(adg0);';
117
133
  const lines = res.split('\n');
118
- const skipStack = lines.slice(0, 8).join('\n') + '\n';
119
- const skipStackEnd = lines.slice(lines.length - 3).join('\n');
134
+ const skipStack = lines.slice(0, 10).join('\n') + '\n';
135
+ const skipStackEnd = lines.slice(lines.length - 5).join('\n');
120
136
  expect(skipStack).toBe(expectedModuleFirstHalf);
121
137
  expect(skipStackEnd).toBe(expectedModuleSecondHalf);
122
138
  });