@bendyline/molen-pack 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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Bendyline LLC
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.
package/README.md ADDED
@@ -0,0 +1,90 @@
1
+ # @bendyline/molen-pack
2
+
3
+ Content packs for Molen: zip files that carry models, documents and catalogs outside the code
4
+ packages, opened from wherever your app keeps them.
5
+
6
+ Part of [Molen](https://molen.dev), an AI-legible 3D experience engine: a deterministic headless
7
+ kernel, a three.js client, and a dev loop an agent can drive end to end.
8
+
9
+ ## Install
10
+
11
+ ```sh
12
+ npm i @bendyline/molen-pack
13
+ ```
14
+
15
+ Node >= 22.13, ESM only. The `.` export runs in browsers, Workers and Node; `./node` adds file and
16
+ directory helpers for Node. Its only dependencies are `@bendyline/molen-schema` and `fflate`.
17
+
18
+ ## Use
19
+
20
+ Where a pack lives is the app's choice: a URL on any origin, a file bundled with an Electron app,
21
+ a file the user picked, bytes you already hold, or storage you read yourself.
22
+
23
+ ```ts
24
+ import { createPackSet, openPack } from '@bendyline/molen-pack';
25
+
26
+ const packs = createPackSet([
27
+ await openPack('/packs/molen.entities-3f2a9c1e5b7d.zip'), // any URL
28
+ await openPack(userPickedFile), // a File or Blob
29
+ await openPack(bytes), // an ArrayBuffer or Uint8Array
30
+ await openPack({ size, read: (offset, length) => myStorage.read(offset, length) }),
31
+ ]);
32
+
33
+ // Asset ids, pack-qualified paths, or plain paths; the pack added last wins.
34
+ const glb = await packs.readBytes('molen.entities.aircraft.p51d');
35
+ const types = await packs.readJson('pack:molen.entities/types/aircraft.types.json');
36
+
37
+ // The client's asset provider shape, so models and material docs load from packs.
38
+ const client = await createClient(link, { assets: { provider: packs.assetProvider() } });
39
+ ```
40
+
41
+ Opening a remote pack reads only its last 64 KiB, which holds the manifest, the zip directory and
42
+ the small documents. Other files are read on demand with HTTP range requests; reads issued
43
+ together are merged when they sit close in the file, at most six run at once, and transient
44
+ failures are retried. A server that ignores `Range` just sends the whole file, which is used as is.
45
+
46
+ Build packs with the CLI (`molen pack build <dir> --out-dir <d>`) or in code:
47
+
48
+ ```ts
49
+ import { buildPack, openDirPack } from '@bendyline/molen-pack/node';
50
+
51
+ // A directory with a molen-pack.source.json describing the pack.
52
+ const built = await buildPack('content/entities', { outDir: 'dist/packs' });
53
+ built.file; // 'molen.entities-3f2a9c1e5b7d.zip', named by a hash of its bytes
54
+
55
+ // The same content, unzipped: handy in tests and during development.
56
+ const pack = await openDirPack('content/entities');
57
+ ```
58
+
59
+ ## What's in it
60
+
61
+ - `openPack(input, options)` — a `Pack` from a URL, `Blob`, bytes, or a `RangeReader`, with
62
+ `readBytes` / `readText` / `readJson` / `prefetch`. Options cover whole-or-range mode, retries,
63
+ concurrency, progress, an expected `contentHash`, and sha256 checks per file.
64
+ - `createPackSet(packs)` — several packs read as one, with later packs overriding earlier ones,
65
+ `provided(role)` to find the files a pack declares for a role, and `assetProvider()`.
66
+ - `createPack(files, options)` / `describePack` / `packFromFiles` — build a pack, or a pack-shaped
67
+ view of loose files, from bytes in any environment.
68
+ - `./node`: `buildPack`, `openFilePack`, `openDirPack`, `openPackAt`, `readPackSource`,
69
+ `extractPack`.
70
+
71
+ A pack is a standard zip you can open with any zip tool. Binary files are their own members,
72
+ deflated when that helps. Small text files are concatenated into a few deflated solid blocks,
73
+ which compresses JSON far better than one file at a time: the default worldgen style pack, 240
74
+ files and 799 KB, builds to 79 KB. `molen pack extract` turns a pack back into its source files.
75
+ The manifest (`molen/pack@1`) lists every file with its size and sha256, the asset ids it
76
+ provides, and a `contentHash` over paths and contents that does not depend on the zip layout.
77
+
78
+ ## Status
79
+
80
+ 0.x, on one fixed version line with every other `@bendyline/molen-*` package. The format is
81
+ beta. Packs are written without zip64, so a pack must stay under 4 GiB and 65,535 members.
82
+ Building the same files always produces the same bytes; that depends on the exact `fflate`
83
+ version this package pins.
84
+
85
+ ## Docs
86
+
87
+ - [Schema: molen/pack@1](https://molen.dev/schemas/pack)
88
+ - [Schema: molen/pack-source@1](https://molen.dev/schemas/pack-source)
89
+
90
+ MIT © Bendyline LLC
@@ -0,0 +1,41 @@
1
+ import { _ as describePack, a as PackIntegrityError, b as sha256, c as openPack, d as PackRetryOptions, f as RangeReader, g as createPack, h as PackOptions, i as PackInput, l as packFromFiles, m as PackFile, n as Pack, o as PackProgress, p as BuiltPack, r as PackEntryNotFoundError, s as ReadOptions, t as OpenPackOptions, u as PackChangedError, v as isTextPath, y as mediaTypeOf } from "./pack-DdapyeeP.mjs";
2
+ import { PackIndex, PackIndexEntry, PackManifest } from "@bendyline/molen-schema";
3
+
4
+ //#region src/set.d.ts
5
+ /** The shape of the client's AssetProvider, so this package needs no client dependency. */
6
+ interface AssetProviderLike {
7
+ load(ref: string): Promise<ArrayBuffer>;
8
+ loadText(ref: string): Promise<string>;
9
+ }
10
+ interface PackAssetProviderOptions {
11
+ /** Prefer this variant (e.g. "ktx2") when the manifest lists one for the asset. */
12
+ variant?: string;
13
+ /** Refs no pack provides go here; without it they are an error. */
14
+ fallback?: AssetProviderLike;
15
+ }
16
+ interface PackSet {
17
+ readonly packs: readonly Pack[];
18
+ add(pack: Pack): void;
19
+ /**
20
+ * Find the pack and path for a ref: `pack:<id>/<path>`, an asset id from a manifest's `ids`,
21
+ * or a bare path. Undefined when no pack has it.
22
+ */
23
+ resolve(ref: string): {
24
+ pack: Pack;
25
+ path: string;
26
+ } | undefined;
27
+ /** The paths every pack lists for a role (e.g. `types`), earliest pack first. */
28
+ provided(role: string): {
29
+ pack: Pack;
30
+ path: string;
31
+ }[];
32
+ readBytes(ref: string, options?: ReadOptions): Promise<ArrayBuffer>;
33
+ readText(ref: string, options?: ReadOptions): Promise<string>;
34
+ readJson<T = unknown>(ref: string, options?: ReadOptions): Promise<T>;
35
+ /** An asset provider for the client (`assets: { provider }`). */
36
+ assetProvider(options?: PackAssetProviderOptions): AssetProviderLike;
37
+ close(): void;
38
+ }
39
+ declare function createPackSet(packs?: readonly Pack[]): PackSet;
40
+ //#endregion
41
+ export { type AssetProviderLike, type BuiltPack, type OpenPackOptions, type Pack, type PackAssetProviderOptions, PackChangedError, PackEntryNotFoundError, type PackFile, type PackIndex, type PackIndexEntry, type PackInput, PackIntegrityError, type PackManifest, type PackOptions, type PackProgress, type PackRetryOptions, type PackSet, type RangeReader, type ReadOptions, createPack, createPackSet, describePack, isTextPath, mediaTypeOf, openPack, packFromFiles, sha256 };
package/dist/index.mjs ADDED
@@ -0,0 +1,105 @@
1
+ import { a as PackChangedError, c as isTextPath, i as packFromFiles, l as mediaTypeOf, n as PackIntegrityError, o as createPack, r as openPack, s as describePack, t as PackEntryNotFoundError, u as sha256 } from "./pack-CDBKnu89.mjs";
2
+ //#region src/set.ts
3
+ var Packs = class {
4
+ list = [];
5
+ constructor(packs) {
6
+ for (const pack of packs) this.add(pack);
7
+ }
8
+ get packs() {
9
+ return this.list;
10
+ }
11
+ add(pack) {
12
+ this.list.push(pack);
13
+ }
14
+ resolve(ref) {
15
+ if (ref.startsWith("pack:")) {
16
+ const rest = ref.slice(5);
17
+ const slash = rest.indexOf("/");
18
+ if (slash < 0) return void 0;
19
+ const id = rest.slice(0, slash);
20
+ const path = rest.slice(slash + 1);
21
+ for (let i = this.list.length - 1; i >= 0; i--) {
22
+ const pack = this.list[i];
23
+ if (pack.manifest.id === id && pack.has(path)) return {
24
+ pack,
25
+ path
26
+ };
27
+ }
28
+ return;
29
+ }
30
+ for (let i = this.list.length - 1; i >= 0; i--) {
31
+ const pack = this.list[i];
32
+ const path = pack.manifest.ids[ref];
33
+ if (path !== void 0) return {
34
+ pack,
35
+ path
36
+ };
37
+ }
38
+ for (let i = this.list.length - 1; i >= 0; i--) {
39
+ const pack = this.list[i];
40
+ if (pack.has(ref)) return {
41
+ pack,
42
+ path: ref
43
+ };
44
+ }
45
+ }
46
+ provided(role) {
47
+ return this.list.flatMap((pack) => (pack.manifest.provides[role] ?? []).map((path) => ({
48
+ pack,
49
+ path
50
+ })));
51
+ }
52
+ found(ref) {
53
+ const hit = this.resolve(ref);
54
+ if (hit === void 0) {
55
+ const ids = this.list.map((pack) => `${pack.manifest.id}@${pack.manifest.version}`);
56
+ throw new Error(`no pack provides "${ref}" (loaded: ${ids.join(", ") || "none"})`);
57
+ }
58
+ return hit;
59
+ }
60
+ async readBytes(ref, options) {
61
+ const { pack, path } = this.found(ref);
62
+ return pack.readBytes(path, options);
63
+ }
64
+ async readText(ref, options) {
65
+ const { pack, path } = this.found(ref);
66
+ return pack.readText(path, options);
67
+ }
68
+ async readJson(ref, options) {
69
+ const { pack, path } = this.found(ref);
70
+ return pack.readJson(path, options);
71
+ }
72
+ assetProvider(options = {}) {
73
+ const pick = (ref) => {
74
+ const hit = this.resolve(ref);
75
+ if (hit === void 0 || options.variant === void 0) return hit;
76
+ const variant = hit.pack.manifest.entries[hit.path]?.variants?.[options.variant];
77
+ return variant !== void 0 && hit.pack.has(variant) ? {
78
+ pack: hit.pack,
79
+ path: variant
80
+ } : hit;
81
+ };
82
+ return {
83
+ load: async (ref) => {
84
+ const hit = pick(ref);
85
+ if (hit !== void 0) return hit.pack.readBytes(hit.path);
86
+ if (options.fallback !== void 0) return options.fallback.load(ref);
87
+ return this.readBytes(ref);
88
+ },
89
+ loadText: async (ref) => {
90
+ const hit = this.resolve(ref);
91
+ if (hit !== void 0) return hit.pack.readText(hit.path);
92
+ if (options.fallback !== void 0) return options.fallback.loadText(ref);
93
+ return this.readText(ref);
94
+ }
95
+ };
96
+ }
97
+ close() {
98
+ for (const pack of this.list) pack.close();
99
+ }
100
+ };
101
+ function createPackSet(packs = []) {
102
+ return new Packs(packs);
103
+ }
104
+ //#endregion
105
+ export { PackChangedError, PackEntryNotFoundError, PackIntegrityError, createPack, createPackSet, describePack, isTextPath, mediaTypeOf, openPack, packFromFiles, sha256 };
@@ -0,0 +1,52 @@
1
+ import { m as PackFile, n as Pack, t as OpenPackOptions } from "./pack-DdapyeeP.mjs";
2
+ import { PackManifest, PackSourceConfig } from "@bendyline/molen-schema";
3
+
4
+ //#region src/node.d.ts
5
+ /** Build settings file in a pack's source directory. */
6
+ declare const PACK_SOURCE_FILE = "molen-pack.source.json";
7
+ /** Index written next to built packs. */
8
+ declare const PACK_INDEX_FILE = "index.json";
9
+ /** Open a built pack file. Reads go to the file on demand; close() releases it. */
10
+ declare function openFilePack(path: string, options?: OpenPackOptions): Promise<Pack>;
11
+ interface PackSource {
12
+ dir: string;
13
+ config: PackSourceConfig;
14
+ files: PackFile[];
15
+ }
16
+ /** Read a pack's source directory: its settings file and every file it includes. */
17
+ declare function readPackSource(dir: string): Promise<PackSource>;
18
+ /**
19
+ * Open an unbuilt pack source directory as a pack. It has the manifest the built pack would
20
+ * have (same entries, ids and contentHash), without zipping anything.
21
+ */
22
+ declare function openDirPack(dir: string, options?: Pick<OpenPackOptions, "expect">): Promise<Pack>;
23
+ /** Open a pack from a URL, a built pack file, or a pack source directory. */
24
+ declare function openPackAt(source: string, options?: OpenPackOptions): Promise<Pack>;
25
+ interface BuiltPackFile {
26
+ manifest: PackManifest;
27
+ /** File name, `<id>-<first 12 hex of the file's sha256>.zip`. */
28
+ file: string;
29
+ /** Absolute path of the written file. */
30
+ path: string;
31
+ size: number;
32
+ /** sha256 of the file's bytes. */
33
+ fileSha256: string;
34
+ /** Path of the updated index.json. */
35
+ indexPath: string;
36
+ }
37
+ /**
38
+ * Build a pack source directory into `outDir`. The file name carries a hash of its bytes, so a
39
+ * host can cache it forever; `index.json` in `outDir` maps the pack id to its current file, and
40
+ * the previous build of the same pack is removed.
41
+ */
42
+ declare function buildPack(dir: string, options: {
43
+ outDir: string;
44
+ solid?: boolean;
45
+ }): Promise<BuiltPackFile>;
46
+ /**
47
+ * Write every file of a pack into `outDir`, with a `molen-pack.source.json` that builds it back
48
+ * to the same content.
49
+ */
50
+ declare function extractPack(pack: Pack, outDir: string): Promise<string[]>;
51
+ //#endregion
52
+ export { BuiltPackFile, PACK_INDEX_FILE, PACK_SOURCE_FILE, PackSource, buildPack, extractPack, openDirPack, openFilePack, openPackAt, readPackSource };
package/dist/node.mjs ADDED
@@ -0,0 +1,203 @@
1
+ import { i as packFromFiles, o as createPack, r as openPack, u as sha256 } from "./pack-CDBKnu89.mjs";
2
+ import { validate } from "@bendyline/molen-schema";
3
+ import { mkdir, open, readFile, readdir, rm, stat, writeFile } from "node:fs/promises";
4
+ import { dirname, join, relative, resolve, sep } from "node:path";
5
+ //#region src/node.ts
6
+ /** Build settings file in a pack's source directory. */
7
+ const PACK_SOURCE_FILE = "molen-pack.source.json";
8
+ /** Index written next to built packs. */
9
+ const PACK_INDEX_FILE = "index.json";
10
+ /** Open a built pack file. Reads go to the file on demand; close() releases it. */
11
+ async function openFilePack(path, options = {}) {
12
+ const handle = await open(path, "r");
13
+ try {
14
+ const { size } = await handle.stat();
15
+ const pack = await openPack({
16
+ size,
17
+ read: async (offset, length) => {
18
+ const buffer = new Uint8Array(length);
19
+ const { bytesRead } = await handle.read(buffer, 0, length, offset);
20
+ if (bytesRead !== length) throw new Error(`${path}: short read at ${offset}`);
21
+ return buffer;
22
+ }
23
+ }, {
24
+ label: path,
25
+ ...options
26
+ });
27
+ const close = pack.close.bind(pack);
28
+ pack.close = () => {
29
+ close();
30
+ handle.close();
31
+ };
32
+ return pack;
33
+ } catch (error) {
34
+ await handle.close();
35
+ throw error;
36
+ }
37
+ }
38
+ function globToRegExp(glob) {
39
+ let pattern = "";
40
+ for (let i = 0; i < glob.length; i++) {
41
+ const char = glob[i];
42
+ if (char === "*" && glob[i + 1] === "*") {
43
+ const slash = glob[i + 2] === "/";
44
+ pattern += slash ? "(?:.*/)?" : ".*";
45
+ i += slash ? 2 : 1;
46
+ } else if (char === "*") pattern += "[^/]*";
47
+ else if (char === "?") pattern += "[^/]";
48
+ else pattern += char.replace(/[.+^${}()|[\]\\]/g, "\\$&");
49
+ }
50
+ return new RegExp(`^${pattern}$`);
51
+ }
52
+ async function walk(dir, root, out) {
53
+ for (const item of await readdir(dir, { withFileTypes: true })) {
54
+ if (item.name.startsWith(".") || item.name === "node_modules") continue;
55
+ const full = join(dir, item.name);
56
+ if (item.isDirectory()) await walk(full, root, out);
57
+ else if (item.isFile()) out.push(relative(root, full).split(sep).join("/"));
58
+ }
59
+ }
60
+ /** Read a pack's source directory: its settings file and every file it includes. */
61
+ async function readPackSource(dir) {
62
+ const root = resolve(dir);
63
+ let raw;
64
+ try {
65
+ raw = JSON.parse(await readFile(join(root, PACK_SOURCE_FILE), "utf8"));
66
+ } catch (error) {
67
+ throw new Error(`${root} has no readable ${PACK_SOURCE_FILE}`, { cause: error });
68
+ }
69
+ const parsed = validate("pack-source", raw);
70
+ if (!parsed.ok) throw new Error(`${join(root, PACK_SOURCE_FILE)}:\n${parsed.formatted}`);
71
+ const config = parsed.value;
72
+ const include = config.include.map(globToRegExp);
73
+ const exclude = config.exclude.map(globToRegExp);
74
+ const paths = [];
75
+ await walk(root, root, paths);
76
+ const selected = paths.filter((path) => path !== PACK_SOURCE_FILE).filter((path) => include.some((glob) => glob.test(path))).filter((path) => !exclude.some((glob) => glob.test(path))).sort();
77
+ return {
78
+ dir: root,
79
+ config,
80
+ files: await Promise.all(selected.map(async (path) => ({
81
+ path,
82
+ bytes: new Uint8Array(await readFile(join(root, ...path.split("/"))))
83
+ })))
84
+ };
85
+ }
86
+ function optionsOf(config) {
87
+ return {
88
+ id: config.id,
89
+ version: config.version,
90
+ ...config.title !== void 0 ? { title: config.title } : {},
91
+ ...config.license !== void 0 ? { license: config.license } : {},
92
+ ...config.notice !== void 0 ? { notice: config.notice } : {},
93
+ ids: config.ids,
94
+ provides: config.provides,
95
+ solid: config.solid
96
+ };
97
+ }
98
+ /**
99
+ * Open an unbuilt pack source directory as a pack. It has the manifest the built pack would
100
+ * have (same entries, ids and contentHash), without zipping anything.
101
+ */
102
+ async function openDirPack(dir, options = {}) {
103
+ const source = await readPackSource(dir);
104
+ const pack = await packFromFiles(source.files, optionsOf(source.config), source.dir);
105
+ const expected = options.expect?.contentHash;
106
+ if (expected !== void 0 && pack.manifest.contentHash !== expected) throw new Error(`${source.dir}: pack "${pack.manifest.id}" has contentHash ${pack.manifest.contentHash}, expected ${expected}`);
107
+ return pack;
108
+ }
109
+ /** Open a pack from a URL, a built pack file, or a pack source directory. */
110
+ async function openPackAt(source, options = {}) {
111
+ if (/^https?:\/\//.test(source)) return openPack(source, options);
112
+ return (await stat(source)).isDirectory() ? openDirPack(source, options) : openFilePack(source, options);
113
+ }
114
+ async function readIndex(path) {
115
+ let raw;
116
+ try {
117
+ raw = JSON.parse(await readFile(path, "utf8"));
118
+ } catch {
119
+ return {
120
+ format: "molen/pack-index@1",
121
+ packs: {}
122
+ };
123
+ }
124
+ const parsed = validate("pack-index", raw);
125
+ if (!parsed.ok) throw new Error(`${path} is not a pack index:\n${parsed.formatted}`);
126
+ return parsed.value;
127
+ }
128
+ /**
129
+ * Build a pack source directory into `outDir`. The file name carries a hash of its bytes, so a
130
+ * host can cache it forever; `index.json` in `outDir` maps the pack id to its current file, and
131
+ * the previous build of the same pack is removed.
132
+ */
133
+ async function buildPack(dir, options) {
134
+ const source = await readPackSource(dir);
135
+ const built = await createPack(source.files, {
136
+ ...optionsOf(source.config),
137
+ ...options.solid !== void 0 ? { solid: options.solid } : {}
138
+ });
139
+ const fileSha256 = await sha256(built.bytes);
140
+ const id = built.manifest.id;
141
+ const file = `${id}-${fileSha256.slice(7, 19)}.zip`;
142
+ const outDir = resolve(options.outDir);
143
+ await mkdir(outDir, { recursive: true });
144
+ const path = join(outDir, file);
145
+ await writeFile(path, built.bytes);
146
+ const indexPath = join(outDir, PACK_INDEX_FILE);
147
+ const index = await readIndex(indexPath);
148
+ const previous = index.packs[id]?.file;
149
+ index.packs[id] = {
150
+ version: built.manifest.version,
151
+ file,
152
+ contentHash: built.manifest.contentHash,
153
+ size: built.bytes.length
154
+ };
155
+ const sorted = {
156
+ format: "molen/pack-index@1",
157
+ packs: Object.fromEntries(Object.entries(index.packs).sort(([a], [b]) => a < b ? -1 : 1))
158
+ };
159
+ await writeFile(indexPath, `${JSON.stringify(sorted, null, 2)}\n`);
160
+ const stillListed = Object.values(sorted.packs).some((entry) => entry.file === previous);
161
+ if (previous !== void 0 && previous !== file && !stillListed) await rm(join(outDir, previous), { force: true });
162
+ return {
163
+ manifest: built.manifest,
164
+ file,
165
+ path,
166
+ size: built.bytes.length,
167
+ fileSha256,
168
+ indexPath
169
+ };
170
+ }
171
+ /**
172
+ * Write every file of a pack into `outDir`, with a `molen-pack.source.json` that builds it back
173
+ * to the same content.
174
+ */
175
+ async function extractPack(pack, outDir) {
176
+ const root = resolve(outDir);
177
+ const written = [];
178
+ for (const path of pack.paths()) {
179
+ const target = join(root, ...path.split("/"));
180
+ if (!target.startsWith(root + sep)) throw new Error(`refusing to write outside ${root}: ${path}`);
181
+ await mkdir(dirname(target), { recursive: true });
182
+ await writeFile(target, new Uint8Array(await pack.readBytes(path)));
183
+ written.push(path);
184
+ }
185
+ const { manifest } = pack;
186
+ const config = {
187
+ format: "molen/pack-source@1",
188
+ id: manifest.id,
189
+ version: manifest.version,
190
+ ...manifest.title !== void 0 ? { title: manifest.title } : {},
191
+ ...manifest.license !== void 0 ? { license: manifest.license } : {},
192
+ ...manifest.notice !== void 0 ? { notice: manifest.notice } : {},
193
+ include: ["**"],
194
+ exclude: [],
195
+ ids: manifest.ids,
196
+ provides: manifest.provides,
197
+ solid: Object.keys(manifest.blocks).length > 0
198
+ };
199
+ await writeFile(join(root, PACK_SOURCE_FILE), `${JSON.stringify(config, null, 2)}\n`);
200
+ return written;
201
+ }
202
+ //#endregion
203
+ export { PACK_INDEX_FILE, PACK_SOURCE_FILE, buildPack, extractPack, openDirPack, openFilePack, openPackAt, readPackSource };