mdmeld 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.
@@ -0,0 +1,609 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/core/index.ts
31
+ var core_exports = {};
32
+ __export(core_exports, {
33
+ check: () => check,
34
+ pack: () => pack,
35
+ unpack: () => unpack
36
+ });
37
+ module.exports = __toCommonJS(core_exports);
38
+
39
+ // src/core/constants.ts
40
+ var FORMAT_VERSION = "1.0.0";
41
+ var MIN_BACKTICK_COUNT = 4;
42
+ var MAX_BACKTICK_COUNT = 8;
43
+ var HASH_PLACEHOLDER = "HASH_PLACEHOLDER";
44
+ var ARCHIVE_HEADER = `<!-- MDMeld v1.0 archive \u2014 a directory tree encoded as markdown.
45
+ Read the manifest below for file listing and positions.
46
+ Spec: https://github.com/3leaps/mdmeld -->`;
47
+
48
+ // src/core/backticks.ts
49
+ function scanForMaxBackticks(content) {
50
+ let max = 0;
51
+ let current = 0;
52
+ for (let i = 0; i < content.length; i++) {
53
+ if (content[i] === "`") {
54
+ current++;
55
+ if (current > max) max = current;
56
+ } else {
57
+ current = 0;
58
+ }
59
+ }
60
+ return max;
61
+ }
62
+ function resolveBacktickCount(maxFoundInContent) {
63
+ const needed = Math.max(maxFoundInContent + 1, MIN_BACKTICK_COUNT);
64
+ if (needed > MAX_BACKTICK_COUNT) return null;
65
+ return needed;
66
+ }
67
+ function generateBackticks(count) {
68
+ return "`".repeat(count);
69
+ }
70
+
71
+ // src/core/base64.ts
72
+ var CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
73
+ function encodeBase64(data) {
74
+ let result = "";
75
+ const len = data.length;
76
+ const remainder = len % 3;
77
+ const mainLen = len - remainder;
78
+ for (let i = 0; i < mainLen; i += 3) {
79
+ const a = data[i];
80
+ const b = data[i + 1];
81
+ const c = data[i + 2];
82
+ result += CHARS[a >> 2];
83
+ result += CHARS[(a & 3) << 4 | b >> 4];
84
+ result += CHARS[(b & 15) << 2 | c >> 6];
85
+ result += CHARS[c & 63];
86
+ }
87
+ if (remainder === 1) {
88
+ const a = data[mainLen];
89
+ result += `${CHARS[a >> 2]}${CHARS[(a & 3) << 4]}==`;
90
+ } else if (remainder === 2) {
91
+ const a = data[mainLen];
92
+ const b = data[mainLen + 1];
93
+ result += `${CHARS[a >> 2]}${CHARS[(a & 3) << 4 | b >> 4]}${CHARS[(b & 15) << 2]}=`;
94
+ }
95
+ return result;
96
+ }
97
+ var DECODE_TABLE = new Uint8Array(128);
98
+ for (let i = 0; i < CHARS.length; i++) {
99
+ DECODE_TABLE[CHARS.charCodeAt(i)] = i;
100
+ }
101
+ function decodeBase64(base64) {
102
+ const str = base64.replace(/\s/g, "");
103
+ const len = str.length;
104
+ let padding = 0;
105
+ if (str[len - 1] === "=") padding++;
106
+ if (str[len - 2] === "=") padding++;
107
+ const byteLen = len * 3 / 4 - padding;
108
+ const result = new Uint8Array(byteLen);
109
+ let j = 0;
110
+ for (let i = 0; i < len; i += 4) {
111
+ const a = DECODE_TABLE[str.charCodeAt(i)];
112
+ const b = DECODE_TABLE[str.charCodeAt(i + 1)];
113
+ const c = DECODE_TABLE[str.charCodeAt(i + 2)];
114
+ const d = DECODE_TABLE[str.charCodeAt(i + 3)];
115
+ result[j++] = a << 2 | b >> 4;
116
+ if (j < byteLen) result[j++] = (b & 15) << 4 | c >> 2;
117
+ if (j < byteLen) result[j++] = (c & 3) << 6 | d;
118
+ }
119
+ return result;
120
+ }
121
+
122
+ // src/core/detect.ts
123
+ function isText(data) {
124
+ if (data.length === 0) return true;
125
+ const sample = data.length > 8192 ? data.subarray(0, 8192) : data;
126
+ const len = sample.length;
127
+ let nullBytes = 0;
128
+ let controlChars = 0;
129
+ let printableOrWhitespace = 0;
130
+ for (let i = 0; i < len; i++) {
131
+ const byte = sample[i];
132
+ if (byte === 0) {
133
+ nullBytes++;
134
+ } else if (byte === 9 || byte === 10 || byte === 13) {
135
+ printableOrWhitespace++;
136
+ } else if (byte < 32) {
137
+ controlChars++;
138
+ } else if (byte <= 126) {
139
+ printableOrWhitespace++;
140
+ }
141
+ }
142
+ if (nullBytes > 0) return false;
143
+ if (controlChars / len > 0.05) return false;
144
+ if (len > 32 && printableOrWhitespace / len < 0.8) return false;
145
+ return true;
146
+ }
147
+
148
+ // src/core/hash.ts
149
+ var import_xxhash_wasm = __toESM(require("xxhash-wasm"), 1);
150
+ async function sha256(data) {
151
+ if (typeof globalThis.crypto?.subtle !== "undefined") {
152
+ return globalThis.crypto.subtle.digest("SHA-256", data);
153
+ }
154
+ const { webcrypto } = await import("crypto");
155
+ return webcrypto.subtle.digest("SHA-256", data);
156
+ }
157
+ var xxhashInstance = null;
158
+ async function getXxhash() {
159
+ if (!xxhashInstance) {
160
+ xxhashInstance = await (0, import_xxhash_wasm.default)();
161
+ }
162
+ return xxhashInstance;
163
+ }
164
+ async function computeHash(content, algorithm) {
165
+ if (algorithm === "xxh64") {
166
+ const xxhash = await getXxhash();
167
+ return xxhash.h64ToString(content);
168
+ }
169
+ const encoder = new TextEncoder();
170
+ const data = encoder.encode(content);
171
+ const hashBuffer = await sha256(data);
172
+ const hashArray = new Uint8Array(hashBuffer);
173
+ return Array.from(hashArray).map((b) => b.toString(16).padStart(2, "0")).join("");
174
+ }
175
+ async function computeHashBytes(data, algorithm) {
176
+ if (algorithm === "xxh64") {
177
+ const xxhash = await getXxhash();
178
+ const raw = xxhash.h64Raw(data);
179
+ return raw.toString(16).padStart(16, "0");
180
+ }
181
+ const hashBuffer = await sha256(data);
182
+ const hashArray = new Uint8Array(hashBuffer);
183
+ return Array.from(hashArray).map((b) => b.toString(16).padStart(2, "0")).join("");
184
+ }
185
+
186
+ // src/core/syntax.ts
187
+ var EXT_TO_SYNTAX = {
188
+ // Web
189
+ ".html": "html",
190
+ ".htm": "html",
191
+ ".css": "css",
192
+ ".js": "javascript",
193
+ ".mjs": "javascript",
194
+ ".cjs": "javascript",
195
+ ".jsx": "jsx",
196
+ ".ts": "typescript",
197
+ ".tsx": "tsx",
198
+ ".mts": "typescript",
199
+ ".cts": "typescript",
200
+ ".vue": "vue",
201
+ ".svelte": "svelte",
202
+ ".astro": "astro",
203
+ // Data
204
+ ".json": "json",
205
+ ".jsonc": "jsonc",
206
+ ".yaml": "yaml",
207
+ ".yml": "yaml",
208
+ ".toml": "toml",
209
+ ".xml": "xml",
210
+ ".csv": "csv",
211
+ ".graphql": "graphql",
212
+ ".gql": "graphql",
213
+ // Config
214
+ ".env": "dotenv",
215
+ ".ini": "ini",
216
+ ".conf": "conf",
217
+ ".cfg": "ini",
218
+ // Shell
219
+ ".sh": "bash",
220
+ ".bash": "bash",
221
+ ".zsh": "zsh",
222
+ ".fish": "fish",
223
+ ".ps1": "powershell",
224
+ ".bat": "batch",
225
+ ".cmd": "batch",
226
+ // Systems
227
+ ".c": "c",
228
+ ".h": "c",
229
+ ".cpp": "cpp",
230
+ ".cc": "cpp",
231
+ ".cxx": "cpp",
232
+ ".hpp": "cpp",
233
+ ".rs": "rust",
234
+ ".go": "go",
235
+ ".java": "java",
236
+ ".kt": "kotlin",
237
+ ".kts": "kotlin",
238
+ ".swift": "swift",
239
+ ".cs": "csharp",
240
+ ".fs": "fsharp",
241
+ ".zig": "zig",
242
+ // Scripting
243
+ ".py": "python",
244
+ ".rb": "ruby",
245
+ ".php": "php",
246
+ ".pl": "perl",
247
+ ".lua": "lua",
248
+ ".r": "r",
249
+ ".R": "r",
250
+ ".jl": "julia",
251
+ ".ex": "elixir",
252
+ ".exs": "elixir",
253
+ ".erl": "erlang",
254
+ ".clj": "clojure",
255
+ ".scala": "scala",
256
+ ".dart": "dart",
257
+ // Markup / Docs
258
+ ".md": "markdown",
259
+ ".mdx": "mdx",
260
+ ".rst": "rst",
261
+ ".tex": "latex",
262
+ ".typ": "typst",
263
+ // DevOps
264
+ ".dockerfile": "dockerfile",
265
+ ".tf": "terraform",
266
+ ".hcl": "hcl",
267
+ ".nix": "nix",
268
+ // SQL
269
+ ".sql": "sql",
270
+ // Misc
271
+ ".diff": "diff",
272
+ ".patch": "diff",
273
+ ".prisma": "prisma",
274
+ ".proto": "protobuf",
275
+ ".wasm": "wasm",
276
+ ".lock": "text",
277
+ ".log": "text",
278
+ ".txt": "text"
279
+ };
280
+ var NAME_TO_SYNTAX = {
281
+ Dockerfile: "dockerfile",
282
+ Makefile: "makefile",
283
+ Containerfile: "dockerfile",
284
+ Justfile: "makefile",
285
+ Vagrantfile: "ruby",
286
+ Gemfile: "ruby",
287
+ Rakefile: "ruby",
288
+ ".gitignore": "gitignore",
289
+ ".gitattributes": "gitattributes",
290
+ ".editorconfig": "editorconfig",
291
+ ".prettierrc": "json",
292
+ ".eslintrc": "json"
293
+ };
294
+ function getSyntax(filePath) {
295
+ const fileName = filePath.split("/").pop() ?? "";
296
+ const byName = NAME_TO_SYNTAX[fileName];
297
+ if (byName) return byName;
298
+ const dotIdx = fileName.lastIndexOf(".");
299
+ if (dotIdx === -1) return "text";
300
+ const ext = fileName.slice(dotIdx).toLowerCase();
301
+ return EXT_TO_SYNTAX[ext] ?? "text";
302
+ }
303
+
304
+ // src/core/yaml.ts
305
+ var import_js_yaml = __toESM(require("js-yaml"), 1);
306
+ function dump(value) {
307
+ return import_js_yaml.default.dump(value, {
308
+ lineWidth: -1,
309
+ noRefs: true,
310
+ quotingType: '"',
311
+ forceQuotes: false
312
+ });
313
+ }
314
+ function load(text) {
315
+ return import_js_yaml.default.load(text);
316
+ }
317
+
318
+ // src/core/pack.ts
319
+ var TEXT_DECODER = new TextDecoder();
320
+ async function pack(files, options = {}) {
321
+ const hashAlgorithm = options.hashAlgorithm ?? "xxh64";
322
+ const created = options.created ?? (/* @__PURE__ */ new Date()).toISOString();
323
+ let maxBackticks = 0;
324
+ const fileInfos = [];
325
+ for (const file of files) {
326
+ const textFile = isText(file.content);
327
+ if (textFile) {
328
+ const text = TEXT_DECODER.decode(file.content);
329
+ const found = scanForMaxBackticks(text);
330
+ if (found > maxBackticks) maxBackticks = found;
331
+ fileInfos.push({ file, isTextFile: true, textContent: text, base64Content: null });
332
+ } else {
333
+ const b64 = encodeBase64(file.content);
334
+ fileInfos.push({ file, isTextFile: false, textContent: null, base64Content: b64 });
335
+ }
336
+ }
337
+ const backtickCount = resolveBacktickCount(maxBackticks);
338
+ if (backtickCount === null) {
339
+ throw new Error(
340
+ "Cannot pack: file content contains a backtick run of 8 or more characters, which exceeds the maximum allowed fence width. Remove the excessive backtick sequences or exclude the file."
341
+ );
342
+ }
343
+ const fence = generateBackticks(backtickCount);
344
+ const contentBlocks = [];
345
+ const fileEntries = [];
346
+ for (const info of fileInfos) {
347
+ const path = info.file.path;
348
+ let contentStr;
349
+ let fenceLang;
350
+ let type;
351
+ let syntax;
352
+ let encoding;
353
+ const hash = await computeHashBytes(info.file.content, hashAlgorithm);
354
+ if (info.textContent !== null) {
355
+ contentStr = info.textContent;
356
+ type = "text";
357
+ syntax = getSyntax(path);
358
+ fenceLang = syntax;
359
+ encoding = void 0;
360
+ } else {
361
+ const b64 = info.base64Content;
362
+ contentStr = b64;
363
+ type = info.isTextFile ? "text" : "binary";
364
+ syntax = getSyntax(path);
365
+ fenceLang = "base64";
366
+ encoding = "base64";
367
+ }
368
+ const block = `### ${path}
369
+
370
+ ${fence}${fenceLang}
371
+ ${contentStr}
372
+ ${fence}`;
373
+ contentBlocks.push(block);
374
+ fileEntries.push({
375
+ path,
376
+ type,
377
+ size: info.file.content.length,
378
+ hash,
379
+ syntax,
380
+ ...encoding ? { encoding } : {},
381
+ position: { start: 0, fence: 0, content: 0, length: 0 }
382
+ // placeholder
383
+ });
384
+ }
385
+ const contentSection = contentBlocks.join("\n\n");
386
+ const manifest = {
387
+ mdmeld: {
388
+ version: FORMAT_VERSION,
389
+ created,
390
+ hash_algorithm: hashAlgorithm,
391
+ backtick_count: backtickCount,
392
+ files: fileEntries
393
+ },
394
+ integrity: {
395
+ manifest_hash: HASH_PLACEHOLDER,
396
+ content_hash: HASH_PLACEHOLDER
397
+ }
398
+ };
399
+ const entriesNoPos = fileEntries.map((f) => {
400
+ const { position: _, ...rest } = f;
401
+ return rest;
402
+ });
403
+ const prelimYaml = dump({
404
+ ...manifest,
405
+ mdmeld: { ...manifest.mdmeld, files: entriesNoPos }
406
+ });
407
+ const prelimFrontmatter = `${ARCHIVE_HEADER}
408
+ ---
409
+ ${prelimYaml}---
410
+ `;
411
+ const prelimLines = countLines(prelimFrontmatter);
412
+ const positions1 = calculatePositions(contentSection, prelimLines);
413
+ applyPositions(fileEntries, positions1);
414
+ const withPosYaml = dump(manifest);
415
+ const withPosFrontmatter = `${ARCHIVE_HEADER}
416
+ ---
417
+ ${withPosYaml}---
418
+ `;
419
+ const finalLines = countLines(withPosFrontmatter);
420
+ if (finalLines !== prelimLines) {
421
+ const positions2 = calculatePositions(contentSection, finalLines);
422
+ applyPositions(fileEntries, positions2);
423
+ }
424
+ const rawContentForHash = `
425
+
426
+ ${contentSection}`;
427
+ const contentHash = await computeHash(rawContentForHash, hashAlgorithm);
428
+ manifest.integrity.content_hash = contentHash;
429
+ const manifestYamlForHash = dump({ mdmeld: manifest.mdmeld });
430
+ const manifestHash = await computeHash(manifestYamlForHash, hashAlgorithm);
431
+ manifest.integrity.manifest_hash = manifestHash;
432
+ const outputYaml = dump(manifest);
433
+ return `${ARCHIVE_HEADER}
434
+ ---
435
+ ${outputYaml}---
436
+
437
+ ${contentSection}`;
438
+ }
439
+ function calculatePositions(contentSection, manifestLineCount) {
440
+ const lines = contentSection.split("\n");
441
+ const positions = [];
442
+ const offset = manifestLineCount + 1;
443
+ let i = 0;
444
+ while (i < lines.length) {
445
+ const line = lines[i];
446
+ if (line.startsWith("### ")) {
447
+ const start = offset + i + 1;
448
+ i++;
449
+ if (i < lines.length && lines[i].trim() === "") {
450
+ i++;
451
+ }
452
+ if (i < lines.length && isFenceLine(lines[i])) {
453
+ const fenceLine = offset + i + 1;
454
+ i++;
455
+ const contentStart = offset + i + 1;
456
+ let contentLength = 0;
457
+ while (i < lines.length && !isFenceLine(lines[i])) {
458
+ contentLength++;
459
+ i++;
460
+ }
461
+ if (i < lines.length) i++;
462
+ positions.push({
463
+ start,
464
+ fence: fenceLine,
465
+ content: contentStart,
466
+ length: contentLength
467
+ });
468
+ }
469
+ } else {
470
+ i++;
471
+ }
472
+ }
473
+ return positions;
474
+ }
475
+ function applyPositions(entries, positions) {
476
+ for (let i = 0; i < entries.length; i++) {
477
+ entries[i].position = positions[i];
478
+ }
479
+ }
480
+ function countLines(s) {
481
+ if (s.length === 0) return 0;
482
+ let count = 0;
483
+ for (let i = 0; i < s.length; i++) {
484
+ if (s[i] === "\n") count++;
485
+ }
486
+ if (s[s.length - 1] !== "\n") count++;
487
+ return count;
488
+ }
489
+ function isFenceLine(line) {
490
+ return /^`{4,}/.test(line.trim());
491
+ }
492
+
493
+ // src/core/unpack.ts
494
+ var TEXT_ENCODER = new TextEncoder();
495
+ async function unpack(content) {
496
+ const { manifest, contentSection } = parseArchive(content);
497
+ const files = extractFiles(contentSection, manifest);
498
+ return { files, manifest };
499
+ }
500
+ async function check(content) {
501
+ const errors = [];
502
+ let manifest;
503
+ let contentSection;
504
+ let rawContentAfterDelimiter;
505
+ try {
506
+ const parsed = parseArchive(content);
507
+ manifest = parsed.manifest;
508
+ contentSection = parsed.contentSection;
509
+ rawContentAfterDelimiter = parsed.rawContentAfterDelimiter;
510
+ } catch (e) {
511
+ return { valid: false, errors: [`Parse error: ${e.message}`] };
512
+ }
513
+ const algorithm = manifest.mdmeld.hash_algorithm;
514
+ if (manifest.integrity.content_hash !== HASH_PLACEHOLDER && manifest.integrity.content_hash !== "") {
515
+ const actual = await computeHash(rawContentAfterDelimiter, algorithm);
516
+ if (actual !== manifest.integrity.content_hash) {
517
+ errors.push(
518
+ `Content hash mismatch: expected ${manifest.integrity.content_hash}, got ${actual}`
519
+ );
520
+ }
521
+ }
522
+ if (manifest.integrity.manifest_hash !== HASH_PLACEHOLDER && manifest.integrity.manifest_hash !== "") {
523
+ const manifestYaml = dump({ mdmeld: manifest.mdmeld });
524
+ const actual = await computeHash(manifestYaml, algorithm);
525
+ if (actual !== manifest.integrity.manifest_hash) {
526
+ errors.push(
527
+ `Manifest hash mismatch: expected ${manifest.integrity.manifest_hash}, got ${actual}`
528
+ );
529
+ }
530
+ }
531
+ const files = extractFiles(contentSection, manifest);
532
+ for (let i = 0; i < manifest.mdmeld.files.length; i++) {
533
+ const entry = manifest.mdmeld.files[i];
534
+ const file = files[i];
535
+ if (!file) {
536
+ errors.push(`Missing content block for file: ${entry.path}`);
537
+ continue;
538
+ }
539
+ if (entry.hash === HASH_PLACEHOLDER) continue;
540
+ const actual = await computeHashBytes(file.content, algorithm);
541
+ if (actual !== entry.hash) {
542
+ errors.push(`File hash mismatch for ${entry.path}: expected ${entry.hash}, got ${actual}`);
543
+ }
544
+ }
545
+ return { valid: errors.length === 0, errors };
546
+ }
547
+ function parseArchive(content) {
548
+ let input = content;
549
+ if (input.startsWith("<!--")) {
550
+ const commentEnd = input.indexOf("-->");
551
+ if (commentEnd !== -1) {
552
+ input = input.slice(commentEnd + 3).trimStart();
553
+ }
554
+ }
555
+ if (!input.startsWith("---")) {
556
+ throw new Error("Missing YAML frontmatter (expected --- delimiter)");
557
+ }
558
+ const secondDelim = input.indexOf("\n---", 3);
559
+ if (secondDelim === -1) {
560
+ throw new Error("Missing closing --- delimiter for YAML frontmatter");
561
+ }
562
+ const yamlStr = input.slice(4, secondDelim);
563
+ const rawContentAfterDelimiter = input.slice(secondDelim + 4);
564
+ const contentSection = rawContentAfterDelimiter.replace(/^\n+/, "");
565
+ const parsed = load(yamlStr);
566
+ if (!parsed || typeof parsed !== "object" || !("mdmeld" in parsed)) {
567
+ throw new Error("Invalid manifest: missing 'mdmeld' key");
568
+ }
569
+ const manifest = parsed;
570
+ const archiveMajor = String(manifest.mdmeld.version).split(".")[0];
571
+ const supportedMajor = FORMAT_VERSION.split(".")[0];
572
+ if (archiveMajor !== supportedMajor) {
573
+ throw new Error(
574
+ `Unsupported archive version: ${manifest.mdmeld.version} (this parser supports major version ${supportedMajor})`
575
+ );
576
+ }
577
+ return { manifest, contentSection, rawContentAfterDelimiter };
578
+ }
579
+ function extractFiles(contentSection, manifest) {
580
+ const backtickCount = manifest.mdmeld.backtick_count;
581
+ const fence = "`".repeat(backtickCount);
582
+ const files = [];
583
+ const pattern = new RegExp(
584
+ `### (.+?)\\s*\\n\\s*${fence}([^\\n]*)\\n([\\s\\S]*?)\\n?${fence}(?=\\s|$)`,
585
+ "g"
586
+ );
587
+ for (const match of contentSection.matchAll(pattern)) {
588
+ const path = match[1].trim();
589
+ const lang = match[2].trim();
590
+ const rawContent = match[3];
591
+ const entry = manifest.mdmeld.files.find((f) => f.path === path);
592
+ const isEncoded = lang === "base64" || entry?.encoding === "base64";
593
+ let content;
594
+ if (isEncoded) {
595
+ content = decodeBase64(rawContent);
596
+ } else {
597
+ content = TEXT_ENCODER.encode(rawContent);
598
+ }
599
+ files.push({ path, content });
600
+ }
601
+ return files;
602
+ }
603
+ // Annotate the CommonJS export names for ESM import in node:
604
+ 0 && (module.exports = {
605
+ check,
606
+ pack,
607
+ unpack
608
+ });
609
+ //# sourceMappingURL=index.cjs.map