@gramlot/gramlot 0.3.34 → 0.3.36

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.
@@ -0,0 +1,3 @@
1
+ // Generated from the shipped collection inventory; do not edit.
2
+ import {declaredCollections} from '../declared-collections.js';
3
+ export default declaredCollections.find(collection => collection.name === "typst");
@@ -8,6 +8,6 @@ mygramlot = GramlotCollection(
8
8
  module="assets/index.js",
9
9
  css=(),
10
10
  dependencies=(),
11
- build_id="sha256:af5f98741b03588431b753ba5baf4a0699371fa0363512f79abb158507e0c2bf",
12
- files=("assets/collection.js", "assets/index.js", "assets/modules/chunk-74O4WKIV.js", "assets/modules/chunk-AU4HFPIY.js", "assets/modules/chunk-YSGSC7KM.js", "assets/modules/code-mirror-engine-RWQTR5G5.js", "assets/modules/jodit-engine-CXRSFV47.js", "assets/modules/markdown-document-VFC23FAY.js", "assets/modules/prose-mirror-engine-DQEAEIMV.js", "commands.json", "grammar.json",),
11
+ build_id="sha256:eeac29911cc1f318cf2d933fe5aa4e9bb3f7c725ec304af0f2a530652291d736",
12
+ files=("assets/collection.js", "assets/index.js", "assets/modules/addon-fit-L6JK4OJX.js", "assets/modules/chunk-74O4WKIV.js", "assets/modules/chunk-AU4HFPIY.js", "assets/modules/chunk-YSGSC7KM.js", "assets/modules/code-mirror-engine-RWQTR5G5.js", "assets/modules/jodit-engine-CXRSFV47.js", "assets/modules/markdown-document-VFC23FAY.js", "assets/modules/prose-mirror-engine-DQEAEIMV.js", "assets/modules/xterm-BF3OSWRI.js", "assets/modules/xterm-UBEXZEYY.js", "commands.json", "grammar.json",),
13
13
  )
@@ -1,5 +1,7 @@
1
- import{c as k,d as c}from"./modules/chunk-AU4HFPIY.js";var n={};k(n,{defineCollection:()=>m});c(n,$);import*as $ from"@gramlot/gramlot/components";import{defineCollection as M}from"@gramlot/gramlot/components";function m(r){if(r.name!=="editors")throw new Error("Unexpected bundled collection");let t=[],e={};r.css?.forEach((o,h)=>{o.href=t[h].href});for(let[o,h]of Object.entries(r.assets??{}))h.href=e[o].href;return M({...r,css:t,assets:e})}import{sharedModules as L}from"@gramlot/gramlot";var D=r=>L["./components/bases.js"][r];var s=D("controlElement");import{sharedModules as T}from"@gramlot/gramlot";var j=r=>T["./libraries.js"][r];var a=j("loadLibrary");import{sharedModules as B}from"@gramlot/gramlot";var H=r=>B["./components/labelbox.js"][r],d=H("Labelbox");import{sharedModules as P}from"@gramlot/gramlot";var S=r=>P["./components/field-state.js"][r],l=S("FieldState");var w=["text","python","javascript","typescript","json","html","css","xml","markdown","sql","typst"],A;function y(r){return class extends s(r){#t="";#e=0;constructor(){super(),this.control=this.ownerDocument.createElement("div"),this.control.id="control",this.control.className="editor-control",this.controlBox.append(this.control);let t=this.ownerDocument.createElement("style");t.textContent=`:host{display:block;height:300px;min-height:0;min-width:0}
1
+ import{c as U,d as f}from"./modules/chunk-AU4HFPIY.js";var n={};U(n,{defineCollection:()=>w});f(n,ct);import*as ct from"@gramlot/gramlot/components";import{defineCollection as V}from"@gramlot/gramlot/components";function w(r){if(r.name!=="editors")throw new Error("Unexpected bundled collection");let t=[],e={};r.css?.forEach((o,u)=>{o.href=t[u].href});for(let[o,u]of Object.entries(r.assets??{}))u.href=e[o].href;return V({...r,css:t,assets:e})}import{sharedModules as N}from"@gramlot/gramlot";var I=r=>N["./components/bases.js"][r];var h=I("controlElement");import{sharedModules as W}from"@gramlot/gramlot";var R=r=>W["./libraries.js"][r];var s=R("loadLibrary");import{sharedModules as G}from"@gramlot/gramlot";var O=r=>G["./components/labelbox.js"][r],c=O("Labelbox");import{sharedModules as $}from"@gramlot/gramlot";var q=r=>$["./components/field-state.js"][r],m=q("FieldState");var S=["text","python","javascript","typescript","json","html","css","xml","markdown","sql","typst"],J;function A(r){return class extends h(r){#t="";#e=0;constructor(){super(),this.control=this.ownerDocument.createElement("div"),this.control.id="control",this.control.className="editor-control",this.controlBox.append(this.control);let t=this.ownerDocument.createElement("style");t.textContent=`:host{display:block;height:300px;min-height:0;min-width:0}
2
2
  .control-box,.editor-control{height:100%;min-height:0;min-width:0}
3
3
  .editor-control{border:1px solid var(--gramlot-border-control,GrayText);border-radius:var(--gramlot-radius-sm,4px);overflow:hidden}
4
4
  :host([data-editor-disabled]) .editor-control{opacity:.6}
5
- .editor-status{padding:1em;color:var(--gramlot-text-secondary,GrayText)}`,this.shadowRoot.append(t);for(let e of["input","change"])this.control.addEventListener(e,o=>{o.target!==this.control&&o.stopImmediatePropagation()});this.control.addEventListener("focusout",()=>this.#r("change"))}get liveWrites(){return!0}connectedCallback(){let t=++this.#e;this.control.textContent="Loading editor\u2026",this.ready=(A??=a("codemirror",this.ownerDocument,()=>import("./modules/code-mirror-engine-RWQTR5G5.js"))).then(e=>{t!==this.#e||!this.isConnected||(this.control.textContent="",this.editor=e.createEditor(this),this.editor.publishHistory())}).catch(e=>{if(t===this.#e)throw this.control.textContent=`CodeMirror could not start: ${e.message}`,this.control.setAttribute("role","alert"),e}),this.ready.catch(e=>console.error(e))}releaseControl(){++this.#e,this.editor?.destroy(),this.editor=null,super.releaseControl()}projectAttributes(t){let e=super.projectAttributes(t),o=this.parameters;if(!w.includes(o.language))throw new TypeError(`Unsupported CodeMirror language: ${o.language}`);if(!Number.isInteger(o.indentUnit)||o.indentUnit<1||o.indentUnit>16)throw new TypeError("indentUnit must be an integer from 1 to 16");if(!Number.isFinite(o.fontSize)||o.fontSize<8||o.fontSize>48)throw new TypeError("fontSize must be from 8 to 48");return this.control.disabled=o.disabled,this.control.readOnly=o.readonly,this.toggleAttribute("data-editor-disabled",o.disabled),this.control.style.fontFamily=o.fontFamily,this.control.style.fontSize=`${o.fontSize}px`,this.editor?.configure(),e}#r(t){this.control.dispatchEvent(new this.ownerDocument.defaultView.Event(t,{bubbles:!0}))}editorChanged(t){this.#t=t,this.#r("input")}readControlValue(){return this.#t}writeControlValue(t){if(typeof t!="string")throw new TypeError("CodeMirror value must be a string");t!==this.#t&&(this.#t=t,this.editor?.replace(t))}focus(){this.parameters.disabled||this.editor?.view.focus()}setDiagnostics(t){this.editor.diagnostics(t)}revealPosition(t){this.editor.reveal(t)}undo(){return this.editor?this.editor.undo():!1}redo(){return this.editor?this.editor.redo():!1}}}y.parameters={disabled:{dtype:"B",default:!1,binding:"read"},readonly:{dtype:"B",default:!1,binding:"read"},live:{dtype:"B",default:!0,binding:"read"}};var i={dtype:"B",default:!0,binding:"read"},u=(0,n.defineComponent)({name:"codeMirror",tag:"gramlot-code-mirror",base:y,mixins:[d,l],parameters:{value:{dtype:"T",default:"",binding:"twoWay"},language:{dtype:"T",default:"text",binding:"read",enum:w},lineNumbers:i,lineWrapping:i,indentUnit:{dtype:"L",default:4,binding:"read"},fontSize:{dtype:"L",default:14,binding:"read"},fontFamily:{dtype:"T",default:"monospace",binding:"read"},folding:i,bracketMatching:i,autoCloseBrackets:i,autoIndent:i,autocompletion:i,highlightActiveLine:i,highlightSelectionMatches:i},implementation:r=>class extends r{}});var V;function x(r){return class extends s(r){#t="";#e=0;constructor(){super(),this.control=this.ownerDocument.createElement("div"),this.control.className="html-editor-control",this.controlBox.append(this.control);let t=this.ownerDocument.createElement("style");t.textContent=":host{display:block;height:400px;min-height:0}.control-box,.html-editor-control{height:100%;min-height:0}.html-editor-control{overflow:hidden}.html-editor-status{font:inherit;color:var(--gramlot-text-secondary,GrayText)}.html-editor-status:empty{display:none}",this.shadowRoot.append(t);for(let e of["input","change"])this.control.addEventListener(e,o=>{o.target!==this.control&&o.stopImmediatePropagation()})}get liveWrites(){return!0}connectedCallback(){this.load()}load(){let t=++this.#e;this.engine?.destroy(),this.engine=null,this.control.textContent="Loading HTML editor\u2026",this.ready=(V??=a("jodit",this.ownerDocument,()=>import("./modules/jodit-engine-CXRSFV47.js"))).then(e=>{t!==this.#e||!this.isConnected||(this.control.textContent="",this.engine=e.createHtmlEditor(this))}).catch(e=>{if(t===this.#e)throw this.control.textContent=`HTML editor could not start: ${e.message}`,this.control.setAttribute("role","alert"),e}),this.ready.catch(e=>console.error(e))}projectAttributes(t){let e=super.projectAttributes(t);return this.control.disabled=this.parameters.disabled,this.control.readOnly=this.parameters.readonly,this.engine?.configure(),e}readControlValue(){return this.#t}writeControlValue(t){if(typeof t!="string")throw new TypeError("HTML editor value must be a string");t!==this.#t&&(this.#t=t,this.engine?.replace(t))}editorChanged(t){this.#t=t,this.control.dispatchEvent(new this.ownerDocument.defaultView.Event("input",{bubbles:!0}))}editorBlurred(){this.control.dispatchEvent(new this.ownerDocument.defaultView.Event("change",{bubbles:!0}))}undo(){return this.engine?this.engine.undo():!1}redo(){return this.engine?this.engine.redo():!1}focus(){this.parameters.disabled||this.engine?.focus()}releaseControl(){++this.#e,this.engine?.destroy(),this.engine=null,super.releaseControl()}}}x.parameters={disabled:{dtype:"B",default:!1,binding:"read"},readonly:{dtype:"B",default:!1,binding:"read"},live:{dtype:"B",default:!0,binding:"read"}};var p=(0,n.defineComponent)({name:"htmlEditor",tag:"gramlot-html-editor",base:x,mixins:[d,l],parameters:{value:{dtype:"T",default:"",binding:"twoWay"}},implementation:r=>class extends r{}});import{sharedModules as F}from"@gramlot/gramlot";var N=r=>F["./components/parameters.js"][r];var C=N("projectParameters");function v(r){return class extends r{constructor(){super();let t=this.attachShadow({mode:"open"}),e=this.ownerDocument.createElement("style");e.textContent=":host{display:block;height:100%;min-height:0}iframe{display:block;width:100%;height:100%;border:0;background:white}",this.frame=this.ownerDocument.createElement("iframe"),this.frame.setAttribute("sandbox",""),this.frame.title="HTML preview",t.append(e,this.frame)}renderDocument(t){return t}render(){let t=this.renderDocument(this.parameters.value);this.frame.srcdoc!==t&&(this.frame.srcdoc=t)}projectAttributes(t){let e=C(this,t);return this.render(),e}}}var f=(0,n.defineComponent)({name:"htmlPreview",tag:"gramlot-html-preview",base:v,parameters:{value:{dtype:"T",default:"",binding:"read"}},implementation:r=>class extends r{}}),g=(0,n.defineComponent)({name:"markdownPreview",tag:"gramlot-markdown-preview",base:v,parameters:{value:{dtype:"T",default:"",binding:"read"},allowHtml:{dtype:"B",default:!1,binding:"read"}},implementation:r=>class extends r{#t;constructor(){super(),this.frame.title="Markdown preview"}connectedCallback(){this.render()}render(){if(this.#t){super.render();return}this.ready||(this.ready=import("./modules/markdown-document-VFC23FAY.js").then(t=>{this.#t=t.renderMarkdownDocument,this.isConnected&&this.render()}),this.ready.catch(t=>console.error(t)))}renderDocument(t){return this.#t(t,{allowHtml:this.parameters.allowHtml,document:this.ownerDocument})}}});var z;function E(r){return class extends s(r){#t="";#e=0;constructor(){super(),this.control=this.ownerDocument.createElement("div"),this.control.className="markdown-editor-control",this.controlBox.append(this.control);let t=this.ownerDocument.createElement("style");t.textContent=":host{display:block;height:400px;min-height:0}.control-box,.markdown-editor-control{height:100%;min-height:0}.markdown-editor-control{overflow:hidden}.markdown-editor-status{font:inherit;color:var(--gramlot-text-secondary,GrayText)}.markdown-editor-status:empty{display:none}",this.shadowRoot.append(t);for(let e of["input","change"])this.control.addEventListener(e,o=>{o.target!==this.control&&o.stopImmediatePropagation()})}get liveWrites(){return!0}connectedCallback(){this.load()}load(){let t=++this.#e;this.engine?.destroy(),this.engine=null,this.control.textContent="Loading Markdown editor\u2026",this.ready=(z??=a("prosemirror",this.ownerDocument,()=>import("./modules/prose-mirror-engine-DQEAEIMV.js"))).then(e=>{t!==this.#e||!this.isConnected||(this.control.textContent="",this.engine=e.createMarkdownEditor(this))}).catch(e=>{if(t===this.#e)throw this.control.textContent=`Markdown editor could not start: ${e.message}`,this.control.setAttribute("role","alert"),e}),this.ready.catch(e=>console.error(e))}projectAttributes(t){let e=super.projectAttributes(t);return this.control.disabled=this.parameters.disabled,this.control.readOnly=this.parameters.readonly,this.engine?.configure(),e}readControlValue(){return this.#t}writeControlValue(t){if(typeof t!="string")throw new TypeError("Markdown editor value must be a string");t!==this.#t&&(this.#t=t,this.engine?.replace(t))}editorChanged(t){this.#t=t,this.control.dispatchEvent(new this.ownerDocument.defaultView.Event("input",{bubbles:!0}))}editorBlurred(){this.control.dispatchEvent(new this.ownerDocument.defaultView.Event("change",{bubbles:!0}))}undo(){return this.engine?this.engine.undo():!1}redo(){return this.engine?this.engine.redo():!1}focus(){this.parameters.disabled||this.engine?.focus()}releaseControl(){++this.#e,this.engine?.destroy(),this.engine=null,super.releaseControl()}}}E.parameters={disabled:{dtype:"B",default:!1,binding:"read"},readonly:{dtype:"B",default:!1,binding:"read"},live:{dtype:"B",default:!0,binding:"read"}};var b=(0,n.defineComponent)({name:"markdownEditor",tag:"gramlot-markdown-editor",base:E,mixins:[d,l],parameters:{value:{dtype:"T",default:"",binding:"twoWay"}},implementation:r=>class extends r{}});var Vt=m({name:"editors",components:[u,p,f,b,g]});export{u as CodeMirror,p as HtmlEditor,f as HtmlPreview,b as MarkdownEditor,g as MarkdownPreview,Vt as default};
5
+ .editor-status{padding:1em;color:var(--gramlot-text-secondary,GrayText)}`,this.shadowRoot.append(t);for(let e of["input","change"])this.control.addEventListener(e,o=>{o.target!==this.control&&o.stopImmediatePropagation()});this.control.addEventListener("focusout",()=>this.#r("change"))}get liveWrites(){return!0}connectedCallback(){let t=++this.#e;this.control.textContent="Loading editor\u2026",this.ready=(J??=s("codemirror",this.ownerDocument,()=>import("./modules/code-mirror-engine-RWQTR5G5.js"))).then(e=>{t!==this.#e||!this.isConnected||(this.control.textContent="",this.editor=e.createEditor(this),this.editor.publishHistory())}).catch(e=>{if(t===this.#e)throw this.control.textContent=`CodeMirror could not start: ${e.message}`,this.control.setAttribute("role","alert"),e}),this.ready.catch(e=>console.error(e))}releaseControl(){++this.#e,this.editor?.destroy(),this.editor=null,super.releaseControl()}projectAttributes(t){let e=super.projectAttributes(t),o=this.parameters;if(!S.includes(o.language))throw new TypeError(`Unsupported CodeMirror language: ${o.language}`);if(!Number.isInteger(o.indentUnit)||o.indentUnit<1||o.indentUnit>16)throw new TypeError("indentUnit must be an integer from 1 to 16");if(!Number.isFinite(o.fontSize)||o.fontSize<8||o.fontSize>48)throw new TypeError("fontSize must be from 8 to 48");return this.control.disabled=o.disabled,this.control.readOnly=o.readonly,this.toggleAttribute("data-editor-disabled",o.disabled),this.control.style.fontFamily=o.fontFamily,this.control.style.fontSize=`${o.fontSize}px`,this.editor?.configure(),e}#r(t){this.control.dispatchEvent(new this.ownerDocument.defaultView.Event(t,{bubbles:!0}))}editorChanged(t){this.#t=t,this.#r("input")}readControlValue(){return this.#t}writeControlValue(t){if(typeof t!="string")throw new TypeError("CodeMirror value must be a string");t!==this.#t&&(this.#t=t,this.editor?.replace(t))}focus(){this.parameters.disabled||this.editor?.view.focus()}setDiagnostics(t){this.editor.diagnostics(t)}revealPosition(t){this.editor.reveal(t)}undo(){return this.editor?this.editor.undo():!1}redo(){return this.editor?this.editor.redo():!1}}}A.parameters={disabled:{dtype:"B",default:!1,binding:"read"},readonly:{dtype:"B",default:!1,binding:"read"},live:{dtype:"B",default:!0,binding:"read"}};var a={dtype:"B",default:!0,binding:"read"},x=(0,n.defineComponent)({name:"codeMirror",tag:"gramlot-code-mirror",base:A,mixins:[c,m],parameters:{value:{dtype:"T",default:"",binding:"twoWay"},language:{dtype:"T",default:"text",binding:"read",enum:S},lineNumbers:a,lineWrapping:a,indentUnit:{dtype:"L",default:4,binding:"read"},fontSize:{dtype:"L",default:14,binding:"read"},fontFamily:{dtype:"T",default:"monospace",binding:"read"},folding:a,bracketMatching:a,autoCloseBrackets:a,autoIndent:a,autocompletion:a,highlightActiveLine:a,highlightSelectionMatches:a},implementation:r=>class extends r{}});var K;function D(r){return class extends h(r){#t="";#e=0;constructor(){super(),this.control=this.ownerDocument.createElement("div"),this.control.className="html-editor-control",this.controlBox.append(this.control);let t=this.ownerDocument.createElement("style");t.textContent=":host{display:block;height:400px;min-height:0}.control-box,.html-editor-control{height:100%;min-height:0}.html-editor-control{overflow:hidden}.html-editor-status{font:inherit;color:var(--gramlot-text-secondary,GrayText)}.html-editor-status:empty{display:none}",this.shadowRoot.append(t);for(let e of["input","change"])this.control.addEventListener(e,o=>{o.target!==this.control&&o.stopImmediatePropagation()})}get liveWrites(){return!0}connectedCallback(){this.load()}load(){let t=++this.#e;this.engine?.destroy(),this.engine=null,this.control.textContent="Loading HTML editor\u2026",this.ready=(K??=s("jodit",this.ownerDocument,()=>import("./modules/jodit-engine-CXRSFV47.js"))).then(e=>{t!==this.#e||!this.isConnected||(this.control.textContent="",this.engine=e.createHtmlEditor(this))}).catch(e=>{if(t===this.#e)throw this.control.textContent=`HTML editor could not start: ${e.message}`,this.control.setAttribute("role","alert"),e}),this.ready.catch(e=>console.error(e))}projectAttributes(t){let e=super.projectAttributes(t);return this.control.disabled=this.parameters.disabled,this.control.readOnly=this.parameters.readonly,this.engine?.configure(),e}readControlValue(){return this.#t}writeControlValue(t){if(typeof t!="string")throw new TypeError("HTML editor value must be a string");t!==this.#t&&(this.#t=t,this.engine?.replace(t))}editorChanged(t){this.#t=t,this.control.dispatchEvent(new this.ownerDocument.defaultView.Event("input",{bubbles:!0}))}editorBlurred(){this.control.dispatchEvent(new this.ownerDocument.defaultView.Event("change",{bubbles:!0}))}undo(){return this.engine?this.engine.undo():!1}redo(){return this.engine?this.engine.redo():!1}focus(){this.parameters.disabled||this.engine?.focus()}releaseControl(){++this.#e,this.engine?.destroy(),this.engine=null,super.releaseControl()}}}D.parameters={disabled:{dtype:"B",default:!1,binding:"read"},readonly:{dtype:"B",default:!1,binding:"read"},live:{dtype:"B",default:!0,binding:"read"}};var C=(0,n.defineComponent)({name:"htmlEditor",tag:"gramlot-html-editor",base:D,mixins:[c,m],parameters:{value:{dtype:"T",default:"",binding:"twoWay"}},implementation:r=>class extends r{}});import{sharedModules as Z}from"@gramlot/gramlot";var Q=r=>Z["./components/parameters.js"][r];var g=Q("projectParameters");function j(r){return class extends r{constructor(){super();let t=this.attachShadow({mode:"open"}),e=this.ownerDocument.createElement("style");e.textContent=":host{display:block;height:100%;min-height:0}iframe{display:block;width:100%;height:100%;border:0;background:white}",this.frame=this.ownerDocument.createElement("iframe"),this.frame.setAttribute("sandbox",""),this.frame.title="HTML preview",t.append(e,this.frame)}renderDocument(t){return t}render(){let t=this.renderDocument(this.parameters.value);this.frame.srcdoc!==t&&(this.frame.srcdoc=t)}projectAttributes(t){let e=g(this,t);return this.render(),e}}}var E=(0,n.defineComponent)({name:"htmlPreview",tag:"gramlot-html-preview",base:j,parameters:{value:{dtype:"T",default:"",binding:"read"}},implementation:r=>class extends r{}}),v=(0,n.defineComponent)({name:"markdownPreview",tag:"gramlot-markdown-preview",base:j,parameters:{value:{dtype:"T",default:"",binding:"read"},allowHtml:{dtype:"B",default:!1,binding:"read"}},implementation:r=>class extends r{#t;constructor(){super(),this.frame.title="Markdown preview"}connectedCallback(){this.render()}render(){if(this.#t){super.render();return}this.ready||(this.ready=import("./modules/markdown-document-VFC23FAY.js").then(t=>{this.#t=t.renderMarkdownDocument,this.isConnected&&this.render()}),this.ready.catch(t=>console.error(t)))}renderDocument(t){return this.#t(t,{allowHtml:this.parameters.allowHtml,document:this.ownerDocument})}}});var X;function P(r){return class extends h(r){#t="";#e=0;constructor(){super(),this.control=this.ownerDocument.createElement("div"),this.control.className="markdown-editor-control",this.controlBox.append(this.control);let t=this.ownerDocument.createElement("style");t.textContent=":host{display:block;height:400px;min-height:0}.control-box,.markdown-editor-control{height:100%;min-height:0}.markdown-editor-control{overflow:hidden}.markdown-editor-status{font:inherit;color:var(--gramlot-text-secondary,GrayText)}.markdown-editor-status:empty{display:none}",this.shadowRoot.append(t);for(let e of["input","change"])this.control.addEventListener(e,o=>{o.target!==this.control&&o.stopImmediatePropagation()})}get liveWrites(){return!0}connectedCallback(){this.load()}load(){let t=++this.#e;this.engine?.destroy(),this.engine=null,this.control.textContent="Loading Markdown editor\u2026",this.ready=(X??=s("prosemirror",this.ownerDocument,()=>import("./modules/prose-mirror-engine-DQEAEIMV.js"))).then(e=>{t!==this.#e||!this.isConnected||(this.control.textContent="",this.engine=e.createMarkdownEditor(this))}).catch(e=>{if(t===this.#e)throw this.control.textContent=`Markdown editor could not start: ${e.message}`,this.control.setAttribute("role","alert"),e}),this.ready.catch(e=>console.error(e))}projectAttributes(t){let e=super.projectAttributes(t);return this.control.disabled=this.parameters.disabled,this.control.readOnly=this.parameters.readonly,this.engine?.configure(),e}readControlValue(){return this.#t}writeControlValue(t){if(typeof t!="string")throw new TypeError("Markdown editor value must be a string");t!==this.#t&&(this.#t=t,this.engine?.replace(t))}editorChanged(t){this.#t=t,this.control.dispatchEvent(new this.ownerDocument.defaultView.Event("input",{bubbles:!0}))}editorBlurred(){this.control.dispatchEvent(new this.ownerDocument.defaultView.Event("change",{bubbles:!0}))}undo(){return this.engine?this.engine.undo():!1}redo(){return this.engine?this.engine.redo():!1}focus(){this.parameters.disabled||this.engine?.focus()}releaseControl(){++this.#e,this.engine?.destroy(),this.engine=null,super.releaseControl()}}}P.parameters={disabled:{dtype:"B",default:!1,binding:"read"},readonly:{dtype:"B",default:!1,binding:"read"},live:{dtype:"B",default:!0,binding:"read"}};var k=(0,n.defineComponent)({name:"markdownEditor",tag:"gramlot-markdown-editor",base:P,mixins:[c,m],parameters:{value:{dtype:"T",default:"",binding:"twoWay"}},implementation:r=>class extends r{}});var B=0,Y=1,_=4,tt=5;function b(r,t){let e=new Uint8Array(t.length+1);return e[0]=r,e.set(t,1),e}function z(r){return b(B,new TextEncoder().encode(r))}function et(r){return b(B,Uint8Array.from(r,t=>t.charCodeAt(0)&255))}function F(r,t){for(let e of[r,t])if(!Number.isInteger(e)||e<1||e>65535)throw new RangeError("A terminal size is 1 to 65535");return b(_,new TextEncoder().encode(JSON.stringify({Width:t,Height:r})))}function rt(r){if(!Number.isInteger(r)||r<0||r>4294967295)throw new RangeError("An acknowledgement counts 0 to 2^32-1 bytes");let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,r),b(tt,t)}function ot(r){let t=new Uint8Array(r);if(t.length===0||t[0]!==Y)throw new Error(`Unexpected terminal frame on channel ${t[0]}`);return t.subarray(1)}var nt;function it(r){return nt??=Promise.all([s("xterm",r,()=>import("./modules/xterm-UBEXZEYY.js")),s("xtermFit",r,()=>import("./modules/addon-fit-L6JK4OJX.js")),s("xtermStyle",r,()=>import("./modules/xterm-BF3OSWRI.js"))]).then(([t,e,o])=>({Terminal:t.Terminal,FitAddon:e.FitAddon,style:o}))}function st(r){return class extends r{constructor(){super();let t=this.attachShadow({mode:"open"});this.engineStyle=this.ownerDocument.createElement("style");let e=this.ownerDocument.createElement("style");e.textContent=`:host{display:block;height:300px;min-height:0;min-width:0}
6
+ .terminal-control{height:100%;min-height:0;padding:4px;background:#000;box-sizing:border-box}
7
+ .terminal-status{padding:1em;color:var(--gramlot-text-secondary,GrayText)}`,this.control=this.ownerDocument.createElement("div"),this.control.className="terminal-control",t.append(this.engineStyle,e,this.control)}projectAttributes(t){return g(this,t)}}}var T=(0,n.defineComponent)({name:"terminal",tag:"gramlot-terminal",base:st,sourceContext:!0,doc:"An interactive terminal connected to the @terminal method `session` of the page store.",parameters:{session:{dtype:"T",default:"",binding:"read"},fontSize:{dtype:"L",default:14,binding:"read"},fontFamily:{dtype:"T",default:"monospace",binding:"read"},connected:{dtype:"B",default:!1,binding:"write"},rows:{dtype:"L",default:0,binding:"write"},columns:{dtype:"L",default:0,binding:"write"}},implementation:r=>class extends r{#t;#e=0;#r=null;#i=null;#o=null;#l=null;#a=null;setSourceContext(t){this.#t=t}connectedCallback(){this.#d()}disconnectedCallback(){this.#h()}projectAttributes(t){let e=super.projectAttributes(t),o=this.parameters;if(typeof o.session!="string"||!o.session)throw new TypeError("terminal requires a session name");if(!Number.isInteger(o.fontSize)||o.fontSize<8||o.fontSize>48)throw new TypeError("fontSize must be from 8 to 48");return this.#o&&(this.#o.options.fontSize=o.fontSize,this.#o.options.fontFamily=o.fontFamily,this.#l.fit()),this.isConnected&&this.#r!==null&&this.#r!==o.session&&(this.#h(),this.#d()),e}input(t){this.#s(z(t))}focus(){this.#o?.focus()}#n(t,e){this.#t&&this.#t.writeParameter(t,e)}#s(t){this.#i?.readyState===1&&this.#i.send(t)}#d(){let t=++this.#e,e=this.ownerDocument;this.#r=this.parameters.session,this.control.textContent="Loading terminal\u2026",this.control.classList.add("terminal-status"),this.ready=it(e).then(({Terminal:o,FitAddon:u,style:H})=>{if(t!==this.#e||!this.isConnected)return;this.control.textContent="",this.control.classList.remove("terminal-status"),this.engineStyle.textContent=H;let M=this.parameters,i=this.#o=new o({fontSize:M.fontSize,fontFamily:M.fontFamily,convertEol:!1}),y=this.#l=new u;i.loadAddon(y),i.open(this.control);let p=this.#i=new e.defaultView.WebSocket(this.#t.terminalUrl(this.#r));p.binaryType="arraybuffer",i.onData(l=>this.#s(z(l))),i.onBinary(l=>this.#s(et(l))),i.onResize(({rows:l,cols:d})=>{this.#s(F(l,d)),this.#n("rows",l),this.#n("columns",d)}),p.addEventListener("open",()=>{t===this.#e&&(this.#n("connected",!0),this.#s(F(i.rows,i.cols)),this.#n("rows",i.rows),this.#n("columns",i.cols))}),p.addEventListener("message",l=>{if(t!==this.#e)return;let d;try{d=ot(l.data)}catch(L){p.close(),this.#t?this.#t.reportError(L,"Terminal"):console.error(L);return}i.write(d,()=>this.#s(rt(d.length)))}),p.addEventListener("close",()=>{t===this.#e&&this.#n("connected",!1)}),this.#a=new e.defaultView.ResizeObserver(()=>{this.#o===i&&y.fit()}),this.#a.observe(this),y.fit()}).catch(o=>{if(t===this.#e)throw this.control.textContent=`The terminal could not start: ${o.message}`,this.control.setAttribute("role","alert"),o}),this.ready.catch(o=>this.#t?this.#t.reportError(o,"Terminal"):console.error(o))}#h(){++this.#e,this.#a?.disconnect(),this.#a=null,this.#i&&(this.#i.close(1e3),this.#i=null,this.#n("connected",!1)),this.#o?.dispose(),this.#o=null,this.#l=null,this.#r=null}}});var he=w({name:"editors",components:[x,C,E,k,v,T]});export{x as CodeMirror,C as HtmlEditor,E as HtmlPreview,k as MarkdownEditor,v as MarkdownPreview,T as Terminal,he as default};
@@ -1,3 +1,3 @@
1
1
  export {default} from "./collection.js";
2
2
  export * from "./collection.js";
3
- export const buildId = "sha256:af5f98741b03588431b753ba5baf4a0699371fa0363512f79abb158507e0c2bf";
3
+ export const buildId = "sha256:eeac29911cc1f318cf2d933fe5aa4e9bb3f7c725ec304af0f2a530652291d736";
@@ -0,0 +1,12 @@
1
+ import"./chunk-AU4HFPIY.js";/**
2
+ * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
3
+ * @license MIT
4
+ *
5
+ * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
6
+ * @license MIT
7
+ *
8
+ * Originally forked from (with the author's permission):
9
+ * Fabrice Bellard's javascript vt100 for jslinux:
10
+ * http://bellard.org/jslinux/
11
+ * Copyright (c) 2011 Fabrice Bellard
12
+ */var p=2,c=1,d=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let i=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(i._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let i=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,s=window.getComputedStyle(this._terminal.element.parentElement),l=parseInt(s.getPropertyValue("height")),o=Math.max(0,parseInt(s.getPropertyValue("width"))),t=window.getComputedStyle(this._terminal.element),r={top:parseInt(t.getPropertyValue("padding-top")),bottom:parseInt(t.getPropertyValue("padding-bottom")),right:parseInt(t.getPropertyValue("padding-right")),left:parseInt(t.getPropertyValue("padding-left"))},a=r.top+r.bottom,n=r.right+r.left,h=l-a,m=o-n-i;return{cols:Math.max(p,Math.floor(m/e.css.cell.width)),rows:Math.max(c,Math.floor(h/e.css.cell.height))}}};export{d as FitAddon};
@@ -0,0 +1,286 @@
1
+ import"./chunk-AU4HFPIY.js";var o=`/**
2
+ * Copyright (c) 2014 The xterm.js authors. All rights reserved.
3
+ * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
4
+ * https://github.com/chjj/term.js
5
+ * @license MIT
6
+ *
7
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ * of this software and associated documentation files (the "Software"), to deal
9
+ * in the Software without restriction, including without limitation the rights
10
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ * copies of the Software, and to permit persons to whom the Software is
12
+ * furnished to do so, subject to the following conditions:
13
+ *
14
+ * The above copyright notice and this permission notice shall be included in
15
+ * all copies or substantial portions of the Software.
16
+ *
17
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23
+ * THE SOFTWARE.
24
+ *
25
+ * Originally forked from (with the author's permission):
26
+ * Fabrice Bellard's javascript vt100 for jslinux:
27
+ * http://bellard.org/jslinux/
28
+ * Copyright (c) 2011 Fabrice Bellard
29
+ * The original design remains. The terminal itself
30
+ * has been extended to include xterm CSI codes, among
31
+ * other features.
32
+ */
33
+
34
+ /**
35
+ * Default styles for xterm.js
36
+ */
37
+
38
+ .xterm {
39
+ cursor: text;
40
+ position: relative;
41
+ user-select: none;
42
+ -ms-user-select: none;
43
+ -webkit-user-select: none;
44
+ }
45
+
46
+ .xterm.focus,
47
+ .xterm:focus {
48
+ outline: none;
49
+ }
50
+
51
+ .xterm .xterm-helpers {
52
+ position: absolute;
53
+ top: 0;
54
+ /**
55
+ * The z-index of the helpers must be higher than the canvases in order for
56
+ * IMEs to appear on top.
57
+ */
58
+ z-index: 5;
59
+ }
60
+
61
+ .xterm .xterm-helper-textarea {
62
+ padding: 0;
63
+ border: 0;
64
+ margin: 0;
65
+ /* Move textarea out of the screen to the far left, so that the cursor is not visible */
66
+ position: absolute;
67
+ opacity: 0;
68
+ left: -9999em;
69
+ top: 0;
70
+ width: 0;
71
+ height: 0;
72
+ z-index: -5;
73
+ /** Prevent wrapping so the IME appears against the textarea at the correct position */
74
+ white-space: nowrap;
75
+ overflow: hidden;
76
+ resize: none;
77
+ }
78
+
79
+ .xterm .composition-view {
80
+ /* TODO: Composition position got messed up somewhere */
81
+ background: #000;
82
+ color: #FFF;
83
+ display: none;
84
+ position: absolute;
85
+ white-space: nowrap;
86
+ z-index: 1;
87
+ }
88
+
89
+ .xterm .composition-view.active {
90
+ display: block;
91
+ }
92
+
93
+ .xterm .xterm-viewport {
94
+ /* On OS X this is required in order for the scroll bar to appear fully opaque */
95
+ background-color: #000;
96
+ overflow-y: scroll;
97
+ cursor: default;
98
+ position: absolute;
99
+ right: 0;
100
+ left: 0;
101
+ top: 0;
102
+ bottom: 0;
103
+ }
104
+
105
+ .xterm .xterm-screen {
106
+ position: relative;
107
+ }
108
+
109
+ .xterm .xterm-screen canvas {
110
+ position: absolute;
111
+ left: 0;
112
+ top: 0;
113
+ }
114
+
115
+ .xterm-char-measure-element {
116
+ display: inline-block;
117
+ visibility: hidden;
118
+ position: absolute;
119
+ top: 0;
120
+ left: -9999em;
121
+ line-height: normal;
122
+ }
123
+
124
+ .xterm.enable-mouse-events {
125
+ /* When mouse events are enabled (eg. tmux), revert to the standard pointer cursor */
126
+ cursor: default;
127
+ }
128
+
129
+ .xterm.xterm-cursor-pointer,
130
+ .xterm .xterm-cursor-pointer {
131
+ cursor: pointer;
132
+ }
133
+
134
+ .xterm.column-select.focus {
135
+ /* Column selection mode */
136
+ cursor: crosshair;
137
+ }
138
+
139
+ .xterm .xterm-accessibility:not(.debug),
140
+ .xterm .xterm-message {
141
+ position: absolute;
142
+ left: 0;
143
+ top: 0;
144
+ bottom: 0;
145
+ right: 0;
146
+ z-index: 10;
147
+ color: transparent;
148
+ pointer-events: none;
149
+ }
150
+
151
+ .xterm .xterm-accessibility-tree:not(.debug) *::selection {
152
+ color: transparent;
153
+ }
154
+
155
+ .xterm .xterm-accessibility-tree {
156
+ font-family: monospace;
157
+ user-select: text;
158
+ white-space: pre;
159
+ }
160
+
161
+ .xterm .xterm-accessibility-tree > div {
162
+ transform-origin: left;
163
+ width: fit-content;
164
+ }
165
+
166
+ .xterm .live-region {
167
+ position: absolute;
168
+ left: -9999px;
169
+ width: 1px;
170
+ height: 1px;
171
+ overflow: hidden;
172
+ }
173
+
174
+ .xterm-dim {
175
+ /* Dim should not apply to background, so the opacity of the foreground color is applied
176
+ * explicitly in the generated class and reset to 1 here */
177
+ opacity: 1 !important;
178
+ }
179
+
180
+ .xterm-underline-1 { text-decoration: underline; }
181
+ .xterm-underline-2 { text-decoration: double underline; }
182
+ .xterm-underline-3 { text-decoration: wavy underline; }
183
+ .xterm-underline-4 { text-decoration: dotted underline; }
184
+ .xterm-underline-5 { text-decoration: dashed underline; }
185
+
186
+ .xterm-overline {
187
+ text-decoration: overline;
188
+ }
189
+
190
+ .xterm-overline.xterm-underline-1 { text-decoration: overline underline; }
191
+ .xterm-overline.xterm-underline-2 { text-decoration: overline double underline; }
192
+ .xterm-overline.xterm-underline-3 { text-decoration: overline wavy underline; }
193
+ .xterm-overline.xterm-underline-4 { text-decoration: overline dotted underline; }
194
+ .xterm-overline.xterm-underline-5 { text-decoration: overline dashed underline; }
195
+
196
+ .xterm-strikethrough {
197
+ text-decoration: line-through;
198
+ }
199
+
200
+ .xterm-screen .xterm-decoration-container .xterm-decoration {
201
+ z-index: 6;
202
+ position: absolute;
203
+ }
204
+
205
+ .xterm-screen .xterm-decoration-container .xterm-decoration.xterm-decoration-top-layer {
206
+ z-index: 7;
207
+ }
208
+
209
+ .xterm-decoration-overview-ruler {
210
+ z-index: 8;
211
+ position: absolute;
212
+ top: 0;
213
+ right: 0;
214
+ pointer-events: none;
215
+ }
216
+
217
+ .xterm-decoration-top {
218
+ z-index: 2;
219
+ position: relative;
220
+ }
221
+
222
+
223
+
224
+ /* Derived from vs/base/browser/ui/scrollbar/media/scrollbar.css */
225
+
226
+ /* xterm.js customization: Override xterm's cursor style */
227
+ .xterm .xterm-scrollable-element > .scrollbar {
228
+ cursor: default;
229
+ }
230
+
231
+ /* Arrows */
232
+ .xterm .xterm-scrollable-element > .scrollbar > .scra {
233
+ cursor: pointer;
234
+ font-size: 11px !important;
235
+ }
236
+
237
+ .xterm .xterm-scrollable-element > .visible {
238
+ opacity: 1;
239
+
240
+ /* Background rule added for IE9 - to allow clicks on dom node */
241
+ background:rgba(0,0,0,0);
242
+
243
+ transition: opacity 100ms linear;
244
+ /* In front of peek view */
245
+ z-index: 11;
246
+ }
247
+ .xterm .xterm-scrollable-element > .invisible {
248
+ opacity: 0;
249
+ pointer-events: none;
250
+ }
251
+ .xterm .xterm-scrollable-element > .invisible.fade {
252
+ transition: opacity 800ms linear;
253
+ }
254
+
255
+ /* Scrollable Content Inset Shadow */
256
+ .xterm .xterm-scrollable-element > .shadow {
257
+ position: absolute;
258
+ display: none;
259
+ }
260
+ .xterm .xterm-scrollable-element > .shadow.top {
261
+ display: block;
262
+ top: 0;
263
+ left: 3px;
264
+ height: 3px;
265
+ width: 100%;
266
+ box-shadow: var(--vscode-scrollbar-shadow, #000) 0 6px 6px -6px inset;
267
+ }
268
+ .xterm .xterm-scrollable-element > .shadow.left {
269
+ display: block;
270
+ top: 3px;
271
+ left: 0;
272
+ height: 100%;
273
+ width: 3px;
274
+ box-shadow: var(--vscode-scrollbar-shadow, #000) 6px 0 6px -6px inset;
275
+ }
276
+ .xterm .xterm-scrollable-element > .shadow.top-left-corner {
277
+ display: block;
278
+ top: 0;
279
+ left: 0;
280
+ height: 3px;
281
+ width: 3px;
282
+ }
283
+ .xterm .xterm-scrollable-element > .shadow.top.left {
284
+ box-shadow: var(--vscode-scrollbar-shadow, #000) 6px 0 6px -6px inset;
285
+ }
286
+ `;export{o as default};