@gjsify/string_decoder 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.
- package/README.md +27 -0
- package/lib/esm/index.js +402 -0
- package/lib/types/index.d.ts +24 -0
- package/package.json +41 -0
- package/src/index.spec.ts +423 -0
- package/src/index.ts +501 -0
- package/src/test.mts +6 -0
- package/tsconfig.json +31 -0
- package/tsconfig.tsbuildinfo +1 -0
package/README.md
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# @gjsify/string_decoder
|
|
2
|
+
|
|
3
|
+
GJS implementation of the Node.js `string_decoder` module. Supports UTF-8, Base64, hex, and streaming decoding.
|
|
4
|
+
|
|
5
|
+
Part of the [gjsify](https://github.com/gjsify/gjsify) project — Node.js and Web APIs for GJS (GNOME JavaScript).
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @gjsify/string_decoder
|
|
11
|
+
# or
|
|
12
|
+
yarn add @gjsify/string_decoder
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
import { StringDecoder } from '@gjsify/string_decoder';
|
|
19
|
+
|
|
20
|
+
const decoder = new StringDecoder('utf-8');
|
|
21
|
+
console.log(decoder.write(Buffer.from([0xe2, 0x82])));
|
|
22
|
+
console.log(decoder.end(Buffer.from([0xac])));
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## License
|
|
26
|
+
|
|
27
|
+
MIT
|
package/lib/esm/index.js
ADDED
|
@@ -0,0 +1,402 @@
|
|
|
1
|
+
import { normalizeEncoding, checkEncoding, base64Encode as bytesToBase64 } from "@gjsify/utils";
|
|
2
|
+
function normalizeAndValidateEncoding(enc) {
|
|
3
|
+
if (enc) checkEncoding(enc);
|
|
4
|
+
return normalizeEncoding(enc);
|
|
5
|
+
}
|
|
6
|
+
function utf8DecodeMaximalSubpart(bytes, start, end2) {
|
|
7
|
+
let result = "";
|
|
8
|
+
let i = start;
|
|
9
|
+
while (i < end2) {
|
|
10
|
+
const b0 = bytes[i];
|
|
11
|
+
if (b0 <= 127) {
|
|
12
|
+
result += String.fromCharCode(b0);
|
|
13
|
+
i++;
|
|
14
|
+
continue;
|
|
15
|
+
}
|
|
16
|
+
if (b0 >= 194 && b0 <= 223) {
|
|
17
|
+
if (i + 1 < end2 && bytes[i + 1] >= 128 && bytes[i + 1] <= 191) {
|
|
18
|
+
result += String.fromCharCode((b0 & 31) << 6 | bytes[i + 1] & 63);
|
|
19
|
+
i += 2;
|
|
20
|
+
} else {
|
|
21
|
+
result += "\uFFFD";
|
|
22
|
+
i++;
|
|
23
|
+
}
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
if (b0 >= 224 && b0 <= 239) {
|
|
27
|
+
let lo2, hi2;
|
|
28
|
+
if (b0 === 224) {
|
|
29
|
+
lo2 = 160;
|
|
30
|
+
hi2 = 191;
|
|
31
|
+
} else if (b0 === 237) {
|
|
32
|
+
lo2 = 128;
|
|
33
|
+
hi2 = 159;
|
|
34
|
+
} else {
|
|
35
|
+
lo2 = 128;
|
|
36
|
+
hi2 = 191;
|
|
37
|
+
}
|
|
38
|
+
if (i + 1 >= end2) {
|
|
39
|
+
result += "\uFFFD";
|
|
40
|
+
i++;
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
const b1 = bytes[i + 1];
|
|
44
|
+
if (b1 < lo2 || b1 > hi2) {
|
|
45
|
+
result += "\uFFFD";
|
|
46
|
+
i++;
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
if (i + 2 >= end2) {
|
|
50
|
+
result += "\uFFFD";
|
|
51
|
+
i += 2;
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
const b2 = bytes[i + 2];
|
|
55
|
+
if (b2 < 128 || b2 > 191) {
|
|
56
|
+
result += "\uFFFD";
|
|
57
|
+
i += 2;
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
const cp = (b0 & 15) << 12 | (b1 & 63) << 6 | b2 & 63;
|
|
61
|
+
result += String.fromCharCode(cp);
|
|
62
|
+
i += 3;
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
if (b0 >= 240 && b0 <= 244) {
|
|
66
|
+
let lo2, hi2;
|
|
67
|
+
if (b0 === 240) {
|
|
68
|
+
lo2 = 144;
|
|
69
|
+
hi2 = 191;
|
|
70
|
+
} else if (b0 === 244) {
|
|
71
|
+
lo2 = 128;
|
|
72
|
+
hi2 = 143;
|
|
73
|
+
} else {
|
|
74
|
+
lo2 = 128;
|
|
75
|
+
hi2 = 191;
|
|
76
|
+
}
|
|
77
|
+
if (i + 1 >= end2) {
|
|
78
|
+
result += "\uFFFD";
|
|
79
|
+
i++;
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
const b1 = bytes[i + 1];
|
|
83
|
+
if (b1 < lo2 || b1 > hi2) {
|
|
84
|
+
result += "\uFFFD";
|
|
85
|
+
i++;
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
if (i + 2 >= end2) {
|
|
89
|
+
result += "\uFFFD";
|
|
90
|
+
i += 2;
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
const b2 = bytes[i + 2];
|
|
94
|
+
if (b2 < 128 || b2 > 191) {
|
|
95
|
+
result += "\uFFFD";
|
|
96
|
+
i += 2;
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
if (i + 3 >= end2) {
|
|
100
|
+
result += "\uFFFD";
|
|
101
|
+
i += 3;
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
const b3 = bytes[i + 3];
|
|
105
|
+
if (b3 < 128 || b3 > 191) {
|
|
106
|
+
result += "\uFFFD";
|
|
107
|
+
i += 3;
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
const cp = (b0 & 7) << 18 | (b1 & 63) << 12 | (b2 & 63) << 6 | b3 & 63;
|
|
111
|
+
result += String.fromCharCode(
|
|
112
|
+
55296 + (cp - 65536 >> 10),
|
|
113
|
+
56320 + (cp - 65536 & 1023)
|
|
114
|
+
);
|
|
115
|
+
i += 4;
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
result += "\uFFFD";
|
|
119
|
+
i++;
|
|
120
|
+
}
|
|
121
|
+
return result;
|
|
122
|
+
}
|
|
123
|
+
function utf8CharLength(byte) {
|
|
124
|
+
if ((byte & 128) === 0) return 1;
|
|
125
|
+
if (byte >= 194 && byte <= 223) return 2;
|
|
126
|
+
if (byte >= 224 && byte <= 239) return 3;
|
|
127
|
+
if (byte >= 240 && byte <= 244) return 4;
|
|
128
|
+
return 0;
|
|
129
|
+
}
|
|
130
|
+
function isValidContinuation(leadByte, charLen, position, byte) {
|
|
131
|
+
if (position === 1) {
|
|
132
|
+
if (charLen === 3) {
|
|
133
|
+
if (leadByte === 224) return byte >= 160 && byte <= 191;
|
|
134
|
+
if (leadByte === 237) return byte >= 128 && byte <= 159;
|
|
135
|
+
return byte >= 128 && byte <= 191;
|
|
136
|
+
}
|
|
137
|
+
if (charLen === 4) {
|
|
138
|
+
if (leadByte === 240) return byte >= 144 && byte <= 191;
|
|
139
|
+
if (leadByte === 244) return byte >= 128 && byte <= 143;
|
|
140
|
+
return byte >= 128 && byte <= 191;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
return byte >= 128 && byte <= 191;
|
|
144
|
+
}
|
|
145
|
+
const StringDecoder = function StringDecoder2(encoding) {
|
|
146
|
+
this.encoding = normalizeAndValidateEncoding(encoding);
|
|
147
|
+
this._lastNeed = 0;
|
|
148
|
+
this._lastTotal = 0;
|
|
149
|
+
this._lastLeadByte = 0;
|
|
150
|
+
if (this.encoding === "utf8") {
|
|
151
|
+
this._lastChar = new Uint8Array(4);
|
|
152
|
+
} else if (this.encoding === "utf16le") {
|
|
153
|
+
this._lastChar = new Uint8Array(4);
|
|
154
|
+
} else if (this.encoding === "base64") {
|
|
155
|
+
this._lastChar = new Uint8Array(3);
|
|
156
|
+
} else {
|
|
157
|
+
this._lastChar = new Uint8Array(0);
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
StringDecoder.prototype.write = function write(buf) {
|
|
161
|
+
if (buf.length === 0) return "";
|
|
162
|
+
switch (this.encoding) {
|
|
163
|
+
case "utf8":
|
|
164
|
+
return writeUtf8(this, buf);
|
|
165
|
+
case "utf16le":
|
|
166
|
+
return writeUtf16le(this, buf);
|
|
167
|
+
case "base64":
|
|
168
|
+
return writeBase64(this, buf);
|
|
169
|
+
case "ascii":
|
|
170
|
+
return decodeAscii(buf);
|
|
171
|
+
case "latin1":
|
|
172
|
+
return decodeLatin1(buf);
|
|
173
|
+
case "hex":
|
|
174
|
+
return decodeHex(buf);
|
|
175
|
+
default:
|
|
176
|
+
return decodeAscii(buf);
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
StringDecoder.prototype.end = function end(buf) {
|
|
180
|
+
let result = "";
|
|
181
|
+
if (buf && buf.length > 0) {
|
|
182
|
+
result = this.write(buf);
|
|
183
|
+
}
|
|
184
|
+
if (this.encoding === "utf8" && this._lastNeed > 0) {
|
|
185
|
+
result += "\uFFFD";
|
|
186
|
+
this._lastNeed = 0;
|
|
187
|
+
this._lastTotal = 0;
|
|
188
|
+
} else if (this.encoding === "utf16le" && this._lastNeed > 0) {
|
|
189
|
+
const stored = this._lastTotal - this._lastNeed;
|
|
190
|
+
for (let i = 0; i + 1 < stored; i += 2) {
|
|
191
|
+
result += String.fromCharCode(this._lastChar[i] | this._lastChar[i + 1] << 8);
|
|
192
|
+
}
|
|
193
|
+
this._lastNeed = 0;
|
|
194
|
+
this._lastTotal = 0;
|
|
195
|
+
} else if (this.encoding === "base64" && this._lastNeed > 0) {
|
|
196
|
+
const remaining = this._lastChar.subarray(0, this._lastTotal - this._lastNeed);
|
|
197
|
+
result += bytesToBase64(remaining);
|
|
198
|
+
this._lastNeed = 0;
|
|
199
|
+
this._lastTotal = 0;
|
|
200
|
+
}
|
|
201
|
+
return result;
|
|
202
|
+
};
|
|
203
|
+
function writeUtf8(self, buf) {
|
|
204
|
+
let i = 0;
|
|
205
|
+
let result = "";
|
|
206
|
+
if (self._lastNeed > 0) {
|
|
207
|
+
while (i < buf.length && self._lastNeed > 0) {
|
|
208
|
+
const byte = buf[i];
|
|
209
|
+
const position = self._lastTotal - self._lastNeed;
|
|
210
|
+
if (isValidContinuation(self._lastLeadByte, self._lastTotal, position, byte)) {
|
|
211
|
+
self._lastChar[position] = byte;
|
|
212
|
+
self._lastNeed--;
|
|
213
|
+
i++;
|
|
214
|
+
} else {
|
|
215
|
+
result += "\uFFFD";
|
|
216
|
+
self._lastNeed = 0;
|
|
217
|
+
self._lastTotal = 0;
|
|
218
|
+
self._lastLeadByte = 0;
|
|
219
|
+
break;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
if (self._lastNeed === 0 && self._lastTotal > 0) {
|
|
223
|
+
result += utf8DecodeMaximalSubpart(self._lastChar, 0, self._lastTotal);
|
|
224
|
+
self._lastTotal = 0;
|
|
225
|
+
self._lastLeadByte = 0;
|
|
226
|
+
}
|
|
227
|
+
if (self._lastNeed > 0) {
|
|
228
|
+
return result;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
let completeEnd = buf.length;
|
|
232
|
+
for (let j = 0; j < Math.min(4, buf.length - i); j++) {
|
|
233
|
+
const idx = buf.length - 1 - j;
|
|
234
|
+
if (idx < i) break;
|
|
235
|
+
const byte = buf[idx];
|
|
236
|
+
if ((byte & 192) !== 128) {
|
|
237
|
+
const charLen = utf8CharLength(byte);
|
|
238
|
+
if (charLen > 0 && byte >= 128) {
|
|
239
|
+
const available = buf.length - idx;
|
|
240
|
+
if (available < charLen) {
|
|
241
|
+
let allValid = true;
|
|
242
|
+
for (let k = 1; k < available; k++) {
|
|
243
|
+
if (!isValidContinuation(byte, charLen, k, buf[idx + k])) {
|
|
244
|
+
allValid = false;
|
|
245
|
+
break;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
if (allValid) {
|
|
249
|
+
completeEnd = idx;
|
|
250
|
+
for (let k = 0; k < available; k++) {
|
|
251
|
+
self._lastChar[k] = buf[idx + k];
|
|
252
|
+
}
|
|
253
|
+
self._lastNeed = charLen - available;
|
|
254
|
+
self._lastTotal = charLen;
|
|
255
|
+
self._lastLeadByte = byte;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
break;
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
if (completeEnd > i) {
|
|
263
|
+
result += utf8DecodeMaximalSubpart(buf, i, completeEnd);
|
|
264
|
+
}
|
|
265
|
+
return result;
|
|
266
|
+
}
|
|
267
|
+
function writeUtf16le(self, buf) {
|
|
268
|
+
let result = "";
|
|
269
|
+
let i = 0;
|
|
270
|
+
if (self._lastNeed > 0) {
|
|
271
|
+
const offset = self._lastTotal - self._lastNeed;
|
|
272
|
+
const needed = Math.min(self._lastNeed, buf.length);
|
|
273
|
+
for (let j2 = 0; j2 < needed; j2++) {
|
|
274
|
+
self._lastChar[offset + j2] = buf[j2];
|
|
275
|
+
}
|
|
276
|
+
self._lastNeed -= needed;
|
|
277
|
+
i = needed;
|
|
278
|
+
if (self._lastNeed > 0) return "";
|
|
279
|
+
const stored = self._lastTotal;
|
|
280
|
+
let j = 0;
|
|
281
|
+
while (j + 1 < stored) {
|
|
282
|
+
const code = self._lastChar[j] | self._lastChar[j + 1] << 8;
|
|
283
|
+
j += 2;
|
|
284
|
+
if (code >= 55296 && code <= 56319) {
|
|
285
|
+
if (j + 1 < stored) {
|
|
286
|
+
const nextCode = self._lastChar[j] | self._lastChar[j + 1] << 8;
|
|
287
|
+
if (nextCode >= 56320 && nextCode <= 57343) {
|
|
288
|
+
result += String.fromCharCode(code, nextCode);
|
|
289
|
+
j += 2;
|
|
290
|
+
continue;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
if (i + 1 < buf.length) {
|
|
294
|
+
const nextCode = buf[i] | buf[i + 1] << 8;
|
|
295
|
+
if (nextCode >= 56320 && nextCode <= 57343) {
|
|
296
|
+
result += String.fromCharCode(code, nextCode);
|
|
297
|
+
i += 2;
|
|
298
|
+
continue;
|
|
299
|
+
}
|
|
300
|
+
} else if (i >= buf.length) {
|
|
301
|
+
self._lastChar[0] = self._lastChar[j - 2];
|
|
302
|
+
self._lastChar[1] = self._lastChar[j - 1];
|
|
303
|
+
self._lastNeed = 2;
|
|
304
|
+
self._lastTotal = 4;
|
|
305
|
+
return result;
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
result += String.fromCharCode(code);
|
|
309
|
+
}
|
|
310
|
+
self._lastTotal = 0;
|
|
311
|
+
}
|
|
312
|
+
while (i + 1 < buf.length) {
|
|
313
|
+
const code = buf[i] | buf[i + 1] << 8;
|
|
314
|
+
i += 2;
|
|
315
|
+
if (code >= 55296 && code <= 56319) {
|
|
316
|
+
if (i + 1 < buf.length) {
|
|
317
|
+
const nextCode = buf[i] | buf[i + 1] << 8;
|
|
318
|
+
if (nextCode >= 56320 && nextCode <= 57343) {
|
|
319
|
+
result += String.fromCharCode(code, nextCode);
|
|
320
|
+
i += 2;
|
|
321
|
+
continue;
|
|
322
|
+
}
|
|
323
|
+
} else if (i < buf.length) {
|
|
324
|
+
result += String.fromCharCode(code);
|
|
325
|
+
self._lastChar[0] = buf[i];
|
|
326
|
+
self._lastNeed = 1;
|
|
327
|
+
self._lastTotal = 2;
|
|
328
|
+
return result;
|
|
329
|
+
} else {
|
|
330
|
+
self._lastChar[0] = buf[i - 2];
|
|
331
|
+
self._lastChar[1] = buf[i - 1];
|
|
332
|
+
self._lastNeed = 2;
|
|
333
|
+
self._lastTotal = 4;
|
|
334
|
+
return result;
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
result += String.fromCharCode(code);
|
|
338
|
+
}
|
|
339
|
+
if (i < buf.length) {
|
|
340
|
+
self._lastChar[0] = buf[i];
|
|
341
|
+
self._lastNeed = 1;
|
|
342
|
+
self._lastTotal = 2;
|
|
343
|
+
}
|
|
344
|
+
return result;
|
|
345
|
+
}
|
|
346
|
+
function writeBase64(self, buf) {
|
|
347
|
+
let start = 0;
|
|
348
|
+
if (self._lastNeed > 0) {
|
|
349
|
+
const needed = Math.min(self._lastNeed, buf.length);
|
|
350
|
+
for (let i = 0; i < needed; i++) {
|
|
351
|
+
self._lastChar[self._lastTotal - self._lastNeed + i] = buf[i];
|
|
352
|
+
self._lastNeed--;
|
|
353
|
+
}
|
|
354
|
+
start = needed;
|
|
355
|
+
if (self._lastNeed > 0) return "";
|
|
356
|
+
}
|
|
357
|
+
const remaining = buf.length - start;
|
|
358
|
+
const complete = remaining - remaining % 3;
|
|
359
|
+
let result = "";
|
|
360
|
+
if (self._lastTotal > 0 && self._lastNeed === 0) {
|
|
361
|
+
result += bytesToBase64(self._lastChar.subarray(0, self._lastTotal));
|
|
362
|
+
self._lastTotal = 0;
|
|
363
|
+
}
|
|
364
|
+
if (complete > 0) {
|
|
365
|
+
result += bytesToBase64(buf.subarray(start, start + complete));
|
|
366
|
+
}
|
|
367
|
+
const leftover = remaining - complete;
|
|
368
|
+
if (leftover > 0) {
|
|
369
|
+
for (let i = 0; i < leftover; i++) {
|
|
370
|
+
self._lastChar[i] = buf[start + complete + i];
|
|
371
|
+
}
|
|
372
|
+
self._lastNeed = 3 - leftover;
|
|
373
|
+
self._lastTotal = 3;
|
|
374
|
+
}
|
|
375
|
+
return result;
|
|
376
|
+
}
|
|
377
|
+
function decodeAscii(buf) {
|
|
378
|
+
let result = "";
|
|
379
|
+
for (let i = 0; i < buf.length; i++) {
|
|
380
|
+
result += String.fromCharCode(buf[i] & 127);
|
|
381
|
+
}
|
|
382
|
+
return result;
|
|
383
|
+
}
|
|
384
|
+
function decodeLatin1(buf) {
|
|
385
|
+
let result = "";
|
|
386
|
+
for (let i = 0; i < buf.length; i++) {
|
|
387
|
+
result += String.fromCharCode(buf[i]);
|
|
388
|
+
}
|
|
389
|
+
return result;
|
|
390
|
+
}
|
|
391
|
+
function decodeHex(buf) {
|
|
392
|
+
let result = "";
|
|
393
|
+
for (let i = 0; i < buf.length; i++) {
|
|
394
|
+
result += buf[i].toString(16).padStart(2, "0");
|
|
395
|
+
}
|
|
396
|
+
return result;
|
|
397
|
+
}
|
|
398
|
+
var index_default = { StringDecoder };
|
|
399
|
+
export {
|
|
400
|
+
StringDecoder,
|
|
401
|
+
index_default as default
|
|
402
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
interface StringDecoderInstance {
|
|
2
|
+
readonly encoding: string;
|
|
3
|
+
write(buf: Uint8Array): string;
|
|
4
|
+
end(buf?: Uint8Array): string;
|
|
5
|
+
}
|
|
6
|
+
interface StringDecoderConstructor {
|
|
7
|
+
new (encoding?: string): StringDecoderInstance;
|
|
8
|
+
(this: StringDecoderInstance, encoding?: string): void;
|
|
9
|
+
prototype: StringDecoderInstance;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* StringDecoder provides an interface for efficiently decoding Buffer data
|
|
13
|
+
* into strings while preserving multi-byte characters that are split across
|
|
14
|
+
* Buffer boundaries.
|
|
15
|
+
*
|
|
16
|
+
* Implemented as a function constructor (not ES6 class) for compatibility
|
|
17
|
+
* with legacy CJS patterns that use StringDecoder.call(this, enc).
|
|
18
|
+
*/
|
|
19
|
+
declare const StringDecoder: StringDecoderConstructor;
|
|
20
|
+
export { StringDecoder };
|
|
21
|
+
declare const _default: {
|
|
22
|
+
StringDecoder: StringDecoderConstructor;
|
|
23
|
+
};
|
|
24
|
+
export default _default;
|
package/package.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@gjsify/string_decoder",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Node.js string_decoder module for Gjs",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"module": "lib/esm/index.js",
|
|
7
|
+
"types": "lib/types/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./lib/types/index.d.ts",
|
|
11
|
+
"default": "./lib/esm/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"scripts": {
|
|
15
|
+
"clear": "rm -rf lib tsconfig.tsbuildinfo tsconfig.types.tsbuildinfo test.gjs.mjs test.node.mjs || exit 0",
|
|
16
|
+
"check": "tsc --noEmit",
|
|
17
|
+
"build": "yarn build:gjsify && yarn build:types",
|
|
18
|
+
"build:gjsify": "gjsify build --library 'src/**/*.{ts,js}' --exclude 'src/**/*.spec.{mts,ts}' 'src/test.{mts,ts}'",
|
|
19
|
+
"build:types": "tsc",
|
|
20
|
+
"build:test": "yarn build:test:gjs && yarn build:test:node",
|
|
21
|
+
"build:test:gjs": "gjsify build src/test.mts --app gjs --outfile test.gjs.mjs",
|
|
22
|
+
"build:test:node": "gjsify build src/test.mts --app node --outfile test.node.mjs",
|
|
23
|
+
"test": "yarn build:gjsify && yarn build:test && yarn test:node && yarn test:gjs",
|
|
24
|
+
"test:gjs": "gjs -m test.gjs.mjs",
|
|
25
|
+
"test:node": "node test.node.mjs"
|
|
26
|
+
},
|
|
27
|
+
"keywords": [
|
|
28
|
+
"gjs",
|
|
29
|
+
"node",
|
|
30
|
+
"string_decoder"
|
|
31
|
+
],
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@gjsify/cli": "^0.1.0",
|
|
34
|
+
"@gjsify/unit": "^0.1.0",
|
|
35
|
+
"@types/node": "^25.5.0",
|
|
36
|
+
"typescript": "^6.0.2"
|
|
37
|
+
},
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"@gjsify/utils": "^0.1.0"
|
|
40
|
+
}
|
|
41
|
+
}
|