@tamagui/native-registry 3.0.0-beta.1455.1 → 3.0.0-beta.1459.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.native.cjs +4 -19
- package/dist/cjs/index.native.js +4 -19
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/cjs/processStyleColors.native.cjs +12 -0
- package/dist/cjs/processStyleColors.native.js +12 -0
- package/dist/cjs/processStyleColors.native.js.map +1 -1
- package/dist/esm/index.native.js +4 -18
- package/dist/esm/index.native.js.map +1 -1
- package/dist/esm/processStyleColors.native.js +6 -0
- package/dist/esm/processStyleColors.native.js.map +1 -1
- package/package.json +2 -2
- package/src/index.native.ts +6 -17
- package/src/processBackgroundImage.d.ts +6 -0
- package/src/processStyleColors.native.ts +14 -2
- package/types/index.native.d.ts +4 -2
- package/types/index.native.d.ts.map +2 -2
- package/types/processStyleColors.native.d.ts.map +2 -2
|
@@ -29,7 +29,7 @@ __export(index_native_exports, {
|
|
|
29
29
|
getViewState: () => getViewState,
|
|
30
30
|
isAvailable: () => isAvailable,
|
|
31
31
|
link: () => link,
|
|
32
|
-
processStyleColors: () =>
|
|
32
|
+
processStyleColors: () => import_processStyleColors.processStyleColors,
|
|
33
33
|
removeScope: () => removeScope,
|
|
34
34
|
resolveSlots: () => resolveSlots,
|
|
35
35
|
setStateName: () => setStateName,
|
|
@@ -38,9 +38,8 @@ __export(index_native_exports, {
|
|
|
38
38
|
module.exports = __toCommonJS(index_native_exports);
|
|
39
39
|
var import_react_native_nitro_modules = require("react-native-nitro-modules");
|
|
40
40
|
var import_mirror = require("./mirror.native.js");
|
|
41
|
-
var import_processStyleColors = require("./processStyleColors.native.js");
|
|
42
41
|
var import_mirror2 = require("./mirror.native.js");
|
|
43
|
-
var
|
|
42
|
+
var import_processStyleColors = require("./processStyleColors.native.js");
|
|
44
43
|
var engine = null;
|
|
45
44
|
var initError = null;
|
|
46
45
|
try {
|
|
@@ -72,16 +71,7 @@ function link(ref, slots) {
|
|
|
72
71
|
var node = getShadowNode(ref);
|
|
73
72
|
if (!node) return null;
|
|
74
73
|
var e = getEngine();
|
|
75
|
-
var
|
|
76
|
-
if (slots.base) prepared.base = (0, import_processStyleColors.processStyleColors)(slots.base);
|
|
77
|
-
if (slots.state) {
|
|
78
|
-
var state = {};
|
|
79
|
-
for (var name in slots.state) {
|
|
80
|
-
state[name] = (0, import_processStyleColors.processStyleColors)(slots.state[name]);
|
|
81
|
-
}
|
|
82
|
-
prepared.state = state;
|
|
83
|
-
}
|
|
84
|
-
var id = e.link(node, prepared, scopeId);
|
|
74
|
+
var id = e.link(node, slots, scopeId);
|
|
85
75
|
var unlinked = false;
|
|
86
76
|
return {
|
|
87
77
|
id,
|
|
@@ -98,12 +88,7 @@ function applyViewStates(entries) {
|
|
|
98
88
|
}
|
|
99
89
|
function updateViewStateTables(entries) {
|
|
100
90
|
if (entries.length === 0) return;
|
|
101
|
-
getEngine().updateViewStateTables(entries
|
|
102
|
-
return {
|
|
103
|
-
...entry,
|
|
104
|
-
props: (0, import_processStyleColors.processStyleColors)(entry.props)
|
|
105
|
-
};
|
|
106
|
-
}));
|
|
91
|
+
getEngine().updateViewStateTables(entries);
|
|
107
92
|
}
|
|
108
93
|
function setStateName(stateName) {
|
|
109
94
|
var scopeId = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : import_mirror.ROOT_SCOPE;
|
package/dist/cjs/index.native.js
CHANGED
|
@@ -29,7 +29,7 @@ __export(index_native_exports, {
|
|
|
29
29
|
getViewState: () => getViewState,
|
|
30
30
|
isAvailable: () => isAvailable,
|
|
31
31
|
link: () => link,
|
|
32
|
-
processStyleColors: () =>
|
|
32
|
+
processStyleColors: () => import_processStyleColors.processStyleColors,
|
|
33
33
|
removeScope: () => removeScope,
|
|
34
34
|
resolveSlots: () => resolveSlots,
|
|
35
35
|
setStateName: () => setStateName,
|
|
@@ -38,9 +38,8 @@ __export(index_native_exports, {
|
|
|
38
38
|
module.exports = __toCommonJS(index_native_exports);
|
|
39
39
|
var import_react_native_nitro_modules = require("react-native-nitro-modules");
|
|
40
40
|
var import_mirror = require("./mirror.native.js");
|
|
41
|
-
var import_processStyleColors = require("./processStyleColors.native.js");
|
|
42
41
|
var import_mirror2 = require("./mirror.native.js");
|
|
43
|
-
var
|
|
42
|
+
var import_processStyleColors = require("./processStyleColors.native.js");
|
|
44
43
|
var engine = null;
|
|
45
44
|
var initError = null;
|
|
46
45
|
try {
|
|
@@ -72,16 +71,7 @@ function link(ref, slots) {
|
|
|
72
71
|
var node = getShadowNode(ref);
|
|
73
72
|
if (!node) return null;
|
|
74
73
|
var e = getEngine();
|
|
75
|
-
var
|
|
76
|
-
if (slots.base) prepared.base = (0, import_processStyleColors.processStyleColors)(slots.base);
|
|
77
|
-
if (slots.state) {
|
|
78
|
-
var state = {};
|
|
79
|
-
for (var name in slots.state) {
|
|
80
|
-
state[name] = (0, import_processStyleColors.processStyleColors)(slots.state[name]);
|
|
81
|
-
}
|
|
82
|
-
prepared.state = state;
|
|
83
|
-
}
|
|
84
|
-
var id = e.link(node, prepared, scopeId);
|
|
74
|
+
var id = e.link(node, slots, scopeId);
|
|
85
75
|
var unlinked = false;
|
|
86
76
|
return {
|
|
87
77
|
id,
|
|
@@ -98,12 +88,7 @@ function applyViewStates(entries) {
|
|
|
98
88
|
}
|
|
99
89
|
function updateViewStateTables(entries) {
|
|
100
90
|
if (entries.length === 0) return;
|
|
101
|
-
getEngine().updateViewStateTables(entries
|
|
102
|
-
return {
|
|
103
|
-
...entry,
|
|
104
|
-
props: (0, import_processStyleColors.processStyleColors)(entry.props)
|
|
105
|
-
};
|
|
106
|
-
}));
|
|
91
|
+
getEngine().updateViewStateTables(entries);
|
|
107
92
|
}
|
|
108
93
|
function setStateName(stateName) {
|
|
109
94
|
var scopeId = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : import_mirror.ROOT_SCOPE;
|
|
@@ -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_native_exports = {};\n__export(index_native_exports, {\n ROOT_SCOPE: () => import_mirror2.ROOT_SCOPE,\n applyViewStates: () => applyViewStates,\n getMirroredStateName: () => import_mirror2.getMirroredStateName,\n getStats: () => getStats,\n getViewState: () => getViewState,\n isAvailable: () => isAvailable,\n link: () => link,\n processStyleColors: () =>
|
|
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_native_exports = {};\n__export(index_native_exports, {\n ROOT_SCOPE: () => import_mirror2.ROOT_SCOPE,\n applyViewStates: () => applyViewStates,\n getMirroredStateName: () => import_mirror2.getMirroredStateName,\n getStats: () => getStats,\n getViewState: () => getViewState,\n isAvailable: () => isAvailable,\n link: () => link,\n processStyleColors: () => import_processStyleColors.processStyleColors,\n removeScope: () => removeScope,\n resolveSlots: () => resolveSlots,\n setStateName: () => setStateName,\n updateViewStateTables: () => updateViewStateTables\n});\nmodule.exports = __toCommonJS(index_native_exports);\nvar import_react_native_nitro_modules = require(\"react-native-nitro-modules\");\nvar import_mirror = require(\"./mirror\");\nvar import_mirror2 = require(\"./mirror\");\nvar import_processStyleColors = require(\"./processStyleColors.native\");\nvar engine = null;\nvar initError = null;\ntry {\n engine = import_react_native_nitro_modules.NitroModules.createHybridObject(\"TamaguiRegistry\");\n} catch (error) {\n initError = error;\n}\nfunction isAvailable() {\n return engine !== null;\n}\nfunction getEngine() {\n if (engine) return engine;\n var detail = initError instanceof Error ? ` ${initError.message}` : \"\";\n throw new Error(`[@tamagui/native-registry] TamaguiRegistry failed to initialize; is react-native-nitro-modules installed and the app rebuilt?${detail}`);\n}\nfunction getShadowNode(ref) {\n var _handle_stateNode;\n var handle = ref === null || ref === void 0 ? void 0 : ref.__internalInstanceHandle;\n var _handle_stateNode_node;\n return (_handle_stateNode_node = handle === null || handle === void 0 ? void 0 : (_handle_stateNode = handle.stateNode) === null || _handle_stateNode === void 0 ? void 0 : _handle_stateNode.node) !== null && _handle_stateNode_node !== void 0 ? _handle_stateNode_node : null;\n}\nfunction isNitroHybridView(ref) {\n var config = ref === null || ref === void 0 ? void 0 : ref.__viewConfig;\n return !!(config === null || config === void 0 ? void 0 : config.validAttributes) && \"hybridRef\" in config.validAttributes;\n}\nfunction link(ref, slots) {\n var scopeId = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : import_mirror.ROOT_SCOPE;\n if (isNitroHybridView(ref)) return null;\n var node = getShadowNode(ref);\n if (!node) return null;\n var e = getEngine();\n var id = e.link(node, slots, scopeId);\n var unlinked = false;\n return {\n id,\n unlink: function() {\n if (unlinked) return;\n unlinked = true;\n e.unlink(id);\n }\n };\n}\nfunction applyViewStates(entries) {\n if (entries.length === 0) return;\n getEngine().applyViewStates(entries);\n}\nfunction updateViewStateTables(entries) {\n if (entries.length === 0) return;\n getEngine().updateViewStateTables(entries);\n}\nfunction setStateName(stateName) {\n var scopeId = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : import_mirror.ROOT_SCOPE;\n (0, import_mirror.setMirroredStateName)(scopeId, stateName);\n getEngine().setStateName(scopeId, stateName);\n}\nfunction removeScope(scopeId) {\n (0, import_mirror.removeMirroredScope)(scopeId);\n getEngine().removeScope(scopeId);\n}\nfunction resolveSlots(slots) {\n var scopeId = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : import_mirror.ROOT_SCOPE;\n var _slots_state;\n var name = (0, import_mirror.getMirroredStateName)(scopeId);\n return {\n ...slots.base,\n ...name ? (_slots_state = slots.state) === null || _slots_state === void 0 ? void 0 : _slots_state[name] : void 0\n };\n}\nfunction getViewState(id) {\n if (!engine) return null;\n return engine.getViewState(id);\n}\nfunction getStats() {\n if (!engine) return {\n viewCount: 0,\n commitCount: 0,\n missCount: 0\n };\n return {\n viewCount: engine.getViewCount(),\n commitCount: engine.getCommitCount(),\n missCount: engine.getMissCount()\n };\n}\n//# sourceMappingURL=index.native.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,Y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AAY,OAAO;AACjC;AACA,SAAS,aAAa,OAAO;CAC3B,IAAI,UAAU,UAAU,SAAS,KAAK,UAAU,OAAO,KAAK,IAAI,UAAU,KAAK,cAAc;CAC7F,IAAI;CACJ,IAAI,QAAQ,GAAG,cAAc,qBAAoB,CAAE,OAAO;CAC1D,OAAO;EACL,GAAG,MAAM;EACT,GAAG,QAAQ,eAAe,MAAM,WAAW,QAAQ,iBAAiB,KAAK,IAAI,KAAK,IAAI,aAAa,QAAQ,KAAK;CAClH;AACF;AACA,SAAS,aAAa,IAAI;CACxB,IAAI,CAAC,QAAQ,OAAO;CACpB,OAAO,OAAO,aAAa,EAAE;AAC/B;AACA,SAAS,WAAW;CAClB,IAAI,CAAC,QAAQ,OAAO;EAClB,WAAW;EACX,aAAa;EACb,WAAW;CACb;CACA,OAAO;EACL,WAAW,OAAO,aAAa;EAC/B,aAAa,OAAO,eAAe;EACnC,WAAW,OAAO,aAAa;CACjC;AACF"}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var __create = Object.create;
|
|
3
4
|
var __defProp = Object.defineProperty;
|
|
4
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
8
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
9
|
var __export = (target, all) => {
|
|
8
10
|
for (var name in all) __defProp(target, name, {
|
|
@@ -19,11 +21,16 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
19
21
|
}
|
|
20
22
|
return to;
|
|
21
23
|
};
|
|
24
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
25
|
+
value: mod,
|
|
26
|
+
enumerable: true
|
|
27
|
+
}) : target, mod));
|
|
22
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
23
29
|
var processStyleColors_native_exports = {};
|
|
24
30
|
__export(processStyleColors_native_exports, { processStyleColors: () => processStyleColors });
|
|
25
31
|
module.exports = __toCommonJS(processStyleColors_native_exports);
|
|
26
32
|
var import_react_native = require("react-native");
|
|
33
|
+
var import_processBackgroundImage = __toESM(require("react-native/Libraries/StyleSheet/processBackgroundImage"), 1);
|
|
27
34
|
var COLOR_PROPS = /* @__PURE__ */ new Set([
|
|
28
35
|
"color",
|
|
29
36
|
"backgroundColor",
|
|
@@ -47,6 +54,11 @@ function processStyleColors(props) {
|
|
|
47
54
|
var out = null;
|
|
48
55
|
for (var key in props) {
|
|
49
56
|
var value = props[key];
|
|
57
|
+
if (key === "experimental_backgroundImage" && value != null) {
|
|
58
|
+
value = (0, import_processBackgroundImage.default)(value);
|
|
59
|
+
out !== null && out !== void 0 ? out : out = { ...props };
|
|
60
|
+
out[key] = value;
|
|
61
|
+
}
|
|
50
62
|
if ((key === "boxShadow" || key === "experimental_backgroundImage" || key === "colorStops") && Array.isArray(value)) {
|
|
51
63
|
var changed = false;
|
|
52
64
|
var next = [];
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var __create = Object.create;
|
|
3
4
|
var __defProp = Object.defineProperty;
|
|
4
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
8
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
9
|
var __export = (target, all) => {
|
|
8
10
|
for (var name in all) __defProp(target, name, {
|
|
@@ -19,11 +21,16 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
19
21
|
}
|
|
20
22
|
return to;
|
|
21
23
|
};
|
|
24
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
25
|
+
value: mod,
|
|
26
|
+
enumerable: true
|
|
27
|
+
}) : target, mod));
|
|
22
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
23
29
|
var processStyleColors_native_exports = {};
|
|
24
30
|
__export(processStyleColors_native_exports, { processStyleColors: () => processStyleColors });
|
|
25
31
|
module.exports = __toCommonJS(processStyleColors_native_exports);
|
|
26
32
|
var import_react_native = require("react-native");
|
|
33
|
+
var import_processBackgroundImage = __toESM(require("react-native/Libraries/StyleSheet/processBackgroundImage"), 1);
|
|
27
34
|
var COLOR_PROPS = /* @__PURE__ */ new Set([
|
|
28
35
|
"color",
|
|
29
36
|
"backgroundColor",
|
|
@@ -47,6 +54,11 @@ function processStyleColors(props) {
|
|
|
47
54
|
var out = null;
|
|
48
55
|
for (var key in props) {
|
|
49
56
|
var value = props[key];
|
|
57
|
+
if (key === "experimental_backgroundImage" && value != null) {
|
|
58
|
+
value = (0, import_processBackgroundImage.default)(value);
|
|
59
|
+
out !== null && out !== void 0 ? out : out = { ...props };
|
|
60
|
+
out[key] = value;
|
|
61
|
+
}
|
|
50
62
|
if ((key === "boxShadow" || key === "experimental_backgroundImage" || key === "colorStops") && Array.isArray(value)) {
|
|
51
63
|
var changed = false;
|
|
52
64
|
var next = [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"processStyleColors.native.js","names":[],"sources":["cjs/processStyleColors.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 processStyleColors_native_exports = {};\n__export(processStyleColors_native_exports, {\n processStyleColors: () => processStyleColors\n});\nmodule.exports = __toCommonJS(processStyleColors_native_exports);\nvar import_react_native = require(\"react-native\");\nvar COLOR_PROPS = /* @__PURE__ */ new Set([\n \"color\",\n \"backgroundColor\",\n \"borderColor\",\n \"borderTopColor\",\n \"borderBottomColor\",\n \"borderLeftColor\",\n \"borderRightColor\",\n \"borderStartColor\",\n \"borderEndColor\",\n \"borderBlockColor\",\n \"borderBlockStartColor\",\n \"borderBlockEndColor\",\n \"shadowColor\",\n \"textShadowColor\",\n \"textDecorationColor\",\n \"tintColor\",\n \"overlayColor\"\n]);\nfunction processStyleColors(props) {\n var out = null;\n for (var key in props) {\n var value = props[key];\n if ((key === \"boxShadow\" || key === \"experimental_backgroundImage\" || key === \"colorStops\") && Array.isArray(value)) {\n var changed = false;\n var next = [];\n var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;\n try {\n for (var _iterator = value[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var entry = _step.value;\n var processed = processStyleColors(entry);\n if (processed !== entry) changed = true;\n next.push(processed);\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n if (changed) {\n out !== null && out !== void 0 ? out : out = {\n ...props\n };\n out[key] = next;\n }\n continue;\n }\n if (!COLOR_PROPS.has(key)) continue;\n var processed1 = typeof value === \"string\" || typeof value === \"object\" && value !== null ? (0, import_react_native.processColor)(value) : value;\n if (typeof processed1 === \"number\") {\n out !== null && out !== void 0 ? out : out = {\n ...props\n };\n out[key] = {\n space: \"srgb\",\n r: (processed1 >>> 16 & 255) / 255,\n g: (processed1 >>> 8 & 255) / 255,\n b: (processed1 & 255) / 255,\n a: (processed1 >>> 24 & 255) / 255\n };\n } else if (processed1 != null && typeof processed1 === \"object\") {\n out !== null && out !== void 0 ? out : out = {\n ...props\n };\n out[key] = processed1;\n }\n }\n return out !== null && out !== void 0 ? out : props;\n}\n//# sourceMappingURL=processStyleColors.native.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,IAAI,oCAAoC,CAAC;AACzC,SAAS,mCAAmC,EAC1C,0BAA0B,mBAC5B,CAAC;AACD,OAAO,UAAU,aAAa,iCAAiC;AAC/D,IAAI,sBAAsB,QAAQ,cAAc;AAChD,IAAI,8BAA8B,IAAI,IAAI;CACxC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA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IAAI,aAAa,OAAO;IACxB,IAAI,eAAe,KAAK,OAAO;GACjC;EACF,OAAO,IAAI,cAAc,QAAQ,OAAO,eAAe,UAAU;GAC/D,QAAQ,QAAQ,QAAQ,KAAK,IAAI,MAAM,MAAM,EAC3C,GAAG,MACL;GACA,IAAI,OAAO;EACb;CACF;CACA,OAAO,QAAQ,QAAQ,QAAQ,KAAK,IAAI,MAAM;AAChD"}
|
|
1
|
+
{"version":3,"file":"processStyleColors.native.js","names":[],"sources":["cjs/processStyleColors.native.js"],"sourcesContent":["\"use strict\";\nvar __create = Object.create;\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __getProtoOf = Object.getPrototypeOf;\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 __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(\n // If the importer is in node compatibility mode or this is not an ESM\n // file that has been converted to a CommonJS file using a Babel-\n // compatible transform (i.e. \"__esModule\" has not been set), then set\n // \"default\" to the CommonJS \"module.exports\" for node compatibility.\n isNodeMode || !mod || !mod.__esModule ? __defProp(target, \"default\", { value: mod, enumerable: true }) : target,\n mod\n));\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar processStyleColors_native_exports = {};\n__export(processStyleColors_native_exports, {\n processStyleColors: () => processStyleColors\n});\nmodule.exports = __toCommonJS(processStyleColors_native_exports);\nvar import_react_native = require(\"react-native\");\nvar import_processBackgroundImage = __toESM(require(\"react-native/Libraries/StyleSheet/processBackgroundImage\"), 1);\nvar COLOR_PROPS = /* @__PURE__ */ new Set([\n \"color\",\n \"backgroundColor\",\n \"borderColor\",\n \"borderTopColor\",\n \"borderBottomColor\",\n \"borderLeftColor\",\n \"borderRightColor\",\n \"borderStartColor\",\n \"borderEndColor\",\n \"borderBlockColor\",\n \"borderBlockStartColor\",\n \"borderBlockEndColor\",\n \"shadowColor\",\n \"textShadowColor\",\n \"textDecorationColor\",\n \"tintColor\",\n \"overlayColor\"\n]);\nfunction processStyleColors(props) {\n var out = null;\n for (var key in props) {\n var value = props[key];\n if (key === \"experimental_backgroundImage\" && value != null) {\n value = (0, import_processBackgroundImage.default)(value);\n out !== null && out !== void 0 ? out : out = {\n ...props\n };\n out[key] = value;\n }\n if ((key === \"boxShadow\" || key === \"experimental_backgroundImage\" || key === \"colorStops\") && Array.isArray(value)) {\n var changed = false;\n var next = [];\n var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;\n try {\n for (var _iterator = value[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var entry = _step.value;\n var processed = processStyleColors(entry);\n if (processed !== entry) changed = true;\n next.push(processed);\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n if (changed) {\n out !== null && out !== void 0 ? out : out = {\n ...props\n };\n out[key] = next;\n }\n continue;\n }\n if (!COLOR_PROPS.has(key)) continue;\n var processed1 = typeof value === \"string\" || typeof value === \"object\" && value !== null ? (0, import_react_native.processColor)(value) : value;\n if (typeof processed1 === \"number\") {\n out !== null && out !== void 0 ? out : out = {\n ...props\n };\n out[key] = {\n space: \"srgb\",\n r: (processed1 >>> 16 & 255) / 255,\n g: (processed1 >>> 8 & 255) / 255,\n b: (processed1 & 255) / 255,\n a: (processed1 >>> 24 & 255) / 255\n };\n } else if (processed1 != null && typeof processed1 === \"object\") {\n out !== null && out !== void 0 ? out : out = {\n ...props\n };\n out[key] = processed1;\n }\n }\n return out !== null && out !== void 0 ? out : props;\n}\n//# sourceMappingURL=processStyleColors.native.js.map\n"],"mappings":";;;AACA,IAAI,WAAW,OAAO;AACtB,IAAI,YAAY,OAAO;AACvB,IAAI,mBAAmB,OAAO;AAC9B,IAAI,oBAAoB,OAAO;AAC/B,IAAI,eAAe,OAAO;AAC1B,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,WAAW,KAAK,YAAY,YAAY,SAAS,OAAO,OAAO,SAAS,aAAa,GAAG,CAAC,IAAI,CAAC,GAAG,YAKnG,cAAc,CAAC,OAAO,CAAC,IAAI,aAAa,UAAU,QAAQ,WAAW;CAAE,OAAO;CAAK,YAAY;AAAK,CAAC,IAAI,QACzG,GACF;AACA,IAAI,gBAAgB,QAAQ,YAAY,UAAU,CAAC,GAAG,cAAc,EAAE,OAAO,KAAK,CAAC,GAAG,GAAG;AACzF,IAAI,oCAAoC,CAAC;AACzC,SAAS,mCAAmC,EAC1C,0BAA0B,mBAC5B,CAAC;AACD,OAAO,UAAU,aAAa,iCAAiC;AA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EACA,IAAI,CAAC,YAAY,IAAI,GAAG,GAAG;EAC3B,IAAI,aAAa,OAAO,UAAU,YAAY,OAAO,UAAU,YAAY,UAAU,QAAQ,GAAG,oBAAoB,aAAY,CAAE,KAAK,IAAI;EAC3I,IAAI,OAAO,eAAe,UAAU;GAClC,QAAQ,QAAQ,QAAQ,KAAK,IAAI,MAAM,MAAM,EAC3C,GAAG,MACL;GACA,IAAI,OAAO;IACT,OAAO;IACP,IAAI,eAAe,KAAK,OAAO;IAC/B,IAAI,eAAe,IAAI,OAAO;IAC9B,IAAI,aAAa,OAAO;IACxB,IAAI,eAAe,KAAK,OAAO;GACjC;EACF,OAAO,IAAI,cAAc,QAAQ,OAAO,eAAe,UAAU;GAC/D,QAAQ,QAAQ,QAAQ,KAAK,IAAI,MAAM,MAAM,EAC3C,GAAG,MACL;GACA,IAAI,OAAO;EACb;CACF;CACA,OAAO,QAAQ,QAAQ,QAAQ,KAAK,IAAI,MAAM;AAChD"}
|
package/dist/esm/index.native.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { NitroModules } from "react-native-nitro-modules";
|
|
2
2
|
import { ROOT_SCOPE, ROOT_SCOPE as ROOT_SCOPE2, getMirroredStateName, getMirroredStateName as getMirroredStateName2, removeMirroredScope, setMirroredStateName } from "./mirror.native.js";
|
|
3
|
-
import { processStyleColors
|
|
3
|
+
import { processStyleColors } from "./processStyleColors.native.js";
|
|
4
4
|
|
|
5
5
|
var engine = null;
|
|
6
6
|
var initError = null;
|
|
@@ -33,16 +33,7 @@ function link(ref, slots) {
|
|
|
33
33
|
var node = getShadowNode(ref);
|
|
34
34
|
if (!node) return null;
|
|
35
35
|
var e = getEngine();
|
|
36
|
-
var
|
|
37
|
-
if (slots.base) prepared.base = processStyleColors(slots.base);
|
|
38
|
-
if (slots.state) {
|
|
39
|
-
var state = {};
|
|
40
|
-
for (var name in slots.state) {
|
|
41
|
-
state[name] = processStyleColors(slots.state[name]);
|
|
42
|
-
}
|
|
43
|
-
prepared.state = state;
|
|
44
|
-
}
|
|
45
|
-
var id = e.link(node, prepared, scopeId);
|
|
36
|
+
var id = e.link(node, slots, scopeId);
|
|
46
37
|
var unlinked = false;
|
|
47
38
|
return {
|
|
48
39
|
id,
|
|
@@ -59,12 +50,7 @@ function applyViewStates(entries) {
|
|
|
59
50
|
}
|
|
60
51
|
function updateViewStateTables(entries) {
|
|
61
52
|
if (entries.length === 0) return;
|
|
62
|
-
getEngine().updateViewStateTables(entries
|
|
63
|
-
return {
|
|
64
|
-
...entry,
|
|
65
|
-
props: processStyleColors(entry.props)
|
|
66
|
-
};
|
|
67
|
-
}));
|
|
53
|
+
getEngine().updateViewStateTables(entries);
|
|
68
54
|
}
|
|
69
55
|
function setStateName(stateName) {
|
|
70
56
|
var scopeId = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : ROOT_SCOPE;
|
|
@@ -101,5 +87,5 @@ function getStats() {
|
|
|
101
87
|
};
|
|
102
88
|
}
|
|
103
89
|
|
|
104
|
-
export { ROOT_SCOPE2 as ROOT_SCOPE, applyViewStates, getMirroredStateName2 as getMirroredStateName, getStats, getViewState, isAvailable, link,
|
|
90
|
+
export { ROOT_SCOPE2 as ROOT_SCOPE, applyViewStates, getMirroredStateName2 as getMirroredStateName, getStats, getViewState, isAvailable, link, processStyleColors, removeScope, resolveSlots, setStateName, updateViewStateTables };
|
|
105
91
|
//# sourceMappingURL=index.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.native.js","names":[],"sources":["esm/index.native.js"],"sourcesContent":["import { NitroModules } from \"react-native-nitro-modules\";\nimport { ROOT_SCOPE, getMirroredStateName, removeMirroredScope, setMirroredStateName } from \"./mirror\";\nimport {
|
|
1
|
+
{"version":3,"file":"index.native.js","names":[],"sources":["esm/index.native.js"],"sourcesContent":["import { NitroModules } from \"react-native-nitro-modules\";\nimport { ROOT_SCOPE, getMirroredStateName, removeMirroredScope, setMirroredStateName } from \"./mirror\";\nimport { ROOT_SCOPE as ROOT_SCOPE2, getMirroredStateName as getMirroredStateName2 } from \"./mirror\";\nimport { processStyleColors } from \"./processStyleColors.native\";\nvar engine = null;\nvar initError = null;\ntry {\n engine = NitroModules.createHybridObject(\"TamaguiRegistry\");\n} catch (error) {\n initError = error;\n}\nfunction isAvailable() {\n return engine !== null;\n}\nfunction getEngine() {\n if (engine) return engine;\n var detail = initError instanceof Error ? ` ${initError.message}` : \"\";\n throw new Error(`[@tamagui/native-registry] TamaguiRegistry failed to initialize; is react-native-nitro-modules installed and the app rebuilt?${detail}`);\n}\nfunction getShadowNode(ref) {\n var _handle_stateNode;\n var handle = ref === null || ref === void 0 ? void 0 : ref.__internalInstanceHandle;\n var _handle_stateNode_node;\n return (_handle_stateNode_node = handle === null || handle === void 0 ? void 0 : (_handle_stateNode = handle.stateNode) === null || _handle_stateNode === void 0 ? void 0 : _handle_stateNode.node) !== null && _handle_stateNode_node !== void 0 ? _handle_stateNode_node : null;\n}\nfunction isNitroHybridView(ref) {\n var config = ref === null || ref === void 0 ? void 0 : ref.__viewConfig;\n return !!(config === null || config === void 0 ? void 0 : config.validAttributes) && \"hybridRef\" in config.validAttributes;\n}\nfunction link(ref, slots) {\n var scopeId = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : ROOT_SCOPE;\n if (isNitroHybridView(ref)) return null;\n var node = getShadowNode(ref);\n if (!node) return null;\n var e = getEngine();\n var id = e.link(node, slots, scopeId);\n var unlinked = false;\n return {\n id,\n unlink: function() {\n if (unlinked) return;\n unlinked = true;\n e.unlink(id);\n }\n };\n}\nfunction applyViewStates(entries) {\n if (entries.length === 0) return;\n getEngine().applyViewStates(entries);\n}\nfunction updateViewStateTables(entries) {\n if (entries.length === 0) return;\n getEngine().updateViewStateTables(entries);\n}\nfunction setStateName(stateName) {\n var scopeId = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : ROOT_SCOPE;\n setMirroredStateName(scopeId, stateName);\n getEngine().setStateName(scopeId, stateName);\n}\nfunction removeScope(scopeId) {\n removeMirroredScope(scopeId);\n getEngine().removeScope(scopeId);\n}\nfunction resolveSlots(slots) {\n var scopeId = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : ROOT_SCOPE;\n var _slots_state;\n var name = getMirroredStateName(scopeId);\n return {\n ...slots.base,\n ...name ? (_slots_state = slots.state) === null || _slots_state === void 0 ? void 0 : _slots_state[name] : void 0\n };\n}\nfunction getViewState(id) {\n if (!engine) return null;\n return engine.getViewState(id);\n}\nfunction getStats() {\n if (!engine) return {\n viewCount: 0,\n commitCount: 0,\n missCount: 0\n };\n return {\n viewCount: engine.getViewCount(),\n commitCount: engine.getCommitCount(),\n missCount: engine.getMissCount()\n };\n}\nexport {\n ROOT_SCOPE2 as ROOT_SCOPE,\n applyViewStates,\n getMirroredStateName2 as getMirroredStateName,\n getStats,\n getViewState,\n isAvailable,\n link,\n processStyleColors,\n removeScope,\n resolveSlots,\n setStateName,\n updateViewStateTables\n};\n//# sourceMappingURL=index.native.js.map\n"],"mappings":";;;;;AAIA,IAAI,SAAS;AACb,IAAI,YAAY;AAChB,IAAI;CACF,SAAS,aAAa,mBAAmB,iBAAiB;AAC5D,SAAS,OAAO;CACd,YAAY;AACd;AACA,SAAS,cAAc;CACrB,OAAO,WAAW;AACpB;AACA,SAAS,YAAY;CACnB,IAAI,QAAQ,OAAO;CACnB,IAAI,SAAS,qBAAqB,QAAQ,IAAI,UAAU,YAAY;CACpE,MAAM,IAAI,MAAM,gIAAgI,QAAQ;AAC1J;AACA,SAAS,cAAc,KAAK;CAC1B,IAAI;CACJ,IAAI,SAAS,QAAQ,QAAQ,QAAQ,KAAK,IAAI,KAAK,IAAI,IAAI;CAC3D,IAAI;CACJ,QAAQ,yBAAyB,WAAW,QAAQ,WAAW,KAAK,IAAI,KAAK,KAAK,oBAAoB,OAAO,eAAe,QAAQ,sBAAsB,KAAK,IAAI,KAAK,IAAI,kBAAkB,UAAU,QAAQ,2BAA2B,KAAK,IAAI,yBAAyB;A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AM;EACT,GAAG,QAAQ,eAAe,MAAM,WAAW,QAAQ,iBAAiB,KAAK,IAAI,KAAK,IAAI,aAAa,QAAQ,KAAK;CAClH;AACF;AACA,SAAS,aAAa,IAAI;CACxB,IAAI,CAAC,QAAQ,OAAO;CACpB,OAAO,OAAO,aAAa,EAAE;AAC/B;AACA,SAAS,WAAW;CAClB,IAAI,CAAC,QAAQ,OAAO;EAClB,WAAW;EACX,aAAa;EACb,WAAW;CACb;CACA,OAAO;EACL,WAAW,OAAO,aAAa;EAC/B,aAAa,OAAO,eAAe;EACnC,WAAW,OAAO,aAAa;CACjC;AACF"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { processColor } from "react-native";
|
|
2
|
+
import processBackgroundImage from "react-native/Libraries/StyleSheet/processBackgroundImage";
|
|
2
3
|
|
|
3
4
|
var COLOR_PROPS = /* @__PURE__ */ new Set([
|
|
4
5
|
"color",
|
|
@@ -23,6 +24,11 @@ function processStyleColors(props) {
|
|
|
23
24
|
var out = null;
|
|
24
25
|
for (var key in props) {
|
|
25
26
|
var value = props[key];
|
|
27
|
+
if (key === "experimental_backgroundImage" && value != null) {
|
|
28
|
+
value = processBackgroundImage(value);
|
|
29
|
+
out !== null && out !== void 0 ? out : out = { ...props };
|
|
30
|
+
out[key] = value;
|
|
31
|
+
}
|
|
26
32
|
if ((key === "boxShadow" || key === "experimental_backgroundImage" || key === "colorStops") && Array.isArray(value)) {
|
|
27
33
|
var changed = false;
|
|
28
34
|
var next = [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"processStyleColors.native.js","names":[],"sources":["esm/processStyleColors.native.js"],"sourcesContent":["import { processColor } from \"react-native\";\nvar COLOR_PROPS = /* @__PURE__ */ new Set([\n \"color\",\n \"backgroundColor\",\n \"borderColor\",\n \"borderTopColor\",\n \"borderBottomColor\",\n \"borderLeftColor\",\n \"borderRightColor\",\n \"borderStartColor\",\n \"borderEndColor\",\n \"borderBlockColor\",\n \"borderBlockStartColor\",\n \"borderBlockEndColor\",\n \"shadowColor\",\n \"textShadowColor\",\n \"textDecorationColor\",\n \"tintColor\",\n \"overlayColor\"\n]);\nfunction processStyleColors(props) {\n var out = null;\n for (var key in props) {\n var value = props[key];\n if ((key === \"boxShadow\" || key === \"experimental_backgroundImage\" || key === \"colorStops\") && Array.isArray(value)) {\n var changed = false;\n var next = [];\n var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;\n try {\n for (var _iterator = value[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var entry = _step.value;\n var processed = processStyleColors(entry);\n if (processed !== entry) changed = true;\n next.push(processed);\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n if (changed) {\n out !== null && out !== void 0 ? out : out = {\n ...props\n };\n out[key] = next;\n }\n continue;\n }\n if (!COLOR_PROPS.has(key)) continue;\n var processed1 = typeof value === \"string\" || typeof value === \"object\" && value !== null ? processColor(value) : value;\n if (typeof processed1 === \"number\") {\n out !== null && out !== void 0 ? out : out = {\n ...props\n };\n out[key] = {\n space: \"srgb\",\n r: (processed1 >>> 16 & 255) / 255,\n g: (processed1 >>> 8 & 255) / 255,\n b: (processed1 & 255) / 255,\n a: (processed1 >>> 24 & 255) / 255\n };\n } else if (processed1 != null && typeof processed1 === \"object\") {\n out !== null && out !== void 0 ? out : out = {\n ...props\n };\n out[key] = processed1;\n }\n }\n return out !== null && out !== void 0 ? out : props;\n}\nexport {\n processStyleColors\n};\n//# sourceMappingURL=processStyleColors.native.js.map\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"processStyleColors.native.js","names":[],"sources":["esm/processStyleColors.native.js"],"sourcesContent":["import { processColor } from \"react-native\";\nimport processBackgroundImage from \"react-native/Libraries/StyleSheet/processBackgroundImage\";\nvar COLOR_PROPS = /* @__PURE__ */ new Set([\n \"color\",\n \"backgroundColor\",\n \"borderColor\",\n \"borderTopColor\",\n \"borderBottomColor\",\n \"borderLeftColor\",\n \"borderRightColor\",\n \"borderStartColor\",\n \"borderEndColor\",\n \"borderBlockColor\",\n \"borderBlockStartColor\",\n \"borderBlockEndColor\",\n \"shadowColor\",\n \"textShadowColor\",\n \"textDecorationColor\",\n \"tintColor\",\n \"overlayColor\"\n]);\nfunction processStyleColors(props) {\n var out = null;\n for (var key in props) {\n var value = props[key];\n if (key === \"experimental_backgroundImage\" && value != null) {\n value = processBackgroundImage(value);\n out !== null && out !== void 0 ? out : out = {\n ...props\n };\n out[key] = value;\n }\n if ((key === \"boxShadow\" || key === \"experimental_backgroundImage\" || key === \"colorStops\") && Array.isArray(value)) {\n var changed = false;\n var next = [];\n var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;\n try {\n for (var _iterator = value[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var entry = _step.value;\n var processed = processStyleColors(entry);\n if (processed !== entry) changed = true;\n next.push(processed);\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n if (changed) {\n out !== null && out !== void 0 ? out : out = {\n ...props\n };\n out[key] = next;\n }\n continue;\n }\n if (!COLOR_PROPS.has(key)) continue;\n var processed1 = typeof value === \"string\" || typeof value === \"object\" && value !== null ? processColor(value) : value;\n if (typeof processed1 === \"number\") {\n out !== null && out !== void 0 ? out : out = {\n ...props\n };\n out[key] = {\n space: \"srgb\",\n r: (processed1 >>> 16 & 255) / 255,\n g: (processed1 >>> 8 & 255) / 255,\n b: (processed1 & 255) / 255,\n a: (processed1 >>> 24 & 255) / 255\n };\n } else if (processed1 != null && typeof processed1 === \"object\") {\n out !== null && out !== void 0 ? out : out = {\n ...props\n };\n out[key] = processed1;\n }\n }\n return out !== null && out !== void 0 ? out : props;\n}\nexport {\n processStyleColors\n};\n//# sourceMappingURL=processStyleColors.native.js.map\n"],"mappings":";;;;AAEA,IAAI,8BAA8B,IAAI,IAAI;CACxC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AACD,SAAS,mBAAmB,OAAO;CACjC,IAAI,MAAM;CACV,KAAK,IAAI,OAAO,OAAO;EACrB,IAAI,QAAQ,MAAM;EAClB,IAAI,QAAQ,kCAAkC,SAAS,MAAM;GAC3D,QAAQ,uBAAuB,KAAK;GACpC,QAAQ,QAAQ,QAAQ,KAAK,IAAI,MAAM,MAAM,EAC3C,GAAG,MACL;GACA,IAAI,OAAO;EACb;EACA,KAAK,QAAQ,eAAe,QAAQ,kCAAkC,QAAQ,iBAAiB,MAAM,QAAQ,KAAK,GAAG;GACnH,IAAI,UAAU;GACd,IAAI,OAAO,CAAC;GACZ,IAAI,4BAA4B,MAAM,oBAAoB,OAAO,iBAAiB,KAAK;GACvF,IAAI;IACF,KAAK,IAAI,YAAY,MAAM,OAAO,SAAS,CAAC,GAAG,OAAO,EAAE,6BAA6B,QAAQ,UAAU,KAAK,EAAC,CAAE,OAAO,4BAA4B,MAAM;KACtJ,IAAI,QAAQ,MAAM;KAClB,IAAI,YAAY,mBAAmB,KAAK;KACxC,IAAI,cAAc,OAAO,UAAU;KACnC,KAAK,KAAK,SAAS;IACrB;GACF,SAAS,KAAK;IACZ,oBAAoB;IACpB,iBAAiB;GACnB,UAAU;IACR,IAAI;KACF,IAAI,CAAC,6BAA6B,UAAU,UAAU,MAAM;MAC1D,UAAU,OAAO;KACnB;IACF,UAAU;KACR,IAAI,mBAAmB;MACrB,MAAM;KACR;IACF;GACF;GACA,IAAI,SAAS;IACX,QAAQ,QAAQ,QAAQ,KAAK,IAAI,MAAM,MAAM,EAC3C,GAAG,MACL;IACA,IAAI,OAAO;GACb;GACA;EACF;EACA,IAAI,CAAC,YAAY,IAAI,GAAG,GAAG;EAC3B,IAAI,aAAa,OAAO,UAAU,YAAY,OAAO,UAAU,YAAY,UAAU,OAAO,aAAa,KAAK,IAAI;EAClH,IAAI,OAAO,eAAe,UAAU;GAClC,QAAQ,QAAQ,QAAQ,KAAK,IAAI,MAAM,MAAM,EAC3C,GAAG,MACL;GACA,IAAI,OAAO;IACT,OAAO;IACP,IAAI,eAAe,KAAK,OAAO;IAC/B,IAAI,eAAe,IAAI,OAAO;IAC9B,IAAI,aAAa,OAAO;IACxB,IAAI,eAAe,KAAK,OAAO;GACjC;EACF,OAAO,IAAI,cAAc,QAAQ,OAAO,eAAe,UAAU;GAC/D,QAAQ,QAAQ,QAAQ,KAAK,IAAI,MAAM,MAAM,EAC3C,GAAG,MACL;GACA,IAAI,OAAO;EACb;CACF;CACA,OAAO,QAAQ,QAAQ,QAAQ,KAAK,IAAI,MAAM;AAChD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/native-registry",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.1459.1",
|
|
4
4
|
"description": "Generic native style registry: zero-re-render style updates via Fabric ShadowTree commits",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
}
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@tamagui/build": "3.0.0-beta.
|
|
49
|
+
"@tamagui/build": "3.0.0-beta.1459.1",
|
|
50
50
|
"react": "19.2.3",
|
|
51
51
|
"react-native": "0.86.2",
|
|
52
52
|
"react-native-nitro-modules": "^0.36.5",
|
package/src/index.native.ts
CHANGED
|
@@ -20,7 +20,6 @@ import {
|
|
|
20
20
|
removeMirroredScope,
|
|
21
21
|
setMirroredStateName,
|
|
22
22
|
} from './mirror'
|
|
23
|
-
import { processStyleColors } from './processStyleColors.native'
|
|
24
23
|
|
|
25
24
|
export type {
|
|
26
25
|
LinkHandle,
|
|
@@ -88,7 +87,8 @@ function isNitroHybridView(ref: unknown): boolean {
|
|
|
88
87
|
/**
|
|
89
88
|
* Link a mounted view to the engine. Captures the ShadowNode once, returns
|
|
90
89
|
* a handle keyed by the engine-issued id: unlink never re-derives anything
|
|
91
|
-
* from the ref, so a torn-down ref cannot leave a stale entry behind.
|
|
90
|
+
* from the ref, so a torn-down ref cannot leave a stale entry behind. Slot
|
|
91
|
+
* props arrive in engine form, already through processStyleColors.
|
|
92
92
|
*/
|
|
93
93
|
export function link(
|
|
94
94
|
ref: unknown,
|
|
@@ -100,17 +100,7 @@ export function link(
|
|
|
100
100
|
if (!node) return null
|
|
101
101
|
|
|
102
102
|
const e = getEngine()
|
|
103
|
-
const
|
|
104
|
-
if (slots.base) prepared.base = processStyleColors(slots.base)
|
|
105
|
-
if (slots.state) {
|
|
106
|
-
const state: Record<string, unknown> = {}
|
|
107
|
-
for (const name in slots.state) {
|
|
108
|
-
state[name] = processStyleColors(slots.state[name])
|
|
109
|
-
}
|
|
110
|
-
prepared.state = state
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
const id = e.link(node, prepared, scopeId)
|
|
103
|
+
const id = e.link(node, slots, scopeId)
|
|
114
104
|
let unlinked = false
|
|
115
105
|
return {
|
|
116
106
|
id,
|
|
@@ -135,13 +125,12 @@ export function applyViewStates(entries: ViewStateUpdate[]): void {
|
|
|
135
125
|
/**
|
|
136
126
|
* Fill lazily resolved state-table entries without switching a view to the
|
|
137
127
|
* per-view runtime controller. The native engine commits an entry immediately
|
|
138
|
-
* only when that state is already active for the view's scope.
|
|
128
|
+
* only when that state is already active for the view's scope. Entry props
|
|
129
|
+
* arrive in engine form, already through processStyleColors.
|
|
139
130
|
*/
|
|
140
131
|
export function updateViewStateTables(entries: ViewStateTableUpdate[]): void {
|
|
141
132
|
if (entries.length === 0) return
|
|
142
|
-
getEngine().updateViewStateTables(
|
|
143
|
-
entries.map((entry) => ({ ...entry, props: processStyleColors(entry.props) }))
|
|
144
|
-
)
|
|
133
|
+
getEngine().updateViewStateTables(entries)
|
|
145
134
|
}
|
|
146
135
|
|
|
147
136
|
/**
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// react-native ships this processor untyped; it returns the parsed gradient list
|
|
2
|
+
declare module 'react-native/Libraries/StyleSheet/processBackgroundImage' {
|
|
3
|
+
export default function processBackgroundImage(
|
|
4
|
+
backgroundImage: unknown
|
|
5
|
+
): ReadonlyArray<Record<string, unknown>>
|
|
6
|
+
}
|
|
@@ -18,8 +18,15 @@
|
|
|
18
18
|
* Object` on anything else. A plain `[r, g, b, a]` array satisfies the C++
|
|
19
19
|
* parser but not this one, and the throw kills the mount-item dispatch and
|
|
20
20
|
* tears the whole React surface down.
|
|
21
|
+
*
|
|
22
|
+
* A background image goes through React Native's own processBackgroundImage
|
|
23
|
+
* first, as React's style diff does for a rendered view: Fabric's parser reads
|
|
24
|
+
* only its output (a `{ type, value }` direction and a `position` on every
|
|
25
|
+
* stop) and drops the angle and every stop of the unprocessed form. That
|
|
26
|
+
* processor throws on its own output, so a value crosses this boundary once.
|
|
21
27
|
*/
|
|
22
28
|
import { processColor, type ColorValue } from 'react-native'
|
|
29
|
+
import processBackgroundImage from 'react-native/Libraries/StyleSheet/processBackgroundImage'
|
|
23
30
|
|
|
24
31
|
const COLOR_PROPS = new Set([
|
|
25
32
|
'color',
|
|
@@ -46,7 +53,12 @@ export function processStyleColors(
|
|
|
46
53
|
): Record<string, unknown> {
|
|
47
54
|
let out: Record<string, unknown> | null = null
|
|
48
55
|
for (const key in props) {
|
|
49
|
-
|
|
56
|
+
let value = props[key]
|
|
57
|
+
if (key === 'experimental_backgroundImage' && value != null) {
|
|
58
|
+
value = processBackgroundImage(value)
|
|
59
|
+
out ??= { ...props }
|
|
60
|
+
out[key] = value
|
|
61
|
+
}
|
|
50
62
|
if (
|
|
51
63
|
(key === 'boxShadow' ||
|
|
52
64
|
key === 'experimental_backgroundImage' ||
|
|
@@ -54,7 +66,7 @@ export function processStyleColors(
|
|
|
54
66
|
Array.isArray(value)
|
|
55
67
|
) {
|
|
56
68
|
let changed = false
|
|
57
|
-
const next = []
|
|
69
|
+
const next: Record<string, unknown>[] = []
|
|
58
70
|
for (const entry of value) {
|
|
59
71
|
const processed = processStyleColors(entry)
|
|
60
72
|
if (processed !== entry) changed = true
|
package/types/index.native.d.ts
CHANGED
|
@@ -6,7 +6,8 @@ export declare function isAvailable(): boolean;
|
|
|
6
6
|
/**
|
|
7
7
|
* Link a mounted view to the engine. Captures the ShadowNode once, returns
|
|
8
8
|
* a handle keyed by the engine-issued id: unlink never re-derives anything
|
|
9
|
-
* from the ref, so a torn-down ref cannot leave a stale entry behind.
|
|
9
|
+
* from the ref, so a torn-down ref cannot leave a stale entry behind. Slot
|
|
10
|
+
* props arrive in engine form, already through processStyleColors.
|
|
10
11
|
*/
|
|
11
12
|
export declare function link(ref: unknown, slots: ViewSlots, scopeId?: string): LinkHandle | null;
|
|
12
13
|
/**
|
|
@@ -18,7 +19,8 @@ export declare function applyViewStates(entries: ViewStateUpdate[]): void;
|
|
|
18
19
|
/**
|
|
19
20
|
* Fill lazily resolved state-table entries without switching a view to the
|
|
20
21
|
* per-view runtime controller. The native engine commits an entry immediately
|
|
21
|
-
* only when that state is already active for the view's scope.
|
|
22
|
+
* only when that state is already active for the view's scope. Entry props
|
|
23
|
+
* arrive in engine form, already through processStyleColors.
|
|
22
24
|
*/
|
|
23
25
|
export declare function updateViewStateTables(entries: ViewStateTableUpdate[]): void;
|
|
24
26
|
/**
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
|
-
"mappings": "AAOA,cACE,YACA,eAEA,WACA,mBACA,sBACA,uBACK;
|
|
2
|
+
"mappings": "AAOA,cACE,YACA,eAEA,WACA,mBACA,sBACA,uBACK;AAQP,cACE,YACA,eACA,QACA,WACA,mBACA,sBACA,uBACK;AACP,SAAS,YAAY,4BAA4B;AACjD,SAAS,0BAA0B;AAkBnC,OAAO,iBAAS;;;;;;;AAyChB,OAAO,iBAAS,KACd,cACA,OAAO,WACP,mBACC;;;;;;AAuBH,OAAO,iBAAS,gBAAgB,SAAS;;;;;;;AAWzC,OAAO,iBAAS,sBAAsB,SAAS;;;;;;AAU/C,OAAO,iBAAS,aAAa,mBAAmB;AAKhD,OAAO,iBAAS,YAAY;;AAM5B,OAAO,iBAAS,aACd,OAAO,WACP,mBACC;;AASH,OAAO,iBAAS,aAAa,aAAa;AAK1C,OAAO,iBAAS,YAAY",
|
|
3
3
|
"names": [],
|
|
4
4
|
"sources": [
|
|
5
5
|
"src/index.native.ts"
|
|
6
6
|
],
|
|
7
7
|
"version": 3,
|
|
8
8
|
"sourcesContent": [
|
|
9
|
-
"/**\n * Native implementation backed by the TamaguiRegistry Nitro HybridObject.\n * The C++ engine commits style updates directly to Fabric's ShadowTree via\n * UIManager::updateShadowTree (RN >= 0.81), with zero React re-renders.\n */\nimport { NitroModules } from 'react-native-nitro-modules'\nimport type { TamaguiRegistry } from './specs/TamaguiRegistry.nitro'\nimport type {\n LinkHandle,\n RegistryStats,\n Unlink,\n ViewSlots,\n ViewStateSnapshot,\n ViewStateTableUpdate,\n ViewStateUpdate,\n} from './types'\nimport {\n ROOT_SCOPE,\n getMirroredStateName,\n removeMirroredScope,\n setMirroredStateName,\n} from './mirror'\
|
|
9
|
+
"/**\n * Native implementation backed by the TamaguiRegistry Nitro HybridObject.\n * The C++ engine commits style updates directly to Fabric's ShadowTree via\n * UIManager::updateShadowTree (RN >= 0.81), with zero React re-renders.\n */\nimport { NitroModules } from 'react-native-nitro-modules'\nimport type { TamaguiRegistry } from './specs/TamaguiRegistry.nitro'\nimport type {\n LinkHandle,\n RegistryStats,\n Unlink,\n ViewSlots,\n ViewStateSnapshot,\n ViewStateTableUpdate,\n ViewStateUpdate,\n} from './types'\nimport {\n ROOT_SCOPE,\n getMirroredStateName,\n removeMirroredScope,\n setMirroredStateName,\n} from './mirror'\n\nexport type {\n LinkHandle,\n RegistryStats,\n Unlink,\n ViewSlots,\n ViewStateSnapshot,\n ViewStateTableUpdate,\n ViewStateUpdate,\n} from './types'\nexport { ROOT_SCOPE, getMirroredStateName } from './mirror'\nexport { processStyleColors } from './processStyleColors.native'\n\n/** Full engine surface: typed Nitro methods plus the raw-JSI methods. */\ninterface Engine extends TamaguiRegistry {\n link(shadowNode: unknown, slots: object, scopeId: string): number\n applyViewStates(entries: ViewStateUpdate[]): void\n updateViewStateTables(entries: ViewStateTableUpdate[]): void\n getViewState(id: number): ViewStateSnapshot | null\n}\n\nlet engine: Engine | null = null\nlet initError: unknown = null\ntry {\n engine = NitroModules.createHybridObject<TamaguiRegistry>('TamaguiRegistry') as Engine\n} catch (error) {\n initError = error\n}\n\nexport function isAvailable(): boolean {\n return engine !== null\n}\n\nfunction getEngine(): Engine {\n if (engine) return engine\n const detail = initError instanceof Error ? ` ${initError.message}` : ''\n throw new Error(\n `[@tamagui/native-registry] TamaguiRegistry failed to initialize; is react-native-nitro-modules installed and the app rebuilt?${detail}`\n )\n}\n\n/**\n * Extract the opaque ShadowNode JSI wrapper from a Fabric host component ref.\n * Same internals access as Unistyles; verified against RN 0.86.\n */\nfunction getShadowNode(ref: unknown): unknown | null {\n const handle = (ref as Record<string, unknown>)?.__internalInstanceHandle as\n | { stateNode?: { node?: unknown } }\n | undefined\n return handle?.stateNode?.node ?? null\n}\n\n/**\n * Nitro hybrid views parse props only from JSI values (their component\n * descriptor uses the JSI RawPropsParser), so the folly props this engine\n * commits, like React Native's own setNativeProps, abort in them. Every\n * Nitro view declares its `hybridRef` prop; those hosts stay unlinked and\n * re-theme through React renders.\n */\nfunction isNitroHybridView(ref: unknown): boolean {\n const config = (ref as { __viewConfig?: { validAttributes?: object } })?.__viewConfig\n return !!config?.validAttributes && 'hybridRef' in config.validAttributes\n}\n\n/**\n * Link a mounted view to the engine. Captures the ShadowNode once, returns\n * a handle keyed by the engine-issued id: unlink never re-derives anything\n * from the ref, so a torn-down ref cannot leave a stale entry behind. Slot\n * props arrive in engine form, already through processStyleColors.\n */\nexport function link(\n ref: unknown,\n slots: ViewSlots,\n scopeId: string = ROOT_SCOPE\n): LinkHandle | null {\n if (isNitroHybridView(ref)) return null\n const node = getShadowNode(ref)\n if (!node) return null\n\n const e = getEngine()\n const id = e.link(node, slots, scopeId)\n let unlinked = false\n return {\n id,\n unlink: () => {\n if (unlinked) return\n unlinked = true\n e.unlink(id)\n },\n }\n}\n\n/**\n * Batched per-view state selection: cold entries carry `props` (computed by\n * the caller, colors already processed via processStyleColors), warm entries\n * just name the state. One native commit for the whole batch.\n */\nexport function applyViewStates(entries: ViewStateUpdate[]): void {\n if (entries.length === 0) return\n getEngine().applyViewStates(entries)\n}\n\n/**\n * Fill lazily resolved state-table entries without switching a view to the\n * per-view runtime controller. The native engine commits an entry immediately\n * only when that state is already active for the view's scope. Entry props\n * arrive in engine form, already through processStyleColors.\n */\nexport function updateViewStateTables(entries: ViewStateTableUpdate[]): void {\n if (entries.length === 0) return\n getEngine().updateViewStateTables(entries)\n}\n\n/**\n * Set the active state name (e.g. theme name) for a scope and commit the\n * update natively. The JS mirror updates first so any concurrent React\n * render paints the same styles the engine commits.\n */\nexport function setStateName(stateName: string, scopeId: string = ROOT_SCOPE): void {\n setMirroredStateName(scopeId, stateName)\n getEngine().setStateName(scopeId, stateName)\n}\n\nexport function removeScope(scopeId: string): void {\n removeMirroredScope(scopeId)\n getEngine().removeScope(scopeId)\n}\n\n/** Resolve the props a view should render right now, mirror-consistent. */\nexport function resolveSlots(\n slots: ViewSlots,\n scopeId: string = ROOT_SCOPE\n): Record<string, unknown> {\n const name = getMirroredStateName(scopeId)\n return {\n ...slots.base,\n ...(name ? slots.state?.[name] : undefined),\n }\n}\n\n/** Debug/test introspection of a linked view's engine tables. Not a hot path. */\nexport function getViewState(id: number): ViewStateSnapshot | null {\n if (!engine) return null\n return engine.getViewState(id)\n}\n\nexport function getStats(): RegistryStats {\n if (!engine) return { viewCount: 0, commitCount: 0, missCount: 0 }\n return {\n viewCount: engine.getViewCount(),\n commitCount: engine.getCommitCount(),\n missCount: engine.getMissCount(),\n }\n}\n"
|
|
10
10
|
]
|
|
11
11
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
|
-
"mappings": "
|
|
2
|
+
"mappings": "AAkDA,OAAO,iBAAS,mBACd,OAAO,0BACN",
|
|
3
3
|
"names": [],
|
|
4
4
|
"sources": [
|
|
5
5
|
"src/processStyleColors.native.ts"
|
|
6
6
|
],
|
|
7
7
|
"version": 3,
|
|
8
8
|
"sourcesContent": [
|
|
9
|
-
"/**\n * Fabric's C++ prop parser cannot take colors as CSS strings, so every color\n * prop must be converted before props reach the engine. The compiler mappings\n * and runtime-mode pushes both use this exact runtime processor before props\n * cross into the engine.\n *\n * Colors go over as `{ space: 'srgb', r, g, b, a }` with each channel a float\n * in 0..1. That shape is the only one both prop parsers a themed view can reach\n * will accept:\n *\n * - C++ `fromRawValueShared` reads it through its `space` branch. The packed\n * ARGB int `processColor` returns is misread here: an opaque grey\n * `0xFFE3E3E3` rendered as `rgb(254, 229, 229)`, taking `0xFF` as red and\n * the real red as alpha, so every themed surface came out tinted pink.\n * - Android additionally mounts some of these props through Java\n * `SurfaceMountingManager.updateProps` -> `ColorPropConverter`, which takes\n * a number or a map and throws `ColorValue: the value must be a number or\n * Object` on anything else. A plain `[r, g, b, a]` array satisfies the C++\n * parser but not this one, and the throw kills the mount-item dispatch and\n * tears the whole React surface down.\n */\nimport { processColor, type ColorValue } from 'react-native'\n\nconst COLOR_PROPS = new Set([\n 'color',\n 'backgroundColor',\n 'borderColor',\n 'borderTopColor',\n 'borderBottomColor',\n 'borderLeftColor',\n 'borderRightColor',\n 'borderStartColor',\n 'borderEndColor',\n 'borderBlockColor',\n 'borderBlockStartColor',\n 'borderBlockEndColor',\n 'shadowColor',\n 'textShadowColor',\n 'textDecorationColor',\n 'tintColor',\n 'overlayColor',\n])\n\nexport function processStyleColors(\n props: Record<string, unknown>\n): Record<string, unknown> {\n let out: Record<string, unknown> | null = null\n for (const key in props) {\n
|
|
9
|
+
"/**\n * Fabric's C++ prop parser cannot take colors as CSS strings, so every color\n * prop must be converted before props reach the engine. The compiler mappings\n * and runtime-mode pushes both use this exact runtime processor before props\n * cross into the engine.\n *\n * Colors go over as `{ space: 'srgb', r, g, b, a }` with each channel a float\n * in 0..1. That shape is the only one both prop parsers a themed view can reach\n * will accept:\n *\n * - C++ `fromRawValueShared` reads it through its `space` branch. The packed\n * ARGB int `processColor` returns is misread here: an opaque grey\n * `0xFFE3E3E3` rendered as `rgb(254, 229, 229)`, taking `0xFF` as red and\n * the real red as alpha, so every themed surface came out tinted pink.\n * - Android additionally mounts some of these props through Java\n * `SurfaceMountingManager.updateProps` -> `ColorPropConverter`, which takes\n * a number or a map and throws `ColorValue: the value must be a number or\n * Object` on anything else. A plain `[r, g, b, a]` array satisfies the C++\n * parser but not this one, and the throw kills the mount-item dispatch and\n * tears the whole React surface down.\n *\n * A background image goes through React Native's own processBackgroundImage\n * first, as React's style diff does for a rendered view: Fabric's parser reads\n * only its output (a `{ type, value }` direction and a `position` on every\n * stop) and drops the angle and every stop of the unprocessed form. That\n * processor throws on its own output, so a value crosses this boundary once.\n */\nimport { processColor, type ColorValue } from 'react-native'\nimport processBackgroundImage from 'react-native/Libraries/StyleSheet/processBackgroundImage'\n\nconst COLOR_PROPS = new Set([\n 'color',\n 'backgroundColor',\n 'borderColor',\n 'borderTopColor',\n 'borderBottomColor',\n 'borderLeftColor',\n 'borderRightColor',\n 'borderStartColor',\n 'borderEndColor',\n 'borderBlockColor',\n 'borderBlockStartColor',\n 'borderBlockEndColor',\n 'shadowColor',\n 'textShadowColor',\n 'textDecorationColor',\n 'tintColor',\n 'overlayColor',\n])\n\nexport function processStyleColors(\n props: Record<string, unknown>\n): Record<string, unknown> {\n let out: Record<string, unknown> | null = null\n for (const key in props) {\n let value = props[key]\n if (key === 'experimental_backgroundImage' && value != null) {\n value = processBackgroundImage(value)\n out ??= { ...props }\n out[key] = value\n }\n if (\n (key === 'boxShadow' ||\n key === 'experimental_backgroundImage' ||\n key === 'colorStops') &&\n Array.isArray(value)\n ) {\n let changed = false\n const next: Record<string, unknown>[] = []\n for (const entry of value) {\n const processed = processStyleColors(entry)\n if (processed !== entry) changed = true\n next.push(processed)\n }\n if (changed) {\n out ??= { ...props }\n out[key] = next\n }\n continue\n }\n if (!COLOR_PROPS.has(key)) continue\n // a style may already carry the packed int form RN accepts (`processColor`\n // output written straight into a style), and that form is misread the same\n // way, so it converts here too rather than only css strings\n const processed =\n typeof value === 'string' || (typeof value === 'object' && value !== null)\n ? processColor(value as ColorValue)\n : value\n if (typeof processed === 'number') {\n out ??= { ...props }\n // processColor packs ARGB, and is signed on Android, hence >>>\n out[key] = {\n space: 'srgb',\n r: ((processed >>> 16) & 0xff) / 255,\n g: ((processed >>> 8) & 0xff) / 255,\n b: (processed & 0xff) / 255,\n a: ((processed >>> 24) & 0xff) / 255,\n }\n } else if (processed != null && typeof processed === 'object') {\n // platform and dynamic colors resolve to opaque objects. processColor\n // normalizes their color branches before Fabric unpacks the shape.\n out ??= { ...props }\n out[key] = processed\n }\n }\n return out ?? props\n}\n"
|
|
10
10
|
]
|
|
11
11
|
}
|