react-native-reanimated 3.4.0 → 3.4.2
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/lib/module/Animated.js +60 -1
- package/lib/module/Animated.js.map +1 -1
- package/lib/module/createAnimatedComponent.js.map +1 -1
- package/lib/module/reanimated2/Easing.js +8 -0
- package/lib/module/reanimated2/Easing.js.map +1 -1
- package/lib/module/reanimated2/UpdateProps.js +2 -2
- package/lib/module/reanimated2/UpdateProps.js.map +1 -1
- package/lib/module/reanimated2/animation/commonTypes.js.map +1 -1
- package/lib/module/reanimated2/animation/decay.js.map +1 -1
- package/lib/module/reanimated2/animation/index.js +1 -1
- package/lib/module/reanimated2/animation/index.js.map +1 -1
- package/lib/module/reanimated2/animation/springUtils.js.map +1 -1
- package/lib/module/reanimated2/animation/styleAnimation.js +2 -2
- package/lib/module/reanimated2/animation/styleAnimation.js.map +1 -1
- package/lib/module/reanimated2/animation/timing.js.map +1 -1
- package/lib/module/reanimated2/animation/transformationMatrix/matrixUtils.js +6 -0
- package/lib/module/reanimated2/animation/transformationMatrix/matrixUtils.js.map +1 -1
- package/lib/module/reanimated2/animation/util.js +4 -19
- package/lib/module/reanimated2/animation/util.js.map +1 -1
- package/lib/module/reanimated2/commonTypes.js.map +1 -1
- package/lib/module/reanimated2/component/FlatList.js.map +1 -1
- package/lib/module/reanimated2/component/ScrollView.js.map +1 -1
- package/lib/module/reanimated2/core.js +16 -0
- package/lib/module/reanimated2/core.js.map +1 -1
- package/lib/module/reanimated2/fabricUtils.js +3 -1
- package/lib/module/reanimated2/fabricUtils.js.map +1 -1
- package/lib/module/reanimated2/globals.d.js.map +1 -1
- package/lib/module/reanimated2/helperTypes.js.map +1 -1
- package/lib/module/reanimated2/hook/commonTypes.js.map +1 -1
- package/lib/module/reanimated2/hook/index.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedGestureHandler.js +1 -1
- package/lib/module/reanimated2/hook/useAnimatedGestureHandler.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedRef.js +2 -2
- package/lib/module/reanimated2/hook/useAnimatedRef.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedStyle.js +1 -1
- package/lib/module/reanimated2/hook/useAnimatedStyle.js.map +1 -1
- package/lib/module/reanimated2/hook/utils.js +2 -27
- package/lib/module/reanimated2/hook/utils.js.map +1 -1
- package/lib/module/reanimated2/index.js.map +1 -1
- package/lib/module/reanimated2/interpolateColor.js.map +1 -1
- package/lib/module/reanimated2/js-reanimated/commonTypes.js.map +1 -1
- package/lib/module/reanimated2/js-reanimated/index.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/Keyframe.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/commonTypes.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/index.js.map +1 -1
- package/lib/module/reanimated2/mappers.js +1 -1
- package/lib/module/reanimated2/mappers.js.map +1 -1
- package/lib/module/reanimated2/mock.js +26 -0
- package/lib/module/reanimated2/mock.js.map +1 -1
- package/lib/module/reanimated2/mutables.js +0 -1
- package/lib/module/reanimated2/mutables.js.map +1 -1
- package/lib/module/reanimated2/platform-specific/checkCppVersion.js +3 -0
- package/lib/module/reanimated2/platform-specific/checkCppVersion.js.map +1 -1
- package/lib/module/reanimated2/platform-specific/jsVersion.js +1 -1
- package/lib/module/reanimated2/platform-specific/jsVersion.js.map +1 -1
- package/lib/module/reanimated2/valueSetter.js +0 -1
- package/lib/module/reanimated2/valueSetter.js.map +1 -1
- package/lib/module/setAndForwardRef.js.map +1 -1
- package/lib/typescript/Animated.d.ts +68 -3
- package/lib/typescript/createAnimatedComponent.d.ts +1 -26
- package/lib/typescript/reanimated2/Easing.d.ts +17 -9
- package/lib/typescript/reanimated2/UpdateProps.d.ts +5 -5
- package/lib/typescript/reanimated2/animation/commonTypes.d.ts +4 -3
- package/lib/typescript/reanimated2/animation/decay.d.ts +2 -4
- package/lib/typescript/reanimated2/animation/index.d.ts +3 -3
- package/lib/typescript/reanimated2/animation/springUtils.d.ts +1 -0
- package/lib/typescript/reanimated2/animation/styleAnimation.d.ts +2 -6
- package/lib/typescript/reanimated2/animation/timing.d.ts +4 -7
- package/lib/typescript/reanimated2/animation/transformationMatrix/matrixUtils.d.ts +1 -1
- package/lib/typescript/reanimated2/animation/util.d.ts +2 -4
- package/lib/typescript/reanimated2/commonTypes.d.ts +0 -4
- package/lib/typescript/reanimated2/component/FlatList.d.ts +2 -1
- package/lib/typescript/reanimated2/component/ScrollView.d.ts +1 -1
- package/lib/typescript/reanimated2/core.d.ts +12 -0
- package/lib/typescript/reanimated2/helperTypes.d.ts +11 -7
- package/lib/typescript/reanimated2/hook/commonTypes.d.ts +2 -2
- package/lib/typescript/reanimated2/hook/index.d.ts +1 -1
- package/lib/typescript/reanimated2/hook/useAnimatedGestureHandler.d.ts +2 -2
- package/lib/typescript/reanimated2/hook/useAnimatedRef.d.ts +4 -4
- package/lib/typescript/reanimated2/hook/useAnimatedStyle.d.ts +4 -5
- package/lib/typescript/reanimated2/hook/utils.d.ts +3 -11
- package/lib/typescript/reanimated2/index.d.ts +3 -1
- package/lib/typescript/reanimated2/interpolateColor.d.ts +2 -3
- package/lib/typescript/reanimated2/js-reanimated/commonTypes.d.ts +1 -43
- package/lib/typescript/reanimated2/js-reanimated/index.d.ts +3 -2
- package/lib/typescript/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.d.ts +4 -4
- package/lib/typescript/reanimated2/layoutReanimation/animationBuilder/Keyframe.d.ts +0 -11
- package/lib/typescript/reanimated2/layoutReanimation/animationBuilder/commonTypes.d.ts +3 -3
- package/lib/typescript/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.d.ts +13 -13
- package/lib/typescript/reanimated2/layoutReanimation/index.d.ts +1 -0
- package/lib/typescript/reanimated2/mappers.d.ts +0 -12
- package/lib/typescript/reanimated2/mock.d.ts +1 -76
- package/lib/typescript/reanimated2/mutables.d.ts +0 -1
- package/lib/typescript/reanimated2/platform-specific/jsVersion.d.ts +1 -1
- package/lib/typescript/reanimated2/valueSetter.d.ts +0 -1
- package/lib/typescript/setAndForwardRef.d.ts +1 -1
- package/package.json +3 -1
- package/src/Animated.ts +80 -6
- package/src/createAnimatedComponent.tsx +2 -2
- package/src/reanimated2/Easing.ts +18 -8
- package/src/reanimated2/UpdateProps.ts +13 -17
- package/src/reanimated2/animation/commonTypes.ts +3 -3
- package/src/reanimated2/animation/decay.ts +3 -1
- package/src/reanimated2/animation/index.ts +3 -3
- package/src/reanimated2/animation/springUtils.ts +2 -0
- package/src/reanimated2/animation/styleAnimation.ts +5 -5
- package/src/reanimated2/animation/timing.ts +6 -4
- package/src/reanimated2/animation/transformationMatrix/matrixUtils.tsx +4 -1
- package/src/reanimated2/animation/util.ts +5 -29
- package/src/reanimated2/commonTypes.ts +0 -25
- package/src/reanimated2/component/FlatList.tsx +3 -1
- package/src/reanimated2/component/ScrollView.tsx +1 -1
- package/src/reanimated2/core.ts +16 -0
- package/src/reanimated2/fabricUtils.ts +1 -0
- package/src/reanimated2/globals.d.ts +3 -3
- package/src/reanimated2/helperTypes.ts +17 -7
- package/src/reanimated2/hook/commonTypes.ts +2 -3
- package/src/reanimated2/hook/index.ts +4 -1
- package/src/reanimated2/hook/useAnimatedGestureHandler.ts +2 -2
- package/src/reanimated2/hook/useAnimatedRef.ts +13 -10
- package/src/reanimated2/hook/useAnimatedStyle.ts +27 -26
- package/src/reanimated2/hook/utils.ts +5 -31
- package/src/reanimated2/index.ts +13 -1
- package/src/reanimated2/interpolateColor.ts +2 -2
- package/src/reanimated2/js-reanimated/commonTypes.ts +3 -3
- package/src/reanimated2/js-reanimated/index.ts +4 -3
- package/src/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.ts +4 -4
- package/src/reanimated2/layoutReanimation/animationBuilder/Keyframe.ts +5 -5
- package/src/reanimated2/layoutReanimation/animationBuilder/commonTypes.ts +3 -3
- package/src/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.ts +13 -13
- package/src/reanimated2/layoutReanimation/index.ts +1 -0
- package/src/reanimated2/mappers.ts +2 -2
- package/src/reanimated2/mock.ts +27 -0
- package/src/reanimated2/mutables.ts +0 -1
- package/src/reanimated2/platform-specific/checkCppVersion.ts +2 -0
- package/src/reanimated2/platform-specific/jsVersion.ts +1 -1
- package/src/reanimated2/valueSetter.ts +0 -1
- package/src/setAndForwardRef.ts +1 -1
- package/lib/module/reanimated2/js-reanimated/Mapper.js +0 -69
- package/lib/module/reanimated2/js-reanimated/Mapper.js.map +0 -1
- package/lib/module/reanimated2/js-reanimated/MapperRegistry.js +0 -109
- package/lib/module/reanimated2/js-reanimated/MapperRegistry.js.map +0 -1
- package/lib/typescript/reanimated2/js-reanimated/Mapper.d.ts +0 -14
- package/lib/typescript/reanimated2/js-reanimated/MapperRegistry.d.ts +0 -14
- package/src/reanimated2/js-reanimated/Mapper.ts +0 -94
- package/src/reanimated2/js-reanimated/MapperRegistry.ts +0 -133
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["shouldBeUseWeb","MutableValue","Mapper","constructor","module","mapper","inputs","arguments","length","undefined","outputs","_defineProperty","id","MAPPER_ID","extractMutablesFromArray","markDirty","dirty","maybeRequestRender","forEach","input","addListener","execute","array","res","extractMutables","value","push","Array","isArray","v","isWebDomElement","Object","keys","key","isWebNode","o","Node","nodeType","nodeName","isWebElement","HTMLElement"],"sources":["Mapper.ts"],"sourcesContent":["import type { NestedObjectValues } from '../commonTypes';\nimport { shouldBeUseWeb } from '../PlatformChecker';\nimport type { JSReanimated } from './commonTypes';\nimport MutableValue from './MutableValue';\n\nexport default class Mapper<T> {\n static MAPPER_ID = 1;\n id: number;\n inputs: MutableValue<T>[];\n outputs: MutableValue<T>[];\n mapper: () => void;\n\n dirty = true;\n\n constructor(\n module: JSReanimated,\n mapper: () => void,\n inputs: NestedObjectValues<MutableValue<T>>[] = [],\n outputs: NestedObjectValues<MutableValue<T>>[] = []\n ) {\n this.id = Mapper.MAPPER_ID++;\n this.inputs = this.extractMutablesFromArray(inputs);\n this.outputs = this.extractMutablesFromArray(outputs);\n this.mapper = mapper;\n\n const markDirty = () => {\n this.dirty = true;\n module.maybeRequestRender();\n };\n\n this.inputs.forEach((input) => {\n input.addListener(markDirty);\n });\n }\n\n execute(): void {\n this.dirty = false;\n this.mapper();\n }\n\n extractMutablesFromArray<T>(\n array: NestedObjectValues<MutableValue<T>>\n ): MutableValue<T>[] {\n const res: MutableValue<T>[] = [];\n\n function extractMutables(value: NestedObjectValues<MutableValue<T>>) {\n if (value == null) {\n // return;\n } else if (value instanceof MutableValue) {\n res.push(value);\n } else if (Array.isArray(value)) {\n value.forEach((v) => extractMutables(v));\n } else if (isWebDomElement(value)) {\n // do nothing on dom elements\n // without this check, we get a \"Maximum call size exceeded error\"\n } else if (typeof value === 'object') {\n Object.keys(value).forEach((key) => {\n extractMutables(value[key]);\n });\n }\n }\n\n extractMutables(array);\n return res;\n }\n}\n\nfunction isWebDomElement(value: any) {\n if (!shouldBeUseWeb()) {\n return false;\n }\n\n // https://stackoverflow.com/a/384380/7869175\n function isWebNode(o: any) {\n return typeof Node === 'object'\n ? o instanceof Node\n : o &&\n typeof o === 'object' &&\n typeof o.nodeType === 'number' &&\n typeof o.nodeName === 'string';\n }\n\n function isWebElement(o: any) {\n return typeof HTMLElement === 'object'\n ? o instanceof HTMLElement // DOM2\n : o &&\n typeof o === 'object' &&\n o !== null &&\n o.nodeType === 1 &&\n typeof o.nodeName === 'string';\n }\n\n return isWebNode(value) || isWebElement(value);\n}\n"],"mappings":";;;AACA,SAASA,cAAc,QAAQ,oBAAoB;AAEnD,OAAOC,YAAY,MAAM,gBAAgB;AAEzC,eAAe,MAAMC,MAAM,CAAI;EAS7BC,WAAWA,CACTC,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W,CAAC,IAAKL,eAAe,CAACK,CAAC,CAAC,CAAC;MAC1C,CAAC,MAAM,IAAIC,eAAe,CAACL,KAAK,CAAC,EAAE;QACjC;QACA;MAAA,CACD,MAAM,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;QACpCM,MAAM,CAACC,IAAI,CAACP,KAAK,CAAC,CAACP,OAAO,CAAEe,GAAG,IAAK;UAClCT,eAAe,CAACC,KAAK,CAACQ,GAAG,CAAC,CAAC;QAC7B,CAAC,CAAC;MACJ;IACF;IAEAT,eAAe,CAACF,KAAK,CAAC;IACtB,OAAOC,GAAG;EACZ;AACF;AAACZ,eAAA,CA5DoBT,MAAM,eACN,CAAC;AA6DtB,SAAS4B,eAAeA,CAACL,KAAU,EAAE;EACnC,IAAI,CAACzB,cAAc,EAAE,EAAE;IACrB,OAAO,KAAK;EACd;;EAEA;EACA,SAASkC,SAASA,CAACC,CAAM,EAAE;IACzB,OAAO,OAAOC,IAAI,KAAK,QAAQ,GAC3BD,CAAC,YAAYC,IAAI,GACjBD,CAAC,IACC,OAAOA,CAAC,KAAK,QAAQ,IACrB,OAAOA,CAAC,CAACE,QAAQ,KAAK,QAAQ,IAC9B,OAAOF,CAAC,CAACG,QAAQ,KAAK,QAAQ;EACtC;EAEA,SAASC,YAAYA,CAACJ,CAAM,EAAE;IAC5B,OAAO,OAAOK,WAAW,KAAK,QAAQ,GAClCL,CAAC,YAAYK,WAAW,CAAC;IAAA,EACzBL,CAAC,IACC,OAAOA,CAAC,KAAK,QAAQ,IACrBA,CAAC,KAAK,IAAI,IACVA,CAAC,CAACE,QAAQ,KAAK,CAAC,IAChB,OAAOF,CAAC,CAACG,QAAQ,KAAK,QAAQ;EACtC;EAEA,OAAOJ,SAAS,CAACT,KAAK,CAAC,IAAIc,YAAY,CAACd,KAAK,CAAC;AAChD"}
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
2
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
3
|
-
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
4
|
-
export default class MapperRegistry {
|
|
5
|
-
constructor(module) {
|
|
6
|
-
_defineProperty(this, "sortedMappers", []);
|
|
7
|
-
_defineProperty(this, "mappers", new Map());
|
|
8
|
-
_defineProperty(this, "_module", void 0);
|
|
9
|
-
_defineProperty(this, "updatedSinceLastExecute", false);
|
|
10
|
-
this._module = module;
|
|
11
|
-
}
|
|
12
|
-
startMapper(mapper) {
|
|
13
|
-
this.mappers.set(mapper.id, mapper);
|
|
14
|
-
this.updatedSinceLastExecute = true;
|
|
15
|
-
return mapper.id;
|
|
16
|
-
}
|
|
17
|
-
stopMapper(id) {
|
|
18
|
-
this.mappers.delete(id);
|
|
19
|
-
this.updatedSinceLastExecute = true;
|
|
20
|
-
}
|
|
21
|
-
execute() {
|
|
22
|
-
if (this.updatedSinceLastExecute) {
|
|
23
|
-
this.updateOrder();
|
|
24
|
-
this.updatedSinceLastExecute = false;
|
|
25
|
-
}
|
|
26
|
-
for (let i = 0, len = this.sortedMappers.length; i < len; ++i) {
|
|
27
|
-
const mapper = this.sortedMappers[i];
|
|
28
|
-
if (mapper.dirty) {
|
|
29
|
-
mapper.execute();
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
updateOrder() {
|
|
34
|
-
const nodes = [...this.mappers.values()].map(mapper => new Node(mapper));
|
|
35
|
-
const mappersById = {};
|
|
36
|
-
this.mappers.forEach(mapper => {
|
|
37
|
-
mappersById[mapper.id] = mapper;
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
// create a graph from array of nodes
|
|
41
|
-
for (let i = 0, nodesLen = nodes.length; i < nodesLen; ++i) {
|
|
42
|
-
const node = nodes[i];
|
|
43
|
-
if (node.mapper.outputs.length === 0) {
|
|
44
|
-
continue;
|
|
45
|
-
}
|
|
46
|
-
for (let j = 0; j < nodesLen; ++j) {
|
|
47
|
-
const restNode = nodes[j];
|
|
48
|
-
if (i === j || restNode.mapper.inputs.length === 0) {
|
|
49
|
-
continue;
|
|
50
|
-
}
|
|
51
|
-
for (let outi = 0, outputsLen = node.mapper.outputs.length; outi < outputsLen; ++outi) {
|
|
52
|
-
for (let resti = 0, restLen = restNode.mapper.inputs.length; resti < restLen; ++resti) {
|
|
53
|
-
if (node.mapper.outputs[outi]._id === restNode.mapper.inputs[resti]._id) {
|
|
54
|
-
node.children.push(restNode);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
const post = {};
|
|
61
|
-
let postCounter = 1;
|
|
62
|
-
const dfs = node => {
|
|
63
|
-
const index = nodes.indexOf(node);
|
|
64
|
-
if (index === -1) {
|
|
65
|
-
// this node has already been handled
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
++postCounter;
|
|
69
|
-
nodes.splice(index, 1);
|
|
70
|
-
if (node.children.length === 0 && nodes.length > 0) {
|
|
71
|
-
post[node.mapper.id] = postCounter++;
|
|
72
|
-
dfs(nodes[0]);
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
for (let i = 0, len = node.children.length; i < len; ++i) {
|
|
76
|
-
dfs(node.children[i]);
|
|
77
|
-
}
|
|
78
|
-
post[node.mapper.id] = postCounter++;
|
|
79
|
-
};
|
|
80
|
-
while (nodes.length) dfs(nodes[0]);
|
|
81
|
-
const postArray = Object.keys(post).map(key => {
|
|
82
|
-
const num = parseInt(key);
|
|
83
|
-
return [num, post[num]];
|
|
84
|
-
});
|
|
85
|
-
postArray.sort((a, b) => {
|
|
86
|
-
return b[1] - a[1];
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
// clear sorted mappers
|
|
90
|
-
this.sortedMappers = [];
|
|
91
|
-
for (let i = 0, len = postArray.length; i < len; ++i) {
|
|
92
|
-
const [id] = postArray[i];
|
|
93
|
-
this.sortedMappers.push(mappersById[id]);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
get needRunOnRender() {
|
|
97
|
-
return this.updatedSinceLastExecute;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
class Node {
|
|
101
|
-
constructor(mapper) {
|
|
102
|
-
let children = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
103
|
-
_defineProperty(this, "mapper", void 0);
|
|
104
|
-
_defineProperty(this, "children", void 0);
|
|
105
|
-
this.mapper = mapper;
|
|
106
|
-
this.children = children;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
//# sourceMappingURL=MapperRegistry.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["MapperRegistry","constructor","module","_defineProperty","Map","_module","startMapper","mapper","mappers","set","id","updatedSinceLastExecute","stopMapper","delete","execute","updateOrder","i","len","sortedMappers","length","dirty","nodes","values","map","Node","mappersById","forEach","nodesLen","node","outputs","j","restNode","inputs","outi","outputsLen","resti","restLen","_id","children","push","post","postCounter","dfs","index","indexOf","splice","postArray","Object","keys","key","num","parseInt","sort","a","b","needRunOnRender","arguments","undefined"],"sources":["MapperRegistry.ts"],"sourcesContent":["import type { JSReanimated } from './commonTypes';\nimport type Mapper from './Mapper';\n\nexport default class MapperRegistry<T> {\n sortedMappers: Mapper<T>[] = [];\n mappers: Map<number, Mapper<T>> = new Map();\n _module: JSReanimated;\n\n updatedSinceLastExecute = false;\n\n constructor(module: JSReanimated) {\n this._module = module;\n }\n\n startMapper(mapper: Mapper<T>): number {\n this.mappers.set(mapper.id, mapper);\n this.updatedSinceLastExecute = true;\n return mapper.id;\n }\n\n stopMapper(id: number): void {\n this.mappers.delete(id);\n this.updatedSinceLastExecute = true;\n }\n\n execute(): void {\n if (this.updatedSinceLastExecute) {\n this.updateOrder();\n this.updatedSinceLastExecute = false;\n }\n\n for (let i = 0, len = this.sortedMappers.length; i < len; ++i) {\n const mapper = this.sortedMappers[i];\n if (mapper.dirty) {\n mapper.execute();\n }\n }\n }\n\n updateOrder(): void {\n const nodes = [...this.mappers.values()].map((mapper) => new Node(mapper));\n\n const mappersById: Record<number, Mapper<T>> = {};\n this.mappers.forEach((mapper) => {\n mappersById[mapper.id] = mapper;\n });\n\n // create a graph from array of nodes\n for (let i = 0, nodesLen = nodes.length; i < nodesLen; ++i) {\n const node = nodes[i];\n if (node.mapper.outputs.length === 0) {\n continue;\n }\n for (let j = 0; j < nodesLen; ++j) {\n const restNode = nodes[j];\n if (i === j || restNode.mapper.inputs.length === 0) {\n continue;\n }\n for (\n let outi = 0, outputsLen = node.mapper.outputs.length;\n outi < outputsLen;\n ++outi\n ) {\n for (\n let resti = 0, restLen = restNode.mapper.inputs.length;\n resti < restLen;\n ++resti\n ) {\n if (\n node.mapper.outputs[outi]._id ===\n restNode.mapper.inputs[resti]._id\n ) {\n node.children.push(restNode);\n }\n }\n }\n }\n }\n\n const post: Record<number, number> = {};\n let postCounter = 1;\n const dfs = (node: Node<T>) => {\n const index = nodes.indexOf(node);\n if (index === -1) {\n // this node has already been handled\n return;\n }\n ++postCounter;\n nodes.splice(index, 1);\n if (node.children.length === 0 && nodes.length > 0) {\n post[node.mapper.id] = postCounter++;\n dfs(nodes[0]);\n return;\n }\n for (let i = 0, len = node.children.length; i < len; ++i) {\n dfs(node.children[i]);\n }\n post[node.mapper.id] = postCounter++;\n };\n\n while (nodes.length) dfs(nodes[0]);\n\n const postArray = Object.keys(post).map((key) => {\n const num = parseInt(key);\n return [num, post[num]];\n });\n postArray.sort((a, b) => {\n return b[1] - a[1];\n });\n\n // clear sorted mappers\n this.sortedMappers = [];\n\n for (let i = 0, len = postArray.length; i < len; ++i) {\n const [id] = postArray[i];\n this.sortedMappers.push(mappersById[id]);\n }\n }\n\n get needRunOnRender(): boolean {\n return this.updatedSinceLastExecute;\n }\n}\n\nclass Node<T> {\n mapper: Mapper<T>;\n children: Node<T>[];\n\n constructor(mapper: Mapper<T>, children = []) {\n this.mapper = mapper;\n this.children = children;\n }\n}\n"],"mappings":";;;AAGA,eAAe,MAAMA,cAAc,CAAI;EAOrCC,WAAWA,CAACC,MAAoB,EAAE;IAAAC,eAAA,wBANL,EAAE;IAAAA,eAAA,kBACG,IAAIC,GAAG,EAAE;IAAAD,eAAA;IAAAA,eAAA,kCAGjB,KAAK;IAG7B,IAAI,CAACE,OAAO,GAAGH,MAAM;EACvB;EAEAI,WAAWA,CAACC,MAAiB,EAAU;IACrC,IAAI,CAACC,OAAO,CAACC,GAAG,CAACF,MAAM,CAACG,EAAE,EAAEH,MAAM,CAAC;IACnC,IAAI,CAACI,uBAAuB,GAAG,IAAI;IACnC,OAAOJ,MAAM,CAACG,EAAE;EAClB;EAEAE,UAAUA,CAACF,EAAU,EAAQ;IAC3B,IAAI,CAACF,OAAO,CAACK,MAAM,CAACH,EAAE,CAAC;IACvB,IAAI,CAACC,uBAAuB,GAAG,IAAI;EACrC;EAEAG,OAAOA,CAAA,EAAS;IACd,IAAI,IAAI,CAACH,uBAAuB,EAAE;MAChC,IAAI,CAACI,WAAW,EAAE;MAClB,IAAI,CAACJ,uBAAuB,GAAG,KAAK;IACtC;IAEA,KAAK,IAAIK,CAAC,GAAG,CAAC,EAAEC,GAAG,GAAG,IAAI,CAACC,aAAa,CAACC,MAAM,EAAEH,CAAC,GAAGC,GAAG,EAAE,EAAED,CAAC,EAAE;MAC7D,MAAMT,MAAM,GAAG,IAAI,CAACW,aAAa,CAACF,CAAC,CAAC;MACpC,IAAIT,MAAM,CAACa,KAAK,EAAE;QAChBb,MAAM,CAACO,OAAO,EAAE;MAClB;IACF;EACF;EAEAC,WAAWA,CAAA,EAAS;IACl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,CAAC;MACzB,OAAO,CAACC,GAAG,EAAEV,IAAI,CAACU,GAAG,CAAC,CAAC;IACzB,CAAC,CAAC;IACFJ,SAAS,CAACM,IAAI,CAAC,CAACC,CAAC,EAAEC,CAAC,KAAK;MACvB,OAAOA,CAAC,CAAC,CAAC,CAAC,GAAGD,CAAC,CAAC,CAAC,CAAC;IACpB,CAAC,CAAC;;IAEF;IACA,IAAI,CAACnC,aAAa,GAAG,EAAE;IAEvB,KAAK,IAAIF,CAAC,GAAG,CAAC,EAAEC,GAAG,GAAG6B,SAAS,CAAC3B,MAAM,EAAEH,CAAC,GAAGC,GAAG,EAAE,EAAED,CAAC,EAAE;MACpD,MAAM,CAACN,EAAE,CAAC,GAAGoC,SAAS,CAAC9B,CAAC,CAAC;MACzB,IAAI,CAACE,aAAa,CAACqB,IAAI,CAACd,WAAW,CAACf,EAAE,CAAC,CAAC;IAC1C;EACF;EAEA,IAAI6C,eAAeA,CAAA,EAAY;IAC7B,OAAO,IAAI,CAAC5C,uBAAuB;EACrC;AACF;AAEA,MAAMa,IAAI,CAAI;EAIZvB,WAAWA,CAACM,MAAiB,EAAiB;IAAA,IAAf+B,QAAQ,GAAAkB,SAAA,CAAArC,MAAA,QAAAqC,SAAA,QAAAC,SAAA,GAAAD,SAAA,MAAG,EAAE;IAAArD,eAAA;IAAAA,eAAA;IAC1C,IAAI,CAACI,MAAM,GAAGA,MAAM;IACpB,IAAI,CAAC+B,QAAQ,GAAGA,QAAQ;EAC1B;AACF"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { NestedObjectValues } from '../commonTypes';
|
|
2
|
-
import type { JSReanimated } from './commonTypes';
|
|
3
|
-
import MutableValue from './MutableValue';
|
|
4
|
-
export default class Mapper<T> {
|
|
5
|
-
static MAPPER_ID: number;
|
|
6
|
-
id: number;
|
|
7
|
-
inputs: MutableValue<T>[];
|
|
8
|
-
outputs: MutableValue<T>[];
|
|
9
|
-
mapper: () => void;
|
|
10
|
-
dirty: boolean;
|
|
11
|
-
constructor(module: JSReanimated, mapper: () => void, inputs?: NestedObjectValues<MutableValue<T>>[], outputs?: NestedObjectValues<MutableValue<T>>[]);
|
|
12
|
-
execute(): void;
|
|
13
|
-
extractMutablesFromArray<T>(array: NestedObjectValues<MutableValue<T>>): MutableValue<T>[];
|
|
14
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { JSReanimated } from './commonTypes';
|
|
2
|
-
import type Mapper from './Mapper';
|
|
3
|
-
export default class MapperRegistry<T> {
|
|
4
|
-
sortedMappers: Mapper<T>[];
|
|
5
|
-
mappers: Map<number, Mapper<T>>;
|
|
6
|
-
_module: JSReanimated;
|
|
7
|
-
updatedSinceLastExecute: boolean;
|
|
8
|
-
constructor(module: JSReanimated);
|
|
9
|
-
startMapper(mapper: Mapper<T>): number;
|
|
10
|
-
stopMapper(id: number): void;
|
|
11
|
-
execute(): void;
|
|
12
|
-
updateOrder(): void;
|
|
13
|
-
get needRunOnRender(): boolean;
|
|
14
|
-
}
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import type { NestedObjectValues } from '../commonTypes';
|
|
2
|
-
import { shouldBeUseWeb } from '../PlatformChecker';
|
|
3
|
-
import type { JSReanimated } from './commonTypes';
|
|
4
|
-
import MutableValue from './MutableValue';
|
|
5
|
-
|
|
6
|
-
export default class Mapper<T> {
|
|
7
|
-
static MAPPER_ID = 1;
|
|
8
|
-
id: number;
|
|
9
|
-
inputs: MutableValue<T>[];
|
|
10
|
-
outputs: MutableValue<T>[];
|
|
11
|
-
mapper: () => void;
|
|
12
|
-
|
|
13
|
-
dirty = true;
|
|
14
|
-
|
|
15
|
-
constructor(
|
|
16
|
-
module: JSReanimated,
|
|
17
|
-
mapper: () => void,
|
|
18
|
-
inputs: NestedObjectValues<MutableValue<T>>[] = [],
|
|
19
|
-
outputs: NestedObjectValues<MutableValue<T>>[] = []
|
|
20
|
-
) {
|
|
21
|
-
this.id = Mapper.MAPPER_ID++;
|
|
22
|
-
this.inputs = this.extractMutablesFromArray(inputs);
|
|
23
|
-
this.outputs = this.extractMutablesFromArray(outputs);
|
|
24
|
-
this.mapper = mapper;
|
|
25
|
-
|
|
26
|
-
const markDirty = () => {
|
|
27
|
-
this.dirty = true;
|
|
28
|
-
module.maybeRequestRender();
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
this.inputs.forEach((input) => {
|
|
32
|
-
input.addListener(markDirty);
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
execute(): void {
|
|
37
|
-
this.dirty = false;
|
|
38
|
-
this.mapper();
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
extractMutablesFromArray<T>(
|
|
42
|
-
array: NestedObjectValues<MutableValue<T>>
|
|
43
|
-
): MutableValue<T>[] {
|
|
44
|
-
const res: MutableValue<T>[] = [];
|
|
45
|
-
|
|
46
|
-
function extractMutables(value: NestedObjectValues<MutableValue<T>>) {
|
|
47
|
-
if (value == null) {
|
|
48
|
-
// return;
|
|
49
|
-
} else if (value instanceof MutableValue) {
|
|
50
|
-
res.push(value);
|
|
51
|
-
} else if (Array.isArray(value)) {
|
|
52
|
-
value.forEach((v) => extractMutables(v));
|
|
53
|
-
} else if (isWebDomElement(value)) {
|
|
54
|
-
// do nothing on dom elements
|
|
55
|
-
// without this check, we get a "Maximum call size exceeded error"
|
|
56
|
-
} else if (typeof value === 'object') {
|
|
57
|
-
Object.keys(value).forEach((key) => {
|
|
58
|
-
extractMutables(value[key]);
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
extractMutables(array);
|
|
64
|
-
return res;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
function isWebDomElement(value: any) {
|
|
69
|
-
if (!shouldBeUseWeb()) {
|
|
70
|
-
return false;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
// https://stackoverflow.com/a/384380/7869175
|
|
74
|
-
function isWebNode(o: any) {
|
|
75
|
-
return typeof Node === 'object'
|
|
76
|
-
? o instanceof Node
|
|
77
|
-
: o &&
|
|
78
|
-
typeof o === 'object' &&
|
|
79
|
-
typeof o.nodeType === 'number' &&
|
|
80
|
-
typeof o.nodeName === 'string';
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
function isWebElement(o: any) {
|
|
84
|
-
return typeof HTMLElement === 'object'
|
|
85
|
-
? o instanceof HTMLElement // DOM2
|
|
86
|
-
: o &&
|
|
87
|
-
typeof o === 'object' &&
|
|
88
|
-
o !== null &&
|
|
89
|
-
o.nodeType === 1 &&
|
|
90
|
-
typeof o.nodeName === 'string';
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
return isWebNode(value) || isWebElement(value);
|
|
94
|
-
}
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
import type { JSReanimated } from './commonTypes';
|
|
2
|
-
import type Mapper from './Mapper';
|
|
3
|
-
|
|
4
|
-
export default class MapperRegistry<T> {
|
|
5
|
-
sortedMappers: Mapper<T>[] = [];
|
|
6
|
-
mappers: Map<number, Mapper<T>> = new Map();
|
|
7
|
-
_module: JSReanimated;
|
|
8
|
-
|
|
9
|
-
updatedSinceLastExecute = false;
|
|
10
|
-
|
|
11
|
-
constructor(module: JSReanimated) {
|
|
12
|
-
this._module = module;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
startMapper(mapper: Mapper<T>): number {
|
|
16
|
-
this.mappers.set(mapper.id, mapper);
|
|
17
|
-
this.updatedSinceLastExecute = true;
|
|
18
|
-
return mapper.id;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
stopMapper(id: number): void {
|
|
22
|
-
this.mappers.delete(id);
|
|
23
|
-
this.updatedSinceLastExecute = true;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
execute(): void {
|
|
27
|
-
if (this.updatedSinceLastExecute) {
|
|
28
|
-
this.updateOrder();
|
|
29
|
-
this.updatedSinceLastExecute = false;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
for (let i = 0, len = this.sortedMappers.length; i < len; ++i) {
|
|
33
|
-
const mapper = this.sortedMappers[i];
|
|
34
|
-
if (mapper.dirty) {
|
|
35
|
-
mapper.execute();
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
updateOrder(): void {
|
|
41
|
-
const nodes = [...this.mappers.values()].map((mapper) => new Node(mapper));
|
|
42
|
-
|
|
43
|
-
const mappersById: Record<number, Mapper<T>> = {};
|
|
44
|
-
this.mappers.forEach((mapper) => {
|
|
45
|
-
mappersById[mapper.id] = mapper;
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
// create a graph from array of nodes
|
|
49
|
-
for (let i = 0, nodesLen = nodes.length; i < nodesLen; ++i) {
|
|
50
|
-
const node = nodes[i];
|
|
51
|
-
if (node.mapper.outputs.length === 0) {
|
|
52
|
-
continue;
|
|
53
|
-
}
|
|
54
|
-
for (let j = 0; j < nodesLen; ++j) {
|
|
55
|
-
const restNode = nodes[j];
|
|
56
|
-
if (i === j || restNode.mapper.inputs.length === 0) {
|
|
57
|
-
continue;
|
|
58
|
-
}
|
|
59
|
-
for (
|
|
60
|
-
let outi = 0, outputsLen = node.mapper.outputs.length;
|
|
61
|
-
outi < outputsLen;
|
|
62
|
-
++outi
|
|
63
|
-
) {
|
|
64
|
-
for (
|
|
65
|
-
let resti = 0, restLen = restNode.mapper.inputs.length;
|
|
66
|
-
resti < restLen;
|
|
67
|
-
++resti
|
|
68
|
-
) {
|
|
69
|
-
if (
|
|
70
|
-
node.mapper.outputs[outi]._id ===
|
|
71
|
-
restNode.mapper.inputs[resti]._id
|
|
72
|
-
) {
|
|
73
|
-
node.children.push(restNode);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
const post: Record<number, number> = {};
|
|
81
|
-
let postCounter = 1;
|
|
82
|
-
const dfs = (node: Node<T>) => {
|
|
83
|
-
const index = nodes.indexOf(node);
|
|
84
|
-
if (index === -1) {
|
|
85
|
-
// this node has already been handled
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
++postCounter;
|
|
89
|
-
nodes.splice(index, 1);
|
|
90
|
-
if (node.children.length === 0 && nodes.length > 0) {
|
|
91
|
-
post[node.mapper.id] = postCounter++;
|
|
92
|
-
dfs(nodes[0]);
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
for (let i = 0, len = node.children.length; i < len; ++i) {
|
|
96
|
-
dfs(node.children[i]);
|
|
97
|
-
}
|
|
98
|
-
post[node.mapper.id] = postCounter++;
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
while (nodes.length) dfs(nodes[0]);
|
|
102
|
-
|
|
103
|
-
const postArray = Object.keys(post).map((key) => {
|
|
104
|
-
const num = parseInt(key);
|
|
105
|
-
return [num, post[num]];
|
|
106
|
-
});
|
|
107
|
-
postArray.sort((a, b) => {
|
|
108
|
-
return b[1] - a[1];
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
// clear sorted mappers
|
|
112
|
-
this.sortedMappers = [];
|
|
113
|
-
|
|
114
|
-
for (let i = 0, len = postArray.length; i < len; ++i) {
|
|
115
|
-
const [id] = postArray[i];
|
|
116
|
-
this.sortedMappers.push(mappersById[id]);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
get needRunOnRender(): boolean {
|
|
121
|
-
return this.updatedSinceLastExecute;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
class Node<T> {
|
|
126
|
-
mapper: Mapper<T>;
|
|
127
|
-
children: Node<T>[];
|
|
128
|
-
|
|
129
|
-
constructor(mapper: Mapper<T>, children = []) {
|
|
130
|
-
this.mapper = mapper;
|
|
131
|
-
this.children = children;
|
|
132
|
-
}
|
|
133
|
-
}
|