@equinor/fusion-framework-vite-plugin-spa 5.2.4-next.1 → 5.2.4

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,4 +1,392 @@
1
- import { D as DiagAPI, a as createContextKey } from './trace-api-DzxUyN-s.js';
1
+ /*
2
+ * Copyright The OpenTelemetry Authors
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+ // this is autogenerated file, see scripts/version-update.js
6
+ const VERSION$2 = '1.9.1';
7
+
8
+ /*
9
+ * Copyright The OpenTelemetry Authors
10
+ * SPDX-License-Identifier: Apache-2.0
11
+ */
12
+ const re = /^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;
13
+ /**
14
+ * Create a function to test an API version to see if it is compatible with the provided ownVersion.
15
+ *
16
+ * The returned function has the following semantics:
17
+ * - Exact match is always compatible
18
+ * - Major versions must match exactly
19
+ * - 1.x package cannot use global 2.x package
20
+ * - 2.x package cannot use global 1.x package
21
+ * - The minor version of the API module requesting access to the global API must be less than or equal to the minor version of this API
22
+ * - 1.3 package may use 1.4 global because the later global contains all functions 1.3 expects
23
+ * - 1.4 package may NOT use 1.3 global because it may try to call functions which don't exist on 1.3
24
+ * - If the major version is 0, the minor version is treated as the major and the patch is treated as the minor
25
+ * - Patch and build tag differences are not considered at this time
26
+ *
27
+ * @param ownVersion version which should be checked against
28
+ */
29
+ function _makeCompatibilityCheck(ownVersion) {
30
+ const acceptedVersions = new Set([ownVersion]);
31
+ const rejectedVersions = new Set();
32
+ const myVersionMatch = ownVersion.match(re);
33
+ if (!myVersionMatch) {
34
+ // we cannot guarantee compatibility so we always return noop
35
+ return () => false;
36
+ }
37
+ const ownVersionParsed = {
38
+ major: +myVersionMatch[1],
39
+ minor: +myVersionMatch[2],
40
+ patch: +myVersionMatch[3],
41
+ prerelease: myVersionMatch[4],
42
+ };
43
+ // if ownVersion has a prerelease tag, versions must match exactly
44
+ if (ownVersionParsed.prerelease != null) {
45
+ return function isExactmatch(globalVersion) {
46
+ return globalVersion === ownVersion;
47
+ };
48
+ }
49
+ function _reject(v) {
50
+ rejectedVersions.add(v);
51
+ return false;
52
+ }
53
+ function _accept(v) {
54
+ acceptedVersions.add(v);
55
+ return true;
56
+ }
57
+ return function isCompatible(globalVersion) {
58
+ if (acceptedVersions.has(globalVersion)) {
59
+ return true;
60
+ }
61
+ if (rejectedVersions.has(globalVersion)) {
62
+ return false;
63
+ }
64
+ const globalVersionMatch = globalVersion.match(re);
65
+ if (!globalVersionMatch) {
66
+ // cannot parse other version
67
+ // we cannot guarantee compatibility so we always noop
68
+ return _reject(globalVersion);
69
+ }
70
+ const globalVersionParsed = {
71
+ major: +globalVersionMatch[1],
72
+ minor: +globalVersionMatch[2],
73
+ patch: +globalVersionMatch[3],
74
+ prerelease: globalVersionMatch[4],
75
+ };
76
+ // if globalVersion has a prerelease tag, versions must match exactly
77
+ if (globalVersionParsed.prerelease != null) {
78
+ return _reject(globalVersion);
79
+ }
80
+ // major versions must match
81
+ if (ownVersionParsed.major !== globalVersionParsed.major) {
82
+ return _reject(globalVersion);
83
+ }
84
+ if (ownVersionParsed.major === 0) {
85
+ if (ownVersionParsed.minor === globalVersionParsed.minor &&
86
+ ownVersionParsed.patch <= globalVersionParsed.patch) {
87
+ return _accept(globalVersion);
88
+ }
89
+ return _reject(globalVersion);
90
+ }
91
+ if (ownVersionParsed.minor <= globalVersionParsed.minor) {
92
+ return _accept(globalVersion);
93
+ }
94
+ return _reject(globalVersion);
95
+ };
96
+ }
97
+ /**
98
+ * Test an API version to see if it is compatible with this API.
99
+ *
100
+ * - Exact match is always compatible
101
+ * - Major versions must match exactly
102
+ * - 1.x package cannot use global 2.x package
103
+ * - 2.x package cannot use global 1.x package
104
+ * - The minor version of the API module requesting access to the global API must be less than or equal to the minor version of this API
105
+ * - 1.3 package may use 1.4 global because the later global contains all functions 1.3 expects
106
+ * - 1.4 package may NOT use 1.3 global because it may try to call functions which don't exist on 1.3
107
+ * - If the major version is 0, the minor version is treated as the major and the patch is treated as the minor
108
+ * - Patch and build tag differences are not considered at this time
109
+ *
110
+ * @param version version of the API requesting an instance of the global API
111
+ */
112
+ const isCompatible = _makeCompatibilityCheck(VERSION$2);
113
+
114
+ /*
115
+ * Copyright The OpenTelemetry Authors
116
+ * SPDX-License-Identifier: Apache-2.0
117
+ */
118
+ const major = VERSION$2.split('.')[0];
119
+ const GLOBAL_OPENTELEMETRY_API_KEY = Symbol.for(`opentelemetry.js.api.${major}`);
120
+ const _global = (typeof globalThis === 'object'
121
+ ? globalThis
122
+ : typeof self === 'object'
123
+ ? self
124
+ : typeof window === 'object'
125
+ ? window
126
+ : typeof global === 'object'
127
+ ? global
128
+ : {});
129
+ function registerGlobal(type, instance, diag, allowOverride = false) {
130
+ var _a;
131
+ const api = (_global[GLOBAL_OPENTELEMETRY_API_KEY] = (_a = _global[GLOBAL_OPENTELEMETRY_API_KEY]) !== null && _a !== void 0 ? _a : {
132
+ version: VERSION$2,
133
+ });
134
+ if (!allowOverride && api[type]) {
135
+ // already registered an API of this type
136
+ const err = new Error(`@opentelemetry/api: Attempted duplicate registration of API: ${type}`);
137
+ diag.error(err.stack || err.message);
138
+ return false;
139
+ }
140
+ if (api.version !== VERSION$2) {
141
+ // All registered APIs must be of the same version exactly
142
+ const err = new Error(`@opentelemetry/api: Registration of version v${api.version} for ${type} does not match previously registered API v${VERSION$2}`);
143
+ diag.error(err.stack || err.message);
144
+ return false;
145
+ }
146
+ api[type] = instance;
147
+ diag.debug(`@opentelemetry/api: Registered a global for ${type} v${VERSION$2}.`);
148
+ return true;
149
+ }
150
+ function getGlobal(type) {
151
+ var _a, _b;
152
+ const globalVersion = (_a = _global[GLOBAL_OPENTELEMETRY_API_KEY]) === null || _a === void 0 ? void 0 : _a.version;
153
+ if (!globalVersion || !isCompatible(globalVersion)) {
154
+ return;
155
+ }
156
+ return (_b = _global[GLOBAL_OPENTELEMETRY_API_KEY]) === null || _b === void 0 ? void 0 : _b[type];
157
+ }
158
+ function unregisterGlobal(type, diag) {
159
+ diag.debug(`@opentelemetry/api: Unregistering a global for ${type} v${VERSION$2}.`);
160
+ const api = _global[GLOBAL_OPENTELEMETRY_API_KEY];
161
+ if (api) {
162
+ delete api[type];
163
+ }
164
+ }
165
+
166
+ /*
167
+ * Copyright The OpenTelemetry Authors
168
+ * SPDX-License-Identifier: Apache-2.0
169
+ */
170
+ /**
171
+ * Component Logger which is meant to be used as part of any component which
172
+ * will add automatically additional namespace in front of the log message.
173
+ * It will then forward all message to global diag logger
174
+ * @example
175
+ * const cLogger = diag.createComponentLogger({ namespace: '@opentelemetry/instrumentation-http' });
176
+ * cLogger.debug('test');
177
+ * // @opentelemetry/instrumentation-http test
178
+ */
179
+ class DiagComponentLogger {
180
+ constructor(props) {
181
+ this._namespace = props.namespace || 'DiagComponentLogger';
182
+ }
183
+ debug(...args) {
184
+ return logProxy('debug', this._namespace, args);
185
+ }
186
+ error(...args) {
187
+ return logProxy('error', this._namespace, args);
188
+ }
189
+ info(...args) {
190
+ return logProxy('info', this._namespace, args);
191
+ }
192
+ warn(...args) {
193
+ return logProxy('warn', this._namespace, args);
194
+ }
195
+ verbose(...args) {
196
+ return logProxy('verbose', this._namespace, args);
197
+ }
198
+ }
199
+ function logProxy(funcName, namespace, args) {
200
+ const logger = getGlobal('diag');
201
+ // shortcut if logger not set
202
+ if (!logger) {
203
+ return;
204
+ }
205
+ return logger[funcName](namespace, ...args);
206
+ }
207
+
208
+ /*
209
+ * Copyright The OpenTelemetry Authors
210
+ * SPDX-License-Identifier: Apache-2.0
211
+ */
212
+ /**
213
+ * Defines the available internal logging levels for the diagnostic logger, the numeric values
214
+ * of the levels are defined to match the original values from the initial LogLevel to avoid
215
+ * compatibility/migration issues for any implementation that assume the numeric ordering.
216
+ */
217
+ var DiagLogLevel;
218
+ (function (DiagLogLevel) {
219
+ /** Diagnostic Logging level setting to disable all logging (except and forced logs) */
220
+ DiagLogLevel[DiagLogLevel["NONE"] = 0] = "NONE";
221
+ /** Identifies an error scenario */
222
+ DiagLogLevel[DiagLogLevel["ERROR"] = 30] = "ERROR";
223
+ /** Identifies a warning scenario */
224
+ DiagLogLevel[DiagLogLevel["WARN"] = 50] = "WARN";
225
+ /** General informational log message */
226
+ DiagLogLevel[DiagLogLevel["INFO"] = 60] = "INFO";
227
+ /** General debug log message */
228
+ DiagLogLevel[DiagLogLevel["DEBUG"] = 70] = "DEBUG";
229
+ /**
230
+ * Detailed trace level logging should only be used for development, should only be set
231
+ * in a development environment.
232
+ */
233
+ DiagLogLevel[DiagLogLevel["VERBOSE"] = 80] = "VERBOSE";
234
+ /** Used to set the logging level to include all logging */
235
+ DiagLogLevel[DiagLogLevel["ALL"] = 9999] = "ALL";
236
+ })(DiagLogLevel || (DiagLogLevel = {}));
237
+
238
+ /*
239
+ * Copyright The OpenTelemetry Authors
240
+ * SPDX-License-Identifier: Apache-2.0
241
+ */
242
+ function createLogLevelDiagLogger(maxLevel, logger) {
243
+ if (maxLevel < DiagLogLevel.NONE) {
244
+ maxLevel = DiagLogLevel.NONE;
245
+ }
246
+ else if (maxLevel > DiagLogLevel.ALL) {
247
+ maxLevel = DiagLogLevel.ALL;
248
+ }
249
+ // In case the logger is null or undefined
250
+ logger = logger || {};
251
+ function _filterFunc(funcName, theLevel) {
252
+ const theFunc = logger[funcName];
253
+ if (typeof theFunc === 'function' && maxLevel >= theLevel) {
254
+ return theFunc.bind(logger);
255
+ }
256
+ return function () { };
257
+ }
258
+ return {
259
+ error: _filterFunc('error', DiagLogLevel.ERROR),
260
+ warn: _filterFunc('warn', DiagLogLevel.WARN),
261
+ info: _filterFunc('info', DiagLogLevel.INFO),
262
+ debug: _filterFunc('debug', DiagLogLevel.DEBUG),
263
+ verbose: _filterFunc('verbose', DiagLogLevel.VERBOSE),
264
+ };
265
+ }
266
+
267
+ /*
268
+ * Copyright The OpenTelemetry Authors
269
+ * SPDX-License-Identifier: Apache-2.0
270
+ */
271
+ const API_NAME$2 = 'diag';
272
+ /**
273
+ * Singleton object which represents the entry point to the OpenTelemetry internal
274
+ * diagnostic API
275
+ *
276
+ * @since 1.0.0
277
+ */
278
+ class DiagAPI {
279
+ /** Get the singleton instance of the DiagAPI API */
280
+ static instance() {
281
+ if (!this._instance) {
282
+ this._instance = new DiagAPI();
283
+ }
284
+ return this._instance;
285
+ }
286
+ /**
287
+ * Private internal constructor
288
+ * @private
289
+ */
290
+ constructor() {
291
+ function _logProxy(funcName) {
292
+ return function (...args) {
293
+ const logger = getGlobal('diag');
294
+ // shortcut if logger not set
295
+ if (!logger)
296
+ return;
297
+ return logger[funcName](...args);
298
+ };
299
+ }
300
+ // Using self local variable for minification purposes as 'this' cannot be minified
301
+ const self = this;
302
+ // DiagAPI specific functions
303
+ const setLogger = (logger, optionsOrLogLevel = { logLevel: DiagLogLevel.INFO }) => {
304
+ var _a, _b, _c;
305
+ if (logger === self) {
306
+ // There isn't much we can do here.
307
+ // Logging to the console might break the user application.
308
+ // Try to log to self. If a logger was previously registered it will receive the log.
309
+ const err = new Error('Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation');
310
+ self.error((_a = err.stack) !== null && _a !== void 0 ? _a : err.message);
311
+ return false;
312
+ }
313
+ if (typeof optionsOrLogLevel === 'number') {
314
+ optionsOrLogLevel = {
315
+ logLevel: optionsOrLogLevel,
316
+ };
317
+ }
318
+ const oldLogger = getGlobal('diag');
319
+ const newLogger = createLogLevelDiagLogger((_b = optionsOrLogLevel.logLevel) !== null && _b !== void 0 ? _b : DiagLogLevel.INFO, logger);
320
+ // There already is an logger registered. We'll let it know before overwriting it.
321
+ if (oldLogger && !optionsOrLogLevel.suppressOverrideMessage) {
322
+ const stack = (_c = new Error().stack) !== null && _c !== void 0 ? _c : '<failed to generate stacktrace>';
323
+ oldLogger.warn(`Current logger will be overwritten from ${stack}`);
324
+ newLogger.warn(`Current logger will overwrite one already registered from ${stack}`);
325
+ }
326
+ return registerGlobal('diag', newLogger, self, true);
327
+ };
328
+ self.setLogger = setLogger;
329
+ self.disable = () => {
330
+ unregisterGlobal(API_NAME$2, self);
331
+ };
332
+ self.createComponentLogger = (options) => {
333
+ return new DiagComponentLogger(options);
334
+ };
335
+ self.verbose = _logProxy('verbose');
336
+ self.debug = _logProxy('debug');
337
+ self.info = _logProxy('info');
338
+ self.warn = _logProxy('warn');
339
+ self.error = _logProxy('error');
340
+ }
341
+ }
342
+
343
+ /*
344
+ * Copyright The OpenTelemetry Authors
345
+ * SPDX-License-Identifier: Apache-2.0
346
+ */
347
+ /**
348
+ * Get a key to uniquely identify a context value
349
+ *
350
+ * @since 1.0.0
351
+ */
352
+ function createContextKey(description) {
353
+ // The specification states that for the same input, multiple calls should
354
+ // return different keys. Due to the nature of the JS dependency management
355
+ // system, this creates problems where multiple versions of some package
356
+ // could hold different keys for the same property.
357
+ //
358
+ // Therefore, we use Symbol.for which returns the same key for the same input.
359
+ return Symbol.for(description);
360
+ }
361
+ class BaseContext {
362
+ /**
363
+ * Construct a new context which inherits values from an optional parent context.
364
+ *
365
+ * @param parentContext a context from which to inherit values
366
+ */
367
+ constructor(parentContext) {
368
+ // for minification
369
+ const self = this;
370
+ self._currentContext = parentContext ? new Map(parentContext) : new Map();
371
+ self.getValue = (key) => self._currentContext.get(key);
372
+ self.setValue = (key, value) => {
373
+ const context = new BaseContext(self._currentContext);
374
+ context._currentContext.set(key, value);
375
+ return context;
376
+ };
377
+ self.deleteValue = (key) => {
378
+ const context = new BaseContext(self._currentContext);
379
+ context._currentContext.delete(key);
380
+ return context;
381
+ };
382
+ }
383
+ }
384
+ /**
385
+ * The root context is used as the default parent context when there is no active context
386
+ *
387
+ * @since 1.0.0
388
+ */
389
+ const ROOT_CONTEXT = new BaseContext();
2
390
 
3
391
  /*
4
392
  * Copyright The OpenTelemetry Authors
@@ -104,6 +492,467 @@ function createNoopMeter() {
104
492
  return NOOP_METER;
105
493
  }
106
494
 
495
+ /*
496
+ * Copyright The OpenTelemetry Authors
497
+ * SPDX-License-Identifier: Apache-2.0
498
+ */
499
+ class NoopContextManager {
500
+ active() {
501
+ return ROOT_CONTEXT;
502
+ }
503
+ with(_context, fn, thisArg, ...args) {
504
+ return fn.call(thisArg, ...args);
505
+ }
506
+ bind(_context, target) {
507
+ return target;
508
+ }
509
+ enable() {
510
+ return this;
511
+ }
512
+ disable() {
513
+ return this;
514
+ }
515
+ }
516
+
517
+ /*
518
+ * Copyright The OpenTelemetry Authors
519
+ * SPDX-License-Identifier: Apache-2.0
520
+ */
521
+ const API_NAME$1 = 'context';
522
+ const NOOP_CONTEXT_MANAGER = new NoopContextManager();
523
+ /**
524
+ * Singleton object which represents the entry point to the OpenTelemetry Context API
525
+ *
526
+ * @since 1.0.0
527
+ */
528
+ class ContextAPI {
529
+ /** Empty private constructor prevents end users from constructing a new instance of the API */
530
+ constructor() { }
531
+ /** Get the singleton instance of the Context API */
532
+ static getInstance() {
533
+ if (!this._instance) {
534
+ this._instance = new ContextAPI();
535
+ }
536
+ return this._instance;
537
+ }
538
+ /**
539
+ * Set the current context manager.
540
+ *
541
+ * @returns true if the context manager was successfully registered, else false
542
+ */
543
+ setGlobalContextManager(contextManager) {
544
+ return registerGlobal(API_NAME$1, contextManager, DiagAPI.instance());
545
+ }
546
+ /**
547
+ * Get the currently active context
548
+ */
549
+ active() {
550
+ return this._getContextManager().active();
551
+ }
552
+ /**
553
+ * Execute a function with an active context
554
+ *
555
+ * @param context context to be active during function execution
556
+ * @param fn function to execute in a context
557
+ * @param thisArg optional receiver to be used for calling fn
558
+ * @param args optional arguments forwarded to fn
559
+ */
560
+ with(context, fn, thisArg, ...args) {
561
+ return this._getContextManager().with(context, fn, thisArg, ...args);
562
+ }
563
+ /**
564
+ * Bind a context to a target function or event emitter
565
+ *
566
+ * @param context context to bind to the event emitter or function. Defaults to the currently active context
567
+ * @param target function or event emitter to bind
568
+ */
569
+ bind(context, target) {
570
+ return this._getContextManager().bind(context, target);
571
+ }
572
+ _getContextManager() {
573
+ return getGlobal(API_NAME$1) || NOOP_CONTEXT_MANAGER;
574
+ }
575
+ /** Disable and remove the global context manager */
576
+ disable() {
577
+ this._getContextManager().disable();
578
+ unregisterGlobal(API_NAME$1, DiagAPI.instance());
579
+ }
580
+ }
581
+
582
+ /*
583
+ * Copyright The OpenTelemetry Authors
584
+ * SPDX-License-Identifier: Apache-2.0
585
+ */
586
+ /**
587
+ * @since 1.0.0
588
+ */
589
+ var TraceFlags;
590
+ (function (TraceFlags) {
591
+ /** Represents no flag set. */
592
+ TraceFlags[TraceFlags["NONE"] = 0] = "NONE";
593
+ /** Bit to represent whether trace is sampled in trace flags. */
594
+ TraceFlags[TraceFlags["SAMPLED"] = 1] = "SAMPLED";
595
+ })(TraceFlags || (TraceFlags = {}));
596
+
597
+ /*
598
+ * Copyright The OpenTelemetry Authors
599
+ * SPDX-License-Identifier: Apache-2.0
600
+ */
601
+ /**
602
+ * @since 1.0.0
603
+ */
604
+ const INVALID_SPANID = '0000000000000000';
605
+ /**
606
+ * @since 1.0.0
607
+ */
608
+ const INVALID_TRACEID = '00000000000000000000000000000000';
609
+ /**
610
+ * @since 1.0.0
611
+ */
612
+ const INVALID_SPAN_CONTEXT = {
613
+ traceId: INVALID_TRACEID,
614
+ spanId: INVALID_SPANID,
615
+ traceFlags: TraceFlags.NONE,
616
+ };
617
+
618
+ /*
619
+ * Copyright The OpenTelemetry Authors
620
+ * SPDX-License-Identifier: Apache-2.0
621
+ */
622
+ /**
623
+ * The NonRecordingSpan is the default {@link Span} that is used when no Span
624
+ * implementation is available. All operations are no-op including context
625
+ * propagation.
626
+ */
627
+ class NonRecordingSpan {
628
+ constructor(spanContext = INVALID_SPAN_CONTEXT) {
629
+ this._spanContext = spanContext;
630
+ }
631
+ // Returns a SpanContext.
632
+ spanContext() {
633
+ return this._spanContext;
634
+ }
635
+ // By default does nothing
636
+ setAttribute(_key, _value) {
637
+ return this;
638
+ }
639
+ // By default does nothing
640
+ setAttributes(_attributes) {
641
+ return this;
642
+ }
643
+ // By default does nothing
644
+ addEvent(_name, _attributes) {
645
+ return this;
646
+ }
647
+ addLink(_link) {
648
+ return this;
649
+ }
650
+ addLinks(_links) {
651
+ return this;
652
+ }
653
+ // By default does nothing
654
+ setStatus(_status) {
655
+ return this;
656
+ }
657
+ // By default does nothing
658
+ updateName(_name) {
659
+ return this;
660
+ }
661
+ // By default does nothing
662
+ end(_endTime) { }
663
+ // isRecording always returns false for NonRecordingSpan.
664
+ isRecording() {
665
+ return false;
666
+ }
667
+ // By default does nothing
668
+ recordException(_exception, _time) { }
669
+ }
670
+
671
+ /*
672
+ * Copyright The OpenTelemetry Authors
673
+ * SPDX-License-Identifier: Apache-2.0
674
+ */
675
+ /**
676
+ * span key
677
+ */
678
+ const SPAN_KEY = createContextKey('OpenTelemetry Context Key SPAN');
679
+ /**
680
+ * Return the span if one exists
681
+ *
682
+ * @param context context to get span from
683
+ */
684
+ function getSpan(context) {
685
+ return context.getValue(SPAN_KEY) || undefined;
686
+ }
687
+ /**
688
+ * Gets the span from the current context, if one exists.
689
+ */
690
+ function getActiveSpan() {
691
+ return getSpan(ContextAPI.getInstance().active());
692
+ }
693
+ /**
694
+ * Set the span on a context
695
+ *
696
+ * @param context context to use as parent
697
+ * @param span span to set active
698
+ */
699
+ function setSpan(context, span) {
700
+ return context.setValue(SPAN_KEY, span);
701
+ }
702
+ /**
703
+ * Remove current span stored in the context
704
+ *
705
+ * @param context context to delete span from
706
+ */
707
+ function deleteSpan(context) {
708
+ return context.deleteValue(SPAN_KEY);
709
+ }
710
+ /**
711
+ * Wrap span context in a NoopSpan and set as span in a new
712
+ * context
713
+ *
714
+ * @param context context to set active span on
715
+ * @param spanContext span context to be wrapped
716
+ */
717
+ function setSpanContext(context, spanContext) {
718
+ return setSpan(context, new NonRecordingSpan(spanContext));
719
+ }
720
+ /**
721
+ * Get the span context of the span if it exists.
722
+ *
723
+ * @param context context to get values from
724
+ */
725
+ function getSpanContext(context) {
726
+ var _a;
727
+ return (_a = getSpan(context)) === null || _a === void 0 ? void 0 : _a.spanContext();
728
+ }
729
+
730
+ /*
731
+ * Copyright The OpenTelemetry Authors
732
+ * SPDX-License-Identifier: Apache-2.0
733
+ */
734
+ // Valid characters (0-9, a-f, A-F) are marked as 1.
735
+ const isHex = new Uint8Array([
736
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
737
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1,
738
+ 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0,
739
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1,
740
+ ]);
741
+ function isValidHex(id, length) {
742
+ // As of 1.9.0 the id was allowed to be a non-string value,
743
+ // even though it was not possible in the types.
744
+ if (typeof id !== 'string' || id.length !== length)
745
+ return false;
746
+ let r = 0;
747
+ for (let i = 0; i < id.length; i += 4) {
748
+ r +=
749
+ (isHex[id.charCodeAt(i)] | 0) +
750
+ (isHex[id.charCodeAt(i + 1)] | 0) +
751
+ (isHex[id.charCodeAt(i + 2)] | 0) +
752
+ (isHex[id.charCodeAt(i + 3)] | 0);
753
+ }
754
+ return r === length;
755
+ }
756
+ /**
757
+ * @since 1.0.0
758
+ */
759
+ function isValidTraceId(traceId) {
760
+ return isValidHex(traceId, 32) && traceId !== INVALID_TRACEID;
761
+ }
762
+ /**
763
+ * @since 1.0.0
764
+ */
765
+ function isValidSpanId(spanId) {
766
+ return isValidHex(spanId, 16) && spanId !== INVALID_SPANID;
767
+ }
768
+ /**
769
+ * Returns true if this {@link SpanContext} is valid.
770
+ * @return true if this {@link SpanContext} is valid.
771
+ *
772
+ * @since 1.0.0
773
+ */
774
+ function isSpanContextValid(spanContext) {
775
+ return (isValidTraceId(spanContext.traceId) && isValidSpanId(spanContext.spanId));
776
+ }
777
+ /**
778
+ * Wrap the given {@link SpanContext} in a new non-recording {@link Span}
779
+ *
780
+ * @param spanContext span context to be wrapped
781
+ * @returns a new non-recording {@link Span} with the provided context
782
+ */
783
+ function wrapSpanContext(spanContext) {
784
+ return new NonRecordingSpan(spanContext);
785
+ }
786
+
787
+ /*
788
+ * Copyright The OpenTelemetry Authors
789
+ * SPDX-License-Identifier: Apache-2.0
790
+ */
791
+ const contextApi = ContextAPI.getInstance();
792
+ /**
793
+ * No-op implementations of {@link Tracer}.
794
+ */
795
+ class NoopTracer {
796
+ // startSpan starts a noop span.
797
+ startSpan(name, options, context = contextApi.active()) {
798
+ const root = Boolean(options === null || options === void 0 ? void 0 : options.root);
799
+ if (root) {
800
+ return new NonRecordingSpan();
801
+ }
802
+ const parentFromContext = context && getSpanContext(context);
803
+ if (isSpanContext(parentFromContext) &&
804
+ isSpanContextValid(parentFromContext)) {
805
+ return new NonRecordingSpan(parentFromContext);
806
+ }
807
+ else {
808
+ return new NonRecordingSpan();
809
+ }
810
+ }
811
+ startActiveSpan(name, arg2, arg3, arg4) {
812
+ let opts;
813
+ let ctx;
814
+ let fn;
815
+ if (arguments.length < 2) {
816
+ return;
817
+ }
818
+ else if (arguments.length === 2) {
819
+ fn = arg2;
820
+ }
821
+ else if (arguments.length === 3) {
822
+ opts = arg2;
823
+ fn = arg3;
824
+ }
825
+ else {
826
+ opts = arg2;
827
+ ctx = arg3;
828
+ fn = arg4;
829
+ }
830
+ const parentContext = ctx !== null && ctx !== void 0 ? ctx : contextApi.active();
831
+ const span = this.startSpan(name, opts, parentContext);
832
+ const contextWithSpanSet = setSpan(parentContext, span);
833
+ return contextApi.with(contextWithSpanSet, fn, undefined, span);
834
+ }
835
+ }
836
+ function isSpanContext(spanContext) {
837
+ return (spanContext !== null &&
838
+ typeof spanContext === 'object' &&
839
+ 'spanId' in spanContext &&
840
+ typeof spanContext['spanId'] === 'string' &&
841
+ 'traceId' in spanContext &&
842
+ typeof spanContext['traceId'] === 'string' &&
843
+ 'traceFlags' in spanContext &&
844
+ typeof spanContext['traceFlags'] === 'number');
845
+ }
846
+
847
+ /*
848
+ * Copyright The OpenTelemetry Authors
849
+ * SPDX-License-Identifier: Apache-2.0
850
+ */
851
+ const NOOP_TRACER = new NoopTracer();
852
+ /**
853
+ * Proxy tracer provided by the proxy tracer provider
854
+ *
855
+ * @since 1.0.0
856
+ */
857
+ class ProxyTracer {
858
+ constructor(provider, name, version, options) {
859
+ this._provider = provider;
860
+ this.name = name;
861
+ this.version = version;
862
+ this.options = options;
863
+ }
864
+ startSpan(name, options, context) {
865
+ return this._getTracer().startSpan(name, options, context);
866
+ }
867
+ startActiveSpan(_name, _options, _context, _fn) {
868
+ const tracer = this._getTracer();
869
+ return Reflect.apply(tracer.startActiveSpan, tracer, arguments);
870
+ }
871
+ /**
872
+ * Try to get a tracer from the proxy tracer provider.
873
+ * If the proxy tracer provider has no delegate, return a noop tracer.
874
+ */
875
+ _getTracer() {
876
+ if (this._delegate) {
877
+ return this._delegate;
878
+ }
879
+ const tracer = this._provider.getDelegateTracer(this.name, this.version, this.options);
880
+ if (!tracer) {
881
+ return NOOP_TRACER;
882
+ }
883
+ this._delegate = tracer;
884
+ return this._delegate;
885
+ }
886
+ }
887
+
888
+ /*
889
+ * Copyright The OpenTelemetry Authors
890
+ * SPDX-License-Identifier: Apache-2.0
891
+ */
892
+ /**
893
+ * An implementation of the {@link TracerProvider} which returns an impotent
894
+ * Tracer for all calls to `getTracer`.
895
+ *
896
+ * All operations are no-op.
897
+ */
898
+ class NoopTracerProvider {
899
+ getTracer(_name, _version, _options) {
900
+ return new NoopTracer();
901
+ }
902
+ }
903
+
904
+ /*
905
+ * Copyright The OpenTelemetry Authors
906
+ * SPDX-License-Identifier: Apache-2.0
907
+ */
908
+ const NOOP_TRACER_PROVIDER = new NoopTracerProvider();
909
+ /**
910
+ * Tracer provider which provides {@link ProxyTracer}s.
911
+ *
912
+ * Before a delegate is set, tracers provided are NoOp.
913
+ * When a delegate is set, traces are provided from the delegate.
914
+ * When a delegate is set after tracers have already been provided,
915
+ * all tracers already provided will use the provided delegate implementation.
916
+ *
917
+ * @deprecated This will be removed in the next major version.
918
+ * @since 1.0.0
919
+ */
920
+ class ProxyTracerProvider {
921
+ /**
922
+ * Get a {@link ProxyTracer}
923
+ */
924
+ getTracer(name, version, options) {
925
+ var _a;
926
+ return ((_a = this.getDelegateTracer(name, version, options)) !== null && _a !== void 0 ? _a : new ProxyTracer(this, name, version, options));
927
+ }
928
+ getDelegate() {
929
+ var _a;
930
+ return (_a = this._delegate) !== null && _a !== void 0 ? _a : NOOP_TRACER_PROVIDER;
931
+ }
932
+ /**
933
+ * Set the delegate tracer provider
934
+ */
935
+ setDelegate(delegate) {
936
+ this._delegate = delegate;
937
+ }
938
+ getDelegateTracer(name, version, options) {
939
+ var _a;
940
+ return (_a = this._delegate) === null || _a === void 0 ? void 0 : _a.getTracer(name, version, options);
941
+ }
942
+ }
943
+
944
+ /*
945
+ * Copyright The OpenTelemetry Authors
946
+ * SPDX-License-Identifier: Apache-2.0
947
+ */
948
+ // Split module-level variable definition into separate files to allow
949
+ // tree-shaking on each api instance.
950
+ /**
951
+ * Entrypoint for context API
952
+ * @since 1.0.0
953
+ */
954
+ const context = ContextAPI.getInstance();
955
+
107
956
  /*
108
957
  * Copyright The OpenTelemetry Authors
109
958
  * SPDX-License-Identifier: Apache-2.0
@@ -120,6 +969,80 @@ function createNoopMeter() {
120
969
  */
121
970
  const diag = DiagAPI.instance();
122
971
 
972
+ /*
973
+ * Copyright The OpenTelemetry Authors
974
+ * SPDX-License-Identifier: Apache-2.0
975
+ */
976
+ const API_NAME = 'trace';
977
+ /**
978
+ * Singleton object which represents the entry point to the OpenTelemetry Tracing API
979
+ *
980
+ * @since 1.0.0
981
+ */
982
+ class TraceAPI {
983
+ /** Empty private constructor prevents end users from constructing a new instance of the API */
984
+ constructor() {
985
+ this._proxyTracerProvider = new ProxyTracerProvider();
986
+ this.wrapSpanContext = wrapSpanContext;
987
+ this.isSpanContextValid = isSpanContextValid;
988
+ this.deleteSpan = deleteSpan;
989
+ this.getSpan = getSpan;
990
+ this.getActiveSpan = getActiveSpan;
991
+ this.getSpanContext = getSpanContext;
992
+ this.setSpan = setSpan;
993
+ this.setSpanContext = setSpanContext;
994
+ }
995
+ /** Get the singleton instance of the Trace API */
996
+ static getInstance() {
997
+ if (!this._instance) {
998
+ this._instance = new TraceAPI();
999
+ }
1000
+ return this._instance;
1001
+ }
1002
+ /**
1003
+ * Set the current global tracer.
1004
+ *
1005
+ * @returns true if the tracer provider was successfully registered, else false
1006
+ */
1007
+ setGlobalTracerProvider(provider) {
1008
+ const success = registerGlobal(API_NAME, this._proxyTracerProvider, DiagAPI.instance());
1009
+ if (success) {
1010
+ this._proxyTracerProvider.setDelegate(provider);
1011
+ }
1012
+ return success;
1013
+ }
1014
+ /**
1015
+ * Returns the global tracer provider.
1016
+ */
1017
+ getTracerProvider() {
1018
+ return getGlobal(API_NAME) || this._proxyTracerProvider;
1019
+ }
1020
+ /**
1021
+ * Returns a tracer from the global tracer provider.
1022
+ */
1023
+ getTracer(name, version) {
1024
+ return this.getTracerProvider().getTracer(name, version);
1025
+ }
1026
+ /** Remove the global tracer provider */
1027
+ disable() {
1028
+ unregisterGlobal(API_NAME, DiagAPI.instance());
1029
+ this._proxyTracerProvider = new ProxyTracerProvider();
1030
+ }
1031
+ }
1032
+
1033
+ /*
1034
+ * Copyright The OpenTelemetry Authors
1035
+ * SPDX-License-Identifier: Apache-2.0
1036
+ */
1037
+ // Split module-level variable definition into separate files to allow
1038
+ // tree-shaking on each api instance.
1039
+ /**
1040
+ * Entrypoint for trace API
1041
+ *
1042
+ * @since 1.0.0
1043
+ */
1044
+ const trace = TraceAPI.getInstance();
1045
+
123
1046
  /*
124
1047
  * Copyright The OpenTelemetry Authors
125
1048
  * SPDX-License-Identifier: Apache-2.0
@@ -1835,5 +2758,5 @@ function createLegacyOtlpBrowserExportDelegate(config, serializer, metricsCompon
1835
2758
  return createOtlpFetchExportDelegate(options, serializer, createLegacyOtlpBrowserExporterMetrics(metricsComponentType, exporterMetricsHelper, options.url, config.selfObsMeterProvider));
1836
2759
  }
1837
2760
 
1838
- export { ATTR_EXCEPTION_TYPE as A, BindOnceFuture as B, ATTR_HTTP_RESPONSE_STATUS_CODE$1 as C, ATTR_SERVER_ADDRESS$1 as D, ExportResultCode as E, ATTR_SERVER_PORT$1 as F, ATTR_HTTP_REQUEST_METHOD as G, ATTR_HTTP_REQUEST_METHOD_ORIGINAL as H, resourceFromAttributes as I, JSON_ENCODER as J, toAnyValue as K, createNoopLogger as L, NOOP_METER as N, OTLPExporterBase as O, NoopLogger as a, NOOP_LOGGER as b, createInstrumentationScope as c, diag as d, createResource as e, createLegacyOtlpBrowserExportDelegate as f, isTimeInput as g, hrTimeDuration as h, isTracingSuppressed as i, hrTime as j, isTimeInputHrTime as k, addHrTimes as l, millisToHrTime as m, ATTR_EXCEPTION_MESSAGE as n, otperformance as o, ATTR_EXCEPTION_STACKTRACE as p, globalErrorHandler as q, ATTR_ERROR_TYPE$1 as r, createNoopMeter as s, toAttributes as t, suppressTracing as u, defaultResource as v, ATTR_URL_FULL as w, ATTR_USER_AGENT_ORIGINAL as x, hrTimeToNanoseconds as y, timeInputToHrTime as z };
1839
- //# sourceMappingURL=create-legacy-browser-delegate-CNfcydOG.js.map
2761
+ export { createNoopLogger as $, ATTR_EXCEPTION_TYPE as A, BindOnceFuture as B, ContextAPI as C, DiagAPI as D, createNoopMeter as E, suppressTracing as F, ExportResultCode as G, defaultResource as H, INVALID_SPAN_CONTEXT as I, JSON_ENCODER as J, isValidTraceId as K, ATTR_URL_FULL as L, ATTR_USER_AGENT_ORIGINAL as M, NOOP_METER as N, OTLPExporterBase as O, hrTimeToNanoseconds as P, timeInputToHrTime as Q, ROOT_CONTEXT as R, ATTR_HTTP_RESPONSE_STATUS_CODE$1 as S, TraceFlags as T, ATTR_SERVER_ADDRESS$1 as U, ATTR_SERVER_PORT$1 as V, ATTR_HTTP_REQUEST_METHOD as W, ATTR_HTTP_REQUEST_METHOD_ORIGINAL as X, ProxyTracerProvider as Y, resourceFromAttributes as Z, toAnyValue as _, isSpanContextValid as a, NoopLogger as b, createContextKey as c, diag as d, NOOP_LOGGER as e, createInstrumentationScope as f, getGlobal as g, createResource as h, isTracingSuppressed as i, toAttributes as j, createLegacyOtlpBrowserExportDelegate as k, isTimeInput as l, hrTimeDuration as m, hrTime as n, otperformance as o, millisToHrTime as p, isTimeInputHrTime as q, registerGlobal as r, addHrTimes as s, trace as t, unregisterGlobal as u, ATTR_EXCEPTION_MESSAGE as v, ATTR_EXCEPTION_STACKTRACE as w, context as x, globalErrorHandler as y, ATTR_ERROR_TYPE$1 as z };
2762
+ //# sourceMappingURL=create-legacy-browser-delegate-BqMGP3GI.js.map