@packall/core 0.0.1 → 0.1.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 (126) hide show
  1. package/dist/{Archive.d.ts → archive.d.ts} +5 -5
  2. package/dist/archive.d.ts.map +1 -0
  3. package/dist/{Bundle.d.ts → bundle.d.ts} +51 -36
  4. package/dist/bundle.d.ts.map +1 -0
  5. package/dist/{DependencyRange.d.ts → dependency-range.d.ts} +2 -2
  6. package/dist/dependency-range.d.ts.map +1 -0
  7. package/dist/{Download.d.ts → download.d.ts} +7 -7
  8. package/dist/download.d.ts.map +1 -0
  9. package/dist/enums/artifact-kind.d.ts +8 -0
  10. package/dist/enums/artifact-kind.d.ts.map +1 -0
  11. package/dist/enums/edge-kind.d.ts +29 -0
  12. package/dist/enums/edge-kind.d.ts.map +1 -0
  13. package/dist/enums/input-file-kind.d.ts +12 -0
  14. package/dist/enums/input-file-kind.d.ts.map +1 -0
  15. package/dist/enums/layout.d.ts +23 -0
  16. package/dist/enums/layout.d.ts.map +1 -0
  17. package/dist/enums/lockfile-format.d.ts +9 -0
  18. package/dist/enums/lockfile-format.d.ts.map +1 -0
  19. package/dist/enums/phase.d.ts +11 -0
  20. package/dist/enums/phase.d.ts.map +1 -0
  21. package/dist/{Errors.d.ts → errors.d.ts} +49 -7
  22. package/dist/errors.d.ts.map +1 -0
  23. package/dist/index.d.ts +44 -28
  24. package/dist/index.d.ts.map +1 -1
  25. package/dist/index.js +2416 -1180
  26. package/dist/index.js.map +1 -1
  27. package/dist/input-file.d.ts +77 -0
  28. package/dist/input-file.d.ts.map +1 -0
  29. package/dist/{Integrity.d.ts → integrity.d.ts} +3 -3
  30. package/dist/integrity.d.ts.map +1 -0
  31. package/dist/{Layout.d.ts → layout.d.ts} +1 -1
  32. package/dist/{Layout.d.ts.map → layout.d.ts.map} +1 -1
  33. package/dist/locked-resolve.d.ts +47 -0
  34. package/dist/locked-resolve.d.ts.map +1 -0
  35. package/dist/lockfile/bun.d.ts +3 -0
  36. package/dist/lockfile/bun.d.ts.map +1 -0
  37. package/dist/lockfile/detect.d.ts +31 -0
  38. package/dist/lockfile/detect.d.ts.map +1 -0
  39. package/dist/lockfile/json.d.ts +23 -0
  40. package/dist/lockfile/json.d.ts.map +1 -0
  41. package/dist/lockfile/names.d.ts +16 -0
  42. package/dist/lockfile/names.d.ts.map +1 -0
  43. package/dist/lockfile/npm.d.ts +3 -0
  44. package/dist/lockfile/npm.d.ts.map +1 -0
  45. package/dist/lockfile/parse.d.ts +23 -0
  46. package/dist/lockfile/parse.d.ts.map +1 -0
  47. package/dist/lockfile/pnpm.d.ts +20 -0
  48. package/dist/lockfile/pnpm.d.ts.map +1 -0
  49. package/dist/lockfile/tree-builder.d.ts +70 -0
  50. package/dist/lockfile/tree-builder.d.ts.map +1 -0
  51. package/dist/lockfile/types.d.ts +70 -0
  52. package/dist/lockfile/types.d.ts.map +1 -0
  53. package/dist/{Manifest.d.ts → manifest.d.ts} +7 -15
  54. package/dist/manifest.d.ts.map +1 -0
  55. package/dist/{Options.d.ts → options.d.ts} +9 -27
  56. package/dist/options.d.ts.map +1 -0
  57. package/dist/{Platform.d.ts → platform.d.ts} +9 -9
  58. package/dist/platform.d.ts.map +1 -0
  59. package/dist/{Progress.d.ts → progress.d.ts} +10 -9
  60. package/dist/progress.d.ts.map +1 -0
  61. package/dist/{Registry.d.ts → registry.d.ts} +42 -44
  62. package/dist/registry.d.ts.map +1 -0
  63. package/dist/{Resolve.d.ts → resolve.d.ts} +25 -26
  64. package/dist/resolve.d.ts.map +1 -0
  65. package/dist/schemas/lenient.d.ts +38 -0
  66. package/dist/schemas/lenient.d.ts.map +1 -0
  67. package/dist/schemas/package-json.d.ts +44 -0
  68. package/dist/schemas/package-json.d.ts.map +1 -0
  69. package/dist/{Spec.d.ts → spec.d.ts} +4 -4
  70. package/dist/spec.d.ts.map +1 -0
  71. package/dist/types/value-of.d.ts +9 -0
  72. package/dist/types/value-of.d.ts.map +1 -0
  73. package/dist/utils/is-record.d.ts +8 -0
  74. package/dist/utils/is-record.d.ts.map +1 -0
  75. package/package.json +3 -2
  76. package/src/{Archive.ts → archive.ts} +92 -92
  77. package/src/{Bundle.ts → bundle.ts} +616 -570
  78. package/src/{DependencyRange.ts → dependency-range.ts} +115 -115
  79. package/src/{Download.ts → download.ts} +133 -132
  80. package/src/enums/artifact-kind.ts +9 -0
  81. package/src/enums/edge-kind.ts +32 -0
  82. package/src/enums/input-file-kind.ts +13 -0
  83. package/src/enums/layout.ts +25 -0
  84. package/src/enums/lockfile-format.ts +10 -0
  85. package/src/enums/phase.ts +12 -0
  86. package/src/{Errors.ts → errors.ts} +87 -5
  87. package/src/index.ts +133 -35
  88. package/src/{InputFile.ts → input-file.ts} +127 -44
  89. package/src/{Integrity.ts → integrity.ts} +121 -122
  90. package/src/locked-resolve.ts +461 -0
  91. package/src/lockfile/bun.ts +207 -0
  92. package/src/lockfile/detect.ts +80 -0
  93. package/src/lockfile/json.ts +132 -0
  94. package/src/lockfile/names.ts +20 -0
  95. package/src/lockfile/npm.ts +308 -0
  96. package/src/lockfile/parse.ts +56 -0
  97. package/src/lockfile/pnpm.ts +225 -0
  98. package/src/lockfile/tree-builder.ts +166 -0
  99. package/src/lockfile/types.ts +74 -0
  100. package/src/{Manifest.ts → manifest.ts} +133 -133
  101. package/src/{Options.ts → options.ts} +7 -27
  102. package/src/{Platform.ts → platform.ts} +23 -23
  103. package/src/{Progress.ts → progress.ts} +106 -106
  104. package/src/{Registry.ts → registry.ts} +115 -121
  105. package/src/{Resolve.ts → resolve.ts} +537 -528
  106. package/src/schemas/lenient.ts +123 -0
  107. package/src/schemas/package-json.ts +27 -0
  108. package/src/{Spec.ts → spec.ts} +11 -19
  109. package/src/types/value-of.ts +8 -0
  110. package/src/utils/is-record.ts +8 -0
  111. package/dist/Archive.d.ts.map +0 -1
  112. package/dist/Bundle.d.ts.map +0 -1
  113. package/dist/DependencyRange.d.ts.map +0 -1
  114. package/dist/Download.d.ts.map +0 -1
  115. package/dist/Errors.d.ts.map +0 -1
  116. package/dist/InputFile.d.ts +0 -46
  117. package/dist/InputFile.d.ts.map +0 -1
  118. package/dist/Integrity.d.ts.map +0 -1
  119. package/dist/Manifest.d.ts.map +0 -1
  120. package/dist/Options.d.ts.map +0 -1
  121. package/dist/Platform.d.ts.map +0 -1
  122. package/dist/Progress.d.ts.map +0 -1
  123. package/dist/Registry.d.ts.map +0 -1
  124. package/dist/Resolve.d.ts.map +0 -1
  125. package/dist/Spec.d.ts.map +0 -1
  126. /package/src/{Layout.ts → layout.ts} +0 -0
@@ -1,121 +1,115 @@
1
- /**
2
- * The registry seam.
3
- *
4
- * This is the **only** place in the engine that knows a registry exists.
5
- * Everything downstream — range resolution, the dependency walk, layout,
6
- * archiving — is expressed against these three operations, so swapping npm for
7
- * something else means implementing this interface and nothing more.
8
- *
9
- * `@packall/registry-npm` provides the implementation that speaks the plain
10
- * npm registry protocol, which is what Artifactory, Nexus, Verdaccio, GitHub
11
- * Packages and registry.npmjs.org all serve.
12
- */
13
- import * as Context from "effect/Context"
14
- import type * as Effect from "effect/Effect"
15
- import type { BundlerError } from "./Errors.js"
16
-
17
- /**
18
- * A single published version, as the registry describes it.
19
- *
20
- * This is a narrowed view of a package.json only the fields that affect what
21
- * has to be downloaded. Unknown fields are ignored rather than rejected,
22
- * because registries add metadata over time and a bundler that breaks on new
23
- * metadata is worse than useless.
24
- */
25
- export interface PackageManifest {
26
- readonly name: string
27
- readonly version: string
28
-
29
- readonly dependencies?: Readonly<Record<string, string>> | undefined
30
- readonly optionalDependencies?: Readonly<Record<string, string>> | undefined
31
- readonly peerDependencies?: Readonly<Record<string, string>> | undefined
32
- readonly peerDependenciesMeta?:
33
- | Readonly<Record<string, { readonly optional?: boolean | undefined }>>
34
- | undefined
35
- readonly devDependencies?: Readonly<Record<string, string>> | undefined
36
- readonly bundleDependencies?: ReadonlyArray<string> | undefined
37
-
38
- /** Platform constraints, used when `--platform` narrows optional deps. */
39
- readonly os?: ReadonlyArray<string> | undefined
40
- readonly cpu?: ReadonlyArray<string> | undefined
41
- readonly libc?: ReadonlyArray<string> | undefined
42
-
43
- readonly deprecated?: string | undefined
44
-
45
- readonly dist: PackageDist
46
- }
47
-
48
- /** Where the tarball lives and how to prove it arrived intact. */
49
- export interface PackageDist {
50
- readonly tarball: string
51
- /** SRI string, e.g. `sha512-...`. Preferred over `shasum`. */
52
- readonly integrity?: string | undefined
53
- /** Legacy hex sha1. Still the only checksum on very old versions. */
54
- readonly shasum?: string | undefined
55
- readonly unpackedSize?: number | undefined
56
- readonly fileCount?: number | undefined
57
- }
58
-
59
- /** Everything the registry knows about one package. */
60
- export interface Packument {
61
- readonly name: string
62
- /** `{ latest: "1.2.3", next: "2.0.0-beta.1" }` */
63
- readonly distTags: Readonly<Record<string, string>>
64
- /** Every published version, keyed by version string. */
65
- readonly versions: Readonly<Record<string, PackageManifest>>
66
- }
67
-
68
- /** The set of operations a registry backend has to provide. */
69
- export interface RegistryService {
70
- /** Short identifier for the manifest and for error messages, e.g. `"npm"`. */
71
- readonly kind: string
72
-
73
- /**
74
- * The registry URL that will actually be used for a given package, after
75
- * per-scope configuration is applied. Used for reporting only.
76
- */
77
- readonly registryFor: (packageName: string) => string
78
-
79
- /**
80
- * Cheap liveness check, run once before any real work.
81
- *
82
- * This is what turns "hangs forever behind a dead VPN" into a five-second
83
- * error naming the host we could not reach.
84
- */
85
- readonly preflight: Effect.Effect<void, BundlerError>
86
-
87
- /**
88
- * Full metadata for a package. Implementations are expected to memoise:
89
- * the dependency walk asks for the same popular packages repeatedly.
90
- */
91
- readonly packument: (packageName: string) => Effect.Effect<Packument, BundlerError>
92
-
93
- /** Fetches the tarball bytes for one published version. */
94
- readonly download: (manifest: PackageManifest) => Effect.Effect<Uint8Array, BundlerError>
95
- }
96
-
97
- /**
98
- * Service tag for the registry backend.
99
- *
100
- * @example
101
- * ```ts
102
- * import { Effect } from "effect"
103
- * import { Registry } from "@packall/core"
104
- *
105
- * const program = Effect.gen(function*() {
106
- * const registry = yield* Registry
107
- * return yield* registry.packument("lodash")
108
- * })
109
- * ```
110
- */
111
- export class Registry extends Context.Service<Registry, RegistryService>()(
112
- "@packall/core/Registry"
113
- ) {}
114
-
115
- /** Extracts the dist-tag mapping, defaulting sensibly when a registry omits it. */
116
- export const resolveDistTag = (packument: Packument, tag: string): string | undefined =>
117
- packument.distTags[tag]
118
-
119
- /** All published version strings, in registry order. */
120
- export const publishedVersions = (packument: Packument): ReadonlyArray<string> =>
121
- Object.keys(packument.versions)
1
+ /**
2
+ * The registry seam.
3
+ *
4
+ * This is the **only** place in the engine that knows a registry exists.
5
+ * Everything downstream — range resolution, the dependency walk, layout,
6
+ * archiving — is expressed against these three operations, so swapping npm for
7
+ * something else means implementing this interface and nothing more.
8
+ *
9
+ * `@packall/registry-npm` provides the implementation that speaks the plain
10
+ * npm registry protocol, which is what Artifactory, Nexus, Verdaccio, GitHub
11
+ * Packages and registry.npmjs.org all serve.
12
+ */
13
+ import * as Context from "effect/Context"
14
+ import type * as Effect from "effect/Effect"
15
+ import type { BundlerError } from "./errors.js"
16
+
17
+ /** Where the tarball lives and how to prove it arrived intact. */
18
+ export type PackageDist = {
19
+ readonly tarball: string
20
+ /** SRI string, e.g. `sha512-...`. Preferred over `shasum`. */
21
+ readonly integrity?: string | undefined
22
+ /** Legacy hex sha1. Still the only checksum on very old versions. */
23
+ readonly shasum?: string | undefined
24
+ readonly unpackedSize?: number | undefined
25
+ readonly fileCount?: number | undefined
26
+ }
27
+
28
+ /**
29
+ * A single published version, as the registry describes it.
30
+ *
31
+ * This is a narrowed view of a package.json — only the fields that affect what
32
+ * has to be downloaded. Unknown fields are ignored rather than rejected,
33
+ * because registries add metadata over time and a bundler that breaks on new
34
+ * metadata is worse than useless.
35
+ */
36
+ export type PackageManifest = {
37
+ readonly name: string
38
+ readonly version: string
39
+
40
+ readonly dependencies?: Readonly<Record<string, string>> | undefined
41
+ readonly optionalDependencies?: Readonly<Record<string, string>> | undefined
42
+ readonly peerDependencies?: Readonly<Record<string, string>> | undefined
43
+ readonly peerDependenciesMeta?:
44
+ | Readonly<Record<string, { readonly optional?: boolean | undefined }>>
45
+ | undefined
46
+ readonly devDependencies?: Readonly<Record<string, string>> | undefined
47
+ readonly bundleDependencies?: ReadonlyArray<string> | undefined
48
+
49
+ /** Platform constraints, used when `--platform` narrows optional deps. */
50
+ readonly os?: ReadonlyArray<string> | undefined
51
+ readonly cpu?: ReadonlyArray<string> | undefined
52
+ readonly libc?: ReadonlyArray<string> | undefined
53
+
54
+ readonly deprecated?: string | undefined
55
+
56
+ readonly dist: PackageDist
57
+ }
58
+
59
+ /** Everything the registry knows about one package. */
60
+ export type Packument = {
61
+ readonly name: string
62
+ /** `{ latest: "1.2.3", next: "2.0.0-beta.1" }` */
63
+ readonly distTags: Readonly<Record<string, string>>
64
+ /** Every published version, keyed by version string. */
65
+ readonly versions: Readonly<Record<string, PackageManifest>>
66
+ }
67
+
68
+ export declare namespace Registry {
69
+ /** The set of operations a registry backend has to provide. */
70
+ export type Service = {
71
+ /** Short identifier for the manifest and for error messages, e.g. `"npm"`. */
72
+ readonly kind: string
73
+
74
+ /**
75
+ * The registry URL that will actually be used for a given package, after
76
+ * per-scope configuration is applied. Used for reporting only.
77
+ */
78
+ readonly registryFor: (packageName: string) => string
79
+
80
+ /**
81
+ * Cheap liveness check, run once before any real work.
82
+ *
83
+ * This is what turns "hangs forever behind a dead VPN" into a five-second
84
+ * error naming the host we could not reach.
85
+ */
86
+ readonly preflight: Effect.Effect<void, BundlerError>
87
+
88
+ /**
89
+ * Full metadata for a package. Implementations are expected to memoise:
90
+ * the dependency walk asks for the same popular packages repeatedly.
91
+ */
92
+ readonly packument: (packageName: string) => Effect.Effect<Packument, BundlerError>
93
+
94
+ /** Fetches the tarball bytes for one published version. */
95
+ readonly download: (manifest: PackageManifest) => Effect.Effect<Uint8Array, BundlerError>
96
+ }
97
+ }
98
+
99
+ /**
100
+ * Service tag for the registry backend.
101
+ *
102
+ * @example
103
+ * ```ts
104
+ * import { Effect } from "effect"
105
+ * import { Registry } from "@packall/core"
106
+ *
107
+ * const program = Effect.gen(function*() {
108
+ * const registry = yield* Registry
109
+ * return yield* registry.packument("lodash")
110
+ * })
111
+ * ```
112
+ */
113
+ export class Registry extends Context.Service<Registry, Registry.Service>()(
114
+ "@packall/core/Registry"
115
+ ) {}