@morphql/playground 0.1.7 → 0.1.8
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.
|
@@ -349,5 +349,6 @@ set totalWithTax = total * (1 + taxRate)`}},{name:"if",category:"control",doc:{s
|
|
|
349
349
|
) else (
|
|
350
350
|
...
|
|
351
351
|
)`}},{name:"modify",category:"action",doc:{signature:"modify <target> = <expression>",description:"Modifies a field in the output by reading from the target (not source). Useful for post-processing already-mapped values.",parameters:[{name:"target",description:"The field name to modify"},{name:"expression",description:"The expression to assign (reads from target, not source)"}],example:`set total = price * quantity
|
|
352
|
-
modify total = total * 1.10`}}
|
|
353
|
-
substring("Hello World", -5) // "World"`}},{name:"split",doc:{signature:"split(str, [separator], [limit])",description:"Splits a string into an array.",parameters:[{name:"str",description:"The string to split"},{name:"separator",description:'(Optional) Delimiter string. Default: ""'},{name:"limit",description:"(Optional) Maximum number of splits"}],returns:"array",example:'split("a,b,c", ",") // ["a", "b", "c"]'}},{name:"replace",doc:{signature:"replace(str, search, replacement)",description:"Replaces occurrences in a string.",parameters:[{name:"str",description:"The source string"},{name:"search",description:"The substring to find"},{name:"replacement",description:"The replacement string"}],returns:"string",example:'replace("Hello World", "World", "MorphQL") // "Hello MorphQL"'}},{name:"text",doc:{signature:"text(value)",description:"Converts a value to a string.",parameters:[{name:"value",description:"The value to convert"}],returns:"string",example:'text(123) // "123"'}},{name:"number",doc:{signature:"number(value)",description:"Converts a value to a number.",parameters:[{name:"value",description:"The value to convert"}],returns:"number",example:'number("42") // 42'}},{name:"uppercase",doc:{signature:"uppercase(str)",description:"Converts a string to uppercase.",parameters:[{name:"str",description:"The string to convert"}],returns:"string",example:'uppercase("hello") // "HELLO"'}},{name:"lowercase",doc:{signature:"lowercase(str)",description:"Converts a string to lowercase.",parameters:[{name:"str",description:"The string to convert"}],returns:"string",example:'lowercase("HELLO") // "hello"'}},{name:"extractnumber",doc:{signature:"extractnumber(str)",description:"Extracts the first numeric sequence from a string.",parameters:[{name:"str",description:"The string to extract from"}],returns:"number",example:'extractnumber("Price: 100USD") // 100'}},{name:"xmlnode",doc:{signature:"xmlnode(value, [attrKey, attrVal, ...])",description:"Wraps a value for XML output with optional attributes.",parameters:[{name:"value",description:"The node content"},{name:"attrKey, attrVal",description:"(Optional) Pairs of attribute keys and values"}],returns:"XML node",example:'xmlnode(content, "id", 1, "type", "text")'}},{name:"to_base64",doc:{signature:"to_base64(value)",description:"Encodes a string value to Base64.",parameters:[{name:"value",description:"The string to encode"}],returns:"string",example:'to_base64("hello") // "aGVsbG8="'}},{name:"from_base64",doc:{signature:"from_base64(value)",description:"Decodes a Base64 string value.",parameters:[{name:"value",description:"The Base64 string to decode"}],returns:"string",example:'from_base64("aGVsbG8=") // "hello"'}},{name:"aslist",doc:{signature:"aslist(value)",description:"Ensures a value is an array. Useful for input formats like XML that might return a single object or an array for the same field.",parameters:[{name:"value",description:"The value to normalize"}],returns:"array",example:"aslist(items) // Always returns an array"}}],w2=()=>C2.map(i=>i.name),L2=[{symbol:"===",category:"comparison",precedence:7},{symbol:"!==",category:"comparison",precedence:7},{symbol:"==",category:"comparison",precedence:7},{symbol:"!=",category:"comparison",precedence:7},{symbol:"<=",category:"comparison",precedence:6},{symbol:">=",category:"comparison",precedence:6},{symbol:"<",category:"comparison",precedence:6},{symbol:">",category:"comparison",precedence:6},{symbol:"&&",category:"logical",precedence:5},{symbol:"||",category:"logical",precedence:4},{symbol:"!",category:"logical",precedence:9},{symbol:"+",category:"arithmetic",precedence:10},{symbol:"-",category:"arithmetic",precedence:10},{symbol:"*",category:"arithmetic",precedence:11},{symbol:"/",category:"arithmetic",precedence:11},{symbol:"=",category:"assignment",precedence:1}],M2=()=>L2.map(i=>i.symbol);function U2(){return{keywords:x2(),builtinFunctions:w2(),operators:M2(),symbols:/[=><!~?:&|+\-*\/\^%]+/,escapes:/\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,tokenizer:{root:[[/\/\/.*$/,"comment"],[/\/\*/,"comment","@comment"],[/[a-zA-Z_$][\w$]*/,{cases:{"@keywords":"keyword","@builtinFunctions":"predefined","@default":"identifier"}}],[/"([^"\\]|\\.)*$/,"string.invalid"],[/'([^'\\]|\\.)*$/,"string.invalid"],[/"/,"string","@string_double"],[/'/,"string","@string_single"],[/-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?/,"number"],[/[{}()\[\]]/,"@brackets"],[/@symbols/,{cases:{"@operators":"operator","@default":""}}]],comment:[[/[^\/*]+/,"comment"],[/\*\//,"comment","@pop"],[/[\/*]/,"comment"]],string_double:[[/[^\\"]+/,"string"],[/@escapes/,"string.escape"],[/\\./,"string.escape.invalid"],[/"/,"string","@pop"]],string_single:[[/[^\\']+/,"string"],[/@escapes/,"string.escape"],[/\\./,"string.escape.invalid"],[/'/,"string","@pop"]]}}}const k2=U2();function I2(i){i.languages.register({id:"morphql"}),i.languages.setMonarchTokensProvider("morphql",k2),i.languages.setLanguageConfiguration("morphql",{comments:{lineComment:"//",blockComment:["/*","*/"]},brackets:[["(",")"],["{","}"],["[","]"]],autoClosingPairs:[{open:"(",close:")"},{open:"{",close:"}"},{open:"[",close:"]"},{open:'"',close:'"'},{open:"'",close:"'"}],surroundingPairs:[{open:"(",close:")"},{open:"{",close:"}"},{open:"[",close:"]"},{open:'"',close:'"'},{open:"'",close:"'"}]})}function z2({initialQuery:i=As[0].query,initialSourceData:n=As[0].source,className:s="",onQueryChange:r,onSourceDataChange:u}){const[c,h]=mt.useState(i),[p,d]=mt.useState(n),[_,T]=mt.useState(!1),[v,R]=mt.useState({result:"",generatedCode:"",error:null}),G=p.trim().startsWith("<")?"xml":"json";mt.useEffect(()=>{h(i)},[i]),mt.useEffect(()=>{d(n)},[n]),mt.useEffect(()=>{async function A(){try{const z=await O2(c),B=z(p);R({result:typeof B=="string"?B:JSON.stringify(B,null,2),generatedCode:z.code,error:null})}catch(z){R({result:"",generatedCode:"",error:z instanceof Error?z.message:String(z)})}}A()},[c,p]);const K=A=>{const z=As.find(B=>B.name===A.target.value);z&&(h(z.query),d(z.source),r?.(z.query),u?.(z.source))},Q=()=>{navigator.clipboard.writeText(v.result),T(!0),setTimeout(()=>T(!1),2e3)},N=A=>{const z=A||"";h(z),r?.(z)},E=A=>{const z=A||"";d(z),u?.(z)};return ct.jsxs("div",{className:`flex flex-col h-full bg-[#0f172a] text-slate-200 overflow-hidden ${s}`,children:[ct.jsxs("header",{className:"flex items-center justify-between px-6 py-4 border-b border-slate-800 bg-[#1e293b]",children:[ct.jsxs("div",{className:"flex items-center gap-3",children:[ct.jsx("div",{className:"w-8 h-8 rounded-lg bg-indigo-500 flex items-center justify-center shadow-lg shadow-indigo-500/20",children:ct.jsx(pS,{className:"w-5 h-5 text-white fill-current"})}),ct.jsxs("div",{children:[ct.jsx("h1",{className:"text-lg font-bold bg-clip-text text-transparent bg-gradient-to-r from-white to-slate-400",children:"MorphQL Playground"}),ct.jsx("p",{className:"text-xs text-slate-400 font-medium",children:"High-Performance Query-to-Code Engine"})]})]}),ct.jsxs("div",{className:"flex items-center gap-4",children:[ct.jsxs("select",{className:"text-xs font-semibold px-3 py-1.5 rounded-full bg-slate-800 hover:bg-slate-700 transition-colors border border-slate-700 text-slate-200 outline-none cursor-pointer",onChange:K,defaultValue:"",children:[ct.jsx("option",{value:"",disabled:!0,children:"Load Example..."}),As.map(A=>ct.jsx("option",{value:A.name,children:A.name},A.name))]}),ct.jsx("a",{href:"https://hyperwindmill.github.io/morphql",className:"text-xs font-semibold px-3 py-1.5 rounded-full bg-slate-800 hover:bg-slate-700 transition-colors border border-slate-700",children:"Documentation"})]})]}),ct.jsxs("main",{className:"flex-1 flex overflow-hidden",children:[ct.jsxs("div",{className:"w-1/2 flex flex-col border-r border-slate-800",children:[ct.jsxs("div",{className:"h-1/2 flex flex-col border-b border-slate-800",children:[ct.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 bg-slate-900 border-b border-slate-800",children:[ct.jsx(cS,{className:"w-4 h-4 text-indigo-400"}),ct.jsx("span",{className:"text-xs font-bold uppercase tracking-wider text-slate-400",children:"Morph Query"})]}),ct.jsx("div",{className:"flex-1 overflow-hidden pt-2",children:ct.jsx(vu,{theme:"vs-dark",defaultLanguage:"morphql",value:c,onChange:N,beforeMount:A=>{I2(A)},options:{minimap:{enabled:!1},fontSize:13,lineNumbers:"on",scrollBeyondLastLine:!1,automaticLayout:!0,padding:{top:10}}})})]}),ct.jsxs("div",{className:"h-1/2 flex flex-col",children:[ct.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 bg-slate-900 border-b border-slate-800",children:[ct.jsx(Am,{className:"w-4 h-4 text-amber-400"}),ct.jsx("span",{className:"text-xs font-bold uppercase tracking-wider text-slate-400",children:"Generated JS"})]}),ct.jsx("div",{className:"flex-1 overflow-hidden pt-2",children:ct.jsx(vu,{theme:"vs-dark",defaultLanguage:"javascript",value:v.generatedCode,options:{readOnly:!0,minimap:{enabled:!1},fontSize:13,lineNumbers:"on",scrollBeyondLastLine:!1,automaticLayout:!0,padding:{top:10}}})})]})]}),ct.jsxs("div",{className:"w-1/2 flex flex-col overflow-hidden",children:[ct.jsxs("div",{className:"h-1/2 flex flex-col border-b border-slate-800",children:[ct.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 bg-slate-900 border-b border-slate-800",children:[ct.jsx(uS,{className:"w-4 h-4 text-emerald-400"}),ct.jsxs("span",{className:"text-xs font-bold uppercase tracking-wider text-slate-400",children:["Source Data (",G.toUpperCase(),")"]})]}),ct.jsx("div",{className:"flex-1 overflow-hidden pt-2",children:ct.jsx(vu,{theme:"vs-dark",language:G==="json"?"json":"xml",value:p,onChange:E,options:{minimap:{enabled:!1},fontSize:14,lineNumbers:"on",scrollBeyondLastLine:!1,automaticLayout:!0,padding:{top:10}}})})]}),ct.jsxs("div",{className:"h-1/2 flex flex-col relative",children:[ct.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-slate-900 border-b border-slate-800",children:[ct.jsxs("div",{className:"flex items-center gap-2",children:[ct.jsx(Am,{className:"w-4 h-4 text-amber-400"}),ct.jsx("span",{className:"text-xs font-bold uppercase tracking-wider text-slate-400",children:"Transformation Result"})]}),ct.jsx("button",{onClick:Q,className:"p-1 hover:bg-slate-800 rounded transition-colors text-slate-400 hover:text-white",title:"Copy Result",children:_?ct.jsx(iS,{className:"w-4 h-4 text-emerald-400"}):ct.jsx(rS,{className:"w-4 h-4"})})]}),ct.jsx("div",{className:"flex-1 overflow-hidden pt-2 bg-[#1e1e1e]",children:v.error?ct.jsxs("div",{className:"p-4 flex gap-3 text-red-400 bg-red-950/20 m-4 rounded-lg border border-red-900/50",children:[ct.jsx(hS,{className:"w-5 h-5 flex-shrink-0"}),ct.jsxs("div",{children:[ct.jsx("p",{className:"text-sm font-bold mb-1",children:"Compilation/Execution Error"}),ct.jsx("p",{className:"text-xs font-mono",children:v.error})]})]}):ct.jsx(vu,{theme:"vs-dark",language:v.result.trim().startsWith("<")?"xml":"json",value:v.result,options:{readOnly:!0,minimap:{enabled:!1},fontSize:14,lineNumbers:"on",scrollBeyondLastLine:!1,automaticLayout:!0,padding:{top:10}}})})]})]})]}),ct.jsxs("footer",{className:"px-6 py-2 border-t border-slate-800 bg-[#1e293b] flex justify-between items-center",children:[ct.jsx("div",{className:"flex items-center gap-6",children:ct.jsx("div",{className:"text-[10px] font-bold text-slate-500 uppercase tracking-tighter",children:"Version: 0.1.7"})}),ct.jsx("div",{className:"text-[10px] text-slate-500 font-medium italic",children:"MorphQL Engine © 2026"})]})]})}function B2(){const[i,n]=mt.useState(()=>sessionStorage.getItem("morph_query")||As[0].query),[s,r]=mt.useState(()=>sessionStorage.getItem("morph_source")||As[0].source),u=h=>{n(h),sessionStorage.setItem("morph_query",h)},c=h=>{r(h),sessionStorage.setItem("morph_source",h)};return ct.jsx("div",{className:"h-screen w-screen",children:ct.jsx(z2,{initialQuery:i,initialSourceData:s,onQueryChange:u,onSourceDataChange:c})})}GT.createRoot(document.getElementById("root")).render(ct.jsx(Ra.StrictMode,{children:ct.jsx(B2,{})}))});export default D2();
|
|
352
|
+
modify total = total * 1.10`}},{name:"return",category:"action",doc:{signature:"return <expression>",description:"Returns a value from the transformation, bypassing the default serialization. Reads from target context by default.",parameters:[{name:"expression",description:"The value to return"}],example:`set computed = price * 1.1
|
|
353
|
+
return computed`}}],x2=()=>R2.map(i=>i.name),C2=[{name:"substring",doc:{signature:"substring(str, start, [length])",description:"Extracts a portion of a string. Supports negative indices.",parameters:[{name:"str",description:"The source string"},{name:"start",description:"Starting index (0-based, negative counts from end)"},{name:"length",description:"(Optional) Number of characters to extract"}],returns:"string",example:`substring("Hello World", 0, 5) // "Hello"
|
|
354
|
+
substring("Hello World", -5) // "World"`}},{name:"split",doc:{signature:"split(str, [separator], [limit])",description:"Splits a string into an array.",parameters:[{name:"str",description:"The string to split"},{name:"separator",description:'(Optional) Delimiter string. Default: ""'},{name:"limit",description:"(Optional) Maximum number of splits"}],returns:"array",example:'split("a,b,c", ",") // ["a", "b", "c"]'}},{name:"replace",doc:{signature:"replace(str, search, replacement)",description:"Replaces occurrences in a string.",parameters:[{name:"str",description:"The source string"},{name:"search",description:"The substring to find"},{name:"replacement",description:"The replacement string"}],returns:"string",example:'replace("Hello World", "World", "MorphQL") // "Hello MorphQL"'}},{name:"text",doc:{signature:"text(value)",description:"Converts a value to a string.",parameters:[{name:"value",description:"The value to convert"}],returns:"string",example:'text(123) // "123"'}},{name:"number",doc:{signature:"number(value)",description:"Converts a value to a number.",parameters:[{name:"value",description:"The value to convert"}],returns:"number",example:'number("42") // 42'}},{name:"uppercase",doc:{signature:"uppercase(str)",description:"Converts a string to uppercase.",parameters:[{name:"str",description:"The string to convert"}],returns:"string",example:'uppercase("hello") // "HELLO"'}},{name:"lowercase",doc:{signature:"lowercase(str)",description:"Converts a string to lowercase.",parameters:[{name:"str",description:"The string to convert"}],returns:"string",example:'lowercase("HELLO") // "hello"'}},{name:"extractnumber",doc:{signature:"extractnumber(str)",description:"Extracts the first numeric sequence from a string.",parameters:[{name:"str",description:"The string to extract from"}],returns:"number",example:'extractnumber("Price: 100USD") // 100'}},{name:"xmlnode",doc:{signature:"xmlnode(value, [attrKey, attrVal, ...])",description:"Wraps a value for XML output with optional attributes.",parameters:[{name:"value",description:"The node content"},{name:"attrKey, attrVal",description:"(Optional) Pairs of attribute keys and values"}],returns:"XML node",example:'xmlnode(content, "id", 1, "type", "text")'}},{name:"to_base64",doc:{signature:"to_base64(value)",description:"Encodes a string value to Base64.",parameters:[{name:"value",description:"The string to encode"}],returns:"string",example:'to_base64("hello") // "aGVsbG8="'}},{name:"from_base64",doc:{signature:"from_base64(value)",description:"Decodes a Base64 string value.",parameters:[{name:"value",description:"The Base64 string to decode"}],returns:"string",example:'from_base64("aGVsbG8=") // "hello"'}},{name:"aslist",doc:{signature:"aslist(value)",description:"Ensures a value is an array. Useful for input formats like XML that might return a single object or an array for the same field.",parameters:[{name:"value",description:"The value to normalize"}],returns:"array",example:"aslist(items) // Always returns an array"}},{name:"spreadsheet",doc:{signature:"spreadsheet(data)",description:"Converts spreadsheet-style data (array of arrays) into an array of objects with named properties. First row is treated as headers.",parameters:[{name:"data",description:"Array of arrays (rows)"}],returns:"array of objects",example:'spreadsheet(csvData) // Converts [["name","age"],["John",30]] to [{name:"John",age:30}]'}}],w2=()=>C2.map(i=>i.name),L2=[{symbol:"===",category:"comparison",precedence:7},{symbol:"!==",category:"comparison",precedence:7},{symbol:"==",category:"comparison",precedence:7},{symbol:"!=",category:"comparison",precedence:7},{symbol:"<=",category:"comparison",precedence:6},{symbol:">=",category:"comparison",precedence:6},{symbol:"<",category:"comparison",precedence:6},{symbol:">",category:"comparison",precedence:6},{symbol:"&&",category:"logical",precedence:5},{symbol:"||",category:"logical",precedence:4},{symbol:"!",category:"logical",precedence:9},{symbol:"+",category:"arithmetic",precedence:10},{symbol:"-",category:"arithmetic",precedence:10},{symbol:"*",category:"arithmetic",precedence:11},{symbol:"/",category:"arithmetic",precedence:11},{symbol:"=",category:"assignment",precedence:1}],M2=()=>L2.map(i=>i.symbol);function U2(){return{keywords:x2(),builtinFunctions:w2(),operators:M2(),symbols:/[=><!~?:&|+\-*\/\^%]+/,escapes:/\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,tokenizer:{root:[[/\/\/.*$/,"comment"],[/\/\*/,"comment","@comment"],[/[a-zA-Z_$][\w$]*/,{cases:{"@keywords":"keyword","@builtinFunctions":"predefined","@default":"identifier"}}],[/"([^"\\]|\\.)*$/,"string.invalid"],[/'([^'\\]|\\.)*$/,"string.invalid"],[/"/,"string","@string_double"],[/'/,"string","@string_single"],[/-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?/,"number"],[/[{}()\[\]]/,"@brackets"],[/@symbols/,{cases:{"@operators":"operator","@default":""}}]],comment:[[/[^\/*]+/,"comment"],[/\*\//,"comment","@pop"],[/[\/*]/,"comment"]],string_double:[[/[^\\"]+/,"string"],[/@escapes/,"string.escape"],[/\\./,"string.escape.invalid"],[/"/,"string","@pop"]],string_single:[[/[^\\']+/,"string"],[/@escapes/,"string.escape"],[/\\./,"string.escape.invalid"],[/'/,"string","@pop"]]}}}const k2=U2();function I2(i){i.languages.register({id:"morphql"}),i.languages.setMonarchTokensProvider("morphql",k2),i.languages.setLanguageConfiguration("morphql",{comments:{lineComment:"//",blockComment:["/*","*/"]},brackets:[["(",")"],["{","}"],["[","]"]],autoClosingPairs:[{open:"(",close:")"},{open:"{",close:"}"},{open:"[",close:"]"},{open:'"',close:'"'},{open:"'",close:"'"}],surroundingPairs:[{open:"(",close:")"},{open:"{",close:"}"},{open:"[",close:"]"},{open:'"',close:'"'},{open:"'",close:"'"}]})}function z2({initialQuery:i=As[0].query,initialSourceData:n=As[0].source,className:s="",onQueryChange:r,onSourceDataChange:u}){const[c,h]=mt.useState(i),[p,d]=mt.useState(n),[_,T]=mt.useState(!1),[v,R]=mt.useState({result:"",generatedCode:"",error:null}),G=p.trim().startsWith("<")?"xml":"json";mt.useEffect(()=>{h(i)},[i]),mt.useEffect(()=>{d(n)},[n]),mt.useEffect(()=>{async function A(){try{const z=await O2(c),B=z(p);R({result:typeof B=="string"?B:JSON.stringify(B,null,2),generatedCode:z.code,error:null})}catch(z){R({result:"",generatedCode:"",error:z instanceof Error?z.message:String(z)})}}A()},[c,p]);const K=A=>{const z=As.find(B=>B.name===A.target.value);z&&(h(z.query),d(z.source),r?.(z.query),u?.(z.source))},Q=()=>{navigator.clipboard.writeText(v.result),T(!0),setTimeout(()=>T(!1),2e3)},N=A=>{const z=A||"";h(z),r?.(z)},E=A=>{const z=A||"";d(z),u?.(z)};return ct.jsxs("div",{className:`flex flex-col h-full bg-[#0f172a] text-slate-200 overflow-hidden ${s}`,children:[ct.jsxs("header",{className:"flex items-center justify-between px-6 py-4 border-b border-slate-800 bg-[#1e293b]",children:[ct.jsxs("div",{className:"flex items-center gap-3",children:[ct.jsx("div",{className:"w-8 h-8 rounded-lg bg-indigo-500 flex items-center justify-center shadow-lg shadow-indigo-500/20",children:ct.jsx(pS,{className:"w-5 h-5 text-white fill-current"})}),ct.jsxs("div",{children:[ct.jsx("h1",{className:"text-lg font-bold bg-clip-text text-transparent bg-gradient-to-r from-white to-slate-400",children:"MorphQL Playground"}),ct.jsx("p",{className:"text-xs text-slate-400 font-medium",children:"High-Performance Query-to-Code Engine"})]})]}),ct.jsxs("div",{className:"flex items-center gap-4",children:[ct.jsxs("select",{className:"text-xs font-semibold px-3 py-1.5 rounded-full bg-slate-800 hover:bg-slate-700 transition-colors border border-slate-700 text-slate-200 outline-none cursor-pointer",onChange:K,defaultValue:"",children:[ct.jsx("option",{value:"",disabled:!0,children:"Load Example..."}),As.map(A=>ct.jsx("option",{value:A.name,children:A.name},A.name))]}),ct.jsx("a",{href:"https://hyperwindmill.github.io/morphql",className:"text-xs font-semibold px-3 py-1.5 rounded-full bg-slate-800 hover:bg-slate-700 transition-colors border border-slate-700",children:"Documentation"})]})]}),ct.jsxs("main",{className:"flex-1 flex overflow-hidden",children:[ct.jsxs("div",{className:"w-1/2 flex flex-col border-r border-slate-800",children:[ct.jsxs("div",{className:"h-1/2 flex flex-col border-b border-slate-800",children:[ct.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 bg-slate-900 border-b border-slate-800",children:[ct.jsx(cS,{className:"w-4 h-4 text-indigo-400"}),ct.jsx("span",{className:"text-xs font-bold uppercase tracking-wider text-slate-400",children:"Morph Query"})]}),ct.jsx("div",{className:"flex-1 overflow-hidden pt-2",children:ct.jsx(vu,{theme:"vs-dark",defaultLanguage:"morphql",value:c,onChange:N,beforeMount:A=>{I2(A)},options:{minimap:{enabled:!1},fontSize:13,lineNumbers:"on",scrollBeyondLastLine:!1,automaticLayout:!0,padding:{top:10}}})})]}),ct.jsxs("div",{className:"h-1/2 flex flex-col",children:[ct.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 bg-slate-900 border-b border-slate-800",children:[ct.jsx(Am,{className:"w-4 h-4 text-amber-400"}),ct.jsx("span",{className:"text-xs font-bold uppercase tracking-wider text-slate-400",children:"Generated JS"})]}),ct.jsx("div",{className:"flex-1 overflow-hidden pt-2",children:ct.jsx(vu,{theme:"vs-dark",defaultLanguage:"javascript",value:v.generatedCode,options:{readOnly:!0,minimap:{enabled:!1},fontSize:13,lineNumbers:"on",scrollBeyondLastLine:!1,automaticLayout:!0,padding:{top:10}}})})]})]}),ct.jsxs("div",{className:"w-1/2 flex flex-col overflow-hidden",children:[ct.jsxs("div",{className:"h-1/2 flex flex-col border-b border-slate-800",children:[ct.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 bg-slate-900 border-b border-slate-800",children:[ct.jsx(uS,{className:"w-4 h-4 text-emerald-400"}),ct.jsxs("span",{className:"text-xs font-bold uppercase tracking-wider text-slate-400",children:["Source Data (",G.toUpperCase(),")"]})]}),ct.jsx("div",{className:"flex-1 overflow-hidden pt-2",children:ct.jsx(vu,{theme:"vs-dark",language:G==="json"?"json":"xml",value:p,onChange:E,options:{minimap:{enabled:!1},fontSize:14,lineNumbers:"on",scrollBeyondLastLine:!1,automaticLayout:!0,padding:{top:10}}})})]}),ct.jsxs("div",{className:"h-1/2 flex flex-col relative",children:[ct.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-slate-900 border-b border-slate-800",children:[ct.jsxs("div",{className:"flex items-center gap-2",children:[ct.jsx(Am,{className:"w-4 h-4 text-amber-400"}),ct.jsx("span",{className:"text-xs font-bold uppercase tracking-wider text-slate-400",children:"Transformation Result"})]}),ct.jsx("button",{onClick:Q,className:"p-1 hover:bg-slate-800 rounded transition-colors text-slate-400 hover:text-white",title:"Copy Result",children:_?ct.jsx(iS,{className:"w-4 h-4 text-emerald-400"}):ct.jsx(rS,{className:"w-4 h-4"})})]}),ct.jsx("div",{className:"flex-1 overflow-hidden pt-2 bg-[#1e1e1e]",children:v.error?ct.jsxs("div",{className:"p-4 flex gap-3 text-red-400 bg-red-950/20 m-4 rounded-lg border border-red-900/50",children:[ct.jsx(hS,{className:"w-5 h-5 flex-shrink-0"}),ct.jsxs("div",{children:[ct.jsx("p",{className:"text-sm font-bold mb-1",children:"Compilation/Execution Error"}),ct.jsx("p",{className:"text-xs font-mono",children:v.error})]})]}):ct.jsx(vu,{theme:"vs-dark",language:v.result.trim().startsWith("<")?"xml":"json",value:v.result,options:{readOnly:!0,minimap:{enabled:!1},fontSize:14,lineNumbers:"on",scrollBeyondLastLine:!1,automaticLayout:!0,padding:{top:10}}})})]})]})]}),ct.jsxs("footer",{className:"px-6 py-2 border-t border-slate-800 bg-[#1e293b] flex justify-between items-center",children:[ct.jsx("div",{className:"flex items-center gap-6",children:ct.jsx("div",{className:"text-[10px] font-bold text-slate-500 uppercase tracking-tighter",children:"Version: 0.1.8"})}),ct.jsx("div",{className:"text-[10px] text-slate-500 font-medium italic",children:"MorphQL Engine © 2026"})]})]})}function B2(){const[i,n]=mt.useState(()=>sessionStorage.getItem("morph_query")||As[0].query),[s,r]=mt.useState(()=>sessionStorage.getItem("morph_source")||As[0].source),u=h=>{n(h),sessionStorage.setItem("morph_query",h)},c=h=>{r(h),sessionStorage.setItem("morph_source",h)};return ct.jsx("div",{className:"h-screen w-screen",children:ct.jsx(z2,{initialQuery:i,initialSourceData:s,onQueryChange:u,onSourceDataChange:c})})}GT.createRoot(document.getElementById("root")).render(ct.jsx(Ra.StrictMode,{children:ct.jsx(B2,{})}))});export default D2();
|
package/dist/index.html
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
|
6
6
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
7
|
<title>playground</title>
|
|
8
|
-
<script type="module" crossorigin src="/assets/index-
|
|
8
|
+
<script type="module" crossorigin src="/assets/index-PWX9Y0Bh.js"></script>
|
|
9
9
|
<link rel="stylesheet" crossorigin href="/assets/index-CXssh6j8.css">
|
|
10
10
|
</head>
|
|
11
11
|
<body>
|