@tamagui/font 1.61.3 → 1.62.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.js +15 -43
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/index.native.js +61 -0
- package/dist/cjs/index.native.js.map +6 -0
- package/dist/esm/index.js +9 -32
- package/dist/esm/index.js.map +1 -1
- package/dist/jsx/index.js +9 -31
- package/dist/jsx/index.js.map +1 -1
- package/dist/jsx/index.native.js +46 -0
- package/dist/jsx/index.native.js.map +6 -0
- package/package.json +4 -4
package/dist/cjs/index.js
CHANGED
|
@@ -1,40 +1,31 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __defProp = Object.defineProperty;
|
|
3
2
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
5
|
var __export = (target, all) => {
|
|
7
6
|
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable:
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
8
|
+
}, __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from == "object" || typeof from == "function")
|
|
12
10
|
for (let key of __getOwnPropNames(from))
|
|
13
|
-
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
11
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
12
|
return to;
|
|
17
13
|
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value:
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
19
15
|
var src_exports = {};
|
|
20
16
|
__export(src_exports, {
|
|
21
17
|
addFont: () => addFont
|
|
22
18
|
});
|
|
23
19
|
module.exports = __toCommonJS(src_exports);
|
|
24
|
-
var import_constants = require("@tamagui/constants");
|
|
25
|
-
var import_web = require("@tamagui/web");
|
|
20
|
+
var import_constants = require("@tamagui/constants"), import_web = require("@tamagui/web");
|
|
26
21
|
function addFont(props) {
|
|
27
|
-
|
|
28
|
-
const config = (0, import_web.getConfig)();
|
|
29
|
-
const { fontFamilyName: fontFamilyNameIn, fontFamily: fontFamilyIn } = props;
|
|
22
|
+
const config = (0, import_web.getConfig)(), { fontFamilyName: fontFamilyNameIn, fontFamily: fontFamilyIn } = props;
|
|
30
23
|
if (process.env.NODE_ENV === "development") {
|
|
31
|
-
if (!config)
|
|
24
|
+
if (!config)
|
|
32
25
|
throw new Error("No config");
|
|
33
|
-
}
|
|
34
26
|
const fontFamily = config.fonts[fontFamilyNameIn];
|
|
35
|
-
if (!props.update && fontFamily)
|
|
27
|
+
if (!props.update && fontFamily)
|
|
36
28
|
return { fontFamily };
|
|
37
|
-
}
|
|
38
29
|
}
|
|
39
30
|
config.fonts[fontFamilyNameIn] = fontFamilyIn;
|
|
40
31
|
const sep = process.env.NODE_ENV === "development" ? config.cssStyleSeparator || " " : "";
|
|
@@ -42,39 +33,20 @@ function addFont(props) {
|
|
|
42
33
|
return `:root${selector} {${sep}${[...decs].join(`;${sep}`)}${sep}}`;
|
|
43
34
|
}
|
|
44
35
|
if (import_constants.isWeb) {
|
|
45
|
-
const fontFamilyToken = (0, import_web.createVariables)(fontFamilyIn, "f",
|
|
46
|
-
|
|
47
|
-
|
|
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 = {
|
|
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 = {
|
|
53
39
|
[fontFamilyNameIn]: {
|
|
54
40
|
name: ff_name.slice(1),
|
|
55
41
|
declarations: fontVars,
|
|
56
42
|
language: ff_language
|
|
57
43
|
}
|
|
58
|
-
}
|
|
59
|
-
const {
|
|
44
|
+
}, {
|
|
60
45
|
name,
|
|
61
46
|
declarations,
|
|
62
47
|
language = "default"
|
|
63
|
-
} = fontDeclaration[fontFamilyNameIn];
|
|
64
|
-
|
|
65
|
-
const langSelector = `:root .t_lang-${name}-${language} ${fontSelector}`;
|
|
66
|
-
const selectors = language === "default" ? ` ${fontSelector}, ${langSelector}` : langSelector;
|
|
67
|
-
const cssRuleSets = declarationsToRuleSet(declarations, selectors);
|
|
68
|
-
const id = `t_font_style_${fontFamilyNameIn}`;
|
|
69
|
-
const existing = document.querySelector(`#${id}`);
|
|
70
|
-
const style = document.createElement("style");
|
|
71
|
-
style.id = id;
|
|
72
|
-
style.appendChild(document.createTextNode(`${cssRuleSets}`));
|
|
73
|
-
document.head.appendChild(style);
|
|
74
|
-
if (existing) {
|
|
75
|
-
(_a = existing.parentElement) == null ? void 0 : _a.removeChild(existing);
|
|
76
|
-
}
|
|
77
|
-
return {
|
|
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), {
|
|
78
50
|
fontFamilyToken,
|
|
79
51
|
fontDeclaration
|
|
80
52
|
};
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/index.ts"],
|
|
4
|
-
"mappings": "
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAAsB,+BACtB,aAKO;AAGA,SAAS,QAAQ,OAMrB;AACD,QAAM,aAAS,sBAAU,GACnB,EAAE,gBAAgB,kBAAkB,YAAY,aAAa,IAAI;AAEvE,MAAI,QAAQ,IAAI,aAAa,eAAe;AAC1C,QAAI,CAAC;AACH,YAAM,IAAI,MAAM,WAAW;AAE7B,UAAM,aAAa,OAAO,MAAM,gBAAgB;AAChD,QAAI,CAAC,MAAM,UAAU;AACnB,aAAO,EAAE,WAAW;AAAA,EAExB;AAEA,SAAO,MAAM,gBAAgB,IAAI;AAEjC,QAAM,MACJ,QAAQ,IAAI,aAAa,gBAAgB,OAAO,qBAAqB,MAAM;AAC7E,WAAS,sBAAsB,MAAgB,WAAW,IAAI;AAC5D,WAAO,QAAQ,QAAQ,KAAK,GAAG,GAAG,CAAC,GAAG,IAAI,EAAE,KAAK,IAAI,GAAG,EAAE,CAAC,GAAG,GAAG;AAAA,EACnE;AAEA,MAAI,wBAAO;AACT,UAAM,sBAAkB,4BAAgB,cAAc,KAAK,EAAI,GACzD,uBAAmB,sBAAU,eAAe,GAC5C,uBAAuB,IAAI,gBAAgB;AAGjD,QAFA,OAAO,YAAY,oBAAoB,IAAI,kBAEvC,MAAM,WAAW;AACnB,YAAM,CAAC,SAAS,WAAW,IAAI,qBAAqB,SAAS,GAAG,IAC5D,qBAAqB,MAAM,GAAG,IAC9B,CAAC,oBAAoB,GACnB,eAAW,kCAAsB,gBAAgB,GACjD,kBAAkB;AAAA,QACtB,CAAC,gBAAgB,GAAG;AAAA,UAClB,MAAM,QAAQ,MAAM,CAAC;AAAA,UACrB,cAAc;AAAA,UACd,UAAU;AAAA,QACZ;AAAA,MACF,GAEM;AAAA,QACJ;AAAA,QACA;AAAA,QACA,WAAW;AAAA,MACb,IAAI,gBAAgB,gBAAgB,GAC9B,eAAe,SAAS,IAAI,IAC5B,eAAe,iBAAiB,IAAI,IAAI,QAAQ,IAAI,YAAY,IAChE,YACJ,aAAa,YAAY,IAAI,YAAY,KAAK,YAAY,KAAK,cAC3D,cAAc,sBAAsB,cAAc,SAAS,GAE3D,KAAK,gBAAgB,gBAAgB,IACrC,WAAW,SAAS,cAAc,IAAI,EAAE,EAAE,GAC1C,QAAQ,SAAS,cAAc,OAAO;AAC5C,mBAAM,KAAK,IACX,MAAM,YAAY,SAAS,eAAe,GAAG,WAAW,EAAE,CAAC,GAC3D,SAAS,KAAK,YAAY,KAAK,GAC3B,YACF,SAAS,eAAe,YAAY,QAAQ,GAEvC;AAAA,QACL;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;",
|
|
5
5
|
"names": []
|
|
6
6
|
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
9
|
+
}, __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from == "object" || typeof from == "function")
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
|
+
return to;
|
|
14
|
+
};
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
16
|
+
var src_exports = {};
|
|
17
|
+
__export(src_exports, {
|
|
18
|
+
addFont: () => addFont
|
|
19
|
+
});
|
|
20
|
+
module.exports = __toCommonJS(src_exports);
|
|
21
|
+
var import_constants = require("@tamagui/constants"), import_web = require("@tamagui/web");
|
|
22
|
+
function addFont(props) {
|
|
23
|
+
const config = (0, import_web.getConfig)(), { fontFamilyName: fontFamilyNameIn, fontFamily: fontFamilyIn } = props;
|
|
24
|
+
if (process.env.NODE_ENV === "development") {
|
|
25
|
+
if (!config)
|
|
26
|
+
throw new Error("No config");
|
|
27
|
+
const fontFamily = config.fonts[fontFamilyNameIn];
|
|
28
|
+
if (!props.update && fontFamily)
|
|
29
|
+
return { fontFamily };
|
|
30
|
+
}
|
|
31
|
+
config.fonts[fontFamilyNameIn] = fontFamilyIn;
|
|
32
|
+
const sep = process.env.NODE_ENV === "development" ? config.cssStyleSeparator || " " : "";
|
|
33
|
+
function declarationsToRuleSet(decs, selector = "") {
|
|
34
|
+
return `:root${selector} {${sep}${[...decs].join(`;${sep}`)}${sep}}`;
|
|
35
|
+
}
|
|
36
|
+
if (import_constants.isWeb) {
|
|
37
|
+
const fontFamilyToken = (0, import_web.createVariables)(fontFamilyIn, "f", !0), parsedFontFamily = (0, import_web.parseFont)(fontFamilyToken), fontFamilyNameParsed = `$${fontFamilyNameIn}`;
|
|
38
|
+
if (config.fontsParsed[fontFamilyNameParsed] = parsedFontFamily, props.insertCSS) {
|
|
39
|
+
const [ff_name, ff_language] = fontFamilyNameParsed.includes("_") ? fontFamilyNameParsed.split("_") : [fontFamilyNameParsed], fontVars = (0, import_web.registerFontVariables)(parsedFontFamily), fontDeclaration = {
|
|
40
|
+
[fontFamilyNameIn]: {
|
|
41
|
+
name: ff_name.slice(1),
|
|
42
|
+
declarations: fontVars,
|
|
43
|
+
language: ff_language
|
|
44
|
+
}
|
|
45
|
+
}, {
|
|
46
|
+
name,
|
|
47
|
+
declarations,
|
|
48
|
+
language = "default"
|
|
49
|
+
} = 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");
|
|
50
|
+
return style.id = id, style.appendChild(document.createTextNode(`${cssRuleSets}`)), document.head.appendChild(style), existing && existing.parentElement?.removeChild(existing), {
|
|
51
|
+
fontFamilyToken,
|
|
52
|
+
fontDeclaration
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
58
|
+
0 && (module.exports = {
|
|
59
|
+
addFont
|
|
60
|
+
});
|
|
61
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/index.ts"],
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAAsB,+BACtB,aAKO;AAGA,SAAS,QAAQ,OAMrB;AACD,QAAM,aAAS,sBAAU,GACnB,EAAE,gBAAgB,kBAAkB,YAAY,aAAa,IAAI;AAEvE,MAAI,QAAQ,IAAI,aAAa,eAAe;AAC1C,QAAI,CAAC;AACH,YAAM,IAAI,MAAM,WAAW;AAE7B,UAAM,aAAa,OAAO,MAAM,gBAAgB;AAChD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Y,KAAK,GAC3B,YACF,SAAS,eAAe,YAAY,QAAQ,GAEvC;AAAA,QACL;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;",
|
|
5
|
+
"names": []
|
|
6
|
+
}
|
package/dist/esm/index.js
CHANGED
|
@@ -6,17 +6,13 @@ import {
|
|
|
6
6
|
registerFontVariables
|
|
7
7
|
} from "@tamagui/web";
|
|
8
8
|
function addFont(props) {
|
|
9
|
-
|
|
10
|
-
const config = getConfig();
|
|
11
|
-
const { fontFamilyName: fontFamilyNameIn, fontFamily: fontFamilyIn } = props;
|
|
9
|
+
const config = getConfig(), { fontFamilyName: fontFamilyNameIn, fontFamily: fontFamilyIn } = props;
|
|
12
10
|
if (process.env.NODE_ENV === "development") {
|
|
13
|
-
if (!config)
|
|
11
|
+
if (!config)
|
|
14
12
|
throw new Error("No config");
|
|
15
|
-
}
|
|
16
13
|
const fontFamily = config.fonts[fontFamilyNameIn];
|
|
17
|
-
if (!props.update && fontFamily)
|
|
14
|
+
if (!props.update && fontFamily)
|
|
18
15
|
return { fontFamily };
|
|
19
|
-
}
|
|
20
16
|
}
|
|
21
17
|
config.fonts[fontFamilyNameIn] = fontFamilyIn;
|
|
22
18
|
const sep = process.env.NODE_ENV === "development" ? config.cssStyleSeparator || " " : "";
|
|
@@ -24,39 +20,20 @@ function addFont(props) {
|
|
|
24
20
|
return `:root${selector} {${sep}${[...decs].join(`;${sep}`)}${sep}}`;
|
|
25
21
|
}
|
|
26
22
|
if (isWeb) {
|
|
27
|
-
const fontFamilyToken = createVariables(fontFamilyIn, "f",
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
config.fontsParsed[fontFamilyNameParsed] = parsedFontFamily;
|
|
31
|
-
if (props.insertCSS) {
|
|
32
|
-
const [ff_name, ff_language] = fontFamilyNameParsed.includes("_") ? fontFamilyNameParsed.split("_") : [fontFamilyNameParsed];
|
|
33
|
-
const fontVars = registerFontVariables(parsedFontFamily);
|
|
34
|
-
const fontDeclaration = {
|
|
23
|
+
const fontFamilyToken = createVariables(fontFamilyIn, "f", !0), parsedFontFamily = parseFont(fontFamilyToken), fontFamilyNameParsed = `$${fontFamilyNameIn}`;
|
|
24
|
+
if (config.fontsParsed[fontFamilyNameParsed] = parsedFontFamily, props.insertCSS) {
|
|
25
|
+
const [ff_name, ff_language] = fontFamilyNameParsed.includes("_") ? fontFamilyNameParsed.split("_") : [fontFamilyNameParsed], fontVars = registerFontVariables(parsedFontFamily), fontDeclaration = {
|
|
35
26
|
[fontFamilyNameIn]: {
|
|
36
27
|
name: ff_name.slice(1),
|
|
37
28
|
declarations: fontVars,
|
|
38
29
|
language: ff_language
|
|
39
30
|
}
|
|
40
|
-
}
|
|
41
|
-
const {
|
|
31
|
+
}, {
|
|
42
32
|
name,
|
|
43
33
|
declarations,
|
|
44
34
|
language = "default"
|
|
45
|
-
} = fontDeclaration[fontFamilyNameIn];
|
|
46
|
-
|
|
47
|
-
const langSelector = `:root .t_lang-${name}-${language} ${fontSelector}`;
|
|
48
|
-
const selectors = language === "default" ? ` ${fontSelector}, ${langSelector}` : langSelector;
|
|
49
|
-
const cssRuleSets = declarationsToRuleSet(declarations, selectors);
|
|
50
|
-
const id = `t_font_style_${fontFamilyNameIn}`;
|
|
51
|
-
const existing = document.querySelector(`#${id}`);
|
|
52
|
-
const style = document.createElement("style");
|
|
53
|
-
style.id = id;
|
|
54
|
-
style.appendChild(document.createTextNode(`${cssRuleSets}`));
|
|
55
|
-
document.head.appendChild(style);
|
|
56
|
-
if (existing) {
|
|
57
|
-
(_a = existing.parentElement) == null ? void 0 : _a.removeChild(existing);
|
|
58
|
-
}
|
|
59
|
-
return {
|
|
35
|
+
} = 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");
|
|
36
|
+
return style.id = id, style.appendChild(document.createTextNode(`${cssRuleSets}`)), document.head.appendChild(style), existing && existing.parentElement?.removeChild(existing), {
|
|
60
37
|
fontFamilyToken,
|
|
61
38
|
fontDeclaration
|
|
62
39
|
};
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/index.ts"],
|
|
4
|
-
"mappings": "AAAA,SAAS,aAAa;AACtB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGA,SAAS,QAAQ,OAMrB;
|
|
4
|
+
"mappings": "AAAA,SAAS,aAAa;AACtB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGA,SAAS,QAAQ,OAMrB;AACD,QAAM,SAAS,UAAU,GACnB,EAAE,gBAAgB,kBAAkB,YAAY,aAAa,IAAI;AAEvE,MAAI,QAAQ,IAAI,aAAa,eAAe;AAC1C,QAAI,CAAC;AACH,YAAM,IAAI,MAAM,WAAW;AAE7B,UAAM,aAAa,OAAO,MAAM,gBAAgB;AAChD,QAAI,CAAC,MAAM,UAAU;AACnB,aAAO,EAAE,WAAW;AAAA,EAExB;AAEA,SAAO,MAAM,gBAAgB,IAAI;AAEjC,QAAM,MACJ,QAAQ,IAAI,aAAa,gBAAgB,OAAO,qBAAqB,MAAM;AAC7E,WAAS,sBAAsB,MAAgB,WAAW,IAAI;AAC5D,WAAO,QAAQ,QAAQ,KAAK,GAAG,GAAG,CAAC,GAAG,IAAI,EAAE,KAAK,IAAI,GAAG,EAAE,CAAC,GAAG,GAAG;AAAA,EACnE;AAEA,MAAI,OAAO;AACT,UAAM,kBAAkB,gBAAgB,cAAc,KAAK,EAAI,GACzD,mBAAmB,UAAU,eAAe,GAC5C,uBAAuB,IAAI,gBAAgB;AAGjD,QAFA,OAAO,YAAY,oBAAoB,IAAI,kBAEvC,MAAM,WAAW;AACnB,YAAM,CAAC,SAAS,WAAW,IAAI,qBAAqB,SAAS,GAAG,IAC5D,qBAAqB,MAAM,GAAG,IAC9B,CAAC,oBAAoB,GACnB,WAAW,sBAAsB,gBAAgB,GACjD,kBAAkB;AAAA,QACtB,CAAC,gBAAgB,GAAG;AAAA,UAClB,MAAM,QAAQ,MAAM,CAAC;AAAA,UACrB,cAAc;AAAA,UACd,UAAU;AAAA,QACZ;AAAA,MACF,GAEM;AAAA,QACJ;AAAA,QACA;AAAA,QACA,WAAW;AAAA,MACb,IAAI,gBAAgB,gBAAgB,GAC9B,eAAe,SAAS,IAAI,IAC5B,eAAe,iBAAiB,IAAI,IAAI,QAAQ,IAAI,YAAY,IAChE,YACJ,aAAa,YAAY,IAAI,YAAY,KAAK,YAAY,KAAK,cAC3D,cAAc,sBAAsB,cAAc,SAAS,GAE3D,KAAK,gBAAgB,gBAAgB,IACrC,WAAW,SAAS,cAAc,IAAI,EAAE,EAAE,GAC1C,QAAQ,SAAS,cAAc,OAAO;AAC5C,mBAAM,KAAK,IACX,MAAM,YAAY,SAAS,eAAe,GAAG,WAAW,EAAE,CAAC,GAC3D,SAAS,KAAK,YAAY,KAAK,GAC3B,YACF,SAAS,eAAe,YAAY,QAAQ,GAEvC;AAAA,QACL;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;",
|
|
5
5
|
"names": []
|
|
6
6
|
}
|
package/dist/jsx/index.js
CHANGED
|
@@ -6,16 +6,13 @@ import {
|
|
|
6
6
|
registerFontVariables
|
|
7
7
|
} from "@tamagui/web";
|
|
8
8
|
function addFont(props) {
|
|
9
|
-
const config = getConfig();
|
|
10
|
-
const { fontFamilyName: fontFamilyNameIn, fontFamily: fontFamilyIn } = props;
|
|
9
|
+
const config = getConfig(), { fontFamilyName: fontFamilyNameIn, fontFamily: fontFamilyIn } = props;
|
|
11
10
|
if (process.env.NODE_ENV === "development") {
|
|
12
|
-
if (!config)
|
|
11
|
+
if (!config)
|
|
13
12
|
throw new Error("No config");
|
|
14
|
-
}
|
|
15
13
|
const fontFamily = config.fonts[fontFamilyNameIn];
|
|
16
|
-
if (!props.update && fontFamily)
|
|
14
|
+
if (!props.update && fontFamily)
|
|
17
15
|
return { fontFamily };
|
|
18
|
-
}
|
|
19
16
|
}
|
|
20
17
|
config.fonts[fontFamilyNameIn] = fontFamilyIn;
|
|
21
18
|
const sep = process.env.NODE_ENV === "development" ? config.cssStyleSeparator || " " : "";
|
|
@@ -23,39 +20,20 @@ function addFont(props) {
|
|
|
23
20
|
return `:root${selector} {${sep}${[...decs].join(`;${sep}`)}${sep}}`;
|
|
24
21
|
}
|
|
25
22
|
if (isWeb) {
|
|
26
|
-
const fontFamilyToken = createVariables(fontFamilyIn, "f",
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
config.fontsParsed[fontFamilyNameParsed] = parsedFontFamily;
|
|
30
|
-
if (props.insertCSS) {
|
|
31
|
-
const [ff_name, ff_language] = fontFamilyNameParsed.includes("_") ? fontFamilyNameParsed.split("_") : [fontFamilyNameParsed];
|
|
32
|
-
const fontVars = registerFontVariables(parsedFontFamily);
|
|
33
|
-
const fontDeclaration = {
|
|
23
|
+
const fontFamilyToken = createVariables(fontFamilyIn, "f", !0), parsedFontFamily = parseFont(fontFamilyToken), fontFamilyNameParsed = `$${fontFamilyNameIn}`;
|
|
24
|
+
if (config.fontsParsed[fontFamilyNameParsed] = parsedFontFamily, props.insertCSS) {
|
|
25
|
+
const [ff_name, ff_language] = fontFamilyNameParsed.includes("_") ? fontFamilyNameParsed.split("_") : [fontFamilyNameParsed], fontVars = registerFontVariables(parsedFontFamily), fontDeclaration = {
|
|
34
26
|
[fontFamilyNameIn]: {
|
|
35
27
|
name: ff_name.slice(1),
|
|
36
28
|
declarations: fontVars,
|
|
37
29
|
language: ff_language
|
|
38
30
|
}
|
|
39
|
-
}
|
|
40
|
-
const {
|
|
31
|
+
}, {
|
|
41
32
|
name,
|
|
42
33
|
declarations,
|
|
43
34
|
language = "default"
|
|
44
|
-
} = fontDeclaration[fontFamilyNameIn];
|
|
45
|
-
|
|
46
|
-
const langSelector = `:root .t_lang-${name}-${language} ${fontSelector}`;
|
|
47
|
-
const selectors = language === "default" ? ` ${fontSelector}, ${langSelector}` : langSelector;
|
|
48
|
-
const cssRuleSets = declarationsToRuleSet(declarations, selectors);
|
|
49
|
-
const id = `t_font_style_${fontFamilyNameIn}`;
|
|
50
|
-
const existing = document.querySelector(`#${id}`);
|
|
51
|
-
const style = document.createElement("style");
|
|
52
|
-
style.id = id;
|
|
53
|
-
style.appendChild(document.createTextNode(`${cssRuleSets}`));
|
|
54
|
-
document.head.appendChild(style);
|
|
55
|
-
if (existing) {
|
|
56
|
-
existing.parentElement?.removeChild(existing);
|
|
57
|
-
}
|
|
58
|
-
return {
|
|
35
|
+
} = 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");
|
|
36
|
+
return style.id = id, style.appendChild(document.createTextNode(`${cssRuleSets}`)), document.head.appendChild(style), existing && existing.parentElement?.removeChild(existing), {
|
|
59
37
|
fontFamilyToken,
|
|
60
38
|
fontDeclaration
|
|
61
39
|
};
|
package/dist/jsx/index.js.map
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/index.ts"],
|
|
4
|
-
"mappings": "AAAA,SAAS,aAAa;AACtB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGA,SAAS,QAAQ,OAMrB;AACD,QAAM,SAAS,UAAU
|
|
4
|
+
"mappings": "AAAA,SAAS,aAAa;AACtB;AAAA,EACE;AAAA,EACA;AAAA,EACA;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YAAY,KAAK,cAC3D,cAAc,sBAAsB,cAAc,SAAS,GAE3D,KAAK,gBAAgB,gBAAgB,IACrC,WAAW,SAAS,cAAc,IAAI,EAAE,EAAE,GAC1C,QAAQ,SAAS,cAAc,OAAO;AAC5C,mBAAM,KAAK,IACX,MAAM,YAAY,SAAS,eAAe,GAAG,WAAW,EAAE,CAAC,GAC3D,SAAS,KAAK,YAAY,KAAK,GAC3B,YACF,SAAS,eAAe,YAAY,QAAQ,GAEvC;AAAA,QACL;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;",
|
|
5
5
|
"names": []
|
|
6
6
|
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { isWeb } from "@tamagui/constants";
|
|
2
|
+
import {
|
|
3
|
+
createVariables,
|
|
4
|
+
getConfig,
|
|
5
|
+
parseFont,
|
|
6
|
+
registerFontVariables
|
|
7
|
+
} from "@tamagui/web";
|
|
8
|
+
function addFont(props) {
|
|
9
|
+
const config = getConfig(), { fontFamilyName: fontFamilyNameIn, fontFamily: fontFamilyIn } = props;
|
|
10
|
+
if (process.env.NODE_ENV === "development") {
|
|
11
|
+
if (!config)
|
|
12
|
+
throw new Error("No config");
|
|
13
|
+
const fontFamily = config.fonts[fontFamilyNameIn];
|
|
14
|
+
if (!props.update && fontFamily)
|
|
15
|
+
return { fontFamily };
|
|
16
|
+
}
|
|
17
|
+
config.fonts[fontFamilyNameIn] = fontFamilyIn;
|
|
18
|
+
const sep = process.env.NODE_ENV === "development" ? config.cssStyleSeparator || " " : "";
|
|
19
|
+
function declarationsToRuleSet(decs, selector = "") {
|
|
20
|
+
return `:root${selector} {${sep}${[...decs].join(`;${sep}`)}${sep}}`;
|
|
21
|
+
}
|
|
22
|
+
if (isWeb) {
|
|
23
|
+
const fontFamilyToken = createVariables(fontFamilyIn, "f", !0), parsedFontFamily = parseFont(fontFamilyToken), fontFamilyNameParsed = `$${fontFamilyNameIn}`;
|
|
24
|
+
if (config.fontsParsed[fontFamilyNameParsed] = parsedFontFamily, props.insertCSS) {
|
|
25
|
+
const [ff_name, ff_language] = fontFamilyNameParsed.includes("_") ? fontFamilyNameParsed.split("_") : [fontFamilyNameParsed], fontVars = registerFontVariables(parsedFontFamily), fontDeclaration = {
|
|
26
|
+
[fontFamilyNameIn]: {
|
|
27
|
+
name: ff_name.slice(1),
|
|
28
|
+
declarations: fontVars,
|
|
29
|
+
language: ff_language
|
|
30
|
+
}
|
|
31
|
+
}, {
|
|
32
|
+
name,
|
|
33
|
+
declarations,
|
|
34
|
+
language = "default"
|
|
35
|
+
} = 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");
|
|
36
|
+
return style.id = id, style.appendChild(document.createTextNode(`${cssRuleSets}`)), document.head.appendChild(style), existing && existing.parentElement?.removeChild(existing), {
|
|
37
|
+
fontFamilyToken,
|
|
38
|
+
fontDeclaration
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
export {
|
|
44
|
+
addFont
|
|
45
|
+
};
|
|
46
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/index.ts"],
|
|
4
|
+
"mappings": "AAAA,SAAS,aAAa;AACtB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGA,SAAS,QAAQ,OAMrB;AACD,QAAM,SAAS,UAAU,GACnB,EAAE,gBAAgB,kBAAkB,YAAY,aAAa,IAAI;AAEvE,MAAI,QAAQ,IAAI,aAAa,eAAe;AAC1C,QAAI,CAAC;AACH,YAAM,IAAI,MAAM,WAAW;AAE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AW,EAAE,CAAC,GAC3D,SAAS,KAAK,YAAY,KAAK,GAC3B,YACF,SAAS,eAAe,YAAY,QAAQ,GAEvC;AAAA,QACL;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;",
|
|
5
|
+
"names": []
|
|
6
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/font",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.62.1",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"source": "src/index.ts",
|
|
6
6
|
"types": "./types/index.d.ts",
|
|
@@ -17,14 +17,14 @@
|
|
|
17
17
|
"watch": "tamagui-build --watch"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@tamagui/constants": "1.
|
|
21
|
-
"@tamagui/web": "1.
|
|
20
|
+
"@tamagui/constants": "1.62.1",
|
|
21
|
+
"@tamagui/web": "1.62.1"
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|
|
24
24
|
"react": "*"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@tamagui/build": "1.
|
|
27
|
+
"@tamagui/build": "1.62.1",
|
|
28
28
|
"react": "^18.2.0"
|
|
29
29
|
},
|
|
30
30
|
"publishConfig": {
|