@tamagui/core 1.112.8 → 1.112.10
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/native.js +43 -19
- package/dist/native.js.map +2 -2
- package/dist/test.native.js +45 -28
- package/dist/test.native.js.map +2 -2
- package/package.json +6 -6
package/dist/test.native.js
CHANGED
|
@@ -1023,9 +1023,10 @@ var require_index_native2 = __commonJS({
|
|
|
1023
1023
|
}
|
|
1024
1024
|
});
|
|
1025
1025
|
module2.exports = __toCommonJS2(src_exports2);
|
|
1026
|
-
var cache2 = /* @__PURE__ */ new Map(), simpleHash = function(
|
|
1026
|
+
var cache2 = /* @__PURE__ */ new Map(), cacheSize = 0, simpleHash = function(strIn) {
|
|
1027
1027
|
var hashMin = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 10;
|
|
1028
|
-
if (cache2.has(
|
|
1028
|
+
if (cache2.has(strIn)) return cache2.get(strIn);
|
|
1029
|
+
var str = strIn;
|
|
1029
1030
|
str[0] === "v" && str.startsWith("var(") && (str = str.slice(6, str.length - 1));
|
|
1030
1031
|
for (var hash = 0, valids = "", added = 0, len = str.length, i = 0; i < len; i++) {
|
|
1031
1032
|
if (hashMin !== "strict" && added <= hashMin) {
|
|
@@ -1042,7 +1043,7 @@ var require_index_native2 = __commonJS({
|
|
|
1042
1043
|
hash = hashChar(hash, str[i]);
|
|
1043
1044
|
}
|
|
1044
1045
|
var res = valids + (hash ? Math.abs(hash) : "");
|
|
1045
|
-
return
|
|
1046
|
+
return cacheSize > 1e4 && (cache2.clear(), cacheSize = 0), cache2.set(strIn, res), cacheSize++, res;
|
|
1046
1047
|
}, hashChar = function(hash, c) {
|
|
1047
1048
|
return Math.imul(31, hash) + c.charCodeAt(0) | 0;
|
|
1048
1049
|
};
|
|
@@ -3037,7 +3038,7 @@ var require_ThemeManager_native = __commonJS({
|
|
|
3037
3038
|
"use strict";
|
|
3038
3039
|
function ThemeManager2() {
|
|
3039
3040
|
var props = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, parentManager = arguments.length > 1 ? arguments[1] : void 0;
|
|
3040
|
-
if (_class_call_check(this, ThemeManager2), _define_property(this, "props", void 0), _define_property(this, "id", void 0), _define_property(this, "themeListeners", void 0), _define_property(this, "parentManager", void 0), _define_property(this, "state", void 0), _define_property(this, "_allKeys", void 0), this.props = props, this.id = 0, this.themeListeners = /* @__PURE__ */ new Set(), this.parentManager = null, this.state = emptyState, this._allKeys = null, uid = (uid + 1) % Number.MAX_VALUE, this.id = uid, parentManager === "root") {
|
|
3041
|
+
if (_class_call_check(this, ThemeManager2), _define_property(this, "props", void 0), _define_property(this, "id", void 0), _define_property(this, "themeListeners", void 0), _define_property(this, "parentManager", void 0), _define_property(this, "state", void 0), _define_property(this, "_allKeys", void 0), _define_property(this, "_selfListener", void 0), this.props = props, this.id = 0, this.themeListeners = /* @__PURE__ */ new Set(), this.parentManager = null, this.state = emptyState, this._allKeys = null, uid = (uid + 1) % Number.MAX_VALUE, this.id = uid, parentManager === "root") {
|
|
3041
3042
|
this.updateStateFromProps(props, !1);
|
|
3042
3043
|
return;
|
|
3043
3044
|
}
|
|
@@ -3057,11 +3058,22 @@ var require_ThemeManager_native = __commonJS({
|
|
|
3057
3058
|
{
|
|
3058
3059
|
key: "updateState",
|
|
3059
3060
|
value: function(nextState) {
|
|
3060
|
-
var
|
|
3061
|
-
this.state = nextState, this._allKeys = null
|
|
3061
|
+
var shouldNotify = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : !0;
|
|
3062
|
+
this.state = nextState, this._allKeys = null;
|
|
3062
3063
|
}
|
|
3063
3064
|
},
|
|
3064
3065
|
{
|
|
3066
|
+
// if (shouldNotify) {
|
|
3067
|
+
// if (process.env.TAMAGUI_TARGET === 'native') {
|
|
3068
|
+
// // native is way slower with queueMicrotask
|
|
3069
|
+
// this.notify()
|
|
3070
|
+
// } else {
|
|
3071
|
+
// // web is way faster this way
|
|
3072
|
+
// queueMicrotask(() => {
|
|
3073
|
+
// this.notify()
|
|
3074
|
+
// })
|
|
3075
|
+
// }
|
|
3076
|
+
// }
|
|
3065
3077
|
key: "getStateIfChanged",
|
|
3066
3078
|
value: function() {
|
|
3067
3079
|
var props = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : this.props, state = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : this.state, parentManager = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : this.parentManager, _ = this.getState(props, parentManager);
|
|
@@ -3104,6 +3116,13 @@ var require_ThemeManager_native = __commonJS({
|
|
|
3104
3116
|
(_this_ = this[_numChangeEventsSent = "_numChangeEventsSent"]) !== null && _this_ !== void 0 || (this[_numChangeEventsSent] = 0), this._numChangeEventsSent++;
|
|
3105
3117
|
}
|
|
3106
3118
|
},
|
|
3119
|
+
{
|
|
3120
|
+
key: "selfUpdate",
|
|
3121
|
+
value: function() {
|
|
3122
|
+
var _this__selfListener, _this;
|
|
3123
|
+
(_this__selfListener = (_this = this)._selfListener) === null || _this__selfListener === void 0 || _this__selfListener.call(_this, this.state.name, this, "self");
|
|
3124
|
+
}
|
|
3125
|
+
},
|
|
3107
3126
|
{
|
|
3108
3127
|
key: "onChangeTheme",
|
|
3109
3128
|
value: function(cb, debugId) {
|
|
@@ -3112,7 +3131,7 @@ var require_ThemeManager_native = __commonJS({
|
|
|
3112
3131
|
var _this__listeningIds;
|
|
3113
3132
|
(_this__listeningIds = this._listeningIds) !== null && _this__listeningIds !== void 0 || (this._listeningIds = /* @__PURE__ */ new Set()), this._listeningIds.add(debugId);
|
|
3114
3133
|
}
|
|
3115
|
-
return this.themeListeners.add(cb), function() {
|
|
3134
|
+
return debugId === !0 && (this._selfListener = cb), this.themeListeners.add(cb), function() {
|
|
3116
3135
|
_this.themeListeners.delete(cb);
|
|
3117
3136
|
};
|
|
3118
3137
|
}
|
|
@@ -3455,7 +3474,7 @@ var require_useTheme_native = __commonJS({
|
|
|
3455
3474
|
if (!theme) return {};
|
|
3456
3475
|
var config = (0, import_config.getConfig)();
|
|
3457
3476
|
function track(key) {
|
|
3458
|
-
keys && !keys.includes(key) && keys.push(key);
|
|
3477
|
+
keys && !keys.includes(key) && (keys.length || themeManager == null || themeManager.selfUpdate(), keys.push(key));
|
|
3459
3478
|
}
|
|
3460
3479
|
return new Proxy(theme, {
|
|
3461
3480
|
has(_, key) {
|
|
@@ -3515,29 +3534,26 @@ var require_useTheme_native = __commonJS({
|
|
|
3515
3534
|
var id = _idToUID[t.id] = {};
|
|
3516
3535
|
_uidToManager.set(id, t);
|
|
3517
3536
|
}
|
|
3518
|
-
},
|
|
3519
|
-
// temporary fix for logs, they are harmless in that i've tried to rewrite this
|
|
3520
|
-
// a few times using the "right" ways, but they are always slower. maybe skill issue
|
|
3521
|
-
function(a) {
|
|
3522
|
-
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) args[_key - 1] = arguments[_key];
|
|
3523
|
-
if (!(typeof a == "string" && a.includes("Cannot update a component"))) return ogLog(a, ...args);
|
|
3524
|
-
}
|
|
3525
|
-
), useChangeThemeEffect = function(props) {
|
|
3537
|
+
}, useChangeThemeEffect = function(props) {
|
|
3526
3538
|
var isRoot = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : !1, keys = arguments.length > 2 ? arguments[2] : void 0, shouldUpdate = arguments.length > 3 ? arguments[3] : void 0, { disable } = props, parentManagerId = import_react3.default.useContext(import_ThemeManagerContext.ThemeManagerIDContext), parentManager = getThemeManager(parentManagerId);
|
|
3527
3539
|
if (!isRoot && !parentManager || disable) return {
|
|
3528
3540
|
isNewTheme: !1,
|
|
3529
3541
|
state: parentManager == null ? void 0 : parentManager.state,
|
|
3530
3542
|
themeManager: parentManager
|
|
3531
3543
|
};
|
|
3532
|
-
var [themeState, setThemeState] = import_react3.default.useState(createState), { state, mounted, isNewTheme, themeManager, inversed } = themeState, isInversingOnMount = !!(!themeState.mounted && props.inverse);
|
|
3544
|
+
var [themeState, setThemeState] = import_react3.default.useState(createState), { state, mounted, isNewTheme, themeManager, inversed, prevState } = themeState, isInversingOnMount = !!(!themeState.mounted && props.inverse);
|
|
3533
3545
|
function getShouldUpdateTheme() {
|
|
3534
|
-
var manager = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : themeManager, nextState = arguments.length > 1 ? arguments[1] : void 0,
|
|
3546
|
+
var manager = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : themeManager, nextState = arguments.length > 1 ? arguments[1] : void 0, prevState2 = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : state, forceShouldChange = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : !1, forceUpdate = shouldUpdate == null ? void 0 : shouldUpdate();
|
|
3535
3547
|
if (!(!manager || !forceShouldChange && forceUpdate === !1)) {
|
|
3536
3548
|
var next = nextState || manager.getState(props, parentManager);
|
|
3537
|
-
if (forceShouldChange || next && !(forceUpdate !== !0 && !manager.getStateShouldChange(next,
|
|
3549
|
+
if (forceShouldChange || next && !(forceUpdate !== !0 && !manager.getStateShouldChange(next, prevState2))) return next;
|
|
3538
3550
|
}
|
|
3539
3551
|
}
|
|
3540
|
-
if (import_constants2.isServer || import_react3.default.
|
|
3552
|
+
if (import_constants2.isServer || (import_react3.default.useLayoutEffect(function() {
|
|
3553
|
+
themeManager && state && prevState && state !== prevState && themeManager.notify();
|
|
3554
|
+
}, [
|
|
3555
|
+
state
|
|
3556
|
+
]), import_react3.default.useEffect(function() {
|
|
3541
3557
|
if (themeManager) {
|
|
3542
3558
|
if (props.inverse && !mounted) {
|
|
3543
3559
|
setThemeState(function(prev) {
|
|
@@ -3550,14 +3566,15 @@ var require_useTheme_native = __commonJS({
|
|
|
3550
3566
|
}
|
|
3551
3567
|
(isNewTheme || getShouldUpdateTheme(themeManager)) && (activeThemeManagers.add(themeManager), setThemeState(createState));
|
|
3552
3568
|
var selfListenerDispose = themeManager.onChangeTheme(function(_a, _b, forced) {
|
|
3553
|
-
forced &&
|
|
3554
|
-
|
|
3555
|
-
|
|
3556
|
-
|
|
3569
|
+
forced && setThemeState(function(prev) {
|
|
3570
|
+
var next = createState(prev, forced !== "self");
|
|
3571
|
+
return next;
|
|
3572
|
+
});
|
|
3573
|
+
}, !0), disposeChangeListener = parentManager == null ? void 0 : parentManager.onChangeTheme(function(name, manager, forced) {
|
|
3557
3574
|
var force = forced || (shouldUpdate == null ? void 0 : shouldUpdate()) || props.deopt || props["disable-child-theme"], shouldTryUpdate = force ?? !!(keys != null && keys.length || isNewTheme);
|
|
3558
|
-
shouldTryUpdate &&
|
|
3575
|
+
shouldTryUpdate && setThemeState(function(prev) {
|
|
3559
3576
|
return createState(prev, force);
|
|
3560
|
-
})
|
|
3577
|
+
});
|
|
3561
3578
|
}, themeManager.id);
|
|
3562
3579
|
return function() {
|
|
3563
3580
|
selfListenerDispose(), disposeChangeListener == null || disposeChangeListener(), isNewTheme && activeThemeManagers.delete(themeManager);
|
|
@@ -3572,7 +3589,7 @@ var require_useTheme_native = __commonJS({
|
|
|
3572
3589
|
props.name,
|
|
3573
3590
|
props.reset,
|
|
3574
3591
|
mounted
|
|
3575
|
-
]), import_constants2.isWeb && isInversingOnMount) return {
|
|
3592
|
+
])), import_constants2.isWeb && isInversingOnMount) return {
|
|
3576
3593
|
isNewTheme: !1,
|
|
3577
3594
|
inversed: !1,
|
|
3578
3595
|
themeManager: parentManager,
|
|
@@ -3617,7 +3634,7 @@ var require_useTheme_native = __commonJS({
|
|
|
3617
3634
|
(0, import_createShallowSetState.isEqualShallow)(prev, response) && // ... and then compare just the state, because we make a new state obj but is likely the same
|
|
3618
3635
|
(0, import_createShallowSetState.isEqualShallow)(prev.state, state2);
|
|
3619
3636
|
if (prev && shouldReturnPrev) return prev;
|
|
3620
|
-
if (response.state = state2, !1)
|
|
3637
|
+
if (response.state = state2, response.prevState = prev == null ? void 0 : prev.state, !1)
|
|
3621
3638
|
var parentState, parentId, themeManagerState;
|
|
3622
3639
|
return response;
|
|
3623
3640
|
}
|