trace-kdzs-sdk 0.1.0 → 0.2.0
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/README.md +44 -18
- package/dist/{common-CvLLuxEe.mjs → common-C-0q1dq5.mjs} +2 -1
- package/dist/common-C-0q1dq5.mjs.map +1 -0
- package/dist/{common-BKQhi1LZ.cjs → common-Ckqz7sCS.cjs} +2 -1
- package/dist/common-Ckqz7sCS.cjs.map +1 -0
- package/dist/core-D3CEDvtx.cjs +876 -0
- package/dist/core-D3CEDvtx.cjs.map +1 -0
- package/dist/core-DQb65OGC.mjs +871 -0
- package/dist/core-DQb65OGC.mjs.map +1 -0
- package/dist/core.cjs +3 -53
- package/dist/core.d.cts +2 -2
- package/dist/core.d.mts +2 -2
- package/dist/core.mjs +2 -52
- package/dist/{index-FHW2y4dt.d.cts → index-BbSDp9gU.d.cts} +17 -2
- package/dist/{index-FHW2y4dt.d.mts → index-BbSDp9gU.d.mts} +17 -2
- package/dist/index.cjs +10 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -8
- package/dist/index.d.mts +11 -8
- package/dist/index.mjs +10 -6
- package/dist/index.mjs.map +1 -1
- package/dist/{web-CDlgH2Jq.mjs → web-2sJz3LXy.mjs} +26 -17
- package/dist/web-2sJz3LXy.mjs.map +1 -0
- package/dist/{web-Dbjr9K0w.cjs → web-PWAFlfHM.cjs} +26 -17
- package/dist/web-PWAFlfHM.cjs.map +1 -0
- package/dist/web.cjs +1 -1
- package/dist/web.d.cts +2 -4
- package/dist/web.d.mts +2 -4
- package/dist/web.mjs +1 -1
- package/docs/TRACE-SDK-API.md +32 -15
- package/package.json +20 -11
- package/dist/common-BKQhi1LZ.cjs.map +0 -1
- package/dist/common-CvLLuxEe.mjs.map +0 -1
- package/dist/core.cjs.map +0 -1
- package/dist/core.mjs.map +0 -1
- package/dist/web-CDlgH2Jq.mjs.map +0 -1
- package/dist/web-Dbjr9K0w.cjs.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core-DQb65OGC.mjs","names":[],"sources":["../node_modules/js-md5/build/md5.mjs","../node_modules/@lukeed/uuid/dist/index.mjs","../src/core/index.ts"],"sourcesContent":["function getDefaultExportFromCjs (x) {\n\treturn x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;\n}\n\nvar md5$1 = {exports: {}};\n\n/**\n * [js-md5]{@link https://github.com/emn178/js-md5}\n *\n * @namespace md5\n * @version 0.11.0\n * @author Chen, Yi-Cyuan [emn178@gmail.com]\n * @copyright Chen, Yi-Cyuan 2014-2026\n * @license MIT\n */\n\n(function (module) {\n\t(function () {\n\n\t var INPUT_ERROR = 'input is invalid type';\n\t var FINALIZE_ERROR = 'finalize already called';\n\t var WINDOW = typeof window === 'object';\n\t var root = WINDOW ? window : {};\n\t if (root.JS_MD5_NO_WINDOW) {\n\t WINDOW = false;\n\t }\n\t var WEB_WORKER = typeof WorkerGlobalScope !== 'undefined' && typeof self !== 'undefined' && self instanceof WorkerGlobalScope;\n\t if (WEB_WORKER) {\n\t root = self;\n\t }\n\t var COMMON_JS = !root.JS_MD5_NO_COMMON_JS && 'object' === 'object' && module.exports;\n\t /* istanbul ignore next */\n\t var ARRAY_BUFFER = !root.JS_MD5_NO_ARRAY_BUFFER && typeof ArrayBuffer !== 'undefined' ;\n\t var HEX_CHARS = '0123456789abcdef'.split('');\n\t var EXTRA = [128, 32768, 8388608, -2147483648];\n\t var SHIFT = [0, 8, 16, 24];\n\t var OUTPUT_TYPES = ['hex', 'array', 'digest', 'arrayBuffer'];\n\t /* istanbul ignore else */\n\t {\n\t OUTPUT_TYPES.push('buffer');\n\t }\n\t /* istanbul ignore else */\n\t {\n\t OUTPUT_TYPES.push('base64');\n\t }\n\t /* istanbul ignore next */\n\t var BASE64_ENCODE_CHAR = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'.split('') ;\n\n\t var blocks = [], buffer8;\n\t if (ARRAY_BUFFER) {\n\t var buffer = new ArrayBuffer(68);\n\t buffer8 = new Uint8Array(buffer);\n\t blocks = new Uint32Array(buffer);\n\t }\n\n\t var isArray = Array.isArray;\n\t /* istanbul ignore else */\n\t if ((root.JS_MD5_NO_NODE_JS || !isArray)) {\n\t isArray = function (obj) {\n\t return Object.prototype.toString.call(obj) === '[object Array]';\n\t };\n\t }\n\n\t var isView = ARRAY_BUFFER ? ArrayBuffer.isView : null;\n\t /* istanbul ignore else */\n\t if (ARRAY_BUFFER && (root.JS_MD5_NO_ARRAY_BUFFER_IS_VIEW || !isView)) {\n\t isView = function (obj) {\n\t return typeof obj === 'object' && obj.buffer && obj.buffer.constructor === ArrayBuffer;\n\t };\n\t }\n\n\t // [message: string, isString: bool]\n\t var formatMessage = function (message) {\n\t var type = typeof message;\n\t if (type === 'string') {\n\t return [message, true];\n\t }\n\t if (type !== 'object' || message === null) {\n\t throw new Error(INPUT_ERROR);\n\t }\n\t if (ARRAY_BUFFER && message.constructor === ArrayBuffer) {\n\t return [new Uint8Array(message), false];\n\t }\n\t if (isArray(message)) {\n\t return [message, false];\n\t }\n\t if (!ARRAY_BUFFER || !isView(message)) {\n\t throw new Error(INPUT_ERROR);\n\t }\n\t // read the underlying bytes of any view (DataView, Uint16Array, ...)\n\t return [new Uint8Array(message.buffer, message.byteOffset, message.byteLength), false];\n\t };\n\n\t /**\n\t * @method hex\n\t * @memberof md5\n\t * @description Output hash as hex string\n\t * @param {String|Array|Uint8Array|ArrayBuffer} message message to hash\n\t * @returns {String} Hex string\n\t * @example\n\t * md5.hex('The quick brown fox jumps over the lazy dog');\n\t * // equal to\n\t * md5('The quick brown fox jumps over the lazy dog');\n\t */\n\t /**\n\t * @method digest\n\t * @memberof md5\n\t * @description Output hash as bytes array\n\t * @param {String|Array|Uint8Array|ArrayBuffer} message message to hash\n\t * @returns {Array} Bytes array\n\t * @example\n\t * md5.digest('The quick brown fox jumps over the lazy dog');\n\t */\n\t /**\n\t * @method array\n\t * @memberof md5\n\t * @description Output hash as bytes array\n\t * @param {String|Array|Uint8Array|ArrayBuffer} message message to hash\n\t * @returns {Array} Bytes array\n\t * @example\n\t * md5.array('The quick brown fox jumps over the lazy dog');\n\t */\n\t /**\n\t * @method arrayBuffer\n\t * @memberof md5\n\t * @description Output hash as ArrayBuffer\n\t * @param {String|Array|Uint8Array|ArrayBuffer} message message to hash\n\t * @returns {ArrayBuffer} ArrayBuffer\n\t * @example\n\t * md5.arrayBuffer('The quick brown fox jumps over the lazy dog');\n\t */\n\t /**\n\t * @method buffer\n\t * @deprecated This maybe confuse with Buffer in node.js. Please use arrayBuffer instead.\n\t * @memberof md5\n\t * @description Output hash as ArrayBuffer\n\t * @param {String|Array|Uint8Array|ArrayBuffer} message message to hash\n\t * @returns {ArrayBuffer} ArrayBuffer\n\t * @example\n\t * md5.buffer('The quick brown fox jumps over the lazy dog');\n\t */\n\t /**\n\t * @method base64\n\t * @memberof md5\n\t * @description Output hash as base64 string\n\t * @param {String|Array|Uint8Array|ArrayBuffer} message message to hash\n\t * @returns {String} base64 string\n\t * @example\n\t * md5.base64('The quick brown fox jumps over the lazy dog');\n\t */\n\t var createOutputMethod = function (outputType) {\n\t return function (message) {\n\t return new Md5(true).update(message)[outputType]();\n\t };\n\t };\n\n\t /**\n\t * @method create\n\t * @memberof md5\n\t * @description Create Md5 object\n\t * @returns {Md5} Md5 object.\n\t * @example\n\t * var hash = md5.create();\n\t */\n\t /**\n\t * @method update\n\t * @memberof md5\n\t * @description Create and update Md5 object\n\t * @param {String|Array|Uint8Array|ArrayBuffer} message message to hash\n\t * @returns {Md5} Md5 object.\n\t * @example\n\t * var hash = md5.update('The quick brown fox jumps over the lazy dog');\n\t * // equal to\n\t * var hash = md5.create();\n\t * hash.update('The quick brown fox jumps over the lazy dog');\n\t */\n\t var createMethod = function () {\n\t var method = createOutputMethod('hex');\n\t method.create = function () {\n\t return new Md5();\n\t };\n\t method.update = function (message) {\n\t return method.create().update(message);\n\t };\n\t for (var i = 0; i < OUTPUT_TYPES.length; ++i) {\n\t var type = OUTPUT_TYPES[i];\n\t method[type] = createOutputMethod(type);\n\t }\n\t return method;\n\t };\n\n\t /**\n\t * @namespace md5.hmac\n\t */\n\t /**\n\t * @method hex\n\t * @memberof md5.hmac\n\t * @description Output hash as hex string\n\t * @param {String|Array|Uint8Array|ArrayBuffer} key key\n\t * @param {String|Array|Uint8Array|ArrayBuffer} message message to hash\n\t * @returns {String} Hex string\n\t * @example\n\t * md5.hmac.hex('key', 'The quick brown fox jumps over the lazy dog');\n\t * // equal to\n\t * md5.hmac('key', 'The quick brown fox jumps over the lazy dog');\n\t */\n\n\t /**\n\t * @method digest\n\t * @memberof md5.hmac\n\t * @description Output hash as bytes array\n\t * @param {String|Array|Uint8Array|ArrayBuffer} key key\n\t * @param {String|Array|Uint8Array|ArrayBuffer} message message to hash\n\t * @returns {Array} Bytes array\n\t * @example\n\t * md5.hmac.digest('key', 'The quick brown fox jumps over the lazy dog');\n\t */\n\t /**\n\t * @method array\n\t * @memberof md5.hmac\n\t * @description Output hash as bytes array\n\t * @param {String|Array|Uint8Array|ArrayBuffer} key key\n\t * @param {String|Array|Uint8Array|ArrayBuffer} message message to hash\n\t * @returns {Array} Bytes array\n\t * @example\n\t * md5.hmac.array('key', 'The quick brown fox jumps over the lazy dog');\n\t */\n\t /**\n\t * @method arrayBuffer\n\t * @memberof md5.hmac\n\t * @description Output hash as ArrayBuffer\n\t * @param {String|Array|Uint8Array|ArrayBuffer} key key\n\t * @param {String|Array|Uint8Array|ArrayBuffer} message message to hash\n\t * @returns {ArrayBuffer} ArrayBuffer\n\t * @example\n\t * md5.hmac.arrayBuffer('key', 'The quick brown fox jumps over the lazy dog');\n\t */\n\t /**\n\t * @method buffer\n\t * @deprecated This maybe confuse with Buffer in node.js. Please use arrayBuffer instead.\n\t * @memberof md5.hmac\n\t * @description Output hash as ArrayBuffer\n\t * @param {String|Array|Uint8Array|ArrayBuffer} key key\n\t * @param {String|Array|Uint8Array|ArrayBuffer} message message to hash\n\t * @returns {ArrayBuffer} ArrayBuffer\n\t * @example\n\t * md5.hmac.buffer('key', 'The quick brown fox jumps over the lazy dog');\n\t */\n\t /**\n\t * @method base64\n\t * @memberof md5.hmac\n\t * @description Output hash as base64 string\n\t * @param {String|Array|Uint8Array|ArrayBuffer} key key\n\t * @param {String|Array|Uint8Array|ArrayBuffer} message message to hash\n\t * @returns {String} base64 string\n\t * @example\n\t * md5.hmac.base64('key', 'The quick brown fox jumps over the lazy dog');\n\t */\n\t var createHmacOutputMethod = function (outputType) {\n\t return function (key, message) {\n\t return new HmacMd5(key, true).update(message)[outputType]();\n\t };\n\t };\n\n\t /**\n\t * @method create\n\t * @memberof md5.hmac\n\t * @description Create HmacMd5 object\n\t * @param {String|Array|Uint8Array|ArrayBuffer} key key\n\t * @returns {HmacMd5} HmacMd5 object.\n\t * @example\n\t * var hash = md5.hmac.create('key');\n\t */\n\t /**\n\t * @method update\n\t * @memberof md5.hmac\n\t * @description Create and update HmacMd5 object\n\t * @param {String|Array|Uint8Array|ArrayBuffer} key key\n\t * @param {String|Array|Uint8Array|ArrayBuffer} message message to hash\n\t * @returns {HmacMd5} HmacMd5 object.\n\t * @example\n\t * var hash = md5.hmac.update('key', 'The quick brown fox jumps over the lazy dog');\n\t * // equal to\n\t * var hash = md5.hmac.create('key');\n\t * hash.update('The quick brown fox jumps over the lazy dog');\n\t */\n\t var createHmacMethod = function () {\n\t var method = createHmacOutputMethod('hex');\n\t method.create = function (key) {\n\t return new HmacMd5(key);\n\t };\n\t method.update = function (key, message) {\n\t return method.create(key).update(message);\n\t };\n\t for (var i = 0; i < OUTPUT_TYPES.length; ++i) {\n\t var type = OUTPUT_TYPES[i];\n\t method[type] = createHmacOutputMethod(type);\n\t }\n\t return method;\n\t };\n\n\t /**\n\t * Md5 class\n\t * @class Md5\n\t * @description This is internal class.\n\t * @see {@link md5.create}\n\t */\n\t function Md5(sharedMemory) {\n\t if (sharedMemory) {\n\t blocks[0] = blocks[16] = blocks[1] = blocks[2] = blocks[3] =\n\t blocks[4] = blocks[5] = blocks[6] = blocks[7] =\n\t blocks[8] = blocks[9] = blocks[10] = blocks[11] =\n\t blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0;\n\t this.blocks = blocks;\n\t this.buffer8 = buffer8;\n\t } else {\n\t if (ARRAY_BUFFER) {\n\t var buffer = new ArrayBuffer(68);\n\t this.buffer8 = new Uint8Array(buffer);\n\t this.blocks = new Uint32Array(buffer);\n\t } else {\n\t this.blocks = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];\n\t }\n\t }\n\t this.h0 = this.h1 = this.h2 = this.h3 = this.start = this.bytes = this.hBytes = 0;\n\t this.finalized = this.hashed = false;\n\t this.first = true;\n\t }\n\n\t /**\n\t * @method update\n\t * @memberof Md5\n\t * @instance\n\t * @description Update hash\n\t * @param {String|Array|Uint8Array|ArrayBuffer} message message to hash\n\t * @returns {Md5} Md5 object.\n\t * @see {@link md5.update}\n\t */\n\t Md5.prototype.update = function (message) {\n\t if (this.finalized) {\n\t throw new Error(FINALIZE_ERROR);\n\t }\n\n\t var result = formatMessage(message);\n\t message = result[0];\n\t var isString = result[1];\n\t var code, code2, index = 0, i, length = message.length, blocks = this.blocks;\n\t var buffer8 = this.buffer8;\n\n\t while (index < length) {\n\t if (this.hashed) {\n\t this.hashed = false;\n\t blocks[0] = blocks[16];\n\t blocks[16] = blocks[1] = blocks[2] = blocks[3] =\n\t blocks[4] = blocks[5] = blocks[6] = blocks[7] =\n\t blocks[8] = blocks[9] = blocks[10] = blocks[11] =\n\t blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0;\n\t }\n\n\t if (isString) {\n\t if (ARRAY_BUFFER) {\n\t for (i = this.start; index < length && i < 64; ++index) {\n\t code = message.charCodeAt(index);\n\t if (code < 0x80) {\n\t buffer8[i++] = code;\n\t } else if (code < 0x800) {\n\t buffer8[i++] = 0xc0 | (code >>> 6);\n\t buffer8[i++] = 0x80 | (code & 0x3f);\n\t } else if (code < 0xd800 || code >= 0xe000) {\n\t buffer8[i++] = 0xe0 | (code >>> 12);\n\t buffer8[i++] = 0x80 | ((code >>> 6) & 0x3f);\n\t buffer8[i++] = 0x80 | (code & 0x3f);\n\t } else if (code < 0xdc00 && (code2 = message.charCodeAt(index + 1)) >= 0xdc00 && code2 < 0xe000) {\n\t ++index;\n\t code = 0x10000 + (((code & 0x3ff) << 10) | (code2 & 0x3ff));\n\t buffer8[i++] = 0xf0 | (code >>> 18);\n\t buffer8[i++] = 0x80 | ((code >>> 12) & 0x3f);\n\t buffer8[i++] = 0x80 | ((code >>> 6) & 0x3f);\n\t buffer8[i++] = 0x80 | (code & 0x3f);\n\t } else {\n\t // unpaired surrogate: U+FFFD\n\t buffer8[i++] = 0xef;\n\t buffer8[i++] = 0xbf;\n\t buffer8[i++] = 0xbd;\n\t }\n\t }\n\t } else {\n\t for (i = this.start; index < length && i < 64; ++index) {\n\t code = message.charCodeAt(index);\n\t if (code < 0x80) {\n\t blocks[i >>> 2] |= code << SHIFT[i++ & 3];\n\t } else if (code < 0x800) {\n\t blocks[i >>> 2] |= (0xc0 | (code >>> 6)) << SHIFT[i++ & 3];\n\t blocks[i >>> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];\n\t } else if (code < 0xd800 || code >= 0xe000) {\n\t blocks[i >>> 2] |= (0xe0 | (code >>> 12)) << SHIFT[i++ & 3];\n\t blocks[i >>> 2] |= (0x80 | ((code >>> 6) & 0x3f)) << SHIFT[i++ & 3];\n\t blocks[i >>> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];\n\t } else if (code < 0xdc00 && (code2 = message.charCodeAt(index + 1)) >= 0xdc00 && code2 < 0xe000) {\n\t ++index;\n\t code = 0x10000 + (((code & 0x3ff) << 10) | (code2 & 0x3ff));\n\t blocks[i >>> 2] |= (0xf0 | (code >>> 18)) << SHIFT[i++ & 3];\n\t blocks[i >>> 2] |= (0x80 | ((code >>> 12) & 0x3f)) << SHIFT[i++ & 3];\n\t blocks[i >>> 2] |= (0x80 | ((code >>> 6) & 0x3f)) << SHIFT[i++ & 3];\n\t blocks[i >>> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];\n\t } else {\n\t // unpaired surrogate: U+FFFD\n\t blocks[i >>> 2] |= 0xef << SHIFT[i++ & 3];\n\t blocks[i >>> 2] |= 0xbf << SHIFT[i++ & 3];\n\t blocks[i >>> 2] |= 0xbd << SHIFT[i++ & 3];\n\t }\n\t }\n\t }\n\t } else {\n\t if (ARRAY_BUFFER) {\n\t for (i = this.start; index < length && i < 64; ++index) {\n\t buffer8[i++] = message[index];\n\t }\n\t } else {\n\t for (i = this.start; index < length && i < 64; ++index) {\n\t blocks[i >>> 2] |= message[index] << SHIFT[i++ & 3];\n\t }\n\t }\n\t }\n\t this.lastByteIndex = i;\n\t this.bytes += i - this.start;\n\t if (i >= 64) {\n\t this.start = i - 64;\n\t this.hash();\n\t this.hashed = true;\n\t } else {\n\t this.start = i;\n\t }\n\t }\n\t if (this.bytes > 4294967295) {\n\t this.hBytes += this.bytes / 4294967296 << 0;\n\t this.bytes = this.bytes % 4294967296;\n\t }\n\t return this;\n\t };\n\n\t Md5.prototype.finalize = function () {\n\t if (this.finalized) {\n\t return;\n\t }\n\t this.finalized = true;\n\t var blocks = this.blocks, i = this.lastByteIndex;\n\t blocks[i >>> 2] |= EXTRA[i & 3];\n\t if (i >= 56) {\n\t if (!this.hashed) {\n\t this.hash();\n\t }\n\t blocks[0] = blocks[16];\n\t blocks[16] = blocks[1] = blocks[2] = blocks[3] =\n\t blocks[4] = blocks[5] = blocks[6] = blocks[7] =\n\t blocks[8] = blocks[9] = blocks[10] = blocks[11] =\n\t blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0;\n\t }\n\t blocks[14] = this.bytes << 3;\n\t blocks[15] = this.hBytes << 3 | this.bytes >>> 29;\n\t this.hash();\n\t };\n\n\t Md5.prototype.hash = function () {\n\t var a, b, c, d, bc, da, blocks = this.blocks;\n\n\t if (this.first) {\n\t a = blocks[0] - 680876937;\n\t a = (a << 7 | a >>> 25) - 271733879 << 0;\n\t d = (-1732584194 ^ a & 2004318071) + blocks[1] - 117830708;\n\t d = (d << 12 | d >>> 20) + a << 0;\n\t c = (-271733879 ^ (d & (a ^ -271733879))) + blocks[2] - 1126478375;\n\t c = (c << 17 | c >>> 15) + d << 0;\n\t b = (a ^ (c & (d ^ a))) + blocks[3] - 1316259209;\n\t b = (b << 22 | b >>> 10) + c << 0;\n\t } else {\n\t a = this.h0;\n\t b = this.h1;\n\t c = this.h2;\n\t d = this.h3;\n\t a += (d ^ (b & (c ^ d))) + blocks[0] - 680876936;\n\t a = (a << 7 | a >>> 25) + b << 0;\n\t d += (c ^ (a & (b ^ c))) + blocks[1] - 389564586;\n\t d = (d << 12 | d >>> 20) + a << 0;\n\t c += (b ^ (d & (a ^ b))) + blocks[2] + 606105819;\n\t c = (c << 17 | c >>> 15) + d << 0;\n\t b += (a ^ (c & (d ^ a))) + blocks[3] - 1044525330;\n\t b = (b << 22 | b >>> 10) + c << 0;\n\t }\n\n\t a += (d ^ (b & (c ^ d))) + blocks[4] - 176418897;\n\t a = (a << 7 | a >>> 25) + b << 0;\n\t d += (c ^ (a & (b ^ c))) + blocks[5] + 1200080426;\n\t d = (d << 12 | d >>> 20) + a << 0;\n\t c += (b ^ (d & (a ^ b))) + blocks[6] - 1473231341;\n\t c = (c << 17 | c >>> 15) + d << 0;\n\t b += (a ^ (c & (d ^ a))) + blocks[7] - 45705983;\n\t b = (b << 22 | b >>> 10) + c << 0;\n\t a += (d ^ (b & (c ^ d))) + blocks[8] + 1770035416;\n\t a = (a << 7 | a >>> 25) + b << 0;\n\t d += (c ^ (a & (b ^ c))) + blocks[9] - 1958414417;\n\t d = (d << 12 | d >>> 20) + a << 0;\n\t c += (b ^ (d & (a ^ b))) + blocks[10] - 42063;\n\t c = (c << 17 | c >>> 15) + d << 0;\n\t b += (a ^ (c & (d ^ a))) + blocks[11] - 1990404162;\n\t b = (b << 22 | b >>> 10) + c << 0;\n\t a += (d ^ (b & (c ^ d))) + blocks[12] + 1804603682;\n\t a = (a << 7 | a >>> 25) + b << 0;\n\t d += (c ^ (a & (b ^ c))) + blocks[13] - 40341101;\n\t d = (d << 12 | d >>> 20) + a << 0;\n\t c += (b ^ (d & (a ^ b))) + blocks[14] - 1502002290;\n\t c = (c << 17 | c >>> 15) + d << 0;\n\t b += (a ^ (c & (d ^ a))) + blocks[15] + 1236535329;\n\t b = (b << 22 | b >>> 10) + c << 0;\n\t a += (c ^ (d & (b ^ c))) + blocks[1] - 165796510;\n\t a = (a << 5 | a >>> 27) + b << 0;\n\t d += (b ^ (c & (a ^ b))) + blocks[6] - 1069501632;\n\t d = (d << 9 | d >>> 23) + a << 0;\n\t c += (a ^ (b & (d ^ a))) + blocks[11] + 643717713;\n\t c = (c << 14 | c >>> 18) + d << 0;\n\t b += (d ^ (a & (c ^ d))) + blocks[0] - 373897302;\n\t b = (b << 20 | b >>> 12) + c << 0;\n\t a += (c ^ (d & (b ^ c))) + blocks[5] - 701558691;\n\t a = (a << 5 | a >>> 27) + b << 0;\n\t d += (b ^ (c & (a ^ b))) + blocks[10] + 38016083;\n\t d = (d << 9 | d >>> 23) + a << 0;\n\t c += (a ^ (b & (d ^ a))) + blocks[15] - 660478335;\n\t c = (c << 14 | c >>> 18) + d << 0;\n\t b += (d ^ (a & (c ^ d))) + blocks[4] - 405537848;\n\t b = (b << 20 | b >>> 12) + c << 0;\n\t a += (c ^ (d & (b ^ c))) + blocks[9] + 568446438;\n\t a = (a << 5 | a >>> 27) + b << 0;\n\t d += (b ^ (c & (a ^ b))) + blocks[14] - 1019803690;\n\t d = (d << 9 | d >>> 23) + a << 0;\n\t c += (a ^ (b & (d ^ a))) + blocks[3] - 187363961;\n\t c = (c << 14 | c >>> 18) + d << 0;\n\t b += (d ^ (a & (c ^ d))) + blocks[8] + 1163531501;\n\t b = (b << 20 | b >>> 12) + c << 0;\n\t a += (c ^ (d & (b ^ c))) + blocks[13] - 1444681467;\n\t a = (a << 5 | a >>> 27) + b << 0;\n\t d += (b ^ (c & (a ^ b))) + blocks[2] - 51403784;\n\t d = (d << 9 | d >>> 23) + a << 0;\n\t c += (a ^ (b & (d ^ a))) + blocks[7] + 1735328473;\n\t c = (c << 14 | c >>> 18) + d << 0;\n\t b += (d ^ (a & (c ^ d))) + blocks[12] - 1926607734;\n\t b = (b << 20 | b >>> 12) + c << 0;\n\t bc = b ^ c;\n\t a += (bc ^ d) + blocks[5] - 378558;\n\t a = (a << 4 | a >>> 28) + b << 0;\n\t d += (bc ^ a) + blocks[8] - 2022574463;\n\t d = (d << 11 | d >>> 21) + a << 0;\n\t da = d ^ a;\n\t c += (da ^ b) + blocks[11] + 1839030562;\n\t c = (c << 16 | c >>> 16) + d << 0;\n\t b += (da ^ c) + blocks[14] - 35309556;\n\t b = (b << 23 | b >>> 9) + c << 0;\n\t bc = b ^ c;\n\t a += (bc ^ d) + blocks[1] - 1530992060;\n\t a = (a << 4 | a >>> 28) + b << 0;\n\t d += (bc ^ a) + blocks[4] + 1272893353;\n\t d = (d << 11 | d >>> 21) + a << 0;\n\t da = d ^ a;\n\t c += (da ^ b) + blocks[7] - 155497632;\n\t c = (c << 16 | c >>> 16) + d << 0;\n\t b += (da ^ c) + blocks[10] - 1094730640;\n\t b = (b << 23 | b >>> 9) + c << 0;\n\t bc = b ^ c;\n\t a += (bc ^ d) + blocks[13] + 681279174;\n\t a = (a << 4 | a >>> 28) + b << 0;\n\t d += (bc ^ a) + blocks[0] - 358537222;\n\t d = (d << 11 | d >>> 21) + a << 0;\n\t da = d ^ a;\n\t c += (da ^ b) + blocks[3] - 722521979;\n\t c = (c << 16 | c >>> 16) + d << 0;\n\t b += (da ^ c) + blocks[6] + 76029189;\n\t b = (b << 23 | b >>> 9) + c << 0;\n\t bc = b ^ c;\n\t a += (bc ^ d) + blocks[9] - 640364487;\n\t a = (a << 4 | a >>> 28) + b << 0;\n\t d += (bc ^ a) + blocks[12] - 421815835;\n\t d = (d << 11 | d >>> 21) + a << 0;\n\t da = d ^ a;\n\t c += (da ^ b) + blocks[15] + 530742520;\n\t c = (c << 16 | c >>> 16) + d << 0;\n\t b += (da ^ c) + blocks[2] - 995338651;\n\t b = (b << 23 | b >>> 9) + c << 0;\n\t a += (c ^ (b | ~d)) + blocks[0] - 198630844;\n\t a = (a << 6 | a >>> 26) + b << 0;\n\t d += (b ^ (a | ~c)) + blocks[7] + 1126891415;\n\t d = (d << 10 | d >>> 22) + a << 0;\n\t c += (a ^ (d | ~b)) + blocks[14] - 1416354905;\n\t c = (c << 15 | c >>> 17) + d << 0;\n\t b += (d ^ (c | ~a)) + blocks[5] - 57434055;\n\t b = (b << 21 | b >>> 11) + c << 0;\n\t a += (c ^ (b | ~d)) + blocks[12] + 1700485571;\n\t a = (a << 6 | a >>> 26) + b << 0;\n\t d += (b ^ (a | ~c)) + blocks[3] - 1894986606;\n\t d = (d << 10 | d >>> 22) + a << 0;\n\t c += (a ^ (d | ~b)) + blocks[10] - 1051523;\n\t c = (c << 15 | c >>> 17) + d << 0;\n\t b += (d ^ (c | ~a)) + blocks[1] - 2054922799;\n\t b = (b << 21 | b >>> 11) + c << 0;\n\t a += (c ^ (b | ~d)) + blocks[8] + 1873313359;\n\t a = (a << 6 | a >>> 26) + b << 0;\n\t d += (b ^ (a | ~c)) + blocks[15] - 30611744;\n\t d = (d << 10 | d >>> 22) + a << 0;\n\t c += (a ^ (d | ~b)) + blocks[6] - 1560198380;\n\t c = (c << 15 | c >>> 17) + d << 0;\n\t b += (d ^ (c | ~a)) + blocks[13] + 1309151649;\n\t b = (b << 21 | b >>> 11) + c << 0;\n\t a += (c ^ (b | ~d)) + blocks[4] - 145523070;\n\t a = (a << 6 | a >>> 26) + b << 0;\n\t d += (b ^ (a | ~c)) + blocks[11] - 1120210379;\n\t d = (d << 10 | d >>> 22) + a << 0;\n\t c += (a ^ (d | ~b)) + blocks[2] + 718787259;\n\t c = (c << 15 | c >>> 17) + d << 0;\n\t b += (d ^ (c | ~a)) + blocks[9] - 343485551;\n\t b = (b << 21 | b >>> 11) + c << 0;\n\n\t if (this.first) {\n\t this.h0 = a + 1732584193 << 0;\n\t this.h1 = b - 271733879 << 0;\n\t this.h2 = c - 1732584194 << 0;\n\t this.h3 = d + 271733878 << 0;\n\t this.first = false;\n\t } else {\n\t this.h0 = this.h0 + a << 0;\n\t this.h1 = this.h1 + b << 0;\n\t this.h2 = this.h2 + c << 0;\n\t this.h3 = this.h3 + d << 0;\n\t }\n\t };\n\n\t /**\n\t * @method hex\n\t * @memberof Md5\n\t * @instance\n\t * @description Output hash as hex string\n\t * @returns {String} Hex string\n\t * @see {@link md5.hex}\n\t * @example\n\t * hash.hex();\n\t */\n\t Md5.prototype.hex = function () {\n\t this.finalize();\n\n\t var h0 = this.h0, h1 = this.h1, h2 = this.h2, h3 = this.h3;\n\n\t return HEX_CHARS[(h0 >>> 4) & 0x0F] + HEX_CHARS[h0 & 0x0F] +\n\t HEX_CHARS[(h0 >>> 12) & 0x0F] + HEX_CHARS[(h0 >>> 8) & 0x0F] +\n\t HEX_CHARS[(h0 >>> 20) & 0x0F] + HEX_CHARS[(h0 >>> 16) & 0x0F] +\n\t HEX_CHARS[(h0 >>> 28) & 0x0F] + HEX_CHARS[(h0 >>> 24) & 0x0F] +\n\t HEX_CHARS[(h1 >>> 4) & 0x0F] + HEX_CHARS[h1 & 0x0F] +\n\t HEX_CHARS[(h1 >>> 12) & 0x0F] + HEX_CHARS[(h1 >>> 8) & 0x0F] +\n\t HEX_CHARS[(h1 >>> 20) & 0x0F] + HEX_CHARS[(h1 >>> 16) & 0x0F] +\n\t HEX_CHARS[(h1 >>> 28) & 0x0F] + HEX_CHARS[(h1 >>> 24) & 0x0F] +\n\t HEX_CHARS[(h2 >>> 4) & 0x0F] + HEX_CHARS[h2 & 0x0F] +\n\t HEX_CHARS[(h2 >>> 12) & 0x0F] + HEX_CHARS[(h2 >>> 8) & 0x0F] +\n\t HEX_CHARS[(h2 >>> 20) & 0x0F] + HEX_CHARS[(h2 >>> 16) & 0x0F] +\n\t HEX_CHARS[(h2 >>> 28) & 0x0F] + HEX_CHARS[(h2 >>> 24) & 0x0F] +\n\t HEX_CHARS[(h3 >>> 4) & 0x0F] + HEX_CHARS[h3 & 0x0F] +\n\t HEX_CHARS[(h3 >>> 12) & 0x0F] + HEX_CHARS[(h3 >>> 8) & 0x0F] +\n\t HEX_CHARS[(h3 >>> 20) & 0x0F] + HEX_CHARS[(h3 >>> 16) & 0x0F] +\n\t HEX_CHARS[(h3 >>> 28) & 0x0F] + HEX_CHARS[(h3 >>> 24) & 0x0F];\n\t };\n\n\t /**\n\t * @method toString\n\t * @memberof Md5\n\t * @instance\n\t * @description Output hash as hex string\n\t * @returns {String} Hex string\n\t * @see {@link md5.hex}\n\t * @example\n\t * hash.toString();\n\t */\n\t Md5.prototype.toString = Md5.prototype.hex;\n\n\t /**\n\t * @method digest\n\t * @memberof Md5\n\t * @instance\n\t * @description Output hash as bytes array\n\t * @returns {Array} Bytes array\n\t * @see {@link md5.digest}\n\t * @example\n\t * hash.digest();\n\t */\n\t Md5.prototype.digest = function () {\n\t this.finalize();\n\n\t var h0 = this.h0, h1 = this.h1, h2 = this.h2, h3 = this.h3;\n\t return [\n\t h0 & 0xFF, (h0 >>> 8) & 0xFF, (h0 >>> 16) & 0xFF, (h0 >>> 24) & 0xFF,\n\t h1 & 0xFF, (h1 >>> 8) & 0xFF, (h1 >>> 16) & 0xFF, (h1 >>> 24) & 0xFF,\n\t h2 & 0xFF, (h2 >>> 8) & 0xFF, (h2 >>> 16) & 0xFF, (h2 >>> 24) & 0xFF,\n\t h3 & 0xFF, (h3 >>> 8) & 0xFF, (h3 >>> 16) & 0xFF, (h3 >>> 24) & 0xFF\n\t ];\n\t };\n\n\t /**\n\t * @method array\n\t * @memberof Md5\n\t * @instance\n\t * @description Output hash as bytes array\n\t * @returns {Array} Bytes array\n\t * @see {@link md5.array}\n\t * @example\n\t * hash.array();\n\t */\n\t Md5.prototype.array = Md5.prototype.digest;\n\n\t /**\n\t * @method arrayBuffer\n\t * @memberof Md5\n\t * @instance\n\t * @description Output hash as ArrayBuffer\n\t * @returns {ArrayBuffer} ArrayBuffer\n\t * @see {@link md5.arrayBuffer}\n\t * @example\n\t * hash.arrayBuffer();\n\t */\n\t Md5.prototype.arrayBuffer = function () {\n\t this.finalize();\n\n\t var buffer = new ArrayBuffer(16);\n\t var blocks = new Uint32Array(buffer);\n\t blocks[0] = this.h0;\n\t blocks[1] = this.h1;\n\t blocks[2] = this.h2;\n\t blocks[3] = this.h3;\n\t return buffer;\n\t };\n\n\t /**\n\t * @method buffer\n\t * @deprecated This maybe confuse with Buffer in node.js. Please use arrayBuffer instead.\n\t * @memberof Md5\n\t * @instance\n\t * @description Output hash as ArrayBuffer\n\t * @returns {ArrayBuffer} ArrayBuffer\n\t * @see {@link md5.buffer}\n\t * @example\n\t * hash.buffer();\n\t */\n\t /* istanbul ignore else */\n\t {\n\t Md5.prototype.buffer = Md5.prototype.arrayBuffer;\n\t }\n\n\t /**\n\t * @method base64\n\t * @memberof Md5\n\t * @instance\n\t * @description Output hash as base64 string\n\t * @returns {String} base64 string\n\t * @see {@link md5.base64}\n\t * @example\n\t * hash.base64();\n\t */\n\t /* istanbul ignore else */\n\t {\n\t Md5.prototype.base64 = function () {\n\t var v1, v2, v3, base64Str = '', bytes = this.array();\n\t for (var i = 0; i < 15;) {\n\t v1 = bytes[i++];\n\t v2 = bytes[i++];\n\t v3 = bytes[i++];\n\t base64Str += BASE64_ENCODE_CHAR[v1 >>> 2] +\n\t BASE64_ENCODE_CHAR[(v1 << 4 | v2 >>> 4) & 63] +\n\t BASE64_ENCODE_CHAR[(v2 << 2 | v3 >>> 6) & 63] +\n\t BASE64_ENCODE_CHAR[v3 & 63];\n\t }\n\t v1 = bytes[i];\n\t base64Str += BASE64_ENCODE_CHAR[v1 >>> 2] +\n\t BASE64_ENCODE_CHAR[(v1 << 4) & 63] +\n\t '==';\n\t return base64Str;\n\t };\n\t }\n\n\t /**\n\t * HmacMd5 class\n\t * @class HmacMd5\n\t * @extends Md5\n\t * @description This is internal class.\n\t * @see {@link md5.hmac.create}\n\t */\n\t function HmacMd5(key, sharedMemory) {\n\t var i, result = formatMessage(key);\n\t key = result[0];\n\t if (result[1]) {\n\t var bytes = [], length = key.length, index = 0, code, code2;\n\t for (i = 0; i < length; ++i) {\n\t code = key.charCodeAt(i);\n\t if (code < 0x80) {\n\t bytes[index++] = code;\n\t } else if (code < 0x800) {\n\t bytes[index++] = (0xc0 | (code >>> 6));\n\t bytes[index++] = (0x80 | (code & 0x3f));\n\t } else if (code < 0xd800 || code >= 0xe000) {\n\t bytes[index++] = (0xe0 | (code >>> 12));\n\t bytes[index++] = (0x80 | ((code >>> 6) & 0x3f));\n\t bytes[index++] = (0x80 | (code & 0x3f));\n\t } else if (code < 0xdc00 && (code2 = key.charCodeAt(i + 1)) >= 0xdc00 && code2 < 0xe000) {\n\t ++i;\n\t code = 0x10000 + (((code & 0x3ff) << 10) | (code2 & 0x3ff));\n\t bytes[index++] = (0xf0 | (code >>> 18));\n\t bytes[index++] = (0x80 | ((code >>> 12) & 0x3f));\n\t bytes[index++] = (0x80 | ((code >>> 6) & 0x3f));\n\t bytes[index++] = (0x80 | (code & 0x3f));\n\t } else {\n\t // unpaired surrogate: U+FFFD\n\t bytes[index++] = 0xef;\n\t bytes[index++] = 0xbf;\n\t bytes[index++] = 0xbd;\n\t }\n\t }\n\t key = bytes;\n\t }\n\n\t if (key.length > 64) {\n\t key = (new Md5(true)).update(key).array();\n\t }\n\n\t var oKeyPad = [], iKeyPad = [];\n\t for (i = 0; i < 64; ++i) {\n\t var b = key[i] || 0;\n\t oKeyPad[i] = 0x5c ^ b;\n\t iKeyPad[i] = 0x36 ^ b;\n\t }\n\n\t Md5.call(this, sharedMemory);\n\n\t this.update(iKeyPad);\n\t this.oKeyPad = oKeyPad;\n\t this.inner = true;\n\t this.sharedMemory = sharedMemory;\n\t }\n\t /* istanbul ignore else */\n\t {\n\t HmacMd5.prototype = new Md5();\n\n\t HmacMd5.prototype.finalize = function () {\n\t Md5.prototype.finalize.call(this);\n\t if (this.inner) {\n\t this.inner = false;\n\t var innerHash = this.array();\n\t Md5.call(this, this.sharedMemory);\n\t this.update(this.oKeyPad);\n\t this.update(innerHash);\n\t Md5.prototype.finalize.call(this);\n\t }\n\t };\n\t }\n\n\t var exports = createMethod();\n\t exports.md5 = exports;\n\t /* istanbul ignore else */\n\t {\n\t exports.md5.hmac = createHmacMethod();\n\t }\n\n\t if (COMMON_JS) {\n\t module.exports = exports;\n\t } else {\n\t /**\n\t * @method md5\b\n\t * @description Md5 hash function, export to global in browsers.\n\t * @param {String|Array|Uint8Array|ArrayBuffer} message message to hash\n\t * @returns {String} md5 hashes\n\t * @example\n\t * md5(''); // d41d8cd98f00b204e9800998ecf8427e\n\t * md5('The quick brown fox jumps over the lazy dog'); // 9e107d9d372bb6826bd81d3542a419d6\n\t * md5('The quick brown fox jumps over the lazy dog.'); // e4d909c290d0fb1ca068ffaddf22cbd0\n\t *\n\t * // It also supports UTF-8 encoding\n\t * md5('中文'); // a7bac2239fcdcb3a067903d8077c4a07\n\t *\n\t * // It also supports byte `Array`, `Uint8Array`, `ArrayBuffer`\n\t * md5([]); // d41d8cd98f00b204e9800998ecf8427e\n\t * md5(new Uint8Array([])); // d41d8cd98f00b204e9800998ecf8427e\n\t */\n\t root.md5 = exports;\n\t }\n\t})(); \n} (md5$1));\n\nvar md5Exports = md5$1.exports;\nvar md5 = /*@__PURE__*/getDefaultExportFromCjs(md5Exports);\n\nexport { md5 as default, md5 };\n","var IDX=256, HEX=[], BUFFER;\nwhile (IDX--) HEX[IDX] = (IDX + 256).toString(16).substring(1);\n\nexport function v4() {\n\tvar i=0, num, out='';\n\n\tif (!BUFFER || ((IDX + 16) > 256)) {\n\t\tBUFFER = Array(i=256);\n\t\twhile (i--) BUFFER[i] = 256 * Math.random() | 0;\n\t\ti = IDX = 0;\n\t}\n\n\tfor (; i < 16; i++) {\n\t\tnum = BUFFER[IDX + i];\n\t\tif (i==6) out += HEX[num & 15 | 64];\n\t\telse if (i==8) out += HEX[num & 63 | 128];\n\t\telse out += HEX[num];\n\n\t\tif (i & 1 && i > 1 && i < 11) out += '-';\n\t}\n\n\tIDX++;\n\treturn out;\n}\n","import { md5 } from 'js-md5'\nimport { v4 } from '@lukeed/uuid'\nimport type { PageContext, TraceCoreOptions } from './types'\n\nexport type { PageContext, TraceCoreOptions, TraceDomain, FlowIdInput, TraceIdInput } from './types'\nexport { CommonAdapter } from '../adapters/common'\nexport type { CommonAdapterOptions } from '../adapters/common'\n\n// 16 位 UUID 派生标识用于日志关联,不作为安全凭证。\nfunction generateTraceId(): string {\n return v4().replace(/-/g, '').slice(0, 16)\n}\n\ntype PageState = Omit<PageContext, 'spanId'> & { spanId: number }\n\nfunction snapshot(page: PageState): PageContext {\n return { ...page, spanId: `S${page.spanId}` }\n}\n\nexport class TraceCore {\n readonly appId: string | undefined\n // 状态属于当前 core 实例;不同应用或不同 SDK 实例互不串数据。\n private readonly pages: Map<string, PageState> = new Map()\n private readonly generateFlowId: (pageKey: string) => string\n private readonly generateTraceId: (pageKey: string, flowId: string) => string\n private resolvePageKey: (() => string) | undefined\n\n constructor(options: TraceCoreOptions = {}) {\n this.appId = options.appId\n this.generateFlowId = options.generateFlowId ?? (pageKey => md5(pageKey).slice(0, 8))\n this.generateTraceId = options.generateTraceId ?? generateTraceId\n }\n\n /** 由适配器提供页面解析能力,core 不依赖平台路由对象。 */\n setPageKeyResolver(resolve: () => string): void {\n this.resolvePageKey = resolve\n }\n\n getPageKey(): string {\n if (!this.resolvePageKey) {\n throw new Error('请先注册页面解析器')\n }\n return this.resolvePageKey()\n }\n\n /** 开启新业务,使用新的 traceId并重置请求序号 */\n startTrace(pageKey: string = this.getPageKey()): string {\n const page = this.getOrCreatePage(pageKey)\n const traceId = generateTraceId()\n page.previousTraceId = page.traceId\n page.traceId = traceId\n page.spanId = 0\n return traceId\n }\n\n ensurePage(pageKey: string): PageContext {\n return snapshot(this.getOrCreatePage(pageKey))\n }\n\n getContext(pageKey: string): PageContext | undefined {\n const page = this.pages.get(pageKey)\n return page ? snapshot(page) : undefined\n }\n\n setFlowId(pageKey: string, flowId: string): void {\n this.getOrCreatePage(pageKey).flowId = flowId\n }\n\n setTraceId(pageKey: string, traceId: string): void {\n const page = this.getOrCreatePage(pageKey)\n if (page.traceId !== traceId) {\n page.previousTraceId = page.traceId\n page.traceId = traceId\n }\n }\n\n nextRequestContext(pageKey: string): PageContext {\n const page = this.getOrCreatePage(pageKey)\n page.spanId += 1\n // 按发起顺序取号,并复制本次请求的 ID;后续 setter 不会改写在途请求。\n return snapshot(page)\n }\n\n removePage(pageKey: string): boolean {\n return this.pages.delete(pageKey)\n }\n\n clear(): void {\n this.pages.clear()\n }\n\n private getOrCreatePage(pageKey: string): PageState {\n const existing = this.pages.get(pageKey)\n if (existing) return existing\n const flowId = this.generateFlowId(pageKey)\n const traceId = this.generateTraceId(pageKey, flowId)\n // 两个 ID 都生成后才保存;新页面的请求序号从 0 开始。\n const page: PageState = { flowId, traceId, spanId: 0 }\n this.pages.set(pageKey, page)\n return page\n }\n}\n"],"ignoreList":[0,1],"mappings":";AAAA,SAAS,wBAAyB,GAAG;CACpC,OAAO,KAAK,EAAE,cAAc,OAAO,UAAU,eAAe,KAAK,GAAG,SAAS,IAAI,EAAE,aAAa;AACjG;AAEA,IAAI,QAAQ,EAAC,SAAS,CAAC,EAAC;;;;;;;;;;CAYvB,SAAU,QAAQ;CAClB,CAAC,WAAY;EAEX,IAAI,cAAc;EAClB,IAAI,iBAAiB;EACrB,IAAI,SAAS,OAAO,WAAW;EAC/B,IAAI,OAAO,SAAS,SAAS,CAAC;EAC9B,IAAI,KAAK,kBACP,SAAS;EAGX,IADiB,OAAO,sBAAsB,eAAe,OAAO,SAAS,eAAe,gBAA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
@@ -1,55 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const
|
|
3
|
-
|
|
4
|
-
let sequence = 0;
|
|
5
|
-
function generateId() {
|
|
6
|
-
return `${Date.now().toString(36)}-${(++sequence).toString(36)}-${Math.random().toString(36).slice(2)}`;
|
|
7
|
-
}
|
|
8
|
-
var TraceCore = class {
|
|
9
|
-
constructor(options = {}) {
|
|
10
|
-
var _options$generateFlow, _options$generateTrac;
|
|
11
|
-
this.pages = /* @__PURE__ */ new Map();
|
|
12
|
-
this.generateFlowId = (_options$generateFlow = options.generateFlowId) !== null && _options$generateFlow !== void 0 ? _options$generateFlow : generateId;
|
|
13
|
-
this.generateTraceId = (_options$generateTrac = options.generateTraceId) !== null && _options$generateTrac !== void 0 ? _options$generateTrac : ((_pageKey, flowId) => flowId);
|
|
14
|
-
}
|
|
15
|
-
ensurePage(pageKey) {
|
|
16
|
-
return { ...this.getOrCreatePage(pageKey) };
|
|
17
|
-
}
|
|
18
|
-
getContext(pageKey) {
|
|
19
|
-
const page = this.pages.get(pageKey);
|
|
20
|
-
return page ? { ...page } : void 0;
|
|
21
|
-
}
|
|
22
|
-
setFlowId(pageKey, flowId) {
|
|
23
|
-
this.getOrCreatePage(pageKey).flowId = flowId;
|
|
24
|
-
}
|
|
25
|
-
setTraceId(pageKey, traceId) {
|
|
26
|
-
this.getOrCreatePage(pageKey).traceId = traceId;
|
|
27
|
-
}
|
|
28
|
-
nextRequestContext(pageKey) {
|
|
29
|
-
const page = this.getOrCreatePage(pageKey);
|
|
30
|
-
page.spanId += 1;
|
|
31
|
-
return { ...page };
|
|
32
|
-
}
|
|
33
|
-
removePage(pageKey) {
|
|
34
|
-
return this.pages.delete(pageKey);
|
|
35
|
-
}
|
|
36
|
-
clear() {
|
|
37
|
-
this.pages.clear();
|
|
38
|
-
}
|
|
39
|
-
getOrCreatePage(pageKey) {
|
|
40
|
-
const existing = this.pages.get(pageKey);
|
|
41
|
-
if (existing) return existing;
|
|
42
|
-
const flowId = this.generateFlowId(pageKey);
|
|
43
|
-
const page = {
|
|
44
|
-
flowId,
|
|
45
|
-
traceId: this.generateTraceId(pageKey, flowId),
|
|
46
|
-
spanId: 0
|
|
47
|
-
};
|
|
48
|
-
this.pages.set(pageKey, page);
|
|
49
|
-
return page;
|
|
50
|
-
}
|
|
51
|
-
};
|
|
2
|
+
const require_core = require("./core-D3CEDvtx.cjs");
|
|
3
|
+
const require_common = require("./common-Ckqz7sCS.cjs");
|
|
52
4
|
exports.CommonAdapter = require_common.CommonAdapter;
|
|
53
|
-
exports.TraceCore = TraceCore;
|
|
54
|
-
|
|
55
|
-
//# sourceMappingURL=core.cjs.map
|
|
5
|
+
exports.TraceCore = require_core.TraceCore;
|
package/dist/core.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
export { CommonAdapter, type FlowIdInput, type PageContext, TraceCore, type TraceCoreOptions, type TraceDomain, type TraceIdInput };
|
|
1
|
+
import { a as PageContext, c as TraceIdInput, i as FlowIdInput, n as CommonAdapter, o as TraceCoreOptions, r as CommonAdapterOptions, s as TraceDomain, t as TraceCore } from "./index-BbSDp9gU.cjs";
|
|
2
|
+
export { CommonAdapter, type CommonAdapterOptions, type FlowIdInput, type PageContext, TraceCore, type TraceCoreOptions, type TraceDomain, type TraceIdInput };
|
package/dist/core.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
export { CommonAdapter, type FlowIdInput, type PageContext, TraceCore, type TraceCoreOptions, type TraceDomain, type TraceIdInput };
|
|
1
|
+
import { a as PageContext, c as TraceIdInput, i as FlowIdInput, n as CommonAdapter, o as TraceCoreOptions, r as CommonAdapterOptions, s as TraceDomain, t as TraceCore } from "./index-BbSDp9gU.mjs";
|
|
2
|
+
export { CommonAdapter, type CommonAdapterOptions, type FlowIdInput, type PageContext, TraceCore, type TraceCoreOptions, type TraceDomain, type TraceIdInput };
|
package/dist/core.mjs
CHANGED
|
@@ -1,53 +1,3 @@
|
|
|
1
|
-
import { t as
|
|
2
|
-
|
|
3
|
-
let sequence = 0;
|
|
4
|
-
function generateId() {
|
|
5
|
-
return `${Date.now().toString(36)}-${(++sequence).toString(36)}-${Math.random().toString(36).slice(2)}`;
|
|
6
|
-
}
|
|
7
|
-
var TraceCore = class {
|
|
8
|
-
constructor(options = {}) {
|
|
9
|
-
var _options$generateFlow, _options$generateTrac;
|
|
10
|
-
this.pages = /* @__PURE__ */ new Map();
|
|
11
|
-
this.generateFlowId = (_options$generateFlow = options.generateFlowId) !== null && _options$generateFlow !== void 0 ? _options$generateFlow : generateId;
|
|
12
|
-
this.generateTraceId = (_options$generateTrac = options.generateTraceId) !== null && _options$generateTrac !== void 0 ? _options$generateTrac : ((_pageKey, flowId) => flowId);
|
|
13
|
-
}
|
|
14
|
-
ensurePage(pageKey) {
|
|
15
|
-
return { ...this.getOrCreatePage(pageKey) };
|
|
16
|
-
}
|
|
17
|
-
getContext(pageKey) {
|
|
18
|
-
const page = this.pages.get(pageKey);
|
|
19
|
-
return page ? { ...page } : void 0;
|
|
20
|
-
}
|
|
21
|
-
setFlowId(pageKey, flowId) {
|
|
22
|
-
this.getOrCreatePage(pageKey).flowId = flowId;
|
|
23
|
-
}
|
|
24
|
-
setTraceId(pageKey, traceId) {
|
|
25
|
-
this.getOrCreatePage(pageKey).traceId = traceId;
|
|
26
|
-
}
|
|
27
|
-
nextRequestContext(pageKey) {
|
|
28
|
-
const page = this.getOrCreatePage(pageKey);
|
|
29
|
-
page.spanId += 1;
|
|
30
|
-
return { ...page };
|
|
31
|
-
}
|
|
32
|
-
removePage(pageKey) {
|
|
33
|
-
return this.pages.delete(pageKey);
|
|
34
|
-
}
|
|
35
|
-
clear() {
|
|
36
|
-
this.pages.clear();
|
|
37
|
-
}
|
|
38
|
-
getOrCreatePage(pageKey) {
|
|
39
|
-
const existing = this.pages.get(pageKey);
|
|
40
|
-
if (existing) return existing;
|
|
41
|
-
const flowId = this.generateFlowId(pageKey);
|
|
42
|
-
const page = {
|
|
43
|
-
flowId,
|
|
44
|
-
traceId: this.generateTraceId(pageKey, flowId),
|
|
45
|
-
spanId: 0
|
|
46
|
-
};
|
|
47
|
-
this.pages.set(pageKey, page);
|
|
48
|
-
return page;
|
|
49
|
-
}
|
|
50
|
-
};
|
|
1
|
+
import { t as TraceCore } from "./core-DQb65OGC.mjs";
|
|
2
|
+
import { t as CommonAdapter } from "./common-C-0q1dq5.mjs";
|
|
51
3
|
export { CommonAdapter, TraceCore };
|
|
52
|
-
|
|
53
|
-
//# sourceMappingURL=core.mjs.map
|
|
@@ -2,20 +2,28 @@
|
|
|
2
2
|
interface PageContext {
|
|
3
3
|
flowId: string;
|
|
4
4
|
traceId: string;
|
|
5
|
-
|
|
5
|
+
previousTraceId?: string;
|
|
6
|
+
spanId: string;
|
|
6
7
|
}
|
|
7
8
|
/** 完整 origin,例如 https://api.example.com;支持多个精确匹配项。 */
|
|
8
9
|
type TraceDomain = string | readonly string[];
|
|
9
10
|
interface TraceCoreOptions {
|
|
11
|
+
appId?: string | undefined;
|
|
10
12
|
generateFlowId?: (pageKey: string) => string;
|
|
11
13
|
generateTraceId?: (pageKey: string, flowId: string) => string;
|
|
12
14
|
}
|
|
13
15
|
interface FlowIdInput {
|
|
16
|
+
appId?: string | undefined;
|
|
14
17
|
pageKey: string;
|
|
15
18
|
}
|
|
16
19
|
interface TraceIdInput extends FlowIdInput {
|
|
17
20
|
flowId: string;
|
|
18
21
|
}
|
|
22
|
+
interface CommonAdapterOptions<TPage = unknown> {
|
|
23
|
+
domain?: TraceDomain;
|
|
24
|
+
headerName?: string;
|
|
25
|
+
pageKey?: (page: TPage) => string;
|
|
26
|
+
}
|
|
19
27
|
declare abstract class CommonAdapter {
|
|
20
28
|
protected readonly core: TraceCore;
|
|
21
29
|
private started;
|
|
@@ -26,10 +34,17 @@ declare abstract class CommonAdapter {
|
|
|
26
34
|
protected abstract interceptRequests(): void;
|
|
27
35
|
}
|
|
28
36
|
declare class TraceCore {
|
|
37
|
+
readonly appId: string | undefined;
|
|
29
38
|
private readonly pages;
|
|
30
39
|
private readonly generateFlowId;
|
|
31
40
|
private readonly generateTraceId;
|
|
41
|
+
private resolvePageKey;
|
|
32
42
|
constructor(options?: TraceCoreOptions);
|
|
43
|
+
/** 由适配器提供页面解析能力,core 不依赖平台路由对象。 */
|
|
44
|
+
setPageKeyResolver(resolve: () => string): void;
|
|
45
|
+
getPageKey(): string;
|
|
46
|
+
/** 开启新业务,使用新的 traceId并重置请求序号 */
|
|
47
|
+
startTrace(pageKey?: string): string;
|
|
33
48
|
ensurePage(pageKey: string): PageContext;
|
|
34
49
|
getContext(pageKey: string): PageContext | undefined;
|
|
35
50
|
setFlowId(pageKey: string, flowId: string): void;
|
|
@@ -39,4 +54,4 @@ declare class TraceCore {
|
|
|
39
54
|
clear(): void;
|
|
40
55
|
private getOrCreatePage;
|
|
41
56
|
}
|
|
42
|
-
export {
|
|
57
|
+
export { PageContext as a, TraceIdInput as c, FlowIdInput as i, CommonAdapter as n, TraceCoreOptions as o, CommonAdapterOptions as r, TraceDomain as s, TraceCore as t };
|
|
@@ -2,20 +2,28 @@
|
|
|
2
2
|
interface PageContext {
|
|
3
3
|
flowId: string;
|
|
4
4
|
traceId: string;
|
|
5
|
-
|
|
5
|
+
previousTraceId?: string;
|
|
6
|
+
spanId: string;
|
|
6
7
|
}
|
|
7
8
|
/** 完整 origin,例如 https://api.example.com;支持多个精确匹配项。 */
|
|
8
9
|
type TraceDomain = string | readonly string[];
|
|
9
10
|
interface TraceCoreOptions {
|
|
11
|
+
appId?: string | undefined;
|
|
10
12
|
generateFlowId?: (pageKey: string) => string;
|
|
11
13
|
generateTraceId?: (pageKey: string, flowId: string) => string;
|
|
12
14
|
}
|
|
13
15
|
interface FlowIdInput {
|
|
16
|
+
appId?: string | undefined;
|
|
14
17
|
pageKey: string;
|
|
15
18
|
}
|
|
16
19
|
interface TraceIdInput extends FlowIdInput {
|
|
17
20
|
flowId: string;
|
|
18
21
|
}
|
|
22
|
+
interface CommonAdapterOptions<TPage = unknown> {
|
|
23
|
+
domain?: TraceDomain;
|
|
24
|
+
headerName?: string;
|
|
25
|
+
pageKey?: (page: TPage) => string;
|
|
26
|
+
}
|
|
19
27
|
declare abstract class CommonAdapter {
|
|
20
28
|
protected readonly core: TraceCore;
|
|
21
29
|
private started;
|
|
@@ -26,10 +34,17 @@ declare abstract class CommonAdapter {
|
|
|
26
34
|
protected abstract interceptRequests(): void;
|
|
27
35
|
}
|
|
28
36
|
declare class TraceCore {
|
|
37
|
+
readonly appId: string | undefined;
|
|
29
38
|
private readonly pages;
|
|
30
39
|
private readonly generateFlowId;
|
|
31
40
|
private readonly generateTraceId;
|
|
41
|
+
private resolvePageKey;
|
|
32
42
|
constructor(options?: TraceCoreOptions);
|
|
43
|
+
/** 由适配器提供页面解析能力,core 不依赖平台路由对象。 */
|
|
44
|
+
setPageKeyResolver(resolve: () => string): void;
|
|
45
|
+
getPageKey(): string;
|
|
46
|
+
/** 开启新业务,使用新的 traceId并重置请求序号 */
|
|
47
|
+
startTrace(pageKey?: string): string;
|
|
33
48
|
ensurePage(pageKey: string): PageContext;
|
|
34
49
|
getContext(pageKey: string): PageContext | undefined;
|
|
35
50
|
setFlowId(pageKey: string, flowId: string): void;
|
|
@@ -39,4 +54,4 @@ declare class TraceCore {
|
|
|
39
54
|
clear(): void;
|
|
40
55
|
private getOrCreatePage;
|
|
41
56
|
}
|
|
42
|
-
export {
|
|
57
|
+
export { PageContext as a, TraceIdInput as c, FlowIdInput as i, CommonAdapter as n, TraceCoreOptions as o, CommonAdapterOptions as r, TraceDomain as s, TraceCore as t };
|
package/dist/index.cjs
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_core = require("./core.cjs");
|
|
3
|
-
const require_web = require("./web-
|
|
4
|
-
const require_common = require("./common-
|
|
2
|
+
const require_core = require("./core-D3CEDvtx.cjs");
|
|
3
|
+
const require_web = require("./web-PWAFlfHM.cjs");
|
|
4
|
+
const require_common = require("./common-Ckqz7sCS.cjs");
|
|
5
5
|
// src/createTrace.ts
|
|
6
6
|
function createTrace(options = {}) {
|
|
7
|
-
const { context, flowId, traceId, adapter } = options;
|
|
8
|
-
const coreOptions = {};
|
|
9
|
-
if (flowId) coreOptions.generateFlowId = (pageKey) => flowId(context, {
|
|
7
|
+
const { appId, context, flowId, traceId, adapter } = options;
|
|
8
|
+
const coreOptions = { appId };
|
|
9
|
+
if (flowId) coreOptions.generateFlowId = (pageKey) => flowId(context, {
|
|
10
|
+
pageKey,
|
|
11
|
+
appId
|
|
12
|
+
});
|
|
10
13
|
if (traceId) coreOptions.generateTraceId = (pageKey, id) => traceId(context, {
|
|
11
14
|
pageKey,
|
|
15
|
+
appId,
|
|
12
16
|
flowId: id
|
|
13
17
|
});
|
|
14
18
|
const core = new require_core.TraceCore(coreOptions);
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["TraceCore"],"sources":["../src/createTrace.ts"],"sourcesContent":["import { TraceCore } from './core'\nimport type { TraceCoreOptions } from './core/types'\nimport type { CreateTraceDefaultOptions, CreateTraceOptions } from './types'\n\nexport function createTrace(options?: CreateTraceDefaultOptions): TraceCore\nexport function createTrace<TContext
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["TraceCore"],"sources":["../src/createTrace.ts"],"sourcesContent":["import { TraceCore } from './core'\nimport type { TraceCoreOptions } from './core/types'\nimport type { CommonAdapterOptions } from './adapters/common'\nimport type { AdapterConstructor, CreateTraceDefaultOptions, CreateTraceOptions } from './types'\n\nexport function createTrace<TAdapter extends AdapterConstructor = AdapterConstructor<CommonAdapterOptions>>(options?: CreateTraceDefaultOptions<TAdapter>): TraceCore\nexport function createTrace<TContext, TAdapter extends AdapterConstructor = AdapterConstructor<CommonAdapterOptions>>(options: CreateTraceOptions<TContext, TAdapter>): TraceCore\nexport function createTrace<TContext>(options: CreateTraceOptions<TContext> | CreateTraceDefaultOptions = {}): TraceCore {\n // 上下文只交给用户自己的生成函数,core 不读取其中的平台或业务字段。\n // 保存原对象引用,允许调用方在后续新页面创建前更新其内容。\n const { appId, context, flowId, traceId, adapter } = options as CreateTraceOptions<TContext>\n const coreOptions: TraceCoreOptions = { appId }\n if (flowId) coreOptions.generateFlowId = pageKey => flowId(context, { pageKey, appId })\n if (traceId) coreOptions.generateTraceId = (pageKey, id) => traceId(context, { pageKey, appId, flowId: id })\n const core = new TraceCore(coreOptions)\n // 创建时选定适配器并启动,业务始终使用这一份 core。\n if (adapter) new adapter(core, options).start()\n return core\n}\n"],"mappings":";;;;;AAOA,SAAgB,YAAsB,UAAoE,CAAC,GAAc;CAGvH,MAAM,EAAE,OAAO,SAAS,QAAQ,SAAS,YAAY;CACrD,MAAM,cAAgC,EAAE,MAAM;CAC9C,IAAI,QAAQ,YAAY,kBAAiB,YAAW,OAAO,SAAS;EAAE;EAAS;CAAM,CAAC;CACtF,IAAI,SAAS,YAAY,mBAAmB,SAAS,OAAO,QAAQ,SAAS;EAAE;EAAS;EAAO,QAAQ;CAAG,CAAC;CAC3G,MAAM,OAAO,IAAIA,aAAAA,UAAU,WAAW;CAEtC,IAAI,SAAS,IAAI,QAAQ,MAAM,OAAO,CAAC,CAAC,MAAM;CAC9C,OAAO;AACT"}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
|
-
import { a as
|
|
1
|
+
import { a as PageContext, c as TraceIdInput, i as FlowIdInput, n as CommonAdapter, o as TraceCoreOptions, r as CommonAdapterOptions, s as TraceDomain, t as TraceCore } from "./index-BbSDp9gU.cjs";
|
|
2
2
|
import { WebAdapter, WebAdapterOptions } from "./web.cjs";
|
|
3
|
-
type AdapterConstructor = new (core: TraceCore, options?:
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
type AdapterConstructor<TOptions = never> = new (core: TraceCore, options?: TOptions) => CommonAdapter;
|
|
4
|
+
type AdapterOptions<TAdapter extends AdapterConstructor> = TAdapter extends AdapterConstructor<infer TOptions> ? TOptions : never;
|
|
5
|
+
interface TraceOptions<TContext, TAdapter extends AdapterConstructor> {
|
|
6
|
+
adapter?: TAdapter;
|
|
7
|
+
appId?: string;
|
|
6
8
|
context: TContext;
|
|
7
9
|
flowId?: (context: TContext, input: FlowIdInput) => string;
|
|
8
10
|
traceId?: (context: TContext, input: TraceIdInput) => string;
|
|
9
11
|
}
|
|
10
|
-
type
|
|
12
|
+
type CreateTraceOptions<TContext, TAdapter extends AdapterConstructor = AdapterConstructor<CommonAdapterOptions>> = TraceOptions<TContext, TAdapter> & AdapterOptions<TAdapter>;
|
|
13
|
+
type CreateTraceDefaultOptions<TAdapter extends AdapterConstructor = AdapterConstructor<CommonAdapterOptions>> = Omit<TraceOptions<undefined, TAdapter>, "context"> & AdapterOptions<TAdapter> & {
|
|
11
14
|
context?: undefined;
|
|
12
15
|
};
|
|
13
|
-
export declare function createTrace(options?: CreateTraceDefaultOptions): TraceCore;
|
|
14
|
-
export declare function createTrace<TContext
|
|
15
|
-
export { type AdapterConstructor, CommonAdapter, type CreateTraceDefaultOptions, type CreateTraceOptions, type FlowIdInput, type PageContext, TraceCore, type TraceCoreOptions, type TraceDomain, type TraceIdInput, type WebAdapterOptions, WebAdapter as web };
|
|
16
|
+
export declare function createTrace<TAdapter extends AdapterConstructor = AdapterConstructor<CommonAdapterOptions>>(options?: CreateTraceDefaultOptions<TAdapter>): TraceCore;
|
|
17
|
+
export declare function createTrace<TContext, TAdapter extends AdapterConstructor = AdapterConstructor<CommonAdapterOptions>>(options: CreateTraceOptions<TContext, TAdapter>): TraceCore;
|
|
18
|
+
export { type AdapterConstructor, CommonAdapter, type CommonAdapterOptions, type CreateTraceDefaultOptions, type CreateTraceOptions, type FlowIdInput, type PageContext, TraceCore, type TraceCoreOptions, type TraceDomain, type TraceIdInput, type WebAdapterOptions, WebAdapter as web };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
|
-
import { a as
|
|
1
|
+
import { a as PageContext, c as TraceIdInput, i as FlowIdInput, n as CommonAdapter, o as TraceCoreOptions, r as CommonAdapterOptions, s as TraceDomain, t as TraceCore } from "./index-BbSDp9gU.mjs";
|
|
2
2
|
import { WebAdapter, WebAdapterOptions } from "./web.mjs";
|
|
3
|
-
type AdapterConstructor = new (core: TraceCore, options?:
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
type AdapterConstructor<TOptions = never> = new (core: TraceCore, options?: TOptions) => CommonAdapter;
|
|
4
|
+
type AdapterOptions<TAdapter extends AdapterConstructor> = TAdapter extends AdapterConstructor<infer TOptions> ? TOptions : never;
|
|
5
|
+
interface TraceOptions<TContext, TAdapter extends AdapterConstructor> {
|
|
6
|
+
adapter?: TAdapter;
|
|
7
|
+
appId?: string;
|
|
6
8
|
context: TContext;
|
|
7
9
|
flowId?: (context: TContext, input: FlowIdInput) => string;
|
|
8
10
|
traceId?: (context: TContext, input: TraceIdInput) => string;
|
|
9
11
|
}
|
|
10
|
-
type
|
|
12
|
+
type CreateTraceOptions<TContext, TAdapter extends AdapterConstructor = AdapterConstructor<CommonAdapterOptions>> = TraceOptions<TContext, TAdapter> & AdapterOptions<TAdapter>;
|
|
13
|
+
type CreateTraceDefaultOptions<TAdapter extends AdapterConstructor = AdapterConstructor<CommonAdapterOptions>> = Omit<TraceOptions<undefined, TAdapter>, "context"> & AdapterOptions<TAdapter> & {
|
|
11
14
|
context?: undefined;
|
|
12
15
|
};
|
|
13
|
-
export declare function createTrace(options?: CreateTraceDefaultOptions): TraceCore;
|
|
14
|
-
export declare function createTrace<TContext
|
|
15
|
-
export { type AdapterConstructor, CommonAdapter, type CreateTraceDefaultOptions, type CreateTraceOptions, type FlowIdInput, type PageContext, TraceCore, type TraceCoreOptions, type TraceDomain, type TraceIdInput, type WebAdapterOptions, WebAdapter as web };
|
|
16
|
+
export declare function createTrace<TAdapter extends AdapterConstructor = AdapterConstructor<CommonAdapterOptions>>(options?: CreateTraceDefaultOptions<TAdapter>): TraceCore;
|
|
17
|
+
export declare function createTrace<TContext, TAdapter extends AdapterConstructor = AdapterConstructor<CommonAdapterOptions>>(options: CreateTraceOptions<TContext, TAdapter>): TraceCore;
|
|
18
|
+
export { type AdapterConstructor, CommonAdapter, type CommonAdapterOptions, type CreateTraceDefaultOptions, type CreateTraceOptions, type FlowIdInput, type PageContext, TraceCore, type TraceCoreOptions, type TraceDomain, type TraceIdInput, type WebAdapterOptions, WebAdapter as web };
|
package/dist/index.mjs
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
|
-
import { TraceCore } from "./core.mjs";
|
|
2
|
-
import { t as WebAdapter } from "./web-
|
|
3
|
-
import { t as CommonAdapter } from "./common-
|
|
1
|
+
import { t as TraceCore } from "./core-DQb65OGC.mjs";
|
|
2
|
+
import { t as WebAdapter } from "./web-2sJz3LXy.mjs";
|
|
3
|
+
import { t as CommonAdapter } from "./common-C-0q1dq5.mjs";
|
|
4
4
|
// src/createTrace.ts
|
|
5
5
|
function createTrace(options = {}) {
|
|
6
|
-
const { context, flowId, traceId, adapter } = options;
|
|
7
|
-
const coreOptions = {};
|
|
8
|
-
if (flowId) coreOptions.generateFlowId = (pageKey) => flowId(context, {
|
|
6
|
+
const { appId, context, flowId, traceId, adapter } = options;
|
|
7
|
+
const coreOptions = { appId };
|
|
8
|
+
if (flowId) coreOptions.generateFlowId = (pageKey) => flowId(context, {
|
|
9
|
+
pageKey,
|
|
10
|
+
appId
|
|
11
|
+
});
|
|
9
12
|
if (traceId) coreOptions.generateTraceId = (pageKey, id) => traceId(context, {
|
|
10
13
|
pageKey,
|
|
14
|
+
appId,
|
|
11
15
|
flowId: id
|
|
12
16
|
});
|
|
13
17
|
const core = new TraceCore(coreOptions);
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../src/createTrace.ts"],"sourcesContent":["import { TraceCore } from './core'\nimport type { TraceCoreOptions } from './core/types'\nimport type { CreateTraceDefaultOptions, CreateTraceOptions } from './types'\n\nexport function createTrace(options?: CreateTraceDefaultOptions): TraceCore\nexport function createTrace<TContext
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/createTrace.ts"],"sourcesContent":["import { TraceCore } from './core'\nimport type { TraceCoreOptions } from './core/types'\nimport type { CommonAdapterOptions } from './adapters/common'\nimport type { AdapterConstructor, CreateTraceDefaultOptions, CreateTraceOptions } from './types'\n\nexport function createTrace<TAdapter extends AdapterConstructor = AdapterConstructor<CommonAdapterOptions>>(options?: CreateTraceDefaultOptions<TAdapter>): TraceCore\nexport function createTrace<TContext, TAdapter extends AdapterConstructor = AdapterConstructor<CommonAdapterOptions>>(options: CreateTraceOptions<TContext, TAdapter>): TraceCore\nexport function createTrace<TContext>(options: CreateTraceOptions<TContext> | CreateTraceDefaultOptions = {}): TraceCore {\n // 上下文只交给用户自己的生成函数,core 不读取其中的平台或业务字段。\n // 保存原对象引用,允许调用方在后续新页面创建前更新其内容。\n const { appId, context, flowId, traceId, adapter } = options as CreateTraceOptions<TContext>\n const coreOptions: TraceCoreOptions = { appId }\n if (flowId) coreOptions.generateFlowId = pageKey => flowId(context, { pageKey, appId })\n if (traceId) coreOptions.generateTraceId = (pageKey, id) => traceId(context, { pageKey, appId, flowId: id })\n const core = new TraceCore(coreOptions)\n // 创建时选定适配器并启动,业务始终使用这一份 core。\n if (adapter) new adapter(core, options).start()\n return core\n}\n"],"mappings":";;;;AAOA,SAAgB,YAAsB,UAAoE,CAAC,GAAc;CAGvH,MAAM,EAAE,OAAO,SAAS,QAAQ,SAAS,YAAY;CACrD,MAAM,cAAgC,EAAE,MAAM;CAC9C,IAAI,QAAQ,YAAY,kBAAiB,YAAW,OAAO,SAAS;EAAE;EAAS;CAAM,CAAC;CACtF,IAAI,SAAS,YAAY,mBAAmB,SAAS,OAAO,QAAQ,SAAS;EAAE;EAAS;EAAO,QAAQ;CAAG,CAAC;CAC3G,MAAM,OAAO,IAAI,UAAU,WAAW;CAEtC,IAAI,SAAS,IAAI,QAAQ,MAAM,OAAO,CAAC,CAAC,MAAM;CAC9C,OAAO;AACT"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as CommonAdapter } from "./common-
|
|
1
|
+
import { t as CommonAdapter } from "./common-C-0q1dq5.mjs";
|
|
2
2
|
// src/adapters/web/pageKey.ts
|
|
3
3
|
/** Web 页面标识默认取 pathname,hash 路由或业务 Tab 可自行映射。 */
|
|
4
4
|
function getPageKey(target, resolve) {
|
|
@@ -18,19 +18,33 @@ function watchPageChange(target, onChange) {
|
|
|
18
18
|
}
|
|
19
19
|
// src/adapters/web/request.ts
|
|
20
20
|
/** 只做域名判断和写入追踪头;页面 ID 与序号由 core 提供。 */
|
|
21
|
-
function interceptRequests(target, domain = target.location.origin, getContext) {
|
|
21
|
+
function interceptRequests(target, domain = target.location.origin, getContext, headerName = "x-trace") {
|
|
22
|
+
const getHeaderValue = () => {
|
|
23
|
+
const { traceId, previousTraceId, flowId, spanId } = getContext();
|
|
24
|
+
return [
|
|
25
|
+
flowId,
|
|
26
|
+
previousTraceId !== null && previousTraceId !== void 0 ? previousTraceId : "",
|
|
27
|
+
traceId,
|
|
28
|
+
spanId
|
|
29
|
+
].join(".");
|
|
30
|
+
};
|
|
22
31
|
const origins = new Set(typeof domain === "string" ? [domain] : domain);
|
|
23
32
|
const isSameDomain = (url) => origins.has(new target.URL(url, target.document.baseURI).origin);
|
|
24
33
|
const originalFetch = target.fetch;
|
|
25
34
|
target.fetch = function(input, init) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
35
|
+
var _init$mode;
|
|
36
|
+
const request = input instanceof target.Request ? input : void 0;
|
|
37
|
+
const url = request ? request.url : String(input);
|
|
38
|
+
if (isSameDomain(url) && ((_init$mode = init === null || init === void 0 ? void 0 : init.mode) !== null && _init$mode !== void 0 ? _init$mode : request === null || request === void 0 ? void 0 : request.mode) !== "no-cors") {
|
|
39
|
+
var _init$headers;
|
|
40
|
+
const headers = new target.Headers((_init$headers = init === null || init === void 0 ? void 0 : init.headers) !== null && _init$headers !== void 0 ? _init$headers : request === null || request === void 0 ? void 0 : request.headers);
|
|
41
|
+
headers.set(headerName, getHeaderValue());
|
|
42
|
+
return originalFetch.call(target, input, Object.create(init !== null && init !== void 0 ? init : null, { headers: {
|
|
43
|
+
value: headers,
|
|
44
|
+
enumerable: true
|
|
45
|
+
} }));
|
|
32
46
|
}
|
|
33
|
-
return originalFetch.call(target,
|
|
47
|
+
return originalFetch.call(target, input, init);
|
|
34
48
|
};
|
|
35
49
|
const prototype = target.XMLHttpRequest.prototype;
|
|
36
50
|
const originalOpen = prototype.open;
|
|
@@ -44,12 +58,7 @@ function interceptRequests(target, domain = target.location.origin, getContext)
|
|
|
44
58
|
const url = requests.get(this);
|
|
45
59
|
if (url !== void 0 && this.readyState === 1) {
|
|
46
60
|
requests.delete(this);
|
|
47
|
-
if (isSameDomain(url))
|
|
48
|
-
const { flowId, traceId, spanId } = getContext();
|
|
49
|
-
this.setRequestHeader("X-Flow-Id", flowId);
|
|
50
|
-
this.setRequestHeader("X-Trace-Id", traceId);
|
|
51
|
-
this.setRequestHeader("X-Span-Id", String(spanId));
|
|
52
|
-
}
|
|
61
|
+
if (isSameDomain(url)) this.setRequestHeader(headerName, getHeaderValue());
|
|
53
62
|
}
|
|
54
63
|
originalSend.call(this, body);
|
|
55
64
|
};
|
|
@@ -68,7 +77,7 @@ var WebAdapter = class extends CommonAdapter {
|
|
|
68
77
|
watchPageChange(this.getWindow(), onChange);
|
|
69
78
|
}
|
|
70
79
|
interceptRequests() {
|
|
71
|
-
interceptRequests(this.getWindow(), this.options.domain, () => this.core.nextRequestContext(this.getPageKey()));
|
|
80
|
+
interceptRequests(this.getWindow(), this.options.domain, () => this.core.nextRequestContext(this.getPageKey()), this.options.headerName);
|
|
72
81
|
}
|
|
73
82
|
getWindow() {
|
|
74
83
|
var _this$options$window;
|
|
@@ -77,4 +86,4 @@ var WebAdapter = class extends CommonAdapter {
|
|
|
77
86
|
};
|
|
78
87
|
export { WebAdapter as t };
|
|
79
88
|
|
|
80
|
-
//# sourceMappingURL=web-
|
|
89
|
+
//# sourceMappingURL=web-2sJz3LXy.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web-2sJz3LXy.mjs","names":[],"sources":["../src/adapters/web/pageKey.ts","../src/adapters/web/request.ts","../src/adapters/web/index.ts"],"sourcesContent":["/** Web 页面标识默认取 pathname,hash 路由或业务 Tab 可自行映射。 */\nexport function getPageKey(target: Window, resolve?: (location: Location) => string): string {\n return resolve ? resolve(target.location) : target.location.pathname\n}\n\n/** 把浏览器路由变化转换成统一的页面变更通知。 */\nexport function watchPageChange(target: Window, onChange: () => void): void {\n for (const name of ['pushState', 'replaceState'] as const) {\n const original = target.history[name]\n target.history[name] = function (this: History, ...args): void {\n original.apply(this, args)\n onChange()\n }\n }\n target.addEventListener('popstate', onChange)\n target.addEventListener('hashchange', onChange)\n}\n","import type { PageContext, TraceDomain } from '../../core/types'\nimport type { CommonAdapterOptions } from '../common'\nimport type { WebWindow } from './index'\n\n/** 只做域名判断和写入追踪头;页面 ID 与序号由 core 提供。 */\nexport function interceptRequests(\n target: WebWindow,\n domain: TraceDomain = target.location.origin,\n getContext: () => PageContext,\n headerName: CommonAdapterOptions['headerName'] = 'x-trace',\n): void {\n const getHeaderValue = () => {\n const { traceId, previousTraceId, flowId, spanId } = getContext()\n // 固定四段,上一轮为空时仍保留第二段空位。\n return [flowId, previousTraceId ?? '', traceId, spanId].join('.')\n }\n const domains = typeof domain === 'string' ? [domain] : domain\n const origins = new Set(domains)\n // 按协议、域名和端口精确比较,外站请求直接交给原方法。\n const isSameDomain = (url: string) => origins.has(new target.URL(url, target.document.baseURI).origin)\n\n const originalFetch = target.fetch\n target.fetch = function (input, init) {\n const request = input instanceof target.Request ? input : undefined\n const url = request ? request.url : String(input)\n if (isSameDomain(url) && (init?.mode ?? request?.mode) !== 'no-cors') {\n const headers = new target.Headers(init?.headers ?? request?.headers)\n headers.set(headerName, getHeaderValue())\n // 保留 input 形式,兼容只接受 URL 字符串的其他 fetch 包装器。\n return originalFetch.call(target, input, Object.create(init ?? null, { headers: { value: headers, enumerable: true } }))\n }\n return originalFetch.call(target, input, init)\n }\n\n const prototype = target.XMLHttpRequest.prototype\n const originalOpen = prototype.open\n const originalSend = prototype.send\n const requests = new WeakMap<XMLHttpRequest, string>()\n\n prototype.open = function (this: XMLHttpRequest, ...args: [string, string | URL, boolean?, (string | null)?, (string | null)?]): void {\n // open 会触发 OPENED 事件,先记录地址以支持事件回调里立即 send。\n requests.set(this, String(args[1]))\n Reflect.apply(originalOpen, this, args)\n }\n prototype.send = function (this: XMLHttpRequest, body): void {\n const url = requests.get(this)\n if (url !== undefined && this.readyState === 1) {\n // 本次地址只使用一次,重复 send 不再取号;下一次 open 会重新记录。\n requests.delete(this)\n if (isSameDomain(url)) {\n this.setRequestHeader(headerName, getHeaderValue())\n }\n }\n // 原 send 只调用一次,网络错误按浏览器原行为返回。\n originalSend.call(this, body)\n }\n}\n","import type { TraceCore } from '../../core'\nimport { CommonAdapter } from '../common'\nimport type { CommonAdapterOptions } from '../common'\nimport { getPageKey, watchPageChange } from './pageKey'\nimport { interceptRequests } from './request'\n\nexport type WebWindow = Window & typeof globalThis\n\nexport interface WebAdapterOptions extends CommonAdapterOptions<Location> {\n window?: WebWindow\n}\n\n/** Web 只负责把页面标识、路由变化和请求入口接到 core。 */\nexport class WebAdapter extends CommonAdapter {\n constructor(core: TraceCore, private readonly options: WebAdapterOptions = {}) {\n super(core)\n }\n\n protected getPageKey(): string {\n return getPageKey(this.getWindow(), this.options.pageKey)\n }\n\n protected watchPageChange(onChange: () => void): void {\n watchPageChange(this.getWindow(), onChange)\n }\n\n protected interceptRequests(): void {\n // 发送时读取当前页面,fetch 和 XHR 共用该页的请求序号。\n interceptRequests(this.getWindow(), this.options.domain, () => this.core.nextRequestContext(this.getPageKey()), this.options.headerName)\n }\n\n private getWindow(): WebWindow {\n return this.options.window ?? window\n }\n}\n"],"mappings":";;;AACA,SAAgB,WAAW,QAAgB,SAAkD;CAC3F,OAAO,UAAU,QAAQ,OAAO,QAAQ,IAAI,OAAO,SAAS;AAC9D;;AAGA,SAAgB,gBAAgB,QAAgB,UAA4B;CAC1E,KAAK,MAAM,QAAQ,CAAC,aAAa,cAAc,GAAY;EACzD,MAAM,WAAW,OAAO,QAAQ;EAChC,OAAO,QAAQ,QAAQ,SAAyB,GAAG,MAAY;GAC7D,SAAS,MAAM,MAAM,IAAI;GACzB,SAAS;EACX;CACF;CACA,OAAO,iBAAiB,YAAY,QAAQ;CAC5C,OAAO,iBAAiB,cAAc,QAAQ;AAChD;;;ACXA,SAAgB,kBACd,QACA,SAAsB,OAAO,SAAS,QACtC,YACA,aAAiD,WAC3C;CACN,MAAM,uBAAuB;EAC3B,MAAM,EAAE,SAAS,iBAAiB,QAAQ,WAAW,WAAW;EAEhE,OAAO;GAAC;GAAQ,oBAAA,QAAA,oBAAA,KAAA,IAAA,kBAAmB;GAAI;GAAS;EAAM,CAAC,CAAC,KAAK,GAAG;CAClE;CAEA,MAAM,UAAU,IAAI,IADJ,OAAO,WAAW,WAAW,CAAC,MAAM,IAAI,MACzB;CAE/B,MAAM,gBAAgB,QAAgB,QAAQ,IAAI,IAAI,OAAO,IAAI,KAAK,OAAO,SAAS,OAAO,CAAC,CAAC,MAAM;CAErG,MAAM,gBAAgB,OAAO;CAC7B,OAAO,QAAQ,SAAU,OAAO,MAAM;;EACpC,MAAM,UAAU,iBAAiB,OAAO,UAAU,QAAQ,KAAA;EAC1D,MAAM,MAAM,UAAU,QAAQ,MAAM,OAAO,KAAK;EAChD,IAAI,aAAa,GAAG,OAAA,aAAA,SAAA,QAAA,SAAA,KAAA,IAA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