@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.
- package/CHANGELOG.md +64 -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,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A conformance harness that runs in Jest and on a device alike (CORE-13, IOS-12).
|
|
3
|
+
*
|
|
4
|
+
* A package describes what any implementation of one of its ports must do as a
|
|
5
|
+
* list of checks. The same list runs against the fake its tests use and against
|
|
6
|
+
* the real adapter (with the native module mocked in Jest, or for real in a demo
|
|
7
|
+
* screen), so the fake cannot drift from the adapter it stands in for. A report
|
|
8
|
+
* is plain data; `expectConformance` turns a failing one into a Jest failure.
|
|
9
|
+
*/
|
|
10
|
+
import type { ConformanceReport } from './redaction';
|
|
11
|
+
export interface Check<Subject> {
|
|
12
|
+
readonly name: string;
|
|
13
|
+
run(subject: Subject): void | Promise<void>;
|
|
14
|
+
}
|
|
15
|
+
/** Runs every check against a fresh subject, so no check depends on another's leftovers. */
|
|
16
|
+
export declare function runChecks<Subject>(makeSubject: () => Subject | Promise<Subject>, checks: readonly Check<Subject>[]): Promise<ConformanceReport>;
|
|
17
|
+
/** Throws one error listing every failed check, for a test runner to report. */
|
|
18
|
+
export declare function expectConformance(report: ConformanceReport, subject?: string): void;
|
|
19
|
+
/** A failed expectation inside a check. */
|
|
20
|
+
export declare function ensure(condition: unknown, message: string): asserts condition;
|
|
21
|
+
export interface FaultRegistry<Point extends string> {
|
|
22
|
+
/** The next `times` calls at `point` throw what `fault` builds. */
|
|
23
|
+
arm(point: Point, fault: () => Error, times?: number): void;
|
|
24
|
+
disarm(point?: Point): void;
|
|
25
|
+
/** Throws if `point` is armed; called by the code under test at that point. */
|
|
26
|
+
throwIfFaulted(point: Point): void;
|
|
27
|
+
/** Points that have fired at least once, so a test can prove its fault was reached. */
|
|
28
|
+
fired(): readonly Point[];
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Deterministic fault injection: a fake or an adapter calls `throwIfFaulted` at its
|
|
32
|
+
* named points, and a test arms the ones it wants to fail (CORE-13, NOT-22).
|
|
33
|
+
*/
|
|
34
|
+
export declare function createFaultRegistry<Point extends string>(): FaultRegistry<Point>;
|
|
35
|
+
//# sourceMappingURL=conformance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conformance.d.ts","sourceRoot":"","sources":["../../../../src/testing/conformance.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAsB,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEzE,MAAM,WAAW,KAAK,CAAC,OAAO;IAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,GAAG,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC5C;AAED,4FAA4F;AAC5F,wBAAsB,SAAS,CAAC,OAAO,EACtC,WAAW,EAAE,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,EAC7C,MAAM,EAAE,SAAS,KAAK,CAAC,OAAO,CAAC,EAAE,GAC/B,OAAO,CAAC,iBAAiB,CAAC,CAa5B;AAED,gFAAgF;AAChF,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,iBAAiB,EAAE,OAAO,SAAmB,GAAG,IAAI,CAM7F;AAED,2CAA2C;AAC3C,wBAAgB,MAAM,CAAC,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAE7E;AAED,MAAM,WAAW,aAAa,CAAC,KAAK,SAAS,MAAM;IAClD,mEAAmE;IACnE,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,KAAK,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5D,MAAM,CAAC,KAAK,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC;IAC5B,+EAA+E;IAC/E,cAAc,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACnC,uFAAuF;IACvF,KAAK,IAAI,SAAS,KAAK,EAAE,CAAC;CAC1B;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,SAAS,MAAM,KAAK,aAAa,CAAC,KAAK,CAAC,CAqBhF"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Test helpers shared by every package: conformance suites that return plain
|
|
3
|
+
* reports, so they run in Jest and on a device alike. Production code never
|
|
4
|
+
* imports this entrypoint.
|
|
5
|
+
*/
|
|
6
|
+
export { REDACTION_PROBES, redactionConformance, type ConformanceFailure, type ConformanceReport, type RedactionProbe, } from './redaction';
|
|
7
|
+
export { createManualScheduler, type ManualScheduler } from './scheduler';
|
|
8
|
+
export { createFaultRegistry, ensure, expectConformance, runChecks, type Check, type FaultRegistry, } from './conformance';
|
|
9
|
+
export { createManualLifecycle, type ManualLifecycle } from './lifecycle';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/testing/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EACN,gBAAgB,EAChB,oBAAoB,EACpB,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,cAAc,GACnB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,qBAAqB,EAAE,KAAK,eAAe,EAAE,MAAM,aAAa,CAAC;AAC1E,OAAO,EACN,mBAAmB,EACnB,MAAM,EACN,iBAAiB,EACjB,SAAS,EACT,KAAK,KAAK,EACV,KAAK,aAAa,GAClB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,qBAAqB,EAAE,KAAK,eAAe,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A lifecycle a test moves by hand (CORE-14). It runs the real port over a scripted
|
|
3
|
+
* `AppState`, so transitions, de-duplication and reference counting behave exactly
|
|
4
|
+
* as they do on a device.
|
|
5
|
+
*/
|
|
6
|
+
import { type AppLifecyclePort, type AppLifecycleState } from '../runtime/lifecycle';
|
|
7
|
+
export interface ManualLifecycle {
|
|
8
|
+
readonly port: AppLifecyclePort;
|
|
9
|
+
/** Moves the app to `state`, as the OS would. Reporting the current state again is a no-op. */
|
|
10
|
+
set(state: AppLifecycleState): void;
|
|
11
|
+
/** Whether the port holds its (scripted) native subscription. */
|
|
12
|
+
isSubscribed(): boolean;
|
|
13
|
+
}
|
|
14
|
+
export declare function createManualLifecycle(initial?: AppLifecycleState): ManualLifecycle;
|
|
15
|
+
//# sourceMappingURL=lifecycle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lifecycle.d.ts","sourceRoot":"","sources":["../../../../src/testing/lifecycle.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAEN,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EAEtB,MAAM,sBAAsB,CAAC;AAE9B,MAAM,WAAW,eAAe;IAC/B,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAC;IAChC,+FAA+F;IAC/F,GAAG,CAAC,KAAK,EAAE,iBAAiB,GAAG,IAAI,CAAC;IACpC,iEAAiE;IACjE,YAAY,IAAI,OAAO,CAAC;CACxB;AAED,wBAAgB,qBAAqB,CAAC,OAAO,GAAE,iBAA4B,GAAG,eAAe,CAoB5F"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One set of secrets every package's redaction must remove (CORE-02).
|
|
3
|
+
*
|
|
4
|
+
* Packages redact with different policies (identifier-only, pattern-based,
|
|
5
|
+
* key-based), but none of them may let one of these through. Each package runs
|
|
6
|
+
* this against every redaction entrypoint it has; the report is plain data, so it
|
|
7
|
+
* runs in Jest and on a device alike.
|
|
8
|
+
*/
|
|
9
|
+
export interface RedactionProbe {
|
|
10
|
+
readonly name: string;
|
|
11
|
+
/** What is handed to the redactor. */
|
|
12
|
+
readonly input: unknown;
|
|
13
|
+
/** The part that must not appear anywhere in the output. */
|
|
14
|
+
readonly secret: string;
|
|
15
|
+
/** Probes that need key-aware redaction; a string-only redactor skips them. */
|
|
16
|
+
readonly structured?: boolean;
|
|
17
|
+
}
|
|
18
|
+
export declare const REDACTION_PROBES: readonly RedactionProbe[];
|
|
19
|
+
export interface ConformanceFailure {
|
|
20
|
+
readonly check: string;
|
|
21
|
+
readonly detail: string;
|
|
22
|
+
}
|
|
23
|
+
export interface ConformanceReport {
|
|
24
|
+
readonly passed: boolean;
|
|
25
|
+
readonly checks: number;
|
|
26
|
+
readonly failures: readonly ConformanceFailure[];
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Runs every probe through `redact` and reports each secret that survived.
|
|
30
|
+
* `stringsOnly` is for a redactor that only accepts text (rn-auth's `redact`).
|
|
31
|
+
*/
|
|
32
|
+
export declare function redactionConformance(redact: (value: unknown) => unknown, options?: {
|
|
33
|
+
readonly stringsOnly?: boolean;
|
|
34
|
+
}): ConformanceReport;
|
|
35
|
+
//# sourceMappingURL=redaction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redaction.d.ts","sourceRoot":"","sources":["../../../../src/testing/redaction.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,MAAM,WAAW,cAAc;IAC9B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,sCAAsC;IACtC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,4DAA4D;IAC5D,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,+EAA+E;IAC/E,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC;CAC9B;AASD,eAAO,MAAM,gBAAgB,EAAE,SAAS,cAAc,EA2BpD,CAAC;AAEH,MAAM,WAAW,kBAAkB;IAClC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,iBAAiB;IACjC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,QAAQ,EAAE,SAAS,kBAAkB,EAAE,CAAC;CACjD;AAsBD;;;GAGG;AACH,wBAAgB,oBAAoB,CACnC,MAAM,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,OAAO,EACnC,OAAO,GAAE;IAAE,QAAQ,CAAC,WAAW,CAAC,EAAE,OAAO,CAAA;CAAO,GAC9C,iBAAiB,CAmBnB"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A scheduler a test drives by hand: nothing fires until `advance` moves the
|
|
3
|
+
* clock past it, so timing assertions are exact and instant.
|
|
4
|
+
*/
|
|
5
|
+
import type { Scheduler } from '../scheduler';
|
|
6
|
+
export interface ManualScheduler extends Scheduler {
|
|
7
|
+
/** The scheduler's clock, in milliseconds since it was created at `startMs`. */
|
|
8
|
+
now(): number;
|
|
9
|
+
/** Moves the clock forward, firing every timer that falls due, in order. */
|
|
10
|
+
advance(ms: number): void;
|
|
11
|
+
/** Timers scheduled and not yet fired or cleared. */
|
|
12
|
+
pending(): number;
|
|
13
|
+
}
|
|
14
|
+
export declare function createManualScheduler(startMs?: number): ManualScheduler;
|
|
15
|
+
//# sourceMappingURL=scheduler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scheduler.d.ts","sourceRoot":"","sources":["../../../../src/testing/scheduler.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C,MAAM,WAAW,eAAgB,SAAQ,SAAS;IACjD,gFAAgF;IAChF,GAAG,IAAI,MAAM,CAAC;IACd,4EAA4E;IAC5E,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,qDAAqD;IACrD,OAAO,IAAI,MAAM,CAAC;CAClB;AAED,wBAAgB,qBAAqB,CAAC,OAAO,SAAI,GAAG,eAAe,CAoClE"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One diagnostic stream for every package (CORE-08).
|
|
3
|
+
*
|
|
4
|
+
* Each package keeps its own typed events (`AdEvent`, `PaymentEvent`...), and also
|
|
5
|
+
* reports what it observed as an `SdkDiagnostic` through a channel. An app installs
|
|
6
|
+
* one `DiagnosticSink` and receives every package's diagnostics in one shape, so
|
|
7
|
+
* wiring crash reporting or analytics is one adapter rather than ten.
|
|
8
|
+
*
|
|
9
|
+
* Sinks live in a registry anchored on `Symbol.for`, so a sink installed through
|
|
10
|
+
* one copy of rn-core also receives diagnostics from packages bundling another.
|
|
11
|
+
* Every context passes through a redactor before any sink sees it.
|
|
12
|
+
*/
|
|
13
|
+
import type { Unsubscribe } from '../listeners/index.js';
|
|
14
|
+
import { type Redactor } from '../redact/index.js';
|
|
15
|
+
export type DiagnosticSeverity = 'debug' | 'info' | 'warn' | 'error';
|
|
16
|
+
export interface SdkDiagnostic<Code extends string = string> {
|
|
17
|
+
/** The package that reported it, e.g. `rn-payment`. */
|
|
18
|
+
readonly pkg: string;
|
|
19
|
+
/** That package's stable diagnostic or event code. */
|
|
20
|
+
readonly code: Code;
|
|
21
|
+
readonly severity: DiagnosticSeverity;
|
|
22
|
+
/** Epoch milliseconds. */
|
|
23
|
+
readonly at: number;
|
|
24
|
+
/** Ties together everything reported within one operation, when the package has one. */
|
|
25
|
+
readonly correlationId?: string;
|
|
26
|
+
/** Already redacted. */
|
|
27
|
+
readonly context?: Readonly<Record<string, unknown>>;
|
|
28
|
+
}
|
|
29
|
+
export type DiagnosticSink = (diagnostic: SdkDiagnostic) => void;
|
|
30
|
+
/**
|
|
31
|
+
* Sends every package's diagnostics to `sink` until the returned function is
|
|
32
|
+
* called. A sink that throws is reported on a fresh task and never affects the
|
|
33
|
+
* package that emitted.
|
|
34
|
+
*/
|
|
35
|
+
export declare function installSdkSink(sink: DiagnosticSink): Unsubscribe;
|
|
36
|
+
/** Whether any sink is installed, for a package that would do extra work only to feed one. */
|
|
37
|
+
export declare function hasSdkSinks(): boolean;
|
|
38
|
+
export interface DiagnosticChannelOptions {
|
|
39
|
+
/** A package-level sink, in addition to every installed one. */
|
|
40
|
+
readonly sink?: DiagnosticSink | undefined;
|
|
41
|
+
/** Defaults to rn-core's identifier-only redactor. */
|
|
42
|
+
readonly redactor?: Redactor | undefined;
|
|
43
|
+
readonly now?: (() => number) | undefined;
|
|
44
|
+
}
|
|
45
|
+
export interface DiagnosticChannel<Code extends string> {
|
|
46
|
+
emit(code: Code, severity: DiagnosticSeverity, context?: Readonly<Record<string, unknown>>, correlationId?: string): void;
|
|
47
|
+
}
|
|
48
|
+
export declare function createDiagnosticChannel<Code extends string = string>(pkg: string, options?: DiagnosticChannelOptions): DiagnosticChannel<Code>;
|
|
49
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/diagnostics/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAc,CAAC;AAEhD,OAAO,EAAkB,KAAK,QAAQ,EAAE,MAAM,oBAAW,CAAC;AAE1D,MAAM,MAAM,kBAAkB,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AAErE,MAAM,WAAW,aAAa,CAAC,IAAI,SAAS,MAAM,GAAG,MAAM;IAC1D,uDAAuD;IACvD,QAAQ,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A0BzB"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One error model for every @chipmobilesdk package (CORE-11).
|
|
3
|
+
*
|
|
4
|
+
* Each package keeps its own public error class and code union (`AdsError`,
|
|
5
|
+
* `PaymentError`...); those classes extend `SdkError`, so an app can handle any
|
|
6
|
+
* package's failure the same way: a code, whether retrying can help, and a cause
|
|
7
|
+
* that has already been through redaction.
|
|
8
|
+
*
|
|
9
|
+
* `isSdkError` checks a brand rather than `instanceof`, so it holds when an app
|
|
10
|
+
* ends up with two copies of this package (two versions in node_modules), which
|
|
11
|
+
* would make `instanceof SdkError` false for half its errors.
|
|
12
|
+
*/
|
|
13
|
+
export interface SdkErrorOptions {
|
|
14
|
+
/** A message the package wrote itself. Foreign text belongs in `redactedCause`. */
|
|
15
|
+
readonly message?: string | undefined;
|
|
16
|
+
/** Whether the same call can succeed if retried. Defaults to false. */
|
|
17
|
+
readonly retryable?: boolean | undefined;
|
|
18
|
+
/** The underlying failure, already reduced to text that is safe to log. */
|
|
19
|
+
readonly redactedCause?: string | undefined;
|
|
20
|
+
}
|
|
21
|
+
export declare class SdkError<Code extends string = string> extends Error {
|
|
22
|
+
/** The package that raised the error, e.g. `rn-ads`. */
|
|
23
|
+
readonly pkg: string;
|
|
24
|
+
readonly code: Code;
|
|
25
|
+
readonly retryable: boolean;
|
|
26
|
+
readonly redactedCause?: string | undefined;
|
|
27
|
+
constructor(pkg: string, code: Code, options?: SdkErrorOptions);
|
|
28
|
+
}
|
|
29
|
+
/** True for an error raised by any @chipmobilesdk package, from any copy of this one. */
|
|
30
|
+
export declare function isSdkError(value: unknown): value is SdkError;
|
|
31
|
+
export interface ErrorCodes<Code extends string> {
|
|
32
|
+
readonly codes: readonly Code[];
|
|
33
|
+
/** Narrows an arbitrary string to the package's code union. */
|
|
34
|
+
is(value: unknown): value is Code;
|
|
35
|
+
isRetryable(code: Code): boolean;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* A package's closed code set and which of its codes are retryable, declared
|
|
39
|
+
* once instead of a union, an array and a `Set` kept in step by hand.
|
|
40
|
+
*/
|
|
41
|
+
export declare function defineErrorCodes<const Code extends string>(codes: readonly Code[], options?: {
|
|
42
|
+
readonly retryable?: readonly NoInfer<Code>[];
|
|
43
|
+
}): ErrorCodes<Code>;
|
|
44
|
+
export interface ConfigIssue {
|
|
45
|
+
/** Where in the config, e.g. `placements.home.adUnitId`. */
|
|
46
|
+
readonly path: string;
|
|
47
|
+
readonly message: string;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Collects every problem in a config before throwing, so an app sees all of them
|
|
51
|
+
* at once rather than one per fix-and-restart cycle.
|
|
52
|
+
*/
|
|
53
|
+
export declare function createIssueCollector(): {
|
|
54
|
+
add(path: string, message: string): void;
|
|
55
|
+
readonly issues: readonly ConfigIssue[];
|
|
56
|
+
/** Throws what `toError` builds from the issues, when there are any. */
|
|
57
|
+
throwIfAny(toError: (issues: readonly ConfigIssue[]) => Error): void;
|
|
58
|
+
};
|
|
59
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/errors/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH,MAAM,WAAW,eAAe;IAC/B,mFAAmF;IACnF,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACtC,uEAAuE;IACvE,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IACzC,2EAA2E;IAC3E,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC5C;AAED,qBAAa,QAAQ,CAAC,IAAI,SAAS,MAAM,GAAG,MAAM,CAAE,SAAQ,KAAK;IAChE,wDAAwD;IACxD,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,IAAI,EAA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ction mechanism, one way to notify listeners and one
|
|
4
|
+
* diagnostic stream, so every package behaves the same way. Pure TypeScript, no
|
|
5
|
+
* native code.
|
|
6
|
+
*
|
|
7
|
+
* Each module is also its own entrypoint (`@chipmobilesdk/rn-core/errors`,
|
|
8
|
+
* `/redact`, `/listeners`, `/diagnostics`); test helpers are only at
|
|
9
|
+
* `@chipmobilesdk/rn-core/testing`.
|
|
10
|
+
*/
|
|
11
|
+
export { SdkError, createIssueCollector, defineErrorCodes, isSdkError, type ConfigIssue, type ErrorCodes, type SdkErrorOptions, } from './errors/index.js';
|
|
12
|
+
export { COMMON_PATTERNS, PATH_PATTERN, REDACTED, createRedactor, describeShape, leadingIdentifier, pickAllowed, redactPatterns, type RedactPolicy, type Redactor, } from './redact/index.js';
|
|
13
|
+
export { createEmitter, createListenerSet, reportAsynchronously, type DedupeOptions, type Emitter, type EmitterOptions, type ListenerErrorOptions, type ListenerSet, type Unsubscribe, } from './listeners/index.js';
|
|
14
|
+
export { createDiagnosticChannel, hasSdkSinks, installSdkSink, type DiagnosticChannel, type DiagnosticChannelOptions, type DiagnosticSeverity, type DiagnosticSink, type SdkDiagnostic, } from './diagnostics/index.js';
|
|
15
|
+
export { checkInteger, checkRange, computeBackoff, createExclusive, createRateLimiter, createSingleFlight, createTimerSet, realScheduler, runWithRetry, withTimeout, type BackoffSpec, type ExclusiveOutcome, type Range, type RetryHandle, type RetryOptions, type Scheduler, type TimerSet, } from './scheduler/index.js';
|
|
16
|
+
export { lazyPeer, type LazyPeer, type PeerResult } from './lazy/index.js';
|
|
17
|
+
export { createMemoryKeyValue, fromMmkvLike, namespaced, openDurable, type KeyValuePort, type MmkvLike, } from './kv/index.js';
|
|
18
|
+
export { appLifecycle, byPlatform, createAppLifecycle, currentPlatform, isDevBuild, onForeground, setPlatformOverride, type AppLifecyclePort, type AppLifecycleState, type AppStateSource, type BuildEnvironment, type RuntimePlatform, } from './runtime/index.js';
|
|
19
|
+
export { createStore, shallowEqual, type Store } from './store/index.js';
|
|
20
|
+
export { clearIntlCaches, getDateTimeFormat, getNumberFormat, isValidTimeZone } from './intl/index.js';
|
|
21
|
+
export { defineMessages, formatMessage, type CatalogOf, type MessageAudience, type MessageCatalog, type MessageSet, type MessageVars, } from './messages/index.js';
|
|
22
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EACN,QAAQ,EACR,oBAAoB,EACpB,gBAAgB,EAChB,UAAU,EACV,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,eAAe,GACpB,MAAM,mBAAU,CAAC;AAClB,OAAO,EACN,eAAe,EACf,YAAY,EACZ,QAAQ,EACR,cAAc,EACd,aAAa,EACb,iBAAiB,EACjB,WAAW,EACX,cAAc,EACd,KAAK,YAAY,EACjB,KAAK,QAAQ,GACb,MAAM,mBAAU,CAAC;AAClB,OAAO,EACN,aAAa,EACb,iBAAiB,EACjB,oBAAoB,EACpB,KAAK,aAAa,EAClB,KAAK,OAAO,EACZ,KAAK,cAAc,EACnB,KAAK,oBAAoB,EACzB,KAAK,WAAW,EAChB,KAAK,WAAW,GAChB,MAAM,sBAAa,CAAC;AACrB,OAAO,EACN,uBAAuB,EACvB,WAAW,EACX,cAAc,EACd,KAAK,iBAAiB,EACtB,KAAK,wBAAwB,EAC7B,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACnB,KAAK,aAAa,GAClB,MAAM,wBAAe,CAAC;AACvB,OAAO,EACN,YAAY,EACZ,UAAU,EACV,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,kBAAkB,EAClB,cAAc,EACd,aAAa,EACb,YAAY,EACZ,WAAW,EACX,KAAK,WAAW,EAChB,KAAK,gBAAgB,EACrB,KAAK,KAAK,EACV,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,KAAK,QAAQ,GACb,MAAM,sBAAa,CAAC;AACrB,OAAO,EAAE,QAAQ,EAAE,KAAK,QAAQ,EAAE,KAAK,UAAU,EAAE,MAAM,iBAAQ,CAAC;AAClE,OAAO,EACN,oBAAoB,EACpB,YAAY,EACZ,UAAU,EACV,WAAW,EACX,KAAK,YAAY,EACjB,KAAK,QAAQ,GACb,MAAM,eAAM,CAAC;AACd,OAAO,EACN,YAAY,EACZ,UAAU,EACV,kBAAkB,EAClB,eAAe,EACf,UAAU,EACV,YAAY,EACZ,mBAAmB,EACnB,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACtB,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,eAAe,GACpB,MAAM,oBAAW,CAAC;AACnB,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,KAAK,KAAK,EAAE,MAAM,kBAAS,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,iBAAQ,CAAC;AAC9F,OAAO,EACN,cAAc,EACd,aAAa,EACb,KAAK,SAAS,EACd,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,UAAU,EACf,KAAK,WAAW,GAChB,MAAM,qBAAY,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cached `Intl` formatters (PERF-01, PERF-08, I18N-03, NOT-20).
|
|
3
|
+
*
|
|
4
|
+
* Constructing an `Intl.DateTimeFormat` or `Intl.NumberFormat` is expensive on
|
|
5
|
+
* Hermes, and rn-notification built one per time-zone calculation (thousands in a
|
|
6
|
+
* recurrence expansion) while rn-i18n built one per formatted value. Formatters
|
|
7
|
+
* are immutable once built, so one per (locale, options) is shared. Each cache is
|
|
8
|
+
* a small LRU: the working set is a few locales and zones, and an app that cycles
|
|
9
|
+
* through many still holds a bounded number.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* A shared `Intl.NumberFormat`. Throws what the constructor throws (an unknown
|
|
13
|
+
* currency, say): callers decide how a bad option is reported.
|
|
14
|
+
*/
|
|
15
|
+
export declare function getNumberFormat(locale: string | undefined, options?: Intl.NumberFormatOptions): Intl.NumberFormat;
|
|
16
|
+
/** A shared `Intl.DateTimeFormat`. Throws what the constructor throws. */
|
|
17
|
+
export declare function getDateTimeFormat(locale: string | undefined, options?: Intl.DateTimeFormatOptions): Intl.DateTimeFormat;
|
|
18
|
+
/**
|
|
19
|
+
* Whether `Intl` accepts the IANA zone, memoized. Hermes raises a hard error for
|
|
20
|
+
* an unknown zone, so a stored zone is checked here before it reaches `Intl`.
|
|
21
|
+
*/
|
|
22
|
+
export declare function isValidTimeZone(timeZone: string): boolean;
|
|
23
|
+
/** Test seam: drops every cached formatter and zone check. */
|
|
24
|
+
export declare function clearIntlCaches(): void;
|
|
25
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/intl/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AA0CH;;;GAGG;AACH,wBAAgB,eAAe,CAC9B,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,OAAO,CAAC,EAAE,IAAI,CAAC,mBAAmB,GAChC,IAAI,CAAC,YAAY,CAEnB;AAED,0EAA0E;AAC1E,wBAAgB,iBAAiB,CAChC,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,OAAO,CAAC,EAAE,IAAI,CAAC,qBAAqB,GAClC,IAAI,CAAC,cAAc,CAKrB;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAczD;AAED,8DAA8D;AAC9D,wBAAgB,eAAe,IAAI,IAAI,CAItC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A synchronous key-value port (DEP-09, NOT-15, PERF-09).
|
|
3
|
+
*
|
|
4
|
+
* rn-payment and rn-notification each wrapped MMKV themselves, and one of them
|
|
5
|
+
* fell back to memory without telling anyone. Here the port says whether it is
|
|
6
|
+
* `durable`, and `openDurable` reports the fallback through `onDegraded`, so a
|
|
7
|
+
* package can emit its own diagnostic instead of silently losing state.
|
|
8
|
+
*
|
|
9
|
+
* rn-core never requires a storage peer itself: the package opens MMKV (or any
|
|
10
|
+
* store with the same shape) and hands it over as an `MmkvLike`.
|
|
11
|
+
*/
|
|
12
|
+
export interface KeyValuePort {
|
|
13
|
+
getString(key: string): string | undefined;
|
|
14
|
+
set(key: string, value: string): void;
|
|
15
|
+
remove(key: string): void;
|
|
16
|
+
keys(): string[];
|
|
17
|
+
clearAll(): void;
|
|
18
|
+
/** False when writes do not survive a restart: the memory fallback. */
|
|
19
|
+
readonly durable: boolean;
|
|
20
|
+
}
|
|
21
|
+
/** The slice of a react-native-mmkv v4 instance the port uses. */
|
|
22
|
+
export interface MmkvLike {
|
|
23
|
+
getString(key: string): string | undefined;
|
|
24
|
+
set(key: string, value: string): void;
|
|
25
|
+
remove(key: string): unknown;
|
|
26
|
+
getAllKeys(): string[];
|
|
27
|
+
clearAll(): void;
|
|
28
|
+
}
|
|
29
|
+
export declare function createMemoryKeyValue(): KeyValuePort;
|
|
30
|
+
export declare function fromMmkvLike(store: MmkvLike): KeyValuePort;
|
|
31
|
+
/**
|
|
32
|
+
* Opens the durable store, or falls back to memory and says so: `onDegraded`
|
|
33
|
+
* receives the reason once, and the returned port reports `durable: false`.
|
|
34
|
+
*/
|
|
35
|
+
export declare function openDurable(open: () => MmkvLike, onDegraded?: (cause: unknown) => void): KeyValuePort;
|
|
36
|
+
/** Keys under `prefix:` only, so several owners can share one store. */
|
|
37
|
+
export declare function namespaced(port: KeyValuePort, prefix: string): KeyValuePort;
|
|
38
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/kv/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,MAAM,WAAW,YAAY;IAC5B,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;IAC3C,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACtC,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,IAAI,IAAI,MAAM,EAAE,CAAC;IACjB,QAAQ,IAAI,IAAI,CAAC;IACjB,uEAAuE;IACvE,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;CAC1B;AAED,kEAAkE;AAClE,MAAM,WAAW,QAAQ;IACxB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;IAC3C,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACtC,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;IAC7B,UAAU,IAAI,MAAM,EAAE,CAAC;IACvB,QAAQ,IAAI,IAAI,CAAC;CACjB;AAED,wBAAgB,oBAAoB,IAAI,YAAY,CAcnD;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,QAAQ,GAAG,YAAY,CAW1D;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAC1B,IAAI,EAAE,MAAM,QAAQ,EACpB,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,GACnC,YAAY,CAOd;AAED,wEAAwE;AACxE,wBAAgB,UAAU,CAAC,IAAI,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,GAAG,YAAY,CAoB3E"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lazy native peers (CORE-06).
|
|
3
|
+
*
|
|
4
|
+
* Every package loads its native peer on first use, so importing a package where
|
|
5
|
+
* the peer is absent (an unsupported platform, a build that excludes it) costs
|
|
6
|
+
* nothing and crashes nothing. There were 18 hand-written `require()` sites with
|
|
7
|
+
* four different failure policies, some silent. Here, one: the load runs once,
|
|
8
|
+
* its result (module or failure) is cached, and a missing peer is a typed result
|
|
9
|
+
* the package maps to its own error code.
|
|
10
|
+
*
|
|
11
|
+
* The `load` thunk must contain the literal `require('peer-name')` and live in the
|
|
12
|
+
* package that depends on the peer, so Metro sees and bundles it there.
|
|
13
|
+
*/
|
|
14
|
+
export type PeerResult<T> = {
|
|
15
|
+
readonly ok: true;
|
|
16
|
+
readonly module: T;
|
|
17
|
+
} | {
|
|
18
|
+
readonly ok: false;
|
|
19
|
+
readonly peer: string;
|
|
20
|
+
readonly cause: unknown;
|
|
21
|
+
};
|
|
22
|
+
export interface LazyPeer<T> {
|
|
23
|
+
readonly name: string;
|
|
24
|
+
/** Loads on the first call and caches the outcome. Never throws. */
|
|
25
|
+
get(): PeerResult<T>;
|
|
26
|
+
/** The module, or throws what `fail` builds: the package's own "peer missing" error. */
|
|
27
|
+
require(fail: (peer: string, cause: unknown) => Error): T;
|
|
28
|
+
isAvailable(): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Test seam: a fake module, `null` to simulate the peer being absent, or
|
|
31
|
+
* `undefined` to go back to really loading it.
|
|
32
|
+
*/
|
|
33
|
+
override(fake: T | null | undefined): void;
|
|
34
|
+
}
|
|
35
|
+
export declare function lazyPeer<T>(name: string, load: () => T): LazyPeer<T>;
|
|
36
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lazy/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,MAAM,MAAM,UAAU,CAAC,CAAC,IACrB;IAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAA;CAAE,GACzC;IAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAA;CAAE,CAAC;AAE1E,MAAM,WAAW,QAAQ,CAAC,CAAC;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,oEAAoE;IACpE,GAAG,IAAI,UAAU,CAAC,CAAC,CAAC,CAAC;IACrB,wFAAwF;IACxF,OAAO,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,KAAK,KAAK,GAAG,CAAC,CAAC;IAC1D,WAAW,IAAI,OAAO,CAAC;IACvB;;;OAGG;IACH,QAAQ,CAAC,IAAI,EAAE,CAAC,GAAG,IAAI,GAAG,SAAS,GAAG,IAAI,CAAC;CAC3C;AAED,wBAAgB,QAAQ,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAkCpE"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Listener sets and event emitters (CORE-03, CORE-08, CORE-12).
|
|
3
|
+
*
|
|
4
|
+
* Every package used to keep its own `Set<listener>` and loop over it. Three of
|
|
5
|
+
* them let a throwing subscriber escape into the code that was notifying, which
|
|
6
|
+
* left a state machine half-updated. Here, once:
|
|
7
|
+
*
|
|
8
|
+
* - `notify` iterates a snapshot: a listener added during a round waits for the
|
|
9
|
+
* next one, and a listener removed during a round is not called, so a consumer
|
|
10
|
+
* that unsubscribed (an unmounted component) is never reached;
|
|
11
|
+
* - each listener runs in its own try/catch, so one throwing subscriber neither
|
|
12
|
+
* stops the others nor reaches the caller;
|
|
13
|
+
* - a listener's error is reported, never swallowed: to `onListenerError` when
|
|
14
|
+
* given, otherwise rethrown on a fresh task, where the app's global error
|
|
15
|
+
* handler and crash reporter see it;
|
|
16
|
+
* - unsubscribing twice is a no-op.
|
|
17
|
+
*/
|
|
18
|
+
export type Unsubscribe = () => void;
|
|
19
|
+
export interface ListenerErrorOptions {
|
|
20
|
+
/**
|
|
21
|
+
* Receives an error a listener threw. Errors raised while this handler runs
|
|
22
|
+
* (say, by a listener it notifies) are dropped rather than reported again, so
|
|
23
|
+
* a failing reporter cannot recurse forever.
|
|
24
|
+
*/
|
|
25
|
+
readonly onListenerError?: ((error: unknown) => void) | undefined;
|
|
26
|
+
}
|
|
27
|
+
/** Rethrows on a fresh task: outside every caller, inside the app's error handler. */
|
|
28
|
+
export declare function reportAsynchronously(error: unknown): void;
|
|
29
|
+
export interface ListenerSet<Args extends unknown[]> {
|
|
30
|
+
/** Adds a listener; the returned function removes it, once. */
|
|
31
|
+
add(listener: (...args: Args) => void): Unsubscribe;
|
|
32
|
+
/** Calls every listener present when the call starts, each in isolation. */
|
|
33
|
+
notify(...args: Args): void;
|
|
34
|
+
readonly size: number;
|
|
35
|
+
clear(): void;
|
|
36
|
+
}
|
|
37
|
+
export declare function createListenerSet<Args extends unknown[] = []>(options?: ListenerErrorOptions): ListenerSet<Args>;
|
|
38
|
+
export interface DedupeOptions<Event> {
|
|
39
|
+
/** The identity of an event that must reach listeners at most once; undefined to never dedupe. */
|
|
40
|
+
readonly key: (event: Event) => string | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* How many keys are remembered. The oldest is forgotten first, so memory stays
|
|
43
|
+
* bounded however long the emitter lives (CORE-12).
|
|
44
|
+
*/
|
|
45
|
+
readonly capacity: number;
|
|
46
|
+
}
|
|
47
|
+
export interface EmitterOptions<Event> extends ListenerErrorOptions {
|
|
48
|
+
readonly dedupe?: DedupeOptions<Event> | undefined;
|
|
49
|
+
}
|
|
50
|
+
export interface Emitter<Event> {
|
|
51
|
+
/** Delivers the event; false when it was a duplicate or the emitter is disposed. */
|
|
52
|
+
emit(event: Event): boolean;
|
|
53
|
+
subscribe(listener: (event: Event) => void): Unsubscribe;
|
|
54
|
+
/** Forgets the dedupe keys `matches` selects, e.g. when a cycle ends. */
|
|
55
|
+
forget(matches: (key: string) => boolean): void;
|
|
56
|
+
/** Drops every listener and dedupe key; later emits do nothing. */
|
|
57
|
+
dispose(): void;
|
|
58
|
+
listenerCount(): number;
|
|
59
|
+
}
|
|
60
|
+
export declare function createEmitter<Event>(options?: EmitterOptions<Event>): Emitter<Event>;
|
|
61
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/listeners/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,MAAM,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC;AAErC,MAAM,WAAW,oBAAoB;IACpC;;;;OAIG;IACH,QAAQ,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;CAClE;AAED,sFAAsF;AACtF,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAIzD;AAED,MAAM,WAAW,WAAW,CAAC,IAAI,SAAS,OAAO,EAAE;IAClD,+DAA+D;IAC/D,GAAG,CAAC,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,IAAI,GAAG,WAAW,CAAC;IACpD,4EAA4E;IAC5E,MAAM,CAAC,GAAG,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC;IAC5B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,KAAK,IAAI,IAAI,CAAC;CACd;AAED,wBAAgB,iBAAiB,CAAC,IAAI,SAAS,OAAO,EAAE,GAAG,EAAE,EAC5D,OAAO,GAAE,oBAAyB,GAChC,WAAW,CAAC,IAAI,CAAC,CA4CnB;AAED,MAAM,WAAW,aAAa,CAAC,KAAK;IACnC,kGAAkG;IAClG,QAAQ,CAAC,GAAG,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,MAAM,GAAG,SAAS,CAAC;IACnD;;;OAGG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,cAAc,CAAC,KAAK,CAAE,SAAQ,oBAAoB;IAClE,QAAQ,CAAC,MAAM,CAAC,EAAE,aAAa,CAAC,KAAK,CAAC,GAAG,SAAS,CAAC;CACnD;AAED,MAAM,WAAW,OAAO,CAAC,KAAK;IAC7B,oFAAoF;IACpF,IAAI,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC;IAC5B,SAAS,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,GAAG,WAAW,CAAC;IACzD,yEAAyE;IACzE,MAAM,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,GAAG,IAAI,CAAC;IAChD,mEAAmE;IACnE,OAAO,IAAI,IAAI,CAAC;IAChB,aAAa,IAAI,MAAM,CAAC;CACxB;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAE,cAAc,CAAC,KAAK,CAAM,GAAG,OAAO,CAAC,KAAK,CAAC,CAkCxF"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Message catalogs (CORE-15, I18N-13, AUTH-16, AI-15).
|
|
3
|
+
*
|
|
4
|
+
* rn-ai, rn-auth and rn-payment each kept their copy keys in a different shape.
|
|
5
|
+
* One shape now: a catalog of default texts split by audience. `user` copy may
|
|
6
|
+
* reach an end user; `developer` copy describes a configuration fault and must
|
|
7
|
+
* never be shown to one. A catalog is plain data (`key -> default text`), so rn-i18n
|
|
8
|
+
* can register any package's catalog in one call and translate it like app copy.
|
|
9
|
+
*/
|
|
10
|
+
/** Message key to default text. `{name}` marks a variable. */
|
|
11
|
+
export type MessageCatalog = Readonly<Record<string, string>>;
|
|
12
|
+
export type MessageAudience = 'user' | 'developer';
|
|
13
|
+
/** Any object whose every key maps to a string; interfaces qualify, unlike an index signature. */
|
|
14
|
+
export type CatalogOf<T> = {
|
|
15
|
+
readonly [K in keyof T]: string;
|
|
16
|
+
};
|
|
17
|
+
export interface MessageSet<User extends CatalogOf<User>, Developer extends CatalogOf<Developer>> {
|
|
18
|
+
/** Every default text, both audiences. */
|
|
19
|
+
readonly defaults: Readonly<User & Developer>;
|
|
20
|
+
/** The copy that may reach an end user: what an app registers for translation. */
|
|
21
|
+
readonly user: Readonly<User>;
|
|
22
|
+
/** Configuration-fault copy for developers; never shown to an end user. */
|
|
23
|
+
readonly developer: Readonly<Developer>;
|
|
24
|
+
readonly userKeys: readonly (keyof User & string)[];
|
|
25
|
+
readonly developerKeys: readonly (keyof Developer & string)[];
|
|
26
|
+
/** The defaults with the app's own texts laid over them. */
|
|
27
|
+
resolve(overrides?: Partial<User & Developer>): User & Developer;
|
|
28
|
+
audienceOf(key: keyof User | keyof Developer): MessageAudience;
|
|
29
|
+
/** A key's default text with `{name}` variables filled in. */
|
|
30
|
+
format(key: keyof User | keyof Developer, vars?: MessageVars): string;
|
|
31
|
+
}
|
|
32
|
+
export type MessageVars = Readonly<Record<string, string | number>>;
|
|
33
|
+
/** Fills `{name}` placeholders; a placeholder with no value is left as written. */
|
|
34
|
+
export declare function formatMessage(template: string, vars?: MessageVars): string;
|
|
35
|
+
export declare function defineMessages<User extends CatalogOf<User>, Developer extends CatalogOf<Developer> = Record<never, string>>(catalog: {
|
|
36
|
+
readonly user: User;
|
|
37
|
+
readonly developer?: Developer;
|
|
38
|
+
}): MessageSet<User, Developer>;
|
|
39
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/messages/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,8DAA8D;AAC9D,MAAM,MAAM,cAAc,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AAE9D,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,WAAW,CAAC;AAEnD,kGAAkG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C,IAAI,CAAC,EAC5B,SAAS,SAAS,SAAS,CAAC,SAAS,CAAC,GAAG,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,EAC7D,OAAO,EAAE;IAAE,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,CAAA;CAAE,GAAG,UAAU,CAAC,IAAI,EAAE,SAAS,CAAC,CAiB/F"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"module"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React glue every package shares (CORE-07, PERF-04).
|
|
3
|
+
*
|
|
4
|
+
* Packages used to mirror their state into `useState` from a `useEffect`
|
|
5
|
+
* subscription: one render late, a tearing risk under concurrent rendering, and
|
|
6
|
+
* every consumer re-rendered on every change. Here, one way:
|
|
7
|
+
* `useSyncExternalStore` over a store whose snapshot keeps its identity until it
|
|
8
|
+
* actually changes, with a selector so a component re-renders only when the part
|
|
9
|
+
* it reads changes.
|
|
10
|
+
*
|
|
11
|
+
* `react` is an optional peer of rn-core, needed only for this entrypoint.
|
|
12
|
+
*/
|
|
13
|
+
import { type ReactNode } from 'react';
|
|
14
|
+
import type { Unsubscribe } from '../listeners/index.js';
|
|
15
|
+
/**
|
|
16
|
+
* Reads an external store. With `select`, the component re-renders only when the
|
|
17
|
+
* selected value changes by `isEqual` (default `Object.is`), however often the
|
|
18
|
+
* store itself changes.
|
|
19
|
+
*/
|
|
20
|
+
export declare function useExternalStore<Snapshot, Selected = Snapshot>(subscribe: (listener: () => void) => Unsubscribe, getSnapshot: () => Snapshot, select?: (snapshot: Snapshot) => Selected, isEqual?: (a: Selected, b: Selected) => boolean): Selected;
|
|
21
|
+
/**
|
|
22
|
+
* A callback whose identity never changes but which always calls the latest
|
|
23
|
+
* `fn`, for listeners an app passes inline that must not re-run an effect.
|
|
24
|
+
*/
|
|
25
|
+
export declare function useLatestCallback<Args extends unknown[], Result>(fn: (...args: Args) => Result): (...args: Args) => Result;
|
|
26
|
+
/**
|
|
27
|
+
* A context with a Provider and a hook that throws a clear error outside it,
|
|
28
|
+
* instead of returning `undefined` for a missing provider.
|
|
29
|
+
*/
|
|
30
|
+
export declare function createSdkContext<T>(name: string): {
|
|
31
|
+
Context: import("react").Context<T | null>;
|
|
32
|
+
Provider: ({ value, children }: {
|
|
33
|
+
value: T;
|
|
34
|
+
children?: ReactNode;
|
|
35
|
+
}) => import("react").FunctionComponentElement<import("react").ProviderProps<T | null>>;
|
|
36
|
+
use: () => T;
|
|
37
|
+
};
|
|
38
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/react/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAON,KAAK,SAAS,EACd,MAAM,OAAO,CAAC;AAEf,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAc,CAAC;AAMhD;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,GAAG,QAAQ,EAC7D,SAAS,EAAE,CAAC,QAAQ,EAAE,MAAM,IAAI,KAAK,WAAW,EAChD,WAAW,EAAE,MAAM,QAAQ,EAC3B,MAAM,GAAE,CAAC,QAAQ,EAAE,QAAQ,KAAK,QAAuD,EACvF,OAAO,GAAE,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,QAAQ,KAAK,OAAmB,GACxD,QAAQ,CAeV;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,SAAS,OAAO,EAAE,EAAE,MAAM,EAC/D,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,MAAM,GAC3B,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,MAAM,CAI3B;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM;;oCAIR;QAAE,KAAK,EAAE,CAAC,CAAC;QAAC,QAAQ,CAAC,EAAE,SAAS,CAAA;KAAE;eAIzD,CAAC;EASjB"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export declare const REDACTED = "[redacted]";
|
|
2
|
+
/**
|
|
3
|
+
* Shapes that are a secret or an identifier wherever they appear. Order matters:
|
|
4
|
+
* a URL is replaced whole before its parts could match anything narrower.
|
|
5
|
+
*/
|
|
6
|
+
export declare const COMMON_PATTERNS: readonly RegExp[];
|
|
7
|
+
/** File paths: file URIs are URLs already; this adds POSIX and Windows paths. */
|
|
8
|
+
export declare const PATH_PATTERN: RegExp;
|
|
9
|
+
/** Replaces every match of every pattern with `[redacted]`. */
|
|
10
|
+
export declare function redactPatterns(text: string, patterns?: readonly RegExp[]): string;
|
|
11
|
+
/**
|
|
12
|
+
* Reduces text this package did not write to a leading engine identifier, or to
|
|
13
|
+
* `[redacted]`. No shape test separates prose describing a failure from prose
|
|
14
|
+
* describing a person, so prose never survives.
|
|
15
|
+
*/
|
|
16
|
+
export declare function leadingIdentifier(text: string): string;
|
|
17
|
+
/** A value's shape without its content: `[string:12]`, `[array:3]`, `[object:2]`. */
|
|
18
|
+
export declare function describeShape(value: unknown): string;
|
|
19
|
+
/** Keeps only allowlisted keys, and only their primitive values. */
|
|
20
|
+
export declare function pickAllowed(detail: Readonly<Record<string, unknown>> | undefined, allow: ReadonlySet<string>): Record<string, string | number | boolean> | undefined;
|
|
21
|
+
export interface RedactPolicy {
|
|
22
|
+
/**
|
|
23
|
+
* How free text is reduced. `identifier` (the default) keeps only a leading
|
|
24
|
+
* engine constant; `patterns` keeps prose and replaces secret-shaped runs.
|
|
25
|
+
*/
|
|
26
|
+
readonly text?: 'identifier' | 'patterns' | undefined;
|
|
27
|
+
/** Patterns for `patterns` text, applied after `COMMON_PATTERNS`. */
|
|
28
|
+
readonly patterns?: readonly RegExp[] | undefined;
|
|
29
|
+
/** Keys whose values are dropped wholesale when an object is rendered. */
|
|
30
|
+
readonly dropKeys?: Iterable<string> | undefined;
|
|
31
|
+
/** Keys `detail()` lets through. */
|
|
32
|
+
readonly allowDetailKeys?: Iterable<string> | undefined;
|
|
33
|
+
/** Keys whose values `context()` replaces by their shape. */
|
|
34
|
+
readonly shapeKeys?: Iterable<string> | undefined;
|
|
35
|
+
/** How deep objects are rendered or walked. Defaults to 2 for text, 6 for context. */
|
|
36
|
+
readonly maxDepth?: number | undefined;
|
|
37
|
+
}
|
|
38
|
+
export interface Redactor {
|
|
39
|
+
/** Any value as one safe string. An SDK error becomes its code. */
|
|
40
|
+
text(value: unknown): string;
|
|
41
|
+
/** A diagnostic detail reduced to its allowlisted primitive values. */
|
|
42
|
+
detail(detail: Readonly<Record<string, unknown>> | undefined): Record<string, string | number | boolean> | undefined;
|
|
43
|
+
/** A diagnostic context with content replaced by shape and strings redacted. */
|
|
44
|
+
context(context: Readonly<Record<string, unknown>> | undefined): Readonly<Record<string, unknown>> | undefined;
|
|
45
|
+
}
|
|
46
|
+
export declare function createRedactor(policy?: RedactPolicy): Redactor;
|
|
47
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/redact/index.ts"],"names":[],"mappings":"AAqBA,eAAO,MAAM,QAAQ,eAAe,CAAC;AAErC;;;GAGG;AACH,eAAO,MAAM,eAAe,EAAE,SAAS,MAAM,EAW3C,CAAC;AAEH,iFAAiF;AACjF,eAAO,MAAM,YAAY,QAAyD,CAAC;AAInF,+DAA+D;AAC/D,wBAAgB,cAAc,CAC7B,IAAI,EAAE,MAAM,EACZ,QAAQ,GAAE,SAAS,MAAM,EAAoB,GAC3C,MAAM,CAER;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAItD;AAED,qFAAqF;AACrF,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAOpD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