@hanzogui/font 8.3.0 → 8.3.2
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/cjs/index.js +63 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/package.json +1 -0
- package/dist/esm/index.js +55 -63
- package/dist/esm/index.js.map +1 -1
- package/package.json +15 -15
- package/types/index.d.ts +1 -1
- package/dist/cjs/index.cjs +0 -93
- package/dist/cjs/index.native.js +0 -98
- package/dist/cjs/index.native.js.map +0 -1
- package/dist/esm/index.mjs +0 -68
- package/dist/esm/index.mjs.map +0 -1
- package/dist/esm/index.native.js +0 -70
- package/dist/esm/index.native.js.map +0 -1
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addFont = addFont;
|
|
4
|
+
const constants_1 = require("@hanzogui/constants");
|
|
5
|
+
const web_1 = require("@hanzogui/web");
|
|
6
|
+
function addFont(props) {
|
|
7
|
+
const config = (0, web_1.getConfig)();
|
|
8
|
+
const { fontFamilyName: fontFamilyNameIn, fontFamily: fontFamilyIn } = props;
|
|
9
|
+
if (process.env.NODE_ENV === 'development') {
|
|
10
|
+
if (!config) {
|
|
11
|
+
throw new Error('No config');
|
|
12
|
+
}
|
|
13
|
+
const fontFamily = config.fonts[fontFamilyNameIn];
|
|
14
|
+
if (!props.update && fontFamily) {
|
|
15
|
+
return { fontFamily };
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
config.fonts[fontFamilyNameIn] = fontFamilyIn;
|
|
19
|
+
const sep =
|
|
20
|
+
// @ts-ignore
|
|
21
|
+
process.env.NODE_ENV === 'development' ? config.cssStyleSeparator || ' ' : '';
|
|
22
|
+
function declarationsToRuleSet(decs, selector = '') {
|
|
23
|
+
return `:root${selector} {${sep}${[...decs].join(`;${sep}`)}${sep}}`;
|
|
24
|
+
}
|
|
25
|
+
if (constants_1.isWeb) {
|
|
26
|
+
const fontFamilyToken = (0, web_1.createVariables)(fontFamilyIn, 'f', true);
|
|
27
|
+
const parsedFontFamily = (0, web_1.parseFont)(fontFamilyToken);
|
|
28
|
+
const fontFamilyNameParsed = `$${fontFamilyNameIn}`;
|
|
29
|
+
config.fontsParsed[fontFamilyNameParsed] = parsedFontFamily;
|
|
30
|
+
if (props.insertCSS) {
|
|
31
|
+
const [ff_name, ff_language] = fontFamilyNameParsed.includes('_')
|
|
32
|
+
? fontFamilyNameParsed.split('_')
|
|
33
|
+
: [fontFamilyNameParsed];
|
|
34
|
+
const fontVars = (0, web_1.registerFontVariables)(parsedFontFamily);
|
|
35
|
+
const fontDeclaration = {
|
|
36
|
+
[fontFamilyNameIn]: {
|
|
37
|
+
name: ff_name.slice(1),
|
|
38
|
+
declarations: fontVars,
|
|
39
|
+
language: ff_language,
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
const { name, declarations, language = 'default', } = fontDeclaration[fontFamilyNameIn];
|
|
43
|
+
const fontSelector = `.font_${name}`;
|
|
44
|
+
const langSelector = `:root .t_lang-${name}-${language} ${fontSelector}`;
|
|
45
|
+
const selectors = language === 'default' ? ` ${fontSelector}, ${langSelector}` : langSelector;
|
|
46
|
+
const cssRuleSets = declarationsToRuleSet(declarations, selectors);
|
|
47
|
+
const id = `t_font_style_${fontFamilyNameIn}`;
|
|
48
|
+
const existing = document.querySelector(`#${id}`);
|
|
49
|
+
const style = document.createElement('style');
|
|
50
|
+
style.id = id;
|
|
51
|
+
style.appendChild(document.createTextNode(`${cssRuleSets}`));
|
|
52
|
+
document.head.appendChild(style);
|
|
53
|
+
if (existing) {
|
|
54
|
+
existing.parentElement?.removeChild(existing);
|
|
55
|
+
}
|
|
56
|
+
return {
|
|
57
|
+
fontFamilyToken,
|
|
58
|
+
fontDeclaration,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=index.js.map
|
|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YAC7C,KAAK,CAAC,EAAE,GAAG,EAAE,CAAA;YACb,KAAK,CAAC,WAAW,CAAC,QAAQ,CAAC,cAAc,CAAC,GAAG,WAAW,EAAE,CAAC,CAAC,CAAA;YAC5D,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAA;YAChC,IAAI,QAAQ,EAAE,CAAC;gBACb,QAAQ,CAAC,aAAa,EAAE,WAAW,CAAC,QAAQ,CAAC,CAAA;YAC/C,CAAC;YACD,OAAO;gBACL,eAAe;gBACf,eAAe;aAChB,CAAA;QACH,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{ "type": "commonjs" }
|
package/dist/esm/index.js
CHANGED
|
@@ -1,68 +1,60 @@
|
|
|
1
|
-
import { isWeb } from
|
|
2
|
-
import { createVariables, getConfig, parseFont, registerFontVariables } from
|
|
3
|
-
function addFont(props) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
import { isWeb } from '@hanzogui/constants';
|
|
2
|
+
import { createVariables, getConfig, parseFont, registerFontVariables, } from '@hanzogui/web';
|
|
3
|
+
export function addFont(props) {
|
|
4
|
+
const config = getConfig();
|
|
5
|
+
const { fontFamilyName: fontFamilyNameIn, fontFamily: fontFamilyIn } = props;
|
|
6
|
+
if (process.env.NODE_ENV === 'development') {
|
|
7
|
+
if (!config) {
|
|
8
|
+
throw new Error('No config');
|
|
9
|
+
}
|
|
10
|
+
const fontFamily = config.fonts[fontFamilyNameIn];
|
|
11
|
+
if (!props.update && fontFamily) {
|
|
12
|
+
return { fontFamily };
|
|
13
|
+
}
|
|
12
14
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
config.fonts[fontFamilyNameIn] = fontFamilyIn;
|
|
16
|
+
const sep =
|
|
17
|
+
// @ts-ignore
|
|
18
|
+
process.env.NODE_ENV === 'development' ? config.cssStyleSeparator || ' ' : '';
|
|
19
|
+
function declarationsToRuleSet(decs, selector = '') {
|
|
20
|
+
return `:root${selector} {${sep}${[...decs].join(`;${sep}`)}${sep}}`;
|
|
18
21
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
22
|
+
if (isWeb) {
|
|
23
|
+
const fontFamilyToken = createVariables(fontFamilyIn, 'f', true);
|
|
24
|
+
const parsedFontFamily = parseFont(fontFamilyToken);
|
|
25
|
+
const fontFamilyNameParsed = `$${fontFamilyNameIn}`;
|
|
26
|
+
config.fontsParsed[fontFamilyNameParsed] = parsedFontFamily;
|
|
27
|
+
if (props.insertCSS) {
|
|
28
|
+
const [ff_name, ff_language] = fontFamilyNameParsed.includes('_')
|
|
29
|
+
? fontFamilyNameParsed.split('_')
|
|
30
|
+
: [fontFamilyNameParsed];
|
|
31
|
+
const fontVars = registerFontVariables(parsedFontFamily);
|
|
32
|
+
const fontDeclaration = {
|
|
33
|
+
[fontFamilyNameIn]: {
|
|
34
|
+
name: ff_name.slice(1),
|
|
35
|
+
declarations: fontVars,
|
|
36
|
+
language: ff_language,
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
const { name, declarations, language = 'default', } = fontDeclaration[fontFamilyNameIn];
|
|
40
|
+
const fontSelector = `.font_${name}`;
|
|
41
|
+
const langSelector = `:root .t_lang-${name}-${language} ${fontSelector}`;
|
|
42
|
+
const selectors = language === 'default' ? ` ${fontSelector}, ${langSelector}` : langSelector;
|
|
43
|
+
const cssRuleSets = declarationsToRuleSet(declarations, selectors);
|
|
44
|
+
const id = `t_font_style_${fontFamilyNameIn}`;
|
|
45
|
+
const existing = document.querySelector(`#${id}`);
|
|
46
|
+
const style = document.createElement('style');
|
|
47
|
+
style.id = id;
|
|
48
|
+
style.appendChild(document.createTextNode(`${cssRuleSets}`));
|
|
49
|
+
document.head.appendChild(style);
|
|
50
|
+
if (existing) {
|
|
51
|
+
existing.parentElement?.removeChild(existing);
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
fontFamilyToken,
|
|
55
|
+
fontDeclaration,
|
|
56
|
+
};
|
|
40
57
|
}
|
|
41
|
-
};
|
|
42
|
-
const {
|
|
43
|
-
name,
|
|
44
|
-
declarations,
|
|
45
|
-
language = "default"
|
|
46
|
-
} = fontDeclaration[fontFamilyNameIn];
|
|
47
|
-
const fontSelector = `.font_${name}`;
|
|
48
|
-
const langSelector = `:root .t_lang-${name}-${language} ${fontSelector}`;
|
|
49
|
-
const selectors = language === "default" ? ` ${fontSelector}, ${langSelector}` : langSelector;
|
|
50
|
-
const cssRuleSets = declarationsToRuleSet(declarations, selectors);
|
|
51
|
-
const id = `t_font_style_${fontFamilyNameIn}`;
|
|
52
|
-
const existing = document.querySelector(`#${id}`);
|
|
53
|
-
const style = document.createElement("style");
|
|
54
|
-
style.id = id;
|
|
55
|
-
style.appendChild(document.createTextNode(`${cssRuleSets}`));
|
|
56
|
-
document.head.appendChild(style);
|
|
57
|
-
if (existing) {
|
|
58
|
-
existing.parentElement?.removeChild(existing);
|
|
59
|
-
}
|
|
60
|
-
return {
|
|
61
|
-
fontFamilyToken,
|
|
62
|
-
fontDeclaration
|
|
63
|
-
};
|
|
64
58
|
}
|
|
65
|
-
}
|
|
66
59
|
}
|
|
67
|
-
|
|
68
|
-
//# sourceMappingURL=index.js.map
|
|
60
|
+
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../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CAAC,OAAO,CAAC,CAAA;YAC7C,KAAK,CAAC,EAAE,GAAG,EAAE,CAAA;YACb,KAAK,CAAC,WAAW,CAAC,QAAQ,CAAC,cAAc,CAAC,GAAG,WAAW,EAAE,CAAC,CAAC,CAAA;YAC5D,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAA;YAChC,IAAI,QAAQ,EAAE,CAAC;gBACb,QAAQ,CAAC,aAAa,EAAE,WAAW,CAAC,QAAQ,CAAC,CAAA;YAC/C,CAAC;YACD,OAAO;gBACL,eAAe;gBACf,eAAe;aAChB,CAAA;QACH,CAAC;IACH,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hanzogui/font",
|
|
3
|
-
"version": "8.3.
|
|
3
|
+
"version": "8.3.2",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"files": [
|
|
6
6
|
"src",
|
|
@@ -9,40 +9,40 @@
|
|
|
9
9
|
],
|
|
10
10
|
"type": "module",
|
|
11
11
|
"sideEffects": false,
|
|
12
|
-
"main": "dist/cjs",
|
|
13
|
-
"module": "dist/esm",
|
|
12
|
+
"main": "./dist/cjs/index.js",
|
|
13
|
+
"module": "./dist/esm/index.js",
|
|
14
14
|
"types": "./types/index.d.ts",
|
|
15
15
|
"exports": {
|
|
16
16
|
"./package.json": "./package.json",
|
|
17
17
|
".": {
|
|
18
18
|
"types": "./types/index.d.ts",
|
|
19
|
-
"react-native": "./dist/esm/index.
|
|
20
|
-
"browser": "./dist/esm/index.
|
|
21
|
-
"module": "./dist/esm/index.
|
|
22
|
-
"import": "./dist/esm/index.
|
|
23
|
-
"require": "./dist/cjs/index.
|
|
24
|
-
"default": "./dist/esm/index.
|
|
19
|
+
"react-native": "./dist/esm/index.js",
|
|
20
|
+
"browser": "./dist/esm/index.js",
|
|
21
|
+
"module": "./dist/esm/index.js",
|
|
22
|
+
"import": "./dist/esm/index.js",
|
|
23
|
+
"require": "./dist/cjs/index.js",
|
|
24
|
+
"default": "./dist/esm/index.js"
|
|
25
25
|
}
|
|
26
26
|
},
|
|
27
27
|
"publishConfig": {
|
|
28
28
|
"access": "public"
|
|
29
29
|
},
|
|
30
30
|
"scripts": {
|
|
31
|
-
"build": "hanzogui-build",
|
|
31
|
+
"build": "hanzogui-build --skip-native",
|
|
32
32
|
"watch": "hanzogui-build --watch",
|
|
33
33
|
"clean": "hanzogui-build clean",
|
|
34
34
|
"clean:build": "hanzogui-build clean:build"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@hanzogui/constants": "8.3.
|
|
38
|
-
"@hanzogui/web": "8.3.
|
|
37
|
+
"@hanzogui/constants": "8.3.2",
|
|
38
|
+
"@hanzogui/web": "8.3.2"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"@hanzogui/build": "8.3.
|
|
42
|
-
"react": "
|
|
41
|
+
"@hanzogui/build": "8.3.2",
|
|
42
|
+
"react": "19.2.8"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
|
-
"react": ">=19"
|
|
45
|
+
"react": ">=19.2.8"
|
|
46
46
|
},
|
|
47
47
|
"skipPublishIfUnchanged": false,
|
|
48
48
|
"repository": {
|
package/types/index.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export declare function addFont(props: {
|
|
|
9
9
|
fontFamilyToken?: undefined;
|
|
10
10
|
fontDeclaration?: undefined;
|
|
11
11
|
} | {
|
|
12
|
+
fontFamily?: undefined;
|
|
12
13
|
fontFamilyToken: never;
|
|
13
14
|
fontDeclaration: {
|
|
14
15
|
[x: string]: {
|
|
@@ -17,6 +18,5 @@ export declare function addFont(props: {
|
|
|
17
18
|
language: string;
|
|
18
19
|
};
|
|
19
20
|
};
|
|
20
|
-
fontFamily?: undefined;
|
|
21
21
|
} | undefined;
|
|
22
22
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/cjs/index.cjs
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all) __defProp(target, name, {
|
|
7
|
-
get: all[name],
|
|
8
|
-
enumerable: true
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
14
|
-
get: () => from[key],
|
|
15
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
21
|
-
value: true
|
|
22
|
-
}), mod);
|
|
23
|
-
var index_exports = {};
|
|
24
|
-
__export(index_exports, {
|
|
25
|
-
addFont: () => addFont
|
|
26
|
-
});
|
|
27
|
-
module.exports = __toCommonJS(index_exports);
|
|
28
|
-
var import_constants = require("@hanzogui/constants");
|
|
29
|
-
var import_web = require("@hanzogui/web");
|
|
30
|
-
function addFont(props) {
|
|
31
|
-
const config = (0, import_web.getConfig)();
|
|
32
|
-
const {
|
|
33
|
-
fontFamilyName: fontFamilyNameIn,
|
|
34
|
-
fontFamily: fontFamilyIn
|
|
35
|
-
} = props;
|
|
36
|
-
if (process.env.NODE_ENV === "development") {
|
|
37
|
-
if (!config) {
|
|
38
|
-
throw new Error("No config");
|
|
39
|
-
}
|
|
40
|
-
const fontFamily = config.fonts[fontFamilyNameIn];
|
|
41
|
-
if (!props.update && fontFamily) {
|
|
42
|
-
return {
|
|
43
|
-
fontFamily
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
config.fonts[fontFamilyNameIn] = fontFamilyIn;
|
|
48
|
-
const sep =
|
|
49
|
-
// @ts-ignore
|
|
50
|
-
process.env.NODE_ENV === "development" ? config.cssStyleSeparator || " " : "";
|
|
51
|
-
function declarationsToRuleSet(decs, selector = "") {
|
|
52
|
-
return `:root${selector} {${sep}${[...decs].join(`;${sep}`)}${sep}}`;
|
|
53
|
-
}
|
|
54
|
-
if (import_constants.isWeb) {
|
|
55
|
-
const fontFamilyToken = (0, import_web.createVariables)(fontFamilyIn, "f", true);
|
|
56
|
-
const parsedFontFamily = (0, import_web.parseFont)(fontFamilyToken);
|
|
57
|
-
const fontFamilyNameParsed = `$${fontFamilyNameIn}`;
|
|
58
|
-
config.fontsParsed[fontFamilyNameParsed] = parsedFontFamily;
|
|
59
|
-
if (props.insertCSS) {
|
|
60
|
-
const [ff_name, ff_language] = fontFamilyNameParsed.includes("_") ? fontFamilyNameParsed.split("_") : [fontFamilyNameParsed];
|
|
61
|
-
const fontVars = (0, import_web.registerFontVariables)(parsedFontFamily);
|
|
62
|
-
const fontDeclaration = {
|
|
63
|
-
[fontFamilyNameIn]: {
|
|
64
|
-
name: ff_name.slice(1),
|
|
65
|
-
declarations: fontVars,
|
|
66
|
-
language: ff_language
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
const {
|
|
70
|
-
name,
|
|
71
|
-
declarations,
|
|
72
|
-
language = "default"
|
|
73
|
-
} = fontDeclaration[fontFamilyNameIn];
|
|
74
|
-
const fontSelector = `.font_${name}`;
|
|
75
|
-
const langSelector = `:root .t_lang-${name}-${language} ${fontSelector}`;
|
|
76
|
-
const selectors = language === "default" ? ` ${fontSelector}, ${langSelector}` : langSelector;
|
|
77
|
-
const cssRuleSets = declarationsToRuleSet(declarations, selectors);
|
|
78
|
-
const id = `t_font_style_${fontFamilyNameIn}`;
|
|
79
|
-
const existing = document.querySelector(`#${id}`);
|
|
80
|
-
const style = document.createElement("style");
|
|
81
|
-
style.id = id;
|
|
82
|
-
style.appendChild(document.createTextNode(`${cssRuleSets}`));
|
|
83
|
-
document.head.appendChild(style);
|
|
84
|
-
if (existing) {
|
|
85
|
-
existing.parentElement?.removeChild(existing);
|
|
86
|
-
}
|
|
87
|
-
return {
|
|
88
|
-
fontFamilyToken,
|
|
89
|
-
fontDeclaration
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
}
|
package/dist/cjs/index.native.js
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all) __defProp(target, name, {
|
|
9
|
-
get: all[name],
|
|
10
|
-
enumerable: true
|
|
11
|
-
});
|
|
12
|
-
};
|
|
13
|
-
var __copyProps = (to, from, except, desc) => {
|
|
14
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
-
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
16
|
-
get: () => from[key],
|
|
17
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
return to;
|
|
21
|
-
};
|
|
22
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
23
|
-
value: true
|
|
24
|
-
}), mod);
|
|
25
|
-
var index_exports = {};
|
|
26
|
-
__export(index_exports, {
|
|
27
|
-
addFont: () => addFont
|
|
28
|
-
});
|
|
29
|
-
module.exports = __toCommonJS(index_exports);
|
|
30
|
-
var import_constants = require("@hanzogui/constants");
|
|
31
|
-
var import_web = require("@hanzogui/web");
|
|
32
|
-
function addFont(props) {
|
|
33
|
-
var config = (0, import_web.getConfig)();
|
|
34
|
-
var {
|
|
35
|
-
fontFamilyName: fontFamilyNameIn,
|
|
36
|
-
fontFamily: fontFamilyIn
|
|
37
|
-
} = props;
|
|
38
|
-
if (process.env.NODE_ENV === "development") {
|
|
39
|
-
if (!config) {
|
|
40
|
-
throw new Error("No config");
|
|
41
|
-
}
|
|
42
|
-
var fontFamily = config.fonts[fontFamilyNameIn];
|
|
43
|
-
if (!props.update && fontFamily) {
|
|
44
|
-
return {
|
|
45
|
-
fontFamily
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
config.fonts[fontFamilyNameIn] = fontFamilyIn;
|
|
50
|
-
var sep =
|
|
51
|
-
// @ts-ignore
|
|
52
|
-
process.env.NODE_ENV === "development" ? config.cssStyleSeparator || " " : "";
|
|
53
|
-
function declarationsToRuleSet(decs) {
|
|
54
|
-
var selector = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "";
|
|
55
|
-
return `:root${selector} {${sep}${[...decs].join(`;${sep}`)}${sep}}`;
|
|
56
|
-
}
|
|
57
|
-
if (import_constants.isWeb) {
|
|
58
|
-
var fontFamilyToken = (0, import_web.createVariables)(fontFamilyIn, "f", true);
|
|
59
|
-
var parsedFontFamily = (0, import_web.parseFont)(fontFamilyToken);
|
|
60
|
-
var fontFamilyNameParsed = `$${fontFamilyNameIn}`;
|
|
61
|
-
config.fontsParsed[fontFamilyNameParsed] = parsedFontFamily;
|
|
62
|
-
if (props.insertCSS) {
|
|
63
|
-
var [ff_name, ff_language] = fontFamilyNameParsed.includes("_") ? fontFamilyNameParsed.split("_") : [fontFamilyNameParsed];
|
|
64
|
-
var fontVars = (0, import_web.registerFontVariables)(parsedFontFamily);
|
|
65
|
-
var fontDeclaration = {
|
|
66
|
-
[fontFamilyNameIn]: {
|
|
67
|
-
name: ff_name.slice(1),
|
|
68
|
-
declarations: fontVars,
|
|
69
|
-
language: ff_language
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
var {
|
|
73
|
-
name,
|
|
74
|
-
declarations,
|
|
75
|
-
language = "default"
|
|
76
|
-
} = fontDeclaration[fontFamilyNameIn];
|
|
77
|
-
var fontSelector = `.font_${name}`;
|
|
78
|
-
var langSelector = `:root .t_lang-${name}-${language} ${fontSelector}`;
|
|
79
|
-
var selectors = language === "default" ? ` ${fontSelector}, ${langSelector}` : langSelector;
|
|
80
|
-
var cssRuleSets = declarationsToRuleSet(declarations, selectors);
|
|
81
|
-
var id = `t_font_style_${fontFamilyNameIn}`;
|
|
82
|
-
var existing = document.querySelector(`#${id}`);
|
|
83
|
-
var style = document.createElement("style");
|
|
84
|
-
style.id = id;
|
|
85
|
-
style.appendChild(document.createTextNode(`${cssRuleSets}`));
|
|
86
|
-
document.head.appendChild(style);
|
|
87
|
-
if (existing) {
|
|
88
|
-
var _existing_parentElement;
|
|
89
|
-
(_existing_parentElement = existing.parentElement) === null || _existing_parentElement === void 0 ? void 0 : _existing_parentElement.removeChild(existing);
|
|
90
|
-
}
|
|
91
|
-
return {
|
|
92
|
-
fontFamilyToken,
|
|
93
|
-
fontDeclaration
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
//# sourceMappingURL=index.native.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["__defProp","Object","defineProperty","__getOwnPropDesc","getOwnPropertyDescriptor","__getOwnPropNames","getOwnPropertyNames","__hasOwnProp","prototype","hasOwnProperty","__export","target","all","name","get","enumerable","__copyProps","to","from","except","desc","key","call","__toCommonJS","mod","value","index_exports","addFont","module","exports","import_constants","require","import_web","props","config","getConfig","fontFamilyName","fontFamilyNameIn","fontFamily","fontFamilyIn","process","env","NODE_ENV","Error","fonts","update","sep","cssStyleSeparator","declarationsToRuleSet","decs","selector","arguments","length","join","isWeb","fontFamilyToken","createVariables","parsedFontFamily","parseFont","fontFamilyNameParsed","fontsParsed","insertCSS","ff_name","ff_language","includes","split","fontVars","registerFontVariables","fontDeclaration","slice","declarations","language","fontSelector","langSelector","selectors","cssRuleSets","id","existing","document","querySelector","style","createElement","appendChild","createTextNode","head","_existing_parentElement","parentElement","removeChild"],"sources":["index.native.js"],"sourcesContent":["\"use strict\";\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar index_exports = {};\n__export(index_exports, {\n addFont: () => addFont\n});\nmodule.exports = __toCommonJS(index_exports);\nvar import_constants = require(\"@hanzogui/constants\");\nvar import_web = require(\"@hanzogui/web\");\nfunction addFont(props) {\n var config = (0, import_web.getConfig)();\n var { fontFamilyName: fontFamilyNameIn, fontFamily: fontFamilyIn } = props;\n if (process.env.NODE_ENV === \"development\") {\n if (!config) {\n throw new Error(\"No config\");\n }\n var fontFamily = config.fonts[fontFamilyNameIn];\n if (!props.update && fontFamily) {\n return {\n fontFamily\n };\n }\n }\n config.fonts[fontFamilyNameIn] = fontFamilyIn;\n var sep = (\n // @ts-ignore\n process.env.NODE_ENV === \"development\" ? config.cssStyleSeparator || \" \" : \"\"\n );\n function declarationsToRuleSet(decs) {\n var selector = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : \"\";\n return `:root${selector} {${sep}${[\n ...decs\n ].join(`;${sep}`)}${sep}}`;\n }\n if (import_constants.isWeb) {\n var fontFamilyToken = (0, import_web.createVariables)(fontFamilyIn, \"f\", true);\n var parsedFontFamily = (0, import_web.parseFont)(fontFamilyToken);\n var fontFamilyNameParsed = `$${fontFamilyNameIn}`;\n config.fontsParsed[fontFamilyNameParsed] = parsedFontFamily;\n if (props.insertCSS) {\n var [ff_name, ff_language] = fontFamilyNameParsed.includes(\"_\") ? fontFamilyNameParsed.split(\"_\") : [\n fontFamilyNameParsed\n ];\n var fontVars = (0, import_web.registerFontVariables)(parsedFontFamily);\n var fontDeclaration = {\n [fontFamilyNameIn]: {\n name: ff_name.slice(1),\n declarations: fontVars,\n language: ff_language\n }\n };\n var { name, declarations, language = \"default\" } = fontDeclaration[fontFamilyNameIn];\n var fontSelector = `.font_${name}`;\n var langSelector = `:root .t_lang-${name}-${language} ${fontSelector}`;\n var selectors = language === \"default\" ? ` ${fontSelector}, ${langSelector}` : langSelector;\n var cssRuleSets = declarationsToRuleSet(declarations, selectors);\n var id = `t_font_style_${fontFamilyNameIn}`;\n var existing = document.querySelector(`#${id}`);\n var style = document.createElement(\"style\");\n style.id = id;\n style.appendChild(document.createTextNode(`${cssRuleSets}`));\n document.head.appendChild(style);\n if (existing) {\n var _existing_parentElement;\n (_existing_parentElement = existing.parentElement) === null || _existing_parentElement === void 0 ? void 0 : _existing_parentElement.removeChild(existing);\n }\n return {\n fontFamilyToken,\n fontDeclaration\n };\n }\n }\n}\n//# sourceMappingURL=index.js.map\n"],"mappings":"AAAA,YAAY;;AACZ,IAAIA,SAAS,GAAGC,MAAM,CAACC,cAAc;AACrC,IAAIC,gBAAgB,GAAGF,MAAM,CAACG,wBAAwB;AACtD,IAAIC,iBAAiB,GAAGJ,MAAM,CAACK,mBAAmB;AAClD,IAAIC,YAAY,GAAGN,MAAM,CAACO,SAAS,CAACC,cAAc;AAClD,IAAIC,QAAQ,GAAGA,CAACC,MAAM,EAAEC,GAAG,KAAK;EAC9B,KAAK,IAAIC,IAAI,IAAID,GAAG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cAAc,CAAC,GAAGR,WAAW,EAAE,CAAC,CAAC;MAC5DG,QAAQ,CAACM,IAAI,CAACF,WAAW,CAACF,KAAK,CAAC;MAChC,IAAIH,QAAQ,EAAE;QACZ,IAAIQ,uBAAuB;QAC3B,CAACA,uBAAuB,GAAGR,QAAQ,CAACS,aAAa,MAAM,IAAI,IAAID,uBAAuB,KAAK,KAAK,CAAC,GAAG,KAAK,CAAC,GAAGA,uBAAuB,CAACE,WAAW,CAACV,QAAQ,CAAC;MAC5J;MACA,OAAO;QACLtB,eAAe;QACfa;MACF,CAAC;IACH;EACF;AACF","ignoreList":[]}
|
package/dist/esm/index.mjs
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { isWeb } from "@hanzogui/constants";
|
|
2
|
-
import { createVariables, getConfig, parseFont, registerFontVariables } from "@hanzogui/web";
|
|
3
|
-
function addFont(props) {
|
|
4
|
-
const config = getConfig();
|
|
5
|
-
const {
|
|
6
|
-
fontFamilyName: fontFamilyNameIn,
|
|
7
|
-
fontFamily: fontFamilyIn
|
|
8
|
-
} = props;
|
|
9
|
-
if (process.env.NODE_ENV === "development") {
|
|
10
|
-
if (!config) {
|
|
11
|
-
throw new Error("No config");
|
|
12
|
-
}
|
|
13
|
-
const fontFamily = config.fonts[fontFamilyNameIn];
|
|
14
|
-
if (!props.update && fontFamily) {
|
|
15
|
-
return {
|
|
16
|
-
fontFamily
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
config.fonts[fontFamilyNameIn] = fontFamilyIn;
|
|
21
|
-
const sep =
|
|
22
|
-
// @ts-ignore
|
|
23
|
-
process.env.NODE_ENV === "development" ? config.cssStyleSeparator || " " : "";
|
|
24
|
-
function declarationsToRuleSet(decs, selector = "") {
|
|
25
|
-
return `:root${selector} {${sep}${[...decs].join(`;${sep}`)}${sep}}`;
|
|
26
|
-
}
|
|
27
|
-
if (isWeb) {
|
|
28
|
-
const fontFamilyToken = createVariables(fontFamilyIn, "f", true);
|
|
29
|
-
const parsedFontFamily = parseFont(fontFamilyToken);
|
|
30
|
-
const fontFamilyNameParsed = `$${fontFamilyNameIn}`;
|
|
31
|
-
config.fontsParsed[fontFamilyNameParsed] = parsedFontFamily;
|
|
32
|
-
if (props.insertCSS) {
|
|
33
|
-
const [ff_name, ff_language] = fontFamilyNameParsed.includes("_") ? fontFamilyNameParsed.split("_") : [fontFamilyNameParsed];
|
|
34
|
-
const fontVars = registerFontVariables(parsedFontFamily);
|
|
35
|
-
const fontDeclaration = {
|
|
36
|
-
[fontFamilyNameIn]: {
|
|
37
|
-
name: ff_name.slice(1),
|
|
38
|
-
declarations: fontVars,
|
|
39
|
-
language: ff_language
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
const {
|
|
43
|
-
name,
|
|
44
|
-
declarations,
|
|
45
|
-
language = "default"
|
|
46
|
-
} = fontDeclaration[fontFamilyNameIn];
|
|
47
|
-
const fontSelector = `.font_${name}`;
|
|
48
|
-
const langSelector = `:root .t_lang-${name}-${language} ${fontSelector}`;
|
|
49
|
-
const selectors = language === "default" ? ` ${fontSelector}, ${langSelector}` : langSelector;
|
|
50
|
-
const cssRuleSets = declarationsToRuleSet(declarations, selectors);
|
|
51
|
-
const id = `t_font_style_${fontFamilyNameIn}`;
|
|
52
|
-
const existing = document.querySelector(`#${id}`);
|
|
53
|
-
const style = document.createElement("style");
|
|
54
|
-
style.id = id;
|
|
55
|
-
style.appendChild(document.createTextNode(`${cssRuleSets}`));
|
|
56
|
-
document.head.appendChild(style);
|
|
57
|
-
if (existing) {
|
|
58
|
-
existing.parentElement?.removeChild(existing);
|
|
59
|
-
}
|
|
60
|
-
return {
|
|
61
|
-
fontFamilyToken,
|
|
62
|
-
fontDeclaration
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
export { addFont };
|
|
68
|
-
//# sourceMappingURL=index.mjs.map
|
package/dist/esm/index.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["isWeb","createVariables","getConfig","parseFont","registerFontVariables","addFont","props","config","fontFamilyName","fontFamilyNameIn","fontFamily","fontFamilyIn","process","env","NODE_ENV","Error","fonts","update","sep","cssStyleSeparator","declarationsToRuleSet","decs","selector","join","fontFamilyToken","parsedFontFamily","fontFamilyNameParsed","fontsParsed","insertCSS","ff_name","ff_language","includes","split","fontVars","fontDeclaration","name","slice","declarations","language","fontSelector","langSelector","selectors","cssRuleSets","id","existing","document","querySelector","style","createElement","appendChild","createTextNode","head","parentElement","removeChild"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,KAAA,QAAa;AACtB,SACEC,eAAA,EACAC,SAAA,EACAC,SAAA,EACAC,qBAAA,QACK;AAGA,SAASC,QAAQC,KAAA,EAMrB;EACD,MAAMC,MAAA,GAASL,SAAA,CAAU;EACzB,MAAM;IAAEM,cAAA,EAAgBC,gBAAA;IAAkBC,UAAA,EAAYC;EAAa,IAAIL,KAAA;EAEvE,IAAIM,OAAA,CAAQC,GAAA,CAAIC,QAAA,KAAa,eAAe;IAC1C,IAAI,CAACP,MAAA,EAAQ;MACX,MAAM,IAAIQ,KAAA,CAAM,WAAW;IAC7B;IACA,MAAML,UAAA,GAAaH,MAAA,CAAOS,KAAA,CAAMP,gBAAgB;IAChD,IAAI,CAACH,KAAA,CAAMW,MAAA,IAAUP,UAAA,EAAY;MAC/B,OAAO;QAAEA;MAAW;IACtB;EACF;EAEAH,MAAA,CAAOS,KAAA,CAAMP,gBAAgB,IAAIE,YAAA;EAEjC,MAAMO,GAAA;EAAA;EAEJN,OAAA,CAAQC,GAAA,CAAIC,QAAA,KAAa,gBAAgBP,MAAA,CAAOY,iBAAA,IAAqB,MAAM;EAC7E,SAASC,sBAAsBC,IAAA,EAAgBC,QAAA,GAAW,IAAI;IAC5D,OAAO,QAAQA,QAAQ,KAAKJ,GAAG,GAAG,CAAC,GAAGG,IAAI,EAAEE,IAAA,CAAK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AA,GAAKA,EAAA;MACXI,KAAA,CAAME,WAAA,CAAYJ,QAAA,CAASK,cAAA,CAAe,GAAGR,WAAW,EAAE,CAAC;MAC3DG,QAAA,CAASM,IAAA,CAAKF,WAAA,CAAYF,KAAK;MAC/B,IAAIH,QAAA,EAAU;QACZA,QAAA,CAASQ,aAAA,EAAeC,WAAA,CAAYT,QAAQ;MAC9C;MACA,OAAO;QACLpB,eAAA;QACAU;MACF;IACF;EACF;AACF","ignoreList":[]}
|
package/dist/esm/index.native.js
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { isWeb } from "@hanzogui/constants";
|
|
2
|
-
import { createVariables, getConfig, parseFont, registerFontVariables } from "@hanzogui/web";
|
|
3
|
-
function addFont(props) {
|
|
4
|
-
var config = getConfig();
|
|
5
|
-
var {
|
|
6
|
-
fontFamilyName: fontFamilyNameIn,
|
|
7
|
-
fontFamily: fontFamilyIn
|
|
8
|
-
} = props;
|
|
9
|
-
if (process.env.NODE_ENV === "development") {
|
|
10
|
-
if (!config) {
|
|
11
|
-
throw new Error("No config");
|
|
12
|
-
}
|
|
13
|
-
var fontFamily = config.fonts[fontFamilyNameIn];
|
|
14
|
-
if (!props.update && fontFamily) {
|
|
15
|
-
return {
|
|
16
|
-
fontFamily
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
config.fonts[fontFamilyNameIn] = fontFamilyIn;
|
|
21
|
-
var sep =
|
|
22
|
-
// @ts-ignore
|
|
23
|
-
process.env.NODE_ENV === "development" ? config.cssStyleSeparator || " " : "";
|
|
24
|
-
function declarationsToRuleSet(decs) {
|
|
25
|
-
var selector = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "";
|
|
26
|
-
return `:root${selector} {${sep}${[...decs].join(`;${sep}`)}${sep}}`;
|
|
27
|
-
}
|
|
28
|
-
if (isWeb) {
|
|
29
|
-
var fontFamilyToken = createVariables(fontFamilyIn, "f", true);
|
|
30
|
-
var parsedFontFamily = parseFont(fontFamilyToken);
|
|
31
|
-
var fontFamilyNameParsed = `$${fontFamilyNameIn}`;
|
|
32
|
-
config.fontsParsed[fontFamilyNameParsed] = parsedFontFamily;
|
|
33
|
-
if (props.insertCSS) {
|
|
34
|
-
var [ff_name, ff_language] = fontFamilyNameParsed.includes("_") ? fontFamilyNameParsed.split("_") : [fontFamilyNameParsed];
|
|
35
|
-
var fontVars = registerFontVariables(parsedFontFamily);
|
|
36
|
-
var fontDeclaration = {
|
|
37
|
-
[fontFamilyNameIn]: {
|
|
38
|
-
name: ff_name.slice(1),
|
|
39
|
-
declarations: fontVars,
|
|
40
|
-
language: ff_language
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
var {
|
|
44
|
-
name,
|
|
45
|
-
declarations,
|
|
46
|
-
language = "default"
|
|
47
|
-
} = fontDeclaration[fontFamilyNameIn];
|
|
48
|
-
var fontSelector = `.font_${name}`;
|
|
49
|
-
var langSelector = `:root .t_lang-${name}-${language} ${fontSelector}`;
|
|
50
|
-
var selectors = language === "default" ? ` ${fontSelector}, ${langSelector}` : langSelector;
|
|
51
|
-
var cssRuleSets = declarationsToRuleSet(declarations, selectors);
|
|
52
|
-
var id = `t_font_style_${fontFamilyNameIn}`;
|
|
53
|
-
var existing = document.querySelector(`#${id}`);
|
|
54
|
-
var style = document.createElement("style");
|
|
55
|
-
style.id = id;
|
|
56
|
-
style.appendChild(document.createTextNode(`${cssRuleSets}`));
|
|
57
|
-
document.head.appendChild(style);
|
|
58
|
-
if (existing) {
|
|
59
|
-
var _existing_parentElement;
|
|
60
|
-
(_existing_parentElement = existing.parentElement) === null || _existing_parentElement === void 0 ? void 0 : _existing_parentElement.removeChild(existing);
|
|
61
|
-
}
|
|
62
|
-
return {
|
|
63
|
-
fontFamilyToken,
|
|
64
|
-
fontDeclaration
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
export { addFont };
|
|
70
|
-
//# sourceMappingURL=index.native.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["isWeb","createVariables","getConfig","parseFont","registerFontVariables","addFont","props","config","fontFamilyName","fontFamilyNameIn","fontFamily","fontFamilyIn","process","env","NODE_ENV","Error","fonts","update","sep","cssStyleSeparator","declarationsToRuleSet","decs","selector","arguments","length","join","fontFamilyToken","parsedFontFamily","fontFamilyNameParsed","fontsParsed","insertCSS","ff_name","ff_language","includes","split","fontVars","fontDeclaration","name","slice","declarations","language","fontSelector","langSelector","selectors","cssRuleSets","id","existing","document","querySelector","style","createElement","appendChild","createTextNode","head","_existing_parentElement","parentElement","removeChild"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,KAAA,QAAa;AACtB,SAAAC,eAAA,EAAAC,SAAA,EAAAC,SAAA,EAAAC,qBAAA;AAAA,SACEC,QAAAC,KAAA;EACA,IAAAC,MAAA,GAAAL,SAAA;EACA;IAAAM,cAAA,EAAAC,gBAAA;IAAAC,UAAA,EAAAC;EAAA,IAAAL,KAAA;EACA,IAAAM,OAAA,CAAAC,GAAA,CAAAC,QAAA;IAAA,IACK,CAAAP,MAAA;MAGA,MAAS,IAAAQ,KAAQ,YAMrB;IACD;IACA,IAAML,UAAE,GAAAH,MAAgB,CAAAS,KAAA,CAAAP,gBAAkB;IAE1C,IAAI,CAAAH,KAAQ,CAAAW,MAAI,IAAAP,UAAa;MAC3B,OAAK;QACHA;MACF;IACA;EACA;EACEH,MAAA,CAAAS,KAAO,CAAEP,gBAAW,IAAAE,YAAA;EAAA,IACtBO,GAAA;EACF;EAEAN,OAAO,CAAAC,GAAM,CAAAC,QAAA,kBAAoB,GAAAP,MAAA,CAAAY,iBAAA,YAEjC;EAAM,SAAAC,sBAAAC,IAAA;IAEJ,IAAAC,QAAY,GAAAC,SAAA,CAAaC,MAAA,QAAAD,SAAuB,iBAAAA,SAAqB,CAAM;IAAA,eAAAD,QAAA,KAAAJ,GAAA,IAC7E,GAAAG,IAAS,CACP,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