@chipmobilesdk/rn-core 0.0.0 → 0.2.0
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/CHANGELOG.md +115 -0
- package/lib/commonjs/diagnostics/index.js +81 -0
- package/lib/commonjs/diagnostics/index.js.map +1 -0
- package/lib/commonjs/errors/index.js +86 -0
- package/lib/commonjs/errors/index.js.map +1 -0
- package/lib/commonjs/index.js +305 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/intl/index.js +98 -0
- package/lib/commonjs/intl/index.js.map +1 -0
- package/lib/commonjs/kv/index.js +83 -0
- package/lib/commonjs/kv/index.js.map +1 -0
- package/lib/commonjs/lazy/index.js +63 -0
- package/lib/commonjs/lazy/index.js.map +1 -0
- package/lib/commonjs/listeners/index.js +110 -0
- package/lib/commonjs/listeners/index.js.map +1 -0
- package/lib/commonjs/messages/index.js +53 -0
- package/lib/commonjs/messages/index.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/react/index.js +93 -0
- package/lib/commonjs/react/index.js.map +1 -0
- package/lib/commonjs/redact/index.js +128 -0
- package/lib/commonjs/redact/index.js.map +1 -0
- package/lib/commonjs/runtime/index.js +77 -0
- package/lib/commonjs/runtime/index.js.map +1 -0
- package/lib/commonjs/runtime/lifecycle.js +105 -0
- package/lib/commonjs/runtime/lifecycle.js.map +1 -0
- package/lib/commonjs/scheduler/index.js +216 -0
- package/lib/commonjs/scheduler/index.js.map +1 -0
- package/lib/commonjs/store/index.js +39 -0
- package/lib/commonjs/store/index.js.map +1 -0
- package/lib/commonjs/testing/conformance.js +79 -0
- package/lib/commonjs/testing/conformance.js.map +1 -0
- package/lib/commonjs/testing/index.js +58 -0
- package/lib/commonjs/testing/index.js.map +1 -0
- package/lib/commonjs/testing/lifecycle.js +37 -0
- package/lib/commonjs/testing/lifecycle.js.map +1 -0
- package/lib/commonjs/testing/redaction.js +118 -0
- package/lib/commonjs/testing/redaction.js.map +1 -0
- package/lib/commonjs/testing/scheduler.js +51 -0
- package/lib/commonjs/testing/scheduler.js.map +1 -0
- package/lib/module/diagnostics/index.js +75 -0
- package/lib/module/diagnostics/index.js.map +1 -0
- package/lib/module/errors/index.js +78 -0
- package/lib/module/errors/index.js.map +1 -0
- package/lib/module/index.js +24 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/intl/index.js +91 -0
- package/lib/module/intl/index.js.map +1 -0
- package/lib/module/kv/index.js +76 -0
- package/lib/module/kv/index.js.map +1 -0
- package/lib/module/lazy/index.js +59 -0
- package/lib/module/lazy/index.js.map +1 -0
- package/lib/module/listeners/index.js +104 -0
- package/lib/module/listeners/index.js.map +1 -0
- package/lib/module/messages/index.js +48 -0
- package/lib/module/messages/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/react/index.js +86 -0
- package/lib/module/react/index.js.map +1 -0
- package/lib/module/redact/index.js +118 -0
- package/lib/module/redact/index.js.map +1 -0
- package/lib/module/runtime/index.js +52 -0
- package/lib/module/runtime/index.js.map +1 -0
- package/lib/module/runtime/lifecycle.js +99 -0
- package/lib/module/runtime/lifecycle.js.map +1 -0
- package/lib/module/scheduler/index.js +203 -0
- package/lib/module/scheduler/index.js.map +1 -0
- package/lib/module/store/index.js +33 -0
- package/lib/module/store/index.js.map +1 -0
- package/lib/module/testing/conformance.js +72 -0
- package/lib/module/testing/conformance.js.map +1 -0
- package/lib/module/testing/index.js +12 -0
- package/lib/module/testing/index.js.map +1 -0
- package/lib/module/testing/lifecycle.js +32 -0
- package/lib/module/testing/lifecycle.js.map +1 -0
- package/lib/module/testing/redaction.js +113 -0
- package/lib/module/testing/redaction.js.map +1 -0
- package/lib/module/testing/scheduler.js +47 -0
- package/lib/module/testing/scheduler.js.map +1 -0
- package/lib/typescript/commonjs/diagnostics/index.d.ts +49 -0
- package/lib/typescript/commonjs/diagnostics/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/errors/index.d.ts +59 -0
- package/lib/typescript/commonjs/errors/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/index.d.ts +22 -0
- package/lib/typescript/commonjs/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/intl/index.d.ts +25 -0
- package/lib/typescript/commonjs/intl/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/kv/index.d.ts +38 -0
- package/lib/typescript/commonjs/kv/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/lazy/index.d.ts +36 -0
- package/lib/typescript/commonjs/lazy/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/listeners/index.d.ts +61 -0
- package/lib/typescript/commonjs/listeners/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/messages/index.d.ts +39 -0
- package/lib/typescript/commonjs/messages/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/react/index.d.ts +38 -0
- package/lib/typescript/commonjs/react/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/redact/index.d.ts +47 -0
- package/lib/typescript/commonjs/redact/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/runtime/index.d.ts +21 -0
- package/lib/typescript/commonjs/runtime/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/runtime/lifecycle.d.ts +34 -0
- package/lib/typescript/commonjs/runtime/lifecycle.d.ts.map +1 -0
- package/lib/typescript/commonjs/scheduler/index.d.ts +108 -0
- package/lib/typescript/commonjs/scheduler/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/store/index.d.ts +18 -0
- package/lib/typescript/commonjs/store/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/testing/conformance.d.ts +35 -0
- package/lib/typescript/commonjs/testing/conformance.d.ts.map +1 -0
- package/lib/typescript/commonjs/testing/index.d.ts +10 -0
- package/lib/typescript/commonjs/testing/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/testing/lifecycle.d.ts +15 -0
- package/lib/typescript/commonjs/testing/lifecycle.d.ts.map +1 -0
- package/lib/typescript/commonjs/testing/redaction.d.ts +35 -0
- package/lib/typescript/commonjs/testing/redaction.d.ts.map +1 -0
- package/lib/typescript/commonjs/testing/scheduler.d.ts +15 -0
- package/lib/typescript/commonjs/testing/scheduler.d.ts.map +1 -0
- package/lib/typescript/module/diagnostics/index.d.ts +49 -0
- package/lib/typescript/module/diagnostics/index.d.ts.map +1 -0
- package/lib/typescript/module/errors/index.d.ts +59 -0
- package/lib/typescript/module/errors/index.d.ts.map +1 -0
- package/lib/typescript/module/index.d.ts +22 -0
- package/lib/typescript/module/index.d.ts.map +1 -0
- package/lib/typescript/module/intl/index.d.ts +25 -0
- package/lib/typescript/module/intl/index.d.ts.map +1 -0
- package/lib/typescript/module/kv/index.d.ts +38 -0
- package/lib/typescript/module/kv/index.d.ts.map +1 -0
- package/lib/typescript/module/lazy/index.d.ts +36 -0
- package/lib/typescript/module/lazy/index.d.ts.map +1 -0
- package/lib/typescript/module/listeners/index.d.ts +61 -0
- package/lib/typescript/module/listeners/index.d.ts.map +1 -0
- package/lib/typescript/module/messages/index.d.ts +39 -0
- package/lib/typescript/module/messages/index.d.ts.map +1 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/react/index.d.ts +38 -0
- package/lib/typescript/module/react/index.d.ts.map +1 -0
- package/lib/typescript/module/redact/index.d.ts +47 -0
- package/lib/typescript/module/redact/index.d.ts.map +1 -0
- package/lib/typescript/module/runtime/index.d.ts +21 -0
- package/lib/typescript/module/runtime/index.d.ts.map +1 -0
- package/lib/typescript/module/runtime/lifecycle.d.ts +34 -0
- package/lib/typescript/module/runtime/lifecycle.d.ts.map +1 -0
- package/lib/typescript/module/scheduler/index.d.ts +108 -0
- package/lib/typescript/module/scheduler/index.d.ts.map +1 -0
- package/lib/typescript/module/store/index.d.ts +18 -0
- package/lib/typescript/module/store/index.d.ts.map +1 -0
- package/lib/typescript/module/testing/conformance.d.ts +35 -0
- package/lib/typescript/module/testing/conformance.d.ts.map +1 -0
- package/lib/typescript/module/testing/index.d.ts +10 -0
- package/lib/typescript/module/testing/index.d.ts.map +1 -0
- package/lib/typescript/module/testing/lifecycle.d.ts +15 -0
- package/lib/typescript/module/testing/lifecycle.d.ts.map +1 -0
- package/lib/typescript/module/testing/redaction.d.ts +35 -0
- package/lib/typescript/module/testing/redaction.d.ts.map +1 -0
- package/lib/typescript/module/testing/scheduler.d.ts +15 -0
- package/lib/typescript/module/testing/scheduler.d.ts.map +1 -0
- package/package.json +154 -46
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_index","require","REDACTED","exports","COMMON_PATTERNS","Object","freeze","PATH_PATTERN","IDENTIFIER_TOKEN","redactPatterns","text","patterns","reduce","out","pattern","replace","leadingIdentifier","token","exec","split","trim","describeShape","value","undefined","length","Array","isArray","keys","pickAllowed","detail","allow","safe","key","entries","has","createRedactor","policy","mode","dropKeys","Set","allowDetailKeys","shapeKeys","textDepth","maxDepth","contextDepth","string","depth","String","isSdkError","code","Error","name","message","map","item","join","entry","walk","inner","context"],"sourceRoot":"../../../src","sources":["redact/index.ts"],"mappings":";;;;;;;;;;;AAmBA,IAAAA,MAAA,GAAAC,OAAA;AAnBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGO,MAAMC,QAAQ,GAAAC,OAAA,CAAAD,QAAA,GAAG,YAAY;;AAEpC;AACA;AACA;AACA;AACO,MAAME,eAAkC,GAAAD,OAAA,CAAAC,eAAA,GAAGC,MAAM,CAACC,MAAM,CAAC,CAC/D;AACA,yCAAyC,EACzC;AACA,0DAA0D,EAC1D;AACA,iDAAiD,EACjD;AACA,8EAA8E,EAC9E;AACA,wBAAwB,CACxB,CAAC;;AAEF;AACO,MAAMC,YAAY,GAAAJ,OAAA,CAAAI,YAAA,GAAG,sDAAsD;AAElF,MAAMC,gBAAgB,GAAG,yBAAyB;;AAElD;AACO,SAASC,cAAcA,CAC7BC,IAAY,EACZC,QAA2B,GAAGP,eAAe,EACpC;EACT,O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,KAAK,CAACC,OAAO,CAACJ,KAAK,CAAC,EAAE,OAAOA,KAAK,CAAC+B,GAAG,CAACC,IAAI,IAAIG,IAAI,CAACH,IAAI,EAAER,KAAK,GAAG,CAAC,CAAC,CAAC;IACzE,MAAMjC,GAA4B,GAAG,CAAC,CAAC;IACvC,KAAK,MAAM,CAACmB,GAAG,EAAE0B,KAAK,CAAC,IAAIrD,MAAM,CAAC4B,OAAO,CAACX,KAAgC,CAAC,EAAE;MAC5ET,GAAG,CAACmB,GAAG,CAAC,GAAGS,SAAS,CAACP,GAAG,CAACF,GAAG,CAAC,GAC1BX,aAAa,CAACqC,KAAK,CAAC,GACpBpB,QAAQ,CAACJ,GAAG,CAACF,GAAG,CAAC,GAChB9B,QAAQ,GACRuD,IAAI,CAACC,KAAK,EAAEZ,KAAK,GAAG,CAAC,CAAC;IAC3B;IACA,OAAOjC,GAAG;EACX;EAEA,OAAO;IACNH,IAAI,EAAEY,KAAK,IAAIZ,IAAI,CAACY,KAAK,CAAC;IAC1BO,MAAM,EAAEA,MAAM,IAAID,WAAW,CAACC,MAAM,EAAEC,KAAK,CAAC;IAC5C6B,OAAO,EAAEA,OAAO,IACfA,OAAO,KAAKpC,SAAS,GAAGA,SAAS,GAAIkC,IAAI,CAACE,OAAO,EAAE,CAAC;EACtD,CAAC;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "appLifecycle", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _lifecycle.appLifecycle;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
exports.byPlatform = byPlatform;
|
|
13
|
+
Object.defineProperty(exports, "createAppLifecycle", {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function () {
|
|
16
|
+
return _lifecycle.createAppLifecycle;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
exports.currentPlatform = currentPlatform;
|
|
20
|
+
exports.isDevBuild = isDevBuild;
|
|
21
|
+
Object.defineProperty(exports, "onForeground", {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () {
|
|
24
|
+
return _lifecycle.onForeground;
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
exports.setPlatformOverride = setPlatformOverride;
|
|
28
|
+
var _index = require("../lazy/index.js");
|
|
29
|
+
var _lifecycle = require("./lifecycle.js");
|
|
30
|
+
/**
|
|
31
|
+
* Where the code is running (CORE-09, IOS-11).
|
|
32
|
+
*
|
|
33
|
+
* Five packages detected the platform five ways, with contradicting fallbacks
|
|
34
|
+
* (rn-payment assumed Android, rn-auth assumed iOS). One source now: it reads
|
|
35
|
+
* React Native's `Platform` lazily, so this module also loads under plain Node,
|
|
36
|
+
* where it reports `unsupported`.
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
/** What a build is for. A package may refuse production configuration elsewhere. */
|
|
40
|
+
|
|
41
|
+
const reactNative = (0, _index.lazyPeer)('react-native', () => require('react-native'));
|
|
42
|
+
let platformOverride;
|
|
43
|
+
|
|
44
|
+
/** The OS the app runs on, or `unsupported` (web, Node, a platform with no adapter). */
|
|
45
|
+
function currentPlatform() {
|
|
46
|
+
if (platformOverride) return platformOverride;
|
|
47
|
+
const result = reactNative.get();
|
|
48
|
+
const os = result.ok ? result.module.Platform?.OS : undefined;
|
|
49
|
+
return os === 'android' || os === 'ios' ? os : 'unsupported';
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** Test seam: pins `currentPlatform()`; `undefined` goes back to the real one. */
|
|
53
|
+
function setPlatformOverride(platform) {
|
|
54
|
+
platformOverride = platform;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** Picks a value for the current platform, falling back to `default`. */
|
|
58
|
+
function byPlatform(values) {
|
|
59
|
+
const platform = currentPlatform();
|
|
60
|
+
if (platform === 'android' && values.android !== undefined) return values.android;
|
|
61
|
+
if (platform === 'ios' && values.ios !== undefined) return values.ios;
|
|
62
|
+
return values.default;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Whether this is a development build: React Native's `__DEV__`, or, where that
|
|
67
|
+
* global does not exist (plain Node, some test runners), `NODE_ENV` not being
|
|
68
|
+
* `production`.
|
|
69
|
+
*/
|
|
70
|
+
function isDevBuild() {
|
|
71
|
+
if (typeof __DEV__ !== 'undefined') return __DEV__ === true;
|
|
72
|
+
const {
|
|
73
|
+
process
|
|
74
|
+
} = globalThis;
|
|
75
|
+
return process?.env?.NODE_ENV !== 'production';
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_index","require","_lifecycle","reactNative","lazyPeer","platformOverride","currentPlatform","result","get","os","ok","module","Platform","OS","undefined","setPlatformOverride","platform","byPlatform","values","android","ios","default","isDevBuild","__DEV__","process","globalThis","env","NODE_ENV"],"sourceRoot":"../../../src","sources":["runtime/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA,IAAAA,MAAA,GAAAC,OAAA;AAsDA,IAAAC,UAAA,GAAAD,OAAA;AA9DA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAKA;;AAOA,MAAME,WAAW,GAAG,IAAAC,eAAQ,EAC3B,cAAc,EACd,MAAMH,OAAO,CAAC,cAAc,CAC7B,CAAC;AAED,IAAII,gBAA6C;;AAEjD;AACO,SAASC,eAAeA,CAAA,EAAoB;EAClD,IAAID,gBAAgB,EAAE,OAAOA,gBAAgB;EAC7C,MAAME,MAAM,GAAGJ,WAAW,CAACK,GAAG,CAAC,CAAC;EAChC,MAAMC,EAAE,GAAGF,MAAM,CAACG,EAAE,GAAGH,MAAM,CAACI,MAAM,CAACC,QAAQ,EAAEC,EAAE,GAAGC,SAAS;EAC7D,OAAOL,EAAE,KAAK,SAAS,IAAIA,EAAE,KAAK,KAAK,GAAGA,EAAE,GAAG,aAAa;AAC7D;;AAEA;AACO,SAASM,mBAAmBA,CAACC,QAAqC,EAAQ;EAChFX,gBAAgB,GAAGW,QAAQ;AAC5B;;AAEA;AACO,SAASC,UAAUA,CAAIC,MAI7B,EAAK;EACL,MAAMF,QAAQ,GAAGV,eAAe,CAAC,CAAC;EAClC,IAAIU,QAAQ,KAAK,SAAS,IAAIE,MAAM,CAACC,OAAO,KAAKL,SAAS,EAAE,OAAOI,MAAM,CAACC,OAAO;EACjF,IAAIH,QAAQ,KAAK,KAAK,IAAIE,MAAM,CAACE,GAAG,KAAKN,SAAS,EAAE,OAAOI,MAAM,CAACE,GAAG;EACrE,OAAOF,MAAM,CAACG,OAAO;AACtB;;AAEA;AACA;AACA;AACA;AACA;AACO,SAASC,UAAUA,CAAA,EAAY;EACrC,IAAI,OAAOC,OAAO,KAAK,WAAW,EAAE,OAAOA,OAAO,KAAK,IAAI;EAC3D,MAAM;IAAEC;EAAQ,CAAC,GAAGC,UAAwE;EAC5F,OAAOD,OAAO,EAAEE,GAAG,EAAEC,QAAQ,KAAK,YAAY;AAC/C","ignoreList":[]}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.appLifecycle = appLifecycle;
|
|
7
|
+
exports.createAppLifecycle = createAppLifecycle;
|
|
8
|
+
exports.onForeground = onForeground;
|
|
9
|
+
var _index = require("../lazy/index.js");
|
|
10
|
+
var _index2 = require("../listeners/index.js");
|
|
11
|
+
/**
|
|
12
|
+
* The app's lifecycle as one port (PERF-07, CORE-14).
|
|
13
|
+
*
|
|
14
|
+
* rn-camera, rn-payment, rn-ads and rn-notification each subscribed to React
|
|
15
|
+
* Native's `AppState` on their own, with their own idea of what `inactive` means.
|
|
16
|
+
* `appLifecycle()` is one shared, reference-counted subscription: the native
|
|
17
|
+
* listener exists only while somebody listens, and every package sees the same
|
|
18
|
+
* transitions in the same order.
|
|
19
|
+
*
|
|
20
|
+
* `react-native` is required on first subscribe, never at import, so this module
|
|
21
|
+
* loads under plain Node too, where the app counts as always `active`.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
/** The slice of React Native's `AppState` the port reads. */
|
|
25
|
+
|
|
26
|
+
const reactNative = (0, _index.lazyPeer)('react-native', () => require('react-native'));
|
|
27
|
+
function defaultSource() {
|
|
28
|
+
const result = reactNative.get();
|
|
29
|
+
return result.ok ? result.module.AppState : undefined;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* `unknown` (iOS before the first report) and anything newer than this SDK count
|
|
34
|
+
* as `active`: an app that is running code it cannot place is most likely in front.
|
|
35
|
+
*/
|
|
36
|
+
function normalize(raw) {
|
|
37
|
+
return raw === 'background' || raw === 'inactive' ? raw : 'active';
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* A lifecycle port over `source`, React Native's `AppState` by default. Packages use
|
|
42
|
+
* the shared `appLifecycle()`; this is for tests and for an app with its own source.
|
|
43
|
+
*/
|
|
44
|
+
function createAppLifecycle(source = defaultSource) {
|
|
45
|
+
const listeners = (0, _index2.createListenerSet)();
|
|
46
|
+
let subscription;
|
|
47
|
+
let last = 'active';
|
|
48
|
+
const read = () => normalize(source()?.currentState);
|
|
49
|
+
return {
|
|
50
|
+
current() {
|
|
51
|
+
return subscription ? last : read();
|
|
52
|
+
},
|
|
53
|
+
subscribe(listener) {
|
|
54
|
+
const remove = listeners.add(listener);
|
|
55
|
+
if (!subscription) {
|
|
56
|
+
const appState = source();
|
|
57
|
+
last = normalize(appState?.currentState);
|
|
58
|
+
subscription = appState?.addEventListener('change', raw => {
|
|
59
|
+
const next = normalize(raw);
|
|
60
|
+
if (next === last) return;
|
|
61
|
+
const previous = last;
|
|
62
|
+
last = next;
|
|
63
|
+
listeners.notify(next, previous);
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
let attached = true;
|
|
67
|
+
return () => {
|
|
68
|
+
if (!attached) return;
|
|
69
|
+
attached = false;
|
|
70
|
+
remove();
|
|
71
|
+
if (listeners.size === 0 && subscription) {
|
|
72
|
+
subscription.remove();
|
|
73
|
+
subscription = undefined;
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
},
|
|
77
|
+
get listenerCount() {
|
|
78
|
+
return listeners.size;
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
let shared;
|
|
83
|
+
|
|
84
|
+
/** The app's lifecycle, shared by every package so there is one native subscription. */
|
|
85
|
+
function appLifecycle() {
|
|
86
|
+
shared ??= createAppLifecycle();
|
|
87
|
+
return shared;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Calls `listener` each time the app comes back from the background. A trip through
|
|
92
|
+
* `inactive` alone (iOS Control Center, an incoming-call banner) is not a return.
|
|
93
|
+
*/
|
|
94
|
+
function onForeground(listener, port = appLifecycle()) {
|
|
95
|
+
let away = port.current() === 'background';
|
|
96
|
+
return port.subscribe(state => {
|
|
97
|
+
if (state === 'background') {
|
|
98
|
+
away = true;
|
|
99
|
+
} else if (state === 'active' && away) {
|
|
100
|
+
away = false;
|
|
101
|
+
listener();
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=lifecycle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_index","require","_index2","reactNative","lazyPeer","defaultSource","result","get","ok","module","AppState","undefined","normalize","raw","createAppLifecycle","source","listeners","createListenerSet","subscription","last","read","currentState","current","subscribe","listener","remove","add","appState","addEventListener","next","previous","notify","attached","size","listenerCount","shared","appLifecycle","onForeground","port","away","state"],"sourceRoot":"../../../src","sources":["runtime/lifecycle.ts"],"mappings":";;;;;;;;AAYA,IAAAA,MAAA,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3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.checkInteger = checkInteger;
|
|
7
|
+
exports.checkRange = checkRange;
|
|
8
|
+
exports.computeBackoff = computeBackoff;
|
|
9
|
+
exports.createExclusive = createExclusive;
|
|
10
|
+
exports.createRateLimiter = createRateLimiter;
|
|
11
|
+
exports.createSingleFlight = createSingleFlight;
|
|
12
|
+
exports.createTimerSet = createTimerSet;
|
|
13
|
+
exports.realScheduler = void 0;
|
|
14
|
+
exports.runWithRetry = runWithRetry;
|
|
15
|
+
exports.withTimeout = withTimeout;
|
|
16
|
+
var _index = require("../listeners/index.js");
|
|
17
|
+
/**
|
|
18
|
+
* Time, retries, concurrency and bounds, shared by every package (CORE-04,
|
|
19
|
+
* CORE-05).
|
|
20
|
+
*
|
|
21
|
+
* rn-ads and rn-payment each had their own copy of these, and the copies had
|
|
22
|
+
* drifted: one validated a backoff and the other did not, one reported a retry
|
|
23
|
+
* policy out of bounds under a timeout's error code. Packages keep their domain
|
|
24
|
+
* defaults and bounds; the mechanism lives here, and bounds checks take a `fail`
|
|
25
|
+
* callback so each package raises its own error with its own code.
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* How timers are scheduled. Injectable so a test drives backoff and expiry by
|
|
30
|
+
* moving a clock instead of waiting.
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
const realScheduler = exports.realScheduler = {
|
|
34
|
+
setTimeout: (callback, ms) => setTimeout(callback, ms),
|
|
35
|
+
clearTimeout: handle => clearTimeout(handle)
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Every timer an owner started, so disposing it can prove nothing is left: a
|
|
40
|
+
* leaked timer is otherwise invisible until it fires into a disposed consumer.
|
|
41
|
+
*/
|
|
42
|
+
|
|
43
|
+
function createTimerSet(scheduler = realScheduler) {
|
|
44
|
+
const handles = new Set();
|
|
45
|
+
return {
|
|
46
|
+
after(ms, callback) {
|
|
47
|
+
const handle = scheduler.setTimeout(() => {
|
|
48
|
+
handles.delete(handle);
|
|
49
|
+
callback();
|
|
50
|
+
}, ms);
|
|
51
|
+
handles.add(handle);
|
|
52
|
+
let cleared = false;
|
|
53
|
+
return () => {
|
|
54
|
+
if (cleared) return;
|
|
55
|
+
cleared = true;
|
|
56
|
+
scheduler.clearTimeout(handle);
|
|
57
|
+
handles.delete(handle);
|
|
58
|
+
};
|
|
59
|
+
},
|
|
60
|
+
clearAll() {
|
|
61
|
+
for (const handle of handles) scheduler.clearTimeout(handle);
|
|
62
|
+
handles.clear();
|
|
63
|
+
},
|
|
64
|
+
size: () => handles.size
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
/** Delay before `attempt`, 1-based: initial × factor^(attempt−1), capped, maybe jittered. */
|
|
68
|
+
function computeBackoff(attempt, spec, random = Math.random) {
|
|
69
|
+
const raw = spec.initialDelayMs * Math.pow(spec.factor ?? 2, Math.max(0, attempt - 1));
|
|
70
|
+
const capped = Math.min(raw, spec.maxDelayMs);
|
|
71
|
+
return spec.jitter === 'full' ? Math.floor(capped * random()) : capped;
|
|
72
|
+
}
|
|
73
|
+
/** Runs `attempt` now, then on the backoff schedule until it succeeds, is cancelled or runs out. */
|
|
74
|
+
function runWithRetry(options) {
|
|
75
|
+
const {
|
|
76
|
+
spec,
|
|
77
|
+
attempt,
|
|
78
|
+
onExhausted
|
|
79
|
+
} = options;
|
|
80
|
+
const scheduler = options.scheduler ?? realScheduler;
|
|
81
|
+
const random = options.random ?? Math.random;
|
|
82
|
+
let count = 0;
|
|
83
|
+
let cancelled = false;
|
|
84
|
+
let pending;
|
|
85
|
+
const run = async () => {
|
|
86
|
+
if (cancelled) return;
|
|
87
|
+
count += 1;
|
|
88
|
+
let succeeded = false;
|
|
89
|
+
try {
|
|
90
|
+
succeeded = await attempt(count);
|
|
91
|
+
} catch {
|
|
92
|
+
// A throwing attempt is a failed attempt; letting it escape would
|
|
93
|
+
// abandon the schedule.
|
|
94
|
+
succeeded = false;
|
|
95
|
+
}
|
|
96
|
+
if (cancelled || succeeded) return;
|
|
97
|
+
if (count >= spec.maxAttempts) {
|
|
98
|
+
onExhausted?.(count);
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
pending = scheduler.setTimeout(() => {
|
|
102
|
+
pending = undefined;
|
|
103
|
+
start();
|
|
104
|
+
}, computeBackoff(count + 1, spec, random));
|
|
105
|
+
};
|
|
106
|
+
// Only `onExhausted` can throw past `run`; that is reported, not swallowed.
|
|
107
|
+
const start = () => {
|
|
108
|
+
run().catch(_index.reportAsynchronously);
|
|
109
|
+
};
|
|
110
|
+
start();
|
|
111
|
+
return {
|
|
112
|
+
cancel() {
|
|
113
|
+
cancelled = true;
|
|
114
|
+
if (pending !== undefined) {
|
|
115
|
+
scheduler.clearTimeout(pending);
|
|
116
|
+
pending = undefined;
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
attempts: () => count,
|
|
120
|
+
exhausted: () => count >= spec.maxAttempts
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Joins concurrent callers onto one in-flight operation. Once it settles the
|
|
126
|
+
* slot clears, so a later call starts fresh: de-duplication, not caching.
|
|
127
|
+
*/
|
|
128
|
+
function createSingleFlight() {
|
|
129
|
+
let current;
|
|
130
|
+
return {
|
|
131
|
+
run(operation) {
|
|
132
|
+
if (current) return current;
|
|
133
|
+
const flight = operation().finally(() => {
|
|
134
|
+
if (current === flight) current = undefined;
|
|
135
|
+
});
|
|
136
|
+
current = flight;
|
|
137
|
+
return flight;
|
|
138
|
+
},
|
|
139
|
+
inFlight: () => current !== undefined
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/** Distinguishes "refused because busy" from any other failure, without throwing. */
|
|
144
|
+
|
|
145
|
+
/** Admits one operation at a time and refuses the rest, rather than queueing them. */
|
|
146
|
+
function createExclusive() {
|
|
147
|
+
let held = false;
|
|
148
|
+
return {
|
|
149
|
+
async run(operation) {
|
|
150
|
+
if (held) return {
|
|
151
|
+
acquired: false
|
|
152
|
+
};
|
|
153
|
+
held = true;
|
|
154
|
+
try {
|
|
155
|
+
return {
|
|
156
|
+
acquired: true,
|
|
157
|
+
value: await operation()
|
|
158
|
+
};
|
|
159
|
+
} finally {
|
|
160
|
+
held = false;
|
|
161
|
+
}
|
|
162
|
+
},
|
|
163
|
+
busy: () => held
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/** Admits at most one call per `minIntervalMs`; a refused call is dropped, not deferred. */
|
|
168
|
+
function createRateLimiter(minIntervalMs, now = Date.now) {
|
|
169
|
+
let lastAt;
|
|
170
|
+
return {
|
|
171
|
+
tryAcquire() {
|
|
172
|
+
const at = now();
|
|
173
|
+
if (lastAt !== undefined && at - lastAt < minIntervalMs) return false;
|
|
174
|
+
lastAt = at;
|
|
175
|
+
return true;
|
|
176
|
+
},
|
|
177
|
+
reset() {
|
|
178
|
+
lastAt = undefined;
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Rejects with `onTimeout()` after `ms`. Always clears its timer, including when
|
|
185
|
+
* the promise wins, so no operation leaks one.
|
|
186
|
+
*/
|
|
187
|
+
function withTimeout(promise, ms, onTimeout, scheduler = realScheduler) {
|
|
188
|
+
let timer;
|
|
189
|
+
const timeout = new Promise((_, reject) => {
|
|
190
|
+
timer = scheduler.setTimeout(() => reject(onTimeout()), ms);
|
|
191
|
+
});
|
|
192
|
+
return Promise.race([promise, timeout]).finally(() => {
|
|
193
|
+
if (timer !== undefined) scheduler.clearTimeout(timer);
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* `value` when it is a finite number inside `range`; otherwise throws what `fail`
|
|
198
|
+
* builds. Out-of-range values are rejected, never clamped: clamping tells an app
|
|
199
|
+
* it configured something it did not.
|
|
200
|
+
*/
|
|
201
|
+
function checkRange(label, value, range, fail, unit = '') {
|
|
202
|
+
if (!Number.isFinite(value) || value < range.min || value > range.max) {
|
|
203
|
+
throw fail(`${label} must be between ${range.min}${unit} and ${range.max}${unit}; received ${value}`);
|
|
204
|
+
}
|
|
205
|
+
return value;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/** As `checkRange`, and a whole number. */
|
|
209
|
+
function checkInteger(label, value, range, fail) {
|
|
210
|
+
checkRange(label, value, range, fail);
|
|
211
|
+
if (!Number.isInteger(value)) {
|
|
212
|
+
throw fail(`${label} must be a whole number; received ${value}`);
|
|
213
|
+
}
|
|
214
|
+
return value;
|
|
215
|
+
}
|
|
216
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_index","require","realScheduler","exports","setTimeout","callback","ms","clearTimeout","handle","createTimerSet","scheduler","handles","Set","after","delete","add","cleared","clearAll","clear","size","computeBackoff","attempt","spec","random","Math","raw","initialDelayMs","pow","factor","max","capped","min","maxDelayMs","jitter","floor","runWithRetry","options","onExhausted","count","cancelled","pending","run","succeeded","maxAttempts","undefined","start","catch","reportAsynchronously","cancel","attempts","exhausted","createSingleFlight","current","operation","flight","finally","inFlight","createExclusive","held","acquired","value","busy","createRateLimiter","minIntervalMs","now","Date","lastAt","tryAcquire","at","reset","withTimeout","promise","onTimeout","timer","timeout","Promise","_","reject","race","checkRange","label","range","fail","unit","Number","isFinite","checkInteger","isInteger"],"sourceRoot":"../../../src","sources":["scheduler/index.ts"],"mappings":";;;;;;;;;;;;;;;AAUA,IAAAA,MAAA,GAAAC,OAAA;AAVA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;;AAMO,MAAMC,aAAwB,GAAAC,OAAA,CAAAD,aAAA,GAAG;EACvCE,UAAU,EAAEA,CAACC,QAAQ,EAAEC,EAAE,KAAKF,UAAU,CAACC,QAAQ,E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QAAQF,KAAK,CAACpD,GAAG,GAAGsD,IAAI,cAAcvB,KAAK,EACxF,CAAC;EACF;EACA,OAAOA,KAAK;AACb;;AAEA;AACO,SAAS0B,YAAYA,CAC3BN,KAAa,EACbpB,KAAa,EACbqB,KAAY,EACZC,IAAgC,EACvB;EACTH,UAAU,CAACC,KAAK,EAAEpB,KAAK,EAAEqB,KAAK,EAAEC,IAAI,CAAC;EACrC,IAAI,CAACE,MAAM,CAACG,SAAS,CAAC3B,KAAK,CAAC,EAAE;IAC7B,MAAMsB,IAAI,CAAC,GAAGF,KAAK,qCAAqCpB,KAAK,EAAE,CAAC;EACjE;EACA,OAAOA,KAAK;AACb","ignoreList":[]}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createStore = createStore;
|
|
7
|
+
exports.shallowEqual = shallowEqual;
|
|
8
|
+
var _index = require("../listeners/index.js");
|
|
9
|
+
/**
|
|
10
|
+
* A store whose snapshot keeps its identity until the state actually changes,
|
|
11
|
+
* which is what `useSyncExternalStore` needs (CORE-07). No React here: a package's
|
|
12
|
+
* pure core can hold its state in one, and its hooks read it through
|
|
13
|
+
* `@chipmobilesdk/rn-core/react`.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
function createStore(initial, isEqual = Object.is) {
|
|
17
|
+
let snapshot = initial;
|
|
18
|
+
const listeners = (0, _index.createListenerSet)();
|
|
19
|
+
return {
|
|
20
|
+
getSnapshot: () => snapshot,
|
|
21
|
+
setState(next) {
|
|
22
|
+
const value = typeof next === 'function' ? next(snapshot) : next;
|
|
23
|
+
if (isEqual(snapshot, value)) return;
|
|
24
|
+
snapshot = value;
|
|
25
|
+
listeners.notify();
|
|
26
|
+
},
|
|
27
|
+
subscribe: listener => listeners.add(listener)
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** Same keys, and each value `Object.is` the other's. */
|
|
32
|
+
function shallowEqual(a, b) {
|
|
33
|
+
if (Object.is(a, b)) return true;
|
|
34
|
+
if (typeof a !== 'object' || typeof b !== 'object' || a === null || b === null) return false;
|
|
35
|
+
const keysA = Object.keys(a);
|
|
36
|
+
if (keysA.length !== Object.keys(b).length) return false;
|
|
37
|
+
return keysA.every(key => Object.prototype.hasOwnProperty.call(b, key) && Object.is(a[key], b[key]));
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_index","require","createStore","initial","isEqual","Object","is","snapshot","listeners","createListenerSet","getSnapshot","setState","next","value","notify","subscribe","listener","add","shallowEqual","a","b","keysA","keys","length","every","key","prototype","hasOwnProperty","call"],"sourceRoot":"../../../src","sources":["store/index.ts"],"mappings":";;;;;;;AAMA,IAAAA,MAAA,GAAAC,OAAA;AANA;AACA;AACA;AACA;AACA;AACA;;AAWO,SAASC,WAAWA,CAAIC,OAAU,EAAEC,OAAgC,GAAGC,MAAM,CAACC,EAAE,EAAY;EAClG,IAAIC,QAAQ,GAAGJ,OAAO;EACtB,MAAMK,SAAS,GAAG,IAAAC,wBAAiB,EAAK,CAAC;EACzC,OAAO;IACNC,WAAW,EAAEA,CAAA,KAAMH,QAAQ;IAC3BI,QAAQA,CAACC,IAAI,EAAE;MACd,MAAMC,KAAK,GAAG,OAAOD,IAAI,KAAK,UAAU,GAAIA,IAAI,CAAwBL,QAAQ,CAAC,GAAGK,IAAI;MACxF,IAAIR,OAAO,CAACG,QAAQ,EAAEM,KAAK,CAAC,EAAE;MAC9BN,QAAQ,GAAGM,KAAK;MAChBL,SAAS,CAACM,MAAM,CAAC,CAAC;IACnB,CAAC;IACDC,SAAS,EAAEC,QAAQ,IAAIR,SAAS,CAACS,GAAG,CAACD,QAAQ;EAC9C,CAAC;AACF;;AAEA;AACO,SAASE,YAAYA,CAAIC,CAAI,EAAEC,CAAI,EAAW;EACpD,IAAIf,MAAM,CAACC,EAAE,CAACa,CAAC,EAAEC,CAAC,CAAC,EAAE,OAAO,IAAI;EAChC,IAAI,OAAOD,CAAC,KAAK,QAAQ,IAAI,OAAOC,CAAC,KAAK,QAAQ,IAAID,CAAC,KAAK,IAAI,IAAIC,CAAC,KAAK,IAAI,EAAE,OAAO,KAAK;EAC5F,MAAMC,KAAK,GAAGhB,MAAM,CAACiB,IAAI,CAACH,CAAC,CAAC;EAC5B,IAAIE,KAAK,CAACE,MAAM,KAAKlB,MAAM,CAACiB,IAAI,CAACF,CAAC,CAAC,CAACG,MAAM,EAAE,OAAO,KAAK;EACxD,OAAOF,KAAK,CAACG,KAAK,CACjBC,GAAG,IACFpB,MAAM,CAACqB,SAAS,CAACC,cAAc,CAACC,IAAI,CAACR,CAAC,EAAEK,GAAG,CAAC,IAC5CpB,MAAM,CAACC,EAAE,CAAEa,CAAC,CAA6BM,GAAG,CAAC,EAAGL,CAAC,CAA6BK,GAAG,CAAC,CACpF,CAAC;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createFaultRegistry = createFaultRegistry;
|
|
7
|
+
exports.ensure = ensure;
|
|
8
|
+
exports.expectConformance = expectConformance;
|
|
9
|
+
exports.runChecks = runChecks;
|
|
10
|
+
/**
|
|
11
|
+
* A conformance harness that runs in Jest and on a device alike (CORE-13, IOS-12).
|
|
12
|
+
*
|
|
13
|
+
* A package describes what any implementation of one of its ports must do as a
|
|
14
|
+
* list of checks. The same list runs against the fake its tests use and against
|
|
15
|
+
* the real adapter (with the native module mocked in Jest, or for real in a demo
|
|
16
|
+
* screen), so the fake cannot drift from the adapter it stands in for. A report
|
|
17
|
+
* is plain data; `expectConformance` turns a failing one into a Jest failure.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/** Runs every check against a fresh subject, so no check depends on another's leftovers. */
|
|
21
|
+
async function runChecks(makeSubject, checks) {
|
|
22
|
+
const failures = [];
|
|
23
|
+
for (const check of checks) {
|
|
24
|
+
try {
|
|
25
|
+
await check.run(await makeSubject());
|
|
26
|
+
} catch (error) {
|
|
27
|
+
failures.push({
|
|
28
|
+
check: check.name,
|
|
29
|
+
detail: error instanceof Error ? error.message : String(error)
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return {
|
|
34
|
+
passed: failures.length === 0,
|
|
35
|
+
checks: checks.length,
|
|
36
|
+
failures
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** Throws one error listing every failed check, for a test runner to report. */
|
|
41
|
+
function expectConformance(report, subject = 'implementation') {
|
|
42
|
+
if (report.passed) return;
|
|
43
|
+
const lines = report.failures.map(failure => ` - ${failure.check}: ${failure.detail}`);
|
|
44
|
+
throw new Error(`${subject} failed ${report.failures.length} of ${report.checks} checks:\n${lines.join('\n')}`);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** A failed expectation inside a check. */
|
|
48
|
+
function ensure(condition, message) {
|
|
49
|
+
if (!condition) throw new Error(message);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Deterministic fault injection: a fake or an adapter calls `throwIfFaulted` at its
|
|
53
|
+
* named points, and a test arms the ones it wants to fail (CORE-13, NOT-22).
|
|
54
|
+
*/
|
|
55
|
+
function createFaultRegistry() {
|
|
56
|
+
const armed = new Map();
|
|
57
|
+
const fired = new Set();
|
|
58
|
+
return {
|
|
59
|
+
arm(point, fault, times = 1) {
|
|
60
|
+
armed.set(point, {
|
|
61
|
+
fault,
|
|
62
|
+
remaining: times
|
|
63
|
+
});
|
|
64
|
+
},
|
|
65
|
+
disarm(point) {
|
|
66
|
+
if (point === undefined) armed.clear();else armed.delete(point);
|
|
67
|
+
},
|
|
68
|
+
throwIfFaulted(point) {
|
|
69
|
+
const entry = armed.get(point);
|
|
70
|
+
if (!entry) return;
|
|
71
|
+
entry.remaining -= 1;
|
|
72
|
+
if (entry.remaining <= 0) armed.delete(point);
|
|
73
|
+
fired.add(point);
|
|
74
|
+
throw entry.fault();
|
|
75
|
+
},
|
|
76
|
+
fired: () => [...fired]
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=conformance.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["runChecks","makeSubject","checks","failures","check","run","error","push","name","detail","Error","message","String","passed","length","expectConformance","report","subject","lines","map","failure","join","ensure","condition","createFaultRegistry","armed","Map","fired","Set","arm","point","fault","times","set","remaining","disarm","undefined","clear","delete","throwIfFaulted","entry","get","add"],"sourceRoot":"../../../src","sources":["testing/conformance.ts"],"mappings":";;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAQA;AACO,eAAeA,SAASA,CAC9BC,WAA6C,EAC7CC,MAAiC,EACJ;EAC7B,MAAMC,QAA8B,GAAG,EAAE;EACzC,KAAK,MAAMC,KAAK,IAAIF,MAAM,EAAE;IAC3B,IAAI;MACH,MAAME,KAAK,CAACC,GAAG,CAAC,MAAMJ,WAAW,CAAC,CAAC,CAAC;IACrC,CAAC,CAAC,OAAOK,KAAK,EAAE;MACfH,QAAQ,CAACI,IAAI,CAAC;QACbH,KAAK,EAAEA,KAAK,CAACI,IAAI;QACjBC,MAAM,EAAEH,KAAK,YAAYI,KAAK,GAAGJ,KAAK,CAACK,OAAO,GAAGC,MAAM,CAACN,KAAK;MAC9D,CAAC,CAAC;IACH;EACD;EACA,OAAO;IAAEO,MAAM,EAAEV,QAAQ,CAACW,MAAM,KAAK,CAAC;IAAEZ,MAAM,EAAEA,MAAM,CAACY,MAAM;IAAEX;EAAS,CAAC;AAC1E;;AAEA;AACO,SAASY,iBAAiBA,CAACC,MAAyB,EAAEC,OAAO,GAAG,gBAAgB,EAAQ;EAC9F,IAAID,MAA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CH,KAAK,CAACe,GAAG,CAACZ,KAAK,CAAC;MAChB,MAAMU,KAAK,CAACT,KAAK,CAAC,CAAC;IACpB,CAAC;IACDJ,KAAK,EAAEA,CAAA,KAAM,CAAC,GAAGA,KAAK;EACvB,CAAC;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "REDACTION_PROBES", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _redaction.REDACTION_PROBES;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "createFaultRegistry", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _conformance.createFaultRegistry;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "createManualLifecycle", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () {
|
|
21
|
+
return _lifecycle.createManualLifecycle;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(exports, "createManualScheduler", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function () {
|
|
27
|
+
return _scheduler.createManualScheduler;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
Object.defineProperty(exports, "ensure", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function () {
|
|
33
|
+
return _conformance.ensure;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
Object.defineProperty(exports, "expectConformance", {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
get: function () {
|
|
39
|
+
return _conformance.expectConformance;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
Object.defineProperty(exports, "redactionConformance", {
|
|
43
|
+
enumerable: true,
|
|
44
|
+
get: function () {
|
|
45
|
+
return _redaction.redactionConformance;
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
Object.defineProperty(exports, "runChecks", {
|
|
49
|
+
enumerable: true,
|
|
50
|
+
get: function () {
|
|
51
|
+
return _conformance.runChecks;
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
var _redaction = require("./redaction.js");
|
|
55
|
+
var _scheduler = require("./scheduler.js");
|
|
56
|
+
var _conformance = require("./conformance.js");
|
|
57
|
+
var _lifecycle = require("./lifecycle.js");
|
|
58
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_redaction","require","_scheduler","_conformance","_lifecycle"],"sourceRoot":"../../../src","sources":["testing/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,IAAAA,UAAA,GAAAC,OAAA;AAOA,IAAAC,UAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAF,OAAA;AAQA,IAAAG,UAAA,GAAAH,OAAA","ignoreList":[]}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createManualLifecycle = createManualLifecycle;
|
|
7
|
+
var _lifecycle = require("../runtime/lifecycle.js");
|
|
8
|
+
/**
|
|
9
|
+
* A lifecycle a test moves by hand (CORE-14). It runs the real port over a scripted
|
|
10
|
+
* `AppState`, so transitions, de-duplication and reference counting behave exactly
|
|
11
|
+
* as they do on a device.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
function createManualLifecycle(initial = 'active') {
|
|
15
|
+
let state = initial;
|
|
16
|
+
const handlers = new Set();
|
|
17
|
+
const source = {
|
|
18
|
+
get currentState() {
|
|
19
|
+
return state;
|
|
20
|
+
},
|
|
21
|
+
addEventListener(_type, handler) {
|
|
22
|
+
handlers.add(handler);
|
|
23
|
+
return {
|
|
24
|
+
remove: () => handlers.delete(handler)
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
return {
|
|
29
|
+
port: (0, _lifecycle.createAppLifecycle)(() => source),
|
|
30
|
+
set(next) {
|
|
31
|
+
state = next;
|
|
32
|
+
for (const handler of [...handlers]) handler(next);
|
|
33
|
+
},
|
|
34
|
+
isSubscribed: () => handlers.size > 0
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=lifecycle.js.map
|