@tamagui/font 3.0.0-beta.765.1 → 3.0.0-beta.804.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 +4 -3
- package/dist/cjs/index.native.cjs +4 -3
- package/dist/cjs/index.native.js +4 -3
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/esm/index.js +2 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/index.mjs +2 -1
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/index.native.js +2 -1
- package/dist/esm/index.native.js.map +1 -1
- package/package.json +4 -4
- package/src/index.ts +7 -5
- package/types/index.d.ts +4 -2
- package/types/index.d.ts.map +1 -1
package/dist/cjs/index.cjs
CHANGED
|
@@ -23,6 +23,7 @@ __export(index_exports, { addFont: () => addFont });
|
|
|
23
23
|
module.exports = __toCommonJS(index_exports);
|
|
24
24
|
var import_constants = require("@tamagui/constants");
|
|
25
25
|
var import_web = require("@tamagui/web");
|
|
26
|
+
var import_internal_runtime = require("@tamagui/web/internal-runtime");
|
|
26
27
|
function addFont(props) {
|
|
27
28
|
const config = (0, import_web.getConfig)();
|
|
28
29
|
const { fontFamilyName: fontFamilyNameIn, fontFamily: fontFamilyIn } = props;
|
|
@@ -41,13 +42,13 @@ function addFont(props) {
|
|
|
41
42
|
return `:root${selector} {${sep}${[...decs].join(`;${sep}`)}${sep}}`;
|
|
42
43
|
}
|
|
43
44
|
if (import_constants.isWeb) {
|
|
44
|
-
const fontFamilyToken = (0,
|
|
45
|
-
const parsedFontFamily = (0,
|
|
45
|
+
const fontFamilyToken = (0, import_internal_runtime.createVariables)(fontFamilyIn, "f", true);
|
|
46
|
+
const parsedFontFamily = (0, import_internal_runtime.parseFont)(fontFamilyToken);
|
|
46
47
|
const fontFamilyNameParsed = fontFamilyNameIn;
|
|
47
48
|
config.fontsParsed[fontFamilyNameParsed] = parsedFontFamily;
|
|
48
49
|
if (props.insertCSS) {
|
|
49
50
|
const [ff_name, ff_language] = fontFamilyNameParsed.includes("_") ? fontFamilyNameParsed.split("_") : [fontFamilyNameParsed];
|
|
50
|
-
const fontVars = (0,
|
|
51
|
+
const fontVars = (0, import_internal_runtime.registerFontVariables)(parsedFontFamily);
|
|
51
52
|
const fontDeclaration = { [fontFamilyNameIn]: {
|
|
52
53
|
name: ff_name,
|
|
53
54
|
declarations: fontVars,
|
|
@@ -25,6 +25,7 @@ __export(index_exports, { addFont: () => addFont });
|
|
|
25
25
|
module.exports = __toCommonJS(index_exports);
|
|
26
26
|
var import_constants = require("@tamagui/constants");
|
|
27
27
|
var import_web = require("@tamagui/web");
|
|
28
|
+
var import_internal_runtime = require("@tamagui/web/internal-runtime");
|
|
28
29
|
function addFont(props) {
|
|
29
30
|
var config = (0, import_web.getConfig)();
|
|
30
31
|
var { fontFamilyName: fontFamilyNameIn, fontFamily: fontFamilyIn } = props;
|
|
@@ -44,13 +45,13 @@ function addFont(props) {
|
|
|
44
45
|
return `:root${selector} {${sep}${[...decs].join(`;${sep}`)}${sep}}`;
|
|
45
46
|
}
|
|
46
47
|
if (import_constants.isWeb) {
|
|
47
|
-
var fontFamilyToken = (0,
|
|
48
|
-
var parsedFontFamily = (0,
|
|
48
|
+
var fontFamilyToken = (0, import_internal_runtime.createVariables)(fontFamilyIn, "f", true);
|
|
49
|
+
var parsedFontFamily = (0, import_internal_runtime.parseFont)(fontFamilyToken);
|
|
49
50
|
var fontFamilyNameParsed = fontFamilyNameIn;
|
|
50
51
|
config.fontsParsed[fontFamilyNameParsed] = parsedFontFamily;
|
|
51
52
|
if (props.insertCSS) {
|
|
52
53
|
var [ff_name, ff_language] = fontFamilyNameParsed.includes("_") ? fontFamilyNameParsed.split("_") : [fontFamilyNameParsed];
|
|
53
|
-
var fontVars = (0,
|
|
54
|
+
var fontVars = (0, import_internal_runtime.registerFontVariables)(parsedFontFamily);
|
|
54
55
|
var fontDeclaration = { [fontFamilyNameIn]: {
|
|
55
56
|
name: ff_name,
|
|
56
57
|
declarations: fontVars,
|
package/dist/cjs/index.native.js
CHANGED
|
@@ -25,6 +25,7 @@ __export(index_exports, { addFont: () => addFont });
|
|
|
25
25
|
module.exports = __toCommonJS(index_exports);
|
|
26
26
|
var import_constants = require("@tamagui/constants");
|
|
27
27
|
var import_web = require("@tamagui/web");
|
|
28
|
+
var import_internal_runtime = require("@tamagui/web/internal-runtime");
|
|
28
29
|
function addFont(props) {
|
|
29
30
|
var config = (0, import_web.getConfig)();
|
|
30
31
|
var { fontFamilyName: fontFamilyNameIn, fontFamily: fontFamilyIn } = props;
|
|
@@ -44,13 +45,13 @@ function addFont(props) {
|
|
|
44
45
|
return `:root${selector} {${sep}${[...decs].join(`;${sep}`)}${sep}}`;
|
|
45
46
|
}
|
|
46
47
|
if (import_constants.isWeb) {
|
|
47
|
-
var fontFamilyToken = (0,
|
|
48
|
-
var parsedFontFamily = (0,
|
|
48
|
+
var fontFamilyToken = (0, import_internal_runtime.createVariables)(fontFamilyIn, "f", true);
|
|
49
|
+
var parsedFontFamily = (0, import_internal_runtime.parseFont)(fontFamilyToken);
|
|
49
50
|
var fontFamilyNameParsed = fontFamilyNameIn;
|
|
50
51
|
config.fontsParsed[fontFamilyNameParsed] = parsedFontFamily;
|
|
51
52
|
if (props.insertCSS) {
|
|
52
53
|
var [ff_name, ff_language] = fontFamilyNameParsed.includes("_") ? fontFamilyNameParsed.split("_") : [fontFamilyNameParsed];
|
|
53
|
-
var fontVars = (0,
|
|
54
|
+
var fontVars = (0, import_internal_runtime.registerFontVariables)(parsedFontFamily);
|
|
54
55
|
var fontDeclaration = { [fontFamilyNameIn]: {
|
|
55
56
|
name: ff_name,
|
|
56
57
|
declarations: fontVars,
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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\");\nvar import_internal_runtime = require(\"@tamagui/web/internal-runtime\");\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_internal_runtime.createVariables)(fontFamilyIn, \"f\", true);\n var parsedFontFamily = (0, import_internal_runtime.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_internal_runtime.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":";;;AACA,IAAI,YAAY,OAAO;AACvB,IAAI,mBAAmB,OAAO;AAC9B,IAAI,oBAAoB,OAAO;AAC/B,IAAI,eAAe,OAAO,UAAU;AACpC,IAAI,YAAY,QAAQ,QAAQ;CAC9B,KAAK,IAAI,QAAQ,KACf,UAAU,QAAQ,MAAM;EAAE,KAAK,IAAI;EAAO,YAAY;CAAK,CAAC;AAChE;AACA,IAAI,eAAe,IAAI,MAAM,QAAQ,SAAS;CAC5C,IAAI,QAAQ,OAAO,SAAS,YAAY,OAAO,SAAS,YAAY;EAClE,KAAK,IAAI,OAAO,kBAAkB,IAAI,GACpC,IAAI,CAAC,aAAa,KAAK,IAAI,GAAG,KAAK,QAAQ,QACzC,UAAU,IAAI,KAAK;GAAE,WAAW,KAAK;GAAM,YAAY,EAAE,OAAO,iBAAiB,MAAM,GAAG,MAAM,KAAK;EAAW,CAAC;CACvH;CACA,OAAO;AACT;AACA,IAAI,gBAAgB,QAAQ,YAAY,UAAU,CAAC,GAAG,cAAc,EAAE,OAAO,KAAK,CAAC,GAAG,GAAG;AACzF,IAA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ACd,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/dist/esm/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { isWeb } from "@tamagui/constants";
|
|
2
|
-
import {
|
|
2
|
+
import { getConfig } from "@tamagui/web";
|
|
3
|
+
import { createVariables, parseFont, registerFontVariables } from "@tamagui/web/internal-runtime";
|
|
3
4
|
|
|
4
5
|
function addFont(props) {
|
|
5
6
|
const config = getConfig();
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["esm/index.js"],"sourcesContent":["import { isWeb } from \"@tamagui/constants\";\nimport {\n createVariables,\n
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["esm/index.js"],"sourcesContent":["import { isWeb } from \"@tamagui/constants\";\nimport { getConfig } from \"@tamagui/web\";\nimport {\n createVariables,\n parseFont,\n registerFontVariables\n} from \"@tamagui/web/internal-runtime\";\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;C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S,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,5 +1,6 @@
|
|
|
1
1
|
import { isWeb } from "@tamagui/constants";
|
|
2
|
-
import {
|
|
2
|
+
import { getConfig } from "@tamagui/web";
|
|
3
|
+
import { createVariables, parseFont, registerFontVariables } from "@tamagui/web/internal-runtime";
|
|
3
4
|
|
|
4
5
|
function addFont(props) {
|
|
5
6
|
const config = getConfig();
|
package/dist/esm/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["esm/index.js"],"sourcesContent":["import { isWeb } from \"@tamagui/constants\";\nimport {\n createVariables,\n
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["esm/index.js"],"sourcesContent":["import { isWeb } from \"@tamagui/constants\";\nimport { getConfig } from \"@tamagui/web\";\nimport {\n createVariables,\n parseFont,\n registerFontVariables\n} from \"@tamagui/web/internal-runtime\";\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,CAAC,CAAC,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,5 +1,6 @@
|
|
|
1
1
|
import { isWeb } from "@tamagui/constants";
|
|
2
|
-
import {
|
|
2
|
+
import { getConfig } from "@tamagui/web";
|
|
3
|
+
import { createVariables, parseFont, registerFontVariables } from "@tamagui/web/internal-runtime";
|
|
3
4
|
|
|
4
5
|
function addFont(props) {
|
|
5
6
|
var config = getConfig();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.native.js","names":[],"sources":["esm/index.native.js"],"sourcesContent":["import { isWeb } from \"@tamagui/constants\";\nimport { createVariables,
|
|
1
|
+
{"version":3,"file":"index.native.js","names":[],"sources":["esm/index.native.js"],"sourcesContent":["import { isWeb } from \"@tamagui/constants\";\nimport { getConfig } from \"@tamagui/web\";\nimport { createVariables, parseFont, registerFontVariables } from \"@tamagui/web/internal-runtime\";\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":";;;;;AAGA,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,CAAC,CAAC,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.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.804.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": "3.0.0-beta.
|
|
38
|
-
"@tamagui/web": "3.0.0-beta.
|
|
37
|
+
"@tamagui/constants": "3.0.0-beta.804.1",
|
|
38
|
+
"@tamagui/web": "3.0.0-beta.804.1"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"@tamagui/build": "3.0.0-beta.
|
|
41
|
+
"@tamagui/build": "3.0.0-beta.804.1",
|
|
42
42
|
"react": "19.2.3"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
package/src/index.ts
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import { isWeb } from '@tamagui/constants'
|
|
2
|
+
import { getConfig } from '@tamagui/web'
|
|
2
3
|
import {
|
|
3
4
|
createVariables,
|
|
4
|
-
getConfig,
|
|
5
5
|
parseFont,
|
|
6
6
|
registerFontVariables,
|
|
7
|
-
} from '@tamagui/web'
|
|
7
|
+
} from '@tamagui/web/internal-runtime'
|
|
8
8
|
import type { CreateTamaguiProps } from '@tamagui/web'
|
|
9
9
|
|
|
10
|
+
type FontDefinition = NonNullable<CreateTamaguiProps['fonts']>[string]
|
|
11
|
+
|
|
10
12
|
export function addFont(props: {
|
|
11
13
|
fontFamilyName: string
|
|
12
|
-
fontFamily:
|
|
14
|
+
fontFamily: FontDefinition
|
|
13
15
|
insertCSS?: boolean
|
|
14
16
|
// TODO make sure to add updateFont
|
|
15
17
|
update?: boolean
|
|
@@ -37,7 +39,7 @@ export function addFont(props: {
|
|
|
37
39
|
}
|
|
38
40
|
|
|
39
41
|
if (isWeb) {
|
|
40
|
-
const fontFamilyToken = createVariables(fontFamilyIn, 'f', true)
|
|
42
|
+
const fontFamilyToken: FontDefinition = createVariables(fontFamilyIn, 'f', true)
|
|
41
43
|
const parsedFontFamily = parseFont(fontFamilyToken)
|
|
42
44
|
const fontFamilyNameParsed = fontFamilyNameIn
|
|
43
45
|
config.fontsParsed[fontFamilyNameParsed] = parsedFontFamily
|
|
@@ -46,7 +48,7 @@ export function addFont(props: {
|
|
|
46
48
|
const [ff_name, ff_language] = fontFamilyNameParsed.includes('_')
|
|
47
49
|
? fontFamilyNameParsed.split('_')
|
|
48
50
|
: [fontFamilyNameParsed]
|
|
49
|
-
const fontVars = registerFontVariables(parsedFontFamily)
|
|
51
|
+
const fontVars: string[] = registerFontVariables(parsedFontFamily)
|
|
50
52
|
const fontDeclaration = {
|
|
51
53
|
[fontFamilyNameIn]: {
|
|
52
54
|
name: ff_name,
|
package/types/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { CreateTamaguiProps } from '@tamagui/web';
|
|
2
|
+
type FontDefinition = NonNullable<CreateTamaguiProps['fonts']>[string];
|
|
2
3
|
export declare function addFont(props: {
|
|
3
4
|
fontFamilyName: string;
|
|
4
|
-
fontFamily:
|
|
5
|
+
fontFamily: FontDefinition;
|
|
5
6
|
insertCSS?: boolean;
|
|
6
7
|
update?: boolean;
|
|
7
8
|
}): {
|
|
@@ -10,7 +11,7 @@ export declare function addFont(props: {
|
|
|
10
11
|
fontDeclaration?: undefined;
|
|
11
12
|
} | {
|
|
12
13
|
fontFamily?: undefined;
|
|
13
|
-
fontFamilyToken:
|
|
14
|
+
fontFamilyToken: import("@tamagui/web").GenericFont<string | number | symbol>;
|
|
14
15
|
fontDeclaration: {
|
|
15
16
|
[x: string]: {
|
|
16
17
|
name: string;
|
|
@@ -19,4 +20,5 @@ export declare function addFont(props: {
|
|
|
19
20
|
};
|
|
20
21
|
};
|
|
21
22
|
} | undefined;
|
|
23
|
+
export {};
|
|
22
24
|
//# sourceMappingURL=index.d.ts.map
|
package/types/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAA;AAEtD,wBAAgB,OAAO,CAAC,KAAK,EAAE;IAC7B,cAAc,EAAE,MAAM,CAAA;IACtB,UAAU,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAA;AAEtD,KAAK,cAAc,GAAG,WAAW,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAA;AAEtE,wBAAgB,OAAO,CAAC,KAAK,EAAE;IAC7B,cAAc,EAAE,MAAM,CAAA;IACtB,UAAU,EAAE,cAAc,CAAA;IAC1B,SAAS,CAAC,EAAE,OAAO,CAAA;IAEnB,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB;;;;;;;;;;;;;;cAoEA"}
|