@liiift-studio/sanity-font-manager 2.5.3 → 2.5.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/dist/index.js +17679 -793
- package/dist/index.mjs +17404 -621
- package/package.json +1 -3
- package/src/index.js +4 -0
- package/src/utils/parseFont.js +33 -27
- package/src/utils/setupDecompressors.js +10 -0
- package/dist/UploadModal-NQZGBJAH.js +0 -7
- package/dist/UploadModal-YJCVHM63.mjs +0 -7
- package/dist/chunk-EBO3CZXG.mjs +0 -15
- package/dist/chunk-MCKGQKYU.js +0 -15
- package/dist/chunk-PGSHWNGW.js +0 -4250
- package/dist/chunk-WSQYNIIZ.mjs +0 -4250
- package/dist/unbrotli-CTU3FKHW.mjs +0 -3434
- package/dist/unbrotli-NSXTNE2T.js +0 -3434
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@liiift-studio/sanity-font-manager",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.5",
|
|
4
4
|
"description": "Sanity Studio plugin — full font management suite with batch upload, format conversion, metadata extraction, CSS generation, collection/pair generation, and script variant support. Supports Sanity v3, v4, and v5.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Liiift Studio",
|
|
@@ -51,9 +51,7 @@
|
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
53
|
"base-64": "^1.0.0",
|
|
54
|
-
"lib-font": "^3.0.1",
|
|
55
54
|
"nanoid": "^5.0.0",
|
|
56
|
-
"pako": "^2.1.0",
|
|
57
55
|
"slugify": "^1.6.6"
|
|
58
56
|
},
|
|
59
57
|
"peerDependencies": {
|
package/src/index.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
// Entry point for @liiift-studio/sanity-font-manager — exports all font manager components, hooks, and utilities
|
|
2
2
|
|
|
3
|
+
// Bootstrap decompressors FIRST — sets globalThis.pako and globalThis.unbrotli
|
|
4
|
+
// before lib-font can be evaluated by any bundler. This must be the first import.
|
|
5
|
+
import './utils/setupDecompressors.js';
|
|
6
|
+
|
|
3
7
|
// Components
|
|
4
8
|
export { BatchUploadFonts } from './components/BatchUploadFonts.jsx';
|
|
5
9
|
export { GenerateCollectionsPairsComponent } from './components/GenerateCollectionsPairsComponent.jsx';
|
package/src/utils/parseFont.js
CHANGED
|
@@ -1,26 +1,21 @@
|
|
|
1
|
-
// Async font parser —
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
// NOW safe to import lib-font — both globals are set
|
|
20
|
-
const mod = await import('lib-font');
|
|
21
|
-
_Font = mod.Font;
|
|
22
|
-
}
|
|
23
|
-
return _Font;
|
|
1
|
+
// Async font parser — ensures decompressor globals are set, with graceful WOFF2 fallback
|
|
2
|
+
|
|
3
|
+
import pako from 'pako';
|
|
4
|
+
import '../vendor/unbrotli.js';
|
|
5
|
+
import { Font } from 'lib-font';
|
|
6
|
+
|
|
7
|
+
// Immediately set globals — this runs at module evaluation time.
|
|
8
|
+
// lib-font's woff.js reads globalThis.pako and woff2.js reads globalThis.unbrotli
|
|
9
|
+
// at their top level. If this module evaluates before lib-font (which tsup guarantees
|
|
10
|
+
// since we import pako and unbrotli first), the globals will be set in time.
|
|
11
|
+
//
|
|
12
|
+
// When Vite re-bundles our package, it may reorder evaluation so lib-font's woff2.js
|
|
13
|
+
// captures globalThis.unbrotli as undefined. In that case, WOFF2 parsing will fail
|
|
14
|
+
// and buildUploadPlan falls back to TTF companion metadata.
|
|
15
|
+
globalThis.pako = pako;
|
|
16
|
+
// unbrotli.js UMD sets globalThis.unbrotli as a side effect — verify it worked
|
|
17
|
+
if (!globalThis.unbrotli) {
|
|
18
|
+
console.warn('[parseFont] globalThis.unbrotli not set after vendor import — WOFF2 parsing may fail. TTF/OTF files will still work.');
|
|
24
19
|
}
|
|
25
20
|
|
|
26
21
|
/** Maximum font file size accepted for parsing (50 MB) */
|
|
@@ -30,6 +25,11 @@ const MAX_FONT_FILE_SIZE = 50 * 1024 * 1024;
|
|
|
30
25
|
* Parse a font file from an ArrayBuffer.
|
|
31
26
|
* Returns a lib-font Font object with all tables accessible via font.opentype.tables.*.
|
|
32
27
|
*
|
|
28
|
+
* WOFF2 note: If the brotli decoder couldn't be initialized (common with Vite pre-bundling),
|
|
29
|
+
* WOFF2 files will fail to parse. The upload plan handles this gracefully — WOFF2 files
|
|
30
|
+
* that share a name with a TTF/OTF get metadata from the companion file. Standalone WOFF2
|
|
31
|
+
* uploads will show a clear error directing the user to also include TTF/OTF files.
|
|
32
|
+
*
|
|
33
33
|
* @param {ArrayBuffer} buffer - Raw font file bytes
|
|
34
34
|
* @param {string} filename - Original filename (used for format detection by lib-font)
|
|
35
35
|
* @returns {Promise<import('lib-font').Font>} Parsed lib-font Font object
|
|
@@ -40,12 +40,18 @@ export async function parseFont(buffer, filename) {
|
|
|
40
40
|
throw new Error(`Font file exceeds ${MAX_FONT_FILE_SIZE / 1024 / 1024}MB limit: ${filename} (${(buffer.byteLength / 1024 / 1024).toFixed(1)}MB)`);
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
const Font = await getFont();
|
|
44
|
-
|
|
45
43
|
return new Promise((resolve, reject) => {
|
|
46
44
|
const font = new Font('font', { skipStyleSheet: true });
|
|
47
45
|
font.onload = (evt) => resolve(evt.detail.font);
|
|
48
|
-
font.onerror = (evt) =>
|
|
49
|
-
|
|
46
|
+
font.onerror = (evt) => {
|
|
47
|
+
const msg = evt.detail?.message || `Failed to parse ${filename}`;
|
|
48
|
+
reject(new Error(msg));
|
|
49
|
+
};
|
|
50
|
+
try {
|
|
51
|
+
font.fromDataBuffer(buffer, filename);
|
|
52
|
+
} catch (err) {
|
|
53
|
+
// lib-font may throw synchronously from WOFF2 constructor if brotli decoder is missing
|
|
54
|
+
reject(new Error(`${filename}: ${err.message}`));
|
|
55
|
+
}
|
|
50
56
|
});
|
|
51
57
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// Sets up globalThis.pako and globalThis.unbrotli for lib-font WOFF/WOFF2 decompression.
|
|
2
|
+
// This module MUST be imported before lib-font is ever evaluated.
|
|
3
|
+
// It runs synchronously at module evaluation time to set the globals.
|
|
4
|
+
|
|
5
|
+
import pako from 'pako';
|
|
6
|
+
import '../vendor/unbrotli.js';
|
|
7
|
+
|
|
8
|
+
globalThis.pako = pako;
|
|
9
|
+
// unbrotli.js is a UMD that sets globalThis.unbrotli as a side effect on evaluation.
|
|
10
|
+
// The import above triggers that side effect.
|
package/dist/chunk-EBO3CZXG.mjs
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
2
|
-
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
3
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
4
|
-
}) : x)(function(x) {
|
|
5
|
-
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
6
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
7
|
-
});
|
|
8
|
-
var __commonJS = (cb, mod) => function __require2() {
|
|
9
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export {
|
|
13
|
-
__require,
|
|
14
|
-
__commonJS
|
|
15
|
-
};
|
package/dist/chunk-MCKGQKYU.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
2
|
-
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
3
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
4
|
-
}) : x)(function(x) {
|
|
5
|
-
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
6
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
7
|
-
});
|
|
8
|
-
var __commonJS = (cb, mod) => function __require2() {
|
|
9
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
exports.__require = __require; exports.__commonJS = __commonJS;
|