@code-recycle/cli
Version:
高级语法查询替换工具;Advanced syntax query replacement tool
24 lines • 6.62 kB
JavaScript
'use strict';exports.id=90,exports.ids=[90],exports.modules={22090:(e,t,r)=>{r.r(t),r.d(t,{CssSelectorForHtml:()=>s,CssSelectorForNgHtml:()=>l,createCssSelectorForHtml:()=>n,createCssSelectorForNgHtml:()=>i});var o=r(99096);async function n(e,t,r){
return new s(e,await t.module$$,r)}var s=class extends o.Ij{constructor(e,t,r){super(r),this.content=e,this.angularComplier=t;const o=(new this.angularComplier.HtmlParser).parse(e,'');if(o.errors&&o.errors.length)throw o.errors
;this.rootNodeList=o.rootNodes}rootNodeList;findTagName(e){return e.name}getChildren(e){return[...e.attrs||[],...e.children||[]]}getNodePosition(e){return[e.sourceSpan.start.offset,e.sourceSpan.end.offset]}getNodeExtraData(e,t,r){
const n=super.getNodeExtraData(e,t,r);for(const t of e.attrs||[])n[t.name]=new o.Nz(t.value);for(const t in e){const r=e[t];if(r instanceof this.angularComplier.ParseSourceSpan){const e=[r.start.offset,r.end.offset];n[`${t}Range`]=new o.Nz(e),
n[`${t}Value`]=new o.Nz(this.content.slice(...e));const s=[r.fullStart.offset,r.end.offset];n[`${t}FullRange`]=new o.Nz(s),n[`${t}FullValue`]=new o.Nz(this.content.slice(...s))}else if(r instanceof this.angularComplier.AST){
const e=[r.sourceSpan.start,r.sourceSpan.end];n[`${t}Range`]=new o.Nz(e),n[`${t}Value`]=new o.Nz(this.content.slice(...e))}}return n}};async function i(e,t,r){return new l(e,await t.module$$,t,r)}var l=class extends o.Ij{constructor(e,t,r,o){super(o),
this.content=e,this.angularComplier=t;const n=this.angularComplier.parseTemplate(e,'',r);if(n.errors&&n.errors.length)throw n.errors.map((e=>e.toString())).join('\n');this.rootNodeList=n.nodes}rootNodeList;findTagName(e){
return'__root'!==e.name&&this.nodeIteration(e,{Element:()=>'Element',Template:()=>'Template',Content:()=>'Content',Text:()=>'Text',default:()=>{},BoundText:()=>'BoundText',TextAttribute:()=>'TextAttribute',BoundAttribute:()=>'BoundAttribute',
BoundEvent:()=>'BoundEvent',Reference:()=>'Reference',Variable:()=>'Variable',IfBlock:()=>'IfBlock',IfBlockBranch:()=>'IfBlockBranch',ForLoopBlock:()=>'ForLoopBlock',ForLoopBlockEmpty:()=>'ForLoopBlockEmpty',DeferredBlock:()=>'DeferredBlock',
DeferredBlockError:()=>'DeferredBlockError',DeferredBlockLoading:()=>'DeferredBlockLoading',DeferredBlockPlaceholder:()=>'DeferredBlockPlaceholder',SwitchBlock:()=>'SwitchBlock',SwitchBlockCase:()=>'SwitchBlockCase',Icu:()=>'Icu',
DeferredTrigger:()=>'DeferredTrigger',UnknownBlock:()=>'UnknownBlock'})}getChildren(e){return this.nodeIteration(e,{Element:e=>this.#e([...e.attributes,...e.inputs,...e.outputs,...e.references,...e.children]),
Template:e=>this.#e([...e.attributes,...e.inputs,...e.outputs,...e.references,...e.templateAttrs,...e.variables,...e.children]),Content:()=>[],Text:()=>[],BoundText:()=>[],TextAttribute:()=>[],BoundAttribute:()=>[],BoundEvent:()=>[],Reference:()=>[],
Variable:()=>[],default:()=>[],IfBlock:e=>this.#e([...e.branches]),IfBlockBranch:e=>this.#e([...e.children,e.expressionAlias]),ForLoopBlock:e=>this.#e([...e.children,e.item]),ForLoopBlockEmpty:e=>this.#e([...e.children]),
DeferredBlock:e=>this.#e([...e.children,e.placeholder,e.loading,e.error]),DeferredBlockError:e=>this.#e([...e.children]),DeferredBlockLoading:e=>this.#e([...e.children]),DeferredBlockPlaceholder:e=>this.#e([...e.children]),
SwitchBlock:e=>this.#e([...e.cases,...e.unknownBlocks]),SwitchBlockCase:e=>this.#e([...e.children]),Icu:e=>this.#e([...Object.values(e.placeholders)]),DeferredTrigger:e=>this.#e([]),UnknownBlock:e=>this.#e([])})}nodeIteration(e,t){
return this.#t(e)?t.Element(e):this.#r(e)?t.BoundText(e):this.#o(e)?t.Text(e):this.#n(e)?t.Template(e):this.#s(e)?t.Content(e):e instanceof this.angularComplier.TmplAstTextAttribute?t.TextAttribute(e):e instanceof this.angularComplier.TmplAstBoundAttribute?t.BoundAttribute(e):e instanceof this.angularComplier.TmplAstBoundEvent?t.BoundEvent(e):e instanceof this.angularComplier.TmplAstReference?t.Reference(e):e instanceof this.angularComplier.TmplAstVariable?t.Variable(e):e instanceof this.angularComplier.TmplAstIfBlock?t.IfBlock(e):e instanceof this.angularComplier.TmplAstIfBlockBranch?t.IfBlockBranch(e):e instanceof this.angularComplier.TmplAstForLoopBlock?t.ForLoopBlock(e):e instanceof this.angularComplier.TmplAstForLoopBlockEmpty?t.ForLoopBlockEmpty(e):e instanceof this.angularComplier.TmplAstDeferredBlock?t.DeferredBlock(e):e instanceof this.angularComplier.TmplAstDeferredBlockError?t.DeferredBlockError(e):e instanceof this.angularComplier.TmplAstDeferredBlockLoading?t.DeferredBlockLoading(e):e instanceof this.angularComplier.TmplAstDeferredBlockPlaceholder?t.DeferredBlockPlaceholder(e):e instanceof this.angularComplier.TmplAstSwitchBlock?t.SwitchBlock(e):e instanceof this.angularComplier.TmplAstSwitchBlockCase?t.SwitchBlockCase(e):e instanceof this.angularComplier.TmplAstIcu?t.Icu(e):e instanceof this.angularComplier.TmplAstDeferredTrigger?t.DeferredTrigger(e):e instanceof this.angularComplier.TmplAstUnknownBlock?t.UnknownBlock(e):t.default(e)
}#t(e){return e instanceof this.angularComplier.TmplAstElement}#r(e){return e instanceof this.angularComplier.TmplAstBoundText}#o(e){return e instanceof this.angularComplier.TmplAstText}#n(e){return e instanceof this.angularComplier.TmplAstTemplate}#s(e){
return e instanceof this.angularComplier.TmplAstContent}getNodePosition(e){return[e.sourceSpan.start.offset,e.sourceSpan.end.offset]}getNodeExtraData(e,t,r,n){const s=super.getNodeExtraData(e,t,r)
;this.#t(e)?(e.inputs.length&&(s.input=new o.Nz(e.inputs.map((e=>e.name)).join(' '))),
e.outputs.length&&(s.output=new o.Nz(e.outputs.map((e=>e.name)).join(' ')))):this.#n(e)&&(e.templateAttrs.length&&(s.templateAttr=new o.Nz(e.templateAttrs.map((e=>e.name)).join(' '))),
e.variables.length&&(s.variable=new o.Nz(e.variables.map((e=>e.name)).join(' ')))),(this.#t(e)||this.#s(e))&&e.attributes.length&&(s.attribute=new o.Nz(e.attributes.map((e=>e.name)).join(' '))),
(this.#n(e)||this.#t(e))&&e.references.length&&(s.reference=new o.Nz(e.references.map((e=>e.name)).join(' ')));for(const t in e){const r=e[t];if(r instanceof this.angularComplier.ParseSourceSpan){const e=[r.start.offset,r.end.offset]
;s[`${t}Range`]=new o.Nz(e),s[`${t}Value`]=new o.Nz(this.content.slice(...e));const n=[r.fullStart.offset,r.end.offset];s[`${t}FullRange`]=new o.Nz(n),s[`${t}FullValue`]=new o.Nz(this.content.slice(...n))}else if(r instanceof this.angularComplier.AST){
const e=[r.sourceSpan.start,r.sourceSpan.end];s[`${t}Range`]=new o.Nz(e),s[`${t}Value`]=new o.Nz(this.content.slice(...e))}}return s}#e(e){return e.filter(Boolean).sort(((e,t)=>e.sourceSpan.start.offset-t.sourceSpan.start.offset))}}}};