@tamagui/font 1.116.1 → 1.116.3
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.
|
@@ -0,0 +1,56 @@
|
|
|
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)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
8
|
+
}, __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from == "object" || typeof from == "function")
|
|
10
|
+
for (let key of __getOwnPropNames(from))
|
|
11
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
15
|
+
var src_exports = {};
|
|
16
|
+
__export(src_exports, {
|
|
17
|
+
addFont: () => addFont
|
|
18
|
+
});
|
|
19
|
+
module.exports = __toCommonJS(src_exports);
|
|
20
|
+
var import_constants = require("@tamagui/constants"), import_web = require("@tamagui/web");
|
|
21
|
+
function addFont(props) {
|
|
22
|
+
const config = (0, import_web.getConfig)(), { fontFamilyName: fontFamilyNameIn, fontFamily: fontFamilyIn } = props;
|
|
23
|
+
if (process.env.NODE_ENV === "development") {
|
|
24
|
+
if (!config)
|
|
25
|
+
throw new Error("No config");
|
|
26
|
+
const fontFamily = config.fonts[fontFamilyNameIn];
|
|
27
|
+
if (!props.update && fontFamily)
|
|
28
|
+
return { fontFamily };
|
|
29
|
+
}
|
|
30
|
+
config.fonts[fontFamilyNameIn] = fontFamilyIn;
|
|
31
|
+
const sep = process.env.NODE_ENV === "development" ? config.cssStyleSeparator || " " : "";
|
|
32
|
+
function declarationsToRuleSet(decs, selector = "") {
|
|
33
|
+
return `:root${selector} {${sep}${[...decs].join(`;${sep}`)}${sep}}`;
|
|
34
|
+
}
|
|
35
|
+
if (import_constants.isWeb) {
|
|
36
|
+
const fontFamilyToken = (0, import_web.createVariables)(fontFamilyIn, "f", !0), parsedFontFamily = (0, import_web.parseFont)(fontFamilyToken), fontFamilyNameParsed = `$${fontFamilyNameIn}`;
|
|
37
|
+
if (config.fontsParsed[fontFamilyNameParsed] = parsedFontFamily, props.insertCSS) {
|
|
38
|
+
const [ff_name, ff_language] = fontFamilyNameParsed.includes("_") ? fontFamilyNameParsed.split("_") : [fontFamilyNameParsed], fontVars = (0, import_web.registerFontVariables)(parsedFontFamily), fontDeclaration = {
|
|
39
|
+
[fontFamilyNameIn]: {
|
|
40
|
+
name: ff_name.slice(1),
|
|
41
|
+
declarations: fontVars,
|
|
42
|
+
language: ff_language
|
|
43
|
+
}
|
|
44
|
+
}, {
|
|
45
|
+
name,
|
|
46
|
+
declarations,
|
|
47
|
+
language = "default"
|
|
48
|
+
} = fontDeclaration[fontFamilyNameIn], fontSelector = `.font_${name}`, langSelector = `:root .t_lang-${name}-${language} ${fontSelector}`, selectors = language === "default" ? ` ${fontSelector}, ${langSelector}` : langSelector, cssRuleSets = declarationsToRuleSet(declarations, selectors), id = `t_font_style_${fontFamilyNameIn}`, existing = document.querySelector(`#${id}`), style = document.createElement("style");
|
|
49
|
+
return style.id = id, style.appendChild(document.createTextNode(`${cssRuleSets}`)), document.head.appendChild(style), existing && existing.parentElement?.removeChild(existing), {
|
|
50
|
+
fontFamilyToken,
|
|
51
|
+
fontDeclaration
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/font",
|
|
3
|
-
"version": "1.116.
|
|
3
|
+
"version": "1.116.3",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"source": "src/index.ts",
|
|
6
6
|
"types": "./types/index.d.ts",
|
|
@@ -21,11 +21,11 @@
|
|
|
21
21
|
"clean:build": "tamagui-build clean:build"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@tamagui/constants": "1.116.
|
|
25
|
-
"@tamagui/web": "1.116.
|
|
24
|
+
"@tamagui/constants": "1.116.3",
|
|
25
|
+
"@tamagui/web": "1.116.3"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@tamagui/build": "1.116.
|
|
28
|
+
"@tamagui/build": "1.116.3",
|
|
29
29
|
"react": "^18.2.0 || ^19.0.0"
|
|
30
30
|
},
|
|
31
31
|
"publishConfig": {
|
|
File without changes
|