@newlogic-digital/core 4.1.5 → 4.1.6
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/package.json +1 -1
- package/src/fontsManifest.js +36 -9
package/package.json
CHANGED
package/src/fontsManifest.js
CHANGED
|
@@ -1,21 +1,48 @@
|
|
|
1
1
|
import { readFile, writeFile } from 'node:fs/promises'
|
|
2
2
|
import { join } from 'node:path'
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Parsuje unicode-range na číselné intervaly [start, end] - minifikátory zápis normalizují
|
|
6
|
+
* (Lightning CSS ve Vite 8 stripuje nuly a používá wildcardy, např. U+0000-00FF → U+??)
|
|
7
|
+
*
|
|
8
|
+
* @param {string} rule
|
|
9
|
+
* @returns {[number, number][]}
|
|
10
|
+
*/
|
|
11
|
+
const parseUnicodeRange = (rule) => {
|
|
12
|
+
const range = (rule.match(/unicode-range:([^;}]+)/i)?.[1] ?? '').toUpperCase()
|
|
13
|
+
|
|
14
|
+
return range.split(',').flatMap((token) => {
|
|
15
|
+
const match = token.trim().match(/^U\+([0-9A-F?]+)(?:-([0-9A-F]+))?$/)
|
|
16
|
+
|
|
17
|
+
if (!match) return []
|
|
18
|
+
if (match[1].includes('?')) {
|
|
19
|
+
return [[parseInt(match[1].replace(/\?/g, '0'), 16), parseInt(match[1].replace(/\?/g, 'F'), 16)]]
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return [[parseInt(match[1], 16), parseInt(match[2] ?? match[1], 16)]]
|
|
23
|
+
})
|
|
24
|
+
}
|
|
25
|
+
|
|
4
26
|
/**
|
|
5
27
|
* @param {string} rule
|
|
6
28
|
* @returns {string | null}
|
|
7
29
|
*/
|
|
8
30
|
const unicodeRangeSubset = (rule) => {
|
|
9
|
-
|
|
10
|
-
|
|
31
|
+
const ranges = parseUnicodeRange(rule)
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* @param {number} start
|
|
35
|
+
* @param {number} [end]
|
|
36
|
+
*/
|
|
37
|
+
const has = (start, end) => ranges.some(([rangeStart, rangeEnd]) => rangeStart === start && (end === undefined || rangeEnd === end))
|
|
11
38
|
|
|
12
|
-
if (
|
|
13
|
-
if (
|
|
14
|
-
if (
|
|
15
|
-
if (
|
|
16
|
-
if (
|
|
17
|
-
if (
|
|
18
|
-
if (
|
|
39
|
+
if (has(0x0000, 0x00FF)) return 'latin'
|
|
40
|
+
if (has(0x0102)) return 'vietnamese'
|
|
41
|
+
if (has(0x0100)) return 'latin-ext'
|
|
42
|
+
if (has(0x0400, 0x045F)) return 'cyrillic'
|
|
43
|
+
if (has(0x0460, 0x052F)) return 'cyrillic-ext'
|
|
44
|
+
if (has(0x1F00, 0x1FFF)) return 'greek-ext'
|
|
45
|
+
if (has(0x0370)) return 'greek'
|
|
19
46
|
|
|
20
47
|
return null
|
|
21
48
|
}
|