@ar.io/wayfinder-core 1.0.3-alpha.0 → 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.
@@ -1 +1 @@
1
- {"version":3,"file":"local-storage-cache.d.ts","sourceRoot":"","sources":["../../src/gateways/local-storage-cache.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AA+B1C,qBAAa,4BAA6B,YAAW,gBAAgB;IACnE,OAAO,CAAC,QAAQ,CAAC,UAAU,CAA8B;IACzD,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAQ;IAC1C,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAmB;IACpD,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;IACpC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,eAAe,CAA6B;gBAExC,EACV,UAAmC,EACnC,gBAAgB,EAChB,MAAsB,GACvB,EAAE;QACD,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,gBAAgB,EAAE,gBAAgB,CAAC;QACnC,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB;IAaK,WAAW,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;IAwCnC,OAAO,CAAC,iBAAiB;IAkBzB,OAAO,CAAC,YAAY;IAOpB,OAAO,CAAC,aAAa;IAmBrB,UAAU,IAAI,IAAI;CAWnB"}
1
+ {"version":3,"file":"local-storage-cache.d.ts","sourceRoot":"","sources":["../../src/gateways/local-storage-cache.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AA+B1C,qBAAa,4BAA6B,YAAW,gBAAgB;IACnE,OAAO,CAAC,QAAQ,CAAC,UAAU,CAA8B;IACzD,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAQ;IAC1C,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAmB;IACpD,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;IACpC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,eAAe,CAA6B;gBAExC,EACV,UAAU,EACV,gBAAgB,EAChB,MAAsB,GACvB,EAAE;QACD,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,gBAAgB,EAAE,gBAAgB,CAAC;QACnC,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB;IAYK,WAAW,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;IAwCnC,OAAO,CAAC,iBAAiB;IAkBzB,OAAO,CAAC,YAAY;IAOpB,OAAO,CAAC,aAAa;IAuBrB,UAAU,IAAI,IAAI;CAWnB"}
@@ -7,12 +7,11 @@ export class LocalStorageGatewaysProvider {
7
7
  ttlSeconds;
8
8
  logger;
9
9
  gatewaysPromise;
10
- constructor({ ttlSeconds = this.defaultTtlSeconds, gatewaysProvider, logger = defaultLogger, }) {
10
+ constructor({ ttlSeconds, gatewaysProvider, logger = defaultLogger, }) {
11
11
  if (!isBrowser()) {
12
12
  throw new Error('LocalStorageGatewaysProvider is only available in browser environments. Consider using SimpleCacheGatewaysProvider for node.js environments.');
13
13
  }
14
- this.gatewaysProvider = gatewaysProvider;
15
- this.ttlSeconds = ttlSeconds;
14
+ this.ttlSeconds = ttlSeconds ?? this.defaultTtlSeconds;
16
15
  this.gatewaysProvider = gatewaysProvider;
17
16
  this.logger = logger;
18
17
  }
@@ -78,6 +77,9 @@ export class LocalStorageGatewaysProvider {
78
77
  if (typeof window === 'undefined' || !window.localStorage) {
79
78
  return;
80
79
  }
80
+ if (gateways.length === 0) {
81
+ return;
82
+ }
81
83
  const cached = {
82
84
  gateways: gateways.map((gateway) => gateway.toString()),
83
85
  timestamp: Date.now(),
@@ -1 +1 @@
1
- {"version":3,"file":"simple-cache.d.ts","sourceRoot":"","sources":["../../src/gateways/simple-cache.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE5D;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,qBAAa,2BAA4B,YAAW,gBAAgB;IAClE,OAAO,CAAC,gBAAgB,CAAmB;IAC3C,OAAO,CAAC,iBAAiB,CAAQ;IACjC,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,aAAa,CAAQ;IAC7B,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,eAAe,CAA6B;gBAExC,EACV,gBAAgB,EAChB,UAAmC,EACnC,MAAsB,GACvB,EAAE;QACD,gBAAgB,EAAE,gBAAgB,CAAC;QACnC,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB;IAQK,WAAW,CAAC,MAAM,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CACxE,GAAG,EAAE,CACN;IA4CD,OAAO,CAAC,YAAY;CAGrB"}
1
+ {"version":3,"file":"simple-cache.d.ts","sourceRoot":"","sources":["../../src/gateways/simple-cache.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE5D;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,qBAAa,2BAA4B,YAAW,gBAAgB;IAClE,OAAO,CAAC,gBAAgB,CAAmB;IAC3C,OAAO,CAAC,iBAAiB,CAAQ;IACjC,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,aAAa,CAAQ;IAC7B,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,eAAe,CAA6B;gBAExC,EACV,gBAAgB,EAChB,UAAU,EACV,MAAsB,GACvB,EAAE;QACD,gBAAgB,EAAE,gBAAgB,CAAC;QACnC,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB;IAQK,WAAW,CAAC,MAAM,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CACxE,GAAG,EAAE,CACN;IA6CD,OAAO,CAAC,YAAY;CAGrB"}
@@ -46,10 +46,10 @@ export class SimpleCacheGatewaysProvider {
46
46
  gatewaysCache;
47
47
  logger;
48
48
  gatewaysPromise;
49
- constructor({ gatewaysProvider, ttlSeconds = this.defaultTtlSeconds, logger = defaultLogger, }) {
49
+ constructor({ gatewaysProvider, ttlSeconds, logger = defaultLogger, }) {
50
50
  this.gatewaysCache = [];
51
51
  this.gatewaysProvider = gatewaysProvider;
52
- this.ttlSeconds = ttlSeconds;
52
+ this.ttlSeconds = ttlSeconds ?? this.defaultTtlSeconds;
53
53
  this.expiresAt = 0;
54
54
  this.logger = logger;
55
55
  }
@@ -62,14 +62,15 @@ export class SimpleCacheGatewaysProvider {
62
62
  });
63
63
  return this.gatewaysCache;
64
64
  }
65
+ // if a promise is already set, return it vs creating a new one
66
+ if (this.gatewaysPromise) {
67
+ return this.gatewaysPromise;
68
+ }
65
69
  try {
66
70
  this.logger.debug('Cache expired, fetching new gateways', {
67
71
  expiresAt: this.expiresAt,
68
72
  ttlSeconds: this.ttlSeconds,
69
73
  });
70
- if (this.gatewaysPromise) {
71
- return this.gatewaysPromise;
72
- }
73
74
  // set the promise to prevent multiple requests to the gatewaysProvider
74
75
  this.gatewaysPromise = this.gatewaysProvider.getGateways(params);
75
76
  const allGateways = await this.gatewaysPromise;
package/dist/version.d.ts CHANGED
@@ -14,5 +14,5 @@
14
14
  * See the License for the specific language governing permissions and
15
15
  * limitations under the License.
16
16
  */
17
- export declare const WAYFINDER_CORE_VERSION = "v1.0.3-alpha.0";
17
+ export declare const WAYFINDER_CORE_VERSION = "v1.0.3";
18
18
  //# sourceMappingURL=version.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,sBAAsB,mBAAmB,CAAC"}
1
+ {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,sBAAsB,WAAW,CAAC"}
package/dist/version.js CHANGED
@@ -14,4 +14,4 @@
14
14
  * See the License for the specific language governing permissions and
15
15
  * limitations under the License.
16
16
  */
17
- export const WAYFINDER_CORE_VERSION = 'v1.0.3-alpha.0';
17
+ export const WAYFINDER_CORE_VERSION = 'v1.0.3';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ar.io/wayfinder-core",
3
- "version": "1.0.3-alpha.0",
3
+ "version": "1.0.3",
4
4
  "description": "WayFinder core library for intelligently routing to optimal AR.IO gateways",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",