react-obsidian 2.31.0-alpha.2 → 2.31.0-alpha.6
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/src/injectors/components/ComponentInjector.d.ts.map +1 -1
- package/dist/src/injectors/components/ComponentInjector.js +3 -3
- package/dist/src/injectors/components/ComponentInjector.js.map +1 -1
- package/dist/src/injectors/components/Sentinel.d.ts +4 -0
- package/dist/src/injectors/components/Sentinel.d.ts.map +1 -0
- package/dist/src/injectors/components/Sentinel.js +40 -0
- package/dist/src/injectors/components/Sentinel.js.map +1 -0
- package/dist/src/injectors/components/Sentinel.native.d.ts +4 -0
- package/dist/src/injectors/components/Sentinel.native.d.ts.map +1 -0
- package/dist/src/injectors/components/{useGraphContainer.js → Sentinel.native.js} +5 -10
- package/dist/src/injectors/components/Sentinel.native.js.map +1 -0
- package/dist/src/injectors/components/useGraph.d.ts.map +1 -1
- package/dist/src/injectors/components/useGraph.js +2 -1
- package/dist/src/injectors/components/useGraph.js.map +1 -1
- package/package.json +7 -6
- package/src/injectors/components/ComponentInjector.tsx +4 -6
- package/src/injectors/components/Sentinel.native.tsx +12 -0
- package/src/injectors/components/Sentinel.tsx +9 -0
- package/src/injectors/components/useGraph.ts +2 -1
- package/dist/src/injectors/components/useGraphContainer.d.ts +0 -6
- package/dist/src/injectors/components/useGraphContainer.d.ts.map +0 -1
- package/dist/src/injectors/components/useGraphContainer.js.map +0 -1
- package/dist/src/utils/reactNativeAvailability.d.ts +0 -2
- package/dist/src/utils/reactNativeAvailability.d.ts.map +0 -1
- package/dist/src/utils/reactNativeAvailability.js +0 -22
- package/dist/src/utils/reactNativeAvailability.js.map +0 -1
- package/src/injectors/components/useGraphContainer.tsx +0 -19
- package/src/utils/reactNativeAvailability.ts +0 -17
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComponentInjector.d.ts","sourceRoot":"","sources":["../../../../src/injectors/components/ComponentInjector.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoC,MAAM,OAAO,CAAC;AAEzD,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAItD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAK5C,MAAM,CAAC,OAAO,OAAO,iBAAiB;IACpC,MAAM,CAAC,CAAC,EACN,MAAM,EAAE,KAAK,CAAC,iBAAiB,CAAC,CAAC,CAAC,EAClC,UAAU,EAAE,MAAM,GAAG,aAAa,CAAC,WAAW,CAAC,GAC9C,KAAK,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAMtC,OAAO,CAAC,aAAa;
|
|
1
|
+
{"version":3,"file":"ComponentInjector.d.ts","sourceRoot":"","sources":["../../../../src/injectors/components/ComponentInjector.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoC,MAAM,OAAO,CAAC;AAEzD,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAItD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAK5C,MAAM,CAAC,OAAO,OAAO,iBAAiB;IACpC,MAAM,CAAC,CAAC,EACN,MAAM,EAAE,KAAK,CAAC,iBAAiB,CAAC,CAAC,CAAC,EAClC,UAAU,EAAE,MAAM,GAAG,aAAa,CAAC,WAAW,CAAC,GAC9C,KAAK,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAMtC,OAAO,CAAC,aAAa;CAsBtB"}
|
|
@@ -40,7 +40,7 @@ const react_1 = __importStar(require("react"));
|
|
|
40
40
|
const hoist_non_react_statics_1 = __importDefault(require("hoist-non-react-statics"));
|
|
41
41
|
const PropsInjector_1 = __importDefault(require("./PropsInjector"));
|
|
42
42
|
const useGraph_1 = __importDefault(require("./useGraph"));
|
|
43
|
-
const
|
|
43
|
+
const Sentinel_1 = __importDefault(require("./Sentinel"));
|
|
44
44
|
const React_1 = require("../../utils/React");
|
|
45
45
|
const graphContext_1 = require("./graphContext");
|
|
46
46
|
const useInjectionToken_1 = require("./useInjectionToken");
|
|
@@ -58,10 +58,10 @@ class ComponentInjector {
|
|
|
58
58
|
const injectionToken = (0, useInjectionToken_1.useInjectionToken)(keyOrGraph);
|
|
59
59
|
const containerRef = (0, react_1.useRef)(null);
|
|
60
60
|
const graph = (0, useGraph_1.default)(keyOrGraph, Target, passedProps, injectionToken, containerRef);
|
|
61
|
-
const Container = (0, useGraphContainer_1.default)(graph);
|
|
62
61
|
const proxiedProps = new PropsInjector_1.default(graph).inject(passedProps);
|
|
63
62
|
return (react_1.default.createElement(graphContext_1.GraphContext.Provider, { value: { injectionToken } },
|
|
64
|
-
react_1.default.createElement(
|
|
63
|
+
graph.inactiveBehavior === 'retain' && react_1.default.createElement(Sentinel_1.default, { ref: containerRef }),
|
|
64
|
+
Target(proxiedProps)));
|
|
65
65
|
}, compare);
|
|
66
66
|
}
|
|
67
67
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComponentInjector.js","sourceRoot":"","sources":["../../../../src/injectors/components/ComponentInjector.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAyD;AACzD,sFAA2D;AAE3D,oEAA4C;AAC5C,0DAAkC;AAClC,
|
|
1
|
+
{"version":3,"file":"ComponentInjector.js","sourceRoot":"","sources":["../../../../src/injectors/components/ComponentInjector.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAyD;AACzD,sFAA2D;AAE3D,oEAA4C;AAC5C,0DAAkC;AAClC,0DAAkC;AAElC,6CAAqE;AACrE,iDAA8C;AAC9C,2DAAwD;AAExD,MAAqB,iBAAiB;IACpC,MAAM,CACJ,MAAkC,EAClC,UAA+C;QAE/C,MAAM,OAAO,GAAG,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;QACvD,IAAA,iCAAoB,EAAC,OAAc,EAAE,MAAa,C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H,eAAe,QAAQ,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
const react_1 = __importStar(require("react"));
|
|
37
|
+
const style = { position: 'absolute', width: 0, height: 0, overflow: 'hidden' };
|
|
38
|
+
const Sentinel = (0, react_1.forwardRef)((_, ref) => (react_1.default.createElement("div", { ref: ref, style: style })));
|
|
39
|
+
exports.default = Sentinel;
|
|
40
|
+
//# sourceMappingURL=Sentinel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Sentinel.js","sourceRoot":"","sources":["../../../../src/injectors/components/Sentinel.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAA0C;AAE1C,MAAM,KAAK,GAAG,EAAE,QAAQ,EAAE,UAAmB,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,QAAQ,EAAE,QAAiB,EAAE,CAAC;AAElG,MAAM,QAAQ,GAAG,IAAA,kBAAU,EAAM,CAAC,CAAC,EAAE,GAAG,EAAE,EAAE,CAAC,CAC3C,uCAAK,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,GAAI,CAChC,CAAC,CAAC;AAEH,kBAAe,QAAQ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Sentinel.native.d.ts","sourceRoot":"","sources":["../../../../src/injectors/components/Sentinel.native.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAO1C,QAAA,MAAM,QAAQ,2DAEZ,CAAC;AAEH,eAAe,QAAQ,CAAC"}
|
|
@@ -33,15 +33,10 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.default = useGraphContainer;
|
|
37
36
|
const react_1 = __importStar(require("react"));
|
|
38
|
-
const reactNativeAvailability_1 = require("../../utils/reactNativeAvailability");
|
|
39
|
-
const isRN = (0, reactNativeAvailability_1.isReactNativeAvailable)();
|
|
40
37
|
// eslint-disable-next-line @typescript-eslint/no-require-imports, global-require
|
|
41
|
-
const
|
|
42
|
-
const
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
//# sourceMappingURL=useGraphContainer.js.map
|
|
38
|
+
const { View } = require('react-native');
|
|
39
|
+
const style = { position: 'absolute', width: 0, height: 0, overflow: 'hidden' };
|
|
40
|
+
const Sentinel = (0, react_1.forwardRef)((_, ref) => (react_1.default.createElement(View, { ref: ref, collapsable: false, style: style })));
|
|
41
|
+
exports.default = Sentinel;
|
|
42
|
+
//# sourceMappingURL=Sentinel.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Sentinel.native.js","sourceRoot":"","sources":["../../../../src/injectors/components/Sentinel.native.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAA0C;AAE1C,iFAAiF;AACjF,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;AAEzC,MAAM,KAAK,GAAG,EAAE,QAAQ,EAAE,UAAmB,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,QAAQ,EAAE,QAAiB,EAAE,CAAC;AAElG,MAAM,QAAQ,GAAG,IAAA,kBAAU,EAAM,CAAC,CAAC,EAAE,GAAG,EAAE,EAAE,CAAC,CAC3C,8BAAC,IAAI,IAAC,GAAG,EAAE,GAAG,EAAE,WAAW,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,GAAI,CACrD,CAAC,CAAC;AAEH,kBAAe,QAAQ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useGraph.d.ts","sourceRoot":"","sources":["../../../../src/injectors/components/useGraph.ts"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;yBAItC,CAAC,cACH,MAAM,GAAG,aAAa,CAAC,WAAW,CAAC,UACvC,GAAG,UACH,OAAO,CAAC,CAAC,CAAC,mBACD,MAAM,iBACR,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC;AALrC,
|
|
1
|
+
{"version":3,"file":"useGraph.d.ts","sourceRoot":"","sources":["../../../../src/injectors/components/useGraph.ts"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;yBAItC,CAAC,cACH,MAAM,GAAG,aAAa,CAAC,WAAW,CAAC,UACvC,GAAG,UACH,OAAO,CAAC,CAAC,CAAC,mBACD,MAAM,iBACR,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC;AALrC,wBA0BE"}
|
|
@@ -13,9 +13,10 @@ exports.default = (keyOrGraph, target, props, injectionToken, containerRef) => {
|
|
|
13
13
|
return resolvedGraph;
|
|
14
14
|
});
|
|
15
15
|
(0, react_1.useEffect)(() => {
|
|
16
|
+
const sentinel = containerRef === null || containerRef === void 0 ? void 0 : containerRef.current;
|
|
16
17
|
ReferenceCounter_1.default.retain(graph);
|
|
17
18
|
return () => {
|
|
18
|
-
const isCleanupCalledDueToActivityPause =
|
|
19
|
+
const isCleanupCalledDueToActivityPause = graph.inactiveBehavior === 'retain' && (sentinel === null || sentinel === void 0 ? void 0 : sentinel.isConnected);
|
|
19
20
|
ReferenceCounter_1.default.release(graph, (g) => {
|
|
20
21
|
if (!isCleanupCalledDueToActivityPause) {
|
|
21
22
|
GraphRegistry_1.default.clear(g);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useGraph.js","sourceRoot":"","sources":["../../../../src/injectors/components/useGraph.ts"],"names":[],"mappings":";;;;;AAAA,iCAAmD;AAGnD,uFAA+D;AAC/D,8EAAsD;AAEtD,kBAAe,CACb,UAA+C,EAC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AAR,QAAQ,uBAAR,QAAQ,CAAE,WAAW,CAAA,CAAC;YACvG,0BAAgB,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,EAAE,EAAE;gBACpC,IAAI,CAAC,iCAAiC,EAAE,CAAC;oBACvC,uBAAa,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;gBACzB,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IACZ,OAAO,KAAK,CAAC;AACf,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-obsidian",
|
|
3
|
-
"version": "2.31.0-alpha.
|
|
3
|
+
"version": "2.31.0-alpha.6",
|
|
4
4
|
"description": "Dependency injection framework for React and React Native applications",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"prepack": "yarn lint && tsc --project tsconfig.prod.json",
|
|
@@ -39,14 +39,15 @@
|
|
|
39
39
|
"@babel/preset-typescript": "7.26.0",
|
|
40
40
|
"@babel/types": "7.24.5",
|
|
41
41
|
"@stylistic/eslint-plugin": "^1.7.0",
|
|
42
|
+
"@testing-library/dom": "^10.0.0",
|
|
42
43
|
"@testing-library/jest-dom": "^6.9.1",
|
|
43
|
-
"@testing-library/react": "
|
|
44
|
+
"@testing-library/react": "16.x.x",
|
|
44
45
|
"@types/hoist-non-react-statics": "^3.3.1",
|
|
45
46
|
"@types/jest": "^30.0.0",
|
|
46
47
|
"@types/jest-when": "^3.5.5",
|
|
47
48
|
"@types/lodash": "^4.14.176",
|
|
48
|
-
"@types/react": "
|
|
49
|
-
"@types/react-dom": "
|
|
49
|
+
"@types/react": "^19.0.0",
|
|
50
|
+
"@types/react-dom": "^19.0.0",
|
|
50
51
|
"@typescript-eslint/eslint-plugin": "^7.18.0",
|
|
51
52
|
"@typescript-eslint/parser": "^7.18.0",
|
|
52
53
|
"babel-plugin-parameter-decorator": "1.x.x",
|
|
@@ -66,8 +67,8 @@
|
|
|
66
67
|
"jest-mock-extended": "^3.0.7",
|
|
67
68
|
"jest-when": "^3.7.0",
|
|
68
69
|
"lodash": "^4.17.21",
|
|
69
|
-
"react": "
|
|
70
|
-
"react-dom": "
|
|
70
|
+
"react": "19.2.4",
|
|
71
|
+
"react-dom": "19.2.4",
|
|
71
72
|
"setimmediate": "^1.0.5",
|
|
72
73
|
"typescript": "^5.7.3"
|
|
73
74
|
},
|
|
@@ -3,7 +3,7 @@ import hoistNonReactStatics from 'hoist-non-react-statics';
|
|
|
3
3
|
import { ObjectGraph } from '../../graph/ObjectGraph';
|
|
4
4
|
import PropsInjector from './PropsInjector';
|
|
5
5
|
import useGraph from './useGraph';
|
|
6
|
-
import
|
|
6
|
+
import Sentinel from './Sentinel';
|
|
7
7
|
import { Constructable } from '../../types';
|
|
8
8
|
import { genericMemo, isMemoizedComponent } from '../../utils/React';
|
|
9
9
|
import { GraphContext } from './graphContext';
|
|
@@ -15,7 +15,7 @@ export default class ComponentInjector {
|
|
|
15
15
|
keyOrGraph: string | Constructable<ObjectGraph>,
|
|
16
16
|
): React.FunctionComponent<Partial<P>> {
|
|
17
17
|
const Wrapped = this.wrapComponent(Target, keyOrGraph);
|
|
18
|
-
hoistNonReactStatics(Wrapped, Target);
|
|
18
|
+
hoistNonReactStatics(Wrapped as any, Target as any);
|
|
19
19
|
return Wrapped;
|
|
20
20
|
}
|
|
21
21
|
|
|
@@ -31,14 +31,12 @@ export default class ComponentInjector {
|
|
|
31
31
|
const injectionToken = useInjectionToken(keyOrGraph);
|
|
32
32
|
const containerRef = useRef(null);
|
|
33
33
|
const graph = useGraph<P>(keyOrGraph, Target, passedProps, injectionToken, containerRef);
|
|
34
|
-
const Container = useGraphContainer(graph);
|
|
35
34
|
const proxiedProps = new PropsInjector(graph).inject(passedProps);
|
|
36
35
|
|
|
37
36
|
return (
|
|
38
37
|
<GraphContext.Provider value={{injectionToken}}>
|
|
39
|
-
<
|
|
40
|
-
|
|
41
|
-
</Container>
|
|
38
|
+
{graph.inactiveBehavior === 'retain' && <Sentinel ref={containerRef} />}
|
|
39
|
+
{Target(proxiedProps as unknown as PropsWithChildren<P>) as React.ReactNode}
|
|
42
40
|
</GraphContext.Provider>
|
|
43
41
|
);
|
|
44
42
|
}, compare);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
|
+
|
|
3
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports, global-require
|
|
4
|
+
const { View } = require('react-native');
|
|
5
|
+
|
|
6
|
+
const style = { position: 'absolute' as const, width: 0, height: 0, overflow: 'hidden' as const };
|
|
7
|
+
|
|
8
|
+
const Sentinel = forwardRef<any>((_, ref) => (
|
|
9
|
+
<View ref={ref} collapsable={false} style={style} />
|
|
10
|
+
));
|
|
11
|
+
|
|
12
|
+
export default Sentinel;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
|
+
|
|
3
|
+
const style = { position: 'absolute' as const, width: 0, height: 0, overflow: 'hidden' as const };
|
|
4
|
+
|
|
5
|
+
const Sentinel = forwardRef<any>((_, ref) => (
|
|
6
|
+
<div ref={ref} style={style} />
|
|
7
|
+
));
|
|
8
|
+
|
|
9
|
+
export default Sentinel;
|
|
@@ -18,9 +18,10 @@ export default <P>(
|
|
|
18
18
|
return resolvedGraph;
|
|
19
19
|
});
|
|
20
20
|
useEffect(() => {
|
|
21
|
+
const sentinel = containerRef?.current;
|
|
21
22
|
referenceCounter.retain(graph);
|
|
22
23
|
return () => {
|
|
23
|
-
const isCleanupCalledDueToActivityPause =
|
|
24
|
+
const isCleanupCalledDueToActivityPause = graph.inactiveBehavior === 'retain' && sentinel?.isConnected;
|
|
24
25
|
referenceCounter.release(graph, (g) => {
|
|
25
26
|
if (!isCleanupCalledDueToActivityPause) {
|
|
26
27
|
graphRegistry.clear(g);
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { ObjectGraph } from '../../graph/ObjectGraph';
|
|
3
|
-
export default function useGraphContainer(graph: ObjectGraph): React.ForwardRefExoticComponent<{
|
|
4
|
-
children?: React.ReactNode | undefined;
|
|
5
|
-
} & React.RefAttributes<any>>;
|
|
6
|
-
//# sourceMappingURL=useGraphContainer.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useGraphContainer.d.ts","sourceRoot":"","sources":["../../../../src/injectors/components/useGraphContainer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAwC,MAAM,OAAO,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAetD,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAC,KAAK,EAAE,WAAW;;8BAE3D"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useGraphContainer.js","sourceRoot":"","sources":["../../../../src/injectors/components/useGraphContainer.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgBA,oCAEC;AAlBD,+CAA6D;AAE7D,iFAA6E;AAE7E,MAAM,IAAI,GAAG,IAAA,gDAAsB,GAAE,CAAC;AACtC,iFAAiF;AACjF,MAAM,OAAO,GAAQ,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC;AAEjE,MAAM,eAAe,GAAG,IAAA,kBAAU,EAAyB,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE,CAAC,CACzE,8BAAC,OAAO,IAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,IAAG,KAAK,CAAC,QAAQ,CAAW,CACjG,CAAC,CAAC;AAEH,MAAM,oBAAoB,GAAG,IAAA,kBAAU,EAAyB,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,CAC/E,8DAAG,KAAK,CAAC,QAAQ,CAAI,CACtB,CAAC,CAAC;AAEH,SAAwB,iBAAiB,CAAC,KAAkB;IAC1D,OAAO,KAAK,CAAC,gBAAgB,KAAK,QAAQ,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,oBAAoB,CAAC;AACtF,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"reactNativeAvailability.d.ts","sourceRoot":"","sources":["../../../src/utils/reactNativeAvailability.ts"],"names":[],"mappings":"AAEA,wBAAgB,sBAAsB,IAAI,OAAO,CAchD"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isReactNativeAvailable = isReactNativeAvailable;
|
|
4
|
-
let cache;
|
|
5
|
-
function isReactNativeAvailable() {
|
|
6
|
-
if (cache !== undefined)
|
|
7
|
-
return cache;
|
|
8
|
-
if (typeof navigator !== 'undefined' && navigator.product === 'ReactNative') {
|
|
9
|
-
cache = true;
|
|
10
|
-
return cache;
|
|
11
|
-
}
|
|
12
|
-
try {
|
|
13
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports, global-require
|
|
14
|
-
require('react-native');
|
|
15
|
-
cache = true;
|
|
16
|
-
}
|
|
17
|
-
catch (_a) {
|
|
18
|
-
cache = false;
|
|
19
|
-
}
|
|
20
|
-
return cache;
|
|
21
|
-
}
|
|
22
|
-
//# sourceMappingURL=reactNativeAvailability.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"reactNativeAvailability.js","sourceRoot":"","sources":["../../../src/utils/reactNativeAvailability.ts"],"names":[],"mappings":";;AAEA,wDAcC;AAhBD,IAAI,KAA0B,CAAC;AAE/B,SAAgB,sBAAsB;IACpC,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,KAAK,CAAC;IACtC,IAAI,OAAO,SAAS,KAAK,WAAW,IAAI,SAAS,CAAC,OAAO,KAAK,aAAa,EAAE,CAAC;QAC5E,KAAK,GAAG,IAAI,CAAC;QACb,OAAO,KAAK,CAAC;IACf,CAAC;IACD,IAAI,CAAC;QACH,iFAAiF;QACjF,OAAO,CAAC,cAAc,CAAC,CAAC;QACxB,KAAK,GAAG,IAAI,CAAC;IACf,CAAC;IAAC,WAAM,CAAC;QACP,KAAK,GAAG,KAAK,CAAC;IAChB,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import React, { forwardRef, PropsWithChildren } from 'react';
|
|
2
|
-
import { ObjectGraph } from '../../graph/ObjectGraph';
|
|
3
|
-
import { isReactNativeAvailable } from '../../utils/reactNativeAvailability';
|
|
4
|
-
|
|
5
|
-
const isRN = isReactNativeAvailable();
|
|
6
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports, global-require
|
|
7
|
-
const Element: any = isRN ? require('react-native').View : 'div';
|
|
8
|
-
|
|
9
|
-
const RetainContainer = forwardRef<any, PropsWithChildren>((props, ref) => (
|
|
10
|
-
<Element ref={ref} style={isRN ? undefined : { display: 'contents' }}>{props.children}</Element>
|
|
11
|
-
));
|
|
12
|
-
|
|
13
|
-
const PassthroughContainer = forwardRef<any, PropsWithChildren>((props, _ref) => (
|
|
14
|
-
<>{props.children}</>
|
|
15
|
-
));
|
|
16
|
-
|
|
17
|
-
export default function useGraphContainer(graph: ObjectGraph) {
|
|
18
|
-
return graph.inactiveBehavior === 'retain' ? RetainContainer : PassthroughContainer;
|
|
19
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
let cache: boolean | undefined;
|
|
2
|
-
|
|
3
|
-
export function isReactNativeAvailable(): boolean {
|
|
4
|
-
if (cache !== undefined) return cache;
|
|
5
|
-
if (typeof navigator !== 'undefined' && navigator.product === 'ReactNative') {
|
|
6
|
-
cache = true;
|
|
7
|
-
return cache;
|
|
8
|
-
}
|
|
9
|
-
try {
|
|
10
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports, global-require
|
|
11
|
-
require('react-native');
|
|
12
|
-
cache = true;
|
|
13
|
-
} catch {
|
|
14
|
-
cache = false;
|
|
15
|
-
}
|
|
16
|
-
return cache;
|
|
17
|
-
}
|