@tamagui/font 2.7.7 → 3.0.0-beta.643.1
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.cjs +64 -80
- package/dist/cjs/index.native.cjs +81 -0
- package/dist/cjs/index.native.js +66 -81
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/esm/index.js +51 -62
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/index.mjs +51 -62
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/index.native.js +53 -64
- package/dist/esm/index.native.js.map +1 -1
- package/package.json +4 -4
- package/src/index.ts +2 -2
- package/types/index.d.ts +1 -1
package/dist/cjs/index.cjs
CHANGED
|
@@ -1,93 +1,77 @@
|
|
|
1
|
+
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
6
|
var __export = (target, all) => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
for (var name in all) __defProp(target, name, {
|
|
8
|
+
get: all[name],
|
|
9
|
+
enumerable: true
|
|
10
|
+
});
|
|
10
11
|
};
|
|
11
12
|
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
15
|
+
get: () => from[key],
|
|
16
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
19
20
|
};
|
|
20
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
21
|
-
value: true
|
|
22
|
-
}), mod);
|
|
21
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
23
22
|
var index_exports = {};
|
|
24
|
-
__export(index_exports, {
|
|
25
|
-
addFont: () => addFont
|
|
26
|
-
});
|
|
23
|
+
__export(index_exports, { addFont: () => addFont });
|
|
27
24
|
module.exports = __toCommonJS(index_exports);
|
|
28
25
|
var import_constants = require("@tamagui/constants");
|
|
29
26
|
var import_web = require("@tamagui/web");
|
|
30
27
|
function addFont(props) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
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
|
-
}
|
|
28
|
+
const config = (0, import_web.getConfig)();
|
|
29
|
+
const { fontFamilyName: fontFamilyNameIn, fontFamily: fontFamilyIn } = props;
|
|
30
|
+
if (process.env.NODE_ENV === "development") {
|
|
31
|
+
if (!config) {
|
|
32
|
+
throw new Error("No config");
|
|
33
|
+
}
|
|
34
|
+
const fontFamily = config.fonts[fontFamilyNameIn];
|
|
35
|
+
if (!props.update && fontFamily) {
|
|
36
|
+
return { fontFamily };
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
config.fonts[fontFamilyNameIn] = fontFamilyIn;
|
|
40
|
+
const sep = process.env.NODE_ENV === "development" ? config.cssStyleSeparator || " " : "";
|
|
41
|
+
function declarationsToRuleSet(decs, selector = "") {
|
|
42
|
+
return `:root${selector} {${sep}${[...decs].join(`;${sep}`)}${sep}}`;
|
|
43
|
+
}
|
|
44
|
+
if (import_constants.isWeb) {
|
|
45
|
+
const fontFamilyToken = (0, import_web.createVariables)(fontFamilyIn, "f", true);
|
|
46
|
+
const parsedFontFamily = (0, import_web.parseFont)(fontFamilyToken);
|
|
47
|
+
const fontFamilyNameParsed = fontFamilyNameIn;
|
|
48
|
+
config.fontsParsed[fontFamilyNameParsed] = parsedFontFamily;
|
|
49
|
+
if (props.insertCSS) {
|
|
50
|
+
const [ff_name, ff_language] = fontFamilyNameParsed.includes("_") ? fontFamilyNameParsed.split("_") : [fontFamilyNameParsed];
|
|
51
|
+
const fontVars = (0, import_web.registerFontVariables)(parsedFontFamily);
|
|
52
|
+
const fontDeclaration = { [fontFamilyNameIn]: {
|
|
53
|
+
name: ff_name,
|
|
54
|
+
declarations: fontVars,
|
|
55
|
+
language: ff_language
|
|
56
|
+
} };
|
|
57
|
+
const { name, declarations, language = "default" } = fontDeclaration[fontFamilyNameIn];
|
|
58
|
+
const fontSelector = `.font_${name}`;
|
|
59
|
+
const langSelector = `:root .t_lang-${name}-${language} ${fontSelector}`;
|
|
60
|
+
const selectors = language === "default" ? ` ${fontSelector}, ${langSelector}` : langSelector;
|
|
61
|
+
const cssRuleSets = declarationsToRuleSet(declarations, selectors);
|
|
62
|
+
const id = `t_font_style_${fontFamilyNameIn}`;
|
|
63
|
+
const existing = document.querySelector(`#${id}`);
|
|
64
|
+
const style = document.createElement("style");
|
|
65
|
+
style.id = id;
|
|
66
|
+
style.appendChild(document.createTextNode(`${cssRuleSets}`));
|
|
67
|
+
document.head.appendChild(style);
|
|
68
|
+
if (existing) {
|
|
69
|
+
existing.parentElement?.removeChild(existing);
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
fontFamilyToken,
|
|
73
|
+
fontDeclaration
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all) __defProp(target, name, {
|
|
10
|
+
get: all[name],
|
|
11
|
+
enumerable: true
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
var __copyProps = (to, from, except, desc) => {
|
|
15
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
16
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
17
|
+
get: () => from[key],
|
|
18
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
22
|
+
};
|
|
23
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
24
|
+
var index_exports = {};
|
|
25
|
+
__export(index_exports, { addFont: () => addFont });
|
|
26
|
+
module.exports = __toCommonJS(index_exports);
|
|
27
|
+
var import_constants = require("@tamagui/constants");
|
|
28
|
+
var import_web = require("@tamagui/web");
|
|
29
|
+
function addFont(props) {
|
|
30
|
+
var config = (0, import_web.getConfig)();
|
|
31
|
+
var { fontFamilyName: fontFamilyNameIn, fontFamily: fontFamilyIn } = props;
|
|
32
|
+
if (process.env.NODE_ENV === "development") {
|
|
33
|
+
if (!config) {
|
|
34
|
+
throw new Error("No config");
|
|
35
|
+
}
|
|
36
|
+
var fontFamily = config.fonts[fontFamilyNameIn];
|
|
37
|
+
if (!props.update && fontFamily) {
|
|
38
|
+
return { fontFamily };
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
config.fonts[fontFamilyNameIn] = fontFamilyIn;
|
|
42
|
+
var sep = process.env.NODE_ENV === "development" ? config.cssStyleSeparator || " " : "";
|
|
43
|
+
function declarationsToRuleSet(decs) {
|
|
44
|
+
var selector = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "";
|
|
45
|
+
return `:root${selector} {${sep}${[...decs].join(`;${sep}`)}${sep}}`;
|
|
46
|
+
}
|
|
47
|
+
if (import_constants.isWeb) {
|
|
48
|
+
var fontFamilyToken = (0, import_web.createVariables)(fontFamilyIn, "f", true);
|
|
49
|
+
var parsedFontFamily = (0, import_web.parseFont)(fontFamilyToken);
|
|
50
|
+
var fontFamilyNameParsed = fontFamilyNameIn;
|
|
51
|
+
config.fontsParsed[fontFamilyNameParsed] = parsedFontFamily;
|
|
52
|
+
if (props.insertCSS) {
|
|
53
|
+
var [ff_name, ff_language] = fontFamilyNameParsed.includes("_") ? fontFamilyNameParsed.split("_") : [fontFamilyNameParsed];
|
|
54
|
+
var fontVars = (0, import_web.registerFontVariables)(parsedFontFamily);
|
|
55
|
+
var fontDeclaration = { [fontFamilyNameIn]: {
|
|
56
|
+
name: ff_name,
|
|
57
|
+
declarations: fontVars,
|
|
58
|
+
language: ff_language
|
|
59
|
+
} };
|
|
60
|
+
var { name, declarations, language = "default" } = fontDeclaration[fontFamilyNameIn];
|
|
61
|
+
var fontSelector = `.font_${name}`;
|
|
62
|
+
var langSelector = `:root .t_lang-${name}-${language} ${fontSelector}`;
|
|
63
|
+
var selectors = language === "default" ? ` ${fontSelector}, ${langSelector}` : langSelector;
|
|
64
|
+
var cssRuleSets = declarationsToRuleSet(declarations, selectors);
|
|
65
|
+
var id = `t_font_style_${fontFamilyNameIn}`;
|
|
66
|
+
var existing = document.querySelector(`#${id}`);
|
|
67
|
+
var style = document.createElement("style");
|
|
68
|
+
style.id = id;
|
|
69
|
+
style.appendChild(document.createTextNode(`${cssRuleSets}`));
|
|
70
|
+
document.head.appendChild(style);
|
|
71
|
+
if (existing) {
|
|
72
|
+
var _existing_parentElement;
|
|
73
|
+
(_existing_parentElement = existing.parentElement) === null || _existing_parentElement === void 0 ? void 0 : _existing_parentElement.removeChild(existing);
|
|
74
|
+
}
|
|
75
|
+
return {
|
|
76
|
+
fontFamilyToken,
|
|
77
|
+
fontDeclaration
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
package/dist/cjs/index.native.js
CHANGED
|
@@ -1,98 +1,83 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
|
|
3
4
|
var __defProp = Object.defineProperty;
|
|
4
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
8
|
var __export = (target, all) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
for (var name in all) __defProp(target, name, {
|
|
10
|
+
get: all[name],
|
|
11
|
+
enumerable: true
|
|
12
|
+
});
|
|
12
13
|
};
|
|
13
14
|
var __copyProps = (to, from, except, desc) => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
16
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
17
|
+
get: () => from[key],
|
|
18
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
21
22
|
};
|
|
22
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
23
|
-
value: true
|
|
24
|
-
}), mod);
|
|
23
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
24
|
var index_exports = {};
|
|
26
|
-
__export(index_exports, {
|
|
27
|
-
addFont: () => addFont
|
|
28
|
-
});
|
|
25
|
+
__export(index_exports, { addFont: () => addFont });
|
|
29
26
|
module.exports = __toCommonJS(index_exports);
|
|
30
27
|
var import_constants = require("@tamagui/constants");
|
|
31
28
|
var import_web = require("@tamagui/web");
|
|
32
29
|
function addFont(props) {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
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
|
-
}
|
|
30
|
+
var config = (0, import_web.getConfig)();
|
|
31
|
+
var { fontFamilyName: fontFamilyNameIn, fontFamily: fontFamilyIn } = props;
|
|
32
|
+
if (process.env.NODE_ENV === "development") {
|
|
33
|
+
if (!config) {
|
|
34
|
+
throw new Error("No config");
|
|
35
|
+
}
|
|
36
|
+
var fontFamily = config.fonts[fontFamilyNameIn];
|
|
37
|
+
if (!props.update && fontFamily) {
|
|
38
|
+
return { fontFamily };
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
config.fonts[fontFamilyNameIn] = fontFamilyIn;
|
|
42
|
+
var sep = process.env.NODE_ENV === "development" ? config.cssStyleSeparator || " " : "";
|
|
43
|
+
function declarationsToRuleSet(decs) {
|
|
44
|
+
var selector = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "";
|
|
45
|
+
return `:root${selector} {${sep}${[...decs].join(`;${sep}`)}${sep}}`;
|
|
46
|
+
}
|
|
47
|
+
if (import_constants.isWeb) {
|
|
48
|
+
var fontFamilyToken = (0, import_web.createVariables)(fontFamilyIn, "f", true);
|
|
49
|
+
var parsedFontFamily = (0, import_web.parseFont)(fontFamilyToken);
|
|
50
|
+
var fontFamilyNameParsed = fontFamilyNameIn;
|
|
51
|
+
config.fontsParsed[fontFamilyNameParsed] = parsedFontFamily;
|
|
52
|
+
if (props.insertCSS) {
|
|
53
|
+
var [ff_name, ff_language] = fontFamilyNameParsed.includes("_") ? fontFamilyNameParsed.split("_") : [fontFamilyNameParsed];
|
|
54
|
+
var fontVars = (0, import_web.registerFontVariables)(parsedFontFamily);
|
|
55
|
+
var fontDeclaration = { [fontFamilyNameIn]: {
|
|
56
|
+
name: ff_name,
|
|
57
|
+
declarations: fontVars,
|
|
58
|
+
language: ff_language
|
|
59
|
+
} };
|
|
60
|
+
var { name, declarations, language = "default" } = fontDeclaration[fontFamilyNameIn];
|
|
61
|
+
var fontSelector = `.font_${name}`;
|
|
62
|
+
var langSelector = `:root .t_lang-${name}-${language} ${fontSelector}`;
|
|
63
|
+
var selectors = language === "default" ? ` ${fontSelector}, ${langSelector}` : langSelector;
|
|
64
|
+
var cssRuleSets = declarationsToRuleSet(declarations, selectors);
|
|
65
|
+
var id = `t_font_style_${fontFamilyNameIn}`;
|
|
66
|
+
var existing = document.querySelector(`#${id}`);
|
|
67
|
+
var style = document.createElement("style");
|
|
68
|
+
style.id = id;
|
|
69
|
+
style.appendChild(document.createTextNode(`${cssRuleSets}`));
|
|
70
|
+
document.head.appendChild(style);
|
|
71
|
+
if (existing) {
|
|
72
|
+
var _existing_parentElement;
|
|
73
|
+
(_existing_parentElement = existing.parentElement) === null || _existing_parentElement === void 0 ? void 0 : _existing_parentElement.removeChild(existing);
|
|
74
|
+
}
|
|
75
|
+
return {
|
|
76
|
+
fontFamilyToken,
|
|
77
|
+
fontDeclaration
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
}
|
|
97
81
|
}
|
|
82
|
+
|
|
98
83
|
//# sourceMappingURL=index.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"index.native.js","names":[],"sources":["cjs/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(\"@tamagui/constants\");\nvar import_web = require(\"@tamagui/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,\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":"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"}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,68 +1,57 @@
|
|
|
1
1
|
import { isWeb } from "@tamagui/constants";
|
|
2
2
|
import { createVariables, getConfig, parseFont, registerFontVariables } from "@tamagui/web";
|
|
3
|
+
|
|
3
4
|
function addFont(props) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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
|
-
}
|
|
5
|
+
const config = getConfig();
|
|
6
|
+
const { fontFamilyName: fontFamilyNameIn, fontFamily: fontFamilyIn } = props;
|
|
7
|
+
if (process.env.NODE_ENV === "development") {
|
|
8
|
+
if (!config) {
|
|
9
|
+
throw new Error("No config");
|
|
10
|
+
}
|
|
11
|
+
const fontFamily = config.fonts[fontFamilyNameIn];
|
|
12
|
+
if (!props.update && fontFamily) {
|
|
13
|
+
return { fontFamily };
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
config.fonts[fontFamilyNameIn] = fontFamilyIn;
|
|
17
|
+
const sep = process.env.NODE_ENV === "development" ? config.cssStyleSeparator || " " : "";
|
|
18
|
+
function declarationsToRuleSet(decs, selector = "") {
|
|
19
|
+
return `:root${selector} {${sep}${[...decs].join(`;${sep}`)}${sep}}`;
|
|
20
|
+
}
|
|
21
|
+
if (isWeb) {
|
|
22
|
+
const fontFamilyToken = createVariables(fontFamilyIn, "f", true);
|
|
23
|
+
const parsedFontFamily = parseFont(fontFamilyToken);
|
|
24
|
+
const fontFamilyNameParsed = fontFamilyNameIn;
|
|
25
|
+
config.fontsParsed[fontFamilyNameParsed] = parsedFontFamily;
|
|
26
|
+
if (props.insertCSS) {
|
|
27
|
+
const [ff_name, ff_language] = fontFamilyNameParsed.includes("_") ? fontFamilyNameParsed.split("_") : [fontFamilyNameParsed];
|
|
28
|
+
const fontVars = registerFontVariables(parsedFontFamily);
|
|
29
|
+
const fontDeclaration = { [fontFamilyNameIn]: {
|
|
30
|
+
name: ff_name,
|
|
31
|
+
declarations: fontVars,
|
|
32
|
+
language: ff_language
|
|
33
|
+
} };
|
|
34
|
+
const { name, declarations, language = "default" } = fontDeclaration[fontFamilyNameIn];
|
|
35
|
+
const fontSelector = `.font_${name}`;
|
|
36
|
+
const langSelector = `:root .t_lang-${name}-${language} ${fontSelector}`;
|
|
37
|
+
const selectors = language === "default" ? ` ${fontSelector}, ${langSelector}` : langSelector;
|
|
38
|
+
const cssRuleSets = declarationsToRuleSet(declarations, selectors);
|
|
39
|
+
const id = `t_font_style_${fontFamilyNameIn}`;
|
|
40
|
+
const existing = document.querySelector(`#${id}`);
|
|
41
|
+
const style = document.createElement("style");
|
|
42
|
+
style.id = id;
|
|
43
|
+
style.appendChild(document.createTextNode(`${cssRuleSets}`));
|
|
44
|
+
document.head.appendChild(style);
|
|
45
|
+
if (existing) {
|
|
46
|
+
existing.parentElement?.removeChild(existing);
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
fontFamilyToken,
|
|
50
|
+
fontDeclaration
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
}
|
|
66
54
|
}
|
|
55
|
+
|
|
67
56
|
export { addFont };
|
|
68
57
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["esm/index.js"],"sourcesContent":["import { isWeb } from \"@tamagui/constants\";\nimport {\n createVariables,\n getConfig,\n parseFont,\n registerFontVariables\n} from \"@tamagui/web\";\nfunction addFont(props) {\n const config = getConfig();\n const { fontFamilyName: fontFamilyNameIn, fontFamily: fontFamilyIn } = props;\n if (process.env.NODE_ENV === \"development\") {\n if (!config) {\n throw new Error(\"No config\");\n }\n const fontFamily = config.fonts[fontFamilyNameIn];\n if (!props.update && fontFamily) {\n return { fontFamily };\n }\n }\n config.fonts[fontFamilyNameIn] = fontFamilyIn;\n const sep = (\n // @ts-ignore\n process.env.NODE_ENV === \"development\" ? config.cssStyleSeparator || \" \" : \"\"\n );\n function declarationsToRuleSet(decs, selector = \"\") {\n return `:root${selector} {${sep}${[...decs].join(`;${sep}`)}${sep}}`;\n }\n if (isWeb) {\n const fontFamilyToken = createVariables(fontFamilyIn, \"f\", true);\n const parsedFontFamily = parseFont(fontFamilyToken);\n const fontFamilyNameParsed = fontFamilyNameIn;\n config.fontsParsed[fontFamilyNameParsed] = parsedFontFamily;\n if (props.insertCSS) {\n const [ff_name, ff_language] = fontFamilyNameParsed.includes(\"_\") ? fontFamilyNameParsed.split(\"_\") : [fontFamilyNameParsed];\n const fontVars = registerFontVariables(parsedFontFamily);\n const fontDeclaration = {\n [fontFamilyNameIn]: {\n name: ff_name,\n declarations: fontVars,\n language: ff_language\n }\n };\n const {\n name,\n declarations,\n language = \"default\"\n } = fontDeclaration[fontFamilyNameIn];\n const fontSelector = `.font_${name}`;\n const langSelector = `:root .t_lang-${name}-${language} ${fontSelector}`;\n const selectors = language === \"default\" ? ` ${fontSelector}, ${langSelector}` : langSelector;\n const cssRuleSets = declarationsToRuleSet(declarations, selectors);\n const id = `t_font_style_${fontFamilyNameIn}`;\n const existing = document.querySelector(`#${id}`);\n const style = document.createElement(\"style\");\n style.id = id;\n style.appendChild(document.createTextNode(`${cssRuleSets}`));\n document.head.appendChild(style);\n if (existing) {\n existing.parentElement?.removeChild(existing);\n }\n return {\n fontFamilyToken,\n fontDeclaration\n };\n }\n }\n}\nexport {\n addFont\n};\n//# sourceMappingURL=index.js.map\n"],"mappings":";;;;AAOA,SAAS,QAAQ,OAAO;CACtB,MAAM,SAAS,UAAU;CACzB,MAAM,EAAE,gBAAgB,kBAAkB,YAAY,iBAAiB;CACvE,IAAI,QAAQ,IAAI,aAAa,eAAe;EAC1C,IAAI,CAAC,QAAQ;GACX,MAAM,IAAI,MAAM,WAAW;EAC7B;EACA,MAAM,aAAa,OAAO,MAAM;EAChC,IAAI,CAAC,MAAM,UAAU,YAAY;GAC/B,OAAO,EAAE,WAAW;EACtB;CACF;CACA,OAAO,MAAM,oBAAoB;CACjC,MAAM,MAEJ,QAAQ,IAAI,aAAa,gBAAgB,OAAO,qBAAqB,MAAM;CAE7E,SAAS,sBAAsB,MAAM,WAAW,IAAI;EAClD,OAAO,QAAQ,SAAS,IAAI,MAAM,CAAC,GAAG,IAAI,EAAE,KAAK,IAAI,KAAK,IAAI,IAAI;CACpE;CACA,IAAI,OAAO;EACT,MAAM,kBAAkB,gBAAgB,cAAc,KAAK,IAAI;EAC/D,MAAM,mBAAmB,UAAU,eAAe;EAClD,MAAM,uBAAuB;EAC7B,OAAO,YAAY,wBAAwB;EAC3C,IAAI,MAAM,WAAW;GACnB,MAAM,CAAC,SAAS,eAAe,qBAAqB,SAAS,GAAG,IAAI,qBAAqB,MAAM,GAAG,IAAI,CAAC,oBAAoB;GAC3H,MAAM,WAAW,sBAAsB,gBAAgB;GACvD,MAAM,kBAAkB,GACrB,mBAAmB;IAClB,MAAM;IACN,cAAc;IACd,UAAU;GACZ,EACF;GACA,MAAM,EACJ,MACA,cACA,WAAW,cACT,gBAAgB;GACpB,MAAM,eAAe,SAAS;GAC9B,MAAM,eAAe,iBAAiB,KAAK,GAAG,SAAS,GAAG;GAC1D,MAAM,YAAY,aAAa,YAAY,IAAI,aAAa,IAAI,iBAAiB;GACjF,MAAM,cAAc,sBAAsB,cAAc,SAAS;GACjE,MAAM,KAAK,gBAAgB;GAC3B,MAAM,WAAW,SAAS,cAAc,IAAI,IAAI;GAChD,MAAM,QAAQ,SAAS,cAAc,OAAO;GAC5C,MAAM,KAAK;GACX,MAAM,YAAY,SAAS,eAAe,GAAG,aAAa,CAAC;GAC3D,SAAS,KAAK,YAAY,KAAK;GAC/B,IAAI,UAAU;IACZ,SAAS,eAAe,YAAY,QAAQ;GAC9C;GACA,OAAO;IACL;IACA;GACF;EACF;CACF;AACF"}
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,68 +1,57 @@
|
|
|
1
1
|
import { isWeb } from "@tamagui/constants";
|
|
2
2
|
import { createVariables, getConfig, parseFont, registerFontVariables } from "@tamagui/web";
|
|
3
|
+
|
|
3
4
|
function addFont(props) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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
|
-
}
|
|
5
|
+
const config = getConfig();
|
|
6
|
+
const { fontFamilyName: fontFamilyNameIn, fontFamily: fontFamilyIn } = props;
|
|
7
|
+
if (process.env.NODE_ENV === "development") {
|
|
8
|
+
if (!config) {
|
|
9
|
+
throw new Error("No config");
|
|
10
|
+
}
|
|
11
|
+
const fontFamily = config.fonts[fontFamilyNameIn];
|
|
12
|
+
if (!props.update && fontFamily) {
|
|
13
|
+
return { fontFamily };
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
config.fonts[fontFamilyNameIn] = fontFamilyIn;
|
|
17
|
+
const sep = process.env.NODE_ENV === "development" ? config.cssStyleSeparator || " " : "";
|
|
18
|
+
function declarationsToRuleSet(decs, selector = "") {
|
|
19
|
+
return `:root${selector} {${sep}${[...decs].join(`;${sep}`)}${sep}}`;
|
|
20
|
+
}
|
|
21
|
+
if (isWeb) {
|
|
22
|
+
const fontFamilyToken = createVariables(fontFamilyIn, "f", true);
|
|
23
|
+
const parsedFontFamily = parseFont(fontFamilyToken);
|
|
24
|
+
const fontFamilyNameParsed = fontFamilyNameIn;
|
|
25
|
+
config.fontsParsed[fontFamilyNameParsed] = parsedFontFamily;
|
|
26
|
+
if (props.insertCSS) {
|
|
27
|
+
const [ff_name, ff_language] = fontFamilyNameParsed.includes("_") ? fontFamilyNameParsed.split("_") : [fontFamilyNameParsed];
|
|
28
|
+
const fontVars = registerFontVariables(parsedFontFamily);
|
|
29
|
+
const fontDeclaration = { [fontFamilyNameIn]: {
|
|
30
|
+
name: ff_name,
|
|
31
|
+
declarations: fontVars,
|
|
32
|
+
language: ff_language
|
|
33
|
+
} };
|
|
34
|
+
const { name, declarations, language = "default" } = fontDeclaration[fontFamilyNameIn];
|
|
35
|
+
const fontSelector = `.font_${name}`;
|
|
36
|
+
const langSelector = `:root .t_lang-${name}-${language} ${fontSelector}`;
|
|
37
|
+
const selectors = language === "default" ? ` ${fontSelector}, ${langSelector}` : langSelector;
|
|
38
|
+
const cssRuleSets = declarationsToRuleSet(declarations, selectors);
|
|
39
|
+
const id = `t_font_style_${fontFamilyNameIn}`;
|
|
40
|
+
const existing = document.querySelector(`#${id}`);
|
|
41
|
+
const style = document.createElement("style");
|
|
42
|
+
style.id = id;
|
|
43
|
+
style.appendChild(document.createTextNode(`${cssRuleSets}`));
|
|
44
|
+
document.head.appendChild(style);
|
|
45
|
+
if (existing) {
|
|
46
|
+
existing.parentElement?.removeChild(existing);
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
fontFamilyToken,
|
|
50
|
+
fontDeclaration
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
}
|
|
66
54
|
}
|
|
55
|
+
|
|
67
56
|
export { addFont };
|
|
68
57
|
//# sourceMappingURL=index.mjs.map
|
package/dist/esm/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["esm/index.js"],"sourcesContent":["import { isWeb } from \"@tamagui/constants\";\nimport {\n createVariables,\n getConfig,\n parseFont,\n registerFontVariables\n} from \"@tamagui/web\";\nfunction addFont(props) {\n const config = getConfig();\n const { fontFamilyName: fontFamilyNameIn, fontFamily: fontFamilyIn } = props;\n if (process.env.NODE_ENV === \"development\") {\n if (!config) {\n throw new Error(\"No config\");\n }\n const fontFamily = config.fonts[fontFamilyNameIn];\n if (!props.update && fontFamily) {\n return { fontFamily };\n }\n }\n config.fonts[fontFamilyNameIn] = fontFamilyIn;\n const sep = (\n // @ts-ignore\n process.env.NODE_ENV === \"development\" ? config.cssStyleSeparator || \" \" : \"\"\n );\n function declarationsToRuleSet(decs, selector = \"\") {\n return `:root${selector} {${sep}${[...decs].join(`;${sep}`)}${sep}}`;\n }\n if (isWeb) {\n const fontFamilyToken = createVariables(fontFamilyIn, \"f\", true);\n const parsedFontFamily = parseFont(fontFamilyToken);\n const fontFamilyNameParsed = fontFamilyNameIn;\n config.fontsParsed[fontFamilyNameParsed] = parsedFontFamily;\n if (props.insertCSS) {\n const [ff_name, ff_language] = fontFamilyNameParsed.includes(\"_\") ? fontFamilyNameParsed.split(\"_\") : [fontFamilyNameParsed];\n const fontVars = registerFontVariables(parsedFontFamily);\n const fontDeclaration = {\n [fontFamilyNameIn]: {\n name: ff_name,\n declarations: fontVars,\n language: ff_language\n }\n };\n const {\n name,\n declarations,\n language = \"default\"\n } = fontDeclaration[fontFamilyNameIn];\n const fontSelector = `.font_${name}`;\n const langSelector = `:root .t_lang-${name}-${language} ${fontSelector}`;\n const selectors = language === \"default\" ? ` ${fontSelector}, ${langSelector}` : langSelector;\n const cssRuleSets = declarationsToRuleSet(declarations, selectors);\n const id = `t_font_style_${fontFamilyNameIn}`;\n const existing = document.querySelector(`#${id}`);\n const style = document.createElement(\"style\");\n style.id = id;\n style.appendChild(document.createTextNode(`${cssRuleSets}`));\n document.head.appendChild(style);\n if (existing) {\n existing.parentElement?.removeChild(existing);\n }\n return {\n fontFamilyToken,\n fontDeclaration\n };\n }\n }\n}\nexport {\n addFont\n};\n//# sourceMappingURL=index.js.map\n"],"mappings":";;;;AAOA,SAAS,QAAQ,OAAO;CACtB,MAAM,SAAS,UAAU;CACzB,MAAM,EAAE,gBAAgB,kBAAkB,YAAY,iBAAiB;CACvE,IAAI,QAAQ,IAAI,aAAa,eAAe;EAC1C,IAAI,CAAC,QAAQ;GACX,MAAM,IAAI,MAAM,WAAW;EAC7B;EACA,MAAM,aAAa,OAAO,MAAM;EAChC,IAAI,CAAC,MAAM,UAAU,YAAY;GAC/B,OAAO,EAAE,WAAW;EACtB;CACF;CACA,OAAO,MAAM,oBAAoB;CACjC,MAAM,MAEJ,QAAQ,IAAI,aAAa,gBAAgB,OAAO,qBAAqB,MAAM;CAE7E,SAAS,sBAAsB,MAAM,WAAW,IAAI;EAClD,OAAO,QAAQ,SAAS,IAAI,MAAM,CAAC,GAAG,IAAI,EAAE,KAAK,IAAI,KAAK,IAAI,IAAI;CACpE;CACA,IAAI,OAAO;EACT,MAAM,kBAAkB,gBAAgB,cAAc,KAAK,IAAI;EAC/D,MAAM,mBAAmB,UAAU,eAAe;EAClD,MAAM,uBAAuB;EAC7B,OAAO,YAAY,wBAAwB;EAC3C,IAAI,MAAM,WAAW;GACnB,MAAM,CAAC,SAAS,eAAe,qBAAqB,SAAS,GAAG,IAAI,qBAAqB,MAAM,GAAG,IAAI,CAAC,oBAAoB;GAC3H,MAAM,WAAW,sBAAsB,gBAAgB;GACvD,MAAM,kBAAkB,GACrB,mBAAmB;IAClB,MAAM;IACN,cAAc;IACd,UAAU;GACZ,EACF;GACA,MAAM,EACJ,MACA,cACA,WAAW,cACT,gBAAgB;GACpB,MAAM,eAAe,SAAS;GAC9B,MAAM,eAAe,iBAAiB,KAAK,GAAG,SAAS,GAAG;GAC1D,MAAM,YAAY,aAAa,YAAY,IAAI,aAAa,IAAI,iBAAiB;GACjF,MAAM,cAAc,sBAAsB,cAAc,SAAS;GACjE,MAAM,KAAK,gBAAgB;GAC3B,MAAM,WAAW,SAAS,cAAc,IAAI,IAAI;GAChD,MAAM,QAAQ,SAAS,cAAc,OAAO;GAC5C,MAAM,KAAK;GACX,MAAM,YAAY,SAAS,eAAe,GAAG,aAAa,CAAC;GAC3D,SAAS,KAAK,YAAY,KAAK;GAC/B,IAAI,UAAU;IACZ,SAAS,eAAe,YAAY,QAAQ;GAC9C;GACA,OAAO;IACL;IACA;GACF;EACF;CACF;AACF"}
|
package/dist/esm/index.native.js
CHANGED
|
@@ -1,70 +1,59 @@
|
|
|
1
1
|
import { isWeb } from "@tamagui/constants";
|
|
2
2
|
import { createVariables, getConfig, parseFont, registerFontVariables } from "@tamagui/web";
|
|
3
|
+
|
|
3
4
|
function addFont(props) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
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
|
-
}
|
|
5
|
+
var config = getConfig();
|
|
6
|
+
var { fontFamilyName: fontFamilyNameIn, fontFamily: fontFamilyIn } = props;
|
|
7
|
+
if (process.env.NODE_ENV === "development") {
|
|
8
|
+
if (!config) {
|
|
9
|
+
throw new Error("No config");
|
|
10
|
+
}
|
|
11
|
+
var fontFamily = config.fonts[fontFamilyNameIn];
|
|
12
|
+
if (!props.update && fontFamily) {
|
|
13
|
+
return { fontFamily };
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
config.fonts[fontFamilyNameIn] = fontFamilyIn;
|
|
17
|
+
var sep = process.env.NODE_ENV === "development" ? config.cssStyleSeparator || " " : "";
|
|
18
|
+
function declarationsToRuleSet(decs) {
|
|
19
|
+
var selector = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "";
|
|
20
|
+
return `:root${selector} {${sep}${[...decs].join(`;${sep}`)}${sep}}`;
|
|
21
|
+
}
|
|
22
|
+
if (isWeb) {
|
|
23
|
+
var fontFamilyToken = createVariables(fontFamilyIn, "f", true);
|
|
24
|
+
var parsedFontFamily = parseFont(fontFamilyToken);
|
|
25
|
+
var fontFamilyNameParsed = fontFamilyNameIn;
|
|
26
|
+
config.fontsParsed[fontFamilyNameParsed] = parsedFontFamily;
|
|
27
|
+
if (props.insertCSS) {
|
|
28
|
+
var [ff_name, ff_language] = fontFamilyNameParsed.includes("_") ? fontFamilyNameParsed.split("_") : [fontFamilyNameParsed];
|
|
29
|
+
var fontVars = registerFontVariables(parsedFontFamily);
|
|
30
|
+
var fontDeclaration = { [fontFamilyNameIn]: {
|
|
31
|
+
name: ff_name,
|
|
32
|
+
declarations: fontVars,
|
|
33
|
+
language: ff_language
|
|
34
|
+
} };
|
|
35
|
+
var { name, declarations, language = "default" } = fontDeclaration[fontFamilyNameIn];
|
|
36
|
+
var fontSelector = `.font_${name}`;
|
|
37
|
+
var langSelector = `:root .t_lang-${name}-${language} ${fontSelector}`;
|
|
38
|
+
var selectors = language === "default" ? ` ${fontSelector}, ${langSelector}` : langSelector;
|
|
39
|
+
var cssRuleSets = declarationsToRuleSet(declarations, selectors);
|
|
40
|
+
var id = `t_font_style_${fontFamilyNameIn}`;
|
|
41
|
+
var existing = document.querySelector(`#${id}`);
|
|
42
|
+
var style = document.createElement("style");
|
|
43
|
+
style.id = id;
|
|
44
|
+
style.appendChild(document.createTextNode(`${cssRuleSets}`));
|
|
45
|
+
document.head.appendChild(style);
|
|
46
|
+
if (existing) {
|
|
47
|
+
var _existing_parentElement;
|
|
48
|
+
(_existing_parentElement = existing.parentElement) === null || _existing_parentElement === void 0 ? void 0 : _existing_parentElement.removeChild(existing);
|
|
49
|
+
}
|
|
50
|
+
return {
|
|
51
|
+
fontFamilyToken,
|
|
52
|
+
fontDeclaration
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
}
|
|
68
56
|
}
|
|
57
|
+
|
|
69
58
|
export { addFont };
|
|
70
59
|
//# sourceMappingURL=index.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"index.native.js","names":[],"sources":["esm/index.native.js"],"sourcesContent":["import { isWeb } from \"@tamagui/constants\";\nimport { createVariables, getConfig, parseFont, registerFontVariables } from \"@tamagui/web\";\nfunction addFont(props) {\n var config = 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 (isWeb) {\n var fontFamilyToken = createVariables(fontFamilyIn, \"f\", true);\n var parsedFontFamily = 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 = registerFontVariables(parsedFontFamily);\n var fontDeclaration = {\n [fontFamilyNameIn]: {\n name: ff_name,\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}\nexport {\n addFont\n};\n//# sourceMappingURL=index.js.map\n"],"mappings":";;;;AAEA,SAAS,QAAQ,OAAO;CACtB,IAAI,SAAS,UAAU;CACvB,IAAI,EAAE,gBAAgB,kBAAkB,YAAY,iBAAiB;CACrE,IAAI,QAAQ,IAAI,aAAa,eAAe;EAC1C,IAAI,CAAC,QAAQ;GACX,MAAM,IAAI,MAAM,WAAW;EAC7B;EACA,IAAI,aAAa,OAAO,MAAM;EAC9B,IAAI,CAAC,MAAM,UAAU,YAAY;GAC/B,OAAO,EACL,WACF;EACF;CACF;CACA,OAAO,MAAM,oBAAoB;CACjC,IAAI,MAEF,QAAQ,IAAI,aAAa,gBAAgB,OAAO,qBAAqB,MAAM;CAE7E,SAAS,sBAAsB,MAAM;EACnC,IAAI,WAAW,UAAU,SAAS,KAAK,UAAU,OAAO,KAAK,IAAI,UAAU,KAAK;EAChF,OAAO,QAAQ,SAAS,IAAI,MAAM,CAChC,GAAG,IACL,EAAE,KAAK,IAAI,KAAK,IAAI,IAAI;CAC1B;CACA,IAAI,OAAO;EACT,IAAI,kBAAkB,gBAAgB,cAAc,KAAK,IAAI;EAC7D,IAAI,mBAAmB,UAAU,eAAe;EAChD,IAAI,uBAAuB;EAC3B,OAAO,YAAY,wBAAwB;EAC3C,IAAI,MAAM,WAAW;GACnB,IAAI,CAAC,SAAS,eAAe,qBAAqB,SAAS,GAAG,IAAI,qBAAqB,MAAM,GAAG,IAAI,CAClG,oBACF;GACA,IAAI,WAAW,sBAAsB,gBAAgB;GACrD,IAAI,kBAAkB,GACnB,mBAAmB;IAClB,MAAM;IACN,cAAc;IACd,UAAU;GACZ,EACF;GACA,IAAI,EAAE,MAAM,cAAc,WAAW,cAAc,gBAAgB;GACnE,IAAI,eAAe,SAAS;GAC5B,IAAI,eAAe,iBAAiB,KAAK,GAAG,SAAS,GAAG;GACxD,IAAI,YAAY,aAAa,YAAY,IAAI,aAAa,IAAI,iBAAiB;GAC/E,IAAI,cAAc,sBAAsB,cAAc,SAAS;GAC/D,IAAI,KAAK,gBAAgB;GACzB,IAAI,WAAW,SAAS,cAAc,IAAI,IAAI;GAC9C,IAAI,QAAQ,SAAS,cAAc,OAAO;GAC1C,MAAM,KAAK;GACX,MAAM,YAAY,SAAS,eAAe,GAAG,aAAa,CAAC;GAC3D,SAAS,KAAK,YAAY,KAAK;GAC/B,IAAI,UAAU;IACZ,IAAI;IACJ,CAAC,0BAA0B,SAAS,mBAAmB,QAAQ,4BAA4B,KAAK,IAAI,KAAK,IAAI,wBAAwB,YAAY,QAAQ;GAC3J;GACA,OAAO;IACL;IACA;GACF;EACF;CACF;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/font",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0-beta.643.1",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"files": [
|
|
6
6
|
"src",
|
|
@@ -34,11 +34,11 @@
|
|
|
34
34
|
"clean:build": "tamagui-build clean:build"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@tamagui/constants": "
|
|
38
|
-
"@tamagui/web": "
|
|
37
|
+
"@tamagui/constants": "3.0.0-beta.643.1",
|
|
38
|
+
"@tamagui/web": "3.0.0-beta.643.1"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"@tamagui/build": "
|
|
41
|
+
"@tamagui/build": "3.0.0-beta.643.1",
|
|
42
42
|
"react": ">=19"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
package/src/index.ts
CHANGED
|
@@ -39,7 +39,7 @@ export function addFont(props: {
|
|
|
39
39
|
if (isWeb) {
|
|
40
40
|
const fontFamilyToken = createVariables(fontFamilyIn, 'f', true)
|
|
41
41
|
const parsedFontFamily = parseFont(fontFamilyToken)
|
|
42
|
-
const fontFamilyNameParsed =
|
|
42
|
+
const fontFamilyNameParsed = fontFamilyNameIn
|
|
43
43
|
config.fontsParsed[fontFamilyNameParsed] = parsedFontFamily
|
|
44
44
|
|
|
45
45
|
if (props.insertCSS) {
|
|
@@ -49,7 +49,7 @@ export function addFont(props: {
|
|
|
49
49
|
const fontVars = registerFontVariables(parsedFontFamily)
|
|
50
50
|
const fontDeclaration = {
|
|
51
51
|
[fontFamilyNameIn]: {
|
|
52
|
-
name: ff_name
|
|
52
|
+
name: ff_name,
|
|
53
53
|
declarations: fontVars,
|
|
54
54
|
language: ff_language,
|
|
55
55
|
},
|
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
|