PageSourceSearch

https://app.ustechautomations.com/assets/CodeModal-Drb_XsDd.js

js ustechautomations.com collected 2026-09-26 00:53:20 UTC 12,596 bytes, 1 lines download raw bytes

1import{a as e,p as t}from"./chunk-6CSD65Y2-xYubHBmU.js";import{l as n,m as a,n as s,o,b as r,p as l,N as i,B as c,d3 as u,a1 as d,I as m}from"./CoreLayout-V9PVLCM0.js";import"./overlayFocus-BmDVzTk_.js";import"./AuthContextDefinition-CrUuQ85U.js";import"./createLucideIcon-B7UGDY3i.js";import"./index-BcwKVuK3.js";import"./index-BfJR_dAR.js";import"./voiceStore-D_K9cjIr.js";import"./loader-circle-Mux4UJzI.js";import"./user-BccZgP0Q.js";const p=e.memo(({open:e,onOpenChange:u,onClose:d,onConfirm:m,onCancel:p,onEscapeKeyDown:h,title:f,description:x,confirmationText:g="Confirm",cancelText:v="Cancel",destructive:j=!1,icon:y="AlertTriangle",size:b="small",children:C})=>t.jsx(n,{open:e,onOpenChange:e=>{u?.(e),e||d?.()},children:t.jsxs(a,{className:`${{"x-small":"max-w-sm",small:"max-w-md",medium:"max-w-lg",large:"max-w-2xl","x-large":"max-w-4xl"}[b]}`,onEscapeKeyDown:h,children:[t.jsxs(s,{children:[t.jsxs(o,{className:"line-clamp-1 flex items-center pb-0.5 text-base",children:[t.jsx("span",{className:"pr-2",children:f}),"AlertTriangle"===y&&t.jsx(r,{className:"h-6 w-6 pl-1 text-warning","aria-hidden":"true"})]}),x&&t.jsx(l,{className:"line-clamp-2 text-sm",children:x})]}),t.jsx("div",{className:"flex flex-col gap-3",children:C}),t.jsx(i,{children:t.jsxs("div",{className:"flex items-center justify-end gap-2 w-full",children:[v&&t.jsx(c,{variant:j?"destructive":"outline",onClick:()=>{p?.(),u?.(!1)},children:v}),g&&m&&t.jsx(c,{variant:j?"destructive":"default",onClick:()=>{m?.(),u?.(!1)},children:g})]})})]})}));p.displayName="ConfirmationModal";const h={str:"StrInput",int:"IntInput",float:"FloatInput",bool:"BoolInput",code:"CodeInput",file:"FileInput",dict:"DictInput",list:"ListInput",prompt:"PromptInput",secret:"SecretStrInput",dropdown:"DropdownInput",multiselect:"MultiselectInput",slider:"SliderInput",Message:"MessageInput",Data:"DataInput",DataFrame:"DataFrameInput",Document:"DocumentInput",LanguageModel:"HandleInput",Embeddings:"HandleInput",Text:"MessageTextInput"},f={Message:"Output",Data:"Output",DataFrame:"Output",Document:"Output",Text:"Output",LanguageModel:"Output",Embeddings:"Output"};function x(e){return e.replace(/[^a-zA-Z0-9_]/g,"_").replace(/^[0-9]/,"_$&").replace(/_+/g,"_").replace(/^_|_$/g,"")}function g(e){return`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}"`}function v(e){const t=e.node||e,{display_name:n="CustomComponent",description:a="A custom component",template:s={},outputs:o=[]}=t,r=x(n)+"Component",l=Object.entries(s).filter(([e,t])=>!1!==t.show&&!e.startsWith("_")&&"code"!==t.type),i=new Set;l.forEach(([e,t])=>{const n=h[t.type]||"StrInput";i.add(n)});const c=Array.from(i).sort().join(", "),u=l.map(([e,t])=>function(e,t){const n=h[t.type]||"StrInput",a=t.display_name||e,s=t.info||"",o=[`name=${g(e)}`,`display_name=${g(a)}`];if(s&&o.push(`info=${g(s)}`),t.required&&o.push("required=True"),t.advanced&&o.push("advanced=True"),t.multiline&&o.push("multiline=True"),t.password&&o.push("password=True"),t.options&&t.options.length>0){const e=t.options.map(e=>g("string"==typeof e?e:e.value)).join(", ");o.push(`options=[${e}]`)}if(t.input_types&&t.input_types.length>0){const e=t.input_types.map(e=>g(e)).join(", ");o.push(`input_types=[${e}]`)}return`        ${n}(\n            ${o.join(",\n            ")},\n        )`}(e,t)).join(",\n"),d=o.filter(e=>!e.hidden).map(e=>function(e){const t=f[e.types[0]]||"Output",n=`build_${x(e.name).toLowerCase()}`;return`        ${t}(\n            ${[`display_name=${g(e.display_name)}`,`name=${g(e.name)}`,`method=${g(n)}`].join(",\n            ")},\n        )`}(e)).join(",\n"),m=o.filter(e=>!e.hidden).map(e=>function(e,t){const n=`build_${x(e.name).toLowerCase()}`,a=e.types[0]||"Data",s=t.slice(0,5).map(([e])=>`        ${e} = self.${e}  # Injected at runtime`).join("\n");return`\n    def ${n}(self) -> ${a}:\n        """\n        Build method for ${e.display_name} output.\n\n        Parameters are accessed via self.<param_name>.\n        Values are injected by the execution engine at runtime\n        from the node's template configuration.\n        """\n${s}\n\n        # Your processing logic here\n        # The actual values come from the UI configuration\n        result = self._process_inputs()\n\n        self.status = f"Processed {self.dis
1play_name}"\n        return ${a}(data={"result": result})`}(e,l)).join("\n"),p=o[0]?.types[0]||"Data";return`"""\n${n} Component\n\n${a}\n\nThis component follows Langflow's architecture:\n- Parameters defined in 'inputs' are configured in the UI\n- Parameter VALUES are injected at runtime via self.<param_name>\n- The code structure is static; only values change per execution\n\nRuntime Parameter Injection:\n  When this flow executes, the execution engine:\n  1. Reads parameter values from node.data.node.template[field].value\n  2. Assigns them to self.<field_name> attributes\n  3. Calls the build method which accesses parameters via self\n"""\n\nfrom langflow.custom import Component\nfrom langflow.io import ${c}, Output\nfrom langflow.schema import Data\nfrom langflow.field_typing import ${p}\n\n\nclass ${r}(Component):\n    """${a}"""\n\n    display_name = ${g(n)}\n    description = ${g(a)}\n    icon = "code"\n    name = ${g(x(n))}\n\n    # Input definitions - these create the UI form fields\n    # Values are set by the user in the visual editor\n    inputs = [\n${u||"        # No visible inputs"}\n    ]\n\n    # Output definitions - these define what this component produces\n    outputs = [\n${d||'        Output(display_name="Output", name="output", method="build_output")'}\n    ]\n${m||`\n    def build_output(self) -> ${p}:\n        """Default build method."""\n        return ${p}(data={"result": "output"})`}\n\n    def _process_inputs(self):\n        """\n        Internal method to process all inputs.\n        Override this in custom implementations.\n        """\n        # Access any parameter via self.<param_name>\n        # Values are automatically available from UI configuration\n        return "processed"\n`}const j=e.memo(({open:r,onOpenChange:i,nodeData:h,nodeId:f,readonly:x=!1,onSaveCode:g})=>{const j=e.useMemo(()=>h?v(h):"# No node data available",[h]),y=e.useMemo(()=>h?function(e){const t=e.node||e,{display_name:n="Component",template:a={}}=t,s=[`# Current Configuration for: ${n}`,"# These values will be injected at runtime",""],o=Object.entries(a).filter(([e,t])=>!1!==t.show&&!e.startsWith("_"));return 0===o.length?s.push("# No configurable parameters"):o.forEac
1h(([e,t])=>{const n=t.value,a=void 0===n||""===n?"<not set>":"string"==typeof n?`"${n}"`:JSON.stringify(n);s.push(`${e} = ${a}  # ${t.type}`)}),s.join("\n")}(h):"",[h]),b=e.useMemo(()=>!!h&&function(e){const t=e.node||e,{template:n={}}=t;return Object.values(n).some(e=>"code"===e.type&&!e.readonly)}(h),[h]),C=e.useMemo(()=>h?function(e){const t=e.node||e,{template:n={}}=t,a=Object.entries(n).find(([e,t])=>"code"===t.type);return a?a[1]:null}(h):null,[h]),[w,$]=e.useState(j),[k,N]=e.useState(!1),[_,I]=e.useState(null),[S,O]=e.useState(!1),[D,T]=e.useState(null),E=e.useRef(null),A=e.useMemo(()=>{const e=h?.node||h;return e?.display_name||"Component"},[h]);e.useEffect(()=>{r&&(C&&C.value?$(C.value):$(j),I(null))},[r,j,C]),e.useEffect(()=>{S||E.current?.focus()},[S]),e.useEffect(()=>{const e=setTimeout(()=>{void 0!==_?.detail?.error&&T("90%")},600);return()=>{clearTimeout(e)}},[_]);const M=C?.value?C.value:j,F=w!==M,L=()=>{const e=function(e){let t=0,n=0,a=0;for(const o of e)"("===o&&t++,")"===o&&t--,"["===o&&n++,"]"===o&&n--,"{"===o&&a++,"}"===o&&a--;if(0!==t)return{error:"SyntaxError: unmatched parentheses",traceback:`Found ${t>0?"unclosed":"extra closing"} parenthesis`};if(0!==n)return{error:"SyntaxError: unmatched brackets",traceback:`Found ${n>0?"unclosed":"extra closing"} bracket`};if(0!==a)return{error:"SyntaxError: unmatched braces",traceback:`Found ${a>0?"unclosed":"extra closing"} brace`};const s=e.split("\n");for(let o=0;o<s.length;o++){const e=s[o].trim();e&&!e.startsWith("#")&&(/^(def|class|if|elif|else|for|while|try|except|finally|with)\s/.test(e)&&!e.endsWith(":")&&e.includes(":\\"))}return null}(w);e?I({detail:{error:e.error,traceback:e.traceback}}):(I({detail:{error:void 0,traceback:void 0}}),g&&g(w),i(!1))},P=k?y:w,z=x||!b&&!k;return t.jsxs(t.Fragment,{children:[t.jsx(n,{open:r,onOpenChange:e=>{!e&&F?O(!0):i(!1)},children:t.jsxs(a,{className:"max-w-6xl h-[90vh] max-h-[98dvh] flex flex-col gap-4 p-6",style:{backgroundColor:"hsl(var(--background))",color:"hsl(var(--foreground))"},onEscapeKeyDown:e=>{e.preventDefault(),F?O(!0):i(!1)},children:[t.jsxs(s,{children:[t.jsxs(o,{className:"line-clamp-1 flex items-center pb-0.5 text-base",children:[t.jsx("span",{className:"pr-2",children:k?"Current Values":"Component Code"}),t.jsx(u,{className:"h-6 w-6 pl-1 text-primary","aria-hidden":"true"}),t.jsx("span",{className:"ml-2 text-sm text-muted-foreground font-normal",children:A})]}),t.jsx(l,{className:"line-clamp-2 text-sm text-muted-foreground",children:k?"Current parameter values that will be injected at runtime":"Python component definition - parameters are accessed via self.<name>"})]}),t.jsxs("div",{className:"flex items-start gap-2 p-3 rounded-md text-sm",style:{backgroundColor:"hsl(var(--muted))"},children:[t.jsx(d,{className:"h-4 w-4 mt-0.5 flex-shrink-0 text-blue-500"}),t.jsxs("div",{className:"text-muted-foreground",children:[t.jsx("strong",{children:"Langflow Architecture:"})," This code defines the component structure. Parameter ",t.jsx("em",{children:"values"})," from the UI are injected at runtime via ",t.jsx("code",{className:"text-xs bg-background px-1 rounded",children:"self.<param>"}),". The code itself doesn't change when you configure the node."]})]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(c,{variant:k?"outline":"default",size:"sm",onClick:()=>N(!1),children:"Component Code"}),t.jsx(c,{variant:k?"default":"outline",size:"sm",onClick:()=>N(!0),children:"Current Values"})]}),t.jsxs("div",{className:"flex flex-1 flex-col rounded-md transition-all duration-300 overflow-hidden",style:{backgroundColor:"hsl(var(--background))"},children:[t.jsx(m,{value:P,readOnly:!0,className:"absolute left-[500%] top-[500%]",id:"codeValue"}),t.jsxs("div",{className:"flex h-full w-full flex-col transition-all",style:{backgroundColor:"hsl(var(--background))"},children:[t.jsx("div",{className:"h-full w-full",style:{backgroundColor:"hsl(var(--background))"},children:t.jsx("textarea",{ref:E,value:P,onChange:e=>!k&&$(e.target.value),readOnly:z,className:"h-full min-w-full rounded-lg border p-4 font-mono text-sm leading-relaxed resize-none focus:outline-none custom-scroll",style:{backgroundColor:"hsl(var(--background))",color:"hsl(var(--foreground))",borderColor:"hsl(var(--border))",tabSize:4,lineHeight:"1.6",fontFamily:"monospace",fontSize:"14px"},spellCheck:!1,"data-testid":"code-editor-textarea"})}),t.jsx("div",{className:"whitespace-break-spaces transition-all delay-500 "+(void 0!==_?.detail?.error?"h-2/6":"h-0"),style:{backgroundColor:"hsl(var(--background))"},children:t.jsxs("div",{className:"mt-5 h-full max-h-[10rem] w-full overflow-y-auto overflow-x-clip text-left custom-scroll",children:[t.jsx("h1",{"data-testid":"title_error_code_modal",className:"text-lg",style:{color:"var(--status-red)"},children:_?.detail?.error}),t.jsx("div",{className:"ml-2 mt-2 w-full text-sm word-break-break-word",children:t.jsx("span",{className:"w-full word-break-break-word",style:{color:"hsl(var(--destructive))"},children:_?.detail?.traceback})})]})}),t.jsxs("div",{className:"flex h-fit w-full justify-between items-center",style:{backgroundColor:"hsl(var(--background))"},children:[t.jsx("div",{className:"text-xs text-muted-foreground",children:z?"Read-only view - Component code is static":"Editable - Changes apply to custom code field"}),t.jsxs("div",{className:"flex gap-2",children:[!k&&b&&t.jsx(c,{className:"mt-3",onClick:L,type:"submit",id:"checkAndSaveBtn",disabled:x||!F,"data-testid":"checkAndSaveBtn",children:"Check & Save"}),t.jsx(c,{className:"mt-3",variant:"outline",onClick:()=>i(!1),children:"Close"})]})]})]})]})]})}),t.jsx(p,{open:S,onOpenChange:O,onClose:()=>O(!1),onConfirm:()=>{L(),O(!1)},onCancel:()=>{O(!1),i(!1)},onEscapeKeyDown:e=>{e.stopPropagation(),O(!1)},size:"x-small",icon:"AlertTriangle",confirmationText:"Check & Save",cancelText:"Discard Changes",title:"Caution",children:t.jsx("p",{className:"text-sm",children:"Are you sure you want to exit without saving your changes?"})})]})});j.displayName="CodeModal";export{j as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.