react-obsidian 2.31.0-alpha.0 → 2.31.0-alpha.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.
@@ -36,11 +36,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.default = useGraphContainer;
37
37
  const react_1 = __importStar(require("react"));
38
38
  const reactNativeAvailability_1 = require("../../utils/reactNativeAvailability");
39
- const packageAvailability_1 = require("../../utils/packageAvailability");
40
39
  const isRN = (0, reactNativeAvailability_1.isReactNativeAvailable)();
41
- const Element = isRN ? (0, packageAvailability_1.dynamicRequire)('react-native').View : 'div';
40
+ // eslint-disable-next-line @typescript-eslint/no-require-imports, global-require
41
+ const Element = isRN ? require('react-native').View : 'div';
42
42
  const RetainContainer = (0, react_1.forwardRef)((props, ref) => (react_1.default.createElement(Element, { ref: ref, style: isRN ? undefined : { display: 'contents' } }, props.children)));
43
- const PassthroughContainer = (0, react_1.forwardRef)((props) => (react_1.default.createElement(react_1.default.Fragment, null, props.children)));
43
+ const PassthroughContainer = (0, react_1.forwardRef)((props, _ref) => (react_1.default.createElement(react_1.default.Fragment, null, props.children)));
44
44
  function useGraphContainer(graph) {
45
45
  return graph.inactiveBehavior === 'retain' ? RetainContainer : PassthroughContainer;
46
46
  }
@@ -1 +1 @@
1
- {"version":3,"file":"useGraphContainer.js","sourceRoot":"","sources":["../../../../src/injectors/components/useGraphContainer.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgBA,oCAEC;AAlBD,+CAA6D;AAE7D,iFAA6E;AAC7E,yEAAiE;AAEjE,MAAM,IAAI,GAAG,IAAA,gDAAsB,GAAE,CAAC;AACtC,MAAM,OAAO,GAAQ,IAAI,CAAC,CAAC,CAAC,IAAA,oCAAc,EAAC,cAAc,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC;AAExE,MAAM,eAAe,GAAG,IAAA,kBAAU,EAAyB,CAAC,K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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 +1 @@
1
- {"version":3,"file":"reactAvailability.d.ts","sourceRoot":"","sources":["../../../src/utils/reactAvailability.ts"],"names":[],"mappings":"AAEA,wBAAgB,gBAAgB,IAAI,OAAO,CAE1C;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,CAAC,GAAG,GAAG,EAAE,WAAW,EAAE,MAAM,GAAG,CAAC,CAOxE"}
1
+ {"version":3,"file":"reactAvailability.d.ts","sourceRoot":"","sources":["../../../src/utils/reactAvailability.ts"],"names":[],"mappings":"AAEA,wBAAgB,gBAAgB,IAAI,OAAO,CAU1C;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,CAAC,GAAG,GAAG,EAAE,WAAW,EAAE,MAAM,GAAG,CAAC,CAOxE"}
@@ -2,9 +2,19 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isReactAvailable = isReactAvailable;
4
4
  exports.createReactRequiredError = createReactRequiredError;
5
- const packageAvailability_1 = require("./packageAvailability");
5
+ let cache;
6
6
  function isReactAvailable() {
7
- return (0, packageAvailability_1.isPackageAvailable)('react');
7
+ if (cache !== undefined)
8
+ return cache;
9
+ try {
10
+ // eslint-disable-next-line @typescript-eslint/no-require-imports, global-require
11
+ require('react');
12
+ cache = true;
13
+ }
14
+ catch (_a) {
15
+ cache = false;
16
+ }
17
+ return cache;
8
18
  }
9
19
  /**
10
20
  * Creates a function that throws an error when called if React is not available.
@@ -1 +1 @@
1
- {"version":3,"file":"reactAvailability.js","sourceRoot":"","sources":["../../../src/utils/reactAvailability.ts"],"names":[],"mappings":";;AAEA,4CAEC;AAMD,4DAOC;AAjBD,+DAA2D;AAE3D,SAAgB,gBAAgB;IAC9B,OAAO,IAAA,wCAAkB,EAAC,OAAO,CAAC,CAAC;AACrC,CAAC;AAED;;;GAGG;AACH,SAAgB,wBAAwB,CAAU,WAAmB;IACnE,OAAO,SAAS,iBAAiB,CAAC,GAAG,KAAY;QAC/C,MAAM,IAAI,KAAK,CACb,GAAG,WAAW,mCAAmC;cAC/C,yCAAyC,CAC5C,CAAC;IACJ,CAAM,CAAC;AACT,CAAC"}
1
+ {"version":3,"file":"reactAvailability.js","sourceRoot":"","sources":["../../../src/utils/reactAvailability.ts"],"names":[],"mappings":";;AAEA,4CAUC;AAMD,4DAOC;AAzBD,IAAI,KAA0B,CAAC;AAE/B,SAAgB,gBAAgB;IAC9B,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,KAAK,CAAC;IACtC,IAAI,CAAC;QACH,iFAAiF;QACjF,OAAO,CAAC,OAAO,CAAC,CAAC;QACjB,KAAK,GAAG,IAAI,CAAC;IACf,CAAC;IAAC,WAAM,CAAC;QACP,KAAK,GAAG,KAAK,CAAC;IAChB,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;GAGG;AACH,SAAgB,wBAAwB,CAAU,WAAmB;IACnE,OAAO,SAAS,iBAAiB,CAAC,GAAG,KAAY;QAC/C,MAAM,IAAI,KAAK,CACb,GAAG,WAAW,mCAAmC;cAC/C,yCAAyC,CAC5C,CAAC;IACJ,CAAM,CAAC;AACT,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"reactNativeAvailability.d.ts","sourceRoot":"","sources":["../../../src/utils/reactNativeAvailability.ts"],"names":[],"mappings":"AAIA,wBAAgB,sBAAsB,IAAI,OAAO,CAQhD"}
1
+ {"version":3,"file":"reactNativeAvailability.d.ts","sourceRoot":"","sources":["../../../src/utils/reactNativeAvailability.ts"],"names":[],"mappings":"AAEA,wBAAgB,sBAAsB,IAAI,OAAO,CAchD"}
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isReactNativeAvailable = isReactNativeAvailable;
4
- const packageAvailability_1 = require("./packageAvailability");
5
4
  let cache;
6
5
  function isReactNativeAvailable() {
7
6
  if (cache !== undefined)
@@ -10,7 +9,14 @@ function isReactNativeAvailable() {
10
9
  cache = true;
11
10
  return cache;
12
11
  }
13
- cache = (0, packageAvailability_1.isPackageAvailable)('react-native');
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
+ }
14
20
  return cache;
15
21
  }
16
22
  //# sourceMappingURL=reactNativeAvailability.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"reactNativeAvailability.js","sourceRoot":"","sources":["../../../src/utils/reactNativeAvailability.ts"],"names":[],"mappings":";;AAIA,wDAQC;AAZD,+DAA2D;AAE3D,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,KAAK,GAAG,IAAA,wCAAkB,EAAC,cAAc,CAAC,CAAC;IAC3C,OAAO,KAAK,CAAC;AACf,CAAC"}
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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-obsidian",
3
- "version": "2.31.0-alpha.0",
3
+ "version": "2.31.0-alpha.2",
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",
@@ -1,16 +1,16 @@
1
1
  import React, { forwardRef, PropsWithChildren } from 'react';
2
2
  import { ObjectGraph } from '../../graph/ObjectGraph';
3
3
  import { isReactNativeAvailable } from '../../utils/reactNativeAvailability';
4
- import { dynamicRequire } from '../../utils/packageAvailability';
5
4
 
6
5
  const isRN = isReactNativeAvailable();
7
- const Element: any = isRN ? dynamicRequire('react-native').View : 'div';
6
+ // eslint-disable-next-line @typescript-eslint/no-require-imports, global-require
7
+ const Element: any = isRN ? require('react-native').View : 'div';
8
8
 
9
9
  const RetainContainer = forwardRef<any, PropsWithChildren>((props, ref) => (
10
10
  <Element ref={ref} style={isRN ? undefined : { display: 'contents' }}>{props.children}</Element>
11
11
  ));
12
12
 
13
- const PassthroughContainer = forwardRef<any, PropsWithChildren>((props) => (
13
+ const PassthroughContainer = forwardRef<any, PropsWithChildren>((props, _ref) => (
14
14
  <>{props.children}</>
15
15
  ));
16
16
 
@@ -1,7 +1,15 @@
1
- import { isPackageAvailable } from './packageAvailability';
1
+ let cache: boolean | undefined;
2
2
 
3
3
  export function isReactAvailable(): boolean {
4
- return isPackageAvailable('react');
4
+ if (cache !== undefined) return cache;
5
+ try {
6
+ // eslint-disable-next-line @typescript-eslint/no-require-imports, global-require
7
+ require('react');
8
+ cache = true;
9
+ } catch {
10
+ cache = false;
11
+ }
12
+ return cache;
5
13
  }
6
14
 
7
15
  /**
@@ -1,5 +1,3 @@
1
- import { isPackageAvailable } from './packageAvailability';
2
-
3
1
  let cache: boolean | undefined;
4
2
 
5
3
  export function isReactNativeAvailable(): boolean {
@@ -8,6 +6,12 @@ export function isReactNativeAvailable(): boolean {
8
6
  cache = true;
9
7
  return cache;
10
8
  }
11
- cache = isPackageAvailable('react-native');
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
+ }
12
16
  return cache;
13
17
  }
@@ -1,3 +0,0 @@
1
- export declare function isPackageAvailable(name: string): boolean;
2
- export declare function dynamicRequire(name: string): any;
3
- //# sourceMappingURL=packageAvailability.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"packageAvailability.d.ts","sourceRoot":"","sources":["../../../src/utils/packageAvailability.ts"],"names":[],"mappings":"AAkBA,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CASxD;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,CAEhD"}
@@ -1,36 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isPackageAvailable = isPackageAvailable;
4
- exports.dynamicRequire = dynamicRequire;
5
- const cache = new Map();
6
- // Indirection makes require non-statically-analyzable so bundlers won't try to resolve the module name.
7
- // eval is wrapped in try/catch to gracefully handle strict CSP environments.
8
- function getDynamicRequireFn() {
9
- if (typeof require === 'undefined') {
10
- return undefined;
11
- }
12
- try {
13
- // eslint-disable-next-line @typescript-eslint/no-require-imports, no-eval
14
- return eval('require');
15
- }
16
- catch (_a) {
17
- return undefined;
18
- }
19
- }
20
- const dynamicRequireFn = getDynamicRequireFn();
21
- function isPackageAvailable(name) {
22
- if (cache.has(name))
23
- return cache.get(name);
24
- try {
25
- dynamicRequireFn === null || dynamicRequireFn === void 0 ? void 0 : dynamicRequireFn(name);
26
- cache.set(name, !!dynamicRequireFn);
27
- }
28
- catch (_a) {
29
- cache.set(name, false);
30
- }
31
- return cache.get(name);
32
- }
33
- function dynamicRequire(name) {
34
- return dynamicRequireFn === null || dynamicRequireFn === void 0 ? void 0 : dynamicRequireFn(name);
35
- }
36
- //# sourceMappingURL=packageAvailability.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"packageAvailability.js","sourceRoot":"","sources":["../../../src/utils/packageAvailability.ts"],"names":[],"mappings":";;AAkBA,gDASC;AAED,wCAEC;AA/BD,MAAM,KAAK,GAAG,IAAI,GAAG,EAAmB,CAAC;AAEzC,wGAAwG;AACxG,6EAA6E;AAC7E,SAAS,mBAAmB;IAC1B,IAAI,OAAO,OAAO,KAAK,WAAW,EAAE,CAAC;QACnC,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,IAAI,CAAC;QACH,0EAA0E;QAC1E,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC;IACzB,CAAC;IAAC,WAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC;AAED,MAAM,gBAAgB,GAAG,mBAAmB,EAAE,CAAC;AAE/C,SAAgB,kBAAkB,CAAC,IAAY;IAC7C,IAAI,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC;QAAE,OAAO,KAAK,CAAC,GAAG,CAAC,IAAI,CAAE,CAAC;IAC7C,IAAI,CAAC;QACH,gBAAgB,aAAhB,gBAAgB,uBAAhB,gBAAgB,CAAG,IAAI,CAAC,CAAC;QACzB,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,gBAAgB,CAAC,CAAC;IACtC,CAAC;IAAC,WAAM,CAAC;QACP,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IACzB,CAAC;IACD,OAAO,KAAK,CAAC,GAAG,CAAC,IAAI,CAAE,CAAC;AAC1B,CAAC;AAED,SAAgB,cAAc,CAAC,IAAY;IACzC,OAAO,gBAAgB,aAAhB,gBAAgB,uBAAhB,gBAAgB,CAAG,IAAI,CAAC,CAAC;AAClC,CAAC"}
@@ -1,32 +0,0 @@
1
- const cache = new Map<string, boolean>();
2
-
3
- // Indirection makes require non-statically-analyzable so bundlers won't try to resolve the module name.
4
- // eval is wrapped in try/catch to gracefully handle strict CSP environments.
5
- function getDynamicRequireFn(): ((name: string) => any) | undefined {
6
- if (typeof require === 'undefined') {
7
- return undefined;
8
- }
9
- try {
10
- // eslint-disable-next-line @typescript-eslint/no-require-imports, no-eval
11
- return eval('require');
12
- } catch {
13
- return undefined;
14
- }
15
- }
16
-
17
- const dynamicRequireFn = getDynamicRequireFn();
18
-
19
- export function isPackageAvailable(name: string): boolean {
20
- if (cache.has(name)) return cache.get(name)!;
21
- try {
22
- dynamicRequireFn?.(name);
23
- cache.set(name, !!dynamicRequireFn);
24
- } catch {
25
- cache.set(name, false);
26
- }
27
- return cache.get(name)!;
28
- }
29
-
30
- export function dynamicRequire(name: string): any {
31
- return dynamicRequireFn?.(name);
32
- }