@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.
Files changed (158) hide show
  1. package/CHANGELOG.md +115 -0
  2. package/lib/commonjs/diagnostics/index.js +81 -0
  3. package/lib/commonjs/diagnostics/index.js.map +1 -0
  4. package/lib/commonjs/errors/index.js +86 -0
  5. package/lib/commonjs/errors/index.js.map +1 -0
  6. package/lib/commonjs/index.js +305 -0
  7. package/lib/commonjs/index.js.map +1 -0
  8. package/lib/commonjs/intl/index.js +98 -0
  9. package/lib/commonjs/intl/index.js.map +1 -0
  10. package/lib/commonjs/kv/index.js +83 -0
  11. package/lib/commonjs/kv/index.js.map +1 -0
  12. package/lib/commonjs/lazy/index.js +63 -0
  13. package/lib/commonjs/lazy/index.js.map +1 -0
  14. package/lib/commonjs/listeners/index.js +110 -0
  15. package/lib/commonjs/listeners/index.js.map +1 -0
  16. package/lib/commonjs/messages/index.js +53 -0
  17. package/lib/commonjs/messages/index.js.map +1 -0
  18. package/lib/commonjs/package.json +1 -0
  19. package/lib/commonjs/react/index.js +93 -0
  20. package/lib/commonjs/react/index.js.map +1 -0
  21. package/lib/commonjs/redact/index.js +128 -0
  22. package/lib/commonjs/redact/index.js.map +1 -0
  23. package/lib/commonjs/runtime/index.js +77 -0
  24. package/lib/commonjs/runtime/index.js.map +1 -0
  25. package/lib/commonjs/runtime/lifecycle.js +105 -0
  26. package/lib/commonjs/runtime/lifecycle.js.map +1 -0
  27. package/lib/commonjs/scheduler/index.js +216 -0
  28. package/lib/commonjs/scheduler/index.js.map +1 -0
  29. package/lib/commonjs/store/index.js +39 -0
  30. package/lib/commonjs/store/index.js.map +1 -0
  31. package/lib/commonjs/testing/conformance.js +79 -0
  32. package/lib/commonjs/testing/conformance.js.map +1 -0
  33. package/lib/commonjs/testing/index.js +58 -0
  34. package/lib/commonjs/testing/index.js.map +1 -0
  35. package/lib/commonjs/testing/lifecycle.js +37 -0
  36. package/lib/commonjs/testing/lifecycle.js.map +1 -0
  37. package/lib/commonjs/testing/redaction.js +118 -0
  38. package/lib/commonjs/testing/redaction.js.map +1 -0
  39. package/lib/commonjs/testing/scheduler.js +51 -0
  40. package/lib/commonjs/testing/scheduler.js.map +1 -0
  41. package/lib/module/diagnostics/index.js +75 -0
  42. package/lib/module/diagnostics/index.js.map +1 -0
  43. package/lib/module/errors/index.js +78 -0
  44. package/lib/module/errors/index.js.map +1 -0
  45. package/lib/module/index.js +24 -0
  46. package/lib/module/index.js.map +1 -0
  47. package/lib/module/intl/index.js +91 -0
  48. package/lib/module/intl/index.js.map +1 -0
  49. package/lib/module/kv/index.js +76 -0
  50. package/lib/module/kv/index.js.map +1 -0
  51. package/lib/module/lazy/index.js +59 -0
  52. package/lib/module/lazy/index.js.map +1 -0
  53. package/lib/module/listeners/index.js +104 -0
  54. package/lib/module/listeners/index.js.map +1 -0
  55. package/lib/module/messages/index.js +48 -0
  56. package/lib/module/messages/index.js.map +1 -0
  57. package/lib/module/package.json +1 -0
  58. package/lib/module/react/index.js +86 -0
  59. package/lib/module/react/index.js.map +1 -0
  60. package/lib/module/redact/index.js +118 -0
  61. package/lib/module/redact/index.js.map +1 -0
  62. package/lib/module/runtime/index.js +52 -0
  63. package/lib/module/runtime/index.js.map +1 -0
  64. package/lib/module/runtime/lifecycle.js +99 -0
  65. package/lib/module/runtime/lifecycle.js.map +1 -0
  66. package/lib/module/scheduler/index.js +203 -0
  67. package/lib/module/scheduler/index.js.map +1 -0
  68. package/lib/module/store/index.js +33 -0
  69. package/lib/module/store/index.js.map +1 -0
  70. package/lib/module/testing/conformance.js +72 -0
  71. package/lib/module/testing/conformance.js.map +1 -0
  72. package/lib/module/testing/index.js +12 -0
  73. package/lib/module/testing/index.js.map +1 -0
  74. package/lib/module/testing/lifecycle.js +32 -0
  75. package/lib/module/testing/lifecycle.js.map +1 -0
  76. package/lib/module/testing/redaction.js +113 -0
  77. package/lib/module/testing/redaction.js.map +1 -0
  78. package/lib/module/testing/scheduler.js +47 -0
  79. package/lib/module/testing/scheduler.js.map +1 -0
  80. package/lib/typescript/commonjs/diagnostics/index.d.ts +49 -0
  81. package/lib/typescript/commonjs/diagnostics/index.d.ts.map +1 -0
  82. package/lib/typescript/commonjs/errors/index.d.ts +59 -0
  83. package/lib/typescript/commonjs/errors/index.d.ts.map +1 -0
  84. package/lib/typescript/commonjs/index.d.ts +22 -0
  85. package/lib/typescript/commonjs/index.d.ts.map +1 -0
  86. package/lib/typescript/commonjs/intl/index.d.ts +25 -0
  87. package/lib/typescript/commonjs/intl/index.d.ts.map +1 -0
  88. package/lib/typescript/commonjs/kv/index.d.ts +38 -0
  89. package/lib/typescript/commonjs/kv/index.d.ts.map +1 -0
  90. package/lib/typescript/commonjs/lazy/index.d.ts +36 -0
  91. package/lib/typescript/commonjs/lazy/index.d.ts.map +1 -0
  92. package/lib/typescript/commonjs/listeners/index.d.ts +61 -0
  93. package/lib/typescript/commonjs/listeners/index.d.ts.map +1 -0
  94. package/lib/typescript/commonjs/messages/index.d.ts +39 -0
  95. package/lib/typescript/commonjs/messages/index.d.ts.map +1 -0
  96. package/lib/typescript/commonjs/package.json +1 -0
  97. package/lib/typescript/commonjs/react/index.d.ts +38 -0
  98. package/lib/typescript/commonjs/react/index.d.ts.map +1 -0
  99. package/lib/typescript/commonjs/redact/index.d.ts +47 -0
  100. package/lib/typescript/commonjs/redact/index.d.ts.map +1 -0
  101. package/lib/typescript/commonjs/runtime/index.d.ts +21 -0
  102. package/lib/typescript/commonjs/runtime/index.d.ts.map +1 -0
  103. package/lib/typescript/commonjs/runtime/lifecycle.d.ts +34 -0
  104. package/lib/typescript/commonjs/runtime/lifecycle.d.ts.map +1 -0
  105. package/lib/typescript/commonjs/scheduler/index.d.ts +108 -0
  106. package/lib/typescript/commonjs/scheduler/index.d.ts.map +1 -0
  107. package/lib/typescript/commonjs/store/index.d.ts +18 -0
  108. package/lib/typescript/commonjs/store/index.d.ts.map +1 -0
  109. package/lib/typescript/commonjs/testing/conformance.d.ts +35 -0
  110. package/lib/typescript/commonjs/testing/conformance.d.ts.map +1 -0
  111. package/lib/typescript/commonjs/testing/index.d.ts +10 -0
  112. package/lib/typescript/commonjs/testing/index.d.ts.map +1 -0
  113. package/lib/typescript/commonjs/testing/lifecycle.d.ts +15 -0
  114. package/lib/typescript/commonjs/testing/lifecycle.d.ts.map +1 -0
  115. package/lib/typescript/commonjs/testing/redaction.d.ts +35 -0
  116. package/lib/typescript/commonjs/testing/redaction.d.ts.map +1 -0
  117. package/lib/typescript/commonjs/testing/scheduler.d.ts +15 -0
  118. package/lib/typescript/commonjs/testing/scheduler.d.ts.map +1 -0
  119. package/lib/typescript/module/diagnostics/index.d.ts +49 -0
  120. package/lib/typescript/module/diagnostics/index.d.ts.map +1 -0
  121. package/lib/typescript/module/errors/index.d.ts +59 -0
  122. package/lib/typescript/module/errors/index.d.ts.map +1 -0
  123. package/lib/typescript/module/index.d.ts +22 -0
  124. package/lib/typescript/module/index.d.ts.map +1 -0
  125. package/lib/typescript/module/intl/index.d.ts +25 -0
  126. package/lib/typescript/module/intl/index.d.ts.map +1 -0
  127. package/lib/typescript/module/kv/index.d.ts +38 -0
  128. package/lib/typescript/module/kv/index.d.ts.map +1 -0
  129. package/lib/typescript/module/lazy/index.d.ts +36 -0
  130. package/lib/typescript/module/lazy/index.d.ts.map +1 -0
  131. package/lib/typescript/module/listeners/index.d.ts +61 -0
  132. package/lib/typescript/module/listeners/index.d.ts.map +1 -0
  133. package/lib/typescript/module/messages/index.d.ts +39 -0
  134. package/lib/typescript/module/messages/index.d.ts.map +1 -0
  135. package/lib/typescript/module/package.json +1 -0
  136. package/lib/typescript/module/react/index.d.ts +38 -0
  137. package/lib/typescript/module/react/index.d.ts.map +1 -0
  138. package/lib/typescript/module/redact/index.d.ts +47 -0
  139. package/lib/typescript/module/redact/index.d.ts.map +1 -0
  140. package/lib/typescript/module/runtime/index.d.ts +21 -0
  141. package/lib/typescript/module/runtime/index.d.ts.map +1 -0
  142. package/lib/typescript/module/runtime/lifecycle.d.ts +34 -0
  143. package/lib/typescript/module/runtime/lifecycle.d.ts.map +1 -0
  144. package/lib/typescript/module/scheduler/index.d.ts +108 -0
  145. package/lib/typescript/module/scheduler/index.d.ts.map +1 -0
  146. package/lib/typescript/module/store/index.d.ts +18 -0
  147. package/lib/typescript/module/store/index.d.ts.map +1 -0
  148. package/lib/typescript/module/testing/conformance.d.ts +35 -0
  149. package/lib/typescript/module/testing/conformance.d.ts.map +1 -0
  150. package/lib/typescript/module/testing/index.d.ts +10 -0
  151. package/lib/typescript/module/testing/index.d.ts.map +1 -0
  152. package/lib/typescript/module/testing/lifecycle.d.ts +15 -0
  153. package/lib/typescript/module/testing/lifecycle.d.ts.map +1 -0
  154. package/lib/typescript/module/testing/redaction.d.ts +35 -0
  155. package/lib/typescript/module/testing/redaction.d.ts.map +1 -0
  156. package/lib/typescript/module/testing/scheduler.d.ts +15 -0
  157. package/lib/typescript/module/testing/scheduler.d.ts.map +1 -0
  158. package/package.json +154 -46
package/CHANGELOG.md CHANGED
@@ -1 +1,116 @@
1
1
  # @chipmobilesdk/rn-core
2
+
3
+ ## 0.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Every package now ships built JavaScript with declaration files, instead of asking the
8
+ app to compile its TypeScript. ([#22](https://github.com/operationd8979/chip-mobile-sdk/pull/22))
9
+
10
+ Each tarball carries `lib/commonjs`, `lib/module` and `lib/typescript` (built with
11
+ `react-native-builder-bob`), and `src/` alongside them. What that changes for a
12
+ consumer:
13
+
14
+ - **Nothing to add to `transformIgnorePatterns`.** `require` resolves to the CommonJS
15
+ build, so an app's Jest loads this package without being told to transform it. That
16
+ was the one thing every consuming app had to know about us (DEP-04).
17
+ - **Typechecking reads our `.d.ts`** rather than compiling our source under our
18
+ `tsconfig`. A consumer's stricter — or looser — settings no longer meet our code.
19
+ - **`import` resolves to ESM**, so a bundler can tree-shake what it does not use.
20
+
21
+ No exported name changed, and no subpath moved: `.`, `./testing`, `./push`,
22
+ `./advanced`, `./app-auth`, `./keychain` and rn-core's twelve subpaths resolve exactly
23
+ as before, each now with its own declarations for both module systems. publint and
24
+ `attw --profile node16` pass on all twelve packages, which they could not before.
25
+
26
+ Inside the monorepo nothing changed either, and that is deliberate: every subpath also
27
+ declares a private `chipmobilesdk-source` condition pointing at its TypeScript, and
28
+ Metro, Jest and `tsc` here ask for that condition first. The demo app bundles 371
29
+ modules straight from `packages/*/src`, so editing a package still changes the app with
30
+ no build step, and coverage is still measured on the source. The condition is named for
31
+ this organization rather than using the conventional `source` because third-party
32
+ packages declare that one too — `@dr.pogodin/react-native-fs` does — and asking for it
33
+ pulled their sources into our stricter compile.
34
+
35
+ `npm run build:packages` builds everything, `prepack` rebuilds before any `npm pack`,
36
+ and `lib/` is git-ignored: the published bytes are produced by the release, never
37
+ committed. `npm run check:manifests` now fails a package whose `main`, `module`,
38
+ `types`, `source` condition, `files`, build script or `prepack` do not match this shape.
39
+
40
+ ### Patch Changes
41
+
42
+ - Each package's public API and its weight are now recorded in the repository, so a change
43
+ to either is reviewed rather than discovered. ([#23](https://github.com/operationd8979/chip-mobile-sdk/pull/23))
44
+
45
+ `packages/<pkg>/etc/*.api.md` is an api-extractor report per entrypoint — twenty-seven
46
+ of them, generated from the declarations the package publishes and committed. A renamed
47
+ type, a widened union, one more optional field: all of it shows up in a pull request's
48
+ diff. `npm run check:api` fails when a report is out of date and `npm run api:update`
49
+ rewrites them.
50
+
51
+ A report that moves now needs a **minor or major** changeset for that package.
52
+ `check:changesets` enforces it, because the report is generated from what the package
53
+ publishes, and a patch release that moves the public surface is how a consumer's build
54
+ breaks on `npm update`. A report added for the first time is a baseline, not a change.
55
+ `./testing` deliberately has no report: test doubles are not a surface a release is
56
+ gated on.
57
+
58
+ `npm run check:size` holds every entrypoint to a budget in `.size-limit.json`, measured
59
+ on the ESM build with peers and rn-core treated as external — they are what an app
60
+ installs beside us, not our weight. Each budget started at today's measurement plus five
61
+ per cent, so growth becomes a decision someone makes instead of a drift nobody sees. The
62
+ current figures run from 500 B (`rn-core/lazy`) to 19 kB (rn-notification).
63
+
64
+ No behaviour or API changed in this release; the entry is here so the changelog records
65
+ when the reports and the budgets began.
66
+
67
+ ## 0.1.0
68
+
69
+ ### Minor Changes
70
+
71
+ - First release: the shared foundation of the @chipmobilesdk packages. `SdkError` and
72
+ `isSdkError` give every package one error model (`pkg`, `code`, `retryable`,
73
+ `redactedCause`), recognised across two copies of the package; `defineErrorCodes`
74
+ and `createIssueCollector` declare codes and collect config problems.
75
+ `createRedactor` and its primitives give one redaction mechanism with
76
+ identifier-only and pattern policies. `createListenerSet` and `createEmitter` notify
77
+ subscribers in isolation (a throwing listener is reported, never swallowed, and never
78
+ reaches the notifier), with a bounded dedupe. `installSdkSink` receives every
79
+ package's diagnostics as one `SdkDiagnostic` stream, across copies of the package.
80
+ `redactionConformance`
81
+ (`@chipmobilesdk/rn-core/testing`) checks any redaction entrypoint against a fixed set
82
+ of secrets. ([#17](https://github.com/operationd8979/chip-mobile-sdk/pull/17))
83
+
84
+ - Port conformance suites: one list of checks that a package's fake and its real adapter
85
+ both pass, so a test written against the fake proves something about the device. ([#17](https://github.com/operationd8979/chip-mobile-sdk/pull/17))
86
+
87
+ - rn-core: `@chipmobilesdk/rn-core/testing` adds `runChecks`, `expectConformance`,
88
+ `ensure` and `createFaultRegistry` (deterministic fault injection by named point).
89
+ - rn-camera: a `./testing` entrypoint with `runPermissionPortConformance`,
90
+ `runCameraEngineConformance` and the test adapter, which stays on the main
91
+ entrypoint too until the next major. `createTestCamera(...).prompts()` counts system
92
+ prompts.
93
+ - rn-payment: `runProviderPortConformance` in `./testing`, passed by the fake store and
94
+ the Play adapter.
95
+ - rn-ads: `runAdsEngineConformance` in `./testing`, passed by the fake engine and the
96
+ AdMob adapter.
97
+ - rn-auth: a `./testing` entrypoint with `createMemorySecureStore`,
98
+ `runSecureTokenStoreConformance` and `runOidcAuthClientConformance`, passed by the
99
+ in-memory doubles and the keychain and app-auth adapters.
100
+
101
+ - One app-lifecycle source, and a startup that needs no extra frame. ([#17](https://github.com/operationd8979/chip-mobile-sdk/pull/17))
102
+
103
+ - rn-core: `appLifecycle()`, a shared, reference-counted `AppState` subscription that
104
+ reports changes only (`active`, `inactive`, `background`), with `onForeground` for a
105
+ return from the background and `createManualLifecycle` in `./testing`.
106
+ - rn-camera, rn-ads and rn-notification hear the lifecycle through it instead of
107
+ subscribing to `AppState` each, so an app holds one native listener. The camera
108
+ controller's core layer no longer imports `react-native`.
109
+ - rn-payment: `syncOnForeground(engine)` and `<PaymentProvider syncOnForeground>` call
110
+ `handleForeground()` on each return from the background. Off by default; calling
111
+ `handleForeground()` yourself works as before.
112
+ - rn-i18n: `i18n.initSync()` resolves the locale before the first render when the
113
+ storage adapter has the new optional `getItemSync`, and returns false otherwise.
114
+ `localeStorageFromKeyValue(port)` builds such an adapter from rn-core's
115
+ `KeyValuePort` (MMKV).
116
+
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createDiagnosticChannel = createDiagnosticChannel;
7
+ exports.hasSdkSinks = hasSdkSinks;
8
+ exports.installSdkSink = installSdkSink;
9
+ var _index = require("../listeners/index.js");
10
+ var _index2 = require("../redact/index.js");
11
+ /**
12
+ * One diagnostic stream for every package (CORE-08).
13
+ *
14
+ * Each package keeps its own typed events (`AdEvent`, `PaymentEvent`...), and also
15
+ * reports what it observed as an `SdkDiagnostic` through a channel. An app installs
16
+ * one `DiagnosticSink` and receives every package's diagnostics in one shape, so
17
+ * wiring crash reporting or analytics is one adapter rather than ten.
18
+ *
19
+ * Sinks live in a registry anchored on `Symbol.for`, so a sink installed through
20
+ * one copy of rn-core also receives diagnostics from packages bundling another.
21
+ * Every context passes through a redactor before any sink sees it.
22
+ */
23
+
24
+ const REGISTRY = Symbol.for('chipmobilesdk.diagnosticSinks');
25
+ function sinks() {
26
+ const host = globalThis;
27
+ host[REGISTRY] ??= new Set();
28
+ return host[REGISTRY];
29
+ }
30
+
31
+ /**
32
+ * Sends every package's diagnostics to `sink` until the returned function is
33
+ * called. A sink that throws is reported on a fresh task and never affects the
34
+ * package that emitted.
35
+ */
36
+ function installSdkSink(sink) {
37
+ const registry = sinks();
38
+ registry.add(sink);
39
+ let active = true;
40
+ return () => {
41
+ if (!active) return;
42
+ active = false;
43
+ registry.delete(sink);
44
+ };
45
+ }
46
+
47
+ /** Whether any sink is installed, for a package that would do extra work only to feed one. */
48
+ function hasSdkSinks() {
49
+ return sinks().size > 0;
50
+ }
51
+ function createDiagnosticChannel(pkg, options = {}) {
52
+ const redactor = options.redactor ?? (0, _index2.createRedactor)();
53
+ const now = options.now ?? Date.now;
54
+ return {
55
+ emit(code, severity, context, correlationId) {
56
+ const targets = options.sink ? [options.sink, ...sinks()] : [...sinks()];
57
+ if (targets.length === 0) return;
58
+ const redacted = redactor.context(context);
59
+ const diagnostic = {
60
+ pkg,
61
+ code,
62
+ severity,
63
+ at: now(),
64
+ ...(correlationId === undefined ? {} : {
65
+ correlationId
66
+ }),
67
+ ...(redacted === undefined ? {} : {
68
+ context: redacted
69
+ })
70
+ };
71
+ for (const sink of targets) {
72
+ try {
73
+ sink(diagnostic);
74
+ } catch (error) {
75
+ (0, _index.reportAsynchronously)(error);
76
+ }
77
+ }
78
+ }
79
+ };
80
+ }
81
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_index","require","_index2","REGISTRY","Symbol","for","sinks","host","globalThis","Set","installSdkSink","sink","registry","add","active","delete","hasSdkSinks","size","createDiagnosticChannel","pkg","options","redactor","createRedactor","now","Date","emit","code","severity","context","correlationId","targets","length","redacted","diagnostic","at","undefined","error","reportAsynchronously"],"sourceRoot":"../../../src","sources":["diagnostics/index.ts"],"mappings":";;;;;;;;AAaA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAdA;AACA;AACA;AACA;AACA;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AQ,GAAGX,QAAQ,CAACO,OAAO,CAACA,OAAO,CAAC;MAC1C,MAAMK,UAA+B,GAAG;QACvCd,GAAG;QACHO,IAAI;QACJC,QAAQ;QACRO,EAAE,EAAEX,GAAG,CAAC,CAAC;QACT,IAAIM,aAAa,KAAKM,SAAS,GAAG,CAAC,CAAC,GAAG;UAAEN;QAAc,CAAC,CAAC;QACzD,IAAIG,QAAQ,KAAKG,SAAS,GAAG,CAAC,CAAC,GAAG;UAAEP,OAAO,EAAEI;QAAS,CAAC;MACxD,CAAC;MACD,KAAK,MAAMrB,IAAI,IAAImB,OAAO,EAAE;QAC3B,IAAI;UACHnB,IAAI,CAACsB,UAAU,CAAC;QACjB,CAAC,CAAC,OAAOG,KAAK,EAAE;UACf,IAAAC,2BAAoB,EAACD,KAAK,CAAC;QAC5B;MACD;IACD;EACD,CAAC;AACF","ignoreList":[]}
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.SdkError = void 0;
7
+ exports.createIssueCollector = createIssueCollector;
8
+ exports.defineErrorCodes = defineErrorCodes;
9
+ exports.isSdkError = isSdkError;
10
+ /**
11
+ * One error model for every @chipmobilesdk package (CORE-11).
12
+ *
13
+ * Each package keeps its own public error class and code union (`AdsError`,
14
+ * `PaymentError`...); those classes extend `SdkError`, so an app can handle any
15
+ * package's failure the same way: a code, whether retrying can help, and a cause
16
+ * that has already been through redaction.
17
+ *
18
+ * `isSdkError` checks a brand rather than `instanceof`, so it holds when an app
19
+ * ends up with two copies of this package (two versions in node_modules), which
20
+ * would make `instanceof SdkError` false for half its errors.
21
+ */
22
+
23
+ const BRAND = Symbol.for('chipmobilesdk.error');
24
+ class SdkError extends Error {
25
+ /** The package that raised the error, e.g. `rn-ads`. */
26
+
27
+ constructor(pkg, code, options = {}) {
28
+ super(options.message ?? code);
29
+ this.name = 'SdkError';
30
+ this.pkg = pkg;
31
+ this.code = code;
32
+ this.retryable = options.retryable ?? false;
33
+ if (options.redactedCause !== undefined) {
34
+ this.redactedCause = options.redactedCause;
35
+ }
36
+ // Keeps subclasses' prototypes intact where Error subclassing is transpiled.
37
+ Object.setPrototypeOf(this, new.target.prototype);
38
+ }
39
+ }
40
+ exports.SdkError = SdkError;
41
+ Object.defineProperty(SdkError.prototype, BRAND, {
42
+ value: true
43
+ });
44
+
45
+ /** True for an error raised by any @chipmobilesdk package, from any copy of this one. */
46
+ function isSdkError(value) {
47
+ return typeof value === 'object' && value !== null && value[BRAND] === true;
48
+ }
49
+ /**
50
+ * A package's closed code set and which of its codes are retryable, declared
51
+ * once instead of a union, an array and a `Set` kept in step by hand.
52
+ */
53
+ function defineErrorCodes(codes, options = {}) {
54
+ const all = new Set(codes);
55
+ const retryable = new Set(options.retryable ?? []);
56
+ return {
57
+ codes: Object.freeze([...codes]),
58
+ is: value => typeof value === 'string' && all.has(value),
59
+ isRetryable: code => retryable.has(code)
60
+ };
61
+ }
62
+ /**
63
+ * Collects every problem in a config before throwing, so an app sees all of them
64
+ * at once rather than one per fix-and-restart cycle.
65
+ */
66
+ function createIssueCollector() {
67
+ const issues = [];
68
+ return {
69
+ add(path, message) {
70
+ issues.push({
71
+ path,
72
+ message
73
+ });
74
+ },
75
+ get issues() {
76
+ return issues;
77
+ },
78
+ /** Throws what `toError` builds from the issues, when there are any. */
79
+ throwIfAny(toError) {
80
+ if (issues.length > 0) {
81
+ throw toError([...issues]);
82
+ }
83
+ }
84
+ };
85
+ }
86
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["BRAND","Symbol","for","SdkError","Error","constructor","pkg","code","options","message","name","retryable","redactedCause","undefined","Object","setPrototypeOf","new","target","prototype","exports","defineProperty","value","isSdkError","defineErrorCodes","codes","all","Set","freeze","is","has","isRetryable","createIssueCollector","issues","add","path","push","throwIfAny","toError","length"],"sourceRoot":"../../../src","sources":["errors/index.ts"],"mappings":";;;;;;;;;AAAA;AACA;AACA;AACA;A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,KAAK,EAAEV,MAAM,CAACa,MAAM,CAAC,CAAC,GAAGH,KAAK,CAAC,CAAC;IAChCI,EAAE,EAAGP,KAAc,IAAoB,OAAOA,KAAK,KAAK,QAAQ,IAAII,GAAG,CAACI,GAAG,CAACR,KAAK,CAAC;IAClFS,WAAW,EAAEvB,IAAI,IAAII,SAAS,CAACkB,GAAG,CAACtB,IAAI;EACxC,CAAC;AACF;AAQA;AACA;AACA;AACA;AACO,SAASwB,oBAAoBA,CAAA,EAAG;EACtC,MAAMC,MAAqB,GAAG,EAAE;EAChC,OAAO;IACNC,GAAGA,CAACC,IAAY,EAAEzB,OAAe,EAAQ;MACxCuB,MAAM,CAACG,IAAI,CAAC;QAAED,IAAI;QAAEzB;MAAQ,CAAC,CAAC;IAC/B,CAAC;IACD,IAAIuB,MAAMA,CAAA,EAA2B;MACpC,OAAOA,MAAM;IACd,CAAC;IACD;IACAI,UAAUA,CAACC,OAAkD,EAAQ;MACpE,IAAIL,MAAM,CAACM,MAAM,GAAG,CAAC,EAAE;QACtB,MAAMD,OAAO,CAAC,CAAC,GAAGL,MAAM,CAAC,CAAC;MAC3B;IACD;EACD,CAAC;AACF","ignoreList":[]}
@@ -0,0 +1,305 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "COMMON_PATTERNS", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _index2.COMMON_PATTERNS;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "PATH_PATTERN", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _index2.PATH_PATTERN;
16
+ }
17
+ });
18
+ Object.defineProperty(exports, "REDACTED", {
19
+ enumerable: true,
20
+ get: function () {
21
+ return _index2.REDACTED;
22
+ }
23
+ });
24
+ Object.defineProperty(exports, "SdkError", {
25
+ enumerable: true,
26
+ get: function () {
27
+ return _index.SdkError;
28
+ }
29
+ });
30
+ Object.defineProperty(exports, "appLifecycle", {
31
+ enumerable: true,
32
+ get: function () {
33
+ return _index8.appLifecycle;
34
+ }
35
+ });
36
+ Object.defineProperty(exports, "byPlatform", {
37
+ enumerable: true,
38
+ get: function () {
39
+ return _index8.byPlatform;
40
+ }
41
+ });
42
+ Object.defineProperty(exports, "checkInteger", {
43
+ enumerable: true,
44
+ get: function () {
45
+ return _index5.checkInteger;
46
+ }
47
+ });
48
+ Object.defineProperty(exports, "checkRange", {
49
+ enumerable: true,
50
+ get: function () {
51
+ return _index5.checkRange;
52
+ }
53
+ });
54
+ Object.defineProperty(exports, "clearIntlCaches", {
55
+ enumerable: true,
56
+ get: function () {
57
+ return _index0.clearIntlCaches;
58
+ }
59
+ });
60
+ Object.defineProperty(exports, "computeBackoff", {
61
+ enumerable: true,
62
+ get: function () {
63
+ return _index5.computeBackoff;
64
+ }
65
+ });
66
+ Object.defineProperty(exports, "createAppLifecycle", {
67
+ enumerable: true,
68
+ get: function () {
69
+ return _index8.createAppLifecycle;
70
+ }
71
+ });
72
+ Object.defineProperty(exports, "createDiagnosticChannel", {
73
+ enumerable: true,
74
+ get: function () {
75
+ return _index4.createDiagnosticChannel;
76
+ }
77
+ });
78
+ Object.defineProperty(exports, "createEmitter", {
79
+ enumerable: true,
80
+ get: function () {
81
+ return _index3.createEmitter;
82
+ }
83
+ });
84
+ Object.defineProperty(exports, "createExclusive", {
85
+ enumerable: true,
86
+ get: function () {
87
+ return _index5.createExclusive;
88
+ }
89
+ });
90
+ Object.defineProperty(exports, "createIssueCollector", {
91
+ enumerable: true,
92
+ get: function () {
93
+ return _index.createIssueCollector;
94
+ }
95
+ });
96
+ Object.defineProperty(exports, "createListenerSet", {
97
+ enumerable: true,
98
+ get: function () {
99
+ return _index3.createListenerSet;
100
+ }
101
+ });
102
+ Object.defineProperty(exports, "createMemoryKeyValue", {
103
+ enumerable: true,
104
+ get: function () {
105
+ return _index7.createMemoryKeyValue;
106
+ }
107
+ });
108
+ Object.defineProperty(exports, "createRateLimiter", {
109
+ enumerable: true,
110
+ get: function () {
111
+ return _index5.createRateLimiter;
112
+ }
113
+ });
114
+ Object.defineProperty(exports, "createRedactor", {
115
+ enumerable: true,
116
+ get: function () {
117
+ return _index2.createRedactor;
118
+ }
119
+ });
120
+ Object.defineProperty(exports, "createSingleFlight", {
121
+ enumerable: true,
122
+ get: function () {
123
+ return _index5.createSingleFlight;
124
+ }
125
+ });
126
+ Object.defineProperty(exports, "createStore", {
127
+ enumerable: true,
128
+ get: function () {
129
+ return _index9.createStore;
130
+ }
131
+ });
132
+ Object.defineProperty(exports, "createTimerSet", {
133
+ enumerable: true,
134
+ get: function () {
135
+ return _index5.createTimerSet;
136
+ }
137
+ });
138
+ Object.defineProperty(exports, "currentPlatform", {
139
+ enumerable: true,
140
+ get: function () {
141
+ return _index8.currentPlatform;
142
+ }
143
+ });
144
+ Object.defineProperty(exports, "defineErrorCodes", {
145
+ enumerable: true,
146
+ get: function () {
147
+ return _index.defineErrorCodes;
148
+ }
149
+ });
150
+ Object.defineProperty(exports, "defineMessages", {
151
+ enumerable: true,
152
+ get: function () {
153
+ return _index1.defineMessages;
154
+ }
155
+ });
156
+ Object.defineProperty(exports, "describeShape", {
157
+ enumerable: true,
158
+ get: function () {
159
+ return _index2.describeShape;
160
+ }
161
+ });
162
+ Object.defineProperty(exports, "formatMessage", {
163
+ enumerable: true,
164
+ get: function () {
165
+ return _index1.formatMessage;
166
+ }
167
+ });
168
+ Object.defineProperty(exports, "fromMmkvLike", {
169
+ enumerable: true,
170
+ get: function () {
171
+ return _index7.fromMmkvLike;
172
+ }
173
+ });
174
+ Object.defineProperty(exports, "getDateTimeFormat", {
175
+ enumerable: true,
176
+ get: function () {
177
+ return _index0.getDateTimeFormat;
178
+ }
179
+ });
180
+ Object.defineProperty(exports, "getNumberFormat", {
181
+ enumerable: true,
182
+ get: function () {
183
+ return _index0.getNumberFormat;
184
+ }
185
+ });
186
+ Object.defineProperty(exports, "hasSdkSinks", {
187
+ enumerable: true,
188
+ get: function () {
189
+ return _index4.hasSdkSinks;
190
+ }
191
+ });
192
+ Object.defineProperty(exports, "installSdkSink", {
193
+ enumerable: true,
194
+ get: function () {
195
+ return _index4.installSdkSink;
196
+ }
197
+ });
198
+ Object.defineProperty(exports, "isDevBuild", {
199
+ enumerable: true,
200
+ get: function () {
201
+ return _index8.isDevBuild;
202
+ }
203
+ });
204
+ Object.defineProperty(exports, "isSdkError", {
205
+ enumerable: true,
206
+ get: function () {
207
+ return _index.isSdkError;
208
+ }
209
+ });
210
+ Object.defineProperty(exports, "isValidTimeZone", {
211
+ enumerable: true,
212
+ get: function () {
213
+ return _index0.isValidTimeZone;
214
+ }
215
+ });
216
+ Object.defineProperty(exports, "lazyPeer", {
217
+ enumerable: true,
218
+ get: function () {
219
+ return _index6.lazyPeer;
220
+ }
221
+ });
222
+ Object.defineProperty(exports, "leadingIdentifier", {
223
+ enumerable: true,
224
+ get: function () {
225
+ return _index2.leadingIdentifier;
226
+ }
227
+ });
228
+ Object.defineProperty(exports, "namespaced", {
229
+ enumerable: true,
230
+ get: function () {
231
+ return _index7.namespaced;
232
+ }
233
+ });
234
+ Object.defineProperty(exports, "onForeground", {
235
+ enumerable: true,
236
+ get: function () {
237
+ return _index8.onForeground;
238
+ }
239
+ });
240
+ Object.defineProperty(exports, "openDurable", {
241
+ enumerable: true,
242
+ get: function () {
243
+ return _index7.openDurable;
244
+ }
245
+ });
246
+ Object.defineProperty(exports, "pickAllowed", {
247
+ enumerable: true,
248
+ get: function () {
249
+ return _index2.pickAllowed;
250
+ }
251
+ });
252
+ Object.defineProperty(exports, "realScheduler", {
253
+ enumerable: true,
254
+ get: function () {
255
+ return _index5.realScheduler;
256
+ }
257
+ });
258
+ Object.defineProperty(exports, "redactPatterns", {
259
+ enumerable: true,
260
+ get: function () {
261
+ return _index2.redactPatterns;
262
+ }
263
+ });
264
+ Object.defineProperty(exports, "reportAsynchronously", {
265
+ enumerable: true,
266
+ get: function () {
267
+ return _index3.reportAsynchronously;
268
+ }
269
+ });
270
+ Object.defineProperty(exports, "runWithRetry", {
271
+ enumerable: true,
272
+ get: function () {
273
+ return _index5.runWithRetry;
274
+ }
275
+ });
276
+ Object.defineProperty(exports, "setPlatformOverride", {
277
+ enumerable: true,
278
+ get: function () {
279
+ return _index8.setPlatformOverride;
280
+ }
281
+ });
282
+ Object.defineProperty(exports, "shallowEqual", {
283
+ enumerable: true,
284
+ get: function () {
285
+ return _index9.shallowEqual;
286
+ }
287
+ });
288
+ Object.defineProperty(exports, "withTimeout", {
289
+ enumerable: true,
290
+ get: function () {
291
+ return _index5.withTimeout;
292
+ }
293
+ });
294
+ var _index = require("./errors/index.js");
295
+ var _index2 = require("./redact/index.js");
296
+ var _index3 = require("./listeners/index.js");
297
+ var _index4 = require("./diagnostics/index.js");
298
+ var _index5 = require("./scheduler/index.js");
299
+ var _index6 = require("./lazy/index.js");
300
+ var _index7 = require("./kv/index.js");
301
+ var _index8 = require("./runtime/index.js");
302
+ var _index9 = require("./store/index.js");
303
+ var _index0 = require("./intl/index.js");
304
+ var _index1 = require("./messages/index.js");
305
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_index","require","_index2","_index3","_index4","_index5","_index6","_index7","_index8","_index9","_index0","_index1"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUA,IAAAA,MAAA,GAAAC,OAAA;AASA,IAAAC,OAAA,GAAAD,OAAA;AAYA,IAAAE,OAAA,GAAAF,OAAA;AAWA,IAAAG,OAAA,GAAAH,OAAA;AAUA,IAAAI,OAAA,GAAAJ,OAAA;AAmBA,IAAAK,OAAA,GAAAL,OAAA;AACA,IAAAM,OAAA,GAAAN,OAAA;AAQA,IAAAO,OAAA,GAAAP,OAAA;AAcA,IAAAQ,OAAA,GAAAR,OAAA;AACA,IAAAS,OAAA,GAAAT,OAAA;AACA,IAAAU,OAAA,GAAAV,OAAA","ignoreList":[]}