@packall/core 0.1.0 → 0.3.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 (96) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +58 -0
  3. package/dist/archive-DmF9XNl7.js +284 -0
  4. package/dist/archive-DmF9XNl7.js.map +1 -0
  5. package/dist/archive.d.ts +47 -15
  6. package/dist/archive.d.ts.map +1 -1
  7. package/dist/bundle.d.ts +6 -3
  8. package/dist/bundle.d.ts.map +1 -1
  9. package/dist/dependency-range.d.ts.map +1 -1
  10. package/dist/download.d.ts +2 -1
  11. package/dist/download.d.ts.map +1 -1
  12. package/dist/enums/artifact-kind.d.ts.map +1 -1
  13. package/dist/enums/edge-kind.d.ts.map +1 -1
  14. package/dist/enums/input-file-kind.d.ts.map +1 -1
  15. package/dist/enums/layout.d.ts.map +1 -1
  16. package/dist/enums/lockfile-format.d.ts.map +1 -1
  17. package/dist/enums/phase.d.ts.map +1 -1
  18. package/dist/errors.d.ts +11 -1
  19. package/dist/errors.d.ts.map +1 -1
  20. package/dist/index.d.ts +12 -10
  21. package/dist/index.d.ts.map +1 -1
  22. package/dist/index.js +169 -344
  23. package/dist/index.js.map +1 -1
  24. package/dist/input-file.d.ts.map +1 -1
  25. package/dist/integrity.d.ts +37 -5
  26. package/dist/integrity.d.ts.map +1 -1
  27. package/dist/layout.d.ts +41 -7
  28. package/dist/layout.d.ts.map +1 -1
  29. package/dist/locked-resolve.d.ts.map +1 -1
  30. package/dist/lockfile/bun.d.ts.map +1 -1
  31. package/dist/lockfile/detect.d.ts.map +1 -1
  32. package/dist/lockfile/json.d.ts.map +1 -1
  33. package/dist/lockfile/names.d.ts.map +1 -1
  34. package/dist/lockfile/npm.d.ts.map +1 -1
  35. package/dist/lockfile/parse.d.ts.map +1 -1
  36. package/dist/lockfile/pnpm.d.ts.map +1 -1
  37. package/dist/lockfile/tree-builder.d.ts.map +1 -1
  38. package/dist/lockfile/types.d.ts.map +1 -1
  39. package/dist/manifest.d.ts.map +1 -1
  40. package/dist/node/archiver.d.ts +5 -0
  41. package/dist/node/archiver.d.ts.map +1 -0
  42. package/dist/node/index.d.ts +13 -0
  43. package/dist/node/index.d.ts.map +1 -0
  44. package/dist/node/index.js +55 -0
  45. package/dist/node/index.js.map +1 -0
  46. package/dist/options.d.ts +3 -3
  47. package/dist/options.d.ts.map +1 -1
  48. package/dist/platform.d.ts +5 -10
  49. package/dist/platform.d.ts.map +1 -1
  50. package/dist/progress.d.ts.map +1 -1
  51. package/dist/registry.d.ts.map +1 -1
  52. package/dist/resolve.d.ts.map +1 -1
  53. package/dist/schemas/lenient.d.ts.map +1 -1
  54. package/dist/schemas/package-json.d.ts.map +1 -1
  55. package/dist/spec.d.ts.map +1 -1
  56. package/dist/types/value-of.d.ts.map +1 -1
  57. package/dist/utils/is-record.d.ts.map +1 -1
  58. package/package.json +11 -10
  59. package/src/archive.ts +95 -92
  60. package/src/bundle.ts +736 -616
  61. package/src/dependency-range.ts +121 -115
  62. package/src/download.ts +155 -133
  63. package/src/enums/artifact-kind.ts +5 -5
  64. package/src/enums/edge-kind.ts +13 -13
  65. package/src/enums/input-file-kind.ts +9 -9
  66. package/src/enums/layout.ts +20 -20
  67. package/src/enums/lockfile-format.ts +6 -6
  68. package/src/enums/phase.ts +8 -8
  69. package/src/errors.ts +211 -199
  70. package/src/index.ts +126 -113
  71. package/src/input-file.ts +246 -234
  72. package/src/integrity.ts +165 -121
  73. package/src/layout.ts +63 -29
  74. package/src/locked-resolve.ts +471 -461
  75. package/src/lockfile/bun.ts +214 -207
  76. package/src/lockfile/detect.ts +80 -80
  77. package/src/lockfile/json.ts +91 -92
  78. package/src/lockfile/names.ts +9 -9
  79. package/src/lockfile/npm.ts +328 -308
  80. package/src/lockfile/parse.ts +32 -32
  81. package/src/lockfile/pnpm.ts +230 -225
  82. package/src/lockfile/tree-builder.ts +116 -116
  83. package/src/lockfile/types.ts +52 -52
  84. package/src/manifest.ts +129 -133
  85. package/src/node/archiver.ts +85 -0
  86. package/src/node/index.ts +13 -0
  87. package/src/options.ts +84 -84
  88. package/src/platform.ts +97 -101
  89. package/src/progress.ts +105 -106
  90. package/src/registry.ts +116 -115
  91. package/src/resolve.ts +560 -537
  92. package/src/schemas/lenient.ts +67 -60
  93. package/src/schemas/package-json.ts +11 -10
  94. package/src/spec.ts +123 -119
  95. package/src/types/value-of.ts +1 -1
  96. package/src/utils/is-record.ts +1 -1
package/src/registry.ts CHANGED
@@ -1,115 +1,116 @@
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
- ) {}
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
+
16
+ import type { BundlerError } from "./errors.js";
17
+
18
+ /** Where the tarball lives and how to prove it arrived intact. */
19
+ export type PackageDist = {
20
+ readonly tarball: string;
21
+ /** SRI string, e.g. `sha512-...`. Preferred over `shasum`. */
22
+ readonly integrity?: string | undefined;
23
+ /** Legacy hex sha1. Still the only checksum on very old versions. */
24
+ readonly shasum?: string | undefined;
25
+ readonly unpackedSize?: number | undefined;
26
+ readonly fileCount?: number | undefined;
27
+ };
28
+
29
+ /**
30
+ * A single published version, as the registry describes it.
31
+ *
32
+ * This is a narrowed view of a package.json only the fields that affect what
33
+ * has to be downloaded. Unknown fields are ignored rather than rejected,
34
+ * because registries add metadata over time and a bundler that breaks on new
35
+ * metadata is worse than useless.
36
+ */
37
+ export type PackageManifest = {
38
+ readonly name: string;
39
+ readonly version: string;
40
+
41
+ readonly dependencies?: Readonly<Record<string, string>> | undefined;
42
+ readonly optionalDependencies?: Readonly<Record<string, string>> | undefined;
43
+ readonly peerDependencies?: Readonly<Record<string, string>> | undefined;
44
+ readonly peerDependenciesMeta?:
45
+ | Readonly<Record<string, { readonly optional?: boolean | undefined }>>
46
+ | undefined;
47
+ readonly devDependencies?: Readonly<Record<string, string>> | undefined;
48
+ readonly bundleDependencies?: ReadonlyArray<string> | undefined;
49
+
50
+ /** Platform constraints, used when `--platform` narrows optional deps. */
51
+ readonly os?: ReadonlyArray<string> | undefined;
52
+ readonly cpu?: ReadonlyArray<string> | undefined;
53
+ readonly libc?: ReadonlyArray<string> | undefined;
54
+
55
+ readonly deprecated?: string | undefined;
56
+
57
+ readonly dist: PackageDist;
58
+ };
59
+
60
+ /** Everything the registry knows about one package. */
61
+ export type Packument = {
62
+ readonly name: string;
63
+ /** `{ latest: "1.2.3", next: "2.0.0-beta.1" }` */
64
+ readonly distTags: Readonly<Record<string, string>>;
65
+ /** Every published version, keyed by version string. */
66
+ readonly versions: Readonly<Record<string, PackageManifest>>;
67
+ };
68
+
69
+ export declare namespace Registry {
70
+ /** The set of operations a registry backend has to provide. */
71
+ export type Service = {
72
+ /** Short identifier for the manifest and for error messages, e.g. `"npm"`. */
73
+ readonly kind: string;
74
+
75
+ /**
76
+ * The registry URL that will actually be used for a given package, after
77
+ * per-scope configuration is applied. Used for reporting only.
78
+ */
79
+ readonly registryFor: (packageName: string) => string;
80
+
81
+ /**
82
+ * Cheap liveness check, run once before any real work.
83
+ *
84
+ * This is what turns "hangs forever behind a dead VPN" into a five-second
85
+ * error naming the host we could not reach.
86
+ */
87
+ readonly preflight: Effect.Effect<void, BundlerError>;
88
+
89
+ /**
90
+ * Full metadata for a package. Implementations are expected to memoise:
91
+ * the dependency walk asks for the same popular packages repeatedly.
92
+ */
93
+ readonly packument: (packageName: string) => Effect.Effect<Packument, BundlerError>;
94
+
95
+ /** Fetches the tarball bytes for one published version. */
96
+ readonly download: (manifest: PackageManifest) => Effect.Effect<Uint8Array, BundlerError>;
97
+ };
98
+ }
99
+
100
+ /**
101
+ * Service tag for the registry backend.
102
+ *
103
+ * @example
104
+ * ```ts
105
+ * import { Effect } from "effect"
106
+ * import { Registry } from "@packall/core"
107
+ *
108
+ * const program = Effect.gen(function*() {
109
+ * const registry = yield* Registry
110
+ * return yield* registry.packument("lodash")
111
+ * })
112
+ * ```
113
+ */
114
+ export class Registry extends Context.Service<Registry, Registry.Service>()(
115
+ "@packall/core/Registry",
116
+ ) {}