@spatialwalk/avatarkit-rtc 1.0.0-beta.1
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 +417 -0
- package/dist/assets/animation-worker-CUXZycUw.js.map +1 -0
- package/dist/core/AnimationHandler.d.ts +17 -0
- package/dist/core/AnimationHandler.d.ts.map +1 -0
- package/dist/core/AvatarPlayer.d.ts +119 -0
- package/dist/core/AvatarPlayer.d.ts.map +1 -0
- package/dist/core/RTCProvider.d.ts +84 -0
- package/dist/core/RTCProvider.d.ts.map +1 -0
- package/dist/core/index.d.ts +7 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/types.d.ts +7 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -0
- package/dist/index10.js +67 -0
- package/dist/index10.js.map +1 -0
- package/dist/index11.js +390 -0
- package/dist/index11.js.map +1 -0
- package/dist/index12.js +108 -0
- package/dist/index12.js.map +1 -0
- package/dist/index13.js +18 -0
- package/dist/index13.js.map +1 -0
- package/dist/index14.js +48 -0
- package/dist/index14.js.map +1 -0
- package/dist/index15.js +29 -0
- package/dist/index15.js.map +1 -0
- package/dist/index16.js +144 -0
- package/dist/index16.js.map +1 -0
- package/dist/index17.js +106 -0
- package/dist/index17.js.map +1 -0
- package/dist/index18.js +28 -0
- package/dist/index18.js.map +1 -0
- package/dist/index2.js +220 -0
- package/dist/index2.js.map +1 -0
- package/dist/index3.js +586 -0
- package/dist/index3.js.map +1 -0
- package/dist/index4.js +410 -0
- package/dist/index4.js.map +1 -0
- package/dist/index5.js +20 -0
- package/dist/index5.js.map +1 -0
- package/dist/index6.js +282 -0
- package/dist/index6.js.map +1 -0
- package/dist/index7.js +53 -0
- package/dist/index7.js.map +1 -0
- package/dist/index8.js +189 -0
- package/dist/index8.js.map +1 -0
- package/dist/index9.js +178 -0
- package/dist/index9.js.map +1 -0
- package/dist/proto/animation.d.ts +12 -0
- package/dist/proto/animation.d.ts.map +1 -0
- package/dist/providers/agora/AgoraProvider.d.ts +71 -0
- package/dist/providers/agora/AgoraProvider.d.ts.map +1 -0
- package/dist/providers/agora/SEIExtractor.d.ts +29 -0
- package/dist/providers/agora/SEIExtractor.d.ts.map +1 -0
- package/dist/providers/agora/index.d.ts +11 -0
- package/dist/providers/agora/index.d.ts.map +1 -0
- package/dist/providers/agora/types.d.ts +14 -0
- package/dist/providers/agora/types.d.ts.map +1 -0
- package/dist/providers/base/BaseProvider.d.ts +11 -0
- package/dist/providers/base/BaseProvider.d.ts.map +1 -0
- package/dist/providers/index.d.ts +10 -0
- package/dist/providers/index.d.ts.map +1 -0
- package/dist/providers/livekit/LiveKitProvider.d.ts +64 -0
- package/dist/providers/livekit/LiveKitProvider.d.ts.map +1 -0
- package/dist/providers/livekit/VP8Extractor.d.ts +10 -0
- package/dist/providers/livekit/VP8Extractor.d.ts.map +1 -0
- package/dist/providers/livekit/animation-transform.d.ts +11 -0
- package/dist/providers/livekit/animation-transform.d.ts.map +1 -0
- package/dist/providers/livekit/animation-worker.d.ts +14 -0
- package/dist/providers/livekit/animation-worker.d.ts.map +1 -0
- package/dist/providers/livekit/index.d.ts +11 -0
- package/dist/providers/livekit/index.d.ts.map +1 -0
- package/dist/providers/livekit/types.d.ts +11 -0
- package/dist/providers/livekit/types.d.ts.map +1 -0
- package/dist/providers/livekit/utils.d.ts +11 -0
- package/dist/providers/livekit/utils.d.ts.map +1 -0
- package/dist/types/index.d.ts +77 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/utils/index.d.ts +7 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/logger.d.ts +13 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/package.json +61 -0
package/dist/index12.js
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
+
import { createAnimationReceiverTransform } from "./index14.js";
|
|
5
|
+
import { logger } from "./index7.js";
|
|
6
|
+
import WorkerWrapper from "./index15.js";
|
|
7
|
+
const DEFAULT_TRANSITION_START_FRAMES = 8;
|
|
8
|
+
const DEFAULT_TRANSITION_END_FRAMES = 12;
|
|
9
|
+
class VP8Extractor {
|
|
10
|
+
constructor() {
|
|
11
|
+
/** @internal */
|
|
12
|
+
__publicField(this, "callbacks", null);
|
|
13
|
+
/** @internal */
|
|
14
|
+
__publicField(this, "receiver", null);
|
|
15
|
+
/** @internal */
|
|
16
|
+
__publicField(this, "transform", null);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Initialize the extractor with a receiver and callbacks.
|
|
20
|
+
* @param receiver - RTCRtpReceiver to extract data from
|
|
21
|
+
* @param callbacks - Callbacks to receive extracted data
|
|
22
|
+
* @internal
|
|
23
|
+
*/
|
|
24
|
+
async initialize(receiver, callbacks) {
|
|
25
|
+
if (this.receiver || this.transform) {
|
|
26
|
+
throw new Error("VP8Extractor already initialized");
|
|
27
|
+
}
|
|
28
|
+
this.receiver = receiver;
|
|
29
|
+
this.callbacks = callbacks;
|
|
30
|
+
if (receiver.transform) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const worker = new WorkerWrapper();
|
|
34
|
+
const onEvent = (evt) => {
|
|
35
|
+
this.handleTransformEvent(evt);
|
|
36
|
+
};
|
|
37
|
+
this.transform = createAnimationReceiverTransform(worker, onEvent);
|
|
38
|
+
receiver.transform = this.transform;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Handle events from the animation transform.
|
|
42
|
+
* @internal
|
|
43
|
+
*/
|
|
44
|
+
handleTransformEvent(evt) {
|
|
45
|
+
if (!this.callbacks) return;
|
|
46
|
+
if (evt.type === "metadata") {
|
|
47
|
+
this.callbacks.onStreamStats({
|
|
48
|
+
framesPerSec: evt.framesPerSec,
|
|
49
|
+
totalFrames: evt.totalFrames ?? 0,
|
|
50
|
+
framesSent: evt.framesSent ?? 0,
|
|
51
|
+
framesLost: evt.framesLost ?? 0,
|
|
52
|
+
framesRecovered: evt.framesRecovered ?? 0,
|
|
53
|
+
framesDropped: evt.framesDropped ?? 0,
|
|
54
|
+
framesOutOfOrder: evt.framesOutOfOrder ?? 0,
|
|
55
|
+
framesDuplicate: evt.framesDuplicate ?? 0,
|
|
56
|
+
lastRenderedSeq: evt.lastRenderedSeq ?? -1
|
|
57
|
+
});
|
|
58
|
+
} else if (evt.type === "transition") {
|
|
59
|
+
this.callbacks.onTransition(evt.protobufData, DEFAULT_TRANSITION_START_FRAMES);
|
|
60
|
+
} else if (evt.type === "transitionEnd") {
|
|
61
|
+
this.callbacks.onTransitionEnd(evt.protobufData, DEFAULT_TRANSITION_END_FRAMES);
|
|
62
|
+
} else if (evt.type === "animation") {
|
|
63
|
+
if (!evt.isIdle) {
|
|
64
|
+
this.callbacks.onAnimationData(evt.protobufData, {
|
|
65
|
+
frameSeq: evt.frameSeq,
|
|
66
|
+
isStart: evt.isStart,
|
|
67
|
+
isEnd: evt.isEnd,
|
|
68
|
+
isIdle: evt.isIdle,
|
|
69
|
+
isRecovered: evt.isRecovered
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
} else if (evt.type === "idleStart") {
|
|
73
|
+
this.callbacks.onIdleStart();
|
|
74
|
+
} else if (evt.type === "error") {
|
|
75
|
+
logger.error("VP8Extractor", "Error:", evt.error);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Check if this extractor is connected to the given receiver.
|
|
80
|
+
* @param receiver - RTCRtpReceiver to check
|
|
81
|
+
* @returns true if connected to this receiver
|
|
82
|
+
* @internal
|
|
83
|
+
*/
|
|
84
|
+
isConnectedTo(receiver) {
|
|
85
|
+
return this.receiver === receiver;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Get the receiver this extractor is connected to.
|
|
89
|
+
* @returns The connected RTCRtpReceiver or null
|
|
90
|
+
* @internal
|
|
91
|
+
*/
|
|
92
|
+
getReceiver() {
|
|
93
|
+
return this.receiver;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Dispose the extractor and release resources.
|
|
97
|
+
* @internal
|
|
98
|
+
*/
|
|
99
|
+
dispose() {
|
|
100
|
+
this.receiver = null;
|
|
101
|
+
this.transform = null;
|
|
102
|
+
this.callbacks = null;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
export {
|
|
106
|
+
VP8Extractor
|
|
107
|
+
};
|
|
108
|
+
//# sourceMappingURL=index12.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index12.js","sources":["../src/providers/livekit/VP8Extractor.ts"],"sourcesContent":["/**\n * VP8 Data Extractor for LiveKit.\n *\n * Extracts animation data from VP8 video tracks using RTCRtpScriptTransform.\n *\n * @internal\n * @packageDocumentation\n */\n\nimport type { AnimationTrackCallbacks } from '../../core/types';\nimport type { AnimationTransformEvent } from './types';\nimport { createAnimationReceiverTransform } from './animation-transform';\nimport { logger } from '../../utils';\n\n// Import worker with inline - this bundles the worker code as a blob URL\nimport AnimationWorker from './animation-worker.ts?worker&inline';\n\n// Default transition frame counts (used when protocol doesn't specify)\nconst DEFAULT_TRANSITION_START_FRAMES = 8;\nconst DEFAULT_TRANSITION_END_FRAMES = 12;\n\n/**\n * VP8Extractor - Extracts animation data from VP8 video tracks.\n *\n * Uses RTCRtpScriptTransform and a Web Worker to parse VP8 frames\n * and extract embedded animation data.\n *\n * @internal\n */\nexport class VP8Extractor {\n /** @internal */\n private callbacks: AnimationTrackCallbacks | null = null;\n /** @internal */\n private receiver: RTCRtpReceiver | null = null;\n /** @internal */\n private transform: RTCRtpScriptTransform | null = null;\n\n /**\n * Initialize the extractor with a receiver and callbacks.\n * @param receiver - RTCRtpReceiver to extract data from\n * @param callbacks - Callbacks to receive extracted data\n * @internal\n */\n async initialize(\n receiver: RTCRtpReceiver,\n callbacks: AnimationTrackCallbacks\n ): Promise<void> {\n if (this.receiver || this.transform) {\n throw new Error('VP8Extractor already initialized');\n }\n\n this.receiver = receiver;\n this.callbacks = callbacks;\n\n // Check if transform is already set\n if (receiver.transform) {\n return;\n }\n\n // Create worker and transform\n const worker = new AnimationWorker();\n const onEvent = (evt: AnimationTransformEvent) => {\n this.handleTransformEvent(evt);\n };\n\n this.transform = createAnimationReceiverTransform(worker, onEvent);\n receiver.transform = this.transform;\n }\n\n /**\n * Handle events from the animation transform.\n * @internal\n */\n private handleTransformEvent(evt: AnimationTransformEvent): void {\n if (!this.callbacks) return;\n\n if (evt.type === 'metadata') {\n this.callbacks.onStreamStats({\n framesPerSec: evt.framesPerSec,\n totalFrames: evt.totalFrames ?? 0,\n framesSent: evt.framesSent ?? 0,\n framesLost: evt.framesLost ?? 0,\n framesRecovered: evt.framesRecovered ?? 0,\n framesDropped: evt.framesDropped ?? 0,\n framesOutOfOrder: evt.framesOutOfOrder ?? 0,\n framesDuplicate: evt.framesDuplicate ?? 0,\n lastRenderedSeq: evt.lastRenderedSeq ?? -1,\n });\n } else if (evt.type === 'transition') {\n this.callbacks.onTransition(evt.protobufData, DEFAULT_TRANSITION_START_FRAMES);\n } else if (evt.type === 'transitionEnd') {\n this.callbacks.onTransitionEnd(evt.protobufData, DEFAULT_TRANSITION_END_FRAMES);\n } else if (evt.type === 'animation') {\n if (!evt.isIdle) {\n this.callbacks.onAnimationData(evt.protobufData, {\n frameSeq: evt.frameSeq,\n isStart: evt.isStart,\n isEnd: evt.isEnd,\n isIdle: evt.isIdle,\n isRecovered: evt.isRecovered,\n });\n }\n } else if (evt.type === 'idleStart') {\n this.callbacks.onIdleStart();\n } else if (evt.type === 'error') {\n logger.error('VP8Extractor', 'Error:', evt.error);\n }\n }\n\n /**\n * Check if this extractor is connected to the given receiver.\n * @param receiver - RTCRtpReceiver to check\n * @returns true if connected to this receiver\n * @internal\n */\n isConnectedTo(receiver: RTCRtpReceiver): boolean {\n return this.receiver === receiver;\n }\n\n /**\n * Get the receiver this extractor is connected to.\n * @returns The connected RTCRtpReceiver or null\n * @internal\n */\n getReceiver(): RTCRtpReceiver | null {\n return this.receiver;\n }\n\n /**\n * Dispose the extractor and release resources.\n * @internal\n */\n dispose(): void {\n this.receiver = null;\n this.transform = null;\n this.callbacks = null;\n }\n}\n"],"names":["AnimationWorker"],"mappings":";;;;;;AAkBA,MAAM,kCAAkC;AACxC,MAAM,gCAAgC;AAU/B,MAAM,aAAa;AAAA,EAAnB;AAEG;AAAA,qCAA4C;AAE5C;AAAA,oCAAkC;AAElC;AAAA,qCAA0C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQlD,MAAM,WACJ,UACA,WACe;AACf,QAAI,KAAK,YAAY,KAAK,WAAW;AACnC,YAAM,IAAI,MAAM,kCAAkC;AAAA,IACpD;AAEA,SAAK,WAAW;AAChB,SAAK,YAAY;AAGjB,QAAI,SAAS,WAAW;AACtB;AAAA,IACF;AAGA,UAAM,SAAS,IAAIA,cAAA;AACnB,UAAM,UAAU,CAAC,QAAiC;AAChD,WAAK,qBAAqB,GAAG;AAAA,IAC/B;AAEA,SAAK,YAAY,iCAAiC,QAAQ,OAAO;AACjE,aAAS,YAAY,KAAK;AAAA,EAC5B;AAAA;AAAA;AAAA;AAAA;AAAA,EAMQ,qBAAqB,KAAoC;AAC/D,QAAI,CAAC,KAAK,UAAW;AAErB,QAAI,IAAI,SAAS,YAAY;AAC3B,WAAK,UAAU,cAAc;AAAA,QAC3B,cAAc,IAAI;AAAA,QAClB,aAAa,IAAI,eAAe;AAAA,QAChC,YAAY,IAAI,cAAc;AAAA,QAC9B,YAAY,IAAI,cAAc;AAAA,QAC9B,iBAAiB,IAAI,mBAAmB;AAAA,QACxC,eAAe,IAAI,iBAAiB;AAAA,QACpC,kBAAkB,IAAI,oBAAoB;AAAA,QAC1C,iBAAiB,IAAI,mBAAmB;AAAA,QACxC,iBAAiB,IAAI,mBAAmB;AAAA,MAAA,CACzC;AAAA,IACH,WAAW,IAAI,SAAS,cAAc;AACpC,WAAK,UAAU,aAAa,IAAI,cAAc,+BAA+B;AAAA,IAC/E,WAAW,IAAI,SAAS,iBAAiB;AACvC,WAAK,UAAU,gBAAgB,IAAI,cAAc,6BAA6B;AAAA,IAChF,WAAW,IAAI,SAAS,aAAa;AACnC,UAAI,CAAC,IAAI,QAAQ;AACf,aAAK,UAAU,gBAAgB,IAAI,cAAc;AAAA,UAC/C,UAAU,IAAI;AAAA,UACd,SAAS,IAAI;AAAA,UACb,OAAO,IAAI;AAAA,UACX,QAAQ,IAAI;AAAA,UACZ,aAAa,IAAI;AAAA,QAAA,CAClB;AAAA,MACH;AAAA,IACF,WAAW,IAAI,SAAS,aAAa;AACnC,WAAK,UAAU,YAAA;AAAA,IACjB,WAAW,IAAI,SAAS,SAAS;AAC/B,aAAO,MAAM,gBAAgB,UAAU,IAAI,KAAK;AAAA,IAClD;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,cAAc,UAAmC;AAC/C,WAAO,KAAK,aAAa;AAAA,EAC3B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,cAAqC;AACnC,WAAO,KAAK;AAAA,EACd;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,UAAgB;AACd,SAAK,WAAW;AAChB,SAAK,YAAY;AACjB,SAAK,YAAY;AAAA,EACnB;AACF;"}
|
package/dist/index13.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
function supportsScriptTransform() {
|
|
2
|
+
return typeof RTCRtpScriptTransform !== "undefined";
|
|
3
|
+
}
|
|
4
|
+
function supportsEncodedStreams() {
|
|
5
|
+
var _a;
|
|
6
|
+
return typeof ((_a = RTCRtpSender == null ? void 0 : RTCRtpSender.prototype) == null ? void 0 : _a.createEncodedStreams) === "function";
|
|
7
|
+
}
|
|
8
|
+
function getInsertableStreamsMethod() {
|
|
9
|
+
if (supportsScriptTransform()) return "scriptTransform";
|
|
10
|
+
if (supportsEncodedStreams()) return "encodedStreams";
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
export {
|
|
14
|
+
getInsertableStreamsMethod,
|
|
15
|
+
supportsEncodedStreams,
|
|
16
|
+
supportsScriptTransform
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=index13.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index13.js","sources":["../src/providers/livekit/utils.ts"],"sourcesContent":["/**\n * Insertable Streams utilities.\n *\n * Note: Audio tracks no longer embed metadata - animation data is now sent via a separate video track.\n * These utilities are kept for potential future use and backwards compatibility.\n *\n * @internal\n * @packageDocumentation\n */\n\n/**\n * Check if browser supports RTCRtpScriptTransform (the modern Insertable Streams API).\n * @returns true if RTCRtpScriptTransform is available\n * @internal\n */\nexport function supportsScriptTransform(): boolean {\n return typeof RTCRtpScriptTransform !== 'undefined';\n}\n\n/**\n * Check if browser supports createEncodedStreams (older Insertable Streams API).\n * @returns true if createEncodedStreams is available\n * @internal\n */\nexport function supportsEncodedStreams(): boolean {\n // This is deprecated but still works in some browsers\n // @ts-expect-error - experimental API\n return typeof RTCRtpSender?.prototype?.createEncodedStreams === 'function';\n}\n\n/**\n * Insertable Streams method type.\n * @internal\n */\nexport type InsertableStreamsMethod = 'scriptTransform' | 'encodedStreams' | null;\n\n/**\n * Get supported Insertable Streams method.\n * @returns The supported method or null if none available\n * @internal\n */\nexport function getInsertableStreamsMethod(): InsertableStreamsMethod {\n if (supportsScriptTransform()) return 'scriptTransform';\n if (supportsEncodedStreams()) return 'encodedStreams';\n return null;\n}\n"],"names":[],"mappings":"AAeO,SAAS,0BAAmC;AACjD,SAAO,OAAO,0BAA0B;AAC1C;AAOO,SAAS,yBAAkC;AAT3C;AAYL,SAAO,SAAO,kDAAc,cAAd,mBAAyB,0BAAyB;AAClE;AAaO,SAAS,6BAAsD;AACpE,MAAI,wBAAA,EAA2B,QAAO;AACtC,MAAI,uBAAA,EAA0B,QAAO;AACrC,SAAO;AACT;"}
|
package/dist/index14.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { logger } from "./index7.js";
|
|
2
|
+
function createAnimationReceiverTransform(workerOrUrl, onEvent) {
|
|
3
|
+
const worker = workerOrUrl instanceof Worker ? workerOrUrl : new Worker(workerOrUrl, { type: "module", name: "animation-receiver" });
|
|
4
|
+
worker.onmessage = (event) => {
|
|
5
|
+
const { type } = event.data;
|
|
6
|
+
if (type === "ready") {
|
|
7
|
+
onEvent == null ? void 0 : onEvent({ type: "ready", operation: "receiver" });
|
|
8
|
+
} else if (type === "metadata") {
|
|
9
|
+
onEvent == null ? void 0 : onEvent(event.data);
|
|
10
|
+
} else if (type === "animation") {
|
|
11
|
+
onEvent == null ? void 0 : onEvent({
|
|
12
|
+
type: "animation",
|
|
13
|
+
protobufData: event.data.protobufData,
|
|
14
|
+
flags: event.data.flags,
|
|
15
|
+
isIdle: event.data.isIdle,
|
|
16
|
+
isStart: event.data.isStart,
|
|
17
|
+
isEnd: event.data.isEnd,
|
|
18
|
+
frameSeq: event.data.frameSeq,
|
|
19
|
+
isRecovered: event.data.isRecovered
|
|
20
|
+
});
|
|
21
|
+
} else if (type === "transition") {
|
|
22
|
+
onEvent == null ? void 0 : onEvent({
|
|
23
|
+
type: "transition",
|
|
24
|
+
protobufData: event.data.protobufData,
|
|
25
|
+
flags: event.data.flags
|
|
26
|
+
});
|
|
27
|
+
} else if (type === "transitionEnd") {
|
|
28
|
+
onEvent == null ? void 0 : onEvent({
|
|
29
|
+
type: "transitionEnd",
|
|
30
|
+
protobufData: event.data.protobufData,
|
|
31
|
+
flags: event.data.flags
|
|
32
|
+
});
|
|
33
|
+
} else if (type === "idleStart") {
|
|
34
|
+
onEvent == null ? void 0 : onEvent({ type: "idleStart" });
|
|
35
|
+
} else if (type === "error") {
|
|
36
|
+
logger.error("AnimationTransform", "Error:", event.data.error);
|
|
37
|
+
onEvent == null ? void 0 : onEvent(event.data);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
worker.onerror = (event) => {
|
|
41
|
+
logger.error("AnimationTransform", "Worker error:", event.message);
|
|
42
|
+
};
|
|
43
|
+
return new RTCRtpScriptTransform(worker, { operation: "receiver" });
|
|
44
|
+
}
|
|
45
|
+
export {
|
|
46
|
+
createAnimationReceiverTransform
|
|
47
|
+
};
|
|
48
|
+
//# sourceMappingURL=index14.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index14.js","sources":["../src/providers/livekit/animation-transform.ts"],"sourcesContent":["/**\n * Animation Transform for Video Track.\n *\n * Uses RTCRtpScriptTransform to extract animation data from the video track.\n * The video track carries animation data in binary format (not actual video).\n *\n * @internal\n * @packageDocumentation\n */\n\nimport type { AnimationTransformEvent } from './types';\nimport { logger } from '../../utils';\n\nexport { METADATA_FIXED_HEADER_SIZE, PACKET_FLAGS } from './types';\n\n/**\n * Check if browser supports RTCRtpScriptTransform.\n * @returns true if RTCRtpScriptTransform is available\n * @internal\n */\nexport function supportsScriptTransform(): boolean {\n return typeof RTCRtpScriptTransform !== 'undefined';\n}\n\n/**\n * Create RTCRtpScriptTransform for animation receiver (video track).\n * @param workerOrUrl - Either a Worker instance or a URL string to the worker script\n * @param onEvent - Optional callback for transform events\n * @returns RTCRtpScriptTransform instance\n * @internal\n */\nexport function createAnimationReceiverTransform(\n workerOrUrl: Worker | string | URL,\n onEvent?: (evt: AnimationTransformEvent) => void\n): RTCRtpScriptTransform {\n // Create worker if URL is provided, otherwise use the provided Worker\n const worker =\n workerOrUrl instanceof Worker\n ? workerOrUrl\n : new Worker(workerOrUrl, { type: 'module', name: 'animation-receiver' });\n\n worker.onmessage = (event) => {\n const { type } = event.data;\n\n if (type === 'ready') {\n onEvent?.({ type: 'ready', operation: 'receiver' });\n } else if (type === 'metadata') {\n onEvent?.(event.data);\n } else if (type === 'animation') {\n onEvent?.({\n type: 'animation',\n protobufData: event.data.protobufData,\n flags: event.data.flags,\n isIdle: event.data.isIdle,\n isStart: event.data.isStart,\n isEnd: event.data.isEnd,\n frameSeq: event.data.frameSeq,\n isRecovered: event.data.isRecovered,\n });\n } else if (type === 'transition') {\n onEvent?.({\n type: 'transition',\n protobufData: event.data.protobufData,\n flags: event.data.flags,\n });\n } else if (type === 'transitionEnd') {\n onEvent?.({\n type: 'transitionEnd',\n protobufData: event.data.protobufData,\n flags: event.data.flags,\n });\n } else if (type === 'idleStart') {\n onEvent?.({ type: 'idleStart' });\n } else if (type === 'error') {\n logger.error('AnimationTransform', 'Error:', event.data.error);\n onEvent?.(event.data);\n }\n };\n\n worker.onerror = (event) => {\n logger.error('AnimationTransform', 'Worker error:', event.message);\n };\n\n return new RTCRtpScriptTransform(worker, { operation: 'receiver' });\n}\n"],"names":[],"mappings":";AA+BO,SAAS,iCACd,aACA,SACuB;AAEvB,QAAM,SACJ,uBAAuB,SACnB,cACA,IAAI,OAAO,aAAa,EAAE,MAAM,UAAU,MAAM,qBAAA,CAAsB;AAE5E,SAAO,YAAY,CAAC,UAAU;AAC5B,UAAM,EAAE,SAAS,MAAM;AAEvB,QAAI,SAAS,SAAS;AACpB,yCAAU,EAAE,MAAM,SAAS,WAAW;IACxC,WAAW,SAAS,YAAY;AAC9B,yCAAU,MAAM;AAAA,IAClB,WAAW,SAAS,aAAa;AAC/B,yCAAU;AAAA,QACR,MAAM;AAAA,QACN,cAAc,MAAM,KAAK;AAAA,QACzB,OAAO,MAAM,KAAK;AAAA,QAClB,QAAQ,MAAM,KAAK;AAAA,QACnB,SAAS,MAAM,KAAK;AAAA,QACpB,OAAO,MAAM,KAAK;AAAA,QAClB,UAAU,MAAM,KAAK;AAAA,QACrB,aAAa,MAAM,KAAK;AAAA,MAAA;AAAA,IAE5B,WAAW,SAAS,cAAc;AAChC,yCAAU;AAAA,QACR,MAAM;AAAA,QACN,cAAc,MAAM,KAAK;AAAA,QACzB,OAAO,MAAM,KAAK;AAAA,MAAA;AAAA,IAEtB,WAAW,SAAS,iBAAiB;AACnC,yCAAU;AAAA,QACR,MAAM;AAAA,QACN,cAAc,MAAM,KAAK;AAAA,QACzB,OAAO,MAAM,KAAK;AAAA,MAAA;AAAA,IAEtB,WAAW,SAAS,aAAa;AAC/B,yCAAU,EAAE,MAAM;IACpB,WAAW,SAAS,SAAS;AAC3B,aAAO,MAAM,sBAAsB,UAAU,MAAM,KAAK,KAAK;AAC7D,yCAAU,MAAM;AAAA,IAClB;AAAA,EACF;AAEA,SAAO,UAAU,CAAC,UAAU;AAC1B,WAAO,MAAM,sBAAsB,iBAAiB,MAAM,OAAO;AAAA,EACnE;AAEA,SAAO,IAAI,sBAAsB,QAAQ,EAAE,WAAW,YAAY;AACpE;"}
|
package/dist/index15.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
const jsContent = 'const VP8_FRAME_HEADER_SIZE = 10;\nconst METADATA_FIXED_HEADER_SIZE = 5;\nconst PACKET_FLAG_IDLE = 1;\nconst PACKET_FLAG_START = 2;\nconst PACKET_FLAG_END = 4;\nconst PACKET_FLAG_GZIPPED = 8;\nconst PACKET_FLAG_TRANSITION = 16;\nconst PACKET_FLAG_TRANSITION_END = 32;\nconst PACKET_FLAG_REDUNDANT = 64;\nlet receiverMetaCount = 0;\nlet lastLogTime = 0;\nlet totalFrames = 0;\nlet framesWithMeta = 0;\nlet wasIdle = false;\nlet lastReceivedTimestamp = null;\nlet framesRecovered = 0;\nlet framesLost = 0;\nconst EXPECTED_TIMESTAMP_INCREMENT = 3600;\nlet lastRenderedSeq = -1;\nlet framesOutOfOrder = 0;\nlet framesDuplicate = 0;\nlet framesDropped = 0;\nlet framesSent = 0;\nfunction parseMetadataHeader(data) {\n if (data.byteLength < METADATA_FIXED_HEADER_SIZE) return null;\n const view = new DataView(data.buffer, data.byteOffset, data.byteLength);\n const flags = data[0];\n const msgLen = view.getUint32(1, true);\n const headerSize = METADATA_FIXED_HEADER_SIZE + msgLen;\n if (data.byteLength < headerSize) return null;\n const compressedData = data.slice(METADATA_FIXED_HEADER_SIZE, METADATA_FIXED_HEADER_SIZE + msgLen);\n const hasRedundant = (flags & PACKET_FLAG_REDUNDANT) !== 0;\n return {\n meta: {\n flags,\n protobufLength: msgLen,\n protobufData: compressedData,\n // This is still compressed at this point\n hasRedundant,\n redundantLength: 0,\n // Will be determined after decompression\n redundantData: null\n // Will be extracted after decompression\n },\n headerSize\n };\n}\nfunction isIdlePacket(flags) {\n return (flags & PACKET_FLAG_IDLE) !== 0;\n}\nfunction isStartPacket(flags) {\n return (flags & PACKET_FLAG_START) !== 0;\n}\nfunction isEndPacket(flags) {\n return (flags & PACKET_FLAG_END) !== 0;\n}\nfunction isGzipped(flags) {\n return (flags & PACKET_FLAG_GZIPPED) !== 0;\n}\nfunction isTransitionPacket(flags) {\n return (flags & PACKET_FLAG_TRANSITION) !== 0;\n}\nfunction isTransitionEndPacket(flags) {\n return (flags & PACKET_FLAG_TRANSITION_END) !== 0;\n}\nasync function decompressGzip(data) {\n const ds = new DecompressionStream("gzip");\n const writer = ds.writable.getWriter();\n const copy = new Uint8Array(data);\n writer.write(copy);\n writer.close();\n const reader = ds.readable.getReader();\n const chunks = [];\n let totalLength = 0;\n while (true) {\n const { done, value } = await reader.read();\n if (done) break;\n chunks.push(value);\n totalLength += value.length;\n }\n const result = new Uint8Array(totalLength);\n let offset = 0;\n for (const chunk of chunks) {\n result.set(chunk, offset);\n offset += chunk.length;\n }\n return result;\n}\nlet totalCompressedBytes = 0;\nlet totalUncompressedBytes = 0;\nfunction parseALRPayload(decompressed, hasRedundant) {\n if (decompressed.byteLength < 4) return null;\n const view = new DataView(decompressed.buffer, decompressed.byteOffset, decompressed.byteLength);\n let offset = 0;\n const frameSeq = view.getUint32(offset, true);\n offset += 4;\n if (!hasRedundant) {\n const currentData2 = decompressed.slice(offset);\n return { frameSeq, currentData: currentData2, prev1Data: null, prev2Data: null };\n }\n if (decompressed.byteLength < offset + 4) return null;\n const currentLen = view.getUint32(offset, true);\n offset += 4;\n if (decompressed.byteLength < offset + currentLen) return null;\n const currentData = decompressed.slice(offset, offset + currentLen);\n offset += currentLen;\n let prev1Data = null;\n if (decompressed.byteLength >= offset + 4) {\n const prev1Len = view.getUint32(offset, true);\n offset += 4;\n if (prev1Len > 0 && decompressed.byteLength >= offset + prev1Len) {\n prev1Data = decompressed.slice(offset, offset + prev1Len);\n offset += prev1Len;\n }\n }\n let prev2Data = null;\n if (decompressed.byteLength >= offset + 4) {\n const prev2Len = view.getUint32(offset, true);\n offset += 4;\n if (prev2Len > 0 && decompressed.byteLength >= offset + prev2Len) {\n prev2Data = decompressed.slice(offset, offset + prev2Len);\n }\n }\n return { frameSeq, currentData, prev1Data, prev2Data };\n}\nfunction sendAnimationToMainThread(protobufData, flags, frameSeq, isRecovered = false) {\n const isIdle = isIdlePacket(flags);\n const isStart = isStartPacket(flags);\n const isEnd = isEndPacket(flags);\n if (frameSeq <= lastRenderedSeq && lastRenderedSeq !== -1 && !isStart) {\n if (frameSeq === lastRenderedSeq) {\n framesDuplicate++;\n } else {\n framesOutOfOrder++;\n }\n return false;\n }\n if (lastRenderedSeq !== -1 && frameSeq > lastRenderedSeq + 1 && !isStart) {\n const gap = frameSeq - lastRenderedSeq - 1;\n framesDropped += gap;\n }\n framesSent++;\n lastRenderedSeq = frameSeq;\n const protobufBuffer = new ArrayBuffer(protobufData.byteLength);\n new Uint8Array(protobufBuffer).set(protobufData);\n self.postMessage({\n type: "animation",\n flags,\n isIdle,\n isStart,\n isEnd,\n isRecovered,\n frameSeq,\n protobufData: protobufBuffer\n }, { transfer: [protobufBuffer] });\n return true;\n}\nfunction receiverTransform(frame, _controller) {\n totalFrames++;\n const data = new Uint8Array(frame.data);\n const currentTimestamp = frame.timestamp;\n if (data.length <= VP8_FRAME_HEADER_SIZE) {\n return;\n }\n const animData = data.subarray(VP8_FRAME_HEADER_SIZE);\n const parsed = parseMetadataHeader(animData);\n if (parsed) {\n const { meta } = parsed;\n framesWithMeta++;\n receiverMetaCount++;\n const isIdle = isIdlePacket(meta.flags);\n const isStart = isStartPacket(meta.flags);\n const isEnd = isEndPacket(meta.flags);\n if (lastReceivedTimestamp !== null && !isIdle && !isStart) {\n const timestampDelta = currentTimestamp - lastReceivedTimestamp;\n if (timestampDelta > EXPECTED_TIMESTAMP_INCREMENT * 1.5) {\n const missedFrames = Math.round(timestampDelta / EXPECTED_TIMESTAMP_INCREMENT) - 1;\n framesLost += missedFrames;\n if (meta.hasRedundant && isGzipped(meta.flags)) {\n totalCompressedBytes += meta.protobufData.byteLength;\n decompressGzip(meta.protobufData).then((decompressed) => {\n totalUncompressedBytes += decompressed.byteLength;\n const parsed2 = parseALRPayload(decompressed, true);\n if (parsed2) {\n const currentSeq = parsed2.frameSeq;\n const framesToRecover = [];\n if (missedFrames >= 2 && parsed2.prev2Data) {\n framesToRecover.push({ data: parsed2.prev2Data, seq: currentSeq - 2 });\n }\n if (missedFrames >= 1 && parsed2.prev1Data) {\n framesToRecover.push({ data: parsed2.prev1Data, seq: currentSeq - 1 });\n }\n const recovered = framesToRecover.length;\n if (recovered > 0) {\n framesRecovered += recovered;\n for (const frame2 of framesToRecover) {\n sendAnimationToMainThread(frame2.data, meta.flags & ~PACKET_FLAG_REDUNDANT, frame2.seq, true);\n }\n }\n sendAnimationToMainThread(parsed2.currentData, meta.flags & ~PACKET_FLAG_REDUNDANT, currentSeq, false);\n }\n }).catch((err) => {\n console.error(`[Animation Worker] ALR decompression error:`, err);\n });\n lastReceivedTimestamp = currentTimestamp;\n return;\n }\n }\n }\n if (!isIdle) {\n lastReceivedTimestamp = currentTimestamp;\n }\n if (isStart) {\n lastReceivedTimestamp = currentTimestamp;\n framesRecovered = 0;\n framesLost = 0;\n lastRenderedSeq = -1;\n framesOutOfOrder = 0;\n framesDuplicate = 0;\n framesDropped = 0;\n framesSent = 0;\n }\n const isTransition = isTransitionPacket(meta.flags);\n if (isIdle) {\n if (!wasIdle) {\n self.postMessage({ type: "idleStart" });\n wasIdle = true;\n }\n } else if (isTransition && meta.protobufLength > 0) {\n wasIdle = false;\n const gzipped = isGzipped(meta.flags);\n if (gzipped) {\n totalCompressedBytes += meta.protobufData.byteLength;\n decompressGzip(meta.protobufData).then((decompressed) => {\n totalUncompressedBytes += decompressed.byteLength;\n const protobufBuffer = new ArrayBuffer(decompressed.byteLength);\n new Uint8Array(protobufBuffer).set(decompressed);\n self.postMessage({\n type: "transition",\n flags: meta.flags,\n protobufData: protobufBuffer\n }, { transfer: [protobufBuffer] });\n }).catch((err) => {\n console.error(`[Animation Worker] Gzip decompress error (transition):`, err);\n });\n } else {\n const protobufBuffer = new ArrayBuffer(meta.protobufData.byteLength);\n new Uint8Array(protobufBuffer).set(meta.protobufData);\n self.postMessage({\n type: "transition",\n flags: meta.flags,\n protobufData: protobufBuffer\n }, { transfer: [protobufBuffer] });\n }\n } else if (isTransitionEndPacket(meta.flags) && meta.protobufLength > 0) {\n const gzipped = isGzipped(meta.flags);\n if (gzipped) {\n totalCompressedBytes += meta.protobufData.byteLength;\n decompressGzip(meta.protobufData).then((decompressed) => {\n totalUncompressedBytes += decompressed.byteLength;\n const protobufBuffer = new ArrayBuffer(decompressed.byteLength);\n new Uint8Array(protobufBuffer).set(decompressed);\n self.postMessage({\n type: "transitionEnd",\n flags: meta.flags,\n protobufData: protobufBuffer\n }, { transfer: [protobufBuffer] });\n }).catch((err) => {\n console.error(`[Animation Worker] Gzip decompress error (transitionEnd):`, err);\n });\n } else {\n const protobufBuffer = new ArrayBuffer(meta.protobufData.byteLength);\n new Uint8Array(protobufBuffer).set(meta.protobufData);\n self.postMessage({\n type: "transitionEnd",\n flags: meta.flags,\n protobufData: protobufBuffer\n }, { transfer: [protobufBuffer] });\n }\n } else if (meta.protobufLength > 0) {\n if (wasIdle) {\n wasIdle = false;\n }\n const gzipped = isGzipped(meta.flags);\n if (gzipped) {\n totalCompressedBytes += meta.protobufData.byteLength;\n decompressGzip(meta.protobufData).then((decompressed) => {\n totalUncompressedBytes += decompressed.byteLength;\n const parsed2 = parseALRPayload(decompressed, meta.hasRedundant);\n if (parsed2) {\n sendAnimationToMainThread(parsed2.currentData, meta.flags & ~PACKET_FLAG_REDUNDANT, parsed2.frameSeq, false);\n }\n }).catch(() => {\n });\n } else {\n const protobufBuffer = new ArrayBuffer(meta.protobufData.byteLength);\n new Uint8Array(protobufBuffer).set(meta.protobufData);\n self.postMessage({\n type: "animation",\n flags: meta.flags,\n isIdle: false,\n isStart,\n isEnd,\n frameSeq: -1,\n // Unknown sequence\n protobufData: protobufBuffer\n }, { transfer: [protobufBuffer] });\n }\n }\n const now = performance.now();\n if (now - lastLogTime > 1e3) {\n lastLogTime = now;\n self.postMessage({\n type: "metadata",\n protobufLength: meta.protobufLength,\n framesPerSec: receiverMetaCount,\n totalFrames,\n framesWithMeta,\n framesLost,\n framesRecovered,\n framesOutOfOrder,\n framesDuplicate,\n framesDropped,\n framesSent,\n lastRenderedSeq\n });\n receiverMetaCount = 0;\n }\n }\n}\nself.onrtctransform = (event) => {\n const transformer = event.transformer;\n const options = transformer.options;\n try {\n if (options.operation === "receiver") {\n receiverMetaCount = 0;\n lastLogTime = 0;\n totalFrames = 0;\n framesWithMeta = 0;\n wasIdle = false;\n lastReceivedTimestamp = null;\n framesRecovered = 0;\n framesLost = 0;\n lastRenderedSeq = -1;\n framesOutOfOrder = 0;\n framesDuplicate = 0;\n framesDropped = 0;\n framesSent = 0;\n transformer.readable.pipeThrough(new TransformStream({ transform: receiverTransform })).pipeTo(transformer.writable).catch((err) => {\n console.error("[Animation Worker] Pipeline error:", err);\n self.postMessage({ type: "error", error: `Animation receiver pipe error: ${err}` });\n });\n self.postMessage({ type: "ready", operation: "receiver" });\n }\n } catch (err) {\n console.error("[Animation Worker] Setup error:", err);\n self.postMessage({ type: "error", error: `Animation transform setup error: ${err}` });\n }\n};\nself.onmessage = (event) => {\n const { type } = event.data;\n if (type === "init") {\n self.postMessage({ type: "initialized" });\n }\n};\n//# sourceMappingURL=animation-worker-CUXZycUw.js.map\n';
|
|
2
|
+
const blob = typeof self !== "undefined" && self.Blob && new Blob(["URL.revokeObjectURL(import.meta.url);", jsContent], { type: "text/javascript;charset=utf-8" });
|
|
3
|
+
function WorkerWrapper(options) {
|
|
4
|
+
let objURL;
|
|
5
|
+
try {
|
|
6
|
+
objURL = blob && (self.URL || self.webkitURL).createObjectURL(blob);
|
|
7
|
+
if (!objURL) throw "";
|
|
8
|
+
const worker = new Worker(objURL, {
|
|
9
|
+
type: "module",
|
|
10
|
+
name: options == null ? void 0 : options.name
|
|
11
|
+
});
|
|
12
|
+
worker.addEventListener("error", () => {
|
|
13
|
+
(self.URL || self.webkitURL).revokeObjectURL(objURL);
|
|
14
|
+
});
|
|
15
|
+
return worker;
|
|
16
|
+
} catch (e) {
|
|
17
|
+
return new Worker(
|
|
18
|
+
"data:text/javascript;charset=utf-8," + encodeURIComponent(jsContent),
|
|
19
|
+
{
|
|
20
|
+
type: "module",
|
|
21
|
+
name: options == null ? void 0 : options.name
|
|
22
|
+
}
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
export {
|
|
27
|
+
WorkerWrapper as default
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=index15.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index15.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/index16.js
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
function varint64read() {
|
|
2
|
+
let lowBits = 0;
|
|
3
|
+
let highBits = 0;
|
|
4
|
+
for (let shift = 0; shift < 28; shift += 7) {
|
|
5
|
+
let b = this.buf[this.pos++];
|
|
6
|
+
lowBits |= (b & 127) << shift;
|
|
7
|
+
if ((b & 128) == 0) {
|
|
8
|
+
this.assertBounds();
|
|
9
|
+
return [lowBits, highBits];
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
let middleByte = this.buf[this.pos++];
|
|
13
|
+
lowBits |= (middleByte & 15) << 28;
|
|
14
|
+
highBits = (middleByte & 112) >> 4;
|
|
15
|
+
if ((middleByte & 128) == 0) {
|
|
16
|
+
this.assertBounds();
|
|
17
|
+
return [lowBits, highBits];
|
|
18
|
+
}
|
|
19
|
+
for (let shift = 3; shift <= 31; shift += 7) {
|
|
20
|
+
let b = this.buf[this.pos++];
|
|
21
|
+
highBits |= (b & 127) << shift;
|
|
22
|
+
if ((b & 128) == 0) {
|
|
23
|
+
this.assertBounds();
|
|
24
|
+
return [lowBits, highBits];
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
throw new Error("invalid varint");
|
|
28
|
+
}
|
|
29
|
+
const TWO_PWR_32_DBL = 4294967296;
|
|
30
|
+
function int64FromString(dec) {
|
|
31
|
+
const minus = dec[0] === "-";
|
|
32
|
+
if (minus) {
|
|
33
|
+
dec = dec.slice(1);
|
|
34
|
+
}
|
|
35
|
+
const base = 1e6;
|
|
36
|
+
let lowBits = 0;
|
|
37
|
+
let highBits = 0;
|
|
38
|
+
function add1e6digit(begin, end) {
|
|
39
|
+
const digit1e6 = Number(dec.slice(begin, end));
|
|
40
|
+
highBits *= base;
|
|
41
|
+
lowBits = lowBits * base + digit1e6;
|
|
42
|
+
if (lowBits >= TWO_PWR_32_DBL) {
|
|
43
|
+
highBits = highBits + (lowBits / TWO_PWR_32_DBL | 0);
|
|
44
|
+
lowBits = lowBits % TWO_PWR_32_DBL;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
add1e6digit(-24, -18);
|
|
48
|
+
add1e6digit(-18, -12);
|
|
49
|
+
add1e6digit(-12, -6);
|
|
50
|
+
add1e6digit(-6);
|
|
51
|
+
return minus ? negate(lowBits, highBits) : newBits(lowBits, highBits);
|
|
52
|
+
}
|
|
53
|
+
function int64ToString(lo, hi) {
|
|
54
|
+
let bits = newBits(lo, hi);
|
|
55
|
+
const negative = bits.hi & 2147483648;
|
|
56
|
+
if (negative) {
|
|
57
|
+
bits = negate(bits.lo, bits.hi);
|
|
58
|
+
}
|
|
59
|
+
const result = uInt64ToString(bits.lo, bits.hi);
|
|
60
|
+
return negative ? "-" + result : result;
|
|
61
|
+
}
|
|
62
|
+
function uInt64ToString(lo, hi) {
|
|
63
|
+
({ lo, hi } = toUnsigned(lo, hi));
|
|
64
|
+
if (hi <= 2097151) {
|
|
65
|
+
return String(TWO_PWR_32_DBL * hi + lo);
|
|
66
|
+
}
|
|
67
|
+
const low = lo & 16777215;
|
|
68
|
+
const mid = (lo >>> 24 | hi << 8) & 16777215;
|
|
69
|
+
const high = hi >> 16 & 65535;
|
|
70
|
+
let digitA = low + mid * 6777216 + high * 6710656;
|
|
71
|
+
let digitB = mid + high * 8147497;
|
|
72
|
+
let digitC = high * 2;
|
|
73
|
+
const base = 1e7;
|
|
74
|
+
if (digitA >= base) {
|
|
75
|
+
digitB += Math.floor(digitA / base);
|
|
76
|
+
digitA %= base;
|
|
77
|
+
}
|
|
78
|
+
if (digitB >= base) {
|
|
79
|
+
digitC += Math.floor(digitB / base);
|
|
80
|
+
digitB %= base;
|
|
81
|
+
}
|
|
82
|
+
return digitC.toString() + decimalFrom1e7WithLeadingZeros(digitB) + decimalFrom1e7WithLeadingZeros(digitA);
|
|
83
|
+
}
|
|
84
|
+
function toUnsigned(lo, hi) {
|
|
85
|
+
return { lo: lo >>> 0, hi: hi >>> 0 };
|
|
86
|
+
}
|
|
87
|
+
function newBits(lo, hi) {
|
|
88
|
+
return { lo: lo | 0, hi: hi | 0 };
|
|
89
|
+
}
|
|
90
|
+
function negate(lowBits, highBits) {
|
|
91
|
+
highBits = ~highBits;
|
|
92
|
+
if (lowBits) {
|
|
93
|
+
lowBits = ~lowBits + 1;
|
|
94
|
+
} else {
|
|
95
|
+
highBits += 1;
|
|
96
|
+
}
|
|
97
|
+
return newBits(lowBits, highBits);
|
|
98
|
+
}
|
|
99
|
+
const decimalFrom1e7WithLeadingZeros = (digit1e7) => {
|
|
100
|
+
const partial = String(digit1e7);
|
|
101
|
+
return "0000000".slice(partial.length) + partial;
|
|
102
|
+
};
|
|
103
|
+
function varint32read() {
|
|
104
|
+
let b = this.buf[this.pos++];
|
|
105
|
+
let result = b & 127;
|
|
106
|
+
if ((b & 128) == 0) {
|
|
107
|
+
this.assertBounds();
|
|
108
|
+
return result;
|
|
109
|
+
}
|
|
110
|
+
b = this.buf[this.pos++];
|
|
111
|
+
result |= (b & 127) << 7;
|
|
112
|
+
if ((b & 128) == 0) {
|
|
113
|
+
this.assertBounds();
|
|
114
|
+
return result;
|
|
115
|
+
}
|
|
116
|
+
b = this.buf[this.pos++];
|
|
117
|
+
result |= (b & 127) << 14;
|
|
118
|
+
if ((b & 128) == 0) {
|
|
119
|
+
this.assertBounds();
|
|
120
|
+
return result;
|
|
121
|
+
}
|
|
122
|
+
b = this.buf[this.pos++];
|
|
123
|
+
result |= (b & 127) << 21;
|
|
124
|
+
if ((b & 128) == 0) {
|
|
125
|
+
this.assertBounds();
|
|
126
|
+
return result;
|
|
127
|
+
}
|
|
128
|
+
b = this.buf[this.pos++];
|
|
129
|
+
result |= (b & 15) << 28;
|
|
130
|
+
for (let readBytes = 5; (b & 128) !== 0 && readBytes < 10; readBytes++)
|
|
131
|
+
b = this.buf[this.pos++];
|
|
132
|
+
if ((b & 128) != 0)
|
|
133
|
+
throw new Error("invalid varint");
|
|
134
|
+
this.assertBounds();
|
|
135
|
+
return result >>> 0;
|
|
136
|
+
}
|
|
137
|
+
export {
|
|
138
|
+
int64FromString,
|
|
139
|
+
int64ToString,
|
|
140
|
+
uInt64ToString,
|
|
141
|
+
varint32read,
|
|
142
|
+
varint64read
|
|
143
|
+
};
|
|
144
|
+
//# sourceMappingURL=index16.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index16.js","sources":["../node_modules/.pnpm/@bufbuild+protobuf@2.11.0/node_modules/@bufbuild/protobuf/dist/esm/wire/varint.js"],"sourcesContent":["// Copyright 2008 Google Inc. All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n// * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n// * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n// * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Code generated by the Protocol Buffer compiler is owned by the owner\n// of the input file used when generating it. This code is not\n// standalone and requires a support library to be linked with it. This\n// support library is itself covered by the above license.\n/**\n * Read a 64 bit varint as two JS numbers.\n *\n * Returns tuple:\n * [0]: low bits\n * [1]: high bits\n *\n * Copyright 2008 Google Inc. All rights reserved.\n *\n * See https://github.com/protocolbuffers/protobuf/blob/8a71927d74a4ce34efe2d8769fda198f52d20d12/js/experimental/runtime/kernel/buffer_decoder.js#L175\n */\nexport function varint64read() {\n let lowBits = 0;\n let highBits = 0;\n for (let shift = 0; shift < 28; shift += 7) {\n let b = this.buf[this.pos++];\n lowBits |= (b & 0x7f) << shift;\n if ((b & 0x80) == 0) {\n this.assertBounds();\n return [lowBits, highBits];\n }\n }\n let middleByte = this.buf[this.pos++];\n // last four bits of the first 32 bit number\n lowBits |= (middleByte & 0x0f) << 28;\n // 3 upper bits are part of the next 32 bit number\n highBits = (middleByte & 0x70) >> 4;\n if ((middleByte & 0x80) == 0) {\n this.assertBounds();\n return [lowBits, highBits];\n }\n for (let shift = 3; shift <= 31; shift += 7) {\n let b = this.buf[this.pos++];\n highBits |= (b & 0x7f) << shift;\n if ((b & 0x80) == 0) {\n this.assertBounds();\n return [lowBits, highBits];\n }\n }\n throw new Error(\"invalid varint\");\n}\n/**\n * Write a 64 bit varint, given as two JS numbers, to the given bytes array.\n *\n * Copyright 2008 Google Inc. All rights reserved.\n *\n * See https://github.com/protocolbuffers/protobuf/blob/8a71927d74a4ce34efe2d8769fda198f52d20d12/js/experimental/runtime/kernel/writer.js#L344\n */\nexport function varint64write(lo, hi, bytes) {\n for (let i = 0; i < 28; i = i + 7) {\n const shift = lo >>> i;\n const hasNext = !(shift >>> 7 == 0 && hi == 0);\n const byte = (hasNext ? shift | 0x80 : shift) & 0xff;\n bytes.push(byte);\n if (!hasNext) {\n return;\n }\n }\n const splitBits = ((lo >>> 28) & 0x0f) | ((hi & 0x07) << 4);\n const hasMoreBits = !(hi >> 3 == 0);\n bytes.push((hasMoreBits ? splitBits | 0x80 : splitBits) & 0xff);\n if (!hasMoreBits) {\n return;\n }\n for (let i = 3; i < 31; i = i + 7) {\n const shift = hi >>> i;\n const hasNext = !(shift >>> 7 == 0);\n const byte = (hasNext ? shift | 0x80 : shift) & 0xff;\n bytes.push(byte);\n if (!hasNext) {\n return;\n }\n }\n bytes.push((hi >>> 31) & 0x01);\n}\n// constants for binary math\nconst TWO_PWR_32_DBL = 0x100000000;\n/**\n * Parse decimal string of 64 bit integer value as two JS numbers.\n *\n * Copyright 2008 Google Inc. All rights reserved.\n *\n * See https://github.com/protocolbuffers/protobuf-javascript/blob/a428c58273abad07c66071d9753bc4d1289de426/experimental/runtime/int64.js#L10\n */\nexport function int64FromString(dec) {\n // Check for minus sign.\n const minus = dec[0] === \"-\";\n if (minus) {\n dec = dec.slice(1);\n }\n // Work 6 decimal digits at a time, acting like we're converting base 1e6\n // digits to binary. This is safe to do with floating point math because\n // Number.isSafeInteger(ALL_32_BITS * 1e6) == true.\n const base = 1e6;\n let lowBits = 0;\n let highBits = 0;\n function add1e6digit(begin, end) {\n // Note: Number('') is 0.\n const digit1e6 = Number(dec.slice(begin, end));\n highBits *= base;\n lowBits = lowBits * base + digit1e6;\n // Carry bits from lowBits to\n if (lowBits >= TWO_PWR_32_DBL) {\n highBits = highBits + ((lowBits / TWO_PWR_32_DBL) | 0);\n lowBits = lowBits % TWO_PWR_32_DBL;\n }\n }\n add1e6digit(-24, -18);\n add1e6digit(-18, -12);\n add1e6digit(-12, -6);\n add1e6digit(-6);\n return minus ? negate(lowBits, highBits) : newBits(lowBits, highBits);\n}\n/**\n * Losslessly converts a 64-bit signed integer in 32:32 split representation\n * into a decimal string.\n *\n * Copyright 2008 Google Inc. All rights reserved.\n *\n * See https://github.com/protocolbuffers/protobuf-javascript/blob/a428c58273abad07c66071d9753bc4d1289de426/experimental/runtime/int64.js#L10\n */\nexport function int64ToString(lo, hi) {\n let bits = newBits(lo, hi);\n // If we're treating the input as a signed value and the high bit is set, do\n // a manual two's complement conversion before the decimal conversion.\n const negative = bits.hi & 0x80000000;\n if (negative) {\n bits = negate(bits.lo, bits.hi);\n }\n const result = uInt64ToString(bits.lo, bits.hi);\n return negative ? \"-\" + result : result;\n}\n/**\n * Losslessly converts a 64-bit unsigned integer in 32:32 split representation\n * into a decimal string.\n *\n * Copyright 2008 Google Inc. All rights reserved.\n *\n * See https://github.com/protocolbuffers/protobuf-javascript/blob/a428c58273abad07c66071d9753bc4d1289de426/experimental/runtime/int64.js#L10\n */\nexport function uInt64ToString(lo, hi) {\n ({ lo, hi } = toUnsigned(lo, hi));\n // Skip the expensive conversion if the number is small enough to use the\n // built-in conversions.\n // Number.MAX_SAFE_INTEGER = 0x001FFFFF FFFFFFFF, thus any number with\n // highBits <= 0x1FFFFF can be safely expressed with a double and retain\n // integer precision.\n // Proven by: Number.isSafeInteger(0x1FFFFF * 2**32 + 0xFFFFFFFF) == true.\n if (hi <= 0x1fffff) {\n return String(TWO_PWR_32_DBL * hi + lo);\n }\n // What this code is doing is essentially converting the input number from\n // base-2 to base-1e7, which allows us to represent the 64-bit range with\n // only 3 (very large) digits. Those digits are then trivial to convert to\n // a base-10 string.\n // The magic numbers used here are -\n // 2^24 = 16777216 = (1,6777216) in base-1e7.\n // 2^48 = 281474976710656 = (2,8147497,6710656) in base-1e7.\n // Split 32:32 representation into 16:24:24 representation so our\n // intermediate digits don't overflow.\n const low = lo & 0xffffff;\n const mid = ((lo >>> 24) | (hi << 8)) & 0xffffff;\n const high = (hi >> 16) & 0xffff;\n // Assemble our three base-1e7 digits, ignoring carries. The maximum\n // value in a digit at this step is representable as a 48-bit integer, which\n // can be stored in a 64-bit floating point number.\n let digitA = low + mid * 6777216 + high * 6710656;\n let digitB = mid + high * 8147497;\n let digitC = high * 2;\n // Apply carries from A to B and from B to C.\n const base = 10000000;\n if (digitA >= base) {\n digitB += Math.floor(digitA / base);\n digitA %= base;\n }\n if (digitB >= base) {\n digitC += Math.floor(digitB / base);\n digitB %= base;\n }\n // If digitC is 0, then we should have returned in the trivial code path\n // at the top for non-safe integers. Given this, we can assume both digitB\n // and digitA need leading zeros.\n return (digitC.toString() +\n decimalFrom1e7WithLeadingZeros(digitB) +\n decimalFrom1e7WithLeadingZeros(digitA));\n}\nfunction toUnsigned(lo, hi) {\n return { lo: lo >>> 0, hi: hi >>> 0 };\n}\nfunction newBits(lo, hi) {\n return { lo: lo | 0, hi: hi | 0 };\n}\n/**\n * Returns two's compliment negation of input.\n * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators#Signed_32-bit_integers\n */\nfunction negate(lowBits, highBits) {\n highBits = ~highBits;\n if (lowBits) {\n lowBits = ~lowBits + 1;\n }\n else {\n // If lowBits is 0, then bitwise-not is 0xFFFFFFFF,\n // adding 1 to that, results in 0x100000000, which leaves\n // the low bits 0x0 and simply adds one to the high bits.\n highBits += 1;\n }\n return newBits(lowBits, highBits);\n}\n/**\n * Returns decimal representation of digit1e7 with leading zeros.\n */\nconst decimalFrom1e7WithLeadingZeros = (digit1e7) => {\n const partial = String(digit1e7);\n return \"0000000\".slice(partial.length) + partial;\n};\n/**\n * Write a 32 bit varint, signed or unsigned. Same as `varint64write(0, value, bytes)`\n *\n * Copyright 2008 Google Inc. All rights reserved.\n *\n * See https://github.com/protocolbuffers/protobuf/blob/1b18833f4f2a2f681f4e4a25cdf3b0a43115ec26/js/binary/encoder.js#L144\n */\nexport function varint32write(value, bytes) {\n if (value >= 0) {\n // write value as varint 32\n while (value > 0x7f) {\n bytes.push((value & 0x7f) | 0x80);\n value = value >>> 7;\n }\n bytes.push(value);\n }\n else {\n for (let i = 0; i < 9; i++) {\n bytes.push((value & 127) | 128);\n value = value >> 7;\n }\n bytes.push(1);\n }\n}\n/**\n * Read an unsigned 32 bit varint.\n *\n * See https://github.com/protocolbuffers/protobuf/blob/8a71927d74a4ce34efe2d8769fda198f52d20d12/js/experimental/runtime/kernel/buffer_decoder.js#L220\n */\nexport function varint32read() {\n let b = this.buf[this.pos++];\n let result = b & 0x7f;\n if ((b & 0x80) == 0) {\n this.assertBounds();\n return result;\n }\n b = this.buf[this.pos++];\n result |= (b & 0x7f) << 7;\n if ((b & 0x80) == 0) {\n this.assertBounds();\n return result;\n }\n b = this.buf[this.pos++];\n result |= (b & 0x7f) << 14;\n if ((b & 0x80) == 0) {\n this.assertBounds();\n return result;\n }\n b = this.buf[this.pos++];\n result |= (b & 0x7f) << 21;\n if ((b & 0x80) == 0) {\n this.assertBounds();\n return result;\n }\n // Extract only last 4 bits\n b = this.buf[this.pos++];\n result |= (b & 0x0f) << 28;\n for (let readBytes = 5; (b & 0x80) !== 0 && readBytes < 10; readBytes++)\n b = this.buf[this.pos++];\n if ((b & 0x80) != 0)\n throw new Error(\"invalid varint\");\n this.assertBounds();\n // Result can have 32 bits, convert it to unsigned\n return result >>> 0;\n}\n"],"names":[],"mappings":"AA2CO,SAAS,eAAe;AAC3B,MAAI,UAAU;AACd,MAAI,WAAW;AACf,WAAS,QAAQ,GAAG,QAAQ,IAAI,SAAS,GAAG;AACxC,QAAI,IAAI,KAAK,IAAI,KAAK,KAAK;AAC3B,gBAAY,IAAI,QAAS;AACzB,SAAK,IAAI,QAAS,GAAG;AACjB,WAAK,aAAY;AACjB,aAAO,CAAC,SAAS,QAAQ;AAAA,IAC7B;AAAA,EACJ;AACA,MAAI,aAAa,KAAK,IAAI,KAAK,KAAK;AAEpC,cAAY,aAAa,OAAS;AAElC,cAAY,aAAa,QAAS;AAClC,OAAK,aAAa,QAAS,GAAG;AAC1B,SAAK,aAAY;AACjB,WAAO,CAAC,SAAS,QAAQ;AAAA,EAC7B;AACA,WAAS,QAAQ,GAAG,SAAS,IAAI,SAAS,GAAG;AACzC,QAAI,IAAI,KAAK,IAAI,KAAK,KAAK;AAC3B,iBAAa,IAAI,QAAS;AAC1B,SAAK,IAAI,QAAS,GAAG;AACjB,WAAK,aAAY;AACjB,aAAO,CAAC,SAAS,QAAQ;AAAA,IAC7B;AAAA,EACJ;AACA,QAAM,IAAI,MAAM,gBAAgB;AACpC;AAoCA,MAAM,iBAAiB;AAQhB,SAAS,gBAAgB,KAAK;AAEjC,QAAM,QAAQ,IAAI,CAAC,MAAM;AACzB,MAAI,OAAO;AACP,UAAM,IAAI,MAAM,CAAC;AAAA,EACrB;AAIA,QAAM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3B,OAAK,IAAI,QAAS;AACd,UAAM,IAAI,MAAM,gBAAgB;AACpC,OAAK,aAAY;AAEjB,SAAO,WAAW;AACtB;","x_google_ignoreList":[0]}
|
package/dist/index17.js
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { uInt64ToString, int64ToString, int64FromString } from "./index16.js";
|
|
2
|
+
const protoInt64 = /* @__PURE__ */ makeInt64Support();
|
|
3
|
+
function makeInt64Support() {
|
|
4
|
+
const dv = new DataView(new ArrayBuffer(8));
|
|
5
|
+
const ok = typeof BigInt === "function" && typeof dv.getBigInt64 === "function" && typeof dv.getBigUint64 === "function" && typeof dv.setBigInt64 === "function" && typeof dv.setBigUint64 === "function" && (!!globalThis.Deno || typeof process != "object" || typeof process.env != "object" || process.env.BUF_BIGINT_DISABLE !== "1");
|
|
6
|
+
if (ok) {
|
|
7
|
+
const MIN = BigInt("-9223372036854775808");
|
|
8
|
+
const MAX = BigInt("9223372036854775807");
|
|
9
|
+
const UMIN = BigInt("0");
|
|
10
|
+
const UMAX = BigInt("18446744073709551615");
|
|
11
|
+
return {
|
|
12
|
+
zero: BigInt(0),
|
|
13
|
+
supported: true,
|
|
14
|
+
parse(value) {
|
|
15
|
+
const bi = typeof value == "bigint" ? value : BigInt(value);
|
|
16
|
+
if (bi > MAX || bi < MIN) {
|
|
17
|
+
throw new Error(`invalid int64: ${value}`);
|
|
18
|
+
}
|
|
19
|
+
return bi;
|
|
20
|
+
},
|
|
21
|
+
uParse(value) {
|
|
22
|
+
const bi = typeof value == "bigint" ? value : BigInt(value);
|
|
23
|
+
if (bi > UMAX || bi < UMIN) {
|
|
24
|
+
throw new Error(`invalid uint64: ${value}`);
|
|
25
|
+
}
|
|
26
|
+
return bi;
|
|
27
|
+
},
|
|
28
|
+
enc(value) {
|
|
29
|
+
dv.setBigInt64(0, this.parse(value), true);
|
|
30
|
+
return {
|
|
31
|
+
lo: dv.getInt32(0, true),
|
|
32
|
+
hi: dv.getInt32(4, true)
|
|
33
|
+
};
|
|
34
|
+
},
|
|
35
|
+
uEnc(value) {
|
|
36
|
+
dv.setBigInt64(0, this.uParse(value), true);
|
|
37
|
+
return {
|
|
38
|
+
lo: dv.getInt32(0, true),
|
|
39
|
+
hi: dv.getInt32(4, true)
|
|
40
|
+
};
|
|
41
|
+
},
|
|
42
|
+
dec(lo, hi) {
|
|
43
|
+
dv.setInt32(0, lo, true);
|
|
44
|
+
dv.setInt32(4, hi, true);
|
|
45
|
+
return dv.getBigInt64(0, true);
|
|
46
|
+
},
|
|
47
|
+
uDec(lo, hi) {
|
|
48
|
+
dv.setInt32(0, lo, true);
|
|
49
|
+
dv.setInt32(4, hi, true);
|
|
50
|
+
return dv.getBigUint64(0, true);
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
return {
|
|
55
|
+
zero: "0",
|
|
56
|
+
supported: false,
|
|
57
|
+
parse(value) {
|
|
58
|
+
if (typeof value != "string") {
|
|
59
|
+
value = value.toString();
|
|
60
|
+
}
|
|
61
|
+
assertInt64String(value);
|
|
62
|
+
return value;
|
|
63
|
+
},
|
|
64
|
+
uParse(value) {
|
|
65
|
+
if (typeof value != "string") {
|
|
66
|
+
value = value.toString();
|
|
67
|
+
}
|
|
68
|
+
assertUInt64String(value);
|
|
69
|
+
return value;
|
|
70
|
+
},
|
|
71
|
+
enc(value) {
|
|
72
|
+
if (typeof value != "string") {
|
|
73
|
+
value = value.toString();
|
|
74
|
+
}
|
|
75
|
+
assertInt64String(value);
|
|
76
|
+
return int64FromString(value);
|
|
77
|
+
},
|
|
78
|
+
uEnc(value) {
|
|
79
|
+
if (typeof value != "string") {
|
|
80
|
+
value = value.toString();
|
|
81
|
+
}
|
|
82
|
+
assertUInt64String(value);
|
|
83
|
+
return int64FromString(value);
|
|
84
|
+
},
|
|
85
|
+
dec(lo, hi) {
|
|
86
|
+
return int64ToString(lo, hi);
|
|
87
|
+
},
|
|
88
|
+
uDec(lo, hi) {
|
|
89
|
+
return uInt64ToString(lo, hi);
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
function assertInt64String(value) {
|
|
94
|
+
if (!/^-?[0-9]+$/.test(value)) {
|
|
95
|
+
throw new Error("invalid int64: " + value);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
function assertUInt64String(value) {
|
|
99
|
+
if (!/^[0-9]+$/.test(value)) {
|
|
100
|
+
throw new Error("invalid uint64: " + value);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
export {
|
|
104
|
+
protoInt64
|
|
105
|
+
};
|
|
106
|
+
//# sourceMappingURL=index17.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index17.js","sources":["../node_modules/.pnpm/@bufbuild+protobuf@2.11.0/node_modules/@bufbuild/protobuf/dist/esm/proto-int64.js"],"sourcesContent":["// Copyright 2021-2026 Buf Technologies, Inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\nimport { int64FromString, int64ToString, uInt64ToString, } from \"./wire/varint.js\";\n/**\n * Int64Support for the current environment.\n */\nexport const protoInt64 = /*@__PURE__*/ makeInt64Support();\nfunction makeInt64Support() {\n const dv = new DataView(new ArrayBuffer(8));\n // note that Safari 14 implements BigInt, but not the DataView methods\n const ok = typeof BigInt === \"function\" &&\n typeof dv.getBigInt64 === \"function\" &&\n typeof dv.getBigUint64 === \"function\" &&\n typeof dv.setBigInt64 === \"function\" &&\n typeof dv.setBigUint64 === \"function\" &&\n (!!globalThis.Deno ||\n typeof process != \"object\" ||\n typeof process.env != \"object\" ||\n process.env.BUF_BIGINT_DISABLE !== \"1\");\n if (ok) {\n const MIN = BigInt(\"-9223372036854775808\");\n const MAX = BigInt(\"9223372036854775807\");\n const UMIN = BigInt(\"0\");\n const UMAX = BigInt(\"18446744073709551615\");\n return {\n zero: BigInt(0),\n supported: true,\n parse(value) {\n const bi = typeof value == \"bigint\" ? value : BigInt(value);\n if (bi > MAX || bi < MIN) {\n throw new Error(`invalid int64: ${value}`);\n }\n return bi;\n },\n uParse(value) {\n const bi = typeof value == \"bigint\" ? value : BigInt(value);\n if (bi > UMAX || bi < UMIN) {\n throw new Error(`invalid uint64: ${value}`);\n }\n return bi;\n },\n enc(value) {\n dv.setBigInt64(0, this.parse(value), true);\n return {\n lo: dv.getInt32(0, true),\n hi: dv.getInt32(4, true),\n };\n },\n uEnc(value) {\n dv.setBigInt64(0, this.uParse(value), true);\n return {\n lo: dv.getInt32(0, true),\n hi: dv.getInt32(4, true),\n };\n },\n dec(lo, hi) {\n dv.setInt32(0, lo, true);\n dv.setInt32(4, hi, true);\n return dv.getBigInt64(0, true);\n },\n uDec(lo, hi) {\n dv.setInt32(0, lo, true);\n dv.setInt32(4, hi, true);\n return dv.getBigUint64(0, true);\n },\n };\n }\n return {\n zero: \"0\",\n supported: false,\n parse(value) {\n if (typeof value != \"string\") {\n value = value.toString();\n }\n assertInt64String(value);\n return value;\n },\n uParse(value) {\n if (typeof value != \"string\") {\n value = value.toString();\n }\n assertUInt64String(value);\n return value;\n },\n enc(value) {\n if (typeof value != \"string\") {\n value = value.toString();\n }\n assertInt64String(value);\n return int64FromString(value);\n },\n uEnc(value) {\n if (typeof value != \"string\") {\n value = value.toString();\n }\n assertUInt64String(value);\n return int64FromString(value);\n },\n dec(lo, hi) {\n return int64ToString(lo, hi);\n },\n uDec(lo, hi) {\n return uInt64ToString(lo, hi);\n },\n };\n}\nfunction assertInt64String(value) {\n if (!/^-?[0-9]+$/.test(value)) {\n throw new Error(\"invalid int64: \" + value);\n }\n}\nfunction assertUInt64String(value) {\n if (!/^[0-9]+$/.test(value)) {\n throw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AACA;AACA,SAAS,kBAAkB,OAAO;AAC9B,MAAI,CAAC,aAAa,KAAK,KAAK,GAAG;AAC3B,UAAM,IAAI,MAAM,oBAAoB,KAAK;AAAA,EAC7C;AACJ;AACA,SAAS,mBAAmB,OAAO;AAC/B,MAAI,CAAC,WAAW,KAAK,KAAK,GAAG;AACzB,UAAM,IAAI,MAAM,qBAAqB,KAAK;AAAA,EAC9C;AACJ;","x_google_ignoreList":[0]}
|
package/dist/index18.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const symbol = Symbol.for("@bufbuild/protobuf/text-encoding");
|
|
2
|
+
function getTextEncoding() {
|
|
3
|
+
if (globalThis[symbol] == void 0) {
|
|
4
|
+
const te = new globalThis.TextEncoder();
|
|
5
|
+
const td = new globalThis.TextDecoder();
|
|
6
|
+
globalThis[symbol] = {
|
|
7
|
+
encodeUtf8(text) {
|
|
8
|
+
return te.encode(text);
|
|
9
|
+
},
|
|
10
|
+
decodeUtf8(bytes) {
|
|
11
|
+
return td.decode(bytes);
|
|
12
|
+
},
|
|
13
|
+
checkUtf8(text) {
|
|
14
|
+
try {
|
|
15
|
+
encodeURIComponent(text);
|
|
16
|
+
return true;
|
|
17
|
+
} catch (_) {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
return globalThis[symbol];
|
|
24
|
+
}
|
|
25
|
+
export {
|
|
26
|
+
getTextEncoding
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=index18.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index18.js","sources":["../node_modules/.pnpm/@bufbuild+protobuf@2.11.0/node_modules/@bufbuild/protobuf/dist/esm/wire/text-encoding.js"],"sourcesContent":["// Copyright 2021-2026 Buf Technologies, Inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\nconst symbol = Symbol.for(\"@bufbuild/protobuf/text-encoding\");\n/**\n * Protobuf-ES requires the Text Encoding API to convert UTF-8 from and to\n * binary. This WHATWG API is widely available, but it is not part of the\n * ECMAScript standard. On runtimes where it is not available, use this\n * function to provide your own implementation.\n *\n * Note that the Text Encoding API does not provide a way to validate UTF-8.\n * Our implementation falls back to use encodeURIComponent().\n */\nexport function configureTextEncoding(textEncoding) {\n globalThis[symbol] = textEncoding;\n}\nexport function getTextEncoding() {\n if (globalThis[symbol] == undefined) {\n const te = new globalThis.TextEncoder();\n const td = new globalThis.TextDecoder();\n globalThis[symbol] = {\n encodeUtf8(text) {\n return te.encode(text);\n },\n decodeUtf8(bytes) {\n return td.decode(bytes);\n },\n checkUtf8(text) {\n try {\n encodeURIComponent(text);\n return true;\n }\n catch (_) {\n return false;\n }\n },\n };\n }\n return globalThis[symbol];\n}\n"],"names":[],"mappings":"AAaA,MAAM,SAAS,OAAO,IAAI,kCAAkC;AAarD,SAAS,kBAAkB;AAC9B,MAAI,WAAW,MAAM,KAAK,QAAW;AACjC,UAAM,KAAK,IAAI,WAAW,YAAW;AACrC,UAAM,KAAK,IAAI,WAAW,YAAW;AACrC,eAAW,MAAM,IAAI;AAAA,MACjB,WAAW,MAAM;AACb,eAAO,GAAG,OAAO,IAAI;AAAA,MACzB;AAAA,MACA,WAAW,OAAO;AACd,eAAO,GAAG,OAAO,KAAK;AAAA,MAC1B;AAAA,MACA,UAAU,MAAM;AACZ,YAAI;AACA,6BAAmB,IAAI;AACvB,iBAAO;AAAA,QACX,SACO,GAAG;AACN,iBAAO;AAAA,QACX;AAAA,MACJ;AAAA,IACZ;AAAA,EACI;AACA,SAAO,WAAW,MAAM;AAC5B;","x_google_ignoreList":[0]}
|