@ar.io/wayfinder-core 1.0.2-alpha.1 → 1.0.2

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.
@@ -17,7 +17,6 @@
17
17
  import { Span, type Tracer } from '@opentelemetry/api';
18
18
  import { NodeTracerProvider } from '@opentelemetry/sdk-trace-node';
19
19
  import { WebTracerProvider } from '@opentelemetry/sdk-trace-web';
20
- import 'zone.js';
21
20
  import { WayfinderEmitter } from './emitter.js';
22
21
  import type { GatewaysProvider, TelemetrySettings, WayfinderOptions } from './types.js';
23
22
  export declare const initTelemetry: ({ enabled, sampleRate, exporterUrl, apiKey, clientName, clientVersion, }: TelemetrySettings) => {
@@ -1 +1 @@
1
- {"version":3,"file":"telemetry.d.ts","sourceRoot":"","sources":["../src/telemetry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAGL,IAAI,EACJ,KAAK,MAAM,EAIZ,MAAM,oBAAoB,CAAC;AAS5B,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAKjE,OAAO,SAAS,CAAC;AACjB,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,KAAK,EACV,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EACjB,MAAM,YAAY,CAAC;AAQpB,eAAO,MAAM,aAAa,GAAI,0EAO3B,iBAAiB,KAChB;IACE,cAAc,EAAE,iBAAiB,GAAG,kBAAkB,CAAC;IACvD,MAAM,EAAE,MAAM,CAAC;CAChB,GACD,SA2DH,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,6FAO/B;IACD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,gBAAgB,CAAC;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,oBAAoB,CAAC,EAAE,gBAAgB,CAAC,sBAAsB,CAAC,CAAC;IAChE,eAAe,CAAC,EAAE,gBAAgB,CAAC,iBAAiB,CAAC,CAAC;IACtD,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;CAChC;;;;CA+EL,CAAC"}
1
+ {"version":3,"file":"telemetry.d.ts","sourceRoot":"","sources":["../src/telemetry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAGL,IAAI,EACJ,KAAK,MAAM,EAIZ,MAAM,oBAAoB,CAAC;AAS5B,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAKjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,KAAK,EACV,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EACjB,MAAM,YAAY,CAAC;AAcpB,eAAO,MAAM,aAAa,GAAI,0EAO3B,iBAAiB,KAChB;IACE,cAAc,EAAE,iBAAiB,GAAG,kBAAkB,CAAC;IACvD,MAAM,EAAE,MAAM,CAAC;CAChB,GACD,SAgEH,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,6FAO/B;IACD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,gBAAgB,CAAC;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,oBAAoB,CAAC,EAAE,gBAAgB,CAAC,sBAAsB,CAAC,CAAC;IAChE,eAAe,CAAC,EAAE,gBAAgB,CAAC,iBAAiB,CAAC,CAAC;IACtD,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;CAChC;;;;CA+EL,CAAC"}
package/dist/telemetry.js CHANGED
@@ -22,12 +22,16 @@ import { BatchSpanProcessor, SimpleSpanProcessor, TraceIdRatioBasedSampler, } fr
22
22
  import { NodeTracerProvider } from '@opentelemetry/sdk-trace-node';
23
23
  import { WebTracerProvider } from '@opentelemetry/sdk-trace-web';
24
24
  import { ATTR_SERVICE_NAME, ATTR_SERVICE_VERSION, } from '@opentelemetry/semantic-conventions';
25
- import 'zone.js';
26
25
  import { isBrowser, isChromeExtension } from './utils/browser.js';
26
+ import { assertZoneLoaded, loadZonePolyfill } from './utils/zone.js';
27
27
  import { WAYFINDER_CORE_VERSION } from './version.js';
28
28
  // avoid re-initializing the tracer provider and tracer
29
29
  let tracerProvider;
30
30
  let tracer;
31
+ // load zone.js polyfill if it's not already loaded
32
+ if (isBrowser()) {
33
+ loadZonePolyfill();
34
+ }
31
35
  export const initTelemetry = ({ enabled = false, sampleRate = 0.1, // 10% sample rate by default
32
36
  exporterUrl = 'https://api.honeycomb.io/v1/traces', apiKey = 'c8gU8dHlu6V7e5k2Gn9LaG', // intentionally left here - if it gets abused we'll disable it
33
37
  clientName, clientVersion, }) => {
@@ -72,6 +76,10 @@ clientName, clientVersion, }) => {
72
76
  resource,
73
77
  spanProcessors: [spanProcessor],
74
78
  });
79
+ // ensure zone.js is loaded before registering the tracer provider if we're using the browser
80
+ if (useWebTracer) {
81
+ assertZoneLoaded();
82
+ }
75
83
  provider.register({
76
84
  // zone.js is only used in the browser (node/extensions/service workers don't need it)
77
85
  contextManager: useWebTracer ? new ZoneContextManager() : undefined,
@@ -0,0 +1,3 @@
1
+ export declare function loadZonePolyfill(): Promise<void>;
2
+ export declare function assertZoneLoaded(): void;
3
+ //# sourceMappingURL=zone.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"zone.d.ts","sourceRoot":"","sources":["../../src/utils/zone.ts"],"names":[],"mappings":"AAmBA,wBAAsB,gBAAgB,kBAMrC;AAED,wBAAgB,gBAAgB,SAM/B"}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * WayFinder
3
+ * Copyright (C) 2022-2025 Permanent Data Solutions, Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { defaultLogger } from '../logger.js';
18
+ import { isBrowser } from './browser.js';
19
+ export async function loadZonePolyfill() {
20
+ // If Zone is already loaded, skip import
21
+ if (isBrowser() && typeof window.Zone === 'undefined') {
22
+ defaultLogger.info('Loading zone.js polyfill');
23
+ await import('zone.js');
24
+ }
25
+ }
26
+ export function assertZoneLoaded() {
27
+ if (isBrowser() && typeof window.Zone === 'undefined') {
28
+ throw new Error('Zone.js is not loaded. Please add zone.js to your project and call loadZonePolyfill() before initializing Wayfinder.');
29
+ }
30
+ }
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.2-alpha.1";
17
+ export declare const WAYFINDER_CORE_VERSION = "v1.0.2";
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.2-alpha.1';
17
+ export const WAYFINDER_CORE_VERSION = 'v1.0.2';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ar.io/wayfinder-core",
3
- "version": "1.0.2-alpha.1",
3
+ "version": "1.0.2",
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",