@code-recycle/cli
Version:
高级语法查询替换工具;Advanced syntax query replacement tool
215 lines • 55.5 kB
JavaScript
'use strict';exports.id=661,exports.ids=[661],exports.modules={96928:(e,t,n)=>{n.d(t,{J:()=>d});var r=n(23659),a=n(79670),i=n(28786),o=n(42551),s=n.n(o),l=n(43592),c=n(7460),u=n(1561),h=n(3283),p=(n(70582),n(57944)),f=n(3084);class d{filePathGroup
;documentContext;lodash=s();path={join:c.join,normalize:c.normalize,resolve:c.resolve,relative:c.relative,basename:c.basename,dirname:c.dirname,isAbsolute:c.isAbsolute,getSystemPath:c.getSystemPath,split:c.split};parserList;#e=(0,r.inject)(i.r)
;rule=this.#e.runnerCall;host=(0,r.inject)(l.j_);injector=(0,r.inject)(r.Injector);#t=(0,r.inject)(l.sR);#n=(0,r.inject)(l.DB);constructor(){this.filePathGroup={currentDir:this.injector.get(l.Wd),currentPath:this.injector.get(l.Kz),
root:this.injector.get(l.ge),scriptCwd:this.#n.scriptCwd},this.documentContext=this.injector.get(l.st),this.parserList=this.injector.get(h.d).parserList}#r;getRootContext(){return this.#r||(this.#r=new a.cY(this)),this.#r}initContext(){
return new a.cY(this)}#a;setCustomPipe(e){this.#a=e}pipeFactory(e){return{...this.#i(e),path:this.path,lodash:this.lodash,_:this.lodash,editorInput:this.rule.read.editorInput,...this.#a?.()}}async changeList(e,t=new a.cY(this)){t.root=t;let n=[]
;for(let r=0;r<e.length;r++){const i=e[r];if(i.disable&&await(0,a.vh)(i.disable,t))continue;let o;if('create'===i.type){let e=await(0,a.vh)(i.path,t);if(!e)continue;await this.rule.operator.newFile(e,await(0,a.vh)(i.content,t))}else if('copy'===i.type){
let e=await Promise.all((0,f.O)(i.from).map((e=>(0,a.vh)(e,t))));if(!e)continue;let n=await(0,a.vh)(i.to,t)
;await this.rule.operator.template(e.filter(Boolean),n,i.source,i.excludeList??this.#t.default?.fileQueryLayer.excludeList,i.ignoreList??this.#t.default?.fileQueryLayer.ignoreList,i,!1,{...i.strategy,...this.#t.default?.templateStrategy})}else{let e
;if(o=await this.getFileParser(i,t),o instanceof Array){let n=t.create(void 0,i.name);e=new a.nE(this.rule,o.map(((e,r)=>{let a=n.create(e,r);return a.root=t,a.file=a,a})),this.#t.default?.nodeQueryOption)}else e=new a.nE(this.rule,[o].map((e=>{
let n=t.create(e,i.name);return n.root=t,n.file=n,n})),this.#t.default?.nodeQueryOption);let r=await e.query(i.list.flat(1));if(i.newPath){await e.updateList(r),await e.createNewFile(i.newPath,i.query);continue}i.update?await e.updateList(r):n.push(...r)}
}return n}async updateChangeList(e){await this.rule.operator.replaceNode(e,(e=>e),(e=>s().get(e,'node.range')),(e=>s().get(e,'node.value')))}async getFileParser(e,t){let n,r=e.parser;if(e.glob)n=await this.rule.read.fileResolveByPattern(await(0,
a.vh)(e.path,t),void 0,{all:!0,languageOption:r});else if(e.path)n=await this.rule.read.fileResolve(await(0,a.vh)(e.path,t),r);else{if(!e.content)throw new Error(u.$localize`缺少解析内容`);n=await this.rule.read.contentResolve(await(0,a.vh)(e.content,t),r)}
for(const e of n instanceof Array?n:[n])if('string'!=typeof e.content)throw new Error(u.$localize`[路径]${e.path||''}\n创建解析器失败`);return n}#i(e){return{ctxValue:t=>e.getNodeValue(t),ctxInferValue:(t,n)=>(e=e.getContext(t),
s().get(e.node?.node?.infer,n).value),ctxInferRange:(t,n)=>(e=e.getContext(t),s().get(e.node?.node?.infer,n).range),ctxData:t=>e.getContext(t).data,ctxFileContent:t=>e.getContext(t).node.content,ctxRange:t=>e.getContext(t).node.node.range}}
stringStatement=e=>'string'==typeof e?t=>(0,p.Q)(e)(this.pipeFactory(t)):e;static ɵfac=function(e){return new(e||d)};static ɵprov=r['ɵɵdefineInjectable']({token:d,factory:d.ɵfac})}},79670:(e,t,n)=>{n.d(t,{aG:()=>x,nE:()=>j,cY:()=>P,M3:()=>v,uH:()=>h,
p:()=>l,xf:()=>L,qY:()=>g,bQ:()=>o,vh:()=>w,zy:()=>E,mu:()=>c,sn:()=>N,CF:()=>A,E8:()=>s,AU:()=>u,or:()=>d,xt:()=>z,F:()=>_,CZ:()=>I,AM:()=>T,y1:()=>m,lS:()=>f,yX:()=>F,cT:()=>y,SZ:()=>p});var r=n(42551),a=n.n(r);function i(e){
return'string'==typeof e||e instanceof Promise}function o(e,t){return'function'==typeof e?e(t):e}function s(e,t){return n=>{let r=n.getContext(e,!1);return t?r.node.content.slice(...r.node.node.contentRange):r.node.node.value}}function l(e){
return t=>t.getContext(e)?.data}function c(e,t=(e=>'[value='+e+']')){return()=>`:is(${e.map(t).join(',')})`}function u(e){return t=>`:not(${e(t)})`}function h(e,t,n){return r=>o(e,r)?o(t,r):o(n,r)}function p(e,t=1,n=-1){return r=>o(e,r).slice(t,n)}
function f(e){return t=>o(e,t)}function d(...e){return t=>{for(let n=0;n<e.length;n++){let r=o(e[n],t);if('string'==typeof r)return r}return''}}function g(e){return t=>(t=t.getContext(e)).node.content}function m(e,t){
return n=>n.getContext(e).node.node[t?'contentRange':'range']}async function w(e,t){return v(e,[t])}async function y(e,t){return i(e)?t.util.stringStatement(await e)(t):e(t)}async function v(e,t){return'function'==typeof e?e(...t):e}
var b=n(26610),$=n(61773),C=n(1561),S=n(3084);async function O(e,t,n){if(!e)return[];let r=await e;return r?(r=(0,S.O)(r),r.filter(Boolean).map((e=>{if('value'in e&&'range'in e){let r=(0,b.kb)(t.node||n);if(r)return r.node??={},r.node.value=e.value,
r.node.range=e.range,r}return e}))):[]}async function k(e,t){if(e instanceof P)return e.node;if(function(e){return e instanceof $.Z}(e))return e;{let n=await t.getFileParser(e);return a().isArray(n)?n[0]:n}}class P{parent;name;children=[];data;node;root
;file;unFindMessage;#o;constructor(e,t,n,r){this.parent=n,this.name=r,this.#o=e,n&&n.children.push(this),t&&(this.node=t)}create(e,t){let n=new P(this.#o,e,this,t);return n.root=this.root,n.file=this.file,n}get util(){return this.#o}get index(){
return this.parent?this.parent.children.findIndex((e=>e===this)):-1}get pipe(){return this.#o.pipeFactory(this)}getContext(e='',t=!1){if(e instanceof Array&&!e.length||!e)return this;let n='string'==typeof e?a().toPath(e):e,r=n[0]
;if('root'===r)return this.root.getContext(n.slice(1));if('item'===r)return this.file.getContext(n.slice(1));if(r.startsWith('parent')){let e=this.#s(r.slice(6));if(e)return e.getContext(n.slice(1));if(t)return;throw new Error('查询父级异常')}{let a=+r
;if(!isNaN(a)){if(this.children[a])return this.children[a].getContext(n.slice(1));if(!t)throw new Error('查询索引异常')}let i=this.#l(r);if(i)return i.getContext(n.slice(1));if(!t)throw new Error(`查询后代${e}异常异常`)}}#l(e){let t=[this];for(;t.length;){
let n=t.shift();for(const r of n.children){if(r.name===e)return r;t.push(r)}}}#s(e){let t=''===e?1:+e,n=this;for(;t;){if(!n.parent)return;n=n.parent,t--}return n}getNode(e='',t=!1){return this.getContext(e,t)?.node}getNodeValue(e='',t=!1){
return this.getContext(e,t)?.node?.node?.value}mark(e){this.unFindMessage=e}}class j{rule;defaultOption;#c;constructor(e,t,n){this.rule=e,this.defaultOption=n,this.#c=t}updateList(e){
return this.rule.operator.replaceNode(e,(e=>e),(e=>a().get(e,'node.range')),(e=>a().get(e,'node.value')))}async createNewFile(e,t){for(const n of this.#c){let r;r=t?(await this.rule.query.selector(n.node,t,!1)).node?.value:n.node.content,
await this.rule.operator.newFile('string'==typeof e?e:e(n.node),r)}}async query(e){let t=[];for(const n of this.#c)t.push(await this.#u(e,n));return t.flat()}async#u(e,t,n){let r=!1,a=[];for(const i of e){let e={matched:!0,list:[]}
;'allOf'in i?e.list=await this.#u(i.allOf,t,'allOf'):'oneOf'in i?e.list=await this.#u(i.oneOf,t,'oneOf'):'anyOf'in i?e.list=await this.#u(i.anyOf,t,'anyOf'):'not'in i?e.list=await this.#u([i.not],t,'not'):('oneOf'===n||'anyOf'===n||'not'===n?i.optional=!0:'allOf'===n&&(i.optional=!1),
e=await this.#h(i,t));let o=e.list;if('allOf'===n){if(!e.matched)throw new Error(C.$localize`allOf 模式失败`);a.push(o)}else if('oneOf'===n&&e.matched){if(r)throw new Error(C.$localize`oneOf 模式失败`);r=!0,a.push(o)}else{if('anyOf'===n&&e.matched){a.push(o),r=!0
;break}if('not'===n){if(e.matched)throw new Error(C.$localize`not 模式失败`)}else a.push(o)}}if('anyOf'===n&&!r)throw new Error(C.$localize`anyOf 模式失败`);return a.flat()}async#h(e,t){let n=[],r=[t],a=t.parent,i=t.index;e:for(;r.length;){let t=r.shift()
;t.parent=a,a&&(a.children[i]=t);const o=t.create(void 0,e.name);if(e.disable&&await w(e.disable,o))return{matched:!1,list:n};let s,l=await v(e.parentMap,[o]);s=l?'string'==typeof l?o.getContext(l).node:await k(await v(l,[o]),o.util):t.node
;let c=e.children?.flat(1);if(!e.query){o.node=s,n.push(...await this.#p(o,e,c,0,s));let t=this.#f(o,e,0);if(!1===t)break e;r.push(...t);continue}
let u=await y(e.query,o),h=e.multi??this.defaultOption?.multi??!1,p=await this.#d(s,u,h,e.mode,e.modeOptions),f=s.node?.value?C.$localize`[父级内容]${s.node?.value}\n`:'',d=e.description?C.$localize`[描述]${e.description}\n`:'',g=e.nullable??this.defaultOption?.nullable,m=e.optional??this.defaultOption?.optional,b=C.$localize`${f}[可空]${!!g}\n[多选]${h}\n${d}[路径]${s.path||''}\n[解析器]${JSON.stringify(s.languageConfig)}\n[查询]${u}\: 未查询到内容`
;if((!p||p instanceof Array&&!p.length)&&!g){if(m)return o.mark(b),{matched:!1,list:n};throw new Error(b)}if(h){for(let t=0;t<p.length;t++){const a=p[t];let i=o.create(a,t);n.push(...await this.#p(i,e,c,t,s));let l=this.#f(i,e,t);if(!1===l)break e
;r.push(...l)}e.listCallback&&n.push(...await O(e.listCallback(o.children,o),o,s))}else{o.node=p,n.push(...await this.#p(o,e,c,0,s));let t=this.#f(o,e,0);if(!1===t)break e;r.push(...t)}}return{matched:!0,list:n}}#d(e,t,n,r,a){
return'like'===(r=r??this.defaultOption?.mode)?this.rule.query.like(e,t,n?1/0:1,a):this.rule.query.selector(e,t,n,a)}async#p(e,t,n,r,i){let o=[];if(n&&o.push(...await this.#u(n,e)),(t.query||t.range)&&e.node){let n,r,s=(0,b.kb)(e.node)
;if(t.query&&([n,r]=a().get(s,'node.range')),t.range){let a=await v(t.range,[e,void 0!==n?[n,r]:void 0]);[n,r]=a||[n,r]}if(void 0===n||void 0===r)throw new Error(C.$localize`替换时未找到替换范围\n配置:${(0,b.Jm)(t)}`);let l=await v(t.offset,[e])||[0,0]
;if(t.delete??this.defaultOption?.delete)a().set(s,'node.value',''),a().set(s,'node.range',[n+l[0],r+l[1]]),o.push(s);else if(t.replace){t.insertBefore??this.defaultOption?.insertBefore?r=n:(t.insertAfter??this.defaultOption?.insertAfter)&&(n=r)
;let a=await this.#g(t.replace,e,i,[n+l[0],r+l[1]]);o.push(...a)}}if(t.callback){let n=await O(t.callback(e,r),e,i);o.push(...n)}return o}async#g(e,t,n,r){let o=[];if('object'!=typeof e||e instanceof Promise){let i=(0,b.kb)(t.node||n)
;return a().set(i,'node.value',`${await y(e,t)}`),r&&a().set(i,'node.range',r),[i]}{let n=t.node?.node?.infer;if(!n)return[];for(const r in e){const s=e[r];let l=n[r];if(!l)throw new Error(C.$localize`替换时没有找到变量[${r}]`);let c=(0,S.O)(l);for(let e of c){
let n=t.node?.cloneNode(e);if(i(s))a().set(n,'node.value',`${await y(s,t)}`);else{let r=await v(s,[t,(0,b.kb)(e)]);'string'==typeof r?a().set(n,'node.value',r):(a().set(n,'node.value',`${r.value}`),r.range&&a().set(n,'node.range',r.range))}o.push(n)}}
return o}}#f(e,t,n){if(t.loop){let r=t.loop(e,n);if(!0===r)return[];if(!1===r)return!1;{let t=[];for(const n of r){let r=new P(e.util,n,void 0,e.name);r.file=e.file,r.root=e.root,t.push(r)}return t}}return[]}}function x(e,t,n='import'){let r=(0,b.kb)(e)
;return a().set(r,'node.value','string'==typeof t?t:E(t,n)),a().set(r,'node.range',[0,0]),r}function E(e,t='import'){let n=''
;for(const r of e)r.default?n+=`${t} ${r.importList[0]} from '${r.path}';`:n+=`${t} ${r.type?'type':''} { ${r.importList.join(',')} } from '${r.path}';`,n+='\n';return n}function L(e){return{
query:String.raw`ImportDeclaration:has(>StringLiteral[value=\'${e}'])`,delete:!0,optional:!0,multi:!0}}function F(e,t){return{query:String.raw`ImportDeclaration>FromKeyword+*[value=\'${e}']`,replace:`'${t}'`}}function T(e,t){
let n=String.raw`ImportDeclaration:has(>StringLiteral[value=\'${e}'])`;return t&&t.length?n+t.map((e=>':has(ImportSpecifier[value='+e+'])')).join(''):n}function _(e,t){return`${t}:has(>Identifier[value=${e}])`}function z(e){
return`CallExpression:has(>Identifier[value=${e}])`}function I(e){return String.raw`ImportDeclaration:has(>StringLiteral[value=\'${e}\'])`}
const N=':is(VariableDeclaration>Identifier,BindingElement>ColonToken+*,PropertyAccessExpression::children(0),CallExpression>SyntaxList>Identifier,BinaryExpression>Identifier,ConditionalExpression>Identifier,PropertyAssignment>ColonToken+Identifier,CallExpression>Identifier,ParenthesizedExpression>OpenParenToken+Identifier)'
;function A(e,t,n){return{...n,query:`CallExpression::children(0)[value=${e}]`,replace:t,multi:!0,optional:!0}}},57944:(e,t,n)=>{n.d(t,{Q:()=>_});var r=n(1561),a=n(98882),i=n(42551),o=n.n(i);const s=(0,a.Ey)({name:'content',
pattern:/(\\\{\{|\{[^\{]|[^\{])+/}),l=(0,a.Ey)({name:'whitespace',pattern:/\s+/,group:a.JG.SKIPPED}),c=(0,a.Ey)({name:'interpolation-left',pattern:'{{',push_mode:'interpolation'}),u=(0,a.Ey)({name:'interpolation-right',pattern:'}}',pop_mode:!0}),h=(0,
a.Ey)({name:'pipeCallSymbol',pattern:'|',push_mode:'pipeName'}),p=(0,a.Ey)({name:'pipeParamSymbol',pattern:':'}),f=(0,a.Ey)({name:'pipeString1Param',pattern:/(\\[']|[^'])+/}),d=(0,a.Ey)({name:'pipeString2Param',pattern:/(\\["]|[^"])+/}),g=(0,a.Ey)({
name:'pipeName',pattern:/([\w$_]+\.?)+/,pop_mode:!0}),m=(0,a.Ey)({name:'bracketLeft',pattern:'(',push_mode:'subPipe'}),w=(0,a.Ey)({name:'bracketRight',pattern:')',pop_mode:!0}),y=(0,a.Ey)({name:'quote1Left',pattern:'\'',push_mode:'string1'}),v=(0,a.Ey)({
name:'quote1Right',pattern:'\'',pop_mode:!0}),b=(0,a.Ey)({name:'quote2Left',pattern:'"',push_mode:'string2'}),$=(0,a.Ey)({name:'quote2Right',pattern:'"',pop_mode:!0}),C=(0,a.Ey)({name:'numberToken',pattern:/\d+(\.\d+)?/}),S=(0,a.Ey)({name:'booleanToken',
pattern:/true|false/}),O=(0,a.Ey)({name:'bracket2Left',pattern:'['}),k=(0,a.Ey)({name:'bracket2Right',pattern:']'}),P=(0,a.Ey)({name:'commaToken',pattern:','}),j={modes:{default:[c,s,l],interpolation:[h,p,u,l,m,w,y,b,C,S,O,k,P],
subPipe:[h,p,l,m,w,y,b,C,S,O,k,P],pipeName:[l,g],string1:[v,f],string2:[$,d]},defaultMode:'default'},x=new a.JG(j);var E;function L(e,t){let n=[],a=e.value;for(const i of e.pipeList){
for(const e of i.paramList)e.type===E.value?n.push(e.value):n.push(L(e,t));let e=o().get(t,i.name);if(!e)throw new Error(r.$localize`未找到管道[${i.name}]`);a=e(a,...n)}return a}!function(e){e[e.pipe=0]='pipe',e[e.value=1]='value'}(E||(E={}))
;class F extends a.jr{program;constructor(){super(j);const e=this;let t=e.RULE('string1Param',(()=>{e.CONSUME(y);let t=e.OPTION((()=>e.CONSUME(f).image));return e.CONSUME(v),e.ACTION((()=>t?.replace(/\\'/g,'\'')||''))})),n=e.RULE('string2Param',(()=>{
e.CONSUME(b);let t=e.OPTION((()=>e.CONSUME(d).image));return e.CONSUME($),e.ACTION((()=>t?.replace(/\\'/g,'\'')||''))})),r=e.RULE('stringParam',(()=>e.OR([{ALT:()=>e.SUBRULE(t)},{ALT:()=>e.SUBRULE(n)}]))),a=e.RULE('literalParam',(()=>e.OR([{
ALT:()=>e.SUBRULE(r)},{ALT:()=>+e.CONSUME(C).image},{ALT:()=>'true'===e.CONSUME(S).image},{ALT(){e.CONSUME(O);let t=[];e.MANY({GATE:()=>e.LA(2).tokenType===P,DEF:()=>{t.push(e.SUBRULE(a)),e.CONSUME(P)}});let n=e.OPTION((()=>e.SUBRULE1(a)))
;return n&&t.push(n),e.CONSUME(k),t}}]))),i=e.RULE('pipe',(()=>{let t=e.SUBRULE(a),n=[];return this.OPTION((()=>{this.MANY((()=>{e.CONSUME(h);let t=e.CONSUME(g).image,r=[];return this.OPTION1((()=>{this.MANY1((()=>{e.CONSUME(p);let t=this.OR([{ALT(){
e.CONSUME(m);let t=e.SUBRULE1(i);return e.CONSUME(w),t}},{ALT(){let t=e.SUBRULE1(a);return e.ACTION((()=>({value:t,type:E.value})))}}]);e.ACTION((()=>{r.push(t)}))}))})),e.ACTION((()=>{n.push({name:t,paramList:r})}))}))})),{value:t,pipeList:n,type:E.pipe}
}));this.program=e.RULE('program',(()=>{let t=[];return this.MANY({DEF:()=>{const n=this.OR([{ALT:()=>{let t=e.CONSUME(s);return e.ACTION((()=>()=>t.image.replace(/\\{{/g,'{{')))}},{ALT:()=>{e.CONSUME(c);let t=e.SUBRULE(i);return e.CONSUME(u),
e.ACTION((()=>e=>L(t,e)))}},{ALT:()=>{this.OPTION((()=>{this.CONSUME(l)}))}}]);n&&t.push(n)}}),t})),this.performSelfAnalysis()}}const T=new F;function _(e){const t=x.tokenize(e);T.input=t.tokens;const n=T.program();if(T.errors.length)throw T.errors[0]
;return e=>1===n.length?n[0](e):n.map((t=>t(e))).join('')}},77898:(e,t,n)=>{n.d(t,{K:()=>i});var r=n(99949),a=n(1561);function i(e,t){return t?async(e,n,a,i)=>{let o=(0,r.I)(t,e.stringStatement);return async()=>{let t=await e.changeList(o.list)
;await e.updateChangeList(t)}}:async(t,n,r,i)=>{let o=await async function(e){let t;if(delete require.cache[e],t=require(e),'function'==typeof t)return t;if('function'==typeof t.default)return t.default;throw new Error(a.$localize`请求[${e}]异常`)}(e)
;return async()=>o(t,n,r,i)}}},99949:(__unused_webpack_module,__webpack_exports__,__webpack_require__)=>{__webpack_require__.d(__webpack_exports__,{I:()=>yamlConfig,h:()=>parseYaml})
;var yaml__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(91198),_util_wrap_array__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(3084);const jsFn={identify:e=>'function'==typeof e,tag:'!js/function',resolve:str=>eval(str)};function parseYaml(e){
return(0,yaml__WEBPACK_IMPORTED_MODULE_0__.qg)(e,{customTags:[jsFn]})}function yamlConfig(e,t){let n=e.changeList;for(const e of n)'copy'===e.type?(e.from&&(e.from=(0,
_util_wrap_array__WEBPACK_IMPORTED_MODULE_1__.O)(e.from).map((e=>('string'==typeof e&&(e=t(e)),e)))),void 0!==e.to&&(e.to=t(e.to)),void 0!==e.disable&&(e.disable=t(e.disable))):'create'===e.type?(void 0!==e.path&&(e.path=t(e.path)),
void 0!==e.content&&(e.content=t(e.content)),void 0!==e.disable&&(e.disable=t(e.disable))):'query'!==e.type&&e.type||(void 0!==e.disable&&(e.disable=t(e.disable)),void 0!==e.path&&(e.path=t(e.path)),void 0!==e.content&&(e.content=t(e.content)),
e.list=nodeQueryStatement(e.list.flat(),t));return{list:n,data:e}}function nodeQueryStatement(e,t){
for(const n of e)'allOf'in n?nodeQueryStatement(n.allOf,t):'oneOf'in n?nodeQueryStatement(n.oneOf,t):'anyOf'in n?nodeQueryStatement(n.anyOf,t):'not'in n?nodeQueryStatement([n.not],t):(void 0!==n.disable&&(n.disable=t(n.disable)),
void 0!==n.range&&(n.range=t(n.range)),void 0!==n.disable&&(n.disable=t(n.disable)),n.children&&nodeQueryStatement(n.children.flat(),t));return e}},28786:(e,t,n)=>{n.d(t,{r:()=>I})
;var r=n(7698),a=n(20806),i=n(7460),o=n(42551),s=n.n(o),l=n(61773),c=n(73526),u=n(23659),h=n(43592),p=n(43488),f=n(44725),d=n(56115),g=n(31421);async function m(e,t){if(e.message&&await t.outputLog(e.message),
e.errorMessage&&await t.outputWarn(e.errorMessage),e.error&&await t.outputError(`[${e.code}]${e.error}`),e.code)throw new Error('')}function w(e,t,n){return new Promise(((r,a)=>{const i=(0,g.execFile)(e,t,{maxBuffer:1048576e3,...n},((e,t,n)=>{r({
message:t,errorMessage:n,code:i.exitCode,error:e?.message})}))}))}var y=n(50914),v=n(79896),b=n.n(v),$=n(62607),C=n(7394),S=n(89101),O=n(7304),k=n(3283),P=n(68178),j=n(33143),x=n(99096),E=n(1561),L=n(67617),F=n(77898),T=n(96928),_=n(99949),z=n(57944)
;class I{injector=(0,u.inject)(u.Injector);host=(0,u.inject)(h.j_);#m=(0,u.inject)(h.Ve);#w=(0,u.inject)(P.t);#t=(0,u.inject)(h.sR);#y=(0,u.inject)(h.DB);#v=(0,u.inject)(h.Wd);#b=(0,u.inject)(k.d);#$=(0,u.inject)(h.st,{optional:!0});extraRule={}
;#C=this.injector.get(S.I);constructor(){}async#S(e,t){const n=t,r=e;return new l.Z(r,this.#b,n)}#O(e){const t=s().toPath(e),n=t.shift(),r=this.#w.get(n);return t.length?s().get(r,t):r}runnerCall={call:{script:async e=>{let t
;(e.endsWith('.yml')||e.endsWith('.yaml'))&&(t=(0,_.h)(await this.host.readContent((0,i.normalize)(e))));let n=await(0,F.K)(e,t);const r=this.injector.get(I);let a=this.injector.get(T.J);return(await n(a,r.runnerCall,r.host,r.injector))()}},read:{
fileResolveByPattern:async(e,t,n={queryMode:0,all:!1})=>{const r={},a=await this.host.queryFile(this.#v,{filePattern:e,queryMode:n.queryMode||0,ignore:n.ignore},(async e=>{if(!r[e]){
const t=await this.host.readContent(e),a=new l.Z(t,this.#b,n.languageOption||this.#k(e),e);r[e]=a}if(!t)return!0;const a=r[e];return!!(await(0,$.firstValueFrom)(a.resolve$$)).queryOne(t)}));return a?n.all?a.map((e=>r[e])):r[a[0]]:n.all?[]:void 0},
fileResolve:async(e,t)=>{let n=!0,r=e;'string'==typeof r&&(r=[r],n=!1);const a=[];for(const e of r){const n=(0,i.resolve)(this.#v,(0,i.normalize)(e)),r=await this.host.readContent(n);if(void 0===r)throw new Error(E.$localize`读取[${n}]失败`)
;const o=new l.Z(r,this.#b,t||this.#k(n),n);a.push(o)}return n?a:a[0]},contentResolve:async(e,t)=>this.#S(e,t),editorInput:async e=>this.#$[e],parseToObject:async(e,t)=>{const n=await(0,$.firstValueFrom)(this.host.read((0,i.resolve)(this.#v,(0,
i.normalize)(e))));let r;return r='json'===t?JSON.parse((0,p.YI)(n,e)):'plain'===t?(0,p.YI)(n,e):'yaml'===t?(0,_.h)((0,p.YI)(n)):n,r},setting:async e=>this.#t.get(e)},query:{selector:async(e,t,n=!1,r)=>{const a=await(0,
$.firstValueFrom)(e.resolve$$),i=e.node;if(n)return(i?a.queryAll(i,t,r):a.queryAll(t,r)).map((t=>e.cloneNode(t)));{const n=i?a.queryOne(i,t,r):a.queryOne(t,r);return n?e.cloneNode(n):void 0}},like:async(e,t,n,r)=>{const a=await(0,
$.firstValueFrom)(e.resolve$$),i=e.node;let o=(i?a.match(i,t,{...r,count:n}):a.match(t,{...r,count:n})).map((t=>e.cloneNode(t)));return 1===n?o[0]:o}},resolve:{queryStatement:z.Q},operator:{replaceNode:async(e,t,n,o)=>{if(!e.length)return;const s=new Map
;let l=[];for(const r of e){const e=await t(r),a=await n(r),i=await o(r);l.push({file:e,range:a,content:i})}l=l.sort(((e,t)=>e.range[0]===t.range[0]&&e.range[1]===t.range[1]?0:(0,c.gR)(t.range,e.range)?-1:(0,
c.gR)(e.range,t.range)?1:e.range[0]-t.range[0]||e.range[1]-t.range[1]));for(const{file:e,range:t,content:n}of l){let a=e.path||e.id;s.has(a)||s.set(a,{file:e,list:[]});let i=s.get(a).list;if(t[0]===t[1])i.push(new r.q(t[0],n));else if(n)if(e.originNode){
let a=e.content.slice(t[0],t[1]),o=(0,j.h)(a,n,t[0]);for(const e of o)1===e.type?i.push(new r.q(e.start,e.content,Math.abs(t[1]-e.start)>Math.abs(t[0]-e.start)?'right':'left')):i.push(new r.Yu(e.start,e.length))
}else i.push(new r.L4(t[0],t[1]-t[0],n));else i.push(new r.Yu(t[0],t[1]-t[0]))}for(const{file:e,list:t}of s.values()){const n=a.C.update(e.content,t);e.path&&await(0,$.firstValueFrom)(this.host.write((0,i.resolve)(this.#v,(0,i.normalize)(e.path)),(0,
p.hq)(n))),e.refresh&&e.refresh(n)}},deleteFile:async e=>{await(0,d.Z)(this.host.delete((0,i.resolve)(this.#v,(0,i.normalize)(e))))},newFile:async(e,t)=>{await(0,$.firstValueFrom)(this.host.write((0,i.resolve)(this.#v,(0,
i.normalize)(e)),'string'==typeof t?(0,p.hq)(t):t))},renameFile:async(e,t)=>{await(0,$.firstValueFrom)(this.host.rename((0,i.resolve)(this.#v,(0,i.normalize)(e)),(0,i.resolve)(this.#v,(0,i.normalize)(t))))},insertSnippet:async(e,t)=>{throw new Error('')},
template:this.#C.template,commandExec:async(e,t,n)=>{const r=await w(e,t,{cwd:n});await m(r,this.#y.hint)}},globalVariable:{setStringByInteractive:async e=>this.#w.setString(e),setBooleanByInteractive:async e=>this.#w.setBoolean(e),set:async(e,t)=>{
this.#w.set(e,t)},get:async e=>{const t=s().toPath(e),n=t.shift(),r=this.#w.get(n);return t.length?s().get(r,t):r}},common:{getData:async(e,t)=>function(e,t){const n=s().toPath(t);let r=e;for(;n.length;){let e=n.shift()
;if(r instanceof x.uF)if('extra'===e){if(e=n.shift(),!e)return r.extra;{const t=r.extra[e];t instanceof x.Nz?r=t.value:t instanceof x.su?r=r.context.map.get(t.value)():t instanceof x.D$&&(r=r.context.map.get(t.value)(!0))}
}else r=s().get(r,e);else r=s().get(r,e)}return r}(e,t),didYouMean:async(e,t,n)=>{let r=t.filter((t=>t.startsWith(e)));return 1===r.length?r[0]:(r.length||(r=t),(0,f.Ay)(e,r,{thresholdType:f.w8.SIMILARITY,threshold:n.threshold}))},
rangeCompare:async(e,t,n)=>'contains'===t?(0,c.gR)(e,n):'reverse-contains'===t?(0,c.gR)(n,e):'intersection'===t?!!(0,c.E$)(e,n):'equal'===t?e[0]===n[0]&&e[1]===n[1]:'not-intersection'===t&&!(0,c.E$)(e,n)},view:{grid:async e=>{const t=[],n=[]
;let r=e.list.map((e=>e instanceof Array?e:[e]));for(let e=0;e<r.length;e++){const a=r[e];for(let r=0;r<a.length;r++){const i=a[r];if(!i)continue;const o='function'==typeof i.config?await i.config():i.config;o&&(i.x=r,i.y=e,i.cols??=1,t.push(o),
delete i.config,n.push(i))}}return{type:'grid',children:t,config:{list:n}}},label:async e=>({type:'label',config:e}),input:async(e,t)=>({type:'input',bind:e,config:t,value:await this.#O(e)}),checkbox:async(e,t)=>({type:'checkbox',bind:e,config:t,
value:await this.#O(e)}),button:async(e,t)=>({type:'button',callback:t,config:e}),select:async(e,t,n,r,a)=>{let i=[],o=await this.#O(e);for(let e=0;e<n.length;e++){const t=n[e],s=await r(t),l=await a(t);i.push({label:s,value:l}),o===l&&(o=e)}return{
type:'select',config:t,bind:e,list:i,value:o}},showData:async(e,t,n)=>({bind:e,config:t,data:n,type:'showData'})},os:{gitClone:async(e,t,n,r,a)=>{t=t||'*';const o=this.#t.gitCloneTmpDir;if(!o)throw new Error(E.$localize`gitCloneTmpDir 不能为空`);const s=(0,
y.x)({url:e,match:t,type:r,commit:a}),l=(0,i.join)((0,i.normalize)(o),s),c=(0,i.getSystemPath)(l),u=n?(0,i.join)(l,n):l;if(!await(0,d.d)(this.host.exists(u)).catch((()=>!1))||!(await(0,d.d)(this.host.list(u))).length){try{await b().promises.rm((0,
i.getSystemPath)(u),{recursive:!0})}catch(e){}const n='commit'!==r&&a?['--branch',a]:[];let o=await w('git',['clone','--filter=blob:none','--no-checkout','--sparse','--depth','1',...n,e,c]);m(o,this.#y.hint),t='string'==typeof t?[t]:t,
o=await w('git',['sparse-checkout','set','--no-cone',...t],{cwd:c}),m(o,this.#y.hint),o=await w('git',['checkout',a].filter(Boolean),{cwd:c}),m(o,this.#y.hint)}const h=new C.j(new O.p(this.host,this.#m),u);h.workspacePath=u;const p=await(0,
$.firstValueFrom)(h.list((0,i.normalize)(''))),f=await Promise.all(p.filter((e=>'.git'!==e)).map((async e=>(await(0,$.firstValueFrom)(h.stat(e))).isFile()?e:(await h.listAll(e)).map((t=>(0,i.join)(e,t)))))).then((e=>e.flat(1))),g={}
;for(const e of f)g[e]=await(0,$.firstValueFrom)(h.read(e));return g}},hint:this.#m};#k(e){let t=this.#b.getDefaultExtLanguageOptions(e)?.[0];if(L.$.parser(E.$localize`[${e}]使用默认解析器[${JSON.stringify(t)}]`),!t){
let t=E.$localize`未通过拓展名找到[${e}]的解析器,请手动指定一个类型;`;throw this.#m.outputError(t),new Error(t)}return t}static ɵfac=function(e){return new(e||I)};static ɵprov=u['ɵɵdefineInjectable']({token:I,factory:I.ɵfac})}},67617:(e,t,n)=>{n.d(t,{$:()=>s,o:()=>o})
;var r=n(1561),a=n(45753),i=n.n(a);const o={parser:r.$localize`解析器`,installParser:r.$localize`安装解析器`},s={parser:i()(o.parser),installParser:i()(o.installParser)}},61773:(e,t,n)=>{n.d(t,{Z:()=>s});var r=n(62607),a=n(74654),i=n(44746),o=n(34322);class s{
content;parserService;languageConfig;path;resolve$$;resolveCache$$;node;id=(0,o.A)();constructor(e,t,n,r){this.content=e,this.parserService=t,this.languageConfig=n,this.path=r,this.#P()}#P(){this.resolve$$=new r.Observable((e=>{
this.resolveCache$$?this.resolveCache$$.then((t=>{e.next(t)})):this.resolveCache$$=Promise.resolve(this.content).then((async t=>{const n=await this.parserService.getParserInstance(this.path??'',t,{},this.languageConfig);return e.next(n),n})).catch((t=>{
e.error(t)}))}))}refresh(e){this.resolveCache$$=void 0,this.content=e}cloneNode(e){const t=(0,a.k)(this);return t.node=e,Object.defineProperty(t,'originNode',{get:()=>e}),t}get originNode(){return this.node}toJSON(){let e
;return this.node&&(this.content.length<=this.node.range[1]?(e=[(0,i.A)(this.content,this.node.range[0]),(0,i.A)(this.content,this.content.length-1)],e[1].column+=1):e=[(0,i.A)(this.content,this.node.range[0]),(0,i.A)(this.content,this.node.range[1])]),{
node:this.node,content:'[[Please use nodeCommon.getData read]]',path:this.path,resolve$$:'[[Hidden]]',position:e}}}},7304:(e,t,n)=>{n.d(t,{p:()=>l});var r=n(7460),a=n(62607),i=n(1561),o=n(26610),s=n(90254);class l extends r.virtualFs.CordHost{delegate
;hint;constructor(e,t){super(e),this.delegate=e,this.hint=t}clear(){this._filesToCreate=new Set,this._filesToRename=new Map,this._filesToRenameRevert=new Map,this._filesToDelete=new Set,this._filesToOverwrite=new Set,this.reset()}async writeToVFS(e){
if(!this.records().length)return;let t=this.records();if(this.clear(),e)for(const e of t)if('create'===e.kind)await(0,o.KA)(e.content)?this.hint.outputLog(i.$localize`操作: ${e.kind}\n文件: ${e.path}\n内容: ${(0,
o.YI)(e.content)}`):this.hint.outputLog(i.$localize`操作: ${e.kind}\n文件: ${e.path}\n内容: [[二进制文件]]`);else if('delete'===e.kind)this.hint.outputLog(i.$localize`操作: ${e.kind}\n文件: ${e.path}`);else if('overwrite'===e.kind){let t=await(0,o.d4)(this.read(e.path))
;if(await(0,o.KA)(e.content)&&await(0,o.KA)(t)){let n=(0,o.YI)(t);this.hint.outputLog(i.$localize`操作: ${e.kind}\n文件: ${e.path}\n变更:\n${c((0,s.YB)(e.path,e.path,n,(0,o.YI)(e.content)))}`)
}else this.hint.outputLog(i.$localize`操作: ${e.kind}\n文件: ${e.path}\n变更: [[二进制文件]]`)}else'rename'===e.kind&&this.hint.outputLog(i.$localize`操作: ${e.kind}\n旧文件: ${e.from}\n新文件: ${e.to}`);else{const e=this.delegate;for(const n of t)'create'===n.kind?await(0,
a.firstValueFrom)(e.write(n.path,n.content)):'delete'===n.kind?await(0,a.firstValueFrom)(e.delete(n.path)):'overwrite'===n.kind?await(0,a.firstValueFrom)(e.write(n.path,n.content)):'rename'===n.kind&&await(0,a.firstValueFrom)(e.rename(n.from,n.to))}}
restore(e){this._filesToCreate.delete(e),this._filesToRename.delete(e),this._filesToRenameRevert.delete(e),this._filesToDelete.delete(e),this._filesToOverwrite.delete(e)}}function c(e){const t=[];for(let n=0;n<e.hunks.length;n++){const r=e.hunks[n]
;0===r.oldLines&&(r.oldStart-=1),0===r.newLines&&(r.newStart-=1),t.push('@@ -'+r.oldStart+','+r.oldLines+' +'+r.newStart+','+r.newLines+' @@'),t.push.apply(t,r.lines)}return t.join('\n')+'\n'}},7394:(e,t,n)=>{n.d(t,{j:()=>g});var r=n(7460),a=n(62607)
;class i{host;constructor(e){this.host=e}readdirSync=void 0;filterFolder;readdir=(e,t,n)=>{const i=(0,r.normalize)(e);let o,s;n?(o=t,s=n):s=t,this.host.exists(i).pipe((0,a.switchMap)((e=>e?this.host.list(i).pipe((0,a.catchError)((e=>{throw e})),(0,
a.switchMap)((e=>e.length?(0,a.combineLatest)(e.map((e=>(0,r.join)(i,e))).map((e=>this.host.stat(e).pipe((0,a.map)((t=>{let n=(0,r.normalize)('');return t.isDirectory()&&(n=e),t.isFile()&&(n=(0,r.dirname)(e)),
this.filterFolder&&!this.filterFolder.startsWith(n+'/')&&(0,r.relative)(this.filterFolder,n).startsWith('../')?void 0:o?.withFileTypes?{isBlockDevice:()=>!1,isCharacterDevice:()=>!1,isDirectory:()=>t.isDirectory(),isFIFO:()=>!1,isFile:()=>t.isFile(),
isSocket:()=>!1,isSymbolicLink:()=>!1,name:(0,r.basename)(e)}:e})))))).pipe((0,a.map)((e=>e.filter(Boolean)))):(0,a.of)([])))):(0,a.of)([]))),(0,a.first)()).subscribe({next:e=>{s(null,e)},error:e=>{s(new Error(e),[])}})};statSync=void 0;lstatSync=void 0
;stat=(e,t)=>{const n=(0,r.normalize)(e);(0,a.firstValueFrom)(this.host.stat(n).pipe((0,a.map)((e=>({isBlockDevice:()=>!1,isCharacterDevice:()=>!1,isDirectory:()=>e?.isDirectory()||!1,isFIFO:()=>!1,isFile:()=>e?.isFile()||!1,isSocket:()=>!1,
isSymbolicLink:()=>!1,name:e?(0,r.basename)(n):'',dev:0,ino:0,mode:0,nlink:0,uid:0,gid:0,rdev:0,size:e?.size||0,blksize:0,blocks:0,atimeMs:0,mtimeMs:0,ctimeMs:0,birthtimeMs:0,atime:e?.atime||0,mtime:e?.mtime||0,ctime:e?.ctime||0,birthtime:e?.birthtime||0
}))))).then((e=>{t(null,e)})).catch((e=>{t(e,void 0)}))};lstat=this.stat}var o=n(24441),s=n.n(o),l=n(26610),c=n(70857),u=n(82535),h=n.n(u),p=n(16928),f=n.n(p),d=n(84217);class g extends r.virtualFs.ResolverHost{delegate;path;#j=new i(this);_resolve(e){
return this.path?(0,r.resolve)(this.path,e):e}workspacePath;constructor(e,t){super(e),this.delegate=e,this.path=t}listAll(e,t){return function(e,t,n){if(!n)return()=>[];let i=(0,r.getSystemPath)(n);return async(o,l)=>{e.filterFolder=o
;let c=l?.ignoreList,u=l?.excludeList;const p=c?await s()(c,{fs:e,cwd:i,unique:!0,onlyFiles:!0,absolute:!0,dot:!0}).catch((()=>[])):[];e.filterFolder=void 0;const g=p.length?await(0,a.firstValueFrom)((0,a.combineLatest)(p.map((e=>t.readContent((0,
r.normalize)(e)).then((t=>({filePath:e,content:t})))))).pipe((0,a.map)((e=>e.flatMap((e=>function(e,t){const n=(0,d.A)(f().relative(t,f().dirname(e.filePath)))
;return e.content.split(/\r?\n/).filter((e=>e&&!e.startsWith('#'))).map((e=>((e,t)=>(e=>'!'===e[0])(e)?'!'+f().posix.join(t,e.slice(1)):f().posix.join(t,e))(e,n)))}(e,i))))))):[];let m=(0,r.relative)(t.workspacePath,o);const w=await s()((0,
r.join)(m,'**/*'),{fs:e,cwd:i,unique:!0,onlyFiles:!0,dot:!0,ignore:u?.map((e=>(0,r.join)(m,e)))});return h()().add(g).add(['.git']).filter(w).map((e=>(0,r.relative)(o,(0,r.join)(n,e))))}}(this.#j,this,this.workspacePath)(this._resolve(e),t)}
readContent(e,t){return(0,a.firstValueFrom)(this.read(e).pipe((0,a.map)((t=>(0,l.YI)(t,e))),(0,a.catchError)((()=>(0,a.of)(void 0)))))}async queryFile(e,t,n){let a=e,i=this.workspacePath,o=(0,r.relative)(i,a);for(;;){let e=(0,r.getSystemPath)((0,
r.normalize)(t.filePattern||'*'));const l=(await s()('win32'===(0,c.platform)()?e.replaceAll('\\','/'):e,{fs:this.#j,cwd:s().convertPathToPattern((0,r.getSystemPath)(a)),ignore:t.ignore})).map((e=>(0,r.resolve)(a,(0,r.normalize)(e)))),u=[]
;if(l.length)for(const e of l)await n(e)&&u.push(e);if(u.length)return u;if(1!==t.queryMode)return;if(''===o)return;a=(0,r.dirname)(a),o=(0,r.relative)(i,a)}}clear(){return this.delegate.clear()}writeToFs(e){return this.delegate.writeToVFS(e)}restore(e){
return this.delegate.restore(this._resolve(e))}records(){return this.delegate.records()}async pathDir(e){let t=await(0,a.firstValueFrom)(this.stat(e)).catch((()=>{}));return!t||t.isDirectory()?e:(0,r.dirname)(e)}}},68178:(e,t,n)=>{n.d(t,{t:()=>s})
;var r=n(23659),a=n(43592),i=n(42551),o=n.n(i);class s{#x=new Map;#E=(0,r.inject)(a.HU,{optional:!0});constructor(){}async setString(e){return this.#L(e,this.#E.setInput)}async setBoolean(e){return this.#L(e,this.#E.setBoolean)}#L(e,t){
let[n,r]=o().partition(e,(e=>e.force||!this.#x.has(e.name)));return Promise.all([t(n).then((e=>{for(const t in e){const n=e[t];this.#x.set(t,n)}return e})),Promise.resolve(r.reduce(((e,t)=>(e[t.name]=this.#x.get(t.name),e)),{}))]).then((([e,t])=>({...t,
...e})))}get(e){return this.#x.get(e)}has(e){return this.#x.has(e)}set(e,t){return this.#x.set(e,t),t}#F(){const e={};for(const[t,n]of this.#x.entries())e[t]=n;return e}static ɵfac=function(e){return new(e||s)};static ɵprov=r['ɵɵdefineInjectable']({
token:s,factory:s.ɵfac})}},70582:(e,t,n)=>{n.d(t,{B:()=>d});var r=n(1561),a=n(35317),i=n(79896),o=n.n(i),s=n(89213),l=n(16928),c=n(70857),u=n(34322),h=n(67617);const p={npm:'install',cnpm:'install',yarn:'add',pnpm:'install'},f={
'@cyia/parser-antlr4':'@cyia/parser-antlr4/-/parser-antlr4-1.0.2.tgz','@cyia/parser-tree-sitter':'@cyia/parser-tree-sitter/-/parser-tree-sitter-0.0.3.tgz','ts-node':'ts-node/-/ts-node-10.9.2.tgz'};async function d(e){let t
;if(t='package'!==e.mode&&e.mode?e.dir:(0,l.join)(e.dir,'node_modules',e.packageName),await o().promises.stat(t).catch((e=>!1)))return t;if('dir'===e.mode)throw new Error(r.$localize`文件夹[${t}]不存在`);if('package'!==e.mode&&e.mode){if('download'===e.mode){
h.$.installParser(r.$localize`准备下载解析器[${e.packageName}]`);for(const n of e.registryList||['https://registry.npmjs.org']){let a=`${n.replace(/\/$/,'')}/${f[e.packageName]}`,i=(0,l.join)((0,c.tmpdir)(),(0,u.A)());try{
let e=await fetch(a),n=await e.arrayBuffer();return await(0,s.kU)(Buffer.from(n),i),await o().promises.cp((0,l.join)(i,'package'),t,{recursive:!0}),await o().promises.rm(i,{recursive:!0}),h.$.installParser(r.$localize`下载完成`),t}catch(e){
h.$.installParser(r.$localize`${a} 下载依赖失败;切换下一个`)}}throw new Error(r.$localize`下载[${e.packageName}]失败,请检查镜像源`)}throw new Error('')}{let n=p[e.manager];return h.$.installParser(r.$localize`准备使用[${e.manager}]安装解析器[${e.packageName}]`),new Promise(((i,o)=>{
(0,a.spawn)(e.manager,[n,e.packageName,e.registryList?.length?`--registry="${e.registryList[0]}"`:void 0].filter(Boolean),{shell:!0,stdio:'inherit',cwd:e.dir,windowsHide:!0}).on('close',(e=>{0===e?(h.$.installParser(r.$localize`安装成功`),
i(t)):(h.$.installParser(r.$localize`安装失败`),o(void 0))}))}))}}},3283:(e,t,n)=>{n.d(t,{d:()=>h});var r=n(7460),a=n(62607),i=n(23659),o=n(43592),s=n(70582),l=n(1561),c=n(79896)
;const u=['cpp','css','html','java','javascript','json','lezer','markdown','php','python','rust','sass','xml'];class h{#T=async(e,t,i,o)=>(await n.e(292).then(n.bind(n,37292))).createCssSelectorForTreeSitter(t,{language:o.name,loadPackage:(0,
a.firstValueFrom)(this.#_.read((0,r.join)(this.#z,o.name+'.wasm'))).then((e=>({path:new Uint8Array(e)})))},i);#I=async(e,t,a,i)=>(await n.e(41).then(n.bind(n,55041))).createCssSelectorForAntlr4(t,{loadPackage:Promise.resolve(require((0,
r.getSystemPath)((0,r.join)(this.#N,`./grammars/${i.packagePath}/index.js`))))},a);#A=async(e,t,r,a)=>{switch(a.packageName){case'cpp':return(await n.e(776).then(n.bind(n,71776))).createCssSelectorForLezer(t,{
package$$:Promise.resolve().then(n.bind(n,49081))},r);case'css':return(await n.e(776).then(n.bind(n,71776))).createCssSelectorForLezer(t,{package$$:Promise.resolve().then(n.bind(n,79467))},r);case'html':
return(await n.e(776).then(n.bind(n,71776))).createCssSelectorForLezer(t,{package$$:Promise.resolve().then(n.bind(n,61869))},r);case'java':return(await n.e(776).then(n.bind(n,71776))).createCssSelectorForLezer(t,{
package$$:Promise.resolve().then(n.bind(n,81544))},r);case'javascript':return(await n.e(776).then(n.bind(n,71776))).createCssSelectorForLezer(t,{package$$:Promise.resolve().then(n.bind(n,81275))},r);case'json':
return(await n.e(776).then(n.bind(n,71776))).createCssSelectorForLezer(t,{package$$:Promise.resolve().then(n.bind(n,64374))},r);case'lezer':return(await n.e(776).then(n.bind(n,71776))).createCssSelectorForLezer(t,{
package$$:Promise.resolve().then(n.bind(n,21116))},r);case'markdown':return(await n.e(776).then(n.bind(n,71776))).createCssSelectorForLezer(t,{package$$:Promise.resolve().then(n.bind(n,64181))},r);case'php':
return(await n.e(776).then(n.bind(n,71776))).createCssSelectorForLezer(t,{package$$:Promise.resolve().then(n.bind(n,51092))},r);case'python':return(await n.e(776).then(n.bind(n,71776))).createCssSelectorForLezer(t,{
package$$:Promise.resolve().then(n.bind(n,462))},r);case'rust':return(await n.e(776).then(n.bind(n,71776))).createCssSelectorForLezer(t,{package$$:Promise.resolve().then(n.bind(n,8858))},r);case'sass':
return(await n.e(776).then(n.bind(n,71776))).createCssSelectorForLezer(t,{package$$:Promise.resolve().then(n.bind(n,79678))},r);case'xml':return(await n.e(776).then(n.bind(n,71776))).createCssSelectorForLezer(t,{
package$$:Promise.resolve().then(n.bind(n,22189))},r)}throw new Error('')};#c=[{use:'typescript',language:'typescript',parser:async(e,t,r,a)=>(await n.e(541).then(n.bind(n,23541))).createCssSelectorForTs(t,void 0,r)},{use:'@angular/compiler',
language:'ng-html',parser:async(e,t,r,a)=>await(await n.e(90).then(n.bind(n,22090))).createCssSelectorForNgHtml(t,{module$$:Promise.resolve().then(n.bind(n,36751))},r)},{use:'@angular/compiler',language:'html',
parser:async(e,t,r,a)=>await(await n.e(90).then(n.bind(n,22090))).createCssSelectorForHtml(t,{module$$:Promise.resolve().then(n.bind(n,36751))},r)},...[{language:'html',extraOptions:{xmlMode:!1}},{language:'xml',extraOptions:{xmlMode:!0}}].map((e=>({
use:'htmlparser2',language:e.language,parser:async(e,t,r,a)=>await(await n.e(712).then(n.bind(n,54712))).createCssSelectorForHtmlParser2(t,a,r)}))),{use:'jsonc-parser',language:'json',
parser:async(e,t,r,a)=>(await n.e(330).then(n.bind(n,5330))).createCssSelectorForJson(t,r)},{use:'gsql-ast-parser',language:'sql',parser:async(e,t,r,a)=>(await n.e(827).then(n.bind(n,86827))).createCssSelectorForPgsqlAstParser(t,r)},{
use:'@vue/compiler-dom',language:'vue',parser:async(e,t,r,a)=>(await n.e(0).then(n.bind(n,75e3))).createCssSelectorForVue(t,void 0,r)},{use:'typescript',language:'javascript',
parser:async(e,t,r,a)=>(await n.e(541).then(n.bind(n,23541))).createCssSelectorForTs(t,{scriptKind:(await Promise.resolve().then(n.t.bind(n,46661,23))).ScriptKind.JS},r)},{use:'typescript',language:'typescriptreact',
parser:async(e,t,r,a)=>(await n.e(541).then(n.bind(n,23541))).createCssSelectorForTs(t,{scriptKind:(await Promise.resolve().then(n.t.bind(n,46661,23))).ScriptKind.TSX},r)},{use:'typescript',language:'javascriptreact',
parser:async(e,t,r,a)=>(await n.e(541).then(n.bind(n,23541))).createCssSelectorForTs(t,{scriptKind:(await Promise.resolve().then(n.t.bind(n,46661,23))).ScriptKind.JSX},r)},{use:'yaml',language:'yaml',
parser:async(e,t,r,a)=>(await n.e(139).then(n.bind(n,91139))).createCssSelectorForYAML(t,r)},...u.map((e=>({use:'@lezer',language:e,parser:this.#A,extraOptions:{packageName:e}})))];#D;#z;#N;#t=(0,i.inject)(o.sR);#_=(0,i.inject)(o.j_);#M=new Set;#V=(0,
i.inject)(o.V,{optional:!0});constructor(){this.#D=new Map(this.#c.map((e=>[`${e.use}/${e.language}`,e])))}get parserMap$(){return this.#D}#q(e){return`${e.use}/${e.language}`}async#R(){let e=await(0,s.B)({manager:this.#t.packageManager||'npm',
mode:this.#t.parserDownload,registryList:this.#t.registryList,dir:this.#t.antlrParserDir||(0,r.getSystemPath)(this.#V),packageName:'@cyia/parser-antlr4'});this.#N=(0,r.normalize)(e);let t=JSON.parse((0,c.readFileSync)((0,r.getSystemPath)((0,
r.join)(this.#N,'manifest.json')),{encoding:'utf-8'})).map((e=>({use:'antlr4',language:e.id,parser:this.#I,extraOptions:e})));for(const e of t)this.#D.set(`${e.use}/${e.language}`,e);this.#M.add('antlr4')}async#U(){let e=await(0,s.B)({
manager:this.#t.packageManager||'npm',mode:this.#t.parserDownload,registryList:this.#t.registryList,dir:this.#t.treeSitterParserDir||(0,r.getSystemPath)(this.#V),packageName:'@cyia/parser-tree-sitter'});this.#z=(0,r.normalize)(e);let t=JSON.parse((0,
c.readFileSync)((0,r.getSystemPath)((0,r.join)(this.#z,'manifest.json')),{encoding:'utf-8'})).map((e=>({use:'tree-sitter',language:e,parser:this.#T,extraOptions:{name:e}})));for(const e of t)this.#D.set(`${e.use}/${e.language}`,e)
;this.#M.add('tree-sitter')}async getParserInstance(e,t,n,r){'antlr4'!==r.use||this.#M.has(r.use)?'tree-sitter'!==r.use||this.#M.has(r.use)||await this.#U():await this.#R();const a=this.#D.get(this.#q(r))
;if(!a)throw new Error(l.$localize`未找到[${JSON.stringify(this.#q(r))}]对应的解析器`);return a.parser(e,t,n,a.extraOptions)}#B;get#Y(){return this.#B||(this.#B=n(54437)),this.#B}getDefaultExtLanguageOptions(e){let t=(0,
r.basename)(e),n=this.#t.parserMap?.[e]||this.#t.parserMap?.[(0,r.extname)(e)];return(n?[n]:n)??(this.#Y[t]||this.#Y[(0,r.extname)(t)])}#K;get parserList(){if(!this.#K){let e=n(92775);this.#K=e.flatMap((e=>e.language.map((t=>({use:e.use,language:t})))))}
return this.#K}static ɵfac=function(e){return new(e||h)};static ɵprov=i['ɵɵdefineInjectable']({token:h,factory:h.ɵfac})}},85661:(e,t,n)=>{n.d(t,{W:()=>j})
;var r=n(7460),a=n(28786),i=n(62607),o=n(3283),s=n(68178),l=n(7394),c=n(7304),u=n(23659),h=n(43592),p=n(89101),f=n(45753),d=n.n(f),g=n(67617),m=n(96928),w=n(44765),y=n(27005),v=n(39023),b=n.n(v);class ${dialogInfo(e,t){throw new Error('')}
async outputLog(...e){console.log(...e)}async outputWarn(...e){console.warn(...e)}async outputError(...e){console.error(...e)}debug(...e){process.stderr.write(b().format(...e)+'\n')}}var C=n(70857),S=n(59360);class O extends S.NodeJsAsyncHost{list(e){
return super.list(e).pipe((0,i.catchError)((()=>(0,i.of)([]))))}}var k=n(21124),P=n.n(k);async function j(e,t,n){let f=new $,v=await async function(e,t){if(e.config.debug){let t=[];for(const n in g.o){const r=!0===e.config.debug?g.o[n]:e.config.debug[n]
;r&&(t.push(r),g.$[n].log=(...t)=>e.hint.debug(...t))}d().enable(t.join(' '))}e.config.disableDebugDate&&(d().inspectOpts.hideDate=!0),e.workspacePath??=e.path;let n=(0,r.normalize)(e.path),f=new l.j(new c.p(e.vfs)),v=await(0,
i.firstValueFrom)(f.stat(n)).catch((()=>{})),b=!v||v.isDirectory()?n:(0,r.dirname)(n),$=(0,r.normalize)(e.workspacePath),C=new l.j(new c.p(e.vfs,e.hint),b);C.workspacePath=$;let S=(0,r.normalize)(e.scriptCwd);return u.Injector.create({providers:[{
provide:u.INJECTOR_SCOPE,useValue:'root'},{provide:h.Wd,useValue:b},{provide:h.Kz,useValue:n},{provide:h.ge,useValue:$},a.r,{provide:h.j_,useValue:C},{provide:h.Ve,useValue:e.hint},{provide:h.HU,useValue:e.globalContext},s.t,{provide:h.sR,
useValue:e.config},{provide:h.DB,useValue:{...e,path:(0,r.normalize)(e.path),dir:b,workspacePath:$,scriptCwd:S}},{provide:h.V,useValue:S},{provide:h.st,useValue:e.documentContext},{provide:h.Bh,useValue:e.platform},o.d,p.I,m.J,w.o,y.P],parent:void 0})}({
scriptCwd:process.cwd(),path:e,workspacePath:t,vfs:new O,hint:f,...n,config:{gitCloneTmpDir:(0,C.tmpdir)(),get:e=>{throw new Error('')},...n?.config},globalContext:{setBoolean:async e=>await P().prompt(e.map((e=>({type:'confirm',name:e.name,
message:e.message??e.name})))),setInput:async e=>await P().prompt(e.map((e=>({type:'input',name:e.name,message:e.message??e.name}))))}}),b=v.get(a.r);return async e=>{b.host.clear();let t=await e(v.get(m.J),b.runnerCall,b.host,b.injector)
;return await b.host.writeToFs(n?.config.dryRun),t}}},44765:(e,t,n)=>{n.d(t,{o:()=>l});var r=n(7460),a=n(87923),i=n(23659),o=n(43592),s=n(1561);class l{#J=(0,i.inject)(o.HU);applyPathTemplate(e,t={interpolationStart:'__',interpolationEnd:'__',
pipeSeparator:'@'}){e={...r.strings,...e};const n=t.interpolationStart,i=t.interpolationEnd,o=n.length,l=i.length;return async c=>{const u=c;let h=c.indexOf(n),p=c.indexOf(i,h+o+1);for(;-1!=h&&-1!=p;){const n=c.substring(h+o,p);let r=e[n]
;if(t.pipeSeparator){const[i,...o]=n.split(t.pipeSeparator);if(r=e[i],'function'==typeof r&&(r=r.call(e,u)),void 0===r){let e=await this.#J.setInput([{name:i,message:s.$localize`使用文件路径模板[${u}]发现未赋值变量[${i}]`}]);r=Object.values(e)[0]}r=o.reduce(((t,n)=>{
if(!n)return t;if(!(n in e))throw new a.UnknownPipeException(n);if('function'!=typeof e[n])throw new a.InvalidPipeException(n);return''+e[n](t)}),''+r)}else if('function'==typeof r&&(r=r.call(e,u)),void 0===r)throw new a.OptionIsNotDefinedException(n)
;h=(c=c.substring(0,h)+r+c.substring(p+l)).indexOf(t.interpolationStart),p=c.indexOf(t.interpolationEnd,h+o+1)}return(0,r.normalize)(c)}}async applyContentTemplate(e,t,n,a){return e={...r.strings,...e},(0,r.template)(t,a)(e)}static ɵfac=function(e){
return new(e||l)};static ɵprov=i['ɵɵdefineInjectable']({token:l,factory:l.ɵfac})}},27005:(e,t,n)=>{n.d(t,{P:()=>c});var r=n(23659),a=n(68178),i=n(42551),o=n.n(i),s=n(1561);class l{context;input;msgTemplate;constructor(e,t,n){this.context=e,this.input=t,
this.msgTemplate=n}has(e){return o().has(this.context,e)}get(e){return o().get(this.context,e)}async setBoolean(e){let t=Object.values(await this.input.setBoolean([{name:e,message:this.msgTemplate(e)}]))[0];return o().set(this.context,e,t),t}
async setString(e){let t=Object.values(await this.input.setString([{name:e,message:this.msgTemplate(e)}]))[0];return o().set(this.context,e,t),t}}class c{#H;#J=(0,r.inject)(a.t);get#W(){
return this.#H||(this.#H=Promise.resolve().then(n.bind(n,70035)).then((e=>e.default))),Promise.resolve().then(n.bind(n,70035)).then((e=>e.default))}async applyContentTemplate(e,t,n,r){let a=await this.#W,i=a.parse(t,{srcName:n
}),o=new l(e,this.#J,(e=>s.$localize`使用文件路径模板[${n}]发现未赋值变量[${e}]`));return await this.#Q(i.body,o),a.compile(t,{noEscape:!0,...r})(e)}async#Q(e,t,n=[]){for(const r of e)if('MustacheStatement'===r.type){let e
;e=r.params.length?r.params[0].original:r.path.original;let a=[...n,e].join('.');t.has(a)||await t.setString(a)}else if('BlockStatement'===r.type){let e=r.path.original;const a=r.params[0].original
;'if'===e?await t.setBoolean(a)&&await this.#Q(r.program.body,t,n):'with'===e&&await this.#Q(r.program.body,t,[...n,a])}}static ɵfac=function(e){return new(e||c)};static ɵprov=r['ɵɵdefineInjectable']({token:c,factory:c.ɵfac})}},89101:(e,t,n)=>{n.d(t,{
I:()=>d});var r=n(7460),a=n(62607),i=n(56115),o=n(50127),s=n(23659),l=n(43592),c=n(1561),u=n(26610),h=n(44765),p=n(27005),f=n(28786);class d{#_=(0,s.inject)(l.j_);#t=(0,s.inject)(l.sR);#G=(0,s.inject)(l.Bh);#Z=(0,s.inject)(h.o);#X=(0,s.inject)(p.P)
;#ee=(0,s.inject)(s.Injector);async#te(e='override',t,n,r){if(t){const t=await(0,a.firstValueFrom)(this.#_.read(n));if((0,o.N)(t,r))return!0;if('error'===e)throw new Error(c.$localize`执行文件操作时文件已经存在`);if('default'===e);else{
if('override'!==e)return this.#G.applyFile(n,r,t,e,{host:this.#_});await(0,a.firstValueFrom)(this.#_.write(n,r))}}else await(0,a.firstValueFrom)(this.#_.write(n,r));return!0}async#ne(e='delete',t,n,r){if('retain'===e)return!0;if(t){
const t=this.#t.revokeSameConfirm,s=await(0,a.firstValueFrom)(this.#_.read(n));return!t&&(0,o.N)(r,s)?(await(0,i.Z)(this.#_.delete(n)),!0):this.#G.revokeFile(n,r,s,e,{host:this.#_})}return!0}template=async(e,t,n,a,o,s,l,h)=>{let p,d=this,g=(0,
r.normalize)(t),m=t.endsWith('/');for(const t of e){if('git'===n){let e=d.#ee.get(f.r).runnerCall.os;p=async function*(){let n='string'==typeof t?{url:t}:t,r=await e.gitClone(n.url,n?.match,n?.output,n?.type,n?.commit);for(const e in r){const t=r[e]
;yield{content:t,path:e}}}}else{if(n&&'local'!==n)throw new Error(c.$localize`未知来源`);{let e=(0,r.normalize)(t),n=await(0,i.d)(this.#_.stat(e)).catch((()=>null));if(!n)throw new Error(c.$localize`未找到[${e}]`);let s=(0,r.basename)(e)
;if(n.isFile())p=async function*(){let t=m?s:'',n=await(0,i.d)(d.#_.read(e));yield{path:t,content:n}};else{if(!n.isDirectory())throw new Error(c.$localize`未知类型`);p=async function*(){let t=await d.#_.listAll(e,{excludeList:a,ignoreList:o})
;for(const n of t)yield{content:await(0,i.d)(d.#_.read((0,r.join)(e,n))),path:m?(0,r.join)(s,n):n}}}}}let e=p();for await(let{path:t,content:n}of e){let e=(0,r.join)(g,t),a=await this.#re(e,n,s),o=await(0,u.KA)(a.content),c=!!await(0,
i.d)(this.#_.stat(a.path)).catch((()=>!1));if(!(l?await this.#ne(o?h?.revokeConflict:h?.binaryRevokeConflict,c,a.path,a.content):await this.#te(o?h?.conflict:h?.binaryConflict,c,a.path,a.content)))throw new Error('')}}};async#re(e,t,r={}){
if(!r.templateContext)return r.pathTemplateSuffix&&(e=g(e,r.pathTemplateSuffix)),{path:e,content:t};let a,i=await(0,u.KA)(t)&&('raw'!==r.contentTemplate||!r.contentTemplate),o='raw'!==r.pathTemplate;if((o||i)&&(a=function(e,t){for(const n in e){
const r=e[n];'function'==typeof r&&(e[n]=e=>r(e,t))}return e}(r.templateContext,e)),o&&(e=await this.#Z.applyPathTemplate(a,r.pathTemplateOptions)(e)),i){let i=(0,u.YI)(t,e)
;'ejs'===r.contentTemplate?i=(await Promise.resolve().then(n.bind(n,42201))).render(i,a,{escape:e=>e,...r.contentTemplateOptions
}):'handlebars'===r.contentTemplate?i=await this.#X.applyContentTemplate(a,i,e,r.contentTem