rsnext/packages/next/compiled/comment-json/index.js

7 lines
154 KiB
JavaScript
Raw Normal View History

(()=>{var e={45:(e,t,i)=>{const r=i(342);const{isObject:s,isArray:n}=i(487);const a="before";const o="after-prop";const u="after-colon";const h="after-value";const c="after-comma";const l=[a,o,u,h,c];const p=":";const f=undefined;const symbol=(e,t)=>Symbol.for(e+p+t);const assign_comments=(e,t,i,s,n,a)=>{const o=symbol(n,s);if(!r(t,o)){return}const u=i===s?o:symbol(n,i);e[u]=t[o];if(a){delete t[o]}};const assign=(e,t,i)=>{i.forEach((i=>{if(!r(t,i)){return}e[i]=t[i];l.forEach((r=>{assign_comments(e,t,i,i,r)}))}));return e};const swap_comments=(e,t,i)=>{if(t===i){return}l.forEach((s=>{const n=symbol(s,i);if(!r(e,n)){assign_comments(e,e,i,t,s);return}const a=e[n];assign_comments(e,e,i,t,s);e[symbol(s,t)]=a}))};const reverse_comments=e=>{const{length:t}=e;let i=0;const r=t/2;for(;i<r;i++){swap_comments(e,i,t-i-1)}};const move_comment=(e,t,i,r,s)=>{l.forEach((n=>{assign_comments(e,t,i+r,i,n,s)}))};const move_comments=(e,t,i,r,s,n)=>{if(s>0){let a=r;while(a-- >0){move_comment(e,t,i+a,s,n&&a<s)}return}let a=0;const o=r+s;while(a<r){const r=a++;move_comment(e,t,i+r,s,n&&a>=o)}};class CommentArray extends Array{splice(...e){const{length:t}=this;const i=super.splice(...e);let[r,s,...n]=e;if(r<0){r+=t}if(arguments.length===1){s=t-r}else{s=Math.min(t-r,s)}const{length:a}=n;const o=a-s;const u=r+s;const h=t-u;move_comments(this,this,u,h,o,true);return i}slice(...e){const{length:t}=this;const i=super.slice(...e);if(!i.length){return new CommentArray}let[r,s]=e;if(s===f){s=t}else if(s<0){s+=t}if(r<0){r+=t}else if(r===f){r=0}move_comments(i,this,r,s-r,-r);return i}unshift(...e){const{length:t}=this;const i=super.unshift(...e);const{length:r}=e;if(r>0){move_comments(this,this,0,t,r,true)}return i}shift(){const e=super.shift();const{length:t}=this;move_comments(this,this,1,t,-1,true);return e}reverse(){super.reverse();reverse_comments(this);return this}pop(){const e=super.pop();const{length:t}=this;l.forEach((e=>{const i=symbol(e,t);delete this[i]}));return e}concat(...e){let{length:t}=this;const i=super.concat(...e);if(!e.length){return i}e.forEach((e=>{const r=t;t+=n(e)?e.length:1;if(!(e instanceof CommentArray)){return}move_comments(i,e,0,e.length,r)}));return i}}e.exports={CommentArray:CommentArray,assign(e,t,i){if(!s(e)){throw new TypeError("Cannot convert undefined or null to object")}if(!s(t)){return e}if(i===f){i=Object.keys(t)}else if(!n(i)){throw new TypeError("keys must be array or undefined")}return assign(e,t,i)},PREFIX_BEFORE:a,PREFIX_AFTER_PROP:o,PREFIX_AFTER_COLON:u,PREFIX_AFTER_VALUE:h,PREFIX_AFTER_COMMA:c,COLON:p,UNDEFINED:f}},946:(e,t,i)=>{const{parse:r,tokenize:s}=i(368);const n=i(382);const{CommentArray:a,assign:o}=i(45);e.exports={parse:r,stringify:n,tokenize:s,CommentArray:a,assign:o}},368:(e,t,i)=>{const r=i(44);const{CommentArray:s,PREFIX_BEFORE:n,PREFIX_AFTER_PROP:a,PREFIX_AFTER_COLON:o,PREFIX_AFTER_VALUE:u,PREFIX_AFTER_COMMA:h,COLON:c,UNDEFINED:l}=i(45);const tokenize=e=>r.tokenize(e,{comment:true,loc:true});const p=[];let f=null;let d=null;const m=[];let x;let D=false;let E=false;let v=null;let y=null;let C=null;let S;let A=null;const clean=()=>{m.length=p.length=0;y=null;x=l};const free=()=>{clean();v.length=0;d=f=v=y=C=A=null};const F="before-all";const g="after";const k="after-all";const w="[";const b="]";const B="{";const T="}";const P=",";const N="";const I="-";const symbolFor=e=>Symbol.for(x!==l?`${e}:${x}`:e);const transform=(e,t)=>A?A(e,t):t;const unexpected=()=>{const e=new SyntaxError(`Unexpected token ${C.value.slice(0,1)}`);Object.assign(e,C.loc.start);throw e};const unexpected_end=()=>{const e=new SyntaxError("Unexpected end of JSON input");Object.assign(e,y?y.loc.end:{line:1,column:0});throw e};const next=()=>{const e=v[++S];E=C&&e&&C.loc.end.line===e.loc.start.line||false;y=C;C=e};const type=()=>{if(!C){unexpected_end()}return C.type==="Punctuator"?C.value:C.type};const is=e=>type()===e;const expect=e=>{if(!is(e)){unexpected()}};const set_comments_host=e=>{p.push(f);f=e};const restore_comments_host=()=>{f=p.pop()};const assign_after_comma_comments=()=>{if(!d){return}const e=[];for(const t of d){
/*!
* repeat-string <https://github.com/jonschlinkert/repeat-string>
*
* Copyright (c) 2014-2015, Jon Schlinkert.
* Licensed under the MIT License.
*/var t="";var i;e.exports=repeat;function repeat(e,r){if(typeof e!=="string"){throw new TypeError("expected a string")}if(r===1)return e;if(r===2)return e+e;var s=e.length*r;if(i!==e||typeof i==="undefined"){i=e;t=""}else if(t.length>=s){return t.substr(0,s)}while(s>t.length&&r>1){if(r&1){t+=e}r>>=1;e+=e}t+=e;t=t.substr(0,s);return t}}};var t={};function __nccwpck_require__(i){var r=t[i];if(r!==undefined){return r.exports}var s=t[i]={exports:{}};var n=true;try{e[i].call(s.exports,s,s.exports,__nccwpck_require__);n=false}finally{if(n)delete t[i]}return s.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var i=__nccwpck_require__(946);module.exports=i})();