tar-xz 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.
Files changed (63) hide show
  1. package/LICENSE +165 -0
  2. package/README.md +201 -0
  3. package/lib/browser/create.d.ts +27 -0
  4. package/lib/browser/create.d.ts.map +1 -0
  5. package/lib/browser/create.js +113 -0
  6. package/lib/browser/create.js.map +1 -0
  7. package/lib/browser/extract.d.ts +24 -0
  8. package/lib/browser/extract.d.ts.map +1 -0
  9. package/lib/browser/extract.js +112 -0
  10. package/lib/browser/extract.js.map +1 -0
  11. package/lib/browser/index.d.ts +7 -0
  12. package/lib/browser/index.d.ts.map +1 -0
  13. package/lib/browser/index.js +7 -0
  14. package/lib/browser/index.js.map +1 -0
  15. package/lib/browser/list.d.ts +23 -0
  16. package/lib/browser/list.d.ts.map +1 -0
  17. package/lib/browser/list.js +81 -0
  18. package/lib/browser/list.js.map +1 -0
  19. package/lib/index.browser.d.ts +12 -0
  20. package/lib/index.browser.d.ts.map +1 -0
  21. package/lib/index.browser.js +14 -0
  22. package/lib/index.browser.js.map +1 -0
  23. package/lib/index.d.ts +12 -0
  24. package/lib/index.d.ts.map +1 -0
  25. package/lib/index.js +14 -0
  26. package/lib/index.js.map +1 -0
  27. package/lib/node/create.d.ts +22 -0
  28. package/lib/node/create.d.ts.map +1 -0
  29. package/lib/node/create.js +155 -0
  30. package/lib/node/create.js.map +1 -0
  31. package/lib/node/extract.d.ts +30 -0
  32. package/lib/node/extract.d.ts.map +1 -0
  33. package/lib/node/extract.js +274 -0
  34. package/lib/node/extract.js.map +1 -0
  35. package/lib/node/index.d.ts +7 -0
  36. package/lib/node/index.d.ts.map +1 -0
  37. package/lib/node/index.js +7 -0
  38. package/lib/node/index.js.map +1 -0
  39. package/lib/node/list.d.ts +20 -0
  40. package/lib/node/list.d.ts.map +1 -0
  41. package/lib/node/list.js +115 -0
  42. package/lib/node/list.js.map +1 -0
  43. package/lib/tar/checksum.d.ts +40 -0
  44. package/lib/tar/checksum.d.ts.map +1 -0
  45. package/lib/tar/checksum.js +91 -0
  46. package/lib/tar/checksum.js.map +1 -0
  47. package/lib/tar/format.d.ts +87 -0
  48. package/lib/tar/format.d.ts.map +1 -0
  49. package/lib/tar/format.js +244 -0
  50. package/lib/tar/format.js.map +1 -0
  51. package/lib/tar/index.d.ts +8 -0
  52. package/lib/tar/index.d.ts.map +1 -0
  53. package/lib/tar/index.js +6 -0
  54. package/lib/tar/index.js.map +1 -0
  55. package/lib/tar/pax.d.ts +82 -0
  56. package/lib/tar/pax.d.ts.map +1 -0
  57. package/lib/tar/pax.js +185 -0
  58. package/lib/tar/pax.js.map +1 -0
  59. package/lib/types.d.ts +144 -0
  60. package/lib/types.d.ts.map +1 -0
  61. package/lib/types.js +26 -0
  62. package/lib/types.js.map +1 -0
  63. package/package.json +80 -0
package/lib/types.d.ts ADDED
@@ -0,0 +1,144 @@
1
+ /**
2
+ * TAR entry type flags (POSIX ustar format)
3
+ */
4
+ export declare const TarEntryType: {
5
+ /** Regular file */
6
+ readonly FILE: "0";
7
+ /** Hard link */
8
+ readonly HARDLINK: "1";
9
+ /** Symbolic link */
10
+ readonly SYMLINK: "2";
11
+ /** Character device */
12
+ readonly CHARDEV: "3";
13
+ /** Block device */
14
+ readonly BLOCKDEV: "4";
15
+ /** Directory */
16
+ readonly DIRECTORY: "5";
17
+ /** FIFO (named pipe) */
18
+ readonly FIFO: "6";
19
+ /** Contiguous file */
20
+ readonly CONTIGUOUS: "7";
21
+ /** PAX extended header for next file */
22
+ readonly PAX_HEADER: "x";
23
+ /** PAX global extended header */
24
+ readonly PAX_GLOBAL: "g";
25
+ };
26
+ export type TarEntryTypeValue = (typeof TarEntryType)[keyof typeof TarEntryType];
27
+ /**
28
+ * TAR entry metadata
29
+ */
30
+ export interface TarEntry {
31
+ /** File path (relative) */
32
+ name: string;
33
+ /** Entry type */
34
+ type: TarEntryTypeValue;
35
+ /** File size in bytes */
36
+ size: number;
37
+ /** File mode (permissions) */
38
+ mode: number;
39
+ /** User ID */
40
+ uid: number;
41
+ /** Group ID */
42
+ gid: number;
43
+ /** Modification time (seconds since epoch) */
44
+ mtime: number;
45
+ /** User name */
46
+ uname: string;
47
+ /** Group name */
48
+ gname: string;
49
+ /** Device major number (for device files) */
50
+ devmajor: number;
51
+ /** Device minor number (for device files) */
52
+ devminor: number;
53
+ /** Link target (for symlinks and hardlinks) */
54
+ linkname: string;
55
+ }
56
+ /**
57
+ * TAR entry with content data
58
+ */
59
+ export interface TarEntryWithData extends TarEntry {
60
+ /** File content */
61
+ data: Uint8Array;
62
+ }
63
+ /**
64
+ * Input file for archive creation
65
+ */
66
+ export interface TarInputFile {
67
+ /** File path in archive */
68
+ name: string;
69
+ /** File content (string, Uint8Array, ArrayBuffer, or Blob) */
70
+ content: string | Uint8Array | ArrayBuffer | Blob;
71
+ /** Optional file mode (default: 0o644 for files, 0o755 for directories) */
72
+ mode?: number;
73
+ /** Optional modification time (default: current time) */
74
+ mtime?: Date | number;
75
+ }
76
+ /**
77
+ * Options for creating tar.xz archives (Node.js)
78
+ */
79
+ export interface CreateOptions {
80
+ /** Output file path */
81
+ file: string;
82
+ /** Base directory for file paths */
83
+ cwd?: string;
84
+ /** Files/directories to include */
85
+ files: string[];
86
+ /** XZ compression preset (0-9, default: 6) */
87
+ preset?: number;
88
+ /** Follow symbolic links */
89
+ follow?: boolean;
90
+ /** Dereference symlinks (archive target, not link) */
91
+ dereference?: boolean;
92
+ }
93
+ /**
94
+ * Options for extracting tar.xz archives (Node.js)
95
+ */
96
+ export interface ExtractOptions {
97
+ /** Input file path */
98
+ file: string;
99
+ /** Output directory */
100
+ cwd?: string;
101
+ /** Number of leading path components to strip */
102
+ strip?: number;
103
+ /** Filter function to select entries */
104
+ filter?: (entry: TarEntry) => boolean;
105
+ /** Preserve file ownership (requires root) */
106
+ preserveOwner?: boolean;
107
+ }
108
+ /**
109
+ * Options for listing tar.xz archives (Node.js)
110
+ */
111
+ export interface ListOptions {
112
+ /** Input file path */
113
+ file: string;
114
+ }
115
+ /**
116
+ * Options for browser-based archive creation
117
+ */
118
+ export interface BrowserCreateOptions {
119
+ /** Files to include */
120
+ files: TarInputFile[];
121
+ /** XZ compression preset (0-9, default: 3 for browser performance) */
122
+ preset?: number;
123
+ }
124
+ /**
125
+ * Options for browser-based archive extraction
126
+ */
127
+ export interface BrowserExtractOptions {
128
+ /** Number of leading path components to strip */
129
+ strip?: number;
130
+ /** Filter function to select entries */
131
+ filter?: (entry: TarEntry) => boolean;
132
+ }
133
+ /**
134
+ * Extracted file from browser API
135
+ */
136
+ export interface ExtractedFile {
137
+ /** File path */
138
+ name: string;
139
+ /** File content */
140
+ data: Uint8Array;
141
+ /** File metadata */
142
+ entry: TarEntry;
143
+ }
144
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,YAAY;IACvB,mBAAmB;;IAEnB,gBAAgB;;IAEhB,oBAAoB;;IAEpB,uBAAuB;;IAEvB,mBAAmB;;IAEnB,gBAAgB;;IAEhB,wBAAwB;;IAExB,sBAAsB;;IAEtB,wCAAwC;;IAExC,iCAAiC;;CAEzB,CAAC;AAEX,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,OAAO,YAAY,CAAC,CAAC;AAEjF;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,2BAA2B;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,iBAAiB;IACjB,IAAI,EAAE,iBAAiB,CAAC;IACxB,yBAAyB;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,8BAA8B;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,cAAc;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,eAAe;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,8CAA8C;IAC9C,KAAK,EAAE,MAAM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A8C;IAC9C,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,sBAAsB;IACtB,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,uBAAuB;IACvB,KAAK,EAAE,YAAY,EAAE,CAAC;IACtB,sEAAsE;IACtE,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,iDAAiD;IACjD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,wCAAwC;IACxC,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,QAAQ,KAAK,OAAO,CAAC;CACvC;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,gBAAgB;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,mBAAmB;IACnB,IAAI,EAAE,UAAU,CAAC;IACjB,oBAAoB;IACpB,KAAK,EAAE,QAAQ,CAAC;CACjB"}
package/lib/types.js ADDED
@@ -0,0 +1,26 @@
1
+ /**
2
+ * TAR entry type flags (POSIX ustar format)
3
+ */
4
+ export const TarEntryType = {
5
+ /** Regular file */
6
+ FILE: '0',
7
+ /** Hard link */
8
+ HARDLINK: '1',
9
+ /** Symbolic link */
10
+ SYMLINK: '2',
11
+ /** Character device */
12
+ CHARDEV: '3',
13
+ /** Block device */
14
+ BLOCKDEV: '4',
15
+ /** Directory */
16
+ DIRECTORY: '5',
17
+ /** FIFO (named pipe) */
18
+ FIFO: '6',
19
+ /** Contiguous file */
20
+ CONTIGUOUS: '7',
21
+ /** PAX extended header for next file */
22
+ PAX_HEADER: 'x',
23
+ /** PAX global extended header */
24
+ PAX_GLOBAL: 'g',
25
+ };
26
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,mBAAmB;IACnB,IAAI,EAAE,GAAG;IACT,gBAAgB;IAChB,QAAQ,EAAE,GAAG;IACb,oBAAoB;IACpB,OAAO,EAAE,GAAG;IACZ,uBAAuB;IACvB,OAAO,EAAE,GAAG;IACZ,mBAAmB;IACnB,QAAQ,EAAE,GAAG;IACb,gBAAgB;IAChB,SAAS,EAAE,GAAG;IACd,wBAAwB;IACxB,IAAI,EAAE,GAAG;IACT,sBAAsB;IACtB,UAAU,EAAE,GAAG;IACf,wCAAwC;IACxC,UAAU,EAAE,GAAG;IACf,iCAAiC;IACjC,UAAU,EAAE,GAAG;CACP,CAAC"}
package/package.json ADDED
@@ -0,0 +1,80 @@
1
+ {
2
+ "name": "tar-xz",
3
+ "version": "0.1.0",
4
+ "description": "Create and extract tar.xz archives with streaming support for Node.js and buffer-based API for browsers",
5
+ "type": "module",
6
+ "main": "./lib/index.js",
7
+ "exports": {
8
+ ".": {
9
+ "browser": {
10
+ "types": "./lib/index.browser.d.ts",
11
+ "import": "./lib/index.browser.js",
12
+ "default": "./lib/index.browser.js"
13
+ },
14
+ "types": "./lib/index.d.ts",
15
+ "import": "./lib/index.js",
16
+ "default": "./lib/index.js"
17
+ }
18
+ },
19
+ "dependencies": {
20
+ "node-liblzma": "^3.1.0"
21
+ },
22
+ "devDependencies": {
23
+ "@biomejs/biome": "^2.3.13",
24
+ "@types/node": "^25.2.0",
25
+ "@vitest/coverage-v8": "^4.0.18",
26
+ "typescript": "^5.9.3",
27
+ "vite": "^6.3.5",
28
+ "vitest": "^4.0.18"
29
+ },
30
+ "types": "./lib/index.d.ts",
31
+ "files": [
32
+ "lib/"
33
+ ],
34
+ "engines": {
35
+ "node": ">=16.0.0"
36
+ },
37
+ "repository": {
38
+ "type": "git",
39
+ "url": "https://github.com/oorabona/node-liblzma",
40
+ "directory": "packages/tar-xz"
41
+ },
42
+ "keywords": [
43
+ "tar",
44
+ "xz",
45
+ "lzma",
46
+ "lzma2",
47
+ "compress",
48
+ "decompress",
49
+ "archive",
50
+ "extract",
51
+ "browser",
52
+ "wasm"
53
+ ],
54
+ "author": "Olivier ORABONA",
55
+ "license": "LGPL-3.0",
56
+ "bugs": {
57
+ "url": "https://github.com/oorabona/node-liblzma/issues"
58
+ },
59
+ "homepage": "https://github.com/oorabona/node-liblzma/tree/master/packages/tar-xz",
60
+ "publishConfig": {
61
+ "registry": "https://registry.npmjs.org/"
62
+ },
63
+ "scripts": {
64
+ "build": "tsc",
65
+ "build:watch": "tsc --watch",
66
+ "build:demo": "vite build --config demo/vite.config.ts",
67
+ "dev:demo": "vite --config demo/vite.config.ts",
68
+ "test": "vitest run",
69
+ "test:watch": "vitest",
70
+ "test:coverage": "vitest run --coverage",
71
+ "type-check": "tsc --noEmit",
72
+ "clean": "rm -rf lib dist-demo",
73
+ "lint": "biome lint",
74
+ "lint:fix": "biome lint --write",
75
+ "format": "biome format",
76
+ "format:write": "biome format --write",
77
+ "check": "biome check",
78
+ "check:write": "biome check --write"
79
+ }
80
+ }