@arcblock/did-connect-service 4.1.59 → 4.1.61
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/og/font-fallback.d.ts +135 -0
- package/dist/og/font-fallback.d.ts.map +1 -0
- package/dist/og/font-fallback.js +229 -0
- package/dist/og/font-fallback.js.map +1 -0
- package/dist/og/font-subset.d.ts +14 -6
- package/dist/og/font-subset.d.ts.map +1 -1
- package/dist/og/font-subset.js +22 -15
- package/dist/og/font-subset.js.map +1 -1
- package/dist/og/generator.d.ts +2 -2
- package/dist/og/generator.d.ts.map +1 -1
- package/dist/og/generator.js +64 -10
- package/dist/og/generator.js.map +1 -1
- package/dist/og/node-font-files.d.ts +93 -0
- package/dist/og/node-font-files.d.ts.map +1 -0
- package/dist/og/node-font-files.js +298 -0
- package/dist/og/node-font-files.js.map +1 -0
- package/dist/og/subset-fonts.generated.d.ts +40 -6
- package/dist/og/subset-fonts.generated.d.ts.map +1 -1
- package/dist/og/subset-fonts.generated.js +24 -19
- package/dist/og/subset-fonts.generated.js.map +1 -1
- package/dist/og/tree-node.d.ts +14 -10
- package/dist/og/tree-node.d.ts.map +1 -1
- package/dist/og/tree-node.js +45 -111
- package/dist/og/tree-node.js.map +1 -1
- package/dist/og/worker.d.ts +44 -5
- package/dist/og/worker.d.ts.map +1 -1
- package/dist/og/worker.js +301 -94
- package/dist/og/worker.js.map +1 -1
- package/package.json +3 -3
- package/dist/http/security-headers.d.ts +0 -38
- package/dist/http/security-headers.d.ts.map +0 -1
- package/dist/http/security-headers.js +0 -67
- package/dist/http/security-headers.js.map +0 -1
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cross-script CJK fallback fonts (ArcBlock/arc#8832).
|
|
3
|
+
*
|
|
4
|
+
* A card's primary font is the viewer locale's regional face (Noto Sans SC /
|
|
5
|
+
* TC / JP, or Noto Sans for Latin locales) so a shared character keeps that
|
|
6
|
+
* region's glyph form. The card's TEXT is whatever the author wrote, so it can
|
|
7
|
+
* hold characters the primary font does not have at all (a Simplified title on
|
|
8
|
+
* a zh-TW card, 歩 on a zh-TW card, kana on an en card). For those, the render
|
|
9
|
+
* adds other CJK families after the primary: satori draws each character with
|
|
10
|
+
* the first font in its `fonts` list that maps it (per glyph, see
|
|
11
|
+
* og-font-fallback.test.ts), so the primary still draws everything it has.
|
|
12
|
+
*
|
|
13
|
+
* The rule (deterministic, from the text alone):
|
|
14
|
+
* 1. `missing` = codepoints of the render that the primary's FULL font does not
|
|
15
|
+
* map (default-ignorable / control codepoints excluded: they draw nothing).
|
|
16
|
+
* 2. Every order of the fallback families (the CJK families other than the
|
|
17
|
+
* primary's; Latin is never a fallback) is evaluated: each family in turn
|
|
18
|
+
* takes the `missing` codepoints its full font maps and that no earlier
|
|
19
|
+
* family took. A family that takes nothing is not loaded. A family is
|
|
20
|
+
* loaded as its subset when the subset maps everything it takes, else as
|
|
21
|
+
* its full font (identical glyphs either way).
|
|
22
|
+
* 3. The order that loads the fewest font bytes wins (bytes ≈ parse CPU and
|
|
23
|
+
* memory). Ties go to the preference order {@link OG_CJK_FALLBACK_PREFERENCE}
|
|
24
|
+
* (zh-CN → ja → zh-TW); when `missing` holds kana, ja must come first (kana
|
|
25
|
+
* drawn with Japanese forms).
|
|
26
|
+
* 4. The whole font set of the render must fit the budget: its raw bytes
|
|
27
|
+
* (primary + fallbacks, every weight loaded) within
|
|
28
|
+
* {@link OG_FONT_RENDER_BUDGET_BYTES}, at most ONE full CJK family, and —
|
|
29
|
+
* when one is full — at most two CJK families (the Latin primary does not
|
|
30
|
+
* count). Each full family costs ~20 MB of parse heap whatever its size, so
|
|
31
|
+
* bytes alone under-count it (measurements in the PR, arc#8832). The
|
|
32
|
+
* cheapest order that fits wins. When no order fits, the fallback whose cut
|
|
33
|
+
* leaves the fewest characters undrawn is cut back and the plan recomputed:
|
|
34
|
+
* a full font is first limited to its subset (it then takes only what its
|
|
35
|
+
* subset maps), a subset is dropped. Either way the family is reported in `overBudget`; the
|
|
36
|
+
* characters it no longer takes go to a later family that maps them, or
|
|
37
|
+
* stay `.notdef`. The primary itself is never refused.
|
|
38
|
+
* Codepoints no family maps (emoji, Hangul — no Korean face) stay `.notdef`,
|
|
39
|
+
* as before. A tree whose text cannot be read reliably gets no fallbacks.
|
|
40
|
+
*
|
|
41
|
+
* Primary subset vs full ({@link ogPrimaryUsesSubset}, ArcBlock/arc#8832):
|
|
42
|
+
* the primary loads its subset when the subset draws every character the full
|
|
43
|
+
* font would (unchanged). A CJK primary whose text needs fallbacks ANYWAY also
|
|
44
|
+
* loads its subset when the characters only its full font has (`gaps`, e.g. 体
|
|
45
|
+
* on a zh-TW card: Noto Sans TC maps it, its subset does not) are all drawn by
|
|
46
|
+
* those fallbacks' SUBSETS — then each gap is drawn by the first fallback that
|
|
47
|
+
* maps it (that family's glyph form, like the rest of the text it came with),
|
|
48
|
+
* provided no character is left undrawn that the full primary would have
|
|
49
|
+
* drawn, no family is loaded only for gaps, and the whole set loads fewer
|
|
50
|
+
* bytes. Without that, a cross-script text loaded the full primary (TC: 11 MB
|
|
51
|
+
* Regular + Bold), which used up rule 4's one full CJK family so a needed
|
|
52
|
+
* fallback (JP for 歩 気 図) was cut. Single-script text never needs a
|
|
53
|
+
* fallback, so it keeps its fonts and pixels.
|
|
54
|
+
*/
|
|
55
|
+
import { type OgSubsetFontSet } from "./font-subset.js";
|
|
56
|
+
/** A CJK family that can serve as a fallback (key in the subset table / font maps). */
|
|
57
|
+
export type OgCjkFamily = "zh-CN" | "ja" | "zh-TW";
|
|
58
|
+
/** Tie-break order among fallback families (see the module comment). */
|
|
59
|
+
export declare const OG_CJK_FALLBACK_PREFERENCE: readonly OgCjkFamily[];
|
|
60
|
+
/**
|
|
61
|
+
* Upper bound on the raw bytes of one render's whole font set (primary +
|
|
62
|
+
* fallbacks, Regular + Bold as loaded) once it has fallbacks. Satori parses
|
|
63
|
+
* every font of the set per render; a render holds the raw bytes, a copy, the
|
|
64
|
+
* parse (≈ 20 MB of V8 heap per full CJK family, ≈ 6–8 MB per subset) and
|
|
65
|
+
* ~20 MB of wasm. The budget is the heaviest set renders already use — full
|
|
66
|
+
* Noto Sans SC Regular + Bold, 16.1 MiB — plus a little, so together with the
|
|
67
|
+
* family limits of rule 4 a fallback never makes a render heavier than the
|
|
68
|
+
* heaviest card today (measured, see the PR for arc#8832).
|
|
69
|
+
*/
|
|
70
|
+
export declare const OG_FONT_RENDER_BUDGET_BYTES: number;
|
|
71
|
+
export interface OgFallbackCandidate {
|
|
72
|
+
family: OgCjkFamily;
|
|
73
|
+
set: OgSubsetFontSet;
|
|
74
|
+
}
|
|
75
|
+
export interface OgFallbackChoice extends OgFallbackCandidate {
|
|
76
|
+
/** Load the family's subset (true) or its full font (false). */
|
|
77
|
+
subset: boolean;
|
|
78
|
+
/** Raw bytes this choice loads (Regular, + Bold when bold is wanted). */
|
|
79
|
+
bytes: number;
|
|
80
|
+
/** The codepoints this family draws. */
|
|
81
|
+
codepoints: number[];
|
|
82
|
+
}
|
|
83
|
+
export interface OgFontPlan {
|
|
84
|
+
/** Fallback families in satori `fonts` order (after the primary). */
|
|
85
|
+
fallbacks: OgFallbackChoice[];
|
|
86
|
+
/** Families cut back (limited to their subset, or dropped) to stay within the budget. */
|
|
87
|
+
overBudget: OgCjkFamily[];
|
|
88
|
+
}
|
|
89
|
+
/** Codepoints that draw nothing by themselves — never a reason to load a font. */
|
|
90
|
+
export declare function ogFallbackIgnorable(cp: number): boolean;
|
|
91
|
+
/** Raw bytes of `set`'s subset (or full) objects for the weights a render loads. */
|
|
92
|
+
export declare function ogFontSetBytes(set: OgSubsetFontSet, subset: boolean, bold: boolean): number;
|
|
93
|
+
/** Rule 4: does the primary plus `fallbacks` fit the budget? */
|
|
94
|
+
export declare function ogFontSetFits(primary: {
|
|
95
|
+
primaryBytes: number;
|
|
96
|
+
primaryFull?: boolean;
|
|
97
|
+
primaryCjk?: boolean;
|
|
98
|
+
}, fallbacks: ReadonlyArray<{
|
|
99
|
+
subset: boolean;
|
|
100
|
+
bytes: number;
|
|
101
|
+
}>, budgetBytes?: number): boolean;
|
|
102
|
+
export interface OgFontPlanInput {
|
|
103
|
+
primary: OgSubsetFontSet;
|
|
104
|
+
primaryBytes: number;
|
|
105
|
+
/**
|
|
106
|
+
* The primary loads its full font (`true`) or its subset (`false`). With a
|
|
107
|
+
* CJK primary loaded as its subset, the characters only its full font maps
|
|
108
|
+
* (its gaps) are offered to the fallbacks' subsets too. Unset: neither.
|
|
109
|
+
*/
|
|
110
|
+
primaryFull?: boolean;
|
|
111
|
+
/** The primary is a CJK family (not the Latin face). */
|
|
112
|
+
primaryCjk?: boolean;
|
|
113
|
+
codepoints: ReadonlySet<number>;
|
|
114
|
+
candidates: readonly OgFallbackCandidate[];
|
|
115
|
+
bold: boolean;
|
|
116
|
+
budgetBytes?: number;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Plans the fallback fonts of one render (see the module comment for the rule).
|
|
120
|
+
* `primaryBytes` is what the primary loads (subset or full, every weight);
|
|
121
|
+
* `candidates` are the fallback families available to this renderer.
|
|
122
|
+
*/
|
|
123
|
+
export declare function planOgFontFallbacks(input: OgFontPlanInput): OgFontPlan;
|
|
124
|
+
/**
|
|
125
|
+
* Whether a render's primary loads its subset (see the module comment): when
|
|
126
|
+
* the subset draws every character exactly like the full font, or — for a CJK
|
|
127
|
+
* primary whose text needs fallbacks anyway — when those fallbacks' subsets
|
|
128
|
+
* draw every character only the full primary has, without leaving any
|
|
129
|
+
* character undrawn that the full primary's plan draws, without a family
|
|
130
|
+
* loaded only for those characters, and for fewer bytes. Inputs as
|
|
131
|
+
* {@link planOgFontFallbacks} (minus `primaryBytes` / `primaryFull`, which
|
|
132
|
+
* follow from the answer).
|
|
133
|
+
*/
|
|
134
|
+
export declare function ogPrimaryUsesSubset(input: Omit<OgFontPlanInput, "primaryBytes" | "primaryFull">): boolean;
|
|
135
|
+
//# sourceMappingURL=font-fallback.d.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AO,CAAA;CAAE,EAC9E,SAAS,EAAE,aAAa,CAAC;IAAE,MAAM,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,EAC5D,WAAW,GAAE,MAAoC,GAChD,OAAO,CAKT;AA+BD,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,eAAe,CAAC;IACzB,YAAY,EAAE,MAAM,CAAC;IACrB;;;;OAIG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,wDAAwD;IACxD,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,UAAU,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAChC,UAAU,EAAE,SAAS,mBAAmB,EAAE,CAAC;IAC3C,IAAI,EAAE,OAAO,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AASD;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,eAAe,GAAG,UAAU,CA4CtE;AAED;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,IAAI,CAAC,eAAe,EAAE,cAAc,GAAG,aAAa,CAAC,GAAG,OAAO,CAuBzG"}
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cross-script CJK fallback fonts (ArcBlock/arc#8832).
|
|
3
|
+
*
|
|
4
|
+
* A card's primary font is the viewer locale's regional face (Noto Sans SC /
|
|
5
|
+
* TC / JP, or Noto Sans for Latin locales) so a shared character keeps that
|
|
6
|
+
* region's glyph form. The card's TEXT is whatever the author wrote, so it can
|
|
7
|
+
* hold characters the primary font does not have at all (a Simplified title on
|
|
8
|
+
* a zh-TW card, 歩 on a zh-TW card, kana on an en card). For those, the render
|
|
9
|
+
* adds other CJK families after the primary: satori draws each character with
|
|
10
|
+
* the first font in its `fonts` list that maps it (per glyph, see
|
|
11
|
+
* og-font-fallback.test.ts), so the primary still draws everything it has.
|
|
12
|
+
*
|
|
13
|
+
* The rule (deterministic, from the text alone):
|
|
14
|
+
* 1. `missing` = codepoints of the render that the primary's FULL font does not
|
|
15
|
+
* map (default-ignorable / control codepoints excluded: they draw nothing).
|
|
16
|
+
* 2. Every order of the fallback families (the CJK families other than the
|
|
17
|
+
* primary's; Latin is never a fallback) is evaluated: each family in turn
|
|
18
|
+
* takes the `missing` codepoints its full font maps and that no earlier
|
|
19
|
+
* family took. A family that takes nothing is not loaded. A family is
|
|
20
|
+
* loaded as its subset when the subset maps everything it takes, else as
|
|
21
|
+
* its full font (identical glyphs either way).
|
|
22
|
+
* 3. The order that loads the fewest font bytes wins (bytes ≈ parse CPU and
|
|
23
|
+
* memory). Ties go to the preference order {@link OG_CJK_FALLBACK_PREFERENCE}
|
|
24
|
+
* (zh-CN → ja → zh-TW); when `missing` holds kana, ja must come first (kana
|
|
25
|
+
* drawn with Japanese forms).
|
|
26
|
+
* 4. The whole font set of the render must fit the budget: its raw bytes
|
|
27
|
+
* (primary + fallbacks, every weight loaded) within
|
|
28
|
+
* {@link OG_FONT_RENDER_BUDGET_BYTES}, at most ONE full CJK family, and —
|
|
29
|
+
* when one is full — at most two CJK families (the Latin primary does not
|
|
30
|
+
* count). Each full family costs ~20 MB of parse heap whatever its size, so
|
|
31
|
+
* bytes alone under-count it (measurements in the PR, arc#8832). The
|
|
32
|
+
* cheapest order that fits wins. When no order fits, the fallback whose cut
|
|
33
|
+
* leaves the fewest characters undrawn is cut back and the plan recomputed:
|
|
34
|
+
* a full font is first limited to its subset (it then takes only what its
|
|
35
|
+
* subset maps), a subset is dropped. Either way the family is reported in `overBudget`; the
|
|
36
|
+
* characters it no longer takes go to a later family that maps them, or
|
|
37
|
+
* stay `.notdef`. The primary itself is never refused.
|
|
38
|
+
* Codepoints no family maps (emoji, Hangul — no Korean face) stay `.notdef`,
|
|
39
|
+
* as before. A tree whose text cannot be read reliably gets no fallbacks.
|
|
40
|
+
*
|
|
41
|
+
* Primary subset vs full ({@link ogPrimaryUsesSubset}, ArcBlock/arc#8832):
|
|
42
|
+
* the primary loads its subset when the subset draws every character the full
|
|
43
|
+
* font would (unchanged). A CJK primary whose text needs fallbacks ANYWAY also
|
|
44
|
+
* loads its subset when the characters only its full font has (`gaps`, e.g. 体
|
|
45
|
+
* on a zh-TW card: Noto Sans TC maps it, its subset does not) are all drawn by
|
|
46
|
+
* those fallbacks' SUBSETS — then each gap is drawn by the first fallback that
|
|
47
|
+
* maps it (that family's glyph form, like the rest of the text it came with),
|
|
48
|
+
* provided no character is left undrawn that the full primary would have
|
|
49
|
+
* drawn, no family is loaded only for gaps, and the whole set loads fewer
|
|
50
|
+
* bytes. Without that, a cross-script text loaded the full primary (TC: 11 MB
|
|
51
|
+
* Regular + Bold), which used up rule 4's one full CJK family so a needed
|
|
52
|
+
* fallback (JP for 歩 気 図) was cut. Single-script text never needs a
|
|
53
|
+
* fallback, so it keeps its fonts and pixels.
|
|
54
|
+
*/
|
|
55
|
+
import { ogFullFontMaps, ogSubsetCovers, ogSubsetFontMaps } from "./font-subset.js";
|
|
56
|
+
/** Tie-break order among fallback families (see the module comment). */
|
|
57
|
+
export const OG_CJK_FALLBACK_PREFERENCE = ["zh-CN", "ja", "zh-TW"];
|
|
58
|
+
/**
|
|
59
|
+
* Upper bound on the raw bytes of one render's whole font set (primary +
|
|
60
|
+
* fallbacks, Regular + Bold as loaded) once it has fallbacks. Satori parses
|
|
61
|
+
* every font of the set per render; a render holds the raw bytes, a copy, the
|
|
62
|
+
* parse (≈ 20 MB of V8 heap per full CJK family, ≈ 6–8 MB per subset) and
|
|
63
|
+
* ~20 MB of wasm. The budget is the heaviest set renders already use — full
|
|
64
|
+
* Noto Sans SC Regular + Bold, 16.1 MiB — plus a little, so together with the
|
|
65
|
+
* family limits of rule 4 a fallback never makes a render heavier than the
|
|
66
|
+
* heaviest card today (measured, see the PR for arc#8832).
|
|
67
|
+
*/
|
|
68
|
+
export const OG_FONT_RENDER_BUDGET_BYTES = 17 * 1024 * 1024;
|
|
69
|
+
const NO_FALLBACKS = { fallbacks: [], overBudget: [] };
|
|
70
|
+
/** Codepoints that draw nothing by themselves — never a reason to load a font. */
|
|
71
|
+
export function ogFallbackIgnorable(cp) {
|
|
72
|
+
return (cp < 0x20 ||
|
|
73
|
+
(cp >= 0x7f && cp <= 0x9f) ||
|
|
74
|
+
cp === 0xad ||
|
|
75
|
+
(cp >= 0x200b && cp <= 0x200f) ||
|
|
76
|
+
(cp >= 0x2028 && cp <= 0x202e) ||
|
|
77
|
+
(cp >= 0x2060 && cp <= 0x206f) ||
|
|
78
|
+
(cp >= 0xfe00 && cp <= 0xfe0f) ||
|
|
79
|
+
cp === 0xfeff ||
|
|
80
|
+
(cp >= 0xe0000 && cp <= 0xe0fff));
|
|
81
|
+
}
|
|
82
|
+
function isKana(cp) {
|
|
83
|
+
return (cp >= 0x3040 && cp <= 0x30ff) || (cp >= 0x31f0 && cp <= 0x31ff) || (cp >= 0xff66 && cp <= 0xff9f);
|
|
84
|
+
}
|
|
85
|
+
/** Raw bytes of `set`'s subset (or full) objects for the weights a render loads. */
|
|
86
|
+
export function ogFontSetBytes(set, subset, bold) {
|
|
87
|
+
if (subset)
|
|
88
|
+
return set.regular.bytes + (bold && set.bold ? set.bold.bytes : 0);
|
|
89
|
+
return set.fullBytes.regular + (bold ? (set.fullBytes.bold ?? 0) : 0);
|
|
90
|
+
}
|
|
91
|
+
/** True when `set`'s subset can stand in for its full font for `codepoints`, in every weight loaded. */
|
|
92
|
+
function subsetServes(set, codepoints, bold) {
|
|
93
|
+
if (bold && !set.bold)
|
|
94
|
+
return false;
|
|
95
|
+
return codepoints.every((cp) => ogSubsetFontMaps(set, cp));
|
|
96
|
+
}
|
|
97
|
+
/** Rule 4: does the primary plus `fallbacks` fit the budget? */
|
|
98
|
+
export function ogFontSetFits(primary, fallbacks, budgetBytes = OG_FONT_RENDER_BUDGET_BYTES) {
|
|
99
|
+
const bytes = fallbacks.reduce((sum, f) => sum + f.bytes, primary.primaryBytes);
|
|
100
|
+
const fulls = fallbacks.filter((f) => !f.subset).length + (primary.primaryFull && primary.primaryCjk ? 1 : 0);
|
|
101
|
+
const families = fallbacks.length + (primary.primaryCjk ? 1 : 0);
|
|
102
|
+
return bytes <= budgetBytes && fulls <= 1 && (fulls === 0 || families <= 2);
|
|
103
|
+
}
|
|
104
|
+
function permutations(items) {
|
|
105
|
+
if (items.length <= 1)
|
|
106
|
+
return [items.slice()];
|
|
107
|
+
return items.flatMap((item, i) => permutations([...items.slice(0, i), ...items.slice(i + 1)]).map((rest) => [item, ...rest]));
|
|
108
|
+
}
|
|
109
|
+
function assign(order, missing, gaps, bold) {
|
|
110
|
+
let remaining = missing;
|
|
111
|
+
const choices = [];
|
|
112
|
+
let bytes = 0;
|
|
113
|
+
for (const { subsetOnly, ...candidate } of order) {
|
|
114
|
+
// A primary gap is taken only by a family's subset (see the module comment).
|
|
115
|
+
const maps = (cp) => ogFullFontMaps(candidate.set, cp) && (!(subsetOnly || gaps.has(cp)) || ogSubsetFontMaps(candidate.set, cp));
|
|
116
|
+
const taken = remaining.filter(maps);
|
|
117
|
+
if (!taken.length)
|
|
118
|
+
continue;
|
|
119
|
+
remaining = remaining.filter((cp) => !maps(cp));
|
|
120
|
+
const subset = subsetOnly || subsetServes(candidate.set, taken, bold);
|
|
121
|
+
const choiceBytes = ogFontSetBytes(candidate.set, subset, bold);
|
|
122
|
+
choices.push({ ...candidate, subset, bytes: choiceBytes, codepoints: taken });
|
|
123
|
+
bytes += choiceBytes;
|
|
124
|
+
}
|
|
125
|
+
return { choices, bytes };
|
|
126
|
+
}
|
|
127
|
+
/** Codepoints of `codepoints` the primary's full font maps but its subset does not. */
|
|
128
|
+
function primaryGaps(primary, codepoints) {
|
|
129
|
+
const gaps = new Set();
|
|
130
|
+
for (const cp of codepoints)
|
|
131
|
+
if (ogFullFontMaps(primary, cp) && !ogSubsetFontMaps(primary, cp))
|
|
132
|
+
gaps.add(cp);
|
|
133
|
+
return gaps;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Plans the fallback fonts of one render (see the module comment for the rule).
|
|
137
|
+
* `primaryBytes` is what the primary loads (subset or full, every weight);
|
|
138
|
+
* `candidates` are the fallback families available to this renderer.
|
|
139
|
+
*/
|
|
140
|
+
export function planOgFontFallbacks(input) {
|
|
141
|
+
const { primary, codepoints, bold } = input;
|
|
142
|
+
const budget = input.budgetBytes ?? OG_FONT_RENDER_BUDGET_BYTES;
|
|
143
|
+
const gaps = input.primaryFull === false && input.primaryCjk ? primaryGaps(primary, codepoints) : new Set();
|
|
144
|
+
const missing = [...gaps];
|
|
145
|
+
for (const cp of codepoints) {
|
|
146
|
+
// Unreadable text (the collector's sentinel): no reliable plan, no fallbacks.
|
|
147
|
+
if (cp < 0)
|
|
148
|
+
return NO_FALLBACKS;
|
|
149
|
+
if (!ogFallbackIgnorable(cp) && !ogFullFontMaps(primary, cp))
|
|
150
|
+
missing.push(cp);
|
|
151
|
+
}
|
|
152
|
+
if (!missing.length)
|
|
153
|
+
return NO_FALLBACKS;
|
|
154
|
+
missing.sort((a, b) => a - b);
|
|
155
|
+
const rank = (family) => OG_CJK_FALLBACK_PREFERENCE.indexOf(family);
|
|
156
|
+
let candidates = input.candidates.filter((c) => c.set !== primary).sort((a, b) => rank(a.family) - rank(b.family));
|
|
157
|
+
const kanaFirst = missing.some(isKana) && candidates.some((c) => c.family === "ja");
|
|
158
|
+
const overBudget = [];
|
|
159
|
+
for (;;) {
|
|
160
|
+
// The cheapest order overall, and the cheapest that fits the budget. Every
|
|
161
|
+
// order covers the same characters, so a fitting order loses nothing.
|
|
162
|
+
// permutations() keeps the preference order lexicographically, so the first
|
|
163
|
+
// cheapest order found is the tie-break winner.
|
|
164
|
+
let best;
|
|
165
|
+
let bestFit;
|
|
166
|
+
for (const order of permutations(candidates)) {
|
|
167
|
+
if (kanaFirst && candidates.some((c) => c.family === "ja") && order[0].family !== "ja")
|
|
168
|
+
continue;
|
|
169
|
+
const plan = assign(order, missing, gaps, bold);
|
|
170
|
+
if (!best || plan.bytes < best.bytes)
|
|
171
|
+
best = plan;
|
|
172
|
+
if (ogFontSetFits(input, plan.choices, budget) && (!bestFit || plan.bytes < bestFit.bytes))
|
|
173
|
+
bestFit = plan;
|
|
174
|
+
}
|
|
175
|
+
if (!best?.choices.length)
|
|
176
|
+
return { fallbacks: [], overBudget };
|
|
177
|
+
if (bestFit)
|
|
178
|
+
return { fallbacks: bestFit.choices, overBudget };
|
|
179
|
+
// Cut back the fallback whose cut leaves the fewest characters undrawn
|
|
180
|
+
// (ties: the heavier one): a full font ⇒ its subset (when it has every
|
|
181
|
+
// weight), a subset ⇒ dropped.
|
|
182
|
+
const canLimit = (c) => !c.subset && (!bold || !!c.set.bold);
|
|
183
|
+
const loss = (c) => (canLimit(c) ? c.codepoints.filter((cp) => !ogSubsetFontMaps(c.set, cp)).length : c.codepoints.length);
|
|
184
|
+
const victim = best.choices.reduce((a, b) => (loss(b) < loss(a) || (loss(b) === loss(a) && b.bytes > a.bytes) ? b : a));
|
|
185
|
+
if (!overBudget.includes(victim.family))
|
|
186
|
+
overBudget.push(victim.family);
|
|
187
|
+
candidates = canLimit(victim)
|
|
188
|
+
? candidates.map((c) => (c.family === victim.family ? { ...c, subsetOnly: true } : c))
|
|
189
|
+
: candidates.filter((c) => c.family !== victim.family);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Whether a render's primary loads its subset (see the module comment): when
|
|
194
|
+
* the subset draws every character exactly like the full font, or — for a CJK
|
|
195
|
+
* primary whose text needs fallbacks anyway — when those fallbacks' subsets
|
|
196
|
+
* draw every character only the full primary has, without leaving any
|
|
197
|
+
* character undrawn that the full primary's plan draws, without a family
|
|
198
|
+
* loaded only for those characters, and for fewer bytes. Inputs as
|
|
199
|
+
* {@link planOgFontFallbacks} (minus `primaryBytes` / `primaryFull`, which
|
|
200
|
+
* follow from the answer).
|
|
201
|
+
*/
|
|
202
|
+
export function ogPrimaryUsesSubset(input) {
|
|
203
|
+
const { primary, codepoints, bold } = input;
|
|
204
|
+
if (ogSubsetCovers(primary, codepoints))
|
|
205
|
+
return true;
|
|
206
|
+
if (!input.primaryCjk || (bold && !primary.bold))
|
|
207
|
+
return false;
|
|
208
|
+
for (const cp of codepoints)
|
|
209
|
+
if (cp < 0)
|
|
210
|
+
return false;
|
|
211
|
+
const gaps = primaryGaps(primary, codepoints);
|
|
212
|
+
const missing = [...codepoints].filter((cp) => !ogFallbackIgnorable(cp) && !ogFullFontMaps(primary, cp));
|
|
213
|
+
// Nothing for a fallback to draw anyway: the full primary draws the gaps (unchanged).
|
|
214
|
+
if (!missing.length)
|
|
215
|
+
return false;
|
|
216
|
+
const total = (bytes, plan) => plan.fallbacks.reduce((sum, f) => sum + f.bytes, bytes);
|
|
217
|
+
const drawn = (plan) => new Set(plan.fallbacks.flatMap((f) => f.codepoints));
|
|
218
|
+
const subsetBytes = ogFontSetBytes(primary, true, bold);
|
|
219
|
+
const fullBytes = ogFontSetBytes(primary, false, bold);
|
|
220
|
+
const withSubset = planOgFontFallbacks({ ...input, primaryBytes: subsetBytes, primaryFull: false });
|
|
221
|
+
const withFull = planOgFontFallbacks({ ...input, primaryBytes: fullBytes, primaryFull: true });
|
|
222
|
+
const subsetDrawn = drawn(withSubset);
|
|
223
|
+
const fullDrawn = drawn(withFull);
|
|
224
|
+
return ([...gaps].every((cp) => subsetDrawn.has(cp)) &&
|
|
225
|
+
missing.every((cp) => subsetDrawn.has(cp) || !fullDrawn.has(cp)) &&
|
|
226
|
+
withSubset.fallbacks.every((f) => f.codepoints.some((cp) => !gaps.has(cp))) &&
|
|
227
|
+
total(subsetBytes, withSubset) < total(fullBytes, withFull));
|
|
228
|
+
}
|
|
229
|
+
//# sourceMappingURL=font-fallback.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"font-fallback.js","sourceRoot":"","sources":["../../src/og/font-fallback.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AAS,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC;IAC/F,MAAM,WAAW,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC;IACtC,MAAM,SAAS,GAAG,KAAK,CAAC,QAAQ,CAAC,CAAC;IAClC,OAAO,CACL,CAAC,GAAG,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAC5C,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAChE,UAAU,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;QAC3E,KAAK,CAAC,WAAW,EAAE,UAAU,CAAC,GAAG,KAAK,CAAC,SAAS,EAAE,QAAQ,CAAC,CAC5D,CAAC;AACJ,CAAC"}
|
package/dist/og/font-subset.d.ts
CHANGED
|
@@ -8,9 +8,11 @@
|
|
|
8
8
|
* `scripts/build-og-subset-fonts.py`) parse ~8× faster and draw the SAME
|
|
9
9
|
* pixels for any text they cover.
|
|
10
10
|
*
|
|
11
|
-
* A renderer uses a subset
|
|
12
|
-
* covered ({@link ogTreeCoveredBySubset})
|
|
13
|
-
*
|
|
11
|
+
* A renderer uses a subset when EVERY character the render can draw is
|
|
12
|
+
* covered ({@link ogTreeCoveredBySubset}), or — with cross-script fallbacks —
|
|
13
|
+
* when those fallbacks draw what the subset lacks (`ogPrimaryUsesSubset` in
|
|
14
|
+
* font-fallback.ts); otherwise it falls back to the full font (the pre-subset
|
|
15
|
+
* behavior). Coverage comes from the generated
|
|
14
16
|
* {@link OG_SUBSET_FONTS} table, and each subset object is checked against its
|
|
15
17
|
* sha256 before use, so a stale or foreign upload is treated as missing rather
|
|
16
18
|
* than drawing the wrong glyphs.
|
|
@@ -24,10 +26,12 @@ import { OG_SUBSET_FONTS, type OgSubsetFontSet } from "./subset-fonts.generated.
|
|
|
24
26
|
export type { OgSubsetFontFile, OgSubsetFontSet } from "./subset-fonts.generated.js";
|
|
25
27
|
export { OG_SUBSET_FONTS, OG_SUBSET_PREFIX } from "./subset-fonts.generated.js";
|
|
26
28
|
/**
|
|
27
|
-
* How a render picked its
|
|
28
|
-
* - `"hit"`: every character was covered
|
|
29
|
+
* How a render picked its PRIMARY font, reported on the `og-render` event:
|
|
30
|
+
* - `"hit"`: the subset fonts were used — every character was covered, or the
|
|
31
|
+
* ones only the full font has are drawn by cross-script fallbacks the text
|
|
32
|
+
* needs anyway (`ogPrimaryUsesSubset` in font-fallback.ts, ArcBlock/arc#8832);
|
|
29
33
|
* - `"miss"`: some character is outside the subset, so the full fonts were used;
|
|
30
|
-
* - `"absent"`: the
|
|
34
|
+
* - `"absent"`: the subset was chosen, but no usable subset was available (object
|
|
31
35
|
* missing, sha256 mismatch, no subset for this font) — full fonts were used.
|
|
32
36
|
*/
|
|
33
37
|
export type OgFontSubsetStatus = "hit" | "miss" | "absent";
|
|
@@ -40,6 +44,10 @@ export declare function setOgSubsetFontsForTesting(table: Readonly<Record<string
|
|
|
40
44
|
export declare function ogSubsetFontKey(file: string): string;
|
|
41
45
|
/** Decodes the generated page encoding: `"<hex>"` = whole page, `"<hex>:<base64 bitmap>"` = some of it. */
|
|
42
46
|
export declare function decodeOgCodepointPages(encoded: string): Map<number, true | Uint8Array>;
|
|
47
|
+
/** True when the FULL fonts of `set` map `codepoint` (every weight). */
|
|
48
|
+
export declare function ogFullFontMaps(set: OgSubsetFontSet, codepoint: number): boolean;
|
|
49
|
+
/** True when the SUBSET of `set` maps `codepoint` (a page requested whole counts, see the generated table). */
|
|
50
|
+
export declare function ogSubsetFontMaps(set: OgSubsetFontSet, codepoint: number): boolean;
|
|
43
51
|
/** Every codepoint in `codepoints` is drawn identically by the subset and the full font. */
|
|
44
52
|
export declare function ogSubsetCovers(set: OgSubsetFontSet, codepoints: Iterable<number>): boolean;
|
|
45
53
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"font-subset.d.ts","sourceRoot":"","sources":["../../src/og/font-subset.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"font-subset.d.ts","sourceRoot":"","sources":["../../src/og/font-subset.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAAE,eAAe,EAAoB,KAAK,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAEtG,YAAY,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AACrF,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAEhF;;;;;;;;GAQG;AACH,MAAM,MAAM,kBAAkB,GAAG,KAAK,GAAG,MAAM,GAAG,QAAQ,CAAC;AAE3D,MAAM,MAAM,iBAAiB,GAAG,MAAM,OAAO,eAAe,CAAC;AAI7D,gFAAgF;AAChF,wBAAgB,gBAAgB,IAAI,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC,CAE5E;AAED,yFAAyF;AACzF,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC,GAAG,SAAS,GAAG,IAAI,CAG7G;AAED,qCAAqC;AACrC,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEpD;AAkBD,2GAA2G;AAC3G,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,EAAE,IAAI,GAAG,UAAU,CAAC,CAetF;AAwBD,wEAAwE;AACxE,wBAAgB,cAAc,CAAC,GAAG,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAE/E;AAED,+GAA+G;AAC/G,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAEjF;AAED,4FAA4F;AAC5F,wBAAgB,cAAc,CAAC,GAAG,EAAE,eAAe,EAAE,UAAU,EAAE,QAAQ,CAAC,MAAM,CAAC,GAAG,OAAO,CAM1F;AAiHD;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,OAAO,GAAG,GAAG,CAAC,MAAM,CAAC,CAoClE;AAED,6FAA6F;AAC7F,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,eAAe,GAAG,SAAS,EAAE,IAAI,EAAE,OAAO,GAAG,OAAO,CAG9F;AAED,+DAA+D;AAC/D,wBAAsB,YAAY,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CAGrE"}
|
package/dist/og/font-subset.js
CHANGED
|
@@ -8,9 +8,11 @@
|
|
|
8
8
|
* `scripts/build-og-subset-fonts.py`) parse ~8× faster and draw the SAME
|
|
9
9
|
* pixels for any text they cover.
|
|
10
10
|
*
|
|
11
|
-
* A renderer uses a subset
|
|
12
|
-
* covered ({@link ogTreeCoveredBySubset})
|
|
13
|
-
*
|
|
11
|
+
* A renderer uses a subset when EVERY character the render can draw is
|
|
12
|
+
* covered ({@link ogTreeCoveredBySubset}), or — with cross-script fallbacks —
|
|
13
|
+
* when those fallbacks draw what the subset lacks (`ogPrimaryUsesSubset` in
|
|
14
|
+
* font-fallback.ts); otherwise it falls back to the full font (the pre-subset
|
|
15
|
+
* behavior). Coverage comes from the generated
|
|
14
16
|
* {@link OG_SUBSET_FONTS} table, and each subset object is checked against its
|
|
15
17
|
* sha256 before use, so a stale or foreign upload is treated as missing rather
|
|
16
18
|
* than drawing the wrong glyphs.
|
|
@@ -59,26 +61,31 @@ export function decodeOgCodepointPages(encoded) {
|
|
|
59
61
|
function coverageOf(set) {
|
|
60
62
|
let coverage = decoded.get(set);
|
|
61
63
|
if (!coverage) {
|
|
62
|
-
coverage = {
|
|
63
|
-
pages: decodeOgCodepointPages(set.subset),
|
|
64
|
-
fullPages: new Set(set.full ? set.full.split(",").map((page) => Number.parseInt(page, 16)) : []),
|
|
65
|
-
};
|
|
64
|
+
coverage = { pages: decodeOgCodepointPages(set.subset), cmap: decodeOgCodepointPages(set.cmap) };
|
|
66
65
|
decoded.set(set, coverage);
|
|
67
66
|
}
|
|
68
67
|
return coverage;
|
|
69
68
|
}
|
|
69
|
+
function inPages(pages, codepoint) {
|
|
70
|
+
const entry = pages.get(codepoint >> 8);
|
|
71
|
+
if (entry === true)
|
|
72
|
+
return true;
|
|
73
|
+
return !!entry && (entry[(codepoint & 0xff) >> 3] & (1 << (codepoint & 7))) !== 0;
|
|
74
|
+
}
|
|
70
75
|
/** True when the subset draws `codepoint` exactly like the full font. */
|
|
71
76
|
function covers(coverage, codepoint) {
|
|
72
77
|
if (codepoint < 0)
|
|
73
78
|
return false;
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
79
|
+
// Not in the full font ⇒ .notdef (or a fallback font) either way.
|
|
80
|
+
return inPages(coverage.pages, codepoint) || !inPages(coverage.cmap, codepoint);
|
|
81
|
+
}
|
|
82
|
+
/** True when the FULL fonts of `set` map `codepoint` (every weight). */
|
|
83
|
+
export function ogFullFontMaps(set, codepoint) {
|
|
84
|
+
return codepoint >= 0 && inPages(coverageOf(set).cmap, codepoint);
|
|
85
|
+
}
|
|
86
|
+
/** True when the SUBSET of `set` maps `codepoint` (a page requested whole counts, see the generated table). */
|
|
87
|
+
export function ogSubsetFontMaps(set, codepoint) {
|
|
88
|
+
return codepoint >= 0 && inPages(coverageOf(set).pages, codepoint);
|
|
82
89
|
}
|
|
83
90
|
/** Every codepoint in `codepoints` is drawn identically by the subset and the full font. */
|
|
84
91
|
export function ogSubsetCovers(set, codepoints) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"font-subset.js","sourceRoot":"","sources":["../../src/og/font-subset.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"font-subset.js","sourceRoot":"","sources":["../../src/og/font-subset.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAwB,MAAM,6BAA6B,CAAC;AAGtG,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAehF,IAAI,aAAoE,CAAC;AAEzE,gFAAgF;AAChF,MAAM,UAAU,gBAAgB;IAC9B,OAAO,aAAa,IAAI,eAAe,CAAC;AAC1C,CAAC;AAED,yFAAyF;AACzF,MAAM,UAAU,0BAA0B,CAAC,KAA4D;IACrG,aAAa,GAAG,KAAK,CAAC;IACtB,OAAO,CAAC,KAAK,EAAE,CAAC;AAClB,CAAC;AAED,qCAAqC;AACrC,MAAM,UAAU,eAAe,CAAC,IAAY;IAC1C,OAAO,GAAG,gBAAgB,IAAI,IAAI,EAAE,CAAC;AACvC,CAAC;AAgBD,MAAM,OAAO,GAAG,IAAI,GAAG,EAA6B,CAAC;AAErD,2GAA2G;AAC3G,MAAM,UAAU,sBAAsB,CAAC,OAAe;IACpD,MAAM,KAAK,GAAG,IAAI,GAAG,EAA6B,CAAC;IACnD,IAAI,CAAC,OAAO;QAAE,OAAO,KAAK,CAAC;IAC3B,KAAK,MAAM,KAAK,IAAI,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;QACvC,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACjC,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;YACd,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC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AC,GAAG;QAAE,OAAO,KAAK,CAAC;IACvB,OAAO,cAAc,CAAC,GAAG,EAAE,uBAAuB,CAAC,IAAI,CAAC,CAAC,CAAC;AAC5D,CAAC;AAED,+DAA+D;AAC/D,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,KAAiB;IAClD,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,KAAgC,CAAC,CAAC;IACvF,OAAO,CAAC,GAAG,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AAChG,CAAC"}
|
package/dist/og/generator.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { type Logger } from "../logger.js";
|
|
2
|
+
import { FONT_FETCH_TIMEOUT_MS } from "./node-font-files.js";
|
|
2
3
|
import type { CreateOgGeneratorOptions, OgGenerator } from "./types.js";
|
|
3
4
|
/** The bundled Regular face (also the default for `og-node`'s `renderOgTree`). */
|
|
4
5
|
export declare const FONT_PATH: string;
|
|
5
|
-
|
|
6
|
-
export declare const FONT_FETCH_TIMEOUT_MS = 10000;
|
|
6
|
+
export { FONT_FETCH_TIMEOUT_MS };
|
|
7
7
|
export interface FontSource {
|
|
8
8
|
fontUrl?: string;
|
|
9
9
|
fontCacheDir: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../src/og/generator.ts"],"names":[],"mappings":"AAOA,OAAO,EAAiB,KAAK,MAAM,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../src/og/generator.ts"],"names":[],"mappings":"AAOA,OAAO,EAAiB,KAAK,MAAM,EAAE,MAAM,cAAc,CAAC;AAK1D,OAAO,EAAE,qBAAqB,EAAiF,MAAM,sBAAsB,CAAC;AAO5I,OAAO,KAAK,EAAE,wBAAwB,EAAqB,WAAW,EAAE,MAAM,YAAY,CAAC;AAS3F,kFAAkF;AAClF,eAAO,MAAM,SAAS,QAAiE,CAAC;AAExF,OAAO,EAAE,qBAAqB,EAAE,CAAC;AAEjC,MAAM,WAAW,UAAU;IACzB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,OAAO,KAAK,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,8EAA8E;IAC9E,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAOD,gHAAgH;AAChH,wBAAgB,QAAQ,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CAoB5D;AAwRD,wBAAgB,iBAAiB,CAAC,OAAO,GAAE,wBAA6B,GAAG,WAAW,CA6ErF"}
|