@lcap/nasl-unified-frontend-generator 3.9.1-beta.21 → 3.9.1-beta.22
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.js +107 -107
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +110 -110
- package/dist/index.mjs.map +1 -1
- package/dist/playground.js +106 -106
- package/dist/playground.js.map +1 -1
- package/dist/playground.mjs +109 -109
- package/dist/playground.mjs.map +1 -1
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var Jt=Object.create;var Te=Object.defineProperty;var zn=Object.getOwnPropertyDescriptor;var Wt=Object.getOwnPropertyNames;var qt=Object.getPrototypeOf,Xt=Object.prototype.hasOwnProperty;var Zt=(r,e)=>{for(var t in e)Te(r,t,{get:e[t],enumerable:!0})},Gn=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Wt(e))!Xt.call(r,o)&&o!==t&&Te(r,o,{get:()=>e[o],enumerable:!(i=zn(e,o))||i.enumerable});return r};var se=(r,e,t)=>(t=r!=null?Jt(qt(r)):{},Gn(e||!r||!r.__esModule?Te(t,"default",{value:r,enumerable:!0}):t,r)),Yt=r=>Gn(Te({},"__esModule",{value:!0}),r),G=(r,e,t,i)=>{for(var o=i>1?void 0:i?zn(e,t):e,
|
|
1
|
+
"use strict";var Jt=Object.create;var Te=Object.defineProperty;var zn=Object.getOwnPropertyDescriptor;var Wt=Object.getOwnPropertyNames;var qt=Object.getPrototypeOf,Xt=Object.prototype.hasOwnProperty;var Zt=(r,e)=>{for(var t in e)Te(r,t,{get:e[t],enumerable:!0})},Gn=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Wt(e))!Xt.call(r,o)&&o!==t&&Te(r,o,{get:()=>e[o],enumerable:!(i=zn(e,o))||i.enumerable});return r};var se=(r,e,t)=>(t=r!=null?Jt(qt(r)):{},Gn(e||!r||!r.__esModule?Te(t,"default",{value:r,enumerable:!0}):t,r)),Yt=r=>Gn(Te({},"__esModule",{value:!0}),r),G=(r,e,t,i)=>{for(var o=i>1?void 0:i?zn(e,t):e,a=r.length-1,c;a>=0;a--)(c=r[a])&&(o=(i?c(e,t,o):c(o))||o);return i&&o&&Te(e,t,o),o},z=(r,e)=>(t,i)=>e(t,i,r);var Mr={};Zt(Mr,{ApiClientIdentifier:()=>_e,FileSystemPlugin:()=>Ce,JavaScriptCodegenPlugin:()=>de,LifeCycleHooksPlugin:()=>je,Logger:()=>L,MicroFrontendPlugin:()=>Ne,NASLAppIRBuilderPlugin:()=>Re,PlacedFile:()=>en,ProjectOrganizerPlugin:()=>Pe,ReactChildrenPropName:()=>Ve,ReactCodegenPlugin:()=>Ie,ReactFileDescription:()=>U,ReactFragment:()=>Be,ReactPresetPlugin:()=>ge,ReactRouterDefaultBizComponentsFolderName:()=>Xe,ReactRouterDefaultViewFolderName:()=>ze,ReactStateManagerMobxPlugin:()=>oe,ReactStateManagerVanillaPlugin:()=>ue,ServiceMetaKind:()=>D,StateActionIR:()=>he,StateContextIR:()=>He,VirtualProject:()=>ln,bindAttrToIR:()=>Ue,bindEventToAction:()=>We,bindViewElementEventToIR:()=>Ee,codeFormatPlugin:()=>xn,compileAsProject:()=>Lr,compileNASLToReactDist:()=>Tr,defaultErrorMessageDict:()=>kn,deserializeAppWhileKeepTypeAnnotation:()=>mn,genMetaData:()=>gn,getComponentName:()=>Nn,hasAfterAllFilesGeneratedKind:()=>$t,inferChangeEventNameFromAttrName:()=>Ye,javaScriptCodeGenPlugin:()=>Sn,jsxCodeGenPlugin:()=>vn,logicToLogicIR:()=>le,makeDefaultContainer:()=>Fn,makePlugin:()=>K,metadataPlugin:()=>Pn,paramToIR:()=>ye,reactComponentLibHackPlugin:()=>Je,reactRouterPlugin:()=>Ge,reactSlotPlugin:()=>In,routesExtractionPlugin:()=>Oe,serializeAppWithKeepTypeAnnotation:()=>Me,styleStringToInlineObject:()=>bn,translateNASLToReactApp:()=>Ln});module.exports=Yt(Mr);var Ut=se(require("axios")),Bt=require("lodash");var Un={files:{"/README.md":{code:`# React + TypeScript + Vite
|
|
2
2
|
|
|
3
3
|
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
|
|
4
4
|
|
|
@@ -4697,7 +4697,7 @@ export const useHandlePageNavigationEvent = ()=>{
|
|
|
4697
4697
|
},
|
|
4698
4698
|
"include": ["src"]
|
|
4699
4699
|
}
|
|
4700
|
-
`}},environment:"vanilla"};var Mt=require("inversify");var lc=require("@abraham/reflection"),De=require("inversify");var D={StateManager:Symbol.for("StateManager"),ReactStateManager:Symbol.for("ReactStateManager"),ReactHookProvider:Symbol.for("ReactHookProvider"),CodePrinter:Symbol.for("CodePrinter"),ReactJavaScriptCodePrinter:Symbol.for("ReactJavaScriptCodePrinter"),BaseNodePrinter:Symbol.for("BaseNodePrinter"),ProjectOrganizer:Symbol.for("ProjectOrganizer"),MicroFrontendManager:Symbol.for("MicroFrontendManager"),FrontendCodeGenerator:Symbol.for("FrontendCodeGenerator"),IRBuilder:Symbol.for("IRBuilder"),IRPostProcesser:Symbol.for("IRPostProcesser"),IRPreProcesser:Symbol.for("IRPreProcesser"),NASLTranspiler:Symbol.for("NASLTranspiler"),ReactCodegen:Symbol.for("ReactCodegen"),CodeGenerationLifecycleHooks:Symbol.for("CodeGenerationLifecycleHooks"),FileSystemProvider:Symbol.for("FileSystemProvider"),FrontendBundlerConfig:Symbol.for("FrontendBundlerConfig"),FrontendPerformance:Symbol.for("FrontendPerformance"),NpmPackageJSONManager:Symbol.for("NpmPackageJSONManager")},$t=[D.CodeGenerationLifecycleHooks,D.NpmPackageJSONManager];var Bn=require("lodash"),Hn=se(require("pino")),_t=process.env.LOG_LEVEL||"info",er=(0,Hn.default)({level:_t,transport:{target:"pino-pretty",options:{colorize:!0}}});function L(r){return er.child({},{msgPrefix:`[${r}] `})}function Qn(r){if(!(0,Bn.isFunction)(r))throw new Error;let e=r.name,t=Object.getOwnPropertyNames(r.prototype),i=L(e);return t.forEach(o=>{let s=r.prototype[o];r.prototype[o]=function(...c){return i.trace({method:o,args:c}),s.apply(this,c)}}),r}var ae=require("@lcap/nasl-concepts");function mn(r){let e=ae.BaseNode.prototype.subConstructor,t=function(o){e.call(this,o),o.typeAnnotation&&(this.typeAnnotation=new ae.TypeAnnotation(o.typeAnnotation)),o.__TypeArguments&&(this.__TypeArguments=o.__TypeArguments.map(s=>s&&new ae.TypeAnnotation(s)))};ae.BaseNode.prototype.subConstructor=t;let i=new ae.App(r);return ae.BaseNode.prototype.subConstructor=e,i}function Me(r){let e=r.__proto__.__proto__,t=e._toJSON,i=function(o){let s=t.call(this,o);return(this.typeAnnotation||this.__TypeAnnotation)&&(s.typeAnnotation=this.typeAnnotation?.toJSON()??this.__TypeAnnotation?.toJSON()),this.__TypeArguments&&(s.__TypeArguments=this.__TypeArguments.map?.(c=>c&&c.toJSON())),s};e._toJSON=i;try{return r.toJSON()}catch(o){throw o}finally{e._toJSON=t}}var ps=require("@abraham/reflection"),F=require("@lcap/nasl-concepts"),W=require("@lcap/nasl-concepts/asserts"),vt=se(require("@lcap/nasl-breakpoint"));var q=require("@lcap/nasl-concepts"),un=require("@lcap/nasl-translator");function Ke(r){let{typeKind:e,typeNamespace:t,typeName:i,typeArguments:o,properties:s}=r||{},c=[];if(e==="union"){if(Array.isArray(o)){let d=o.map(m=>Ke(m)).sort((m,b)=>m>b?1:-1);c.push(d.join(" | "))}}else if(e==="anonymousStructure"){if(c.push("{"),Array.isArray(s)){let d=s.sort(({name:m},{name:b})=>m>b?1:-1).map(m=>{let{name:b,typeAnnotation:g}=m||{};return`${b}: ${Ke(g)}`});c.push(d.join(", "))}c.push("}")}else{let d=[];t&&d.push(t),i&&d.push(i);let m=d.join(".");if(m&&c.push(m),e==="generic"){if(c.push("<"),Array.isArray(o)){let b=o.map(g=>Ke(g));c.push(b.join(", "))}c.push(">")}}return c.join("")}function gn(r,e,t){let i=t?.isPreviewFe??!1,o=t?.isPureFeMode??!1,s=t?.isExport??!1,c=[],d=[],m=[],b=[],g=[],R=[],A=[],v=[];e.views&&d.push(...e.views),Array.isArray(r.dataSources)&&r.dataSources.forEach(y=>{Array.isArray(y.entities)&&m.push(...y.entities)}),r.structures&&b.push(...r.structures),r.enums&&g.push(...r.enums),r.logics&&R.push(...r.logics),r.processes&&v.push(...r.processes),r.dependencies&&c.push(...r.dependencies),r.interfaceDependencies&&c.push(...r.interfaceDependencies),r.connectorDependencies&&c.push(...r.connectorDependencies),g.push(...q.configurationEnums),g.push(...q.processV2Enums),r.interfaces.forEach(y=>{y&&A.push(y)}),c.forEach(y=>{y.views&&d.push(...y.views),y.structures&&b.push(...y.structures),y.enums&&g.push(...y.enums),y.logics&&R.push(...y.logics),y.interfaces&&A.push(...y.interfaces),Array.isArray(y.dataSources)&&y.dataSources.forEach(I=>{Array.isArray(I.entities)&&m.push(...I.entities)})});let n=[],S={},w=e.variables||[],a=e.bindEvents,p={},u={},k={},f={},h=[];Array.isArray(g)&&(n.push(...g),g.forEach(y=>{let{name:I,enumItems:P}=y||{};y.module?I=`extensions.${y.module.name}.enums.${I}`:y.name==="I18nEnum"&&y.getNamespace()==="nasl.configuration.enums"&&(I="nasl.configuration.enums.I18nEnum");let M={};P.forEach(({label:E,value:V})=>{M[V]=E?.value}),u[I]=M})),Array.isArray(m)&&(n.push(...m),m.forEach(y=>{let{ns:I}=y;Array.isArray(I?.logics)&&h.push(...I.logics)})),Array.isArray(b)&&n.push(...b),n.forEach(y=>{let P=`${y.getNamespace()}.${y.name}`,M=y.toJSON?.();if(["Enum"].includes(y.concept)){let{typeName:V,typeNamespace:T}=y.valueType||{};M.enumItems?.map(N=>{N.value=V==="Long"&&T==="nasl.core"?+N.value:N.value})}if(["Entity","Structure"].includes(y.concept)&&M.properties.forEach((V,T)=>{let{defaultValue:N}=y.properties[T];N?.expression?V.defaultCode={code:N.toJS((0,un.createCompilerState)("",{getVuePrototype:!0})),executeCode:["NewComposite","NewList","NewMap","StringInterpolation","BinaryExpression","UnaryExpression","StringLiteral"].includes(N.expression.concept)}:V.defaultCode={}}),Array.isArray(M.properties)){let V=y.getAncestor("App");M.properties.forEach(T=>{let{typeAnnotation:N={}}=T;if(N?.typeNamespace?.endsWith(".metadataTypes")){let Y;if(N.typeNamespace==="app.metadataTypes")Y=V.metadataTypes?.find(_=>_.name===N.typeName)?.typeAnnotation;else if(N.typeNamespace?.startsWith("extensions.")&&N.typeNamespace?.endsWith(".metadataTypes")){let _=N.typeNamespace?.replace("extensions.","").replace(".metadataTypes","");Y=V.dependencies?.find(O=>O.name===_)?.metadataTypes?.find(O=>O.name===N.typeName)?.typeAnnotation??{}}N.typeKind="primitive",N.typeNamespace="nasl.core",N.typeName=Y?.typeName}})}S[P]=M;let{properties:E}=y;Array.isArray(E)&&E.forEach(V=>{j(V?.typeAnnotation)})}),[{namespace:"nasl.auth",list:q.authStructures},{namespace:"nasl.ui",list:q.uiStructures},{namespace:"nasl.collection",list:q.collectionStructures},{namespace:"nasl.interface",list:q.interfaceStructures},{namespace:"nasl.process",list:q.processStructures},{namespace:"nasl.processV2",list:q.processV2Structures},{namespace:"nasl.http",list:q.httpStructures}].forEach(y=>{let{namespace:I,list:P}=y||{};Array.isArray(P)&&P.forEach(M=>{let E=`${I}.${M.name}`;S[E]=M.toJSON?.();let{properties:V}=M;Array.isArray(V)&&V.forEach(T=>{j(T?.typeAnnotation)})})}),Array.isArray(R)&&h.push(...R),h.forEach(y=>{let I=y.getNamespace(),P=I?`${I}.${y.name}`:y.name;k[P]=i?y.toMockService():y.toService()}),v.forEach(y=>{Array.isArray(y.logics)&&y.logics.forEach(I=>{let P=I.getNamespace(),M=P?`${P}.${I.name}`:I.name;k[M]=I.toProcessService()})}),A.forEach(y=>{let I=y.toService();o&&s&&(I.url.path=I.url.path.replace(/^\/[^/]+\/[^/]+\//,"/")),i&&(I=y.toMockService()),f[`${y.getNamespace()}.${y.name}`]=I}),e.traverseStrictChildren(y=>{j(y?.typeAnnotation||y?.__TypeAnnotation)},["virtualParams"]);let C=[...w];Array.isArray(C)&&C?.forEach(y=>{let{defaultValue:I}=y,P=y.typeAnnotation||y.__TypeAnnotation;if(P?.typeNamespace?.endsWith(".metadataTypes")){let E=(r?.findNodeByCompleteName(P.typeNamespace+"."+P.typeName)||{}).typeAnnotation||{};P.typeKind=E.typeKind,P.typeNamespace=E.typeNamespace,P.typeName=E.typeName}I?.expression?y.defaultCode={code:I.toJS((0,un.createCompilerState)("",{getVuePrototype:!0})),executeCode:["NewComposite","NewList","NewMap","StringInterpolation","BinaryExpression","UnaryExpression","StringLiteral"].includes(I.expression.concept)}:y.defaultCode={},j(P)}),Array.isArray(a)&&a.forEach(y=>{let I=y?.typeAnnotation||y.__TypeAnnotation;j(I)});function j(y){if(y){let I=Ke(y);if(!S[I]){S[I]=y?.toJSON?.()??y;let{properties:P,typeArguments:M}=S[I]||{};Array.isArray(P)&&P.forEach(E=>{j(E?.typeAnnotation)}),Array.isArray(M)&&M.forEach(E=>{j(E)})}}}return a.forEach(y=>{let I=y.getViewEventName(),P=y.toFunction();p[I]=P,o&&delete p.beforeRouter}),{frontendEvents:p,frontendVariables:C,dataTypesMap:S,enumsMap:u,logicsMap:k,servicesMap:{_custom:f}}}var be=require("inversify"),$e=require("lodash");var he=class{constructor(e){Object.assign(this,e)}};function H(r){return r!=null}function Kn(r){return Array.isArray(r)?r:[r]}function Jn(){throw new Error("todo")}function te(r){let e=r?JSON.stringify(r):String(r);throw new Error(`not implemented for ${e}`)}function X(r){let e=r?JSON.stringify(r):String(r);throw new Error(`never implemented for ${e}. Should never be here!`)}function ee(r){throw new Error(`assertNever failed: ${r}`)}var Wn=r=>r.startsWith("elements."),qn=r=>r.split(".").at(1),fn=r=>`${r}Ref`;function Xn(r){return r.kind==="library"}function Zn(r){return r.tag==="template"}var ce=require("@lcap/nasl-concepts");function hn(r,e){let t=r?.split(".")||[],o=t[0]==="app"?1:0;return t.findIndex((s,c)=>c%2===o?s===e:!1)}function Yn(r){let e=r.typeAnnotation||r.__TypeAnnotation,{sortedTypeKey:t,typeKind:i,typeName:o,typeNamespace:s}=e||{};if(s?.endsWith(".metadataTypes")){let b=(r.app.findNodeByCompleteName(s+"."+o)||{}).typeAnnotation||{};t=`${b.typeNamespace}.${b.typeName}`,i=b.typeKind,o=b.typeName}let c=e&&(!["primitive","union"].includes(i)||o==="DateTime"),d=r.defaultValue?.expression?r.defaultValue.expression:new ce.Unparsed({code:void 0});return c?ce.CallFunction.from({calleeName:"genInitFromSchema",arguments:[new ce.Argument({expression:new ce.StringLiteral({value:t})}),new ce.Argument({expression:d})]},r.parentNode,r.parentKey):d}var $n=require("@lcap/nasl-utils");var Se=r=>r.replaceAll("_","-").replace(/(?:-)([a-zA-Z0-9])/g,(e,t)=>t.toUpperCase()),pe=r=>(0,$n.firstUpperCase)(Se(r));function _n(r){return/^[A-Z]/.test(r)}function et(r){return H(r)&&r!==""}function nt(r){return r.charAt(0).toUpperCase()+r.slice(1)}function Q({name:r,functions:e}){return{name:r,functions:e}}var Rn=require("@lcap/nasl-concepts"),Cn=require("@lcap/nasl-concepts/asserts"),wt=require("html-escaper"),re=require("inversify"),ne=require("lodash");var tt="__SomethingYouNeverGuessAsUndefinedPlaceholder__undefined__";function rt(r){return JSON.stringify(r,(e,t)=>t===void 0?tt:t,2).replaceAll(`"${tt}"`,"undefined")}var it=require("path");function ot(r){return(0,it.extname)(r)!==""}function yn(r){return"/"+r.map(t=>t.name).join("/")}var wn=Q({name:"apiClientPlugin",functions:{buildApiStubFile(r,e){function t(o){let s=o.map(c=>[c.logic.name,c.logic.toService()]);return Object.fromEntries(s)}let i=Object.assign({},e.logicsMap,t(r));return new U("apis",[{from:"@lcap/basic-template",import:"{initLogic, initDataTypes, initService, Global}"}],[],["export { genInitFromSchema } from '@lcap/basic-template/dist/init/dataTypes';",`export const dataTypesMap = ${JSON.stringify(e.dataTypesMap)};`,`export const enumsMap = ${JSON.stringify(e.enumsMap)};`,`export const servicesMap = ${JSON.stringify(e.servicesMap)};`,`const logicsMap = ${JSON.stringify(i)};`,`
|
|
4700
|
+
`}},environment:"vanilla"};var Mt=require("inversify");var lc=require("@abraham/reflection"),De=require("inversify");var D={StateManager:Symbol.for("StateManager"),ReactStateManager:Symbol.for("ReactStateManager"),ReactHookProvider:Symbol.for("ReactHookProvider"),CodePrinter:Symbol.for("CodePrinter"),ReactJavaScriptCodePrinter:Symbol.for("ReactJavaScriptCodePrinter"),BaseNodePrinter:Symbol.for("BaseNodePrinter"),ProjectOrganizer:Symbol.for("ProjectOrganizer"),MicroFrontendManager:Symbol.for("MicroFrontendManager"),FrontendCodeGenerator:Symbol.for("FrontendCodeGenerator"),IRBuilder:Symbol.for("IRBuilder"),IRPostProcesser:Symbol.for("IRPostProcesser"),IRPreProcesser:Symbol.for("IRPreProcesser"),NASLTranspiler:Symbol.for("NASLTranspiler"),ReactCodegen:Symbol.for("ReactCodegen"),CodeGenerationLifecycleHooks:Symbol.for("CodeGenerationLifecycleHooks"),FileSystemProvider:Symbol.for("FileSystemProvider"),FrontendBundlerConfig:Symbol.for("FrontendBundlerConfig"),FrontendPerformance:Symbol.for("FrontendPerformance"),NpmPackageJSONManager:Symbol.for("NpmPackageJSONManager")},$t=[D.CodeGenerationLifecycleHooks,D.NpmPackageJSONManager];var Bn=require("lodash"),Hn=se(require("pino")),_t=process.env.LOG_LEVEL||"info",er=(0,Hn.default)({level:_t,transport:{target:"pino-pretty",options:{colorize:!0}}});function L(r){return er.child({},{msgPrefix:`[${r}] `})}function Qn(r){if(!(0,Bn.isFunction)(r))throw new Error;let e=r.name,t=Object.getOwnPropertyNames(r.prototype),i=L(e);return t.forEach(o=>{let a=r.prototype[o];r.prototype[o]=function(...c){return i.trace({method:o,args:c}),a.apply(this,c)}}),r}var ae=require("@lcap/nasl-concepts");function mn(r){let e=ae.BaseNode.prototype.subConstructor,t=function(o){e.call(this,o),o.typeAnnotation&&(this.typeAnnotation=new ae.TypeAnnotation(o.typeAnnotation)),o.__TypeArguments&&(this.__TypeArguments=o.__TypeArguments.map(a=>a&&new ae.TypeAnnotation(a)))};ae.BaseNode.prototype.subConstructor=t;let i=new ae.App(r);return ae.BaseNode.prototype.subConstructor=e,i}function Me(r){let e=r.__proto__.__proto__,t=e._toJSON,i=function(o){let a=t.call(this,o);return(this.typeAnnotation||this.__TypeAnnotation)&&(a.typeAnnotation=this.typeAnnotation?.toJSON()??this.__TypeAnnotation?.toJSON()),this.__TypeArguments&&(a.__TypeArguments=this.__TypeArguments.map?.(c=>c&&c.toJSON())),a};e._toJSON=i;try{return r.toJSON()}catch(o){throw o}finally{e._toJSON=t}}var ps=require("@abraham/reflection"),F=require("@lcap/nasl-concepts"),q=require("@lcap/nasl-concepts/asserts"),vt=se(require("@lcap/nasl-breakpoint"));var X=require("@lcap/nasl-concepts"),un=require("@lcap/nasl-translator");function Ke(r){let{typeKind:e,typeNamespace:t,typeName:i,typeArguments:o,properties:a}=r||{},c=[];if(e==="union"){if(Array.isArray(o)){let d=o.map(m=>Ke(m)).sort((m,b)=>m>b?1:-1);c.push(d.join(" | "))}}else if(e==="anonymousStructure"){if(c.push("{"),Array.isArray(a)){let d=a.sort(({name:m},{name:b})=>m>b?1:-1).map(m=>{let{name:b,typeAnnotation:u}=m||{};return`${b}: ${Ke(u)}`});c.push(d.join(", "))}c.push("}")}else{let d=[];t&&d.push(t),i&&d.push(i);let m=d.join(".");if(m&&c.push(m),e==="generic"){if(c.push("<"),Array.isArray(o)){let b=o.map(u=>Ke(u));c.push(b.join(", "))}c.push(">")}}return c.join("")}function gn(r,e,t){let i=t?.isPreviewFe??!1,o=t?.isPureFeMode??!1,a=t?.isExport??!1,c=[],d=[],m=[],b=[],u=[],R=[],I=[],v=[];e.views&&d.push(...e.views),Array.isArray(r.dataSources)&&r.dataSources.forEach(f=>{Array.isArray(f.entities)&&m.push(...f.entities)}),r.structures&&b.push(...r.structures),r.enums&&u.push(...r.enums),r.logics&&R.push(...r.logics),r.processes&&v.push(...r.processes),r.dependencies&&c.push(...r.dependencies),r.interfaceDependencies&&c.push(...r.interfaceDependencies),r.connectorDependencies&&c.push(...r.connectorDependencies),u.push(...X.configurationEnums),u.push(...X.processV2Enums),r.interfaces.forEach(f=>{f&&I.push(f)}),c.forEach(f=>{f.views&&d.push(...f.views),f.structures&&b.push(...f.structures),f.enums&&u.push(...f.enums),f.logics&&R.push(...f.logics),f.interfaces&&I.push(...f.interfaces),Array.isArray(f.dataSources)&&f.dataSources.forEach(A=>{Array.isArray(A.entities)&&m.push(...A.entities)})});let n=[],S={},w=e.variables||[],s=e.bindEvents,p={},g={},k={},h={},y=[];Array.isArray(u)&&(n.push(...u),u.forEach(f=>{let{name:A,enumItems:N}=f||{};f.module?A=`extensions.${f.module.name}.enums.${A}`:f.name==="I18nEnum"&&f.getNamespace()==="nasl.configuration.enums"&&(A="nasl.configuration.enums.I18nEnum");let M={};N.forEach(({label:E,value:V})=>{M[V]=E?.value}),g[A]=M})),Array.isArray(m)&&(n.push(...m),m.forEach(f=>{let{ns:A}=f;Array.isArray(A?.logics)&&y.push(...A.logics)})),Array.isArray(b)&&n.push(...b),n.forEach(f=>{let N=`${f.getNamespace()}.${f.name}`,M=f.toJSON?.();if(["Enum"].includes(f.concept)){let{typeName:V,typeNamespace:T}=f.valueType||{};M.enumItems?.map(P=>{P.value=V==="Long"&&T==="nasl.core"?+P.value:P.value})}if(["Entity","Structure"].includes(f.concept)&&M.properties.forEach((V,T)=>{let{defaultValue:P}=f.properties[T];P?.expression?V.defaultCode={code:P.toJS((0,un.createCompilerState)("",{getVuePrototype:!0})),executeCode:["NewComposite","NewList","NewMap","StringInterpolation","BinaryExpression","UnaryExpression","StringLiteral"].includes(P.expression.concept)}:V.defaultCode={}}),Array.isArray(M.properties)){let V=f.getAncestor("App");M.properties.forEach(T=>{let{typeAnnotation:P={}}=T;if(P?.typeNamespace?.endsWith(".metadataTypes")){let Y;if(P.typeNamespace==="app.metadataTypes")Y=V.metadataTypes?.find(_=>_.name===P.typeName)?.typeAnnotation;else if(P.typeNamespace?.startsWith("extensions.")&&P.typeNamespace?.endsWith(".metadataTypes")){let _=P.typeNamespace?.replace("extensions.","").replace(".metadataTypes","");Y=V.dependencies?.find(O=>O.name===_)?.metadataTypes?.find(O=>O.name===P.typeName)?.typeAnnotation??{}}P.typeKind="primitive",P.typeNamespace="nasl.core",P.typeName=Y?.typeName}})}S[N]=M;let{properties:E}=f;Array.isArray(E)&&E.forEach(V=>{j(V?.typeAnnotation)})}),[{namespace:"nasl.auth",list:X.authStructures},{namespace:"nasl.ui",list:X.uiStructures},{namespace:"nasl.collection",list:X.collectionStructures},{namespace:"nasl.interface",list:X.interfaceStructures},{namespace:"nasl.process",list:X.processStructures},{namespace:"nasl.processV2",list:X.processV2Structures},{namespace:"nasl.http",list:X.httpStructures}].forEach(f=>{let{namespace:A,list:N}=f||{};Array.isArray(N)&&N.forEach(M=>{let E=`${A}.${M.name}`;S[E]=M.toJSON?.();let{properties:V}=M;Array.isArray(V)&&V.forEach(T=>{j(T?.typeAnnotation)})})}),Array.isArray(R)&&y.push(...R),y.forEach(f=>{let A=f.getNamespace(),N=A?`${A}.${f.name}`:f.name;k[N]=i?f.toMockService():f.toService()}),v.forEach(f=>{Array.isArray(f.logics)&&f.logics.forEach(A=>{let N=A.getNamespace(),M=N?`${N}.${A.name}`:A.name;k[M]=A.toProcessService()})}),I.forEach(f=>{let A=f.toService();o&&a&&(A.url.path=A.url.path.replace(/^\/[^/]+\/[^/]+\//,"/")),i&&(A=f.toMockService()),h[`${f.getNamespace()}.${f.name}`]=A}),e.traverseStrictChildren(f=>{j(f?.typeAnnotation||f?.__TypeAnnotation)},["virtualParams"]);let C=[...w];Array.isArray(C)&&C?.forEach(f=>{let{defaultValue:A}=f,N=f.typeAnnotation||f.__TypeAnnotation;if(N?.typeNamespace?.endsWith(".metadataTypes")){let E=(r?.findNodeByCompleteName(N.typeNamespace+"."+N.typeName)||{}).typeAnnotation||{};N.typeKind=E.typeKind,N.typeNamespace=E.typeNamespace,N.typeName=E.typeName}A?.expression?f.defaultCode={code:A.toJS((0,un.createCompilerState)("",{getVuePrototype:!0})),executeCode:["NewComposite","NewList","NewMap","StringInterpolation","BinaryExpression","UnaryExpression","StringLiteral"].includes(A.expression.concept)}:f.defaultCode={},j(N)}),Array.isArray(s)&&s.forEach(f=>{let A=f?.typeAnnotation||f.__TypeAnnotation;j(A)});function j(f){if(f){let A=Ke(f);if(!S[A]){S[A]=f?.toJSON?.()??f;let{properties:N,typeArguments:M}=S[A]||{};Array.isArray(N)&&N.forEach(E=>{j(E?.typeAnnotation)}),Array.isArray(M)&&M.forEach(E=>{j(E)})}}}return s.forEach(f=>{let A=f.getViewEventName(),N=f.toFunction();p[A]=N,o&&delete p.beforeRouter}),{frontendEvents:p,frontendVariables:C,dataTypesMap:S,enumsMap:g,logicsMap:k,servicesMap:{_custom:h}}}var be=require("inversify"),$e=require("lodash");var he=class{constructor(e){Object.assign(this,e)}};function Q(r){return r!=null}function Kn(r){return Array.isArray(r)?r:[r]}function Jn(){throw new Error("todo")}function te(r){let e=r?JSON.stringify(r):String(r);throw new Error(`not implemented for ${e}`)}function Z(r){let e=r?JSON.stringify(r):String(r);throw new Error(`never implemented for ${e}. Should never be here!`)}function ee(r){throw new Error(`assertNever failed: ${r}`)}var Wn=r=>r.startsWith("elements."),qn=r=>r.split(".").at(1),fn=r=>`${r}Ref`;function Xn(r){return r.kind==="library"}function Zn(r){return r.tag==="template"}var ce=require("@lcap/nasl-concepts");function hn(r,e){let t=r?.split(".")||[],o=t[0]==="app"?1:0;return t.findIndex((a,c)=>c%2===o?a===e:!1)}function Yn(r){let e=r.typeAnnotation||r.__TypeAnnotation,{sortedTypeKey:t,typeKind:i,typeName:o,typeNamespace:a}=e||{};if(a?.endsWith(".metadataTypes")){let b=(r.app.findNodeByCompleteName(a+"."+o)||{}).typeAnnotation||{};t=`${b.typeNamespace}.${b.typeName}`,i=b.typeKind,o=b.typeName}let c=e&&(!["primitive","union"].includes(i)||o==="DateTime"),d=r.defaultValue?.expression?r.defaultValue.expression:new ce.Unparsed({code:void 0});return c?ce.CallFunction.from({calleeName:"genInitFromSchema",arguments:[new ce.Argument({expression:new ce.StringLiteral({value:t})}),new ce.Argument({expression:d})]},r.parentNode,r.parentKey):d}var $n=require("@lcap/nasl-utils");var Se=r=>r.replaceAll("_","-").replace(/(?:-)([a-zA-Z0-9])/g,(e,t)=>t.toUpperCase()),pe=r=>(0,$n.firstUpperCase)(Se(r));function _n(r){return/^[A-Z]/.test(r)}function et(r){return Q(r)&&r!==""}function nt(r){return r.charAt(0).toUpperCase()+r.slice(1)}function K({name:r,functions:e}){return{name:r,functions:e}}var Rn=require("@lcap/nasl-concepts"),Cn=require("@lcap/nasl-concepts/asserts"),wt=require("html-escaper"),re=require("inversify"),ne=require("lodash");var tt="__SomethingYouNeverGuessAsUndefinedPlaceholder__undefined__";function rt(r){return JSON.stringify(r,(e,t)=>t===void 0?tt:t,2).replaceAll(`"${tt}"`,"undefined")}var it=require("path");function ot(r){return(0,it.extname)(r)!==""}function yn(r){return"/"+r.map(t=>t.name).join("/")}var wn=K({name:"apiClientPlugin",functions:{buildApiStubFile(r,e){function t(o){let a=o.map(c=>[c.logic.name,c.logic.toService()]);return Object.fromEntries(a)}let i=Object.assign({},e.logicsMap,t(r));return new U("apis",[{from:"@lcap/basic-template",import:"{initLogic, initDataTypes, initService, Global}"}],[],["export { genInitFromSchema } from '@lcap/basic-template/dist/init/dataTypes';",`export const dataTypesMap = ${JSON.stringify(e.dataTypesMap)};`,`export const enumsMap = ${JSON.stringify(e.enumsMap)};`,`export const servicesMap = ${JSON.stringify(e.servicesMap)};`,`const logicsMap = ${JSON.stringify(i)};`,`
|
|
4701
4701
|
const {$global} = initDataTypes({dataTypesMap, i18nInfo: window.appInfo.i18nInfo});
|
|
4702
4702
|
export const dataTypesGlobal = $global;
|
|
4703
4703
|
window.$isInstanceOf = Global.prototype.$isInstanceOf;
|
|
@@ -4723,7 +4723,7 @@ const genInitFromSchema = useGenInitFromSchema();
|
|
|
4723
4723
|
export const useServices = ()=>{
|
|
4724
4724
|
return services;
|
|
4725
4725
|
}
|
|
4726
|
-
`])}}});var st=se(require("postcss"));var at=se(require("postcss-js"));function bn(r){try{let e=st.parse(r);return at.default.objectify(e)}catch{return{}}}var vn=
|
|
4726
|
+
`])}}});var st=se(require("postcss"));var at=se(require("postcss-js"));function bn(r){try{let e=st.parse(r);return at.default.objectify(e)}catch{return{}}}var vn=K({name:"JsxCodeGen",functions:{printTag(r){return`<${r} />`}}});var ct=require("prettier/standalone");var pt=se(require("prettier/parser-typescript"));var nr={tabWidth:2,printWidth:150,singleQuote:!0,trailingComma:"es5",plugins:[pt.default],parser:"typescript"},tr=L("codeFormatPlugin"),xn=K({name:"CodeFormatPlugin",functions:{async format(r,e){function t(){try{return(0,ct.format)(r,{...nr,...e})}catch(o){return tr.debug(o,"format\u51FA\u9519"),r}}return await t()}}});var rr="notFound",Oe=K({name:"RoutesExtraction",functions:{extractRoute(r,e,t){let i=(u,R)=>u.flatMap(I=>{let v=`${R}${I.identifier}`,n={accumulativePath:v,thisLevelPath:`${I.identifier}`,children:i(I.childComponents,`${v}/`),elementTemplate:I,kind:"normal",lazy:!!t?.lazy,meta:{title:I.__raw.title??"",crumb:I.__raw.crumb?.value??""}},S=n.children?.map(w=>{if(w.kind==="normal"&&w.elementTemplate.__raw.isIndex)return{accumulativePath:`${v}/`,thisLevelPath:"",redirect:`${v}/${w.elementTemplate.identifier}`,kind:"redirect"}}).filter(Q);return S?.length&&n.children?.push(...S),[n]}),o=i(r,e),a=r.find(u=>u.__raw.isIndex);a&&o.push({accumulativePath:"/",thisLevelPath:"/",redirect:`${e}${a.identifier}`,kind:"redirect"});let c=r.find(u=>u.identifier===rr)??a;c&&o.push({accumulativePath:"*",thisLevelPath:"*",redirect:`${e}${c.identifier}`,kind:"redirect"});let d=[],m=[];return o.filter(u=>u.kind==="normal").forEach(u=>{let R=(I,v)=>{if(I.kind==="normal"){let n=I.elementTemplate.__raw,S=v||n.auth;S?d.push(I.accumulativePath):m.push(I.accumulativePath),I.children?.forEach(w=>{R(w,S)})}};R(u,!1)}),{authResourcePaths:d,baseResourcePaths:m,routes:o}}}});var B=require("@lcap/nasl-concepts"),$=require("@lcap/nasl-concepts/asserts"),lt=require("lodash");var ir=L("component hack"),Je=K({name:"ReactComponentLibHackPlugin",functions:{__hooksDefinitions(){return new U("ReactComponentLibHackHooks",[{import:"{initUtils, cookie}",from:"@lcap/basic-template"},{import:"{Modal}",from:"antd"},{import:"{message}",from:"@lcap/pc-react-ui"},{from:"./apis",import:"{enumsMap, dataTypesMap}"},{from:"@lcap/basic-template",import:"{ initAuth }"},{from:"./apis",import:"{dataTypesGlobal}"}],[],[`
|
|
4727
4727
|
const {utils} = initUtils({enumsMap, dataTypesMap});
|
|
4728
4728
|
const ui = { showMessage: message.info };
|
|
4729
4729
|
|
|
@@ -4770,111 +4770,111 @@ const genInitFromSchema = useGenInitFromSchema();
|
|
|
4770
4770
|
return nasl;
|
|
4771
4771
|
};
|
|
4772
4772
|
|
|
4773
|
-
`])},hackBindAttribute(r,e){function t(
|
|
4773
|
+
`])},hackBindAttribute(r,e){function t(a){return a.typeAnnotation??a.__TypeAnnotation}function i(a){return a.typeKind==="primitive"&&a.typeNamespace==="nasl.core"&&a.typeName==="String"}if(e.name===Ve&&e.__raw.type==="dynamic"&&e.__raw.parentNode?.tag!=="template"){let a=t(e.expression.expr);if(a&&i(a))return e;let c=B.Argument.from({expression:e.expression.expr},e.__raw,"arguments");c.__TypeAnnotation=a??new B.TypeAnnotation;let d=B.CallFunction.from({calleeName:"ToString",calleeNamespace:"nasl.util",arguments:[c]});return d.__TypeAnnotation=B.TypeAnnotation.createPrimitive("String"),{...e,expression:{expr:d}}}else if(e.name==="dataSource"){let R=function(v){return{__raw:v,logics:v.logics.map(le),concept:v.concept,params:v.getContextLogicParams().map(ye),handlerName:c.dataFetchMethod}};var o=R;if((0,$.isIdentifier)(e.expression.expr)||(0,$.isMemberExpression)(e.expression.expr)||(0,$.isNumericLiteral)(e.expression.expr)||(0,$.isStringLiteral)(e.expression.expr)||(0,$.isBooleanLiteral)(e.expression.expr)||(0,$.isNullLiteral)(e.expression.expr)){let v=B.CallFunction.from({calleeName:"toJS",arguments:[new B.Argument({expression:e.expression.expr})]},e.__raw.parentNode,e.__raw.parentKey);return{...e,expression:{expr:v}}}let a=`dataSource${(0,lt.uniqueId)()}`,c={queryParam:"event",tempResultVariable:`${a}LoadResult`,dataFetchMethod:`${a}Load`},d=e.__raw.getAncestor("ViewElement");if(!d){let v=`\u627E\u4E0D\u5230${e.__raw.nodePath} \u7684\u7956\u5148ViewElement`;throw ir.error(v),new Error(v)}let m=r.findComponentRefByComponentName(d?.name??"")?.identifier;m&&e.expression.expr.traverseStrictChildren(v=>{(0,$.isMemberExpression)(v)&&(0,$.isIdentifier)(v.object)&&(0,$.isIdentifier)(v.property)&&v.object.name===m&&["current","pageSize","sorter","order"].includes(v.property.name)&&(v.object=new B.Identifier({name:c.queryParam}),v.property=new B.Identifier({name:v.property.name}))});let b=B.Logic.from({body:[new B.Assignment({left:new B.Identifier({name:c.tempResultVariable}),right:e.expression.expr}),new B.Unparsed({code:`return ${c.tempResultVariable}`})],params:[new B.Param({name:c.queryParam})],returns:[new B.Return({name:c.tempResultVariable})]},e.__raw.parentNode,void 0),u=B.BindEvent.from({name:"dataSource",params:b.params,logics:[b]},e.__raw.parentNode,"bindEvents"),I=R(u);return Ee(u),r.provideAction(We(I)),I}return e}}});var yt=require("@lcap/nasl-concepts");var H=require("@lcap/nasl-concepts"),l=require("@lcap/nasl-concepts/asserts"),Ae=require("@lcap/nasl-concepts/service"),W=se(require("@lcap/nasl-breakpoint")),gt=require("inversify"),ft=se(require("json5")),ht=require("lodash");var kn={required:"\u8868\u5355\u9879\u4E0D\u5F97\u4E3A\u7A7A",filled:"\u8868\u5355\u9879\u4E0D\u5F97\u4E3A\u7A7A",notEmpty:"\u8868\u5355\u9879\u4E0D\u5F97\u4E3A\u7A7A",empty:"\u8868\u5355\u9879\u5FC5\u987B\u4E3A\u7A7A",minLength:"\u4E0D\u5F97\u5C11\u4E8E{args}\u4E2A\u5B57\u7B26",maxLength:"\u4E0D\u5F97\u8D85\u8FC7{args}\u4E2A\u5B57\u7B26",rangeLength:"\u8BF7\u8F93\u5165{args}-{args}\u4E2A\u5B57\u7B26",min:"\u4E0D\u80FD\u5C0F\u4E8E{args}",max:"\u4E0D\u80FD\u5927\u4E8E{args}",range:"\u8303\u56F4\u5728{args}-{args}\u4E4B\u95F4",pattern:"\u8868\u5355\u9879\u683C\u5F0F\u4E0D\u6B63\u786E",is:"\u5FC5\u987B\u4E0E{args}\u76F8\u540C",isNot:"\u5FC5\u987B\u4E0E{args}\u4E0D\u540C",equals:"\u5FC5\u987B\u7B49\u4E8E{args}",notEquals:"\u5FC5\u987B\u4E0D\u7B49\u4E8E{args}",confirmed:"\u4E24\u6B21\u8F93\u5165\u7684\u5BC6\u7801\u4E0D\u4E00\u81F4",includes:"\u5FC5\u987B\u5305\u542B{args}",excludes:"\u4E0D\u80FD\u5305\u542B{args}",included:"\u5FC5\u987B\u4E3A{args}\u4E2D\u7684\u503C",excluded:"\u4E0D\u80FD\u4E3A{args}\u4E2D\u7684\u503C",unique:"\u8BE5\u8868\u5355\u9879\u5DF2\u7ECF\u5B58\u5728",noDuplicates:"\u4E0D\u80FD\u51FA\u73B0\u91CD\u590D\u9879",string:"\u8BF7\u8F93\u5165\u5B57\u7B26\u4E32",number:"\u8BF7\u8F93\u5165\u6570\u5B57",numeric:"\u8BF7\u8F93\u5165\u6570\u5B57",integer:"\u8BF7\u8F93\u5165\u6574\u6570",decimal:"\u8BF7\u8F93\u5165\u6B63\u786E\u683C\u5F0F\u7684\u5C0F\u6570",boolean:"\u5FC5\u987B\u4E3A\u5E03\u5C14\u7C7B\u578B",function:"\u5FC5\u987B\u4E3A\u51FD\u6570",object:"\u5FC5\u987B\u4E3A\u5BF9\u8C61",plainObject:"\u5FC5\u987B\u4E3A\u7B80\u5355\u5BF9\u8C61",array:"\u5FC5\u987B\u4E3A\u6570\u7EC4",alpha:"\u8BF7\u8F93\u5165\u5B57\u6BCD",alphaNum:"\u8BF7\u8F93\u5165\u5B57\u6BCD\u6216\u6570\u5B57",alphaDash:"\u8BF7\u8F93\u5165\u5B57\u6BCD\u6216\u4E0B\u5212\u7EBF",alphaNumDash:"\u8BF7\u8F93\u5165\u5B57\u6BCD\u3001\u6570\u5B57\u6216\u4E0B\u5212\u7EBF",alphaSpaces:"\u4EE5\u5B57\u6BCD\u6216\u7A7A\u683C\u7EC4\u6210",lowerCase:"\u4E0D\u80FD\u51FA\u73B0\u5927\u5199\u5B57\u6BCD",upperCase:"\u4E0D\u80FD\u51FA\u73B0\u5C0F\u5199\u5B57\u6BCD","^az":"\u4EE5\u5C0F\u5199\u5B57\u6BCD\u5F00\u5934","^az09":"\u4EE5\u5C0F\u5199\u5B57\u6BCD\u6216\u6570\u5B57\u5F00\u5934","^az09_":"\u4EE5\u5C0F\u5199\u5B57\u6BCD\u3001\u6570\u5B57\u6216\u4E0B\u5212\u7EBF\u5F00\u5934","^azAZ":"\u4EE5\u5B57\u6BCD\u5F00\u5934","^azAZ09":"\u4EE5\u5B57\u6BCD\u6216\u6570\u5B57\u5F00\u5934","^azAZ09_":"\u4EE5\u5B57\u6BCD\u3001\u6570\u5B57\u6216\u4E0B\u5212\u7EBF\u5F00\u5934",az09$:"\u4EE5\u5C0F\u5199\u5B57\u6BCD\u6216\u6570\u5B57\u7ED3\u5C3E",azAZ09$:"\u4EE5\u5B57\u6BCD\u6216\u6570\u5B57\u7ED3\u5C3E","^09$":"\u4EE5\u6570\u5B57\u7EC4\u6210","^az09$":"\u4EE5\u5C0F\u5199\u5B57\u6BCD\u6216\u6570\u5B57\u7EC4\u6210","^az09-$":"\u4EE5\u5C0F\u5199\u5B57\u6BCD\u3001\u6570\u5B57\u6216\u4E2D\u5212\u7EBF\u7EC4\u6210","^az09-.$":"\u4EE5\u5C0F\u5199\u5B57\u6BCD\u3001\u6570\u5B57\u3001'-'\u6216'.'\u7EC4\u6210","^azAZ09$":"\u4EE5\u5B57\u6BCD\u6216\u6570\u5B57\u7EC4\u6210","^azAZ09-$":"\u4EE5\u5B57\u6BCD\u3001\u6570\u5B57\u6216'-'\u7EC4\u6210","^az09-_$":"\u4EE5\u5C0F\u5199\u5B57\u6BCD\u3001\u6570\u5B57\u3001'-'\u6216'_'\u7EC4\u6210","^azAZ09_$":"\u4EE5\u5B57\u6BCD\u3001\u6570\u5B57\u6216'_'\u7EC4\u6210","^azAZ09-_$":"\u4EE5\u5B57\u6BCD\u3001\u6570\u5B57\u3001'-'\u6216'_'\u7EC4\u6210","without--":"\u4E0D\u80FD\u8FDE\u7EED\u51FA\u73B0\u4E2D\u5212\u7EBF",without__:"\u4E0D\u80FD\u8FDE\u7EED\u51FA\u73B0\u4E0B\u5212\u7EBF",email:"\u8BF7\u8F93\u5165\u6B63\u786E\u7684\u90AE\u7BB1",ip:"\u8BF7\u8F93\u5165\u6B63\u786E\u7684 IP",ipRange:"\u8BF7\u8F93\u5165\u6B63\u786E\u7684 IP \u6BB5",port:"\u8BF7\u8F93\u5165\u6B63\u786E\u7684\u7AEF\u53E3",url:"\u8BF7\u8F93\u5165\u6B63\u786E\u7684 URL",macAddress:"\u8BF7\u8F93\u5165\u6B63\u786E\u7684 MAC \u5730\u5740",md5:"\u8BF7\u8F93\u5165\u6B63\u786E\u7684 MD5",ascii:"\u5FC5\u987B\u4E3A ASCII",base32:"\u5FC5\u987B\u4E3A base32 \u7F16\u7801",base64:"\u5FC5\u987B\u4E3A base64 \u7F16\u7801",byteLength:"\u5B57\u8282\u957F\u5EA6\u4E0D\u5728\u6307\u5B9A\u8303\u56F4\u5185",dataURI:"\u5FC5\u987B\u4E3A DataURI \u7F16\u7801",magnetURI:"\u5FC5\u987B\u4E3A MagnetURI \u7F16\u7801",divisibleBy:"\u5FC5\u987B\u88AB{args}\u6574\u9664",fullWidth:"\u5FC5\u987B\u8F93\u5165\u5168\u89D2\u5B57\u7B26",halfWidth:"\u5FC5\u987B\u8F93\u5165\u534A\u89D2\u5B57\u7B26",hash:"\u54C8\u5E0C\u7F16\u7801\u4E0D\u7B26\u5408{args}\u7B97\u6CD5",hexColor:"\u8BF7\u8F93\u5165\u5408\u6CD5\u7684\u5341\u516D\u8FDB\u5236\u989C\u8272\u503C",hex:"\u8BF7\u8F93\u5165\u5341\u516D\u8FDB\u5236\u6570",identityCard:"\u8BF7\u8F93\u5165\u5408\u6CD5\u7684\u8EAB\u4EFD\u8BC1\u53F7\u7801",creditCard:"\u8BF7\u8F93\u5165\u5408\u6CD5\u7684\u4FE1\u7528\u5361\u53F7",fqdn:"\u8BF7\u8F93\u5165\u5408\u6CD5\u7684\u5168\u9650\u5B9A\u57DF\u540D",ipOrFQDN:"\u8BF7\u8F93\u5165\u4E00\u4E2A\u5408\u6CD5 IP \u6216\u5168\u9650\u5B9A\u57DF\u540D",isbn:"\u5FC5\u987B\u4E3A\u5408\u6CD5\u7684\u56FD\u9645\u6807\u51C6\u4E66\u53F7",issn:"\u5FC5\u987B\u4E3A\u5408\u6CD5\u7684\u56FD\u9645\u6807\u51C6\u8FDE\u7EED\u51FA\u7248\u7269\u7F16\u53F7",isin:"\u5FC5\u987B\u4E3A\u5408\u6CD5\u7684\u56FD\u9645\u8BC1\u5238\u8BC6\u522B\u7801",iso8601:"\u5FC5\u987B\u4E3A\u5408\u6CD5\u7684 ISO8601 \u65E5\u671F\u683C\u5F0F",rfc3339:"\u5FC5\u987B\u4E3A\u5408\u6CD5\u7684 RFC3339 \u65E5\u671F\u683C\u5F0F",iso31661Alpha2:"\u5FC5\u987B\u4E3A\u5408\u6CD5\u7684 ISO 3166-1 Alpha-2 \u56FD\u5BB6\u4EE3\u7801",iso31661Alpha3:"\u5FC5\u987B\u4E3A\u5408\u6CD5\u7684 ISO 3166-1 Alpha-3 \u56FD\u5BB6\u4EE3\u7801",json:"\u5FC5\u987B\u4E3A JSON \u683C\u5F0F\u5B57\u7B26\u4E32",jwt:"\u5FC5\u987B\u4E3A\u5408\u6CD5\u7684 JSON Web Token",latLong:"\u8BF7\u8F93\u5165\u5408\u6CD5\u7684\u7ECF\u7EAC\u5EA6\u5750\u6807\uFF0C\u5982 (-17.738223, 85.605469)",mobile:"\u8BF7\u8F93\u5165\u5408\u6CD5\u7684\u624B\u673A\u53F7\u7801",mongoId:"\u8BF7\u8F93\u5165\u5408\u6CD5\u7684 MongoDB \u5BF9\u8C61 ID",postalCode:"\u8BF7\u8F93\u5165\u5408\u6CD5\u7684\u90AE\u653F\u7F16\u7801",uuid:"\u8BF7\u8F93\u5165\u5408\u6CD5\u7684 UUID",chinese:"\u8BF7\u8F93\u5165\u4E2D\u6587\u5185\u5BB9"};var dt=require("@lcap/nasl-concepts");function mt(r){return r.concept==="LogNode"}var ut="$logReport",qe=L("JavaScriptCodeGen");function x(r,e){return t(o(r));function t(n){if(mt(n)){if(n.__actualNode){let S=x(n.__actualNode,e),w=n.__actualNode.arguments?.[0],s=x(w,e),p=n.__actualNode.calleeName,g=e?.resolve?.({kind:"calleeNamespace",value:ut});if(!g)throw new Error(`cannot reolve ${ut}`);return S+=`;${g}({
|
|
4774
4774
|
logicName: '${n.__logic?.name}',
|
|
4775
4775
|
path: '${n.__path}',
|
|
4776
4776
|
level: '${p}',
|
|
4777
|
-
message: ${
|
|
4778
|
-
});`,S}return""}else{if(d(n))return m(n);if((0,l.isLogicItem)(n))return v(n);if((0,l.isLogic)(n))return c(n)}return b(n)}function i(n){let S=n.typeAnnotation||n.__TypeAnnotation,{sortedTypeKey:w,typeKind:
|
|
4777
|
+
message: ${s},
|
|
4778
|
+
});`,S}return""}else{if(d(n))return m(n);if((0,l.isLogicItem)(n))return v(n);if((0,l.isLogic)(n))return c(n)}return b(n)}function i(n){let S=n.typeAnnotation||n.__TypeAnnotation,{sortedTypeKey:w,typeKind:s,typeName:p,typeNamespace:g}=S||{};if(g?.endsWith(".metadataTypes")){let h=n.app.findNodeByCompleteName(g+"."+p)?.typeAnnotation;h&&(w=`${h.typeNamespace}.${h.typeName}`,s=h.typeKind,p=h.typeName)}if(S&&(!["primitive","union"].includes(s??"")||p==="DateTime")){let h=t(n);return H.CallFunction.from({calleeName:"genInitFromSchema",arguments:[new H.Argument({expression:new H.StringLiteral({value:w})}),new H.Argument({expression:new H.Unparsed({code:h})})]},n.parentNode,n.parentKey)}return n}function o(n){return(0,l.isCallFunction)(n)||(0,l.isCallLogic)(n)||(0,l.isNewComposite)(n)||(0,l.isDefaultValue)(n)?i(n):n}function a(n){return`(${w()})=>(${S()})`;function S(){let s=n.logics[0];return x(s,e)}function w(){return n.params.map(s=>s.name).toString()}}function c(n){let S="async (";return Array.isArray(n.params)&&(S+=n.params.map(w=>w.name).toString()),S+=") => {",Array.isArray(n.params)&&n.params.forEach(w=>{let s=x(w,e);w.name!==s&&(S+=`${w.name} = ${s};
|
|
4779
4779
|
`)}),Array.isArray(n.variables)&&n.variables.forEach(w=>{S+=`let ${x(w,e)};
|
|
4780
4780
|
`}),Array.isArray(n.returns)&&n.returns.forEach(w=>{S+=`let ${x(w,e)};
|
|
4781
4781
|
`}),Array.isArray(n.body)&&n.body.forEach(w=>{if((0,ht.isNil)(w))throw qe.error(`${n.nodePath} \u7684 body \u6709\u7A7A\u503C`),new Error("");S+=t(w),S+=`
|
|
4782
|
-
`}),S+="}",S}function d(n){return n instanceof
|
|
4783
|
-
`)}if(n instanceof
|
|
4784
|
-
${w}`}if(n instanceof
|
|
4782
|
+
`}),S+="}",S}function d(n){return n instanceof W.AfterStartNode||n instanceof W.BeforeEndNode||n instanceof W.CallbackNode||n instanceof W.BreakpointNode}function m(n){if(n instanceof W.AfterStartNode){let S=n._logicNodePath,w=x(n.logic,e),s="const $breaker = window.$breaker.colonize()",p=`await $breaker.fireHook('after-start')('${S}')`;return[w,s,p].filter(Boolean).join(`
|
|
4783
|
+
`)}if(n instanceof W.BeforeEndNode){let S=n._logicNodePath,w=x(n.logic,e);return`${`await $breaker.fireHook('before-end')('${S}')`}
|
|
4784
|
+
${w}`}if(n instanceof W.CallbackNode){let S=n.logic||n.variable;if(!S)return"";let w=x(S,e);return!W.isFunctional(S)||!w?w:`$breaker.transfer(($breaker) => ${w})`}if(n instanceof W.BreakpointNode){let S=n.logic||n.variable,w=n._nodePath,s=`generateBreakpoint('${w}'`,p=w&&`await $breaker.generateBreakpoint('${w}', ${W.parse})()`;if(!S)return p;let g;return g=W.makeGenerators(!1,x,e).reduce((y,C)=>y||C(n)(p),""),g=W.makeGenerators(!0,x,e).reduce((y,C)=>y&&y.includes(s)?y:C(n)(p),g),g||p}return te(n)}function b(n){if((0,l.isReturn)(n)){let p=function(g){let k="",h=g.typeAnnotation||g.__TypeAnnotation,y=h&&(!["primitive","union"].includes(h.typeKind)||h.typeName==="DateTime");y&&(k+=`genInitFromSchema('${h?.sortedTypeKey}',`);let C=g.defaultValue?.toJS?.()??"undefined";return k+=C,y&&(k+=")"),k};var S=p;let w=e?.resolve?.({kind:"identifier",value:new H.Identifier({name:n.name})})??n.name,s=p(n);return`${w} = ${s}`}if((0,l.isParam)(n)){let w=n.defaultValue?x(n.defaultValue,e):void 0;return w?`${n.name} === undefined ? ${w} : ${n.name}`:`${n.name}`}if((0,l.isVariable)(n)){let w=n.typeAnnotation||n.__TypeAnnotation,{sortedTypeKey:s,typeKind:p,typeName:g,typeNamespace:k}=w||{};if(k?.endsWith(".metadataTypes")){let j=(n.app.findNodeByCompleteName(k+"."+g)||{}).typeAnnotation||{};s=`${j.typeNamespace}.${j.typeName}`,p=j.typeKind,g=j.typeName}let h=w&&(!["primitive","union"].includes(p)||g==="DateTime"),y=`${n.name} = `;if(h&&(y+=`genInitFromSchema('${s}',`),n.defaultValue?.expression){let C=x(n.defaultValue.expression,e);y+=C}else y+="undefined";return h&&(y+=")"),y}if((0,l.isDefaultValue)(n)){let w="";return["Date","Time","DateTime"].includes(n.parentNode?.typeAnnotation?.typeName)&&n.expression?.value===""?"null":(w+=n.expression?x(n.expression,e):"undefined",w)}return te(n)}function u(n){if(n.calleeNamespace){let S=n.calleeNamespace,w=S.startsWith("extensions."),s=S.startsWith("extensions.")&&S.includes(".frontends."),p=`'${n.calleeNamespace}.${n.calleeName}'`;return n.calleeNamespace.startsWith("app.dataSources.")?`apiClient[${p}]`:w?s?`$library['${S.split(".")[1]}']['${n.calleeName}']`:`apiClient[${p}]`:`${e?.resolve?.({kind:"calleeNamespace",value:n.calleeNamespace})??n.calleeNamespace}.${n.calleeName}`}else return e?.resolve?.({kind:"identifier",value:new H.Identifier({name:n.calleeName})})??n.calleeName}function R(n){let S=u(n),w=(0,l.isCallLogic)(n)?s(n).join(", "):n.arguments.map(p=>x(p,e)).join(", ");return`${S}?.(${w})`;function s(p){let g="";g+=`
|
|
4785
4785
|
config: {
|
|
4786
4786
|
download: false,
|
|
4787
4787
|
},
|
|
4788
4788
|
headers: {
|
|
4789
4789
|
"lcap-calllogic-uuid": "${p.uuid}",
|
|
4790
|
-
},`;let k=p.calleeName;if(p.isProcessV2Logic)throw qe.error("\u7FFB\u8BD1\u5668\u5C1A\u672A\u652F\u6301\u6D41\u7A0BV2\u7684\u903B\u8F91"),new Error("\u7FFB\u8BD1\u5668\u5C1A\u672A\u652F\u6301\u6D41\u7A0BV2\u7684\u903B\u8F91");if(p.isViewLogic)return p.arguments.map(
|
|
4791
|
-
${T.keyword}: ${x(T.arg,e)}`).join(", ");
|
|
4792
|
-
`;break}case"update":case"createOrUpdate":case"batchUpdate":{
|
|
4793
|
-
`;let V=
|
|
4794
|
-
`);
|
|
4795
|
-
`,
|
|
4790
|
+
},`;let k=p.calleeName;if(p.isProcessV2Logic)throw qe.error("\u7FFB\u8BD1\u5668\u5C1A\u672A\u652F\u6301\u6D41\u7A0BV2\u7684\u903B\u8F91"),new Error("\u7FFB\u8BD1\u5668\u5C1A\u672A\u652F\u6301\u6D41\u7A0BV2\u7684\u903B\u8F91");if(p.isViewLogic)return p.arguments.map(y=>x(y,e));{let C=p.getCallNode()?.params||[],j=C.some(N=>N.spread),f=hn(p.calleeNamespace,"entities"),A=hn(p.calleeNamespace,"processes");if(f!==-1){let N=p.arguments,M=!1;switch(k){case"get":case"delete":{N=[],g+="query: {";let V=C.map((T,P)=>{let Y=p.arguments?.[P];return{keyword:T?.name,arg:Y}}).map(T=>`
|
|
4791
|
+
${T.keyword}: ${x(T.arg,e)}`).join(", ");g+=V,g+=`},
|
|
4792
|
+
`;break}case"update":case"createOrUpdate":case"batchUpdate":{g+=`body: {
|
|
4793
|
+
`;let V=N.map(T=>`${T.keyword==="body"?p.calleeName==="batchUpdate"?"entities":"entity":T.keyword}: ${x(T.expression,e)}`).join(`,
|
|
4794
|
+
`);g+=V,g+=`},
|
|
4795
|
+
`,N=[],M=!0;break}case"updateBy":{g+="body: {";let V=N.map(T=>{let P=T.keyword==="body"?"entity":T.keyword;if(T.expression.returnExpression){let Y=JSON.stringify(h(T.expression.returnExpression)).replace(/"__@@(.*?)@@__"/g,"$1");return`${P}: {
|
|
4796
4796
|
concept: 'Function',
|
|
4797
4797
|
name: 'filter',
|
|
4798
4798
|
returnExpression: window.$resolveRequestData(${Y})
|
|
4799
|
-
}`}return`${
|
|
4800
|
-
`,
|
|
4799
|
+
}`}return`${P}: ${x(T.expression,e)}`}).join(",");g+=V,g+=`},
|
|
4800
|
+
`,N=[],M=!0;break}case"deleteBy":{g+="body: ";let V=JSON.stringify(h(N[0].expression.returnExpression)).replace(/"__@@(.*?)@@__"/g,"$1");g+=`{
|
|
4801
4801
|
concept: 'Function',
|
|
4802
4802
|
name: 'filter',
|
|
4803
4803
|
returnExpression: window.$resolveRequestData(${V})
|
|
4804
|
-
}`,
|
|
4805
|
-
`,
|
|
4806
|
-
${E?.keyword}: ${x(E,e)}`:
|
|
4807
|
-
body: {`,!
|
|
4808
|
-
${_?.keyword}: ${x(_?.arg,e)}`).join(", ");if(
|
|
4809
|
-
${V.name}: [${fe}],`}let Y=p.__TypeArguments?.length?p.__TypeArguments:p.typeArguments;Array.isArray(Y)&&Y.length&&(
|
|
4810
|
-
__typeArguments: ${ft.stringify(Y)}`)}
|
|
4811
|
-
`)}function v(n){if((0,l.isSubLogic)(n))return c(n);if((0,l.isAnonymousFunction)(n)){let
|
|
4812
|
-
${
|
|
4813
|
-
}`;return n.alternate.length?`${
|
|
4814
|
-
`):p!==
|
|
4804
|
+
}`,g+=`,
|
|
4805
|
+
`,N=[],M=!0;break}default:break}let E=N.find(V=>V.keyword==="body");M||(E?g+=`
|
|
4806
|
+
${E?.keyword}: ${x(E,e)}`:g+="body: {}")}else{let N=A!==-1,M=E=>!!E?.expression;if(g+=`path: {},
|
|
4807
|
+
body: {`,!N){let E=[...C],V;j&&(V=E.pop());let T=E.map((_,O)=>{let fe=p.completeArguments[O];return{keyword:_?.name,arg:fe}}).filter(_=>M(_.arg)),P=T.map(_=>`
|
|
4808
|
+
${_?.keyword}: ${x(_?.arg,e)}`).join(", ");if(g+=P,T.length&&(g+=", "),j){let _=p.completeArguments.slice(E.length),O=J=>J?.expression,fe=_.filter(J=>O(J)).map(J=>x(J,e)||"").join(", ");g+=`
|
|
4809
|
+
${V.name}: [${fe}],`}let Y=p.__TypeArguments?.length?p.__TypeArguments:p.typeArguments;Array.isArray(Y)&&Y.length&&(g+=`
|
|
4810
|
+
__typeArguments: ${ft.stringify(Y)}`)}g+="}"}}return[`{${g}}`];function h(y){if(!y)return;if(y.concept==="Identifier"){let f=x(y,e);return{concept:y.concept,name:y.name,value:`__@@${f}@@__`,expression:f}}if(y.concept==="MemberExpression"){let{concept:f}=y,{value:A}=y;if(y?.object.name==="_")return{concept:f,name:y.name,value:A,object:y.object,property:y.property};let N=x(y,e);return y.object?.namespace==="app.enums"?(A=N.replace(/^"(.+)"$/,"$1"),N=void 0,f="StringLiteral"):A=`__@@${N}@@__`,{concept:f,name:y.name,value:A,expression:N}}let C;y.concept==="UnaryExpression"?C=h(y.argument):C=h(y.left);let j=h(y.right);return{concept:y.concept,name:y.name,value:y.value,expression:y.expression,operator:y.operator,left:C,right:j}}}}function I(n){return n.map(S=>x(S,e)).join(`;
|
|
4811
|
+
`)}function v(n){if((0,l.isSubLogic)(n))return c(n);if((0,l.isAnonymousFunction)(n)){let s=n.parentNode?.parentNode;return(0,l.isCallLogic)(s)&&/dataSources\.[^.]+\.entities\.[^.]+\.logics/.test(s.calleeNamespace)&&["update","updateBy","createOrUpdate","batchUpdate"].includes(s.calleeName)?(()=>{let g="[";return n.body&&(0,l.isNewList)(n.body)&&n.body.items.forEach((k,h,y)=>{g+=`'${x(k.property,e)}'`,h!==y.length-1&&(g+=",")}),g+="]",g})():a({logics:[n.body],params:n.params})}else{if((0,l.isAbort)(n))return"throw Error('\u7A0B\u5E8F\u4E2D\u6B62');";if((0,l.isStart)(n))return"";if((0,l.isEnd)(n)){let s=n.logic.returns.at(0);return s?`return ${s.name};`:"return;"}else if((0,l.isIfStatement)(n)){let s=`if(${x(n.test,e)}){
|
|
4812
|
+
${I(n.consequent)}
|
|
4813
|
+
}`;return n.alternate.length?`${s} else {${I(n.alternate)}}`:s}else if((0,l.isSwitchStatement)(n)){let s="";return n.cases.forEach(p=>{s+=x(p,e)}),s}else if((0,l.isSwitchCase)(n)){let s=n.parentNode;if(!(0,l.isSwitchStatement)(s))throw new Error("SwitchCase\u7684\u7236\u8282\u70B9\u4E0D\u662FSwitchStatement");let p=s.cases.indexOf(n),g=s.cases.length;if(p===-1)throw new Error("\u65E0\u6CD5\u5728\u7236\u8282\u70B9\u4E2D\u627E\u5230\u6B64SwitchCase");let k="";return p===0?(k="if (",k+=n.test?x(n.test,e):"",k+=`) {
|
|
4814
|
+
`):p!==g-1?(k="else if (",k+=n.test?x(n.test,e):"",k+=`) {
|
|
4815
4815
|
`):k+=`else {
|
|
4816
|
-
`,Array.isArray(n.consequent)&&n.consequent.forEach(
|
|
4816
|
+
`,Array.isArray(n.consequent)&&n.consequent.forEach(h=>{k+=`${x(h,e)}
|
|
4817
4817
|
`}),k+=`}
|
|
4818
|
-
`,k}else if((0,l.isForEachStatement)(n)){let
|
|
4819
|
-
`,
|
|
4820
|
-
`,
|
|
4821
|
-
`,
|
|
4822
|
-
`,
|
|
4823
|
-
`,
|
|
4824
|
-
`,Array.isArray(n.body)&&n.body.forEach(C=>{
|
|
4825
|
-
`}),
|
|
4826
|
-
`,
|
|
4827
|
-
`,
|
|
4828
|
-
`,Array.isArray(n.body)&&n.body.forEach(p=>{
|
|
4829
|
-
`}),
|
|
4830
|
-
`,
|
|
4831
|
-
`}),
|
|
4818
|
+
`,k}else if((0,l.isForEachStatement)(n)){let s="",p=n.each?x(n.each,e):"",g=Math.random(),k=Math.round(g*1e4),h=`$forEachListVariable${k}`,y="";return n.end?y=x(n.end,e):n.each&&(y=`(${h} || {}).length`),s+=`var ${h} = ${p};
|
|
4819
|
+
`,s+=`var $forEachStartVariable${k} = ${n.start&&x(n.start,e)};
|
|
4820
|
+
`,s+=`var $forEachEndVariable${k} = ${y};
|
|
4821
|
+
`,s+=`if(Array.isArray($forEachListVariable${k})) {
|
|
4822
|
+
`,s+=`for (let ${n.index.name} = $forEachStartVariable${k}; `,s+=`${n.index.name} < $forEachEndVariable${k}; ${n.index.name}++) {
|
|
4823
|
+
`,s+=`var ${n.item.name} = $forEachListVariable${k}[${n.index.name}];
|
|
4824
|
+
`,Array.isArray(n.body)&&n.body.forEach(C=>{s+=`${x(C,e)}
|
|
4825
|
+
`}),s+=`}
|
|
4826
|
+
`,s+=`}
|
|
4827
|
+
`,s}else if((0,l.isWhileStatement)(n)){let s="";return s+="while (",s+=n.test?x(n.test,e):"",s+=`) {
|
|
4828
|
+
`,Array.isArray(n.body)&&n.body.forEach(p=>{s+=`${x(p,e)}
|
|
4829
|
+
`}),s+=`}
|
|
4830
|
+
`,s}else{if((0,l.isAssignment)(n))return`${x(n.left,{...e,shouldInsertOptional:!1})} = ${x(n.right,e)}`;if((0,l.isBatchAssignment)(n)){let s="",p=new Map;return n.assignmentLines.forEach(({leftIndex:g,rightIndex:k})=>{let h=JSON.stringify(k);p.has(h)?p.set(h,[...p.get(h),g]):p.set(h,[g])}),p.forEach((g,k)=>{let h=JSON.parse(k)||[],y=g.map(A=>A.length!==1?n.left.members[A[1]]:n.left.expression),[C,j]=[h[0],h[1]],f=j!==void 0?n.rights[C].members[j]:n.rights[C].expression;y.forEach(A=>{s+=`${x(A,{...e,shouldInsertOptional:!1})}`,s+=" = "}),s+=`${x(f,e)}`,s+=`;
|
|
4831
|
+
`}),s}else{if((0,l.isComment)(n))return["/**",...n.value.split(`
|
|
4832
4832
|
`).map(p=>`* ${p}`),"*/"].join(`
|
|
4833
|
-
`);if((0,l.isCallLogic)(n))return["jsonSerialize","jsonDeserialize"].includes(n.calleeName)&&n.calleeNamespace==="nasl.util"?R(n):((n.calleeNamespace==="nasl.browser"||n.calleeNamespace==="nasl.configuration"||n.calleeNamespace==="nasl.process")&&(n.calleeNamespace="$global"),`await (${R(n)})`);if((0,l.isCallConnector)(n))return
|
|
4834
|
-
'${Qe?.keyword}': ${dn}`:
|
|
4833
|
+
`);if((0,l.isCallLogic)(n))return["jsonSerialize","jsonDeserialize"].includes(n.calleeName)&&n.calleeNamespace==="nasl.util"?R(n):((n.calleeNamespace==="nasl.browser"||n.calleeNamespace==="nasl.configuration"||n.calleeNamespace==="nasl.process")&&(n.calleeNamespace="$global"),`await (${R(n)})`);if((0,l.isCallConnector)(n))return Z();if((0,l.isCallFunction)(n)){let s="",p=n.getAncestor("Logic"),g=n.calleeName;n.view&&p&&(g=H.asyncFuncMap[n.calleeName]?H.asyncFuncMap[n.calleeName]:g,H.asyncFuncMap[n.calleeName]&&(s+="await "));let k=u({calleeName:g,calleeNamespace:n.calleeNamespace});s+=`${k}`,s+="(";let h;if(n.calleeName==="ToString"){let C=n.arguments[0];h=C.typeAnnotation||C.__TypeAnnotation}else n.calleeName==="FromString"&&(h=n.typeArguments?.[0]);if(n.calleeName==="ToString"&&h&&(s+=`'${h.sortedTypeKey}', `),Array.isArray(n.arguments)&&n.arguments.length&&n.arguments.forEach((C,j)=>{let f=x(C,e),A=C.typeAnnotation||C.__TypeAnnotation;(0,Ae.transfromUnionTypeAnnotation)(A,n.app);let{sortedTypeKey:N}=(0,Ae.transfromMetadataType)(A,n.app);["HasValue"].includes(n.calleeName)&&(f=`{ type: '${N}', value: ${f} }`),s+=f,j!==n.arguments?.length-1&&(s+=", ")}),n.calleeName==="FromString"&&h){let{sortedTypeKey:C}=(0,Ae.transfromMetadataType)(h,n.app);s+=`, '${C}'`}if(!(["ToString","FromString"].includes(n.calleeName)&&h)&&Array.isArray(n.typeArguments)&&n.typeArguments.length){n.arguments?.length&&(s+=", ");let C=n.typeArguments.length;n.typeArguments?.forEach((j,f)=>{s+=JSON.stringify(j),f!==C-1&&(s+=", ")})}return s+=")",s}else if((0,l.isCallInterface)(n)){let C=function(){let O=n.getAncestor("Connector"),fe=n.getAncestor("Integration");return O&&fe?p?.integration?.connectors?.find?.(J=>J.name===k):O&&!fe?p?.connectorDependencies?.find?.(J=>J.name===k):p?.interfaceDependencies?.find?.(J=>J.name===k)};var S=C;let{calleewholeKey:s,app:p,completeArguments:g}=n,[,k,,h]=s.split("."),j=C()?.interfaces?.find?.(O=>O.name===h);if(!j)throw!n.calleeNamespace||!n.calleeName?new Error("\u8C03\u7528\u63A5\u53E3\u4E3A\u7A7A"):new Error(`${k}\u4E0B\u7684${h}\u63A5\u53E3\u672A\u627E\u5230`);let f=!1,A=j.params,N=A.filter(O=>O.in==="query").map(O=>O.name),M=A.filter(O=>O.in==="header").map(O=>O.name),E=A.filter(O=>O.in==="body").map(O=>(O.typeAnnotation.typeKind==="primitive"&&(f=!0),O.name)),V=A.filter(O=>O.in==="path").map(O=>O.name),T=(O,fe,J,Mn,On)=>{let Vn=O.filter(Qe=>fe.includes(Qe.keyword));return Vn.forEach((Qe,Kt)=>{let dn=x(Qe,e);On?J+=` ...${dn}`:Mn?J+=`
|
|
4834
|
+
'${Qe?.keyword}': ${dn}`:J+=` ${dn}`,Kt!==O.length-1&&(J+=", ")}),Vn.length===0&&!Mn&&!On&&(J+="undefined"),J},P=`await $services['_custom']['${n.calleeNamespace}.${n.calleeName}']`;P+=`({ config: {
|
|
4835
4835
|
download: false,
|
|
4836
4836
|
},
|
|
4837
|
-
query: {`,
|
|
4838
|
-
`,
|
|
4839
|
-
})`;let Y=n.typeAnnotation||n.__TypeAnnotation;return Y&&!["primitive","union"].includes(Y.typeKind)&&(
|
|
4840
|
-
`)}}`;if((0,l.isIdentifier)(n)){let{namespace:
|
|
4841
|
-
`:h
|
|
4837
|
+
query: {`,P=T(g,N,P,!0,!1),P+="}, path: {",P=T(g,V,P,!0,!1),P+="}, headers: {",P=T(g,M,P,!0,!1),P+=`},
|
|
4838
|
+
`,f?(P+="body: ",P=T(g,E,P,!1,!1)):(P+="body: {",P=T(g,E,P,!1,!0),P+="}"),P+=`
|
|
4839
|
+
})`;let Y=n.typeAnnotation||n.__TypeAnnotation;return Y&&!["primitive","union"].includes(Y.typeKind)&&(P=`genInitFromSchema('${Y?.sortedTypeKey}', ${P})`),P}else{if((0,l.isCallAuthInterface)(n))return Z();if((0,l.isDestination)(n)){let k=function(h){let y="`",C=h.genViewArr();if(Array.isArray(C)&&C.length){y+=`/${C.join("/")}`;let{completeArguments:j}=h;if(j.length){let f=h.viewNode,A=[];f?.params&&(A=f.params);let N=A.length,M=j.map((E,V)=>{let T=x(E,e),P="";return T&&V<N&&(P+=`${E.keyword}=\${`,T==="undefined"?P+="null":P+=T,P+="}"),P}).filter(E=>!!E);y+=`?${M.join("&")}`}if(h.anchor){let f=x(h.anchor,e);f&&(y+=`#\${${f}}`)}}return y+="`",y};var w=k;let s=k(n);if((0,l.isBindAttribute)(n.parentNode))return s;let g="";return g+="$destination(",g+=s,g+=',"',g+=`${n.target}`,g+='")',g}else if((0,l.isExternalDestination)(n)){let s="";if(n.link){let p=x(n.link,e);if((0,l.isBindAttribute)(n.parentNode))return p;let k=e?.resolve?.({kind:"identifier",value:new H.Identifier({name:"$link"})});if(s+=`${k}(\`\${`,s+=`${p}`,s+="}",n.anchor){let h=x(n.anchor,e);h&&(s+=`#\${${h}}`)}s+='`,"',s+=`${n.target}`,s+='")'}return s}else if((0,l.isValidationRule)(n)){let s="{";if(n.calleeName&&n.calleeName.includes("("))return`'${n.calleeName}'`;if(n.calleeName==="unique"?s+="validate: 'excluded',":n.calleeName==="confirmed"?s+="validate: 'is',":s+=`validate: '${n.calleeName}',`,n.arguments.length){let p="[";n.arguments?.forEach((g,k)=>{p+=x(g,e),k!==n.arguments?.length-1&&(p+=", ")}),p+="]",s+=`args: ${p} ,`}if(n.errorMessage)s+=`message: ${x(n.errorMessage,e)},`;else{let p=kn[n.calleeName]??"",g=0;for(;p&&p.indexOf("{args}")!==-1;)p=p.replace("{args}",`\${${x(n.arguments[g],e)}}`),g++;if(p?.includes("{label}"))return Jn();n.frontend?.i18nInfo?.enabled&&(p=`\${$i18n.t('${n.i18nKeyPrefix}${n.calleeName}')}`),s+=`message: \`${p}\`,`}return s+="trigger: 'input+blur'",["required","filled","notEmpty"].includes(n.calleeName)&&(s+=",required: true"),s+="}",s}else if((0,l.isArgument)(n)){let s="";if(n.expression){let p=x(n.expression,e);s+=p}else s+="undefined";return n.spread?`...${s}`:`${s}`}else{if((0,l.isAnchor)(n))return n.expression?x(n.expression,e):"";if((0,l.isJSBlock)(n))return n.code;if((0,l.isJavaLogic)(n))return Z();if((0,l.isBlock)(n))return`{${n.logicItems.map(p=>x(p,e)).join(`
|
|
4840
|
+
`)}}`;if((0,l.isIdentifier)(n)){let{namespace:s}=n;if(s)if(n.isFrontendVariables){let p=H.MemberExpression.from({object:new H.Identifier({name:"$frontendVariables"}),property:new H.Identifier({name:n.name})},n.parentNode,n.parentKey);return x(p,e)}else if(n.isEnum()){let p=n.name;return s.startsWith("extensions.")&&(p=`${s}.${n.name}`),p}else{if(s.endsWith("configuration.groups.custom.properties"))return`"${s}.${n.name}"`;if(s.endsWith("logics"))return`'${s}.${n.name}'`}return e?.resolve?.({kind:"identifier",value:n})??n.name}else{if((0,l.isNullLiteral)(n))return"null";if((0,l.isBooleanLiteral)(n))return n.value;if((0,l.isStringLiteral)(n)){let s="",p=`${JSON.stringify(n.value)}`;return n.i18nKey&&n.value&&n.frontend?.i18nInfo?.enabled?s=`$i18n.t('${n.i18nKey}')`:n.i18nKey&&n.getAncestor("BusinessComponent")?s=`($global?.i18nInfo?.enabled ? $i18n.t('${n.i18nKey}') : ${p})`:typeof n.value=="string"&&(s=p),s}else{if((0,l.isStringInterpolation)(n))return n.expressions.length?n.expressions.map(s=>{let p=s.typeAnnotation||s.__TypeAnnotation;(0,Ae.transfromUnionTypeAnnotation)(p,n.app);let{sortedTypeKey:g}=(0,Ae.transfromMetadataType)(p,n.app);return`nasl.util.ToString('${g}', ${x(s,e)})`}).join(" + "):"''";if((0,l.isNumericLiteral)(n))return n.value;if((0,l.isBinaryExpression)(n))return`${x(n.left,e)}${n.operator}${x(n.right,e)}`;if((0,l.isMatchCase)(n)){let s=n.parentNode;if(!(0,l.isMatch)(s))throw new Error("MatchCase\u7684\u7236\u8282\u70B9\u975EMatch");let p="";if(Array.isArray(n.patterns)){let k=n.patterns.map(y=>(0,l.isTypeAnnotation)(y)?`window.$isInstanceOf(${x(s.expression,e)}, '${y.sortedTypeKey}')`:`window.$global.isEqual(${x(s.expression,e)}, ${x(y,e)})`).join("||"),h=s.cases.length;if(h>1){let y=s.cases.indexOf(n);if(y===-1)throw new Error("\u65E0\u6CD5\u5728Match\u4E2D\u627E\u5230\u6B64MatchCase");y===0?p=`if (${k}) {
|
|
4841
|
+
`:y!==h-1?p=`else if (${k}) {
|
|
4842
4842
|
`:p+=`else {
|
|
4843
|
-
`}Array.isArray(n.body)&&n.body.forEach((
|
|
4844
|
-
`}),
|
|
4845
|
-
`)}return p}else if((0,l.isMatch)(n)){let
|
|
4846
|
-
`:
|
|
4847
|
-
`),n.expression&&Array.isArray(n.cases)&&n.cases.forEach((
|
|
4848
|
-
`:
|
|
4849
|
-
`,
|
|
4850
|
-
`}else if(p&&p.typeKind!=="anonymousStructure"){
|
|
4851
|
-
`;let
|
|
4852
|
-
`}),
|
|
4853
|
-
`}else{
|
|
4854
|
-
`,n.properties.forEach(
|
|
4855
|
-
`});let
|
|
4856
|
-
`}),
|
|
4857
|
-
`}return
|
|
4858
|
-
`:
|
|
4859
|
-
`,
|
|
4860
|
-
`,n.items.forEach((p,
|
|
4843
|
+
`}Array.isArray(n.body)&&n.body.forEach((y,C)=>{n.parentNode.isExpression&&C===n.body.length-1&&y.concept!=="Abort"&&(p+="return "),p+=`${x(y,e)}
|
|
4844
|
+
`}),h>1&&(p+=`}
|
|
4845
|
+
`)}return p}else if((0,l.isMatch)(n)){let s="",p=n.getAncestor("Logic");return(n.isExpression||!p)&&(p?s+=`await (async () => {
|
|
4846
|
+
`:s+=`(() => {
|
|
4847
|
+
`),n.expression&&Array.isArray(n.cases)&&n.cases.forEach((g,k)=>{s+=x(g,e)}),(n.isExpression||!p)&&(s+="})()"),s}else if((0,l.isUnaryExpression)(n)){let s=x(n.argument,e);return n.operator==="isNull"?s:`!(${s})`}else if((0,l.isMemberExpression)(n)){if((0,l.isIdentifier)(n.object)&&n.object.isEnum()&&(0,l.isIdentifier)(n.property))return x(new H.StringLiteral({value:n.property.name}),e);let s=e?.shouldInsertOptional===!1?"":"?";if((0,l.isIdentifier)(n.object)){let p=n.object.name;return`${e?.resolve?.({kind:"calleeNamespace",value:p})??p}${s}.${x(n.property)}`}return`${x(n.object,e)}${s}.${x(n.property)}`}else{if((0,l.isUnparsed)(n))return n.code;if((0,l.isNew)(n))return"";if((0,l.isNewComposite)(n)){let s="",{typeAnnotation:p}=n,g=n.assignmentLines.findIndex(({leftIndex:h})=>h[1]===void 0);if(!n.typeAnnotation)return"";if(n.getAncestor("Logic")?s+=`await (async () => {
|
|
4848
|
+
`:s+=`(() => {
|
|
4849
|
+
`,g!==-1){let{rightIndex:h}=n.assignmentLines[g],y=h[1]!==void 0?n.rights[h[0]].members[h[1]]:n.rights[h[0]].expression;s+=`return ${x(y,e)};
|
|
4850
|
+
`}else if(p&&p.typeKind!=="anonymousStructure"){s+=`const obj = genInitFromSchema('${p.sortedTypeKey}', nasl.util.New(${p.toJS()}));
|
|
4851
|
+
`;let h=new Map;n.assignmentLines.forEach(({leftIndex:y,rightIndex:C})=>{let j=JSON.stringify(C);h.has(j)?h.set(j,[...h.get(j),y]):h.set(j,[y])}),h.forEach((y,C)=>{let j=JSON.parse(C)||[],f=y.map(E=>n.properties[E[1]]),[A,N]=[j[0],j[1]],M=N!==void 0?n.rights[A].members[N]:n.rights[A].expression;f.forEach(E=>{s+=`obj.${E.name} = `}),s+=`${x(M,e)}`,s+=`;
|
|
4852
|
+
`}),s+=`return obj;
|
|
4853
|
+
`}else{s+=`const obj = {};
|
|
4854
|
+
`,n.properties.forEach(y=>{s+=`obj.${y.name} = null;
|
|
4855
|
+
`});let h=new Map;n.assignmentLines.forEach(({leftIndex:y,rightIndex:C})=>{let j=JSON.stringify(C);h.has(j)?h.set(j,[...h.get(j),y]):h.set(j,[y])}),h.forEach((y,C)=>{let j=JSON.parse(C)||[],f=y.map(E=>n.properties[E[1]]),[A,N]=[j[0],j[1]],M=N!==void 0?n.rights[A].members[N]:n.rights[A].expression;f.forEach(E=>{s+=`obj.${E.name} = `}),s+=`${x(M,e)}`,s+=`;
|
|
4856
|
+
`}),s+=`return obj;
|
|
4857
|
+
`}return s+="})()",s}else if((0,l.isNewList)(n)){let s="";return n.getAncestor?.("Logic")?s+=`await (async () => {
|
|
4858
|
+
`:s+=`(() => {
|
|
4859
|
+
`,s+=`const arr = [
|
|
4860
|
+
`,n.items.forEach((p,g)=>{s+=x(p,e),g+1<n.items.length&&(s+=", ")}),s+=`
|
|
4861
4861
|
];
|
|
4862
|
-
`,
|
|
4863
|
-
`,
|
|
4864
|
-
`:
|
|
4865
|
-
`,
|
|
4866
|
-
`,
|
|
4867
|
-
`,n.keys.forEach((p,
|
|
4868
|
-
`,
|
|
4869
|
-
`}),
|
|
4870
|
-
`,
|
|
4871
|
-
`,Array.isArray(
|
|
4872
|
-
})`,p}else return(0,l.isCallQueryComponent)(n)?
|
|
4873
|
-
`);return`{path: "${v}", meta: ${JSON.stringify(
|
|
4862
|
+
`,s+=`return arr;
|
|
4863
|
+
`,s+="})()",s}else if((0,l.isNewMap)(n)){let s="";return n.getAncestor?.("Logic")?s+=`await (async () => {
|
|
4864
|
+
`:s+=`(() => {
|
|
4865
|
+
`,s+=`const obj = {};
|
|
4866
|
+
`,s+=`let k;
|
|
4867
|
+
`,n.keys.forEach((p,g)=>{let k=p,h=n.values[g];s+="k = ",s+=`${k?x(k,e):void 0};
|
|
4868
|
+
`,s+="obj[k] = ",s+=`${h?x(h,e):void 0};
|
|
4869
|
+
`}),s+=`return obj;
|
|
4870
|
+
`,s+="})()",s}else if((0,l.isCallEvent)(n)){let{completeArguments:s=[]}=n,p="";if(p+=`props?.on${nt(n.calleeName)}({
|
|
4871
|
+
`,Array.isArray(s)&&s.length){let k=n.getCallNode()?.params;s.forEach((h,y)=>{let C=x(h,e),j=k?.[y]?.defaultValue;if(j){let f=x(j,e);f&&(C=`${C} !== undefined ? ${C} : ${f}`)}p+=`${h.keyword}: ${C}`,y!==s?.length-1&&(p+=", ")})}return p+=`
|
|
4872
|
+
})`,p}else return(0,l.isCallQueryComponent)(n)?Z():(0,l.isQueryFromExpression)(n)?Z():(0,l.isQueryJoinExpression)(n)?Z():(0,l.isQueryFieldExpression)(n)?Z():(0,l.isQueryAggregateExpression)(n)?Z():(0,l.isQueryOrderByExpression)(n)?Z():(0,l.isQueryGroupByExpression)(n)?Z():(0,l.isQuerySelectExpression)(n)?Z():(0,l.isQueryLimitExpression)(n)?Z():(0,l.isSqlQueryComponent)(n)?Z():(0,l.isOqlQueryComponent)(n)?Z():(0,l.isProcessOutcome)(n)?Z():(0,l.isAssignee)(n)?Z():(0,l.isProcessOutcomes)(n)?Z():n?(qe.warn(`Concept:${n.concept} \u672A\u88AB\u5904\u7406\uFF0C\u56DE\u9000\u81F3\u9ED8\u8BA4\u7FFB\u8BD1\uFF0C\u8BF7\u62A5\u544A\u6B64\u9519\u8BEF`),n.toJS()):(qe.error("\u9047\u5230\u7A7A\u8282\u70B9\uFF0C\u8BF7\u62A5\u544A\u6B64\u9519\u8BEF"),"(undefined)")}}}}}}}}}}var Sn=K({name:"javaScriptCodeGen",functions:{printSyntaxNode(r,e){return x(r,e)}}}),de=class{printSyntaxNode(e,t){return x(e,t)}};de=G([(0,gt.injectable)()],de);var or=L("ReactRouterPlugin"),sr=[{from:"react-dom",import:"ReactDOM"},{from:"react",import:"React, { useEffect, useState }"},{from:"react-router-dom",import:" { RouterProvider, Navigate, useNavigate,useLocation } "},{from:"./router/component",import:"{ createRouter }"},{from:"./router/hooks",import:"{ useUserInfo, useUserResources }"},{from:"./nasl",import:"{ useAppConfig }"}],ze="__views__",Xe="__bizComponents__",An=class{constructor(){this.dict=new Map}query(e){let t=this.inc(e);return t===1?`${e}`:`${e}${t}`}inc(e){let t=this.initName(e);return this.dict.set(e,t+1),t+1}initName(e){return this.dict.has(e)?this.dict.get(e):(this.dict.set(e,0),0)}},Ge=K({name:"ReactRouter",functions:{routeToCode(r,e){let t={...vn.functions,...Sn.functions},i=new An,o=new WeakMap,a=c(r);function c(I){return I.flatMap(v=>{if(v.kind==="normal"){let n=v.elementTemplate.identifier;if(n){let S=e.get(v.elementTemplate),w=pe(n),s=pe(`${S}${n}`.replaceAll("/","-").replace(/^-/,"")),p=i.query(s);v.elementMangledName=p,or.debug({mangledName:p});let k={from:`./${ze}${S}/${w}`,import:p,lazy:v.lazy};return o.set(v.elementTemplate,k),[k,...c(v.children??[])]}}return[]})}function d(I){let v=I.thisLevelPath??"/";if(I.kind==="normal"){let p=function(){return`element: ${w}`};var n=p;let S=I.children?.map(d).filter(Q)??[],w=t.printTag(I.elementMangledName??I.elementTemplate.identifier),s=S.join(`,
|
|
4873
|
+
`);return`{path: "${v}", meta: ${JSON.stringify(I.meta)}, children: [${s}], ${p()} }`}if(I.kind==="redirect"){let S=t.printSyntaxNode(yt.StringLiteral.from({value:I.redirect}));return`{path: "${v}", element: <Navigate to={${S}} />}`}te(I)}let m=[...sr,...a,{from:"@lcap/pc-react-ui",import:"{ConfigProvider, RouterContext}"},{from:"./platform.config",import:"platformConfig"},{from:"@/components/FrontendEventWrapper",import:"FrontendEventWrapper"}];return{code:`
|
|
4874
4874
|
${`const defaultRoutes = [{
|
|
4875
4875
|
path: '/',
|
|
4876
4876
|
children: [
|
|
4877
|
-
${r.map(d).filter(
|
|
4877
|
+
${r.map(d).filter(Q).join(`,
|
|
4878
4878
|
`)}
|
|
4879
4879
|
],
|
|
4880
4880
|
element: <FrontendEventWrapper></FrontendEventWrapper>,
|
|
@@ -4928,8 +4928,8 @@ query: {`,N=T(u,P,N,!0,!1),N+="}, path: {",N=T(u,V,N,!0,!1),N+="}, headers: {",N
|
|
|
4928
4928
|
const {link, destination} = initRouter();
|
|
4929
4929
|
export const useLink = ()=>link;
|
|
4930
4930
|
export const useDestination = useNavigate;
|
|
4931
|
-
`])}}});var No=L("ReactSlotPlugin"),In=
|
|
4932
|
-
`)??"";function v(n){return(0,wt.escape)(n).replace(/({|})/g,(S,w)=>`{'${w}'}`)}})(),b=
|
|
4931
|
+
`])}}});var No=L("ReactSlotPlugin"),In=K({name:"ReactSlotPlugin",functions:{preprocessForSlots(r){let e=[];for(let t of r.children){let i=t.slot.target;if(i){if(r.attrs.some(o=>o.name===i)){let o=r.__raw.nodePath;throw new Error(`${o}\u5B58\u5728\u591A\u4E2AslotName=${i}\u7684\u5B50\u5143\u7D20\u6216\u5DF2\u7ECF\u6709attr\u540D\u4E3A${i}\uFF0C\u4E3A\u810F\u6570\u636E`)}if(Zn(t.component)&&t.children.length===0)continue;r.attrs.push(Ue({type:"component",component:t,scopeVariable:t.slot.scope,name:i}))}else e.push(t)}r.children=e}}});var ar=L("react codegen");function Nn(r){return pe(r.identifier)}var Ve="children",Be=class r{constructor(e,t,i,o,a,c,d){this.name=e;this.imports=t;this.hooks=i;this.children=o;this.ctx=a;this.reactCodegenPlugin=c;this.options=d;this.attrMap=new Map;this.directives=new Map}getImports(){return(0,ne.uniq)([...this.imports,...this.hooks.map(e=>e.kind==="free"?e.import:{from:"react",import:`{${e.kind}}`}),{import:"{ observer }",from:"mobx-react-lite"},{from:"mobx",import:"{ toJS, autorun }"}].filter(Q))}getHooks(){return this.hooks}getAttrMapStr(){let e=[];for(let[t,i]of this.attrMap)if(t!==Ve){let o=()=>{if(i.kind==="expr")return`{${i.payload}}`;{let a=i.payload;return a.includes('"')?`{${JSON.stringify(a)}}`:`${JSON.stringify(a)}`}};e.push({key:Se(t),value:o()})}return e.map(({key:t,value:i})=>` ${t}=${i}`).join("")}getMangledName(){return this.options?.mangledName??this.name}isIdeSlot(){return this.name==="IdeSlot"}toJsx(e){let t=this.getAttrMapStr(),i=e?.rootAsFragment?"":this.name,o=()=>{let m=(()=>{let R=this.attrMap.get(Ve);if(R)return R.kind==="string"?v(R.payload):`{${R.payload}}`;return e?.shallow?"":this.children.map(n=>n.toJsx({rootAsFragment:n.isIdeSlot()})).join(`
|
|
4932
|
+
`)??"";function v(n){return(0,wt.escape)(n).replace(/({|})/g,(S,w)=>`{'${w}'}`)}})(),b=u();if(this.options?.slot){let R=this.options?.slot.scope;if(this.options?.slot.target&&R)return{body:`(${R}: any) => ${b}`}}return{body:b};function u(){return i?`<${i}${t}>${m}</${i}>`:`<>${m}</>`}},{body:a}=o(),c=this.directives.get("if");return c?`{(${this.ctx.resolveExprToString(c.expression.expr,this.reactCodegenPlugin.javaScriptCodegen,this.reactCodegenPlugin.reactStateManager.withCtx(this.ctx))}) ? (${a}) : undefined}`:a}genUpdateParamsHooks(){if(this.options?.kind==="biz-component"){let e=this.options.params??[];if(!e.length)return;this.hooks.push({kind:"useEffect",body:`() => {
|
|
4933
4933
|
${e.map(t=>`localStore.${t.name} = props.${t.name}`).join(`;
|
|
4934
4934
|
`)}
|
|
4935
4935
|
}`,deps:[{expr:new Rn.Identifier({name:"props"})}]}),this.hooks.push({kind:"useEffect",body:`() => {
|
|
@@ -4942,21 +4942,21 @@ query: {`,N=T(u,P,N,!0,!1),N+="}, path: {",N=T(u,V,N,!0,!1),N+="}, headers: {",N
|
|
|
4942
4942
|
`).join(`;
|
|
4943
4943
|
`)}
|
|
4944
4944
|
}
|
|
4945
|
-
}`,deps:[]})}}toFunctionComponentVariable(){let e=this.getMangledName(),t=this.toJsx({rootAsFragment:!0});this.genUpdateParamsHooks();let i=
|
|
4945
|
+
}`,deps:[]})}}toFunctionComponentVariable(){let e=this.getMangledName(),t=this.toJsx({rootAsFragment:!0});this.genUpdateParamsHooks();let i=a=>{switch(a.kind){case"useCallback":{let c=a.body;return`const ${a.declaration} = useCallback(${c}, [${a.deps.map(d=>this.ctx.resolveExprToString(d.expr,this.reactCodegenPlugin.javaScriptCodegen,this.reactCodegenPlugin.reactStateManager.withCtx(this.ctx))).join(",")}])`}case"useState":return`const [${a.declarations.join(",")}] = useState(${a.initial})`;case"useEffect":return`useEffect(${a.body}, [${a.deps.map(c=>this.ctx.resolveExprToString(c.expr,this.reactCodegenPlugin.javaScriptCodegen,this.reactCodegenPlugin.reactStateManager.withCtx(this.ctx))).join(",")}])`;case"free":return`${a.code}`;default:te(a)}},o=(0,ne.uniq)([...this.getImports()]).filter(Q);if(this.options?.kind==="biz-component"){let a=`const ${e}: FC = observer(forwardRef((props, ref) => {
|
|
4946
4946
|
${this.hooks.map(i).join(`;
|
|
4947
4947
|
`)}
|
|
4948
4948
|
return (${t});
|
|
4949
|
-
}));`;return this.imports.push({from:"react",import:"{ forwardRef }"}),{componentStr:
|
|
4949
|
+
}));`;return this.imports.push({from:"react",import:"{ forwardRef }"}),{componentStr:a,imports:o}}else return{componentStr:`const ${e}: FC = observer((props) => {
|
|
4950
4950
|
${this.hooks.map(i).join(`;
|
|
4951
4951
|
`)}
|
|
4952
4952
|
return (${t});
|
|
4953
|
-
});`,imports:o}}toCode(){let{componentStr:e,imports:t}=this.toFunctionComponentVariable();return{code:e,imports:t}}static fromComponentIR(e,t){let i=Nn(e),o=e.elements.map(c=>t.genReactFragment(c,e.stateContext)),
|
|
4954
|
-
`)}}`}}this.attrMap.set("style",d(c))}bindDirective(e){this.directives.set(e.kind,e)}},U=class r{constructor(e,t,i,o,
|
|
4953
|
+
});`,imports:o}}toCode(){let{componentStr:e,imports:t}=this.toFunctionComponentVariable();return{code:e,imports:t}}static fromComponentIR(e,t){let i=Nn(e),o=e.elements.map(c=>t.genReactFragment(c,e.stateContext)),a=t.reactStateManager.produceHooks(e.stateContext);return e.kind==="biz-component"?new r(i,[...o.flatMap(c=>c.getImports())],[...a,...o.flatMap(c=>c.getHooks())],o,e.stateContext,t,{mangledName:`__${i}`,kind:e.kind,params:e.__raw.params}):new r(i,[...o.flatMap(c=>c.getImports())],[...a,...o.flatMap(c=>c.getHooks())],o,e.stateContext,t,{mangledName:`__${i}`})}bindEvent(e,t){let i=t?.handlerPrefix??"on-",o=e.__raw.name,a=`${i}${o}`,d=this.reactCodegenPlugin.reactStateManager.withCtx(this.ctx).resolveIdentifier(new Rn.Identifier({name:e.handlerName}));if(!d)throw new Error("cannot find event handler");let m=e.params,b=m.at(0);if(m.length>1&&b){let u=m.map(R=>R.name).join(",");this.attrMap.set(a,{kind:"expr",payload:`(${b.name}) => ${d}(${u})`})}else this.attrMap.set(a,{kind:"expr",payload:d})}bindAttr(e){switch(e.kind){case"expr":{if(e.__raw.type==="string")this.attrMap.set(e.__raw.name,{kind:"string",payload:String(e.__raw.value)});else if(e.__raw.type==="dynamic")if(e.expression.expr){let t=Je.functions.hackBindAttribute(this.ctx,e);if(t.concept==="BindEvent")return this.bindEvent(t,{handlerPrefix:""});let i=this.ctx.resolveExprToString(t.expression.expr,this.reactCodegenPlugin.javaScriptCodegen,this.reactCodegenPlugin.reactStateManager.withCtx(this.ctx));this.attrMap.set(e.__raw.name,{kind:"expr",payload:i})}else{let t=`${e.__raw.nodePath}@${e.__raw.concept} \u7684expression \u4E3A\u7A7A`;ar.debug(t);return}else if(e.__raw.type==="static"){if(e.__raw.name==="children"){this.attrMap.set(e.__raw.name,{kind:"string",payload:String(e.__raw.value)});return}et(e.__raw.value)&&this.attrMap.set(e.__raw.name,{kind:"expr",payload:String(e.__raw.value)})}return}case"render":{let t=this.reactCodegenPlugin.genReactFragment(e.component,this.ctx),i=t.toJsx();this.imports.push(...t.getImports()),this.attrMap.set(e.name,{kind:"expr",payload:i});return}case"validation-rules":{let t=e.rules.map(i=>this.ctx.resolveExprToString(i,this.reactCodegenPlugin.javaScriptCodegen,this.reactCodegenPlugin.reactStateManager.withCtx(this.ctx)));this.attrMap.set(e.name,{kind:"expr",payload:`[${t.join(", ")}]`});return}default:ee(e)}}setStyleAndStaticStyle(e,t){if(e.length===0&&!t)return;let i=bn(t);e.forEach(m=>{if(!m.name)throw new Error(m.nodePath);if(m.expression&&(i[m.name]=m,!(0,Cn.isBindStyle)(m)))throw new Error(`${m} is not bindStyle`)});let o=this;function a(m){return m.replace(/-([a-z])/g,(b,u)=>u.toUpperCase())}let c=Object.entries(i).map(([m,b])=>{if((0,ne.isObject)(b)&&(0,Cn.isBindStyle)(b)){let u=a(m),R=o.ctx.resolveExprToString(b.expression,this.reactCodegenPlugin.javaScriptCodegen,this.reactCodegenPlugin.reactStateManager.withCtx(o.ctx));return u==="backgroundImage"?{kind:"expr",payload:`\`url(\${${R}})\``,key:u}:{kind:"expr",payload:R,key:u}}else if((0,ne.isString)(b))return{kind:"string",payload:b,key:m}}).filter(Q);function d(m){return{kind:"expr",payload:`{${m.map(u=>{let R=I();return`${JSON.stringify(u.key)}: ${R}`;function I(){return u.kind==="expr"?u.payload:`${JSON.stringify(u.payload)}`}}).join(`,
|
|
4954
|
+
`)}}`}}this.attrMap.set("style",d(c))}bindDirective(e){this.directives.set(e.kind,e)}},U=class r{constructor(e,t,i,o,a){this.fileName=e;this.imports=t;this.body=i;this.exports=o;this.folder=a}get fileNameWithExt(){return this.fileName.includes(".")?this.fileName:`${this.fileName}.tsx`}getFolderPath(){if(this.folder)return yn(this.folder)}getImports(){return[...this.imports,...this.body.flatMap(e=>e.getImports())].filter(Q)}async serialize(e){let t=this.exports,i=this.body.map(b=>b.toCode()),a=this.getImports().map(e),d=[(0,ne.uniq)(a).join(`
|
|
4955
4955
|
`),i.map(b=>b.code).join(`
|
|
4956
4956
|
`),(0,ne.uniq)(t).join(`
|
|
4957
4957
|
`)].join(`
|
|
4958
4958
|
`),m=await xn.functions.format(d);return this.fileNameWithExt.endsWith(".tsx")?`//@ts-nocheck
|
|
4959
|
-
${m}`:m}merge(e){return e?(this.imports.push(...e.imports),this.body.push(...e.body),this.exports.push(...e.exports),this):this}static empty(e){return new r(e??"NoName",[],[],[])}};function cr(r){return Xn(r.component)&&r.component.tag==="template"?"":r.component.tag}var Ie=class{constructor(e,t,i,o,
|
|
4959
|
+
${m}`:m}merge(e){return e?(this.imports.push(...e.imports),this.body.push(...e.body),this.exports.push(...e.exports),this):this}static empty(e){return new r(e??"NoName",[],[],[])}};function cr(r){return Xn(r.component)&&r.component.tag==="template"?"":r.component.tag}var Ie=class{constructor(e,t,i,o,a){this.javaScriptCodegen=e;this.reactStateManager=t;this.frontendPerformance=i;this.projectOrganizer=o;this.reactHookProviders=a}genReactFragment(e,t){let i={...Oe.functions,...Ge.functions,...In.functions},o=[{from:"react",import:"React"},{from:"react",import:"{type FC}"}],a=[];i.preprocessForSlots(e);let c=e.children.map(u=>this.genReactFragment(u,t));c.forEach(u=>{a.push(...u.getHooks()),o.push(...u.getImports())});let d=cr(e),m=new Be(d,o,a,c,t,this,{slot:e.slot}),b=pr(e.component);b&&o.push(b),m.setStyleAndStaticStyle(e.__raw.bindStyles??[],e.__raw.staticStyle??"");for(let u of e.events)m.bindEvent(u);for(let u of e.attrs)m.bindAttr(u);for(let u of e.directives)m.bindDirective(u);return m}genReactComponent(e,t){let i=Nn(e),o=Be.fromComponentIR(e,this);return[new U(i,(0,ne.uniq)(o.getImports()),[o],[`export default ${o.getMangledName()}`],t)]}recursivelyGenReactComponent(e,t,i){return t.set(e,i?yn(i):"/"),(0,ne.flatten)([this.genReactComponent(e,i),e.kind==="view"?e.childComponents.flatMap(o=>this.recursivelyGenReactComponent(o,t,[...i??[],{name:e.identifier}])):[]])}buildRoutes(e,t){let i={...Oe.functions,...Ge.functions},{routes:o}=i.extractRoute(e,"/",{lazy:this.frontendPerformance?.performanceOptions?.lazy??!0}),{code:a,imports:c}=i.routeToCode(o,t);return new U("Router",[...c],[],[a])}buildPlatformConfig(e){let t={...Oe.functions},{authResourcePaths:i,baseResourcePaths:o}=t.extractRoute(e.views,"/",{lazy:!1}),a={...e.configs.basePlatformConfig,authResourcePaths:i,baseResourcePaths:o};return new U("platform.config.ts",[],[],[`export default ${rt(a)}`])}buildInit(e){let i=e.configs.document.icon?`
|
|
4960
4960
|
{
|
|
4961
4961
|
const link = document.createElement('link');
|
|
4962
4962
|
link.rel = 'shortcut icon';
|
|
@@ -5025,8 +5025,8 @@ ${m}`:m}merge(e){return e?(this.imports.push(...e.imports),this.body.push(...e.b
|
|
|
5025
5025
|
}
|
|
5026
5026
|
}
|
|
5027
5027
|
init();
|
|
5028
|
-
`])}async buildMasterCss(e,t){L("buildMasterCss").info(t);let o=t.map(
|
|
5029
|
-
`),o=JSON.stringify(e.filter(
|
|
5028
|
+
`])}async buildMasterCss(e,t){L("buildMasterCss").info(t);let o=t.map(a=>a.kind==="standard"?`@import './packages/${a.name}@${a.version}/dist-theme/index.css';`:`@import './packages/extension/${a.name}@${a.version}/dist-theme/index.css';`);return new U("index.css",[],[],[...o,e])}async buildGlobalFrontendVariableFile(e,t){let i=e.map(a=>{let c=()=>{let b=a.defaultValue?.expression?t.resolveExprToString(a.defaultValue.expression,this.javaScriptCodegen,this.reactStateManager.withCtx(t)):void 0;if(a.localCache){let u=`loadFromLocalStorage(${d})`;return b?`${u} ?? ${b}`:u}else if(b)return b},d=`${JSON.stringify(a.name)}`,m=c();return m?`${a.name} = ${m};`:`${a.name}: any;`}).join(`
|
|
5029
|
+
`),o=JSON.stringify(e.filter(a=>a.localCache).map(a=>a.name));return new U("global-variables.tsx",[{from:"mobx",import:"{makeAutoObservable, observe}"},{from:"./Hooks",import:"{genInitFromSchema, nasl}"}],[],[`
|
|
5030
5030
|
const loadFromLocalStorage = (key: string)=> {
|
|
5031
5031
|
const value = globalThis.localStorage[key];
|
|
5032
5032
|
try {
|
|
@@ -5061,16 +5061,16 @@ ${m}`:m}merge(e){return e?(this.imports.push(...e.imports),this.body.push(...e.b
|
|
|
5061
5061
|
saveToLocalStorage(key, value);
|
|
5062
5062
|
}
|
|
5063
5063
|
});
|
|
5064
|
-
`])}buildLibraryHook(e){let t=e.filter(o=>o.kind==="extension"),i=t.map(o=>({from:`@extension/${o.name}`,import:`* as ${pe(o.name)}`})).filter(
|
|
5064
|
+
`])}buildLibraryHook(e){let t=e.filter(o=>o.kind==="extension"),i=t.map(o=>({from:`@extension/${o.name}`,import:`* as ${pe(o.name)}`})).filter(Q);return new U("",[...i],[],[`export const useLibrary = ()=>{
|
|
5065
5065
|
return {
|
|
5066
5066
|
${t.map(o=>`${o.name}: ${pe(o.name)}`)}
|
|
5067
5067
|
};
|
|
5068
|
-
}`])}async genFiles(e,t){let i=U.empty("Hooks").merge(new U("",[{from:"./init"}],[],[])).merge(Ge.functions.__hooksDefinitions()).merge(wn.functions.__hooksDefinitions()).merge(Je.functions.__hooksDefinitions()).merge(Ze.functions.__hooksDefinitions()).merge(this.buildLibraryHook(e.packages)).merge(new U("",[],[],["export {nasl, genInitFromSchema};"]));this.reactHookProviders?.forEach(
|
|
5068
|
+
}`])}async genFiles(e,t){let i=U.empty("Hooks").merge(new U("",[{from:"./init"}],[],[])).merge(Ge.functions.__hooksDefinitions()).merge(wn.functions.__hooksDefinitions()).merge(Je.functions.__hooksDefinitions()).merge(Ze.functions.__hooksDefinitions()).merge(this.buildLibraryHook(e.packages)).merge(new U("",[],[],["export {nasl, genInitFromSchema};"]));this.reactHookProviders?.forEach(I=>{i.merge(I.genHookDefinition())});let o=wn.functions.buildApiStubFile(e.apis,e.configs.metaData),a=new WeakMap,c=e.views.flatMap(I=>this.recursivelyGenReactComponent(I,a)),d=e.bizComponents.flatMap(I=>this.recursivelyGenReactComponent(I,a)),m=this.buildRoutes(e.views,a),b=await this.buildMasterCss(e.configs.themeCSS,e.packages),u=await this.buildGlobalFrontendVariableFile(e.configs.globalVariables,e.baseCtx);return await this.projectOrganizer.organize({baseDir:t,project:{api:o,utils:i,routes:m,views:c,bizComponents:d,platformConfig:this.buildPlatformConfig(e),init:this.buildInit(e),masterCss:b,globalVariables:u}})}};Ie=G([(0,re.injectable)(),z(0,(0,re.inject)(D.ReactJavaScriptCodePrinter)),z(1,(0,re.inject)(D.ReactStateManager)),z(2,(0,re.inject)(D.FrontendPerformance)),z(3,(0,re.inject)(D.ProjectOrganizer)),z(4,(0,re.multiInject)(D.ReactHookProvider)),z(4,(0,re.optional)())],Ie);function pr(r){switch(r.kind){case"library":return{from:`${r.libraryName}`,import:`{${r.tag}}`};case"biz-component":return{from:`${r.libraryName}`,import:`${r.tag}`};default:ee(r)}}var Ze=K({name:"i18nPlugin",functions:{genI18nInfo(r){let e={enabled:!1,locale:"zh-CN",messages:{},I18nList:[]};if(r?.i18nInfo?.enabled){let t=r.i18nInfo?.toJSON();e=JSON.parse(JSON.stringify(t)),e.messages=e.messageMap,delete e.messageMap;let i=e.messages||{},o=r.getI18nKeyNodes(),a={};o.forEach(m=>{a[m.i18nKey]=m.value});let c=i["zh-CN"],d={...c,...a};i["zh-CN"]=d,Object.keys(i).forEach(m=>{if(m!=="zh-CN"){let b=i[m];Object.keys(d).forEach(u=>{a[u]&&c[u]!==a[u]?b[u]=d[u]:b[u]||(b[u]=d[u])})}}),e.I18nList=r.getCurrentLanguageList()}return e},__hooksDefinitions(){return new U("",[],[],[`export const useI18n = ()=>{
|
|
5069
5069
|
return window.$i18n ?? {};
|
|
5070
5070
|
}
|
|
5071
5071
|
export const useI18nInfo = ()=>{
|
|
5072
5072
|
return window.appInfo.i18nInfo ?? {};
|
|
5073
|
-
}`])}}});var Pn=Q({name:"MetadataPlugin",functions:{makeBasePlatformConfig(r,e,t){let i=t?.lowcodeDomain,o=t?.envNuimsDomain?.[t?.env]||t?.nuimsDomain,s=t?.envLcpDomain?.[t?.env]?.lcpDomain||t?.lowcodeDomain;return{appConfig:{id:r.id,project:r.name,domainName:r.name,nuimsDomain:o,lowcodeDomain:i,envNuimsDomain:t.envNuimsDomain,tenantType:t.tenantType,tenantLevel:t.tenantLevel,extendedConfig:t.extendedConfig,envConfig:{lowcodeDomain:s},tenant:t.tenant,documentTitle:e.documentTitle,basePath:e.prefixPath,frontendName:e.name,sysPrefixPath:r.sysPrefixPath,appTimeZone:r?.appTimeZone,i18nInfo:Ze.functions.genI18nInfo(e),rootViewData:void 0},dnsAddr:r.dnsAddr,tenant:t.tenant,env:t.env,hasUserCenter:r.hasUserCenter,hasAuth:r.hasAuth,basePath:e.prefixPath,sysPrefixPath:r.sysPrefixPath,frontendName:e.name,isPreviewFe:!!t.isPreviewFe}}}});var He=class r{constructor(e,t,i,o){this.providedStates=e;this.consumedStateNames=t;this.actions=i;this.parentCtx=o}recursivelyExtractTreeStates(){return[...this.providedStates.filter(e=>e.kind==="tree"),...this.parentCtx?.recursivelyExtractTreeStates()??[]]}resolveExprToString(e,t,i){return t.printSyntaxNode(e,{resolve({kind:o,value:s}){switch(o){case"calleeNamespace":return i.resolveCalleeNamespace(s);case"identifier":return i.resolveIdentifier(s)}}})}static fromParent(e){return new r([],[],[],e)}provide(e){return this.providedStates.push(e),this}provideAction(e){return this.actions.push(e),this}findStateByName(e){return this.providedStates.find(t=>t.identifier===e)??this.parentCtx?.findStateByName(e)}findActionByName(e){return this.actions.find(t=>t.name===e)??this.parentCtx?.findActionByName(e)}findComponentRefByComponentName(e){return this.findStateByName(fn(e))??this.parentCtx?.findComponentRefByComponentName(e)}};function lr(r,e){let t=[],i=[];return r.dependencies&&t.push(...r.dependencies),r.interfaceDependencies&&t.push(...r.interfaceDependencies),e.views&&i.push(...e.views),t.forEach(o=>{o.views&&i.push(...o.views)}),i}function ye(r){return{name:r.name,typeAnnotation:r.__TypeAnnotation,defaultValue:r.defaultValue}}function dr(r){if(e(r)||t(r)){if(t(r)){let i=F.CallFunction.from({calleeNamespace:"nasl.auth",calleeName:"has",arguments:[F.Argument.from({expression:new F.StringLiteral({value:r.viewElement.authPath})})]},r.parentNode,r.parentKey);return{__raw:r,concept:r.concept,expression:we(i),kind:"if"}}else{let i=r.expression;if(i)return{__raw:r,concept:r.concept,expression:we(i),kind:"if"};me.debug({nodePath:r.nodePath},"\u65E0expression\u7684directive\uFF0C\u53EF\u80FD\u4E3A\u810F\u6570\u636E")}return}else return me.error({nodePath:r.nodePath},`\u9047\u5230\u4E86\u4E0D\u652F\u6301\u7684 directive: ${r.name}`),te(r);function e(i){return i.name==="if"}function t(i){return i.name==="auth"}}function we(r){return{expr:r,deps:[]}}function Ue(r){if(r.type===void 0&&r.name==="rules")return{kind:"validation-rules",concept:"BindAttribute",name:"rules",rules:r.rules,__raw:r};switch(r.type){case"string":{let e=F.StringLiteral.from({value:r.value});if(r.sync)throw me.error({nodePath:r.nodePath},"string\u4E0D\u53EF\u4E3Async"),new Error("string\u4E0D\u53EF\u4E3Async");if(r.i18nKey&&r.value&&r.frontend?.i18nInfo?.enabled){r.type="dynamic";let t=F.CallFunction.from({calleeNamespace:"$i18n",calleeName:"t",arguments:[F.Argument.from({expression:F.StringLiteral.from({value:r.i18nKey})})]},r.parentNode,r.parentKey);return{__raw:r,concept:r.concept,kind:"expr",expression:we(t),name:r.name,sync:!1}}return{__raw:r,concept:r.concept,kind:"expr",expression:we(e),name:r.name,sync:!1}}case"static":case"dynamic":return r.type==="dynamic"&&(r.destination?r.expression=r.destination:r.externalDestination&&(r.expression=r.externalDestination,r.name="link")),{__raw:r,concept:r.concept,kind:"expr",expression:we(r.expression),name:r.name,sync:r.sync??!1};case"component":return{kind:"render",concept:"BindAttribute",component:r.component,scopeVariable:r.scopeVariable,name:r.name};default:ee(r)}}function le(r){return{logic:r,deps:[]}}function xt(r,e){function t(i){return["pc","h5"].includes(i)}return e&&t(e)?r:Se(`${e??""}-${r}`)}function Ye(r){return{value:"change",checked:"change"}[r]??`${r}-change`}function Ee(r){return{__raw:r,logics:r.logics.map(le),concept:r.concept,params:r.getContextLogicParams().map(ye),handlerName:xt(r.name,r.parentNode.name)}}function We(r){return{__raw:r.__raw,logics:r.logics,deps:[],name:r.handlerName,params:r.params,kind:"standalone"}}var bt="@lcap/pc-react-ui";function mr(r){let e=r.tag;if(e.startsWith("BS"))return{kind:"biz-component",tag:e,libraryName:`@/components/${pe(e.slice(2))}`};if(_n(e)){let t=r?.app?.dependencies?.find(o=>o.frontends.some(s=>s.viewComponents.some(c=>c.name===e)));return e==="Router"?{kind:"library",libraryName:"react-router-dom",tag:"Outlet"}:{kind:"library",libraryName:t?`@extension/${t.name}`:bt,tag:e}}else if(e){if(e.includes("-"))throw me.error({viewElement:(0,$e.pick)(r,["name","concept","tag"]),nodePath:r.nodePath},"\u4E0D\u652F\u6301\u7684tag\uFF0C\u53EF\u80FD\u4E3A\u810F\u6570\u636E"),new Error(`\u5B58\u5728\u810F\u6570\u636E: ${r.nodePath}`);return{kind:"library",libraryName:bt,tag:e}}throw new Error("empty tag name!")}function ur(r){r.attrs.flatMap(t=>{if(t.kind==="expr"&&t.sync){if(t.expression.expr)return[t];me.debug(`${t.__raw.nodePath}\u7684expression\u4E3A\u7A7A\uFF0C\u4F46\u4ECD\u4E3A\u53CC\u5411\u7ED1\u5B9A\u3002\u5DF2\u5FFD\u7565\u3002`)}return[]}).forEach(t=>{me.debug({x:t},"\u6784\u9020\u53CC\u5411\u7ED1\u5B9A\u7684handler");let i=d(),o=i.params.at(0),s=new F.Param({name:o?.name??"event"}),c=F.Logic.from({name:"_syncChange",body:[F.Assignment.from({left:t.expression.expr,right:s},t.__raw.parentNode,t.__raw.parentKey)],params:[s]});i.logics.unshift(le(c)),o||i.params.push(ye(s));function d(){let m=Ye(t.name),b=xt(m,t.__raw.parentNode?.name);me.trace({targetEventName:m,targetHandlerName:b});let g=r.events.find(A=>A.handlerName===b);if(g)return g;let R=Ee(F.BindEvent.from({logics:[],name:m},t.__raw.parentNode,"bindEvents"));return r.events.push(R),R}})}function kt(r){if(r.logics.length>1){let e=[],t=r.params.map(s=>F.Param.from(s)),i=r.logics.map(s=>{let c=`${r.name}_${s.logic.name}`,d=F.Logic.from({...s.logic,params:t,name:c},s.logic.parentNode,s.logic.parentKey);return le(d)}),o=new he({...r,logics:i});return e.push(o),i.forEach(s=>{let c=new he({...r,name:s.logic.name,logics:[s],kind:"standalone"});e.push(c)}),e}else return[r]}function gr(r){if(r.some(s=>s.kind!=="if"))throw me.error("mergeIfDirectives\u63A5\u6536\u5230\u4E86\u4E0D\u662Fif\u6307\u4EE4\u7684bindDirectives"),new Error("mergeIfDirectives\u63A5\u6536\u5230\u4E86\u4E0D\u662Fif\u6307\u4EE4\u7684bindDirectives");let[e,...t]=r;if(!e)return r;let i=e.expression.expr;for(let s of t)i=F.BinaryExpression.from({left:i,operator:"&&",right:s.expression.expr},s.__raw.parentNode,s.__raw.parentKey);return[{kind:"if",concept:"BindDirective",expression:we(i),__raw:e.__raw}]}function St(r,e){let t=e.bindAttrs.map(Ue),o={directives:gr(e.bindDirectives.map(dr).filter(H)),attrs:t,events:e.bindEvents.map(Ee).filter(H),children:e.children.map(c=>St(r,c)),component:mr(e),__raw:e,slot:{scope:e.slotScope||void 0,target:s(e.slotTarget)}};return ur(o),o.events.forEach(c=>{let d=kt(We(c));for(let m of d)r.provideAction(m)}),o;function s(c){if(!(c==="default"||c===""))return c}}function fr(r){let e=[],t=[];return r.variables.forEach(o=>{let s={kind:"local-logic",initialization:{kind:"static",value:we(Yn(o))},identifier:o.name,typeAnnotation:o.__TypeAnnotation};e.push(s)}),r.bindEvents.forEach(o=>{let s=(0,W.isFrontend)(o.parentNode),c=new he({__raw:o,logics:o.logics.map(le),deps:[],name:o.name,params:o.getContextLogicParams().map(ye),kind:s?"frontend-lifecycle":"view-lifecycle"}),d=kt(c);t.push(...d)}),r.logics.forEach(o=>{t.push(new he({__raw:o,deps:[],name:o.name,params:o.params.map(ye),logics:[o].map(le),kind:"standalone"}))}),r.params?.forEach(o=>{let s={kind:"local-logic",initialization:{kind:(0,W.isView)(r)?"url-param":"props",__raw:ye(o),defaultValue:o.defaultValue?.expression?we(o.defaultValue.expression):void 0},identifier:o.name,typeAnnotation:o.__TypeAnnotation};e.push(s)}),{consumedStateNames:[],providedStates:e,actions:t}}function hr(r){return r.provide({identifier:"nasl",kind:"tree",typeAnnotation:null,initialization:{kind:"global-hook",hookName:"useNasl"}}).provide({identifier:"$frontendVariables",kind:"tree",typeAnnotation:null,initialization:{kind:"frontend-variable",hookName:"useFrontendVariables"}}).provide({identifier:"$services",kind:"tree",typeAnnotation:null,initialization:{kind:"global-hook",hookName:"useServices"}}).provide({identifier:"$destination",kind:"tree",typeAnnotation:null,initialization:{kind:"global-hook",hookName:"useDestination"}}).provide({identifier:"$library",kind:"tree",typeAnnotation:null,initialization:{kind:"global-hook",hookName:"useLibrary"}}).provide({identifier:"$link",kind:"tree",typeAnnotation:null,initialization:{kind:"global-hook",hookName:"useLink"}}).provide({identifier:"userInfo",kind:"tree",typeAnnotation:null,initialization:{kind:"global-hook",hookName:"useUserInfo"}}).provide({identifier:"$i18n",kind:"tree",typeAnnotation:null,initialization:{kind:"global-hook",hookName:"useI18n"}}).provide({identifier:"i18nInfo",kind:"tree",typeAnnotation:null,initialization:{kind:"global-hook",hookName:"useI18nInfo"}}).provide({identifier:"genInitFromSchema",kind:"tree",typeAnnotation:null,initialization:{kind:"global-hook",hookName:"useGenInitFromSchema"}})}function jn(r,e){if(e&&Wn(e)){let t=qn(e);if(!t)return;let i=r.findComponentRefByComponentName(t);if(i)return i;let s={kind:"standalone",identifier:fn(t),initialization:{kind:"component-ref",componentName:t},typeAnnotation:null};return r.provide(s),s}}function yr(r){let e=new He([],[],[],null);return hr(e)}var _e="apiClient";function wr(r,e){return e.provide({kind:"tree",identifier:_e,initialization:{kind:"api-client"},typeAnnotation:null}),r.map(le)}function br(r){return r.dependencies.map(t=>{if(!(0,W.isConnector)(t)&&t.frontends?.length)return t}).filter(H)}function Dn(r,e){return r.map(t=>{let{providedStates:i,actions:o}=fr(t),s=new He(i,[],o,e);m(t,s);let c=t.elements.map(g=>St(s,g));b(c);let d={stateContext:s,identifier:t.name,elements:c};if((0,W.isView)(t)){let g=Dn(t.children,e);return{...d,kind:"view",__raw:t,childComponents:g}}else return{...d,kind:"biz-component",__raw:t};function m(g,R){let A=[];(0,W.isView)(g)&&(A=g.children,g.children=[]),g.traverseStrictChildren(v=>{if((0,$e.isObject)(v)&&"playground"in v&&(v.playground=[]),(0,W.isMemberExpression)(v)){if((0,W.isIdentifier)(v.object)&&(0,W.isIdentifier)(v.property)&&v.object.name==="elements"&&v.property.name==="$ce"){let n=v.getAncestor("ViewElement");if(n){let S=`elements.${n.name}`,w=jn(R,S);w&&(v.emit=()=>{},v.parentNode&&(v.parentNode.emit=()=>{}),v.replaceNode({name:w.identifier,concept:"Identifier"}))}}else if((0,W.isIdentifier)(v.object)&&v.object.namespace==="elements.$ce.property"){let n=v.getAncestor("ViewElement");if(n){let S=`elements.${n.name}`,w=jn(R,S);w&&(v.object=new F.Identifier({name:w.identifier}))}}}else if((0,W.isCallLogic)(v)){let n=jn(R,v.calleeNamespace);n&&(v.calleeNamespace=n.identifier)}}),(0,W.isView)(g)&&(g.children=A)}function b(g){g.forEach(R=>{let A=s.findComponentRefByComponentName(R.__raw.name);if(A){let v=Ue(new F.BindAttribute({name:"ref",type:"dynamic",expression:new F.Identifier({name:A.identifier})}));R.attrs.push(v)}b(R.children)})}})}function vr(r,e,t){let i=lr(r,e);return Dn(i,t)}function xr(r,e,t){let i=r.frontendTypes.find(c=>c.kind===e.type)?.businessComponents??[],o=F.BusinessComponent.from({bindEvents:[...e.bindEvents,new F.BindEvent({name:"rendered",logics:[new F.Logic({body:[F.CallLogic.from({calleeNamespace:"window",calleeName:"rendered"})]})]})],name:"FrontendEventWrapper",params:[],elements:[new F.ViewElement({tag:"Router",children:[]})]});i.push(o);for(let c of i)c.parentNode=e,c.traverseStrictChildren(d=>{(0,W.isViewElement)(d)&&d.tag==="IdeSlot"&&(d.tag="template",d.bindAttrs.push(F.BindAttribute.from({name:"children",type:"dynamic",expression:F.MemberExpression.from({object:{concept:"Identifier",name:"props",folded:!1},property:{concept:"Identifier",name:Se(d.name),folded:!1}})},d,"bindAttrs")))});return Dn(i,t)}var me=L("IR builder"),Re=class{constructor(e,t){this.preProcessors=e;this.postProcessors=t}selfBuildIR(e,t,i){{let R=function(){let n={...Pn.functions}.makeBasePlatformConfig(e,t,i),S=gn(e,t,i),w=t.bindEvents.map(Ee).filter(H);return{config:i,basePlatformConfig:n,events:w,metaData:S,globalVariables:t.variables,themeCSS:t.genThemeCSS(),document:{icon:t.documentIcon}}},A=function(){let v=br(e).map(n=>({kind:"extension",name:n.name,version:n.version,hasCss:!0}));return me.debug({extensionPackages:v}),[...v,{kind:"standard",name:"@lcap/pc-react-ui",version:"1.1.0"}]};var o=R,s=A;i.debug&&vt.genBreakpoints(e);let c=yr(t.variables),d=wr(e.logics,c),m=vr(e,t,c),b=xr(e,t,c);return m.flatMap(v=>v.childComponents),{baseCtx:c,configs:R(),apis:d,views:m,bizComponents:b,packages:A()}}}buildIR(e,t,i){this.preProcessors?.forEach(s=>{let c=s.preProcess(e,t,i);e=c.app,t=c.frontend,i=c.config});let o=this.selfBuildIR(e,t,i);return this.postProcessors?.forEach(s=>{o=s.postProcess(o,i)}),o}};Re=G([(0,be.injectable)(),z(0,(0,be.multiInject)(D.IRPreProcesser)),z(0,(0,be.optional)()),z(1,(0,be.multiInject)(D.IRPostProcesser)),z(1,(0,be.optional)())],Re);var At=require("inversify"),It=require("memfs");var Ce=class{constructor(){this.vol=new It.Volume}read(e){if(this.vol.existsSync(e))return this.vol.readFileSync(e).toString()}write(e,t){this.vol.fromJSON({[e]:t})}remove(e){this.vol.unlinkSync(e)}toJSON(){return this.vol.toJSON()}};Ce=G([(0,At.injectable)()],Ce);var Pt=require("inversify");var Rt=`
|
|
5073
|
+
}`])}}});var Pn=K({name:"MetadataPlugin",functions:{makeBasePlatformConfig(r,e,t){let i=t?.lowcodeDomain,o=t?.envNuimsDomain?.[t?.env]||t?.nuimsDomain,a=t?.envLcpDomain?.[t?.env]?.lcpDomain||t?.lowcodeDomain;return{appConfig:{id:r.id,project:r.name,domainName:r.name,nuimsDomain:o,lowcodeDomain:i,envNuimsDomain:t.envNuimsDomain,tenantType:t.tenantType,tenantLevel:t.tenantLevel,extendedConfig:t.extendedConfig,envConfig:{lowcodeDomain:a},tenant:t.tenant,documentTitle:e.documentTitle,basePath:e.prefixPath,frontendName:e.name,sysPrefixPath:r.sysPrefixPath,appTimeZone:r?.appTimeZone,i18nInfo:Ze.functions.genI18nInfo(e),rootViewData:void 0},dnsAddr:r.dnsAddr,tenant:t.tenant,env:t.env,hasUserCenter:r.hasUserCenter,hasAuth:r.hasAuth,basePath:e.prefixPath,sysPrefixPath:r.sysPrefixPath,frontendName:e.name,isPreviewFe:!!t.isPreviewFe}}}});var He=class r{constructor(e,t,i,o){this.providedStates=e;this.consumedStateNames=t;this.actions=i;this.parentCtx=o}recursivelyExtractTreeStates(){return[...this.providedStates.filter(e=>e.kind==="tree"),...this.parentCtx?.recursivelyExtractTreeStates()??[]]}resolveExprToString(e,t,i){return t.printSyntaxNode(e,{resolve({kind:o,value:a}){switch(o){case"calleeNamespace":return i.resolveCalleeNamespace(a);case"identifier":return i.resolveIdentifier(a)}}})}static fromParent(e){return new r([],[],[],e)}provide(e){return this.providedStates.push(e),this}provideAction(e){return this.actions.push(e),this}findStateByName(e){return this.providedStates.find(t=>t.identifier===e)??this.parentCtx?.findStateByName(e)}findActionByName(e){return this.actions.find(t=>t.name===e)??this.parentCtx?.findActionByName(e)}findComponentRefByComponentName(e){return this.findStateByName(fn(e))??this.parentCtx?.findComponentRefByComponentName(e)}};function lr(r,e){let t=[],i=[];return r.dependencies&&t.push(...r.dependencies),r.interfaceDependencies&&t.push(...r.interfaceDependencies),e.views&&i.push(...e.views),t.forEach(o=>{o.views&&i.push(...o.views)}),i}function ye(r){return{name:r.name,typeAnnotation:r.__TypeAnnotation,defaultValue:r.defaultValue}}function dr(r){if(e(r)||t(r)){if(t(r)){let i=F.CallFunction.from({calleeNamespace:"nasl.auth",calleeName:"has",arguments:[F.Argument.from({expression:new F.StringLiteral({value:r.viewElement.authPath})})]},r.parentNode,r.parentKey);return{__raw:r,concept:r.concept,expression:we(i),kind:"if"}}else{let i=r.expression;if(i)return{__raw:r,concept:r.concept,expression:we(i),kind:"if"};me.debug({nodePath:r.nodePath},"\u65E0expression\u7684directive\uFF0C\u53EF\u80FD\u4E3A\u810F\u6570\u636E")}return}else return me.error({nodePath:r.nodePath},`\u9047\u5230\u4E86\u4E0D\u652F\u6301\u7684 directive: ${r.name}`),te(r);function e(i){return i.name==="if"}function t(i){return i.name==="auth"}}function we(r){return{expr:r,deps:[]}}function Ue(r){if(r.type===void 0&&r.name==="rules")return{kind:"validation-rules",concept:"BindAttribute",name:"rules",rules:r.rules,__raw:r};switch(r.type){case"string":{let e=F.StringLiteral.from({value:r.value});if(r.sync)throw me.error({nodePath:r.nodePath},"string\u4E0D\u53EF\u4E3Async"),new Error("string\u4E0D\u53EF\u4E3Async");if(r.i18nKey&&r.value&&r.frontend?.i18nInfo?.enabled){r.type="dynamic";let t=F.CallFunction.from({calleeNamespace:"$i18n",calleeName:"t",arguments:[F.Argument.from({expression:F.StringLiteral.from({value:r.i18nKey})})]},r.parentNode,r.parentKey);return{__raw:r,concept:r.concept,kind:"expr",expression:we(t),name:r.name,sync:!1}}return{__raw:r,concept:r.concept,kind:"expr",expression:we(e),name:r.name,sync:!1}}case"static":case"dynamic":return r.type==="dynamic"&&(r.destination?r.expression=r.destination:r.externalDestination&&(r.expression=r.externalDestination,r.name="link")),{__raw:r,concept:r.concept,kind:"expr",expression:we(r.expression),name:r.name,sync:r.sync??!1};case"component":return{kind:"render",concept:"BindAttribute",component:r.component,scopeVariable:r.scopeVariable,name:r.name};default:ee(r)}}function le(r){return{logic:r,deps:[]}}function xt(r,e){function t(i){return["pc","h5"].includes(i)}return e&&t(e)?r:Se(`${e??""}-${r}`)}function Ye(r){return{value:"change",checked:"change"}[r]??`${r}-change`}function Ee(r){return{__raw:r,logics:r.logics.map(le),concept:r.concept,params:r.getContextLogicParams().map(ye),handlerName:xt(r.name,r.parentNode.name)}}function We(r){return{__raw:r.__raw,logics:r.logics,deps:[],name:r.handlerName,params:r.params,kind:"standalone"}}var bt="@lcap/pc-react-ui";function mr(r){let e=r.tag;if(e.startsWith("BS"))return{kind:"biz-component",tag:e,libraryName:`@/components/${pe(e.slice(2))}`};if(_n(e)){let t=r?.app?.dependencies?.find(o=>o.frontends.some(a=>a.viewComponents.some(c=>c.name===e)));return e==="Router"?{kind:"library",libraryName:"react-router-dom",tag:"Outlet"}:{kind:"library",libraryName:t?`@extension/${t.name}`:bt,tag:e}}else if(e){if(e.includes("-"))throw me.error({viewElement:(0,$e.pick)(r,["name","concept","tag"]),nodePath:r.nodePath},"\u4E0D\u652F\u6301\u7684tag\uFF0C\u53EF\u80FD\u4E3A\u810F\u6570\u636E"),new Error(`\u5B58\u5728\u810F\u6570\u636E: ${r.nodePath}`);return{kind:"library",libraryName:bt,tag:e}}throw new Error("empty tag name!")}function ur(r){r.attrs.flatMap(t=>{if(t.kind==="expr"&&t.sync){if(t.expression.expr)return[t];me.debug(`${t.__raw.nodePath}\u7684expression\u4E3A\u7A7A\uFF0C\u4F46\u4ECD\u4E3A\u53CC\u5411\u7ED1\u5B9A\u3002\u5DF2\u5FFD\u7565\u3002`)}return[]}).forEach(t=>{me.debug({x:t},"\u6784\u9020\u53CC\u5411\u7ED1\u5B9A\u7684handler");let i=d(),o=i.params.at(0),a=new F.Param({name:o?.name??"event"}),c=F.Logic.from({name:"_syncChange",body:[F.Assignment.from({left:t.expression.expr,right:a},t.__raw.parentNode,t.__raw.parentKey)],params:[a]});i.logics.unshift(le(c)),o||i.params.push(ye(a));function d(){let m=Ye(t.name),b=xt(m,t.__raw.parentNode?.name);me.trace({targetEventName:m,targetHandlerName:b});let u=r.events.find(I=>I.handlerName===b);if(u)return u;let R=Ee(F.BindEvent.from({logics:[],name:m},t.__raw.parentNode,"bindEvents"));return r.events.push(R),R}})}function kt(r){if(r.logics.length>1){let e=[],t=r.params.map(a=>F.Param.from(a)),i=r.logics.map(a=>{let c=`${r.name}_${a.logic.name}`,d=F.Logic.from({...a.logic,params:t,name:c},a.logic.parentNode,a.logic.parentKey);return le(d)}),o=new he({...r,logics:i});return e.push(o),i.forEach(a=>{let c=new he({...r,name:a.logic.name,logics:[a],kind:"standalone"});e.push(c)}),e}else return[r]}function gr(r){if(r.some(a=>a.kind!=="if"))throw me.error("mergeIfDirectives\u63A5\u6536\u5230\u4E86\u4E0D\u662Fif\u6307\u4EE4\u7684bindDirectives"),new Error("mergeIfDirectives\u63A5\u6536\u5230\u4E86\u4E0D\u662Fif\u6307\u4EE4\u7684bindDirectives");let[e,...t]=r;if(!e)return r;let i=e.expression.expr;for(let a of t)i=F.BinaryExpression.from({left:i,operator:"&&",right:a.expression.expr},a.__raw.parentNode,a.__raw.parentKey);return[{kind:"if",concept:"BindDirective",expression:we(i),__raw:e.__raw}]}function St(r,e){let t=e.bindAttrs.map(Ue),o={directives:gr(e.bindDirectives.map(dr).filter(Q)),attrs:t,events:e.bindEvents.map(Ee).filter(Q),children:e.children.map(c=>St(r,c)),component:mr(e),__raw:e,slot:{scope:e.slotScope||void 0,target:a(e.slotTarget)}};return ur(o),o.events.forEach(c=>{let d=kt(We(c));for(let m of d)r.provideAction(m)}),o;function a(c){if(!(c==="default"||c===""))return c}}function fr(r){let e=[],t=[];return r.variables.forEach(o=>{let a={kind:"local-logic",initialization:{kind:"static",value:we(Yn(o))},identifier:o.name,typeAnnotation:o.__TypeAnnotation};e.push(a)}),r.bindEvents.forEach(o=>{let a=(0,q.isFrontend)(o.parentNode),c=new he({__raw:o,logics:o.logics.map(le),deps:[],name:o.name,params:o.getContextLogicParams().map(ye),kind:a?"frontend-lifecycle":"view-lifecycle"}),d=kt(c);t.push(...d)}),r.logics.forEach(o=>{t.push(new he({__raw:o,deps:[],name:o.name,params:o.params.map(ye),logics:[o].map(le),kind:"standalone"}))}),r.params?.forEach(o=>{let a={kind:"local-logic",initialization:{kind:(0,q.isView)(r)?"url-param":"props",__raw:ye(o),defaultValue:o.defaultValue?.expression?we(o.defaultValue.expression):void 0},identifier:o.name,typeAnnotation:o.__TypeAnnotation};e.push(a)}),{consumedStateNames:[],providedStates:e,actions:t}}function hr(r){return r.provide({identifier:"nasl",kind:"tree",typeAnnotation:null,initialization:{kind:"global-hook",hookName:"useNasl"}}).provide({identifier:"$frontendVariables",kind:"tree",typeAnnotation:null,initialization:{kind:"frontend-variable",hookName:"useFrontendVariables"}}).provide({identifier:"$services",kind:"tree",typeAnnotation:null,initialization:{kind:"global-hook",hookName:"useServices"}}).provide({identifier:"$destination",kind:"tree",typeAnnotation:null,initialization:{kind:"global-hook",hookName:"useDestination"}}).provide({identifier:"$library",kind:"tree",typeAnnotation:null,initialization:{kind:"global-hook",hookName:"useLibrary"}}).provide({identifier:"$link",kind:"tree",typeAnnotation:null,initialization:{kind:"global-hook",hookName:"useLink"}}).provide({identifier:"userInfo",kind:"tree",typeAnnotation:null,initialization:{kind:"global-hook",hookName:"useUserInfo"}}).provide({identifier:"$i18n",kind:"tree",typeAnnotation:null,initialization:{kind:"global-hook",hookName:"useI18n"}}).provide({identifier:"i18nInfo",kind:"tree",typeAnnotation:null,initialization:{kind:"global-hook",hookName:"useI18nInfo"}}).provide({identifier:"genInitFromSchema",kind:"tree",typeAnnotation:null,initialization:{kind:"global-hook",hookName:"useGenInitFromSchema"}})}function jn(r,e){if(e&&Wn(e)){let t=qn(e);if(!t)return;let i=r.findComponentRefByComponentName(t);if(i)return i;let a={kind:"standalone",identifier:fn(t),initialization:{kind:"component-ref",componentName:t},typeAnnotation:null};return r.provide(a),a}}function yr(r){let e=new He([],[],[],null);return hr(e)}var _e="apiClient";function wr(r,e){return e.provide({kind:"tree",identifier:_e,initialization:{kind:"api-client"},typeAnnotation:null}),r.map(le)}function br(r){return r.dependencies.map(t=>{if(!(0,q.isConnector)(t)&&t.frontends?.length)return t}).filter(Q)}function Dn(r,e){return r.map(t=>{let{providedStates:i,actions:o}=fr(t),a=new He(i,[],o,e);m(t,a);let c=t.elements.map(u=>St(a,u));b(c);let d={stateContext:a,identifier:t.name,elements:c};if((0,q.isView)(t)){let u=Dn(t.children,e);return{...d,kind:"view",__raw:t,childComponents:u}}else return{...d,kind:"biz-component",__raw:t};function m(u,R){let I=[];(0,q.isView)(u)&&(I=u.children,u.children=[]),u.traverseStrictChildren(v=>{if((0,$e.isObject)(v)&&"playground"in v&&(v.playground=[]),(0,q.isMemberExpression)(v)){if((0,q.isIdentifier)(v.object)&&(0,q.isIdentifier)(v.property)&&v.object.name==="elements"&&v.property.name==="$ce"){let n=v.getAncestor("ViewElement");if(n){let S=`elements.${n.name}`,w=jn(R,S);w&&(v.emit=()=>{},v.parentNode&&(v.parentNode.emit=()=>{}),v.replaceNode({name:w.identifier,concept:"Identifier"}))}}else if((0,q.isIdentifier)(v.object)&&v.object.namespace==="elements.$ce.property"){let n=v.getAncestor("ViewElement");if(n){let S=`elements.${n.name}`,w=jn(R,S);w&&(v.object=new F.Identifier({name:w.identifier}))}}}else if((0,q.isCallLogic)(v)){let n=jn(R,v.calleeNamespace);n&&(v.calleeNamespace=n.identifier)}}),(0,q.isView)(u)&&(u.children=I)}function b(u){u.forEach(R=>{let I=a.findComponentRefByComponentName(R.__raw.name);if(I){let v=Ue(new F.BindAttribute({name:"ref",type:"dynamic",expression:new F.Identifier({name:I.identifier})}));R.attrs.push(v)}b(R.children)})}})}function vr(r,e,t){let i=lr(r,e);return Dn(i,t)}function xr(r,e,t){let i=r.frontendTypes.find(c=>c.kind===e.type)?.businessComponents??[],o=F.BusinessComponent.from({bindEvents:[...e.bindEvents,new F.BindEvent({name:"rendered",logics:[new F.Logic({body:[F.CallLogic.from({calleeNamespace:"window",calleeName:"rendered"})]})]})],name:"FrontendEventWrapper",params:[],elements:[new F.ViewElement({tag:"Router",children:[]})]});i.push(o);for(let c of i)c.parentNode=e,c.traverseStrictChildren(d=>{(0,q.isViewElement)(d)&&d.tag==="IdeSlot"&&(d.tag="template",d.bindAttrs.push(F.BindAttribute.from({name:"children",type:"dynamic",expression:F.MemberExpression.from({object:{concept:"Identifier",name:"props",folded:!1},property:{concept:"Identifier",name:Se(d.name),folded:!1}})},d,"bindAttrs")))});return Dn(i,t)}var me=L("IR builder"),Re=class{constructor(e,t){this.preProcessors=e;this.postProcessors=t}selfBuildIR(e,t,i){{let R=function(){let n={...Pn.functions}.makeBasePlatformConfig(e,t,i),S=gn(e,t,i),w=t.bindEvents.map(Ee).filter(Q);return{config:i,basePlatformConfig:n,events:w,metaData:S,globalVariables:t.variables,themeCSS:t.genThemeCSS(),document:{icon:t.documentIcon}}},I=function(){let v=br(e).map(n=>({kind:"extension",name:n.name,version:n.version,hasCss:!0}));return me.debug({extensionPackages:v}),[...v,{kind:"standard",name:"@lcap/pc-react-ui",version:"1.1.0"}]};var o=R,a=I;i.debug&&vt.genBreakpoints(e);let c=yr(t.variables),d=wr(e.logics,c),m=vr(e,t,c),b=xr(e,t,c);return m.flatMap(v=>v.childComponents),{baseCtx:c,configs:R(),apis:d,views:m,bizComponents:b,packages:I()}}}buildIR(e,t,i){this.preProcessors?.forEach(a=>{let c=a.preProcess(e,t,i);e=c.app,t=c.frontend,i=c.config});let o=this.selfBuildIR(e,t,i);return this.postProcessors?.forEach(a=>{o=a.postProcess(o,i)}),o}};Re=G([(0,be.injectable)(),z(0,(0,be.multiInject)(D.IRPreProcesser)),z(0,(0,be.optional)()),z(1,(0,be.multiInject)(D.IRPostProcesser)),z(1,(0,be.optional)())],Re);var At=require("inversify"),It=require("memfs");var Ce=class{constructor(){this.vol=new It.Volume}read(e){if(this.vol.existsSync(e))return this.vol.readFileSync(e).toString()}write(e,t){this.vol.fromJSON({[e]:t})}remove(e){this.vol.unlinkSync(e)}toJSON(){return this.vol.toJSON()}};Ce=G([(0,At.injectable)()],Ce);var Pt=require("inversify");var Rt=`
|
|
5074
5074
|
if(window.ICESTARK && window.ICESTARK.root) {
|
|
5075
5075
|
Object.assign(window.ICESTARK, {
|
|
5076
5076
|
appEnter({ container, customProps }) {
|
|
@@ -5168,13 +5168,13 @@ ${m}`:m}merge(e){return e?(this.imports.push(...e.imports),this.body.push(...e.b
|
|
|
5168
5168
|
} else {
|
|
5169
5169
|
loadAssets();
|
|
5170
5170
|
}
|
|
5171
|
-
`;var kr={qiankun:Ct,icestark:Rt};function Nt(r){if(r.type==="h5")return"";let{framework:e,name:t,routePrefix:i,proxyPrefix:o,loginUrl:
|
|
5172
|
-
${
|
|
5171
|
+
`;var kr={qiankun:Ct,icestark:Rt};function Nt(r){if(r.type==="h5")return"";let{framework:e,name:t,routePrefix:i,proxyPrefix:o,loginUrl:a,noAuthUrl:c,notFoundUrl:d}=r.app.integration?.microApp||{};e||="icestark",a===`${i}${r.basePath}/login`&&(a=void 0),c===`${i}${r.basePath}/noAuth`&&(c=void 0),d===`${i}${r.basePath}/notFound`&&(d=void 0);let m=JSON.stringify({name:t||void 0,routePrefix:i||void 0,proxyPrefix:o||void 0,loginUrl:a||void 0,noAuthUrl:c||void 0,notFoundUrl:d||void 0});return kr[e].replace(/\{properties\}/g,m)}var Ne=class{produceScript(e){return Nt(e)}};Ne=G([(0,Pt.injectable)()],Ne);var nn=require("inversify"),Fe=require("path");var Sr=r=>r.import?r.lazy?`const ${r.import} = React.lazy(() => import('${r.from}'));`:`import ${r.import} from '${r.from}';`:`import '${r.from}';`,jt=L("ProjectOrganizerPlugin"),Ar=[".mjs",".js",".mts",".ts",".jsx",".tsx",".json"];function Ir(r){return Dt(r)||r.from.startsWith("/")}function Dt(r){return r.from.startsWith(".")}async function Rr(r){let e=new WeakMap,t={},i=[];return Object.entries(r.project).forEach(([c,d])=>{if(d){let m=Kn(d);for(let b of m){let{dir:u}=a(c,b),R=new en(b,u);i.push(R),t[R.originalAbsolutePath]=R;let I=b.getImports().map(v=>{if(Ir(v)){let n=Dt(v)?(0,Fe.join)(u,v.from):v.from;return{ir:v,kind:"relative",getRelativePathAfterMoving:()=>{let w=u,s=p()??n;return jt.debug({currentDir:w,targetPath:s}),`./${(0,Fe.relative)(w,s)}`;function p(){if(!ot(v.from))for(let g of Ar){let k=t[n+g]?.currentAbsolutePath;if(k)return k}}}}}else return{ir:v,kind:"absolute"}});e.set(R,I)}}}),{mapping:e,placedFiles:i};function o(c){let d={name:"src"};return c==="views"?[d,{name:ze}]:c==="bizComponents"?[d,{name:Xe}]:[d]}function a(c,d){let m=o(c);d.folder=[...m,...d.folder??[]];let b=d.getFolderPath()??"";return{path:(0,Fe.join)(b,d.fileNameWithExt),dir:b}}}var en=class r{constructor(e,t){this.file=e;this.folder=t;this.originalFolder=t,this.currentAbsolutePath=this.originalAbsolutePath}get originalAbsolutePath(){return(0,Fe.join)(this.originalFolder,this.file.fileNameWithExt)}getFolder(){return this.folder.endsWith("/")?this.folder:`${this.folder}/`}moveFileTo(e){return this.currentAbsolutePath=new r(this.file,e).originalAbsolutePath,this.folder=e,this}};async function Cr(r,e){return Promise.all(e.map(async i=>{let o=c=>{let d=m(c);return Sr(d);function m(b){let u=r.get(i)?.find(R=>R.ir===b);if(u){let R=t(u);return{...b,from:R}}return b}};return{content:await i.file.serialize(o),path:i.currentAbsolutePath}}));function t(i){return i.kind==="relative"?i.getRelativePathAfterMoving():i.ir.from}}var Pe=class{constructor(e){this.fileSystemProvider=e}async organize(e){let{mapping:t,placedFiles:i}=await Rr(e);return await this.moveFilesAsYouWant(i),await Cr(t,i)}async moveFilesAsYouWant(e){let t=jt.child({},{msgPrefix:"[\u79FB\u52A8\u6587\u4EF6] "});for(let i of e){let o=`/${ze}/`,a=`/${Xe}/`;if(i.originalAbsolutePath.includes(o)){let c=i.getFolder().replace(o,"/pages/");i.moveFileTo(c),t.debug(`${i.originalAbsolutePath} -> ${i.currentAbsolutePath}`)}else if(i.originalAbsolutePath.includes(a)){let c=i.getFolder().replace(a,"/components/");i.moveFileTo(c),t.debug(`${i.originalAbsolutePath} -> ${i.currentAbsolutePath}`)}}}};Pe=G([(0,nn.injectable)(),Qn,z(0,(0,nn.inject)(D.FileSystemProvider))],Pe);var Et=require("inversify");var ve=class{constructor(){this.compilerConfig={backendUrl:"",publicPath:"",aliasMapStr:""}}setCompilerConfig(e){this.compilerConfig={backendUrl:e.backendUrl??this.compilerConfig.backendUrl,publicPath:e.publicPath??this.compilerConfig.publicPath,aliasMapStr:e.aliasMapStr??this.compilerConfig.aliasMapStr}}getCompilerConfig(){return this.compilerConfig}static install(e){return e.bind(D.FrontendBundlerConfig).to(ve).inSingletonScope(),e}};ve=G([(0,Et.injectable)()],ve);var Ft=require("inversify");var xe=class{constructor(){this.performanceOptions={lazy:!0,chunks:"all"}}setOptions(e){this.performanceOptions={lazy:e.lazy??this.performanceOptions.lazy,chunks:e.chunks??this.performanceOptions.chunks}}static install(e){return e.bind(D.FrontendPerformance).to(xe).inSingletonScope(),e}};xe=G([(0,Ft.injectable)()],xe);var oa=require("@abraham/reflection"),tn=require("inversify");var je=class{constructor(e){this.fileSystemProvider=e}afterAllFilesGenerated(){}};je=G([(0,tn.injectable)(),z(0,(0,tn.inject)(D.FileSystemProvider))],je);var on=require("inversify"),rn=require("lodash");var Nr=L("NpmPackageJSONManagerPlugin"),ie=class extends je{constructor(t){super(t);this.fileSystemProvider=t;this.packageJSONPath="/package.json";this.isAfterAllFilesGenerated=!1;this.willMergeObject={}}readPkg(){try{let t=this.fileSystemProvider.read(this.packageJSONPath);if(t)return JSON.parse(t)}catch(t){Nr.error(t,"\u8BFB\u53D6 package.json \u6587\u4EF6\u5931\u8D25")}}writePkg(t){this.fileSystemProvider.write(this.packageJSONPath,JSON.stringify(t,null,2))}afterAllFilesGenerated(){if(this.isAfterAllFilesGenerated=!0,Object.keys(this.willMergeObject).length>0){let t=this.readPkg()??{};(0,rn.merge)(t,this.willMergeObject),this.writePkg(t)}}patch(t){if(!this.isAfterAllFilesGenerated){(0,rn.merge)(this.willMergeObject,t);return}let i=this.readPkg()??{};(0,rn.merge)(i,t),this.writePkg(i)}static install(t){return t.bind(ie).toSelf().inSingletonScope(),t.bind(D.NpmPackageJSONManager).toService(ie),t.bind(D.CodeGenerationLifecycleHooks).toService(ie),t}};ie=G([(0,on.injectable)(),z(0,(0,on.inject)(D.FileSystemProvider))],ie);var sn=require("inversify");var Le=class{constructor(e){this.javaScriptCodegen=e}printSyntaxNode(e,t){return this.javaScriptCodegen.printSyntaxNode(e,t)}};Le=G([(0,sn.injectable)(),z(0,(0,sn.inject)(de))],Le);var Tt=require("@lcap/nasl-concepts/asserts"),pn=require("inversify");var ke=require("@lcap/nasl-concepts");var an=require("@lcap/nasl-concepts");function Lt(r){return new an.Argument({expression:new an.Identifier({name:r.name})})}var cn=require("inversify");var Pr=L("ReactStateManagerVanilla"),En=class{static componentRefNameToHook(e){return{kind:"free",code:`const ${e}= useRef(null);`,import:{from:"react",import:"{ useRef }"}}}},ue=class{constructor(e){this.reactJavaScriptCodegen=e}makeTreeStateHooks(e){return e.recursivelyExtractTreeStates().map(i=>{switch(i.initialization.kind){case"global-hook":{let o=i.initialization.hookName;return{kind:"free",code:`const ${i.identifier} = ${o}();`,import:{from:"/src/Hooks",import:`{${o}}`}}}case"api-client":return{kind:"free",import:{from:"/src/apis",import:"{apiClient, genInitFromSchema}"},code:""};case"frontend-variable":{let o=i.initialization.hookName;return{kind:"free",code:`const ${i.identifier} = ${o}();`,import:{from:"/src/global-variables",import:`{${o}}`}}}default:ee(i.initialization)}})}makeLocalLogicHooks(e){let t=e.providedStates.flatMap(o=>{let a=o.identifier;return[{kind:"useState",declarations:[`${a}`,`use${a}`],initial:void 0}]}),i=e.actions.filter(o=>o.kind==="standalone").flatMap(o=>[{kind:"useCallback",declaration:o.name,deps:[],body:this.actionToBody(e,o)}]);return[...t,...i]}actionToBody(e,t,i){function o(){let c=t.params.map(d=>ke.Param.from(d));if(t.logics.length===0)return new ke.Logic;if(t.logics.length===1){let d=t.logics[0].logic;return ke.Logic.from({...d,params:c})}else return ke.Logic.from({params:c,body:t.logics.map(m=>{let b=`${m.logic.name}`;return ke.CallLogic.from({calleeName:b,arguments:t.params.map(Lt)})})})}let a=o();return`${e.resolveExprToString(a,this.reactJavaScriptCodegen,i?.()?.(e)??this.withCtx(e))}`}makeLocalIndividualHooks(e,t){return[...e.providedStates.filter(i=>i.kind==="standalone").flatMap(i=>{if(i.initialization&&i.kind==="standalone")switch(i.initialization.kind){case"component-ref":return[En.componentRefNameToHook(i.identifier)];default:ee(i.initialization.kind)}return te(i)}),...e.actions.filter(i=>i.kind==="frontend-lifecycle").flatMap(i=>{let o=this.actionToBody(e,i,t),a=`window.${i.name} = ${o};`;return[{kind:"useEffect",deps:[],body:`()=>{
|
|
5172
|
+
${a}
|
|
5173
5173
|
return ()=>{};
|
|
5174
5174
|
}`}]}),...e.actions.filter(i=>i.kind==="view-lifecycle").flatMap(i=>[{kind:"useEffect",deps:[],body:`()=>{
|
|
5175
5175
|
(${this.actionToBody(e,i,t)})();
|
|
5176
5176
|
return ()=>{};
|
|
5177
|
-
}`}])]}initializationToExpr(e,t){if(t)switch(t.kind){case"static":return e.resolveExprToString(t.value.expr,this.reactJavaScriptCodegen,this.withCtx(e));case"url-param":return t.defaultValue?.expr?e.resolveExprToString(t.defaultValue?.expr,this.reactJavaScriptCodegen,this.withCtx(e)):void 0;case"props":return t.defaultValue?.expr?e.resolveExprToString(t.defaultValue?.expr,this.reactJavaScriptCodegen,this.withCtx(e)):`props.${t.__raw.name}`;default:return ee(t)}}produceHooks(e){let t=this.makeTreeStateHooks(e),i=this.makeLocalIndividualHooks(e),o=this.makeLocalLogicHooks(e);return[...t,...i,...o]}withCtx(e){return{resolveIdentifier:t=>this.__resolveIdentifier(e,t),resolveCalleeNamespace:t=>this.__resolveName(e,t)}}__resolveIdentifier(e,t){return this.__resolveName(e,t.name)}__resolveName(e,t){let i=o(t)??
|
|
5177
|
+
}`}])]}initializationToExpr(e,t){if(t)switch(t.kind){case"static":return e.resolveExprToString(t.value.expr,this.reactJavaScriptCodegen,this.withCtx(e));case"url-param":return t.defaultValue?.expr?e.resolveExprToString(t.defaultValue?.expr,this.reactJavaScriptCodegen,this.withCtx(e)):void 0;case"props":return t.defaultValue?.expr?e.resolveExprToString(t.defaultValue?.expr,this.reactJavaScriptCodegen,this.withCtx(e)):`props.${t.__raw.name}`;default:return ee(t)}}produceHooks(e){let t=this.makeTreeStateHooks(e),i=this.makeLocalIndividualHooks(e),o=this.makeLocalLogicHooks(e);return[...t,...i,...o]}withCtx(e){return{resolveIdentifier:t=>this.__resolveIdentifier(e,t),resolveCalleeNamespace:t=>this.__resolveName(e,t)}}__resolveIdentifier(e,t){return this.__resolveName(e,t.name)}__resolveName(e,t){let i=o(t)??a(t);return i||Pr.debug(`cannot find symbol "${t}" in the state context`),i;function o(c){let d=e.findActionByName(c);if(d)return`${d.name}`}function a(c){let d=e.findStateByName(c);if(d)switch(d.kind){case"standalone":case"local-logic":case"tree":return c;default:ee(d)}}}__hooksDefinitions(){return new U("VanillaHookUtils",[],[],[`
|
|
5178
5178
|
const useStateRef = <T extends unknown>(initialState: T) => {
|
|
5179
5179
|
const [state, setState] = useState(initialState);
|
|
5180
5180
|
const ref = useRef(initialState);
|
|
@@ -5186,15 +5186,15 @@ useEffect(() => {
|
|
|
5186
5186
|
// Use "as const" below so the returned array is a proper tuple
|
|
5187
5187
|
return [state, setState, ref] as const;
|
|
5188
5188
|
};
|
|
5189
|
-
`])}};ue=G([(0,cn.injectable)(),z(0,(0,cn.inject)(D.ReactJavaScriptCodePrinter))],ue);var jr=L("MobX Plugin"),oe=class{constructor(e){this.reactStateManagerVanillaPlugin=e}makeLocalLogicBundleHook(e){let t=d=>`${d.name}:${this.reactStateManagerVanillaPlugin.actionToBody(e,d,()=>this.withCtx.bind(this))}`,i=this,o=[...e.providedStates.filter(d=>d.kind==="local-logic"&&d.initialization?.kind!=="url-param").map(c),...e.actions.filter(d=>d.kind==="standalone").map(t)];function
|
|
5189
|
+
`])}};ue=G([(0,cn.injectable)(),z(0,(0,cn.inject)(D.ReactJavaScriptCodePrinter))],ue);var jr=L("MobX Plugin"),oe=class{constructor(e){this.reactStateManagerVanillaPlugin=e}makeLocalLogicBundleHook(e){let t=d=>`${d.name}:${this.reactStateManagerVanillaPlugin.actionToBody(e,d,()=>this.withCtx.bind(this))}`,i=this,o=[...e.providedStates.filter(d=>d.kind==="local-logic"&&d.initialization?.kind!=="url-param").map(c),...e.actions.filter(d=>d.kind==="standalone").map(t)];function a(){let m=e.providedStates.filter(b=>b.kind==="local-logic"&&b.initialization?.kind==="url-param").map(b=>{let u=i.reactStateManagerVanillaPlugin.initializationToExpr(e,b.initialization)??"''",R=`
|
|
5190
5190
|
get ${b.identifier}() {
|
|
5191
|
-
return ${i.storeName}.$queryParams.get('${b.identifier}') || ${
|
|
5191
|
+
return ${i.storeName}.$queryParams.get('${b.identifier}') || ${u};
|
|
5192
5192
|
}
|
|
5193
|
-
`,
|
|
5193
|
+
`,I=`
|
|
5194
5194
|
set ${b.identifier}(value) {
|
|
5195
5195
|
${i.storeName}.$updateQueryParam('${b.identifier}', value);
|
|
5196
5196
|
}
|
|
5197
|
-
`;return`${R},${
|
|
5197
|
+
`;return`${R},${I}`}).join(",");return m&&`
|
|
5198
5198
|
$queryParams: new URL(window.location).searchParams,
|
|
5199
5199
|
$updateQueryParam(key: string, value: string) {
|
|
5200
5200
|
const params = new URL(window.location).searchParams;
|
|
@@ -5204,16 +5204,16 @@ return [state, setState, ref] as const;
|
|
|
5204
5204
|
},
|
|
5205
5205
|
${m},`}return{kind:"free",code:`const ${i.storeName} = useLocalObservable(()=>{
|
|
5206
5206
|
return {
|
|
5207
|
-
${
|
|
5207
|
+
${a()}
|
|
5208
5208
|
${o}
|
|
5209
5209
|
}
|
|
5210
5210
|
})`,import:{import:"{ useLocalObservable }",from:"mobx-react-lite"}};function c(d){let m=i.reactStateManagerVanillaPlugin.initializationToExpr(e,d.initialization);return`${d.identifier}: ${m??"undefined"}`}}makePublicBusinessLogicHook(e){let t=e.actions.filter(i=>i.kind==="standalone"&&(0,Tt.isBusinessLogic)(i.__raw)&&i.__raw.isPublic);return t.length===0?[]:[{kind:"free",code:`
|
|
5211
5211
|
useImperativeHandle(ref, () => ({
|
|
5212
5212
|
${t.map(i=>`${i.name}: ${this.storeName}.${i.name}`).join(",")}
|
|
5213
5213
|
}));
|
|
5214
|
-
`,import:{from:"react",import:"{ useImperativeHandle }"}}]}produceHooks(e){let t=this.makeLocalLogicBundleHook(e),i=this.reactStateManagerVanillaPlugin.makeTreeStateHooks(e),o=this.reactStateManagerVanillaPlugin.makeLocalIndividualHooks(e,()=>this.withCtx.bind(this)),
|
|
5214
|
+
`,import:{from:"react",import:"{ useImperativeHandle }"}}]}produceHooks(e){let t=this.makeLocalLogicBundleHook(e),i=this.reactStateManagerVanillaPlugin.makeTreeStateHooks(e),o=this.reactStateManagerVanillaPlugin.makeLocalIndividualHooks(e,()=>this.withCtx.bind(this)),a=this.makePublicBusinessLogicHook(e);return[...i,t,...o,...a]}get storeName(){return"localStore"}__resolveIdentifier(e,t){return this.__resolveName(e,t.name)}__resolveName(e,t){let i=this,o=a(t)??c(t);return o||jr.debug(`cannot find symbol "${t}" in the state context`),o;function a(d){let m=e.findActionByName(d);if(m)return`${i.storeName}.${m.name}`}function c(d){let m=e.findStateByName(d);if(m)switch(m.kind){case"standalone":switch(m.initialization.kind){case"component-ref":return d;default:ee(m.initialization.kind)}case"tree":return d;case"local-logic":return`${i.storeName}.${d}`;default:ee(m)}}}withCtx(e){return{resolveIdentifier:t=>this.__resolveIdentifier(e,t),resolveName:t=>this.__resolveName(e,t),resolveCalleeNamespace:t=>{let o=(a=>{if(!a.startsWith("nasl.")&&a.startsWith("app.logics"))return this.__resolveName(e,_e)})(t);if(o)return o;{let a=this.__resolveName(e,t);return a?.endsWith("Ref")?`${a}.current`:a}}}}genHookDefinition(){return new U("MobxHooks",[],[],[`export const useUserInfo = ()=>{
|
|
5215
5215
|
return window.$global.userInfo ?? {};
|
|
5216
|
-
}`])}static install(e){let t=e.createChild();return t.bind(D.ReactStateManager).to(oe),t.bind(D.ReactHookProvider).to(oe),t}};oe=G([(0,pn.injectable)(),z(0,(0,pn.inject)(ue))],oe);var Dr=L("ReactPresetPlugin"),ge=class{constructor(e,t,i,o){this.irBuilder=e;this.microFrontendManager=t;this.fileSystemProvider=i;this.reactCodeGenerator=o}async transpile(e){let t=Me(e.app);try{let i=mn(t),o=i.findNodeByPath(e.frontend.nodePath),
|
|
5216
|
+
}`])}static install(e){let t=e.createChild();return t.bind(D.ReactStateManager).to(oe),t.bind(D.ReactHookProvider).to(oe),t}};oe=G([(0,pn.injectable)(),z(0,(0,pn.inject)(ue))],oe);var Dr=L("ReactPresetPlugin"),ge=class{constructor(e,t,i,o){this.irBuilder=e;this.microFrontendManager=t;this.fileSystemProvider=i;this.reactCodeGenerator=o}async transpile(e){let t=Me(e.app);try{let i=mn(t),o=i.findNodeByPath(e.frontend.nodePath),a=this.irBuilder.buildIR(i,o,e.config),c=this.microFrontendManager.produceScript(o);Dr.debug({script:c});let d=await this.reactCodeGenerator.genFiles(a,e.baseDir),m=e.config.debug,b=[...d,{path:"/src/entry/index.tsx",content:`
|
|
5217
5217
|
import '../init';
|
|
5218
5218
|
import {renderApp} from './helper';
|
|
5219
5219
|
|
|
@@ -5246,8 +5246,8 @@ window.LazyLoad.css(\${JSON.stringify(cssAssets)})\`;
|
|
|
5246
5246
|
${c};
|
|
5247
5247
|
})();\`;
|
|
5248
5248
|
}
|
|
5249
|
-
`}];for(let
|
|
5250
|
-
`)??"";
|
|
5251
|
-
'@': path.resolve(__dirname, './src'),`;let p=Qt(r,t,e),
|
|
5252
|
-
`)??"";throw i.error("\u9875\u9762\u4EE3\u7801\u7F16\u8BD1\u9519\u8BEF"),
|
|
5249
|
+
`}];for(let u of b)this.fileSystemProvider.write(u.path,u.content);return b}catch(i){throw i}}static install(e){let t=e.createChild();return t.bind(D.NASLTranspiler).to(ge),t.bind(D.IRBuilder).to(Re),t.bind(de).toSelf(),t=oe.install(t),t.bind(ue).toSelf(),t.bind(D.ReactJavaScriptCodePrinter).to(Le),t.bind(D.ReactCodegen).to(Ie),t.bind(D.ProjectOrganizer).to(Pe),t.bind(D.MicroFrontendManager).to(Ne),t.bind(D.FileSystemProvider).to(Ce).inSingletonScope(),t=ve.install(t),t=xe.install(t),t=ie.install(t),t}};ge=G([(0,De.injectable)(),z(0,(0,De.inject)(D.IRBuilder)),z(1,(0,De.inject)(D.MicroFrontendManager)),z(2,(0,De.inject)(D.FileSystemProvider)),z(3,(0,De.inject)(D.ReactCodegen))],ge);function Fn(){return ge.install(new Mt.Container)}async function Ln(r,e,t,i="./out",o){let a=L("\u7FFB\u8BD1\u8FC7\u7A0B");a.debug({config:t});async function c(){a.info("\u5F00\u59CB\u7FFB\u8BD1");try{let m=await o.get(D.NASLTranspiler).transpile({app:r,frontend:e,config:t,baseDir:i});return o.isBound(D.CodeGenerationLifecycleHooks)&&o.getAll(D.CodeGenerationLifecycleHooks).forEach(b=>{b.afterAllFilesGenerated()}),m}catch(m){throw a.error(m),m}finally{a.info("\u7FFB\u8BD1\u7ED3\u675F")}}return await c()??[]}function Ot(r,e,t){let i=`${e.USER_STATIC_URL}/${e.tenant}/${r.id}/${e.env}`;return t&&i.startsWith("//")?`${t}:${i}`:i}function Er(r){try{let e=new URL(r);return e.protocol==="http:"||e.protocol==="https:"?r:"https://"+r}catch{return`https://${r}`}}function Vt(r){return Er(r.replace(/^\/\//,""))}var zt=require("@lcap/nasl-concepts/asserts"),Tn=se(require("axios"));function Fr(r){let e=L("extractFrontendDeps"),t=r.dependencies.filter(a=>!(0,zt.isConnector)(a)&&!!a.frontends?.length);e.info({packageInfo:r.packageInfos});let i=[...t.map(({name:a,version:c})=>({name:a,version:c,kind:"extension"}))],o={name:"@lcap/pc-react-ui",version:"1.1.0",kind:"standard"};return i.push(o),i}async function Gt(r,e,t,i){let o=L("downloadDependenciesToProject"),a=Fr(r);if(a.length===0){o.info("\u65E0\u4F9D\u8D56\u5E93");return}else o.info({feExtensions:a.map(m=>`${m.name}@${m.version}`)},"\u524D\u7AEF\u4F9D\u8D56\u5E93\u5217\u8868");o.info("\u5F00\u59CB\u4E0B\u8F7D\u524D\u7AEF\u4F9D\u8D56\u5E93");let c=Vt(i.STATIC_URL),d=await Promise.all(a.map(async m=>{o.info({ext:m},"\u4E0B\u8F7D\u4F9D\u8D56\u5E93");let u=`packages${m.kind==="extension"?"/extension":""}/${m.name}@${m.version}`,R=`${u}/dist-theme`,I=`${c}/${u}`,v=await S(m);o.debug({sources:v});let n=v.map(w=>{let s=`${c}/${w}`;return o.debug({url:s,source:w}),{url:s,source:w}});t.write(`/src/${u}/dist-theme/index.css`,""),o.info({urls:n.map(w=>w.url)},"\u4E0B\u8F7D\u6587\u4EF6\u5217\u8868");try{await Promise.all([...n.map(async({source:w,url:s})=>{o.debug({url:s},"\u6B63\u5728\u4E0B\u8F7D");try{let g=(await Tn.default.get(s,{responseType:"text"})).data,k=`/src/${w}`;t.write(k,g),o.debug({vfsPath:k},"\u5199\u5165\u865A\u62DF\u6587\u4EF6\u7CFB\u7EDF\u8DEF\u5F84")}catch(p){o.error({url:s,error:p},"\u4E0B\u8F7D\u5931\u8D25")}o.debug({url:s},"\u4E0B\u8F7D\u6210\u529F")})])}catch(w){o.error(w)}async function S({name:w,version:s}){if(w==="@lcap/pc-react-ui")return["index.js","index.css"].map(y=>`packages/${w}@${s}/dist-theme/${y}`);let p=`${I}/manifest`,h=(await Tn.default.get(p,{responseType:"text"})).data.split(/\n/).filter(y=>y.trim().startsWith(R)).map(y=>y.split(":")[0].trim());return h.length===0?[`${u}/dist-theme/index.js`]:h}return{packagePath:I,sources:v,projectPath:u,...m}}));return o.info("\u4F9D\u8D56\u5E93\u4E0B\u8F7D\u5B8C\u6210"),o.debug(d),d}var Ht=require("light-join"),ln=class{constructor(e){this.fileDict=e}mutateFile(e,t,i={}){this.fileDict[e]={...i,code:t}}getFileDict(){return{files:this.fileDict}}readFile(e){return this.fileDict[e].code}};async function Lr(r,e,t,i){let o=i??Fn(),a=L("compileAsProject");a.info("\u5F00\u59CB\u7FFB\u8BD1\u4EE3\u7801"),(!t?.isExport&&t?.env==="dev"||t?.debug)&&a.info("\u542F\u7528\u5236\u54C1\u65E5\u5FD7\u63D2\u4EF6"),a.info("\u8F7D\u5165\u9879\u76EE\u6A21\u677F");let c=o.get(D.FileSystemProvider);Object.entries(Un.files).forEach(([w,s])=>{c.write(w,s.code)});let d=Gt(r,e,c,{STATIC_URL:t.STATIC_URL}),{backendUrl:m,publicPath:b,aliasMapStr:u}=await n(),R=await Ln(r,e,t,"/",o);await S(c),a.debug(Object.keys(c.toJSON()),"\u751F\u6210\u7684\u6587\u4EF6");let I=new ln({});return Object.entries(c.toJSON()).forEach(([w,s])=>{I.mutateFile(w,s??"")}),I;function v(w,s){if(s.isExport)return"localhost:8080";let p=`http://${s.env}.${w.name}.${s.tenant}.${s.lowcodeDomain}`;return w.sysPrefixPath?(a.info(`\u542F\u7528\u5168\u5C40\u524D\u7F00: sysPrefixPath = ${w.sysPrefixPath}`),(0,Ht.lightJoin)(p,w.sysPrefixPath)):p}async function n(){let s=(await d)?.map(h=>{let y=h.sources.find(C=>C.endsWith("/index.js"));if(y)return{name:h.name,resolvedTo:`./src/${y}`,scope:h.kind==="extension"?"@extension":void 0}}).filter(Q).map(h=>`'${h.scope?`${h.scope}/${h.name}`:h.name}' : path.resolve(__dirname, '${h.resolvedTo}'),`).join(`
|
|
5250
|
+
`)??"";s+=`
|
|
5251
|
+
'@': path.resolve(__dirname, './src'),`;let p=Qt(r,t,e),g=v(r,t);return a.info({publicPath:p,backendUrl:g,aliasMapStr:s},"rspack\u914D\u7F6E"),o.get(D.FrontendBundlerConfig).setCompilerConfig({backendUrl:g,publicPath:p,aliasMapStr:s}),{backendUrl:g,publicPath:p,aliasMapStr:s}}async function S(w){let s=o.get(D.FrontendPerformance),p=w.read("/rspack.config.js");p&&(s?.performanceOptions?.chunks&&(p=p.replace("chunks: 'all'",`chunks: '${s?.performanceOptions?.chunks}'`)),w.write("/rspack.config.js",p.replace("const backendUrl = '';",`const backendUrl = '${m}'`).replace("const publicPath = '';",`const publicPath = '${b}';`).replace("alias: {}",`alias: {${u}}`)))}}function Qt(r,e,t){if(e.isExport)return"/";let i=`${Ot(r,e)}${t.basePath??""}`;return i.endsWith("/")?i:`${i}/`}async function Tr(r,e,t){let i=L("compileNASLToReactDist");t={...t,STATIC_URL:t.STATIC_URL||globalThis?.appInfo?.STATIC_URL};let o=Qt(r,t,e);i.info("\u8C03\u7528\u7F16\u8BD1\u63A5\u53E3\uFF0C\u8F93\u51FA\u9759\u6001\u6587\u4EF6");try{let c=(await Ut.default.post("/api/v1/app/compileNaslToDist",{config:t,appId:r.id,frontendNodePath:e.nodePath,app:Me(r)}).then(d=>{if(d?.data?.code!==200){let b=d.data?.message??"\u539F\u56E0\u672A\u77E5",u=d.data?.errorPayload?.logs?.join(`
|
|
5252
|
+
`)??"";throw i.error("\u9875\u9762\u4EE3\u7801\u7F16\u8BD1\u9519\u8BEF"),u&&console.error(u),b?new Error(`\u9875\u9762\u4EE3\u7801\u7F16\u8BD1\u9519\u8BEF: ${b}`):new Error("\u9875\u9762\u4EE3\u7801\u7F16\u8BD1\u9519\u8BEF")}return d.data.result.files})).map(d=>{let m=o+(0,Bt.trimStart)(d.path,"/");return{...d,path:m}});return i.info("\u7F16\u8BD1\u7ED3\u679C",c.map(d=>d.path)),c}catch(a){throw a}}0&&(module.exports={ApiClientIdentifier,FileSystemPlugin,JavaScriptCodegenPlugin,LifeCycleHooksPlugin,Logger,MicroFrontendPlugin,NASLAppIRBuilderPlugin,PlacedFile,ProjectOrganizerPlugin,ReactChildrenPropName,ReactCodegenPlugin,ReactFileDescription,ReactFragment,ReactPresetPlugin,ReactRouterDefaultBizComponentsFolderName,ReactRouterDefaultViewFolderName,ReactStateManagerMobxPlugin,ReactStateManagerVanillaPlugin,ServiceMetaKind,StateActionIR,StateContextIR,VirtualProject,bindAttrToIR,bindEventToAction,bindViewElementEventToIR,codeFormatPlugin,compileAsProject,compileNASLToReactDist,defaultErrorMessageDict,deserializeAppWhileKeepTypeAnnotation,genMetaData,getComponentName,hasAfterAllFilesGeneratedKind,inferChangeEventNameFromAttrName,javaScriptCodeGenPlugin,jsxCodeGenPlugin,logicToLogicIR,makeDefaultContainer,makePlugin,metadataPlugin,paramToIR,reactComponentLibHackPlugin,reactRouterPlugin,reactSlotPlugin,routesExtractionPlugin,serializeAppWithKeepTypeAnnotation,styleStringToInlineObject,translateNASLToReactApp});
|
|
5253
5253
|
//# sourceMappingURL=index.js.map
|