@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,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,C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AAG,IAAI;qBAG1B,SAAS,WAAW,EAAE;IAGpC,wEAAwE;wBACpD,CAAC,MAAM,EAAE,SAAS,WAAW,EAAE,KAAK,KAAK,GAAG,IAAI;EAMrE"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @chipmobilesdk/rn-core — the shared foundation of the @chipmobilesdk packages:
|
|
3
|
+
* one error model, one redaction 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';
|
|
12
|
+
export { COMMON_PATTERNS, PATH_PATTERN, REDACTED, createRedactor, describeShape, leadingIdentifier, pickAllowed, redactPatterns, type RedactPolicy, type Redactor, } from './redact';
|
|
13
|
+
export { createEmitter, createListenerSet, reportAsynchronously, type DedupeOptions, type Emitter, type EmitterOptions, type ListenerErrorOptions, type ListenerSet, type Unsubscribe, } from './listeners';
|
|
14
|
+
export { createDiagnosticChannel, hasSdkSinks, installSdkSink, type DiagnosticChannel, type DiagnosticChannelOptions, type DiagnosticSeverity, type DiagnosticSink, type SdkDiagnostic, } from './diagnostics';
|
|
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';
|
|
16
|
+
export { lazyPeer, type LazyPeer, type PeerResult } from './lazy';
|
|
17
|
+
export { createMemoryKeyValue, fromMmkvLike, namespaced, openDurable, type KeyValuePort, type MmkvLike, } from './kv';
|
|
18
|
+
export { appLifecycle, byPlatform, createAppLifecycle, currentPlatform, isDevBuild, onForeground, setPlatformOverride, type AppLifecyclePort, type AppLifecycleState, type AppStateSource, type BuildEnvironment, type RuntimePlatform, } from './runtime';
|
|
19
|
+
export { createStore, shallowEqual, type Store } from './store';
|
|
20
|
+
export { clearIntlCaches, getDateTimeFormat, getNumberFormat, isValidTimeZone } from './intl';
|
|
21
|
+
export { defineMessages, formatMessage, type CatalogOf, type MessageAudience, type MessageCatalog, type MessageSet, type MessageVars, } from './messages';
|
|
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,UAAU,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,UAAU,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,aAAa,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,eAAe,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,aAAa,CAAC;AACrB,OAAO,EAAE,QAAQ,EAAE,KAAK,QAAQ,EAAE,KAAK,UAAU,EAAE,MAAM,QAAQ,CAAC;AAClE,OAAO,EACN,oBAAoB,EACpB,YAAY,EACZ,UAAU,EACV,WAAW,EACX,KAAK,YAAY,EACjB,KAAK,QAAQ,GACb,MAAM,MAAM,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,WAAW,CAAC;AACnB,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,KAAK,KAAK,EAAE,MAAM,SAAS,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAC9F,OAAO,EACN,cAAc,EACd,aAAa,EACb,KAAK,SAAS,EACd,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,UAAU,EACf,KAAK,WAAW,GAChB,MAAM,YAAY,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;;;;;;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G,MAAM,CAAC,CAAC,CAAC;AAEpE,mFAAmF;AACnF,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,WAAW,GAAG,MAAM,CAK1E;AAED,wBAAgB,cAAc,CAC7B,IAAI,SAAS,SAAS,CAAC,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":"commonjs"}
|
|
@@ -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';
|
|
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,cAAc,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,MA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EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,GAAG,SAAS,CAAC;IACzD,gFAAgF;IAChF,OAAO,CACN,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,SAAS,GACpD,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC;CACjD;AAED,wBAAgB,cAAc,CAAC,MAAM,GAAE,YAAiB,GAAG,QAAQ,CAoDlE"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export type RuntimePlatform = 'android' | 'ios' | 'unsupported';
|
|
2
|
+
/** What a build is for. A package may refuse production configuration elsewhere. */
|
|
3
|
+
export type BuildEnvironment = 'development' | 'test' | 'production';
|
|
4
|
+
/** The OS the app runs on, or `unsupported` (web, Node, a platform with no adapter). */
|
|
5
|
+
export declare function currentPlatform(): RuntimePlatform;
|
|
6
|
+
/** Test seam: pins `currentPlatform()`; `undefined` goes back to the real one. */
|
|
7
|
+
export declare function setPlatformOverride(platform: RuntimePlatform | undefined): void;
|
|
8
|
+
/** Picks a value for the current platform, falling back to `default`. */
|
|
9
|
+
export declare function byPlatform<T>(values: {
|
|
10
|
+
readonly android?: T;
|
|
11
|
+
readonly ios?: T;
|
|
12
|
+
readonly default: T;
|
|
13
|
+
}): T;
|
|
14
|
+
/**
|
|
15
|
+
* Whether this is a development build: React Native's `__DEV__`, or, where that
|
|
16
|
+
* global does not exist (plain Node, some test runners), `NODE_ENV` not being
|
|
17
|
+
* `production`.
|
|
18
|
+
*/
|
|
19
|
+
export declare function isDevBuild(): boolean;
|
|
20
|
+
export { appLifecycle, createAppLifecycle, onForeground, type AppLifecyclePort, type AppLifecycleState, type AppStateSource, } from './lifecycle';
|
|
21
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/runtime/index.ts"],"names":[],"mappings":"AAUA,MAAM,MAAM,eAAe,GAAG,SAAS,GAAG,KAAK,GAAG,aAAa,CAAC;AAEhE,oFAAoF;AACpF,MAAM,MAAM,gBAAgB,GAAG,aAAa,GAAG,MAAM,GAAG,YAAY,CAAC;AAarE,wFAAwF;AACxF,wBAAgB,eAAe,IAAI,eAAe,CAKjD;AAED,kFAAkF;AAClF,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,eAAe,GAAG,SAAS,GAAG,IAAI,CAE/E;AAED,yEAAyE;AACzE,wBAAgB,UAAU,CAAC,CAAC,EAAE,MAAM,EAAE;IACrC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IACrB,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IACjB,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC;CACpB,GAAG,CAAC,CAKJ;AAED;;;;GAIG;AACH,wBAAgB,UAAU,IAAI,OAAO,CAIpC;AAED,OAAO,EACN,YAAY,EACZ,kBAAkB,EAClB,YAAY,EACZ,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACtB,KAAK,cAAc,GACnB,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { type Unsubscribe } from '../listeners';
|
|
2
|
+
export type AppLifecycleState = 'active' | 'inactive' | 'background';
|
|
3
|
+
export interface AppLifecyclePort {
|
|
4
|
+
/** The state now. */
|
|
5
|
+
current(): AppLifecycleState;
|
|
6
|
+
/**
|
|
7
|
+
* Called on every change of state, with the state before it. Repeated reports
|
|
8
|
+
* of the same state are not changes. The returned function removes the
|
|
9
|
+
* listener, once.
|
|
10
|
+
*/
|
|
11
|
+
subscribe(listener: (state: AppLifecycleState, previous: AppLifecycleState) => void): Unsubscribe;
|
|
12
|
+
/** How many listeners are attached; the native subscription lives while this is above zero. */
|
|
13
|
+
readonly listenerCount: number;
|
|
14
|
+
}
|
|
15
|
+
/** The slice of React Native's `AppState` the port reads. */
|
|
16
|
+
export interface AppStateSource {
|
|
17
|
+
readonly currentState?: string | null;
|
|
18
|
+
addEventListener(type: 'change', listener: (state: string) => void): {
|
|
19
|
+
remove(): void;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* A lifecycle port over `source`, React Native's `AppState` by default. Packages use
|
|
24
|
+
* the shared `appLifecycle()`; this is for tests and for an app with its own source.
|
|
25
|
+
*/
|
|
26
|
+
export declare function createAppLifecycle(source?: () => AppStateSource | undefined): AppLifecyclePort;
|
|
27
|
+
/** The app's lifecycle, shared by every package so there is one native subscription. */
|
|
28
|
+
export declare function appLifecycle(): AppLifecyclePort;
|
|
29
|
+
/**
|
|
30
|
+
* Calls `listener` each time the app comes back from the background. A trip through
|
|
31
|
+
* `inactive` alone (iOS Control Center, an incoming-call banner) is not a return.
|
|
32
|
+
*/
|
|
33
|
+
export declare function onForeground(listener: () => void, port?: AppLifecyclePort): Unsubscribe;
|
|
34
|
+
//# sourceMappingURL=lifecycle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lifecycle.d.ts","sourceRoot":"","sources":["../../../../src/runtime/lifecycle.ts"],"names":[],"mappings":"AAaA,OAAO,EAAqB,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAEnE,MAAM,MAAM,iBAAiB,GAAG,QAAQ,GAAG,UAAU,GAAG,YAAY,CAAC;AAErE,MAAM,WAAW,gBAAgB;IAChC,qBAAqB;IACrB,OAAO,IAAI,iBAAiB,CAAC;IAC7B;;;;OAIG;IACH,SAAS,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,iBAAiB,EAAE,QAAQ,EAAE,iBAAiB,KAAK,IAAI,GAAG,WAAW,CAAC;IAClG,+FAA+F;IAC/F,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;CAC/B;AAED,6DAA6D;AAC7D,MAAM,WAAW,cAAc;IAC9B,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtC,gBAAgB,CAAC,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,GAAG;QAAE,MAAM,IAAI,IAAI,CAAA;KAAE,CAAC;CACxF;AAwBD;;;GAGG;AACH,wBAAgB,kBAAkB,CACjC,MAAM,GAAE,MAAM,cAAc,GAAG,SAAyB,GACtD,gBAAgB,CAyClB;AAID,wFAAwF;AACxF,wBAAgB,YAAY,IAAI,gBAAgB,CAG/C;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAC3B,QAAQ,EAAE,MAAM,IAAI,EACpB,IAAI,GAAE,gBAAiC,GACrC,WAAW,CAUb"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Time, retries, concurrency and bounds, shared by every package (CORE-04,
|
|
3
|
+
* CORE-05).
|
|
4
|
+
*
|
|
5
|
+
* rn-ads and rn-payment each had their own copy of these, and the copies had
|
|
6
|
+
* drifted: one validated a backoff and the other did not, one reported a retry
|
|
7
|
+
* policy out of bounds under a timeout's error code. Packages keep their domain
|
|
8
|
+
* defaults and bounds; the mechanism lives here, and bounds checks take a `fail`
|
|
9
|
+
* callback so each package raises its own error with its own code.
|
|
10
|
+
*/
|
|
11
|
+
import { type Unsubscribe } from '../listeners';
|
|
12
|
+
/**
|
|
13
|
+
* How timers are scheduled. Injectable so a test drives backoff and expiry by
|
|
14
|
+
* moving a clock instead of waiting.
|
|
15
|
+
*/
|
|
16
|
+
export interface Scheduler {
|
|
17
|
+
setTimeout(callback: () => void, ms: number): unknown;
|
|
18
|
+
clearTimeout(handle: unknown): void;
|
|
19
|
+
}
|
|
20
|
+
export declare const realScheduler: Scheduler;
|
|
21
|
+
/**
|
|
22
|
+
* Every timer an owner started, so disposing it can prove nothing is left: a
|
|
23
|
+
* leaked timer is otherwise invisible until it fires into a disposed consumer.
|
|
24
|
+
*/
|
|
25
|
+
export interface TimerSet {
|
|
26
|
+
after(ms: number, callback: () => void): Unsubscribe;
|
|
27
|
+
clearAll(): void;
|
|
28
|
+
size(): number;
|
|
29
|
+
}
|
|
30
|
+
export declare function createTimerSet(scheduler?: Scheduler): TimerSet;
|
|
31
|
+
export interface BackoffSpec {
|
|
32
|
+
readonly initialDelayMs: number;
|
|
33
|
+
readonly maxDelayMs: number;
|
|
34
|
+
/** Growth per attempt. Defaults to 2. */
|
|
35
|
+
readonly factor?: number | undefined;
|
|
36
|
+
/**
|
|
37
|
+
* `none` keeps a schedule exact (one device retrying its own request has no
|
|
38
|
+
* herd to avoid); `full` spreads it over [0, delay] so a fleet that failed at
|
|
39
|
+
* once does not retry in lockstep. Defaults to `none`.
|
|
40
|
+
*/
|
|
41
|
+
readonly jitter?: 'none' | 'full' | undefined;
|
|
42
|
+
}
|
|
43
|
+
/** Delay before `attempt`, 1-based: initial × factor^(attempt−1), capped, maybe jittered. */
|
|
44
|
+
export declare function computeBackoff(attempt: number, spec: BackoffSpec, random?: () => number): number;
|
|
45
|
+
export interface RetryHandle {
|
|
46
|
+
/** Cancels any pending attempt. Idempotent. */
|
|
47
|
+
cancel(): void;
|
|
48
|
+
/** Attempts made so far. */
|
|
49
|
+
attempts(): number;
|
|
50
|
+
/** True once `maxAttempts` were made without success. */
|
|
51
|
+
exhausted(): boolean;
|
|
52
|
+
}
|
|
53
|
+
export interface RetryOptions {
|
|
54
|
+
readonly spec: BackoffSpec & {
|
|
55
|
+
readonly maxAttempts: number;
|
|
56
|
+
};
|
|
57
|
+
/** Resolves true when the attempt succeeded. A throw counts as a failed attempt. */
|
|
58
|
+
readonly attempt: (attemptNumber: number) => Promise<boolean>;
|
|
59
|
+
/** Called once every attempt failed. Exhaustion is reported, never thrown. */
|
|
60
|
+
readonly onExhausted?: ((attempts: number) => void) | undefined;
|
|
61
|
+
readonly scheduler?: Scheduler | undefined;
|
|
62
|
+
readonly random?: (() => number) | undefined;
|
|
63
|
+
}
|
|
64
|
+
/** Runs `attempt` now, then on the backoff schedule until it succeeds, is cancelled or runs out. */
|
|
65
|
+
export declare function runWithRetry(options: RetryOptions): RetryHandle;
|
|
66
|
+
/**
|
|
67
|
+
* Joins concurrent callers onto one in-flight operation. Once it settles the
|
|
68
|
+
* slot clears, so a later call starts fresh: de-duplication, not caching.
|
|
69
|
+
*/
|
|
70
|
+
export declare function createSingleFlight<T>(): {
|
|
71
|
+
run(operation: () => Promise<T>): Promise<T>;
|
|
72
|
+
inFlight(): boolean;
|
|
73
|
+
};
|
|
74
|
+
/** Distinguishes "refused because busy" from any other failure, without throwing. */
|
|
75
|
+
export type ExclusiveOutcome<T> = {
|
|
76
|
+
acquired: true;
|
|
77
|
+
value: T;
|
|
78
|
+
} | {
|
|
79
|
+
acquired: false;
|
|
80
|
+
};
|
|
81
|
+
/** Admits one operation at a time and refuses the rest, rather than queueing them. */
|
|
82
|
+
export declare function createExclusive(): {
|
|
83
|
+
run<T>(operation: () => Promise<T>): Promise<ExclusiveOutcome<T>>;
|
|
84
|
+
busy(): boolean;
|
|
85
|
+
};
|
|
86
|
+
/** Admits at most one call per `minIntervalMs`; a refused call is dropped, not deferred. */
|
|
87
|
+
export declare function createRateLimiter(minIntervalMs: number, now?: () => number): {
|
|
88
|
+
tryAcquire(): boolean;
|
|
89
|
+
reset(): void;
|
|
90
|
+
};
|
|
91
|
+
/**
|
|
92
|
+
* Rejects with `onTimeout()` after `ms`. Always clears its timer, including when
|
|
93
|
+
* the promise wins, so no operation leaks one.
|
|
94
|
+
*/
|
|
95
|
+
export declare function withTimeout<T>(promise: Promise<T>, ms: number, onTimeout: () => Error, scheduler?: Scheduler): Promise<T>;
|
|
96
|
+
export interface Range {
|
|
97
|
+
readonly min: number;
|
|
98
|
+
readonly max: number;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* `value` when it is a finite number inside `range`; otherwise throws what `fail`
|
|
102
|
+
* builds. Out-of-range values are rejected, never clamped: clamping tells an app
|
|
103
|
+
* it configured something it did not.
|
|
104
|
+
*/
|
|
105
|
+
export declare function checkRange(label: string, value: number, range: Range, fail: (message: string) => Error, unit?: string): number;
|
|
106
|
+
/** As `checkRange`, and a whole number. */
|
|
107
|
+
export declare function checkInteger(label: string, value: number, range: Range, fail: (message: string) => Error): number;
|
|
108
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/scheduler/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAwB,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAEtE;;;GAGG;AACH,MAAM,WAAW,SAAS;IACzB,UAAU,CAAC,QAAQ,EAAE,MAAM,IAAI,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC;IACtD,YAAY,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;CACpC;AAED,eAAO,MAAM,aAAa,EAAE,SAG3B,CAAC;AAEF;;;GAGG;AACH,MAAM,WAAW,QAAQ;IACxB,KAAK,CAAC,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,IAAI,GAAG,WAAW,CAAC;IACrD,QAAQ,IAAI,IAAI,CAAC;IACjB,IAAI,IAAI,MAAM,CAAC;CACf;AAED,wBAAgB,cAAc,CAAC,SAAS,GAAE,SAAyB,GAAG,QAAQ,CAuB7E;AAED,MAAM,WAAW,WAAW;IAC3B,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,yCAAyC;IACzC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACrC;;;;OAIG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;CAC9C;AAED,6FAA6F;AAC7F,wBAAgB,cAAc,CAC7B,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,WAAW,EACjB,MAAM,GAAE,MAAM,MA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AAC,CAAC,CAAC,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC;IAClE,IAAI,IAAI,OAAO,CAAC;CAChB,CAcA;AAED,4FAA4F;AAC5F,wBAAgB,iBAAiB,CAChC,aAAa,EAAE,MAAM,EACrB,GAAG,GAAE,MAAM,MAAiB,GAC1B;IAAE,UAAU,IAAI,OAAO,CAAC;IAAC,KAAK,IAAI,IAAI,CAAA;CAAE,CAa1C;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAC5B,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,EACnB,EAAE,EAAE,MAAM,EACV,SAAS,EAAE,MAAM,KAAK,EACtB,SAAS,GAAE,SAAyB,GAClC,OAAO,CAAC,CAAC,CAAC,CAQZ;AAED,MAAM,WAAW,KAAK;IACrB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACrB;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CACzB,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,KAAK,EAChC,IAAI,SAAK,GACP,MAAM,CAOR;AAED,2CAA2C;AAC3C,wBAAgB,YAAY,CAC3B,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,KAAK,GAC9B,MAAM,CAMR"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A store whose snapshot keeps its identity until the state actually changes,
|
|
3
|
+
* which is what `useSyncExternalStore` needs (CORE-07). No React here: a package's
|
|
4
|
+
* pure core can hold its state in one, and its hooks read it through
|
|
5
|
+
* `@chipmobilesdk/rn-core/react`.
|
|
6
|
+
*/
|
|
7
|
+
import { type Unsubscribe } from '../listeners';
|
|
8
|
+
export interface Store<T> {
|
|
9
|
+
/** The current snapshot: the same object until the state actually changes. */
|
|
10
|
+
getSnapshot(): T;
|
|
11
|
+
/** Replaces the state; listeners hear about it only when `isEqual` says it changed. */
|
|
12
|
+
setState(next: T | ((previous: T) => T)): void;
|
|
13
|
+
subscribe(listener: () => void): Unsubscribe;
|
|
14
|
+
}
|
|
15
|
+
export declare function createStore<T>(initial: T, isEqual?: (a: T, b: T) => boolean): Store<T>;
|
|
16
|
+
/** Same keys, and each value `Object.is` the other's. */
|
|
17
|
+
export declare function shallowEqual<T>(a: T, b: T): boolean;
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/store/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAqB,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAEnE,MAAM,WAAW,KAAK,CAAC,CAAC;IACvB,8EAA8E;IAC9E,WAAW,IAAI,CAAC,CAAC;IACjB,uFAAuF;IACvF,QAAQ,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,IAAI,CAAC;IAC/C,SAAS,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,WAAW,CAAC;CAC7C;AAED,wBAAgB,WAAW,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,OAAmB,GAAG,KAAK,CAAC,CAAC,CAAC,CAajG;AAED,yDAAyD;AACzD,wBAAgB,YAAY,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,OAAO,CAUnD"}
|