@packall/core 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 (51) hide show
  1. package/dist/Archive.d.ts +32 -0
  2. package/dist/Archive.d.ts.map +1 -0
  3. package/dist/Bundle.d.ts +123 -0
  4. package/dist/Bundle.d.ts.map +1 -0
  5. package/dist/DependencyRange.d.ts +26 -0
  6. package/dist/DependencyRange.d.ts.map +1 -0
  7. package/dist/Download.d.ts +35 -0
  8. package/dist/Download.d.ts.map +1 -0
  9. package/dist/Errors.d.ts +124 -0
  10. package/dist/Errors.d.ts.map +1 -0
  11. package/dist/InputFile.d.ts +46 -0
  12. package/dist/InputFile.d.ts.map +1 -0
  13. package/dist/Integrity.d.ts +48 -0
  14. package/dist/Integrity.d.ts.map +1 -0
  15. package/dist/Layout.d.ts +53 -0
  16. package/dist/Layout.d.ts.map +1 -0
  17. package/dist/Manifest.d.ts +82 -0
  18. package/dist/Manifest.d.ts.map +1 -0
  19. package/dist/Options.d.ts +100 -0
  20. package/dist/Options.d.ts.map +1 -0
  21. package/dist/Platform.d.ts +69 -0
  22. package/dist/Platform.d.ts.map +1 -0
  23. package/dist/Progress.d.ts +107 -0
  24. package/dist/Progress.d.ts.map +1 -0
  25. package/dist/Registry.d.ts +106 -0
  26. package/dist/Registry.d.ts.map +1 -0
  27. package/dist/Resolve.d.ts +105 -0
  28. package/dist/Resolve.d.ts.map +1 -0
  29. package/dist/Spec.d.ts +62 -0
  30. package/dist/Spec.d.ts.map +1 -0
  31. package/dist/index.d.ts +36 -0
  32. package/dist/index.d.ts.map +1 -0
  33. package/dist/index.js +1766 -0
  34. package/dist/index.js.map +1 -0
  35. package/package.json +38 -0
  36. package/src/Archive.ts +92 -0
  37. package/src/Bundle.ts +570 -0
  38. package/src/DependencyRange.ts +115 -0
  39. package/src/Download.ts +132 -0
  40. package/src/Errors.ts +216 -0
  41. package/src/InputFile.ts +229 -0
  42. package/src/Integrity.ts +122 -0
  43. package/src/Layout.ts +103 -0
  44. package/src/Manifest.ts +133 -0
  45. package/src/Options.ts +123 -0
  46. package/src/Platform.ts +182 -0
  47. package/src/Progress.ts +106 -0
  48. package/src/Registry.ts +121 -0
  49. package/src/Resolve.ts +528 -0
  50. package/src/Spec.ts +186 -0
  51. package/src/index.ts +44 -0
@@ -0,0 +1,100 @@
1
+ /**
2
+ * Option types shared by the resolver and the bundler, plus their defaults.
3
+ *
4
+ * Defaults are chosen so that the *unflagged* command produces a bundle that
5
+ * actually installs offline on a machine that is not the one you built it on.
6
+ * Every switch that makes the bundle smaller is opt-in.
7
+ */
8
+ import type { PlatformFilter } from "./Platform.js";
9
+ /** How the resulting tarball(s) are shaped. */
10
+ export type Layout =
11
+ /**
12
+ * One tarball per requested spec, each carrying its own complete dependency
13
+ * closure. Shared dependencies repeat across tarballs, so the total is
14
+ * larger — but each one imports, rolls back and hands off independently.
15
+ */
16
+ "per-spec"
17
+ /**
18
+ * One tarball for everything, with the union of all closures deduplicated.
19
+ * Smallest output and a single import step; all-or-nothing to roll back.
20
+ */
21
+ | "single"
22
+ /**
23
+ * No archive at all — just the npm-layout directory tree, ready for
24
+ * `jf rt upload` or rsync.
25
+ */
26
+ | "dir";
27
+ export declare const layouts: ReadonlyArray<Layout>;
28
+ /** Which dependency edges the resolver follows. */
29
+ export interface DependencyScope {
30
+ /**
31
+ * Follow `optionalDependencies`. On by default — this is where per-platform
32
+ * native binaries live, and omitting them is the most common reason an
33
+ * offline install fails on a machine other than the one that built it.
34
+ */
35
+ readonly optional: boolean;
36
+ /**
37
+ * Follow non-optional `peerDependencies`. On by default, because npm 7+
38
+ * auto-installs peers and will reach for the network if they are absent.
39
+ */
40
+ readonly peer: boolean;
41
+ /** Which platforms optional dependencies are kept for. */
42
+ readonly platforms: PlatformFilter;
43
+ }
44
+ export declare const defaultScope: DependencyScope;
45
+ /** Options governing version selection and the dependency walk. */
46
+ export interface ResolveOptions {
47
+ readonly scope: DependencyScope;
48
+ /**
49
+ * When a root spec is a range, take *every* published version that satisfies
50
+ * it rather than only the best match.
51
+ *
52
+ * `npmb react@^18` bundles one version; `npmb --all-versions react@^18`
53
+ * bundles all of them.
54
+ */
55
+ readonly allVersions: boolean;
56
+ /** With `allVersions`, keep at most this many (newest first). */
57
+ readonly maxVersions?: number | undefined;
58
+ /** Let prereleases satisfy ranges that would not normally admit them. */
59
+ readonly includePrerelease: boolean;
60
+ /** How many registry requests to have in flight at once. */
61
+ readonly concurrency: number;
62
+ }
63
+ export declare const defaultResolveOptions: ResolveOptions;
64
+ /** Options for a full bundle run. */
65
+ export interface BundleOptions extends ResolveOptions {
66
+ readonly layout: Layout;
67
+ /** Directory the finished artifacts are written to. */
68
+ readonly outDir: string;
69
+ /** Base name for the archive in `single` layout. Defaults to `bundle`. */
70
+ readonly archiveName?: string | undefined;
71
+ /** Resolve and report, but download nothing and write nothing. */
72
+ readonly dryRun: boolean;
73
+ /**
74
+ * Verify every tarball against the checksum the registry advertised.
75
+ *
76
+ * On by default and there is essentially no good reason to turn it off; the
77
+ * escape hatch exists only for registries that serve broken metadata.
78
+ */
79
+ readonly verifyIntegrity: boolean;
80
+ /** Overwrite existing files in `outDir` instead of refusing. */
81
+ readonly force: boolean;
82
+ /**
83
+ * Planned output files to leave untouched, by file name.
84
+ *
85
+ * The engine never asks anything; deciding is the caller's job. The CLI's
86
+ * `--force prompt` resolves its per-file answers into this set, so "keep the
87
+ * existing one" means that artifact is simply not produced, and the rest of
88
+ * the run continues.
89
+ */
90
+ readonly skipExisting?: ReadonlySet<string> | undefined;
91
+ /**
92
+ * Planned output files that may be replaced, by file name.
93
+ *
94
+ * A narrower `force`: `--force tsdown` says "replace tsdown's bundle, and
95
+ * still ask about anything else".
96
+ */
97
+ readonly overwrite?: ReadonlySet<string> | undefined;
98
+ }
99
+ export declare const defaultBundleOptions: Omit<BundleOptions, "outDir">;
100
+ //# sourceMappingURL=Options.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Options.d.ts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,CAAA;IACxB;;;;;OAKG;IACH,QAAQ,CAAC,eAAe,EAAE,OAAO,CAAA;IACjC,gEAAgE;IAChE,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAA;IACvB;;;;;;;OAOG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,SAAS,CAAA;IACvD;;;;;OAKG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,SAAS,CAAA;CACrD;AAED,eAAO,MAAM,oBAAoB,EAAE,IAAI,CAAC,aAAa,EAAE,QAAQ,CAM9D,CAAA"}
@@ -0,0 +1,69 @@
1
+ /**
2
+ * Platform matching for optional dependencies.
3
+ *
4
+ * This module exists because of one specific, very annoying failure mode.
5
+ *
6
+ * Packages with native code — esbuild, rollup, sharp, swc, lightningcss,
7
+ * `@parcel/watcher` — publish their binary as a *set* of sibling packages, one
8
+ * per platform, and list all of them in `optionalDependencies`. npm installs
9
+ * only the one matching the current machine and silently skips the rest.
10
+ *
11
+ * So if you bundle on a Mac and skip the non-matching optional deps, the
12
+ * resulting bundle installs fine on your Mac and fails on the Linux CI box
13
+ * inside the firewall — which is the only place it actually matters. Hence the
14
+ * default is "take every platform" and narrowing is opt-in.
15
+ */
16
+ /** A target to keep, e.g. `linux-x64`, `linux-x64-musl`, or just `linux`. */
17
+ export interface PlatformTarget {
18
+ readonly os: string;
19
+ /** Undefined means "every architecture for this OS". */
20
+ readonly cpu?: string | undefined;
21
+ /** `glibc` / `musl`. Undefined means "don't care". */
22
+ readonly libc?: string | undefined;
23
+ }
24
+ /**
25
+ * Which platforms optional dependencies should be resolved for.
26
+ *
27
+ * - `All` — keep everything, regardless of `os`/`cpu`/`libc` (the default).
28
+ * - `Targets` — keep only packages that could install on one of these.
29
+ */
30
+ export type PlatformFilter = {
31
+ readonly _tag: "All";
32
+ } | {
33
+ readonly _tag: "Targets";
34
+ readonly targets: ReadonlyArray<PlatformTarget>;
35
+ };
36
+ export declare const allPlatforms: PlatformFilter;
37
+ export declare const platformTargets: (targets: ReadonlyArray<PlatformTarget>) => PlatformFilter;
38
+ /** The machine we are currently running on. */
39
+ export declare const currentPlatform: () => PlatformTarget;
40
+ /**
41
+ * Parses `linux`, `linux-x64`, `darwin-arm64`, `win32-x64`, `linux-x64-musl`,
42
+ * `linux-musl`.
43
+ *
44
+ * An OS on its own means every architecture for that OS, which is almost always
45
+ * what you want: "the Windows and Linux bindings" is a far more natural way to
46
+ * describe a target set than enumerating four `os-arch` pairs, and it keeps
47
+ * working when a package adds an arm64 build.
48
+ *
49
+ * Returns `null` rather than throwing so the CLI can report every bad value at
50
+ * once alongside the list of accepted forms.
51
+ */
52
+ export declare const parsePlatformTarget: (input: string) => PlatformTarget | null;
53
+ /** Constraints declared by a package, as they appear in its manifest. */
54
+ export interface PlatformConstraints {
55
+ readonly os?: ReadonlyArray<string> | undefined;
56
+ readonly cpu?: ReadonlyArray<string> | undefined;
57
+ readonly libc?: ReadonlyArray<string> | undefined;
58
+ }
59
+ /** Would this package install on this specific target? */
60
+ export declare const matchesTarget: (constraints: PlatformConstraints, target: PlatformTarget) => boolean;
61
+ /**
62
+ * Should this package be included, given the active filter?
63
+ *
64
+ * Under `All` this is unconditionally `true` — that is the whole point.
65
+ */
66
+ export declare const isIncluded: (constraints: PlatformConstraints, filter: PlatformFilter) => boolean;
67
+ /** Renders a filter for the manifest and for `--dry-run` output. */
68
+ export declare const formatPlatformFilter: (filter: PlatformFilter) => string;
69
+ //# sourceMappingURL=Platform.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Platform.d.ts","sourceRoot":"","sources":["../src/Platform.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,6EAA6E;AAC7E,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IACnB,wDAAwD;IACxD,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IACjC,sDAAsD;IACtD,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CACnC;AAED;;;;;GAKG;AACH,MAAM,MAAM,cAAc,GACtB;IAAE,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAA;CAAE,GACxB;IAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC,cAAc,CAAC,CAAA;CAAE,CAAA;AAEjF,eAAO,MAAM,YAAY,EAAE,cAAgC,CAAA;AAE3D,eAAO,MAAM,eAAe,YAAa,aAAa,CAAC,cAAc,CAAC,KAAG,cAGvE,CAAA;AAEF,+CAA+C;AAC/C,eAAO,MAAM,eAAe,QAAO,cAGjC,CAAA;AAkCF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,mBAAmB,UAAW,MAAM,KAAG,cAAc,GAAG,IAmBpE,CAAA;AA+BD,yEAAyE;AACzE,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,EAAE,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,GAAG,SAAS,CAAA;IAC/C,QAAQ,CAAC,GAAG,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,GAAG,SAAS,CAAA;IAChD,QAAQ,CAAC,IAAI,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,GAAG,SAAS,CAAA;CAClD;AAED,0DAA0D;AAC1D,eAAO,MAAM,aAAa,gBACX,mBAAmB,UACxB,cAAc,KACrB,OAOF,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,UAAU,gBACR,mBAAmB,UACxB,cAAc,KACrB,OAGF,CAAA;AAED,oEAAoE;AACpE,eAAO,MAAM,oBAAoB,WAAY,cAAc,KAAG,MAK7D,CAAA"}
@@ -0,0 +1,107 @@
1
+ /**
2
+ * Progress reporting.
3
+ *
4
+ * The engine emits structured events; it never writes to a terminal. That
5
+ * separation is what lets the CLI draw a live TTY view, CI print plain lines,
6
+ * and the test suite assert on an array of events without any of them
7
+ * interfering with each other.
8
+ */
9
+ import * as Context from "effect/Context";
10
+ import * as Effect from "effect/Effect";
11
+ import * as Layer from "effect/Layer";
12
+ /** The phases a bundle run moves through, in order. */
13
+ export type Phase = "preflight" | "resolve" | "download" | "archive" | "done";
14
+ /** A structured progress event. */
15
+ export type ProgressEvent =
16
+ /** A phase began. `total` is set only when it is known up front. */
17
+ {
18
+ readonly _tag: "PhaseStarted";
19
+ readonly phase: Phase;
20
+ readonly total?: number | undefined;
21
+ }
22
+ /** A phase finished. */
23
+ | {
24
+ readonly _tag: "PhaseCompleted";
25
+ readonly phase: Phase;
26
+ }
27
+ /** The resolver discovered a package that has to be included. */
28
+ | {
29
+ readonly _tag: "PackageResolved";
30
+ readonly name: string;
31
+ readonly version: string;
32
+ /** Running count of resolved packages, for a live counter. */
33
+ readonly resolvedCount: number;
34
+ /** Packages still queued for resolution. */
35
+ readonly pendingCount: number;
36
+ }
37
+ /** A tarball download started. */
38
+ | {
39
+ readonly _tag: "DownloadStarted";
40
+ readonly name: string;
41
+ readonly version: string;
42
+ }
43
+ /** A tarball download finished. */
44
+ | {
45
+ readonly _tag: "DownloadCompleted";
46
+ readonly name: string;
47
+ readonly version: string;
48
+ readonly bytes: number;
49
+ readonly completedCount: number;
50
+ readonly totalCount: number;
51
+ }
52
+ /** A download failed and will be retried. */
53
+ | {
54
+ readonly _tag: "DownloadRetrying";
55
+ readonly name: string;
56
+ readonly version: string;
57
+ readonly attempt: number;
58
+ readonly reason: string;
59
+ }
60
+ /** An archive is being written. */
61
+ | {
62
+ readonly _tag: "ArchiveStarted";
63
+ readonly path: string;
64
+ readonly entryCount: number;
65
+ }
66
+ /** An archive finished. */
67
+ | {
68
+ readonly _tag: "ArchiveCompleted";
69
+ readonly path: string;
70
+ readonly bytes: number;
71
+ }
72
+ /** Something noteworthy but non-fatal, e.g. a deprecated package. */
73
+ | {
74
+ readonly _tag: "Warning";
75
+ readonly message: string;
76
+ };
77
+ /** The reporting sink. */
78
+ export interface ProgressService {
79
+ readonly emit: (event: ProgressEvent) => Effect.Effect<void>;
80
+ }
81
+ declare const Progress_base: Context.ServiceClass<Progress, "@packall/core/Progress", ProgressService>;
82
+ /** Service tag for progress reporting. */
83
+ export declare class Progress extends Progress_base {
84
+ }
85
+ /** Emits an event to whichever reporter is installed. */
86
+ export declare const emit: (event: ProgressEvent) => Effect.Effect<void, never, Progress>;
87
+ /**
88
+ * Discards every event.
89
+ *
90
+ * The default for library consumers and for tests that do not care about
91
+ * progress — silence should never require ceremony.
92
+ */
93
+ export declare const layerSilent: Layer.Layer<Progress>;
94
+ /** Sends every event to a callback. Used by the CLI renderer. */
95
+ export declare const layerCallback: (onEvent: (event: ProgressEvent) => void) => Layer.Layer<Progress>;
96
+ /**
97
+ * Accumulates every event into a `Ref`, for assertions.
98
+ *
99
+ * Returned as `[layer, ref]` so a test can provide the layer and then read the
100
+ * transcript afterwards.
101
+ */
102
+ export declare const makeCollector: Effect.Effect<{
103
+ readonly layer: Layer.Layer<Progress, never, never>;
104
+ readonly events: Effect.Effect<readonly ProgressEvent[], never, never>;
105
+ }, never, never>;
106
+ export {};
107
+ //# sourceMappingURL=Progress.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Progress.d.ts","sourceRoot":"","sources":["../src/Progress.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AACzC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AAGrC,uDAAuD;AACvD,MAAM,MAAM,KAAK,GAAG,WAAW,GAAG,SAAS,GAAG,UAAU,GAAG,SAAS,GAAG,MAAM,CAAA;AAE7E,mCAAmC;AACnC,MAAM,MAAM,aAAa;AACvB,oEAAoE;AAClE;IAAE,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC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Q,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;CAAE;AACzF,2BAA2B;GACzB;IAAE,QAAQ,CAAC,IAAI,EAAE,kBAAkB,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE;AACtF,qEAAqE;GACnE;IAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAA;AAE1D,0BAA0B;AAC1B,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,IAAI,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;CAC7D;;AAED,0CAA0C;AAC1C,qBAAa,QAAS,SAAQ,aAE7B;CAAG;AAEJ,yDAAyD;AACzD,eAAO,MAAM,IAAI,UAAW,aAAa,KAAG,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,EAAE,QAAQ,CAI3E,CAAA;AAEJ;;;;;GAKG;AACH,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,KAAK,CAAC,QAAQ,CAE5C,CAAA;AAEF,iEAAiE;AACjE,eAAO,MAAM,aAAa,YACf,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,KACtC,KAAK,CAAC,KAAK,CAAC,QAAQ,CAGnB,CAAA;AAEJ;;;;;GAKG;AACH,eAAO,MAAM,aAAa;;;gBAMxB,CAAA"}
@@ -0,0 +1,106 @@
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
+ * A single published version, as the registry describes it.
18
+ *
19
+ * This is a narrowed view of a package.json — only the fields that affect what
20
+ * has to be downloaded. Unknown fields are ignored rather than rejected,
21
+ * because registries add metadata over time and a bundler that breaks on new
22
+ * metadata is worse than useless.
23
+ */
24
+ export interface PackageManifest {
25
+ readonly name: string;
26
+ readonly version: string;
27
+ readonly dependencies?: Readonly<Record<string, string>> | undefined;
28
+ readonly optionalDependencies?: Readonly<Record<string, string>> | undefined;
29
+ readonly peerDependencies?: Readonly<Record<string, string>> | undefined;
30
+ readonly peerDependenciesMeta?: Readonly<Record<string, {
31
+ readonly optional?: boolean | undefined;
32
+ }>> | undefined;
33
+ readonly devDependencies?: Readonly<Record<string, string>> | undefined;
34
+ readonly bundleDependencies?: ReadonlyArray<string> | undefined;
35
+ /** Platform constraints, used when `--platform` narrows optional deps. */
36
+ readonly os?: ReadonlyArray<string> | undefined;
37
+ readonly cpu?: ReadonlyArray<string> | undefined;
38
+ readonly libc?: ReadonlyArray<string> | undefined;
39
+ readonly deprecated?: string | undefined;
40
+ readonly dist: PackageDist;
41
+ }
42
+ /** Where the tarball lives and how to prove it arrived intact. */
43
+ export interface PackageDist {
44
+ readonly tarball: string;
45
+ /** SRI string, e.g. `sha512-...`. Preferred over `shasum`. */
46
+ readonly integrity?: string | undefined;
47
+ /** Legacy hex sha1. Still the only checksum on very old versions. */
48
+ readonly shasum?: string | undefined;
49
+ readonly unpackedSize?: number | undefined;
50
+ readonly fileCount?: number | undefined;
51
+ }
52
+ /** Everything the registry knows about one package. */
53
+ export interface Packument {
54
+ readonly name: string;
55
+ /** `{ latest: "1.2.3", next: "2.0.0-beta.1" }` */
56
+ readonly distTags: Readonly<Record<string, string>>;
57
+ /** Every published version, keyed by version string. */
58
+ readonly versions: Readonly<Record<string, PackageManifest>>;
59
+ }
60
+ /** The set of operations a registry backend has to provide. */
61
+ export interface RegistryService {
62
+ /** Short identifier for the manifest and for error messages, e.g. `"npm"`. */
63
+ readonly kind: string;
64
+ /**
65
+ * The registry URL that will actually be used for a given package, after
66
+ * per-scope configuration is applied. Used for reporting only.
67
+ */
68
+ readonly registryFor: (packageName: string) => string;
69
+ /**
70
+ * Cheap liveness check, run once before any real work.
71
+ *
72
+ * This is what turns "hangs forever behind a dead VPN" into a five-second
73
+ * error naming the host we could not reach.
74
+ */
75
+ readonly preflight: Effect.Effect<void, BundlerError>;
76
+ /**
77
+ * Full metadata for a package. Implementations are expected to memoise:
78
+ * the dependency walk asks for the same popular packages repeatedly.
79
+ */
80
+ readonly packument: (packageName: string) => Effect.Effect<Packument, BundlerError>;
81
+ /** Fetches the tarball bytes for one published version. */
82
+ readonly download: (manifest: PackageManifest) => Effect.Effect<Uint8Array, BundlerError>;
83
+ }
84
+ declare const Registry_base: Context.ServiceClass<Registry, "@packall/core/Registry", RegistryService>;
85
+ /**
86
+ * Service tag for the registry backend.
87
+ *
88
+ * @example
89
+ * ```ts
90
+ * import { Effect } from "effect"
91
+ * import { Registry } from "@packall/core"
92
+ *
93
+ * const program = Effect.gen(function*() {
94
+ * const registry = yield* Registry
95
+ * return yield* registry.packument("lodash")
96
+ * })
97
+ * ```
98
+ */
99
+ export declare class Registry extends Registry_base {
100
+ }
101
+ /** Extracts the dist-tag mapping, defaulting sensibly when a registry omits it. */
102
+ export declare const resolveDistTag: (packument: Packument, tag: string) => string | undefined;
103
+ /** All published version strings, in registry order. */
104
+ export declare const publishedVersions: (packument: Packument) => ReadonlyArray<string>;
105
+ export {};
106
+ //# sourceMappingURL=Registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Registry.d.ts","sourceRoot":"","sources":["../src/Registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AACzC,OAAO,KAA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,CAAC,MAAM,CAAC,UAAU,EAAE,YAAY,CAAC,CAAA;CAC1F;;AAED;;;;;;;;;;;;;GAaG;AACH,qBAAa,QAAS,SAAQ,aAE7B;CAAG;AAEJ,mFAAmF;AACnF,eAAO,MAAM,cAAc,cAAe,SAAS,OAAO,MAAM,KAAG,MAAM,GAAG,SACnD,CAAA;AAEzB,wDAAwD;AACxD,eAAO,MAAM,iBAAiB,cAAe,SAAS,KAAG,aAAa,CAAC,MAAM,CAC5C,CAAA"}
@@ -0,0 +1,105 @@
1
+ /**
2
+ * Version selection and the dependency closure walk.
3
+ *
4
+ * This is the part that decides *what* ends up in a bundle. Its only side
5
+ * effect is asking the `Registry` service for metadata, which makes the whole
6
+ * of it testable against a fake registry with no network at all.
7
+ *
8
+ * The walk is breadth-first in waves: resolve the current frontier
9
+ * concurrently, collect the newly discovered edges, repeat. Wave-based BFS
10
+ * gives real parallelism without a dynamic worker pool, and because each wave
11
+ * merges its results serially there is no shared mutable state being written
12
+ * from more than one fiber.
13
+ *
14
+ * One subtlety worth calling out: metadata is cached across walks, but each
15
+ * walk still traverses the full graph. That is what lets `per-spec` layout ask
16
+ * "what does *this* root version depend on" many times over while the network
17
+ * is touched exactly once per package.
18
+ */
19
+ import * as Effect from "effect/Effect";
20
+ import type { BundlerError } from "./Errors.js";
21
+ import type { ResolveOptions } from "./Options.js";
22
+ import type { Packument, PackageManifest } from "./Registry.js";
23
+ import { Registry } from "./Registry.js";
24
+ import * as Progress from "./Progress.js";
25
+ import type { PackageSpec, Selector } from "./Spec.js";
26
+ /** Why a package is in the bundle. */
27
+ export type EdgeKind = "prod" | "optional" | "peer";
28
+ /** A single justification for including a package. */
29
+ export type Reason = {
30
+ readonly _tag: "Root";
31
+ readonly spec: string;
32
+ } | {
33
+ readonly _tag: "Edge";
34
+ readonly from: string;
35
+ readonly kind: EdgeKind;
36
+ };
37
+ /** `name@version` — the identity of a resolved package throughout the engine. */
38
+ export type PackageKey = string;
39
+ export declare const packageKey: (name: string, version: string) => PackageKey;
40
+ /** One package, pinned to one version, with every reason it was pulled in. */
41
+ export interface ResolvedPackage {
42
+ readonly name: string;
43
+ readonly version: string;
44
+ readonly manifest: PackageManifest;
45
+ readonly reasons: ReadonlyArray<Reason>;
46
+ }
47
+ /** Something we could not include, reported rather than thrown. */
48
+ export interface ResolutionWarning {
49
+ readonly message: string;
50
+ /** `name@version` of the package whose manifest contained the problem. */
51
+ readonly from?: string | undefined;
52
+ }
53
+ /** What one requested spec expanded to. */
54
+ export interface RootResolution {
55
+ readonly spec: PackageSpec;
56
+ /** The concrete versions the spec selected — more than one under `--all-versions`. */
57
+ readonly versions: ReadonlyArray<string>;
58
+ /** Closure per selected version, keyed by version. Drives `per-spec` layout. */
59
+ readonly closures: ReadonlyMap<string, ReadonlyArray<PackageKey>>;
60
+ /** Union of every per-version closure. */
61
+ readonly closure: ReadonlyArray<PackageKey>;
62
+ }
63
+ /** The complete result of resolving every requested spec. */
64
+ export interface Resolution {
65
+ readonly roots: ReadonlyArray<RootResolution>;
66
+ /** The deduplicated union of every closure, sorted by name then version. */
67
+ readonly packages: ReadonlyArray<ResolvedPackage>;
68
+ readonly warnings: ReadonlyArray<ResolutionWarning>;
69
+ }
70
+ /** Index of a resolution by `name@version`, for lookups during bundling. */
71
+ export declare const indexPackages: (resolution: Resolution) => ReadonlyMap<PackageKey, ResolvedPackage>;
72
+ /**
73
+ * Turns a selector into the concrete version(s) it names.
74
+ *
75
+ * `all` controls whether a range collapses to its best match — npm's behaviour,
76
+ * and what you always want for a transitive dependency — or expands to every
77
+ * satisfying published version, which is what `--all-versions` is for.
78
+ */
79
+ export declare const selectVersions: (packument: Packument, selector: Selector, options: {
80
+ readonly all: boolean;
81
+ readonly maxVersions?: number | undefined;
82
+ readonly includePrerelease: boolean;
83
+ }) => ReadonlyArray<string>;
84
+ /** One pending item on the BFS frontier. */
85
+ export interface Task {
86
+ readonly name: string;
87
+ readonly selector: Selector;
88
+ readonly reason: Reason;
89
+ /** Optional edges tolerate resolution failure; required ones do not. */
90
+ readonly tolerateFailure: boolean;
91
+ }
92
+ /** Expands one resolved manifest into the edges that follow from it. */
93
+ export declare const edgesOf: (manifest: PackageManifest, options: ResolveOptions) => {
94
+ readonly tasks: ReadonlyArray<Task>;
95
+ readonly warnings: ReadonlyArray<ResolutionWarning>;
96
+ };
97
+ /**
98
+ * Resolves every requested spec.
99
+ *
100
+ * Each selected root *version* is walked separately so `per-spec` layout has an
101
+ * exact closure per tarball, while all walks share one cache, so a package
102
+ * reached from twenty roots is fetched once.
103
+ */
104
+ export declare const resolve: (specs: ReadonlyArray<PackageSpec>, options: ResolveOptions) => Effect.Effect<Resolution, BundlerError, Registry | Progress.Progress>;
105
+ //# sourceMappingURL=Resolve.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Resolve.d.ts","sourceRoot":"","sources":["../src/Resolve.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAGvC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE/C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAElD,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA;AACzC,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AAGtD,sCAAsC;AACtC,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,UAAU,GAAG,MAAM,CAAA;AAEnD,sDAAsD;AACtD,MAAM,MAAM,MAAM,GACd;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAChD;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CA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;CACpD;AAED,4EAA4E;AAC5E,eAAO,MAAM,aAAa,eACZ,UAAU,KACrB,WAAW,CAAC,UAAU,EAAE,eAAe,CACmC,CAAA;AAM7E;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,cACd,SAAS,YACV,QAAQ,WACT;IACP,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAA;IACrB,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IACzC,QAAQ,CAAC,iBAAiB,EAAE,OAAO,CAAA;CACpC,KACA,aAAa,CAAC,MAAM,CAwCtB,CAAA;AAWD,4CAA4C;AAC5C,MAAM,WAAW,IAAI;IACnB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAA;IAC3B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,wEAAwE;IACxE,QAAQ,CAAC,eAAe,EAAE,OAAO,CAAA;CAClC;AAwDD,wEAAwE;AACxE,eAAO,MAAM,OAAO,aACR,eAAe,WAChB,cAAc,KACtB;IACD,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC,IAAI,CAAC,CAAA;IACnC,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAAC,iBAAiB,CAAC,CAAA;CAiDpD,CAAA;AA4LD;;;;;;GAMG;AACH,eAAO,MAAM,OAAO,UACX,aAAa,CAAC,WAAW,CAAC,WACxB,cAAc,KACtB,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,YAAY,EAAE,QAAQ,GAAG,QAAQ,CAAC,QAAQ,CAkDnE,CAAA"}
package/dist/Spec.d.ts ADDED
@@ -0,0 +1,62 @@
1
+ import { InvalidSpecError } from "./Errors.js";
2
+ /** How a spec narrows down which version(s) of a package we want. */
3
+ export type Selector =
4
+ /** An exact, fully-qualified version: `react@18.2.0`. */
5
+ {
6
+ readonly _tag: "Exact";
7
+ readonly version: string;
8
+ }
9
+ /** A semver range: `react@^18`, `react@>=17 <19`, `react@*`. */
10
+ | {
11
+ readonly _tag: "Range";
12
+ readonly range: string;
13
+ }
14
+ /** A dist-tag: `react@latest`, `typescript@next`. */
15
+ | {
16
+ readonly _tag: "Tag";
17
+ readonly tag: string;
18
+ };
19
+ /** A parsed, validated package spec. */
20
+ export interface PackageSpec {
21
+ /** The npm package name, including scope. */
22
+ readonly name: string;
23
+ /** What the user asked for after the `@`. */
24
+ readonly selector: Selector;
25
+ /** The original string, kept verbatim for error messages and the manifest. */
26
+ readonly raw: string;
27
+ }
28
+ /** Renders a spec back into the canonical `name@selector` form. */
29
+ export declare const formatSpec: (spec: PackageSpec) => string;
30
+ /** Human-readable form of just the selector part. */
31
+ export declare const formatSelector: (selector: Selector) => string;
32
+ /**
33
+ * Validates an npm package name against the rules the registry actually
34
+ * enforces. Returns `null` when valid, or the reason it is not.
35
+ */
36
+ export declare const validatePackageName: (name: string) => string | null;
37
+ /**
38
+ * Parses a single spec string.
39
+ *
40
+ * Splitting on `@` is the fiddly part: a scoped name *starts* with `@`, so we
41
+ * look for the last `@` that is not at index 0.
42
+ */
43
+ export declare const parseSpec: (raw: string) => PackageSpec;
44
+ /** Classifies the part after the `@` as an exact version, a range, or a dist-tag. */
45
+ export declare const parseSelector: (raw: string, text: string) => Selector;
46
+ /**
47
+ * Parses many specs, collecting *every* failure rather than stopping at the
48
+ * first. Somebody bundling forty packages should be told about all four typos
49
+ * in one go, not made to re-run four times.
50
+ */
51
+ export declare const parseSpecs: (inputs: ReadonlyArray<string>) => {
52
+ readonly specs: ReadonlyArray<PackageSpec>;
53
+ readonly errors: ReadonlyArray<InvalidSpecError>;
54
+ };
55
+ /**
56
+ * Collapses duplicate specs, keeping the first occurrence.
57
+ *
58
+ * `npmb react react@latest` is a plausible thing to type and should not
59
+ * download React twice.
60
+ */
61
+ export declare const dedupeSpecs: (specs: ReadonlyArray<PackageSpec>) => ReadonlyArray<PackageSpec>;
62
+ //# sourceMappingURL=Spec.d.ts.map
@@ -0,0 +1 @@
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CAAC,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC,gBAAgB,CAAC,CAAA;CAehG,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,WAAW,UAAW,aAAa,CAAC,WAAW,CAAC,KAAG,aAAa,CAAC,WAAW,CAUxF,CAAA"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * `@packall/core` — the registry-agnostic bundling engine.
3
+ *
4
+ * Nothing in here knows about npm specifically. Point it at any implementation
5
+ * of the `Registry` service and it will resolve, download, verify and package
6
+ * a dependency closure.
7
+ */
8
+ export * as Archive from "./Archive.js";
9
+ export * as Bundle from "./Bundle.js";
10
+ export * as DependencyRange from "./DependencyRange.js";
11
+ export * as Download from "./Download.js";
12
+ export * as Integrity from "./Integrity.js";
13
+ export * as InputFile from "./InputFile.js";
14
+ export * as Layout from "./Layout.js";
15
+ export * as Manifest from "./Manifest.js";
16
+ export * as Options from "./Options.js";
17
+ export * as Platform from "./Platform.js";
18
+ export * as Progress from "./Progress.js";
19
+ export * as Resolve from "./Resolve.js";
20
+ export * as Spec from "./Spec.js";
21
+ export { bundle, bundleResolved, plan, plannedOutputs, summarize, withLayout } from "./Bundle.js";
22
+ export type { BundleArtifact, BundleContext, BundleResult, PlanSummary } from "./Bundle.js";
23
+ export { Registry } from "./Registry.js";
24
+ export type { Packument, PackageDist, PackageManifest, RegistryService } from "./Registry.js";
25
+ export { Progress as ProgressTag } from "./Progress.js";
26
+ export type { ProgressEvent } from "./Progress.js";
27
+ export { resolve } from "./Resolve.js";
28
+ export type { Resolution, ResolvedPackage, RootResolution } from "./Resolve.js";
29
+ export { parseSpec, parseSpecs } from "./Spec.js";
30
+ export type { PackageSpec, Selector } from "./Spec.js";
31
+ export type { BundleOptions, DependencyScope, Layout as LayoutKind, ResolveOptions } from "./Options.js";
32
+ export { defaultBundleOptions, defaultResolveOptions, defaultScope, layouts } from "./Options.js";
33
+ export type { PlatformFilter, PlatformTarget } from "./Platform.js";
34
+ export { allPlatforms, currentPlatform, parsePlatformTarget, platformTargets } from "./Platform.js";
35
+ export * from "./Errors.js";
36
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AACvC,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AACrC,OAAO,KAAK,eAAe,MAAM,sBAAsB,CAAA;AACvD,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA;AACzC,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAA;AAC3C,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAA;AAC3C,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AACrC,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA;AACzC,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AACvC,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA;AACzC,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA;AACzC,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AACvC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AAGjC,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,IAAI,EAAE,cAAc,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACjG,YAAY,EAAE,cAAc,EAAE,aAAa,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAC3F,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAC7F,OAAO,EAAE,QAAQ,IAAI,WAAW,EAAE,MAAM,eAAe,CAAA;AACvD,YAAY,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,cA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