@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,927 +0,0 @@
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 = '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);
113
-
114
- /*
115
- * Copyright The OpenTelemetry Authors
116
- * SPDX-License-Identifier: Apache-2.0
117
- */
118
- const major = VERSION.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,
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) {
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}`);
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}.`);
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}.`);
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();
390
-
391
- /*
392
- * Copyright The OpenTelemetry Authors
393
- * SPDX-License-Identifier: Apache-2.0
394
- */
395
- class NoopContextManager {
396
- active() {
397
- return ROOT_CONTEXT;
398
- }
399
- with(_context, fn, thisArg, ...args) {
400
- return fn.call(thisArg, ...args);
401
- }
402
- bind(_context, target) {
403
- return target;
404
- }
405
- enable() {
406
- return this;
407
- }
408
- disable() {
409
- return this;
410
- }
411
- }
412
-
413
- /*
414
- * Copyright The OpenTelemetry Authors
415
- * SPDX-License-Identifier: Apache-2.0
416
- */
417
- const API_NAME$1 = 'context';
418
- const NOOP_CONTEXT_MANAGER = new NoopContextManager();
419
- /**
420
- * Singleton object which represents the entry point to the OpenTelemetry Context API
421
- *
422
- * @since 1.0.0
423
- */
424
- class ContextAPI {
425
- /** Empty private constructor prevents end users from constructing a new instance of the API */
426
- constructor() { }
427
- /** Get the singleton instance of the Context API */
428
- static getInstance() {
429
- if (!this._instance) {
430
- this._instance = new ContextAPI();
431
- }
432
- return this._instance;
433
- }
434
- /**
435
- * Set the current context manager.
436
- *
437
- * @returns true if the context manager was successfully registered, else false
438
- */
439
- setGlobalContextManager(contextManager) {
440
- return registerGlobal(API_NAME$1, contextManager, DiagAPI.instance());
441
- }
442
- /**
443
- * Get the currently active context
444
- */
445
- active() {
446
- return this._getContextManager().active();
447
- }
448
- /**
449
- * Execute a function with an active context
450
- *
451
- * @param context context to be active during function execution
452
- * @param fn function to execute in a context
453
- * @param thisArg optional receiver to be used for calling fn
454
- * @param args optional arguments forwarded to fn
455
- */
456
- with(context, fn, thisArg, ...args) {
457
- return this._getContextManager().with(context, fn, thisArg, ...args);
458
- }
459
- /**
460
- * Bind a context to a target function or event emitter
461
- *
462
- * @param context context to bind to the event emitter or function. Defaults to the currently active context
463
- * @param target function or event emitter to bind
464
- */
465
- bind(context, target) {
466
- return this._getContextManager().bind(context, target);
467
- }
468
- _getContextManager() {
469
- return getGlobal(API_NAME$1) || NOOP_CONTEXT_MANAGER;
470
- }
471
- /** Disable and remove the global context manager */
472
- disable() {
473
- this._getContextManager().disable();
474
- unregisterGlobal(API_NAME$1, DiagAPI.instance());
475
- }
476
- }
477
-
478
- /*
479
- * Copyright The OpenTelemetry Authors
480
- * SPDX-License-Identifier: Apache-2.0
481
- */
482
- /**
483
- * @since 1.0.0
484
- */
485
- var TraceFlags;
486
- (function (TraceFlags) {
487
- /** Represents no flag set. */
488
- TraceFlags[TraceFlags["NONE"] = 0] = "NONE";
489
- /** Bit to represent whether trace is sampled in trace flags. */
490
- TraceFlags[TraceFlags["SAMPLED"] = 1] = "SAMPLED";
491
- })(TraceFlags || (TraceFlags = {}));
492
-
493
- /*
494
- * Copyright The OpenTelemetry Authors
495
- * SPDX-License-Identifier: Apache-2.0
496
- */
497
- /**
498
- * @since 1.0.0
499
- */
500
- const INVALID_SPANID = '0000000000000000';
501
- /**
502
- * @since 1.0.0
503
- */
504
- const INVALID_TRACEID = '00000000000000000000000000000000';
505
- /**
506
- * @since 1.0.0
507
- */
508
- const INVALID_SPAN_CONTEXT = {
509
- traceId: INVALID_TRACEID,
510
- spanId: INVALID_SPANID,
511
- traceFlags: TraceFlags.NONE,
512
- };
513
-
514
- /*
515
- * Copyright The OpenTelemetry Authors
516
- * SPDX-License-Identifier: Apache-2.0
517
- */
518
- /**
519
- * The NonRecordingSpan is the default {@link Span} that is used when no Span
520
- * implementation is available. All operations are no-op including context
521
- * propagation.
522
- */
523
- class NonRecordingSpan {
524
- constructor(spanContext = INVALID_SPAN_CONTEXT) {
525
- this._spanContext = spanContext;
526
- }
527
- // Returns a SpanContext.
528
- spanContext() {
529
- return this._spanContext;
530
- }
531
- // By default does nothing
532
- setAttribute(_key, _value) {
533
- return this;
534
- }
535
- // By default does nothing
536
- setAttributes(_attributes) {
537
- return this;
538
- }
539
- // By default does nothing
540
- addEvent(_name, _attributes) {
541
- return this;
542
- }
543
- addLink(_link) {
544
- return this;
545
- }
546
- addLinks(_links) {
547
- return this;
548
- }
549
- // By default does nothing
550
- setStatus(_status) {
551
- return this;
552
- }
553
- // By default does nothing
554
- updateName(_name) {
555
- return this;
556
- }
557
- // By default does nothing
558
- end(_endTime) { }
559
- // isRecording always returns false for NonRecordingSpan.
560
- isRecording() {
561
- return false;
562
- }
563
- // By default does nothing
564
- recordException(_exception, _time) { }
565
- }
566
-
567
- /*
568
- * Copyright The OpenTelemetry Authors
569
- * SPDX-License-Identifier: Apache-2.0
570
- */
571
- /**
572
- * span key
573
- */
574
- const SPAN_KEY = createContextKey('OpenTelemetry Context Key SPAN');
575
- /**
576
- * Return the span if one exists
577
- *
578
- * @param context context to get span from
579
- */
580
- function getSpan(context) {
581
- return context.getValue(SPAN_KEY) || undefined;
582
- }
583
- /**
584
- * Gets the span from the current context, if one exists.
585
- */
586
- function getActiveSpan() {
587
- return getSpan(ContextAPI.getInstance().active());
588
- }
589
- /**
590
- * Set the span on a context
591
- *
592
- * @param context context to use as parent
593
- * @param span span to set active
594
- */
595
- function setSpan(context, span) {
596
- return context.setValue(SPAN_KEY, span);
597
- }
598
- /**
599
- * Remove current span stored in the context
600
- *
601
- * @param context context to delete span from
602
- */
603
- function deleteSpan(context) {
604
- return context.deleteValue(SPAN_KEY);
605
- }
606
- /**
607
- * Wrap span context in a NoopSpan and set as span in a new
608
- * context
609
- *
610
- * @param context context to set active span on
611
- * @param spanContext span context to be wrapped
612
- */
613
- function setSpanContext(context, spanContext) {
614
- return setSpan(context, new NonRecordingSpan(spanContext));
615
- }
616
- /**
617
- * Get the span context of the span if it exists.
618
- *
619
- * @param context context to get values from
620
- */
621
- function getSpanContext(context) {
622
- var _a;
623
- return (_a = getSpan(context)) === null || _a === void 0 ? void 0 : _a.spanContext();
624
- }
625
-
626
- /*
627
- * Copyright The OpenTelemetry Authors
628
- * SPDX-License-Identifier: Apache-2.0
629
- */
630
- // Valid characters (0-9, a-f, A-F) are marked as 1.
631
- const isHex = new Uint8Array([
632
- 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,
633
- 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,
634
- 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,
635
- 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,
636
- ]);
637
- function isValidHex(id, length) {
638
- // As of 1.9.0 the id was allowed to be a non-string value,
639
- // even though it was not possible in the types.
640
- if (typeof id !== 'string' || id.length !== length)
641
- return false;
642
- let r = 0;
643
- for (let i = 0; i < id.length; i += 4) {
644
- r +=
645
- (isHex[id.charCodeAt(i)] | 0) +
646
- (isHex[id.charCodeAt(i + 1)] | 0) +
647
- (isHex[id.charCodeAt(i + 2)] | 0) +
648
- (isHex[id.charCodeAt(i + 3)] | 0);
649
- }
650
- return r === length;
651
- }
652
- /**
653
- * @since 1.0.0
654
- */
655
- function isValidTraceId(traceId) {
656
- return isValidHex(traceId, 32) && traceId !== INVALID_TRACEID;
657
- }
658
- /**
659
- * @since 1.0.0
660
- */
661
- function isValidSpanId(spanId) {
662
- return isValidHex(spanId, 16) && spanId !== INVALID_SPANID;
663
- }
664
- /**
665
- * Returns true if this {@link SpanContext} is valid.
666
- * @return true if this {@link SpanContext} is valid.
667
- *
668
- * @since 1.0.0
669
- */
670
- function isSpanContextValid(spanContext) {
671
- return (isValidTraceId(spanContext.traceId) && isValidSpanId(spanContext.spanId));
672
- }
673
- /**
674
- * Wrap the given {@link SpanContext} in a new non-recording {@link Span}
675
- *
676
- * @param spanContext span context to be wrapped
677
- * @returns a new non-recording {@link Span} with the provided context
678
- */
679
- function wrapSpanContext(spanContext) {
680
- return new NonRecordingSpan(spanContext);
681
- }
682
-
683
- /*
684
- * Copyright The OpenTelemetry Authors
685
- * SPDX-License-Identifier: Apache-2.0
686
- */
687
- const contextApi = ContextAPI.getInstance();
688
- /**
689
- * No-op implementations of {@link Tracer}.
690
- */
691
- class NoopTracer {
692
- // startSpan starts a noop span.
693
- startSpan(name, options, context = contextApi.active()) {
694
- const root = Boolean(options === null || options === void 0 ? void 0 : options.root);
695
- if (root) {
696
- return new NonRecordingSpan();
697
- }
698
- const parentFromContext = context && getSpanContext(context);
699
- if (isSpanContext(parentFromContext) &&
700
- isSpanContextValid(parentFromContext)) {
701
- return new NonRecordingSpan(parentFromContext);
702
- }
703
- else {
704
- return new NonRecordingSpan();
705
- }
706
- }
707
- startActiveSpan(name, arg2, arg3, arg4) {
708
- let opts;
709
- let ctx;
710
- let fn;
711
- if (arguments.length < 2) {
712
- return;
713
- }
714
- else if (arguments.length === 2) {
715
- fn = arg2;
716
- }
717
- else if (arguments.length === 3) {
718
- opts = arg2;
719
- fn = arg3;
720
- }
721
- else {
722
- opts = arg2;
723
- ctx = arg3;
724
- fn = arg4;
725
- }
726
- const parentContext = ctx !== null && ctx !== void 0 ? ctx : contextApi.active();
727
- const span = this.startSpan(name, opts, parentContext);
728
- const contextWithSpanSet = setSpan(parentContext, span);
729
- return contextApi.with(contextWithSpanSet, fn, undefined, span);
730
- }
731
- }
732
- function isSpanContext(spanContext) {
733
- return (spanContext !== null &&
734
- typeof spanContext === 'object' &&
735
- 'spanId' in spanContext &&
736
- typeof spanContext['spanId'] === 'string' &&
737
- 'traceId' in spanContext &&
738
- typeof spanContext['traceId'] === 'string' &&
739
- 'traceFlags' in spanContext &&
740
- typeof spanContext['traceFlags'] === 'number');
741
- }
742
-
743
- /*
744
- * Copyright The OpenTelemetry Authors
745
- * SPDX-License-Identifier: Apache-2.0
746
- */
747
- const NOOP_TRACER = new NoopTracer();
748
- /**
749
- * Proxy tracer provided by the proxy tracer provider
750
- *
751
- * @since 1.0.0
752
- */
753
- class ProxyTracer {
754
- constructor(provider, name, version, options) {
755
- this._provider = provider;
756
- this.name = name;
757
- this.version = version;
758
- this.options = options;
759
- }
760
- startSpan(name, options, context) {
761
- return this._getTracer().startSpan(name, options, context);
762
- }
763
- startActiveSpan(_name, _options, _context, _fn) {
764
- const tracer = this._getTracer();
765
- return Reflect.apply(tracer.startActiveSpan, tracer, arguments);
766
- }
767
- /**
768
- * Try to get a tracer from the proxy tracer provider.
769
- * If the proxy tracer provider has no delegate, return a noop tracer.
770
- */
771
- _getTracer() {
772
- if (this._delegate) {
773
- return this._delegate;
774
- }
775
- const tracer = this._provider.getDelegateTracer(this.name, this.version, this.options);
776
- if (!tracer) {
777
- return NOOP_TRACER;
778
- }
779
- this._delegate = tracer;
780
- return this._delegate;
781
- }
782
- }
783
-
784
- /*
785
- * Copyright The OpenTelemetry Authors
786
- * SPDX-License-Identifier: Apache-2.0
787
- */
788
- /**
789
- * An implementation of the {@link TracerProvider} which returns an impotent
790
- * Tracer for all calls to `getTracer`.
791
- *
792
- * All operations are no-op.
793
- */
794
- class NoopTracerProvider {
795
- getTracer(_name, _version, _options) {
796
- return new NoopTracer();
797
- }
798
- }
799
-
800
- /*
801
- * Copyright The OpenTelemetry Authors
802
- * SPDX-License-Identifier: Apache-2.0
803
- */
804
- const NOOP_TRACER_PROVIDER = new NoopTracerProvider();
805
- /**
806
- * Tracer provider which provides {@link ProxyTracer}s.
807
- *
808
- * Before a delegate is set, tracers provided are NoOp.
809
- * When a delegate is set, traces are provided from the delegate.
810
- * When a delegate is set after tracers have already been provided,
811
- * all tracers already provided will use the provided delegate implementation.
812
- *
813
- * @deprecated This will be removed in the next major version.
814
- * @since 1.0.0
815
- */
816
- class ProxyTracerProvider {
817
- /**
818
- * Get a {@link ProxyTracer}
819
- */
820
- getTracer(name, version, options) {
821
- var _a;
822
- return ((_a = this.getDelegateTracer(name, version, options)) !== null && _a !== void 0 ? _a : new ProxyTracer(this, name, version, options));
823
- }
824
- getDelegate() {
825
- var _a;
826
- return (_a = this._delegate) !== null && _a !== void 0 ? _a : NOOP_TRACER_PROVIDER;
827
- }
828
- /**
829
- * Set the delegate tracer provider
830
- */
831
- setDelegate(delegate) {
832
- this._delegate = delegate;
833
- }
834
- getDelegateTracer(name, version, options) {
835
- var _a;
836
- return (_a = this._delegate) === null || _a === void 0 ? void 0 : _a.getTracer(name, version, options);
837
- }
838
- }
839
-
840
- /*
841
- * Copyright The OpenTelemetry Authors
842
- * SPDX-License-Identifier: Apache-2.0
843
- */
844
- // Split module-level variable definition into separate files to allow
845
- // tree-shaking on each api instance.
846
- /**
847
- * Entrypoint for context API
848
- * @since 1.0.0
849
- */
850
- const context = ContextAPI.getInstance();
851
-
852
- /*
853
- * Copyright The OpenTelemetry Authors
854
- * SPDX-License-Identifier: Apache-2.0
855
- */
856
- const API_NAME = 'trace';
857
- /**
858
- * Singleton object which represents the entry point to the OpenTelemetry Tracing API
859
- *
860
- * @since 1.0.0
861
- */
862
- class TraceAPI {
863
- /** Empty private constructor prevents end users from constructing a new instance of the API */
864
- constructor() {
865
- this._proxyTracerProvider = new ProxyTracerProvider();
866
- this.wrapSpanContext = wrapSpanContext;
867
- this.isSpanContextValid = isSpanContextValid;
868
- this.deleteSpan = deleteSpan;
869
- this.getSpan = getSpan;
870
- this.getActiveSpan = getActiveSpan;
871
- this.getSpanContext = getSpanContext;
872
- this.setSpan = setSpan;
873
- this.setSpanContext = setSpanContext;
874
- }
875
- /** Get the singleton instance of the Trace API */
876
- static getInstance() {
877
- if (!this._instance) {
878
- this._instance = new TraceAPI();
879
- }
880
- return this._instance;
881
- }
882
- /**
883
- * Set the current global tracer.
884
- *
885
- * @returns true if the tracer provider was successfully registered, else false
886
- */
887
- setGlobalTracerProvider(provider) {
888
- const success = registerGlobal(API_NAME, this._proxyTracerProvider, DiagAPI.instance());
889
- if (success) {
890
- this._proxyTracerProvider.setDelegate(provider);
891
- }
892
- return success;
893
- }
894
- /**
895
- * Returns the global tracer provider.
896
- */
897
- getTracerProvider() {
898
- return getGlobal(API_NAME) || this._proxyTracerProvider;
899
- }
900
- /**
901
- * Returns a tracer from the global tracer provider.
902
- */
903
- getTracer(name, version) {
904
- return this.getTracerProvider().getTracer(name, version);
905
- }
906
- /** Remove the global tracer provider */
907
- disable() {
908
- unregisterGlobal(API_NAME, DiagAPI.instance());
909
- this._proxyTracerProvider = new ProxyTracerProvider();
910
- }
911
- }
912
-
913
- /*
914
- * Copyright The OpenTelemetry Authors
915
- * SPDX-License-Identifier: Apache-2.0
916
- */
917
- // Split module-level variable definition into separate files to allow
918
- // tree-shaking on each api instance.
919
- /**
920
- * Entrypoint for trace API
921
- *
922
- * @since 1.0.0
923
- */
924
- const trace = TraceAPI.getInstance();
925
-
926
- export { ContextAPI as C, DiagAPI as D, INVALID_SPAN_CONTEXT as I, ProxyTracerProvider as P, ROOT_CONTEXT as R, TraceFlags as T, createContextKey as a, isValidTraceId as b, context as c, getGlobal as g, isSpanContextValid as i, registerGlobal as r, trace as t, unregisterGlobal as u };
927
- //# sourceMappingURL=trace-api-DzxUyN-s.js.map