packtory 0.0.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 (143) hide show
  1. package/LICENSE +21 -0
  2. package/artifacts/artifacts-builder.d.ts +20 -0
  3. package/artifacts/artifacts-builder.d.ts.map +1 -0
  4. package/artifacts/artifacts-builder.js +43 -0
  5. package/artifacts/artifacts-builder.js.map +1 -0
  6. package/artifacts/file-manager.d.ts +18 -0
  7. package/artifacts/file-manager.d.ts.map +1 -0
  8. package/artifacts/file-manager.js +35 -0
  9. package/artifacts/file-manager.js.map +1 -0
  10. package/bundler/bundle-build-options.d.ts +19 -0
  11. package/bundler/bundle-build-options.d.ts.map +1 -0
  12. package/bundler/bundle-build-options.js +25 -0
  13. package/bundler/bundle-build-options.js.map +1 -0
  14. package/bundler/bundle-description.d.ts +27 -0
  15. package/bundler/bundle-description.d.ts.map +1 -0
  16. package/bundler/bundler.d.ts +11 -0
  17. package/bundler/bundler.d.ts.map +1 -0
  18. package/bundler/bundler.js +98 -0
  19. package/bundler/bundler.js.map +1 -0
  20. package/bundler/content.js +53 -0
  21. package/bundler/content.js.map +1 -0
  22. package/bundler/substitute-bundles.js +73 -0
  23. package/bundler/substitute-bundles.js.map +1 -0
  24. package/config/additional-files.d.ts +13 -0
  25. package/config/additional-files.d.ts.map +1 -0
  26. package/config/additional-files.js +8 -0
  27. package/config/additional-files.js.map +1 -0
  28. package/config/base-validations.d.ts +5 -0
  29. package/config/base-validations.d.ts.map +1 -0
  30. package/config/base-validations.js +3 -0
  31. package/config/base-validations.js.map +1 -0
  32. package/config/config.d.ts +470 -0
  33. package/config/config.d.ts.map +1 -0
  34. package/config/config.js +65 -0
  35. package/config/config.js.map +1 -0
  36. package/config/entry-point.d.ts +13 -0
  37. package/config/entry-point.d.ts.map +1 -0
  38. package/config/entry-point.js +8 -0
  39. package/config/entry-point.js.map +1 -0
  40. package/config/package-json.d.ts +33 -0
  41. package/config/package-json.d.ts.map +1 -0
  42. package/config/package-json.js +34 -0
  43. package/config/package-json.js.map +1 -0
  44. package/config/registry-settings.d.ts +13 -0
  45. package/config/registry-settings.d.ts.map +1 -0
  46. package/config/registry-settings.js +8 -0
  47. package/config/registry-settings.js.map +1 -0
  48. package/config/validation.d.ts +13 -0
  49. package/config/validation.d.ts.map +1 -0
  50. package/config/validation.js +99 -0
  51. package/config/validation.js.map +1 -0
  52. package/config/versioning-settings.d.ts +23 -0
  53. package/config/versioning-settings.d.ts.map +1 -0
  54. package/config/versioning-settings.js +15 -0
  55. package/config/versioning-settings.js.map +1 -0
  56. package/dependency-scanner/dependency-graph.d.ts +33 -0
  57. package/dependency-scanner/dependency-graph.d.ts.map +1 -0
  58. package/dependency-scanner/dependency-graph.js +60 -0
  59. package/dependency-scanner/dependency-graph.js.map +1 -0
  60. package/dependency-scanner/scanner.d.ts +34 -0
  61. package/dependency-scanner/scanner.d.ts.map +1 -0
  62. package/dependency-scanner/scanner.js +131 -0
  63. package/dependency-scanner/scanner.js.map +1 -0
  64. package/dependency-scanner/source-file-references.js +68 -0
  65. package/dependency-scanner/source-file-references.js.map +1 -0
  66. package/dependency-scanner/source-map-file-locator.d.ts +10 -0
  67. package/dependency-scanner/source-map-file-locator.d.ts.map +1 -0
  68. package/dependency-scanner/source-map-file-locator.js +23 -0
  69. package/dependency-scanner/source-map-file-locator.js.map +1 -0
  70. package/dependency-scanner/typescript-file-host.d.ts +10 -0
  71. package/dependency-scanner/typescript-file-host.d.ts.map +1 -0
  72. package/dependency-scanner/typescript-file-host.js +50 -0
  73. package/dependency-scanner/typescript-file-host.js.map +1 -0
  74. package/dependency-scanner/typescript-project-analyzer.d.ts +23 -0
  75. package/dependency-scanner/typescript-project-analyzer.d.ts.map +1 -0
  76. package/dependency-scanner/typescript-project-analyzer.js +64 -0
  77. package/dependency-scanner/typescript-project-analyzer.js.map +1 -0
  78. package/directed-graph/graph.d.ts +27 -0
  79. package/directed-graph/graph.d.ts.map +1 -0
  80. package/directed-graph/graph.js +183 -0
  81. package/directed-graph/graph.js.map +1 -0
  82. package/file-description/compare.js +18 -0
  83. package/file-description/compare.js.map +1 -0
  84. package/file-description/equal.js +4 -0
  85. package/file-description/equal.js.map +1 -0
  86. package/file-description/file-description.d.ts +5 -0
  87. package/file-description/file-description.d.ts.map +1 -0
  88. package/file-description/sort.js +13 -0
  89. package/file-description/sort.js.map +1 -0
  90. package/package-json.js +33 -0
  91. package/package-json.js.map +1 -0
  92. package/package.json +48 -0
  93. package/packages/bundler/bundler.entry-point.js +21 -0
  94. package/packages/bundler/bundler.entry-point.js.map +1 -0
  95. package/packages/packtory/packtory.entry-point.d.ts +7 -0
  96. package/packages/packtory/packtory.entry-point.d.ts.map +1 -0
  97. package/packages/packtory/packtory.entry-point.js +32 -0
  98. package/packages/packtory/packtory.entry-point.js.map +1 -0
  99. package/packtory/map-config.js +55 -0
  100. package/packtory/map-config.js.map +1 -0
  101. package/packtory/normalize-paths.js +26 -0
  102. package/packtory/normalize-paths.js.map +1 -0
  103. package/packtory/packtory.d.ts +25 -0
  104. package/packtory/packtory.d.ts.map +1 -0
  105. package/packtory/packtory.js +30 -0
  106. package/packtory/packtory.js.map +1 -0
  107. package/packtory/scheduler.d.ts +18 -0
  108. package/packtory/scheduler.d.ts.map +1 -0
  109. package/packtory/scheduler.js +74 -0
  110. package/packtory/scheduler.js.map +1 -0
  111. package/progress/progress-broadcaster.d.ts +40 -0
  112. package/progress/progress-broadcaster.d.ts.map +1 -0
  113. package/progress/progress-broadcaster.js +16 -0
  114. package/progress/progress-broadcaster.js.map +1 -0
  115. package/publisher/extract-package-tarball.js +12 -0
  116. package/publisher/extract-package-tarball.js.map +1 -0
  117. package/publisher/publisher.d.ts +40 -0
  118. package/publisher/publisher.d.ts.map +1 -0
  119. package/publisher/publisher.js +73 -0
  120. package/publisher/publisher.js.map +1 -0
  121. package/publisher/registry-client.d.ts +24 -0
  122. package/publisher/registry-client.d.ts.map +1 -0
  123. package/publisher/registry-client.js +90 -0
  124. package/publisher/registry-client.js.map +1 -0
  125. package/publisher/version.js +35 -0
  126. package/publisher/version.js.map +1 -0
  127. package/readme.md +38 -0
  128. package/source-modifier/import-paths.js +17 -0
  129. package/source-modifier/import-paths.js.map +1 -0
  130. package/tar/extract-tar.js +17 -0
  131. package/tar/extract-tar.js.map +1 -0
  132. package/tar/tarball-builder.d.ts +7 -0
  133. package/tar/tarball-builder.d.ts.map +1 -0
  134. package/tar/tarball-builder.js +35 -0
  135. package/tar/tarball-builder.js.map +1 -0
  136. package/validation/capitalize.js +7 -0
  137. package/validation/capitalize.js.map +1 -0
  138. package/validation/formatting/ast.js +113 -0
  139. package/validation/formatting/ast.js.map +1 -0
  140. package/validation/formatting.js +98 -0
  141. package/validation/formatting.js.map +1 -0
  142. package/validation/validate.js +17 -0
  143. package/validation/validate.js.map +1 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) [2023]
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,20 @@
1
+ /// <reference types="node" resolution-mode="require"/>
2
+ import type { BundleDescription } from '../bundler/bundle-description.js';
3
+ import type { TarballBuilder } from '../tar/tarball-builder.js';
4
+ import type { FileDescription } from '../file-description/file-description.js';
5
+ import type { FileManager } from './file-manager.js';
6
+ export type ArtifactsBuilderDependencies = {
7
+ readonly fileManager: FileManager;
8
+ readonly tarballBuilder: TarballBuilder;
9
+ };
10
+ export type TarballArtifact = {
11
+ readonly tarData: Buffer;
12
+ readonly shasum: string;
13
+ };
14
+ export type ArtifactsBuilder = {
15
+ collectContents(bundle: BundleDescription): Promise<readonly FileDescription[]>;
16
+ buildTarball(bundle: BundleDescription): Promise<TarballArtifact>;
17
+ buildFolder(bundle: BundleDescription, targetFolder: string): Promise<void>;
18
+ };
19
+ export declare function createArtifactsBuilder(artifactsBuilderDependencies: ArtifactsBuilderDependencies): ArtifactsBuilder;
20
+ //# sourceMappingURL=artifacts-builder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"artifacts-builder.d.ts","sourceRoot":"","sources":["../../../../source/artifacts/artifacts-builder.ts"],"names":[],"mappings":";AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAC1E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yCAAyC,CAAC;AAC/E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD,MAAM,MAAM,4BAA4B,GAAG;IACvC,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC;IAClC,QAAQ,CAAC,cAAc,EAAE,cAAc,CAAC;CAC3C,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC1B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC3B,eAAe,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,SAAS,eAAe,EAAE,CAAC,CAAC;IAChF,YAAY,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;IAClE,WAAW,CAAC,MAAM,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC/E,CAAC;AAEF,wBAAgB,sBAAsB,CAAC,4BAA4B,EAAE,4BAA4B,GAAG,gBAAgB,CAgDnH"}
@@ -0,0 +1,43 @@
1
+ import path from 'node:path';
2
+ import ssri from 'ssri';
3
+ export function createArtifactsBuilder(artifactsBuilderDependencies) {
4
+ const { fileManager, tarballBuilder } = artifactsBuilderDependencies;
5
+ async function collectContents(bundle) {
6
+ const artifactContents = [];
7
+ for (const entry of bundle.contents) {
8
+ const targetFilePath = path.join('package', entry.targetFilePath);
9
+ if (entry.kind === 'reference') {
10
+ const content = await fileManager.readFile(entry.sourceFilePath);
11
+ artifactContents.push({ filePath: targetFilePath, content });
12
+ }
13
+ else {
14
+ artifactContents.push({ filePath: targetFilePath, content: entry.source });
15
+ }
16
+ }
17
+ return artifactContents;
18
+ }
19
+ return {
20
+ collectContents,
21
+ async buildTarball(bundle) {
22
+ const contents = await collectContents(bundle);
23
+ const tarData = await tarballBuilder.build(contents);
24
+ return {
25
+ shasum: ssri.fromData(tarData, { algorithms: ['sha1'] }).hexDigest(),
26
+ tarData
27
+ };
28
+ },
29
+ async buildFolder(bundle, targetFolder) {
30
+ const readability = await fileManager.checkReadability(targetFolder);
31
+ if (readability.isReadable) {
32
+ throw new Error(`Folder ${targetFolder} already exists`);
33
+ }
34
+ for (const entry of bundle.contents) {
35
+ const targetFilePath = path.join(targetFolder, entry.targetFilePath);
36
+ await (entry.kind === 'reference'
37
+ ? fileManager.copyFile(entry.sourceFilePath, targetFilePath)
38
+ : fileManager.writeFile(targetFilePath, entry.source));
39
+ }
40
+ }
41
+ };
42
+ }
43
+ //# sourceMappingURL=artifacts-builder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"artifacts-builder.js","sourceRoot":"","sources":["../../../../source/artifacts/artifacts-builder.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,IAAI,MAAM,MAAM,CAAC;AAsBxB,MAAM,UAAU,sBAAsB,CAAC,4BAA0D;IAC7F,MAAM,EAAE,WAAW,EAAE,cAAc,EAAE,GAAG,4BAA4B,CAAC;IAErE,KAAK,UAAU,eAAe,CAAC,MAAyB;QACpD,MAAM,gBAAgB,GAAsB,EAAE,CAAC;QAE/C,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;YAClC,MAAM,cAAc,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC;YAElE,IAAI,KAAK,CAAC,IAAI,KAAK,WAAW,EAAE,CAAC;gBAC7B,MAAM,OAAO,GAAG,MAAM,WAAW,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;gBACjE,gBAAgB,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,cAAc,EAAE,OAAO,EAAE,CAAC,CAAC;YACjE,CAAC;iBAAM,CAAC;gBACJ,gBAAgB,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,cAAc,EAAE,OAAO,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;YAC/E,CAAC;QACL,CAAC;QACD,OAAO,gBAAgB,CAAC;IAC5B,CAAC;IAED,OAAO;QACH,eAAe;QAEf,KAAK,CAAC,YAAY,CAAC,MAAM;YACrB,MAAM,QAAQ,GAAG,MAAM,eAAe,CAAC,MAAM,CAAC,CAAC;YAC/C,MAAM,OAAO,GAAG,MAAM,cAAc,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;YAErD,OAAO;gBACH,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,EAAE,UAAU,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,SAAS,EAAE;gBACpE,OAAO;aACV,CAAC;QACN,CAAC;QAED,KAAK,CAAC,WAAW,CAAC,MAAM,EAAE,YAAY;YAClC,MAAM,WAAW,GAAG,MAAM,WAAW,CAAC,gBAAgB,CAAC,YAAY,CAAC,CAAC;YAErE,IAAI,WAAW,CAAC,UAAU,EAAE,CAAC;gBACzB,MAAM,IAAI,KAAK,CAAC,UAAU,YAAY,iBAAiB,CAAC,CAAC;YAC7D,CAAC;YAED,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;gBAClC,MAAM,cAAc,GAAG,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC;gBAErE,MAAM,CAAC,KAAK,CAAC,IAAI,KAAK,WAAW;oBAC7B,CAAC,CAAC,WAAW,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,EAAE,cAAc,CAAC;oBAC5D,CAAC,CAAC,WAAW,CAAC,SAAS,CAAC,cAAc,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;YAC/D,CAAC;QACL,CAAC;KACJ,CAAC;AACN,CAAC"}
@@ -0,0 +1,18 @@
1
+ /// <reference types="node" resolution-mode="require"/>
2
+ /// <reference types="node" resolution-mode="require"/>
3
+ import fs from 'node:fs';
4
+ export type FileManagerDependencies = {
5
+ readonly hostFileSystem: typeof fs.promises;
6
+ };
7
+ type FileOrFolderReadability = {
8
+ readonly isReadable: boolean;
9
+ };
10
+ export type FileManager = {
11
+ checkReadability(fileOrFolderPath: string): Promise<FileOrFolderReadability>;
12
+ readFile(filePath: string): Promise<string>;
13
+ writeFile(filePath: string, content: string): Promise<void>;
14
+ copyFile(from: string, to: string): Promise<void>;
15
+ };
16
+ export declare function createFileManager(dependencies: FileManagerDependencies): FileManager;
17
+ export {};
18
+ //# sourceMappingURL=file-manager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-manager.d.ts","sourceRoot":"","sources":["../../../../source/artifacts/file-manager.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AAGzB,MAAM,MAAM,uBAAuB,GAAG;IAClC,QAAQ,CAAC,cAAc,EAAE,OAAO,EAAE,CAAC,QAAQ,CAAC;CAC/C,CAAC;AAEF,KAAK,uBAAuB,GAAG;IAC3B,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;CAChC,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACtB,gBAAgB,CAAC,gBAAgB,EAAE,MAAM,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC;IAC7E,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAC5C,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5D,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACrD,CAAC;AAEF,wBAAgB,iBAAiB,CAAC,YAAY,EAAE,uBAAuB,GAAG,WAAW,CAuCpF"}
@@ -0,0 +1,35 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ export function createFileManager(dependencies) {
4
+ const { hostFileSystem } = dependencies;
5
+ async function checkReadability(fileOrFolderPath) {
6
+ try {
7
+ await hostFileSystem.access(fileOrFolderPath, fs.constants.R_OK);
8
+ return { isReadable: true };
9
+ }
10
+ catch {
11
+ return { isReadable: false };
12
+ }
13
+ }
14
+ async function writeFile(filePath, content) {
15
+ const containingFolder = path.dirname(filePath);
16
+ const parentReadability = await checkReadability(containingFolder);
17
+ if (!parentReadability.isReadable) {
18
+ await hostFileSystem.mkdir(containingFolder, { recursive: true });
19
+ }
20
+ await hostFileSystem.writeFile(filePath, content, { encoding: 'utf8' });
21
+ }
22
+ async function readFile(filePath) {
23
+ return hostFileSystem.readFile(filePath, { encoding: 'utf8' });
24
+ }
25
+ return {
26
+ checkReadability,
27
+ writeFile,
28
+ readFile,
29
+ async copyFile(from, to) {
30
+ const content = await readFile(from);
31
+ await writeFile(to, content);
32
+ }
33
+ };
34
+ }
35
+ //# sourceMappingURL=file-manager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-manager.js","sourceRoot":"","sources":["../../../../source/artifacts/file-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAiB7B,MAAM,UAAU,iBAAiB,CAAC,YAAqC;IACnE,MAAM,EAAE,cAAc,EAAE,GAAG,YAAY,CAAC;IAExC,KAAK,UAAU,gBAAgB,CAAC,gBAAwB;QACpD,IAAI,CAAC;YACD,MAAM,cAAc,CAAC,MAAM,CAAC,gBAAgB,EAAE,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;YACjE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;QAChC,CAAC;QAAC,MAAM,CAAC;YACL,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC;QACjC,CAAC;IACL,CAAC;IAED,KAAK,UAAU,SAAS,CAAC,QAAgB,EAAE,OAAe;QACtD,MAAM,gBAAgB,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QAChD,MAAM,iBAAiB,GAAG,MAAM,gBAAgB,CAAC,gBAAgB,CAAC,CAAC;QAEnE,IAAI,CAAC,iBAAiB,CAAC,UAAU,EAAE,CAAC;YAChC,MAAM,cAAc,CAAC,KAAK,CAAC,gBAAgB,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACtE,CAAC;QAED,MAAM,cAAc,CAAC,SAAS,CAAC,QAAQ,EAAE,OAAO,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC;IAC5E,CAAC;IAED,KAAK,UAAU,QAAQ,CAAC,QAAgB;QACpC,OAAO,cAAc,CAAC,QAAQ,CAAC,QAAQ,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC;IACnE,CAAC;IAED,OAAO;QACH,gBAAgB;QAEhB,SAAS;QAET,QAAQ;QAER,KAAK,CAAC,QAAQ,CAAC,IAAI,EAAE,EAAE;YACnB,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,IAAI,CAAC,CAAC;YACrC,MAAM,SAAS,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;QACjC,CAAC;KACJ,CAAC;AACN,CAAC"}
@@ -0,0 +1,19 @@
1
+ import type { EntryPoint } from '../config/entry-point.js';
2
+ import type { AdditionalFileDescription } from '../config/additional-files.js';
3
+ import type { AdditionalPackageJsonAttributes, MainPackageJson } from '../config/package-json.js';
4
+ import type { BundleDescription } from './bundle-description.js';
5
+ export type EntryPoints = readonly [EntryPoint, ...(readonly EntryPoint[])];
6
+ export type BundleBuildOptions = {
7
+ readonly sourcesFolder: string;
8
+ readonly entryPoints: EntryPoints;
9
+ readonly name: string;
10
+ readonly version: string;
11
+ readonly mainPackageJson: MainPackageJson;
12
+ readonly includeSourceMapFiles?: boolean | undefined;
13
+ readonly bundleDependencies?: readonly BundleDescription[];
14
+ readonly bundlePeerDependencies?: readonly BundleDescription[];
15
+ readonly additionalFiles?: readonly (AdditionalFileDescription | string)[];
16
+ readonly additionalPackageJsonAttributes?: AdditionalPackageJsonAttributes;
17
+ };
18
+ export declare function validateBundleBuildOptions(options: BundleBuildOptions): void;
19
+ //# sourceMappingURL=bundle-build-options.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bundle-build-options.d.ts","sourceRoot":"","sources":["../../../../source/bundler/bundle-build-options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAC/E,OAAO,KAAK,EAAE,+BAA+B,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAClG,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAEjE,MAAM,MAAM,WAAW,GAAG,SAAS,CAAC,UAAU,EAAE,GAAG,CAAC,SAAS,UAAU,EAAE,CAAC,CAAC,CAAC;AAE5E,MAAM,MAAM,kBAAkB,GAAG;IAC7B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC;IAClC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,eAAe,EAAE,eAAe,CAAC;IAC1C,QAAQ,CAAC,qBAAqB,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IACrD,QAAQ,CAAC,kBAAkB,CAAC,EAAE,SAAS,iBAAiB,EAAE,CAAC;IAC3D,QAAQ,CAAC,sBAAsB,CAAC,EAAE,SAAS,iBAAiB,EAAE,CAAC;IAC/D,QAAQ,CAAC,eAAe,CAAC,EAAE,SAAS,CAAC,yBAAyB,GAAG,MAAM,CAAC,EAAE,CAAC;IAC3E,QAAQ,CAAC,+BAA+B,CAAC,EAAE,+BAA+B,CAAC;CAC9E,CAAC;AAoBF,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,kBAAkB,GAAG,IAAI,CAa5E"}
@@ -0,0 +1,25 @@
1
+ function extractName(bundle) {
2
+ return bundle.packageJson.name;
3
+ }
4
+ function findDuplicates(list) {
5
+ const uniqueValues = [];
6
+ return list.filter((value) => {
7
+ if (uniqueValues.includes(value)) {
8
+ return true;
9
+ }
10
+ uniqueValues.push(value);
11
+ return false;
12
+ });
13
+ }
14
+ export function validateBundleBuildOptions(options) {
15
+ const { bundleDependencies = [], bundlePeerDependencies = [] } = options;
16
+ const dependencyNames = bundleDependencies.map(extractName);
17
+ const peerDependencyNames = bundlePeerDependencies.map(extractName);
18
+ const allNames = [...dependencyNames, ...peerDependencyNames];
19
+ const duplicatedNames = findDuplicates(allNames);
20
+ if (duplicatedNames.length > 0) {
21
+ const formattedNames = duplicatedNames.join(', ');
22
+ throw new Error(`The following packages are listed more than once in dependencies or peerDependencies: ${formattedNames}`);
23
+ }
24
+ }
25
+ //# sourceMappingURL=bundle-build-options.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bundle-build-options.js","sourceRoot":"","sources":["../../../../source/bundler/bundle-build-options.ts"],"names":[],"mappings":"AAoBA,SAAS,WAAW,CAAC,MAAyB;IAC1C,OAAO,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC;AACnC,CAAC;AAED,SAAS,cAAc,CAAC,IAAuB;IAC3C,MAAM,YAAY,GAAa,EAAE,CAAC;IAElC,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE;QACzB,IAAI,YAAY,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;YAC/B,OAAO,IAAI,CAAC;QAChB,CAAC;QAED,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAEzB,OAAO,KAAK,CAAC;IACjB,CAAC,CAAC,CAAC;AACP,CAAC;AAED,MAAM,UAAU,0BAA0B,CAAC,OAA2B;IAClE,MAAM,EAAE,kBAAkB,GAAG,EAAE,EAAE,sBAAsB,GAAG,EAAE,EAAE,GAAG,OAAO,CAAC;IACzE,MAAM,eAAe,GAAG,kBAAkB,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IAC5D,MAAM,mBAAmB,GAAG,sBAAsB,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IACpE,MAAM,QAAQ,GAAG,CAAC,GAAG,eAAe,EAAE,GAAG,mBAAmB,CAAC,CAAC;IAC9D,MAAM,eAAe,GAAG,cAAc,CAAC,QAAQ,CAAC,CAAC;IAEjD,IAAI,eAAe,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC7B,MAAM,cAAc,GAAG,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAClD,MAAM,IAAI,KAAK,CACX,yFAAyF,cAAc,EAAE,CAC5G,CAAC;IACN,CAAC;AACL,CAAC"}
@@ -0,0 +1,27 @@
1
+ import type { PackageJson, SetRequired } from 'type-fest';
2
+ type SourceContent = {
3
+ readonly kind: 'source';
4
+ readonly targetFilePath: string;
5
+ readonly source: string;
6
+ readonly sourceFilePath?: undefined;
7
+ };
8
+ type ReferenceContent = {
9
+ readonly kind: 'reference';
10
+ readonly targetFilePath: string;
11
+ readonly sourceFilePath: string;
12
+ readonly source?: undefined;
13
+ };
14
+ type SubstitutedContent = {
15
+ readonly kind: 'substituted';
16
+ readonly targetFilePath: string;
17
+ readonly sourceFilePath: string;
18
+ readonly source: string;
19
+ };
20
+ export type BundleContent = Readonly<ReferenceContent | SourceContent | SubstitutedContent>;
21
+ export type BundlePackageJson = Readonly<SetRequired<PackageJson, 'name' | 'version'>>;
22
+ export type BundleDescription = {
23
+ readonly contents: readonly BundleContent[];
24
+ readonly packageJson: BundlePackageJson;
25
+ };
26
+ export {};
27
+ //# sourceMappingURL=bundle-description.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bundle-description.d.ts","sourceRoot":"","sources":["../../../../source/bundler/bundle-description.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAE1D,KAAK,aAAa,GAAG;IACjB,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,cAAc,CAAC,EAAE,SAAS,CAAC;CACvC,CAAC;AAEF,KAAK,gBAAgB,GAAG;IACpB,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAC3B,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,CAAC;CAC/B,CAAC;AAEF,KAAK,kBAAkB,GAAG;IACtB,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;IAC7B,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG,QAAQ,CAAC,gBAAgB,GAAG,aAAa,GAAG,kBAAkB,CAAC,CAAC;AAE5F,MAAM,MAAM,iBAAiB,GAAG,QAAQ,CAAC,WAAW,CAAC,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC;AAEvF,MAAM,MAAM,iBAAiB,GAAG;IAC5B,QAAQ,CAAC,QAAQ,EAAE,SAAS,aAAa,EAAE,CAAC;IAC5C,QAAQ,CAAC,WAAW,EAAE,iBAAiB,CAAC;CAC3C,CAAC"}
@@ -0,0 +1,11 @@
1
+ import type { DependencyScanner } from '../dependency-scanner/scanner.js';
2
+ import { type BundleBuildOptions } from './bundle-build-options.js';
3
+ import type { BundleDescription } from './bundle-description.js';
4
+ export type BundlerDependencies = {
5
+ readonly dependencyScanner: DependencyScanner;
6
+ };
7
+ export type Bundler = {
8
+ build(options: BundleBuildOptions): Promise<BundleDescription>;
9
+ };
10
+ export declare function createBundler(dependencies: Readonly<BundlerDependencies>): Bundler;
11
+ //# sourceMappingURL=bundler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bundler.d.ts","sourceRoot":"","sources":["../../../../source/bundler/bundler.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAO1E,OAAO,EAAE,KAAK,kBAAkB,EAAgD,MAAM,2BAA2B,CAAC;AAClH,OAAO,KAAK,EAAE,iBAAiB,EAAqB,MAAM,yBAAyB,CAAC;AAIpF,MAAM,MAAM,mBAAmB,GAAG;IAC9B,QAAQ,CAAC,iBAAiB,EAAE,iBAAiB,CAAC;CACjD,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG;IAClB,KAAK,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;CAClE,CAAC;AAgFF,wBAAgB,aAAa,CAAC,YAAY,EAAE,QAAQ,CAAC,mBAAmB,CAAC,GAAG,OAAO,CAoFlF"}
@@ -0,0 +1,98 @@
1
+ import path from 'node:path';
2
+ import { mergeDependencyFiles } from '../dependency-scanner/dependency-graph.js';
3
+ import { validateBundleBuildOptions } from './bundle-build-options.js';
4
+ import { substituteDependencies } from './substitute-bundles.js';
5
+ import { combineAllPackageFiles } from './content.js';
6
+ function containsBundleWithPackageName(bundles, name) {
7
+ return bundles.some((bundle) => {
8
+ return bundle.packageJson.name === name;
9
+ });
10
+ }
11
+ function distributeDependencies(packageDependencies, bundlePeerDependencies) {
12
+ const dependencies = {};
13
+ const peerDependencies = {};
14
+ for (const [dependencyName, dependencyVersion] of Object.entries(packageDependencies)) {
15
+ if (containsBundleWithPackageName(bundlePeerDependencies, dependencyName)) {
16
+ peerDependencies[dependencyName] = dependencyVersion;
17
+ }
18
+ else {
19
+ dependencies[dependencyName] = dependencyVersion;
20
+ }
21
+ }
22
+ return { dependencies, ...(Object.keys(peerDependencies).length > 0 ? { peerDependencies } : {}) };
23
+ }
24
+ function buildPackageJson(options, packageDependencies) {
25
+ const { name, version, sourcesFolder, mainPackageJson, entryPoints: [firstEntryPoint], additionalPackageJsonAttributes = {}, bundlePeerDependencies = [] } = options;
26
+ const distributedDependencies = distributeDependencies(packageDependencies, bundlePeerDependencies);
27
+ const types = firstEntryPoint.declarationFile === undefined
28
+ ? undefined
29
+ : path.relative(sourcesFolder, firstEntryPoint.declarationFile);
30
+ const packageJson = {
31
+ ...distributedDependencies,
32
+ name,
33
+ version,
34
+ main: path.relative(sourcesFolder, firstEntryPoint.js),
35
+ ...(mainPackageJson.type === undefined ? {} : { type: mainPackageJson.type }),
36
+ ...(types === undefined ? {} : { types })
37
+ };
38
+ return { ...additionalPackageJsonAttributes, ...packageJson };
39
+ }
40
+ export function createBundler(dependencies) {
41
+ const { dependencyScanner } = dependencies;
42
+ async function scanAndSubstitute(options) {
43
+ const { entryPoint, sourcesFolder, mainPackageJson, includeSourceMapFiles, resolveDeclarationFiles, bundleDependencies } = options;
44
+ const moduleResolution = mainPackageJson.type === 'module' ? 'module' : 'common-js';
45
+ const dependencyGraph = await dependencyScanner.scan(entryPoint, sourcesFolder, {
46
+ mainPackageJson,
47
+ moduleResolution,
48
+ includeSourceMapFiles,
49
+ includeDevDependencies: resolveDeclarationFiles,
50
+ resolveDeclarationFiles
51
+ });
52
+ return substituteDependencies(dependencyGraph, entryPoint, bundleDependencies);
53
+ }
54
+ async function resolveDependenciesForAllEntrypoints(options) {
55
+ const { entryPoints, sourcesFolder, mainPackageJson, includeSourceMapFiles, bundleDependencies } = options;
56
+ let dependencyFiles = { topLevelDependencies: {}, localFiles: [] };
57
+ for (const entryPoint of entryPoints) {
58
+ const jsDependencyGraph = await scanAndSubstitute({
59
+ entryPoint: entryPoint.js,
60
+ sourcesFolder,
61
+ mainPackageJson,
62
+ includeSourceMapFiles,
63
+ resolveDeclarationFiles: false,
64
+ bundleDependencies
65
+ });
66
+ dependencyFiles = mergeDependencyFiles(dependencyFiles, jsDependencyGraph.flatten(entryPoint.js));
67
+ if (entryPoint.declarationFile !== undefined) {
68
+ const declarationDependencyGraph = await scanAndSubstitute({
69
+ entryPoint: entryPoint.declarationFile,
70
+ sourcesFolder,
71
+ mainPackageJson,
72
+ includeSourceMapFiles,
73
+ resolveDeclarationFiles: true,
74
+ bundleDependencies
75
+ });
76
+ dependencyFiles = mergeDependencyFiles(dependencyFiles, declarationDependencyGraph.flatten(entryPoint.declarationFile));
77
+ }
78
+ }
79
+ return dependencyFiles;
80
+ }
81
+ return {
82
+ async build(options) {
83
+ validateBundleBuildOptions(options);
84
+ const { includeSourceMapFiles = false, bundleDependencies = [], bundlePeerDependencies = [] } = options;
85
+ const resolvedDependencies = await resolveDependenciesForAllEntrypoints({
86
+ entryPoints: options.entryPoints,
87
+ sourcesFolder: options.sourcesFolder,
88
+ mainPackageJson: options.mainPackageJson,
89
+ includeSourceMapFiles,
90
+ bundleDependencies: [...bundleDependencies, ...bundlePeerDependencies]
91
+ });
92
+ const packageJson = buildPackageJson(options, resolvedDependencies.topLevelDependencies);
93
+ const contents = combineAllPackageFiles(options.sourcesFolder, resolvedDependencies.localFiles, packageJson, options.additionalFiles);
94
+ return { contents, packageJson };
95
+ }
96
+ };
97
+ }
98
+ //# sourceMappingURL=bundler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bundler.js","sourceRoot":"","sources":["../../../../source/bundler/bundler.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAEH,oBAAoB,EAEvB,MAAM,2CAA2C,CAAC;AAEnD,OAAO,EAA6C,0BAA0B,EAAE,MAAM,2BAA2B,CAAC;AAElH,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAUtD,SAAS,6BAA6B,CAAC,OAAqC,EAAE,IAAY;IACtF,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE;QAC3B,OAAO,MAAM,CAAC,WAAW,CAAC,IAAI,KAAK,IAAI,CAAC;IAC5C,CAAC,CAAC,CAAC;AACP,CAAC;AAOD,SAAS,sBAAsB,CAC3B,mBAA2C,EAC3C,sBAAoD;IAEpD,MAAM,YAAY,GAA2B,EAAE,CAAC;IAChD,MAAM,gBAAgB,GAA2B,EAAE,CAAC;IAEpD,KAAK,MA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O,CAAC,eAAe,CAC1B,CAAC;YAEF,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC;QACrC,CAAC;KACJ,CAAC;AACN,CAAC"}
@@ -0,0 +1,53 @@
1
+ import path from 'node:path';
2
+ import { serializePackageJson } from '../package-json.js';
3
+ function prependSourcesFolderIfNecessary(sourcesFolder, filePath) {
4
+ if (!path.isAbsolute(filePath)) {
5
+ return path.join(sourcesFolder, filePath);
6
+ }
7
+ return filePath;
8
+ }
9
+ export function combineAllPackageFiles(sourcesFolder, localDependencies, packageJson, additionalFiles = []) {
10
+ const referenceContents = localDependencies.map((localFile) => {
11
+ const targetFilePath = path.relative(sourcesFolder, localFile.filePath);
12
+ if (localFile.substitutionContent.isJust) {
13
+ return {
14
+ kind: 'substituted',
15
+ sourceFilePath: localFile.filePath,
16
+ targetFilePath,
17
+ source: localFile.substitutionContent.value
18
+ };
19
+ }
20
+ return {
21
+ kind: 'reference',
22
+ sourceFilePath: localFile.filePath,
23
+ targetFilePath
24
+ };
25
+ });
26
+ const additionalContents = additionalFiles.map((additionalFile) => {
27
+ if (typeof additionalFile === 'string') {
28
+ return {
29
+ kind: 'reference',
30
+ sourceFilePath: path.join(sourcesFolder, additionalFile),
31
+ targetFilePath: additionalFile
32
+ };
33
+ }
34
+ if (path.isAbsolute(additionalFile.targetFilePath)) {
35
+ throw new Error('The targetFilePath must be relative');
36
+ }
37
+ return {
38
+ kind: 'reference',
39
+ sourceFilePath: prependSourcesFolderIfNecessary(sourcesFolder, additionalFile.sourceFilePath),
40
+ targetFilePath: additionalFile.targetFilePath
41
+ };
42
+ });
43
+ return [
44
+ {
45
+ kind: 'source',
46
+ source: serializePackageJson(packageJson),
47
+ targetFilePath: 'package.json'
48
+ },
49
+ ...referenceContents,
50
+ ...additionalContents
51
+ ];
52
+ }
53
+ //# sourceMappingURL=content.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content.js","sourceRoot":"","sources":["../../../../source/bundler/content.ts"],"names":[],"mapp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AC,cAAc,CAAC,cAAc,CAAC,EAAE,CAAC;YACjD,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;QAC3D,CAAC;QAED,OAAO;YACH,IAAI,EAAE,WAAW;YACjB,cAAc,EAAE,+BAA+B,CAAC,aAAa,EAAE,cAAc,CAAC,cAAc,CAAC;YAC7F,cAAc,EAAE,cAAc,CAAC,cAAc;SAChD,CAAC;IACN,CAAC,CAAC,CAAC;IAEH,OAAO;QACH;YACI,IAAI,EAAE,QAAQ;YACd,MAAM,EAAE,oBAAoB,CAAC,WAAW,CAAC;YACzC,cAAc,EAAE,cAAc;SACjC;QACD,GAAG,iBAAiB;QACpB,GAAG,kBAAkB;KACxB,CAAC;AACN,CAAC"}
@@ -0,0 +1,73 @@
1
+ import { Maybe } from 'true-myth';
2
+ import { createDependencyGraph } from '../dependency-scanner/dependency-graph.js';
3
+ import { replaceImportPaths } from '../source-modifier/import-paths.js';
4
+ function findReplacement(file, dependencies) {
5
+ for (const bundle of dependencies) {
6
+ const matchingContent = bundle.contents.find((content) => {
7
+ return content.sourceFilePath === file;
8
+ });
9
+ if (matchingContent !== undefined && matchingContent.kind !== 'source') {
10
+ const targetPath = `${bundle.packageJson.name}/${matchingContent.targetFilePath}`;
11
+ return Maybe.just({
12
+ targetPath,
13
+ packageName: bundle.packageJson.name,
14
+ packageVersion: bundle.packageJson.version
15
+ });
16
+ }
17
+ }
18
+ return Maybe.nothing();
19
+ }
20
+ function findAllPathReplacements(files, dependencies) {
21
+ const allReplacements = new Map();
22
+ const topLevelDependencies = new Map();
23
+ for (const file of files) {
24
+ const result = findReplacement(file, dependencies);
25
+ if (result.isJust) {
26
+ const { targetPath, packageName, packageVersion } = result.value;
27
+ allReplacements.set(file, targetPath);
28
+ topLevelDependencies.set(packageName, packageVersion);
29
+ }
30
+ }
31
+ return { importPathReplacements: allReplacements, topLevelDependencies };
32
+ }
33
+ function mergeTopLevelDependencies(first, second) {
34
+ return new Map([...first.entries(), ...second.entries()]);
35
+ }
36
+ export function substituteDependencies(graph, entryPointFile, dependencies) {
37
+ const substitutedGraph = createDependencyGraph();
38
+ const outstandingConnections = [];
39
+ graph.walk(entryPointFile, (node) => {
40
+ if (!substitutedGraph.isKnown(node.filePath)) {
41
+ const replacements = findAllPathReplacements(node.localFiles, dependencies);
42
+ for (const file of node.localFiles) {
43
+ if (!replacements.importPathReplacements.has(file)) {
44
+ outstandingConnections.push({ from: node.filePath, to: file });
45
+ }
46
+ }
47
+ if (replacements.importPathReplacements.size > 0) {
48
+ const substitutionContent = Maybe.just(replaceImportPaths(node.tsSourceFile, replacements.importPathReplacements));
49
+ substitutedGraph.addDependency(node.filePath, {
50
+ sourceMapFilePath: node.sourceMapFilePath,
51
+ topLevelDependencies: mergeTopLevelDependencies(node.topLevelDependencies, replacements.topLevelDependencies),
52
+ tsSourceFile: node.tsSourceFile,
53
+ substitutionContent
54
+ });
55
+ }
56
+ else {
57
+ substitutedGraph.addDependency(node.filePath, {
58
+ sourceMapFilePath: node.sourceMapFilePath,
59
+ topLevelDependencies: node.topLevelDependencies,
60
+ tsSourceFile: node.tsSourceFile,
61
+ substitutionContent: node.substitutionContent
62
+ });
63
+ }
64
+ }
65
+ });
66
+ for (const connection of outstandingConnections) {
67
+ if (!substitutedGraph.hasConnection(connection.from, connection.to)) {
68
+ substitutedGraph.connect(connection.from, connection.to);
69
+ }
70
+ }
71
+ return substitutedGraph;
72
+ }
73
+ //# sourceMappingURL=substitute-bundles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"substitute-bundles.js","sourceRoot":"","sources":["../../../../source/bundler/substitute-bundles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAClC,OAAO,EAAwB,qBAAqB,EAAE,MAAM,2CAA2C,CAAC;AACxG,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AASxE,SAAS,eAAe,CAAC,IAAY,EAAE,YAA0C;IAC7E,KAAK,MAA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YAAY,EAAE,IAAI,CAAC,YAAY;oBAC/B,mBAAmB;iBACtB,CAAC,CAAC;YACP,CAAC;iBAAM,CAAC;gBACJ,gBAAgB,CAAC,aAAa,CAAC,IAAI,CAAC,QAAQ,EAAE;oBAC1C,iBAAiB,EAAE,IAAI,CAAC,iBAAiB;oBACzC,oBAAoB,EAAE,IAAI,CAAC,oBAAoB;oBAC/C,YAAY,EAAE,IAAI,CAAC,YAAY;oBAC/B,mBAAmB,EAAE,IAAI,CAAC,mBAAmB;iBAChD,CAAC,CAAC;YACP,CAAC;QACL,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,KAAK,MAAM,UAAU,IAAI,sBAAsB,EAAE,CAAC;QAC9C,IAAI,CAAC,gBAAgB,CAAC,aAAa,CAAC,UAAU,CAAC,IAAI,EAAE,UAAU,CAAC,EAAE,CAAC,EAAE,CAAC;YAClE,gBAAgB,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,EAAE,UAAU,CAAC,EAAE,CAAC,CAAC;QAC7D,CAAC;IACL,CAAC;IAED,OAAO,gBAAgB,CAAC;AAC5B,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { type Schema } from '@effect/schema/Schema';
2
+ import { type NoExpand } from './base-validations.js';
3
+ declare const $additionalFileDescriptionSchema: Schema<{
4
+ readonly sourceFilePath: string;
5
+ readonly targetFilePath: string;
6
+ }, {
7
+ readonly sourceFilePath: string;
8
+ readonly targetFilePath: string;
9
+ }>;
10
+ export type AdditionalFileDescription = NoExpand<Schema.To<typeof $additionalFileDescriptionSchema>>;
11
+ export declare const additionalFileDescriptionSchema: Schema<AdditionalFileDescription>;
12
+ export {};
13
+ //# sourceMappingURL=additional-files.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"additional-files.d.ts","sourceRoot":"","sources":["../../../../source/config/additional-files.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAU,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,KAAK,QAAQ,EAAwB,MAAM,uBAAuB,CAAC;AAE5E,QAAA,MAAM,gCAAgC;;;;;;EAGpC,CAAC;AAEH,MAAM,MAAM,yBAAyB,GAAG,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,OAAO,gCAAgC,CAAC,CAAC,CAAC;AAErG,eAAO,MAAM,+BAA+B,EAAE,MAAM,CAAC,yBAAyB,CAAoC,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { struct } from '@effect/schema/Schema';
2
+ import { nonEmptyStringSchema } from './base-validations.js';
3
+ const $additionalFileDescriptionSchema = struct({
4
+ sourceFilePath: nonEmptyStringSchema,
5
+ targetFilePath: nonEmptyStringSchema
6
+ });
7
+ export const additionalFileDescriptionSchema = $additionalFileDescriptionSchema;
8
+ //# sourceMappingURL=additional-files.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"additional-files.js","sourceRoot":"","sources":["../../../../source/config/additional-files.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAiB,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAE5E,MAAM,gCAAgC,GAAG,MAAM,CAAC;IAC5C,cAAc,EAAE,oBAAoB;IACpC,cAAc,EAAE,oBAAoB;CACvC,CAAC,CAAC;AAIH,MAAM,CAAC,MAAM,+BAA+B,GAAsC,gCAAgC,CAAC"}
@@ -0,0 +1,5 @@
1
+ export declare const nonEmptyStringSchema: import("@effect/schema/Schema").Schema<string, string>;
2
+ export type NoExpand<T> = T & {
3
+ readonly _?: never;
4
+ };
5
+ //# sourceMappingURL=base-validations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base-validations.d.ts","sourceRoot":"","sources":["../../../../source/config/base-validations.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,oBAAoB,wDAA0B,CAAC;AAE5D,MAAM,MAAM,QAAQ,CAAC,CAAC,IAAI,CAAC,GAAG;IAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,KAAK,CAAA;CAAE,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { string, nonEmpty } from '@effect/schema/Schema';
2
+ export const nonEmptyStringSchema = string.pipe(nonEmpty());
3
+ //# sourceMappingURL=base-validations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base-validations.js","sourceRoot":"","sources":["../../../../source/config/base-validations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEzD,MAAM,CAAC,MAAM,oBAAoB,GAAG,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC"}