@chipmobilesdk/rn-core 0.1.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.
Files changed (158) hide show
  1. package/CHANGELOG.md +64 -0
  2. package/lib/commonjs/diagnostics/index.js +81 -0
  3. package/lib/commonjs/diagnostics/index.js.map +1 -0
  4. package/lib/commonjs/errors/index.js +86 -0
  5. package/lib/commonjs/errors/index.js.map +1 -0
  6. package/lib/commonjs/index.js +305 -0
  7. package/lib/commonjs/index.js.map +1 -0
  8. package/lib/commonjs/intl/index.js +98 -0
  9. package/lib/commonjs/intl/index.js.map +1 -0
  10. package/lib/commonjs/kv/index.js +83 -0
  11. package/lib/commonjs/kv/index.js.map +1 -0
  12. package/lib/commonjs/lazy/index.js +63 -0
  13. package/lib/commonjs/lazy/index.js.map +1 -0
  14. package/lib/commonjs/listeners/index.js +110 -0
  15. package/lib/commonjs/listeners/index.js.map +1 -0
  16. package/lib/commonjs/messages/index.js +53 -0
  17. package/lib/commonjs/messages/index.js.map +1 -0
  18. package/lib/commonjs/package.json +1 -0
  19. package/lib/commonjs/react/index.js +93 -0
  20. package/lib/commonjs/react/index.js.map +1 -0
  21. package/lib/commonjs/redact/index.js +128 -0
  22. package/lib/commonjs/redact/index.js.map +1 -0
  23. package/lib/commonjs/runtime/index.js +77 -0
  24. package/lib/commonjs/runtime/index.js.map +1 -0
  25. package/lib/commonjs/runtime/lifecycle.js +105 -0
  26. package/lib/commonjs/runtime/lifecycle.js.map +1 -0
  27. package/lib/commonjs/scheduler/index.js +216 -0
  28. package/lib/commonjs/scheduler/index.js.map +1 -0
  29. package/lib/commonjs/store/index.js +39 -0
  30. package/lib/commonjs/store/index.js.map +1 -0
  31. package/lib/commonjs/testing/conformance.js +79 -0
  32. package/lib/commonjs/testing/conformance.js.map +1 -0
  33. package/lib/commonjs/testing/index.js +58 -0
  34. package/lib/commonjs/testing/index.js.map +1 -0
  35. package/lib/commonjs/testing/lifecycle.js +37 -0
  36. package/lib/commonjs/testing/lifecycle.js.map +1 -0
  37. package/lib/commonjs/testing/redaction.js +118 -0
  38. package/lib/commonjs/testing/redaction.js.map +1 -0
  39. package/lib/commonjs/testing/scheduler.js +51 -0
  40. package/lib/commonjs/testing/scheduler.js.map +1 -0
  41. package/lib/module/diagnostics/index.js +75 -0
  42. package/lib/module/diagnostics/index.js.map +1 -0
  43. package/lib/module/errors/index.js +78 -0
  44. package/lib/module/errors/index.js.map +1 -0
  45. package/lib/module/index.js +24 -0
  46. package/lib/module/index.js.map +1 -0
  47. package/lib/module/intl/index.js +91 -0
  48. package/lib/module/intl/index.js.map +1 -0
  49. package/lib/module/kv/index.js +76 -0
  50. package/lib/module/kv/index.js.map +1 -0
  51. package/lib/module/lazy/index.js +59 -0
  52. package/lib/module/lazy/index.js.map +1 -0
  53. package/lib/module/listeners/index.js +104 -0
  54. package/lib/module/listeners/index.js.map +1 -0
  55. package/lib/module/messages/index.js +48 -0
  56. package/lib/module/messages/index.js.map +1 -0
  57. package/lib/module/package.json +1 -0
  58. package/lib/module/react/index.js +86 -0
  59. package/lib/module/react/index.js.map +1 -0
  60. package/lib/module/redact/index.js +118 -0
  61. package/lib/module/redact/index.js.map +1 -0
  62. package/lib/module/runtime/index.js +52 -0
  63. package/lib/module/runtime/index.js.map +1 -0
  64. package/lib/module/runtime/lifecycle.js +99 -0
  65. package/lib/module/runtime/lifecycle.js.map +1 -0
  66. package/lib/module/scheduler/index.js +203 -0
  67. package/lib/module/scheduler/index.js.map +1 -0
  68. package/lib/module/store/index.js +33 -0
  69. package/lib/module/store/index.js.map +1 -0
  70. package/lib/module/testing/conformance.js +72 -0
  71. package/lib/module/testing/conformance.js.map +1 -0
  72. package/lib/module/testing/index.js +12 -0
  73. package/lib/module/testing/index.js.map +1 -0
  74. package/lib/module/testing/lifecycle.js +32 -0
  75. package/lib/module/testing/lifecycle.js.map +1 -0
  76. package/lib/module/testing/redaction.js +113 -0
  77. package/lib/module/testing/redaction.js.map +1 -0
  78. package/lib/module/testing/scheduler.js +47 -0
  79. package/lib/module/testing/scheduler.js.map +1 -0
  80. package/lib/typescript/commonjs/diagnostics/index.d.ts +49 -0
  81. package/lib/typescript/commonjs/diagnostics/index.d.ts.map +1 -0
  82. package/lib/typescript/commonjs/errors/index.d.ts +59 -0
  83. package/lib/typescript/commonjs/errors/index.d.ts.map +1 -0
  84. package/lib/typescript/commonjs/index.d.ts +22 -0
  85. package/lib/typescript/commonjs/index.d.ts.map +1 -0
  86. package/lib/typescript/commonjs/intl/index.d.ts +25 -0
  87. package/lib/typescript/commonjs/intl/index.d.ts.map +1 -0
  88. package/lib/typescript/commonjs/kv/index.d.ts +38 -0
  89. package/lib/typescript/commonjs/kv/index.d.ts.map +1 -0
  90. package/lib/typescript/commonjs/lazy/index.d.ts +36 -0
  91. package/lib/typescript/commonjs/lazy/index.d.ts.map +1 -0
  92. package/lib/typescript/commonjs/listeners/index.d.ts +61 -0
  93. package/lib/typescript/commonjs/listeners/index.d.ts.map +1 -0
  94. package/lib/typescript/commonjs/messages/index.d.ts +39 -0
  95. package/lib/typescript/commonjs/messages/index.d.ts.map +1 -0
  96. package/lib/typescript/commonjs/package.json +1 -0
  97. package/lib/typescript/commonjs/react/index.d.ts +38 -0
  98. package/lib/typescript/commonjs/react/index.d.ts.map +1 -0
  99. package/lib/typescript/commonjs/redact/index.d.ts +47 -0
  100. package/lib/typescript/commonjs/redact/index.d.ts.map +1 -0
  101. package/lib/typescript/commonjs/runtime/index.d.ts +21 -0
  102. package/lib/typescript/commonjs/runtime/index.d.ts.map +1 -0
  103. package/lib/typescript/commonjs/runtime/lifecycle.d.ts +34 -0
  104. package/lib/typescript/commonjs/runtime/lifecycle.d.ts.map +1 -0
  105. package/lib/typescript/commonjs/scheduler/index.d.ts +108 -0
  106. package/lib/typescript/commonjs/scheduler/index.d.ts.map +1 -0
  107. package/lib/typescript/commonjs/store/index.d.ts +18 -0
  108. package/lib/typescript/commonjs/store/index.d.ts.map +1 -0
  109. package/lib/typescript/commonjs/testing/conformance.d.ts +35 -0
  110. package/lib/typescript/commonjs/testing/conformance.d.ts.map +1 -0
  111. package/lib/typescript/commonjs/testing/index.d.ts +10 -0
  112. package/lib/typescript/commonjs/testing/index.d.ts.map +1 -0
  113. package/lib/typescript/commonjs/testing/lifecycle.d.ts +15 -0
  114. package/lib/typescript/commonjs/testing/lifecycle.d.ts.map +1 -0
  115. package/lib/typescript/commonjs/testing/redaction.d.ts +35 -0
  116. package/lib/typescript/commonjs/testing/redaction.d.ts.map +1 -0
  117. package/lib/typescript/commonjs/testing/scheduler.d.ts +15 -0
  118. package/lib/typescript/commonjs/testing/scheduler.d.ts.map +1 -0
  119. package/lib/typescript/module/diagnostics/index.d.ts +49 -0
  120. package/lib/typescript/module/diagnostics/index.d.ts.map +1 -0
  121. package/lib/typescript/module/errors/index.d.ts +59 -0
  122. package/lib/typescript/module/errors/index.d.ts.map +1 -0
  123. package/lib/typescript/module/index.d.ts +22 -0
  124. package/lib/typescript/module/index.d.ts.map +1 -0
  125. package/lib/typescript/module/intl/index.d.ts +25 -0
  126. package/lib/typescript/module/intl/index.d.ts.map +1 -0
  127. package/lib/typescript/module/kv/index.d.ts +38 -0
  128. package/lib/typescript/module/kv/index.d.ts.map +1 -0
  129. package/lib/typescript/module/lazy/index.d.ts +36 -0
  130. package/lib/typescript/module/lazy/index.d.ts.map +1 -0
  131. package/lib/typescript/module/listeners/index.d.ts +61 -0
  132. package/lib/typescript/module/listeners/index.d.ts.map +1 -0
  133. package/lib/typescript/module/messages/index.d.ts +39 -0
  134. package/lib/typescript/module/messages/index.d.ts.map +1 -0
  135. package/lib/typescript/module/package.json +1 -0
  136. package/lib/typescript/module/react/index.d.ts +38 -0
  137. package/lib/typescript/module/react/index.d.ts.map +1 -0
  138. package/lib/typescript/module/redact/index.d.ts +47 -0
  139. package/lib/typescript/module/redact/index.d.ts.map +1 -0
  140. package/lib/typescript/module/runtime/index.d.ts +21 -0
  141. package/lib/typescript/module/runtime/index.d.ts.map +1 -0
  142. package/lib/typescript/module/runtime/lifecycle.d.ts +34 -0
  143. package/lib/typescript/module/runtime/lifecycle.d.ts.map +1 -0
  144. package/lib/typescript/module/scheduler/index.d.ts +108 -0
  145. package/lib/typescript/module/scheduler/index.d.ts.map +1 -0
  146. package/lib/typescript/module/store/index.d.ts +18 -0
  147. package/lib/typescript/module/store/index.d.ts.map +1 -0
  148. package/lib/typescript/module/testing/conformance.d.ts +35 -0
  149. package/lib/typescript/module/testing/conformance.d.ts.map +1 -0
  150. package/lib/typescript/module/testing/index.d.ts +10 -0
  151. package/lib/typescript/module/testing/index.d.ts.map +1 -0
  152. package/lib/typescript/module/testing/lifecycle.d.ts +15 -0
  153. package/lib/typescript/module/testing/lifecycle.d.ts.map +1 -0
  154. package/lib/typescript/module/testing/redaction.d.ts +35 -0
  155. package/lib/typescript/module/testing/redaction.d.ts.map +1 -0
  156. package/lib/typescript/module/testing/scheduler.d.ts +15 -0
  157. package/lib/typescript/module/testing/scheduler.d.ts.map +1 -0
  158. package/package.json +154 -46
@@ -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,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAbA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAmBA;;AAUA,MAAME,WAAW,GAAG,IAAAC,eAAQ,EAC3B,cAAc,EACd,MAAMH,OAAO,CAAC,cAAc,CAC7B,CAAC;AAED,SAASI,aAAaA,CAAA,EAA+B;EACpD,MAAMC,MAAM,GAAGH,WAAW,CAACI,GAAG,CAAC,CAAC;EAChC,OAAOD,MAAM,CAACE,EAAE,GAAGF,MAAM,CAACG,MAAM,CAACC,QAAQ,GAAGC,SAAS;AACtD;;AAEA;AACA;AACA;AACA;AACA,SAASC,SAASA,CAACC,GAA8B,EAAqB;EACrE,OAAOA,GAAG,KAAK,YAAY,IAAIA,GAAG,KAAK,UAAU,GAAGA,GAAG,GAAG,QAAQ;AACnE;;AAEA;AACA;AACA;AACA;AACO,SAASC,kBAAkBA,CACjCC,MAAwC,GAAGV,aAAa,EACrC;EACnB,MAAMW,SAAS,GAAG,IAAAC,yBAAiB,EAAyC,CAAC;EAC7E,IAAIC,YAA4C;EAChD,IAAIC,IAAuB,GAAG,QAAQ;EAEtC,MAAMC,IAAI,GAAGA,CAAA,KAAyBR,SAAS,CAACG,MAAM,CAAC,CAAC,EAAEM,YAAY,CAAC;EAEvE,OAAO;IACNC,OAAOA,CAAA,EAAG;MACT,OAAOJ,YAAY,GAAG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AO,CAAC,CAAC,KAAK,YAAY;EAC1C,OAAOgB,IAAI,CAACf,SAAS,CAACiB,KAAK,IAAI;IAC9B,IAAIA,KAAK,KAAK,YAAY,EAAE;MAC3BD,IAAI,GAAG,IAAI;IACZ,CAAC,MAAM,IAAIC,KAAK,KAAK,QAAQ,IAAID,IAAI,EAAE;MACtCA,IAAI,GAAG,KAAK;MACZf,QAAQ,CAAC,CAAC;IACX;EACD,CAAC,CAAC;AACH","ignoreList":[]}
@@ -0,0 +1,216 @@
1
+ "use strict";
2
+
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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AI,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;QACjB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ACY,KAAK,CAAC,CAAC,CAAC,KAClCZ,KAAK,CAACa,MAAM,CAACR,KAAK,CAAC;IACzB,CAAC;IACDS,cAAcA,CAACT,KAAK,EAAE;MACrB,MAAMU,KAAK,GAAGf,KAAK,CAACgB,GAAG,CAACX,KAAK,CAAC;MAC9B,IAAI,CAACU,KAAK,EAAE;MACZA,KAAK,CAACN,SAAS,IAAI,CAAC;MACpB,IAAIM,KAAK,CAACN,SAAS,IAAI,CAAC,EAAET,KAAK,CAACa,MAAM,CAACR,KAAK,CAAC;MAC7CH,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
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_lifecycle","require","createManualLifecycle","initial","state","handlers","Set","source","currentState","addEventListener","_type","handler","add","remove","delete","port","createAppLifecycle","set","next","isSubscribed","size"],"sourceRoot":"../../../src","sources":["testing/lifecycle.ts"],"mappings":";;;;;;AAKA,IAAAA,UAAA,GAAAC,OAAA;AALA;AACA;AACA;AACA;AACA;;AAgBO,SAASC,qBAAqBA,CAACC,OAA0B,GAAG,QAAQ,EAAmB;EAC7F,IAAIC,KAAwB,GAAGD,OAAO;EACtC,MAAME,QAAQ,GAAG,IAAIC,GAAG,CAAwB,CAAC;EACjD,MAAMC,MAAsB,GAAG;IAC9B,IAAIC,YAAYA,CAAA,EAAG;MAClB,OAAOJ,KAAK;IACb,CAAC;IACDK,gBAAgBA,CAACC,KAAK,EAAEC,OAAO,EAAE;MAChCN,QAAQ,CAACO,GAAG,CAACD,OAAO,CAAC;MACrB,OAAO;QAAEE,MAAM,EAAEA,CAAA,KAAMR,QAAQ,CAACS,MAAM,CAACH,OAAO;MAAE,CAAC;IAClD;EACD,CAAC;EACD,OAAO;IACNI,IAAI,EAAE,IAAAC,6BAAkB,EAAC,MAAMT,MAAM,CAAC;IACtCU,GAAGA,CAACC,IAAI,EAAE;MACTd,KAAK,GAAGc,IAAI;MACZ,KAAK,MAAMP,OAAO,IAAI,CAAC,GAAGN,QAAQ,CAAC,EAAEM,OAAO,CAACO,IAAI,CAAC;IACnD,CAAC;IACDC,YAAY,EAAEA,CAAA,KAAMd,QAAQ,CAACe,IAAI,GAAG;EACrC,CAAC;AACF","ignoreList":[]}