@tamagui/font 1.110.5 → 1.111.0
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.native.js +14 -71
- package/dist/cjs/index.native.js.map +2 -2
- package/dist/esm/index.native.js +14 -71
- package/dist/esm/index.native.js.map +2 -2
- package/dist/esm/index.native.mjs +60 -0
- package/dist/esm/index.native.mjs.map +1 -0
- package/dist/jsx/index.native.js +14 -71
- package/dist/jsx/index.native.js.map +2 -2
- package/package.json +4 -4
package/dist/cjs/index.native.js
CHANGED
|
@@ -19,69 +19,8 @@ __export(src_exports, {
|
|
|
19
19
|
});
|
|
20
20
|
module.exports = __toCommonJS(src_exports);
|
|
21
21
|
var import_constants = require("@tamagui/constants"), import_web = require("@tamagui/web");
|
|
22
|
-
function _array_like_to_array(arr, len) {
|
|
23
|
-
(len == null || len > arr.length) && (len = arr.length);
|
|
24
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
25
|
-
return arr2;
|
|
26
|
-
}
|
|
27
|
-
function _array_with_holes(arr) {
|
|
28
|
-
if (Array.isArray(arr)) return arr;
|
|
29
|
-
}
|
|
30
|
-
function _array_without_holes(arr) {
|
|
31
|
-
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
32
|
-
}
|
|
33
|
-
function _define_property(obj, key, value) {
|
|
34
|
-
return key in obj ? Object.defineProperty(obj, key, {
|
|
35
|
-
value,
|
|
36
|
-
enumerable: !0,
|
|
37
|
-
configurable: !0,
|
|
38
|
-
writable: !0
|
|
39
|
-
}) : obj[key] = value, obj;
|
|
40
|
-
}
|
|
41
|
-
function _iterable_to_array(iter) {
|
|
42
|
-
if (typeof Symbol < "u" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
43
|
-
}
|
|
44
|
-
function _iterable_to_array_limit(arr, i) {
|
|
45
|
-
var _i = arr == null ? null : typeof Symbol < "u" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
46
|
-
if (_i != null) {
|
|
47
|
-
var _arr = [], _n = !0, _d = !1, _s, _e;
|
|
48
|
-
try {
|
|
49
|
-
for (_i = _i.call(arr); !(_n = (_s = _i.next()).done) && (_arr.push(_s.value), !(i && _arr.length === i)); _n = !0)
|
|
50
|
-
;
|
|
51
|
-
} catch (err) {
|
|
52
|
-
_d = !0, _e = err;
|
|
53
|
-
} finally {
|
|
54
|
-
try {
|
|
55
|
-
!_n && _i.return != null && _i.return();
|
|
56
|
-
} finally {
|
|
57
|
-
if (_d) throw _e;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
return _arr;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
function _non_iterable_rest() {
|
|
64
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
65
|
-
}
|
|
66
|
-
function _non_iterable_spread() {
|
|
67
|
-
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
68
|
-
}
|
|
69
|
-
function _sliced_to_array(arr, i) {
|
|
70
|
-
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
71
|
-
}
|
|
72
|
-
function _to_consumable_array(arr) {
|
|
73
|
-
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
74
|
-
}
|
|
75
|
-
function _unsupported_iterable_to_array(o, minLen) {
|
|
76
|
-
if (o) {
|
|
77
|
-
if (typeof o == "string") return _array_like_to_array(o, minLen);
|
|
78
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
79
|
-
if (n === "Object" && o.constructor && (n = o.constructor.name), n === "Map" || n === "Set") return Array.from(n);
|
|
80
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
22
|
function addFont(props) {
|
|
84
|
-
var config = (0, import_web.getConfig)(),
|
|
23
|
+
var config = (0, import_web.getConfig)(), { fontFamilyName: fontFamilyNameIn, fontFamily: fontFamilyIn } = props;
|
|
85
24
|
if (process.env.NODE_ENV === "development") {
|
|
86
25
|
if (!config)
|
|
87
26
|
throw new Error("No config");
|
|
@@ -95,19 +34,23 @@ function addFont(props) {
|
|
|
95
34
|
var sep = process.env.NODE_ENV === "development" ? config.cssStyleSeparator || " " : "";
|
|
96
35
|
function declarationsToRuleSet(decs) {
|
|
97
36
|
var selector = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "";
|
|
98
|
-
return
|
|
37
|
+
return `:root${selector} {${sep}${[
|
|
38
|
+
...decs
|
|
39
|
+
].join(`;${sep}`)}${sep}}`;
|
|
99
40
|
}
|
|
100
41
|
if (import_constants.isWeb) {
|
|
101
|
-
var fontFamilyToken = (0, import_web.createVariables)(fontFamilyIn, "f", !0), parsedFontFamily = (0, import_web.parseFont)(fontFamilyToken), fontFamilyNameParsed =
|
|
42
|
+
var fontFamilyToken = (0, import_web.createVariables)(fontFamilyIn, "f", !0), parsedFontFamily = (0, import_web.parseFont)(fontFamilyToken), fontFamilyNameParsed = `$${fontFamilyNameIn}`;
|
|
102
43
|
if (config.fontsParsed[fontFamilyNameParsed] = parsedFontFamily, props.insertCSS) {
|
|
103
|
-
var
|
|
44
|
+
var [ff_name, ff_language] = fontFamilyNameParsed.includes("_") ? fontFamilyNameParsed.split("_") : [
|
|
104
45
|
fontFamilyNameParsed
|
|
105
|
-
],
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
46
|
+
], fontVars = (0, import_web.registerFontVariables)(parsedFontFamily), fontDeclaration = {
|
|
47
|
+
[fontFamilyNameIn]: {
|
|
48
|
+
name: ff_name.slice(1),
|
|
49
|
+
declarations: fontVars,
|
|
50
|
+
language: ff_language
|
|
51
|
+
}
|
|
52
|
+
}, { name, declarations, language = "default" } = 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");
|
|
53
|
+
if (style.id = id, style.appendChild(document.createTextNode(`${cssRuleSets}`)), document.head.appendChild(style), existing) {
|
|
111
54
|
var _existing_parentElement;
|
|
112
55
|
(_existing_parentElement = existing.parentElement) === null || _existing_parentElement === void 0 || _existing_parentElement.removeChild(existing);
|
|
113
56
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Users/n8/tamagui/code/core/font/src/index.ts"],
|
|
4
|
-
"mappings": "
|
|
5
|
-
"names": ["addFont", "props", "config", "getConfig", "
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;AAAA;;;;;uBAAsB,+BACtB,aAKO;AAGA,SAASA,QAAQC;AAOtB,MAAMC,aAASC,sBAAAA,GACT,EAAEC,gBAAgBC,kBAAkBC,YAAYC,aAAY,IAAKN;AAEvE,MAAIO,QAAQC,IAAIC,aAAa,eAAe;AAC1C,QAAI,CAACR;AACH,YAAM,IAAIS,MAAM,WAAA;AAElB,QAAML,aAAaJ,OAAOU,MAAMP,gBAAAA;AAChC,QAAI,CAACJ,MAAMY,UAAUP;AACnB,aAAO;QAAEA;MAAW;EAExB;AAEAJ,SAAOU,MAAMP,gBAAAA,IAAoBE;AAEjC,MAAMO,MACJN,QAAQC,IAAIC,aAAa,gBAAgBR,OAAOa,qBAAqB,MAAM;AAC7E,WAASC,sBAAsBC,MAAc;QAAEC,WAAAA,UAAAA,SAAAA,KAAAA,UAAAA,CAAAA,MAAAA,SAAAA,UAAAA,CA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",
|
|
5
|
+
"names": ["addFont", "props", "config", "getConfig", "fontFamilyName", "fontFamilyNameIn", "fontFamily", "fontFamilyIn", "process", "env", "NODE_ENV", "Error", "fonts", "update", "sep", "cssStyleSeparator", "declarationsToRuleSet", "decs", "selector", "join", "isWeb", "fontFamilyToken", "createVariables", "parsedFontFamily", "parseFont", "fontFamilyNameParsed", "fontsParsed", "insertCSS", "ff_name", "ff_language", "includes", "split", "fontVars", "registerFontVariables", "fontDeclaration", "name", "slice", "declarations", "language", "fontSelector", "langSelector", "selectors", "cssRuleSets", "id", "existing", "document", "querySelector", "style", "createElement", "appendChild", "createTextNode", "head", "parentElement", "removeChild"]
|
|
6
6
|
}
|
package/dist/esm/index.native.js
CHANGED
|
@@ -1,68 +1,7 @@
|
|
|
1
1
|
import { isWeb } from "@tamagui/constants";
|
|
2
2
|
import { createVariables, getConfig, parseFont, registerFontVariables } from "@tamagui/web";
|
|
3
|
-
function _array_like_to_array(arr, len) {
|
|
4
|
-
(len == null || len > arr.length) && (len = arr.length);
|
|
5
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
6
|
-
return arr2;
|
|
7
|
-
}
|
|
8
|
-
function _array_with_holes(arr) {
|
|
9
|
-
if (Array.isArray(arr)) return arr;
|
|
10
|
-
}
|
|
11
|
-
function _array_without_holes(arr) {
|
|
12
|
-
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
13
|
-
}
|
|
14
|
-
function _define_property(obj, key, value) {
|
|
15
|
-
return key in obj ? Object.defineProperty(obj, key, {
|
|
16
|
-
value,
|
|
17
|
-
enumerable: !0,
|
|
18
|
-
configurable: !0,
|
|
19
|
-
writable: !0
|
|
20
|
-
}) : obj[key] = value, obj;
|
|
21
|
-
}
|
|
22
|
-
function _iterable_to_array(iter) {
|
|
23
|
-
if (typeof Symbol < "u" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
24
|
-
}
|
|
25
|
-
function _iterable_to_array_limit(arr, i) {
|
|
26
|
-
var _i = arr == null ? null : typeof Symbol < "u" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
27
|
-
if (_i != null) {
|
|
28
|
-
var _arr = [], _n = !0, _d = !1, _s, _e;
|
|
29
|
-
try {
|
|
30
|
-
for (_i = _i.call(arr); !(_n = (_s = _i.next()).done) && (_arr.push(_s.value), !(i && _arr.length === i)); _n = !0)
|
|
31
|
-
;
|
|
32
|
-
} catch (err) {
|
|
33
|
-
_d = !0, _e = err;
|
|
34
|
-
} finally {
|
|
35
|
-
try {
|
|
36
|
-
!_n && _i.return != null && _i.return();
|
|
37
|
-
} finally {
|
|
38
|
-
if (_d) throw _e;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
return _arr;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
function _non_iterable_rest() {
|
|
45
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
46
|
-
}
|
|
47
|
-
function _non_iterable_spread() {
|
|
48
|
-
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
49
|
-
}
|
|
50
|
-
function _sliced_to_array(arr, i) {
|
|
51
|
-
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
52
|
-
}
|
|
53
|
-
function _to_consumable_array(arr) {
|
|
54
|
-
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
55
|
-
}
|
|
56
|
-
function _unsupported_iterable_to_array(o, minLen) {
|
|
57
|
-
if (o) {
|
|
58
|
-
if (typeof o == "string") return _array_like_to_array(o, minLen);
|
|
59
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
60
|
-
if (n === "Object" && o.constructor && (n = o.constructor.name), n === "Map" || n === "Set") return Array.from(n);
|
|
61
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
3
|
function addFont(props) {
|
|
65
|
-
var config = getConfig(),
|
|
4
|
+
var config = getConfig(), { fontFamilyName: fontFamilyNameIn, fontFamily: fontFamilyIn } = props;
|
|
66
5
|
if (process.env.NODE_ENV === "development") {
|
|
67
6
|
if (!config)
|
|
68
7
|
throw new Error("No config");
|
|
@@ -76,19 +15,23 @@ function addFont(props) {
|
|
|
76
15
|
var sep = process.env.NODE_ENV === "development" ? config.cssStyleSeparator || " " : "";
|
|
77
16
|
function declarationsToRuleSet(decs) {
|
|
78
17
|
var selector = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "";
|
|
79
|
-
return
|
|
18
|
+
return `:root${selector} {${sep}${[
|
|
19
|
+
...decs
|
|
20
|
+
].join(`;${sep}`)}${sep}}`;
|
|
80
21
|
}
|
|
81
22
|
if (isWeb) {
|
|
82
|
-
var fontFamilyToken = createVariables(fontFamilyIn, "f", !0), parsedFontFamily = parseFont(fontFamilyToken), fontFamilyNameParsed =
|
|
23
|
+
var fontFamilyToken = createVariables(fontFamilyIn, "f", !0), parsedFontFamily = parseFont(fontFamilyToken), fontFamilyNameParsed = `$${fontFamilyNameIn}`;
|
|
83
24
|
if (config.fontsParsed[fontFamilyNameParsed] = parsedFontFamily, props.insertCSS) {
|
|
84
|
-
var
|
|
25
|
+
var [ff_name, ff_language] = fontFamilyNameParsed.includes("_") ? fontFamilyNameParsed.split("_") : [
|
|
85
26
|
fontFamilyNameParsed
|
|
86
|
-
],
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
27
|
+
], fontVars = registerFontVariables(parsedFontFamily), fontDeclaration = {
|
|
28
|
+
[fontFamilyNameIn]: {
|
|
29
|
+
name: ff_name.slice(1),
|
|
30
|
+
declarations: fontVars,
|
|
31
|
+
language: ff_language
|
|
32
|
+
}
|
|
33
|
+
}, { name, declarations, language = "default" } = 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");
|
|
34
|
+
if (style.id = id, style.appendChild(document.createTextNode(`${cssRuleSets}`)), document.head.appendChild(style), existing) {
|
|
92
35
|
var _existing_parentElement;
|
|
93
36
|
(_existing_parentElement = existing.parentElement) === null || _existing_parentElement === void 0 || _existing_parentElement.removeChild(existing);
|
|
94
37
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Users/n8/tamagui/code/core/font/src/index.ts"],
|
|
4
|
-
"mappings": "AAAA,SAASA,aAAa;AACtB,SACEC,iBACAC,WACAC,WACAC,6BACK
|
|
5
|
-
"names": ["isWeb", "createVariables", "getConfig", "parseFont", "registerFontVariables", "addFont", "props", "config", "
|
|
4
|
+
"mappings": "AAAA,SAASA,aAAa;AACtB,SACEC,iBACAC,WACAC,WACAC,6BACK;AAGA,SAASC,QAAQC;AAOtB,MAAMC,SAASL,UAAAA,GACT,EAAEM,gBAAgBC,kBAAkBC,YAAYC,aAAY,IAAKL;AAEvE,MAAIM,QAAQC,IAAIC,aAAa,eAAe;AAC1C,QAAI,CAACP;AACH,YAAM,IAAIQ,MAAM,WAAA;AAElB,QAAML,aAAaH,OAAOS,MAAMP,gBAAAA;AAChC,QAAI,CAACH,MAAMW,UAAUP;AACnB,aAAO;QAAEA;MAAW;EAExB;AAEAH,SAAOS,MAAMP,gBAAAA,IAAoBE;AAEjC,MAAMO,MACJN,QAAQC,IAAIC,aAAa,gBAAgBP,OAAOY,qBAAqB,MAAM;AAC7E,WAASC,sBAAsBC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A,UAAAA,wBAAwBS,YAAYT,QAAAA;MACtC;AACA,aAAO;QACLpB;QACAU;MACF;IACF;EACF;AACF;",
|
|
5
|
+
"names": ["isWeb", "createVariables", "getConfig", "parseFont", "registerFontVariables", "addFont", "props", "config", "fontFamilyName", "fontFamilyNameIn", "fontFamily", "fontFamilyIn", "process", "env", "NODE_ENV", "Error", "fonts", "update", "sep", "cssStyleSeparator", "declarationsToRuleSet", "decs", "selector", "join", "fontFamilyToken", "parsedFontFamily", "fontFamilyNameParsed", "fontsParsed", "insertCSS", "ff_name", "ff_language", "includes", "split", "fontVars", "fontDeclaration", "name", "slice", "declarations", "language", "fontSelector", "langSelector", "selectors", "cssRuleSets", "id", "existing", "document", "querySelector", "style", "createElement", "appendChild", "createTextNode", "head", "parentElement", "removeChild"]
|
|
6
6
|
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { isWeb } from "@tamagui/constants";
|
|
2
|
+
import { createVariables, getConfig, parseFont, registerFontVariables } from "@tamagui/web";
|
|
3
|
+
function addFont(props) {
|
|
4
|
+
var config = getConfig(),
|
|
5
|
+
{
|
|
6
|
+
fontFamilyName: fontFamilyNameIn,
|
|
7
|
+
fontFamily: fontFamilyIn
|
|
8
|
+
} = props;
|
|
9
|
+
if (process.env.NODE_ENV === "development") {
|
|
10
|
+
if (!config) throw new Error("No config");
|
|
11
|
+
var fontFamily = config.fonts[fontFamilyNameIn];
|
|
12
|
+
if (!props.update && fontFamily) return {
|
|
13
|
+
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", !0),
|
|
24
|
+
parsedFontFamily = parseFont(fontFamilyToken),
|
|
25
|
+
fontFamilyNameParsed = `$${fontFamilyNameIn}`;
|
|
26
|
+
if (config.fontsParsed[fontFamilyNameParsed] = parsedFontFamily, props.insertCSS) {
|
|
27
|
+
var [ff_name, ff_language] = fontFamilyNameParsed.includes("_") ? fontFamilyNameParsed.split("_") : [fontFamilyNameParsed],
|
|
28
|
+
fontVars = registerFontVariables(parsedFontFamily),
|
|
29
|
+
fontDeclaration = {
|
|
30
|
+
[fontFamilyNameIn]: {
|
|
31
|
+
name: ff_name.slice(1),
|
|
32
|
+
declarations: fontVars,
|
|
33
|
+
language: ff_language
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
name,
|
|
38
|
+
declarations,
|
|
39
|
+
language = "default"
|
|
40
|
+
} = fontDeclaration[fontFamilyNameIn],
|
|
41
|
+
fontSelector = `.font_${name}`,
|
|
42
|
+
langSelector = `:root .t_lang-${name}-${language} ${fontSelector}`,
|
|
43
|
+
selectors = language === "default" ? ` ${fontSelector}, ${langSelector}` : langSelector,
|
|
44
|
+
cssRuleSets = declarationsToRuleSet(declarations, selectors),
|
|
45
|
+
id = `t_font_style_${fontFamilyNameIn}`,
|
|
46
|
+
existing = document.querySelector(`#${id}`),
|
|
47
|
+
style = document.createElement("style");
|
|
48
|
+
if (style.id = id, style.appendChild(document.createTextNode(`${cssRuleSets}`)), document.head.appendChild(style), existing) {
|
|
49
|
+
var _existing_parentElement;
|
|
50
|
+
(_existing_parentElement = existing.parentElement) === null || _existing_parentElement === void 0 || _existing_parentElement.removeChild(existing);
|
|
51
|
+
}
|
|
52
|
+
return {
|
|
53
|
+
fontFamilyToken,
|
|
54
|
+
fontDeclaration
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
export { addFont };
|
|
60
|
+
//# sourceMappingURL=index.native.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["isWeb","createVariables","getConfig","parseFont","registerFontVariables","addFont","props","config","fontFamilyName","fontFamilyNameIn","fontFamily","fontFamilyIn","process","env","NODE_ENV","Error","fonts","update","sep","cssStyleSeparator","declarationsToRuleSet","decs","selector","arguments","length","join","fontFamilyToken","parsedFontFamily","fontFamilyNameParsed","fontsParsed","insertCSS","ff_name","ff_language","includes","split","fontVars","fontDeclaration","name","slice","declarations","language","fontSelector","langSelector","selectors","cssRuleSets","id","existing","document","querySelector","style","createElement","appendChild","createTextNode","head","_existing_parentElement","parentElement","removeChild"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,KAAA,QAAa;AACtB,SAAAC,eAAA,EAAAC,SAAA,EAAAC,SAAA,EAAAC,qBAAA;AAAA,SACEC,QAAAC,KAAA;EACA,IAAAC,MAAA,GAAAL,SAAA;IAAA;MAAAM,cAAA,EAAAC,gBAAA;MAAAC,UAAA,EAAAC;IAAA,IAAAL,KAAA;EACA,IAAAM,OAAA,CAAAC,GAAA,CAAAC,QAAA;IACA,KAAAP,MAAA,QACK,IAAAQ,KAAA;IAGA,IAAAL,UAAiB,GAAAH,MAMrB,CAAAS,KAAA,CAAAP,gBAAA;IACD,IAAM,CAAAH,KAAA,CAAAW,MAAS,IAAAP,UACP,EAEJ;MACEA;IACF;EAEF;EACAH,MAAI,CAACS,KAAA,CAAMP,gBAAU,IAAAE,YAAA;EACnB,IAAAO,GAAA,GAAAN,OAAS,CAAAC,GAAA,CAAAC,QAAW,qBAAAP,MAAA,CAAAY,iBAAA;EAExB,SAAAC,sBAAAC,IAAA;IAEA,IAAAC,QAAa,GAAAC,SAAA,CAAAC,MAAoB,QAAAD,SAAA,iBAAAA,SAAA;IAEjC,OAAM,QACJD,QAAY,KAAAJ,GAAA,IACd,GAAAG,IAAS,CACP,CAAAI,IAAA,CAAO,IAAAP,GAAA,EAAQ,IAA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,QAAA,CAAAS,aAAqB,cAAeD,uBAC1C,KAAS,KAAK,KAAAA,uBACV,CAAAE,WACF,CAASV,QAAA;MAEJ;MACL,OACA;QACFpB,eAAA;QACFU;MACF;IACF","ignoreList":[]}
|
package/dist/jsx/index.native.js
CHANGED
|
@@ -1,68 +1,7 @@
|
|
|
1
1
|
import { isWeb } from "@tamagui/constants";
|
|
2
2
|
import { createVariables, getConfig, parseFont, registerFontVariables } from "@tamagui/web";
|
|
3
|
-
function _array_like_to_array(arr, len) {
|
|
4
|
-
(len == null || len > arr.length) && (len = arr.length);
|
|
5
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
6
|
-
return arr2;
|
|
7
|
-
}
|
|
8
|
-
function _array_with_holes(arr) {
|
|
9
|
-
if (Array.isArray(arr)) return arr;
|
|
10
|
-
}
|
|
11
|
-
function _array_without_holes(arr) {
|
|
12
|
-
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
13
|
-
}
|
|
14
|
-
function _define_property(obj, key, value) {
|
|
15
|
-
return key in obj ? Object.defineProperty(obj, key, {
|
|
16
|
-
value,
|
|
17
|
-
enumerable: !0,
|
|
18
|
-
configurable: !0,
|
|
19
|
-
writable: !0
|
|
20
|
-
}) : obj[key] = value, obj;
|
|
21
|
-
}
|
|
22
|
-
function _iterable_to_array(iter) {
|
|
23
|
-
if (typeof Symbol < "u" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
24
|
-
}
|
|
25
|
-
function _iterable_to_array_limit(arr, i) {
|
|
26
|
-
var _i = arr == null ? null : typeof Symbol < "u" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
27
|
-
if (_i != null) {
|
|
28
|
-
var _arr = [], _n = !0, _d = !1, _s, _e;
|
|
29
|
-
try {
|
|
30
|
-
for (_i = _i.call(arr); !(_n = (_s = _i.next()).done) && (_arr.push(_s.value), !(i && _arr.length === i)); _n = !0)
|
|
31
|
-
;
|
|
32
|
-
} catch (err) {
|
|
33
|
-
_d = !0, _e = err;
|
|
34
|
-
} finally {
|
|
35
|
-
try {
|
|
36
|
-
!_n && _i.return != null && _i.return();
|
|
37
|
-
} finally {
|
|
38
|
-
if (_d) throw _e;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
return _arr;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
function _non_iterable_rest() {
|
|
45
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
46
|
-
}
|
|
47
|
-
function _non_iterable_spread() {
|
|
48
|
-
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
49
|
-
}
|
|
50
|
-
function _sliced_to_array(arr, i) {
|
|
51
|
-
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
52
|
-
}
|
|
53
|
-
function _to_consumable_array(arr) {
|
|
54
|
-
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
55
|
-
}
|
|
56
|
-
function _unsupported_iterable_to_array(o, minLen) {
|
|
57
|
-
if (o) {
|
|
58
|
-
if (typeof o == "string") return _array_like_to_array(o, minLen);
|
|
59
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
60
|
-
if (n === "Object" && o.constructor && (n = o.constructor.name), n === "Map" || n === "Set") return Array.from(n);
|
|
61
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
3
|
function addFont(props) {
|
|
65
|
-
var config = getConfig(),
|
|
4
|
+
var config = getConfig(), { fontFamilyName: fontFamilyNameIn, fontFamily: fontFamilyIn } = props;
|
|
66
5
|
if (process.env.NODE_ENV === "development") {
|
|
67
6
|
if (!config)
|
|
68
7
|
throw new Error("No config");
|
|
@@ -76,19 +15,23 @@ function addFont(props) {
|
|
|
76
15
|
var sep = process.env.NODE_ENV === "development" ? config.cssStyleSeparator || " " : "";
|
|
77
16
|
function declarationsToRuleSet(decs) {
|
|
78
17
|
var selector = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "";
|
|
79
|
-
return
|
|
18
|
+
return `:root${selector} {${sep}${[
|
|
19
|
+
...decs
|
|
20
|
+
].join(`;${sep}`)}${sep}}`;
|
|
80
21
|
}
|
|
81
22
|
if (isWeb) {
|
|
82
|
-
var fontFamilyToken = createVariables(fontFamilyIn, "f", !0), parsedFontFamily = parseFont(fontFamilyToken), fontFamilyNameParsed =
|
|
23
|
+
var fontFamilyToken = createVariables(fontFamilyIn, "f", !0), parsedFontFamily = parseFont(fontFamilyToken), fontFamilyNameParsed = `$${fontFamilyNameIn}`;
|
|
83
24
|
if (config.fontsParsed[fontFamilyNameParsed] = parsedFontFamily, props.insertCSS) {
|
|
84
|
-
var
|
|
25
|
+
var [ff_name, ff_language] = fontFamilyNameParsed.includes("_") ? fontFamilyNameParsed.split("_") : [
|
|
85
26
|
fontFamilyNameParsed
|
|
86
|
-
],
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
27
|
+
], fontVars = registerFontVariables(parsedFontFamily), fontDeclaration = {
|
|
28
|
+
[fontFamilyNameIn]: {
|
|
29
|
+
name: ff_name.slice(1),
|
|
30
|
+
declarations: fontVars,
|
|
31
|
+
language: ff_language
|
|
32
|
+
}
|
|
33
|
+
}, { name, declarations, language = "default" } = 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");
|
|
34
|
+
if (style.id = id, style.appendChild(document.createTextNode(`${cssRuleSets}`)), document.head.appendChild(style), existing) {
|
|
92
35
|
var _existing_parentElement;
|
|
93
36
|
(_existing_parentElement = existing.parentElement) === null || _existing_parentElement === void 0 || _existing_parentElement.removeChild(existing);
|
|
94
37
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Users/n8/tamagui/code/core/font/src/index.ts"],
|
|
4
|
-
"mappings": "AAAA,SAASA,aAAa;AACtB,SACEC,iBACAC,WACAC,WACAC,6BACK
|
|
5
|
-
"names": ["isWeb", "createVariables", "getConfig", "parseFont", "registerFontVariables", "addFont", "props", "config", "
|
|
4
|
+
"mappings": "AAAA,SAASA,aAAa;AACtB,SACEC,iBACAC,WACAC,WACAC,6BACK;AAGA,SAASC,QAAQC;AAOtB,MAAMC,SAASL,UAAAA,GACT,EAAEM,gBAAgBC,kBAAkBC,YAAYC,aAAY,IAAKL;AAEvE,MAAIM,QAAQC,IAAIC,aAAa,eAAe;AAC1C,QAAI,CAACP;AACH,YAAM,IAAIQ,MAAM,WAAA;AAElB,QAAML,aAAaH,OAAOS,MAAMP,gBAAAA;AAChC,QAAI,CAACH,MAAMW,UAAUP;AACnB,aAAO;QAAEA;MAAW;EAExB;AAEAH,SAAOS,MAAMP,gBAAAA,IAAoBE;AAEjC,MAAMO,MACJN,QAAQC,IAAIC,aAAa,gBAAgBP,OAAOY,qBAAqB,MAAM;AAC7E,WAASC,sBAAsBC,MAAc;QAAEC,WAAAA,UAAAA,SAAAA,KAAAA,UAAAA,CAAAA,MAAAA,SAAAA,UAAAA,CAAAA,IAAW;AACxD,WAAO,QAAQA,QAAAA,KAAaJ,GAAAA,GAAM;SAAIG;MAAME,KAAK,IAAIL,GAAAA,EAAK,CAAA,GAAIA,GAAAA;EAChE;AAEA,MAAIlB,OAAO;AACT,QAAMwB,kBAAkBvB,gBAAgBU,cAAc,KAAK,EAAA,GACrDc,mBAAmBtB,UAAUqB,eAAAA,GAC7BE,uBAAuB,IAAIjB,gBAAAA;AAGjC,QAFAF,OAAOoB,YAAYD,oBAAAA,IAAwBD,kBAEvCnB,MAAMsB,WAAW;AACnB,UAAM,CAACC,SAASC,WAAAA,IAAeJ,qBAAqBK,SAAS,GAAA,IACzDL,qBAAqBM,MAAM,GAAA,IAC3B;QAACN;SACCO,WAAW7B,sBAAsBqB,gBAAAA,GACjCS,kBAAkB;QACtB,CAACzB,gBAAAA,GAAmB;UAClB0B,MAAMN,QAAQO,MAAM,CAAA;UACpBC,cAAcJ;UACdK,UAAUR;QACZ;MACF,GAEM,EACJK,MACAE,cACAC,WAAW,UAAS,IAClBJ,gBAAgBzB,gBAAAA,GACd8B,eAAe,SAASJ,IAAAA,IACxBK,eAAe,iBAAiBL,IAAAA,IAAQG,QAAAA,IAAYC,YAAAA,IACpDE,YACJH,aAAa,YAAY,IAAIC,YAAAA,KAAiBC,YAAAA,KAAiBA,cAC3DE,cAActB,sBAAsBiB,cAAcI,SAAAA,GAElDE,KAAK,gBAAgBlC,gBAAAA,IACrBmC,WAAWC,SAASC,cAAc,IAAIH,EAAAA,EAAI,GAC1CI,QAAQF,SAASG,cAAc,OAAA;AAIrC,UAHAD,MAAMJ,KAAKA,IACXI,MAAME,YAAYJ,SAASK,eAAe,GAAGR,WAAAA,EAAa,CAAA,GAC1DG,SAASM,KAAKF,YAAYF,KAAAA,GACtBH,UAAU;YACZA;SAAAA,0BAAAA,SAASQ,mBAAa,QAAtBR,4BAAAA,UAAAA,wBAAwBS,YAAYT,QAAAA;MACtC;AACA,aAAO;QACLpB;QACAU;MACF;IACF;EACF;AACF;",
|
|
5
|
+
"names": ["isWeb", "createVariables", "getConfig", "parseFont", "registerFontVariables", "addFont", "props", "config", "fontFamilyName", "fontFamilyNameIn", "fontFamily", "fontFamilyIn", "process", "env", "NODE_ENV", "Error", "fonts", "update", "sep", "cssStyleSeparator", "declarationsToRuleSet", "decs", "selector", "join", "fontFamilyToken", "parsedFontFamily", "fontFamilyNameParsed", "fontsParsed", "insertCSS", "ff_name", "ff_language", "includes", "split", "fontVars", "fontDeclaration", "name", "slice", "declarations", "language", "fontSelector", "langSelector", "selectors", "cssRuleSets", "id", "existing", "document", "querySelector", "style", "createElement", "appendChild", "createTextNode", "head", "parentElement", "removeChild"]
|
|
6
6
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/font",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.111.0",
|
|
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.
|
|
25
|
-
"@tamagui/web": "1.
|
|
24
|
+
"@tamagui/constants": "1.111.0",
|
|
25
|
+
"@tamagui/web": "1.111.0"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@tamagui/build": "1.
|
|
28
|
+
"@tamagui/build": "1.111.0",
|
|
29
29
|
"react": "^18.2.0 || ^19.0.0"
|
|
30
30
|
},
|
|
31
31
|
"publishConfig": {
|