mirror of
https://github.com/darksaid98/auto-changelog.git
synced 2026-12-04 14:38:48 +00:00
chore: update commitlint config
Signed-off-by: Ardalan Amini <[email protected]>
This commit is contained in:
7 files changed
+78
-130
No files matched your search
+3
-7
@@ -1,8 +1,4 @@
|
||||
require('./sourcemap-register.js');(()=>{var __webpack_modules__={1037:(e,t,a)=>{"use strict";Object.defineProperty(t,"__esModule",{value:true});t.generateChangelog=void 0;const s=a(9093);const r=a(6622);function trim(e){if(e==null)return e;return e.trim().replace(/ {2,}/g," ")}function unique(e){return[...new Set(e)]}function sortBy(e,t){return e.sort(((e,a)=>e[t].localeCompare(a[t])))}async function generateChangelog(e){const{paginate:t,rest:a}=(0,r.octokit)();const{owner:i,repo:p,url:n}=(0,r.repository)();const o=(0,r.defaultCommitType)();const d=(0,r.commitTypes)();const l=(0,r.includePRLinks)();const m=(0,r.includeCommitLinks)();const c=(0,r.mentionAuthors)();const u=(0,r.useGithubAutolink)();const h=t.iterator(a.repos.listCommits,{per_page:100,sha:(0,r.sha)(),owner:i,repo:p});const g=[];e:for await(const{data:t}of h){for(const a of t){if(a.sha===e)break e;const t=a.commit.message.split("\n")[0];(0,s.debug)(`commit message -> ${t}`);let{type:i,scope:p,description:h,pr:v,flag:w,breaking:y}=(0,r.parseCommitMessage)(t);if(!h)continue;h=trim(h);w=trim(w);if(w==="ignore")continue;i=d[trim(i??"")]??o;let b=g.find((e=>e.type===i));if(b==null){b={type:i,scopes:[]};g.push(b)}p=trim(p??"");let E=b.scopes.find((e=>e.scope===p));if(E==null){E={scope:p,logs:[]};b.scopes.push(E)}let _=E.logs.find((e=>e.description===h));if(_==null){_={breaking:y,description:h,references:[]};E.logs.push(_)}const T=[];if(v&&l)T.push(u?`#${v}`:`[#${v}](${n}/issues/${v})`);else if(m)T.push(u?a.sha:`\`[${a.sha}](${n}/commit/${a.sha})\``);const k=a.author?.login;if(k&&c){const e=`by @${k}`;T.push(e);const t=_.references[_.references.length-1];if(t?.endsWith(e)){_.references.push(_.references.pop().replace(e,`& ${T.join(" ")}`));continue}}if(T.length>0)_.references.push(T.join(" "))}}const v=unique(Object.values(d).concat(o));const w=[];for(const e of v){const t=g.find((t=>t.type===e));if(t==null)continue;w.push(`## ${e}`);sortBy(t.scopes,"scope");for(const{scope:e,logs:a}of t.scopes){let t="";if(e.length>0){w.push(`* **${e}:**`);t=" "}for(const{breaking:e,description:s,references:r}of a){let a=`${t}* ${e?"***breaking:*** ":""}${s}`;if(r.length>0)a+=` (${r.join(", ")})`;w.push(a)}}w.push("")}return w.join("\n")}t.generateChangelog=generateChangelog},1054:(e,t,a)=>{"use strict";Object.defineProperty(t,"__esModule",{value:true});t.generateFooter=void 0;const s=a(346);const r=a(6622);async function generateFooter(e){const{owner:t,repo:a,url:i}=(0,r.repository)();const p=(0,r.releaseName)();const n=[];if((0,r.mentionNewContributors)()){const{rest:i}=(0,r.octokit)();const{data:o}=await i.repos.generateReleaseNotes({owner:t,repo:a,tag_name:p,previous_tag_name:e});const d=s.marked.lexer(o.body);const l=d.findIndex((e=>e.type==="heading"&&e.text==="New Contributors"));const m=d[l+1];if(m.type==="list")n.push(`## New Contributors\n${m.raw}\n`)}if((0,r.includeCompareLink)()&&e){let t=`${i}/compare/${e}...${p}`;if(!(0,r.useGithubAutolink)()||(0,r.releaseNamePrefix)())t=`\`[${e}...${p}](${i}/compare/${e}...${p})\``;n.push(`**Full Changelog**: ${t}`)}if(n.length>0)n.unshift("");return n.join("\n\n")}t.generateFooter=generateFooter},9806:(e,t,a)=>{"use strict";Object.defineProperty(t,"__esModule",{value:true});t.getTagInfo=void 0;const s=a(6622);async function getTagInfo(){const{paginate:e,rest:t}=(0,s.octokit)();const{owner:a,repo:r}=(0,s.repository)();const i={releaseId:"latest",prerelease:false};let p=null;if((0,s.semver)()){p=(0,s.parseSemVer)();if(p==null)throw new Error(`Expected a semver compatible releaseName, got "${(0,s.releaseName)()}" instead.`);i.prerelease=p.prerelease.length>0;if(i.prerelease)i.releaseId=`${p.prerelease[0]}`}const n=e.iterator(t.repos.listTags,{per_page:100,owner:a,repo:r});e:for await(const{data:e}of n){for(const{name:t,commit:a}of e){if((0,s.sha)()===a.sha)continue;if(p==null){i.previous={name:t,sha:a.sha};break e}const e=(0,s.parseSemVer)(t);if(e==null||p.compare(e)<=0)continue;if(e.prerelease.length>0&&!i.prerelease)continue;i.previous={name:t,sha:a.sha};break e}}return i}t.getTagInfo=getTagInfo},9024:(e,t,a)=>{"use strict";Object.defineProperty(t,"__esModule",{value:true});t.booleanInput=void 0;const s=a(9093);const r=a(3231);function booleanInput(e,t=true){return(0,r.cache)(e,(()=>(0,s.getBooleanInput)(e,{required:t})))}t.booleanInput=booleanInput},3231:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:true});t.cache=void 0;const a=new Map;function cache(e,t,s=false){if(!a.has(e)||s)a.set(e,t());return a.get(e)}t.cache=cache},6622:function(e,t,a){"use strict";var s=this&&this.__createBinding||(Object.create?function(e,t,a,s){if(s===undefined)s=a;var r=Object.getOwnPropertyDescriptor(t,a);if(!r||("get"in r?!t.__esModule:r.writable||r.configurable)){r={enumerable:true,get:function(){return t[a]}}}Object.defineProperty(e,s,r)}:function(e,t,a,s){if(s===undefined)s=a;e[s]=t[a]});var r=this&&this.__exportStar||function(e,t){for(var a in e)if(a!=="default"&&!Object.prototype.hasOwnProperty.call(t,a))s(t,e,Line truncated
|
||||
/*!
|
||||
* is-plain-object <https://github.com/jonschlinkert/is-plain-object>
|
||||
*
|
||||
* Copyright (c) 2014-2017, Jon Schlinkert.
|
||||
* Released under the MIT License.
|
||||
*/function isObject(e){return Object.prototype.toString.call(e)==="[object Object]"}function isPlainObject(e){var t,a;if(isObject(e)===false)return false;t=e.constructor;if(t===undefined)return true;a=t.prototype;if(isObject(a)===false)return false;if(a.hasOwnProperty("isPrototypeOf")===false){return false}return true}t.isPlainObject=isPlainObject},3918:(e,t,a)=>{"use strict";const s=a(901);const r=Symbol("max");const i=Symbol("length");const p=Symbol("lengthCalculator");const n=Symbol("allowStale");const o=Symbol("maxAge");const d=Symbol("dispose");const l=Symbol("noDisposeOnSet");const m=Symbol("lruList");const c=Symbol("cache");const u=Symbol("updateAgeOnGet");const naiveLength=()=>1;class LRUCache{constructor(e){if(typeof e==="number")e={max:e};if(!e)e={};if(e.max&&(typeof e.max!=="number"||e.max<0))throw new TypeError("max must be a non-negative number");const t=this[r]=e.max||Infinity;const a=e.length||naiveLength;this[p]=typeof a!=="function"?naiveLength:a;this[n]=e.stale||false;if(e.maxAge&&typeof e.maxAge!=="number")throw new TypeError("maxAge must be a number");this[o]=e.maxAge||0;this[d]=e.dispose;this[l]=e.noDisposeOnSet||false;this[u]=e.updateAgeOnGet||false;this.reset()}set max(e){if(typeof e!=="number"||e<0)throw new TypeError("max must be a non-negative number");this[r]=e||Infinity;trim(this)}get max(){return this[r]}set allowStale(e){this[n]=!!e}get allowStale(){return this[n]}set maxAge(e){if(typeof e!=="number")throw new TypeError("maxAge must be a non-negative number");this[o]=e;trim(this)}get maxAge(){return this[o]}set lengthCalculator(e){if(typeof e!=="function")e=naiveLength;if(e!==this[p]){this[p]=e;this[i]=0;this[m].forEach((e=>{e.length=this[p](e.value,e.key);this[i]+=e.length}))}trim(this)}get lengthCalculator(){return this[p]}get length(){return this[i]}get itemCount(){return this[m].length}rforEach(e,t){t=t||this;for(let a=this[m].tail;a!==null;){const s=a.prev;forEachStep(this,e,a,t);a=s}}forEach(e,t){t=t||this;for(let a=this[m].head;a!==null;){const s=a.next;forEachStep(this,e,a,t);a=s}}keys(){return this[m].toArray().map((e=>e.key))}values(){return this[m].toArray().map((e=>e.value))}reset(){if(this[d]&&this[m]&&this[m].length){this[m].forEach((e=>this[d](e.key,e.value)))}this[c]=new Map;this[m]=new s;this[i]=0}dump(){return this[m].map((e=>isStale(this,e)?false:{k:e.key,v:e.value,e:e.now+(e.maxAge||0)})).toArray().filter((e=>e))}dumpLru(){return this[m]}set(e,t,a){a=a||this[o];if(a&&typeof a!=="number")throw new TypeError("maxAge must be a number");const s=a?Date.now():0;const n=this[p](t,e);if(this[c].has(e)){if(n>this[r]){del(this,this[c].get(e));return false}const p=this[c].get(e);const o=p.value;if(this[d]){if(!this[l])this[d](e,o.value)}o.now=s;o.maxAge=a;o.value=t;this[i]+=n-o.length;o.length=n;this.get(e);trim(this);return true}const u=new Entry(e,t,n,s,a);if(u.length>this[r]){if(this[d])this[d](e,t);return false}this[i]+=u.length;this[m].unshift(u);this[c].set(e,this[m].head);trim(this);return true}has(e){if(!this[c].has(e))return false;const t=this[c].get(e).value;return!isStale(this,t)}get(e){return get(this,e,true)}peek(e){return get(this,e,false)}pop(){const e=this[m].tail;if(!e)return null;del(this,e);return e.value}del(e){del(this,this[c].get(e))}load(e){this.reset();const t=Date.now();for(let a=e.length-1;a>=0;a--){const s=e[a];const r=s.e||0;if(r===0)this.set(s.k,s.v);else{const e=r-t;if(e>0){this.set(s.k,s.v,e)}}}}prune(){this[c].forEach(((e,t)=>get(this,t,false)))}}const get=(e,t,a)=>{const s=e[c].get(t);if(s){const t=s.value;if(isStale(e,t)){del(e,s);if(!e[n])return undefined}else{if(a){if(e[u])s.value.now=Date.now();e[m].unshiftNode(s)}}return t.value}};const isStale=(e,t)=>{if(!t||!t.maxAge&&!e[o])return false;const a=Date.now()-t.now;return t.maxAge?a>t.maxAge:e[o]&&a>e[o]};const trim=e=>{if(e[i]>e[r]){for(let t=e[m].tail;e[i]>e[r]&&t!==null;){const a=t.prev;del(e,t);t=a}}};const del=(e,t)=>{if(t){const a=t.value;if(e[d])e[d](a.key,a.value);e[i]-=a.length;e[c].delete(a.key);e[m].removeNode(t)}};class Entry{constructor(e,t,a,s,r){this.key=e;this.value=t;this.length=a;this.now=s;this.maxAge=r||0}}const forEachStep=(e,t,a,s)=>{let r=a.value;if(isStale(e,r)){del(e,a);if(!e[n])r=undefined}if(r)t.call(s,r.value,r.key,e)};e.exports=LRUCache},2595:(e,t,a)=>{"use strict";Object.defineProperty(t,"__esModule",{value:true});function _interopDefault(e){return e&&typeof e==="object"&&"default"in e?e["default"]:e}var s=_interopDefault(a(2781));var r=_interopDefault(a(3685));var i=_interopDefault(a(7310));var p=_interopDefault(a(872));var n=_interopDefault(a(5687));var o=_interopDefault(a(9796));const d=s.Readable;const l=Symbol("buffer");const m=Symbol("type");class Blob{constructor(){this[m]="";const e=arguments[0];const t=arguments[1];const a=[];let s=0;if(e){const t=e;const r=Number(t.length);for(let e=0;e<r;e++){const r=t[e];let i;if(r instanceof Buffer){i=r}else if(ArrayBuffer.isView(r)){i=Buffer.from(r.buffer,r.byteOffset,r.byteLength)}else if(r instanceof ArLine truncated
|
||||
require('./sourcemap-register.js');(()=>{var e={1037:(e,t,A)=>{"use strict";Object.defineProperty(t,"__esModule",{value:true});t.generateChangelog=void 0;const s=A(9093);const r=A(6622);function trim(e){if(e==null)return e;return e.trim().replace(/ {2,}/g," ")}function unique(e){return[...new Set(e)]}function sortBy(e,t){return e.sort(((e,A)=>e[t].localeCompare(A[t])))}async function generateChangelog(e){const{paginate:t,rest:A}=(0,r.octokit)();const{owner:n,repo:o,url:i}=(0,r.repository)();const a=(0,r.defaultCommitType)();const c=(0,r.commitTypes)();const l=(0,r.includePRLinks)();const g=(0,r.includeCommitLinks)();const u=(0,r.mentionAuthors)();const h=(0,r.useGithubAutolink)();const E=t.iterator(A.repos.listCommits,{per_page:100,sha:(0,r.sha)(),owner:n,repo:o});const d=[];e:for await(const{data:t}of E){for(const A of t){if(A.sha===e)break e;const t=A.commit.message.split("\n")[0];(0,s.debug)(`commit message -> ${t}`);let{type:n,scope:o,description:E,pr:p,flag:C,breaking:Q}=(0,r.parseCommitMessage)(t);if(!E)continue;E=trim(E);C=trim(C);if(C==="ignore")continue;n=c[trim(n??"")]??a;let B=d.find((e=>e.type===n));if(B==null){B={type:n,scopes:[]};d.push(B)}o=trim(o??"");let I=B.scopes.find((e=>e.scope===o));if(I==null){I={scope:o,logs:[]};B.scopes.push(I)}let m=I.logs.find((e=>e.description===E));if(m==null){m={breaking:Q,description:E,references:[]};I.logs.push(m)}const y=[];if(p&&l)y.push(h?`#${p}`:`[#${p}](${i}/issues/${p})`);else if(g)y.push(h?A.sha:`\`[${A.sha}](${i}/commit/${A.sha})\``);const w=A.author?.login;if(w&&u){const e=`by @${w}`;y.push(e);const t=m.references[m.references.length-1];if(t?.endsWith(e)){m.references.push(m.references.pop().replace(e,`& ${y.join(" ")}`));continue}}if(y.length>0)m.references.push(y.join(" "))}}const p=unique(Object.values(c).concat(a));const C=[];for(const e of p){const t=d.find((t=>t.type===e));if(t==null)continue;C.push(`## ${e}`);sortBy(t.scopes,"scope");for(const{scope:e,logs:A}of t.scopes){let t="";if(e.length>0){C.push(`* **${e}:**`);t=" "}for(const{breaking:e,description:s,references:r}of A){let A=`${t}* ${e?"***breaking:*** ":""}${s}`;if(r.length>0)A+=` (${r.join(", ")})`;C.push(A)}}C.push("")}return C.join("\n")}t.generateChangelog=generateChangelog},1054:(e,t,A)=>{"use strict";Object.defineProperty(t,"__esModule",{value:true});t.generateFooter=void 0;const s=A(346);const r=A(6622);async function generateFooter(e){const{owner:t,repo:A,url:n}=(0,r.repository)();const o=(0,r.releaseName)();const i=[];if((0,r.mentionNewContributors)()){const{rest:n}=(0,r.octokit)();const{data:a}=await n.repos.generateReleaseNotes({owner:t,repo:A,tag_name:o,previous_tag_name:e});const c=s.marked.lexer(a.body);const l=c.findIndex((e=>e.type==="heading"&&e.text==="New Contributors"));const g=c[l+1];if(g.type==="list")i.push(`## New Contributors\n${g.raw}\n`)}if((0,r.includeCompareLink)()&&e){let t=`${n}/compare/${e}...${o}`;if(!(0,r.useGithubAutolink)()||(0,r.releaseNamePrefix)())t=`\`[${e}...${o}](${n}/compare/${e}...${o})\``;i.push(`**Full Changelog**: ${t}`)}if(i.length>0)i.unshift("");return i.join("\n\n")}t.generateFooter=generateFooter},9806:(e,t,A)=>{"use strict";Object.defineProperty(t,"__esModule",{value:true});t.getTagInfo=void 0;const s=A(6622);async function getTagInfo(){const{paginate:e,rest:t}=(0,s.octokit)();const{owner:A,repo:r}=(0,s.repository)();const n={releaseId:"latest",prerelease:false};let o=null;if((0,s.semver)()){o=(0,s.parseSemVer)();if(o==null)throw new Error(`Expected a semver compatible releaseName, got "${(0,s.releaseName)()}" instead.`);n.prerelease=o.prerelease.length>0;if(n.prerelease)n.releaseId=`${o.prerelease[0]}`}const i=e.iterator(t.repos.listTags,{per_page:100,owner:A,repo:r});e:for await(const{data:e}of i){for(const{name:t,commit:A}of e){if((0,s.sha)()===A.sha)continue;if(o==null){n.previous={name:t,sha:A.sha};break e}const e=(0,s.parseSemVer)(t);if(e==null||o.compare(e)<=0)continue;if(e.prerelease.length>0&&!n.prerelease)continue;n.previous={name:t,sha:A.sha};break e}}return n}t.getTagInfo=getTagInfo},9024:(e,t,A)=>{"use strict";Object.defineProperty(t,"__esModule",{value:true});t.booleanInput=void 0;const s=A(9093);const r=A(3231);function booleanInput(e,t=true){return(0,r.cache)(e,(()=>(0,s.getBooleanInput)(e,{required:t})))}t.booleanInput=booleanInput},3231:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:true});t.cache=void 0;const A=new Map;function cache(e,t,s=false){if(!A.has(e)||s)A.set(e,t());return A.get(e)}t.cache=cache},6622:function(e,t,A){"use strict";var s=this&&this.__createBinding||(Object.create?function(e,t,A,s){if(s===undefined)s=A;var r=Object.getOwnPropertyDescriptor(t,A);if(!r||("get"in r?!t.__esModule:r.writable||r.configurable)){r={enumerable:true,get:function(){return t[A]}}}Object.defineProperty(e,s,r)}:function(e,t,A,s){if(s===undefined)s=A;e[s]=t[A]});var r=this&&this.__exportStar||function(e,t){for(var A in e)if(A!=="default"&&!Object.prototype.hasOwnProperty.call(t,A))s(t,e,A)};Object.definePLine truncated
|
||||
/*! formdata-polyfill. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */;const escape=e=>e.replace(/\n/g,"%0A").replace(/\r/g,"%0D").replace(/"/g,"%22");const normalizeLinefeeds=e=>e.replace(/\r?\n|\r/g,"\r\n");const s=[];const r=new Uint8Array([13,10]);g=0;let n=false;for(const[t,o]of e){if(typeof o==="string"){const e=S.encode(A+`; name="${escape(normalizeLinefeeds(t))}"`+`\r\n\r\n${normalizeLinefeeds(o)}\r\n`);s.push(e);g+=e.byteLength}else{const e=S.encode(`${A}; name="${escape(normalizeLinefeeds(t))}"`+(o.name?`; filename="${escape(o.name)}"`:"")+"\r\n"+`Content-Type: ${o.type||"application/octet-stream"}\r\n\r\n`);s.push(e,o,r);if(typeof o.size==="number"){g+=e.byteLength+o.size+r.byteLength}else{n=true}}}const o=S.encode(`--${t}--`);s.push(o);g+=o.byteLength;if(n){g=null}l=e;c=async function*(){for(const e of s){if(e.stream){yield*e.stream()}else{yield e}}};u="multipart/form-data; boundary="+t}else if(o(e)){l=e;g=e.size;if(e.type){u=e.type}}else if(typeof e[Symbol.asyncIterator]==="function"){if(t){throw new TypeError("keepalive")}if(r.isDisturbed(e)||e.locked){throw new TypeError("Response body object should not be disturbed or locked")}s=e instanceof R?e:n(e)}if(typeof l==="string"||r.isBuffer(l)){g=Buffer.byteLength(l)}if(c!=null){let t;s=new R({async start(){t=c(e)[Symbol.asyncIterator]()},async pull(e){const{value:A,done:r}=await t.next();if(r){queueMicrotask((()=>{e.close()}))}else{if(!I(s)){e.enqueue(new Uint8Array(A))}}return e.desiredSize>0},async cancel(e){await t.return()},type:undefined})}const h={stream:s,source:l,length:g};return[h,u]}function safelyExtractBody(e,t=false){if(!R){R=A(5356).ReadableStream}if(e instanceof R){B(!r.isDisturbed(e),"The body has already been consumed.");B(!e.locked,"The stream is locked.")}return extractBody(e,t)}function cloneBody(e){const[t,A]=e.stream.tee();const s=d(A,{transfer:[A]});const[,r]=s.tee();e.stream=t;return{stream:r,length:e.length,source:e.source}}async function*consumeBody(e){if(e){if(m(e)){yield e}else{const t=e.stream;if(r.isDisturbed(t)){throw new TypeError("The body has already been consumed.")}if(t.locked){throw new TypeError("The stream is locked.")}t[Q]=true;yield*t}}}function throwIfAborted(e){if(e.aborted){throw new E("The operation was aborted.","AbortError")}}function bodyMixinMethods(e){const t={blob(){return specConsumeBody(this,(e=>{let t=bodyMimeType(this);if(t==="failure"){t=""}else if(t){t=b(t)}return new p([e],{type:t})}),e)},arrayBuffer(){return specConsumeBody(this,(e=>new Uint8Array(e).buffer),e)},text(){return specConsumeBody(this,utf8DecodeBytes,e)},json(){return specConsumeBody(this,parseJSONFromBytes,e)},async formData(){h.brandCheck(this,e);throwIfAborted(this[u]);const t=this.headers.get("Content-Type");if(/multipart\/form-data/.test(t)){const e={};for(const[t,A]of this.headers)e[t.toLowerCase()]=A;const t=new g;let A;try{A=new s({headers:e,preservePath:true})}catch(e){throw new E(`${e}`,"AbortError")}A.on("field",((e,A)=>{t.append(e,A)}));A.on("file",((e,A,s,r,n)=>{const o=[];if(r==="base64"||r.toLowerCase()==="base64"){let r="";A.on("data",(e=>{r+=e.toString().replace(/[\r\n]/gm,"");const t=r.length-r.length%4;o.push(Buffer.from(r.slice(0,t),"base64"));r=r.slice(t)}));A.on("end",(()=>{o.push(Buffer.from(r,"base64"));t.append(e,new D(o,s,{type:n}))}))}else{A.on("data",(e=>{o.push(e)}));A.on("end",(()=>{t.append(e,new D(o,s,{type:n}))}))}}));const r=new Promise(((e,t)=>{A.on("finish",e);A.on("error",(e=>t(new TypeError(e))))}));if(this.body!==null)for await(const e of consumeBody(this[u].body))A.write(e);A.end();await r;return t}else if(/application\/x-www-form-urlencoded/.test(t)){let e;try{let t="";const A=new TextDecoder("utf-8",{ignoreBOM:true});for await(const e of consumeBody(this[u].body)){if(!m(e)){throw new TypeError("Expected Uint8Array chunk")}t+=A.decode(e,{stream:true})}t+=A.decode();e=new URLSearchParams(t)}catch(e){throw Object.assign(new TypeError,{cause:e})}const t=new g;for(const[A,s]of e){t.append(A,s)}return t}else{await Promise.resolve();throwIfAborted(this[u]);throw h.errors.exception({header:`${e.name}.formData`,message:"Could not parse content as FormData."})}}};return t}function mixinBody(e){Object.assign(e.prototype,bodyMixinMethods(e))}async function specConsumeBody(e,t,A){h.brandCheck(e,A);throwIfAborted(e[u]);if(bodyUnusable(e[u].body)){throw new TypeError("Body is unusable")}const s=c();const errorSteps=e=>s.reject(e);const successSteps=e=>{try{s.resolve(t(e))}catch(e){errorSteps(e)}};if(e[u].body==null){successSteps(new Uint8Array);return s.promise}await l(e[u].body,successSteps,errorSteps);return s.promise}function bodyUnusable(e){return e!=null&&(e.stream.locked||r.isDisturbed(e.stream))}function utf8DecodeBytes(e){if(e.length===0){return""}if(e[0]===239&&e[1]===187&&e[2]===191){e=e.subarray(3)}const t=T.decode(e);return t}function parseJSONFromBytes(e){return JSON.parse(utf8DecodeBytes(e))}function bodyMimeType(e){const{headersList:t}=e[u];const A=t.get("content-Line truncated
|
||||
/*! ws. MIT License. Einar Otto Stangvik <[email protected]> */n[r-4]=this.maskKey[0];n[r-3]=this.maskKey[1];n[r-2]=this.maskKey[2];n[r-1]=this.maskKey[3];n[1]=A;if(A===126){n.writeUInt16BE(t,2)}else if(A===127){n[2]=n[3]=0;n.writeUIntBE(t,4,6)}n[1]|=128;for(let e=0;e<t;e++){n[r+e]=this.frameData[e]^this.maskKey[e%4]}return n}}e.exports={WebsocketFrameSend:WebsocketFrameSend}},4657:(e,t,A)=>{"use strict";const{Writable:s}=A(2781);const r=A(7643);const{parserStates:n,opcodes:o,states:i,emptyBuffer:a}=A(1974);const{kReadyState:c,kSentClose:l,kResponse:g,kReceivedClose:u}=A(2605);const{isValidStatusCode:h,failWebsocketConnection:E,websocketMessageReceived:d}=A(1744);const{WebsocketFrameSend:p}=A(2052);const C={};C.ping=r.channel("undici:websocket:ping");C.pong=r.channel("undici:websocket:pong");class ByteParser extends s{#o=[];#i=0;#a=n.INFO;#c={};#l=[];constructor(e){super();this.ws=e}_write(e,t,A){this.#o.push(e);this.#i+=e.length;this.run(A)}run(e){while(true){if(this.#a===n.INFO){if(this.#i<2){return e()}const t=this.consume(2);this.#c.fin=(t[0]&128)!==0;this.#c.opcode=t[0]&15;this.#c.originalOpcode??=this.#c.opcode;this.#c.fragmented=!this.#c.fin&&this.#c.opcode!==o.CONTINUATION;if(this.#c.fragmented&&this.#c.opcode!==o.BINARY&&this.#c.opcode!==o.TEXT){E(this.ws,"Invalid frame type was fragmented.");return}const A=t[1]&127;if(A<=125){this.#c.payloadLength=A;this.#a=n.READ_DATA}else if(A===126){this.#a=n.PAYLOADLENGTH_16}else if(A===127){this.#a=n.PAYLOADLENGTH_64}if(this.#c.fragmented&&A>125){E(this.ws,"Fragmented frame exceeded 125 bytes.");return}else if((this.#c.opcode===o.PING||this.#c.opcode===o.PONG||this.#c.opcode===o.CLOSE)&&A>125){E(this.ws,"Payload length for control frame exceeded 125 bytes.");return}else if(this.#c.opcode===o.CLOSE){if(A===1){E(this.ws,"Received close frame with a 1-byte body.");return}const e=this.consume(A);this.#c.closeInfo=this.parseCloseBody(false,e);if(!this.ws[l]){const e=Buffer.allocUnsafe(2);e.writeUInt16BE(this.#c.closeInfo.code,0);const t=new p(e);this.ws[g].socket.write(t.createFrame(o.CLOSE),(e=>{if(!e){this.ws[l]=true}}))}this.ws[c]=i.CLOSING;this.ws[u]=true;this.end();return}else if(this.#c.opcode===o.PING){const t=this.consume(A);if(!this.ws[u]){const e=new p(t);this.ws[g].socket.write(e.createFrame(o.PONG));if(C.ping.hasSubscribers){C.ping.publish({payload:t})}}this.#a=n.INFO;if(this.#i>0){continue}else{e();return}}else if(this.#c.opcode===o.PONG){const t=this.consume(A);if(C.pong.hasSubscribers){C.pong.publish({payload:t})}if(this.#i>0){continue}else{e();return}}}else if(this.#a===n.PAYLOADLENGTH_16){if(this.#i<2){return e()}const t=this.consume(2);this.#c.payloadLength=t.readUInt16BE(0);this.#a=n.READ_DATA}else if(this.#a===n.PAYLOADLENGTH_64){if(this.#i<8){return e()}const t=this.consume(8);const A=t.readUInt32BE(0);if(A>2**31-1){E(this.ws,"Received payload length > 2^31 bytes.");return}const s=t.readUInt32BE(4);this.#c.payloadLength=(A<<8)+s;this.#a=n.READ_DATA}else if(this.#a===n.READ_DATA){if(this.#i<this.#c.payloadLength){return e()}else if(this.#i>=this.#c.payloadLength){const e=this.consume(this.#c.payloadLength);this.#l.push(e);if(!this.#c.fragmented||this.#c.fin&&this.#c.opcode===o.CONTINUATION){const e=Buffer.concat(this.#l);d(this.ws,this.#c.originalOpcode,e);this.#c={};this.#l.length=0}this.#a=n.INFO}}if(this.#i>0){continue}else{e();break}}}consume(e){if(e>this.#i){return null}else if(e===0){return a}if(this.#o[0].length===e){this.#i-=this.#o[0].length;return this.#o.shift()}const t=Buffer.allocUnsafe(e);let A=0;while(A!==e){const s=this.#o[0];const{length:r}=s;if(r+A===e){t.set(this.#o.shift(),A);break}else if(r+A>e){t.set(s.subarray(0,e-A),A);this.#o[0]=s.subarray(e-A);break}else{t.set(this.#o.shift(),A);A+=s.length}}this.#i-=e;return t}parseCloseBody(e,t){let A;if(t.length>=2){A=t.readUInt16BE(0)}if(e){if(!h(A)){return null}return{code:A}}let s=t.subarray(2);if(s[0]===239&&s[1]===187&&s[2]===191){s=s.subarray(3)}if(A!==undefined&&!h(A)){return null}try{s=new TextDecoder("utf-8",{fatal:true}).decode(s)}catch{return null}return{code:A,reason:s}}get closingInfo(){return this.#c.closeInfo}}e.exports={ByteParser:ByteParser}},2605:e=>{"use strict";e.exports={kWebSocketURL:Symbol("url"),kReadyState:Symbol("ready state"),kController:Symbol("controller"),kResponse:Symbol("response"),kBinaryType:Symbol("binary type"),kSentClose:Symbol("sent close"),kReceivedClose:Symbol("received close"),kByteParser:Symbol("byte parser")}},1744:(e,t,A)=>{"use strict";const{kReadyState:s,kController:r,kResponse:n,kBinaryType:o,kWebSocketURL:i}=A(2605);const{states:a,opcodes:c}=A(1974);const{MessageEvent:l,ErrorEvent:g}=A(9382);function isEstablished(e){return e[s]===a.OPEN}function isClosing(e){return e[s]===a.CLOSING}function isClosed(e){return e[s]===a.CLOSED}function fireEvent(e,t,A=Event,s){const r=new A(e,s);t.dispatchEvent(r)}function websocketMessageReceived(e,t,A){if(e[s]!==a.OPEN){return}let r;if(t===c.TEXT){try{r=new TextDecoder("utf-8",{fatal:true}).decode(A)Line truncated
|
||||
//# sourceMappingURL=index.js.map
|
||||
Reference in new issue
Block a user