@keepsnappy/react-native 0.1.0-alpha.11 → 0.1.0-alpha.12
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/README.md +5 -5
- package/app.plugin.js +7 -7
- package/js/babel-transformer.js +5 -5
- package/js/hook.polyfill.js +6 -6
- package/js/renderer-switch.js +2 -2
- package/js/sdk/activation.ts +5 -5
- package/js/sdk/boot.ts +1 -1
- package/js/sdk/core.ts +7 -7
- package/js/sdk/push-install.ts +4 -4
- package/js/zustand-vanilla.js +1 -1
- package/metro.js +10 -11
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -53,11 +53,11 @@ All values are read at **bundle time** (Expo CLI loads `.env*` into the Metro pr
|
|
|
53
53
|
| Variable (current name) | Proposed public name | Values | Effect |
|
|
54
54
|
|---|---|---|---|
|
|
55
55
|
| `EXPO_PUBLIC_KEEPSNAPPY` | `PERFLAB` | `1` = on, anything else = off | Build flag. Off: Metro config untouched, SDK not in the bundle. On: hook polyfill + SDK boot in the bundle. |
|
|
56
|
-
| `EXPO_PUBLIC_KEEPSNAPPY_MODE` | `KEEPSNAPPY_MODE` | `dormant` / `auto` | `auto`: measure from the first frame (same as `
|
|
57
|
-
| `EXPO_PUBLIC_KEEPSNAPPY_AUTO` | `KEEPSNAPPY_AUTO` | `1` = on | Measure-only builds: collection (React hook walk, PerformanceObserver, log to console and native file) is on from the first frame, with no deep link needed. Off: only markers until a settings link turns collection on. Equivalent to `
|
|
56
|
+
| `EXPO_PUBLIC_KEEPSNAPPY_MODE` | `KEEPSNAPPY_MODE` | `dormant` / `auto` | `auto`: measure from the first frame (same as `KEEPSNAPPY_AUTO=1`). `dormant`: nothing runs until activated (below); once activated the process measures like `auto`. Unset: `auto` if `KEEPSNAPPY_AUTO=1`, else manual (markers until a settings link turns collection on). |
|
|
57
|
+
| `EXPO_PUBLIC_KEEPSNAPPY_AUTO` | `KEEPSNAPPY_AUTO` | `1` = on | Measure-only builds: collection (React hook walk, PerformanceObserver, log to console and native file) is on from the first frame, with no deep link needed. Off: only markers until a settings link turns collection on. Equivalent to `KEEPSNAPPY_MODE=auto`; `KEEPSNAPPY_MODE` wins when both are set. |
|
|
58
58
|
| `EXPO_PUBLIC_KEEPSNAPPY_INGEST_URL` | `KEEPSNAPPY_INGEST_URL` | URL of the farm ingest (`POST /v1/ingest`) | Push client. Push is on only if both the URL and the key are set. |
|
|
59
59
|
| `EXPO_PUBLIC_KEEPSNAPPY_KEY` | `KEEPSNAPPY_KEY` | ingest key | Sent as `x-perflab-key`. |
|
|
60
|
-
| `EXPO_PUBLIC_KEEPSNAPPY_SAMPLER` | `KEEPSNAPPY_SAMPLER` | `auto` / `manual` / `off` | Native resource sampler default. Unset: `auto` when `
|
|
60
|
+
| `EXPO_PUBLIC_KEEPSNAPPY_SAMPLER` | `KEEPSNAPPY_SAMPLER` | `auto` / `manual` / `off` | Native resource sampler default. Unset: `auto` when `KEEPSNAPPY_AUTO=1`, else `off`. |
|
|
61
61
|
| `EXPO_PUBLIC_KEEPSNAPPY_SAMPLER_MS` | `KEEPSNAPPY_SAMPLER_MS` | ms, 250–60000 | Auto sampling interval (default 4000; windows also get a sample at open and at close). |
|
|
62
62
|
| `EXPO_PUBLIC_KEEPSNAPPY_PROFILE` | `KEEPSNAPPY_PROFILE` | `1` = on | Default of `profile`: per-component update causes per window (any renderer), plus self/total ms and updaters with the profiling renderer (`react.profile`). |
|
|
63
63
|
| `EXPO_PUBLIC_KEEPSNAPPY_REACT_EXPORT` | `KEEPSNAPPY_REACT_EXPORT` | `1` = on | Default of `rexport`: a React DevTools v5 export per window (`Documents/perf-lab/react-<process>-<window id>-<name>.json`, TraceSift's input). Inside a run (a run token is set) the files are held and written at `flush=1`; otherwise at window end. |
|
|
@@ -115,7 +115,7 @@ Launch arguments as a second activation path are not implemented.
|
|
|
115
115
|
| `sampler` | `auto` / `manual` / `off` | Native resource sampler mode |
|
|
116
116
|
| `samplerMs` | 250–60000 | Auto sampling interval |
|
|
117
117
|
| `sample` | `1` | Take one sample now (ignored when the sampler is off) |
|
|
118
|
-
| `net` | `1`/`true` or `0` | Count network requests per window (default on with `
|
|
118
|
+
| `net` | `1`/`true` or `0` | Count network requests per window (default on with `KEEPSNAPPY_AUTO=1`) |
|
|
119
119
|
| `profile`, `rexport`, `cpuprof` | `1`/`true` or `0` | Update causes + render times per component, React export file per window, Hermes `.cpuprofile` around windows (see the env defaults above) |
|
|
120
120
|
| `cpuhz` | 10–10000 | Hermes sampling frequency |
|
|
121
121
|
| `diag` | `1`/`true` or `0` | Diagnostic iteration: React exports on (as `rexport=1`) and every raw file of the run kept and uploaded at `flush=1` (see Profile files). In a dormant build it comes from the activation only |
|
|
@@ -258,4 +258,4 @@ Why not a folder `file:` dependency or `bun link`: for a folder outside the app,
|
|
|
258
258
|
|
|
259
259
|
With the flag off the JS bundle carries no SDK code (check: `grep -c __PERFLAB_HOOK__ main.jsbundle` is 0) and, after a prebuild with the flag off, the binary carries no SDK native code (no `PerfLab` in `Podfile.lock`, in `ExpoModulesProvider.swift` or in the app binary's symbols).
|
|
260
260
|
|
|
261
|
-
|
|
261
|
+
Use `EXPO_PUBLIC_KEEPSNAPPY*`, `KEEPSNAPPY_*`, and `withKeepSnappy`. Previous build environment names and `withPerfLab` are no longer supported. Native module identities, stored records and wire formats are unchanged.
|
package/app.plugin.js
CHANGED
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
//
|
|
3
3
|
// The native module (iOS pod PerfLab, Android expo.modules.perflab) is linked
|
|
4
4
|
// by Expo autolinking from expo-module.config.json. With the build flag off
|
|
5
|
-
// (
|
|
5
|
+
// (EXPO_PUBLIC_KEEPSNAPPY is not "1" when `expo prebuild` runs) this plugin
|
|
6
6
|
// excludes the package from Expo autolinking, so a store build carries no SDK
|
|
7
7
|
// native code: no pod, no Android project, no ExpoModulesProvider entry. With
|
|
8
8
|
// the flag on it removes that exclusion again (prebuild without --clean edits
|
|
9
9
|
// the existing files) and records the flag in the app config, so the native
|
|
10
10
|
// fingerprints of flag-on and flag-off builds differ. It also records which
|
|
11
|
-
// React renderer the bundle carries (
|
|
11
|
+
// React renderer the bundle carries (KEEPSNAPPY_REACT_PROFILING, see metro.js):
|
|
12
12
|
// `always` (=1), `switch` (=switch) or `off`.
|
|
13
13
|
//
|
|
14
14
|
// expo-modules-autolinking reads exclusions only from the app's package.json and
|
|
@@ -18,14 +18,14 @@
|
|
|
18
18
|
const { withPodfile, withSettingsGradle } = require('expo/config-plugins');
|
|
19
19
|
|
|
20
20
|
const PACKAGE_NAME = require('./package.json').name;
|
|
21
|
-
const PACKAGE_NAMES = [...new Set([PACKAGE_NAME, '@keepsnappy/react-native'
|
|
21
|
+
const PACKAGE_NAMES = [...new Set([PACKAGE_NAME, '@keepsnappy/react-native'])];
|
|
22
22
|
const namesFor = name => name === PACKAGE_NAME ? PACKAGE_NAMES : [name];
|
|
23
23
|
// Keep this generated-line marker stable so old exclusions can be removed.
|
|
24
24
|
const TAG = 'perflab: native module excluded, EXPO_PUBLIC_PERF_LAB is not 1';
|
|
25
25
|
|
|
26
|
-
const isEnabled = () => (process.env.EXPO_PUBLIC_KEEPSNAPPY
|
|
26
|
+
const isEnabled = () => (process.env.EXPO_PUBLIC_KEEPSNAPPY) === '1';
|
|
27
27
|
|
|
28
|
-
const profilingRenderer = (value = (process.env.KEEPSNAPPY_REACT_PROFILING
|
|
28
|
+
const profilingRenderer = (value = (process.env.KEEPSNAPPY_REACT_PROFILING)) => {
|
|
29
29
|
if (value === '1') {
|
|
30
30
|
return 'always';
|
|
31
31
|
}
|
|
@@ -76,7 +76,7 @@ const editSettingsGradle = (contents, enabled, language = 'groovy', name = PACKA
|
|
|
76
76
|
return lines.join('\n');
|
|
77
77
|
};
|
|
78
78
|
|
|
79
|
-
const
|
|
79
|
+
const withKeepSnappy = config => {
|
|
80
80
|
const enabled = isEnabled();
|
|
81
81
|
if (enabled) {
|
|
82
82
|
config.extra = {
|
|
@@ -99,7 +99,7 @@ const withPerfLab = config => {
|
|
|
99
99
|
return config;
|
|
100
100
|
};
|
|
101
101
|
|
|
102
|
-
module.exports =
|
|
102
|
+
module.exports = withKeepSnappy;
|
|
103
103
|
module.exports.editPodfile = editPodfile;
|
|
104
104
|
module.exports.editSettingsGradle = editSettingsGradle;
|
|
105
105
|
module.exports.profilingRenderer = profilingRenderer;
|
package/js/babel-transformer.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Wraps the app's Babel transformer (set by
|
|
1
|
+
// Wraps the app's Babel transformer (set by withKeepSnappy) and adds one import to
|
|
2
2
|
// the entry module: the perf-lab boot module. That import is what puts the SDK
|
|
3
3
|
// in the graph; getModulesRunBeforeMainModule then runs it before the entry.
|
|
4
4
|
//
|
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
|
|
9
9
|
const path = require('path');
|
|
10
10
|
|
|
11
|
-
const upstreamPath = (process.env.KEEPSNAPPY_UPSTREAM_BABEL_TRANSFORMER
|
|
12
|
-
const entryFile = (process.env.KEEPSNAPPY_ENTRY_FILE
|
|
13
|
-
const bootFile = (process.env.KEEPSNAPPY_BOOT_FILE
|
|
11
|
+
const upstreamPath = (process.env.KEEPSNAPPY_UPSTREAM_BABEL_TRANSFORMER);
|
|
12
|
+
const entryFile = (process.env.KEEPSNAPPY_ENTRY_FILE);
|
|
13
|
+
const bootFile = (process.env.KEEPSNAPPY_BOOT_FILE);
|
|
14
14
|
|
|
15
15
|
if (!upstreamPath || !entryFile || !bootFile) {
|
|
16
16
|
throw new Error(
|
|
@@ -30,7 +30,7 @@ const inlineEnv = src =>
|
|
|
30
30
|
|
|
31
31
|
const envSignature = () =>
|
|
32
32
|
Object.keys(process.env)
|
|
33
|
-
.filter(name =>
|
|
33
|
+
.filter(name => name.startsWith('EXPO_PUBLIC_KEEPSNAPPY'))
|
|
34
34
|
.sort()
|
|
35
35
|
.map(name => `${name}=${process.env[name]}`)
|
|
36
36
|
.join('&');
|
package/js/hook.polyfill.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// A polyfill is a plain script (no require), so this file stays self-contained:
|
|
4
4
|
// it only counts and buffers. The SDK boot module attaches a listener later.
|
|
5
5
|
//
|
|
6
|
-
// Dormant builds (
|
|
6
|
+
// Dormant builds (EXPO_PUBLIC_KEEPSNAPPY_MODE=dormant) first read the activation
|
|
7
7
|
// record through the native module, synchronously (Expo installs
|
|
8
8
|
// `expo.modules` before the bundle runs; on Android the polyfill installs them itself). Not activated: nothing is installed
|
|
9
9
|
// and the React DevTools global stays exactly as without the SDK. If the native
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
// boot module decides (it still runs before the renderer loads).
|
|
12
12
|
//
|
|
13
13
|
// `profile` on __PERFLAB_ACTIVATION__ picks the React renderer in a
|
|
14
|
-
//
|
|
15
|
-
// activation's `profile` in a dormant build,
|
|
14
|
+
// KEEPSNAPPY_REACT_PROFILING=switch bundle (js/renderer-switch.js): the
|
|
15
|
+
// activation's `profile` in a dormant build, EXPO_PUBLIC_KEEPSNAPPY_PROFILE otherwise.
|
|
16
16
|
(function (g) {
|
|
17
17
|
if (g.__PERFLAB_HOOK__ || g.__PERFLAB_ACTIVATION__) {
|
|
18
18
|
return;
|
|
@@ -29,13 +29,13 @@
|
|
|
29
29
|
}
|
|
30
30
|
};
|
|
31
31
|
var modeEnv = env(function () {
|
|
32
|
-
return (process.env.EXPO_PUBLIC_KEEPSNAPPY_MODE
|
|
32
|
+
return (process.env.EXPO_PUBLIC_KEEPSNAPPY_MODE);
|
|
33
33
|
});
|
|
34
34
|
var autoEnv = env(function () {
|
|
35
|
-
return (process.env.EXPO_PUBLIC_KEEPSNAPPY_AUTO
|
|
35
|
+
return (process.env.EXPO_PUBLIC_KEEPSNAPPY_AUTO);
|
|
36
36
|
});
|
|
37
37
|
var profileEnv = env(function () {
|
|
38
|
-
return (process.env.EXPO_PUBLIC_KEEPSNAPPY_PROFILE
|
|
38
|
+
return (process.env.EXPO_PUBLIC_KEEPSNAPPY_PROFILE);
|
|
39
39
|
});
|
|
40
40
|
var MODE =
|
|
41
41
|
modeEnv === 'dormant' || modeEnv === 'auto'
|
package/js/renderer-switch.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
// React Native's production renderer in a
|
|
1
|
+
// React Native's production renderer in a KEEPSNAPPY_REACT_PROFILING=switch bundle.
|
|
2
2
|
// Both renderers are in the bundle; this module picks one when React Native
|
|
3
3
|
// first requires it, from what hook.polyfill.js (or the boot module) read out
|
|
4
|
-
// of the activation record before React loaded.
|
|
4
|
+
// of the activation record before React loaded. withKeepSnappy (metro.js)
|
|
5
5
|
// resolves the two module names below to RN's own implementation files.
|
|
6
6
|
'use strict';
|
|
7
7
|
|
package/js/sdk/activation.ts
CHANGED
|
@@ -2,17 +2,17 @@
|
|
|
2
2
|
// not, so it stays small and imports nothing: no React Native, no core.
|
|
3
3
|
//
|
|
4
4
|
// Modes (bundle time):
|
|
5
|
-
// auto - measuring from the first frame (
|
|
5
|
+
// auto - measuring from the first frame (EXPO_PUBLIC_KEEPSNAPPY_MODE=auto or KEEPSNAPPY_AUTO=1)
|
|
6
6
|
// manual - markers only until a settings link turns collection on (no mode set)
|
|
7
7
|
// dormant - nothing installed until an activation link; it applies from the NEXT launch
|
|
8
8
|
//
|
|
9
9
|
// The activation record lives in the app sandbox (`perf-lab/activation.json`,
|
|
10
10
|
// written by the native module). hook.polyfill.js reads it once, synchronously,
|
|
11
11
|
// before React loads, and leaves the raw value in __PERFLAB_ACTIVATION__.
|
|
12
|
-
// Its `profile` field picks the React renderer in a
|
|
12
|
+
// Its `profile` field picks the React renderer in a KEEPSNAPPY_REACT_PROFILING=switch
|
|
13
13
|
// bundle (js/renderer-switch.js), so a process is wholly one renderer.
|
|
14
14
|
|
|
15
|
-
export const PERF_LAB_ENABLED = (process.env.EXPO_PUBLIC_KEEPSNAPPY
|
|
15
|
+
export const PERF_LAB_ENABLED = (process.env.EXPO_PUBLIC_KEEPSNAPPY) === '1';
|
|
16
16
|
|
|
17
17
|
export const PERF_LAB_DEEP_LINK_PATH = 'devtools/perf-lab';
|
|
18
18
|
|
|
@@ -29,8 +29,8 @@ export const resolveMode = (
|
|
|
29
29
|
};
|
|
30
30
|
|
|
31
31
|
export const MODE: PerfLabMode = resolveMode(
|
|
32
|
-
(process.env.EXPO_PUBLIC_KEEPSNAPPY_MODE
|
|
33
|
-
(process.env.EXPO_PUBLIC_KEEPSNAPPY_AUTO
|
|
32
|
+
(process.env.EXPO_PUBLIC_KEEPSNAPPY_MODE),
|
|
33
|
+
(process.env.EXPO_PUBLIC_KEEPSNAPPY_AUTO),
|
|
34
34
|
);
|
|
35
35
|
|
|
36
36
|
export const DEFAULT_TTL_S = 7200;
|
package/js/sdk/boot.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// perf-lab SDK entry.
|
|
1
|
+
// perf-lab SDK entry. withKeepSnappy (metro.js) adds this module to the graph and
|
|
2
2
|
// runs it after InitializeCore, before the app's entry module. The React hook
|
|
3
3
|
// itself was installed earlier by hook.polyfill.js (unless dormant).
|
|
4
4
|
//
|
package/js/sdk/core.ts
CHANGED
|
@@ -275,15 +275,15 @@ const defaultSettings = (): Settings => ({
|
|
|
275
275
|
log: AUTO ? 'both' : 'console',
|
|
276
276
|
faults: { ...NO_FAULTS },
|
|
277
277
|
faultTarget: DEFAULT_FAULT_TARGET,
|
|
278
|
-
profile: (process.env.EXPO_PUBLIC_KEEPSNAPPY_PROFILE
|
|
279
|
-
rexport: (process.env.EXPO_PUBLIC_KEEPSNAPPY_REACT_EXPORT
|
|
280
|
-
cpuprof: (process.env.EXPO_PUBLIC_KEEPSNAPPY_CPUPROF
|
|
281
|
-
cpuhz: Number((process.env.EXPO_PUBLIC_KEEPSNAPPY_CPUPROF_HZ
|
|
278
|
+
profile: (process.env.EXPO_PUBLIC_KEEPSNAPPY_PROFILE) === '1',
|
|
279
|
+
rexport: (process.env.EXPO_PUBLIC_KEEPSNAPPY_REACT_EXPORT) === '1',
|
|
280
|
+
cpuprof: (process.env.EXPO_PUBLIC_KEEPSNAPPY_CPUPROF) === '1',
|
|
281
|
+
cpuhz: Number((process.env.EXPO_PUBLIC_KEEPSNAPPY_CPUPROF_HZ)) || 250,
|
|
282
282
|
diag: false,
|
|
283
283
|
...samplerDefaults({
|
|
284
284
|
auto: AUTO,
|
|
285
|
-
sampler: (process.env.EXPO_PUBLIC_KEEPSNAPPY_SAMPLER
|
|
286
|
-
samplerMs: (process.env.EXPO_PUBLIC_KEEPSNAPPY_SAMPLER_MS
|
|
285
|
+
sampler: (process.env.EXPO_PUBLIC_KEEPSNAPPY_SAMPLER),
|
|
286
|
+
samplerMs: (process.env.EXPO_PUBLIC_KEEPSNAPPY_SAMPLER_MS),
|
|
287
287
|
}),
|
|
288
288
|
});
|
|
289
289
|
|
|
@@ -1279,7 +1279,7 @@ const onCommitFiberUnmount = (_rendererId: number, fiber: Fiber) => {
|
|
|
1279
1279
|
export const lastRoot = (rendererId = 1): FiberRoot | null =>
|
|
1280
1280
|
g.__PERFLAB_HOOK__?.state.lastRootByRenderer[rendererId] ?? null;
|
|
1281
1281
|
|
|
1282
|
-
// The polyfill (
|
|
1282
|
+
// The polyfill (withKeepSnappy) installed the hook before React loaded; attach to
|
|
1283
1283
|
// it. Without the polyfill, fall back to installing it now, as the prototype did.
|
|
1284
1284
|
export const attachHook = () => {
|
|
1285
1285
|
if (!PERF_LAB_ENABLED || hookState.installed) {
|
package/js/sdk/push-install.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Wires the push client to React Native: env config, device info, AppState.
|
|
2
|
-
// Push stays off unless both
|
|
3
|
-
//
|
|
2
|
+
// Push stays off unless both EXPO_PUBLIC_KEEPSNAPPY_INGEST_URL and
|
|
3
|
+
// EXPO_PUBLIC_KEEPSNAPPY_KEY are set at build time.
|
|
4
4
|
|
|
5
5
|
import { AppState, Platform } from 'react-native';
|
|
6
6
|
|
|
@@ -18,8 +18,8 @@ import {
|
|
|
18
18
|
import { ownFetch } from './net-install';
|
|
19
19
|
import { createPushClient, type DeviceInfo, type PushSpool } from './push';
|
|
20
20
|
|
|
21
|
-
const INGEST_URL = (process.env.EXPO_PUBLIC_KEEPSNAPPY_INGEST_URL
|
|
22
|
-
const INGEST_KEY = (process.env.EXPO_PUBLIC_KEEPSNAPPY_KEY
|
|
21
|
+
const INGEST_URL = (process.env.EXPO_PUBLIC_KEEPSNAPPY_INGEST_URL);
|
|
22
|
+
const INGEST_KEY = (process.env.EXPO_PUBLIC_KEEPSNAPPY_KEY);
|
|
23
23
|
|
|
24
24
|
const randomId = () =>
|
|
25
25
|
`r${Date.now().toString(36)}${Math.random().toString(36).slice(2, 10)}`;
|
package/js/zustand-vanilla.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// zustand/vanilla in a PerfLab bundle.
|
|
1
|
+
// zustand/vanilla in a PerfLab bundle. withKeepSnappy (metro.js) resolves every
|
|
2
2
|
// `zustand/vanilla` request to this module (zustand 5's index, react and
|
|
3
3
|
// traditional entries all load it by that name), and the name below to the real
|
|
4
4
|
// one. Each store's setState goes through the cause tracker's store writer
|
package/metro.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
//
|
|
1
|
+
// withKeepSnappy(metroConfig): the only line an app adds to metro.config.js.
|
|
2
2
|
//
|
|
3
|
-
// With
|
|
3
|
+
// With EXPO_PUBLIC_KEEPSNAPPY=1 it
|
|
4
4
|
// 1. appends the React DevTools hook as a Metro polyfill, so the hook exists
|
|
5
5
|
// before any module (React included) evaluates;
|
|
6
6
|
// 2. wraps the Babel transformer so the app's entry module imports the SDK boot
|
|
@@ -11,12 +11,12 @@
|
|
|
11
11
|
// zustand store's setState through the cause tracker (REQ-MEAS-32 timers).
|
|
12
12
|
// Without the flag it returns the config object untouched.
|
|
13
13
|
//
|
|
14
|
-
//
|
|
14
|
+
// KEEPSNAPPY_REACT_PROFILING=1 (independent of the flag) resolves React Native's
|
|
15
15
|
// production renderer to its profiling build (fiber actualDuration /
|
|
16
16
|
// selfBaseDuration, root.memoizedUpdaters), the same rewrite as
|
|
17
17
|
// @callstack/inspector's withInspector. Nothing else in the bundle changes.
|
|
18
18
|
//
|
|
19
|
-
//
|
|
19
|
+
// KEEPSNAPPY_REACT_PROFILING=switch (flag on only) bundles both Fabric renderers
|
|
20
20
|
// behind js/renderer-switch.js, which loads the profiling one only in a process
|
|
21
21
|
// whose activation asked for it (plan 40 §2.1). Ignored with the flag off.
|
|
22
22
|
|
|
@@ -31,13 +31,13 @@ const ENV_UPSTREAM = 'KEEPSNAPPY_UPSTREAM_BABEL_TRANSFORMER';
|
|
|
31
31
|
const ENV_ENTRY = 'KEEPSNAPPY_ENTRY_FILE';
|
|
32
32
|
const ENV_BOOT = 'KEEPSNAPPY_BOOT_FILE';
|
|
33
33
|
|
|
34
|
-
const isEnabled = () => (process.env.EXPO_PUBLIC_KEEPSNAPPY
|
|
35
|
-
const isProfiling = () => (process.env.KEEPSNAPPY_REACT_PROFILING
|
|
36
|
-
const isSwitch = () => (process.env.KEEPSNAPPY_REACT_PROFILING
|
|
34
|
+
const isEnabled = () => (process.env.EXPO_PUBLIC_KEEPSNAPPY) === '1';
|
|
35
|
+
const isProfiling = () => (process.env.KEEPSNAPPY_REACT_PROFILING) === '1';
|
|
36
|
+
const isSwitch = () => (process.env.KEEPSNAPPY_REACT_PROFILING) === 'switch';
|
|
37
37
|
|
|
38
38
|
const SWITCH_PATH = path.join(__dirname, 'js', 'renderer-switch.js');
|
|
39
39
|
// The names renderer-switch.js requires; they resolve next to RN's shim.
|
|
40
|
-
const SDK_NAMES = ['@keepsnappy/react-native'
|
|
40
|
+
const SDK_NAMES = ['@keepsnappy/react-native'];
|
|
41
41
|
const SWITCH_TARGET_PREFIXES = SDK_NAMES.map(name => `${name}/renderer/`);
|
|
42
42
|
const FABRIC_RENDERERS = new Set([
|
|
43
43
|
'../implementations/ReactFabric-prod',
|
|
@@ -175,7 +175,7 @@ const resolveEntry = projectRoot => {
|
|
|
175
175
|
return null;
|
|
176
176
|
};
|
|
177
177
|
|
|
178
|
-
function
|
|
178
|
+
function withKeepSnappy(input) {
|
|
179
179
|
if (!isEnabled()) {
|
|
180
180
|
return isProfiling() ? withReactProfiling(input) : input;
|
|
181
181
|
}
|
|
@@ -225,8 +225,7 @@ function withPerfLab(input) {
|
|
|
225
225
|
}
|
|
226
226
|
|
|
227
227
|
module.exports = {
|
|
228
|
-
|
|
229
|
-
withKeepSnappy: withPerfLab,
|
|
228
|
+
withKeepSnappy,
|
|
230
229
|
withReactProfiling,
|
|
231
230
|
withRendererSwitch,
|
|
232
231
|
withStoreWrap,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@keepsnappy/react-native",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.12",
|
|
4
4
|
"description": "KeepSnappy in-app SDK for React Native / Expo: zero-code measurement windows, React commit hook, native signposts and log file",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"repository": {
|