@uniweb/build 0.14.15 → 0.14.16

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 (2) hide show
  1. package/package.json +2 -2
  2. package/src/uwx/zip.js +18 -10
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniweb/build",
3
- "version": "0.14.15",
3
+ "version": "0.14.16",
4
4
  "description": "Build tooling for the Uniweb Component Web Platform",
5
5
  "type": "module",
6
6
  "exports": {
@@ -63,8 +63,8 @@
63
63
  "@uniweb/theming": "0.1.4"
64
64
  },
65
65
  "optionalDependencies": {
66
- "@uniweb/runtime": "0.8.19",
67
66
  "@uniweb/content-reader": "1.1.12",
67
+ "@uniweb/runtime": "0.8.20",
68
68
  "@uniweb/schemas": "0.2.3"
69
69
  },
70
70
  "peerDependencies": {
package/src/uwx/zip.js CHANGED
@@ -1,11 +1,12 @@
1
1
  // Minimal, zero-dependency ZIP writer/reader for .uwx containers.
2
2
  //
3
- // DESIGN DECISION: Stored only (compression method 0), no Deflate. A .uwx
4
- // container is a ZIP; compression is an optimization, not part of the
5
- // contract, and every standard ZIP reader handles Stored entries. Staying
6
- // Stored-only removes a class of cross-tool byte asymmetry and needs no
7
- // zlib. If package size ever matters, a Deflate path can be added later via
8
- // Node's built-in `zlib.deflateRawSync` without changing callers.
3
+ // DESIGN DECISION: our WRITER (`createZip`) emits Stored only (compression
4
+ // method 0), no Deflate. A .uwx container is a ZIP; compression is an
5
+ // optimization, not part of the contract, and every standard ZIP reader
6
+ // handles Stored entries. Staying Stored-only on write removes a class of
7
+ // cross-tool byte asymmetry. The READER (`readZip`) additionally inflates
8
+ // Deflate (method 8) entries — the backend's pull `.uwx` Deflates larger
9
+ // entities, and the framework must read what the backend produces.
9
10
  //
10
11
  // No Zip64: per-record JSON files are far below 4 GiB and entry counts far
11
12
  // below 65535. The format is otherwise the classic APPNOTE layout, all
@@ -17,6 +18,7 @@
17
18
  // makes byte output reproducible for a given input.
18
19
 
19
20
  import { crc32 } from './crc32.js'
21
+ import { inflateRawSync } from 'node:zlib'
20
22
 
21
23
  const LOCAL_SIG = 0x04034b50
22
24
  const CENTRAL_SIG = 0x02014b50
@@ -89,11 +91,12 @@ export function createZip(files) {
89
91
  }
90
92
 
91
93
  /**
92
- * Reader for our own Stored archivesused by tests and by inspection /
93
- * `--dry-run`. Not a general-purpose unzip.
94
+ * Reader for `.uwx` containers. Handles Stored (method 0 what our writer emits)
95
+ * and Deflate (method 8 — what the backend's pull `.uwx` uses); any other method
96
+ * throws. Not otherwise a general-purpose unzip (no Zip64, no encryption).
94
97
  *
95
98
  * @param {Buffer} buf
96
- * @returns {Map<string, Buffer>} name -> data
99
+ * @returns {Map<string, Buffer>} name -> uncompressed data
97
100
  */
98
101
  export function readZip(buf) {
99
102
  const out = new Map()
@@ -115,6 +118,7 @@ export function readZip(buf) {
115
118
  if (buf.readUInt32LE(p) !== CENTRAL_SIG) {
116
119
  throw new Error('uwx/zip: bad central directory signature')
117
120
  }
121
+ const method = buf.readUInt16LE(p + 10)
118
122
  const compSize = buf.readUInt32LE(p + 20)
119
123
  const nameLen = buf.readUInt16LE(p + 28)
120
124
  const extraLen = buf.readUInt16LE(p + 30)
@@ -127,7 +131,11 @@ export function readZip(buf) {
127
131
  const lNameLen = buf.readUInt16LE(localOff + 26)
128
132
  const lExtraLen = buf.readUInt16LE(localOff + 28)
129
133
  const dataStart = localOff + 30 + lNameLen + lExtraLen
130
- out.set(name, buf.subarray(dataStart, dataStart + compSize))
134
+ const raw = buf.subarray(dataStart, dataStart + compSize)
135
+ // Stored (0) → verbatim; Deflate (8) → inflate the raw deflate stream.
136
+ if (method === 0) out.set(name, raw)
137
+ else if (method === 8) out.set(name, inflateRawSync(raw))
138
+ else throw new Error(`uwx/zip: unsupported compression method ${method} for ${name}`)
131
139
 
132
140
  p += 46 + nameLen + extraLen + commentLen
133
141
  }