memory-extract 0.1.4 → 0.1.5

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/README.md CHANGED
@@ -0,0 +1,83 @@
1
+ # memory-extract
2
+
3
+ Embed files into a PNG image and open them back from the PNG alone.
4
+
5
+ Use it to ship static sites, single assets or small apps as portable `.png` cartridges. The image still opens as a normal PNG and the payload lives in a custom chunk inside the file.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ npm install memory-extract
11
+ ```
12
+
13
+ ## CLI
14
+
15
+ ### `memory-pack [path] [filename]`
16
+
17
+ Pack a file or directory into a memory PNG
18
+
19
+ ```bash
20
+ memory-pack # pack current directory → ./<folder-name>.png
21
+ memory-pack dist # pack ./dist → ./dist.png
22
+ memory-pack dist App # pack ./dist → ./App.png
23
+ ```
24
+
25
+
26
+ | Argument | Default | Description |
27
+ | ---------- | ------------------ | ----------------------------------------- |
28
+ | `path` | `.` | File or directory to pack |
29
+ | `filename` | basename of `path` | Output PNG name (`.png` added if missing) |
30
+
31
+
32
+
33
+ | Flag | Description |
34
+ | ---------------- | -------------------------------------------- |
35
+ | `--cover <path>` | Cover image instead of the default blank PNG |
36
+ | `--out <path>` | Output PNG path |
37
+
38
+
39
+
40
+
41
+ ### `memory-unpack <png> [out-dir]`
42
+
43
+ Extract the packed files from a memory PNG
44
+
45
+ ```bash
46
+ memory-unpack dist.png
47
+ memory-unpack dist.png ./restored
48
+ ```
49
+
50
+
51
+
52
+ ### `memory-play <png>`
53
+
54
+ Open a memory PNG in the browser
55
+
56
+ ```bash
57
+ memory-play App.png
58
+ ```
59
+
60
+ ## Library
61
+
62
+ Browser exports:
63
+
64
+ ```js
65
+ import {
66
+ extractMemory,
67
+ listManifestFiles,
68
+ readMemoryFile,
69
+ createMemoryBlob,
70
+ } from "memory-extract";
71
+ ```
72
+
73
+
74
+
75
+ Node helpers:
76
+
77
+ ```js
78
+ import { embedMemory, encodeMemoryPayload } from "memory-extract/node";
79
+ import { guessMimeType, encodeV2Archive } from "memory-extract/payload";
80
+ ```
81
+
82
+ `createMemoryBlob()` is for in-browser launch via blob URLs. The CLI uses HTTP or `file://` instead.
83
+
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "memory-extract",
3
3
  "description": "Tool for embedding data into PNG images",
4
4
  "license": "MIT",
5
- "version": "0.1.4",
5
+ "version": "0.1.5",
6
6
  "author": "semigarden",
7
7
  "repository": {
8
8
  "type": "git",
package/tools/unpack.mjs CHANGED
@@ -27,7 +27,7 @@ const parseArgs = async (argv) => {
27
27
  const main = async () => {
28
28
  const { input, explicitOut, host } = await parseArgs(process.argv.slice(2));
29
29
  const buffer = await readFile(input);
30
- const { png, manifest, fileBytes, version } = extractMemory(buffer);
30
+ const { manifest, fileBytes, version } = extractMemory(buffer);
31
31
  const outDir = resolveUnpackDir({
32
32
  manifestSource: manifest.source ?? "",
33
33
  explicitOut,
@@ -35,7 +35,6 @@ const main = async () => {
35
35
  });
36
36
 
37
37
  await mkdir(outDir, { recursive: true });
38
- await writeFile(path.join(outDir, "cover.png"), png);
39
38
 
40
39
  for (const filePath of listManifestFiles(manifest)) {
41
40
  const target = resolveSafePath(
@@ -48,11 +47,6 @@ const main = async () => {
48
47
  await writeFile(target, readMemoryFile(manifest, filePath, fileBytes));
49
48
  }
50
49
 
51
- await writeFile(
52
- path.join(outDir, "manifest.json"),
53
- `${JSON.stringify(manifest, null, 2)}\n`
54
- );
55
-
56
50
  console.log(
57
51
  `Extracted ${listManifestFiles(manifest).length} files to ${outDir} (format v${version})`
58
52
  );