"use strict";(self.webpackChunkdocs=self.webpackChunkdocs||[]).push([["8434"],{6263:function(e,n,s){s.r(n),s.d(n,{default:()=>p,frontMatter:()=>t,metadata:()=>i,assets:()=>l,toc:()=>a,contentTitle:()=>c});var i=JSON.parse('{"id":"configuration/configuration-object","title":"Configuration Object","description":"LiveCodes is very flexible and provides a wide range of configuration options.","source":"@site/docs/configuration/configuration-object.mdx","sourceDirName":"configuration","slug":"/configuration/configuration-object","permalink":"/docs/configuration/configuration-object","draft":false,"unlisted":false,"editUrl":"https://github.com/live-codes/livecodes/tree/develop/docs/docs/configuration/configuration-object.mdx","tags":[],"version":"current","frontMatter":{},"sidebar":"docsSidebar","previous":{"title":"Configuration","permalink":"/docs/configuration/"},"next":{"title":"Query Parameters","permalink":"/docs/configuration/query-params"}}'),r=s("5893"),d=s("65"),o=s("3365");let t={},c="Configuration Object",l={},a=[{value:"Usage",id:"usage",level:2},{value:"TypeScript Types",id:"typescript-types",level:2},{value:"Default Config",id:"default-config",level:2},{value:"Project Content",id:"project-content",level:2},{value:"title",id:"title",level:3},{value:"description",id:"description",level:3},{value:"head",id:"head",level:3},{value:"htmlAttrs",id:"htmlattrs",level:3},{value:"tags",id:"tags",level:3},{value:"activeEditor",id:"activeeditor",level:3},{value:"languages",id:"languages",level:3},{value:"markup",id:"markup",level:3},{value:"style",id:"style",level:3},{value:"script",id:"script",level:3},{value:"stylesheets",id:"stylesheets",level:3},{value:"scripts",id:"scripts",level:3},{value:"cssPreset",id:"csspreset",level:3},{value:"processors",id:"processors",level:3},{value:"customSettings",id:"customsettings",level:3},{value:"imports",id:"imports",level:3},{value:"types",id:"types",level:3},{value:"tests",id:"tests",level:3},{value:"version",id:"version",level:3},{value:"App Settings",id:"app-settings",level:2},{value:"readonly",id:"readonly",level:3},{value:"allowLangChange",id:"allowlangchange",level:3},{value:"view",id:"view",level:3},{value:"mode",id:"mode",level:3},{value:"tools",id:"tools",level:3},{value:"zoom",id:"zoom",level:3},{value:"User Settings",id:"user-settings",level:2},{value:"enableAI",id:"enableai",level:3},{value:"autoupdate",id:"autoupdate",level:3},{value:"autosave",id:"autosave",level:3},{value:"autotest",id:"autotest",level:3},{value:"delay",id:"delay",level:3},{value:"formatOnsave",id:"formatonsave",level:3},{value:"layout",id:"layout",level:3},{value:"theme",id:"theme",level:3},{value:"themeColor",id:"themecolor",level:3},{value:"editorTheme",id:"editortheme",level:3},{value:"appLanguage",id:"applanguage",level:3},{value:"recoverUnsaved",id:"recoverunsaved",level:3},{value:"welcome",id:"welcome",level:3},{value:"showSpacing",id:"showspacing",level:3},{value:"editor",id:"editor",level:3},{value:"fontFamily",id:"fontfamily",level:3},{value:"fontSize",id:"fontsize",level:3},{value:"useTabs",id:"usetabs",level:3},{value:"tabSize",id:"tabsize",level:3},{value:"lineNumbers",id:"linenumbers",level:3},{value:"wordWrap",id:"wordwrap",level:3},{value:"closeBrackets",id:"closebrackets",level:3},{value:"foldRegions",id:"foldregions",level:3},{value:"emmet",id:"emmet",level:3},{value:"editorMode",id:"editormode",level:3},{value:"semicolons",id:"semicolons",level:3},{value:"singleQuote",id:"singlequote",level:3},{value:"trailingComma",id:"trailingcomma",level:3}];function h(e){let n={a:"a",admonition:"admonition",code:"code",h1:"h1",h2:"h2",h3:"h3",header:"header",img:"img",li:"li",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,d.a)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(n.header,{children:(0,r.jsx)(n.h1,{id:"configuration-object",children:"Configuration Object"})}),"\n","\n",(0,r.jsx)(n.p,{children:"LiveCodes is very flexible and provides a wide range of configuration options.\nA JavaScript object is used for configuration and keeping state."}),"\n",(0,r.jsx)(n.h2,{id:"usage",children:"Usage"}),"\n",(0,r.jsxs)(n.p,{children:["The configuration object can be used while initializing a new playground using the ",(0,r.jsx)(n.a,{href:"/docs/sdk/",children:"SDK"}),"."]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-ts",children:"import { createPlayground } from 'livecodes';\n\n(async () => {\n const playground = await createPlayground('#container', {\n config: {\n // config options here\n },\n });\n\n // the object can be retrieved using the method `getConfig`\n console.log(await playground.getConfig());\n\n // and can be later changed using the method `setConfig`\n await playground.setConfig({\n // new config options\n });\n})();\n"})}),"\n",(0,r.jsxs)(n.p,{children:["Alternatively, the URL ",(0,r.jsx)(n.a,{href:"/docs/configuration/query-params",children:"query parameter"})," ",(0,r.jsx)(n.code,{children:"config"})," can provide a URL to a JSON representation of the configuration object to be used while initializing the app."]}),"\n",(0,r.jsx)(n.p,{children:"Example:"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{children:"https://livecodes.io/?config=https://my-custom-server.com/config.json\n"})}),"\n",(0,r.jsx)(n.h2,{id:"typescript-types",children:"TypeScript Types"}),"\n",(0,r.jsxs)(n.p,{children:["TypeScript types are ",(0,r.jsx)(n.a,{href:"/docs/api/interfaces/Config",children:"documented here"})," and can be imported from the library."]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-ts",children:"import type { Config } from 'livecodes';\n"})}),"\n",(0,r.jsx)(n.h2,{id:"default-config",children:"Default Config"}),"\n",(0,r.jsxs)(n.p,{children:["Default config is ",(0,r.jsx)(n.a,{href:"https://github.com/live-codes/livecodes/blob/develop/src/livecodes/config/default-config.ts",children:"defined here"}),"."]}),"\n",(0,r.jsx)(n.h2,{id:"project-content",children:"Project Content"}),"\n",(0,r.jsxs)(n.p,{children:["These are properties that define the content of the current ",(0,r.jsx)(n.a,{href:"/docs/features/projects",children:"project"}),"."]}),"\n",(0,r.jsx)(n.h3,{id:"title",children:(0,r.jsx)(n.code,{children:"title"})}),"\n",(0,r.jsxs)(n.p,{children:["Type: ",(0,r.jsx)(n.a,{href:"/docs/api/interfaces/Config#title",children:(0,r.jsx)(n.code,{children:"string"})})]}),"\n",(0,r.jsxs)(n.p,{children:["Default: ",(0,r.jsx)(n.code,{children:'"Untitled Project"'})]}),"\n",(0,r.jsxs)(n.p,{children:["Project title. This is used as ",(0,r.jsx)(n.a,{href:"/docs/features/result",children:"result page"})," title and title meta tag. Also used in ",(0,r.jsx)(n.a,{href:"/docs/features/projects",children:"project"})," search. This can be set in the UI from the title input (above result page) or from Project menu \u2192 Project Info."]}),"\n",(0,r.jsx)(n.h3,{id:"description",children:(0,r.jsx)(n.code,{children:"description"})}),"\n",(0,r.jsxs)(n.p,{children:["Type: ",(0,r.jsx)(n.a,{href:"/docs/api/interfaces/Config#description",children:(0,r.jsx)(n.code,{children:"string"})})]}),"\n",(0,r.jsxs)(n.p,{children:["Default: ",(0,r.jsx)(n.code,{children:'""'})]}),"\n",(0,r.jsxs)(n.p,{children:["Project description. Used in ",(0,r.jsx)(n.a,{href:"/docs/features/projects",children:"project"})," search and result page description meta tag. This can be set in the UI from Project menu \u2192 Project Info."]}),"\n",(0,r.jsx)(n.h3,{id:"head",children:(0,r.jsx)(n.code,{children:"head"})}),"\n",(0,r.jsxs)(n.p,{children:["Type: ",(0,r.jsx)(n.a,{href:"/docs/api/interfaces/Config#head",children:(0,r.jsx)(n.code,{children:"string"})})]}),"\n",(0,r.jsxs)(n.p,{children:["Default: ",(0,r.jsx)(n.code,{children:'\'\\n\''})]}),"\n",(0,r.jsxs)(n.p,{children:["Content added to the ",(0,r.jsx)(n.a,{href:"/docs/features/result",children:"result page"})," ",(0,r.jsx)(n.code,{children:""})," element. This can be set in the UI from Project menu \u2192 Project Info."]}),"\n",(0,r.jsx)(n.h3,{id:"htmlattrs",children:(0,r.jsx)(n.code,{children:"htmlAttrs"})}),"\n",(0,r.jsxs)(n.p,{children:["Type: ",(0,r.jsx)(n.a,{href:"/docs/api/interfaces/Config#htmlattrs",children:(0,r.jsx)(n.code,{children:"string | Record"})})]}),"\n",(0,r.jsxs)(n.p,{children:["Default: ",(0,r.jsx)(n.code,{children:'\'lang="en" class=""\''})]}),"\n",(0,r.jsxs)(n.p,{children:["Attributes added to the ",(0,r.jsx)(n.a,{href:"/docs/features/result",children:"result page"})," ",(0,r.jsx)(n.code,{children:""})," element. It can be an object or a string."]}),"\n",(0,r.jsxs)(n.p,{children:["Example: ",(0,r.jsx)(n.code,{children:'{ lang: "en", class: "dark" }'})," or ",(0,r.jsx)(n.code,{children:'\'lang="en" class="dark"\''}),",\nbecome ",(0,r.jsx)(n.code,{children:''}),"."]}),"\n",(0,r.jsx)(n.p,{children:"This can be set in the UI from Project menu \u2192 Project Info."}),"\n",(0,r.jsx)(n.h3,{id:"tags",children:(0,r.jsx)(n.code,{children:"tags"})}),"\n",(0,r.jsxs)(n.p,{children:["Type: ",(0,r.jsx)(n.a,{href:"/docs/api/interfaces/Config#tags",children:(0,r.jsx)(n.code,{children:"string[]"})})]}),"\n",(0,r.jsxs)(n.p,{children:["Default: ",(0,r.jsx)(n.code,{children:"[]"})]}),"\n",(0,r.jsxs)(n.p,{children:["Project tags. Used in ",(0,r.jsx)(n.a,{href:"/docs/features/projects",children:"project"})," filter and search. This can be set in the UI from Project menu \u2192 Project Info."]}),"\n",(0,r.jsx)(n.h3,{id:"activeeditor",children:(0,r.jsx)(n.code,{children:"activeEditor"})}),"\n",(0,r.jsxs)(n.p,{children:["Type: ",(0,r.jsx)(n.a,{href:"/docs/api/interfaces/Config#activeeditor",children:(0,r.jsx)(n.code,{children:'"markup" | "style" | "script" | undefined'})})]}),"\n",(0,r.jsx)(n.p,{children:'Default: Last used editor for user, otherwise "markup"'}),"\n",(0,r.jsx)(n.p,{children:"Selects the active editor to show."}),"\n",(0,r.jsx)(n.h3,{id:"languages",children:(0,r.jsx)(n.code,{children:"languages"})}),"\n",(0,r.jsxs)(n.p,{children:["Type: ",(0,r.jsx)(n.a,{href:"/docs/api/interfaces/Config#languages",children:(0,r.jsx)(n.code,{children:"Language[] | undefined"})})]}),"\n",(0,r.jsxs)(n.p,{children:["Default: all supported languages in full app and only current editor languages in ",(0,r.jsx)(n.a,{href:"/docs/features/embeds",children:"embeds"}),"."]}),"\n",(0,r.jsxs)(n.p,{children:["List of enabled languages. Languages that are not already loaded in the editors (",(0,r.jsx)(n.a,{href:"#markup",children:"markup"}),", ",(0,r.jsx)(n.a,{href:"#style",children:"style"})," and ",(0,r.jsx)(n.a,{href:"#script",children:"script"}),") can be selected from a drop down menu at the editor title."]}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{alt:"Change Language",src:s(4945).Z+"",width:"2240",height:"1400"})}),"\n",(0,r.jsx)(n.h3,{id:"markup",children:(0,r.jsx)(n.code,{children:"markup"})}),"\n",(0,r.jsxs)(n.p,{children:["Type: ",(0,r.jsx)(n.a,{href:"/docs/api/interfaces/Config#markup",children:(0,r.jsx)(n.code,{children:"Editor"})})]}),"\n",(0,r.jsxs)(n.p,{children:["Default: ",(0,r.jsx)(n.code,{children:'{ language: "html", content: "" }'})]}),"\n",(0,r.jsx)(n.p,{children:"An object that configures the language and content of the markup editor. This can include the following properties:"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsxs)(n.li,{children:["\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.code,{children:"language"}),":\nType: ",(0,r.jsx)(n.a,{href:"/docs/api/type-aliases/Language",children:"Language"}),"\nDefault: ",(0,r.jsx)(n.code,{children:'"html"'})," in markup editor, ",(0,r.jsx)(n.code,{children:'"css"'})," in style editor and ",(0,r.jsx)(n.code,{children:'"javascript"'})," in script editor.\nThis can be a language name, extension or alias (as defined in ",(0,r.jsx)(n.a,{href:"/docs/languages/",children:"language documentations"}),").\n(e.g. ",(0,r.jsx)(n.code,{children:'"markdown"'}),", ",(0,r.jsx)(n.code,{children:'"md"'}),")"]}),"\n"]}),"\n",(0,r.jsxs)(n.li,{children:["\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.code,{children:"content"}),":\nType: ",(0,r.jsx)(n.a,{href:"/docs/api/interfaces/Config#content",children:(0,r.jsx)(n.code,{children:"string | undefined"})}),"\nDefault: ",(0,r.jsx)(n.code,{children:'""'}),"\nThe initial content of the code editor."]}),"\n"]}),"\n",(0,r.jsxs)(n.li,{children:["\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.code,{children:"contentUrl"}),":\nType: ",(0,r.jsx)(n.a,{href:"/docs/api/interfaces/Config#contenturl",children:(0,r.jsx)(n.code,{children:"string | undefined"})}),"\nDefault: ",(0,r.jsx)(n.code,{children:"undefined"}),"\nA URL to load ",(0,r.jsx)(n.code,{children:"content"})," from. It has to be a valid URL that is CORS-enabled.\nThe URL is only fetched if ",(0,r.jsx)(n.code,{children:"content"})," property had no value."]}),"\n"]}),"\n",(0,r.jsxs)(n.li,{children:["\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.code,{children:"hiddenContent"}),":\nType: ",(0,r.jsx)(n.a,{href:"/docs/api/interfaces/Config#hiddencontent",children:(0,r.jsx)(n.code,{children:"string | undefined"})}),"\nDefault: ",(0,r.jsx)(n.code,{children:"undefined"}),"\nHidden content that gets evaluated without being visible in the code editor.\nThis can be useful in embedded playgrounds (e.g. for adding helper functions, utilities or tests)"]}),"\n"]}),"\n",(0,r.jsxs)(n.li,{children:["\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.code,{children:"hiddenContentUrl"}),":\nType: ",(0,r.jsx)(n.a,{href:"/docs/api/interfaces/Config#hiddencontenturl",children:(0,r.jsx)(n.code,{children:"string | undefined"})}),"\nDefault: ",(0,r.jsx)(n.code,{children:"undefined"}),"\nA URL to load ",(0,r.jsx)(n.code,{children:"hiddenContent"})," from. It has to be a valid URL that is CORS-enabled.\nThe URL is only fetched if ",(0,r.jsx)(n.code,{children:"hiddenContent"})," property had no value."]}),"\n"]}),"\n",(0,r.jsxs)(n.li,{children:["\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.code,{children:"foldedLines"}),":\nType: ",(0,r.jsx)(n.a,{href:"/docs/api/interfaces/Config#foldedlines",children:(0,r.jsx)(n.code,{children:"Array<{ from: number; to: number }> | undefined"})}),"\nDefault: ",(0,r.jsx)(n.code,{children:"undefined"}),"\nLines that get folded when the editor loads. The code can be unfolded by clicking on arrow beside the line.\nThis can be useful for less relevant code in embedded playgrounds."]}),"\n"]}),"\n",(0,r.jsxs)(n.li,{children:["\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.code,{children:"title"}),":\nType: ",(0,r.jsx)(n.a,{href:"/docs/api/interfaces/Config#title",children:(0,r.jsx)(n.code,{children:"string | undefined"})}),"\nDefault: ",(0,r.jsx)(n.code,{children:'""'}),'\nIf set, this is used as the title of the editor in the UI, overriding the default title set to the language name (e.g. "Python" can be used instead of "Py (Wasm)").']}),"\n"]}),"\n",(0,r.jsxs)(n.li,{children:["\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.code,{children:"hideTitle"}),":\nType: ",(0,r.jsx)(n.a,{href:"/docs/api/interfaces/Config#hidetitle",children:(0,r.jsx)(n.code,{children:"boolean | undefined"})}),"\nDefault: ",(0,r.jsx)(n.code,{children:'""'}),"\nIf ",(0,r.jsx)(n.code,{children:"true"}),", the title of the code editor is hidden, however its code is still evaluated.\nThis can be useful in embedded playgrounds (e.g. for hiding unnecessary code)."]}),"\n"]}),"\n",(0,r.jsxs)(n.li,{children:["\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.code,{children:"order"}),":\nType: ",(0,r.jsx)(n.a,{href:"/docs/api/interfaces/Config#order",children:(0,r.jsx)(n.code,{children:"number | undefined"})}),"\nDefault: ",(0,r.jsx)(n.code,{children:"0"}),"\nThe order of the editor in the UI."]}),"\n"]}),"\n",(0,r.jsxs)(n.li,{children:["\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.code,{children:"selector"}),":\nType: ",(0,r.jsx)(n.a,{href:"/docs/api/interfaces/Config#selector",children:(0,r.jsx)(n.code,{children:"string | undefined"})}),"\nDefault: ",(0,r.jsx)(n.code,{children:"undefined"}),"\nA CSS selector to load ",(0,r.jsx)(n.code,{children:"content"})," from ",(0,r.jsx)(n.a,{href:"/docs/features/import#import-code-from-dom",children:"DOM import"}),"."]}),"\n"]}),"\n",(0,r.jsxs)(n.li,{children:["\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.code,{children:"position"}),":\nType: ",(0,r.jsx)(n.a,{href:"/docs/api/interfaces/Config#position",children:(0,r.jsx)(n.code,{children:"{lineNumber: number, column?: number} | undefined"})}),"\nDefault: ",(0,r.jsx)(n.code,{children:"undefined"}),"\nThe initial position of the cursor in the code editor.\nExample: ",(0,r.jsx)(n.code,{children:"{lineNumber: 5, column: 10}"})]}),"\n"]}),"\n"]}),"\n",(0,r.jsx)(n.h3,{id:"style",children:(0,r.jsx)(n.code,{children:"style"})}),"\n",(0,r.jsxs)(n.p,{children:["Type: ",(0,r.jsx)(n.a,{href:"/docs/api/interfaces/Config#style",children:(0,r.jsx)(n.code,{children:"Editor"})})]}),"\n",(0,r.jsxs)(n.p,{children:["Default: ",(0,r.jsx)(n.code,{children:'{ language: "css", content: "" }'})]}),"\n",(0,r.jsxs)(n.p,{children:["An object that configures the language and content of the style editor. See ",(0,r.jsx)(n.a,{href:"#markup",children:"markup"})," for more details."]}),"\n",(0,r.jsx)(n.h3,{id:"script",children:(0,r.jsx)(n.code,{children:"script"})}),"\n",(0,r.jsxs)(n.p,{children:["Type: ",(0,r.jsx)(n.a,{href:"/docs/api/interfaces/Config#script",children:(0,r.jsx)(n.code,{children:"Editor"})})]}),"\n",(0,r.jsxs)(n.p,{children:["Default: ",(0,r.jsx)(n.code,{children:'{ language: "javascript", content: "" }'})]}),"\n",(0,r.jsxs)(n.p,{children:["An object that configures the language and content of the script editor. See ",(0,r.jsx)(n.a,{href:"#markup",children:"markup"})," for more details."]}),"\n",(0,r.jsx)(n.h3,{id:"stylesheets",children:(0,r.jsx)(n.code,{children:"stylesheets"})}),"\n",(0,r.jsxs)(n.p,{children:["Type: ",(0,r.jsx)(n.a,{href:"/docs/api/interfaces/Config#stylesheets",children:(0,r.jsx)(n.code,{children:"string[]"})})]}),"\n",(0,r.jsxs)(n.p,{children:["Default: ",(0,r.jsx)(n.code,{children:"[]"})]}),"\n",(0,r.jsxs)(n.p,{children:["List of URLs for ",(0,r.jsx)(n.a,{href:"/docs/features/external-resources",children:"external stylesheets"})," to add to the ",(0,r.jsx)(n.a,{href:"/docs/features/result",children:"result page"}),"."]}),"\n",(0,r.jsx)(n.h3,{id:"scripts",children:(0,r.jsx)(n.code,{children:"scripts"})}),"\n",(0,r.jsxs)(n.p,{children:["Type: ",(0,r.jsx)(n.a,{href:"/docs/api/interfaces/Config#scripts",children:(0,r.jsx)(n.code,{children:"string[]"})})]}),"\n",(0,r.jsxs)(n.p,{children:["Default: ",(0,r.jsx)(n.code,{children:"[]"})]}),"\n",(0,r.jsxs)(n.p,{children:["List of URLs for ",(0,r.jsx)(n.a,{href:"/docs/features/external-resources",children:"external scripts"})," to add to the ",(0,r.jsx)(n.a,{href:"/docs/features/result",children:"result page"}),"."]}),"\n",(0,r.jsx)(n.h3,{id:"csspreset",children:(0,r.jsx)(n.code,{children:"cssPreset"})}),"\n",(0,r.jsxs)(n.p,{children:["Type: ",(0,r.jsx)(n.a,{href:"/docs/api/interfaces/Config#csspreset",children:(0,r.jsx)(n.code,{children:'"" | "normalize.css" | "reset-css"'})})]}),"\n",(0,r.jsxs)(n.p,{children:["Default: ",(0,r.jsx)(n.code,{children:'""'})]}),"\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.a,{href:"/docs/features/external-resources#css-presets",children:"CSS Preset"})," to use."]}),"\n",(0,r.jsx)(n.h3,{id:"processors",children:(0,r.jsx)(n.code,{children:"processors"})}),"\n",(0,r.jsxs)(n.p,{children:["Type: ",(0,r.jsx)(n.a,{href:"/docs/api/internal/type-aliases/Processor",children:(0,r.jsx)(n.code,{children:"Processor[]"})})]}),"\n",(0,r.jsxs)(n.p,{children:["Default: ",(0,r.jsx)(n.code,{children:"[]"})]}),"\n",(0,r.jsxs)(n.p,{children:["List of enabled ",(0,r.jsx)(n.a,{href:"/docs/features/css#css-processors",children:"CSS processors"}),"."]}),"\n",(0,r.jsx)(n.h3,{id:"customsettings",children:(0,r.jsx)(n.code,{children:"customSettings"})}),"\n",(0,r.jsxs)(n.p,{children:["Type: ",(0,r.jsx)(n.a,{href:"/docs/api/interfaces/Config#customsettings",children:(0,r.jsx)(n.code,{children:"CustomSettings"})})]}),"\n",(0,r.jsxs)(n.p,{children:["Default: ",(0,r.jsx)(n.code,{children:"{}"})]}),"\n",(0,r.jsxs)(n.p,{children:["Defines ",(0,r.jsx)(n.a,{href:"/docs/advanced/custom-settings",children:"custom settings"})," for the current project."]}),"\n",(0,r.jsx)(n.h3,{id:"imports",children:(0,r.jsx)(n.code,{children:"imports"})}),"\n",(0,r.jsxs)(n.p,{children:["Type: ",(0,r.jsx)(n.a,{href:"/docs/api/interfaces/Config#imports",children:(0,r.jsx)(n.code,{children:"[key: string]: string"})})]}),"\n",(0,r.jsxs)(n.p,{children:["Default: ",(0,r.jsx)(n.code,{children:"{}"})]}),"\n",(0,r.jsxs)(n.p,{children:["Allows specifying custom ",(0,r.jsx)(n.a,{href:"https://github.com/WICG/import-maps",children:"import maps"})," for ",(0,r.jsx)(n.a,{href:"/docs/features/module-resolution#custom-module-resolution",children:"module imports"}),"."]}),"\n",(0,r.jsx)(n.p,{children:"For example, adding this JavaScript code:"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-js",children:"import moment from 'moment';\nimport { partition } from 'lodash';\n"})}),"\n",(0,r.jsx)(n.p,{children:"would add this import map in the result page:"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-html",children:' `,m=`
`.trimStart();return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(t,{className:`container_Egsj ${e.className}`,style:{height:o||"50vh",...e.style},appUrl:c.G,...e,config:{theme:a,themeColor:"hsl(215, 8%, 60%)",..."object"==typeof e.config?e.config:{}}}),!1!==e.showCode&&(0,i.jsx)(u,{js:p,ts:j,react:f,vue:x,svelte:m})]})}},8294:function(e,n,s){s.d(n,{T:function(){return r},r:function(){return d}});var i=s(7728);async function r(e){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};"object"!=typeof e||e instanceof HTMLElement||!e.headless&&"headless"!==e.view||(n=e,e=null);let{config:s={},headless:i,loading:r="lazy",view:o}=n,t=i||"headless"===o,c=null,l=null;if("string"==typeof e)c=document.querySelector(e);else if(e instanceof HTMLElement)c=e;else if(!(t&&"object"==typeof e))throw Error("A valid container element is required.");if(!c){if(t)T(c=document.createElement("div")),document.body.appendChild(c);else throw Error(`Cannot find element: "${e}"`)}let a=new URL(d(n)),h=a.origin;a.searchParams.set("embed","true"),a.searchParams.set("loading",t?"eager":r),a.searchParams.set("sdkVersion",process.env.SDK_VERSION||"latest"),"object"==typeof s&&Object.keys(s).length>0&&a.searchParams.set("config","sdk");let p=n.params;"object"==typeof p&&Object.keys(p).length>0&&JSON.stringify(p).length<1800&&Object.keys(p).forEach(e=>{a.searchParams.set(e,encodeURIComponent(String(p[e])))});let j=!1,f="Cannot call API methods after calling `destroy()`.",u=await new Promise(e=>{if(!c)return;let n=c.dataset.height||c.style.height;if(n&&!t){let e=isNaN(Number(n))?n:n+"px";c.style.height=e}"false"===c.dataset.defaultStyles||t||(c.style.backgroundColor||="#fff",c.style.border||="1px solid black",c.style.borderRadius||="8px",c.style.boxSizing||="border-box",c.style.padding||="0",c.style.width||="100%",c.style.height||=c.style.height||"300px",c.style.minHeight="200px",c.style.flexGrow="1",c.style.overflow||="hidden",c.style.resize||="vertical");let i="livecodes",d=c.querySelector(`iframe.${i}`),o=d||document.createElement("iframe");o.classList.add(i),o.setAttribute("allow","accelerometer; camera; encrypted-media; display-capture; geolocation; gyroscope; microphone; midi; clipboard-read; clipboard-write; web-share"),o.setAttribute("allowtransparency","true"),o.setAttribute("allowpaymentrequest","true"),o.setAttribute("allowfullscreen","true"),o.setAttribute("sandbox","allow-same-origin allow-downloads allow-forms allow-modals allow-orientation-lock allow-pointer-lock allow-popups allow-presentation allow-scripts"),o.setAttribute("loading","eager"===r?"eager":"lazy"),t?T(o):(o.style.height="100%",o.style.minHeight="200px",o.style.width="100%",o.style.margin="0",o.style.border="0",o.style.borderRadius=c.style.borderRadius),addEventListener("message",function e(n){n.source===o.contentWindow&&n.origin===h&&n.data?.type==="livecodes-init"&&(removeEventListener("message",e),l=Number(n.data.payload.appVersion.replace(/^v/,"")))}),(!l||l<46)&&addEventListener("message",function e(n){n.source===o.contentWindow&&n.origin===h&&n.data?.type==="livecodes-get-config"&&(removeEventListener("message",e),o.contentWindow?.postMessage({type:"livecodes-config",payload:s},h))}),o.onload=()=>{e(o)},o.src=a.href,d||c.appendChild(o)}),x=new Promise(e=>{addEventListener("message",function n(s){s.source===u.contentWindow&&s.origin===h&&s.data?.type==="livecodes-ready"&&(removeEventListener("message",n),e(),x.settled=!0)})}),m=()=>j?Promise.reject(f):new Promise(async e=>{x.settled&&e(),u.contentWindow?.postMessage({type:"livecodes-load"},h),await x,e()}),g=(e,n)=>new Promise(async(s,i)=>{if(j)return i(f);await m();let r=S();addEventListener("message",function n(d){if(d.source===u.contentWindow&&d.origin===h&&d.data?.type==="livecodes-api-response"&&d.data?.id===r&&d.data.method===e){removeEventListener("message",n);let e=d.data.payload;e?.error?i(e.error):s(e)}}),u.contentWindow?.postMessage({method:e,id:r,args:n},h)}),y={},v=["load","ready","code","console","tests","destroy"],b=(e,n)=>{if(j)throw Error(f);return v.includes(e)?(g("watch",[e]),y[e]||(y[e]=[]),y[e]?.push(n),{remove:()=>{y[e]=y[e]?.filter(e=>e!==n),y[e]?.length===0&&g("watch",[e,"unsubscribe"])}}):{remove:()=>void 0}},w=e=>({"livecodes-app-loaded":"load","livecodes-ready":"ready","livecodes-change":"code","livecodes-console":"console","livecodes-test-results":"tests","livecodes-destroy":"destroy"})[e];addEventListener("message",async e=>{let n=w(e.data?.type??"");if(e.source!==u.contentWindow||e.origin!==h||!n||!y[n])return;let s=e.data?.payload;y[n]?.forEach(e=>{e(s)})});let C=()=>{Object.values(y).forEach(e=>{e.length=0}),u?.remove?.(),j=!0};function T(e){e.style.position="absolute",e.style.top="0",e.style.visibility="hidden",e.style.opacity="0"}"lazy"===r&&"IntersectionObserver"in window&&new IntersectionObserver((e,n)=>{e.forEach(async e=>{e.isIntersecting&&(await m(),n.unobserve(c))})},{rootMargin:"150px"}).observe(c);let S=()=>(String(Math.random())+Date.now().toFixed()).replace("0.","");return{load:()=>m(),run:()=>g("run"),format:e=>g("format",[e]),getShareUrl:e=>g("getShareUrl",[e]),getConfig:e=>g("getConfig",[e]),setConfig:e=>g("setConfig",[e]),getCode:()=>g("getCode"),show:(e,n)=>g("show",[e,n]),runTests:()=>g("runTests"),onChange:e=>b("code",e),watch:b,exec:function(e){for(var n=arguments.length,s=Array(n>1?n-1:0),i=1;ix.settled?g("destroy").then(C):j?Promise.reject(f):(C(),Promise.resolve())}}function d(){let e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{appUrl:s="https://livecodes.io",params:r={},config:d={},headless:o,import:t,lite:c,view:l,...a}=n;try{e=new URL(s)}catch{throw Error(`${s} is not a valid URL.`)}let h=new URLSearchParams;Object.entries(a).forEach(n=>{let[s,i]=n;void 0!==i&&e.searchParams.set(s,String(i))});let p="headless"===n.view||o;if(c&&(console.warn('Deprecation notice: "lite" option is deprecated. Use "config: { mode: \'lite\' }" instead.'),"object"==typeof d&&null==d.mode?d.mode="lite":e.searchParams.set("lite","true")),l&&(console.warn('Deprecation notice: The "view" option has been moved to "config.view". For headless mode use "headless: true".'),"object"==typeof d&&null==d.view&&"headless"!==l?d.view=l:e.searchParams.set("view",l)),"string"==typeof d)try{new URL(d),e.searchParams.set("config",encodeURIComponent(d))}catch{throw Error('"config" is not a valid URL or configuration object.')}else d&&"object"==typeof d&&Object.keys(d).length>0&&(d.title&&"Untitled Project"!==d.title&&e.searchParams.set("title",d.title),d.description&&d.description.length>0&&e.searchParams.set("description",d.description),h.set("config","code/"+(0,i.compressToEncodedURIComponent)(JSON.stringify(d))));if(r&&"object"==typeof r&&Object.keys(r).length>0)try{h.set("params",(0,i.compressToEncodedURIComponent)(JSON.stringify(r)))}catch{Object.keys(r).forEach(n=>{e.searchParams.set(n,encodeURIComponent(String(r[n])))})}return t&&e.searchParams.set("x",encodeURIComponent(t)),p&&e.searchParams.set("headless","true"),e.hash=h.toString(),e.href}},65:function(e,n,s){s.d(n,{Z:function(){return t},a:function(){return o}});var i=s(7294);let r={},d=i.createContext(r);function o(e){let n=i.useContext(d);return i.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function t(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(r):e.components||r:o(e.components),i.createElement(d.Provider,{value:n},e.children)}}}]);