@lightsparkdev/core 1.0.2 → 1.0.3

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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # @lightsparkdev/core
2
2
 
3
+ ## 1.0.3
4
+
5
+ ### Patch Changes
6
+
7
+ - e451948: Use AsyncStorage in wallet-sdk to check for SDK logging enabled, for ReactNative support
8
+
3
9
  ## 1.0.2
4
10
 
5
11
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -461,9 +461,14 @@ var NodeKeyCache_default = NodeKeyCache;
461
461
  var Logger = class {
462
462
  context;
463
463
  loggingEnabled = false;
464
- constructor(loggerContext) {
464
+ constructor(loggerContext, getLoggingEnabled) {
465
465
  this.context = loggerContext;
466
- if (isBrowser) {
466
+ this.updateLoggingEnabled(getLoggingEnabled);
467
+ }
468
+ async updateLoggingEnabled(getLoggingEnabled) {
469
+ if (getLoggingEnabled) {
470
+ this.loggingEnabled = await getLoggingEnabled();
471
+ } else if (isBrowser) {
467
472
  try {
468
473
  this.loggingEnabled = localStorage.getItem("lightspark-logging-enabled") === "1";
469
474
  } catch (e) {
package/dist/index.d.ts CHANGED
@@ -101,10 +101,12 @@ declare class NodeKeyCache {
101
101
  private stripPemTags;
102
102
  }
103
103
 
104
+ type GetLoggingEnabled = (() => Promise<boolean> | boolean) | undefined;
104
105
  declare class Logger {
105
106
  context: string;
106
107
  loggingEnabled: boolean;
107
- constructor(loggerContext: string);
108
+ constructor(loggerContext: string, getLoggingEnabled?: GetLoggingEnabled);
109
+ updateLoggingEnabled(getLoggingEnabled: GetLoggingEnabled): Promise<void>;
108
110
  info(message: string, ...rest: unknown[]): void;
109
111
  }
110
112
 
package/dist/index.js CHANGED
@@ -397,9 +397,14 @@ var NodeKeyCache_default = NodeKeyCache;
397
397
  var Logger = class {
398
398
  context;
399
399
  loggingEnabled = false;
400
- constructor(loggerContext) {
400
+ constructor(loggerContext, getLoggingEnabled) {
401
401
  this.context = loggerContext;
402
- if (isBrowser) {
402
+ this.updateLoggingEnabled(getLoggingEnabled);
403
+ }
404
+ async updateLoggingEnabled(getLoggingEnabled) {
405
+ if (getLoggingEnabled) {
406
+ this.loggingEnabled = await getLoggingEnabled();
407
+ } else if (isBrowser) {
403
408
  try {
404
409
  this.loggingEnabled = localStorage.getItem("lightspark-logging-enabled") === "1";
405
410
  } catch (e) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lightsparkdev/core",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "Lightspark JS SDK",
5
5
  "author": "Lightspark Inc.",
6
6
  "keywords": [
@@ -47,7 +47,7 @@
47
47
  "CHANGELOG.md"
48
48
  ],
49
49
  "scripts": {
50
- "build": "tsup src/index.ts --format cjs,esm --dts",
50
+ "build": "yarn tsc && tsup src/index.ts --format cjs,esm --dts",
51
51
  "clean": "rm -rf .turbo && rm -rf dist",
52
52
  "dev": "yarn build -- --watch",
53
53
  "format:fix": "prettier src --write",
package/src/Logger.ts CHANGED
@@ -1,12 +1,20 @@
1
1
  import { isBrowser } from "./index.js";
2
2
 
3
+ type GetLoggingEnabled = (() => Promise<boolean> | boolean) | undefined;
4
+
3
5
  export class Logger {
4
6
  context: string;
5
7
  loggingEnabled = false;
6
8
 
7
- constructor(loggerContext: string) {
9
+ constructor(loggerContext: string, getLoggingEnabled?: GetLoggingEnabled) {
8
10
  this.context = loggerContext;
9
- if (isBrowser) {
11
+ this.updateLoggingEnabled(getLoggingEnabled);
12
+ }
13
+
14
+ async updateLoggingEnabled(getLoggingEnabled: GetLoggingEnabled) {
15
+ if (getLoggingEnabled) {
16
+ this.loggingEnabled = await getLoggingEnabled();
17
+ } else if (isBrowser) {
10
18
  try {
11
19
  this.loggingEnabled =
12
20
  localStorage.getItem("lightspark-logging-enabled") === "1";