react-native-onyx 3.0.53 → 3.0.55

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.
@@ -1,29 +0,0 @@
1
- "use strict";
2
- /**
3
- * Stores settings from Onyx.init globally so they can be made accessible by other parts of the library.
4
- */
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.setPerformanceMetricsEnabled = setPerformanceMetricsEnabled;
7
- exports.isPerformanceMetricsEnabled = isPerformanceMetricsEnabled;
8
- exports.addGlobalSettingsChangeListener = addGlobalSettingsChangeListener;
9
- const globalSettings = {
10
- enablePerformanceMetrics: false,
11
- };
12
- const listeners = new Set();
13
- function addGlobalSettingsChangeListener(listener) {
14
- listeners.add(listener);
15
- return () => {
16
- listeners.delete(listener);
17
- };
18
- }
19
- function notifyListeners() {
20
- for (const listener of listeners)
21
- listener(globalSettings);
22
- }
23
- function setPerformanceMetricsEnabled(enabled) {
24
- globalSettings.enablePerformanceMetrics = enabled;
25
- notifyListeners();
26
- }
27
- function isPerformanceMetricsEnabled() {
28
- return globalSettings.enablePerformanceMetrics;
29
- }
@@ -1,10 +0,0 @@
1
- type ImportType = ReturnType<typeof require>;
2
- /**
3
- * Create a lazily-imported module proxy.
4
- * This is useful for lazily requiring optional dependencies.
5
- */
6
- declare const createModuleProxy: <TModule>(getModule: () => ImportType) => TModule;
7
- declare class OptionalDependencyNotInstalledError extends Error {
8
- constructor(name: string);
9
- }
10
- export { createModuleProxy, OptionalDependencyNotInstalledError };
@@ -1,37 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.OptionalDependencyNotInstalledError = exports.createModuleProxy = void 0;
4
- /**
5
- * Create a lazily-imported module proxy.
6
- * This is useful for lazily requiring optional dependencies.
7
- */
8
- const createModuleProxy = (getModule) => {
9
- const holder = { module: undefined };
10
- const proxy = new Proxy(holder, {
11
- get: (target, property) => {
12
- if (property === '$$typeof') {
13
- // If inlineRequires is enabled, Metro will look up all imports
14
- // with the $$typeof operator. In this case, this will throw the
15
- // `OptionalDependencyNotInstalledError` error because we try to access the module
16
- // even though we are not using it (Metro does it), so instead we return undefined
17
- // to bail out of inlineRequires here.
18
- return undefined;
19
- }
20
- if (target.module == null) {
21
- // lazy initialize module via require()
22
- // caller needs to make sure the require() call is wrapped in a try/catch
23
- // eslint-disable-next-line no-param-reassign
24
- target.module = getModule();
25
- }
26
- return target.module[property];
27
- },
28
- });
29
- return proxy;
30
- };
31
- exports.createModuleProxy = createModuleProxy;
32
- class OptionalDependencyNotInstalledError extends Error {
33
- constructor(name) {
34
- super(`${name} is not installed!`);
35
- }
36
- }
37
- exports.OptionalDependencyNotInstalledError = OptionalDependencyNotInstalledError;
@@ -1 +0,0 @@
1
- export default performance;
@@ -1,4 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- // Use the existing performance API on web
4
- exports.default = performance;
@@ -1,20 +0,0 @@
1
- declare const PerformanceProxy: {
2
- timeOrigin: number;
3
- now: () => number;
4
- mark: (markName: string, markOptions?: import("react-native-performance/lib/typescript/performance").MarkOptions) => import("react-native-performance").PerformanceMark;
5
- clearMarks: (name?: string) => void;
6
- measure: (measureName: string, startOrMeasureOptions?: import("react-native-performance/lib/typescript/performance").StartOrMeasureOptions, endMark?: string | number) => import("react-native-performance").PerformanceMeasure;
7
- clearMeasures: (name?: string) => void;
8
- metric: (name: string, valueOrOptions: import("react-native-performance/lib/typescript/performance").ValueOrOptions) => import("react-native-performance").PerformanceMetric;
9
- clearMetrics: (name?: string) => void;
10
- getEntries: () => import("react-native-performance").PerformanceEntry[];
11
- getEntriesByName: (name: string, type?: import("react-native-performance").EntryType) => import("react-native-performance").PerformanceEntry[];
12
- getEntriesByType: {
13
- (type: "measure"): import("react-native-performance").PerformanceMeasure[];
14
- (type: "mark"): import("react-native-performance").PerformanceMark[];
15
- (type: "resource"): import("react-native-performance").PerformanceResourceTiming[];
16
- (type: "metric"): import("react-native-performance").PerformanceMetric[];
17
- (type: "react-native-mark"): import("react-native-performance").PerformanceReactNativeMark[];
18
- };
19
- };
20
- export default PerformanceProxy;
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const ModuleProxy_1 = require("../ModuleProxy");
4
- const PerformanceProxy = (0, ModuleProxy_1.createModuleProxy)(() => {
5
- try {
6
- return require('react-native-performance').default;
7
- }
8
- catch (_a) {
9
- throw new ModuleProxy_1.OptionalDependencyNotInstalledError('react-native-performance');
10
- }
11
- });
12
- exports.default = PerformanceProxy;
package/dist/metrics.d.ts DELETED
@@ -1,8 +0,0 @@
1
- /**
2
- * Wraps a function with metrics capturing logic
3
- */
4
- declare function decorateWithMetrics<Args extends unknown[], ReturnType>(func: (...args: Args) => ReturnType, alias?: string): {
5
- (...args: Args): ReturnType;
6
- name: string;
7
- };
8
- export default decorateWithMetrics;
package/dist/metrics.js DELETED
@@ -1,47 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const PerformanceProxy_1 = __importDefault(require("./dependencies/PerformanceProxy"));
7
- /**
8
- * Capture a measurement between the start mark and now
9
- */
10
- function measureMarkToNow(startMark, detail) {
11
- PerformanceProxy_1.default.measure(`${startMark.name} [${startMark.detail.args.toString()}]`, {
12
- start: startMark.startTime,
13
- end: PerformanceProxy_1.default.now(),
14
- detail: Object.assign(Object.assign({}, startMark.detail), detail),
15
- });
16
- }
17
- function isPromiseLike(value) {
18
- return value != null && typeof value === 'object' && 'then' in value;
19
- }
20
- /**
21
- * Wraps a function with metrics capturing logic
22
- */
23
- function decorateWithMetrics(func, alias = func.name) {
24
- function decorated(...args) {
25
- const mark = PerformanceProxy_1.default.mark(alias, { detail: { args, alias } });
26
- const originalReturnValue = func(...args);
27
- if (isPromiseLike(originalReturnValue)) {
28
- /*
29
- * The handlers added here are not affecting the original promise
30
- * They create a separate chain that's not exposed (returned) to the original caller
31
- */
32
- originalReturnValue
33
- .then((result) => {
34
- measureMarkToNow(mark, { result });
35
- })
36
- .catch((error) => {
37
- measureMarkToNow(mark, { error });
38
- });
39
- return originalReturnValue;
40
- }
41
- measureMarkToNow(mark, { result: originalReturnValue });
42
- return originalReturnValue;
43
- }
44
- decorated.name = `${alias}_DECORATED`;
45
- return decorated;
46
- }
47
- exports.default = decorateWithMetrics;