@4players/odin-common 7.2.1 → 7.3.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/mod.d.ts +0 -1
- package/mod.js +1 -1
- package/mod.mjs +1 -1
- package/package.json +14 -5
- package/zod/mod.d.ts +1 -0
- package/zod/mod.js +1 -0
- package/zod/mod.mjs +1 -0
package/mod.d.ts
CHANGED
package/mod.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var Se=Object.create;var M=Object.defineProperty;var ze=Object.getOwnPropertyDescriptor;var ke=Object.getOwnPropertyNames;var Le=Object.getPrototypeOf,Pe=Object.prototype.hasOwnProperty;var Re=(t,e)=>{for(var r in e)M(t,r,{get:e[r],enumerable:!0})},Q=(t,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let p of ke(e))!Pe.call(t,p)&&p!==r&&M(t,p,{get:()=>e[p],enumerable:!(s=ze(e,p))||s.enumerable});return t};var P=(t,e,r)=>(r=t!=null?Se(Le(t)):{},Q(e||!t||!t.__esModule?M(r,"default",{value:t,enumerable:!0}):r,t)),we=t=>Q(M({},"__esModule",{value:!0}),t);var Tt={};Re(Tt,{APM_DEFAULTS:()=>ht,Backend:()=>le,ByteArraySchema:()=>y,CONNECTION_STATS_INITIAL:()=>xt,ChannelSet:()=>D,ChannelSetSchema:()=>q,DEFAULT_FORMATTER:()=>de,JITTER_STATS_INITIAL:()=>bt,JsonSchema:()=>C,LogFunctions:()=>pe,LogHandler:()=>$,LogLevelNames:()=>se,LogLevels:()=>G,LogSymbols:()=>ce,LogVerbosity:()=>_,Logger:()=>H,MainCommandsRpc:()=>je,MainNotificationSchema:()=>Me,MainNotificationsRpc:()=>Ne,MediaAudioPropertiesSchema:()=>te,MediaIdSchema:()=>T,MediaPropertiesSchema:()=>N,MediaSchema:()=>U,MediaVideoPropertiesSchema:()=>re,MessagePackRpcSchema:()=>Ce,MessageReceivedSchema:()=>B,MinDBFS:()=>vr,PRETTY_FORMATTER:()=>yt,PeerIdSchema:()=>v,PeerPositionSchema:()=>j,PeerSchema:()=>I,PeerUpdateSchema:()=>O,RoomCommandsRpc:()=>Fe,RoomNotificationSchema:()=>Ue,RoomNotificationsRpc:()=>Ie,RoomV1:()=>z,RoomV2:()=>oe,Selector:()=>K,Strand:()=>Y,TokenAudienceSchema:()=>X,TokenClaimsSchema:()=>Ae,TokenSubjectSchema:()=>ee,VAD_DEFAULTS:()=>vt,VideoCodec:()=>Z,WebRtcUpdateSchema:()=>w,abortableSleep:()=>Ye,assert:()=>F,debug:()=>gt,error:()=>lt,extendUrl:()=>et,fail:()=>W,failure:()=>x,find:()=>Je,fromBase64:()=>Oe,fromBase64Url:()=>Ee,fromBytes:()=>Be,generateUUID:()=>rt,getLevelByName:()=>R,getLevelName:()=>L,getLogger:()=>k,info:()=>ft,isAudioCapable:()=>Ge,isBlinkBrowser:()=>ae,isElectronBrowser:()=>$e,isFailure:()=>ut,isFirefoxBrowser:()=>qe,isFunction:()=>it,isNull:()=>at,isNumber:()=>J,isObject:()=>st,isProperty:()=>ot,isSafariBrowser:()=>We,isSharedArrayBufferCapable:()=>He,isString:()=>ct,isSuccess:()=>dt,isUndefined:()=>pt,nextTick:()=>Qe,normalizeUrl:()=>Xe,oneOrMany:()=>A,sleep:()=>Ke,success:()=>f,toBytes:()=>De,toRaw:()=>Ze,unwrap:()=>b,unwrapOr:()=>V,validateUUID:()=>nt,warn:()=>mt,zod:()=>St});module.exports=we(Tt);var St=P(require("zod"));var u=require("zod"),y=u.z.custom(t=>t instanceof Uint8Array),_e=u.z.union([u.z.string(),u.z.number(),u.z.boolean(),u.z.null()]),C=u.z.lazy(()=>u.z.union([_e,u.z.array(C),u.z.record(C)])),Ce=u.z.union([u.z.tuple([u.z.literal(0),u.z.number(),u.z.string(),u.z.unknown()]),u.z.tuple([u.z.literal(1),u.z.number(),u.z.nullable(u.z.string()),u.z.unknown()]),u.z.tuple([u.z.literal(2),u.z.string(),u.z.unknown()])]);var c=require("zod"),X=c.z.enum(["sfu","gateway"]),ee=c.z.enum(["connect","roomclose","roomupdate","roombanclient","roomsendmessage"]),Ae=c.z.object({uid:c.z.string(),cid:c.z.optional(c.z.string()),rid:A(c.z.string()).refine(t=>t.length>=1,{message:"missing rid"}),nsp:c.z.optional(c.z.string()),adr:c.z.optional(c.z.string()),aud:c.z.optional(A(X)),sub:c.z.optional(A(ee)),exp:c.z.optional(c.z.number()),nbf:c.z.optional(c.z.number()),ups:c.z.optional(c.z.string()),tgs:c.z.optional(A(c.z.string())),tsp:c.z.optional(c.z.number()),internal:c.z.optional(c.z.object({server:c.z.optional(c.z.string())}))});function A(t){return c.z.union([t.transform(e=>[e]),c.z.array(t)])}var n=P(require("zod"));var d=P(require("zod")),T=d.number(),te=d.object({kind:d.optional(d.literal("audio")),uid:d.optional(d.string()),customType:d.optional(d.string())}),re=d.object({kind:d.optional(d.literal("video")),codec:d.optional(d.string()),uid:d.optional(d.string()),customType:d.optional(d.string())}),N=d.union([te,re]),U=d.object({id:T,properties:N,paused:d.boolean()});var l=P(require("zod"));var v=l.number(),j=l.union([l.tuple([l.number(),l.number(),l.number()]),l.tuple([l.number(),l.number()])]),I=l.object({id:v,user_id:l.string(),user_data:y,medias:l.array(U)}),O=l.discriminatedUnion("kind",[l.object({kind:l.literal("UserDataChanged"),peer_id:v,user_data:y}),l.object({kind:l.literal("MediaStarted"),peer_id:v,media:U}),l.object({kind:l.literal("MediaStopped"),peer_id:v,media_id:T})]);var ne=P(require("zod")),D=class t{constructor(e=BigInt(0)){this.value=e}from(...e){let r=e.reduce((s,p)=>s|E(p),BigInt(0));return new t(r)}contains(e){return(this.value&E(e))!==BigInt(0)}insert(e){this.value|=E(e)}remove(e){this.value&=~E(e)}[Symbol.iterator](){let e=-1,r=new t(this.value);return{next(){for(;e<63;)if(e+=1,r.contains(e))return{value:e,done:!1};return{value:void 0,done:!0}}}}},q=ne.bigint().transform(t=>new D(t));function E(t){return BigInt(1)<<BigInt(t)}var z;(m=>(m.RoomIdSchema=n.string(),m.RoomSchema=n.object({id:m.RoomIdSchema,customer:n.string(),user_data:y,peers:n.array(I)}),m.RoomUpdateSchema=n.discriminatedUnion("kind",[n.object({kind:n.literal("Joined"),room:m.RoomSchema,media_ids:n.array(T),own_peer_id:v}),n.object({kind:n.literal("Left"),reason:n.enum(["RoomClosing","ServerClosing","PeerKicked"])}),n.object({kind:n.literal("UserDataChanged"),user_data:n.optional(y)}),n.object({kind:n.literal("PeerJoined"),peer:I}),n.object({kind:n.literal("PeerLeft"),peer_id:v})]),m.RoomUpdatesSchema=n.object({updates:n.array(m.RoomUpdateSchema)}),m.RoomStatusSchema=n.enum(["Joining","Joined","Closed"]),m.RoomStatusChangedSchema=n.object({status:m.RoomStatusSchema,message:n.optional(n.string())})))(z||={});var oe;(i=>(i.ParametersSchema=n.record(C),i.PeerProperties=n.object({user_data:y.optional(),tags:n.array(n.string()).optional(),audio_parameters:i.ParametersSchema.optional(),video_parameters:i.ParametersSchema.optional()}),i.PingSchema=n.object({Ping:n.object({id:n.number()})}),i.ChangeSelfSchema=n.object({ChangeSelf:i.PeerProperties.omit({tags:!0})}),i.SetAudioMaskSchema=n.object({SetAudioMask:n.object({peer_id:n.number(),mask:q})}),i.SendMessageSchema=n.object({SendMessage:n.object({peer_ids:n.number().array().default([]),message:y})}),i.CallSchema=i.PingSchema.or(i.ChangeSelfSchema).or(i.SetAudioMaskSchema).or(i.SendMessageSchema),i.PongSchema=n.object({Pong:n.object({id:n.number()})}),i.JoinedSchema=n.object({Joined:n.object({own_peer_id:n.number(),room_id:n.string(),customer:n.string()})}),i.LeftSchema=n.object({Left:n.object({reason:n.enum(["room_closing","server_closing","peer_kicked"])})}),i.PeerJoinedSchema=n.object({PeerJoined:i.PeerProperties.extend({peer_id:n.number(),user_id:n.string()})}),i.PeerLeftSchema=n.object({PeerLeft:n.object({peer_id:n.number()})}),i.PeerChangedSchema=n.object({PeerChanged:i.PeerProperties.extend({peer_id:n.number()})}),i.NewReconnectTokenSchema=n.object({NewReconnectToken:n.object({token:n.string()})}),i.MessageReceivedSchema=n.object({MessageReceived:n.object({sender_peer_id:n.number(),message:y})}),i.ErrorSchema=n.object({Error:n.object({message:y})}),i.EventSchema=i.PongSchema.or(i.JoinedSchema).or(i.LeftSchema).or(i.PeerJoinedSchema).or(i.PeerLeftSchema).or(i.PeerChangedSchema).or(i.NewReconnectTokenSchema).or(i.MessageReceivedSchema).or(i.ErrorSchema)))(oe||={});var ie=require("zod");var B=ie.z.object({sender_peer_id:v,message:y});var a=P(require("zod"));var w=a.discriminatedUnion("kind",[a.object({kind:a.literal("Sdp"),type:a.enum(["Answer","Offer"]),sdp:a.string(),media_map:a.array(a.tuple([T,a.string()]))}),a.object({kind:a.literal("Trickle"),candidate:a.string(),spd_mid:a.optional(a.string()),spd_mline_index:a.optional(a.number()),username_fragment:a.optional(a.union([a.string(),a.null()]))}),a.object({kind:a.literal("TrickleFinished")})]);var o=require("zod");var je={Hello:{request:o.z.object({stream:o.z.literal("main")}),response:o.z.null()},JoinRoom:{request:o.z.object({token:o.z.string(),room_id:z.RoomIdSchema,user_data:y,position:j}),response:o.z.object({peer_id:v,stream_id:o.z.optional(o.z.number()),token:o.z.optional(o.z.string())})},WebRtcUpdate:{request:w,response:o.z.null()},RequestReconnectToken:{request:o.z.object({peer_id:o.z.optional(v)}),response:o.z.string()},Ping:{request:o.z.object({}),response:o.z.null()}},Fe={Hello:{request:o.z.object({stream:o.z.literal("room"),token:o.z.string(),room_id:o.z.string(),user_data:y,position:j}),response:o.z.null()},UpdatePeer:{request:o.z.object({user_data:y}),response:o.z.null()},StartMedia:{request:o.z.object({media_id:T,properties:N}),response:o.z.null()},StopMedia:{request:o.z.object({media_id:T}),response:o.z.null()},PauseMedia:{request:o.z.object({media_id:T}),response:o.z.null()},ResumeMedia:{request:o.z.object({media_id:T}),response:o.z.null()},SetPeerPosition:{request:o.z.object({position:j}),response:o.z.null()},SendMessage:{request:o.z.object({target_peer_ids:o.z.optional(o.z.array(v)),message:y}),response:o.z.null()}};var h=P(require("zod"));var Me=h.object({name:h.literal("WebRtcUpdate"),properties:w}),Ne={WebRtcUpdate:w},Ue=h.union([h.object({name:h.literal("RoomStatusChanged"),properties:z.RoomStatusChangedSchema}),h.object({name:h.literal("RoomUpdated"),properties:z.RoomUpdatesSchema}),h.object({name:h.literal("PeerUpdated"),properties:O}),h.object({name:h.literal("MessageReceived"),properties:B})]),Ie={RoomStatusChanged:z.RoomStatusChangedSchema,RoomUpdated:z.RoomUpdatesSchema,PeerUpdated:O,MessageReceived:B};function F(t,e){t||W(e)}function W(t){throw new Error(t)}function f(t){return{type:"Success",value:t}}function x(t){return{type:"Failure",reason:t}}function b(t){return t.type==="Failure"&&W(t.reason),t.value}function V(t,e){return t.type==="Success"?t.value:e}function Oe(t){try{let e=atob(t),r=Uint8Array.from(e,p=>p.codePointAt(0)),s=new TextDecoder("utf8");return f(s.decode(r))}catch(e){return x(String(e))}}function Ee(t){try{let e=atob(t.replace(/-/g,"+").replace(/_/g,"/")),r=Uint8Array.from(e,p=>p.codePointAt(0)),s=new TextDecoder("utf8");return f(s.decode(r))}catch(e){return x(String(e))}}function De(t){try{F(t!==void 0,"undefined cannot be converted to byte array"),F(t!==null,"null cannot be converted to byte array");let e=JSON.stringify(t),r=new TextEncoder;return f(r.encode(e))}catch(e){return x(String(e))}}function Be(t){try{F(t.length>0,"empty byte array cannot be converted to value");let e=new TextDecoder().decode(t),r=JSON.parse(e);return f(r)}catch(e){return x(String(e))}}var Ve=["VP8","VP9","AV1","H264"],Z=class{constructor(e){this.codec=e}channels=0;clockRate=9e4;isValid(){return Ve.includes(this.codec)}isSupported(){if(typeof RTCRtpReceiver>"u"||typeof RTCRtpReceiver.getCapabilities>"u")return null;let e=V(this.getMimeType(),"").toLowerCase(),r=new Set(V(this.getSdpFmtpLine(),"").split(";").map(s=>s.trim().toLowerCase()));return RTCRtpReceiver.getCapabilities("video")?.codecs?.find(s=>{let p=s.mimeType.toLowerCase(),g=new Set((s.sdpFmtpLine??"").split(";").map(m=>m.trim().toLowerCase()));if(e!==p||r.size!==g.size)return!1;for(let m of r)if(!g.has(m))return!1;return!0})??null}getPayloadType(){switch(this.codec){case"VP8":return f(96);case"VP9":return f(98);case"AV1":return f(41);case"H264":return f(102);default:return x("invalid video codec")}}getMimeType(){switch(this.codec){case"VP8":return f("video/VP8");case"VP9":return f("video/VP9");case"AV1":return f("video/AV1");case"H264":return f("video/H264");default:return x("invalid video codec")}}getSdpFmtpLine(){switch(this.codec){case"VP8":return f("");case"VP9":return f("profile-id=2");case"AV1":return f("level-idx=5;profile=0;tier=0");case"H264":return f("level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f");default:return x("invalid video codec")}}};function Je(t,e){for(let r of t)if(e(r))return r}function Ge(){return typeof AudioContext<"u"&&typeof Worker<"u"}function He(){return typeof SharedArrayBuffer<"u"}function ae(){return/(apple)?webkit\/537\.36/i.test(globalThis.navigator.userAgent)}function $e(){return/electron/i.test(globalThis.navigator.userAgent)}function qe(){return/firefox|iceweasel|fxios/i.test(globalThis.navigator.userAgent)}function We(){return ae()?!1:/safari|applewebkit/i.test(globalThis.navigator.userAgent)}function Ze(t){return JSON.parse(JSON.stringify(t))}var K=class t{constructor(e){this._Generators=e;this._Futures=e.map(t.addIndex)}_Futures;async next(){let[e,r]=await Promise.race(this._Futures);return this._Futures[r]=t.addIndex(this._Generators[r],r),e}static async addIndex(e,r){return[await e(),r]}};function Ke(t,e){return t<=0?Promise.resolve(e):new Promise(r=>setTimeout(()=>r(e),t))}function Ye(t,e){return e.aborted?Promise.resolve("aborted"):new Promise(r=>{let s=()=>r("aborted");e.addEventListener("abort",s,{once:!0}),setTimeout(()=>{e.removeEventListener("abort",s),r(void 0)},t)})}function Qe(){return new Promise(t=>setTimeout(t,0))}var Y=class{_Tasks=[];_Running=!1;_Values;constructor(...e){this._Values=e}enqueue(e){return new Promise((r,s)=>{let p=async()=>{try{let g=await e(...this._Values);r(g)}catch(g){s(g)}};this._Tasks.push(p),this._Running||this.execute()})}async execute(){for(this._Running=!0;;){let e=this._Tasks.shift();if(e===void 0)break;await e()}this._Running=!1}};function Xe(t){let e=t.trim();t.indexOf("://")===-1&&(e=`https://${e}`);try{return f(new URL(e))}catch(r){return x(String(r))}}function et(t,e){let r=t.pathname;r.endsWith("/")===!1&&(r+="/");try{return f(new URL(r+e,t))}catch(s){return x(String(s))}}var tt=/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;function rt(){return crypto.randomUUID()}function nt(t){return tt.test(t)}function ot(t,e){return e in t}function it(t){return typeof t=="function"}function at(t){return typeof t=="object"&&t===null}function J(t){return typeof t=="number"}function st(t){return typeof t=="object"}function ct(t){return typeof t=="string"}function pt(t){return typeof t>"u"}function ut(t){return t.type==="Failure"}function dt(t){return t.type==="Success"}var _=(g=>(g[g.NONE=0]="NONE",g[g.ERROR=1]="ERROR",g[g.WARN=2]="WARN",g[g.INFO=3]="INFO",g[g.DEBUG=4]="DEBUG",g))(_||{}),G=Object.values(_).filter(t=>!isNaN(Number(t))),se=Object.keys(_).filter(t=>isNaN(Number(t))),ce={0:"\u26AB",1:"\u{1F534}",2:"\u{1F7E1}",3:"\u{1F535}",4:"\u{1F7E3}"},pe={0:console.log,1:console.error,2:console.warn,3:console.info,4:console.debug};function R(t){let e=_[t];return e===void 0?x(`invalid log level name '${t}'; valid names are: ${se.join(", ")}`):f(e)}function L(t){let e=_[t];return e===void 0?x(`invalid log level ${t}; valid levels are: ${G[0]}-${G[G.length-1]}`):f(e)}var S="default",ue=new Map;function k(t=S){let e=ue.get(t);return e||(e=new H("WARN",t)),e}function lt(t,...e){return t instanceof Function?k(S).error(t,...e):k(S).error(t,...e)}function mt(t,...e){return t instanceof Function?k(S).warn(t,...e):k(S).warn(t,...e)}function ft(t,...e){return t instanceof Function?k(S).info(t,...e):k(S).info(t,...e)}function gt(t,...e){return t instanceof Function?k(S).debug(t,...e):k(S).debug(t,...e)}var H=class{name;_Level;_Handlers;constructor(e,r,s){this.name=r??S,J(e)?this._Level=b(R(b(L(e)))):this._Level=b(R(e)),this._Handlers=s?.handlers||[new $(e)],ue.set(this.name,this)}get level(){return this._Level}set level(e){this.levelName=b(L(e))}get levelName(){return b(L(this._Level))}set levelName(e){this._Level=b(R(e)),this._Handlers.forEach(r=>r.level=this._Level)}get handlers(){return this._Handlers}addHandler(e){this._Handlers.push(e)}removeHandler(e){let r=this._Handlers.indexOf(e);r!==-1&&this._Handlers.splice(r,1)}log(e,r,...s){if(this.level<e)return r instanceof Function?void 0:r;let p,g;return r instanceof Function?(p=r(),g=this.asString(p)):g=this.asString(r),this._Handlers.forEach(m=>{m.handle({date:new Date,level:e,levelName:b(L(e)),logger:this.name,message:g,args:s})}),r instanceof Function?p:r}error(e,...r){return this.log(1,e,...r)}warn(e,...r){return this.log(2,e,...r)}info(e,...r){return this.log(3,e,...r)}debug(e,...r){return this.log(4,e,...r)}asString(e,r=!1){return typeof e=="string"?r?`"${e}"`:e:e===null||typeof e=="number"||typeof e=="bigint"||typeof e=="boolean"||typeof e>"u"||typeof e=="symbol"?String(e):e instanceof Error?e.stack:typeof e=="object"?`{${Object.entries(e).map(([s,p])=>`"${s}":${this.asString(p,!0)}`).join(",")}}`:"undefined"}},de=({message:t})=>t,yt=t=>{let e=`[${t.date.toISOString()}]`,r=`[${t.levelName}]`,s=t.logger!==S?`[${t.logger}] `:"",p=ce[t.level];return`${e} ${p} ${r.padEnd(7," ")} ${s}${t.message}`},$=class{_Level;_FormatterFn;constructor(e,r=de){J(e)?this._Level=b(R(b(L(e)))):this._Level=b(R(e)),this._FormatterFn=r}get level(){return this._Level}set level(e){this.levelName=b(L(e))}get levelName(){return b(L(this._Level))}set levelName(e){this._Level=b(R(e))}handle(e){this._Level<e.level||this.log(this._FormatterFn(e),e)}log(e,r){pe[r.level](e,...r.args)}};var vr=-758.596,le;(e=>{let t;(m=>(m[m.InvalidPassword=-1]="InvalidPassword",m[m.Unknown=0]="Unknown",m[m.Unencrypted=1]="Unencrypted",m[m.Encrypted=2]="Encrypted"))(t=e.PeerCipherStatus||={})})(le||={});var xt={bytesSent:0,bytesReceived:0,packetsSent:0,packetsReceived:0,rtt:0,packetLoss:0},bt={packetsBuffered:0,packetsSeen:0,packetsProcessed:0,packetsTooEarly:0,packetsTooLate:0,packetsDropped:0,packetsInvalid:0,packetsRepeated:0,packetsLost:0},vt={voiceActivity:{attackThreshold:.9,releaseThreshold:.8},volumeGate:{attackThreshold:-30,releaseThreshold:-40}},ht={echoCanceller:!0,highPassFilter:!1,noiseSuppression:"Moderate",transientSuppressor:!1,gainController:!0};0&&(module.exports={APM_DEFAULTS,Backend,ByteArraySchema,CONNECTION_STATS_INITIAL,ChannelSet,ChannelSetSchema,DEFAULT_FORMATTER,JITTER_STATS_INITIAL,JsonSchema,LogFunctions,LogHandler,LogLevelNames,LogLevels,LogSymbols,LogVerbosity,Logger,MainCommandsRpc,MainNotificationSchema,MainNotificationsRpc,MediaAudioPropertiesSchema,MediaIdSchema,MediaPropertiesSchema,MediaSchema,MediaVideoPropertiesSchema,MessagePackRpcSchema,MessageReceivedSchema,MinDBFS,PRETTY_FORMATTER,PeerIdSchema,PeerPositionSchema,PeerSchema,PeerUpdateSchema,RoomCommandsRpc,RoomNotificationSchema,RoomNotificationsRpc,RoomV1,RoomV2,Selector,Strand,TokenAudienceSchema,TokenClaimsSchema,TokenSubjectSchema,VAD_DEFAULTS,VideoCodec,WebRtcUpdateSchema,abortableSleep,assert,debug,error,extendUrl,fail,failure,find,fromBase64,fromBase64Url,fromBytes,generateUUID,getLevelByName,getLevelName,getLogger,info,isAudioCapable,isBlinkBrowser,isElectronBrowser,isFailure,isFirefoxBrowser,isFunction,isNull,isNumber,isObject,isProperty,isSafariBrowser,isSharedArrayBufferCapable,isString,isSuccess,isUndefined,nextTick,normalizeUrl,oneOrMany,sleep,success,toBytes,toRaw,unwrap,unwrapOr,validateUUID,warn,zod});
|
|
1
|
+
var Se=Object.create;var M=Object.defineProperty;var ze=Object.getOwnPropertyDescriptor;var ke=Object.getOwnPropertyNames;var Le=Object.getPrototypeOf,Pe=Object.prototype.hasOwnProperty;var Re=(t,e)=>{for(var r in e)M(t,r,{get:e[r],enumerable:!0})},Q=(t,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let p of ke(e))!Pe.call(t,p)&&p!==r&&M(t,p,{get:()=>e[p],enumerable:!(s=ze(e,p))||s.enumerable});return t};var R=(t,e,r)=>(r=t!=null?Se(Le(t)):{},Q(e||!t||!t.__esModule?M(r,"default",{value:t,enumerable:!0}):r,t)),we=t=>Q(M({},"__esModule",{value:!0}),t);var Tt={};Re(Tt,{APM_DEFAULTS:()=>ht,Backend:()=>le,ByteArraySchema:()=>y,CONNECTION_STATS_INITIAL:()=>xt,ChannelSet:()=>D,ChannelSetSchema:()=>q,DEFAULT_FORMATTER:()=>de,JITTER_STATS_INITIAL:()=>bt,JsonSchema:()=>C,LogFunctions:()=>pe,LogHandler:()=>$,LogLevelNames:()=>se,LogLevels:()=>G,LogSymbols:()=>ce,LogVerbosity:()=>_,Logger:()=>H,MainCommandsRpc:()=>je,MainNotificationSchema:()=>Me,MainNotificationsRpc:()=>Ne,MediaAudioPropertiesSchema:()=>te,MediaIdSchema:()=>T,MediaPropertiesSchema:()=>N,MediaSchema:()=>U,MediaVideoPropertiesSchema:()=>re,MessagePackRpcSchema:()=>Ce,MessageReceivedSchema:()=>B,MinDBFS:()=>br,PRETTY_FORMATTER:()=>yt,PeerIdSchema:()=>v,PeerPositionSchema:()=>j,PeerSchema:()=>I,PeerUpdateSchema:()=>O,RoomCommandsRpc:()=>Fe,RoomNotificationSchema:()=>Ue,RoomNotificationsRpc:()=>Ie,RoomV1:()=>z,RoomV2:()=>oe,Selector:()=>K,Strand:()=>Y,TokenAudienceSchema:()=>X,TokenClaimsSchema:()=>Ae,TokenSubjectSchema:()=>ee,VAD_DEFAULTS:()=>vt,VideoCodec:()=>Z,WebRtcUpdateSchema:()=>w,abortableSleep:()=>Ye,assert:()=>F,debug:()=>gt,error:()=>lt,extendUrl:()=>et,fail:()=>W,failure:()=>x,find:()=>Je,fromBase64:()=>Oe,fromBase64Url:()=>Ee,fromBytes:()=>Be,generateUUID:()=>rt,getLevelByName:()=>P,getLevelName:()=>L,getLogger:()=>k,info:()=>ft,isAudioCapable:()=>Ge,isBlinkBrowser:()=>ae,isElectronBrowser:()=>$e,isFailure:()=>ut,isFirefoxBrowser:()=>qe,isFunction:()=>it,isNull:()=>at,isNumber:()=>J,isObject:()=>st,isProperty:()=>ot,isSafariBrowser:()=>We,isSharedArrayBufferCapable:()=>He,isString:()=>ct,isSuccess:()=>dt,isUndefined:()=>pt,nextTick:()=>Qe,normalizeUrl:()=>Xe,oneOrMany:()=>A,sleep:()=>Ke,success:()=>f,toBytes:()=>De,toRaw:()=>Ze,unwrap:()=>b,unwrapOr:()=>V,validateUUID:()=>nt,warn:()=>mt});module.exports=we(Tt);var u=require("zod"),y=u.z.custom(t=>t instanceof Uint8Array),_e=u.z.union([u.z.string(),u.z.number(),u.z.boolean(),u.z.null()]),C=u.z.lazy(()=>u.z.union([_e,u.z.array(C),u.z.record(C)])),Ce=u.z.union([u.z.tuple([u.z.literal(0),u.z.number(),u.z.string(),u.z.unknown()]),u.z.tuple([u.z.literal(1),u.z.number(),u.z.nullable(u.z.string()),u.z.unknown()]),u.z.tuple([u.z.literal(2),u.z.string(),u.z.unknown()])]);var c=require("zod"),X=c.z.enum(["sfu","gateway"]),ee=c.z.enum(["connect","roomclose","roomupdate","roombanclient","roomsendmessage"]),Ae=c.z.object({uid:c.z.string(),cid:c.z.optional(c.z.string()),rid:A(c.z.string()).refine(t=>t.length>=1,{message:"missing rid"}),nsp:c.z.optional(c.z.string()),adr:c.z.optional(c.z.string()),aud:c.z.optional(A(X)),sub:c.z.optional(A(ee)),exp:c.z.optional(c.z.number()),nbf:c.z.optional(c.z.number()),ups:c.z.optional(c.z.string()),tgs:c.z.optional(A(c.z.string())),tsp:c.z.optional(c.z.number()),internal:c.z.optional(c.z.object({server:c.z.optional(c.z.string())}))});function A(t){return c.z.union([t.transform(e=>[e]),c.z.array(t)])}var n=R(require("zod"));var d=R(require("zod")),T=d.number(),te=d.object({kind:d.optional(d.literal("audio")),uid:d.optional(d.string()),customType:d.optional(d.string())}),re=d.object({kind:d.optional(d.literal("video")),codec:d.optional(d.string()),uid:d.optional(d.string()),customType:d.optional(d.string())}),N=d.union([te,re]),U=d.object({id:T,properties:N,paused:d.boolean()});var l=R(require("zod"));var v=l.number(),j=l.union([l.tuple([l.number(),l.number(),l.number()]),l.tuple([l.number(),l.number()])]),I=l.object({id:v,user_id:l.string(),user_data:y,medias:l.array(U)}),O=l.discriminatedUnion("kind",[l.object({kind:l.literal("UserDataChanged"),peer_id:v,user_data:y}),l.object({kind:l.literal("MediaStarted"),peer_id:v,media:U}),l.object({kind:l.literal("MediaStopped"),peer_id:v,media_id:T})]);var ne=R(require("zod")),D=class t{constructor(e=BigInt(0)){this.value=e}from(...e){let r=e.reduce((s,p)=>s|E(p),BigInt(0));return new t(r)}contains(e){return(this.value&E(e))!==BigInt(0)}insert(e){this.value|=E(e)}remove(e){this.value&=~E(e)}[Symbol.iterator](){let e=-1,r=new t(this.value);return{next(){for(;e<63;)if(e+=1,r.contains(e))return{value:e,done:!1};return{value:void 0,done:!0}}}}},q=ne.bigint().transform(t=>new D(t));function E(t){return BigInt(1)<<BigInt(t)}var z;(m=>(m.RoomIdSchema=n.string(),m.RoomSchema=n.object({id:m.RoomIdSchema,customer:n.string(),user_data:y,peers:n.array(I)}),m.RoomUpdateSchema=n.discriminatedUnion("kind",[n.object({kind:n.literal("Joined"),room:m.RoomSchema,media_ids:n.array(T),own_peer_id:v}),n.object({kind:n.literal("Left"),reason:n.enum(["RoomClosing","ServerClosing","PeerKicked"])}),n.object({kind:n.literal("UserDataChanged"),user_data:n.optional(y)}),n.object({kind:n.literal("PeerJoined"),peer:I}),n.object({kind:n.literal("PeerLeft"),peer_id:v})]),m.RoomUpdatesSchema=n.object({updates:n.array(m.RoomUpdateSchema)}),m.RoomStatusSchema=n.enum(["Joining","Joined","Closed"]),m.RoomStatusChangedSchema=n.object({status:m.RoomStatusSchema,message:n.optional(n.string())})))(z||={});var oe;(i=>(i.ParametersSchema=n.record(C),i.PeerProperties=n.object({user_data:y.optional(),tags:n.array(n.string()).optional(),audio_parameters:i.ParametersSchema.optional(),video_parameters:i.ParametersSchema.optional()}),i.PingSchema=n.object({Ping:n.object({id:n.number()})}),i.ChangeSelfSchema=n.object({ChangeSelf:i.PeerProperties.omit({tags:!0})}),i.SetAudioMaskSchema=n.object({SetAudioMask:n.object({peer_id:n.number(),mask:q})}),i.SendMessageSchema=n.object({SendMessage:n.object({peer_ids:n.number().array().default([]),message:y})}),i.CallSchema=i.PingSchema.or(i.ChangeSelfSchema).or(i.SetAudioMaskSchema).or(i.SendMessageSchema),i.PongSchema=n.object({Pong:n.object({id:n.number()})}),i.JoinedSchema=n.object({Joined:n.object({own_peer_id:n.number(),room_id:n.string(),customer:n.string()})}),i.LeftSchema=n.object({Left:n.object({reason:n.enum(["room_closing","server_closing","peer_kicked"])})}),i.PeerJoinedSchema=n.object({PeerJoined:i.PeerProperties.extend({peer_id:n.number(),user_id:n.string()})}),i.PeerLeftSchema=n.object({PeerLeft:n.object({peer_id:n.number()})}),i.PeerChangedSchema=n.object({PeerChanged:i.PeerProperties.extend({peer_id:n.number()})}),i.NewReconnectTokenSchema=n.object({NewReconnectToken:n.object({token:n.string()})}),i.MessageReceivedSchema=n.object({MessageReceived:n.object({sender_peer_id:n.number(),message:y})}),i.ErrorSchema=n.object({Error:n.object({message:y})}),i.EventSchema=i.PongSchema.or(i.JoinedSchema).or(i.LeftSchema).or(i.PeerJoinedSchema).or(i.PeerLeftSchema).or(i.PeerChangedSchema).or(i.NewReconnectTokenSchema).or(i.MessageReceivedSchema).or(i.ErrorSchema)))(oe||={});var ie=require("zod");var B=ie.z.object({sender_peer_id:v,message:y});var a=R(require("zod"));var w=a.discriminatedUnion("kind",[a.object({kind:a.literal("Sdp"),type:a.enum(["Answer","Offer"]),sdp:a.string(),media_map:a.array(a.tuple([T,a.string()]))}),a.object({kind:a.literal("Trickle"),candidate:a.string(),spd_mid:a.optional(a.string()),spd_mline_index:a.optional(a.number()),username_fragment:a.optional(a.union([a.string(),a.null()]))}),a.object({kind:a.literal("TrickleFinished")})]);var o=require("zod");var je={Hello:{request:o.z.object({stream:o.z.literal("main")}),response:o.z.null()},JoinRoom:{request:o.z.object({token:o.z.string(),room_id:z.RoomIdSchema,user_data:y,position:j}),response:o.z.object({peer_id:v,stream_id:o.z.optional(o.z.number()),token:o.z.optional(o.z.string())})},WebRtcUpdate:{request:w,response:o.z.null()},RequestReconnectToken:{request:o.z.object({peer_id:o.z.optional(v)}),response:o.z.string()},Ping:{request:o.z.object({}),response:o.z.null()}},Fe={Hello:{request:o.z.object({stream:o.z.literal("room"),token:o.z.string(),room_id:o.z.string(),user_data:y,position:j}),response:o.z.null()},UpdatePeer:{request:o.z.object({user_data:y}),response:o.z.null()},StartMedia:{request:o.z.object({media_id:T,properties:N}),response:o.z.null()},StopMedia:{request:o.z.object({media_id:T}),response:o.z.null()},PauseMedia:{request:o.z.object({media_id:T}),response:o.z.null()},ResumeMedia:{request:o.z.object({media_id:T}),response:o.z.null()},SetPeerPosition:{request:o.z.object({position:j}),response:o.z.null()},SendMessage:{request:o.z.object({target_peer_ids:o.z.optional(o.z.array(v)),message:y}),response:o.z.null()}};var h=R(require("zod"));var Me=h.object({name:h.literal("WebRtcUpdate"),properties:w}),Ne={WebRtcUpdate:w},Ue=h.union([h.object({name:h.literal("RoomStatusChanged"),properties:z.RoomStatusChangedSchema}),h.object({name:h.literal("RoomUpdated"),properties:z.RoomUpdatesSchema}),h.object({name:h.literal("PeerUpdated"),properties:O}),h.object({name:h.literal("MessageReceived"),properties:B})]),Ie={RoomStatusChanged:z.RoomStatusChangedSchema,RoomUpdated:z.RoomUpdatesSchema,PeerUpdated:O,MessageReceived:B};function F(t,e){t||W(e)}function W(t){throw new Error(t)}function f(t){return{type:"Success",value:t}}function x(t){return{type:"Failure",reason:t}}function b(t){return t.type==="Failure"&&W(t.reason),t.value}function V(t,e){return t.type==="Success"?t.value:e}function Oe(t){try{let e=atob(t),r=Uint8Array.from(e,p=>p.codePointAt(0)),s=new TextDecoder("utf8");return f(s.decode(r))}catch(e){return x(String(e))}}function Ee(t){try{let e=atob(t.replace(/-/g,"+").replace(/_/g,"/")),r=Uint8Array.from(e,p=>p.codePointAt(0)),s=new TextDecoder("utf8");return f(s.decode(r))}catch(e){return x(String(e))}}function De(t){try{F(t!==void 0,"undefined cannot be converted to byte array"),F(t!==null,"null cannot be converted to byte array");let e=JSON.stringify(t),r=new TextEncoder;return f(r.encode(e))}catch(e){return x(String(e))}}function Be(t){try{F(t.length>0,"empty byte array cannot be converted to value");let e=new TextDecoder().decode(t),r=JSON.parse(e);return f(r)}catch(e){return x(String(e))}}var Ve=["VP8","VP9","AV1","H264"],Z=class{constructor(e){this.codec=e}channels=0;clockRate=9e4;isValid(){return Ve.includes(this.codec)}isSupported(){if(typeof RTCRtpReceiver>"u"||typeof RTCRtpReceiver.getCapabilities>"u")return null;let e=V(this.getMimeType(),"").toLowerCase(),r=new Set(V(this.getSdpFmtpLine(),"").split(";").map(s=>s.trim().toLowerCase()));return RTCRtpReceiver.getCapabilities("video")?.codecs?.find(s=>{let p=s.mimeType.toLowerCase(),g=new Set((s.sdpFmtpLine??"").split(";").map(m=>m.trim().toLowerCase()));if(e!==p||r.size!==g.size)return!1;for(let m of r)if(!g.has(m))return!1;return!0})??null}getPayloadType(){switch(this.codec){case"VP8":return f(96);case"VP9":return f(98);case"AV1":return f(41);case"H264":return f(102);default:return x("invalid video codec")}}getMimeType(){switch(this.codec){case"VP8":return f("video/VP8");case"VP9":return f("video/VP9");case"AV1":return f("video/AV1");case"H264":return f("video/H264");default:return x("invalid video codec")}}getSdpFmtpLine(){switch(this.codec){case"VP8":return f("");case"VP9":return f("profile-id=2");case"AV1":return f("level-idx=5;profile=0;tier=0");case"H264":return f("level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f");default:return x("invalid video codec")}}};function Je(t,e){for(let r of t)if(e(r))return r}function Ge(){return typeof AudioContext<"u"&&typeof Worker<"u"}function He(){return typeof SharedArrayBuffer<"u"}function ae(){return/(apple)?webkit\/537\.36/i.test(globalThis.navigator.userAgent)}function $e(){return/electron/i.test(globalThis.navigator.userAgent)}function qe(){return/firefox|iceweasel|fxios/i.test(globalThis.navigator.userAgent)}function We(){return ae()?!1:/safari|applewebkit/i.test(globalThis.navigator.userAgent)}function Ze(t){return JSON.parse(JSON.stringify(t))}var K=class t{constructor(e){this._Generators=e;this._Futures=e.map(t.addIndex)}_Futures;async next(){let[e,r]=await Promise.race(this._Futures);return this._Futures[r]=t.addIndex(this._Generators[r],r),e}static async addIndex(e,r){return[await e(),r]}};function Ke(t,e){return t<=0?Promise.resolve(e):new Promise(r=>setTimeout(()=>r(e),t))}function Ye(t,e){return e.aborted?Promise.resolve("aborted"):new Promise(r=>{let s=()=>r("aborted");e.addEventListener("abort",s,{once:!0}),setTimeout(()=>{e.removeEventListener("abort",s),r(void 0)},t)})}function Qe(){return new Promise(t=>setTimeout(t,0))}var Y=class{_Tasks=[];_Running=!1;_Values;constructor(...e){this._Values=e}enqueue(e){return new Promise((r,s)=>{let p=async()=>{try{let g=await e(...this._Values);r(g)}catch(g){s(g)}};this._Tasks.push(p),this._Running||this.execute()})}async execute(){for(this._Running=!0;;){let e=this._Tasks.shift();if(e===void 0)break;await e()}this._Running=!1}};function Xe(t){let e=t.trim();t.indexOf("://")===-1&&(e=`https://${e}`);try{return f(new URL(e))}catch(r){return x(String(r))}}function et(t,e){let r=t.pathname;r.endsWith("/")===!1&&(r+="/");try{return f(new URL(r+e,t))}catch(s){return x(String(s))}}var tt=/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;function rt(){return crypto.randomUUID()}function nt(t){return tt.test(t)}function ot(t,e){return e in t}function it(t){return typeof t=="function"}function at(t){return typeof t=="object"&&t===null}function J(t){return typeof t=="number"}function st(t){return typeof t=="object"}function ct(t){return typeof t=="string"}function pt(t){return typeof t>"u"}function ut(t){return t.type==="Failure"}function dt(t){return t.type==="Success"}var _=(g=>(g[g.NONE=0]="NONE",g[g.ERROR=1]="ERROR",g[g.WARN=2]="WARN",g[g.INFO=3]="INFO",g[g.DEBUG=4]="DEBUG",g))(_||{}),G=Object.values(_).filter(t=>!isNaN(Number(t))),se=Object.keys(_).filter(t=>isNaN(Number(t))),ce={0:"\u26AB",1:"\u{1F534}",2:"\u{1F7E1}",3:"\u{1F535}",4:"\u{1F7E3}"},pe={0:console.log,1:console.error,2:console.warn,3:console.info,4:console.debug};function P(t){let e=_[t];return e===void 0?x(`invalid log level name '${t}'; valid names are: ${se.join(", ")}`):f(e)}function L(t){let e=_[t];return e===void 0?x(`invalid log level ${t}; valid levels are: ${G[0]}-${G[G.length-1]}`):f(e)}var S="default",ue=new Map;function k(t=S){let e=ue.get(t);return e||(e=new H("WARN",t)),e}function lt(t,...e){return t instanceof Function?k(S).error(t,...e):k(S).error(t,...e)}function mt(t,...e){return t instanceof Function?k(S).warn(t,...e):k(S).warn(t,...e)}function ft(t,...e){return t instanceof Function?k(S).info(t,...e):k(S).info(t,...e)}function gt(t,...e){return t instanceof Function?k(S).debug(t,...e):k(S).debug(t,...e)}var H=class{name;_Level;_Handlers;constructor(e,r,s){this.name=r??S,J(e)?this._Level=b(P(b(L(e)))):this._Level=b(P(e)),this._Handlers=s?.handlers||[new $(e)],ue.set(this.name,this)}get level(){return this._Level}set level(e){this.levelName=b(L(e))}get levelName(){return b(L(this._Level))}set levelName(e){this._Level=b(P(e)),this._Handlers.forEach(r=>r.level=this._Level)}get handlers(){return this._Handlers}addHandler(e){this._Handlers.push(e)}removeHandler(e){let r=this._Handlers.indexOf(e);r!==-1&&this._Handlers.splice(r,1)}log(e,r,...s){if(this.level<e)return r instanceof Function?void 0:r;let p,g;return r instanceof Function?(p=r(),g=this.asString(p)):g=this.asString(r),this._Handlers.forEach(m=>{m.handle({date:new Date,level:e,levelName:b(L(e)),logger:this.name,message:g,args:s})}),r instanceof Function?p:r}error(e,...r){return this.log(1,e,...r)}warn(e,...r){return this.log(2,e,...r)}info(e,...r){return this.log(3,e,...r)}debug(e,...r){return this.log(4,e,...r)}asString(e,r=!1){return typeof e=="string"?r?`"${e}"`:e:e===null||typeof e=="number"||typeof e=="bigint"||typeof e=="boolean"||typeof e>"u"||typeof e=="symbol"?String(e):e instanceof Error?e.stack:typeof e=="object"?`{${Object.entries(e).map(([s,p])=>`"${s}":${this.asString(p,!0)}`).join(",")}}`:"undefined"}},de=({message:t})=>t,yt=t=>{let e=`[${t.date.toISOString()}]`,r=`[${t.levelName}]`,s=t.logger!==S?`[${t.logger}] `:"",p=ce[t.level];return`${e} ${p} ${r.padEnd(7," ")} ${s}${t.message}`},$=class{_Level;_FormatterFn;constructor(e,r=de){J(e)?this._Level=b(P(b(L(e)))):this._Level=b(P(e)),this._FormatterFn=r}get level(){return this._Level}set level(e){this.levelName=b(L(e))}get levelName(){return b(L(this._Level))}set levelName(e){this._Level=b(P(e))}handle(e){this._Level<e.level||this.log(this._FormatterFn(e),e)}log(e,r){pe[r.level](e,...r.args)}};var br=-758.596,le;(e=>{let t;(m=>(m[m.InvalidPassword=-1]="InvalidPassword",m[m.Unknown=0]="Unknown",m[m.Unencrypted=1]="Unencrypted",m[m.Encrypted=2]="Encrypted"))(t=e.PeerCipherStatus||={})})(le||={});var xt={bytesSent:0,bytesReceived:0,packetsSent:0,packetsReceived:0,rtt:0,packetLoss:0},bt={packetsBuffered:0,packetsSeen:0,packetsProcessed:0,packetsTooEarly:0,packetsTooLate:0,packetsDropped:0,packetsInvalid:0,packetsRepeated:0,packetsLost:0},vt={voiceActivity:{attackThreshold:.9,releaseThreshold:.8},volumeGate:{attackThreshold:-30,releaseThreshold:-40}},ht={echoCanceller:!0,highPassFilter:!1,noiseSuppression:"Moderate",transientSuppressor:!1,gainController:!0};0&&(module.exports={APM_DEFAULTS,Backend,ByteArraySchema,CONNECTION_STATS_INITIAL,ChannelSet,ChannelSetSchema,DEFAULT_FORMATTER,JITTER_STATS_INITIAL,JsonSchema,LogFunctions,LogHandler,LogLevelNames,LogLevels,LogSymbols,LogVerbosity,Logger,MainCommandsRpc,MainNotificationSchema,MainNotificationsRpc,MediaAudioPropertiesSchema,MediaIdSchema,MediaPropertiesSchema,MediaSchema,MediaVideoPropertiesSchema,MessagePackRpcSchema,MessageReceivedSchema,MinDBFS,PRETTY_FORMATTER,PeerIdSchema,PeerPositionSchema,PeerSchema,PeerUpdateSchema,RoomCommandsRpc,RoomNotificationSchema,RoomNotificationsRpc,RoomV1,RoomV2,Selector,Strand,TokenAudienceSchema,TokenClaimsSchema,TokenSubjectSchema,VAD_DEFAULTS,VideoCodec,WebRtcUpdateSchema,abortableSleep,assert,debug,error,extendUrl,fail,failure,find,fromBase64,fromBase64Url,fromBytes,generateUUID,getLevelByName,getLevelName,getLogger,info,isAudioCapable,isBlinkBrowser,isElectronBrowser,isFailure,isFirefoxBrowser,isFunction,isNull,isNumber,isObject,isProperty,isSafariBrowser,isSharedArrayBufferCapable,isString,isSuccess,isUndefined,nextTick,normalizeUrl,oneOrMany,sleep,success,toBytes,toRaw,unwrap,unwrapOr,validateUUID,warn});
|
package/mod.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as mr from"zod";import{z as l}from"zod";var y=l.custom(t=>t instanceof Uint8Array),se=l.union([l.string(),l.number(),l.boolean(),l.null()]),_=l.lazy(()=>l.union([se,l.array(_),l.record(_)])),ke=l.union([l.tuple([l.literal(0),l.number(),l.string(),l.unknown()]),l.tuple([l.literal(1),l.number(),l.nullable(l.string()),l.unknown()]),l.tuple([l.literal(2),l.string(),l.unknown()])]);import{z as s}from"zod";var ce=s.enum(["sfu","gateway"]),pe=s.enum(["connect","roomclose","roomupdate","roombanclient","roomsendmessage"]),Re=s.object({uid:s.string(),cid:s.optional(s.string()),rid:C(s.string()).refine(t=>t.length>=1,{message:"missing rid"}),nsp:s.optional(s.string()),adr:s.optional(s.string()),aud:s.optional(C(ce)),sub:s.optional(C(pe)),exp:s.optional(s.number()),nbf:s.optional(s.number()),ups:s.optional(s.string()),tgs:s.optional(C(s.string())),tsp:s.optional(s.number()),internal:s.optional(s.object({server:s.optional(s.string())}))});function C(t){return s.union([t.transform(e=>[e]),s.array(t)])}import*as r from"zod";import*as p from"zod";var T=p.number(),ue=p.object({kind:p.optional(p.literal("audio")),uid:p.optional(p.string()),customType:p.optional(p.string())}),de=p.object({kind:p.optional(p.literal("video")),codec:p.optional(p.string()),uid:p.optional(p.string()),customType:p.optional(p.string())}),M=p.union([ue,de]),N=p.object({id:T,properties:M,paused:p.boolean()});import*as u from"zod";var h=u.number(),A=u.union([u.tuple([u.number(),u.number(),u.number()]),u.tuple([u.number(),u.number()])]),U=u.object({id:h,user_id:u.string(),user_data:y,medias:u.array(N)}),I=u.discriminatedUnion("kind",[u.object({kind:u.literal("UserDataChanged"),peer_id:h,user_data:y}),u.object({kind:u.literal("MediaStarted"),peer_id:h,media:N}),u.object({kind:u.literal("MediaStopped"),peer_id:h,media_id:T})]);import*as H from"zod";var O=class t{constructor(e=BigInt(0)){this.value=e}from(...e){let n=e.reduce((c,g)=>c|j(g),BigInt(0));return new t(n)}contains(e){return(this.value&j(e))!==BigInt(0)}insert(e){this.value|=j(e)}remove(e){this.value&=~j(e)}[Symbol.iterator](){let e=-1,n=new t(this.value);return{next(){for(;e<63;)if(e+=1,n.contains(e))return{value:e,done:!1};return{value:void 0,done:!0}}}}},$=H.bigint().transform(t=>new O(t));function j(t){return BigInt(1)<<BigInt(t)}var z;(d=>(d.RoomIdSchema=r.string(),d.RoomSchema=r.object({id:d.RoomIdSchema,customer:r.string(),user_data:y,peers:r.array(U)}),d.RoomUpdateSchema=r.discriminatedUnion("kind",[r.object({kind:r.literal("Joined"),room:d.RoomSchema,media_ids:r.array(T),own_peer_id:h}),r.object({kind:r.literal("Left"),reason:r.enum(["RoomClosing","ServerClosing","PeerKicked"])}),r.object({kind:r.literal("UserDataChanged"),user_data:r.optional(y)}),r.object({kind:r.literal("PeerJoined"),peer:U}),r.object({kind:r.literal("PeerLeft"),peer_id:h})]),d.RoomUpdatesSchema=r.object({updates:r.array(d.RoomUpdateSchema)}),d.RoomStatusSchema=r.enum(["Joining","Joined","Closed"]),d.RoomStatusChangedSchema=r.object({status:d.RoomStatusSchema,message:r.optional(r.string())})))(z||={});var le;(i=>(i.ParametersSchema=r.record(_),i.PeerProperties=r.object({user_data:y.optional(),tags:r.array(r.string()).optional(),audio_parameters:i.ParametersSchema.optional(),video_parameters:i.ParametersSchema.optional()}),i.PingSchema=r.object({Ping:r.object({id:r.number()})}),i.ChangeSelfSchema=r.object({ChangeSelf:i.PeerProperties.omit({tags:!0})}),i.SetAudioMaskSchema=r.object({SetAudioMask:r.object({peer_id:r.number(),mask:$})}),i.SendMessageSchema=r.object({SendMessage:r.object({peer_ids:r.number().array().default([]),message:y})}),i.CallSchema=i.PingSchema.or(i.ChangeSelfSchema).or(i.SetAudioMaskSchema).or(i.SendMessageSchema),i.PongSchema=r.object({Pong:r.object({id:r.number()})}),i.JoinedSchema=r.object({Joined:r.object({own_peer_id:r.number(),room_id:r.string(),customer:r.string()})}),i.LeftSchema=r.object({Left:r.object({reason:r.enum(["room_closing","server_closing","peer_kicked"])})}),i.PeerJoinedSchema=r.object({PeerJoined:i.PeerProperties.extend({peer_id:r.number(),user_id:r.string()})}),i.PeerLeftSchema=r.object({PeerLeft:r.object({peer_id:r.number()})}),i.PeerChangedSchema=r.object({PeerChanged:i.PeerProperties.extend({peer_id:r.number()})}),i.NewReconnectTokenSchema=r.object({NewReconnectToken:r.object({token:r.string()})}),i.MessageReceivedSchema=r.object({MessageReceived:r.object({sender_peer_id:r.number(),message:y})}),i.ErrorSchema=r.object({Error:r.object({message:y})}),i.EventSchema=i.PongSchema.or(i.JoinedSchema).or(i.LeftSchema).or(i.PeerJoinedSchema).or(i.PeerLeftSchema).or(i.PeerChangedSchema).or(i.NewReconnectTokenSchema).or(i.MessageReceivedSchema).or(i.ErrorSchema)))(le||={});import{z as me}from"zod";var E=me.object({sender_peer_id:h,message:y});import*as a from"zod";var R=a.discriminatedUnion("kind",[a.object({kind:a.literal("Sdp"),type:a.enum(["Answer","Offer"]),sdp:a.string(),media_map:a.array(a.tuple([T,a.string()]))}),a.object({kind:a.literal("Trickle"),candidate:a.string(),spd_mid:a.optional(a.string()),spd_mline_index:a.optional(a.number()),username_fragment:a.optional(a.union([a.string(),a.null()]))}),a.object({kind:a.literal("TrickleFinished")})]);import{z as o}from"zod";var Ye={Hello:{request:o.object({stream:o.literal("main")}),response:o.null()},JoinRoom:{request:o.object({token:o.string(),room_id:z.RoomIdSchema,user_data:y,position:A}),response:o.object({peer_id:h,stream_id:o.optional(o.number()),token:o.optional(o.string())})},WebRtcUpdate:{request:R,response:o.null()},RequestReconnectToken:{request:o.object({peer_id:o.optional(h)}),response:o.string()},Ping:{request:o.object({}),response:o.null()}},Qe={Hello:{request:o.object({stream:o.literal("room"),token:o.string(),room_id:o.string(),user_data:y,position:A}),response:o.null()},UpdatePeer:{request:o.object({user_data:y}),response:o.null()},StartMedia:{request:o.object({media_id:T,properties:M}),response:o.null()},StopMedia:{request:o.object({media_id:T}),response:o.null()},PauseMedia:{request:o.object({media_id:T}),response:o.null()},ResumeMedia:{request:o.object({media_id:T}),response:o.null()},SetPeerPosition:{request:o.object({position:A}),response:o.null()},SendMessage:{request:o.object({target_peer_ids:o.optional(o.array(h)),message:y}),response:o.null()}};import*as b from"zod";var ot=b.object({name:b.literal("WebRtcUpdate"),properties:R}),it={WebRtcUpdate:R},at=b.union([b.object({name:b.literal("RoomStatusChanged"),properties:z.RoomStatusChangedSchema}),b.object({name:b.literal("RoomUpdated"),properties:z.RoomUpdatesSchema}),b.object({name:b.literal("PeerUpdated"),properties:I}),b.object({name:b.literal("MessageReceived"),properties:E})]),st={RoomStatusChanged:z.RoomStatusChangedSchema,RoomUpdated:z.RoomUpdatesSchema,PeerUpdated:I,MessageReceived:E};function F(t,e){t||q(e)}function q(t){throw new Error(t)}function m(t){return{type:"Success",value:t}}function x(t){return{type:"Failure",reason:t}}function v(t){return t.type==="Failure"&&q(t.reason),t.value}function D(t,e){return t.type==="Success"?t.value:e}function dt(t){try{let e=atob(t),n=Uint8Array.from(e,g=>g.codePointAt(0)),c=new TextDecoder("utf8");return m(c.decode(n))}catch(e){return x(String(e))}}function lt(t){try{let e=atob(t.replace(/-/g,"+").replace(/_/g,"/")),n=Uint8Array.from(e,g=>g.codePointAt(0)),c=new TextDecoder("utf8");return m(c.decode(n))}catch(e){return x(String(e))}}function gt(t){try{F(t!==void 0,"undefined cannot be converted to byte array"),F(t!==null,"null cannot be converted to byte array");let e=JSON.stringify(t),n=new TextEncoder;return m(n.encode(e))}catch(e){return x(String(e))}}function yt(t){try{F(t.length>0,"empty byte array cannot be converted to value");let e=new TextDecoder().decode(t),n=JSON.parse(e);return m(n)}catch(e){return x(String(e))}}var fe=["VP8","VP9","AV1","H264"],W=class{constructor(e){this.codec=e}channels=0;clockRate=9e4;isValid(){return fe.includes(this.codec)}isSupported(){if(typeof RTCRtpReceiver>"u"||typeof RTCRtpReceiver.getCapabilities>"u")return null;let e=D(this.getMimeType(),"").toLowerCase(),n=new Set(D(this.getSdpFmtpLine(),"").split(";").map(c=>c.trim().toLowerCase()));return RTCRtpReceiver.getCapabilities("video")?.codecs?.find(c=>{let g=c.mimeType.toLowerCase(),f=new Set((c.sdpFmtpLine??"").split(";").map(d=>d.trim().toLowerCase()));if(e!==g||n.size!==f.size)return!1;for(let d of n)if(!f.has(d))return!1;return!0})??null}getPayloadType(){switch(this.codec){case"VP8":return m(96);case"VP9":return m(98);case"AV1":return m(41);case"H264":return m(102);default:return x("invalid video codec")}}getMimeType(){switch(this.codec){case"VP8":return m("video/VP8");case"VP9":return m("video/VP9");case"AV1":return m("video/AV1");case"H264":return m("video/H264");default:return x("invalid video codec")}}getSdpFmtpLine(){switch(this.codec){case"VP8":return m("");case"VP9":return m("profile-id=2");case"AV1":return m("level-idx=5;profile=0;tier=0");case"H264":return m("level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f");default:return x("invalid video codec")}}};function ht(t,e){for(let n of t)if(e(n))return n}function St(){return typeof AudioContext<"u"&&typeof Worker<"u"}function zt(){return typeof SharedArrayBuffer<"u"}function ge(){return/(apple)?webkit\/537\.36/i.test(globalThis.navigator.userAgent)}function kt(){return/electron/i.test(globalThis.navigator.userAgent)}function Lt(){return/firefox|iceweasel|fxios/i.test(globalThis.navigator.userAgent)}function Pt(){return ge()?!1:/safari|applewebkit/i.test(globalThis.navigator.userAgent)}function wt(t){return JSON.parse(JSON.stringify(t))}var Z=class t{constructor(e){this._Generators=e;this._Futures=e.map(t.addIndex)}_Futures;async next(){let[e,n]=await Promise.race(this._Futures);return this._Futures[n]=t.addIndex(this._Generators[n],n),e}static async addIndex(e,n){return[await e(),n]}};function At(t,e){return t<=0?Promise.resolve(e):new Promise(n=>setTimeout(()=>n(e),t))}function jt(t,e){return e.aborted?Promise.resolve("aborted"):new Promise(n=>{let c=()=>n("aborted");e.addEventListener("abort",c,{once:!0}),setTimeout(()=>{e.removeEventListener("abort",c),n(void 0)},t)})}function Ft(){return new Promise(t=>setTimeout(t,0))}var K=class{_Tasks=[];_Running=!1;_Values;constructor(...e){this._Values=e}enqueue(e){return new Promise((n,c)=>{let g=async()=>{try{let f=await e(...this._Values);n(f)}catch(f){c(f)}};this._Tasks.push(g),this._Running||this.execute()})}async execute(){for(this._Running=!0;;){let e=this._Tasks.shift();if(e===void 0)break;await e()}this._Running=!1}};function It(t){let e=t.trim();t.indexOf("://")===-1&&(e=`https://${e}`);try{return m(new URL(e))}catch(n){return x(String(n))}}function Ot(t,e){let n=t.pathname;n.endsWith("/")===!1&&(n+="/");try{return m(new URL(n+e,t))}catch(c){return x(String(c))}}var ye=/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;function Dt(){return crypto.randomUUID()}function Bt(t){return ye.test(t)}function Jt(t,e){return e in t}function Gt(t){return typeof t=="function"}function Ht(t){return typeof t=="object"&&t===null}function B(t){return typeof t=="number"}function $t(t){return typeof t=="object"}function qt(t){return typeof t=="string"}function Wt(t){return typeof t>"u"}function Zt(t){return t.type==="Failure"}function Kt(t){return t.type==="Success"}var w=(f=>(f[f.NONE=0]="NONE",f[f.ERROR=1]="ERROR",f[f.WARN=2]="WARN",f[f.INFO=3]="INFO",f[f.DEBUG=4]="DEBUG",f))(w||{}),V=Object.values(w).filter(t=>!isNaN(Number(t))),xe=Object.keys(w).filter(t=>isNaN(Number(t))),be={0:"\u26AB",1:"\u{1F534}",2:"\u{1F7E1}",3:"\u{1F535}",4:"\u{1F7E3}"},ve={0:console.log,1:console.error,2:console.warn,3:console.info,4:console.debug};function P(t){let e=w[t];return e===void 0?x(`invalid log level name '${t}'; valid names are: ${xe.join(", ")}`):m(e)}function L(t){let e=w[t];return e===void 0?x(`invalid log level ${t}; valid levels are: ${V[0]}-${V[V.length-1]}`):m(e)}var S="default",Y=new Map;function k(t=S){let e=Y.get(t);return e||(e=new J("WARN",t)),e}function er(t,...e){return t instanceof Function?k(S).error(t,...e):k(S).error(t,...e)}function tr(t,...e){return t instanceof Function?k(S).warn(t,...e):k(S).warn(t,...e)}function rr(t,...e){return t instanceof Function?k(S).info(t,...e):k(S).info(t,...e)}function nr(t,...e){return t instanceof Function?k(S).debug(t,...e):k(S).debug(t,...e)}var J=class{name;_Level;_Handlers;constructor(e,n,c){this.name=n??S,B(e)?this._Level=v(P(v(L(e)))):this._Level=v(P(e)),this._Handlers=c?.handlers||[new G(e)],Y.set(this.name,this)}get level(){return this._Level}set level(e){this.levelName=v(L(e))}get levelName(){return v(L(this._Level))}set levelName(e){this._Level=v(P(e)),this._Handlers.forEach(n=>n.level=this._Level)}get handlers(){return this._Handlers}addHandler(e){this._Handlers.push(e)}removeHandler(e){let n=this._Handlers.indexOf(e);n!==-1&&this._Handlers.splice(n,1)}log(e,n,...c){if(this.level<e)return n instanceof Function?void 0:n;let g,f;return n instanceof Function?(g=n(),f=this.asString(g)):f=this.asString(n),this._Handlers.forEach(d=>{d.handle({date:new Date,level:e,levelName:v(L(e)),logger:this.name,message:f,args:c})}),n instanceof Function?g:n}error(e,...n){return this.log(1,e,...n)}warn(e,...n){return this.log(2,e,...n)}info(e,...n){return this.log(3,e,...n)}debug(e,...n){return this.log(4,e,...n)}asString(e,n=!1){return typeof e=="string"?n?`"${e}"`:e:e===null||typeof e=="number"||typeof e=="bigint"||typeof e=="boolean"||typeof e>"u"||typeof e=="symbol"?String(e):e instanceof Error?e.stack:typeof e=="object"?`{${Object.entries(e).map(([c,g])=>`"${c}":${this.asString(g,!0)}`).join(",")}}`:"undefined"}},he=({message:t})=>t,or=t=>{let e=`[${t.date.toISOString()}]`,n=`[${t.levelName}]`,c=t.logger!==S?`[${t.logger}] `:"",g=be[t.level];return`${e} ${g} ${n.padEnd(7," ")} ${c}${t.message}`},G=class{_Level;_FormatterFn;constructor(e,n=he){B(e)?this._Level=v(P(v(L(e)))):this._Level=v(P(e)),this._FormatterFn=n}get level(){return this._Level}set level(e){this.levelName=v(L(e))}get levelName(){return v(L(this._Level))}set levelName(e){this._Level=v(P(e))}handle(e){this._Level<e.level||this.log(this._FormatterFn(e),e)}log(e,n){ve[n.level](e,...n.args)}};var ar=-758.596,Te;(e=>{let t;(d=>(d[d.InvalidPassword=-1]="InvalidPassword",d[d.Unknown=0]="Unknown",d[d.Unencrypted=1]="Unencrypted",d[d.Encrypted=2]="Encrypted"))(t=e.PeerCipherStatus||={})})(Te||={});var sr={bytesSent:0,bytesReceived:0,packetsSent:0,packetsReceived:0,rtt:0,packetLoss:0},cr={packetsBuffered:0,packetsSeen:0,packetsProcessed:0,packetsTooEarly:0,packetsTooLate:0,packetsDropped:0,packetsInvalid:0,packetsRepeated:0,packetsLost:0},pr={voiceActivity:{attackThreshold:.9,releaseThreshold:.8},volumeGate:{attackThreshold:-30,releaseThreshold:-40}},ur={echoCanceller:!0,highPassFilter:!1,noiseSuppression:"Moderate",transientSuppressor:!1,gainController:!0};export{ur as APM_DEFAULTS,Te as Backend,y as ByteArraySchema,sr as CONNECTION_STATS_INITIAL,O as ChannelSet,$ as ChannelSetSchema,he as DEFAULT_FORMATTER,cr as JITTER_STATS_INITIAL,_ as JsonSchema,ve as LogFunctions,G as LogHandler,xe as LogLevelNames,V as LogLevels,be as LogSymbols,w as LogVerbosity,J as Logger,Ye as MainCommandsRpc,ot as MainNotificationSchema,it as MainNotificationsRpc,ue as MediaAudioPropertiesSchema,T as MediaIdSchema,M as MediaPropertiesSchema,N as MediaSchema,de as MediaVideoPropertiesSchema,ke as MessagePackRpcSchema,E as MessageReceivedSchema,ar as MinDBFS,or as PRETTY_FORMATTER,h as PeerIdSchema,A as PeerPositionSchema,U as PeerSchema,I as PeerUpdateSchema,Qe as RoomCommandsRpc,at as RoomNotificationSchema,st as RoomNotificationsRpc,z as RoomV1,le as RoomV2,Z as Selector,K as Strand,ce as TokenAudienceSchema,Re as TokenClaimsSchema,pe as TokenSubjectSchema,pr as VAD_DEFAULTS,W as VideoCodec,R as WebRtcUpdateSchema,jt as abortableSleep,F as assert,nr as debug,er as error,Ot as extendUrl,q as fail,x as failure,ht as find,dt as fromBase64,lt as fromBase64Url,yt as fromBytes,Dt as generateUUID,P as getLevelByName,L as getLevelName,k as getLogger,rr as info,St as isAudioCapable,ge as isBlinkBrowser,kt as isElectronBrowser,Zt as isFailure,Lt as isFirefoxBrowser,Gt as isFunction,Ht as isNull,B as isNumber,$t as isObject,Jt as isProperty,Pt as isSafariBrowser,zt as isSharedArrayBufferCapable,qt as isString,Kt as isSuccess,Wt as isUndefined,Ft as nextTick,It as normalizeUrl,C as oneOrMany,At as sleep,m as success,gt as toBytes,wt as toRaw,v as unwrap,D as unwrapOr,Bt as validateUUID,tr as warn,mr as zod};
|
|
1
|
+
import{z as l}from"zod";var y=l.custom(t=>t instanceof Uint8Array),se=l.union([l.string(),l.number(),l.boolean(),l.null()]),_=l.lazy(()=>l.union([se,l.array(_),l.record(_)])),ke=l.union([l.tuple([l.literal(0),l.number(),l.string(),l.unknown()]),l.tuple([l.literal(1),l.number(),l.nullable(l.string()),l.unknown()]),l.tuple([l.literal(2),l.string(),l.unknown()])]);import{z as s}from"zod";var ce=s.enum(["sfu","gateway"]),pe=s.enum(["connect","roomclose","roomupdate","roombanclient","roomsendmessage"]),Re=s.object({uid:s.string(),cid:s.optional(s.string()),rid:C(s.string()).refine(t=>t.length>=1,{message:"missing rid"}),nsp:s.optional(s.string()),adr:s.optional(s.string()),aud:s.optional(C(ce)),sub:s.optional(C(pe)),exp:s.optional(s.number()),nbf:s.optional(s.number()),ups:s.optional(s.string()),tgs:s.optional(C(s.string())),tsp:s.optional(s.number()),internal:s.optional(s.object({server:s.optional(s.string())}))});function C(t){return s.union([t.transform(e=>[e]),s.array(t)])}import*as r from"zod";import*as p from"zod";var T=p.number(),ue=p.object({kind:p.optional(p.literal("audio")),uid:p.optional(p.string()),customType:p.optional(p.string())}),de=p.object({kind:p.optional(p.literal("video")),codec:p.optional(p.string()),uid:p.optional(p.string()),customType:p.optional(p.string())}),M=p.union([ue,de]),N=p.object({id:T,properties:M,paused:p.boolean()});import*as u from"zod";var h=u.number(),A=u.union([u.tuple([u.number(),u.number(),u.number()]),u.tuple([u.number(),u.number()])]),U=u.object({id:h,user_id:u.string(),user_data:y,medias:u.array(N)}),I=u.discriminatedUnion("kind",[u.object({kind:u.literal("UserDataChanged"),peer_id:h,user_data:y}),u.object({kind:u.literal("MediaStarted"),peer_id:h,media:N}),u.object({kind:u.literal("MediaStopped"),peer_id:h,media_id:T})]);import*as H from"zod";var O=class t{constructor(e=BigInt(0)){this.value=e}from(...e){let n=e.reduce((c,g)=>c|j(g),BigInt(0));return new t(n)}contains(e){return(this.value&j(e))!==BigInt(0)}insert(e){this.value|=j(e)}remove(e){this.value&=~j(e)}[Symbol.iterator](){let e=-1,n=new t(this.value);return{next(){for(;e<63;)if(e+=1,n.contains(e))return{value:e,done:!1};return{value:void 0,done:!0}}}}},$=H.bigint().transform(t=>new O(t));function j(t){return BigInt(1)<<BigInt(t)}var z;(d=>(d.RoomIdSchema=r.string(),d.RoomSchema=r.object({id:d.RoomIdSchema,customer:r.string(),user_data:y,peers:r.array(U)}),d.RoomUpdateSchema=r.discriminatedUnion("kind",[r.object({kind:r.literal("Joined"),room:d.RoomSchema,media_ids:r.array(T),own_peer_id:h}),r.object({kind:r.literal("Left"),reason:r.enum(["RoomClosing","ServerClosing","PeerKicked"])}),r.object({kind:r.literal("UserDataChanged"),user_data:r.optional(y)}),r.object({kind:r.literal("PeerJoined"),peer:U}),r.object({kind:r.literal("PeerLeft"),peer_id:h})]),d.RoomUpdatesSchema=r.object({updates:r.array(d.RoomUpdateSchema)}),d.RoomStatusSchema=r.enum(["Joining","Joined","Closed"]),d.RoomStatusChangedSchema=r.object({status:d.RoomStatusSchema,message:r.optional(r.string())})))(z||={});var le;(i=>(i.ParametersSchema=r.record(_),i.PeerProperties=r.object({user_data:y.optional(),tags:r.array(r.string()).optional(),audio_parameters:i.ParametersSchema.optional(),video_parameters:i.ParametersSchema.optional()}),i.PingSchema=r.object({Ping:r.object({id:r.number()})}),i.ChangeSelfSchema=r.object({ChangeSelf:i.PeerProperties.omit({tags:!0})}),i.SetAudioMaskSchema=r.object({SetAudioMask:r.object({peer_id:r.number(),mask:$})}),i.SendMessageSchema=r.object({SendMessage:r.object({peer_ids:r.number().array().default([]),message:y})}),i.CallSchema=i.PingSchema.or(i.ChangeSelfSchema).or(i.SetAudioMaskSchema).or(i.SendMessageSchema),i.PongSchema=r.object({Pong:r.object({id:r.number()})}),i.JoinedSchema=r.object({Joined:r.object({own_peer_id:r.number(),room_id:r.string(),customer:r.string()})}),i.LeftSchema=r.object({Left:r.object({reason:r.enum(["room_closing","server_closing","peer_kicked"])})}),i.PeerJoinedSchema=r.object({PeerJoined:i.PeerProperties.extend({peer_id:r.number(),user_id:r.string()})}),i.PeerLeftSchema=r.object({PeerLeft:r.object({peer_id:r.number()})}),i.PeerChangedSchema=r.object({PeerChanged:i.PeerProperties.extend({peer_id:r.number()})}),i.NewReconnectTokenSchema=r.object({NewReconnectToken:r.object({token:r.string()})}),i.MessageReceivedSchema=r.object({MessageReceived:r.object({sender_peer_id:r.number(),message:y})}),i.ErrorSchema=r.object({Error:r.object({message:y})}),i.EventSchema=i.PongSchema.or(i.JoinedSchema).or(i.LeftSchema).or(i.PeerJoinedSchema).or(i.PeerLeftSchema).or(i.PeerChangedSchema).or(i.NewReconnectTokenSchema).or(i.MessageReceivedSchema).or(i.ErrorSchema)))(le||={});import{z as me}from"zod";var E=me.object({sender_peer_id:h,message:y});import*as a from"zod";var R=a.discriminatedUnion("kind",[a.object({kind:a.literal("Sdp"),type:a.enum(["Answer","Offer"]),sdp:a.string(),media_map:a.array(a.tuple([T,a.string()]))}),a.object({kind:a.literal("Trickle"),candidate:a.string(),spd_mid:a.optional(a.string()),spd_mline_index:a.optional(a.number()),username_fragment:a.optional(a.union([a.string(),a.null()]))}),a.object({kind:a.literal("TrickleFinished")})]);import{z as o}from"zod";var Ye={Hello:{request:o.object({stream:o.literal("main")}),response:o.null()},JoinRoom:{request:o.object({token:o.string(),room_id:z.RoomIdSchema,user_data:y,position:A}),response:o.object({peer_id:h,stream_id:o.optional(o.number()),token:o.optional(o.string())})},WebRtcUpdate:{request:R,response:o.null()},RequestReconnectToken:{request:o.object({peer_id:o.optional(h)}),response:o.string()},Ping:{request:o.object({}),response:o.null()}},Qe={Hello:{request:o.object({stream:o.literal("room"),token:o.string(),room_id:o.string(),user_data:y,position:A}),response:o.null()},UpdatePeer:{request:o.object({user_data:y}),response:o.null()},StartMedia:{request:o.object({media_id:T,properties:M}),response:o.null()},StopMedia:{request:o.object({media_id:T}),response:o.null()},PauseMedia:{request:o.object({media_id:T}),response:o.null()},ResumeMedia:{request:o.object({media_id:T}),response:o.null()},SetPeerPosition:{request:o.object({position:A}),response:o.null()},SendMessage:{request:o.object({target_peer_ids:o.optional(o.array(h)),message:y}),response:o.null()}};import*as b from"zod";var ot=b.object({name:b.literal("WebRtcUpdate"),properties:R}),it={WebRtcUpdate:R},at=b.union([b.object({name:b.literal("RoomStatusChanged"),properties:z.RoomStatusChangedSchema}),b.object({name:b.literal("RoomUpdated"),properties:z.RoomUpdatesSchema}),b.object({name:b.literal("PeerUpdated"),properties:I}),b.object({name:b.literal("MessageReceived"),properties:E})]),st={RoomStatusChanged:z.RoomStatusChangedSchema,RoomUpdated:z.RoomUpdatesSchema,PeerUpdated:I,MessageReceived:E};function F(t,e){t||q(e)}function q(t){throw new Error(t)}function m(t){return{type:"Success",value:t}}function x(t){return{type:"Failure",reason:t}}function v(t){return t.type==="Failure"&&q(t.reason),t.value}function D(t,e){return t.type==="Success"?t.value:e}function dt(t){try{let e=atob(t),n=Uint8Array.from(e,g=>g.codePointAt(0)),c=new TextDecoder("utf8");return m(c.decode(n))}catch(e){return x(String(e))}}function lt(t){try{let e=atob(t.replace(/-/g,"+").replace(/_/g,"/")),n=Uint8Array.from(e,g=>g.codePointAt(0)),c=new TextDecoder("utf8");return m(c.decode(n))}catch(e){return x(String(e))}}function gt(t){try{F(t!==void 0,"undefined cannot be converted to byte array"),F(t!==null,"null cannot be converted to byte array");let e=JSON.stringify(t),n=new TextEncoder;return m(n.encode(e))}catch(e){return x(String(e))}}function yt(t){try{F(t.length>0,"empty byte array cannot be converted to value");let e=new TextDecoder().decode(t),n=JSON.parse(e);return m(n)}catch(e){return x(String(e))}}var fe=["VP8","VP9","AV1","H264"],W=class{constructor(e){this.codec=e}channels=0;clockRate=9e4;isValid(){return fe.includes(this.codec)}isSupported(){if(typeof RTCRtpReceiver>"u"||typeof RTCRtpReceiver.getCapabilities>"u")return null;let e=D(this.getMimeType(),"").toLowerCase(),n=new Set(D(this.getSdpFmtpLine(),"").split(";").map(c=>c.trim().toLowerCase()));return RTCRtpReceiver.getCapabilities("video")?.codecs?.find(c=>{let g=c.mimeType.toLowerCase(),f=new Set((c.sdpFmtpLine??"").split(";").map(d=>d.trim().toLowerCase()));if(e!==g||n.size!==f.size)return!1;for(let d of n)if(!f.has(d))return!1;return!0})??null}getPayloadType(){switch(this.codec){case"VP8":return m(96);case"VP9":return m(98);case"AV1":return m(41);case"H264":return m(102);default:return x("invalid video codec")}}getMimeType(){switch(this.codec){case"VP8":return m("video/VP8");case"VP9":return m("video/VP9");case"AV1":return m("video/AV1");case"H264":return m("video/H264");default:return x("invalid video codec")}}getSdpFmtpLine(){switch(this.codec){case"VP8":return m("");case"VP9":return m("profile-id=2");case"AV1":return m("level-idx=5;profile=0;tier=0");case"H264":return m("level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f");default:return x("invalid video codec")}}};function ht(t,e){for(let n of t)if(e(n))return n}function St(){return typeof AudioContext<"u"&&typeof Worker<"u"}function zt(){return typeof SharedArrayBuffer<"u"}function ge(){return/(apple)?webkit\/537\.36/i.test(globalThis.navigator.userAgent)}function kt(){return/electron/i.test(globalThis.navigator.userAgent)}function Lt(){return/firefox|iceweasel|fxios/i.test(globalThis.navigator.userAgent)}function Pt(){return ge()?!1:/safari|applewebkit/i.test(globalThis.navigator.userAgent)}function wt(t){return JSON.parse(JSON.stringify(t))}var Z=class t{constructor(e){this._Generators=e;this._Futures=e.map(t.addIndex)}_Futures;async next(){let[e,n]=await Promise.race(this._Futures);return this._Futures[n]=t.addIndex(this._Generators[n],n),e}static async addIndex(e,n){return[await e(),n]}};function At(t,e){return t<=0?Promise.resolve(e):new Promise(n=>setTimeout(()=>n(e),t))}function jt(t,e){return e.aborted?Promise.resolve("aborted"):new Promise(n=>{let c=()=>n("aborted");e.addEventListener("abort",c,{once:!0}),setTimeout(()=>{e.removeEventListener("abort",c),n(void 0)},t)})}function Ft(){return new Promise(t=>setTimeout(t,0))}var K=class{_Tasks=[];_Running=!1;_Values;constructor(...e){this._Values=e}enqueue(e){return new Promise((n,c)=>{let g=async()=>{try{let f=await e(...this._Values);n(f)}catch(f){c(f)}};this._Tasks.push(g),this._Running||this.execute()})}async execute(){for(this._Running=!0;;){let e=this._Tasks.shift();if(e===void 0)break;await e()}this._Running=!1}};function It(t){let e=t.trim();t.indexOf("://")===-1&&(e=`https://${e}`);try{return m(new URL(e))}catch(n){return x(String(n))}}function Ot(t,e){let n=t.pathname;n.endsWith("/")===!1&&(n+="/");try{return m(new URL(n+e,t))}catch(c){return x(String(c))}}var ye=/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;function Dt(){return crypto.randomUUID()}function Bt(t){return ye.test(t)}function Jt(t,e){return e in t}function Gt(t){return typeof t=="function"}function Ht(t){return typeof t=="object"&&t===null}function B(t){return typeof t=="number"}function $t(t){return typeof t=="object"}function qt(t){return typeof t=="string"}function Wt(t){return typeof t>"u"}function Zt(t){return t.type==="Failure"}function Kt(t){return t.type==="Success"}var w=(f=>(f[f.NONE=0]="NONE",f[f.ERROR=1]="ERROR",f[f.WARN=2]="WARN",f[f.INFO=3]="INFO",f[f.DEBUG=4]="DEBUG",f))(w||{}),V=Object.values(w).filter(t=>!isNaN(Number(t))),xe=Object.keys(w).filter(t=>isNaN(Number(t))),be={0:"\u26AB",1:"\u{1F534}",2:"\u{1F7E1}",3:"\u{1F535}",4:"\u{1F7E3}"},ve={0:console.log,1:console.error,2:console.warn,3:console.info,4:console.debug};function P(t){let e=w[t];return e===void 0?x(`invalid log level name '${t}'; valid names are: ${xe.join(", ")}`):m(e)}function L(t){let e=w[t];return e===void 0?x(`invalid log level ${t}; valid levels are: ${V[0]}-${V[V.length-1]}`):m(e)}var S="default",Y=new Map;function k(t=S){let e=Y.get(t);return e||(e=new J("WARN",t)),e}function er(t,...e){return t instanceof Function?k(S).error(t,...e):k(S).error(t,...e)}function tr(t,...e){return t instanceof Function?k(S).warn(t,...e):k(S).warn(t,...e)}function rr(t,...e){return t instanceof Function?k(S).info(t,...e):k(S).info(t,...e)}function nr(t,...e){return t instanceof Function?k(S).debug(t,...e):k(S).debug(t,...e)}var J=class{name;_Level;_Handlers;constructor(e,n,c){this.name=n??S,B(e)?this._Level=v(P(v(L(e)))):this._Level=v(P(e)),this._Handlers=c?.handlers||[new G(e)],Y.set(this.name,this)}get level(){return this._Level}set level(e){this.levelName=v(L(e))}get levelName(){return v(L(this._Level))}set levelName(e){this._Level=v(P(e)),this._Handlers.forEach(n=>n.level=this._Level)}get handlers(){return this._Handlers}addHandler(e){this._Handlers.push(e)}removeHandler(e){let n=this._Handlers.indexOf(e);n!==-1&&this._Handlers.splice(n,1)}log(e,n,...c){if(this.level<e)return n instanceof Function?void 0:n;let g,f;return n instanceof Function?(g=n(),f=this.asString(g)):f=this.asString(n),this._Handlers.forEach(d=>{d.handle({date:new Date,level:e,levelName:v(L(e)),logger:this.name,message:f,args:c})}),n instanceof Function?g:n}error(e,...n){return this.log(1,e,...n)}warn(e,...n){return this.log(2,e,...n)}info(e,...n){return this.log(3,e,...n)}debug(e,...n){return this.log(4,e,...n)}asString(e,n=!1){return typeof e=="string"?n?`"${e}"`:e:e===null||typeof e=="number"||typeof e=="bigint"||typeof e=="boolean"||typeof e>"u"||typeof e=="symbol"?String(e):e instanceof Error?e.stack:typeof e=="object"?`{${Object.entries(e).map(([c,g])=>`"${c}":${this.asString(g,!0)}`).join(",")}}`:"undefined"}},he=({message:t})=>t,or=t=>{let e=`[${t.date.toISOString()}]`,n=`[${t.levelName}]`,c=t.logger!==S?`[${t.logger}] `:"",g=be[t.level];return`${e} ${g} ${n.padEnd(7," ")} ${c}${t.message}`},G=class{_Level;_FormatterFn;constructor(e,n=he){B(e)?this._Level=v(P(v(L(e)))):this._Level=v(P(e)),this._FormatterFn=n}get level(){return this._Level}set level(e){this.levelName=v(L(e))}get levelName(){return v(L(this._Level))}set levelName(e){this._Level=v(P(e))}handle(e){this._Level<e.level||this.log(this._FormatterFn(e),e)}log(e,n){ve[n.level](e,...n.args)}};var ar=-758.596,Te;(e=>{let t;(d=>(d[d.InvalidPassword=-1]="InvalidPassword",d[d.Unknown=0]="Unknown",d[d.Unencrypted=1]="Unencrypted",d[d.Encrypted=2]="Encrypted"))(t=e.PeerCipherStatus||={})})(Te||={});var sr={bytesSent:0,bytesReceived:0,packetsSent:0,packetsReceived:0,rtt:0,packetLoss:0},cr={packetsBuffered:0,packetsSeen:0,packetsProcessed:0,packetsTooEarly:0,packetsTooLate:0,packetsDropped:0,packetsInvalid:0,packetsRepeated:0,packetsLost:0},pr={voiceActivity:{attackThreshold:.9,releaseThreshold:.8},volumeGate:{attackThreshold:-30,releaseThreshold:-40}},ur={echoCanceller:!0,highPassFilter:!1,noiseSuppression:"Moderate",transientSuppressor:!1,gainController:!0};export{ur as APM_DEFAULTS,Te as Backend,y as ByteArraySchema,sr as CONNECTION_STATS_INITIAL,O as ChannelSet,$ as ChannelSetSchema,he as DEFAULT_FORMATTER,cr as JITTER_STATS_INITIAL,_ as JsonSchema,ve as LogFunctions,G as LogHandler,xe as LogLevelNames,V as LogLevels,be as LogSymbols,w as LogVerbosity,J as Logger,Ye as MainCommandsRpc,ot as MainNotificationSchema,it as MainNotificationsRpc,ue as MediaAudioPropertiesSchema,T as MediaIdSchema,M as MediaPropertiesSchema,N as MediaSchema,de as MediaVideoPropertiesSchema,ke as MessagePackRpcSchema,E as MessageReceivedSchema,ar as MinDBFS,or as PRETTY_FORMATTER,h as PeerIdSchema,A as PeerPositionSchema,U as PeerSchema,I as PeerUpdateSchema,Qe as RoomCommandsRpc,at as RoomNotificationSchema,st as RoomNotificationsRpc,z as RoomV1,le as RoomV2,Z as Selector,K as Strand,ce as TokenAudienceSchema,Re as TokenClaimsSchema,pe as TokenSubjectSchema,pr as VAD_DEFAULTS,W as VideoCodec,R as WebRtcUpdateSchema,jt as abortableSleep,F as assert,nr as debug,er as error,Ot as extendUrl,q as fail,x as failure,ht as find,dt as fromBase64,lt as fromBase64Url,yt as fromBytes,Dt as generateUUID,P as getLevelByName,L as getLevelName,k as getLogger,rr as info,St as isAudioCapable,ge as isBlinkBrowser,kt as isElectronBrowser,Zt as isFailure,Lt as isFirefoxBrowser,Gt as isFunction,Ht as isNull,B as isNumber,$t as isObject,Jt as isProperty,Pt as isSafariBrowser,zt as isSharedArrayBufferCapable,qt as isString,Kt as isSuccess,Wt as isUndefined,Ft as nextTick,It as normalizeUrl,C as oneOrMany,At as sleep,m as success,gt as toBytes,wt as toRaw,v as unwrap,D as unwrapOr,Bt as validateUUID,tr as warn};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@4players/odin-common",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.3.1",
|
|
4
4
|
"description": "A collection of commonly used type definitions and utility functions across ODIN web projects",
|
|
5
5
|
"author": "Josho Bleicker <josho.bleicker@4players.io> (https://www.4players.io)",
|
|
6
6
|
"homepage": "https://www.4players.io",
|
|
@@ -14,10 +14,19 @@
|
|
|
14
14
|
],
|
|
15
15
|
"private": false,
|
|
16
16
|
"license": "ISC",
|
|
17
|
-
"
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
"export": {
|
|
18
|
+
".": {
|
|
19
|
+
"main": "./mod.js",
|
|
20
|
+
"module": "./mod.mjs",
|
|
21
|
+
"types": "./mod.d.ts"
|
|
22
|
+
},
|
|
23
|
+
"./zod": {
|
|
24
|
+
"main": "./zod/mod.js",
|
|
25
|
+
"module": "./zod/mod.mjs",
|
|
26
|
+
"types": "./zod/mod.d.ts"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
20
29
|
"dependencies": {
|
|
21
|
-
"zod": "
|
|
30
|
+
"zod": "~3.25.0"
|
|
22
31
|
}
|
|
23
32
|
}
|
package/zod/mod.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * as zod from 'zod';
|
package/zod/mod.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var p=Object.create;var e=Object.defineProperty;var s=Object.getOwnPropertyDescriptor;var t=Object.getOwnPropertyNames;var x=Object.getPrototypeOf,z=Object.prototype.hasOwnProperty;var b=(o,r)=>{for(var a in r)e(o,a,{get:r[a],enumerable:!0})},m=(o,r,a,f)=>{if(r&&typeof r=="object"||typeof r=="function")for(let d of t(r))!z.call(o,d)&&d!==a&&e(o,d,{get:()=>r[d],enumerable:!(f=s(r,d))||f.enumerable});return o};var c=(o,r,a)=>(a=o!=null?p(x(o)):{},m(r||!o||!o.__esModule?e(a,"default",{value:o,enumerable:!0}):a,o)),g=o=>m(e({},"__esModule",{value:!0}),o);var h={};b(h,{zod:()=>i});module.exports=g(h);var i=c(require("zod"));0&&(module.exports={zod});
|
package/zod/mod.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import*as r from"zod";export{r as zod};
|