@hyperframes/parsers 0.8.225 → 0.8.227
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/dist/assetResolution.d.ts +3 -1
- package/dist/assetResolution.js +10 -1
- package/package.json +2 -2
|
@@ -68,7 +68,9 @@ type ProjectFileRead = {
|
|
|
68
68
|
} | {
|
|
69
69
|
kind: "missing";
|
|
70
70
|
};
|
|
71
|
+
declare function decodeTextHonoringBom(bytes: Buffer): string;
|
|
72
|
+
declare const readTextFile: (path: string) => string;
|
|
71
73
|
/** Reads through one descriptor, so the file-type check and the read see the same file. */
|
|
72
74
|
declare function readProjectFile(path: string): ProjectFileRead;
|
|
73
75
|
|
|
74
|
-
export { type ProjectFileRead, cleanAssetUrl, collectSubCompositionSrcs, hasUnresolvedTemplatingToken, isRemoteOrInlineUrl, isUnresolvedAssetPlaceholder, isWithinProjectRoot, maskNonScannableRanges, readProjectFile, resolveAuthoredAssetFile, resolveExistingLocalAsset, resolveLocalAssetCandidates, resolveProjectRelativeSrc };
|
|
76
|
+
export { type ProjectFileRead, cleanAssetUrl, collectSubCompositionSrcs, decodeTextHonoringBom, hasUnresolvedTemplatingToken, isRemoteOrInlineUrl, isUnresolvedAssetPlaceholder, isWithinProjectRoot, maskNonScannableRanges, readProjectFile, readTextFile, resolveAuthoredAssetFile, resolveExistingLocalAsset, resolveLocalAssetCandidates, resolveProjectRelativeSrc };
|
package/dist/assetResolution.js
CHANGED
|
@@ -258,6 +258,13 @@ function maskNonScannableRanges(html) {
|
|
|
258
258
|
out = maskRange(out, /<script\b[^>]*>[\s\S]*?<\/script\b[^>]*>/gi);
|
|
259
259
|
return out;
|
|
260
260
|
}
|
|
261
|
+
function decodeTextHonoringBom(bytes) {
|
|
262
|
+
if (bytes[0] === 255 && bytes[1] === 254) return bytes.subarray(2).toString("utf16le");
|
|
263
|
+
if (bytes[0] === 254 && bytes[1] === 255)
|
|
264
|
+
return Buffer.from(bytes.subarray(2, bytes.length - bytes.length % 2)).swap16().toString("utf16le");
|
|
265
|
+
return bytes.toString("utf-8").replace(/^\uFEFF/, "");
|
|
266
|
+
}
|
|
267
|
+
var readTextFile = (path) => decodeTextHonoringBom(readFileSync(path));
|
|
261
268
|
function readProjectFile(path) {
|
|
262
269
|
let fd;
|
|
263
270
|
try {
|
|
@@ -270,7 +277,7 @@ function readProjectFile(path) {
|
|
|
270
277
|
}
|
|
271
278
|
try {
|
|
272
279
|
if (!fstatSync(fd).isFile()) return { kind: "folder" };
|
|
273
|
-
return { kind: "file", text: readFileSync(fd
|
|
280
|
+
return { kind: "file", text: decodeTextHonoringBom(readFileSync(fd)) };
|
|
274
281
|
} finally {
|
|
275
282
|
closeSync(fd);
|
|
276
283
|
}
|
|
@@ -278,12 +285,14 @@ function readProjectFile(path) {
|
|
|
278
285
|
export {
|
|
279
286
|
cleanAssetUrl,
|
|
280
287
|
collectSubCompositionSrcs,
|
|
288
|
+
decodeTextHonoringBom,
|
|
281
289
|
hasUnresolvedTemplatingToken,
|
|
282
290
|
isRemoteOrInlineUrl,
|
|
283
291
|
isUnresolvedAssetPlaceholder,
|
|
284
292
|
isWithinProjectRoot,
|
|
285
293
|
maskNonScannableRanges,
|
|
286
294
|
readProjectFile,
|
|
295
|
+
readTextFile,
|
|
287
296
|
resolveAuthoredAssetFile,
|
|
288
297
|
resolveExistingLocalAsset,
|
|
289
298
|
resolveLocalAssetCandidates,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hyperframes/parsers",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.227",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/heygen-com/hyperframes",
|
|
@@ -139,7 +139,7 @@
|
|
|
139
139
|
"tsx": "^4.21.0",
|
|
140
140
|
"typescript": "^5.0.0",
|
|
141
141
|
"vitest": "^4.1.11",
|
|
142
|
-
"@hyperframes/core": "0.8.
|
|
142
|
+
"@hyperframes/core": "0.8.227"
|
|
143
143
|
},
|
|
144
144
|
"scripts": {
|
|
145
145
|
"build": "tsup",
|