lone-format 0.1.3 → 0.1.4
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/dist/index.d.ts +1 -6
- package/dist/lone-format.css +1 -1
- package/dist/lone-format.js +1673 -328
- package/dist/lone-format.umd.cjs +8 -1
- package/package.json +4 -2
- package/dist/components/JsonFormat/JsonNode.vue.d.ts +0 -65
- package/dist/components/JsonFormat/index.vue.d.ts +0 -57
- package/dist/components/JsonFormat/types.d.ts +0 -36
- package/dist/components/index.d.ts +0 -2
package/dist/lone-format.umd.cjs
CHANGED
|
@@ -1 +1,8 @@
|
|
|
1
|
-
(function(N,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(N=typeof globalThis<"u"?globalThis:N||self,e(N.LoneFormat={},N.Vue))})(this,function(N,e){"use strict";const M={class:"json-node"},P={key:0,class:"json-node__container"},K={class:"json-node__line"},L={key:2,class:"json-node__colon"},G=["title"],R={key:3,class:"json-node__collapsed"},q={key:4,class:"json-node__comma"},z={key:0,class:"json-node__children"},W={class:"json-node__children-content"},H={class:"json-node__line json-node__closing-bracket"},Q={class:"json-node__bracket"},X={key:0,class:"json-node__comma"},Y={key:1,class:"json-node__primitive"},Z={key:2,class:"json-node__colon"},ee=["title"],te={key:5,class:"json-node__comma"},ne=e.defineComponent({name:"JsonNode",__name:"JsonNode",props:{value:{},keyName:{},level:{},path:{default:""},expanded:{},isLast:{type:Boolean,default:!1}},emits:["update:value","toggle-expand","copy","update:key"],setup(B,{emit:k}){e.useCssVars(t=>({56869946:t.level}));const l=B,g=k,d=e.ref(!1),u=e.ref(!1),f=e.ref(""),i=e.ref(""),y=t=>{if(!/^-?\d+(\.\d+)?$/.test(t))return!1;const n=Number(t);return!Number.isSafeInteger(n)||t.length>15},S=e.computed(()=>l.value!==null&&typeof l.value=="object"),E=e.computed(()=>Array.isArray(l.value)),_=e.computed(()=>l.path?l.path:l.keyName?l.keyName:"root"),V=e.computed(()=>l.expanded.has(_.value)),C=e.computed(()=>l.keyName),$=e.computed(()=>E.value?"[":"{"),b=e.computed(()=>E.value?"]":"}"),J=e.computed(()=>{if(!l.value)return"";const n=Object.keys(l.value).length;return E.value?n>0?` ${n} items `:" ":n>0?` ${n} keys `:" "}),A=e.computed(()=>{const t=typeof l.value;return l.value===null?"json-node__value--null":t==="boolean"?"json-node__value--boolean":t==="number"?"json-node__value--number":t==="string"?y(l.value)?"json-node__value--number":"json-node__value--string":""}),w=e.computed(()=>u.value?i.value:l.value===null?"null":typeof l.value=="boolean"||typeof l.value=="number"?String(l.value):typeof l.value=="string"?y(l.value)?l.value:`"${l.value}"`:String(l.value)),O=e.computed(()=>"Click to edit, double-click to copy"),x=t=>l.level===0?t:_.value?`${_.value}.${t}`:t,I=t=>{const n=Object.keys(l.value);return n.indexOf(t)===n.length-1},h=()=>{g("toggle-expand",_.value)},v=()=>{l.level!==0&&(d.value=!0,f.value=l.keyName,e.nextTick(()=>{const t=document.querySelectorAll(".json-node__key-input"),n=t[t.length-1];n&&(n.focus(),n.select())}))},T=()=>{S.value||(u.value=!0,typeof l.value=="string"&&y(l.value)||typeof l.value=="string"?i.value=l.value:i.value=String(l.value),e.nextTick(()=>{const t=document.querySelectorAll(".json-node__value-input"),n=t[t.length-1];n&&(n.focus(),n.select())}))},j=()=>{if(l.level===0||!d.value)return;const t=f.value.trim();if(!t){s();return}if(t===l.keyName){d.value=!1;return}d.value=!1,g("update:key",_.value,t)},o=()=>{try{let t;const n=i.value.trim();if(n==="null")t=null;else if(n==="true"||n==="false")t=n==="true";else if(!isNaN(Number(n))&&n!==""){const r=Number(n);!Number.isSafeInteger(r)||n.length>15?t=n:t=r}else t=i.value;g("update:value",_.value,t),u.value=!1}catch(t){console.error("Failed to parse value:",t),u.value=!1}},s=()=>{d.value=!1,f.value=l.keyName},a=()=>{u.value=!1,typeof l.value=="string"&&y(l.value)||typeof l.value=="string"?i.value=l.value:i.value=String(l.value)};return(t,n)=>{const r=e.resolveComponent("JsonNode",!0);return e.openBlock(),e.createElementBlock("div",M,[S.value?(e.openBlock(),e.createElementBlock("div",P,[e.createElementVNode("div",K,[t.keyName&&!d.value?(e.openBlock(),e.createElementBlock("span",{key:0,class:"json-node__key",onClick:v,title:"Click to edit key"},' "'+e.toDisplayString(C.value)+'" ',1)):e.createCommentVNode("",!0),t.keyName&&d.value?e.withDirectives((e.openBlock(),e.createElementBlock("input",{key:1,"onUpdate:modelValue":n[0]||(n[0]=c=>f.value=c),onKeyup:[e.withKeys(j,["enter"]),e.withKeys(s,["escape"])],onBlur:j,class:"json-node__key-input"},null,544)),[[e.vModelText,f.value]]):e.createCommentVNode("",!0),t.keyName?(e.openBlock(),e.createElementBlock("span",L,": ")):e.createCommentVNode("",!0),e.createElementVNode("span",{class:"json-node__bracket json-node__bracket--clickable",onClick:h,title:V.value?"Click to collapse":"Click to expand"},e.toDisplayString($.value),9,G),V.value?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("span",R,[e.createTextVNode(e.toDisplayString(J.value)+" ",1),e.createElementVNode("span",{class:"json-node__bracket json-node__bracket--clickable",onClick:h},e.toDisplayString(b.value),1)])),!V.value&&!t.isLast?(e.openBlock(),e.createElementBlock("span",q,",")):e.createCommentVNode("",!0)]),V.value?(e.openBlock(),e.createElementBlock("div",z,[e.createElementVNode("div",W,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.value,(c,m)=>(e.openBlock(),e.createElementBlock("div",{key:m,class:"json-node__child"},[e.createVNode(r,{value:c,"key-name":E.value?"":String(m),level:t.level+1,path:x(String(m)),expanded:t.expanded,"onUpdate:value":n[1]||(n[1]=(p,F)=>t.$emit("update:value",p,F)),onToggleExpand:n[2]||(n[2]=p=>t.$emit("toggle-expand",p)),onCopy:n[3]||(n[3]=p=>t.$emit("copy",p)),"onUpdate:key":n[4]||(n[4]=(p,F)=>t.$emit("update:key",p,F)),"is-last":I(String(m))},null,8,["value","key-name","level","path","expanded","is-last"])]))),128))]),e.createElementVNode("div",H,[e.createElementVNode("span",Q,e.toDisplayString(b.value),1),t.isLast?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("span",X,","))])])):e.createCommentVNode("",!0)])):(e.openBlock(),e.createElementBlock("div",Y,[t.keyName&&!d.value?(e.openBlock(),e.createElementBlock("span",{key:0,class:"json-node__key",onClick:v,title:"Click to edit key"},' "'+e.toDisplayString(C.value)+'" ',1)):e.createCommentVNode("",!0),t.keyName&&d.value?e.withDirectives((e.openBlock(),e.createElementBlock("input",{key:1,"onUpdate:modelValue":n[5]||(n[5]=c=>f.value=c),onKeyup:[e.withKeys(j,["enter"]),e.withKeys(s,["escape"])],onBlur:j,class:"json-node__key-input"},null,544)),[[e.vModelText,f.value]]):e.createCommentVNode("",!0),t.keyName?(e.openBlock(),e.createElementBlock("span",Z,": ")):e.createCommentVNode("",!0),u.value?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("span",{key:3,class:e.normalizeClass(["json-node__value",A.value]),onClick:T,onDblclick:n[6]||(n[6]=c=>t.$emit("copy",t.value)),title:O.value},e.toDisplayString(w.value),43,ee)),u.value?e.withDirectives((e.openBlock(),e.createElementBlock("input",{key:4,"onUpdate:modelValue":n[7]||(n[7]=c=>i.value=c),onKeyup:[e.withKeys(o,["enter"]),e.withKeys(a,["escape"])],onBlur:o,class:"json-node__value-input"},null,544)),[[e.vModelText,i.value]]):e.createCommentVNode("",!0),t.isLast?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("span",te,","))]))])}}}),D=(B,k)=>{const l=B.__vccOpts||B;for(const[g,d]of k)l[g]=d;return l},oe=D(ne,[["__scopeId","data-v-5a60a3b2"]]),se={class:"json-format"},le={key:0,class:"json-format__toolbar"},re={class:"json-format__actions"},ae=["disabled"],ce=["disabled"],ie=["disabled"],de=["disabled"],ue={class:"json-format__info"},pe={key:0,class:"json-format__status json-format__status--success"},me={key:1,class:"json-format__status json-format__status--error"},fe={class:"json-format__content"},ye={key:0,class:"json-format__error"},_e={key:1,class:"json-format__viewer"},U=D(e.defineComponent({name:"JsonFormat",__name:"index",props:{modelValue:{default:""},readonly:{type:Boolean,default:!1},maxDepth:{default:10},showToolbar:{type:Boolean,default:!0}},emits:["update:modelValue","copy-success","copy-error","expand-all","collapse-all","compress"],setup(B,{expose:k,emit:l}){const g=B,d=l,u=e.ref(null),f=e.ref(""),i=e.ref(new Set),y=e.computed(()=>f.value===""),S=o=>{if(!o.trim()){u.value=null,f.value="";return}try{let s=o;s=s.replace(/:\s*(\d{16,})\s*([,}])/g,': "$1"$2'),s=s.replace(/:\s*(\d+\.\d*?0+)\s*([,}])/g,': "$1"$2'),u.value=JSON.parse(s),f.value="",e.nextTick(()=>{u.value!==null&&b()})}catch(s){f.value=s instanceof Error?s.message:"Unknown parsing error",u.value=null}};e.watch(()=>g.modelValue,o=>{S(o)},{immediate:!0});const E=o=>{if(!/^-?\d+(\.\d+)?$/.test(o))return!1;const s=Number(o);return!Number.isSafeInteger(s)||o.length>15},_=(o,s,a)=>JSON.stringify(o,(t,n)=>{if(typeof n=="string"&&E(n))return`__BIG_NUMBER__${n}__BIG_NUMBER__`;if(typeof n=="string"&&/^-?\d+(\.\d+)?$/.test(n)){const r=Number(n);if(Number.isSafeInteger(r)&&r.toString()===n)return r;if(!Number.isNaN(r)&&isFinite(r)&&n.includes("."))return r.toString()===n?r:n;if(!Number.isNaN(r)&&isFinite(r))return r}return s&&typeof s=="function"?s(t,n):n},a).replace(/"__BIG_NUMBER__(.+?)__BIG_NUMBER__"/g,"$1"),V=(o,s)=>{if(!g.readonly)try{const a=C(u.value,o,s),t=_(a,null,2);d("update:modelValue",t)}catch(a){console.error("Failed to update JSON:",a)}},C=(o,s,a)=>{if(!s||s==="root")return a;const t=s.split("."),n=h(o,t.slice(0,-1));let r=n;for(let m=0;m<t.length-1;m++){const p=t[m];p!=="root"&&(Array.isArray(r)?r=r[parseInt(p)]:r=r[p])}const c=t[t.length-1];return c==="root"?a:(Array.isArray(r)?r[parseInt(c)]=a:r[c]=a,n)},$=o=>{i.value.has(o)?i.value.delete(o):i.value.add(o)},b=()=>{const o=new Set,s=(a,t="")=>{a!==null&&typeof a=="object"&&(o.add(t||"root"),Array.isArray(a)?a.forEach((n,r)=>{const c=t?`${t}.${r}`:`${r}`;s(n,c)}):Object.keys(a).forEach(n=>{const r=t?`${t}.${n}`:n;s(a[n],r)}))};s(u.value),i.value=o,d("expand-all")},J=()=>{i.value=new Set(["root"]),d("collapse-all")},A=async()=>{if(y.value)try{const s=JSON.stringify(u.value,null,2).replace(/"(\d{16,})"/g,"$1");await navigator.clipboard.writeText(s),d("copy-success",s)}catch(o){console.error("Failed to copy JSON:",o),d("copy-error",o instanceof Error?o:new Error("Failed to copy JSON"))}},w=()=>{if(y.value)try{const o=_(u.value);d("update:modelValue",o),d("compress",o)}catch(o){console.error("Failed to compress JSON:",o)}},O=async o=>{try{let s;typeof o=="string"&&E(o)?s=o:typeof o=="string"?s=`"${o}"`:s=JSON.stringify(o),await navigator.clipboard.writeText(s)}catch(s){console.error("Failed to copy value:",s)}},x=(o,s)=>{if(!g.readonly)try{const a=I(u.value,o,s),t=_(a,null,2);d("update:modelValue",t),j(o,s)}catch(a){console.error("Failed to rename key:",a)}},I=(o,s,a)=>{if(!s||s==="root")return o;const t=s.split("."),n=h(o,t.slice(0,-1));if(t.length===1){const m=t[0];return n&&typeof n=="object"&&!Array.isArray(n)?v(n,m,a):n}let r=n;for(let m=0;m<t.length-1;m++){const p=t[m];Array.isArray(r)?r=r[parseInt(p)]:r=r[p]}const c=t[t.length-1];if(!Array.isArray(r)&&r&&typeof r=="object"){const m=v(r,c,a),p=t.slice(0,-1);p.length>0&&T(n,p,m)}return n},h=(o,s)=>{if(s.length===0)return o;if(Array.isArray(o)){const a=[...o],t=s[0],n=parseInt(t);return s.length===1||(a[n]=h(o[n],s.slice(1))),a}else if(o&&typeof o=="object"){const a={...o},t=s[0];return s.length===1||(a[t]=h(o[t],s.slice(1))),a}return o},v=(o,s,a)=>{if(!o||typeof o!="object"||Array.isArray(o))return o;const t=Object.keys(o),n={};for(const r of t)r===s?n[a]=o[r]:n[r]=o[r];return n},T=(o,s,a)=>{let t=o;for(let r=0;r<s.length-1;r++){const c=s[r];Array.isArray(t)?t=t[parseInt(c)]:t=t[c]}const n=s[s.length-1];Array.isArray(t)?t[parseInt(n)]=a:t[n]=a},j=(o,s)=>{const a=new Set;i.value.forEach(t=>{if(t===o){const n=o.split(".");n[n.length-1]=s,a.add(n.join("."))}else if(t.startsWith(o+".")){const n=o.split(".");n[n.length-1]=s;const r=n.join("."),c=t.substring(o.length);a.add(r+c)}else a.add(t)}),i.value=a};return k({copyJson:A,compressSource:w,expandAll:b,collapseAll:J,toggleExpand:$,updateValue:V,updateKey:x,isValidJson:()=>y.value,getParsedJson:()=>u.value,getExpandedNodes:()=>i.value,getParseError:()=>f.value,parseJson:o=>S(o),copyValue:o=>O(o)}),(o,s)=>(e.openBlock(),e.createElementBlock("div",se,[o.showToolbar?(e.openBlock(),e.createElementBlock("div",le,[e.createElementVNode("div",re,[e.createElementVNode("button",{class:"json-format__btn json-format__btn--primary",onClick:A,disabled:!y.value,title:"Copy JSON"}," 📋 Copy ",8,ae),e.createElementVNode("button",{class:"json-format__btn json-format__btn--secondary",onClick:b,disabled:!y.value,title:"Expand All"}," ⬇️ Expand All ",8,ce),e.createElementVNode("button",{class:"json-format__btn json-format__btn--secondary",onClick:J,disabled:!y.value,title:"Collapse All"}," ➡️ Collapse All ",8,ie),e.createElementVNode("button",{class:"json-format__btn json-format__btn--secondary",onClick:w,disabled:!y.value,title:"Compress JSON"}," 📦 Compress ",8,de)]),e.createElementVNode("div",ue,[y.value?(e.openBlock(),e.createElementBlock("span",pe," ✅ Valid JSON ")):(e.openBlock(),e.createElementBlock("span",me," ❌ Invalid JSON "))])])):e.createCommentVNode("",!0),e.createElementVNode("div",fe,[y.value?(e.openBlock(),e.createElementBlock("div",_e,[e.createVNode(oe,{value:u.value,"key-name":"",level:0,expanded:i.value,"is-last":!0,"onUpdate:value":V,onToggleExpand:$,onCopy:O,"onUpdate:key":x},null,8,["value","expanded"])])):(e.openBlock(),e.createElementBlock("div",ye,[s[0]||(s[0]=e.createElementVNode("h4",null,"JSON Parse Error:",-1)),e.createElementVNode("pre",null,e.toDisplayString(f.value),1)]))])]))}}),[["__scopeId","data-v-e91f0005"]]),ke=[U],ge={install:B=>{ke.forEach(k=>{const l=k.name||k.__name||"UnknownComponent";B.component(l,k)})}};N.JsonFormat=U,N.default=ge,Object.defineProperties(N,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
1
|
+
(function(I,s){typeof exports=="object"&&typeof module<"u"?s(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],s):(I=typeof globalThis<"u"?globalThis:I||self,s(I.LoneFormat={},I.Vue))})(this,function(I,s){"use strict";class J{add(e,t,o){if(typeof arguments[0]!="string")for(let n in arguments[0])this.add(n,arguments[0][n],arguments[1]);else(Array.isArray(e)?e:[e]).forEach(function(n){this[n]=this[n]||[],t&&this[n][o?"unshift":"push"](t)},this)}run(e,t){this[e]=this[e]||[],this[e].forEach(function(o){o.call(t&&t.context?t.context:t,t)})}}class ee{constructor(e){this.jsep=e,this.registered={}}register(){for(var e=arguments.length,t=new Array(e),o=0;o<e;o++)t[o]=arguments[o];t.forEach(n=>{if(typeof n!="object"||!n.name||!n.init)throw new Error("Invalid JSEP plugin format");this.registered[n.name]||(n.init(this.jsep),this.registered[n.name]=n)})}}class i{static get version(){return"1.4.0"}static toString(){return"JavaScript Expression Parser (JSEP) v"+i.version}static addUnaryOp(e){return i.max_unop_len=Math.max(e.length,i.max_unop_len),i.unary_ops[e]=1,i}static addBinaryOp(e,t,o){return i.max_binop_len=Math.max(e.length,i.max_binop_len),i.binary_ops[e]=t,o?i.right_associative.add(e):i.right_associative.delete(e),i}static addIdentifierChar(e){return i.additional_identifier_chars.add(e),i}static addLiteral(e,t){return i.literals[e]=t,i}static removeUnaryOp(e){return delete i.unary_ops[e],e.length===i.max_unop_len&&(i.max_unop_len=i.getMaxKeyLen(i.unary_ops)),i}static removeAllUnaryOps(){return i.unary_ops={},i.max_unop_len=0,i}static removeIdentifierChar(e){return i.additional_identifier_chars.delete(e),i}static removeBinaryOp(e){return delete i.binary_ops[e],e.length===i.max_binop_len&&(i.max_binop_len=i.getMaxKeyLen(i.binary_ops)),i.right_associative.delete(e),i}static removeAllBinaryOps(){return i.binary_ops={},i.max_binop_len=0,i}static removeLiteral(e){return delete i.literals[e],i}static removeAllLiterals(){return i.literals={},i}get char(){return this.expr.charAt(this.index)}get code(){return this.expr.charCodeAt(this.index)}constructor(e){this.expr=e,this.index=0}static parse(e){return new i(e).parse()}static getMaxKeyLen(e){return Math.max(0,...Object.keys(e).map(t=>t.length))}static isDecimalDigit(e){return e>=48&&e<=57}static binaryPrecedence(e){return i.binary_ops[e]||0}static isIdentifierStart(e){return e>=65&&e<=90||e>=97&&e<=122||e>=128&&!i.binary_ops[String.fromCharCode(e)]||i.additional_identifier_chars.has(String.fromCharCode(e))}static isIdentifierPart(e){return i.isIdentifierStart(e)||i.isDecimalDigit(e)}throwError(e){const t=new Error(e+" at character "+this.index);throw t.index=this.index,t.description=e,t}runHook(e,t){if(i.hooks[e]){const o={context:this,node:t};return i.hooks.run(e,o),o.node}return t}searchHook(e){if(i.hooks[e]){const t={context:this};return i.hooks[e].find(function(o){return o.call(t.context,t),t.node}),t.node}}gobbleSpaces(){let e=this.code;for(;e===i.SPACE_CODE||e===i.TAB_CODE||e===i.LF_CODE||e===i.CR_CODE;)e=this.expr.charCodeAt(++this.index);this.runHook("gobble-spaces")}parse(){this.runHook("before-all");const e=this.gobbleExpressions(),t=e.length===1?e[0]:{type:i.COMPOUND,body:e};return this.runHook("after-all",t)}gobbleExpressions(e){let t=[],o,n;for(;this.index<this.expr.length;)if(o=this.code,o===i.SEMCOL_CODE||o===i.COMMA_CODE)this.index++;else if(n=this.gobbleExpression())t.push(n);else if(this.index<this.expr.length){if(o===e)break;this.throwError('Unexpected "'+this.char+'"')}return t}gobbleExpression(){const e=this.searchHook("gobble-expression")||this.gobbleBinaryExpression();return this.gobbleSpaces(),this.runHook("after-expression",e)}gobbleBinaryOp(){this.gobbleSpaces();let e=this.expr.substr(this.index,i.max_binop_len),t=e.length;for(;t>0;){if(i.binary_ops.hasOwnProperty(e)&&(!i.isIdentifierStart(this.code)||this.index+e.length<this.expr.length&&!i.isIdentifierPart(this.expr.charCodeAt(this.index+e.length))))return this.index+=t,e;e=e.substr(0,--t)}return!1}gobbleBinaryExpression(){let e,t,o,n,l,u,f,d,h;if(u=this.gobbleToken(),!u||(t=this.gobbleBinaryOp(),!t))return u;for(l={value:t,prec:i.binaryPrecedence(t),right_a:i.right_associative.has(t)},f=this.gobbleToken(),f||this.throwError("Expected expression after "+t),n=[u,l,f];t=this.gobbleBinaryOp();){if(o=i.binaryPrecedence(t),o===0){this.index-=t.length;break}l={value:t,prec:o,right_a:i.right_associative.has(t)},h=t;const b=k=>l.right_a&&k.right_a?o>k.prec:o<=k.prec;for(;n.length>2&&b(n[n.length-2]);)f=n.pop(),t=n.pop().value,u=n.pop(),e={type:i.BINARY_EXP,operator:t,left:u,right:f},n.push(e);e=this.gobbleToken(),e||this.throwError("Expected expression after "+h),n.push(l,e)}for(d=n.length-1,e=n[d];d>1;)e={type:i.BINARY_EXP,operator:n[d-1].value,left:n[d-2],right:e},d-=2;return e}gobbleToken(){let e,t,o,n;if(this.gobbleSpaces(),n=this.searchHook("gobble-token"),n)return this.runHook("after-token",n);if(e=this.code,i.isDecimalDigit(e)||e===i.PERIOD_CODE)return this.gobbleNumericLiteral();if(e===i.SQUOTE_CODE||e===i.DQUOTE_CODE)n=this.gobbleStringLiteral();else if(e===i.OBRACK_CODE)n=this.gobbleArray();else{for(t=this.expr.substr(this.index,i.max_unop_len),o=t.length;o>0;){if(i.unary_ops.hasOwnProperty(t)&&(!i.isIdentifierStart(this.code)||this.index+t.length<this.expr.length&&!i.isIdentifierPart(this.expr.charCodeAt(this.index+t.length)))){this.index+=o;const l=this.gobbleToken();return l||this.throwError("missing unaryOp argument"),this.runHook("after-token",{type:i.UNARY_EXP,operator:t,argument:l,prefix:!0})}t=t.substr(0,--o)}i.isIdentifierStart(e)?(n=this.gobbleIdentifier(),i.literals.hasOwnProperty(n.name)?n={type:i.LITERAL,value:i.literals[n.name],raw:n.name}:n.name===i.this_str&&(n={type:i.THIS_EXP})):e===i.OPAREN_CODE&&(n=this.gobbleGroup())}return n?(n=this.gobbleTokenProperty(n),this.runHook("after-token",n)):this.runHook("after-token",!1)}gobbleTokenProperty(e){this.gobbleSpaces();let t=this.code;for(;t===i.PERIOD_CODE||t===i.OBRACK_CODE||t===i.OPAREN_CODE||t===i.QUMARK_CODE;){let o;if(t===i.QUMARK_CODE){if(this.expr.charCodeAt(this.index+1)!==i.PERIOD_CODE)break;o=!0,this.index+=2,this.gobbleSpaces(),t=this.code}this.index++,t===i.OBRACK_CODE?(e={type:i.MEMBER_EXP,computed:!0,object:e,property:this.gobbleExpression()},e.property||this.throwError('Unexpected "'+this.char+'"'),this.gobbleSpaces(),t=this.code,t!==i.CBRACK_CODE&&this.throwError("Unclosed ["),this.index++):t===i.OPAREN_CODE?e={type:i.CALL_EXP,arguments:this.gobbleArguments(i.CPAREN_CODE),callee:e}:(t===i.PERIOD_CODE||o)&&(o&&this.index--,this.gobbleSpaces(),e={type:i.MEMBER_EXP,computed:!1,object:e,property:this.gobbleIdentifier()}),o&&(e.optional=!0),this.gobbleSpaces(),t=this.code}return e}gobbleNumericLiteral(){let e="",t,o;for(;i.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);if(this.code===i.PERIOD_CODE)for(e+=this.expr.charAt(this.index++);i.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);if(t=this.char,t==="e"||t==="E"){for(e+=this.expr.charAt(this.index++),t=this.char,(t==="+"||t==="-")&&(e+=this.expr.charAt(this.index++));i.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);i.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+e+this.char+")")}return o=this.code,i.isIdentifierStart(o)?this.throwError("Variable names cannot start with a number ("+e+this.char+")"):(o===i.PERIOD_CODE||e.length===1&&e.charCodeAt(0)===i.PERIOD_CODE)&&this.throwError("Unexpected period"),{type:i.LITERAL,value:parseFloat(e),raw:e}}gobbleStringLiteral(){let e="";const t=this.index,o=this.expr.charAt(this.index++);let n=!1;for(;this.index<this.expr.length;){let l=this.expr.charAt(this.index++);if(l===o){n=!0;break}else if(l==="\\")switch(l=this.expr.charAt(this.index++),l){case"n":e+=`
|
|
2
|
+
`;break;case"r":e+="\r";break;case"t":e+=" ";break;case"b":e+="\b";break;case"f":e+="\f";break;case"v":e+="\v";break;default:e+=l}else e+=l}return n||this.throwError('Unclosed quote after "'+e+'"'),{type:i.LITERAL,value:e,raw:this.expr.substring(t,this.index)}}gobbleIdentifier(){let e=this.code,t=this.index;for(i.isIdentifierStart(e)?this.index++:this.throwError("Unexpected "+this.char);this.index<this.expr.length&&(e=this.code,i.isIdentifierPart(e));)this.index++;return{type:i.IDENTIFIER,name:this.expr.slice(t,this.index)}}gobbleArguments(e){const t=[];let o=!1,n=0;for(;this.index<this.expr.length;){this.gobbleSpaces();let l=this.code;if(l===e){o=!0,this.index++,e===i.CPAREN_CODE&&n&&n>=t.length&&this.throwError("Unexpected token "+String.fromCharCode(e));break}else if(l===i.COMMA_CODE){if(this.index++,n++,n!==t.length){if(e===i.CPAREN_CODE)this.throwError("Unexpected token ,");else if(e===i.CBRACK_CODE)for(let u=t.length;u<n;u++)t.push(null)}}else if(t.length!==n&&n!==0)this.throwError("Expected comma");else{const u=this.gobbleExpression();(!u||u.type===i.COMPOUND)&&this.throwError("Expected comma"),t.push(u)}}return o||this.throwError("Expected "+String.fromCharCode(e)),t}gobbleGroup(){this.index++;let e=this.gobbleExpressions(i.CPAREN_CODE);if(this.code===i.CPAREN_CODE)return this.index++,e.length===1?e[0]:e.length?{type:i.SEQUENCE_EXP,expressions:e}:!1;this.throwError("Unclosed (")}gobbleArray(){return this.index++,{type:i.ARRAY_EXP,elements:this.gobbleArguments(i.CBRACK_CODE)}}}const te=new J;Object.assign(i,{hooks:te,plugins:new ee(i),COMPOUND:"Compound",SEQUENCE_EXP:"SequenceExpression",IDENTIFIER:"Identifier",MEMBER_EXP:"MemberExpression",LITERAL:"Literal",THIS_EXP:"ThisExpression",CALL_EXP:"CallExpression",UNARY_EXP:"UnaryExpression",BINARY_EXP:"BinaryExpression",ARRAY_EXP:"ArrayExpression",TAB_CODE:9,LF_CODE:10,CR_CODE:13,SPACE_CODE:32,PERIOD_CODE:46,COMMA_CODE:44,SQUOTE_CODE:39,DQUOTE_CODE:34,OPAREN_CODE:40,CPAREN_CODE:41,OBRACK_CODE:91,CBRACK_CODE:93,QUMARK_CODE:63,SEMCOL_CODE:59,COLON_CODE:58,unary_ops:{"-":1,"!":1,"~":1,"+":1},binary_ops:{"||":1,"??":1,"&&":2,"|":3,"^":4,"&":5,"==":6,"!=":6,"===":6,"!==":6,"<":7,">":7,"<=":7,">=":7,"<<":8,">>":8,">>>":8,"+":9,"-":9,"*":10,"/":10,"%":10,"**":11},right_associative:new Set(["**"]),additional_identifier_chars:new Set(["$","_"]),literals:{true:!0,false:!1,null:null},this_str:"this"}),i.max_unop_len=i.getMaxKeyLen(i.unary_ops),i.max_binop_len=i.getMaxKeyLen(i.binary_ops);const B=r=>new i(r).parse(),re=Object.getOwnPropertyNames(class{});Object.getOwnPropertyNames(i).filter(r=>!re.includes(r)&&B[r]===void 0).forEach(r=>{B[r]=i[r]}),B.Jsep=i;const ne="ConditionalExpression";var oe={name:"ternary",init(r){r.hooks.add("after-expression",function(t){if(t.node&&this.code===r.QUMARK_CODE){this.index++;const o=t.node,n=this.gobbleExpression();if(n||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===r.COLON_CODE){this.index++;const l=this.gobbleExpression();if(l||this.throwError("Expected expression"),t.node={type:ne,test:o,consequent:n,alternate:l},o.operator&&r.binary_ops[o.operator]<=.9){let u=o;for(;u.right.operator&&r.binary_ops[u.right.operator]<=.9;)u=u.right;t.node.test=u.right,u.right=t.node,t.node=o}}else this.throwError("Expected :")}})}};B.plugins.register(oe);const z=47,se=92;var ie={name:"regex",init(r){r.hooks.add("gobble-token",function(t){if(this.code===z){const o=++this.index;let n=!1;for(;this.index<this.expr.length;){if(this.code===z&&!n){const l=this.expr.slice(o,this.index);let u="";for(;++this.index<this.expr.length;){const d=this.code;if(d>=97&&d<=122||d>=65&&d<=90||d>=48&&d<=57)u+=this.char;else break}let f;try{f=new RegExp(l,u)}catch(d){this.throwError(d.message)}return t.node={type:r.LITERAL,value:f,raw:this.expr.slice(o-1,this.index)},t.node=this.gobbleTokenProperty(t.node),t.node}this.code===r.OBRACK_CODE?n=!0:n&&this.code===r.CBRACK_CODE&&(n=!1),this.index+=this.code===se?2:1}this.throwError("Unclosed Regex")}})}};const q=43,V={name:"assignment",assignmentOperators:new Set(["=","*=","**=","/=","%=","+=","-=","<<=",">>=",">>>=","&=","^=","|=","||=","&&=","??="]),updateOperators:[q,45],assignmentPrecedence:.9,init(r){const e=[r.IDENTIFIER,r.MEMBER_EXP];V.assignmentOperators.forEach(o=>r.addBinaryOp(o,V.assignmentPrecedence,!0)),r.hooks.add("gobble-token",function(n){const l=this.code;V.updateOperators.some(u=>u===l&&u===this.expr.charCodeAt(this.index+1))&&(this.index+=2,n.node={type:"UpdateExpression",operator:l===q?"++":"--",argument:this.gobbleTokenProperty(this.gobbleIdentifier()),prefix:!0},(!n.node.argument||!e.includes(n.node.argument.type))&&this.throwError(`Unexpected ${n.node.operator}`))}),r.hooks.add("after-token",function(n){if(n.node){const l=this.code;V.updateOperators.some(u=>u===l&&u===this.expr.charCodeAt(this.index+1))&&(e.includes(n.node.type)||this.throwError(`Unexpected ${n.node.operator}`),this.index+=2,n.node={type:"UpdateExpression",operator:l===q?"++":"--",argument:n.node,prefix:!1})}}),r.hooks.add("after-expression",function(n){n.node&&t(n.node)});function t(o){V.assignmentOperators.has(o.operator)?(o.type="AssignmentExpression",t(o.left),t(o.right)):o.operator||Object.values(o).forEach(n=>{n&&typeof n=="object"&&t(n)})}}};B.plugins.register(ie,V),B.addUnaryOp("typeof"),B.addLiteral("null",null),B.addLiteral("undefined",void 0);const ae=new Set(["constructor","__proto__","__defineGetter__","__defineSetter__"]),C={evalAst(r,e){switch(r.type){case"BinaryExpression":case"LogicalExpression":return C.evalBinaryExpression(r,e);case"Compound":return C.evalCompound(r,e);case"ConditionalExpression":return C.evalConditionalExpression(r,e);case"Identifier":return C.evalIdentifier(r,e);case"Literal":return C.evalLiteral(r,e);case"MemberExpression":return C.evalMemberExpression(r,e);case"UnaryExpression":return C.evalUnaryExpression(r,e);case"ArrayExpression":return C.evalArrayExpression(r,e);case"CallExpression":return C.evalCallExpression(r,e);case"AssignmentExpression":return C.evalAssignmentExpression(r,e);default:throw SyntaxError("Unexpected expression",r)}},evalBinaryExpression(r,e){return{"||":(o,n)=>o||n(),"&&":(o,n)=>o&&n(),"|":(o,n)=>o|n(),"^":(o,n)=>o^n(),"&":(o,n)=>o&n(),"==":(o,n)=>o==n(),"!=":(o,n)=>o!=n(),"===":(o,n)=>o===n(),"!==":(o,n)=>o!==n(),"<":(o,n)=>o<n(),">":(o,n)=>o>n(),"<=":(o,n)=>o<=n(),">=":(o,n)=>o>=n(),"<<":(o,n)=>o<<n(),">>":(o,n)=>o>>n(),">>>":(o,n)=>o>>>n(),"+":(o,n)=>o+n(),"-":(o,n)=>o-n(),"*":(o,n)=>o*n(),"/":(o,n)=>o/n(),"%":(o,n)=>o%n()}[r.operator](C.evalAst(r.left,e),()=>C.evalAst(r.right,e))},evalCompound(r,e){let t;for(let o=0;o<r.body.length;o++){r.body[o].type==="Identifier"&&["var","let","const"].includes(r.body[o].name)&&r.body[o+1]&&r.body[o+1].type==="AssignmentExpression"&&(o+=1);const n=r.body[o];t=C.evalAst(n,e)}return t},evalConditionalExpression(r,e){return C.evalAst(r.test,e)?C.evalAst(r.consequent,e):C.evalAst(r.alternate,e)},evalIdentifier(r,e){if(Object.hasOwn(e,r.name))return e[r.name];throw ReferenceError(`${r.name} is not defined`)},evalLiteral(r){return r.value},evalMemberExpression(r,e){const t=String(r.computed?C.evalAst(r.property):r.property.name),o=C.evalAst(r.object,e);if(o==null)throw TypeError(`Cannot read properties of ${o} (reading '${t}')`);if(!Object.hasOwn(o,t)&&ae.has(t))throw TypeError(`Cannot read properties of ${o} (reading '${t}')`);const n=o[t];return typeof n=="function"?n.bind(o):n},evalUnaryExpression(r,e){return{"-":o=>-C.evalAst(o,e),"!":o=>!C.evalAst(o,e),"~":o=>~C.evalAst(o,e),"+":o=>+C.evalAst(o,e),typeof:o=>typeof C.evalAst(o,e)}[r.operator](r.argument)},evalArrayExpression(r,e){return r.elements.map(t=>C.evalAst(t,e))},evalCallExpression(r,e){const t=r.arguments.map(n=>C.evalAst(n,e));return C.evalAst(r.callee,e)(...t)},evalAssignmentExpression(r,e){if(r.left.type!=="Identifier")throw SyntaxError("Invalid left-hand side in assignment");const t=r.left.name,o=C.evalAst(r.right,e);return e[t]=o,e[t]}};class le{constructor(e){this.code=e,this.ast=B(this.code)}runInNewContext(e){const t=Object.assign(Object.create(null),e);return C.evalAst(this.ast,t)}}function T(r,e){return r=r.slice(),r.push(e),r}function G(r,e){return e=e.slice(),e.unshift(r),e}class ce extends Error{constructor(e){super('JSONPath should not be called with "new" (it prevents return of (unwrapped) scalar values)'),this.avoidNew=!0,this.value=e,this.name="NewError"}}function O(r,e,t,o,n){if(!(this instanceof O))try{return new O(r,e,t,o,n)}catch(u){if(!u.avoidNew)throw u;return u.value}typeof r=="string"&&(n=o,o=t,t=e,e=r,r=null);const l=r&&typeof r=="object";if(r=r||{},this.json=r.json||t,this.path=r.path||e,this.resultType=r.resultType||"value",this.flatten=r.flatten||!1,this.wrap=Object.hasOwn(r,"wrap")?r.wrap:!0,this.sandbox=r.sandbox||{},this.eval=r.eval===void 0?"safe":r.eval,this.ignoreEvalErrors=typeof r.ignoreEvalErrors>"u"?!1:r.ignoreEvalErrors,this.parent=r.parent||null,this.parentProperty=r.parentProperty||null,this.callback=r.callback||o||null,this.otherTypeCallback=r.otherTypeCallback||n||function(){throw new TypeError("You must supply an otherTypeCallback callback option with the @other() operator.")},r.autostart!==!1){const u={path:l?r.path:e};l?"json"in r&&(u.json=r.json):u.json=t;const f=this.evaluate(u);if(!f||typeof f!="object")throw new ce(f);return f}}O.prototype.evaluate=function(r,e,t,o){let n=this.parent,l=this.parentProperty,{flatten:u,wrap:f}=this;if(this.currResultType=this.resultType,this.currEval=this.eval,this.currSandbox=this.sandbox,t=t||this.callback,this.currOtherTypeCallback=o||this.otherTypeCallback,e=e||this.json,r=r||this.path,r&&typeof r=="object"&&!Array.isArray(r)){if(!r.path&&r.path!=="")throw new TypeError('You must supply a "path" property when providing an object argument to JSONPath.evaluate().');if(!Object.hasOwn(r,"json"))throw new TypeError('You must supply a "json" property when providing an object argument to JSONPath.evaluate().');({json:e}=r),u=Object.hasOwn(r,"flatten")?r.flatten:u,this.currResultType=Object.hasOwn(r,"resultType")?r.resultType:this.currResultType,this.currSandbox=Object.hasOwn(r,"sandbox")?r.sandbox:this.currSandbox,f=Object.hasOwn(r,"wrap")?r.wrap:f,this.currEval=Object.hasOwn(r,"eval")?r.eval:this.currEval,t=Object.hasOwn(r,"callback")?r.callback:t,this.currOtherTypeCallback=Object.hasOwn(r,"otherTypeCallback")?r.otherTypeCallback:this.currOtherTypeCallback,n=Object.hasOwn(r,"parent")?r.parent:n,l=Object.hasOwn(r,"parentProperty")?r.parentProperty:l,r=r.path}if(n=n||null,l=l||null,Array.isArray(r)&&(r=O.toPathString(r)),!r&&r!==""||!e)return;const d=O.toPathArray(r);d[0]==="$"&&d.length>1&&d.shift(),this._hasParentSelector=null;const h=this._trace(d,e,["$"],n,l,t).filter(function(b){return b&&!b.isParentSelector});return h.length?!f&&h.length===1&&!h[0].hasArrExpr?this._getPreferredOutput(h[0]):h.reduce((b,k)=>{const w=this._getPreferredOutput(k);return u&&Array.isArray(w)?b=b.concat(w):b.push(w),b},[]):f?[]:void 0},O.prototype._getPreferredOutput=function(r){const e=this.currResultType;switch(e){case"all":{const t=Array.isArray(r.path)?r.path:O.toPathArray(r.path);return r.pointer=O.toPointer(t),r.path=typeof r.path=="string"?r.path:O.toPathString(r.path),r}case"value":case"parent":case"parentProperty":return r[e];case"path":return O.toPathString(r[e]);case"pointer":return O.toPointer(r.path);default:throw new TypeError("Unknown result type")}},O.prototype._handleCallback=function(r,e,t){if(e){const o=this._getPreferredOutput(r);r.path=typeof r.path=="string"?r.path:O.toPathString(r.path),e(o,t,r)}},O.prototype._trace=function(r,e,t,o,n,l,u,f){let d;if(!r.length)return d={path:t,value:e,parent:o,parentProperty:n,hasArrExpr:u},this._handleCallback(d,l,"value"),d;const h=r[0],b=r.slice(1),k=[];function w(m){Array.isArray(m)?m.forEach(S=>{k.push(S)}):k.push(m)}if((typeof h!="string"||f)&&e&&Object.hasOwn(e,h))w(this._trace(b,e[h],T(t,h),e,h,l,u));else if(h==="*")this._walk(e,m=>{w(this._trace(b,e[m],T(t,m),e,m,l,!0,!0))});else if(h==="..")w(this._trace(b,e,t,o,n,l,u)),this._walk(e,m=>{typeof e[m]=="object"&&w(this._trace(r.slice(),e[m],T(t,m),e,m,l,!0))});else{if(h==="^")return this._hasParentSelector=!0,{path:t.slice(0,-1),expr:b,isParentSelector:!0};if(h==="~")return d={path:T(t,h),value:n,parent:o,parentProperty:null},this._handleCallback(d,l,"property"),d;if(h==="$")w(this._trace(b,e,t,null,null,l,u));else if(/^(-?\d*):(-?\d*):?(\d*)$/u.test(h))w(this._slice(h,b,e,t,o,n,l));else if(h.indexOf("?(")===0){if(this.currEval===!1)throw new Error("Eval [?(expr)] prevented in JSONPath expression.");const m=h.replace(/^\?\((.*?)\)$/u,"$1"),S=/@.?([^?]*)[['](\??\(.*?\))(?!.\)\])[\]']/gu.exec(m);S?this._walk(e,A=>{const D=[S[2]],P=S[1]?e[A][S[1]]:e[A];this._trace(D,P,t,o,n,l,!0).length>0&&w(this._trace(b,e[A],T(t,A),e,A,l,!0))}):this._walk(e,A=>{this._eval(m,e[A],A,t,o,n)&&w(this._trace(b,e[A],T(t,A),e,A,l,!0))})}else if(h[0]==="("){if(this.currEval===!1)throw new Error("Eval [(expr)] prevented in JSONPath expression.");w(this._trace(G(this._eval(h,e,t.at(-1),t.slice(0,-1),o,n),b),e,t,o,n,l,u))}else if(h[0]==="@"){let m=!1;const S=h.slice(1,-2);switch(S){case"scalar":(!e||!["object","function"].includes(typeof e))&&(m=!0);break;case"boolean":case"string":case"undefined":case"function":typeof e===S&&(m=!0);break;case"integer":Number.isFinite(e)&&!(e%1)&&(m=!0);break;case"number":Number.isFinite(e)&&(m=!0);break;case"nonFinite":typeof e=="number"&&!Number.isFinite(e)&&(m=!0);break;case"object":e&&typeof e===S&&(m=!0);break;case"array":Array.isArray(e)&&(m=!0);break;case"other":m=this.currOtherTypeCallback(e,t,o,n);break;case"null":e===null&&(m=!0);break;default:throw new TypeError("Unknown value type "+S)}if(m)return d={path:t,value:e,parent:o,parentProperty:n},this._handleCallback(d,l,"value"),d}else if(h[0]==="`"&&e&&Object.hasOwn(e,h.slice(1))){const m=h.slice(1);w(this._trace(b,e[m],T(t,m),e,m,l,u,!0))}else if(h.includes(",")){const m=h.split(",");for(const S of m)w(this._trace(G(S,b),e,t,o,n,l,!0))}else!f&&e&&Object.hasOwn(e,h)&&w(this._trace(b,e[h],T(t,h),e,h,l,u,!0))}if(this._hasParentSelector)for(let m=0;m<k.length;m++){const S=k[m];if(S&&S.isParentSelector){const A=this._trace(S.expr,e,S.path,o,n,l,u);if(Array.isArray(A)){k[m]=A[0];const D=A.length;for(let P=1;P<D;P++)m++,k.splice(m,0,A[P])}else k[m]=A}}return k},O.prototype._walk=function(r,e){if(Array.isArray(r)){const t=r.length;for(let o=0;o<t;o++)e(o)}else r&&typeof r=="object"&&Object.keys(r).forEach(t=>{e(t)})},O.prototype._slice=function(r,e,t,o,n,l,u){if(!Array.isArray(t))return;const f=t.length,d=r.split(":"),h=d[2]&&Number.parseInt(d[2])||1;let b=d[0]&&Number.parseInt(d[0])||0,k=d[1]&&Number.parseInt(d[1])||f;b=b<0?Math.max(0,b+f):Math.min(f,b),k=k<0?Math.max(0,k+f):Math.min(f,k);const w=[];for(let m=b;m<k;m+=h)this._trace(G(m,e),t,o,n,l,u,!0).forEach(A=>{w.push(A)});return w},O.prototype._eval=function(r,e,t,o,n,l){this.currSandbox._$_parentProperty=l,this.currSandbox._$_parent=n,this.currSandbox._$_property=t,this.currSandbox._$_root=this.json,this.currSandbox._$_v=e;const u=r.includes("@path");u&&(this.currSandbox._$_path=O.toPathString(o.concat([t])));const f=this.currEval+"Script:"+r;if(!O.cache[f]){let d=r.replaceAll("@parentProperty","_$_parentProperty").replaceAll("@parent","_$_parent").replaceAll("@property","_$_property").replaceAll("@root","_$_root").replaceAll(/@([.\s)[])/gu,"_$_v$1");if(u&&(d=d.replaceAll("@path","_$_path")),this.currEval==="safe"||this.currEval===!0||this.currEval===void 0)O.cache[f]=new this.safeVm.Script(d);else if(this.currEval==="native")O.cache[f]=new this.vm.Script(d);else if(typeof this.currEval=="function"&&this.currEval.prototype&&Object.hasOwn(this.currEval.prototype,"runInNewContext")){const h=this.currEval;O.cache[f]=new h(d)}else if(typeof this.currEval=="function")O.cache[f]={runInNewContext:h=>this.currEval(d,h)};else throw new TypeError(`Unknown "eval" property "${this.currEval}"`)}try{return O.cache[f].runInNewContext(this.currSandbox)}catch(d){if(this.ignoreEvalErrors)return!1;throw new Error("jsonPath: "+d.message+": "+r)}},O.cache={},O.toPathString=function(r){const e=r,t=e.length;let o="$";for(let n=1;n<t;n++)/^(~|\^|@.*?\(\))$/u.test(e[n])||(o+=/^[0-9*]+$/u.test(e[n])?"["+e[n]+"]":"['"+e[n]+"']");return o},O.toPointer=function(r){const e=r,t=e.length;let o="";for(let n=1;n<t;n++)/^(~|\^|@.*?\(\))$/u.test(e[n])||(o+="/"+e[n].toString().replaceAll("~","~0").replaceAll("/","~1"));return o},O.toPathArray=function(r){const{cache:e}=O;if(e[r])return e[r].concat();const t=[],n=r.replaceAll(/@(?:null|boolean|number|string|integer|undefined|nonFinite|scalar|array|object|function|other)\(\)/gu,";$&;").replaceAll(/[['](\??\(.*?\))[\]'](?!.\])/gu,function(l,u){return"[#"+(t.push(u)-1)+"]"}).replaceAll(/\[['"]([^'\]]*)['"]\]/gu,function(l,u){return"['"+u.replaceAll(".","%@%").replaceAll("~","%%@@%%")+"']"}).replaceAll("~",";~;").replaceAll(/['"]?\.['"]?(?![^[]*\])|\[['"]?/gu,";").replaceAll("%@%",".").replaceAll("%%@@%%","~").replaceAll(/(?:;)?(\^+)(?:;)?/gu,function(l,u){return";"+u.split("").join(";")+";"}).replaceAll(/;;;|;;/gu,";..;").replaceAll(/;$|'?\]|'$/gu,"").split(";").map(function(l){const u=l.match(/#(\d+)/u);return!u||!u[1]?l:t[u[1]]});return e[r]=n,e[r].concat()},O.prototype.safeVm={Script:le};const ue=function(r,e,t){const o=r.length;for(let n=0;n<o;n++){const l=r[n];t(l)&&e.push(r.splice(n--,1)[0])}};class de{constructor(e){this.code=e}runInNewContext(e){let t=this.code;const o=Object.keys(e),n=[];ue(o,n,h=>typeof e[h]=="function");const l=o.map(h=>e[h]);t=n.reduce((h,b)=>{let k=e[b].toString();return/function/u.test(k)||(k="function "+k),"var "+b+"="+k+";"+h},"")+t,!/(['"])use strict\1/u.test(t)&&!o.includes("arguments")&&(t="var arguments = undefined;"+t),t=t.replace(/;\s*$/u,"");const f=t.lastIndexOf(";"),d=f!==-1?t.slice(0,f+1)+" return "+t.slice(f+1):" return "+t;return new Function(...o,d)(...l)}}O.prototype.vm={Script:de};const he={class:"json-node"},fe={key:0,class:"json-node__container"},pe={class:"json-node__line"},ye={key:2,class:"json-node__colon"},ge=["title"],Ee={key:3,class:"json-node__collapsed"},me={key:4,class:"json-node__comma"},be={key:0,class:"json-node__children"},_e={class:"json-node__children-content"},xe={class:"json-node__line json-node__closing-bracket"},ke={class:"json-node__bracket"},Oe={key:0,class:"json-node__comma"},Ce={key:1,class:"json-node__primitive"},we={key:2,class:"json-node__colon"},Ae=["title"],Se={key:0,class:"json-node__comma"},Ne=s.defineComponent({name:"JsonNode",__name:"JsonNode",props:{value:{},keyName:{},level:{},path:{default:""},expanded:{},isLast:{type:Boolean,default:!1}},emits:["update:value","toggle-expand","copy","update:key"],setup(r,{emit:e}){s.useCssVars(p=>({"1f6d5aa6":p.level}));const t=r,o=e,n=s.ref(!1),l=s.ref(!1),u=s.ref(""),f=s.ref(""),d=p=>{if(!/^-?\d+(\.\d+)?$/.test(p))return!1;const _=Number(p);return!Number.isSafeInteger(_)||p.length>15},h=s.computed(()=>t.value!==null&&typeof t.value=="object"),b=s.computed(()=>Array.isArray(t.value)),k=s.computed(()=>t.path?t.path:t.keyName?t.keyName:"root"),w=s.computed(()=>t.expanded.has(k.value)),m=s.computed(()=>t.keyName),S=s.computed(()=>b.value?"[":"{"),A=s.computed(()=>b.value?"]":"}"),D=s.computed(()=>{if(!t.value)return"";const _=Object.keys(t.value).length;return b.value?_>0?` ${_} items `:" ":_>0?` ${_} keys `:" "}),P=s.computed(()=>{const p=typeof t.value;return t.value===null?"json-node__value--null":p==="boolean"?"json-node__value--boolean":p==="number"?"json-node__value--number":p==="string"?d(t.value)?"json-node__value--number":"json-node__value--string":""}),F=s.computed(()=>l.value?f.value:t.value===null?"null":typeof t.value=="boolean"||typeof t.value=="number"?String(t.value):typeof t.value=="string"?d(t.value)?t.value:`"${t.value}"`:String(t.value)),K=s.computed(()=>"Click to edit, double-click to copy"),U=p=>t.level===0?p:k.value?`${k.value}.${p}`:p,X=p=>{const _=Object.keys(t.value);return _.indexOf(p)===_.length-1},L=()=>{o("toggle-expand",k.value)},M=()=>{t.level!==0&&(n.value=!0,u.value=t.keyName,s.nextTick(()=>{const p=document.querySelectorAll(".json-node__key-input"),_=p[p.length-1];_&&(_.focus(),_.select())}))},H=()=>{h.value||(l.value=!0,typeof t.value=="string"&&d(t.value)||typeof t.value=="string"?f.value=t.value:f.value=String(t.value),s.nextTick(()=>{const p=document.querySelectorAll(".json-node__value-input"),_=p[p.length-1];_&&(_.focus(),_.select())}))},R=()=>{if(t.level===0||!n.value)return;const p=u.value.trim();if(!p){$();return}if(p===t.keyName){n.value=!1;return}n.value=!1,o("update:key",k.value,p)},Q=()=>{try{let p;const _=f.value.trim();if(_==="null")p=null;else if(_==="true"||_==="false")p=_==="true";else if(!isNaN(Number(_))&&_!==""){const a=Number(_);!Number.isSafeInteger(a)||_.length>15?p=_:p=a}else p=f.value;o("update:value",k.value,p),l.value=!1}catch(p){console.error("Failed to parse value:",p),l.value=!1}},$=()=>{n.value=!1,u.value=t.keyName},Y=()=>{l.value=!1,typeof t.value=="string"&&d(t.value)||typeof t.value=="string"?f.value=t.value:f.value=String(t.value)};return(p,_)=>{const a=s.resolveComponent("JsonNode",!0);return s.openBlock(),s.createElementBlock("div",he,[h.value?(s.openBlock(),s.createElementBlock("div",fe,[s.createElementVNode("div",pe,[p.keyName&&!n.value?(s.openBlock(),s.createElementBlock("span",{key:0,class:"json-node__key",onClick:M,title:"Click to edit key"},' "'+s.toDisplayString(m.value)+'" ',1)):s.createCommentVNode("",!0),p.keyName&&n.value?s.withDirectives((s.openBlock(),s.createElementBlock("input",{key:1,"onUpdate:modelValue":_[0]||(_[0]=c=>u.value=c),onKeyup:[s.withKeys(R,["enter"]),s.withKeys($,["escape"])],onBlur:R,class:"json-node__key-input"},null,544)),[[s.vModelText,u.value]]):s.createCommentVNode("",!0),p.keyName?(s.openBlock(),s.createElementBlock("span",ye,": ")):s.createCommentVNode("",!0),s.createElementVNode("span",{class:"json-node__bracket json-node__bracket--clickable",onClick:L,title:w.value?"Click to collapse":"Click to expand"},s.toDisplayString(S.value),9,ge),w.value?s.createCommentVNode("",!0):(s.openBlock(),s.createElementBlock("span",Ee,[s.createTextVNode(s.toDisplayString(D.value)+" ",1),s.createElementVNode("span",{class:"json-node__bracket json-node__bracket--clickable",onClick:L},s.toDisplayString(A.value),1)])),!w.value&&!p.isLast?(s.openBlock(),s.createElementBlock("span",me,",")):s.createCommentVNode("",!0)]),w.value?(s.openBlock(),s.createElementBlock("div",be,[s.createElementVNode("div",_e,[(s.openBlock(!0),s.createElementBlock(s.Fragment,null,s.renderList(p.value,(c,E)=>(s.openBlock(),s.createElementBlock("div",{key:E,class:"json-node__child"},[s.createVNode(a,{value:c,"key-name":b.value?"":String(E),level:p.level+1,path:U(String(E)),expanded:p.expanded,"onUpdate:value":_[1]||(_[1]=(y,g)=>p.$emit("update:value",y,g)),onToggleExpand:_[2]||(_[2]=y=>p.$emit("toggle-expand",y)),onCopy:_[3]||(_[3]=y=>p.$emit("copy",y)),"onUpdate:key":_[4]||(_[4]=(y,g)=>p.$emit("update:key",y,g)),"is-last":X(String(E))},null,8,["value","key-name","level","path","expanded","is-last"])]))),128))]),s.createElementVNode("div",xe,[s.createElementVNode("span",ke,s.toDisplayString(A.value),1),p.isLast?s.createCommentVNode("",!0):(s.openBlock(),s.createElementBlock("span",Oe,","))])])):s.createCommentVNode("",!0)])):(s.openBlock(),s.createElementBlock("div",Ce,[p.keyName&&!n.value?(s.openBlock(),s.createElementBlock("span",{key:0,class:"json-node__key",onClick:M,title:"Click to edit key"},' "'+s.toDisplayString(m.value)+'" ',1)):s.createCommentVNode("",!0),p.keyName&&n.value?s.withDirectives((s.openBlock(),s.createElementBlock("input",{key:1,"onUpdate:modelValue":_[5]||(_[5]=c=>u.value=c),onKeyup:[s.withKeys(R,["enter"]),s.withKeys($,["escape"])],onBlur:R,class:"json-node__key-input"},null,544)),[[s.vModelText,u.value]]):s.createCommentVNode("",!0),p.keyName?(s.openBlock(),s.createElementBlock("span",we,": ")):s.createCommentVNode("",!0),l.value?s.createCommentVNode("",!0):(s.openBlock(),s.createElementBlock("span",{key:3,class:s.normalizeClass(["json-node__value",P.value]),onClick:H,onDblclick:_[6]||(_[6]=c=>p.$emit("copy",p.value)),title:K.value},[s.createTextVNode(s.toDisplayString(F.value),1),p.isLast?s.createCommentVNode("",!0):(s.openBlock(),s.createElementBlock("span",Se,","))],42,Ae)),l.value?s.withDirectives((s.openBlock(),s.createElementBlock("input",{key:4,"onUpdate:modelValue":_[7]||(_[7]=c=>f.value=c),onKeyup:[s.withKeys(Q,["enter"]),s.withKeys(Y,["escape"])],onBlur:Q,class:"json-node__value-input"},null,544)),[[s.vModelText,f.value]]):s.createCommentVNode("",!0)]))])}}}),W=(r,e)=>{const t=r.__vccOpts||r;for(const[o,n]of e)t[o]=n;return t},ve=W(Ne,[["__scopeId","data-v-fdfd4b42"]]),Pe={class:"json-format"},Be={key:0,class:"json-format__toolbar"},De={class:"json-format__actions"},je=["disabled"],Ie=["disabled"],Te=["disabled"],$e=["disabled"],Re={class:"json-format__info"},Ve={key:0,class:"json-format__status json-format__status--success"},Ue={key:1,class:"json-format__status json-format__status--error"},Le={class:"json-format__content"},Me={key:0,class:"json-format__error"},Fe={key:1,class:"json-format__error"},Ke={key:2,class:"json-format__viewer"},Z=W(s.defineComponent({name:"JsonFormat",__name:"index",props:{modelValue:{default:""},readonly:{type:Boolean,default:!1},maxDepth:{default:10},showToolbar:{type:Boolean,default:!0}},emits:["update:modelValue","copy-success","copy-error","expand-all","collapse-all","compress"],setup(r,{expose:e,emit:t}){const o=r,n=t,l=s.ref(null),u=s.ref(""),f=s.ref(new Set),d=s.ref(null),h=s.ref(""),b=s.computed(()=>u.value===""),k=s.computed(()=>h.value?null:d.value!==null?d.value:l.value),w=a=>{if(!a.trim()){l.value=null,u.value="",d.value=null,h.value="";return}try{let c=a;c=c.replace(/:\s*(\d{16,})\s*([,}])/g,': "$1"$2'),c=c.replace(/:\s*(\d+\.\d*?0+)\s*([,}])/g,': "$1"$2'),l.value=JSON.parse(c),u.value="",d.value=null,h.value="",s.nextTick(()=>{k.value!==null&&U()})}catch(c){u.value=c instanceof Error?c.message:"Unknown parsing error",l.value=null,d.value=null,h.value=""}},m=a=>{if(!a||!a.expression.trim()){S();return}if(!l.value){h.value="No valid JSON data to filter";return}try{let c;if(a.type==="jsonpath")c=O({path:a.expression,json:l.value}),c.length===1&&a.expression.includes("$[")===!1&&!a.expression.endsWith("[*]")?d.value=c[0]:d.value=c;else if(a.type==="js")c=new Function("data",`
|
|
3
|
+
try {
|
|
4
|
+
return ${a.expression};
|
|
5
|
+
} catch (error) {
|
|
6
|
+
throw new Error('JavaScript expression error: ' + error.message);
|
|
7
|
+
}
|
|
8
|
+
`)(l.value),d.value=c;else throw new Error(`Unsupported filter type: ${a.type}`);h.value="",s.nextTick(()=>{U()})}catch(c){h.value=c instanceof Error?c.message:"Filter execution error",d.value=null}},S=()=>{d.value=null,h.value=""};s.watch(()=>o.modelValue,a=>{w(a)},{immediate:!0});const A=a=>{if(!/^-?\d+(\.\d+)?$/.test(a))return!1;const c=Number(a);return!Number.isSafeInteger(c)||a.length>15},D=(a,c,E)=>JSON.stringify(a,(y,g)=>{if(typeof g=="string"&&A(g))return`__BIG_NUMBER__${g}__BIG_NUMBER__`;if(typeof g=="string"&&/^-?\d+(\.\d+)?$/.test(g)){const x=Number(g);if(Number.isSafeInteger(x)&&x.toString()===g)return x;if(!Number.isNaN(x)&&isFinite(x)&&g.includes("."))return x.toString()===g?x:g;if(!Number.isNaN(x)&&isFinite(x))return x}return c&&typeof c=="function"?c(y,g):g},E).replace(/"__BIG_NUMBER__(.+?)__BIG_NUMBER__"/g,"$1"),P=(a,c)=>{if(!o.readonly)try{const E=F(l.value,a,c),y=D(E,null,2);n("update:modelValue",y)}catch(E){console.error("Failed to update JSON:",E)}},F=(a,c,E)=>{if(!c||c==="root")return E;const y=c.split("."),g=$(a,y.slice(0,-1));let x=g;for(let v=0;v<y.length-1;v++){const j=y[v];j!=="root"&&(Array.isArray(x)?x=x[parseInt(j)]:x=x[j])}const N=y[y.length-1];return N==="root"?E:(Array.isArray(x)?x[parseInt(N)]=E:x[N]=E,g)},K=a=>{f.value.has(a)?f.value.delete(a):f.value.add(a)},U=()=>{const a=new Set,c=(E,y="")=>{E!==null&&typeof E=="object"&&(a.add(y||"root"),Array.isArray(E)?E.forEach((g,x)=>{const N=y?`${y}.${x}`:`${x}`;c(g,N)}):Object.keys(E).forEach(g=>{const x=y?`${y}.${g}`:g;c(E[g],x)}))};c(k.value),f.value=a,n("expand-all")},X=()=>{f.value=new Set(["root"]),n("collapse-all")},L=async()=>{if(b.value)try{const a=k.value,E=JSON.stringify(a,null,2).replace(/"(\d{16,})"/g,"$1");await navigator.clipboard.writeText(E),n("copy-success",E)}catch(a){console.error("Failed to copy JSON:",a),n("copy-error",a instanceof Error?a:new Error("Failed to copy JSON"))}},M=()=>{if(b.value)try{const a=k.value,c=D(a);n("update:modelValue",c),n("compress",c)}catch(a){console.error("Failed to compress JSON:",a)}},H=async a=>{try{let c;typeof a=="string"&&A(a)?c=a:typeof a=="string"?c=`"${a}"`:c=JSON.stringify(a),await navigator.clipboard.writeText(c)}catch(c){console.error("Failed to copy value:",c)}},R=(a,c)=>{if(!o.readonly)try{const E=Q(l.value,a,c),y=D(E,null,2);n("update:modelValue",y),_(a,c)}catch(E){console.error("Failed to rename key:",E)}},Q=(a,c,E)=>{if(!c||c==="root")return a;const y=c.split("."),g=$(a,y.slice(0,-1));if(y.length===1){const v=y[0];return g&&typeof g=="object"&&!Array.isArray(g)?Y(g,v,E):g}let x=g;for(let v=0;v<y.length-1;v++){const j=y[v];Array.isArray(x)?x=x[parseInt(j)]:x=x[j]}const N=y[y.length-1];if(!Array.isArray(x)&&x&&typeof x=="object"){const v=Y(x,N,E),j=y.slice(0,-1);j.length>0&&p(g,j,v)}return g},$=(a,c)=>{if(c.length===0)return a;if(Array.isArray(a)){const E=[...a],y=c[0],g=parseInt(y);return c.length===1||(E[g]=$(a[g],c.slice(1))),E}else if(a&&typeof a=="object"){const E={...a},y=c[0];return c.length===1||(E[y]=$(a[y],c.slice(1))),E}return a},Y=(a,c,E)=>{if(!a||typeof a!="object"||Array.isArray(a))return a;const y=Object.keys(a),g={};for(const x of y)x===c?g[E]=a[x]:g[x]=a[x];return g},p=(a,c,E)=>{let y=a;for(let x=0;x<c.length-1;x++){const N=c[x];Array.isArray(y)?y=y[parseInt(N)]:y=y[N]}const g=c[c.length-1];Array.isArray(y)?y[parseInt(g)]=E:y[g]=E},_=(a,c)=>{const E=new Set;f.value.forEach(y=>{if(y===a){const g=a.split(".");g[g.length-1]=c,E.add(g.join("."))}else if(y.startsWith(a+".")){const g=a.split(".");g[g.length-1]=c;const x=g.join("."),N=y.substring(a.length);E.add(x+N)}else E.add(y)}),f.value=E};return e({copyJson:L,compressSource:M,expandAll:U,collapseAll:X,toggleExpand:K,updateValue:P,updateKey:R,filter:m,clearFilter:S,isValidJson:()=>b.value,getParsedJson:()=>l.value,getFilteredJson:()=>d.value,getExpandedNodes:()=>f.value,getParseError:()=>u.value,getFilterError:()=>h.value,parseJson:a=>w(a),copyValue:a=>H(a)}),(a,c)=>(s.openBlock(),s.createElementBlock("div",Pe,[a.showToolbar?(s.openBlock(),s.createElementBlock("div",Be,[s.createElementVNode("div",De,[s.createElementVNode("button",{class:"json-format__btn json-format__btn--primary",onClick:L,disabled:!b.value,title:"Copy JSON"}," 📋 Copy ",8,je),s.createElementVNode("button",{class:"json-format__btn json-format__btn--secondary",onClick:U,disabled:!b.value,title:"Expand All"}," ⬇️ Expand All ",8,Ie),s.createElementVNode("button",{class:"json-format__btn json-format__btn--secondary",onClick:X,disabled:!b.value,title:"Collapse All"}," ➡️ Collapse All ",8,Te),s.createElementVNode("button",{class:"json-format__btn json-format__btn--secondary",onClick:M,disabled:!b.value,title:"Compress JSON"}," 📦 Compress ",8,$e)]),s.createElementVNode("div",Re,[b.value?(s.openBlock(),s.createElementBlock("span",Ve," ✅ Valid JSON ")):(s.openBlock(),s.createElementBlock("span",Ue," ❌ Invalid JSON "))])])):s.createCommentVNode("",!0),s.createElementVNode("div",Le,[b.value?h.value?(s.openBlock(),s.createElementBlock("div",Fe,[c[1]||(c[1]=s.createElementVNode("h4",null,"Filter Error:",-1)),s.createElementVNode("pre",null,s.toDisplayString(h.value),1)])):(s.openBlock(),s.createElementBlock("div",Ke,[s.createVNode(ve,{value:k.value,"key-name":"",level:0,expanded:f.value,"is-last":!0,"onUpdate:value":P,onToggleExpand:K,onCopy:H,"onUpdate:key":R},null,8,["value","expanded"])])):(s.openBlock(),s.createElementBlock("div",Me,[c[0]||(c[0]=s.createElementVNode("h4",null,"JSON Parse Error:",-1)),s.createElementVNode("pre",null,s.toDisplayString(u.value),1)]))])]))}}),[["__scopeId","data-v-c212b38f"]]),Xe=[Z],He={install:r=>{Xe.forEach(e=>{const t=e.name||e.__name||"UnknownComponent";r.component(t,e)})}};I.JsonFormat=Z,I.default=He,Object.defineProperties(I,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lone-format",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A Vue 3 component library for formatting with tree-shaking support",
|
|
6
6
|
"main": "./dist/lone-format.umd.cjs",
|
|
@@ -34,7 +34,8 @@
|
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@types/json-bigint": "^1.0.4",
|
|
37
|
-
"json-bigint": "^1.0.0"
|
|
37
|
+
"json-bigint": "^1.0.0",
|
|
38
|
+
"jsonpath-plus": "^10.3.0"
|
|
38
39
|
},
|
|
39
40
|
"peerDependencies": {
|
|
40
41
|
"vue": ">=3.0.0"
|
|
@@ -47,6 +48,7 @@
|
|
|
47
48
|
"prettier": "^3.6.2",
|
|
48
49
|
"typescript": "~5.8.3",
|
|
49
50
|
"vite": "^7.0.4",
|
|
51
|
+
"vite-plugin-dts": "^4.5.4",
|
|
50
52
|
"vitepress": "^1.6.3",
|
|
51
53
|
"vue-tsc": "^2.2.12"
|
|
52
54
|
}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import type { PropType as __PropType } from 'vue';
|
|
2
|
-
declare const _sfc_main: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
3
|
-
value: {
|
|
4
|
-
type: __PropType<any>;
|
|
5
|
-
required: true;
|
|
6
|
-
};
|
|
7
|
-
keyName: {
|
|
8
|
-
type: __PropType<string>;
|
|
9
|
-
required: true;
|
|
10
|
-
};
|
|
11
|
-
level: {
|
|
12
|
-
type: __PropType<number>;
|
|
13
|
-
required: true;
|
|
14
|
-
};
|
|
15
|
-
path: {
|
|
16
|
-
type: __PropType<string>;
|
|
17
|
-
required: false;
|
|
18
|
-
default: string;
|
|
19
|
-
};
|
|
20
|
-
expanded: {
|
|
21
|
-
type: __PropType<Set<string>>;
|
|
22
|
-
required: true;
|
|
23
|
-
};
|
|
24
|
-
isLast: {
|
|
25
|
-
type: __PropType<boolean>;
|
|
26
|
-
required: false;
|
|
27
|
-
default: boolean;
|
|
28
|
-
};
|
|
29
|
-
}>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("update:value" | "toggle-expand" | "copy" | "update:key")[], "update:value" | "toggle-expand" | "copy" | "update:key", import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
30
|
-
value: {
|
|
31
|
-
type: __PropType<any>;
|
|
32
|
-
required: true;
|
|
33
|
-
};
|
|
34
|
-
keyName: {
|
|
35
|
-
type: __PropType<string>;
|
|
36
|
-
required: true;
|
|
37
|
-
};
|
|
38
|
-
level: {
|
|
39
|
-
type: __PropType<number>;
|
|
40
|
-
required: true;
|
|
41
|
-
};
|
|
42
|
-
path: {
|
|
43
|
-
type: __PropType<string>;
|
|
44
|
-
required: false;
|
|
45
|
-
default: string;
|
|
46
|
-
};
|
|
47
|
-
expanded: {
|
|
48
|
-
type: __PropType<Set<string>>;
|
|
49
|
-
required: true;
|
|
50
|
-
};
|
|
51
|
-
isLast: {
|
|
52
|
-
type: __PropType<boolean>;
|
|
53
|
-
required: false;
|
|
54
|
-
default: boolean;
|
|
55
|
-
};
|
|
56
|
-
}>> & Readonly<{
|
|
57
|
-
"onUpdate:value"?: (...args: any[]) => any;
|
|
58
|
-
"onToggle-expand"?: (...args: any[]) => any;
|
|
59
|
-
onCopy?: (...args: any[]) => any;
|
|
60
|
-
"onUpdate:key"?: (...args: any[]) => any;
|
|
61
|
-
}>, {
|
|
62
|
-
path: string;
|
|
63
|
-
isLast: boolean;
|
|
64
|
-
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
65
|
-
export default _sfc_main;
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import type { PropType as __PropType } from 'vue';
|
|
2
|
-
declare const _sfc_main: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
3
|
-
modelValue: {
|
|
4
|
-
type: __PropType<string>;
|
|
5
|
-
required: true;
|
|
6
|
-
default: string;
|
|
7
|
-
};
|
|
8
|
-
readonly: {
|
|
9
|
-
type: __PropType<boolean>;
|
|
10
|
-
required: false;
|
|
11
|
-
default: boolean;
|
|
12
|
-
};
|
|
13
|
-
maxDepth: {
|
|
14
|
-
type: __PropType<number>;
|
|
15
|
-
required: false;
|
|
16
|
-
default: number;
|
|
17
|
-
};
|
|
18
|
-
showToolbar: {
|
|
19
|
-
type: __PropType<boolean>;
|
|
20
|
-
required: false;
|
|
21
|
-
default: boolean;
|
|
22
|
-
};
|
|
23
|
-
}>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("update:modelValue" | "copy-success" | "copy-error" | "expand-all" | "collapse-all" | "compress")[], "update:modelValue" | "copy-success" | "copy-error" | "expand-all" | "collapse-all" | "compress", import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
24
|
-
modelValue: {
|
|
25
|
-
type: __PropType<string>;
|
|
26
|
-
required: true;
|
|
27
|
-
default: string;
|
|
28
|
-
};
|
|
29
|
-
readonly: {
|
|
30
|
-
type: __PropType<boolean>;
|
|
31
|
-
required: false;
|
|
32
|
-
default: boolean;
|
|
33
|
-
};
|
|
34
|
-
maxDepth: {
|
|
35
|
-
type: __PropType<number>;
|
|
36
|
-
required: false;
|
|
37
|
-
default: number;
|
|
38
|
-
};
|
|
39
|
-
showToolbar: {
|
|
40
|
-
type: __PropType<boolean>;
|
|
41
|
-
required: false;
|
|
42
|
-
default: boolean;
|
|
43
|
-
};
|
|
44
|
-
}>> & Readonly<{
|
|
45
|
-
"onUpdate:modelValue"?: (...args: any[]) => any;
|
|
46
|
-
"onCopy-success"?: (...args: any[]) => any;
|
|
47
|
-
"onCopy-error"?: (...args: any[]) => any;
|
|
48
|
-
"onExpand-all"?: (...args: any[]) => any;
|
|
49
|
-
"onCollapse-all"?: (...args: any[]) => any;
|
|
50
|
-
onCompress?: (...args: any[]) => any;
|
|
51
|
-
}>, {
|
|
52
|
-
modelValue: string;
|
|
53
|
-
readonly: boolean;
|
|
54
|
-
maxDepth: number;
|
|
55
|
-
showToolbar: boolean;
|
|
56
|
-
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
57
|
-
export default _sfc_main;
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* JsonFormat 组件暴露的方法接口
|
|
3
|
-
*/
|
|
4
|
-
export interface JsonFormatExposed {
|
|
5
|
-
copyJson: () => Promise<void>;
|
|
6
|
-
expandAll: () => void;
|
|
7
|
-
collapseAll: () => void;
|
|
8
|
-
toggleExpand: (path: string) => void;
|
|
9
|
-
updateValue: (path: string, newValue: any) => void;
|
|
10
|
-
updateKey: (oldPath: string, newKey: string) => void;
|
|
11
|
-
isValidJson: () => boolean;
|
|
12
|
-
getParsedJson: () => any;
|
|
13
|
-
getExpandedNodes: () => Set<string>;
|
|
14
|
-
getParseError: () => string;
|
|
15
|
-
parseJson: (jsonString: string) => void;
|
|
16
|
-
copyValue: (value: any) => Promise<void>;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* JsonFormat 组件的 Props 接口
|
|
20
|
-
*/
|
|
21
|
-
export interface JsonFormatProps {
|
|
22
|
-
modelValue: string;
|
|
23
|
-
readonly?: boolean;
|
|
24
|
-
maxDepth?: number;
|
|
25
|
-
showToolbar?: boolean;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* JsonFormat 组件的事件接口
|
|
29
|
-
*/
|
|
30
|
-
export interface JsonFormatEmits {
|
|
31
|
-
'update:modelValue': [value: string];
|
|
32
|
-
'copy-success': [value: string];
|
|
33
|
-
'copy-error': [error: Error];
|
|
34
|
-
'expand-all': [];
|
|
35
|
-
'collapse-all': [];
|
|
36
|
-
}
|