jsii 5.9.44-dev.0 → 6.0.0-dev.0

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 (72) hide show
  1. package/README.md +73 -289
  2. package/lib/assembler.js +95 -46
  3. package/lib/assembler.js.map +1 -1
  4. package/lib/case.js +13 -10
  5. package/lib/case.js.map +1 -1
  6. package/lib/common/find-utils.js +35 -2
  7. package/lib/common/find-utils.js.map +1 -1
  8. package/lib/common/symbol-id.js +39 -7
  9. package/lib/common/symbol-id.js.map +1 -1
  10. package/lib/compiler.js +51 -8
  11. package/lib/compiler.js.map +1 -1
  12. package/lib/directives.js +48 -16
  13. package/lib/directives.js.map +1 -1
  14. package/lib/docs.js +36 -4
  15. package/lib/docs.js.map +1 -1
  16. package/lib/helpers.js +38 -4
  17. package/lib/helpers.js.map +1 -1
  18. package/lib/jsii-diagnostic.js +524 -497
  19. package/lib/jsii-diagnostic.js.map +1 -1
  20. package/lib/literate.js +35 -2
  21. package/lib/literate.js.map +1 -1
  22. package/lib/main.js +40 -7
  23. package/lib/main.js.map +1 -1
  24. package/lib/project-info.d.ts +1 -1
  25. package/lib/project-info.js +41 -11
  26. package/lib/project-info.js.map +1 -1
  27. package/lib/support.js +7 -4
  28. package/lib/support.js.map +1 -1
  29. package/lib/transforms/deprecated-remover.js +65 -23
  30. package/lib/transforms/deprecated-remover.js.map +1 -1
  31. package/lib/transforms/deprecation-warnings.js +50 -10
  32. package/lib/transforms/deprecation-warnings.js.map +1 -1
  33. package/lib/transforms/runtime-info.js +36 -2
  34. package/lib/transforms/runtime-info.js.map +1 -1
  35. package/lib/tsconfig/compiler-options.js +40 -5
  36. package/lib/tsconfig/compiler-options.js.map +1 -1
  37. package/lib/tsconfig/rulesets/configurable-options.js +10 -1
  38. package/lib/tsconfig/rulesets/configurable-options.js.map +1 -1
  39. package/lib/tsconfig/rulesets/deprecated-options.js +16 -1
  40. package/lib/tsconfig/rulesets/deprecated-options.js.map +1 -1
  41. package/lib/tsconfig/rulesets/generated.public.js +7 -2
  42. package/lib/tsconfig/rulesets/generated.public.js.map +1 -1
  43. package/lib/tsconfig/rulesets/jsii-configured-options.js +0 -1
  44. package/lib/tsconfig/rulesets/jsii-configured-options.js.map +1 -1
  45. package/lib/tsconfig/rulesets/minimal.public.js +4 -1
  46. package/lib/tsconfig/rulesets/minimal.public.js.map +1 -1
  47. package/lib/tsconfig/rulesets/strict.public.js +12 -9
  48. package/lib/tsconfig/rulesets/strict.public.js.map +1 -1
  49. package/lib/tsconfig/tsconfig-validator.js +9 -3
  50. package/lib/tsconfig/tsconfig-validator.js.map +1 -1
  51. package/lib/tsconfig/validator.d.ts +5 -0
  52. package/lib/tsconfig/validator.js +26 -16
  53. package/lib/tsconfig/validator.js.map +1 -1
  54. package/lib/type-analysis.js +39 -3
  55. package/lib/type-analysis.js.map +1 -1
  56. package/lib/type-reference.js +34 -1
  57. package/lib/type-reference.js.map +1 -1
  58. package/lib/type-tracker.js +35 -4
  59. package/lib/type-tracker.js.map +1 -1
  60. package/lib/type-visitor.js +34 -1
  61. package/lib/type-visitor.js.map +1 -1
  62. package/lib/utils.js +37 -2
  63. package/lib/utils.js.map +1 -1
  64. package/lib/validator.js +49 -11
  65. package/lib/validator.js.map +1 -1
  66. package/lib/version.d.ts +3 -3
  67. package/lib/version.js +2 -2
  68. package/lib/version.js.map +1 -1
  69. package/lib/warnings.js +34 -1
  70. package/lib/warnings.js.map +1 -1
  71. package/package.json +6 -8
  72. package/releases.json +3 -2
package/lib/assembler.js CHANGED
@@ -1,23 +1,59 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = 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);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
2
38
  Object.defineProperty(exports, "__esModule", { value: true });
3
39
  exports.Assembler = void 0;
4
- const crypto = require("node:crypto");
5
- const fs = require("node:fs");
6
- const path = require("node:path");
7
- const spec = require("@jsii/spec");
40
+ const crypto = __importStar(require("node:crypto"));
41
+ const fs = __importStar(require("node:fs"));
42
+ const path = __importStar(require("node:path"));
43
+ const spec = __importStar(require("@jsii/spec"));
8
44
  const spec_1 = require("@jsii/spec");
9
- const chalk = require("chalk");
10
- const deepEqual = require("fast-deep-equal/es6");
11
- const log4js = require("log4js");
12
- const ts = require("typescript");
13
- const Case = require("./case");
45
+ const chalk_1 = __importDefault(require("chalk"));
46
+ const es6_1 = __importDefault(require("fast-deep-equal/es6"));
47
+ const log4js = __importStar(require("log4js"));
48
+ const ts = __importStar(require("typescript"));
49
+ const Case = __importStar(require("./case"));
14
50
  const symbol_id_1 = require("./common/symbol-id");
15
51
  const directives_1 = require("./directives");
16
52
  const docs_1 = require("./docs");
17
53
  const helpers_1 = require("./helpers");
18
54
  const jsii_diagnostic_1 = require("./jsii-diagnostic");
19
- const literate = require("./literate");
20
- const bindings = require("./node-bindings");
55
+ const literate = __importStar(require("./literate"));
56
+ const bindings = __importStar(require("./node-bindings"));
21
57
  const project_info_1 = require("./project-info");
22
58
  const reserved_words_1 = require("./reserved-words");
23
59
  const sets_1 = require("./sets");
@@ -38,6 +74,34 @@ const LOG = log4js.getLogger('jsii/assembler');
38
74
  * The JSII Assembler consumes a ``ts.Program`` instance and emits a JSII assembly.
39
75
  */
40
76
  class Assembler {
77
+ projectInfo;
78
+ system;
79
+ program;
80
+ stdlib;
81
+ runtimeTypeInfoInjector;
82
+ deprecatedRemover;
83
+ warningsInjector;
84
+ mainFile;
85
+ tscRootDir;
86
+ compressAssembly;
87
+ usedFeatures = new Set();
88
+ _typeChecker;
89
+ _diagnostics = new Array();
90
+ _deferred = new Array();
91
+ _types = new Map();
92
+ _packageInfoCache = new Map();
93
+ /** Map of Symbol to namespace export Symbol */
94
+ _submoduleMap = new Map();
95
+ /**
96
+ * Submodule information
97
+ *
98
+ * Contains submodule information for all namespaces that have been seen
99
+ * across all assemblies (this and dependencies).
100
+ *
101
+ * Filtered to local submodules only at time of writing the assembly out to disk.
102
+ */
103
+ _submodules = new Map();
104
+ _typeTracker = new type_tracker_1.TypeTracker();
41
105
  /**
42
106
  * @param projectInfo information about the package being assembled
43
107
  * @param program the TypeScript program to be assembled from
@@ -48,23 +112,6 @@ class Assembler {
48
112
  this.system = system;
49
113
  this.program = program;
50
114
  this.stdlib = stdlib;
51
- this.usedFeatures = new Set();
52
- this._diagnostics = new Array();
53
- this._deferred = new Array();
54
- this._types = new Map();
55
- this._packageInfoCache = new Map();
56
- /** Map of Symbol to namespace export Symbol */
57
- this._submoduleMap = new Map();
58
- /**
59
- * Submodule information
60
- *
61
- * Contains submodule information for all namespaces that have been seen
62
- * across all assemblies (this and dependencies).
63
- *
64
- * Filtered to local submodules only at time of writing the assembly out to disk.
65
- */
66
- this._submodules = new Map();
67
- this._typeTracker = new type_tracker_1.TypeTracker();
68
115
  this._typeChecker = this.program.getTypeChecker();
69
116
  if (options.stripDeprecated) {
70
117
  let allowlistedDeprecations;
@@ -125,7 +172,7 @@ class Assembler {
125
172
  else {
126
173
  this._registerDependenciesNamespaces(sourceFile);
127
174
  if (LOG.isTraceEnabled()) {
128
- LOG.trace(`Processing source file: ${chalk.blue(path.relative(this.projectInfo.projectRoot, sourceFile.fileName))}`);
175
+ LOG.trace(`Processing source file: ${chalk_1.default.blue(path.relative(this.projectInfo.projectRoot, sourceFile.fileName))}`);
129
176
  }
130
177
  const symbol = this._typeChecker.getSymbolAtLocation(sourceFile);
131
178
  if (symbol) {
@@ -218,7 +265,7 @@ class Assembler {
218
265
  const zipped = (0, spec_1.writeAssembly)(this.projectInfo.projectRoot, _fingerprint(assembly), {
219
266
  compress: this.compressAssembly ?? false,
220
267
  });
221
- LOG.trace(`${zipped ? 'Zipping' : 'Emitting'} assembly: ${chalk.blue(path.join(this.projectInfo.projectRoot, spec_1.SPEC_FILE_NAME))}`);
268
+ LOG.trace(`${zipped ? 'Zipping' : 'Emitting'} assembly: ${chalk_1.default.blue(path.join(this.projectInfo.projectRoot, spec_1.SPEC_FILE_NAME))}`);
222
269
  }
223
270
  try {
224
271
  return {
@@ -669,7 +716,7 @@ class Assembler {
669
716
  // to access the module specifier ("from 'module'") part.
670
717
  const symbol = this._typeChecker.getSymbolAtLocation(node.parent.moduleSpecifier);
671
718
  if (LOG.isTraceEnabled()) {
672
- LOG.trace(`Entering submodule: ${chalk.cyan([...context.namespace, symbol.name].join('.'))}`);
719
+ LOG.trace(`Entering submodule: ${chalk_1.default.cyan([...context.namespace, symbol.name].join('.'))}`);
673
720
  }
674
721
  const nsContext = context.appendNamespace(node.name.text);
675
722
  const allTypes = this._typeChecker.getExportsOfModule(symbol).flatMap((child) => {
@@ -680,7 +727,7 @@ class Assembler {
680
727
  return this._visitNode(decl, nsContext);
681
728
  });
682
729
  if (LOG.isTraceEnabled()) {
683
- LOG.trace(`Leaving submodule: ${chalk.cyan([...context.namespace, symbol.name].join('.'))}`);
730
+ LOG.trace(`Leaving submodule: ${chalk_1.default.cyan([...context.namespace, symbol.name].join('.'))}`);
684
731
  }
685
732
  return allTypes;
686
733
  }
@@ -721,7 +768,7 @@ class Assembler {
721
768
  const name = node.name.getText();
722
769
  const symbol = this._typeChecker.getSymbolAtLocation(node.name);
723
770
  if (LOG.isTraceEnabled()) {
724
- LOG.trace(`Entering namespace: ${chalk.cyan([...context.namespace, name].join('.'))}`);
771
+ LOG.trace(`Entering namespace: ${chalk_1.default.cyan([...context.namespace, name].join('.'))}`);
725
772
  }
726
773
  const nsContext = context.appendNamespace(node.name.getText());
727
774
  const allTypes = this._typeChecker.getExportsOfModule(symbol).flatMap((prop) => {
@@ -732,7 +779,7 @@ class Assembler {
732
779
  return this._visitNode(decl, nsContext);
733
780
  });
734
781
  if (LOG.isTraceEnabled()) {
735
- LOG.trace(`Leaving namespace: ${chalk.cyan([...context.namespace, name].join('.'))}`);
782
+ LOG.trace(`Leaving namespace: ${chalk_1.default.cyan([...context.namespace, name].join('.'))}`);
736
783
  }
737
784
  return allTypes;
738
785
  }
@@ -765,7 +812,7 @@ class Assembler {
765
812
  }
766
813
  }
767
814
  if (LOG.isInfoEnabled()) {
768
- LOG.info(`Registering JSII ${chalk.magenta(jsiiType.kind)}: ${chalk.green(jsiiType.fqn)}`);
815
+ LOG.info(`Registering JSII ${chalk_1.default.magenta(jsiiType.kind)}: ${chalk_1.default.green(jsiiType.fqn)}`);
769
816
  }
770
817
  this._types.set(jsiiType.fqn, jsiiType);
771
818
  jsiiType.locationInModule = this.declarationLocation(node);
@@ -877,7 +924,7 @@ class Assembler {
877
924
  // eslint-disable-next-line complexity
878
925
  _visitClass(type, ctx) {
879
926
  if (LOG.isTraceEnabled()) {
880
- LOG.trace(`Processing class: ${chalk.gray(ctx.namespace.join('.'))}.${chalk.cyan(type.symbol.name)}`);
927
+ LOG.trace(`Processing class: ${chalk_1.default.gray(ctx.namespace.join('.'))}.${chalk_1.default.cyan(type.symbol.name)}`);
881
928
  }
882
929
  if (_hasInternalJsDocTag(type.symbol)) {
883
930
  return undefined;
@@ -915,7 +962,7 @@ class Assembler {
915
962
  // Crawl up the inheritance tree if the current base type is not exported, so we identify the type(s) to be
916
963
  // erased, and identify the closest exported base class, should there be one.
917
964
  while (base && this._isPrivateOrInternal(base.symbol)) {
918
- LOG.debug(`Base class of ${chalk.green(jsiiType.fqn)} named ${chalk.green(base.symbol.name)} is not exported, erasing it...`);
965
+ LOG.debug(`Base class of ${chalk_1.default.green(jsiiType.fqn)} named ${chalk_1.default.green(base.symbol.name)} is not exported, erasing it...`);
919
966
  erasedBases.push(base);
920
967
  base = (base.getBaseTypes() ?? [])[0];
921
968
  }
@@ -1161,7 +1208,7 @@ class Assembler {
1161
1208
  const hasInternalSymbolName = isInternalSymbol(symbol);
1162
1209
  const hasUnderscorePrefix = !hasInternalSymbolName && symbol.name.startsWith('_');
1163
1210
  if (_isPrivate(symbol)) {
1164
- LOG.trace(`${chalk.cyan(symbol.name)} is marked "private", or is an unexported type declaration`);
1211
+ LOG.trace(`${chalk_1.default.cyan(symbol.name)} is marked "private", or is an unexported type declaration`);
1165
1212
  return true;
1166
1213
  }
1167
1214
  // If all the declarations are marked with `@jsii ignore`, then this is effetcively private as far as jsii is concerned.
@@ -1184,7 +1231,7 @@ class Assembler {
1184
1231
  }
1185
1232
  _visitEnum(type, ctx) {
1186
1233
  if (LOG.isTraceEnabled()) {
1187
- LOG.trace(`Processing enum: ${chalk.gray(ctx.namespace.join('.'))}.${chalk.cyan(type.symbol.name)}`);
1234
+ LOG.trace(`Processing enum: ${chalk_1.default.gray(ctx.namespace.join('.'))}.${chalk_1.default.cyan(type.symbol.name)}`);
1188
1235
  }
1189
1236
  // Forcefully resolving to the EnumDeclaration symbol for single-valued enums
1190
1237
  let decl = type.symbol.declarations?.[0];
@@ -1307,7 +1354,7 @@ class Assembler {
1307
1354
  }
1308
1355
  _visitInterface(type, ctx) {
1309
1356
  if (LOG.isTraceEnabled()) {
1310
- LOG.trace(`Processing interface: ${chalk.gray(ctx.namespace.join('.'))}.${chalk.cyan(type.symbol.name)}`);
1357
+ LOG.trace(`Processing interface: ${chalk_1.default.gray(ctx.namespace.join('.'))}.${chalk_1.default.cyan(type.symbol.name)}`);
1311
1358
  }
1312
1359
  if (_hasInternalJsDocTag(type.symbol)) {
1313
1360
  return undefined;
@@ -1442,7 +1489,7 @@ class Assembler {
1442
1489
  }
1443
1490
  _visitMethod(symbol, type, ctx, declaringTypeDecl) {
1444
1491
  if (LOG.isTraceEnabled()) {
1445
- LOG.trace(`Processing method: ${chalk.green(type.fqn)}#${chalk.cyan(symbol.name)}`);
1492
+ LOG.trace(`Processing method: ${chalk_1.default.green(type.fqn)}#${chalk_1.default.cyan(symbol.name)}`);
1446
1493
  }
1447
1494
  const declaration = symbol.valueDeclaration;
1448
1495
  const signature = this._typeChecker.getSignatureFromDeclaration(declaration);
@@ -1497,7 +1544,7 @@ class Assembler {
1497
1544
  this._validateReferencedDocParams(method, symbol);
1498
1545
  type.methods = type.methods ?? [];
1499
1546
  if (type.methods.find((m) => m.name === method.name && m.static === method.static) != null) {
1500
- LOG.trace(`Dropping re-declaration of ${chalk.green(type.fqn)}#${chalk.cyan(method.name)}`);
1547
+ LOG.trace(`Dropping re-declaration of ${chalk_1.default.green(type.fqn)}#${chalk_1.default.cyan(method.name)}`);
1501
1548
  return;
1502
1549
  }
1503
1550
  type.methods.push(method);
@@ -1518,7 +1565,7 @@ class Assembler {
1518
1565
  return;
1519
1566
  }
1520
1567
  if (LOG.isTraceEnabled()) {
1521
- LOG.trace(`Processing property: ${chalk.green(type.fqn)}#${chalk.cyan(symbol.name)}`);
1568
+ LOG.trace(`Processing property: ${chalk_1.default.green(type.fqn)}#${chalk_1.default.cyan(symbol.name)}`);
1522
1569
  }
1523
1570
  const declaration = symbol.valueDeclaration ?? symbol.declarations?.[0];
1524
1571
  const signature = declaration;
@@ -1571,14 +1618,14 @@ class Assembler {
1571
1618
  property.docs = this._visitDocumentation(symbol, ctx).docs;
1572
1619
  type.properties = type.properties ?? [];
1573
1620
  if (type.properties.find((prop) => prop.name === property.name && prop.static === property.static) != null) {
1574
- LOG.trace(`Dropping re-declaration of ${chalk.green(type.fqn)}#${chalk.cyan(property.name)}`);
1621
+ LOG.trace(`Dropping re-declaration of ${chalk_1.default.green(type.fqn)}#${chalk_1.default.cyan(property.name)}`);
1575
1622
  return;
1576
1623
  }
1577
1624
  type.properties.push(property);
1578
1625
  }
1579
1626
  _toParameter(paramSymbol, ctx) {
1580
1627
  if (LOG.isTraceEnabled()) {
1581
- LOG.trace(`Processing parameter: ${chalk.cyan(paramSymbol.name)}`);
1628
+ LOG.trace(`Processing parameter: ${chalk_1.default.cyan(paramSymbol.name)}`);
1582
1629
  }
1583
1630
  const paramDeclaration = paramSymbol.valueDeclaration;
1584
1631
  this._warnAboutReservedWords(paramSymbol);
@@ -1747,7 +1794,7 @@ class Assembler {
1747
1794
  }
1748
1795
  // eslint-disable-next-line no-await-in-loop
1749
1796
  const resolvedType = this._typeReference(subType, declaration, purpose);
1750
- if (types.some((ref) => deepEqual(ref, resolvedType))) {
1797
+ if (types.some((ref) => (0, es6_1.default)(ref, resolvedType))) {
1751
1798
  continue;
1752
1799
  }
1753
1800
  types.push(resolvedType);
@@ -2339,6 +2386,8 @@ function isProhibitedMemberName(name) {
2339
2386
  * Information about the context in which a declaration is emitted.
2340
2387
  */
2341
2388
  class EmitContext {
2389
+ namespace;
2390
+ stability;
2342
2391
  constructor(namespace, stability) {
2343
2392
  this.namespace = namespace;
2344
2393
  this.stability = stability;