@packall/core 0.4.1 → 0.5.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.
@@ -10,4 +10,5 @@
10
10
  * This is the entry point's whole public API.
11
11
  */
12
12
  export { layerArchiver } from "./archiver.js";
13
+ export { currentPlatform } from "./platform.js";
13
14
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/node/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/node/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC"}
@@ -51,5 +51,13 @@ const dotSlash = (entry) => entry.startsWith("./") ? entry : `./${entry}`;
51
51
  const describe = (cause) => cause instanceof Error ? cause.message : String(cause);
52
52
 
53
53
  //#endregion
54
- export { layerArchiver };
54
+ //#region src/node/platform.ts
55
+ /** The machine we are currently running on. */
56
+ const currentPlatform = () => ({
57
+ os: process.platform,
58
+ cpu: process.arch
59
+ });
60
+
61
+ //#endregion
62
+ export { currentPlatform, layerArchiver };
55
63
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["layerArchiver: Layer.Layer<Archiver>"],"sources":["../../src/node/archiver.ts"],"sourcesContent":["/**\n * The Node `Archiver`, backed by `node-tar`.\n *\n * Behind `@packall/core/node` rather than the main barrel: importing\n * `@packall/core` must not drag `node-tar` — and through it `node:fs` — into a\n * browser bundle. Anything running on Node reaches for this explicitly.\n *\n * Uses `node-tar`, the same library npm itself packs with. Writing a USTAR\n * encoder by hand would be a fun afternoon and a bad idea: scoped package\n * paths routinely exceed the 100-byte name field, so correctness depends on\n * prefix-splitting and PAX headers that `tar` already gets right.\n */\nimport * as Effect from \"effect/Effect\";\nimport * as FileSystem from \"effect/FileSystem\";\nimport * as Layer from \"effect/Layer\";\nimport type { PlatformError } from \"effect/PlatformError\";\nimport { create } from \"tar\";\n\nimport type { ArchiveResult, CreateArchiveOptions } from \"../archive.js\";\nimport { Archiver } from \"../archive.js\";\nimport { ArchiveError } from \"../errors.js\";\n\nconst createArchive = (\n\toptions: CreateArchiveOptions,\n): Effect.Effect<ArchiveResult, ArchiveError | PlatformError, FileSystem.FileSystem> =>\n\tEffect.gen(function* () {\n\t\tconst fs = yield* FileSystem.FileSystem;\n\n\t\tyield* Effect.tryPromise({\n\t\t\ttry: () =>\n\t\t\t\tcreate(\n\t\t\t\t\t{\n\t\t\t\t\t\tgzip: options.gzipLevel === undefined ? true : { level: options.gzipLevel },\n\t\t\t\t\t\tfile: options.outPath,\n\t\t\t\t\t\tcwd: options.cwd,\n\t\t\t\t\t\t// Normalises uid/gid/mtime so the same inputs produce byte-identical\n\t\t\t\t\t\t// output — which matters when a security team wants to diff two\n\t\t\t\t\t\t// bundles or re-derive one from a manifest.\n\t\t\t\t\t\tportable: true,\n\t\t\t\t\t\t// Undo the `./` added below, so recorded entry names stay exactly\n\t\t\t\t\t\t// the registry paths the manifest lists.\n\t\t\t\t\t\tonWriteEntry: (entry) => {\n\t\t\t\t\t\t\tentry.path = entry.path.replace(/^\\.\\//, \"\");\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t// Sorted so archive order is stable across runs and platforms.\n\t\t\t\t\toptions.entries.toSorted().map(dotSlash),\n\t\t\t\t),\n\t\t\tcatch: (cause) => new ArchiveError(options.outPath, describe(cause), { cause }),\n\t\t});\n\n\t\tconst info = yield* fs.stat(options.outPath);\n\n\t\treturn { path: options.outPath, bytes: Number(info.size) };\n\t});\n\n/** The Node packing backend. */\nexport const layerArchiver: Layer.Layer<Archiver> = Layer.succeed(Archiver)({\n\tcreate: createArchive,\n});\n\n/**\n * Guards every entry against tar's `@` convention.\n *\n * In a tar file list, a leading `@` means \"splice in the entries of this other\n * archive\" — a GNU convention `node-tar` implements by stripping the `@` and\n * looking for what is left. Every scoped package is a top-level entry starting\n * with `@`, so this hit the bundler in both possible ways:\n *\n * - `@oxc-project` became `oxc-project`, which does not exist, and the run died\n * with an ENOENT naming a path that appears nowhere in the staging tree.\n * - `@esbuild` became `esbuild`, which *does* exist — the unscoped package of\n * the same name sitting right next to it. No error, and every scoped tarball\n * silently missing from a bundle that reported success. That is the dangerous\n * one: you would not find out until the install failed behind the firewall.\n *\n * `./@scope` is not subject to the convention and resolves identically.\n *\n * Any other backend has to answer this question too — the browser writer must\n * be held to the same test.\n */\nconst dotSlash = (entry: string): string => (entry.startsWith(\"./\") ? entry : `./${entry}`);\n\nconst describe = (cause: unknown): string =>\n\tcause instanceof Error ? cause.message : String(cause);\n"],"mappings":";;;;;;;AAsBA,MAAM,iBACL,YAEA,OAAO,IAAI,aAAa;CACvB,MAAM,KAAK,OAAO,WAAW;AAE7B,QAAO,OAAO,WAAW;EACxB,WACC,OACC;GACC,MAAM,QAAQ,cAAc,SAAY,OAAO,EAAE,OAAO,QAAQ,WAAW;GAC3E,MAAM,QAAQ;GACd,KAAK,QAAQ;GAIb,UAAU;GAGV,eAAe,UAAU;AACxB,UAAM,OAAO,MAAM,KAAK,QAAQ,SAAS,GAAG;;GAE7C,EAED,QAAQ,QAAQ,UAAU,CAAC,IAAI,SAAS,CACxC;EACF,QAAQ,UAAU,IAAI,aAAa,QAAQ,SAAS,SAAS,MAAM,EAAE,EAAE,OAAO,CAAC;EAC/E,CAAC;CAEF,MAAM,OAAO,OAAO,GAAG,KAAK,QAAQ,QAAQ;AAE5C,QAAO;EAAE,MAAM,QAAQ;EAAS,OAAO,OAAO,KAAK,KAAK;EAAE;EACzD;;AAGH,MAAaA,gBAAuC,MAAM,QAAQ,SAAS,CAAC,EAC3E,QAAQ,eACR,CAAC;;;;;;;;;;;;;;;;;;;;;AAsBF,MAAM,YAAY,UAA2B,MAAM,WAAW,KAAK,GAAG,QAAQ,KAAK;AAEnF,MAAM,YAAY,UACjB,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM"}
1
+ {"version":3,"file":"index.js","names":["layerArchiver: Layer.Layer<Archiver>"],"sources":["../../src/node/archiver.ts","../../src/node/platform.ts"],"sourcesContent":["/**\n * The Node `Archiver`, backed by `node-tar`.\n *\n * Behind `@packall/core/node` rather than the main barrel: importing\n * `@packall/core` must not drag `node-tar` — and through it `node:fs` — into a\n * browser bundle. Anything running on Node reaches for this explicitly.\n *\n * Uses `node-tar`, the same library npm itself packs with. Writing a USTAR\n * encoder by hand would be a fun afternoon and a bad idea: scoped package\n * paths routinely exceed the 100-byte name field, so correctness depends on\n * prefix-splitting and PAX headers that `tar` already gets right.\n */\nimport * as Effect from \"effect/Effect\";\nimport * as FileSystem from \"effect/FileSystem\";\nimport * as Layer from \"effect/Layer\";\nimport type { PlatformError } from \"effect/PlatformError\";\nimport { create } from \"tar\";\n\nimport type { ArchiveResult, CreateArchiveOptions } from \"../archive.js\";\nimport { Archiver } from \"../archive.js\";\nimport { ArchiveError } from \"../errors.js\";\n\nconst createArchive = (\n\toptions: CreateArchiveOptions,\n): Effect.Effect<ArchiveResult, ArchiveError | PlatformError, FileSystem.FileSystem> =>\n\tEffect.gen(function* () {\n\t\tconst fs = yield* FileSystem.FileSystem;\n\n\t\tyield* Effect.tryPromise({\n\t\t\ttry: () =>\n\t\t\t\tcreate(\n\t\t\t\t\t{\n\t\t\t\t\t\tgzip: options.gzipLevel === undefined ? true : { level: options.gzipLevel },\n\t\t\t\t\t\tfile: options.outPath,\n\t\t\t\t\t\tcwd: options.cwd,\n\t\t\t\t\t\t// Normalises uid/gid/mtime so the same inputs produce byte-identical\n\t\t\t\t\t\t// output — which matters when a security team wants to diff two\n\t\t\t\t\t\t// bundles or re-derive one from a manifest.\n\t\t\t\t\t\tportable: true,\n\t\t\t\t\t\t// Undo the `./` added below, so recorded entry names stay exactly\n\t\t\t\t\t\t// the registry paths the manifest lists.\n\t\t\t\t\t\tonWriteEntry: (entry) => {\n\t\t\t\t\t\t\tentry.path = entry.path.replace(/^\\.\\//, \"\");\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t// Sorted so archive order is stable across runs and platforms.\n\t\t\t\t\toptions.entries.toSorted().map(dotSlash),\n\t\t\t\t),\n\t\t\tcatch: (cause) => new ArchiveError(options.outPath, describe(cause), { cause }),\n\t\t});\n\n\t\tconst info = yield* fs.stat(options.outPath);\n\n\t\treturn { path: options.outPath, bytes: Number(info.size) };\n\t});\n\n/** The Node packing backend. */\nexport const layerArchiver: Layer.Layer<Archiver> = Layer.succeed(Archiver)({\n\tcreate: createArchive,\n});\n\n/**\n * Guards every entry against tar's `@` convention.\n *\n * In a tar file list, a leading `@` means \"splice in the entries of this other\n * archive\" — a GNU convention `node-tar` implements by stripping the `@` and\n * looking for what is left. Every scoped package is a top-level entry starting\n * with `@`, so this hit the bundler in both possible ways:\n *\n * - `@oxc-project` became `oxc-project`, which does not exist, and the run died\n * with an ENOENT naming a path that appears nowhere in the staging tree.\n * - `@esbuild` became `esbuild`, which *does* exist — the unscoped package of\n * the same name sitting right next to it. No error, and every scoped tarball\n * silently missing from a bundle that reported success. That is the dangerous\n * one: you would not find out until the install failed behind the firewall.\n *\n * `./@scope` is not subject to the convention and resolves identically.\n *\n * Any other backend has to answer this question too — the browser writer must\n * be held to the same test.\n */\nconst dotSlash = (entry: string): string => (entry.startsWith(\"./\") ? entry : `./${entry}`);\n\nconst describe = (cause: unknown): string =>\n\tcause instanceof Error ? cause.message : String(cause);\n","/**\n * The machine we are currently running on.\n *\n * One function, in its own file, for the reason the whole `/node` subpath\n * exists: it reads `process`, and importing `@packall/core` has to stay safe in\n * a browser. Everything else in `platform.ts` is string work over what a\n * manifest declares — it has no host and needs none, so it stays on the main\n * entry where the engine can reach it.\n */\n\nimport type { PlatformTarget } from \"../platform.js\";\n\n/** The machine we are currently running on. */\nexport const currentPlatform = (): PlatformTarget => ({\n\tos: process.platform,\n\tcpu: process.arch,\n});\n"],"mappings":";;;;;;;AAsBA,MAAM,iBACL,YAEA,OAAO,IAAI,aAAa;CACvB,MAAM,KAAK,OAAO,WAAW;AAE7B,QAAO,OAAO,WAAW;EACxB,WACC,OACC;GACC,MAAM,QAAQ,cAAc,SAAY,OAAO,EAAE,OAAO,QAAQ,WAAW;GAC3E,MAAM,QAAQ;GACd,KAAK,QAAQ;GAIb,UAAU;GAGV,eAAe,UAAU;AACxB,UAAM,OAAO,MAAM,KAAK,QAAQ,SAAS,GAAG;;GAE7C,EAED,QAAQ,QAAQ,UAAU,CAAC,IAAI,SAAS,CACxC;EACF,QAAQ,UAAU,IAAI,aAAa,QAAQ,SAAS,SAAS,MAAM,EAAE,EAAE,OAAO,CAAC;EAC/E,CAAC;CAEF,MAAM,OAAO,OAAO,GAAG,KAAK,QAAQ,QAAQ;AAE5C,QAAO;EAAE,MAAM,QAAQ;EAAS,OAAO,OAAO,KAAK,KAAK;EAAE;EACzD;;AAGH,MAAaA,gBAAuC,MAAM,QAAQ,SAAS,CAAC,EAC3E,QAAQ,eACR,CAAC;;;;;;;;;;;;;;;;;;;;;AAsBF,MAAM,YAAY,UAA2B,MAAM,WAAW,KAAK,GAAG,QAAQ,KAAK;AAEnF,MAAM,YAAY,UACjB,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM;;;;;ACvEvD,MAAa,yBAAyC;CACrD,IAAI,QAAQ;CACZ,KAAK,QAAQ;CACb"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * The machine we are currently running on.
3
+ *
4
+ * One function, in its own file, for the reason the whole `/node` subpath
5
+ * exists: it reads `process`, and importing `@packall/core` has to stay safe in
6
+ * a browser. Everything else in `platform.ts` is string work over what a
7
+ * manifest declares — it has no host and needs none, so it stays on the main
8
+ * entry where the engine can reach it.
9
+ */
10
+ import type { PlatformTarget } from "../platform.js";
11
+ /** The machine we are currently running on. */
12
+ export declare const currentPlatform: () => PlatformTarget;
13
+ //# sourceMappingURL=platform.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"platform.d.ts","sourceRoot":"","sources":["../../src/node/platform.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAErD,+CAA+C;AAC/C,eAAO,MAAM,eAAe,QAAO,cAGjC,CAAC"}
@@ -36,8 +36,6 @@ export type PlatformConstraints = {
36
36
  };
37
37
  export declare const allPlatforms: PlatformFilter;
38
38
  export declare const platformTargets: (targets: ReadonlyArray<PlatformTarget>) => PlatformFilter;
39
- /** The machine we are currently running on. */
40
- export declare const currentPlatform: () => PlatformTarget;
41
39
  /**
42
40
  * Parses `linux`, `linux-x64`, `darwin-arm64`, `win32-x64`, `linux-x64-musl`,
43
41
  * `linux-musl`.
@@ -1 +1 @@
1
- {"version":3,"file":"platform.d.ts","sourceRoot":"","sources":["../src/platform.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,6EAA6E;AAC7E,MAAM,MAAM,cAAc,GAAG;IAC5B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,wDAAwD;IACxD,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,sDAAsD;IACtD,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACnC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,cAAc,GACvB;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,CAAC;AAEjF,yEAAyE;AACzE,MAAM,MAAM,mBAAmB,GAAG;IACjC,QAAQ,CAAC,EAAE,CAAC,EAAE,aA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AC,OAAO,EAAE,aAAa,CAAC,cAAc,CAAC,CAAA;CAAE,CAAC;AAEjF,yEAAyE;AACzE,MAAM,MAAM,mBAAmB,GAAG;IACjC,QAAQ,CAAC,EAAE,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,GAAG,SAAS,CAAC;IAChD,QAAQ,CAAC,GAAG,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,GAAG,SAAS,CAAC;IACjD,QAAQ,CAAC,IAAI,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,GAAG,SAAS,CAAC;CAClD,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,cAAgC,CAAC;AAE5D,eAAO,MAAM,eAAe,YAAa,aAAa,CAAC,cAAc,CAAC,KAAG,cAGvE,CAAC;AAkCH;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,mBAAmB,UAAW,MAAM,KAAG,cAAc,GAAG,IAqBpE,CAAC;AA+BF,0DAA0D;AAC1D,eAAO,MAAM,aAAa,gBACZ,mBAAmB,UACxB,cAAc,KACpB,OAOF,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,UAAU,gBAAiB,mBAAmB,UAAU,cAAc,KAAG,OAGrF,CAAC;AAEF,oEAAoE;AACpE,eAAO,MAAM,oBAAoB,WAAY,cAAc,KAAG,MAO7D,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@packall/core",
3
- "version": "0.4.1",
3
+ "version": "0.5.0",
4
4
  "description": "Registry-agnostic engine for bundling npm packages and their full dependency closure for offline import.",
5
5
  "homepage": "https://packall.vercel.app",
6
6
  "bugs": {
package/src/index.ts CHANGED
@@ -58,7 +58,6 @@ export { parseDependencyTarget } from "./dependency-range.js";
58
58
  export type { PlatformConstraints, PlatformFilter, PlatformTarget } from "./platform.js";
59
59
  export {
60
60
  allPlatforms,
61
- currentPlatform,
62
61
  formatPlatformFilter,
63
62
  isIncluded,
64
63
  parsePlatformTarget,
package/src/node/index.ts CHANGED
@@ -11,3 +11,4 @@
11
11
  */
12
12
 
13
13
  export { layerArchiver } from "./archiver.js";
14
+ export { currentPlatform } from "./platform.js";
@@ -0,0 +1,17 @@
1
+ /**
2
+ * The machine we are currently running on.
3
+ *
4
+ * One function, in its own file, for the reason the whole `/node` subpath
5
+ * exists: it reads `process`, and importing `@packall/core` has to stay safe in
6
+ * a browser. Everything else in `platform.ts` is string work over what a
7
+ * manifest declares — it has no host and needs none, so it stays on the main
8
+ * entry where the engine can reach it.
9
+ */
10
+
11
+ import type { PlatformTarget } from "../platform.js";
12
+
13
+ /** The machine we are currently running on. */
14
+ export const currentPlatform = (): PlatformTarget => ({
15
+ os: process.platform,
16
+ cpu: process.arch,
17
+ });
package/src/platform.ts CHANGED
@@ -42,12 +42,6 @@ export const platformTargets = (targets: ReadonlyArray<PlatformTarget>): Platfor
42
42
  targets,
43
43
  });
44
44
 
45
- /** The machine we are currently running on. */
46
- export const currentPlatform = (): PlatformTarget => ({
47
- os: process.platform,
48
- cpu: process.arch,
49
- });
50
-
51
45
  /**
52
46
  * npm's documented `os` values, plus the names people actually type.
53
47
  *